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
JsonCrusher (300 LOC): - Field variance analysis for mid-array selection - Allocation: 30% start (schema), 15% end (recency), 55% importance - Truncates long strings (>500 chars) with markers - Handles nested structures recursively DiffCompressor (180 LOC): - Keeps: file headers, hunk markers (@@), change lines (+/-) - Drops: context lines (spaces), unchanged content - Preserves binary file markers 32 optimizer tests total (17 phase1 + 15 phase2): - JsonCrusher: 8 tests (object, array, boundaries, truncation, nesting) - DiffCompressor: 7 tests (simple, multiple hunks, new/deleted files)
ContentRouter uses Google Magika ML for content detection (<1ms) with regex fallback. Detects JSON, code, logs, diffs, config, text. LogCompressor reuses M3.7.7 patterns (markers, cascade, strip_ansi) to shrink build logs by keeping errors/stacks and dropping noise. 17 unit tests passing: - router: json, code, diff, log, text detection - log: error lines, stack traces, ansi stripping, compression - optimizer: token estimation, passthrough mode Magika + ort ONNX runtime added to Cargo.toml.