Repository navigation
feat(orcad): gate agent launches on readiness and refuse callers that leave while waiting - #35710
Conversation
… for departed callers requires: may read the parsed params, so terminal.create and session.tabs.createTerminal wait on accounts only when they start an agent; plain shells stay ungated. createAgentSession, ensureAgentSession, agentSession.create, agent.launch (unless it reuses a terminal), git.generateCommitMessage and the worker-launching orchestration methods also wait on accounts. The feature wait races the request signal and the connection close and refuses without running the handler.
An attach to an existing session is restore latency and needs no fresh account state; only kind 'explicit' may start an agent.
A startOrcad test that fails partway left latches closed, so later tests in the same worker could wait 10 s on a gated method.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
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 |
[Medium impact] The PR affects startup waits across agent-launch RPC workflows on orcad hosts. The PR appears safe to merge, with non-blocking fixes recommended for Git-helper coverage and the reset test. FindingsSummaryAdds parameter-based startup requirements for agent launches and cancels readiness waits when callers disconnect.
|
| export const GIT_COMMIT_MESSAGE_GENERATION_METHODS = [ | ||
| defineMethod({ | ||
| name: 'git.generateCommitMessage', | ||
| requires: ['accounts'], |
There was a problem hiding this comment.
git.generatePullRequestFields and git.discoverCommitMessageModels also prepare Claude/Codex account environments and start agent processes, but neither declares requires: ['accounts']. Add both to the gated set and its manifest test.
RPC starts after accounts today, so this is non-blocking. It leaves these launches unprotected when startup is staged.
| // The shared setup resets after every test; these two run in order in one worker. | ||
| it('may leave latches closed when a test stops partway', () => { | ||
| installOrcadFeatureReadiness() | ||
| expect(rpcMethodFeatureWait(['accounts'])).not.toBeNull() |
There was a problem hiding this comment.
This test starts a real 10-second wait and drops its promise. _resetOrcadFeatureReadinessForTests only replaces current; it does not settle that wait or clear its timer. If the worker remains alive, the abandoned promise rejects with runtime_unavailable after 10 seconds.
Keep the readiness handle, assert that the wait exists, then open accounts and await the promise. The readiness object can remain installed to test the shared reset.
Flag-off: No behaviour change, flag on or off. Every readiness latch still opens before orcad starts RPC (from #35571), so no call waits today. The desktop never installs a readiness.
User-risk: Very low.
ELI5
#35571 let an RPC method say "wait until this part of startup is done". This PR adds the same gate to everything that starts an agent: agents need their account setup. It also makes sure that if the caller goes away while waiting, the call is dropped rather than run for nobody. Today every gate opens before the first call, so nothing changes yet. These are prerequisites the reviewers asked for before any gate may open later.
What Changed
Requirements can now depend on a call's params.
requires:is nowOrcadFeatureRequirement<P>: either a fixed list or a function of the parsed params. The dispatcher resolves it from the admitted params. New fileruntime/rpc/agent-launch-feature-requirement.ts.What now waits on the
accountslatch:terminal.createandsession.tabs.createTerminal, only when they start an agent:agent,launchAgent,launchConfig,resumeProviderSessionorsourceChatForkis set, orcommandis recognised by the existingrecognizeAgentLaunchCommand. Plain shells and commands likelsare never gated.agent.launchandagent.launchReplay, unless they reuse a live terminal (reuseTerminal), which starts no process.terminal.ensureAgentSession, only forkind: 'explicit'. An attach (kind: 'automatic') restores an existing pane, and its latency is what the user sees on restore. This matches the WSL account-env classifier.terminal.createAgentSession,agentSession.createandgit.generateCommitMessage, always.orchestration.workerStartandorchestration.federationAttachStart, in addition toorchestration.A caller that leaves while waiting is never run.
options.signalagainst a new dispatch-onlyconnectionSignal.connectionSignalaborts when the connection closes and is never handed to handlers.runtime_unavailableand the handler never runs.accounts.subscribewould register close cleanup after the close already happened, and a unary mutation could run twice after the client retries.options.signalfrom its socket-close registration. The Unix-socket transport now passes its per-message disconnect signal asconnectionSignal(runtime-rpc-request-admission.ts), because short RPCs get no handler signal there.Test isolation.
config/scripts/vitest-orcad-feature-readiness-reset.ts, resets the module-level readiness after every unit test. AstartOrcadtest that fails partway can no longer leave latches closed and make later tests in the worker wait 10 s.Why
terminal.create. That method also opens plain shells, which must never wait for account setup.Linked Issue
Internal WSL cold-start work, option (c) "staged readiness". This follows #35571 and covers e9-reviewer's two prerequisites (gate every agent launch; cancel while waiting) and fix-reviewer's test-reset nit.
Visual Proof
N/A: no UI or behaviour change.
Testing
dispatcher-feature-readiness.test.ts:terminal.createruns at once while an agent one waits;ensureAgentSessionruns at once with every latch closed, while an explicit one waits;runtime-rpc-local-disconnect-forwarding.test.ts: a gated short RPC whose local Unix caller disconnects mid-wait is refused and never run. It fails without theconnectionSignalwiring.orcad-feature-readiness-manifest.test.ts: the exact gated set, plus the per-param cases (plain,ls,claude,codex,launchAgent,launchConfig, resume,reuseTerminal, ensureexplicit/automatic).orcad-feature-readiness.test.ts: latches closed in one test are open in the next, which proves the shared reset. It fails without the setup file.Full
src/mainrun with and without the setup file: 1054 s with and 1162 s without, with no new failures. The local-only failures appear in both runs or pass on re-run.runtime/rpcand orcad suites after rebasing onto main: the only failures also fail on main locally, plus one flaky search test that passes alone.Load rule:
pnpm tc,typecheck:ci,check:code-quality:changed, the anti-slop lint and the ast-grep gates.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
runtime_unavailable.ensureAgentSessionattach and plain shells stay ungated), so this needs two reviewers.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)