Repository navigation
Conversation
…d pane handle Refs #29. fe79e4d made worker-start's agent_readiness wait follow the same process when a session-graph reload remints the new pane's handle. The upstream merge de99ccc ("takes upstream's orchestration wholesale") dropped its wiring: local-worker-start went back to waitForWorkerAgentReady and the custody-row rebind DB method was removed, leaving waitForWorkerAgentReadyRebinding with no caller. A reminted handle again failed the start with terminal_handle_stale and left the created terminal behind. Restore the wiring: worker-start waits through waitForWorkerAgentReadyRebinding, and on a same-incarnation remint moves the creation custody row and the start's handle to the new one. Another process, no handle, or a second stale answer still fail the start as before. No schema change.
… readiness Refs #29. orchestration.federationAttachStart waited for the agent on the original handle, so a session-graph reload that reminted the pane failed the attach with terminal_handle_stale, the same failure fixed for local worker-start. It now waits through waitForWorkerAgentReadyRebinding and carries the same process's new handle into the attachment stage, authority and dispatch input. Custody is created after readiness there, so no row moves. Also asserts the reminted-start test's result shape before its annotated cast, and notes why the local custody rebind may match no row.
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
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. |
This was referenced Nov 13, 2026
Owner
Author
|
Superseded by #61. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When Orca starts a worker agent it waits for the agent to be ready. Sometimes Orca reloads its internal terminal list during that wait and hands the same terminal a new ID, so the wait fails with "terminal handle stale" and the worker never gets its task. An earlier fix for this existed, but a later upstream merge deleted the code that used it. This puts that fix back.
What Changed
Before:
orca orchestration worker-start(and the remote attach start) could fail atagent_readinesswithterminal_handle_stalewhen a session-graph reload re-issued the pane's handle mid-wait. The Task was never injected and the freshly created terminal was left behind.After: the wait follows the same pane and process to its new handle, waits once more, and carries on. The worker's custody record and setup stage move to the new handle, so later steps and failure cleanup use the live one. A different process, no handle, or a second stale answer still fails the start as before.
Mechanism:
waitForWorkerAgentReadyRebinding(already in the tree, but with no caller since merge de99ccc removed the original wiring from fe79e4d) is called again.worker-start-agent-readiness.tscalls it and re-binds the custody row through the restoredrebindWorkerTerminalResourceHandle;local-worker-start.tsuses it.federation.ts,orchestration.federationAttachStart): same wait via the helper, reassigning the handle before the setup outcome is saved. No DB rebind, because custody is created after readiness on that path.Why
The helper and its unit tests already existed, so restoring the original wiring is the smallest change and needs no new behavior. The remote attach path had the same unrebound wait, so it is fixed in the same change rather than left as a sibling copy of the bug. Retrying only the stale wait on a new handle for the same process is safe; a replacement process is never adopted.
Linked Issue
Fixes #29
Visual Proof
N/A: backend orchestration runtime change, no UI or interaction change.
Testing
Ran on macOS (Darwin) in a dedicated worktree off
fork/main. I could not reproduce the failure against a live Orca; the evidence is the git history, a code trace, and a mocked-harness test.pnpm tc: exit 0.pnpm test src/main/runtime/rpc src/main/runtime/orchestration src/main/runtime/terminal --maxWorkers=2: exit 0, 593 files passed, 2814 tests passed.ORCA_CODE_QUALITY_BASE=4ecd5364fe9 pnpm check:changed --force: exit 0, 26 of 26 checks passed.Revert check: with
local-worker-start.tsreverted to base, the new testreminted panefails (expected 'failed' to be 'ready'); restored, it passes.The remote attach change has no test: no existing federation test drives its readiness wait cheaply.
I manually tested these changes locally. Not ticked: no live Orca reproduction; verified through tests and a trace.
Automated tests added/updated, or explained why not below. One test added for the local start; none for the remote attach (see above).
Every added test fails without this change and avoids the test anti-patterns
Risk
Low to medium. It touches the worker-start readiness path, which every worker launch uses, but the new branch runs only when the wait already failed with
terminal_handle_stalefor a pane whose process is unchanged. The remote attach path is untested beyond review and typecheck. If wrong, a start that would have failed stale could instead bind to the wrong handle; the rebind only matches the same Dispatch, old handle and process. Back it out with a plain revert; no data or settings are migrated. Known and not changed: if the second wait itself throws after a confirmed remint, the custody row stays on the old handle (same as the original fix).Level: Low
Review
Two independent full-branch reviews. Round 1 found a failing quality gate (bare type cast in the new test) and the remote attach sibling; both fixed. Round 2 was clean with only optional nits (no test for the DB guard or federation path).
Agent skill upstream boundary
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). Ranpnpm tc, scoped tests andcheck:changed; full lint/build left to CI.