Skip to content

fix(orchestration): file federated worker mail under the coordinator Run - #19542

Merged
Jinwoo-H merged 1 commit into
mainfrom
federated-mailbox-home-run
Sep 8, 2026
Merged

Jinwoo-H merged 1 commit into
mainfrom
federated-mailbox-home-run

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 77 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1489 $\color{#cf222e}{\Huge{\mathbf{−}}}$​512 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​977
Prod 23 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​110 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​76

Replaces #19339.

Problem

A federated worker host has no dispatch_contexts row for the remote Dispatch, so every mailbox write for it fell through to the ?? LEGACY_RUN_ID fallback and landed in run_legacy_local. The mail worked while cached, but after the host restarted the legacy-adoption probe in orchestration-schema-version-skew.ts saw a live row in the legacy Run, decided the database predated Runs, and replayed the destructive adoption. The coordinator's check then found its instruction gone.

Fix

  • orchestration.federationAttachStart now carries the coordinator's real runId (required). The worker host stores it as remote_dispatch_attachments.home_run_id and inserts a stub runs row with INSERT OR IGNORE so foreign keys hold. No synthetic Run, no resolver.
  • Schema v40 adds the column. Federation is unreleased (feat(orchestration): make multi-agent workflows durable #16904 landed after v1.4.197), so no released profile has attachment rows; development-only rows get an empty placeholder and fail closed until re-attached.
  • All four ?? LEGACY_RUN_ID write fallbacks are deleted (message-insert.ts, task-store.ts, decision-gate-store.ts, check-worker.ts). A missing Run now throws instead of misfiling. federation-control-message.ts writes the attachment's home Run and rejects a replay under a different Run.
  • Probe hardening from fix(orchestration): give federated worker hosts a non-legacy mailbox Run #19339: an attachment-matched mailbox row is never evidence of a pre-Runs database.
  • worker-show loop fix from fix(orchestration): give federated worker hosts a non-legacy mailbox Run #19339: unverifiable with nothing else owed projects nextAction: none; guide text updated and bundle regenerated.

Verification

  • Orchestration + RPC + CLI + shared + runtime suites: 883 files, 10,527 tests pass.
  • tc:node, tc:cli, changed-code quality (0 new findings), bundled-guide and bundle-manifest verify, reliability gates (110), max-lines and ts-nocheck ratchets, git diff --check.
  • Mutations killed: dropping the stub Run insert (8 failures), restoring the check-worker legacy fallback (3 failures), restoring each other writer fallback, disabling the probe exclusions.
  • New tests: real orchestration.check RPC across a DB close/reopen on a federated attachment, loopback attach filing once under the local Run, missing-home-Run refusal, v40 migration placeholder rejection, probe message/delivery cases.

Compatibility

None required: federation has not shipped. Genuine pre-Runs databases still receive the existing one-time adoption. No stream opcode or daemon change.

@pullfrog

pullfrog Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

This run was cancelled 🛑

The workflow was cancelled before completion. Please check the link below for details.

Pullfrog  | View workflow run | via Pullfrog | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change makes orchestration tasks and messages require explicit Run identifiers. Federated attachments now store and propagate their home Run through schemas, migrations, RPC handlers, and control messages. Worker projection returns no command for unverifiable workers without pending work. The change adds regression tests for migrations, writer validation, federated attachment delivery, restart replay, and loopback mail delivery. It also updates orchestration guidance and reliability gates.

Priority: ➖ Normal — Impact reflects medium issue severity.

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to f8b68

Task creation now requires a Run, but callers can still omit it at compile time and encounter a runtime failure. Make the input contract required before merge.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, fix, verification, and compatibility impact, but it does not follow the required template. It omits the required ELI5, What Changed, Visual Proof, AI Disclosure, … Update the description to include every template section. Add an ELI5 summary, structured What Changed and Why sections, a Linked Issue entry using the required format, Visual Proof with N/A and a reason if applicable, Testing details and c…
Docstring Coverage ⚠️ Warning Docstring coverage is 34.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 50 files. (49 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: federated worker mail is filed under the coordinator Run.
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.
Full details: Description check

Explanation

The description explains the problem, fix, verification, and compatibility impact, but it does not follow the required template. It omits the required ELI5, What Changed, Visual Proof, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections, and it does not use the required linked-issue format.

Resolution

Update the description to include every template section. Add an ELI5 summary, structured What Changed and Why sections, a Linked Issue entry using the required format, Visual Proof with N/A and a reason if applicable, Testing details and checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and the complete Checklist.

Full details: Docstring Coverage

Explanation

Docstring coverage is 34.78% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 50 files. (49 skipped: 2 unsupported, 47 over the file limit.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 1973c789-803c-4254-aa81-da2708974944

📥 Commits

Reviewing files that changed from the base of the PR and between 96c6aa2 and f8b6844.

📒 Files selected for processing (100)
  • config/reliability-gates.jsonc
  • config/scripts/orchestration-skill-guidance.test.mjs
  • skill-guides/orchestration.md
  • src/cli/bundled-skill-guides.ts
  • src/main/runtime/orca-runtime-subscribe-to-terminal-resize.ts
  • src/main/runtime/orca-runtime-tests/lineage-and-scan-cache-part-05.spec.ts
  • src/main/runtime/orca-runtime-tests/mobile-creation-and-orchestration-part-02.spec.ts
  • src/main/runtime/orca-runtime-tests/terminal-output-and-worker-recovery-part-04.spec.ts
  • src/main/runtime/orchestration-messages-fake-parity.test.ts
  • src/main/runtime/orchestration/coordinator-decision-gates.test.ts
  • src/main/runtime/orchestration/coordinator-dispatch-unobserved-prompt.test.ts
  • src/main/runtime/orchestration/coordinator-drift-probe-coalescing.test.ts
  • src/main/runtime/orchestration/coordinator-escalation-triage.test.ts
  • src/main/runtime/orchestration/coordinator-stale-base-flag.test.ts
  • src/main/runtime/orchestration/coordinator.test.ts
  • src/main/runtime/orchestration/db-empty-dispatch-shortcircuit.benchmark.test.ts
  • src/main/runtime/orchestration/db-heartbeat-straggler-guard.test.ts
  • src/main/runtime/orchestration/db-message-timestamp.test.ts
  • src/main/runtime/orchestration/db-messages.test.ts
  • src/main/runtime/orchestration/db-task-create-readiness.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-invariant.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-lifecycle-guards.test.ts
  • src/main/runtime/orchestration/db-task-dispatch-races.test.ts
  • src/main/runtime/orchestration/db-undelivered-mailboxes.test.ts
  • src/main/runtime/orchestration/db.test.ts
  • src/main/runtime/orchestration/db/attempt-outcome-projection.test.ts
  • src/main/runtime/orchestration/db/contract-constants.ts
  • src/main/runtime/orchestration/db/decision-gate-lifecycle.test.ts
  • src/main/runtime/orchestration/db/decision-gates/decision-gate-store.ts
  • src/main/runtime/orchestration/db/dispatch-depth.test.ts
  • src/main/runtime/orchestration/db/dispatch-mailbox-consumer-fencing.test.ts
  • src/main/runtime/orchestration/db/dispatch-row-writer.ts
  • src/main/runtime/orchestration/db/federation/federated-dispatch-observation-fence.test.ts
  • src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-create.ts
  • src/main/runtime/orchestration/db/federation/remote-dispatch-attachment-release.test.ts
  • src/main/runtime/orchestration/db/lifecycle-transition.test.ts
  • src/main/runtime/orchestration/db/messages/message-insert.ts
  • src/main/runtime/orchestration/db/schema/create-graph-tables-sql.ts
  • src/main/runtime/orchestration/db/schema/federated-home-run-migration.test.ts
  • src/main/runtime/orchestration/db/schema/migrate-v40.ts
  • src/main/runtime/orchestration/db/schema/migrate.ts
  • src/main/runtime/orchestration/db/tasks/task-store.ts
  • src/main/runtime/orchestration/db/writer-run-required.test.ts
  • src/main/runtime/orchestration/dispatch-failure-idempotency.test.ts
  • src/main/runtime/orchestration/failed-start-terminal-adoption.test.ts
  • src/main/runtime/orchestration/federation-acknowledgment-integrity.test.ts
  • src/main/runtime/orchestration/federation-control-message.ts
  • src/main/runtime/orchestration/lifecycle-caller-edges.test.ts
  • src/main/runtime/orchestration/lifecycle-reconciliation.test.ts
  • src/main/runtime/orchestration/lightweight-run-worker-exit-escalation.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-eligibility.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-stage.test.ts
  • src/main/runtime/orchestration/mailbox-pointer-submit.test.ts
  • src/main/runtime/orchestration/message-batch-atomicity.test.ts
  • src/main/runtime/orchestration/nested-worker-depth-migration.test.ts
  • src/main/runtime/orchestration/orchestration-adopted-run-binding.test.ts
  • src/main/runtime/orchestration/orchestration-all-start-versions-migration.test.ts
  • src/main/runtime/orchestration/orchestration-db-retention-pagination.test.ts
  • src/main/runtime/orchestration/orchestration-federated-legacy-probe.test.ts
  • src/main/runtime/orchestration/orchestration-legacy-storage-test-fixture.ts
  • src/main/runtime/orchestration/orchestration-mutation-question-db.test.ts
  • src/main/runtime/orchestration/orchestration-schema-version-skew.ts
  • src/main/runtime/orchestration/orchestration-settled-worker-resume-fence-db.test.ts
  • src/main/runtime/orchestration/orchestration-version-skew-migration.test.ts
  • src/main/runtime/orchestration/orchestration-worker-dispatch-db.test.ts
  • src/main/runtime/orchestration/r1-identity-migration.test.ts
  • src/main/runtime/orchestration/types.ts
  • src/main/runtime/orchestration/worker-start-unobserved-prompt-settlement.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federated-message-targeting.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federated-release-safety.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federated-worker-start.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-agent-launch.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-control-mail.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-folder-placement.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-lifecycle-settlement.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-liveness-verdict.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-setup.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-prompt-budget.test.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation-start-schema.ts
  • src/main/runtime/rpc/methods/orchestration/federation/federation.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-worker-federated-attachment.test.ts
  • src/main/runtime/rpc/methods/orchestration/messaging/check-worker.ts
  • src/main/runtime/rpc/methods/orchestration/runs/migration-behavior.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/failed-start-residual-terminal.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/legacy-dispatch-projection.test.ts
  • src/main/runtime/rpc/methods/orchestration/worker/manual-dispatch-observation.test.ts
  • src/main/runtime/rpc/methods/structured-worker-stop-receipt.test.ts
  • src/main/runtime/rpc/orchestration-11745-regression-verification.test.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher-test-fixture.ts
  • src/main/runtime/rpc/orchestration-legacy-coordinator-race.test.ts
  • src/main/runtime/rpc/orchestration-legacy-question-takeover.test.ts
  • src/main/runtime/rpc/orchestration-legacy-takeover-delivery.test.ts
  • src/main/runtime/rpc/orchestration-legacy-takeover-dispatcher.test.ts
  • src/main/runtime/rpc/orchestration-mutation-ledger.test.ts
  • src/main/runtime/rpc/orchestration-mutation-request-show.test.ts
  • src/main/runtime/rpc/orchestration-runtime-update-settlement.test.ts
  • src/main/runtime/runtime-legacy-worker-terminal-resume-fence.test.ts
  • src/main/runtime/runtime-rpc-request-authorization.test.ts
  • src/shared/orchestration-fleet-projection.test.ts
  • src/shared/orchestration-fleet-worker-projection.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Comment thread src/main/runtime/orchestration/db/tasks/task-store.ts
@Jinwoo-H
Jinwoo-H merged commit 98fdbc4 into main Sep 8, 2026
58 of 87 checks passed
nwparker added a commit that referenced this pull request Sep 8, 2026
…e main static analysis

The 7 auto.components.settings.TerminalPane.minimumContrast.* entries added by #18126 have zero call sites; the shipped component reads settings.contrast.*. Because the runtime-required catalog classifies any key with no literal-default call site as required, the orphans broke 'Verify runtime-required localization catalog' on main and red-lit every PR in the repo.

Deleting them is the root-cause fix: regenerating would instead add dead strings to the boot bundle. On main+delete, --fix regenerates a byte-identical catalog and the CI step exits 0.

Merged with 'test / tests node 24 3/8' red: that failure is an unrelated main break from the #19542/#19551 collision, not from this change.
brennanb2025 added a commit that referenced this pull request Sep 9, 2026
…rdinators (#19689)

* fix(orchestration): accept v1.4.198 coordinators on federationAttachStart

#19542 made runId required on the attach RPC and backfilled existing
attachments with '', on the premise that federation was unreleased. It
shipped in v1.4.198, so a v1.4.198 coordinator got 'Missing Run ID' from
an upgraded worker host, and every pre-upgrade attachment lost its mailbox
because home_run_id='' matches no Run.

- runId is optional on the wire; an absent id mints a per-attachment stub
  Run (run_federated_<dispatch>) through the same INSERT OR IGNORE path.
- migrate-v40 backfills existing attachments with the stub and inserts the
  stub Runs, so in-flight workers keep reporting back.
- create SQL gives home_run_id a DEFAULT '' so a rolled-back v1.4.198 host
  can still insert into a v1.4.199-created table.

Stub Runs never carry run_legacy_local, and #19542's attachment-mailbox
exclusion in the skew probe is untouched, so no adoption replay path is
reintroduced (probe test added).

* fix(orchestration): repair empty federated home Run ids on every open

A host on v1.4.199 that rolls back to v1.4.198, attaches workers (rows
land with home_run_id='' via the DEFAULT), then upgrades again never
re-runs the v40 backfill because user_version is already 40, so those
attachments stay without a Run and their control mail is refused.

Lift the two idempotent set-based statements out of migrate-v40 into
backfillFederatedStubHomeRuns and run it from both the v40 migration and
the OrchestrationDb constructor after migrate(), matching the existing
on-open rememberCurrentRunCoordinatorHandles repair.

Tests: reopen a v40 file DB holding a v1.4.198-shaped '' row through the
constructor and assert the stub Run and mailbox; pin the wire schema
accepting a v1.4.198 request with no runId ('' -> undefined, whitespace
passes the schema and is refused at the DB layer).

---------

Co-authored-by: Merge Sim <sim@local>
brennanb2025 added a commit that referenced this pull request Sep 9, 2026
…rdinators (#19689)

* fix(orchestration): accept v1.4.198 coordinators on federationAttachStart

#19542 made runId required on the attach RPC and backfilled existing
attachments with '', on the premise that federation was unreleased. It
shipped in v1.4.198, so a v1.4.198 coordinator got 'Missing Run ID' from
an upgraded worker host, and every pre-upgrade attachment lost its mailbox
because home_run_id='' matches no Run.

- runId is optional on the wire; an absent id mints a per-attachment stub
  Run (run_federated_<dispatch>) through the same INSERT OR IGNORE path.
- migrate-v40 backfills existing attachments with the stub and inserts the
  stub Runs, so in-flight workers keep reporting back.
- create SQL gives home_run_id a DEFAULT '' so a rolled-back v1.4.198 host
  can still insert into a v1.4.199-created table.

Stub Runs never carry run_legacy_local, and #19542's attachment-mailbox
exclusion in the skew probe is untouched, so no adoption replay path is
reintroduced (probe test added).

* fix(orchestration): repair empty federated home Run ids on every open

A host on v1.4.199 that rolls back to v1.4.198, attaches workers (rows
land with home_run_id='' via the DEFAULT), then upgrades again never
re-runs the v40 backfill because user_version is already 40, so those
attachments stay without a Run and their control mail is refused.

Lift the two idempotent set-based statements out of migrate-v40 into
backfillFederatedStubHomeRuns and run it from both the v40 migration and
the OrchestrationDb constructor after migrate(), matching the existing
on-open rememberCurrentRunCoordinatorHandles repair.

Tests: reopen a v40 file DB holding a v1.4.198-shaped '' row through the
constructor and assert the stub Run and mailbox; pin the wire schema
accepting a v1.4.198 request with no runId ('' -> undefined, whitespace
passes the schema and is refused at the DB layer).

---------

Co-authored-by: Merge Sim <sim@local>
(cherry picked from commit addd9f3)
Jinwoo-H added a commit that referenced this pull request Sep 9, 2026
…nd Run

#19542 deleted the fallback that filed such mail under the legacy Run, because a
live row there makes the schema-skew probe read the database as pre-Runs and
replay adoption on the next open. That refusal also broke the first command in
the guide: `orca orchestration send --to <handle>` between two plain terminals,
which worked in v1.4.198.

Restore delivery by filing under `run_unbound`, a Run the probe never matches,
created on first use so `run list` shows it only to a user who has such mail.

Claude-Session: 1fec75fd-224b-46ab-95fe-d88e0f3d9ff9
Jinwoo-H added a commit that referenced this pull request Sep 9, 2026
…nd Run (#19696)

* fix(orchestration): file mail from terminals in no Run under an unbound Run

#19542 deleted the fallback that filed such mail under the legacy Run, because a
live row there makes the schema-skew probe read the database as pre-Runs and
replay adoption on the next open. That refusal also broke the first command in
the guide: `orca orchestration send --to <handle>` between two plain terminals,
which worked in v1.4.198.

Restore delivery by filing under `run_unbound`, a Run the probe never matches,
created on first use so `run list` shows it only to a user who has such mail.

Claude-Session: 1fec75fd-224b-46ab-95fe-d88e0f3d9ff9

* fix(orchestration): create the unbound Run only for a null Run id

Claude-Session: 1fec75fd-224b-46ab-95fe-d88e0f3d9ff9
brennanb2025 pushed a commit that referenced this pull request Sep 9, 2026
…nd Run (#19696)

* fix(orchestration): file mail from terminals in no Run under an unbound Run

#19542 deleted the fallback that filed such mail under the legacy Run, because a
live row there makes the schema-skew probe read the database as pre-Runs and
replay adoption on the next open. That refusal also broke the first command in
the guide: `orca orchestration send --to <handle>` between two plain terminals,
which worked in v1.4.198.

Restore delivery by filing under `run_unbound`, a Run the probe never matches,
created on first use so `run list` shows it only to a user who has such mail.

Claude-Session: 1fec75fd-224b-46ab-95fe-d88e0f3d9ff9

* fix(orchestration): create the unbound Run only for a null Run id

Claude-Session: 1fec75fd-224b-46ab-95fe-d88e0f3d9ff9
(cherry picked from commit 0fe132e)
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