Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions contracts/OMN-20674.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2026 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
---
schema_version: "1.0.0"
ticket_id: "OMN-20674"
title: "Host the morning friction sweep orchestrator with a deployment overlay"
summary: "Host the morning friction sweep as an unregistered omnimarket node: contract with declared bus topics, golden chain, error chain, decision parity against transcripts recorded from the original workflow, and a strict deployment overlay for every brief, path, lane and bound. The caller switch and the deletion of the original entry points are separate steps in the operator tooling repository."
is_seam_ticket: false
interface_change: false
interfaces_touched: []
requirements:
- id: "req-friction-node"
statement: "Host the friction sweep as a contract, a declarative node and a Definition-B handler whose topics are declared in the contract."
acceptance:
- id: "AC1"
statement: "AC1: the tool is a contract.yaml, a declarative node and a handler with the canonical definition-B signature, and its topics are declared in the contract"
evidence_requirements:
- kind: "tests"
description: "AC1: golden chain, decision parity against the recorded original transcripts, error chain, overlay and phase gateway pass."
command: "uv run pytest tests/nodes/node_morning_friction_sweep_orchestrator/test_golden_chain_morning_friction_sweep_orchestrator.py -q -p no:randomly"
emergency_bypass:
enabled: false
justification: ""
follow_up_ticket_id: ""
dod_evidence:
- id: "dod-omn20674-ac1-golden-chain"
description: "AC1: golden chain and decision parity pass."
source: "manual"
checks:
- check_type: "test_passes"
check_value: "uv run pytest tests/nodes/node_morning_friction_sweep_orchestrator/test_golden_chain_morning_friction_sweep_orchestrator.py -q -p no:randomly"
cwd: "${OMNI_HOME}/omnimarket"
binds_ac: ["AC1"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-FileCopyrightText: 2026 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
"""Canonical morning friction sweep orchestration."""

from .handlers.handler_morning_friction_sweep import (
DELEGATION_REASON_RE,
OVERLAY_ENV,
HandlerMorningFrictionSweep,
MorningFrictionSweepConfigurationError,
delegation_problem,
load_friction_overlay,
premise_audit_problem,
)
from .node import NodeMorningFrictionSweepOrchestrator

__all__ = [
"DELEGATION_REASON_RE",
"OVERLAY_ENV",
"HandlerMorningFrictionSweep",
"MorningFrictionSweepConfigurationError",
"NodeMorningFrictionSweepOrchestrator",
"delegation_problem",
"load_friction_overlay",
"premise_audit_problem",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# SPDX-FileCopyrightText: 2026 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
name: node_morning_friction_sweep_orchestrator
contract_version: {major: 1, minor: 0, patch: 0}
node_type: orchestrator
node_version: {major: 1, minor: 0, patch: 0}
lifecycle: experimental
description: >
Guarded morning friction sweep: same-date idempotency precheck, five
concurrent sources, synthesis, adjudication, then report and watermark.
Phase execution reuses the canonical delegation orchestrator and infra
request-response wiring. The deployment's briefs, paths, lanes and bounds
come from an overlay; the node holds none of them.
input_model:
name: ModelMorningFrictionSweepRequest
module: omnimarket.nodes.node_morning_friction_sweep_orchestrator.models.model_morning_friction_sweep
output_model:
name: ModelMorningFrictionSweepResult
module: omnimarket.nodes.node_morning_friction_sweep_orchestrator.models.model_morning_friction_sweep
handler:
module: omnimarket.nodes.node_morning_friction_sweep_orchestrator.handlers.handler_morning_friction_sweep
class: HandlerMorningFrictionSweep
handler_routing:
routing_strategy: operation_match
handlers:
- operation: morning_friction_sweep
handler:
name: HandlerMorningFrictionSweep
module: omnimarket.nodes.node_morning_friction_sweep_orchestrator.handlers.handler_morning_friction_sweep
input_model: omnimarket.nodes.node_morning_friction_sweep_orchestrator.models.model_morning_friction_sweep.ModelMorningFrictionSweepRequest
output_model: omnimarket.nodes.node_morning_friction_sweep_orchestrator.models.model_morning_friction_sweep.ModelMorningFrictionSweepResult
terminal_event: onex.evt.omnimarket.morning-friction-sweep-completed.v1
terminal_events:
success: onex.evt.omnimarket.morning-friction-sweep-completed.v1
failure: onex.evt.omnimarket.morning-friction-sweep-failed.v1
descriptor:
node_archetype: orchestrator
purity: impure
idempotent: false
timeout_ms: 18000000
runtime_profiles: [effects]
env_dependencies:
ONEX_ENVIRONMENT: {required: true, description: Explicit runtime environment for canonical bus wiring.}
OMNIMARKET_MORNING_FRICTION_SWEEP_OVERLAY: {required: false, description: Path to the deployment overlay.yaml; when unset the first node_morning_friction_sweep_orchestrator/overlay.yaml under ONEX_SKILL_OVERLAY_ROOTS is used, and a run with neither refuses to start.}
event_bus:
subscribe_topics:
- onex.cmd.omnimarket.morning-friction-sweep-start.v1
publish_topics:
- onex.evt.omnimarket.morning-friction-sweep-completed.v1
- onex.evt.omnimarket.morning-friction-sweep-failed.v1
- onex.cmd.omnibase-infra.delegation-request.v1
request_response:
instances:
- name: friction_phase
request_topic: onex.cmd.omnibase-infra.delegation-request.v1
reply_topics:
completed: onex.evt.omnibase-infra.delegation-completed.v1
failed: onex.evt.omnibase-infra.delegation-failed.v1
correlation: {location: body, field: correlation_id}
timeout_seconds: 7200
consumer_group_mode: per_instance
runtime_dispatch:
# The host scheduler (CLI dispatcher) is this node's producer; declared so it is not inferred from subscribe_topics[0].
command_topic: onex.cmd.omnimarket.morning-friction-sweep-start.v1

# Explicit SINK declaration (contract topic graph closure): no node contract
# subscribes to these; the host scheduler that started the run reads the terminal.
externally_consumed_topics:
- onex.evt.omnimarket.morning-friction-sweep-completed.v1
- onex.evt.omnimarket.morning-friction-sweep-failed.v1

metadata:
ticket: OMN-20674
phase_order: [Precheck, Scan, Synthesize, Adjudicate, Report]
transport_type: kafka
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-FileCopyrightText: 2026 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
"""Morning friction sweep handlers."""
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# SPDX-FileCopyrightText: 2026 OmniNode.ai Inc.
# SPDX-License-Identifier: MIT
"""Use the canonical delegation request-response wiring for friction sweep phases.

No model HTTP clients, subprocess executors, or consumer implementation here.
The infra runtime owns publishing, correlation matching, and bounded replies.
"""

from __future__ import annotations

import asyncio
import json
import os
from importlib.resources import files
from typing import cast
from uuid import uuid5

import yaml
from omnibase_core.models.contracts.subcontracts import ModelRequestResponseConfig
from omnibase_core.models.delegation.wire import ModelDelegationRequest
from omnibase_core.models.events.model_event_envelope import ModelEventEnvelope
from omnibase_core.protocols.event_bus.protocol_event_bus_publisher import (
ProtocolEventBusPublisher,
)
from pydantic import BaseModel, JsonValue

from ..models import model_friction_phase_results as results
from ..models.model_morning_friction_sweep import (
ModelFrictionPhaseRequest,
ModelMorningFrictionSweepRequest,
)
from ..protocols.protocol_friction_rpc import ProtocolFrictionRpc

PACKAGE = "omnimarket.nodes.node_morning_friction_sweep_orchestrator"
INSTANCE = "friction_phase"

RESULT_TYPES: dict[str, type[BaseModel]] = {
"friction-precheck": results.ModelFrictionPrecheck,
"friction-scan": results.ModelFrictionScan,
"friction-source-linear": results.ModelFrictionSource,
"friction-source-checkpoints": results.ModelFrictionSource,
"friction-source-ci": results.ModelFrictionSource,
"friction-source-guards": results.ModelFrictionSource,
"friction-synthesize": results.ModelFrictionSynthesis,
"friction-adjudicate": results.ModelFrictionAdjudication,
"friction-report": results.ModelFrictionReport,
}


class HandlerFrictionPhaseBus:
"""A phase gateway using infra's existing RPC service and delegation topics."""

def __init__(
self,
event_bus: ProtocolEventBusPublisher | None = None,
rpc: ProtocolFrictionRpc | None = None,
) -> None:
self._rpc = rpc
self._event_bus = event_bus
self._lock = asyncio.Lock()
self._instance: dict[str, JsonValue] | None = None

def _request_response(self) -> dict[str, JsonValue]:
contract = yaml.safe_load(files(PACKAGE).joinpath("contract.yaml").read_text())
return cast(dict[str, JsonValue], contract["event_bus"]["request_response"])

def _declared_instance(self) -> dict[str, JsonValue]:
if self._instance is None:
instances = cast(
list[dict[str, JsonValue]], self._request_response()["instances"]
)
self._instance = next(i for i in instances if i["name"] == INSTANCE)
return self._instance

async def _wiring(self) -> ProtocolFrictionRpc:
async with self._lock:
if self._rpc is None:
if self._event_bus is None:
raise ValueError("friction sweep requires the runtime event_bus")
from omnibase_infra.runtime.request_response_wiring import (
RequestResponseWiring,
)

wiring = RequestResponseWiring(
self._event_bus,
environment=os.environ["ONEX_ENVIRONMENT"],
app_name="morning-friction-sweep",
)
await wiring.wire_request_response(
ModelRequestResponseConfig.model_validate(self._request_response())
)
self._rpc = wiring
return self._rpc

async def run(
self,
run: ModelMorningFrictionSweepRequest,
phase: ModelFrictionPhaseRequest,
) -> dict[str, JsonValue] | None:
instance = self._declared_instance()
timeout = int(cast(int, instance["timeout_seconds"]))
correlation = uuid5(run.correlation_id, phase.label)
command = ModelDelegationRequest(
correlation_id=correlation,
tenant_id=run.tenant_id,
emitted_at=run.emitted_at,
prompt=phase.prompt,
task_type="agent_delegation",
max_tokens=8192,
requested_timeout_seconds=timeout,
context_pack=json.dumps(
{"phase": phase.phase, "model": phase.model, "effort": phase.effort}
),
response_format={"type": "json_object"},
response_contract=cast(dict[str, object], phase.schema_definition),
)
envelope = ModelEventEnvelope[ModelDelegationRequest](
payload=command,
correlation_id=correlation,
tenant_id=run.tenant_id,
event_type=str(instance["request_topic"]),
envelope_timestamp=run.emitted_at,
)
wiring = await self._wiring()
response = await wiring.send_request(
INSTANCE, envelope.model_dump(mode="json"), timeout_seconds=timeout
)
payload = response.get("payload", response)
if not isinstance(payload, dict):
raise ValueError("friction phase terminal payload must be an object")
if str(payload.get("correlation_id")) != str(correlation):
raise ValueError("friction phase terminal correlation does not match")
if payload.get("tenant_id", run.tenant_id) != run.tenant_id:
raise ValueError("friction phase terminal tenant does not match")
content = payload.get("content")
if not isinstance(content, str):
raise ValueError("friction phase terminal contains no content")
decoded = json.loads(content)
if decoded is None:
return None
if not isinstance(decoded, dict):
raise ValueError("friction phase result must be an object")
RESULT_TYPES[phase.label].model_validate(decoded)
return cast(dict[str, JsonValue], decoded)
Loading
Loading