gabriel / muse public
fix task/fix-muse-dir-staging #1 / 1
gabriel · 167 days ago · Apr 14, 2026 · Diff

fix: prevent .muse/ internals from leaking into working-tree snapshots

Data-integrity bug: muse code add .muse/agent.md (or any explicit path inside .muse/) bypassed the _ALWAYS_PRUNE_DIRS exclusion that the walker honours. The explicit-path and directory-arg branches in _collect_paths had no guard, so VCS-internal files could be staged and committed.

Consequence: on checkout to a branch whose snapshot omits those files, muse would delete .muse/agent.md and .muse/config.toml from disk — corrupting live VCS state.

Fix: add _is_inside_muse_dir(root, path) helper and call it at the top of the explicit-path loop in _collect_paths. Paths inside .muse/ are silently skipped with a debug log, identical treatment to out-of-repo paths.

Tests I7/I8/I9 in TestSecurityI cover: I7 — dot-add never stages .muse/ files (was already safe via walker) I8 — explicit .muse/agent.md is silently rejected I9 — .muse/ as a directory arg stages nothing from inside it

sha256:886b6675cbe9c199e84d3f5fcedd981ee1d2aa393effc6752944878bff04b90d sha
+5 ~2 symbols
sha256:85842e312a049aeacc6f57bd3523a14d0155d4f55bc1828e973e3dee26baffff snapshot
+5
symbols added
~2
symbols modified
0
dead code introduced
Semantic Changes 7 symbols
~ muse/cli/commands/code_stage.py .py 2 symbols added, 1 symbol modified
+ _MUSE_DIR_NAME variable variable _MUSE_DIR_NAME L81–81
+ _is_inside_muse_dir function function _is_inside_muse_dir L228–245
~ tests/test_cmd_code_add.py .py 3 symbols added, 1 symbol modified
+ test_I7_muse_dir_file_not_staged_by_dot method method test_I7_muse_dir_file_not_staged_by_dot L165–182
+ test_I8_muse_dir_file_not_staged_when_explicit method method test_I8_muse_dir_file_not_staged_when_explicit L184–201
+ test_I9_muse_dir_subdir_not_staged_when_explicit method method test_I9_muse_dir_subdir_not_staged_when_explicit L203–215
← Older Oldest on task/fix-muse-dir-staging
All commits
Newer → Latest on task/fix-muse-dir-staging

0 comments

No comments yet. Be the first to start the discussion.

To add a comment, use the Muse CLI: muse hub commit comment sha256:886b6675cbe9c199e84d3f5fcedd981ee1d2aa393effc6752944878bff04b90d --body "your comment"