Repository navigation
test: stop supervision-host fixture processes after each case - #10
Merged
VasanthAmana merged 3 commits intoOct 5, 2026
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: addedstop_registered_homesand arun_casewrapper, and every test case now runs throughrun_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_cleanupreuses the same helper.tests/fm-supervision-host.test.sh: the casetest_claude_stop_hook_notifies_when_at_turn_downtime_write_failsnow 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 fortests/fm-supervision-host.test.shfrom 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.
Evidence: supervision-host full run transcript
Source: supervision-host full run transcript
Evidence: coverage, runner, workflow and doc checks
Source: coverage, runner, workflow and doc checks
Measured Runtime
CI, per-script
duration_msfrom each run'sfm-test-timing-portable-serial-*artifacts and job wall times from the job records:tests/fm-supervision-host.test.shThe 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:
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: startedline, 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.
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.
bin/fm-test-run.sh --check-coverage(ok, serial_max_ms=1074843 under the 1200000 per-shard budget)bash tests/fm-test-run.test.shbash tests/fm-ci-workflow.test.sh(three timeout tiers still pinned)bin/fm-doc-audience-check.sh(ok)bash tests/fm-supervision-host.test.shrun end-to-end: 73 ok, 0 not ok, 10m13s wall on this loaded host✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.