Skip to content

fix(OMN-10079): publish terminal outputs for brokered runtime commands - #1515

Merged
jonahgabriel merged 4 commits into
mainfrom
jonah/omn-10079-runtime-market-terminal-applier
May 7, 2026
Merged

jonahgabriel merged 4 commits into
mainfrom
jonah/omn-10079-runtime-market-terminal-applier

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented May 7, 2026 •

Copy link
Copy Markdown
Collaborator

Ticket

  • OMN-10079

Summary

  • discover contract-level terminal_event for auto-wired contracts
  • default handler output publication to terminal_event when a contract has multiple publish_topics
  • keep Pattern B broker package route discovery scoped to pattern_b_broker.package_names instead of ONEX_ACTIVE_RUNTIME_PACKAGES

Live proof

  • On .201, Codex runtime adapter session_bootstrap returned ok=true via onex.cmd.omnimarket.pattern-b-dispatch.v1
  • terminal payload came from onex.evt.omnimarket.session-bootstrap-completed.v2 with status=ready and dry_run=true
  • deploy evidence command is recorded in contracts/OMN-10079.yaml

Verification

  • uv run pytest tests/integration/test_pattern_b_terminal_result_applier.py tests/unit/runtime/auto_wiring/test_wiring.py tests/unit/runtime/test_service_pattern_b_broker.py -q
  • uv run validate-yaml contracts/OMN-10079.yaml
  • uv run ruff format
  • uv run ruff check --fix
  • git push hooks passed

Summary by CodeRabbit

  • New Features

    • Added terminal event support for orchestrator contracts, enabling designated topics for handler result publication.
    • Added a new ticket contract declaration (OMN-10079) including evidence checks and terminal-event metadata.
  • Tests

    • Added integration and unit tests covering terminal-event result handling in the dispatch flow.
  • Chores

    • Pattern B broker now derives package names from configured package list when present.

@coderabbitai

coderabbitai Bot commented May 7, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 17c5531a-8c8d-4d8b-8c80-19da0d7052a3

📥 Commits

Reviewing files that changed from the base of the PR and between 38d454e and e25120a.

📒 Files selected for processing (1)
  • contracts/OMN-10079.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • contracts/OMN-10079.yaml

📝 Walkthrough

Walkthrough

Adds orchestrator "terminal_event" support: contract metadata, discovery parsing, model field, wiring selection for terminal-topic result dispatch, Pattern B package-name derivation tweak, and unit/integration tests plus a new contract file.

Changes

Terminal Event Result Handling

Layer / File(s) Summary
Contract Definition
contracts/OMN-10079.yaml
New ticket contract file added: schema/ticket metadata, interfaces touched, emergency_bypass: false, and three dod_evidence entries (dod-001, dod-002, dod-003) with command-based checks.
Data Model
src/omnibase_infra/runtime/auto_wiring/models/model_discovered_contract.py
ModelDiscoveredContract gains optional terminal_event: str | None field (default None) to store an orchestrator-declared terminal event topic.
Contract Discovery
src/omnibase_infra/runtime/auto_wiring/discovery.py
_parse_contract() now extracts terminal_event from the contract YAML (raw.get("terminal_event")) and passes it into the constructed ModelDiscoveredContract.
Handler Wiring
src/omnibase_infra/runtime/auto_wiring/handler_wiring.py
_subscribe_contract_topics() broadens output-topic derivation for non-DB-IO contracts: if a single publish_topic exists use it; otherwise if contract.terminal_event is present and included in publish_topics use that; else log a warning and leave result applier unset. When derived, DispatchResultApplier is instantiated with event_bus and the chosen output_topic.
Pattern B Broker Initialization
src/omnibase_infra/runtime/service_runtime_host_process.py
_start_pattern_b_broker() now derives package_names by trimming and filtering pattern_b_broker_config.package_names directly (tuple of stripped parts) instead of calling parse_active_runtime_packages(...), affecting the routes used to initialize the broker.
Integration Tests
tests/integration/test_pattern_b_terminal_result_applier.py
New async integration test verifies a multi-publish contract emits handler result to the configured terminal topic. Adds ModelTerminalResult Pydantic model and HandlerTerminalResult handler; wires handler via wire_from_manifest (patched import), publishes a command, collects terminal-topic result, and asserts status and correlation_id.
Unit Tests
tests/unit/runtime/auto_wiring/test_wiring.py, tests/unit/runtime/test_service_pattern_b_broker.py
Unit test TestTerminalEventResultApplier added to assert wiring publishes exactly once to terminal topic. Pattern B broker tests updated to capture computed ingress package_names and a new test ensures _start_pattern_b_broker uses configured pattern_b_broker.package_names even when ONEX_ACTIVE_RUNTIME_PACKAGES is set.

Sequence Diagram

sequenceDiagram
    participant Contract as Contract YAML
    participant Discovery as Discovery Parser
    participant Model as ModelDiscoveredContract
    participant Wiring as Handler Wiring
    participant Bus as Event Bus
    participant Handler as Handler
    participant Applier as DispatchResultApplier

    Contract->>Discovery: load contract (OMN-10079)
    Discovery->>Model: create ModelDiscoveredContract (includes terminal_event)
    Model->>Wiring: supply discovered contract
    Wiring->>Wiring: determine output_topic (single publish or terminal_event)
    Bus->>Handler: deliver command envelope
    Handler->>Handler: process -> result model
    Handler->>Applier: return result
    Applier->>Bus: publish result to terminal_event topic
    Bus->>Bus: emit terminal-topic message
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A terminal event hops into view,
Contracts now point where results must land,
Discovery and wiring march in line,
Tests gather messages by hand,
Cheers from a rabbit in the dev wonderland.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: adding support for publishing terminal outputs for brokered runtime commands, which aligns with the core objective of discovering contract-level terminal_event and routing handler outputs to it.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-10079-runtime-market-terminal-applier

Comment @coderabbitai help to get the list of available commands and usage tips.

@jonahgabriel
jonahgabriel enabled auto-merge (squash) May 7, 2026 01:11
@jonahgabriel
jonahgabriel merged commit f392bb1 into main May 7, 2026
87 of 94 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-10079-runtime-market-terminal-applier branch May 7, 2026 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant