Skip to content

fix(fleet-sync): untracked files alone no longer block a fast-forward - #8

Merged
7hoenix merged 2 commits into
mainfrom
fm/fix-fleetsync-untracked-4q
Jul 24, 2026
Merged

7hoenix merged 2 commits into
mainfrom
fm/fix-fleetsync-untracked-4q

Conversation

@7hoenix

@7hoenix 7hoenix commented Jul 23, 2026

Copy link
Copy Markdown
Owner

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

  • Changed the fast-forward safety check in bin/fm-fleet-sync.sh to count only tracked changes (git status --porcelain --untracked-files=no), so a clone carrying untracked files (e.g. an intentional per-clone treehouse.toml) is no longer misreported as STUCK and can sync; clones with genuinely modified or staged tracked files still refuse as before.
  • Handled the overwrite edge case without clobbering: when an incoming commit adds a tracked file at the path of a local untracked file, git's own --ff-only/recovery checkout refusal is caught and surfaced as a real STUCK carrying git's reason (report_stuck gained an optional reason argument), rather than pre-deleting the local file.
  • Updated the script header contract to document tracked-only cleanliness and 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.

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)

=== Running fm-fleet-sync.sh myapp (with the fix) ===
myapp: synced 82c4157..3d68a72
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-forward

=== BASE (pre-fix) fm-fleet-sync.sh: clone HEAD dbb620e, one commit behind origin, carries untracked treehouse.toml ===
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-forward

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.

  • 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_untouched
  • E2E repro on the fixed script: real bare origin + clone one commit behind carrying an untracked treehouse.toml; ran bin/fm-fleet-sync.sh myapp -> myapp: synced 82c4157..3d68a72, app.txt advanced to v2, treehouse.toml preserved
  • Same 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.

7hoenix added 2 commits July 23, 2026 09:21
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.
@7hoenix
7hoenix merged commit 5f7be0a into main Jul 24, 2026
4 checks passed
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.

1 participant