`a_worker_reaped_while_its_tree_is_walked_is_never_missed` fails about one run
in five on the dev Mac, always the same way:
assertion `left == right` failed: setup: the server and its 60 idle children
left: 62
right: 61
Not load, and not the behaviour under test — the setup. The perl server's
worker is
if ($p == 0) { print "$$\n"; my $x = 0; $x += $_ for 1 .. 150000; exit 0 }
so it prints its pid *before* doing its work. `ask("warm up")` returns as soon
as that line is read, which is while the worker is still running, still the
server's child, and not yet reaped. The next line walks the tree and finds 62
members. The comment above it said "the tree is quiet before the first span",
and that is the part that was not true; load only widens the window.
So the setup waits for the shape it asserts instead of asserting it on the
first walk, through a `settled_tree(root, want)` in the same idiom as this
file's `quiet()` — poll, return when it matches, panic after 20 s naming the
tree it last saw. The test's own assertions are untouched, and the guard still
fails the test if the tree never settles, so nothing here is weakened: a walk
that cannot find the shape still stops the run.
Measured on this host: 2 failures in 5 runs before, 12 passes in 12 after.
The file's three other tree-count assertions were checked and are sound —
their workers are long-lived (the awk blocks on `getline`), or the walk
happens before any request, so there is no transient child to catch.
Found while replicating `macos-energy-backend` locally for #183; it is the
only failure in that job and it is unrelated to that PR, which touches
`mesh/` alone.
Co-Authored-By: Claude Opus 5 <[email protected]>