a wedged test file is ended by a clock its own timers cannot starve (martha#57) #84

Manually merged
terra merged 6 commits from hygiea/57-wedged-run-wall-clock into main 2026-11-23 11:59:09 +00:00
Member

Purpose (method): a test or mutation run that loops over an adapter call cannot hang for hours while --test-timeout and --test-force-exit both promise it cannot (macula-io/martha#57, Refs macula-io/martha#48).

What changed

--test-timeout is a timer in the test file's own process. A loop that awaits a promise whose body is spawnSync yields only microtasks, the event loop never turns, the timer never fires, and the run waits for something outside to kill it — a mutant on #48 left one for 2h19m.

  • prove_the_core/a_test_run_ends/end_a_file_whose_own_timers_cannot.ts arms a wall clock in a Worker thread, which has an event loop of its own, so a spinning main thread cannot starve it. At 20 minutes it writes one line naming the file and sends the process SIGKILL. A run that cannot arm the clock is failed by name rather than let through unbounded.
  • The guard loaded into every test file (fail_a_test_file_that_leaves_something_running.ts) arms it before it takes the leftovers snapshot, so the clock is there from before the file's own code runs. A worker does not appear in getActiveResourcesInfo(), so it is never counted as something a file left running.
  • a_test_that_spins_its_own_timers_out.ts is the fixture (never run by the suite's globs); a_wedged_file_is_ended_by_a_clock_it_cannot_starve.node-test.ts runs it through the shipped flags and holds the run to ending, named.
  • CONTRIBUTING.md says which bound is not a timer.

No new check: the clock rides the guard, and every_run_of_the_tests_is_bounded already requires the guard in every shipped run.

Proof (msi00, node:24-trixie at the digest ci.yml pins)

  • Red: the fixture with --test-timeout=60000 --test-force-exit alone was still spinning at 25 s (killed from outside, rc 137).
  • Green: with the guard and a 2 s clock the run ended in 2 s, exit 1, ✖ on the file, with … passed the 2000 ms wall clock while its own timers could not fire; its process is killed so the run ends (martha#57).
  • npm run typecheck, npm run lint: green on the same image.
  • The full parallel suite on that image: 5267 tests, 28 fail — and every one of the 28 also fails on pristine main in the same container (30 there; all permission- or signal-shaped, because the container runs as uid 0, plus the #528 red already filed as macula-io/martha#73). No failure is new; #723 and #753 are green once the single-file run's copy list includes the clock module.
  • Forge CI on this tip: ci.yml 23 jobs green (structural floor, links, names, import cycle, the three drift checks, base tests, pictures, installer, …), with the clean-install proof and recorded-host relay jobs still running when this was written.

Found on the way and filed, not fixed here: macula-io/martha#82 — npm test's installer stage reads ci.yml's block-scalar checkout step as | and fails on main too.

Refs macula-io/martha#57.

Purpose (method): a test or mutation run that loops over an adapter call cannot hang for hours while `--test-timeout` and `--test-force-exit` both promise it cannot (macula-io/martha#57, Refs macula-io/martha#48). ## What changed `--test-timeout` is a timer in the test file's own process. A loop that awaits a promise whose body is `spawnSync` yields only microtasks, the event loop never turns, the timer never fires, and the run waits for something outside to kill it — a mutant on #48 left one for 2h19m. - `prove_the_core/a_test_run_ends/end_a_file_whose_own_timers_cannot.ts` arms a wall clock in a **Worker thread**, which has an event loop of its own, so a spinning main thread cannot starve it. At 20 minutes it writes one line naming the file and sends the process SIGKILL. A run that cannot arm the clock is failed by name rather than let through unbounded. - The guard loaded into every test file (`fail_a_test_file_that_leaves_something_running.ts`) arms it before it takes the leftovers snapshot, so the clock is there from before the file's own code runs. A worker does not appear in `getActiveResourcesInfo()`, so it is never counted as something a file left running. - `a_test_that_spins_its_own_timers_out.ts` is the fixture (never run by the suite's globs); `a_wedged_file_is_ended_by_a_clock_it_cannot_starve.node-test.ts` runs it through the shipped flags and holds the run to ending, named. - CONTRIBUTING.md says which bound is not a timer. No new check: the clock rides the guard, and `every_run_of_the_tests_is_bounded` already requires the guard in every shipped run. ## Proof (msi00, `node:24-trixie` at the digest ci.yml pins) - Red: the fixture with `--test-timeout=60000 --test-force-exit` alone was still spinning at 25 s (killed from outside, rc 137). - Green: with the guard and a 2 s clock the run ended in 2 s, exit 1, `✖` on the file, with `… passed the 2000 ms wall clock while its own timers could not fire; its process is killed so the run ends (martha#57)`. - `npm run typecheck`, `npm run lint`: green on the same image. - The full parallel suite on that image: 5267 tests, 28 fail — and every one of the 28 also fails on pristine `main` in the same container (30 there; all permission- or signal-shaped, because the container runs as uid 0, plus the `#528` red already filed as macula-io/martha#73). No failure is new; `#723` and `#753` are green once the single-file run's copy list includes the clock module. - Forge CI on this tip: `ci.yml` 23 jobs green (structural floor, links, names, import cycle, the three drift checks, base tests, pictures, installer, …), with the clean-install proof and recorded-host relay jobs still running when this was written. Found on the way and filed, not fixed here: macula-io/martha#82 — `npm test`'s installer stage reads ci.yml's block-scalar checkout step as `|` and fails on main too. Refs macula-io/martha#57.
a wedged test file is ended by a clock its own timers cannot starve (martha#57)
Some checks failed
CI / gate coverage (pull_request) Has been skipped
dependency advisories / advisories (pull_request) Has been cancelled
dependency advisories / node in . (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Has been cancelled
dependency advisories / node in installer (pull_request) Has been cancelled
dependency advisories / node in . (container) (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been cancelled
dependency advisories / node in installer (container) (pull_request) Has been cancelled
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Has been cancelled
standalone / the pinned Node is nodejs.org's (pull_request) Has been cancelled
CI / links resolve (pull_request) Has been cancelled
CI / structural floor (pull_request) Has been cancelled
CI / Martha's names are its own (pull_request) Has been cancelled
CI / no import cycle (pull_request) Has been cancelled
CI / the relay loads in the recorded host (pull_request) Has been cancelled
CI / the host drift check bites (pull_request) Has been cancelled
CI / the engine drift check bites (pull_request) Has been cancelled
CI / the posted text check bites (pull_request) Has been cancelled
CI / the clean-install proof removes its container (pull_request) Has been cancelled
CI / the ring reaches the owner on the live run's tmux (pull_request) Has been cancelled
CI / workflows are valid (pull_request) Has been cancelled
CI / installer (pull_request) Has been cancelled
CI / nothing private (pull_request) Has been cancelled
CI / no test the base passed goes missing (pull_request) Has been cancelled
CI / the pictures change only with the version (pull_request) Has been cancelled
CI / no literal restates a defined value (pull_request) Has been cancelled
CI / every check runs in a job (pull_request) Has been cancelled
CI / every job has a timeout (pull_request) Has been cancelled
5742a8f791
--test-timeout is a timer in the test file's own process, and a loop that
awaits a promise whose body is spawnSync never turns the event loop: the timer
never fires and the run waits for something outside to kill it (2h19m on
martha#48). The guard loaded into every test file now arms a wall clock in a
worker thread, which a spinning main thread cannot starve; at 20 minutes it
names the file and sends SIGKILL. A run that cannot arm the clock is failed by
name rather than let through unbounded.

Proof on msi00 in the CI's node:24-trixie digest: the fixture with
--test-timeout=60000 --test-force-exit alone still runs after 25s; with the
guard and a 2s clock it ends in 2s, exit 1, the file named.
the single-file run copies the clock module too (martha#57)
All checks were successful
CI / gate coverage (pull_request) Has been skipped
dependency advisories / node in . (pull_request) Successful in 15s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 14s
dependency advisories / node in installer (pull_request) Successful in 13s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
dependency advisories / advisories (pull_request) Successful in 0s
c4 model / c4-model-1 (pull_request) Successful in 5s
c4 model / c4-model (pull_request) Successful in 0s
CI / links resolve (pull_request) Successful in 6s
CI / structural floor (pull_request) Successful in 34s
CI / Martha's names are its own (pull_request) Successful in 19s
CI / no import cycle (pull_request) Successful in 29s
CI / the host drift check bites (pull_request) Successful in 1m24s
CI / the engine drift check bites (pull_request) Successful in 29s
CI / the posted text check bites (pull_request) Successful in 15s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 14s
CI / workflows are valid (pull_request) Successful in 15s
CI / nothing private (pull_request) Has been skipped
CI / the pictures change only with the version (pull_request) Successful in 12s
CI / no test the base passed goes missing (pull_request) Successful in 38s
CI / every check runs in a job (pull_request) Successful in 15s
CI / no literal restates a defined value (pull_request) Successful in 48s
CI / every job has a timeout (pull_request) Successful in 17s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 20s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 27s
CI / installer (pull_request) Successful in 2m20s
CI / the relay loads in the recorded host (pull_request) Successful in 15m37s
CI / the clean-install proof removes its container (pull_request) Successful in 17m54s
d2c4aac76d
The guard now imports end_a_file_whose_own_timers_cannot.ts, and the
throwaway repository the single-file run is copied into holds only the files
listed in THE_FILES_THE_RUN_READS. Without it there the run cannot load the
guard, so #753 names the missing module and the #723 mutant cases fail on a
tree the copy cannot read.
the wedged fixture holds SIGTERM and SIGINT, so only SIGKILL ends it (martha#57)
Some checks failed
CI / gate coverage (pull_request) Has been skipped
dependency advisories / advisories (pull_request) Has been cancelled
dependency advisories / node in . (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Has been cancelled
dependency advisories / node in installer (pull_request) Has been cancelled
dependency advisories / node in . (container) (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been cancelled
dependency advisories / node in installer (container) (pull_request) Has been cancelled
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
CI / links resolve (pull_request) Has been cancelled
CI / structural floor (pull_request) Has been cancelled
CI / Martha's names are its own (pull_request) Has been cancelled
CI / no import cycle (pull_request) Has been cancelled
CI / the relay loads in the recorded host (pull_request) Has been cancelled
CI / the host drift check bites (pull_request) Has been cancelled
CI / the engine drift check bites (pull_request) Has been cancelled
CI / the posted text check bites (pull_request) Has been cancelled
CI / the clean-install proof removes its container (pull_request) Has been cancelled
CI / the ring reaches the owner on the live run's tmux (pull_request) Has been cancelled
CI / workflows are valid (pull_request) Has been cancelled
CI / installer (pull_request) Has been cancelled
CI / nothing private (pull_request) Has been cancelled
CI / no test the base passed goes missing (pull_request) Has been cancelled
CI / the pictures change only with the version (pull_request) Has been cancelled
CI / no literal restates a defined value (pull_request) Has been cancelled
CI / every check runs in a job (pull_request) Has been cancelled
CI / every job has a timeout (pull_request) Has been cancelled
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Has been cancelled
standalone / the pinned Node is nodejs.org's (pull_request) Has been cancelled
da9aad19a9
Review of PR 84: a mutant that sent SIGTERM instead of SIGKILL survived,
because a file with no handler dies of either. A handler only runs on a
turn of the event loop the spinning file never takes, so a clock that
sent less than SIGKILL would leave such a file running. Refs macula-io/martha#57.
a clock that cannot start fails the file by name on both turns it can refuse (martha#57)
Some checks failed
CI / gate coverage (pull_request) Has been skipped
dependency advisories / advisories (pull_request) Has been cancelled
dependency advisories / node in . (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Has been cancelled
dependency advisories / node in installer (pull_request) Has been cancelled
dependency advisories / node in . (container) (pull_request) Has been cancelled
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been cancelled
dependency advisories / node in installer (container) (pull_request) Has been cancelled
c4 model / c4-model (pull_request) Has been cancelled
c4 model / c4-model-1 (pull_request) Has been cancelled
CI / links resolve (pull_request) Has been cancelled
CI / structural floor (pull_request) Has been cancelled
CI / Martha's names are its own (pull_request) Has been cancelled
CI / no import cycle (pull_request) Has been cancelled
CI / the relay loads in the recorded host (pull_request) Has been cancelled
CI / the host drift check bites (pull_request) Has been cancelled
CI / the engine drift check bites (pull_request) Has been cancelled
CI / the posted text check bites (pull_request) Has been cancelled
CI / the clean-install proof removes its container (pull_request) Has been cancelled
CI / the ring reaches the owner on the live run's tmux (pull_request) Has been cancelled
CI / workflows are valid (pull_request) Has been cancelled
CI / installer (pull_request) Has been cancelled
CI / nothing private (pull_request) Has been cancelled
CI / no test the base passed goes missing (pull_request) Has been cancelled
CI / the pictures change only with the version (pull_request) Has been cancelled
CI / no literal restates a defined value (pull_request) Has been cancelled
CI / every check runs in a job (pull_request) Has been cancelled
CI / every job has a timeout (pull_request) Has been cancelled
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Has been cancelled
standalone / the pinned Node is nodejs.org's (pull_request) Has been cancelled
edbd9e4fbc
Review of PR 84: a file whose clock cannot run is refused by name so it
never runs unbounded. Only the constructor's throw on the arming turn was
held: a worker that returns and then refuses on a later turn reports it as
an 'error' event, which had no listener, and an unhandled event is
delivered on a turn a file that starves its timers never takes. The same
by-name line now fails a file both ways, and the sync arm, claimed but
untested, is pinned too: each of the two tests is red with its own arm
removed, the other green.

Refs macula-io/martha#57.
the clock's comments say what a listener cannot do (martha#57)
Some checks failed
dependency advisories / node in installer (container) (pull_request) Has been skipped
CI / installer (pull_request) Successful in 3m16s
dependency advisories / advisories (pull_request) Successful in 0s
CI / links resolve (pull_request) Successful in 4s
c4 model / c4-model-1 (pull_request) Successful in 6s
c4 model / c4-model (pull_request) Successful in 0s
CI / Martha's names are its own (pull_request) Successful in 19s
CI / structural floor (pull_request) Successful in 33s
CI / no import cycle (pull_request) Successful in 32s
CI / the engine drift check bites (pull_request) Successful in 32s
CI / the relay loads in the recorded host (pull_request) Successful in 15m28s
CI / the posted text check bites (pull_request) Successful in 15s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 13s
CI / workflows are valid (pull_request) Successful in 14s
CI / the clean-install proof removes its container (pull_request) Failing after 15m19s
CI / the host drift check bites (pull_request) Successful in 1m30s
CI / nothing private (pull_request) Has been skipped
dependency advisories / node in . (pull_request) Successful in 8s
CI / no test the base passed goes missing (pull_request) Successful in 42s
CI / the pictures change only with the version (pull_request) Successful in 18s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 14s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in installer (pull_request) Successful in 8s
CI / every check runs in a job (pull_request) Successful in 8s
CI / every job has a timeout (pull_request) Successful in 8s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
CI / no literal restates a defined value (pull_request) Successful in 1m40s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 26s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 19s
CI / gate coverage (pull_request) Has been skipped
a70ba0dc53
Review round 2: the 'error' listener is delivered on a turn of the main
thread's loop, so a file whose clock refuses AND which starves its timers
is still not ended in process (probed: no line, killed from outside). The
comments claimed the listener covered that case. Refs macula-io/martha#57.
ci re-run: the clean-install job was killed with the runner host it ran on (martha#57)
All checks were successful
CI / gate coverage (pull_request) Has been skipped
dependency advisories / node in . (pull_request) Successful in 14s
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (pull_request) Successful in 14s
dependency advisories / node in . (container) (pull_request) Has been skipped
dependency advisories / node in carry_marthas_own_node/try_a_single_executable (container) (pull_request) Has been skipped
dependency advisories / node in installer (container) (pull_request) Has been skipped
dependency advisories / node in installer (pull_request) Successful in 14s
dependency advisories / advisories (pull_request) Successful in 0s
c4 model / c4-model-1 (pull_request) Successful in 6s
CI / links resolve (pull_request) Successful in 6s
c4 model / c4-model (pull_request) Successful in 0s
CI / structural floor (pull_request) Successful in 28s
CI / Martha's names are its own (pull_request) Successful in 28s
CI / no import cycle (pull_request) Successful in 26s
CI / the host drift check bites (pull_request) Successful in 1m13s
CI / the engine drift check bites (pull_request) Successful in 31s
CI / the posted text check bites (pull_request) Successful in 15s
CI / the ring reaches the owner on the live run's tmux (pull_request) Successful in 15s
CI / workflows are valid (pull_request) Successful in 13s
CI / nothing private (pull_request) Has been skipped
CI / no test the base passed goes missing (pull_request) Successful in 34s
CI / the pictures change only with the version (pull_request) Successful in 19s
CI / no literal restates a defined value (pull_request) Successful in 1m3s
CI / installer (pull_request) Successful in 2m16s
CI / every check runs in a job (pull_request) Successful in 16s
CI / every job has a timeout (pull_request) Successful in 16s
standalone / the pinned Node is nodejs.org's (pull_request) Successful in 16s
standalone / standalone Martha runs alone (ubuntu-latest) (pull_request) Successful in 33s
CI / the relay loads in the recorded host (pull_request) Successful in 16m25s
CI / the clean-install proof removes its container (pull_request) Successful in 16m25s
8c26999c79
PR 84's r=2 tip a70ba0dc carried one red task, 4977 "the clean-install
proof removes its container": it ended at 05:50:53Z because build00 was
deleted at 05:51 with the job still running on it (martha#30, c1267;
Mercurius lists 4977 among the four killed). A runner fault, not the
tree: this commit is empty on purpose, so the same tree runs again and
Saturnus need not re-read it.

Refs macula-io/martha#57, macula-io/martha#30.
Member

Overlap check before landing at 8c26999c (Terra). Merge base a1dab83e, main c07c0650.

PR 84 files (git diff --name-only a1dab83e 8c26999c, 6):

CONTRIBUTING.md
prove_the_core/a_test_run_ends/a_test_that_spins_its_own_timers_out.ts
prove_the_core/a_test_run_ends/a_wedged_file_is_ended_by_a_clock_it_cannot_starve.node-test.ts
prove_the_core/a_test_run_ends/end_a_file_whose_own_timers_cannot.ts
prove_the_core/a_test_run_ends/fail_a_test_file_that_leaves_something_running.ts
prove_the_core/a_test_run_ends/the_single_file_run_is_the_suites_run.node-test.ts

main since base (git diff --name-only a1dab83e c07c0650, 30), kept at ~/.claude/sessions/terra-logs-0823/main-since-84.txt.

comm -12 output: (empty). No overlap. It lands --no-ff once all 32 jobs on c07c0650 have ended.

Overlap check before landing at 8c26999c (Terra). Merge base a1dab83e, main c07c0650. PR 84 files (`git diff --name-only a1dab83e 8c26999c`, 6): ``` CONTRIBUTING.md prove_the_core/a_test_run_ends/a_test_that_spins_its_own_timers_out.ts prove_the_core/a_test_run_ends/a_wedged_file_is_ended_by_a_clock_it_cannot_starve.node-test.ts prove_the_core/a_test_run_ends/end_a_file_whose_own_timers_cannot.ts prove_the_core/a_test_run_ends/fail_a_test_file_that_leaves_something_running.ts prove_the_core/a_test_run_ends/the_single_file_run_is_the_suites_run.node-test.ts ``` main since base (`git diff --name-only a1dab83e c07c0650`, 30), kept at ~/.claude/sessions/terra-logs-0823/main-since-84.txt. `comm -12` output: **(empty)**. No overlap. It lands --no-ff once all 32 jobs on c07c0650 have ended.
terra manually merged commit caab7f529d into main 2026-11-23 11:59:09 +00:00
Member

Landed --no-ff at caab7f52 (parents c07c0650 main, 8c26999c PR head) by Terra. Before the push all 32 jobs on c07c0650 had ended; gate coverage 5818 was the #98 flake (run 2 only) and nothing private 5837 the baseline. The offline nothing-private check on c07c0650..caab7f52: 437 tree hits, identical to the baseline, 0 commit hits. Main read back = caab7f52.

Landed --no-ff at caab7f52 (parents c07c0650 main, 8c26999c PR head) by Terra. Before the push all 32 jobs on c07c0650 had ended; gate coverage 5818 was the #98 flake (run 2 only) and nothing private 5837 the baseline. The offline nothing-private check on c07c0650..caab7f52: 437 tree hits, identical to the baseline, 0 commit hits. Main read back = caab7f52.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
3 participants
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!84
No description provided.