Repository navigation
Conversation
`dispatch --to <terminal> --inject` delivers a task into an already-running agent but records only a dispatch context, so `worker-show`, `worker-read`, `worker-list`, and `worker-retain` never see the lane, and an already-dispatched task cannot be started or retried into supervision afterwards. `--supervise` writes the same supervised worker record `worker-start --terminal` writes. It runs only after injection has proven an agent is present and the pane has stable identity, and it is a record write alone: the terminal is never created, closed, waited on, or written to a second time. The adopted terminal is recorded as external ownership, so release retains it instead of closing a pane the operator started by hand. The response reports `supervised` unconditionally. The dispatch params schema is permissive, so an older host would drop the flag without a word; the receipt lets the CLI say the request was not honored. Refs stablyai#13678
The worker can send worker_done between the prompt write and the record write; settlement updates worker_dispatches WHERE state = 'ready', so a row that does not exist yet is skipped, and the later insert would publish a ready worker for a lane nobody is running. Require status = 'dispatched' inside the attach transaction. The dispatch handler already downgrades a failed record write to unsupervised, so a worker that finishes that fast settles its task normally and the coordinator is told why the lane is unsupervised. Reported by CodeRabbit on stablyai#13681.
|
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)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
Merge Risk: 🟡 Moderate · up to Supervised adopted dispatches can record incorrect terminal metadata if a handle is remounted during injection, while dry-run requests may bypass required flag validation. These bounded correctness issues require owner awareness and resolution or explicit acceptance before merge. 🚥 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.
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)
1232-1245: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winValidate
--supervisebefore the dry-run return.
--dry-run --supervisereturns successfully withsupervised: falsebecause Line 1233 returns before Line 1259 validates--inject. This violates the documented requirement that--superviserequires--inject.Move the validation before the dry-run branch. Add a regression test for
--dry-run --supervisewithout--inject.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ab548174-7499-49eb-9132-7ba502186f3f
📒 Files selected for processing (8)
skill-guides/orchestration.mdsrc/cli/args.tssrc/cli/bundled-skill-guides.tssrc/cli/handlers/orchestration.tssrc/cli/specs/orchestration.tssrc/main/runtime/orchestration/db.tssrc/main/runtime/rpc/methods/orchestration-adopted-dispatch-supervision.test.tssrc/main/runtime/rpc/methods/orchestration.ts
Included review availability: Your plan includes up to 10 reviews per rolling hour; 1 remains after this review.
--dry-run --supervise without --inject returned supervised:false and a preamble, so a preview said yes to a dispatch the real path refuses.
|
@coderabbitai the outside-diff finding on The The check needs nothing the dry-run branch does not already have: it reads only Regression test in it('rejects --supervise without --inject on a dry run too', async () => {
const task = db.createTask({ spec: 'work', runId })
await expect(
call('orchestration.dispatch', {
task: task.id, to: 'term_worker', from: 'term_coord',
run: runId, supervise: true, dryRun: true
})
).rejects.toThrow('--supervise requires --inject')
})All 770 tests under |
|
Tip For best results, initiate chat on the files or code changes.
✏️ Learnings added
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
orca orchestration dispatch --to <handle> --inject --superviserecords the same supervised worker thatworker-start --terminalrecords, so the wholeworker-*set works on an adopted pane. Without--supervise, nothing changes.Fixes part of #13678.
Evidence
Reproduced against the real RPC handlers on
upstream/main(fe0ab305c4), with an in-memory orchestration DB, a run bound toterm_coord, a ready task, andterm_workerreporting a running agent plus a stable pane and process incarnation:workerStartwrites adispatch_contextsrow and aworker_dispatchesrow;dispatchwrites only the first. Every verb that fails above keys on the second:worker-showandworker-readatorchestration-worker-control.ts:35and:170,worker-retainatorchestration-worker-release.ts:78, andworker-listthrough aJOIN worker_dispatchesatdb.ts:6147.worker-stopandworker-abandonalready have acontext_onlybranch for the same case, so two of six verbs handled it and four did not.The lane could not be repaired after the fact.
--retry-offails for a second reason on top of the task status: the retry guard requires a prior worker row, and an injected lane has none.This is the composition it breaks. On a machine where
worker-start's launch path is unreliable, you start the agent by hand in a pane you have proven is alive, then hand it the task withdispatch --inject. We ran a wave that way on 2026-08-10 (v1.4.176). It delivers the task and gives the Run a mailbox, and it leaves the coordinator recomputing every lane's state from artifacts on disk.Why the flag is opt-in
Making it unconditional would be a behavior change for existing callers, not a fix.
worker-stopon a supervised worker closes the agent terminal (orchestration-worker-stop.ts:113-123), whileworker-stopon an injected lane deliberately leaves the process alone. Flipping that silently would start closing hand-started panes for anyone following the documented low-level recipe inskill-guides/orchestration.md. #13678 discusses two further options — degrading theworker-show/worker-readread path, and unconditional supervision — that are still open. This PR only adds the choice.What it does, and does not, touch
Supervision runs after injection has already proven an agent is present and the pane has stable identity, and it is a record write alone. The agent terminal is never created, closed, waited on, or written to a second time — the tests assert
sendTerminalAgentPromptwas called once andcreateTerminal/closeTerminalnot at all.The adopted terminal is recorded with
externalownership, the same asworker-start --terminal, soworker-releasereportsretainedwith reasonexternal_terminaland never closes a pane the operator started.--superviserequires--inject; without it there is no proven agent to supervise.If the record write fails, the dispatch downgrades to unsupervised and reports
superviseErrorrather than failing. The preamble is already in the worker's input by then and cannot be recalled, so failing the call would report a delivered task as undelivered.Compatibility
Remote wire. Rule 1 of
docs/reference/remote-wire-compatibility.md:superviseis a new optional param andsuperviseda new optional response field. An old client ignores the extra field; an old host ignores the param. Because the dispatch params schema is permissive, an old host would drop--supervisesilently, so the handler reportssupervisedunconditionally and the CLI prints a warning when a--superviserequest comes back unsupervised. No new opcode, no protocol bump.Git providers, SSH, folder workspaces. No provider, path, or platform behavior is involved. The worktree id comes from
showTerminaland is nullable, so a folder workspace or a terminal without one recordsnull— the same columnworker-startalready leaves nullable. Host scope is carried through from the dispatch authority, so an SSH-hosted pane records the scope its authority reports.Existing behavior. Plain
--injectis byte-for-byte unchanged apart from the addedsupervised: falsefield.Test plan
New:
src/main/runtime/rpc/methods/orchestration-adopted-dispatch-supervision.test.ts, 8 cases — worker-show and worker-list report the adopted lane; the pane is not restarted or re-prompted; release retains the external terminal;worker_donesettles the adopted worker through the ordinary report path; plain--injectstays unsupervised;--supervisewithout--injectis rejected; a failed injection supervises nothing; a failed record write downgrades instead of throwing.pnpm typecheckfails identically on an unmodifiedupstream/mainin this environment (tsconfig.json(9,5): error TS5102: Option 'baseUrl' has been removed), so the per-project check above is the one that covers this diff.Bundled skill guides were regenerated with
config/scripts/generate-bundled-skill-guides.mjs --writeafter theskill-guides/orchestration.mdedit.Moved from #13681, same commits, same head SHA. That pull request was opened from an organisation-owned fork, and GitHub refuses maintainer pushes on org-owned forks even when
maintainer_can_modifyreportstrue— so a maintainer could not push a fixup to it, only ask or rewrite. This one is on a personal fork, where a maintainer push works.The review history stays readable on #13681: #13681