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
+1 -1
View File
@@ -20,4 +20,4 @@ pub use lesson::{
pub use query::{Query, QuerySet, SynthesisQuery};
pub use prompt::{PromptBuilder, PromptMessages};
pub use symptom_projection::{project_symptom, SymptomVector};
pub use optimizer::{ContextOptimizer, ContextOptimizerConfig, ContentType, OptimizedChunk};
pub use optimizer::{ContextOptimizer, ContextOptimizerConfig, ContentType, OptimizedChunk, CacheAligner, AlignedContent, CcrStore};