Skip to content

fix(OMN-11025): migrate delegation DTO imports - #629

Merged
jonahgabriel merged 5 commits into
mainfrom
jonah/omn-11025-market-delegation-dtos
May 15, 2026
Merged

jonahgabriel merged 5 commits into
mainfrom
jonah/omn-11025-market-delegation-dtos

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented May 15, 2026 •

Copy link
Copy Markdown
Contributor

Ticket: OMN-11025
Evidence-Ticket: OMN-11025
Evidence-Source: OCC#1019

Summary

  • migrate omnimarket delegation DTO compatibility paths to canonical omnibase_compat.contracts.delegation.wire classes from OMN-11024
  • preserve existing omnimarket module/contract refs with import shims
  • rename local collision classes while preserving aliases; ModelRoutingDecision is untouched
  • add repo-local OMN-11025 work-tracking contract and focused compatibility coverage
  • pin omnibase-compat through a git source at the same OMN-11024 merge commit after archive zip fetches returned 504/503 in CI/local install

Verification

  • uv sync --locked --all-extras
  • uv run ruff check pyproject.toml src/omnimarket/events/delegation.py src/omnimarket/adapters/llm/bifrost/model_bifrost_delegation_config.py src/omnimarket/nodes/node_budget_policy_compute/models/model_budget_limits.py src/omnimarket/nodes/node_delegation_orchestrator/models src/omnimarket/nodes/node_delegation_quality_gate_reducer/models src/omnimarket/nodes/node_delegation_routing_reducer/models src/omnimarket/nodes/node_delegation_routing_reducer/handlers/handler_delegation_routing.py src/omnimarket/nodes/node_projection_delegation/handlers/handler_projection_delegation.py src/omnimarket/nodes/node_build_loop_orchestrator/models/model_dispatch_trace.py tests/test_delegation_dto_omnibase_compat_imports.py
  • uv run python scripts/ci/check_node_metadata_dependencies.py
  • uv run pytest tests/test_delegation_dto_omnibase_compat_imports.py tests/test_memory_dto_omnimemory_imports.py tests/unit/delegation tests/nodes/node_delegation_routing_reducer/test_contract_routing_policy.py tests/test_golden_chain_projection_delegation.py tests/unit/nodes/node_build_loop_orchestrator/test_dispatch_trace.py src/omnimarket/nodes/node_budget_policy_compute/tests/test_handler_budget_policy.py -q
  • uv run pytest tests/ --splits 20 --group 5 --store-durations --durations-path .test_durations -v --tb=short -m "not kafka" --junitxml=junit-5.xml
  • D4 delegation-wire targeted overlay check: PASS, findings=[]
  • uv run python - <<'PY' ... yaml.safe_load(Path('docs/work-tracking/contracts/OMN-11025.yaml').read_text()) ... PY
  • git diff --check

Runtime / Deploy Gate

No runtime deploy, restart, or .201 mutation was performed. This is import compatibility and local collision cleanup; post-merge validation should smoke import the affected delegation node entry points on the deployed image.

Summary by CodeRabbit

Release Notes

  • Chores
    • Consolidated delegation model definitions into a canonical compatibility package for improved consistency across the system.
    • Added omnibase-compat>=0.3.1 dependency to support enhanced delegation infrastructure.
    • Standardized quality gate model naming with backwards-compatible aliases to ensure existing integrations continue to work without modifications.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@jonahgabriel has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a795512a-b128-4d07-a305-a6789a5f6249

📥 Commits

Reviewing files that changed from the base of the PR and between 555c799 and 3052f15.

📒 Files selected for processing (3)
  • src/omnimarket/nodes/node_delegation_routing_reducer/models/model_delegation_config.py
  • tests/nodes/node_delegation_routing_reducer/test_contract_routing_policy.py
  • tests/test_delegation_dto_omnibase_compat_imports.py
📝 Walkthrough

Walkthrough

This PR consolidates omnimarket delegation data models into canonical omnibase_compat.contracts.delegation.wire re-exports. It updates pyproject.toml to use Git-pinned omnibase-compat, adds omnibase-compat dependency to four node metadata files, migrates ~15 model files across orchestrator/quality-gate/budget/routing nodes from local Pydantic definitions to re-exports, replaces a classmethod YAML parser with a standalone function, renames two model classes with compatibility aliases, and introduces a comprehensive compatibility test suite validating all re-exports.

Changes

Delegation DTO compatibility re-export migration

Layer / File(s) Summary
Dependency setup and contract tracking
pyproject.toml, src/omnimarket/nodes/node_budget_policy_compute/metadata.yaml, src/omnimarket/nodes/node_delegation_orchestrator/metadata.yaml, src/omnimarket/nodes/node_delegation_routing_reducer/metadata.yaml, src/omnimarket/nodes/node_delegation_quality_gate_reducer/metadata.yaml, docs/work-tracking/contracts/OMN-11025.yaml
pyproject.toml switches omnibase-compat from ZIP archive to Git repository with pinned rev. Four node metadata files add omnibase-compat>=0.3.1 dependency. Work-tracking contract OMN-11025 documents the migration with DoD evidence including test validation, ruff checks, and deploy-gate guidance.
Core delegation event models migration
src/omnimarket/events/delegation.py, src/omnimarket/adapters/llm/bifrost/model_bifrost_delegation_config.py
events/delegation.py becomes a compatibility shim re-exporting EnumQualityContractMode, ModelDelegationRequest, ModelDelegationResult, validate_acceptance_criteria, and acceptance-criteria constants from omnibase_compat. Bifrost adapter re-exports seven delegation config DTOs from the same source instead of defining them locally.
Orchestrator node request/result/event reexports
src/omnimarket/nodes/node_delegation_orchestrator/models/model_delegation_request.py, model_delegation_result.py, model_delegation_event.py
Three core flow models switch import source to omnibase_compat.contracts.delegation.wire while maintaining backward-compatible re-export surface.
Orchestrator node intent model variants
src/omnimarket/nodes/node_delegation_orchestrator/models/model_inference_intent.py, model_quality_gate_intent.py, model_routing_intent.py, model_baseline_intent.py
Four intent variant models that structure different request types convert from local Pydantic BaseModel to re-exports from omnibase_compat.
Orchestrator node detailed DTOs
src/omnimarket/nodes/node_delegation_orchestrator/models/model_inference_response_data.py, model_compliance_loop_result.py, model_task_delegated_event.py
Three complex state-holding models (response data, compliance result, task event) that were fully defined inline become re-exports from canonical omnibase_compat wire package.
Quality gate reducer models
src/omnimarket/nodes/node_delegation_quality_gate_reducer/models/model_quality_contract.py, model_quality_gate_input.py, model_quality_gate_result.py
Quality gate node imports are updated to source from omnibase_compat; EnumQualityGateCategory and ModelQualityGateResult move from local Literal and Pydantic definitions to re-exports.
Budget policy compute models
src/omnimarket/nodes/node_budget_policy_compute/models/model_budget_limits.py
ModelBudgetLimits (with max tokens/cost/time fields) converts from local definition to re-export from omnibase_compat.
Routing reducer config and models with YAML parser
src/omnimarket/nodes/node_delegation_routing_reducer/models/model_delegation_config.py, model_routing_tier.py, model_tier_model.py, src/omnimarket/nodes/node_delegation_routing_reducer/handlers/handler_delegation_routing.py
model_delegation_config.py removes inline Pydantic class and replaces from_yaml_text classmethod with standalone parse_delegation_config_yaml function that maps YAML fields into imported canonical DTOs; routing tier and tier model become re-exports. Handler integration updated to call new parser function.
Handler and derived model class renames
src/omnimarket/nodes/node_projection_delegation/handlers/handler_projection_delegation.py, src/omnimarket/nodes/node_build_loop_orchestrator/models/model_dispatch_trace.py
Projection handler renames ModelTaskDelegatedEvent → ModelProjectionTaskDelegatedEvent with alias for backward compatibility. Build loop orchestrator renames ModelQualityGateResult → ModelDispatchQualityGateResult with alias. Both update __all__ to export the new canonical names.
Compatibility verification test suite
tests/test_delegation_dto_omnibase_compat_imports.py
New test module with DTO_IMPORTS registry mapping 20+ legacy omnimarket model paths to canonical omnibase_compat paths, DELEGATION_CONTRACTS list of nodes to validate, helper functions _resolve and _model_refs for dynamic import/traversal, and two parametrized tests verifying re-export equivalence and contract YAML model references originate from omnibase_compat.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs

  • OmniNode-ai/omnimarket#614: Updates handler output schema registry imports to reference ModelDelegationResult from omnimarket's delegation orchestrator node, which is being migrated to an omnibase_compat re-export in this PR.
  • OmniNode-ai/omnimarket#619: Adds delegate-skill dispatch handler logic that constructs ModelDelegationRequest with quality contract mode and acceptance criteria, and maps ModelDelegationResult fields—tightly coupled to the delegation wire contract being consolidated in this PR.

🐰 From your friendly code-review rabbit:

Hop, hop! The models all agreed to live upstream,
In omnibase_compat—a delegation dream!
They left their local homes with grace and care,
Re-exports in place, now shared everywhere. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Title check ✅ Passed The PR title clearly summarizes the main change: migrating delegation DTO imports to use canonical classes from omnibase_compat.contracts.delegation.wire, which aligns with the substantial refactoring across delegation-related modules shown in the changeset.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ 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-11025-market-delegation-dtos

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

@github-actions
github-actions Bot enabled auto-merge May 15, 2026 02:46
@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown

✅ Architectural Review — PASSED

Errors: 0
Warnings: 0

What this checks

Rule Description
ARCH-TOPIC-001 No hardcoded Kafka topic strings in handler code
ARCH-DI-001 No event_bus=None bypass
ARCH-DI-002 No direct Handler instantiation outside workflow_runner/adapters
ARCH-DI-003 No reinvented DI containers
ARCH-TOPIC-002 contract.yaml topics follow `onex.{cmd

No architectural violations found.

Powered by node_pr_review_bot

@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown

✅ PR Review Bot — CLEAN

Findings: 0
Run ID: ``

Note: Reviewer models are running as stubs (OMN-7969–OMN-7972 pending). Architectural findings from Phase 1 (arch-lint) are the authoritative signal until model handlers land.


Verdict semantics

Verdict Meaning
clean No blocking findings
risks_noted Findings noted; threads passed verification
blocking_issue MAJOR/CRITICAL findings not resolved — do not merge

Powered by node_pr_review_bot — FSM pipeline with multi-model review fan-out

@github-actions

github-actions Bot commented May 15, 2026 •

Copy link
Copy Markdown

⚠️ Hostile Reviewer — DEGRADED (informational)

Blocking findings (critical/error): 0
Total findings: 0
Models succeeded: none

Note: All reviewer models failed or were unavailable. Degraded results are informational during the pilot phase (OMN-8524) and do not block merge. Error: cli_review exited non-zero (all models failed or binary error)


Gate semantics (pilot phase)

Verdict Meaning Blocks merge?
passed No critical/error findings No
blocked CRITICAL or ERROR findings found Yes
degraded All models unavailable (infra) No (pilot)

Powered by omniintelligence.review_pairing.cli_review — node-based adversarial review via HandlerLlmCliSubprocess (OMN-8524)

@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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/test_delegation_dto_omnibase_compat_imports.py (1)

91-95: ⚡ Quick win

Fail fast on unmapped contract DTO refs.

This filter only checks refs already listed in DTO_IMPORTS, so new omnimarket.* refs in contract.yaml can be missed while the test still passes. Assert there are no unmapped refs before compatibility checks.

Proposed patch
-    model_refs = [
-        ref
-        for ref in _model_refs(contract)
-        if ref in DTO_IMPORTS and not ref.endswith(".ModelRoutingDecision")
-    ]
+    all_contract_refs = [
+        ref
+        for ref in _model_refs(contract)
+        if ref.startswith("omnimarket.") and not ref.endswith(".ModelRoutingDecision")
+    ]
+    unmapped_refs = sorted(set(all_contract_refs) - set(DTO_IMPORTS))
+    assert not unmapped_refs, (
+        f"Unmapped delegation DTO refs in {node_name} contract.yaml: {unmapped_refs}"
+    )
+    model_refs = [ref for ref in all_contract_refs if ref in DTO_IMPORTS]
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_delegation_dto_omnibase_compat_imports.py` around lines 91 - 95,
The test currently builds model_refs by filtering _model_refs(contract) against
DTO_IMPORTS, which hides any new omnimarket.* refs; modify the test to first
compute unmapped = [ref for ref in _model_refs(contract) if ref not in
DTO_IMPORTS] and assert that unmapped is empty (raise/assert with a clear
message listing unmapped refs) before proceeding to the existing compatibility
checks that use model_refs, so any new contract DTO refs are caught immediately;
refer to _model_refs, DTO_IMPORTS, and the model_refs variable when making this
change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/omnimarket/nodes/node_delegation_routing_reducer/models/model_delegation_config.py`:
- Around line 25-35: The YAML parsing currently assumes safe_load returns a dict
and that m["use_for"] is list-like, which can lead to AttributeError or turn a
scalar string into a tuple of characters; update the parsing in the block that
builds tiers and ModelTierModel so you first verify raw is a dict (fall back to
{} if None), ensure raw.get("tiers", []) yields a list and each tier_data is a
dict, ensure tier_data.get("models", []) yields a list and each m is a dict, and
coerce m.get("use_for") safely by treating strings as single-item lists or
validating it is already a list before converting to a tuple for
ModelTierModel(use_for=...), raising or logging a clear error if types mismatch;
refer to the variables raw, tiers, tier_data, m and the ModelTierModel
constructor to locate where to add these checks.

---

Nitpick comments:
In `@tests/test_delegation_dto_omnibase_compat_imports.py`:
- Around line 91-95: The test currently builds model_refs by filtering
_model_refs(contract) against DTO_IMPORTS, which hides any new omnimarket.*
refs; modify the test to first compute unmapped = [ref for ref in
_model_refs(contract) if ref not in DTO_IMPORTS] and assert that unmapped is
empty (raise/assert with a clear message listing unmapped refs) before
proceeding to the existing compatibility checks that use model_refs, so any new
contract DTO refs are caught immediately; refer to _model_refs, DTO_IMPORTS, and
the model_refs variable when making this change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a738e55a-8d8a-42dc-b5a2-b061369fd183

📥 Commits

Reviewing files that changed from the base of the PR and between 4c56042 and 555c799.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (29)
  • docs/work-tracking/contracts/OMN-11025.yaml
  • pyproject.toml
  • src/omnimarket/adapters/llm/bifrost/model_bifrost_delegation_config.py
  • src/omnimarket/events/delegation.py
  • src/omnimarket/nodes/node_budget_policy_compute/metadata.yaml
  • src/omnimarket/nodes/node_budget_policy_compute/models/model_budget_limits.py
  • src/omnimarket/nodes/node_build_loop_orchestrator/models/model_dispatch_trace.py
  • src/omnimarket/nodes/node_delegation_orchestrator/metadata.yaml
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_baseline_intent.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_compliance_loop_result.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_delegation_event.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_delegation_request.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_delegation_result.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_inference_intent.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_inference_response_data.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_quality_gate_intent.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_routing_intent.py
  • src/omnimarket/nodes/node_delegation_orchestrator/models/model_task_delegated_event.py
  • src/omnimarket/nodes/node_delegation_quality_gate_reducer/metadata.yaml
  • src/omnimarket/nodes/node_delegation_quality_gate_reducer/models/model_quality_contract.py
  • src/omnimarket/nodes/node_delegation_quality_gate_reducer/models/model_quality_gate_input.py
  • src/omnimarket/nodes/node_delegation_quality_gate_reducer/models/model_quality_gate_result.py
  • src/omnimarket/nodes/node_delegation_routing_reducer/handlers/handler_delegation_routing.py
  • src/omnimarket/nodes/node_delegation_routing_reducer/metadata.yaml
  • src/omnimarket/nodes/node_delegation_routing_reducer/models/model_delegation_config.py
  • src/omnimarket/nodes/node_delegation_routing_reducer/models/model_routing_tier.py
  • src/omnimarket/nodes/node_delegation_routing_reducer/models/model_tier_model.py
  • src/omnimarket/nodes/node_projection_delegation/handlers/handler_projection_delegation.py
  • tests/test_delegation_dto_omnibase_compat_imports.py

@sonarqubecloud

Copy link
Copy Markdown

@jonahgabriel
jonahgabriel added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 8927423 May 15, 2026
56 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-11025-market-delegation-dtos branch May 15, 2026 10:28
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