gabriel / muse public
fix BREAKING dev
AI Agent gabriel · 146 days ago · Apr 25, 2026 · Diff

fix: migrate Pattern B caches from fixed .tmp to mkstemp (Phase 5)

Eliminates concurrent-save race condition in symbol_cache, callgraph_cache, implicit_edge_cache, and _InvariantFileCache. Each now uses tempfile.mkstemp with a unique per-cache prefix so two parallel writers never collide on the same temp filename.

Write pattern changes: symbol_cache.py: .symbols_*.tmp (was symbols.msgpack.tmp) callgraph_cache.py: .callgraph_*.tmp (was callgraph.msgpack.tmp) implicit_edge_cache.py:.implicit_edges_*.tmp _invariants.py: .invariants_*.tmp

repo.py: add all four new prefixes to _MUSE_TEMP_PREFIXES so orphaned temps from crashed saves are swept on next startup.

TDD: 4 new orphaned-sweep tests (red before repo.py change, green after). Updated fixed-filename .tmp assertions to glob pattern. Added missing atomic-write test to symbol_cache. 188 cache tests + 84 regression tests all pass.

sha256:54a266e734569229e06919ddea3ebdbb10106c1fbf9581ef76b91ea1fbb59242 sha
+13 ~16 symbols
sha256:3c17d505aa6d14a9b0298c3d9aa9e949c7812b376314adc4968b09b485aa80de snapshot
+13
symbols added
~16
symbols modified
0
dead code introduced
Semantic Changes 29 symbols
~ muse/core/callgraph_cache.py .py 2 symbols added, 2 symbols modified
+ os import import os L75–75
+ tempfile import import tempfile L77–77
~ save
~ muse/core/implicit_edge_cache.py .py 2 symbols added, 2 symbols modified
+ os import import os L62–62
+ tempfile import import tempfile L64–64
~ save
~ muse/core/symbol_cache.py .py 2 symbols added, 2 symbols modified
+ os import import os L70–70
+ tempfile import import tempfile L72–72
~ save
~ muse/plugins/code/_invariants.py .py 2 symbols added, 2 symbols modified
+ os import import os L79–79
+ tempfile import import tempfile L81–81
~ save
~ tests/test_callgraph_cache.py .py 1 symbol added, 2 symbols modified
+ test_orphaned_tmp_swept_on_startup method method test_orphaned_tmp_swept_on_startup L306–313
~ tests/test_core_symbol_cache.py .py 2 symbols added, 1 symbol modified
+ test_atomic_write_no_tmp_leftover method method test_atomic_write_no_tmp_leftover L257–262
+ test_orphaned_tmp_swept_on_startup method method test_orphaned_tmp_swept_on_startup L264–271
~ tests/test_implicit_edge_cache.py .py 1 symbol added, 2 symbols modified
+ test_orphaned_tmp_swept_on_startup method method test_orphaned_tmp_swept_on_startup L303–310
~ tests/test_invariant_file_cache.py .py 1 symbol added, 1 symbol modified
+ test_orphaned_tmp_swept_on_startup method method test_orphaned_tmp_swept_on_startup L315–323
← 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:54a266e734569229e06919ddea3ebdbb10106c1fbf9581ef76b91ea1fbb59242 --body "your comment"