feat: M3.8.1 phase 3 — CacheAligner + CCR Store (18 tests)

CacheAligner (180 LOC, 8 tests):
- Detects dynamic patterns: timestamps, UUIDs, session IDs, temp paths, SHAs
- Uses once_cell Lazy statics + Regex for pattern matching
- Separates stable prefix (cache-able) from dynamic tail (varies)
- Reports drift metrics (0.0-1.0 ratio of dynamic content)
- Preserves identical prefixes across calls for KV cache hits

CcrStore (170 LOC, 10 tests):
- LRU cache with IndexMap (preserves insertion order)
- SHA256 hashing for content identification
- TTL-based expiry (default 1hr, configurable)
- Thread-safe (Mutex-wrapped)
- Supports large content (tested 100KB+)

ContextOptimizer integration (2 tests):
- Wired CCR store into optimizer
- Stores originals when compression occurs + CCR enabled
- Returns hash for retrieval hints

50 optimizer tests total:
Phase 1 (17) + Phase 2 (15) + Phase 3 (18) = 50 passing
This commit is contained in:
Story Crater Bot
2026-08-28 09:39:31 -07:00
parent fd4ca2a17a
commit e96510d80d
6 changed files with 447 additions and 2 deletions
+2
View File
@@ -19,3 +19,5 @@ time = { version = "0.3", features = ["serde", "formatting", "parsing", "macros"
magika = "1.1.0"
ort = { version = "2.0.0-rc.12", default-features = true }
regex = "1.10"
once_cell = "1.19"
indexmap = "2.0"