refactor(host-kit): settle deadline races via settleWithin with R87 race ratchet
Summary
Moves the daemon's deadline-settle helper into host-kit; all daemon deadline races now use it. 15 files touched; 334 insertions / 115 deletions.
settleWithin(work, timeoutMs)inpackages/host-kit/src/internal/retry.tsbesideDeadline/sleep, exported via the existing@agent-device/host-kit/retrysubpath. Typed outcome{ kind: 'settled', value } | { kind: 'deadline' }; doc comment states it does not cancel the work; the deadline timer is cleared on every settle path. Additive only.- Daemon-local
settleWithinBudgetremoved; all deadline races usesettleWithin(server-shutdown.ts,daemon-runtime.ts,provider-lease-expiry.ts,daemon-session-idle-expiry.ts). Non-deadline races untouched (abort race, TTL timers,process-exit.ts). - New layering ratchet R87:
Promise.race(count per package must not grow past the merge-base (rule +LAYERING_RULES+ unit test).
BEFORE: daemon-owned helper + 4 hand-rolled race blocks; Promise.race( in packages/daemon = 5, each relying on manual clearTimeout. AFTER: one host-kit primitive; daemon count = 1 (non-deadline abort race); R87 blocks regrowth. SIZE: removes 4 race blocks + 1 bespoke timer, adds 1 helper + gate. PERF: deadline timers can no longer outlive settled work. COLLOCATION: deadline settling sits with the other deadline machinery in host-kit. No wire impact.
Validation
Tested SHA: 9bdc4eb854e4c8cdb2237c5d841873ee652e4e03. check:affected --run --head receipt run-EfSWzy/receipt.json (exactCommit: true, base eeff795f47): format, lint, typecheck, layering (R87 OK), build, package, vitest-related + 8 more passed; unit failed only — Base-blocked (same pnpm test:unit on unchanged base fails 145 tests under current host load; here 5-8, all in untouched files, green in isolation). Focused: host-kit 674 passed (4 new tests); 18 daemon suites 157 passed; layering/package/production-exports/lint/typecheck green; pnpm format run (daemon races 5 -> 1, repo 45 -> 41). CI owns full coverage, device lanes (none needed), provider integration. Risk: unit needs a green rerun on a quieter host.
![Autofix with [code]smith](https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark-3x.png)
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.