feat: muse#53 item 12 — muse symlog prune-orphans
Adds `muse symlog prune-orphans [--dry-run] [--json]`: finds and removes symlog journals whose symbol no longer exists at HEAD — the file was deleted/renamed away, or the symbol was removed from a file that still exists. Journals are append-only and never auto-deleted on symbol removal, so without this they'd accumulate indefinitely after large-scale renames/deletions. Analogous to `muse gc` for unreachable objects.
Core additions in muse/core/symlog.py: - `_symbol_exists_in_head()`: walks HEAD commit -> snapshot manifest -> file object -> extract_symbols(), returning False (never raising) on any failure along the way, matching extract_symbols()'s own fail-silent contract. - `find_orphan_symlogs()`: filters list_symlog_symbols() by the above. - `prune_orphan_symlogs(dry_run=...)`: reuses the existing, already- tested delete_symlog_entry(addr, index=None) for the actual removal rather than reimplementing file deletion.
Covered by tests/test_cmd_symlog_prune_orphans.py (4 cases: clean repo reports zero orphans and leaves the live journal intact, a symbol removed from a surviving file is pruned while the sibling symbol's journal is untouched, a deleted file's symbol is pruned, --dry-run reports without deleting). Confirmed genuine RED by reverting both changed files and re-running (all 4 failed with JSONDecodeError, since 'prune-orphans' wasn't a recognized dispatch keyword), then GREEN with the fix restored plus the full symlog regression suite (233 tests, zero regressions). Live-verified via muse-dev against a disposable /tmp sandbox (dry-run then real prune correctly left compute_total's journal intact while removing apply_discount's).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Semantic Changes
40 symbols
Files Changed
+1
~3
1235 in snapshot
0 comments
muse hub commit comment sha256:986277e88b9de700cfb77ed3385e7b344df08fbb801c9615906da7df9c45c91d --body "your comment"
No comments yet. Be the first to start the discussion.