Repository navigation
Conversation
`orchestration send --to <handle>` accepted any bare terminal handle and answered ok:true, storing a legacy `to_handle` row that no reader returns. Refuse a handle with no live pane and no active Dispatch with `terminal_not_found`, and, when an address is accepted but no reader polls it, name that recipient in a `warnings` entry on the receipt. A bare-handle row is only returned by the per-handle branch of `orchestration check`. A coordinator reads `run:<id>` and a worker reads `dispatch:<id>`, so a live recipient can still be unable to pull the message. Group fan-out writes the same kind of row per recipient, which is why `@all` traffic never shows up in a check. Two addresses stay accepted on purpose: an active Dispatch assignee whose pane key is not momentarily resolvable, and the retained pre-update Run, whose handles are expected to be dead and whose mail is kept for inspection. Both carry a warning instead of an error. Fixes stablyai#13363
The remote CLI fixture resolved every handle to a null pane, so the new send validation refused its recipient. Resolve the recipient the way the host runtime does and stub the active-Dispatch lookup.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughOrchestration sends now resolve terminal recipient reachability before delivery. Missing terminals produce Merge Risk: ⚪ Minimal · up to The change improves reporting and refusal behavior for unreachable orchestration targets, with the supplied checks passing for the touched areas; no actionable merge-blocking risk remains beyond normal review and checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1⚔️ Resolve merge conflicts 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 26897f06-598e-4599-bd6f-7bfa80d69fc7
📒 Files selected for processing (8)
src/cli/handlers/orchestration-send-receipt-warnings.test.tssrc/cli/handlers/orchestration.tssrc/main/runtime/rpc/errors.tssrc/main/runtime/rpc/methods/orchestration-recipient-reachability.tssrc/main/runtime/rpc/methods/orchestration.test.tssrc/main/runtime/rpc/methods/orchestration.tssrc/main/runtime/rpc/orchestration-runtime-update-settlement.test.tssrc/main/ssh/ssh-remote-orca-cli.test.ts
Group fan-out resolved recipient reach only after every row was inserted and notified, so an @ALL or @WorkTree: member with no live pane and no active Dispatch still got a legacy to_handle row that no reader can surface. An orphaned PTY is the concrete case: terminal.list reports it, but its leaf id is `pty:<id>` rather than a pane UUID, so getTerminalPaneKey returns null. Resolve reach for every recipient before db.insertMessage, deliver to the reachable ones, and name each dropped recipient on the receipt with a new `recipient_unreachable` warning. Group membership is discovered rather than chosen, so refusing the whole broadcast for one dead member would let a single orphaned pane block a live fleet. A fan-out where no recipient is reachable stores nothing readable at all and still fails with terminal_not_found.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/main/runtime/rpc/methods/orchestration.ts (1)
648-648: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winReturn
sendWarningsfrom each direct lifecycle receipt.When a direct lifecycle send returns at lines 624, 639, or 644, it bypasses line 648. A bare recipient with an active Dispatch and no live pane is deliverable and receives
no_live_terminal, but these receipts omit that warning. AddsendWarningsto these return values and add a regression test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3517837b-6660-4235-8398-bcc9ddcfcd6c
📒 Files selected for processing (4)
src/cli/handlers/orchestration-send-receipt-warnings.test.tssrc/main/runtime/rpc/methods/orchestration-recipient-reachability.tssrc/main/runtime/rpc/methods/orchestration.test.tssrc/main/runtime/rpc/methods/orchestration.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/cli/handlers/orchestration-send-receipt-warnings.test.ts
- src/main/runtime/rpc/methods/orchestration-recipient-reachability.ts
…ts too Only the ordinary direct receipt carried sendWarnings. The three lifecycle returns — a capability rejection, a suppressed heartbeat and a rejected worker report — returned before it, so a sender that addressed a bare handle with an active Dispatch and no live pane got a clean-looking receipt and never learned that nothing was listening. The warning describes the address, not the outcome, so every direct receipt owes it. A withSendWarnings helper now attaches it at all four returns, so a later return added to this path cannot silently drop it again. Two regression tests, both verified failing on the parent commit: a suppressed heartbeat and a rejected worker_done, each addressed to a handle that warns no_live_terminal. The heartbeat case runs without a bound Run on purpose — a heartbeat naming a dispatchId is readdressed to the sender's Run when it has one, and a run: address carries no bare-handle warning to lose.
|
Picking up the outside-diff comment from the 2026-08-10 review, on The diagnosis holds exactly as written. Three returns sat before line 648 — the The remedy is a Two regression tests in
One detail worth recording, since it shaped the first test. A heartbeat that names a
|
|
Superseded by #14964. The original branch predates #13717's canonical Run/Dispatch mailbox architecture and its fork rejects maintainer pushes despite the editable-maintainer flag, so the current-main rewrite could not be pushed here. The replacement preserves the issue's intent, documents the narrowed semantics, and carries deterministic receipt + DB/check red/green/revert proof. This PR was not merged. |
|
Understood, and no objection to the supersede — #14964 is built on the architecture this branch predates, and that is the right way round. Thanks for carrying the intent rather than dropping it. I read the replacement. It covers both holes that only surfaced during review here, and covers one of them better than this branch did: On the push failure — you are right, and the cause is not the flag. That is ours to fix, not yours, and it affects every open PR we have here — so the same rewrite-and-close is the only path available to you on any of them. I am raising it on our side today. Until it is resolved, the practical workaround is to tell me what you want changed and I will push it within the day; I am watching these daily. |
Summary
orchestration sendnow refuses a terminal handle that no reader holds, and when it accepts an address that nothing polls it says so on the receipt instead of answering a bareok: true.This builds on #13458 by @bbingz, which found the same hole and fixed the clearest part of it. That PR is right about the shape of the check and right about the exception: an active Dispatch assignee whose pane key is not momentarily resolvable must still receive status mail, so
getTerminalPaneKeyalone cannot be the test. That carve-out is kept here, with its reasoning, and this PR is meant to land instead of #13458 rather than beside it — if #13458 goes in first I will rebase and cut this down to the remainder.The delta is three things.
1. A live handle is not the same as a reachable handle
I checked the coordinator-handover case from the issue before building on it, and the code does not say what the issue says.
run-userebindsruns.coordinator_handleandruns.coordinator_pane_keyand bumpsconsumer_generation; the previous coordinator's terminal keeps running, and because the pane-to-Run binding lives onruns.coordinator_pane_key, that pane ends up bound to nothing. So mail addressed to the pre-handover handle is readable — the fenced terminal's ownorchestration checkreturns it through the per-handle branch. What breaks is different, and worse to debug: the row is filed under the Run, the Run's mailbox only selectsto_handle = 'run:<id>', and the current coordinator never sees it. The sender getsok: truefor a message the coordinator it meant to reach will never read.That is the general rule, not a handover quirk. A legacy
to_handlerow is only returned by the per-handle branch oforchestration check. A coordinator readsrun:<id>; a worker with an active Dispatch readsdispatch:<id>; neither query returns bare-handle rows. So the useful question is the one the issue asks — is this handle still an addressee anyone reads — and it is answerable from the code. Refusing here would be wrong: those terminals are live and do receive the row, both by push-on-idle and by their owncheck. The receipt says it instead.2. Group forms
@alland@worktree:<id>write one legacy-handle row per live terminal, so every recipient that is a coordinator or an active worker gets a row itscheckwill never return — the ~23 invisible rows in the issue. Both options in the issue were open. I chose reporting over rerouting: fan-out exists to give each recipient independent read tracking (§4.5), and folding those rows into the Run mailbox would collapse that and drop group chatter into the fenced-delivery/ack protocol that lifecycle mail depends on, where a new coordinator generation would replay it. The group form also stays accepted — its members come fromlistTerminals, so they are live by construction. The receipt now names the recipients whosecheckwill not surface the message.3. Warnings on the receipt
orchestration.sendgains an optionalwarningsarray ({ code, recipient, message }), and the CLI prints oneWarning:line per entry. Three codes:no_live_terminal— accepted through a carve-out, but nothing holds the handle right now.recipient_reads_other_mailbox— the recipient pollsrun:<id>ordispatch:<id>, so this row will not appear in itscheck; the message names the address to use instead.recipient_outside_run— the row is filed under a Run the recipient does not belong to, which is what a stale coordinator handle looks like after a handover.A new optional result field is wire-safe for older clients per
docs/reference/remote-wire-compatibility.md.One more thing #13458 will hit
The bare refusal on its own breaks
orchestration-runtime-update-settlement.test.tson currentmain: after a contract update the adopted Run keeps pre-update work for inspection, itscoordinator_handleisNULL, and a retained worker's only address is a handle the runtime can no longer resolve. Refusing there drops the report the adopted Run exists to keep. So sends filed under the adopted Run are accepted with ano_live_terminalwarning rather than refused. Worth knowing for #13458 as it stands.Reproduction
Before (from the issue):
After, as asserted by the tests in this PR:
I could not exercise the packaged CLI against a live runtime from this environment, so the
afterblock is the RPC behaviour the tests assert, not a transcript. The invisibility claims behind it were verified against the realOrchestrationDbandOrcaRuntimeService, not mocks of them: the tests send through the RPC handler and then read back throughorchestration.check.Test plan
vitest run src/main/runtime/rpc/methods/orchestration.test.ts— 160 passed. New cases: unknown handle refused withterminal_not_foundand no row stored; active Dispatch assignee without a pane accepted withno_live_terminal; live worker warned withrecipient_reads_other_mailboxand itscheckproven empty; coordinator warned with therun:mailbox named; handle replaced byrun-usewarned withrecipient_outside_run, with the Run mailbox proven empty and the fenced terminal proven still able to read; plain live terminal outside any Run gets no warnings;@allnames both unreachable recipients and both checks proven empty.vitest run src/cli/handlers/orchestration-send-receipt-warnings.test.ts— 3 passed (single receipt, fan-out receipt, clean receipt unchanged).vitest run src/main/runtime/rpc src/cli/handlers— 157 files, 1552 passed, 1 skipped.pnpm typecheck— clean.pnpm lint— clean.pnpm test(full suite) — 4594 files passed, 49271 passed, 99 skipped. Two failures remain, both insrc/main/agent-hooks/WSL relay tests; they fail identically on unmodifiedupstream/mainin this environment (no WSL host).src/main/ssh/ssh-remote-orca-cli.test.ts— its fixture resolved every handle to a null pane, so the new validation refused its recipient. The fixture now resolves the recipient the way a host runtime does; second commit.Fixes #13363
Follow-up: unreachable fan-out recipients (review round 2)
CodeRabbit found a hole this PR had left open: group fan-out resolved recipient reach only
after every row was inserted and notified, so an unreachable member still got a row nobody
can read. It is reachable in practice —
terminal.listreports a connected PTY that owns nopane (
buildPtyTerminalSummary, leaf idpty:<ptyId>), andgetTerminalPaneKeyreturns nullfor it because the id is not a pane UUID. Reach now resolves before
db.insertMessage.The judgement call, stated on purpose. The bot asked for all-or-nothing: refuse the whole
fan-out if any member is unreachable. I chose per-recipient reporting instead. Group membership
is discovered rather than chosen — the sender picks
@all, not who is in it — so one orphanedpane would block a broadcast to every live agent, with no way for the sender to exclude the
offender. That trades a storage bug for an availability bug.
Unreachable recipients are therefore dropped before insertion and named on the receipt under a
new warning code
recipient_unreachable, distinct fromno_live_terminal, which reports a rowthat was stored (an in-flight Dispatch assignee whose pane is momentarily unresolvable).
recipientscounts delivered rows rather than resolved handles. The strict rule survives whereit still earns its keep: a fan-out in which no recipient is reachable stores nothing readable at
all, so it throws
terminal_not_foundand writes no rows.Added tests:
skips a fan-out member nothing can reach and names it on the receipt,refuses a fan-out when no resolved recipient can be reached, andkeeps delivering to a worktree group when one member has no pane(the@worktree:<id>form),plus a CLI receipt case for the partial-delivery line.
vitest runover the four touchedsuites: 194 passed.
pnpm lintandpnpm typecheckclean.