Skip to content

feat(OMN-13644): plumb context_pack_hash onto all delegation terminals + projection - #1455

Merged
jonahgabriel merged 3 commits into
devfrom
jonah/omn-13644-context-pack-hash-plumb-terminals
Jun 27, 2026
Merged

jonahgabriel merged 3 commits into
devfrom
jonah/omn-13644-context-pack-hash-plumb-terminals

Conversation

@jonahgabriel

@jonahgabriel jonahgabriel commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

OMN-13644 — Plumb context_pack_hash onto all delegation terminals + projection

Problem

ModelDelegationResult gained a context_pack_hash field upstream (OMN-13646, omnibase_core 0.46.1 @ 52ee18b4c8fcc517996084437266f0738caf1cb5) but omnimarket never set it. The delegation orchestrator already collected the hash into TerminalEmissionInputs.context_pack_hash at the three terminal sites, yet _emit_terminal built ModelDelegationResult(...) without it (dead field), and the projection converter dropped it — so every delegation_events row read the '' default regardless of arm.

Change

  • Pin bump: omnibase_core git rev → 52ee18b4c8fcc517996084437266f0738caf1cb5 (0.46.1) in pyproject.toml ([tool.uv.sources] + override) + refreshed uv.lock. The existing >=0.45.0,<0.47.0 constraint already allows it.
  • Orchestrator (handler_delegation_workflow.py): capture context_pack_hash once at request acceptance into DelegationWorkflowState.context_pack_hash; the three terminal sites now read that pinned value (not the live request), and _emit_terminal sets ModelDelegationResult(context_pack_hash=…). It therefore persists identically on COMPLETED and FAILED/ESCALATED terminals — escalation re-routing or prompt-text loss between attempts can no longer drop it.
  • Projection (handler_projection_delegation.py): _canonical_result_to_task_delegated_payload carries the hash into ModelTaskDelegatedEvent, so the row mapping reads a real value rather than the '' default; a missing field falls back to '' honestly.

The hash is non-empty only when an actual context pack was injected (ON arm, gated by _context_pack_hash_for_event on context_pack presence); the '' OFF-arm default is preserved verbatim.

Canonical compliance

Canonical only: CONTRACT + NODE + HANDLER. No bespoke co-writer event (the OMN-13629 anti-pattern), no Plugin*, no new REST; topics stay contract-sourced; event-bus is the transport. No hardcoded absolute paths; strongly-typed; no defensive defaults (the documented '' OFF-arm default excepted). Dev lane only — no prod/stability/judge touch.

Dependencies

Depends on OMN-13646 (core context_pack_hash field), pinned at rev 52ee18b4c8fcc517996084437266f0738caf1cb5.

dod_evidence

DoD contract: docs/work-tracking/contracts/OMN-13644.yaml.

  • uv run pytest tests/unit/delegation/test_context_pack_hash_plumb_omn13644.py -q → 7 passed. Proves the acceptance-pinned hash reaches the COMPLETED and FAILED canonical terminals and the projection converter; OFF-arm '' preserved; missing field → ''.
  • uv run pytest tests/unit/delegation/ tests/test_golden_chain_projection_delegation.py tests/test_projection_delegation_api_contract.py -q → 499 passed, 1 skipped.
  • uv run pytest tests/ -q (no -k) → 9818 passed, 54 skipped, 3 failed — the 3 failures are pre-existing live-Kafka integration tests (tests/integration/test_cost_event_publisher_kafka.py, test_kafka_integration_bus_smoke.py) that time out with no local broker (runtime is on .201, not local); unrelated to this change.
  • uv run mypy <two touched handlers> --strict → Success: no issues found.
  • ruff format + ruff check --fix clean; pre-commit run --all-files clean (only the test-regenerated dep-health evidence artifacts were touched and reverted — not part of this PR).

Deploy

No runtime deploy here — pure handler-logic plumb + dependency pin bump. The serialized dev redeploy + live psql proof (hash non-empty on COMPLETED and FAILED rows) runs separately (Redeploy #1).


Evidence-Source: OCC#3189
Evidence-Ticket: OMN-13644

…s + projection

Capture context_pack_hash ONCE at request acceptance into
DelegationWorkflowState and thread it through the single terminal builder
(_emit_terminal) onto the canonical ModelDelegationResult, so it persists on
COMPLETED and FAILED/ESCALATED terminals alike — escalation re-routing or
prompt-text loss between attempts no longer drops it. The projection converter
(_canonical_result_to_task_delegated_payload) now carries the hash into
ModelTaskDelegatedEvent so the row mapping reads a real value rather than the
'' default.

Depends on OMN-13646 (omnibase_core ModelDelegationResult.context_pack_hash,
core 0.46.1 @ 52ee18b4c8fcc517996084437266f0738caf1cb5); pin bumped here.
@github-actions
github-actions Bot enabled auto-merge June 26, 2026 23:37
@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jonahgabriel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 32 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 293349a1-7a54-4a33-9837-9557dc3cab8c

📥 Commits

Reviewing files that changed from the base of the PR and between 5e3116b and 5a650ed.

📒 Files selected for processing (1)
  • docs/work-tracking/contracts/OMN-13644.yaml
📝 Walkthrough

Walkthrough

This PR adds an OMN-13644 work-tracking contract, updates the omnibase-core revision, stores context_pack_hash at delegation acceptance, preserves it through terminal results, and maps it into task-delegated projection payloads. New unit tests cover terminal, projection, and missing-field cases.

Changes

Delegation context hash plumbing

Layer / File(s) Summary
Workflow hash capture and terminal reuse
docs/work-tracking/contracts/OMN-13644.yaml, pyproject.toml, src/omnimarket/nodes/node_delegation_orchestrator/handlers/handler_delegation_workflow.py, tests/unit/delegation/test_context_pack_hash_plumb_omn13644.py
The contract records the context_pack_hash behavior and evidence, the uv pin updates omnibase-core, and the workflow code/tests pin and reuse the hash across completed and failed terminals.
Projection mapping
src/omnimarket/nodes/node_projection_delegation/handlers/handler_projection_delegation.py, tests/unit/delegation/test_context_pack_hash_plumb_omn13644.py
The canonical-to-task-delegated converter copies context_pack_hash from the payload or uses "" when missing, and tests cover non-empty, empty-string, and absent-field inputs.

Sequence Diagram(s)

sequenceDiagram
  participant ModelDelegationRequest
  participant HandlerDelegationWorkflow
  participant DelegationWorkflowState
  participant ModelDelegationResult
  participant _canonical_result_to_task_delegated_payload
  participant ModelTaskDelegatedEvent
  ModelDelegationRequest->>HandlerDelegationWorkflow: handle_delegation_request()
  HandlerDelegationWorkflow->>DelegationWorkflowState: store context_pack_hash
  HandlerDelegationWorkflow->>ModelDelegationResult: emit terminal context_pack_hash
  ModelDelegationResult->>_canonical_result_to_task_delegated_payload: convert payload
  _canonical_result_to_task_delegated_payload->>ModelTaskDelegatedEvent: set context_pack_hash
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I hopped through hashes under silver stars,
Pinning each crumb as the workflow mars.
From request to result, I carried the thread,
Then projected it onward, warm and well-fed.
🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 22.73% 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 title clearly matches the main change: threading context_pack_hash through delegation terminals and projection.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jonah/omn-13644-context-pack-hash-plumb-terminals

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

@github-actions

Copy link
Copy Markdown

⚠️ Architectural Review — WARNINGS

Errors: 0
Warnings: 1

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

ARCH-DI-002: Direct Handler instantiation (warning)\n\n```\nsrc/omnimarket/nodes/node_delegation_orchestrator/handlers/handler_delegation_workflow.py:489: loop = HandlerComplianceLoop()

src/omnimarket/nodes/node_delegation_orchestrator/handlers/handler_delegation_workflow.py:707: HandlerEscalationDecision()\n```\n\nHandler classes should be wired only in workflow_runner.py or adapter modules. Direct instantiation elsewhere bypasses the contract system.\n\n

Powered by node_pr_review_bot

@github-actions

github-actions Bot commented Jun 26, 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

1 similar comment
@github-actions

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

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/unit/delegation/test_context_pack_hash_plumb_omn13644.py (1)

161-227: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add one lifecycle-terminal regression test.

This suite covers the quality-gate COMPLETED path and the inference-error FAILED path, but the handler change also threads context_pack_hash through handle_agent_task_lifecycle in src/omnimarket/nodes/node_delegation_orchestrator/handlers/handler_delegation_workflow.py Line 1967. A small A2A lifecycle terminal assertion would lock down the remaining changed emitter and fully match the “all delegation terminals” contract.

🤖 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/unit/delegation/test_context_pack_hash_plumb_omn13644.py` around lines
161 - 227, Add a regression test for the A2A lifecycle terminal path, since the
current suite only covers the quality-gate COMPLETED and inference-error FAILED
terminals. Extend TestContextPackHashOnTerminals with a case that drives
handle_agent_task_lifecycle in HandlerDelegationWorkflow and asserts the
terminal event/canonical result preserves context_pack_hash, using the existing
_CONTEXT_HASH and the same acceptance-pinned behavior checked by the other
terminal tests.
🤖 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 `@docs/work-tracking/contracts/OMN-13644.yaml`:
- Around line 59-64: The deploy-gate evidence entry uses a noncanonical check
command, so the validator will miss it despite the correct description. Update
the DOD check under the deploy-gate item in OMN-13644.yaml to use the
repository’s canonical printf-based placeholder format and ensure the
check_value explicitly contains the word deploy. Keep the surrounding contract
structure the same and adjust only the deploy-gate evidence entry so the
validator recognizes it.

---

Nitpick comments:
In `@tests/unit/delegation/test_context_pack_hash_plumb_omn13644.py`:
- Around line 161-227: Add a regression test for the A2A lifecycle terminal
path, since the current suite only covers the quality-gate COMPLETED and
inference-error FAILED terminals. Extend TestContextPackHashOnTerminals with a
case that drives handle_agent_task_lifecycle in HandlerDelegationWorkflow and
asserts the terminal event/canonical result preserves context_pack_hash, using
the existing _CONTEXT_HASH and the same acceptance-pinned behavior checked by
the other terminal tests.
🪄 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: 83d0b8a7-0a04-4188-8dca-85c804307d2e

📥 Commits

Reviewing files that changed from the base of the PR and between 98a002f and 5e3116b.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (5)
  • docs/work-tracking/contracts/OMN-13644.yaml
  • pyproject.toml
  • src/omnimarket/nodes/node_delegation_orchestrator/handlers/handler_delegation_workflow.py
  • src/omnimarket/nodes/node_projection_delegation/handlers/handler_projection_delegation.py
  • tests/unit/delegation/test_context_pack_hash_plumb_omn13644.py

Comment thread docs/work-tracking/contracts/OMN-13644.yaml Outdated
@jonahgabriel
jonahgabriel added this pull request to the merge queue Jun 27, 2026
Merged via the queue into dev with commit 8aae85f Jun 27, 2026
71 checks passed
@jonahgabriel
jonahgabriel deleted the jonah/omn-13644-context-pack-hash-plumb-terminals branch June 27, 2026 00:07
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