Repository navigation
test(bin): isolate behavior suites from the live fleet home - #3706
AgardnerAU wants to merge 18 commits into
Conversation
[Medium impact] The PR appears safe to merge; no actionable issues remain. Reviews (4) · Last reviewed commit: "Merge branch 'main' of https://github.co..." · Reviewed by Greptile |
256f645 to
b902c69
Compare
|
Rebased onto current The branch no longer conflicts. Conflicts resolved on the merits: the opt-in live-e2e suites that upstream refactored to source Three fixes were needed for suites and fixtures added upstream since this branch was written:
The previously red "Behavior portable parallel 2" job was not a test failure: it recorded Three suites fail identically on unmodified No test was weakened, skipped, relaxed or deleted. |
|
The workflow runs on this pull request are held at Could a maintainer release the held runs when convenient? Happy to rebase first if the base has moved far enough to matter. |
|
Merged current main into this branch (head a013d7f1978103b5d06d10ad50678aac287dbbf2); the only conflict was a docs/scripts.md table row. It is up to date with main and ready for CI - the fork workflow runs are waiting for maintainer approval. |
|
Speaking as Kun's firstmate: Thank you @AgardnerAU, and sorry these runs sat waiting on maintainer approval for so long. This is my first full triage pass on this PR. I read the whole thread and the diff of tip What I checked:
Where it stands:
Main is red this wake, so nothing merges right now. Once CI is green here and main is green, this goes to Kun as a merge-or-leave. Nothing more is needed from you unless CI turns something up. |
|
Merged current main into this branch (head d410d045). Two test files now source tests/lib.sh on main, so their conflicts took main's version, which already isolates. The isolation owner was also carried into one suite and three copied-runner fixtures that main added since the last update. The touched suites pass locally. Up to date with current main and ready for CI. |
|
CI note: 16 of 17 jobs pass on d410d045. The one failure, tests/fm-pi-primary-types.test.sh (TS2339: Property 'prompt' does not exist on type 'BeforeAgentStartEvent'), is already red on main's own CI at 6407052 and is outside this PR. |
|
Speaking as Kun's firstmate: thanks @AgardnerAU for the CI note. You're right. What changed since my stamp earlier today: nothing in the code. The head is still Heads-up on overlap: your #3026 and #3098 add the same Contract-class: new-default (test harness only), same as before. VISION.md: no change, all rules align. Status: waiting for main to go green. Once main is green, this goes to Kun to merge or leave. It won't auto-merge, and there's nothing waiting on you. |
|
This PR replaces #3026 and #3098. Both add the same |
d410d04 to
732a004
Compare
|
Speaking as Kun's firstmate: thank you @AgardnerAU for the refresh, and for carrying the isolation owner into every suite and fixture main added since October. Your note that this replaces #3026 and #3098 is recorded too. I re-read the tip Waiting on you for one thread: Greptile's new P2 on Contract-class: new-default (test harness only), unchanged. The product's unconfigured run is untouched, but serial and direct |
Firstmate exports the live home into a worker's environment, so a suite started from inside one inherits pointers at the real fleet records. On 2026-08-31 a full-suite run from a task worktree wrote four fake task records straight into this home's live fleet state. Only the two test runners cleared those pointers, and only inside the worker subshell they fork, so the clearing applied when a runner started a suite and not when one was invoked as `bash tests/<file>.test.sh`. Counted by resolved source path, 137 of 173 suites reach tests/lib.sh and 36 do not - but tests/lib.sh cleared nothing, so every suite was exposed on the direct path, not just the 36. Add bin/fm-test-env-lib.sh as the single owner of that pointer list, taken from the change already submitted upstream. Both runners and tests/lib.sh now call it once per process instead of keeping their own inline copies. The 36 suites that do not source tests/lib.sh call the owner directly: tests/lib.sh also brings reporters, ROOT and an EXIT trap, and all 36 already define at least one of those - 37 of them arm an EXIT trap, which bash would silently replace. tests/fm-test-env-lib.test.sh enforces the invariant so a new suite cannot skip isolation silently, and its matcher is checked against the substring error this area has made before: a suite whose only mentions are bin/fm-*-lib.sh must not count as isolated. Verified: tests/fm-gotmp.test.sh and tests/fm-gitignore-config.test.sh both fail on the base when invoked directly with a worker's ambient pointers and pass here with no test weakened.
Upstream added tests/fm-backend-herdr-stale-active-tab-e2e.test.sh and tests/fm-turnend-foreign-owner-arm-fix.test.sh after this branch was written. Neither sources tests/lib.sh, so the executable invariant named both as reaching the live fleet home on their direct-invocation path. Route each directly to bin/fm-test-env-lib.sh immediately after its own set - line, the same treatment every other non-reacher gets, rather than through tests/lib.sh: both own reporters and an EXIT trap that sourcing the shared library would replace. All 217 suites now reach the owner.
…ures The runner sources bin/fm-test-env-lib.sh unconditionally at startup, so a fixture repository holding a copied runner without that owner dies before the behavior under test runs. Upstream added two such fixtures after this branch was written: the primary-checkout/linked-worktree pair and the non-lane scheduling repo. The first swallowed the primary-checkout refusal the case asserts; the second failed the --list-scheduled family outright. Copy the owner into both, as the other copied-runner fixtures already do.
…r fixture tests/fm-test-fixtures.test.sh copies the runner into a throwaway tree to prove fixture Git isolation. The runner sources bin/fm-test-env-lib.sh at startup, so that tree needs the owner too or the runner dies before the Git-config assertion runs.
…pstream Upstream added tests/fm-jev-mem-guard.test.sh, which does not source tests/lib.sh, so the executable invariant named it as reaching the live fleet home. Route it directly to bin/fm-test-env-lib.sh as the other standalone suites do. Upstream also added three fixtures that copy the runner into a throwaway repository without bin/fm-test-env-lib.sh, which the runner sources at startup. Copy the owner into each, as the other copied-runner fixtures already do.
732a004 to
3f404ee
Compare
|
Greptile’s P2 identified a real gap in The reported Full suite failure is unrelated to the PR code. The check in Actions run 41472694874 stopped at “Require the full-ci go-ahead and passing lanes” with The correction passed the focused test and repository lint locally and was pushed through no-mistakes at head |
…fm/fm-test-suites-not-isolated-from-live-home # Conflicts: # bin/fm-test-run.sh
|
Speaking as Kun's firstmate: thanks @AgardnerAU — the Greptile P2 fix at Waiting on you:
Contract-class stays new-default (test harness only). Greptile is clean. Rockets: none. Unlabelled Full suite failure is our label gate. |
Intent
Check any of our submissions to Kun Chen's repos to see if they need action from us; if so and it makes sense, use codex to review them and resubmit; if unsure, wait.
Context: a read-only triage (data/upstream-pr-triage-2026-10-30/report.md, 2026-10-31) found these AgardnerAU PRs on kunchenguid/firstmate now conflict with current main and need a refresh, with no scope or design choice:
Merging upstream is the maintainer's call, never ours.
Captain's ask, 2026-11-03: review the maintainer's (kunchenguid) latest comments and reviews on #3706. Work out each concrete ask or failing lane they name, then fix what belongs to this PR through your pipeline, with evidence for anything you judge unrelated. Write a draft reply to the maintainer in data/upstream-refresh-a-2026-10-31/maintainer-reply-draft.md in this home (plain, factual, no direct address to anyone else). Do NOT post any comment or reply on GitHub: the captain approves replies first. Do not merge. Report when the fixes are pushed and the draft is ready.
The latest Greptile inline P2 on tests/fm-test-env-lib.test.sh says Bash keeps
$$unchanged in a subshell, so a suite that calls the isolation owner only in a subshell and forwards its exit status can pass both checks even though its top-level shell did not clear fleet pointers. Its existing subshell decoy does not catch that case. The maintainer asks to record the real process ID with a Bash 3.2-compatible fallback and add a subshell decoy that forwards the owner's status. The current Full suite check stopped before running any test lane because FM_CI_FULL=false and the required full-ci label is absent; FM_CI_LANES_FAILED=false. Releasing that fork workflow is the maintainer's decision.What Changed
bin/fm-test-env-lib.shas the one owner of the fleet-environment pointers a test must not inherit. These includeFM_HOME, the*_OVERRIDEroots, the wake queue,FM_BACKEND,FM_SESSION_START_STAGE_FILE,FM_SUPERVISION_MODELandFM_TRACE_CONTEXT.fm_test_env_isolateclears the pointers in the calling process. It returns non-zero if a pointer survives, and the caller then refuses to run.bin/fm-test-run.shandbin/fm-test-isolation-proof.shnow call it once at startup and no longer keep their own shorter inlineunsetlists.tests/lib.shalso calls it and sets its sourced guard only after the call succeeds.fm-test-run.shselects thepure-contract-unitfamily plus the suites that reference the shared test helpers when this file changes.bash tests/<file>.test.shruns isolated too. Each suite that does not sourcetests/lib.shor a shared helper now calls the owner directly in its top-level shell. This covers the backend smoke and e2e suites, the AFK, quota, gotmp and gitignore suites, and others. Runner fixtures infm-test-run.test.sh,fm-test-fixtures.test.shandfm-test-isolation-proof.test.shcopy the owner into their fixture repositories.tests/fm-test-env-lib.test.sh. It stops each suite at the owner and fails, naming the file, when the suite's original top-level process does not reach the owner or writes through an inherited fleet pointer first. It records the real process ID throughBASHPID, with a Bash 3.2 fallback that reads a child shell'sPPID. Decoy suites cover a heredoc, isolation inside a child process, a write before isolation, and isolation inside a subshell that forwards the owner's exit status.CONTRIBUTING.mdanddocs/scripts.mddocument the owner and the rule that each suite must call it.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The new commit changes only test code, and it does what the maintainer asked. The stub owner now records BASHPID, with a Bash 3.2 fallback that reads $PPID from an exec'd sh. The subshell decoy now forwards the owner's exit status, so it fails without the PID fix and passes with it. If the fallback fails, no marker is written and the probe rejects the suite (fail-closed).
Testing
I ran the isolation-owner suite at HEAD and it passed. I did a regression mutation in a disposable copy: with the old
$$PID marker restored, the new forwarded-status subshell decoy makes the suite fail, so the gap that Greptile and the maintainer reported is now detected. I forced the BASHPID-less fallback for Bash 3.2 and the whole suite still passed, and a direct demo showed that the fallback tells a subshell apart from its parent. I also ran two backend smoke suites directly with a polluted FM_HOME. Both skipped because their CLIs are absent, and the sentinel home stayed empty. The worktree is clean. Removing the scratch copy in /tmp was denied by permissions, so it is still there.$$)Evidence: Suite run at HEAD (all checks pass)
Source: Suite run at HEAD (all checks pass)
Evidence: Regression mutation diff (old $$ marker restored)
Source: Regression mutation diff (old $$ marker restored)
Evidence: Suite fails with old $$ marker (decoy catches forwarded subshell status)
Source: Suite fails with old $$ marker (decoy catches forwarded subshell status)
ok - the probe rejects an owner reference that never executes not ok - the probe accepted isolation that executed only inside a subshell rc=1Evidence: Forced Bash 3.2 fallback mutation diff
Source: Forced Bash 3.2 fallback mutation diff
Evidence: Suite passes with BASHPID unset (fallback path)
Source: Suite passes with BASHPID unset (fallback path)
Evidence: Fallback PID demo
Source: Fallback PID demo
dollar=3199449 top_fallback=3199449 subshell_fallback=3199452Evidence: Direct suites with polluted FM_HOME leave sentinel empty
Source: Direct suites with polluted FM_HOME leave sentinel empty
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.
$$)FM_HOME=/nonexistent-live-sentinel bash tests/fm-test-env-lib.test.shat HEAD (all 11 checks pass, including all 318 suites reaching the owner and the new forwarded-status subshell decoy)Regression mutation in a disposablegit archive HEADcopy: replaced the probe's owner_pid with the old$$marker and ranbash tests/fm-test-env-lib.test.sh. The run fails with 'not ok - the probe accepted isolation that executed only inside a subshell' (rc=1)Forced the Bash 3.2 fallback by addingunset BASHPIDbefore the owner_pid assignment in the disposable copy and reran the full suite. All checks pass (rc=0)Direct fallback demo:bash -c 'unset BASHPID; ...'shows that the top-level fallback equals$$and the subshell fallback gives a different PIDRantests/fm-backend-paseo-smoke.test.shandtests/fm-backend-tern-smoke.test.shwith FM_HOME and FM_STATE_OVERRIDE pointing at a sentinel home. Both skipped because their CLIs are absent. The sentinel home stayed empty✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.