Repository navigation
test: fix host-dependent test preconditions - #87
Merged
Merged
Conversation
…ually assert Four scripts failed or silently voided their own case depending on the host, independently of any change under test. fm-remote-secondmate-lifecycle-e2e and fm-remote-job-orphan-reap were broken preconditions. fm-remote-entrypoint.sh runs a remote command under the composed operator PATH, a fixed list of well-known install locations that deliberately ignores the caller's PATH, so a runner whose tasks-axi lives under a user-level npm prefix made every remote fm-fleet-snapshot.sh call fail its own dependency check; the fixture now publishes tasks-axi and node on the remote code root's bin the way tests/fm-remote-backlog-handoff.test.sh already does. The orphan reap fixture required ppid 1, but orphans reparent to the nearest child subreaper, so a systemd --user manager or a container init voided that whole case; it now asserts the property the leak needs, that the worker outlived its launching shell and sits outside the test's own process tree, which the reap condition itself never depended on. fm-spawn-worktree-settle measured wall-clock seconds as a proxy for poll cycles. The identical two-read path takes about two seconds idle and seventeen on a saturated host, so a five-second budget failed under load without the loop behaving differently. It now counts pane_current_path reads, which the fake tmux already records: two for an already-settled pane, three when one stale read precedes it. That count is load-independent and strictly stronger - an extra confirming cycle now fails at four reads, where four seconds passed the old budget. fm-backend-herdr-presentation-e2e is not fixed here. It passed alone in 479s and inside a full-suite run in 548s, so its reported failure is intermittent and load-dependent rather than a broken assertion, and no sound category can be assigned without a reproduction.
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
Four test scripts failed on every full-suite run in this environment regardless of what changed, costing real time on every task: two separate workers each stopped to investigate them as possible regressions of their own work.
tests/fm-backend-herdr-presentation-e2e.test.sh
tests/fm-remote-job-orphan-reap.test.sh
tests/fm-remote-secondmate-lifecycle-e2e.test.sh
tests/fm-spawn-worktree-settle.test.sh
Evidence they are pre-existing: two independent branches with entirely unrelated changes - one moving procedure sections out of the always-loaded instructions, one fixing a status-line key parser - produced the SAME failing set in full-suite runs on 2026-08-31. Neither branch touches any of those files. fm-remote-job-orphan-reap was already known to arrive broken from the upstream template: its precondition silently voids its own subject wherever orphaned processes do not reparent to init.
Why this was worth fixing rather than remembering: a permanently-red test is worse than no test, because it trains every worker to skip a whole failing family, which is exactly how a real regression in one of those areas would get waved through. Three of the four cover remote second mates, Herdr presentation, and worktree settling, where a silent break is expensive.
The task: for each of the four, establish which of three categories it is and act accordingly.
Report which of the three each one turned out to be, with the evidence. Confirm the alone-versus-suite difference for each of the four before concluding.
Constraints accepted and applied:
What was found and done, per test:
tests/fm-remote-secondmate-lifecycle-e2e.test.sh - BROKEN PRECONDITION, fixed. It failed alone too, not only in a suite: 19 cases passed and 'fleet snapshot did not select the remote structured-home projection' failed, aborting the remaining 7. Instrumenting the suppressed stderr of the remote summary call showed 'fm-fleet-snapshot: tasks-axi not found', rc=1. fm-remote-entrypoint.sh runs the remote command under fm_remote_job_compose_operator_path, a fixed list of well-known install locations (~/.local/bin, nvm/asdf/mise, /opt/homebrew/bin, /usr/local/bin, /usr/bin, /bin, ...) that deliberately ignores the caller's PATH, and this runner's tasks-axi lives at ~/.npm-global/bin. In GitHub Actions npm -g installs to /usr/local/bin, which IS on that list, so the case passes in CI and fails on a developer machine with a user-level npm prefix. The fixture already installs a fake tmux and a herdr fixture into the remote code root's bin, which the child PATH resolves first; it simply never published tasks-axi there. Fix: symlink tasks-axi and node into the remote code root's bin, which is exactly what the sibling tests/fm-remote-backlog-handoff.test.sh already does, plus matching top-of-file skip guards. All 26 cases now pass.
tests/fm-remote-job-orphan-reap.test.sh - BROKEN PRECONDITION, fixed. It also failed alone. The failing line was a precondition, '[ "$(ppid_of "$WORKER")" = 1 ]', reporting 'the fixture worker is not orphaned to init, so this case does not reproduce the leak'. On this host systemd --user (pid 276) is a registered child subreaper, so orphans reparent to it and never reach pid 1; the same is true under any systemd user session or a container init. bin/fm-remote-job-reap-orphans.sh states in its own header that the reap condition is exactly fm_remote_job_root_is_live failing for the root named in the worker's command line, with no dependence on the adopting parent, so ppid 1 was never the property under test. Fix: assert the property the leak actually needs - the worker outlived the shell that started it and is not a descendant of the test's own process tree - via a small is_descendant_of helper, and correct a now-inaccurate pass label that still said 'at ppid 1'. All 7 cases now pass.
tests/fm-spawn-worktree-settle.test.sh - BROKEN PRECONDITION, fixed. It passed alone (11.8s) and failed under load. Its second case asserted wall-clock seconds, [ "$elapsed" -le 5 ], as a proxy for 'not an extra full poll cycle'. A standalone probe reproducing the same fixture while the machine was busy measured the identical two-read path at 17s, against a recorded quiet-machine baseline of 4598ms for the whole script - the margin was already near zero when idle. Fix, and deliberately NOT a longer budget: count the pane_current_path reads the settle loop performs, which the fake tmux already records. The loop sleeps once per read, so that count IS its cycle count and is identical on an idle and a saturated host - exactly 2 reads for an already-settled pane, exactly 3 when one stale read precedes it. The new assertion is strictly stronger than the one it replaces: an implementation regression that adds one extra confirming cycle now fails at 4 reads, where 4 seconds passed the old 5-second budget. That red state was demonstrated by temporarily patching bin/fm-spawn.sh to require an extra confirming poll and observing the new assertion fail, then restoring the file clean.
tests/fm-backend-herdr-presentation-e2e.test.sh - NOT REPRODUCED, deliberately not changed, reported as follow-up. It passed alone in 479s and passed again inside a full-suite run in 548s, only 14% slower. So on today's evidence it is not permanently red in this environment; its reported failure is intermittent and load-dependent rather than a broken assertion, and no sound category can be assigned without a reproduction. No skip, no timeout change, and no speculative fix was applied to it. Reproduction conditions for a follow-up: run it alone under heavy synthetic CPU load and capture the failing case; the structural candidates noticed while reading it are fm_herdr_lab_provision's fixed 60-second wait for the lab server to report running, which the test triggers repeatedly through stop/reprovision cycles, and fm_backend_herdr_pane_idle_shell_pid's fixed ~1-second idle-shell settle budget (10 polls x 0.1s), either of which a saturated host can widen past its bound.
A short durable note was added to CONTRIBUTING.md's testing section stating the general rule these three shared: a behavior assertion must pin the property it names rather than a host-dependent proxy for it, because a wall-clock budget, a ppid of 1, and a tool resolving on the caller's PATH each hold on one machine and silently void or fail the same case on another.
Artifact-style constraint for this pipeline: pipeline-authored risk rationales, fix summaries, and PR bodies must use role-neutral prose with no second person and no captain, user, firstmate, or crewmate role nouns. This constraint does not apply to product code, prompts, or user-facing copy.
What Changed
Risk Assessment
✅ Low: The changes are confined to correcting three host-dependent test preconditions and documenting the shared testing invariant, while the unreproduced intermittent Herdr failure remains explicitly unchanged for follow-up.
Testing
The three corrected tests passed independently while directly demonstrating remote dependency publication, adopted-orphan reaping, and deterministic pane-read settling; the unchanged Herdr test passed independently on Herdr 0.8.0, and all four then passed together through the canonical runner with zero failures or skips. No visual artifact was captured because these changes affect CLI/process test behavior rather than a rendered UI; end-user-visible command transcripts and timing JSON were preserved instead.
Evidence: Selected four-test suite transcript
Evidence: Selected suite timing results
Evidence: Herdr presentation standalone transcript
Evidence: Remote orphan reaping standalone transcript
Evidence: Remote second-mate lifecycle standalone transcript
Evidence: Worktree settle standalone transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
Inspectedgit diff 00aa3a0f173fdbf368acfe70aaadc7666c41d648..8769b254341da61081ad247b322092d187abb137to confirm scope and acceptance intent.tests/fm-remote-job-orphan-reap.test.shtests/fm-spawn-worktree-settle.test.shtests/fm-remote-secondmate-lifecycle-e2e.test.shtests/fm-backend-herdr-presentation-e2e.test.shbin/fm-test-run.sh --json /tmp/no-mistakes-evidence/01M1EV5V36V9MZHPZX51SWYDFN/four-tests-selected-suite.json tests/fm-backend-herdr-presentation-e2e.test.sh tests/fm-remote-job-orphan-reap.test.sh tests/fm-remote-secondmate-lifecycle-e2e.test.sh tests/fm-spawn-worktree-settle.test.shVerifiedgit status --shortremained empty after testing.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.