fix: git-export deletes ignored/untracked local files not owned by any prior export
GitExporter.sync_to_git deleted every file under --git-dir not on a hardcoded/--exclude list, without consulting ignore rules or checking whether Muse had ever actually written that path. Ignored, untracked local files (.env, config/local.yaml) that were never part of any Muse snapshot were permanently deleted and unrecoverable.
Fix, per the ticket's requested design:
1. Track the manifest paths written by the previous successful export in a sidecar JSON file (muse/core/bridge/state.py::_SidecarData). Delete candidates are now computed as owned_before - owned_now — never an unconditional sweep of the whole working tree. A path Muse never wrote can never appear in owned_before, so it can never be deleted, on the first export or any subsequent one.
2. Within the delete-candidate set, consult git check-ignore --stdin (batched, one subprocess call) and .museignore's global patterns; skip ignored paths unless --allow-delete-ignored is passed. This is defense-in-depth for a path that was legitimately Muse-owned before but has since been reused by an ignored local file.
Note: git check-ignore never reports a path as ignored while it's still tracked in the git index (correct, standard git behavior) — a reused path that was previously tracked by the bridge needs .museignore, not .gitignore, for ignore-based protection until something actually untracks it. Documented directly in GitExporter._ignored_paths.
Verified against the exact reproduction in the ticket: .env and config/local.yaml both survive a git-export run that previously deleted them. git-import was investigated and found to have no delete pass at all — it only reads git commits into the Muse object store, never touches git working-tree files — so the ticket's '(and git-import)' framing doesn't apply to any code path that actually exists.
5 new regression tests in tests/test_bridge_git_export.py (TestIgnoredFileProtection). All 282 existing bridge tests still pass (one test mock updated for the new sync_to_git parameter).
Closes #65.
Semantic Changes
29 symbols
Files Changed
~4
1128 in snapshot
0 comments
muse hub commit comment sha256:d25a7c7c4fbf0db573ca9a8db4f8f88f8e88ae732d8c7cdfa2624ebeabd130f0 --body "your comment"
No comments yet. Be the first to start the discussion.