Repository navigation
fix(orchestration): let the owning Run address a Dispatch after its assignee binds a child Run - #24974
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Owner Run can reach a nested worker Dispatch —
resolveRunBoundDispatchRecipientnow skips therunMismatchguard when the explicitrun:equalsdispatch.run_id, so an owner coordinator's send redirects to the assignee's current Run (with the existingrecipient_run_bound_redirectwarning) instead of failing withrecipient_run_mismatch. Dispatch ownership is untouched. - Positive test added —
run-bound-recipient-mail.test.tscovers the owner-Run redirect and asserts the Dispatch stays owned by the root Run. - Rejection test repointed —
run-bound-mailbox-safety.test.tsnow names the assignee Run (leadRun.id) and expectsdispatch_run_mismatch, preserving the non-owner rejection.
Verified: the three focused routing suites pass (40 tests), and reverting the source hunk makes the new test fail with recipient_run_mismatch, so it is genuine coverage rather than theatre.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
No actionable comments were generated in the recent review.
|
Naming a Dispatch's own Run with --run is equivalent to omitting it, so mail to a Dispatch whose assignee now coordinates a child Run redirects to that Run's mailbox instead of failing recipient_run_mismatch. Fixes stablyai#24699 Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
32adeea to
3610e30
Compare

ELI5
A coordinator gives a task to a worker, and the worker then starts its own sub-team. After that, if the coordinator messaged the worker about the task and named its own project, Orca refused the message and said it belonged somewhere else. Now Orca delivers the message to the worker's new sub-team mailbox and adds a short note saying where it went.
What Changed
run-create, which creates R2, so B now coordinates R2. After that:orca orchestration send --run R1 --to dispatch:<id>failed withrecipient_run_mismatch("belongs to Run R2").--run R2failed withdispatch_run_mismatch("Dispatch belongs to R1").--runworked.--run R1(the Dispatch's own Run) works the same as leaving out--run. The mail is redirected torun:R2and returns therecipient_run_bound_redirectwarning.--run R2, and any other Run, are still rejected.recipient-routing.ts,resolveRunBoundDispatchRecipientcompared the explicit--runwith the assignee's current bound Run (R2). ButresolveMessageRunhad already required--runto equal the Dispatch's owning Run (R1). So every explicit--runon a redirected Dispatch failed one check or the other. The function now skipsrunMismatchwhenexplicitRunId === dispatch.run_id.run-bound-mailbox-safety.test.ts, the old "refuses an explicit sender Run that would silently redirect" case is replaced. Its assertion is now inverted, and the redirect was never silent because it returns a warning. The new test checks two things:dispatch_run_mismatch.Why
Naming the Dispatch's own Run is the most explicit way to send this message, and it should not be stricter than leaving
--runout. This doesn't open a new mailbox to anyone: the same sender already reaches the samerun:R2mailbox without--run. The exception only applies when the explicit Run equals the Dispatch's owning Run. The payload-scoped Dispatch guard (runMismatch) still applies in every other case. Dispatch ownership is unchanged, and settled Dispatches are still refused earlier byassertDispatchMailboxDeliverable.Linked Issue
Fixes #24699
Visual Proof
N/A. This is server-side orchestration routing (RPC/CLI behavior) with no UI change. The before and after are shown by tests:
recipient-routing.tsrestored to main): the new test fails withOrchestrationError: dispatch:ctx_… belongs to Run run_…, not explicitly requested Run run_…, thrown atrecipient-routing.ts:87.Testing
Reproduced the bug on main using the new test case in
run-bound-mailbox-safety.test.ts(1 of 28 tests failed withrecipient_run_mismatch). It passes with the fix.Ran scratch probes on the branch:
dispatch_inactive.pnpm test src/main/runtime/rpc/methods/orchestration/messaging/: 12 files, 255 tests passed after rebasing onto current main.orchestration-party-addressing.test.tspassed 27/27.oxlint (anti-slop, code-quality), ast-grep, the changed-code quality gate and oxfmt are clean on the touched files.
Tested on macOS. The change is platform-agnostic server routing. There are no CLI, wire or schema changes, so mixed client/server versions are unaffected. It has no impact on folder workspaces or SSH.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Notes
--run R1is stored withrun_idR2, so it doesn't appear in R1's Run-scoped history. This is the same as leaving out--run, and the redirect warning tells the sender.--run R1(--to term_lead --run R1) still fails withrecipient_run_mismatch.Original fix by @lorenzozanee in #24974.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)