test(host-kit): wait for the shell's trap before aborting in kill-settle tests
Summary
Fixes a load flake in exec-kill-settle.test.ts. The graceful-abort test slept a fixed 100 ms and then aborted. The child shell installs its TERM trap on its own schedule, and nothing ordered the two. Under heavy load (load average ~50), SIGTERM landed before the trap existed. The shell then died without writing released. The production path (killProcessTree: SIGTERM, then SIGKILL after the grace) is correct.
Fix: the shell writes a ready marker after it installs the trap and starts its holder. The test polls for that marker (bounded at 2 s) and races it against command settlement, so an early exit fails at once with a clear message. No retries, no timeout changes, and every assertion is kept. 1 file touched, test-only.
The adjacent deadline/escalation test has the same assumption (trap in place before 400 ms). A marker can't fix it: the deadline timer starts at spawn inside runCmd, so the test cannot hold the signal back. I left it unchanged.
Validation
Tested SHA d4fa3eb346, base 9e4bc2d80b.
- Planted race (
sleep 1beforetrap): base fails with ENOENT onreleased; this head passes. - Planted production bug (
killProcessTreesends SIGKILL first): this head still fails (ENOENT onreleased). pnpm exec vitest run packages/host-kit/src/internal/exec-kill-settle.test.tsĆ10: 10/10 pass.pnpm check:affected --run --head d4fa3eb346: 6/6 pass (format, lint, typecheck, layering, fallow, vitest-related),exactCommit=true.
CI owns the full unit and coverage jobs.
š¤ Generated with Claude Code