Repository navigation
feat(daemon): pace automatic terminal restores on headless hosts - #27428
Conversation
6529db5 to
de52e1b
Compare
982bd76 to
a92fcb5
Compare
a92fcb5 to
f91e598
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to Headless hosts that reuse an existing daemon may not pace automatic terminal restores. Reconcile the daemon’s admission mode on adoption before merging, unless this limitation is explicitly accepted. Pre-merge checks |
|
ELI5
On a headless Orca host (
orca serve, or Orca running on an SSH machine), reconnecting a client can restart dozens of saved agents at once. With this PR the host restarts them a few at a time instead of all together. Shells you open yourself still start immediately.What Changed
Stacked on #27424, which added an observe-only gate. Review only the top commit.
orca serveand orcad, including orcad on SSH hosts): automatic restores pass through the gate inenforcemode. At most 3 are in flight at once, at 1 per second after a burst of 3.Mechanism:
DaemonLaunchPolicy.spawnAdmissionis set by the launcher:enforcewhenstate.isServeModeor in orcad,observeon desktop. It reaches the daemon as--spawn-admission enforceon the daemon's own command line, not as an environment variable, because the daemon's environment becomes every shell's environment.TerminalSpawnGate.admitreturns synchronously when no wait is needed, so an unpaced fork keeps today's timing against the host's shutdown fence. When it does wait, the creation re-checks the shutdown fence and cancellation afterwards.spawnIntentonPtySpawnOptionsand on the daemoncreateOrAttachpayload. Nothing sets it yet. When present, it lets the host answerterminal_spawn_deferred:<reason>(paused, live cap, pressure, or deadline) instead of pacing. The follow-up client PR sets it and keeps the pane sleeping when it gets that answer.terminal_spawn_refusederror. It is deliberately not the "Daemon temporarily unavailable; reconnect" message: main treats that message as "daemon gone" and would replace a healthy daemon. Nothing produces critical pressure yet; the growth breaker PR adds it.Why
This is the restore budget for #10493 (a restore storm forked thousands of processes and panicked the machine), applied where it is safe today.
Linked Issue
Refs #10493
Visual Proof
N/A: no UI change. On a headless host, automatic restores after a reconnect now appear over a few seconds instead of all at once.
Testing
terminal-spawn-gate.test.ts(enforce):terminal_spawn_deferred:live_cap, and is admitted once a live one exits;daemon-pty-adapter-spawn-intent.test.ts:spawnIntentreaches the daemon payload and is absent when not declared. The launcher flag is parsed, and any other value means observe.pnpm tc,pnpm lintandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
Notes
docs/reference/remote-wire-compatibility.md):spawnIntentis an optional field.wsl.exeforks on the Windows host's daemon, and are paced there. No platform-specific code.Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck, and focused tests pass locally; CI covers the rest