Skip to content

test: stop supervision-host fixture processes after each case - #10

Merged
VasanthAmana merged 3 commits into
merkensoft-iris:mainfrom
VasanthAmana:fm/firstmate-supervision-host-test-runtime
Oct 5, 2026
Merged

VasanthAmana merged 3 commits into
merkensoft-iris:mainfrom
VasanthAmana:fm/firstmate-supervision-host-test-runtime

Conversation

@VasanthAmana

@VasanthAmana VasanthAmana commented Oct 5, 2026 •

Copy link
Copy Markdown

Intent

Install a modern bash on this laptop with Homebrew.

That instruction, with the proper shell fix that follows from it, is the work this task unblocks: the shell fix is up as #9 (titled "fix(bin): run fm_exec_timed on bash 3.2 without BASHPID") and cannot get a CI verdict. One CI check, "Behavior portable serial 2", was cancelled at its 30-minute job cap on two attempts although every test step passed. The timing artifacts of CI run 37262811606 show why: shard 2 took 29m38s, of which one script, tests/fm-supervision-host (the test for the supervision host that arrived with the 5 Oct merge of upstream kunchenguid/firstmate, PR 8), took 25m56s (1,555,533 ms); the other 19 scripts in the shard total 3m41s. bin/fm-test-run.sh hints that script at 789,123 ms from a single sample, so the runner's model thinks the shard is fine. docs/fm-test-portable-shards.md says a lane at its bound needs a distribution or runtime fix, not a larger timeout, and tests/fm-ci-workflow.test.sh pins exactly three timeout tiers (5, 30, 75). A rebalance alone cannot fix it: any shard holding that script has a floor of about 26 minutes, and recording the measured time as the hint trips the runner's own 20-minute per-shard coverage guard. Until this is fixed no PR to this repository can rely on a green run.

What Changed

  • tests/fm-supervision-host.test.sh: added stop_registered_homes and a run_case wrapper, and every test case now runs through run_case. Parked hosts, arms and watchers from a finished case are stopped before the next case starts, instead of staying alive until suite cleanup. suite_cleanup reuses the same helper.
  • tests/fm-supervision-host.test.sh: the case test_claude_stop_hook_notifies_when_at_turn_downtime_write_fails now waits for the first cycle's status line to reach the Stop hook before it sends the close (see "Failed first CI attempt" below). No assertion or wait bound changed.
  • bin/fm-test-run.sh: changed the runtime hint for tests/fm-supervision-host.test.sh from 789123 ms to 498629 ms, the script's duration in this PR's CI run 37275607709.
  • docs/fm-test-portable-shards.md: the note on that script's hint now names that run, the 737269-1567419 ms range the unchanged file measured before, and that the new value has one sample.

Risk Assessment

✅ Low: Test-only reaping between cases plus a hint and doc refresh as instructed; the cleanup logic is sound, and the hint is explicitly provisional pending CI timing.

Testing

I ran the full supervision-host script, which drives real fixture hosts, watchers and arms, and all 73 cases passed with the per-case process reaping in place. The runner and workflow tests, the coverage guard and the doc audit also passed. The measured wall time was 10m13s here, slower than the author's 491 s because the machine was busy; it is still far below the 25m56s CI figure. I could not confirm the authoritative CI timing locally, and the doc says so and marks the hint as pending the first CI timing artifact.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Run the whole supervision-host script and see every case pass with per-case reaping ✅ pass live supervision-host-run.txt (73 ok, 0 not ok)
Refreshed 491100 ms hint keeps the runner's coverage guard and 20-minute per-shard bound passing ✅ pass live checks.txt (FM_TEST_COVERAGE ok)
The runner and workflow tests still pass and still pin the three timeout tiers ✅ pass live checks.txt (fm-test-run and fm-ci-workflow tests ok)
Doc update passes the doc audience check ✅ pass live checks.txt (fm-doc-audience-check: ok)
Authoritative CI runtime of shard 2 stays under its 30-minute cap ⏸️ untested no Only a CI run can give this number; the doc states the hint is a local macOS measurement pending the first CI timing artifact.
Evidence: supervision-host full run transcript

Source: supervision-host full run transcript

ok - host+hook: a successor closed before exit_to_main does not suppress the branch-outcome rewake
ok - host+hook: a successor that closes during a held engine turn does not suppress the branch-outcome rewake
ok - host+hook: a refused hand-back becomes a delivered failure notice
ok - host+hook: a refused hand-back on an announced handling marker becomes a delivered failure notice
ok - host: parked child-exit sampling uses ordinary half-second sleeps
ok - report surface: only the branch actor's current turn may report, and only on the tasks its wake names
ok - report surface: visible late outcomes queue a relay, while silent outcomes remain stored without a wake or note
ok - dispatch entry: the host reads branch eligibility, the offer rule, and the wake prompt from the Pi branch's own owner
ok - drain: BRANCH OUTCOMES runs on a Claude home by default and on another primary with the file, never with off, and never on Pi
ok - drain: captain outcomes come first, and routine overflow collapses into a count one drain clears
ok - drain: repeated captain outcomes collapse per task, and the byte cap presents only the run its acknowledgement covers
ok - drain: a long away window costs one short drain, captain outcomes collapsed per task and routine overflow counted, and nothing from it is shown again
ok - drain: the BRANCH OUTCOMES budgets count bytes, cutting multibyte summaries by whole characters in any locale
ok - drain: branch outcomes stay unread when a projection of the store fails
ok - drain: branch outcomes stay unread and the drain fails when jq is missing
ok - drain: branch outcomes stay unread when the drain cannot print them
ok - drain: a legacy backlog is presented with each outcome's age and a check-first instruction, never adopted
ok - drain: a keyed decision survives acknowledgement through a newer outcome for its task
ok - drain: an outcome carried across a switch off Pi comes back with its age, never adopted
ok - drain: an outcome nothing has shown is presented until acknowledged, and a repeated acknowledgement changes nothing
ok - drain: an outcome the host drain presented but main never acknowledged stays unprocessed across a switch to Pi
ok - drain: an outcome the host drain presented but main never acknowledged survives an outcome index repair
ok - host: an attended wake the branch may take is handled on the engine, and its routine outcome never wakes main
ok - host: an attended captain outcome wakes main once and stays in its drain until main acknowledges it
ok - host: a captain outcome recorded after the captain left waits for the return, then reaches main's drain
ok - host: a quiet record without its daemon is a present captain, so outcomes and decisions reach main
ok - host: an attended decision close stays main's exactly as the plain arm delivers it
ok - host: an off written while the host is parked sends the next attended close to main, naming the opt-out
ok - host: a main-only pass-through leaves the successor watcher running and the close undelivered for main
ok - host: an attended close whose main session cannot be identified reaches main and runs no engine turn
ok - host: a decision close accepted away whose turn starts attended still reaches main unchanged
ok - host: an attended close whose task turns main-only before its turn still reaches main unchanged
ok - host+hook: an attended main-only pass-through rewakes main and keeps its successor watcher
ok - host+hook: a captain outcome beside a quiet record rewakes the present captain with no away note
ok - host+hook: a Claude home without config/supervision-host runs the host at the default engine, and an off file restores the plain arm
ok - host+hook: a close that turns main-only at its turn rewakes main and keeps its successor watcher
ok - host+hook: failed at-turn downtime write notifies main despite a healthy successor
ok - host+hook: a successor close that lands during main's turn is delivered at the next turn end
ok - host+hook: the next park takes over the cycle a main-only pass-through left, so one arm owns it
ok - host+hook: a park stopped mid take-over leaves the take-over to the next park
ok - host+hook: a successor that cannot be recorded is stopped, and main's next turn end arms a fresh cycle
ok - host: a primary with no verified dialog mirror keeps every attended close on main, and its away posture still runs
ok - host: each wake carries the captain's dialog since the last wake, without operational input
ok - host: the dialog mirror, its feed, and the wake file are owner-only
ok - host: dialog a turn never completed with its report (a park boundary, a stopped turn, no report) reaches the next turn
ok - host: an attended wake whose mirror is missing, cannot be read (at the feed or at the prompt), or holds a malformed entry reaches main before any engine turn, and the cursor stays put
ok - host: an away wake is handled on the engine through the branch contract and never reaches main
ok - host: an engine turn that records no outcome hands its durable wake to main
ok - host: a captain return during an engine turn hands that turn's outcomes to main
ok - host: silent outcomes are excluded from both captain-return handoff paths
ok - host: an early visible outcome survives more than 1,000 same-turn receipts
ok - host: an outcome lookup failure forces a visible main handoff
ok - host: an outcome recorded after the return reaches main even when its host dies at the turn's end
ok - host: a killed predecessor's engine is reaped and the next host removes its turn files
ok - host: a turn that reports but leaves its granted rows queued hands the wake to main
ok - host: a captain return during a failed engine turn still hands that turn's outcomes to main
ok - host: an engine turn whose result is incomplete hands its wake to main
ok - host: two engine errors latch the session, main keeps every away wake in the cooldown, a failed probe doubles it up to its cap, and a report recovers it silently
ok - host: an attended close in a latched session reaches main as the arm printed it and leaves the latch as it was, and a home that opted out with off never reads it
ok - host: attended, two engine errors latch the session, main keeps every close unchanged in the cooldown, a failed probe doubles it up to its cap, and a routine probe's recovery stays in the ledger, off main
ok - host: an engine turn is bounded, and tool processes outside its process group are reaped
ok - host: a restarted host stops, by recorded identity, the cycle a killed predecessor left running
ok - host: the park ends itself with a boundary wake and a stopped watcher
ok - host: waiting closes cannot carry the park past its boundary
ok - host: a close whose margin runs out while the successor starts reaches main at the boundary without a turn
ok - host: the park's test clock is inert without the test marker
ok - host: a park at or beyond the Stop-hook registration falls back to the default boundary
ok - host: an owner's later park limit lets a turn outlive the boundary, and no other limit does
ok - host: the first cycle's status streams once, --restart replaces a stale watcher, and an owner predecessor makes a handling successor
ok - host: an unchanged held outcome reaches the captain once across cadences, and a later decision on the task still does
ok - host: a home naming an unverified engine hands every away wake to main with the reason
ok - host: a host outside the session-lock owner stands down without arming
ok - host: a host under a superseded auto-arm generation stands down without touching the owner
bash tests/fm-supervision-host.test.sh  204.52s user 316.82s system 85% cpu 10:13.18 total
Evidence: coverage, runner, workflow and doc checks

Source: coverage, runner, workflow and doc checks

FM_TEST_COVERAGE ok total=247 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=207 serial_shards=9 serial_unhinted=5 serial_max_ms=1074843 serial_budget_ms=1200000 herdr=16
Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3
Ignoring racc-1.7.3 because its extensions are not built. Try: gem pristine racc --version 1.7.3
ok - Herdr CI family-run step times out at 20 min under a 75 min job backstop
ok - aggregate-json merges lane timing artifacts
Ignoring racc-1.7.3 because its extensions are not built. Try: gem pristine racc --version 1.7.3
Ignoring ffi-1.16.3 because its extensions are not built. Try: gem pristine ffi --version 1.16.3
Ignoring racc-1.7.3 because its extensions are not built. Try: gem pristine racc --version 1.7.3
ok - Herdr keeps a 20 minute step tripwire under a 75 minute job backstop
fm-doc-audience-check: ok surfaces=119 local_links=734

Measured Runtime

CI, per-script duration_ms from each run's fm-test-timing-portable-serial-* artifacts and job wall times from the job records:

Before (run 37262811606) After (run 37275607709, attempt 2) After (run 37282667129, final head)
tests/fm-supervision-host.test.sh 1555533 ms (25m56s) 498629 ms (8m19s) 498890 ms (8m19s)
Shard 2, sum of scripts 1776433 ms, 20 scripts 992811 ms, 25 scripts 985229 ms, 25 scripts
Shard 2 job cancelled at the 30-minute cap (29m38s of scripts) 16m52s 16m47s

The before run and attempt 2 drew the same slower runner class: the first 22 cases take the same time in both, and the later cases stop inflating (the three latch cases took 126 / 80 / 157 s before and 29 / 17 / 33 s after).
In the final run the nine serial shards' script sums range from 801895 to 1065821 ms and their jobs from 13m44s to 18m08s, so no serial shard is above 20 minutes.
The hint is the first CI sample (498629); the final run's 498890 ms is a second sample 261 ms above it.

Why it was slow: fixture processes left alive by finished cases.
Sampled every 20 s during a local run of the unchanged script: 24 alive at case 33, 56 at case 44, and 80-92 during the last cases, all released only at suite exit.
After the change, a listing 0.3 s after each case found 0 left after every one of the 73 cases.
In CI job logs of the unchanged script (ours and six upstream runs of the identical file, 737269-1567419 ms), cases 1-30 cost about 0.75-1.1x their local time and cases 45-70 about 1.5-4.5x, so the slowdown followed position in the script.

Same machine (macOS, Apple M3 Max), whole script unless noted:

Condition Before After
Run alone, all 14 cores 563.5 s 491.1 s
Clamped to the 4 efficiency cores to stand in for a small loaded runner, cases 1-41 608.4 s 455.5 s
Same clamp, cases 33-41 only 321 s 157 s

There is no whole-script before number under the clamp: one run was stopped after case 41 and a second failed case 42 on a wait bound while another workload shared the machine.
The clamped after run completed all 73 cases in 1585.6 s; it contained one unexplained 224 s outlier on one case that five targeted reruns did not reproduce.

Failed first CI attempt

Attempt 1 of "Behavior portable serial 2" in run 37275607709 failed one case, hook write failure: the Stop hook did not finish.
In that case the host exits 1 without printing the close, so the Stop hook can tell it from a host that died only by the first cycle's watcher: started line, which the host passes on at a roughly once-a-second check.
When the close arrives before that check, the hook sees empty output, runs the park a second time, and delivers its failure notice about 31 seconds later, past the case's 25-second wait.
The leftover processes this PR removes had been slowing the first close enough to hide that ordering: no case of this script fails in any of upstream's 55 failed serial-shard jobs since 27 Sep.
Forcing the ordering on macOS reproduced it (hook exit after 37.2 s on its second attempt, assertions still passing with a longer wait); with the fixture wait added, the same forced ordering exits on the first attempt in 9.1-9.4 s, 3 of 3 runs.
The natural ordering was not observed on a Linux runner, so the link to runner speed is inferred from that reproduction and the history.
The product behaviour on that path (a delayed notice when the status line was not passed on first) is unchanged by this PR.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ⚠️ tests/fm-supervision-host.test.sh:191 - The intent requires that the 25m56s supervision-host script stop dominating shard 2 so the lane fits its 30-minute cap, and the runner's 789,123 ms hint is described as misleading. The change only reaps each case's host, arm and watcher processes between cases. Nothing in the diff shows the script's runtime actually drops, and the stale 789123 hint in bin/fm-test-run.sh:859 is untouched. If the slowness comes from the script's own sleeps or polling rather than CPU contention from leaked processes, shard 2 still times out. The remedy is a measured before/after runtime and a hint update, which needs the author's decision. It also has to stay under the 20-minute per-shard coverage guard.
  • ℹ️ tests/fm-supervision-host.test.sh:205 - The change is mechanically sound. run_case reaps the registered homes and then truncates HOMES_FILE. The EXIT trap still reaps the final case's homes, and a failing case under set -e still hits the trap. Each home pid is signalled exactly as before, so no cross-case home reuse is broken. Per-home kill-wait loops of up to 5s add a small amount of serial time per case.

🔧 Fix applied.
1 info still open:

  • ℹ️ bin/fm-test-run.sh:859 - The hint (491100 ms) is a local, unloaded macOS number, while CI ran this script 1.5-4.5x slower than local in later cases. The doc states it is provisional pending the first CI timing artifact. The shard packer may under-weight this script until it is corrected from that artifact, which is already planned in this run.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Run the whole supervision-host script and see every case pass with per-case reaping ✅ pass live supervision-host-run.txt (73 ok, 0 not ok)
Refreshed 491100 ms hint keeps the runner's coverage guard and 20-minute per-shard bound passing ✅ pass live checks.txt (FM_TEST_COVERAGE ok)
The runner and workflow tests still pass and still pin the three timeout tiers ✅ pass live checks.txt (fm-test-run and fm-ci-workflow tests ok)
Doc update passes the doc audience check ✅ pass live checks.txt (fm-doc-audience-check: ok)
Authoritative CI runtime of shard 2 stays under its 30-minute cap ⏸️ untested no Only a CI run can give this number; the doc states the hint is a local macOS measurement pending the first CI timing artifact.
  • bin/fm-test-run.sh --check-coverage (ok, serial_max_ms=1074843 under the 1200000 per-shard budget)
  • bash tests/fm-test-run.test.sh
  • bash tests/fm-ci-workflow.test.sh (three timeout tiers still pinned)
  • bin/fm-doc-audience-check.sh (ok)
  • bash tests/fm-supervision-host.test.sh run end-to-end: 73 ok, 0 not ok, 10m13s wall on this loaded host
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

tests/fm-supervision-host.test.sh left every case's parked host, watcher
arm, watcher, and fake harness session running until suite cleanup. More
than 80 of them were alive by the last cases, each polling once or twice a
second, so on a CI runner's few processors every later case ran two to four
times slower than the same case run early. The script measured between
737269 ms and 1567419 ms on unchanged code across upstream's own runs, and
1555533 ms in the run that cancelled portable serial shard 2 at its
30-minute cap.

Each case now runs through run_case, which stops the homes that case
registered before the next case starts. No case, assertion, wait bound, or
timeout changes.
…ot update the PR body, so that is still to do. - **Test fix:** In `tests/fm-supervision-host.test.sh` I added the `hook_saw_first_cycle` helper next to `hook_exited`. `test_claude_stop_hook_notifies_when_at_turn_downtime_write_fails` now waits on it before `append_status`, so the first cycle's status line reaches the Stop hook before the close. No other case, assertion or wait bound changed. - **Hint:** The hint in `bin/fm-test-run.sh` is now `tests/fm-supervision-host.test.sh 498629`, taken from the CI timing artifact. Nothing else under `bin/` changed. - **Doc:** In `docs/fm-test-portable-shards.md` I replaced the four hint sentences with the current-facts version you specified. The "local macOS measurement" and "will be corrected" sentences are gone. - **Local checks:** `bash tests/fm-supervision-host.test.sh` printed only `ok` lines in its last three lines of output. I did not count the 73 cases. I did not reproduce the original failure after the fix. `--check-coverage` is ok at 1074843 ms against its 1200000 ms per-shard budget. `tests/fm-test-run.test.sh`, `tests/fm-ci-workflow.test.sh` and `bin/fm-doc-audience-check.sh` all passed. - **PR body:** I didn't edit it. It still needs the CI before/after numbers and the failed-attempt explanation. I'm leaving it to the outer executor because it is outward-facing
@VasanthAmana
VasanthAmana merged commit b9b5b89 into merkensoft-iris:main Oct 5, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant