test(coding-agent): cover the shutdown recovery path per call site (senpi#3067 L5)
Summary
Fixes L5 of #3067 only (test gap for the shutdown-level recovery). L1 is #6118, L2/L3/L4 are untouched, so this PR does not close #3067. Test-only change, no production code touched.
What changed
- New
packages/coding-agent/test/suite/regressions/3067-shutdown-call-sites.test.ts: one test per call site that can throw before the child is signalled (or right after its stop), each showing the child still receives SIGTERM, then SIGKILL, and is reaped, and shutdown still exits 1 with the generation left intact (by design: an unobserved child exit leaves its generation, pointer and settings intact):drain.stopthrows (!childStopStartedpath — the recovery reaps the child);stopWatchersthrows after the child stop;clients.destroyAllthrows after the child stop.
RED → GREEN
The tests drive real performShutdown with a real SIGTERM-ignoring child and fake timers for the 5 s + 30 s waits (plus a real event-loop turn per slice, so the SIGKILLed child's exit is actually observed — without it the mocked 30 s kill wait fires first and the recovery reports the exit unobserved). Test-only, so there is no pre-fix code failure to show: these are the missing coverage, not a bug fix.
Tests
- New:
3067-shutdown-call-sites.test.ts— 3 passed. bun run check(oxlint, fmt, tsc, locks) — exit 0.- Local changelog gate (
node scripts/check-pr-changelog.mjs --base <merge-base>) — PASS (no runtime source changes detected, no fragment needed for a test-only PR).
Out of scope
L2 (wall-clock steps / /proc ticks), L3 (once-per-generation logging), L4 (recovery error chaining, #6144) — left for follow-ups.
Notes
- AI 协助说明:本 PR 由 AI 助手协助撰写,测试与核查如正文所示。
- CLA:待用户本人签署。
Summary by cubic
Adds missing test coverage for the shutdown recovery path in performShutdown (L5 of #3067), with two gradations: drain.stop throwing before the child is signalled (where the recovery reap drives SIGTERM then SIGKILL), and stopWatchers or clients.destroyAll throwing after the ordinary child stop. Each test drives a real shutdown with a SIGTERM-ignoring child under fake timers and asserts the child is signalled SIGTERM, then SIGKILL, is reaped, and shutdown exits 1 with the generation left intact. The tests also pin each call site's position in the failure sequence and verify the stop intent distinguishes the recovery reap from the ordinary child stop. Test-only change; there is no fix to exercise, so these tests just document the expected behavior.