Repository navigation
feat(daemon): observe-only fork gate for automatic terminal restores - #27424
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
📥 Commits
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to No merge-blocking issue is established; this observe-only change is ready for normal checks. Pre-merge checks |
|
6529db5 to
de52e1b
Compare
ELI5
When Orca reconnects to a host, it can restart many saved agent sessions at once. Nothing on the host keeps count, so a big restore can start far more processes than the machine can handle. This PR adds a counter at the one place where a terminal process is actually started. For now it only watches and writes down what it would have done. It never slows down or blocks anything.
What Changed
spawn-admission-observedto the daemon log whenever the policy would have made a restore wait, held it back, or refused it.Mechanism:
src/shared/host-spawn-admission.tsis a pure, clock-injected policy. Defaults: 3 automatic restores in flight, 1 per second with a burst of 3, and 8 automatic sessions alive. A user resume gets its own small per-client budget. It is shared code so that other execution owners can reuse it.createOrAttachTerminalSessionthat is about to fork, after the live-session attach andattachOnlyreturns. Attach and agent-session adoption are never charged.Why
This is the observe-only first step of the headless-serve restore budget (#10493: a restore storm that started thousands of processes). The design puts the gate at the creation branch rather than in the main process, because only that branch knows a process is about to be created. The main process cannot tell an attach from a cold restore, and its count would reset whenever it restarts. Shipping the counting first lets us check the 3 / 1 per second / 8 defaults against real logs before anything waits or is deferred. Enforcement, the client "restore paused" state, and the crash pause come in follow-up PRs.
Linked Issue
Refs #10493 (first step; does not close it)
Visual Proof
N/A: observe-only. No user-visible behavior changes; the only output is new daemon log lines.
Testing
src/shared/host-spawn-admission.test.ts: inference, pacing, concurrency, the per-client user-resume budget, and pause/pressure/live-cap deferral for callers that negotiated it. Callers that did not are never deferred and are refused only at critical pressure. A seeded model test (M-1) checks the pacing and live-cap invariants over random arrivals.src/main/daemon/terminal-spawn-gate.test.ts: through the realTerminalHost. Every restore is still admitted while would-wait decisions are counted. An attach is never charged. A session exit frees its live slot. A throwing fork frees its in-flight slot. A plain shell is not counted.pnpm tc,pnpm lintandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
Notes
wsl.exeforks on the Windows daemon, so they are counted there. No platform-specific code is involved.Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck, and focused tests pass locally; CI covers the rest