Repository navigation
fix(fleet-sync): untracked files alone no longer block a fast-forward - #8
Merged
Merged
Conversation
Cleanliness check counted untracked files as dirty, so an intentional dropped-in file (the per-clone worktree-pool config) falsely reported STUCK and blocked all clone syncing. Count tracked changes only via --untracked-files=no. When an incoming commit would overwrite a local untracked file, git refuses the ff-only merge or recovery checkout on its own; report that as STUCK with git's reason and never clobber the file.
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
Fix a false-STUCK bug in bin/fm-fleet-sync.sh: its fast-forward safety check treated UNTRACKED files as uncommitted changes and refused a safe fast-forward, blocking all clone syncing since ~2026-07-17 for clones carrying the intentional per-clone worktree-pool config (treehouse.toml). Fix: the cleanliness check now counts TRACKED changes only, via 'git status --porcelain --untracked-files=no', so untracked files alone never block a fast-forward. Deliberate decisions: (1) fix lives in the shared safety-check logic so every caller (session-start sweep, teardown refresh, on-merge wake) benefits - no allowlisting treehouse.toml by name; (2) genuinely dirty clones with modified/staged tracked files still refuse as STUCK exactly as before; (3) edge case handled deliberately - when an incoming commit adds a tracked file at the same path as a local untracked file, git's own 'merge --ff-only' / recovery checkout refuses ('untracked working tree files would be overwritten'); we do NOT pre-delete or clobber the local file, we catch that refusal and report it as a real STUCK carrying git's reason (report_stuck gained an optional reason arg). Header contract updated to document tracked-only cleanliness. Added 3 colocated tests to tests/fm-fleet-sync.test.sh covering untracked-only fast-forward, tracked-change-alongside-untracked still STUCK, and the untracked-overwrite conflict STUCK-without-clobber; full suite green and bin/fm-lint.sh passes under pinned ShellCheck 0.11.0.
What Changed
bin/fm-fleet-sync.shto count only tracked changes (git status --porcelain --untracked-files=no), so a clone carrying untracked files (e.g. an intentional per-clonetreehouse.toml) is no longer misreported as STUCK and can sync; clones with genuinely modified or staged tracked files still refuse as before.--ff-only/recovery checkout refusal is caught and surfaced as a real STUCK carrying git's reason (report_stuckgained an optional reason argument), rather than pre-deleting the local file.tests/fm-fleet-sync.test.shcovering untracked-only fast-forward, tracked-change-alongside-untracked still STUCK, and the untracked-overwrite conflict STUCK-without-clobber.Risk Assessment
✅ Low: A tightly-scoped, well-tested safety-check fix in shared fleet-sync logic that only relaxes the cleanliness check to tracked files, preserves all existing refusal paths, and never clobbers local files.
Testing
The baseline test command and the full tests/fm-fleet-sync.test.sh suite pass, including the three new tests covering untracked-only fast-forward, tracked-change-alongside-untracked STUCK, and untracked-overwrite conflict STUCK-without-clobber. Beyond the suite, I built a from-scratch git origin/clone reproduction mirroring the real bug (a clone lagging origin by one landed commit while carrying an untracked treehouse.toml worktree-pool config): the fixed script now fast-forwards ("myapp: synced 82c4157..3d68a72") and preserves the untracked file, whereas the pre-fix script extracted from the base commit refuses the identical safe fast-forward with the exact false-STUCK message ("STUCK ... with uncommitted changes, 1 commits behind"). This is a CLI/operational change with no UI surface, so evidence is CLI transcripts rather than screenshots. Worktree left clean, transient temp script removed.
Evidence: E2E: fixed script fast-forwards untracked-config clone
=== Running fm-fleet-sync.sh myapp (with the fix) === myapp: synced 82c4157..3d68a72 (clone advanced to v2, treehouse.toml preserved)Evidence: Repro: base script false-STUCK on same clone
myapp: STUCK: on branch main with uncommitted changes, 1 commits behind origin/main - needs attention clone HEAD after BASE run: dbb620e (still behind origin/main 85b0ef4) --> BUG: untracked-only clone refused a safe fast-forwardPipeline
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.
command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"bash tests/fm-fleet-sync.test.sh- full suite green, including the 3 new colocated tests:test_untracked_only_on_default_fast_forwards,test_tracked_change_with_untracked_still_stuck,test_untracked_overwrite_conflict_is_stuck_untouchedE2E repro on the fixed script: real bare origin + clone one commit behind carrying an untrackedtreehouse.toml; ranbin/fm-fleet-sync.sh myapp->myapp: synced 82c4157..3d68a72, app.txt advanced to v2, treehouse.toml preservedSame scenario on the base (pre-fix) script extracted from 8f7e811 ->myapp: STUCK: on branch main with uncommitted changes, 1 commits behind origin/main, clone HEAD stayed behind (the reported false-STUCK bug)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.