Repository navigation
refactor(cli): extract the serve supervisor's after-exit decision into a pure policy - #27446
Conversation
|
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 4 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This refactor moves the serve supervisor's exit decision into a separate tested policy function. No behavior change or merge-blocking risk was identified. Pre-merge checks |
|
ELI5
When
orca serveruns under a service manager, a small CLI process watches the real server process and decides what to do when it exits: exit too, explain a crash, or wait for an update and start the new version. That decision was mixed into the code that spawns processes and reads files. This PR moves the decision into its own small, pure function so the upcoming restart rules (backoff, crash-loop brake) can be tested on their own. Nothing changes for users.What Changed
src/cli/runtime/serve-supervisor-policy.ts:decideAfterServeChildExit({ exit, expectedHandoff, handoff, hasHandoffPath })returnsexit,fail-replacement,signal-exitorawait-install.superviseForegroundServekeeps only the I/O. It waits for the child, reads the handoff file (only in the cases that read it before), records failures, waits for the bundle, and respawns. It then acts on the decision.Why
This is step B2 of the headless-serve design, and it comes before any behavior change. The owner's decision Q5 adds a
--supervisemode with jittered backoff and a durable crash-loop brake. Doing that inside an I/O loop would make the rules hard to test exhaustively. A pure policy allows model tests over random exit sequences. The orcad launch path already reuses this loop, so it inherits the same contract.Linked Issue
Refs #10493 and #14541 (groundwork for the supervised mode; no behavior change)
Visual Proof
N/A: refactor with no behavior change.
Testing
serve-supervisor-policy.test.ts: covers the following.src/cli/runtimesuites pass unchanged (206 tests), including the macOS supervisor/update-handoff tests inlaunch.test.ts.pnpm tc,pnpm lintandpnpm run check:code-quality:changedpass.Review
Agent skill upstream boundary
Notes
Checklist
N/Afor visuals with reasonpnpm lint,pnpm typecheck, and focused tests pass locally; CI covers the rest