Repository navigation
fix: stage remote home clones before publication - #5733
Merged
Merged
Conversation
A remote home provision cloned the code root directly into the public FM_HOME path while rollback() claimed rm -rf of that same path on any failure. Bash defers trapped signals past a foreground child, but any other cleanup or lifecycle path that removes the home directory races the live clone's object copy, producing the CI flake "fatal: failed to copy file to .../.git/objects/...: No such file or directory". Clone into a private staging directory beside the home and publish with an atomic rename once complete, so no cleanup can remove a directory a live clone is still writing; a home that appears mid-provision now dies cleanly instead of inheriting torn state. The regression coverage holds a real clone mid-copy, removes the public path, and requires the provision to finish and publish intact.
8 tasks
ashkonmousavi
added a commit
to ashkonmousavi/firstmate
that referenced
this pull request
Sep 26, 2026
Intent
Fix the flaky CI failure in tests/fm-spawn-compact-adviser-disable-remote.test.sh where provisioning a remote seed home intermittently dies with 'fatal: failed to copy file to /.git/objects/...: No such file or directory'. Reliability policy: fix the cause, never retries, sleeps, or looser thresholds. Root fix: fm-remote-home-provision.sh clones the code root into a private staging directory beside the target home and publishes it with an atomic rename only once the clone completes, so no cleanup (its own rollback, a competing provision, or an external rm -rf of the public path) can remove a directory a live clone is still writing; a sentinel file written inside the stage proves after the rename that the published home is ours, so a home appearing mid-provision dies cleanly without adopting, altering, or nesting into the foreign path. Regression coverage in fm-remote-secondmate-lifecycle-e2e.test.sh holds a real clone mid-copy through a git shim (SIGSTOP verified via ps state), removes the public home path, and requires an intact published clone (rev-parse, fsck, clean status, content compare); a second scenario proves a foreign home created during the hold survives untouched while the provision dies cleanly. Verified to fail pre-fix and pass post-fix. Deliberately out of scope: a sibling 'rm: Directory not empty' cleanup failure in CI run 36202051270 is not proven to share this cause.
What Changed
Risk Assessment
✅ Low: The staged clone, post-rename ownership check, rollback path, and behavioral regression coverage are bounded and show no substantiated new defect.
Testing
The focused lifecycle races and compact-adviser regression passed. Direct CLI checks confirmed an intact published clone, clean refusal of a competing home, and ordinary seed convergence. The broader lifecycle run timed out after its provisioning checks passed; its later coverage is not claimed. No worktree artifacts remain.
Evidence: Live clone-race CLI transcript
Source: Live clone-race CLI transcript
Evidence: Live seed and foreign-home CLI transcript
Source: Live seed and foreign-home CLI transcript
Evidence: Focused provisioning race checks
Source: Focused provisioning race checks
Evidence: Remote compact-adviser regression
Source: Remote compact-adviser regression
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_TEST_PROVISION_ONLY=1 tests/fm-remote-secondmate-lifecycle-e2e.test.shtests/fm-spawn-compact-adviser-disable-remote.test.shDirectbin/fm-remote-home-provision.shseed, convergence, and foreign-home refusal using the worktree as the code rootDirect provisioning with a verified SIGSTOPed real Git clone, followed by public-path removal and competing-home creationtests/fm-remote-secondmate-lifecycle-e2e.test.sh(timed out after 240 seconds, beyond the targeted provisioning checks)⏭️ **Document** - skipped
Step was skipped.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.