gabriel / muse public
fix patch task/230-fix-read-snapshot-drops-directories #1 / 1
AI Agent gabriel · 1 day ago · Sep 18, 2026 · Diff

fix: muse read-snapshot silently dropped the directories field (musehub#93)

read_snapshot() already returns a full SnapshotRecord including .directories, but the CLI command's output construction never surfaced it -- _SnapshotOutput's TypedDict didn't declare the field and run() never read record.directories. Since directories are part of the snapshot's own identity (hash_snapshot(manifest, directories) computes snapshot_id), this made read-snapshot's claimed "full snapshot metadata" output silently incomplete -- you could not verify a snapshot's own directories field without reading the raw object file directly, exactly the workaround used to diagnose musehub#93 in the first place.

Added directories (list[str]) and dir_count (int) to the JSON output, both filtered consistently with the existing manifest/file_count when --path-prefix is given. Text-mode output now also shows the dir count alongside the file count.

This was explicitly one of #93's checklist items ("(muse, separate) muse read-snapshot drops the directories field"). Picking up #93/#60 properly now -- this is the first, self-contained piece.

6 new tests: directories present, empty-list (not absent) when none, directories still surfaced with --no-manifest (they're identity, not bulk data), --path-prefix filters directories too, text format shows dir count, and an explicit write→read round-trip with 31 directories (matching #93's own reported symptom shape) as a regression guard.

Tests: 31/31 in test_cmd_read_snapshot.py.

sha256:ec9e0eaa77bbe47e7bfee744380e01c917423f027fbe6c9eeb8b8f440330dc8f sha
+7 ~3 symbols
2 changed · 1196 in snapshot files
sha256:e7b441d1afdfa929470314b92320f83cc963b8689f2bac022643e222706d857f snapshot
+7
symbols added
~3
symbols modified
2
files changed
1196
files in snapshot
0
dead code introduced
Semantic Changes 10 symbols
~ tests/test_cmd_read_snapshot.py .py 7 symbols added, 1 symbol modified
+ TestDirectories class class TestDirectories L220–273
+ test_directories_present_in_output method method test_directories_present_in_output L221–226
+ test_directories_present_with_no_manifest method method test_directories_present_with_no_manifest L235–244
+ test_directories_survive_write_and_read_roundtrip method method test_directories_survive_write_and_read_roundtrip L263–273
+ test_no_directories_is_empty_list_not_absent method method test_no_directories_is_empty_list_not_absent L228–233
+ test_path_prefix_filters_directories_too method method test_path_prefix_filters_directories_too L246–255
+ test_text_format_shows_dir_count method method test_text_format_shows_dir_count L257–261
~ _snap
Files Changed
~2
1196 in snapshot
← Older Oldest on task/230-fix-read-snapshot-drops-directories
All commits
Newer → Latest on task/230-fix-read-snapshot-drops-directories

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