Repository navigation
feat(daemon): one automatic-restore budget per execution host - #27492
Conversation
8ab05d5 to
5a78f3e
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
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 The change makes automatic-restore limits shared across daemons on one host. No actionable merge-blocking risk is evident from the supplied context. Pre-merge checks |
|
0c98466 to
11a1d7f
Compare
ELI5
A desktop Orca and an
orca serveon the same machine each run their own terminal host. Until now each one had its own automatic-restore budget, so two of them could restore 16 agents at once, where the owner decided on 8 per machine. Now they share one budget, using the same small per-machine file that #27488 introduced for the terminal cap.What Changed
decideSpawnAdmission) is unchanged. It receives a merged view for that one decision, and accounting stays on each daemon's own state.terminal-spawn-host-share.ts, and the deferral error to its own file, to keep the gate small.Why
Decision Q1 says the budget is per execution host: a desktop and orcad on one machine share it. The ledger already gives each daemon one file it alone writes, with stale-holder recovery (a dead pid is deleted, an unrefreshed entry is ignored). Reusing it needs no lock, and no lock recovery after a crash.
Alternatives considered:
Accepted imprecision: two daemons deciding in the same millisecond can each take the last automatic slot, because the automatic budget is read and then published, not reserved first. This is bounded by one restore per extra daemon. It is a budget, not a safety ceiling; the ceilings remain #27488's terminal cap, which does reserve first, and the growth breaker. The merged rate bucket starts full 10 seconds back, so a sustained stream across daemons can get at most one extra burst; each daemon's own bucket still holds.
Linked Issue
Part of the headless-serve robustness work for #10493 (D1 step 4, decision Q1 "per execution host"). #27488 is merged; this PR is now based on main.
Visual Proof
N/A. This is host-side admission only; no UI changes.
Testing
Pure merge: unchanged state when no other daemon has work; another daemon's live restores hit the shared live cap of 8; a shared concurrency of 3; one rate budget across daemons; admits older than 10 s are forgotten; never more permissive than the daemon's own bucket.
Ledger: sums the automatic work other daemons publish, drops old admits, and reads a terminals-only entry from feat(daemon): cap terminals per execution host #27488 as zero.
Two real
TerminalHost+ gate pairs sharing one ledger dir (desktop and serve): 5 + 3 live restores defer the ninth withlive_cap, and one exit frees it; desktop and serve spend one burst; a waiter on serve gets through once the desktop releases its slots.pnpm tc,pnpm lint,oxlintandpnpm run check:code-quality:changedpass. The gate, ledger, guard and spawn-intent suites pass.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
Notes
SSH: each SSH host's daemons share that host's ledger; a client never reads it. The crash pause stays per daemon (its marker sits in its runtime dir). Pressure is already a machine-wide fact. Desktop stays in observe mode, but it still publishes its automatic work. So when the desktop already runs 8 or more resumed agents, an enforcing
orca serveon the same machine keeps its own declared restores asleep (live_cap). This is intended: the budget protects the machine, and restores the desktop already runs use it. Those panes keep their resume handle, a click resumes them, and an old client's restores are still only paced. A test pins this. Windows and macOS/Linux use the same file logic.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)