Repository navigation
Conversation
Behavior portable serial 2: every case in tests/fm-supervision-host.test.sh left its parked host, successor watcher, and fake main session running until the suite's EXIT trap, so late cases competed with dozens of earlier polling processes. run_case now stops and forgets each case's registered homes when the case ends. Behavior tests (Herdr), presentation e2e: the concurrent-recovery case resumed two homes without --herdr-resume-lock-wait, so the loser refused after the default 5 s wait whenever the winner's hold outlasted it. Both resumes now opt in to the wait, which is what the case claims to prove. The test cleanup also makes the read-only git-hooks strip directories writable before rm. Behavior tests (Herdr), focus-flash Part C: the non-vacuity check needs the concurrent sampler to land in the short wrong-focus window after the explicit close. The test's CLI wrapper now holds the operation after the close until the sampler has recorded a non-anchor sample, bounded to 5 s. Behavior timing aggregate: the Herdr artifact uploads several paths, so its timing JSON keeps a nested fm-test/ directory after the merged download and the flat glob skipped it. The aggregate step now uses globstar.
|
Speaking as Kun's firstmate: thanks @jroethel, this is a welcome one. Serial 2 timing out inside What I checked (tip CI: first-time fork run. I reviewed the diff (tests plus that one glob line, with no secret, network, or trigger change) and approved CI 38145664592 and Require no-mistakes 38145664579 / 38145829649. Contract-class: restore. Tests and CI plumbing only, and no product default path changes. The aggregate step was already meant to cover every lane but missed the nested Herdr JSON. VISION: aligns on all seven rules. It's test and CI infrastructure, which supports "field incidents become regression coverage" and adds no captain-facing surface, vendor coupling, or authority change. Next step: waiting on CI. One note: this PR edits |
… write failure: the Stop hook did not finish` in tests/fm-supervision-host.test.sh. The suite stopped at test_claude_stop_hook_notifies_when_at_turn_downtime_write_fails. The cause is a timing race in bin/fm-supervision-host.sh, not this PR's run_case teardown. The failing case alone, with a fresh home each run on 2 cores, failed within two iterations. Invariant: the host's output contract says the first cycle's `watcher: started|attached` line reaches the owner on every exit. Every exit that isn't a death therefore has at least one line of output. The owner reads empty output as "host died". await_close only streamed that line while it polled a live arm (once per second). If the arm closed inside one poll window, the line stayed in ARM_TEXT, and only emit() would print it. The at-turn `pass-through downtime-unrestored` path exits 1 without calling emit(), so the output was empty. The Stop hook (bin/fm-claude-stop-autoarm.sh) then retried. A second host took over the successor and stayed parked, and the hook never returned the "auto-arm FAILED" notice the case expects. When the poll won the race, the line was printed and the case passed. Fix, at the one shared boundary every exit path reads through: await_close now calls stream_ready_line once more after the arm has exited, if the line is still pending. The existing code then drops it from ARM_TEXT, so the output bytes are the same in both orderings. The other exit paths (emit, exit_to_main, boundary_exit, stand_down) are unchanged. Verification: - With the fix, the failing case passed 10/10 in a loop on 2 cores (taskset -c 0,1). Before the fix it failed by the second iteration. - `shellcheck -x bin/fm-supervision-host.sh` is clean. - Every suite that drives the host passed: fm-supervision-host 75/75, fm-claude-stop-autoarm 59/59, fm-pi-watch-extension 60/60, fm-cursor-primary 30/30, fm-omp-harness 16/16, fm-supervision-instructions 12/12, fm-watch-checkpoint 8/8. I removed the scratch test file I used to reproduce the failure, and a stray bin/bin symlink one of my scratch runs created. The only change left is bin/fm-supervision-host.sh
|
Speaking as Kun's firstmate: thanks @jroethel. Head Contract-class: restore (unchanged). The first-cycle status line is already specified output, and the rest is test and CI race fixes. VISION: all seven rules align. Status: waiting on CI. Once CI and no-mistakes are green, this goes to Kun to merge directly. It edits |
Intent
Captain picked this to start now from the Bearings board (2026-10-10): offer the fork's CI race fixes to upstream kunchenguid/firstmate.
Recorded plan for this item: jroethel/firstmate PR 13 (Herdr recovery lock wait and focus-flash sampler race, d0ad4f8) and PR 14 (supervision-host per-case teardown, 4aea099); upstream main also flakes (2 of its last 20 runs failed); kunchenguid requires PRs raised via the no-mistakes pipeline; bundle merge-multi-waiver (aa08e3b) and ci-aggregate-herdr-glob (1dc669c) since both are done.
Known since: the fork took upstream's own resume lock-wait default (#6649) over PR 13's lock-wait change, and tests/fm-backend-herdr-focus-flash-e2e.test.sh no longer differs from upstream main.
The captain has approved offering this branch upstream (Bearings board, 2026-10-11).
What Changed
tests/fm-supervision-host.test.sh: each case now runs through a newrun_casewrapper that callsstop_registered_homesright after the case finishes. That stops each home's parked host, watcher cycle, and fake main session, then clears the homes file. Before, they kept polling until suite exit and competed for CPU with later cases, so on two-core runners those cases woke too late for their waits.fm-backend-herdr-focus-flash-e2e.test.sh, on a stealing release the stubbed CLI now pauses briefly afterpane close(up to about 5s). It waits until the focus sampler records a non-anchor sample, so the non-vacuity check no longer depends on how the sampler and the close interleave.fm-backend-herdr-presentation-e2e.test.sh, both concurrent-recovery spawns now pass--herdr-resume-lock-wait, so the second one waits for the session lock instead of being refused after the short default wait.chmod -R u+wbeforerm -rf, so the read-only git-hooks strip directories that spawn leaves behind can be deleted..github/workflows/ci.yml: the timing-aggregate step turns onglobstarand matches**/fm-test-timing-*.json. The Herdr lane's timing JSON sits in a nestedfm-test/directory after the merged artifact download, and the old pattern missed it.Risk Assessment
✅ Low: The change touches only tests and CI: all 75 supervision-host cases are wrapped in run_case with none missed, both concurrent resumes opt in to the documented --herdr-resume-lock-wait flag, the focus-flash hold is bounded and still requires a real non-anchor sample, and the globstar glob matches both the flat and nested timing JSON without duplicates.
Testing
I ran all four changed areas against the real code: focus-flash e2e on herdr 0.9.3 (3 runs) and on an isolated copy of the CI-pinned 0.7.4 (5 runs plus 40 stress runs, all passing); the full presentation e2e on 0.7.4 (25/25 ok in 555s, test temp dir removed, live default session untouched); a supervision-host comparison where leftover processes grow from 5 to 17 on base but drop back to 0-2 after each case on target; and the real CI aggregate step, which skips the nested Herdr timing JSON on base (lanes=1) and includes it on target (lanes=2). The focus-flash and lock-wait races did not reproduce on base locally, so those two are covered only by target passing. Per the earlier decision, I did not re-run the full supervision-host suite. This change has no UI, so there are no screenshots. All temp labs, servers, and drivers were torn down, and the worktree is clean.
Evidence: CI timing aggregate step, base vs target, on the merged-download layout
Source: CI timing aggregate step, base vs target, on the merged-download layout
base: FM_TEST_AGGREGATE lanes=1 total=1 (nested fm-test/fm-test-timing-herdr.json skipped) target: FM_TEST_AGGREGATE lanes=2 total=2 (Herdr lane included)Evidence: Supervision-host leftover fixture processes after each case, base vs target
Source: Supervision-host leftover fixture processes after each case, base vs target
base: 5 -> 8 -> 9 -> 11 -> 17 live fixture processes (accumulating) target: 0 -> 2 -> 0 -> 1 -> 0 live fixture processes all 5 cases pass on both; 0 survivors after suite exitEvidence: Presentation e2e on isolated herdr 0.7.4
Source: Presentation e2e on isolated herdr 0.7.4
ok - real Herdr lab: concurrent cross-home recoveries replace exact husks under one session lock with no focus drift 25 ok, exit 0 in 555s; TMP_ROOT fully removedEvidence: Focus-flash e2e on isolated herdr 0.7.4 (steal_live=1)
Source: Focus-flash e2e on isolated herdr 0.7.4 (steal_live=1)
Evidence: Focus-flash stress test, base vs target, 16 cores under load
Source: Focus-flash stress test, base vs target, 16 cores under load
Evidence: Focus-flash stress test, base vs target, 2 pinned cores under load
Source: Focus-flash stress test, base vs target, 2 pinned cores under load
Evidence: Focus-flash e2e on local herdr 0.9.3
Source: Focus-flash e2e on local herdr 0.9.3
Evidence these are real failures, and how this relates to other PRs
tests/fm-supervision-host.test.shon three PR runs within one day, each at a different case: run 37896148317 (hook write failure: the Stop hook did not finish), run 37940524033 (return-fail: the host did not hand the wake to main), and run 37993944190 (return: the host did not hand the late outcome to main).Pinned to two cores on a loaded host, unmodified main failed around case 34 (
hook quiet: the Stop hook never closed) after 8m18s; with this change all 75 cases passed (27m20s).concurrent secondmate recovery failed ... could not acquire its session lock; refusing a concurrent resume, followed byrm: cannot remove ... .git-hooks/...: Permission deniedfrom the test cleanup.fm-test/fm-test-timing-herdr.json, which the old flat glob misses and the globstar glob matches.Related open PRs:
tests/fm-supervision-host.test.shinto six suites so serial shards can spread it.It does not stop each case's processes at case end, so this change is complementary.
Whichever lands second needs a mechanical rebase, because the case runner and the cleanup move into the shared helper file;
run_caseandstop_registered_homeswould then live intests/supervision-host-helpers.shand apply to every sibling suite.If it lands, the
--herdr-resume-lock-waitflag on the two concurrent resumes here becomes redundant but harmless, and the other edits in this PR touch different code.This PR deliberately does not change the recovery lock-wait default (feat(bin): add opt-in --herdr-resume-lock-wait to fm-spawn #6649 added the opt-in and kept refuse-by-default).
Deliberately omitted: a repeatable
--allow-redinbin/fm-pr-merge.sh.It is a feature rather than a race fix, and open PRs #5224 and #5232 already propose it.
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/fm-backend-herdr-presentation-e2e.test.sh:308- The cleanup now runschmod -R u+w "$TMP_ROOT"beforerm -rf. This is a cleanup hygiene fix, not one of the three race fixes. It matches the existing pattern in tests/fm-extension-binding.test.sh:126 and tests/fm-secondmate-busy-contract-live-e2e.test.sh:39, it is harmless (chmod -R does not follow symlinks), and the commit message discloses it. It is noted only because it goes slightly beyond the intent's 'CI race fixes' scope. Under the standing en-route-defect policy no action is needed.✅ **Test** - passed
✅ No issues found.
bash tests/fm-backend-herdr-focus-flash-e2e.test.shx3 against local herdr 0.9.3 (steal_live=0)Installed the pinned herdr 0.7.4 withbin/fm-install-herdr.shinto a throwaway temp HOME/XDG/TMPDIR and started a throwaway defaultherdr serverthere, so the live default session at ~/.config/herdr was never touchedbash tests/fm-backend-herdr-focus-flash-e2e.test.shx5 on isolated herdr 0.7.4 (steal_live=1, so Part C runs the new hold-after-close path)Stress test: base vs target focus-flash, 20 runs each with 24 busy-loop CPU hogs on 16 cores, then 20 each pinned to 2 cores (taskset -c 0,1) with 4 hogs, on isolated 0.7.4bash tests/fm-backend-herdr-presentation-e2e.test.shon isolated herdr 0.7.4, then checked that the test's TMP_ROOT was fully removed and the live default session was unchangedSupervision-host driver: the base and target copies of tests/fm-supervision-host.test.sh, cut down to 5 loop cases, with a probe after each case counting live processes whose FM_HOME is under the suite TMP_ROOT; both drivers were built outside the worktreePulled the real 'Build aggregate timing summary' run block out of base and target ci.yml with PyYAML and ran it with RUNNER_TEMP pointing at a fake merged-download folder (top-level lane JSON plus nested fm-test/fm-test-timing-herdr.json), using lane JSONs produced bybin/fm-test-run.sh --json✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.