Repository navigation
CC-390: cache parsed snapshot segments across refresh cycles - #464
Conversation
This comment has been minimized.
This comment has been minimized.
|
Automatic approval held Kody's assessment:
|
…ll (Kody round 1)
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…ode+birthtime key
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
Automatic approval held: Kody could not verify the current PR head and labels. |
Addresses the remaining tracked #390 matrix finding f6: the one-minute refresh re-read and re-parsed every snapshot in the 90-minute window each cycle.
#390 stays closed; this completes its tracked remainder. Independent of #462 (different files).
Summary
Implements CC-390: caches parsed snapshot segments across refresh cycles so unchanged snapshots are reused. The cache is process-wide and shared across readers for the one-minute refresh path.
Changes
MuseCodeSnapshotSegmentCachekeyed by path, mtime and size with hit/miss counters, reset support and 8,192-entry capacity with clear-on-full behavior.MuseCodeSessionReader.segment(...)through the shared cache, with existing read/parse logic preserved inparseSegment(...).Tests
testReaderServesUnchangedSnapshotsFromParseCachecovering cache reuse on second read with no additional parses.testReaderReparsesASnapshotRewrittenInPlacecovering re-parse after rewrite with new mtime/content.Risks / Open review findings
Sources/QuotaCore/MuseCodeSessionReader.swift, both unverified as resolved: weak cache key may return stale tokens on same-size rewrite (line 185), and cache clears all entries on overflow causing thrash (line 197).Summary
Addresses CC-390 by retaining parsed snapshot segments in
MuseCodeSnapshotSegmentCacheacross refresh cycles. Changes cache overflow handling to evict a single entry when over capacity instead of clearing all entries, so an over-cap working set degrades to partial misses rather than causing full re-parses on the next scan.Tests Added
Adds
testParseCacheOverflowEvictsOneEntryInsteadOfClearingAll, which fills the cache to capacity, inserts one overflow entry, then verifies the remaining entries stay cached without re-parsing. Run results and runtime verification are unverified in the provided changes.Summary
Caches parsed Muse Code snapshot segments across refresh cycles for CC-390. The snapshot segment cache key now includes path, file resource identity, modification time, and size, so unchanged snapshots avoid a second read and parse across the one-minute refresh cycles. The change also guards against stale hits when a snapshot path is reused after rotation by replacement.
Changes
MuseCodeSnapshotSegmentCache.segment(sessionId:url:modified:size:parse:)to includefileResourceIdentifierin the cache key alongside path, mtime, and size. Updated comments to document write-once UUID names with rotation by replacement.Impact
Reduces repeated file reads and parsing during refreshes when snapshots are unchanged, while preserving correctness for replaced files. No additional user-facing behavior change beyond efficiency and staleness protection is inferred from this diff.
Testing
No test additions or test execution evidence are present in the provided diff, so behavior remains unverified.
Risks / Open Review Findings
String(describing:)file identifier may break snapshot cache hits atSources/QuotaCore/MuseCodeSessionReader.swift:193.Summary
Related to CC-390. Avoids re-parsing snapshot segments across refresh cycles by caching by content identity, while still re-parsing when the underlying file is replaced.
Changes
systemFileNumber+ creation date, modification date, and size usingFileManager.attributesOfIteminstead of cached URL resource values. This distinguishes a replacement file with identical path/size/mtime and avoids returning stale segments with one stat per lookup.Tests
testParseCacheReparseesReplacedFileWithIdenticalMetadatafor same-path replacement with identical size and mtime. Pass/fail, execution, and runtime verification remain unverified in this summary.