gabriel / muse public
feat patch storage dev
AI Agent gabriel · 115 days ago · May 21, 2026 · Diff

feat(storage): phase 4 — shelf entries use git-header+JSON, no extension

- shelf_entry_path() returns .muse/shelf/<algo>/<hex> (no extension) - write_shelf_entry() writes 'shelf <size>\0<json>' framing (crash-safe atomic rename) - read_shelf_entry() parses header+JSON; silently migrates .msgpack on first read - list_shelf_entries() handles both new-format (no extension) and .msgpack legacy files - delete_shelf_entry() removes both new and legacy .msgpack files - gc._collect_shelf_objects() reads object IDs from new-format shelf entries - test_phase4_shelf_json.py: 18 new tests covering all Phase 4 requirements - test_shelf_msgpack_storage.py: updated 11 tests to reflect no-extension format - test_cmd_shelf.py: updated fsync test to check _write_shelf_header_atomic

Issue: #12

sha256:5cb3eb55c96351accd2253e726ac0d2d101dd39919315e3d00fca4379852e58d sha
+49 ~22 −2 symbols
sha256:59e87ccf4ec74481b4682a91f8ddf139ee7ce2041c8fccc19eda85c31b89d0f3 snapshot
+49
symbols added
~22
symbols modified
−2
symbols removed
0
dead code introduced
Semantic Changes 73 symbols
~ tests/test_phase4_shelf_json.py .py 45 symbols added
+ TestDeleteShelfEntry class class TestDeleteShelfEntry L262–294
+ test_delete_absent_entry_returns_false method method test_delete_absent_entry_returns_false L287–294
+ test_delete_removes_legacy_msgpack_file method method test_delete_removes_legacy_msgpack_file L275–285
+ test_delete_removes_new_format_file method method test_delete_removes_new_format_file L263–273
+ TestGcShelfWalk class class TestGcShelfWalk L301–314
+ test_gc_finds_object_ids_in_new_format_entry method method test_gc_finds_object_ids_in_new_format_entry L302–314
+ TestLegacyShelfUpgrade class class TestLegacyShelfUpgrade L185–255
+ test_legacy_migrated_on_list method method test_legacy_migrated_on_list L231–241
+ test_legacy_migrated_to_new_format_on_read method method test_legacy_migrated_to_new_format_on_read L207–218
+ test_legacy_msgpack_readable_via_list method method test_legacy_msgpack_readable_via_list L197–205
+ test_legacy_msgpack_readable_via_read_shelf_entry method method test_legacy_msgpack_readable_via_read_shelf_entry L186–195
+ test_legacy_msgpack_removed_after_migration method method test_legacy_msgpack_removed_after_migration L220–229
+ test_mixed_format_list method method test_mixed_format_list L243–255
+ TestListShelfEntries class class TestListShelfEntries L160–178
+ test_list_finds_new_format_entries method method test_list_finds_new_format_entries L161–169
+ test_list_multiple_entries method method test_list_multiple_entries L171–178
+ TestShelfEntryPath class class TestShelfEntryPath L85–98
+ test_shelf_entry_path_has_no_extension method method test_shelf_entry_path_has_no_extension L86–90
+ test_shelf_entry_path_structure method method test_shelf_entry_path_structure L92–98
+ TestWriteShelfEntry class class TestWriteShelfEntry L105–153
+ test_file_has_no_extension method method test_file_has_no_extension L145–153
+ test_write_payload_is_valid_json method method test_write_payload_is_valid_json L121–131
+ test_write_produces_shelf_header method method test_write_produces_shelf_header L106–119
+ test_write_read_roundtrip method method test_write_read_roundtrip L133–143
+ _OBJ_A variable variable _OBJ_A L36–36
+ _OBJ_B variable variable _OBJ_B L37–37
+ _entry function function _entry L53–65
+ _legacy_path function function _legacy_path L68–70
+ _make_repo function function _make_repo L44–46
+ _shelf_id function function _shelf_id L49–50
+ _write_legacy_shelf function function _write_legacy_shelf L73–78
+ annotations import import annotations L12–12
+ delete_shelf_entry import import delete_shelf_entry L22–22
+ hash_blob import import hash_blob L20–20
+ json import import json L14–14
+ list_shelf_entries import import list_shelf_entries L22–22
+ long_id import import long_id L29–29
+ msgpack import import msgpack L17–17
+ pathlib import import pathlib L15–15
+ pytest import import pytest L18–18
+ read_shelf_entry import import read_shelf_entry L22–22
+ shelf_dir import import shelf_dir L21–21
+ shelf_entry_path import import shelf_entry_path L22–22
+ split_id import import split_id L29–29
+ write_shelf_entry import import write_shelf_entry L22–22
~ muse/core/gc.py .py 1 symbol modified
~ muse/core/store.py .py 2 symbols added, 5 symbols modified
+ _read_shelf_file function function _read_shelf_file L2295–2322
+ _write_shelf_header_atomic function function _write_shelf_header_atomic L700–734
← Older Oldest on dev
All commits
Newer → Latest on dev

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