Skip to content

fix(OMN-10168): add orchestrator dispatcher coverage gate - #1440

Merged
jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10168-dispatcher-coverage
Apr 28, 2026
Merged

jonahgabriel merged 1 commit into
mainfrom
jonah/omn-10168-dispatcher-coverage

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Apr 28, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Adds default-off ONEX_STRICT_DISPATCHER_COVERAGE enforcement before auto-wiring commits dispatchers/subscriptions.
  • Fails strict startup when an orchestrator subscribing to an onex.cmd.*.*-start.v1 topic has no live dispatcher message type for the topic-derived event_type alias.
  • Adds unit and integration coverage for default-off behavior, strict missing-dispatcher failure, explicit event_type aliases, topic-derived aliases, and handler-preparation failures.
  • Adds repo-local deploy-gate contract evidence for OMN-10168.

SEAM-4 audit

Parser-only audit used fresh OMN-10168 worktrees, not the stale canonical checkout:

  • Roots: omnibase_infra/src/omnibase_infra/nodes, omnimarket/src/omnimarket/nodes
  • Contracts parsed: 235
  • Discovery errors: 0
  • Orchestrator start contracts: 11
  • Missing dispatchers: 0

pr_lifecycle_orchestrator is already covered by its contract alias from omnimarket#431: omnimarket.pr-lifecycle-orchestrator-start. No omnimarket code change was required for this task.

Verification

  • uv run pytest tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py tests/integration/test_orchestrator_dispatcher_coverage_integration.py tests/unit/runtime/auto_wiring/test_wiring.py tests/unit/runtime/auto_wiring/test_handler_wiring_event_type_alias.py -q -> 53 passed
  • uv run validate-yaml contracts/OMN-10168.yaml -> passed
  • uv run ruff check src/omnibase_infra/runtime/auto_wiring/handler_wiring.py tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py -> passed
  • uv run ruff check --fix tests/integration/test_orchestrator_dispatcher_coverage_integration.py -> passed
  • uv run ruff format --check src/omnibase_infra/runtime/auto_wiring/handler_wiring.py tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py -> passed
  • uv run ruff format tests/integration/test_orchestrator_dispatcher_coverage_integration.py -> passed
  • uv run mypy src/omnibase_infra/runtime/auto_wiring/handler_wiring.py --strict -> passed
  • git diff --check -> passed
  • pre-commit run --files src/omnibase_infra/runtime/auto_wiring/handler_wiring.py tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py tests/integration/test_orchestrator_dispatcher_coverage_integration.py contracts/OMN-10168.yaml -> passed
  • Commit and push hooks -> passed

No live .201 deploy/restart was performed.

Refs OMN-10168.

Summary by CodeRabbit

  • New Features

    • Optional strict orchestrator dispatcher coverage validation mode that enforces routing completeness and blocks wiring when gaps are detected (toggleable via environment variable).
  • Tests

    • Added unit and integration tests covering strict-mode success, failure, and failure propagation scenarios.
  • Chores

    • Added a deployment contract describing required evidence, validation checks, and manual post-merge verification steps.

@coderabbitai

coderabbitai Bot commented Apr 28, 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: c558172a-8892-4b7c-b756-6b9c57293efc

📥 Commits

Reviewing files that changed from the base of the PR and between 6953320 and bad8174.

📒 Files selected for processing (4)
  • contracts/OMN-10168.yaml
  • src/omnibase_infra/runtime/auto_wiring/handler_wiring.py
  • tests/integration/test_orchestrator_dispatcher_coverage_integration.py
  • tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py
✅ Files skipped from review due to trivial changes (1)
  • contracts/OMN-10168.yaml
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py
  • src/omnibase_infra/runtime/auto_wiring/handler_wiring.py

📝 Walkthrough

Walkthrough

Adds an opt-in strict dispatcher coverage validation (controlled by ONEX_STRICT_DISPATCHER_COVERAGE) to auto-wiring: it derives orchestrator start-command aliases, computes live message types from prepared handlers, detects missing coverage or prep failures, and aborts wiring when gaps are found. Includes contract and tests.

Changes

Cohort / File(s) Summary
Strict Dispatcher Coverage Contract
contracts/OMN-10168.yaml
New deploy-gate contract declaring evidence requirements, CI checks, and DOD steps for enabling strict dispatcher coverage.
Auto-wiring Handler Validation
src/omnibase_infra/runtime/auto_wiring/handler_wiring.py
Adds an opt-in gate (ONEX_STRICT_DISPATCHER_COVERAGE) that: classifies orchestrator contracts, derives start-command aliases from subscribe topics, prepares handlers to compute actual message types, records prep failures, detects missing aliases, and raises ModelOnexError to halt wiring if gaps exist.
Dispatcher Coverage Tests
tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py, tests/integration/test_orchestrator_dispatcher_coverage_integration.py
New unit and integration tests covering unset vs strict mode, success/failure scenarios, routing acceptance rules, and propagation of handler-prep failures; verifies dispatcher counts and error messages.

Sequence Diagram(s)

sequenceDiagram
    participant Client as AutoWiring
    participant Manifest as Manifest
    participant Contracts as OrchestratorContracts
    participant Handlers as HandlerPrep
    participant Validator as CoverageValidator
    participant Engine as MessageEngine

    rect rgba(100,150,200,0.5)
    Note over Client: Strict mode enabled (optional)
    end

    Client->>Contracts: Scan discovered orchestrator contracts
    Contracts-->>Client: Start-command aliases (from subscribe topics)

    Client->>Handlers: Prepare/import handlers
    Handlers-->>Client: Prepared handlers and their message types
    Handlers-->>Client: Prep failures (if any)

    Client->>Validator: Build live message-type set and compare to aliases
    Validator-->>Client: Coverage result (gaps or OK)

    alt Gaps or prep failures
        Client->>Engine: Abort wiring (raise ModelOnexError)
    else All covered
        Client->>Engine: Commit dispatchers/subscriptions
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I checked each start, each alias and gate,

handlers lined up, none left to fate.
When gaps were found I shouted "Not so fast!" —
Wiring paused until all gaps were passed. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.48% 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 clearly and concisely describes the main change: adding an orchestrator dispatcher coverage gate for OMN-10168, which aligns with the primary objective of implementing strict validation for dispatcher coverage.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-10168-dispatcher-coverage

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

@github-actions
github-actions Bot enabled auto-merge April 28, 2026 07:06

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
contracts/OMN-10168.yaml (1)

36-38: Consider importing a public function or module for dod-002 verification.

The check imports _strict_dispatcher_coverage_enabled, a private (underscore-prefixed) function. Private functions are implementation details and may be renamed/removed without notice. If this check is meant to verify the feature exists, consider importing the module itself or exposing a public entry point for contract verification.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@contracts/OMN-10168.yaml` around lines 36 - 38, The check currently imports
the private function _strict_dispatcher_coverage_enabled from
omnibase_infra.runtime.auto_wiring.handler_wiring; change the check to rely on a
public symbol or the module itself to avoid depending on an internal name.
Either import the module (omnibase_infra.runtime.auto_wiring.handler_wiring) and
assert the public API exists via hasattr or import a newly exposed public
function (e.g., strict_dispatcher_coverage_enabled) and assert it is callable;
update the check_value command to reference that module or public symbol instead
of the underscore-prefixed _strict_dispatcher_coverage_enabled.
tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py (1)

83-188: Well-designed test suite covering key scenarios.

The tests comprehensively cover the strict dispatcher coverage feature: default-off behavior, strict rejection, explicit alias acceptance, topic-derived alias acceptance, and preparation failure propagation. Consider adding a test for non-orchestrator contracts to verify they're not subject to the strict check, but this is optional.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py`
around lines 83 - 188, Add an additional unit test in
tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py that
verifies non-orchestrator contracts are not enforced by the strict dispatcher
coverage check: create a manifest using ModelAutoWiringManifest with a contract
built via _make_contract that is not an orchestrator (i.e., differs from
pr_lifecycle_orchestrator/START_ALIAS), set ONEX_STRICT_DISPATCHER_COVERAGE to
"1", patch _import_handler_class to return FakeHandler, call wire_from_manifest
(or MessageDispatchEngine as in other tests) and assert that wiring proceeds
(total_wired or total_skipped as appropriate) and no ModelOnexError is raised;
reference symbols: ModelAutoWiringManifest, _make_contract, START_ALIAS,
wire_from_manifest, and _import_handler_class to locate where to add the test.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@contracts/OMN-10168.yaml`:
- Around line 36-38: The check currently imports the private function
_strict_dispatcher_coverage_enabled from
omnibase_infra.runtime.auto_wiring.handler_wiring; change the check to rely on a
public symbol or the module itself to avoid depending on an internal name.
Either import the module (omnibase_infra.runtime.auto_wiring.handler_wiring) and
assert the public API exists via hasattr or import a newly exposed public
function (e.g., strict_dispatcher_coverage_enabled) and assert it is callable;
update the check_value command to reference that module or public symbol instead
of the underscore-prefixed _strict_dispatcher_coverage_enabled.

In `@tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py`:
- Around line 83-188: Add an additional unit test in
tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py that
verifies non-orchestrator contracts are not enforced by the strict dispatcher
coverage check: create a manifest using ModelAutoWiringManifest with a contract
built via _make_contract that is not an orchestrator (i.e., differs from
pr_lifecycle_orchestrator/START_ALIAS), set ONEX_STRICT_DISPATCHER_COVERAGE to
"1", patch _import_handler_class to return FakeHandler, call wire_from_manifest
(or MessageDispatchEngine as in other tests) and assert that wiring proceeds
(total_wired or total_skipped as appropriate) and no ModelOnexError is raised;
reference symbols: ModelAutoWiringManifest, _make_contract, START_ALIAS,
wire_from_manifest, and _import_handler_class to locate where to add the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b67c28e8-9063-4413-b34a-5ae677502659

📥 Commits

Reviewing files that changed from the base of the PR and between 6aee45c and 6953320.

📒 Files selected for processing (3)
  • contracts/OMN-10168.yaml
  • src/omnibase_infra/runtime/auto_wiring/handler_wiring.py
  • tests/unit/runtime/auto_wiring/test_orchestrator_dispatcher_coverage.py

@jonahgabriel
jonahgabriel force-pushed the jonah/omn-10168-dispatcher-coverage branch from 6953320 to bad8174 Compare April 28, 2026 07:10
@github-actions
github-actions Bot added this pull request to the merge queue Apr 28, 2026
@jonahgabriel
jonahgabriel removed this pull request from the merge queue due to a manual request Apr 28, 2026
@jonahgabriel
jonahgabriel added this pull request to the merge queue Apr 28, 2026
Merged via the queue into main with commit 4296d7c Apr 28, 2026
64 of 65 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-10168-dispatcher-coverage branch April 28, 2026 07:35
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