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

feat: migrate invariants cache to .muse/cache/invariants.msgpack (Phase 4)

- Add invariants_cache_path(root) to paths.py - _InvariantFileCache: rename _muse_dir → _cache_dir; load() derives cache_dir = muse_dir / 'cache'; save() calls mkdir(parents, exist_ok) - Add size property and prune() method (were missing) - Full docstrings on class, load(), save(), get(), put(), prune(), empty() - New test_invariant_file_cache.py: 29 tests across tiers 1/2/5/6/7 (unit, integration, data integrity, performance, security) - 89 existing invariant tests: all pass

sha256:f3b726b50f0aee3622bba751e0a67aa7ae4cf75a798477dbce581940b6a9cf70 sha
+51 ~9 symbols
3 changed · 970 in snapshot files
sha256:c70c0cc4c2694aa1cd311fe23c839348f317cca2af1d90886d36efc8cc4f8a47 snapshot
+51
symbols added
~9
symbols modified
3
files changed
970
files in snapshot
0
dead code introduced
Semantic Changes 60 symbols
~ tests/test_invariant_file_cache.py .py 47 symbols added
+ TestDataIntegrity class class TestDataIntegrity L249–335
+ test_corrupt_bytes_returns_empty method method test_corrupt_bytes_returns_empty L252–256
+ test_invalid_entry_skipped_valid_survives method method test_invalid_entry_skipped_valid_survives L274–295
+ test_missing_entries_key_returns_empty method method test_missing_entries_key_returns_empty L266–272
+ test_no_tmp_file_leftover_after_save method method test_no_tmp_file_leftover_after_save L307–313
+ test_non_dict_entry_value_skipped method method test_non_dict_entry_value_skipped L297–305
+ test_old_location_file_is_ignored method method test_old_location_file_is_ignored L315–335
+ test_wrong_version_returns_empty method method test_wrong_version_returns_empty L258–264
+ TestIntegration class class TestIntegration L165–241
+ test_dirty_false_after_successful_save method method test_dirty_false_after_successful_save L208–213
+ test_load_missing_file_returns_empty method method test_load_missing_file_returns_empty L168–171
+ test_load_without_muse_dir_returns_empty method method test_load_without_muse_dir_returns_empty L225–229
+ test_multiple_entries_round_trip method method test_multiple_entries_round_trip L231–241
+ test_save_creates_file_at_correct_path method method test_save_creates_file_at_correct_path L173–178
+ test_save_load_round_trip_preserves_all_fields method method test_save_load_round_trip_preserves_all_fields L180–200
+ test_save_noop_when_not_dirty method method test_save_noop_when_not_dirty L202–206
+ test_second_save_does_not_update_mtime method method test_second_save_does_not_update_mtime L215–223
+ TestPerformance class class TestPerformance L343–381
+ test_warm_cache_skips_ast_parse method method test_warm_cache_skips_ast_parse L346–381
+ TestSecurity class class TestSecurity L389–427
+ test_deeply_nested_payload_does_not_crash method method test_deeply_nested_payload_does_not_crash L409–427
+ test_mode_000_file_returns_empty_no_raise method method test_mode_000_file_returns_empty_no_raise L393–407
+ TestUnit class class TestUnit L88–157
+ test_different_keys_independent method method test_different_keys_independent L114–121
+ test_empty_cache_dir_is_none method method test_empty_cache_dir_is_none L149–151
+ test_empty_save_is_noop method method test_empty_save_is_noop L153–157
+ test_get_miss_returns_none method method test_get_miss_returns_none L91–93
+ test_prune_noop_when_all_live method method test_prune_noop_when_all_live L142–147
+ test_prune_removes_stale_sets_dirty method method test_prune_removes_stale_sets_dirty L132–140
+ test_put_marks_dirty method method test_put_marks_dirty L101–105
+ test_put_same_key_overwrites method method test_put_same_key_overwrites L107–112
+ test_put_then_get_hit method method test_put_then_get_hit L95–99
+ test_size_grows_with_put method method test_size_grows_with_put L126–130
+ test_size_starts_zero method method test_size_starts_zero L123–124
+ _cache_path function function _cache_path L79–80
+ _file_data function function _file_data L60–76
+ _make_repo function function _make_repo L54–57
+ _FILE_CACHE_VERSION import import _FILE_CACHE_VERSION L42–42
+ _FileData import import _FileData L42–42
+ _InvariantFileCache import import _InvariantFileCache L42–42
+ annotations import import annotations L32–32
+ msgpack import import msgpack L39–39
+ os import import os L34–34
+ pathlib import import pathlib L35–35
+ pytest import import pytest L40–40
+ stat import import stat L36–36
+ time import import time L37–37
~ muse/core/paths.py .py 1 symbol added
+ invariants_cache_path function function invariants_cache_path L185–187
~ muse/plugins/code/_invariants.py .py 3 symbols added, 9 symbols modified
+ prune method method prune L352–363
+ size method method size L339–341
+ _cache_dir import import _cache_dir L84–84
~ empty
~ get
~ load
~ put
~ save
Files Changed
+1 ~2
970 in snapshot
← 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:f3b726b50f0aee3622bba751e0a67aa7ae4cf75a798477dbce581940b6a9cf70 --body "your comment"