Repository navigation
fix(orchestration): reject task messages for another implicit Run - #32037
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
10dfc05b-a520-45be-afc4-c2a9d18a9415
📒 Files selected for processing: 3
src/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/orchestration/messaging/implicit-task-run-routing.test.tssrc/main/runtime/rpc/methods/orchestration/routing.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| // Lifecycle validation owns malformed payload errors; routing simply cannot derive a Dispatch. | ||
| } | ||
| } | ||
| const payloadNamesDispatch = dispatchId !== undefined |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Do not treat an empty dispatchId as a resolved payload Dispatch.
If a worker sends a status payload with dispatchId: "" and a Task from another Run, payloadNamesDispatch is true. The empty ID makes Dispatch lookup fall back to the worker’s active Dispatch. The condition at Line 83 then skips the Task ownership check, so routing accepts the foreign Task in the inferred Run. Require a nonempty payload Dispatch ID before applying this exception.
Proposed fix
--- "a/src/main/runtime/rpc/methods/orchestration/routing.ts"
+++ "b/src/main/runtime/rpc/methods/orchestration/routing.ts"
@@ -46,7 +46,7 @@
// Lifecycle validation owns malformed payload errors; routing simply cannot derive a Dispatch.
}
}
- const payloadNamesDispatch = dispatchId !== undefined
+ const payloadNamesDispatch = Boolean(dispatchId)
if (!dispatchId && params.to?.startsWith('dispatch:')) {
dispatchId = params.to.slice('dispatch:'.length)
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const payloadNamesDispatch = dispatchId !== undefined | |
| const payloadNamesDispatch = Boolean(dispatchId) |
074df3f to
a35dfa0
Compare
…ispatch scope Add task_run_mismatch to the RPC passthrough allowlist so clients see the code instead of runtime_error, skip the guard when the payload names a resolved Dispatch so lifecycle validation keeps its audited task_dispatch_mismatch rejection, and tell the sender how to recover. Co-Authored-By: Claude <noreply@anthropic.com>
…sk mismatches Lifecycle sends (worker_done/heartbeat/escalation/decision_gate) from a worker with an active Dispatch now skip task_run_mismatch so the rejection is recorded in the Dispatch Run, as on main, instead of throwing advice that loops into dispatch_run_mismatch. Co-Authored-By: Claude <noreply@anthropic.com>
…ve runnable task_run_mismatch steps A worker that coordinates the Task's child Run still reports to its parent Run implicitly, as on main. The refusal now names the exact --run that will be accepted; Dispatch-bound senders are only offered their own Run. Co-Authored-By: Claude <noreply@anthropic.com>
a35dfa0 to
c202c7d
Compare
ELI5
An agent can run
orca orchestration send --type status --task-id <task>without saying where the message goes. Orca then guesses the destination Run from who it thinks the sender is. When that guess was wrong (#30402: a Codex worker was mistaken for an unrelated terminal), the report went into the wrong Run's inbox, the CLI printedSent msg_...with exit 0, and the real coordinator never got it.With this PR, if the message names a Task that belongs to a different Run than the one Orca guessed, Orca refuses the send. Nothing is stored and nobody is woken, and the error gives the exact command that will work:
A worker that has an active Dispatch can only send to that Dispatch's Run (anything else hits
dispatch_run_mismatch), so its error only offers that Run:rerun with --run run_B to send to your Dispatch ctx_...'s Run.Unchanged:
--to/--runsends go where the sender asked, even across Runs.--to/--run. The message goes to its parent Run, the same as on main.worker_done,heartbeat,escalation,decision_gate) from a worker with a Dispatch keep their current handling. A stale Task ID there is still refused by the lifecycle check (task_dispatch_mismatch/missing_dispatch_id), and the coordinator still sees that refusal in its inbox.--dispatch-id, unknown Task IDs, Tasks with no Run, and malformed payloads behave as before.What changed
routing.ts(resolveMessageRun): when there's no--toor--run, a known Task owned by another Run raisestask_run_mismatch. Three cases skip the check:The check costs one primary-key Task read, plus a coordinator-binding lookup only on the mismatch path.
send-methods.ts: passes the message type intoresolveMessageRun.errors.ts: addstask_run_mismatchto the RPC passthrough allowlist. Without it, the CLI got a genericruntime_error.Built-in flows that use implicit targeting
I searched
skill-guides/,skills/,resources/skills, the CLI specs/help, and the worker preamble (src/main/runtime/orchestration/preamble.ts) fororchestration send. Every built-in worker command (heartbeat, escalation, worker_done) passes--task-id <own> --dispatch-id <own>, so it skips the guard. The coordinator follow-ups use--to dispatch:<id>. No built-in flow sends a foreign Task without a destination. Nested coordinators also neednestedWorkerMaxDepthset to 2 or more (the default is 1; seesrc/shared/nested-worker-depth.ts), so the nested case is opt-in.Validation
Real CLI round trip. I built the CLI and main from this branch and ran
electron . --serveagainst a throwaway isolated profile (ORCA_USER_DATA_PATH=/tmp/oe32037/profile, background launch,nestedWorkerMaxDepth: 2). I created three real PTY terminals in a fixture repo: coordinator C, nested coordinator N and child worker X. Every command ran inside its terminal, so it used that terminal's realORCA_TERMINAL_HANDLE/ORCA_PANE_KEYidentity. Setup: C ranrun-create(R1),task-create(T1) anddispatch T1 --to N. N ranrun-create(R2),task-create(T2) anddispatch T2 --to X. Results:send --type status --task-idtask_run_mismatch, offering only--run R2.--run R2then succeeded.--run R1/--to run:R1fail withdispatch_run_mismatch, which is why the message no longer suggests them.task_run_mismatchoffering--run R2or--run R1.--run R2then succeeded.worker_done --task-id T2 --dispatch-id D2completedC's
checkshowed exactly the two N reports in R1. Afterwards I stopped the server and deleted the profile.Rebased onto origin/main
28c726855e1d(headc202c7d7d26a), which includes #32168 (main's max-lines and typecheck fix). No conflicts. After the rebase:pnpm test src/main/runtime/rpc/methods/orchestration src/main/runtime/rpc/errorsgives 91 files and 1004 tests passing; fullpnpm tcis clean; oxlint, oxfmt andcheck:code-quality:changedare clean.Tests.
implicit-task-run-routing.test.tshas 14 tests. That includes a new nested-coordinator case, which fails without the exemption and passes with it.TMPDIR=/private/tmp pnpm vitest run src/main/runtime/rpc/methods/orchestration/messaging src/main/runtime/rpc/errors.test.ts src/main/runtime/rpc/orchestration-party-addressing.test.ts: 15 files, 326 tests pass.check:code-quality:changed, oxlint and oxfmt pass.Not exercised: remote, WSL or Windows hosts. The change is in the host-local
orchestration.sendhandler, with no new wire fields and no platform-specific code. Each host enforces only its own copy. An older CLI that doesn't recognisetask_run_mismatchstill prints the message text.Linked issue
Partial repair for #30402: this covers the routing half. The sender-identity half was addressed by #30406 (merged). Plain-text send receipts remain open. This PR must not close #30402. #13696 is a separate report.
Remaining risks / tradeoffs
--runto use. Scripts that relied on the misdelivery need that flag. No built-in skill or preamble does this.Visual proof
N/A: backend message admission, with no rendered UI.
Agent skill upstream boundary