The hard-killed #70 loop case waits for its detach and reads its tail until gone (martha#248) #275

Manually merged
terra merged 0 commits from vesta/248-hard-killed-loop into main 2026-11-27 01:15:05 +00:00
Member

Purpose (flake class): two races in the "#70 a hard-killed run's loop is ended by the next run" case, each able to red a loaded box with a message that blames the code rather than the case.

The detach race. The loop starts as setsid … &; the shell writes $! as soon as the fork returns, before the child calls setsid. The case waited only for the file, then killed the group and asserted the loop survived. Under load the child may not be scheduled inside that window, the group kill takes the loop, and the case reds with "the loop went with the killed run, so this check proves nothing". A new processGroupOf(pid) (stat field 5, or undefined when /proc no longer holds it) and untilInASessionOfItsOwn(loop, group) wait, bounded by the file's own look idiom, until the loop's group is no longer the run's, and fail by name naming the group it is in now.

The tail read. After the next run's sweep the case waited a fixed WAIT_MS and read the loop once. That fixed wait is replaced by the existing bounded untilGone helper.

The hard-killed case's own timeout. { timeout: THE_CASES_TIMEOUT_MS } is given to the hard-killed case too, so with #222's widened tear-down bound a broken run fails by name rather than by the runner's 60 s cancellation.

Proof. The whole npm test on this exact tip: 5610 tests, 5572 pass, 0 fail, 38 skipped, 518 s, the hard-killed case among them; two mutated runs (the detach dropped, the sweep's kill dropped) red by name. npm run verify passes. .github/workflows is 0 bytes against the post-268 main, and the private check is clean on both ranges.

Found on the way and filed, not done here: martha#261 (theLoopAt's t.after kills by number with no identity check).

Refs #248

Purpose (flake class): two races in the "#70 a hard-killed run's loop is ended by the next run" case, each able to red a loaded box with a message that blames the code rather than the case. **The detach race.** The loop starts as `setsid … &`; the shell writes `$!` as soon as the fork returns, before the child calls `setsid`. The case waited only for the file, then killed the group and asserted the loop survived. Under load the child may not be scheduled inside that window, the group kill takes the loop, and the case reds with "the loop went with the killed run, so this check proves nothing". A new `processGroupOf(pid)` (stat field 5, or undefined when /proc no longer holds it) and `untilInASessionOfItsOwn(loop, group)` wait, bounded by the file's own look idiom, until the loop's group is no longer the run's, and fail by name naming the group it is in now. **The tail read.** After the next run's sweep the case waited a fixed `WAIT_MS` and read the loop once. That fixed wait is replaced by the existing bounded `untilGone` helper. **The hard-killed case's own timeout.** `{ timeout: THE_CASES_TIMEOUT_MS }` is given to the hard-killed case too, so with #222's widened tear-down bound a broken run fails by name rather than by the runner's 60 s cancellation. **Proof.** The whole npm test on this exact tip: 5610 tests, 5572 pass, 0 fail, 38 skipped, 518 s, the hard-killed case among them; two mutated runs (the detach dropped, the sweep's kill dropped) red by name. `npm run verify` passes. `.github/workflows` is 0 bytes against the post-268 main, and the private check is clean on both ranges. Found on the way and filed, not done here: martha#261 (`theLoopAt`'s `t.after` kills by number with no identity check). Refs #248
TEAR_DOWN_DEADLINE_MS was RUN_DEADLINE_MS, the deadline a wrapped command gets before the run is called hung. But
the tear-down runs only after the command has ended, and it may give that session two graces of its own
(THE_COMMANDS_SESSION_ENDS_MS each) before what is left is killed; and a process SIGKILLed under a full suite can sit
in uninterruptible sleep until the kernel lets it go. Job 24229 consumed the whole of the old bound (30354 ms) where
the same case takes 277 ms on a quiet box.

The wait is now twice the command's deadline, and the case carries a timeout above that wait, so a process that
outlives it fails by name instead of being cancelled by the runner. A failed check now names the process's kernel
state and prints what the run said, so the next instance says which of those it was. With the tear-down's kill
dropped, the case reds by name at 60278 ms — and the hard-killed-loop case beside it too.
The loop starts as `setsid … &`, and the shell writes its pid as soon as the fork returns — before the child has
called setsid. The case then killed the run's group at once and asserted the loop had survived, so on a loaded box the
kill could take a loop that had not left yet (red as "the loop went with the killed run", which is the check saying it
proved nothing). It now waits, bounded, until the loop's process group is no longer the run's, and fails by name if it
never leaves.

The tail after the next run's sweep read the loop once after a fixed wait; it now waits bounded, the shape the
neighbour took in martha#222. With the detach dropped the case reds by name at the wait (5248 ms); with the sweep's
kill dropped it reds by name at the tail (30474 ms).
THE_CASES_TIMEOUT_MS is what martha#222 gave the loop case: above the run's deadline, the tear-down behind it, and one
more deadline, so a case that would hang fails by its own name inside the job rather than as a bare timeout with no case.
The hard-killed case makes the same waits — the run's, its tear-down's, then the next run's — so it takes the same room.
terra manually merged commit 61ec8da029 into main 2026-11-27 01:15:05 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
martha-ai/martha!275
No description provided.