gabriel / muse public
feat patch dev
AI Agent gabriel · 148 days ago · Apr 25, 2026 · Diff

feat: add MsgpackCache.from_root() — eliminates repeated is_dir guard in loaders

Adds from_root(root) classmethod to MsgpackCache. Takes a repo root, checks for .muse/, returns load(muse_dir) on hit or empty() on miss. Replaces the identical 3-line guard that load_symbol_cache / load_callgraph_cache / load_implicit_edge_cache each duplicated.

_InvariantFileCache overrides from_root to delegate to its load(repo_root), which already performs the is_dir check internally.

The four convenience loaders become one-liners: return XxxCache.from_root(root). The 20+ CLI command callers are unchanged.

Adds TestFromRoot (4 tests) to test_cache_base.py. Total cache tests: 179. Plan doc updated with from_root spec, tests, and wiring notes.

sha256:8dfc71bd41425032b28f57428f129a29a9967ceee0026b8d9eb49ad4ecfcb4f1 sha
+10 ~12 −3 symbols
sha256:57b85305f4dc8b69462bf867ece4b9967ef2ca83210b4a2c10bc5eeb9b1d3f96 snapshot
+10
symbols added
~12
symbols modified
−3
symbols removed
0
dead code introduced
Semantic Changes 25 symbols
~ docs/cache-reorganization-plan.md .md 2 symbols added, 7 symbols modified
+ from_root — wiring in callers section from_root — wiring in callers L547–567
+ code[python]@L551 variable variable code[python]@L551 L551–561
~ Phases
~ py
~ muse/core/cache_base.py .py 2 symbols added, 1 symbol modified
+ from_root method method from_root L151–175
+ _muse_dir import import _muse_dir L43–43 ← moved from muse/core/symbol_cache.py
~ muse/core/callgraph_cache.py .py 1 symbol removed, 1 symbol modified
_muse_dir import import _muse_dir L66–66
~ muse/core/implicit_edge_cache.py .py 1 symbol removed, 1 symbol modified
_muse_dir import import _muse_dir L59–59
~ muse/core/symbol_cache.py .py 1 symbol removed, 1 symbol modified
_muse_dir import import _muse_dir L74–74 → moved to muse/core/cache_base.py
~ muse/plugins/code/_invariants.py .py 1 symbol added, 1 symbol modified
+ from_root method method from_root L297–308
~ tests/test_cache_base.py .py 5 symbols added
+ TestFromRoot class class TestFromRoot L204–231
+ test_from_root_empty_save_is_noop method method test_from_root_empty_save_is_noop L226–231
+ test_from_root_round_trip method method test_from_root_round_trip L218–224
+ test_from_root_with_muse_dir_sets_cache_dir method method test_from_root_with_muse_dir_sets_cache_dir L207–210
+ test_from_root_without_muse_dir_returns_empty method method test_from_root_without_muse_dir_returns_empty L212–216
← 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:8dfc71bd41425032b28f57428f129a29a9967ceee0026b8d9eb49ad4ecfcb4f1 --body "your comment"