test(host-kit): hold the deadline clock until the shell ignores the first signal

Merged
TH
3d ago
+174-88

Summary

Each deadline test in exec-kill-settle.test.ts started its timer at spawn. Under load, the deadline fired before the shell reached the step under test:

  • The escalation test: before trap '' TERM.
  • The pipe-holder test: before the holder pid was recorded ("the pipe holder never recorded its pid").
  • The three exited-child tests: before the child exited, which silently moved them onto another path.

This is the sibling of #4039.

Fix: fake only setTimeout/clearTimeout; the child stays real. Each test advances the clock once the child reports its step (stdout or exit).

  • Escalation: a child.kill spy (via onSpawn) records [SIGTERM] at the deadline and at grace−1 ms, then [SIGTERM, SIGKILL] at the grace. The child dies by SIGKILL.
  • Pipe holder: it writes finished just before exit. A missing marker at settlement means settlement came before close. A pid probe could see an unreaped zombie.

No production change. 1 file.

Validation (head 87fbd5af3f)

  • sleep 1 before the pid write: base 4025dfb7b3 fails; head passes.
  • Exit-not-settling plant (close only): the holder tests fail.
  • Kill-after-exit-not-settling plant: 3 exited-child tests fail. On base with a 0.5s exit delay, they pass.
  • Escalation plants (grace 0, SIGKILL-only, never, +1 ms): all fail.
  • Whole file 10/10 at load 110–130 (6 extra yes processes).
  • pnpm check:affected --run --head 87fbd5af3f: 6/6 checks passed, exactCommit=true.

🤖 Generated with Claude Code