gabriel / muse public
fix BREAKING stage,status dev #93 / 100
AI Agent gabriel · 104 days ago · May 26, 2026 · Diff

fix(stage,status): don't re-stage or surface already-committed empty dirs

Two bugs, both about empty dirs that are already in HEAD's snapshot.directories:

1. muse code add . was sentinel-staging committed empty dirs on every run because the empty_dirs_to_stage loop had no check against HEAD dirs. Fix: skip any dir already in _head_snapshot_dirs() before staging.

2. muse status was showing committed empty dirs as staged.added when their sentinel was in the stage index, because staged_added_dirs wasn't filtered against committed_empty_dirs when building DirStatus. Fix: staged_added=sorted(staged_added_dirs - committed_empty_dirs).

Regression tests: TestStageIdempotency (4 tests) in test_code_stage.py, D9/D10 in test_status_directory_tracking.py.

sha256:00518230287e4eef5012e619cd030beb8883260e0b170ee53d68d89bbe058928 sha
+10 ~5 symbols
sha256:b5ba3cc0123fffd9e94c60392fb969e29a4fc00c3566386a69c21902dce45040 snapshot
+10
symbols added
~5
symbols modified
0
dead code introduced
Semantic Changes 15 symbols
~ muse/cli/commands/code_stage.py .py 1 symbol added, 1 symbol modified
+ _head_snapshot_dirs function function _head_snapshot_dirs L260–273
~ muse/plugins/code/plugin.py .py 2 symbols modified
~ tests/test_code_stage.py .py 7 symbols added, 1 symbol modified
+ TestStageIdempotency class class TestStageIdempotency L970–1050
+ _run method method _run L973–976
+ _setup_repo method method _setup_repo L978–983
+ test_committed_empty_dir_not_staged_on_add method method test_committed_empty_dir_not_staged_on_add L1011–1025
+ test_second_add_after_deletion_staged_is_noop method method test_second_add_after_deletion_staged_is_noop L985–996
+ test_second_add_after_modification_staged_is_noop method method test_second_add_after_modification_staged_is_noop L998–1009
+ test_total_matches_sum_of_categories method method test_total_matches_sum_of_categories L1027–1050
~ _env
~ tests/test_status_directory_tracking.py .py 2 symbols added, 1 symbol modified
+ test_D10_committed_dir_clean_after_commit method method test_D10_committed_dir_clean_after_commit L226–235
+ test_D9_committed_dir_not_in_staged_added_after_code_add method method test_D9_committed_dir_not_in_staged_added_after_code_add L209–224

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:00518230287e4eef5012e619cd030beb8883260e0b170ee53d68d89bbe058928 --body "your comment"