Skip to content

test: remove the remote secondmate e2e fixture with fm_test_remove_tree - #7752

Merged
kunchenguid merged 1 commit into
kunchenguid:mainfrom
c6aw:fm/upstream-fm-flake-7629-cleanup
Oct 26, 2026
Merged

kunchenguid merged 1 commit into
kunchenguid:mainfrom
c6aw:fm/upstream-fm-flake-7629-cleanup

Conversation

@c6aw

@c6aw c6aw commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Intent

Refs #7629. Test-only.

tests/fm-remote-secondmate-lifecycle-e2e.test.sh removes its fixture root in the EXIT trap with a plain rm -rf. When the run stops early, for example when the watcher auto-relaunch leg fails, the fixture still holds the read-only state/<id>.git-hooks strip folder, so cleanup prints "Permission denied" for each hook, leaves the fixture root behind and exits non-zero. The CI logs discussed in #7629 show these lines after the failing leg.

This change makes the cleanup use the shared fm_test_remove_tree, which makes read-only fixture directories writable before it removes them. The watcher auto-relaunch wait itself is left as main has it.

Evidence: on main, a copy of the test that stops right after the watcher leg leaks the hooks folder; with this change it leaves nothing behind, a forced failure of the leg also leaves nothing behind, and the full file passes; bin/fm-test-run.sh --check-coverage unchanged.

What Changed

  • The EXIT-trap cleanup in tests/fm-remote-secondmate-lifecycle-e2e.test.sh now removes the fixture root with the shared fm_test_remove_tree helper instead of a plain rm -rf. The helper makes read-only fixture directories writable before it deletes them. One example is the state/<id>.git-hooks strip folder that is left behind when a run stops early. Before this change, cleanup in that case printed "Permission denied", left the fixture root on disk and exited non-zero.
  • The test logic is unchanged, including the watcher auto-relaunch wait.

Refs #7629

🤖 Generated with Claude Code

Risk Assessment

✅ Low: A one-line, test-only change swaps the EXIT-trap rm -rf for the shared fm_test_remove_tree helper (tests/lib.sh:300), which first makes fixture directories writable (it skips symlinked roots) and then removes the tree; TMP_ROOT is an absolute path that was resolved earlier, and the change matches the stated intent exactly.

Testing

I ran four variants of the e2e test in parallel, each with its own TMPDIR. The variants were the base cleanup stopped after the watcher leg, the new cleanup stopped at the same point, the new cleanup with a forced watcher-leg failure, and the full file. On base, cleanup printed 15 "Permission denied" lines, exited 1, and left the fixture root with remote-home/state/parent-route/ios.git-hooks. With the change, both early-stop runs and the full run left no fixture root and printed no "Permission denied" lines. The early-stop and full runs exited 0, the forced-failure run exited 1 from its own failing assertion, and the full file printed ALL TESTS PASSED. The temporary variant files and TMPDIRs are removed, and the worktree is clean.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Reproduce on base: a run that stops after the watcher leg leaks the read-only hooks folder and cleanup fails ✅ pass live base-stop.log: 15 'rm: cannot remove .../ios.git-hooks/...: Permission denied' lines, exit=1, ios.git-hooks folder left in TMPDIR
With the change, the same early stop removes the whole fixture root ✅ pass live head-stop.log: watcher leg ok, exit=0, no Permission denied lines; the TMPDIR held no fixture root
Adversarial: a forced failure of the watcher leg still leaves nothing behind ✅ pass live head-fail.log: 'not ok - EVIDENCE: forced watcher leg failure', exit=1 from the assertion only, no Permission denied lines, no fixture root left
The full lifecycle e2e file still passes and cleans up ✅ pass live full.log: ALL TESTS PASSED, exit=0, no fixture root left
Evidence: Base cleanup, early stop: Permission denied, ios.git-hooks leaked, exit=1

Source: Base cleanup, early stop: Permission denied, ios.git-hooks leaked, exit=1

ok - overlapping remote home provisioning serializes through publication and rollback
ok - competing cleanup of the public home cannot reach a live provisioning clone
ok - a home that appears mid-provision makes the provision die without touching it
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
ok - remote inheritance rejects incomplete and superseded payload generations
ok - mixed local and remote routes validate without migration
ok - remote spawn launches on the remote-local backend and records a host-qualified route
ok - legacy and mismatched remote endpoints fail closed before backend access
ok - non-herdr remote endpoints are refused without changing either route
ok - remote spawn serializes inheritance through launch publication
ok - marked send and routed reply complete through the existing parent correlation owner
ok - partial remote inheritance retains reread intent through bootstrap convergence
ok - config push and bootstrap serialize remote inheritance convergence
ok - remote inherited config retains and retries a failed live reread nudge
ok - fleet snapshot projects mixed local and remote structured state
ok - remote update imports and fast-forwards the persistent home on its configured host
ok - the remote restart verb delegates to the host-local control plane and refuses before stopping anything
ok - startup repairs remote readiness before probing without relaunching
ok - watch liveness: a dead remote secondmate is auto-relaunched on its own host with one wake
EVIDENCE: stopping right after watcher leg
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/sendemail-validate': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-auto-gc': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/post-rewrite': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-push': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/post-merge': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/post-checkout': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-rebase': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/post-commit': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/prepare-commit-msg': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-merge-commit': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-commit': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/post-applypatch': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/pre-applypatch': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/applypatch-msg': Permission denied
rm: cannot remove '/tmp/ev-base-stop.IB0M/fm-remote-secondmate-e2e.mB7gg1/remote-home/state/parent-route/ios.git-hooks/commit-msg': Permission denied
exit=1
Evidence: New cleanup, early stop after watcher leg: clean, exit=0

Source: New cleanup, early stop after watcher leg: clean, exit=0

ok - overlapping remote home provisioning serializes through publication and rollback
ok - competing cleanup of the public home cannot reach a live provisioning clone
ok - a home that appears mid-provision makes the provision die without touching it
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
ok - remote inheritance rejects incomplete and superseded payload generations
ok - mixed local and remote routes validate without migration
ok - remote spawn launches on the remote-local backend and records a host-qualified route
ok - legacy and mismatched remote endpoints fail closed before backend access
ok - non-herdr remote endpoints are refused without changing either route
ok - remote spawn serializes inheritance through launch publication
ok - marked send and routed reply complete through the existing parent correlation owner
ok - partial remote inheritance retains reread intent through bootstrap convergence
ok - config push and bootstrap serialize remote inheritance convergence
ok - remote inherited config retains and retries a failed live reread nudge
ok - fleet snapshot projects mixed local and remote structured state
ok - remote update imports and fast-forwards the persistent home on its configured host
ok - the remote restart verb delegates to the host-local control plane and refuses before stopping anything
ok - startup repairs remote readiness before probing without relaunching
ok - watch liveness: a dead remote secondmate is auto-relaunched on its own host with one wake
EVIDENCE: stopping right after watcher leg
exit=0
Evidence: New cleanup, forced watcher-leg failure: no Permission denied, no leftover root

Source: New cleanup, forced watcher-leg failure: no Permission denied, no leftover root

ok - overlapping remote home provisioning serializes through publication and rollback
ok - competing cleanup of the public home cannot reach a live provisioning clone
ok - a home that appears mid-provision makes the provision die without touching it
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
ok - remote inheritance rejects incomplete and superseded payload generations
ok - mixed local and remote routes validate without migration
ok - remote spawn launches on the remote-local backend and records a host-qualified route
ok - legacy and mismatched remote endpoints fail closed before backend access
ok - non-herdr remote endpoints are refused without changing either route
ok - remote spawn serializes inheritance through launch publication
ok - marked send and routed reply complete through the existing parent correlation owner
ok - partial remote inheritance retains reread intent through bootstrap convergence
ok - config push and bootstrap serialize remote inheritance convergence
ok - remote inherited config retains and retries a failed live reread nudge
ok - fleet snapshot projects mixed local and remote structured state
ok - remote update imports and fast-forwards the persistent home on its configured host
ok - the remote restart verb delegates to the host-local control plane and refuses before stopping anything
ok - startup repairs remote readiness before probing without relaunching
not ok - EVIDENCE: forced watcher leg failure
exit=1
Evidence: Full file with change: ALL TESTS PASSED, exit=0

Source: Full file with change: ALL TESTS PASSED, exit=0

ok - overlapping remote home provisioning serializes through publication and rollback
ok - competing cleanup of the public home cannot reach a live provisioning clone
ok - a home that appears mid-provision makes the provision die without touching it
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
ok - remote inheritance rejects incomplete and superseded payload generations
ok - mixed local and remote routes validate without migration
ok - remote spawn launches on the remote-local backend and records a host-qualified route
ok - legacy and mismatched remote endpoints fail closed before backend access
ok - non-herdr remote endpoints are refused without changing either route
ok - remote spawn serializes inheritance through launch publication
ok - marked send and routed reply complete through the existing parent correlation owner
ok - partial remote inheritance retains reread intent through bootstrap convergence
ok - config push and bootstrap serialize remote inheritance convergence
ok - remote inherited config retains and retries a failed live reread nudge
ok - fleet snapshot projects mixed local and remote structured state
ok - remote update imports and fast-forwards the persistent home on its configured host
ok - the remote restart verb delegates to the host-local control plane and refuses before stopping anything
ok - startup repairs remote readiness before probing without relaunching
ok - watch liveness: a dead remote secondmate is auto-relaunched on its own host with one wake
ok - watch liveness: an unreachable remote secondmate is probed, preserved, and never failed over
ok - the host-local state read steps around a stale shadowing herdr client
ok - startup reports alive legacy backends without changing their routes
ok - unreachable no-ledger remote state remains explicit with no local respawn or failover
ok - remote retirement refuses child work, then removes only its own endpoint while a shared-session sibling survives
ok - remote retirement archives the complete parent-side status log when enabled
ok - remote missing-status retirement remains lock-free with archival enabled
ok - an absent remote home retires only with the dispatcher's arguments and is never recreated
ALL TESTS PASSED
exit=0
Evidence: Leftover listing after each run
base-stop: fm-remote-secondmate-e2e.*/remote-home/state/parent-route/ios.git-hooks left behind (23 entries), 15 'Permission denied'
head-stop: fixture root gone, 0 'Permission denied'
head-fail: fixture root gone, 0 'Permission denied'
full: fixture root gone, 0 'Permission denied'
- Outcome: ⚠️ 1 info across 1 run (9m16s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ tests/fm-remote-secondmate-lifecycle-e2e.test.sh:53 - Every run, base and changed, leaves three small lib.sh registry files (.fm-test-cleanup/procevent/watcher.<pid>.*) in TMPDIR. This test's own EXIT trap replaces the lib.sh trap that would remove them. The behaviour exists on base too and is outside this change's scope, which is the fixture root.
  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Reproduce on base: a run that stops after the watcher leg leaks the read-only hooks folder and cleanup fails ✅ pass live base-stop.log: 15 'rm: cannot remove .../ios.git-hooks/...: Permission denied' lines, exit=1, ios.git-hooks folder left in TMPDIR
With the change, the same early stop removes the whole fixture root ✅ pass live head-stop.log: watcher leg ok, exit=0, no Permission denied lines; the TMPDIR held no fixture root
Adversarial: a forced failure of the watcher leg still leaves nothing behind ✅ pass live head-fail.log: 'not ok - EVIDENCE: forced watcher leg failure', exit=1 from the assertion only, no Permission denied lines, no fixture root left
The full lifecycle e2e file still passes and cleans up ✅ pass live full.log: ALL TESTS PASSED, exit=0, no fixture root left
  • TMPDIR=&lt;isolated&gt; bash tests/zz-ev-base-stop.test.sh: the base cleanup (rm -rf --) on a copy that exits right after the watcher leg passes
  • TMPDIR=&lt;isolated&gt; bash tests/zz-ev-head-stop.test.sh: the change's cleanup on the same truncated copy
  • TMPDIR=&lt;isolated&gt; bash tests/zz-ev-head-fail.test.sh: a forced fail inserted right after the watcher auto-relaunch leg
  • TMPDIR=&lt;isolated&gt; bash tests/fm-remote-secondmate-lifecycle-e2e.test.sh: the full file
  • find &lt;TMPDIR&gt; after each run, to list what was left and any *.git-hooks folder
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The EXIT trap removed the fixture root with a plain rm -rf. When the run
stops early, for example when the watcher auto-relaunch leg fails, the
fixture still holds the read-only state/<id>.git-hooks strip folder, so
cleanup prints "Permission denied" for each hook, leaves the fixture root
behind and exits non-zero. Use the shared fm_test_remove_tree, which makes
read-only fixture directories writable before it removes them.

Refs kunchenguid#7629
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @c6aw. This is a tidy fix for the leftover ios.git-hooks folder and the "Permission denied" noise after an early stop that #7629 shows, and the base-vs-head cleanup evidence makes it easy to check.

What I checked: head d4b4bbb1 against main ffb2aca0. The only change is one line in the EXIT trap of tests/fm-remote-secondmate-lifecycle-e2e.test.sh, which swaps rm -rf for the shared fm_test_remove_tree helper. The helper is in tests/lib.sh, which this file already sources, and it skips symlinked roots. Nothing touches workflows, product scripts, credentials or the network, so I approved the first-time fork runs (CI 40236928063, no-mistakes 40236928062). The no-mistakes attestation binds this head, live validation is go (4/4), and the no-mistakes check has already passed.

Contract-class: restore. This is test-only. Fixture cleanup is meant to leave nothing behind, and this makes it do that on the early-stop path; no product default changes. VISION.md: One captain aligns (no captain-facing change) · Authority aligns · Scripts aligns (reuses the exact shared helper) · Restart aligns · Delegation aligns (cleaner regression coverage) · Vendor aligns · Scope aligns (repo discipline: field flakes become cleaner tests).

Where it stands: waiting on CI only, so there's nothing more you need to do. If the required checks come back green and it stays mergeable, it can merge without waiting on Kun.

@kunchenguid
kunchenguid merged commit 2b46ed1 into kunchenguid:main Oct 26, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @c6aw — really appreciate you taking the time on this.

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.

2 participants