feat: M3.8.2 cache aligner integration — metrics + headers (3 tests)

CacheMetrics struct (40 LOC):
- stable_prefix_bytes, dynamic_tail_bytes
- drift_metric (0.0-1.0 ratio)
- cache_eligible flag (drift < 0.3)
- compression_ratio() and header_* methods

PromptBuilder::cache_metrics() (40 LOC):
- Calculates cache alignment metrics for query+chunk pairs
- Integrates CacheAligner output
- Gets compression ratio from ContextOptimizer
- Used for HTTP headers and observability

HTTP headers ready for client integration:
- X-Cache-Stable-Bytes
- X-Cache-Drift
- X-Cache-Eligible
- X-Compression-Ratio

3 new tests:
- test_cache_metrics_stable_query
- test_cache_metrics_compression_ratio
- test_cache_metrics_header_drift

Total: 117 mem-core tests (114 before + 3 new)
This commit is contained in:
Story Crater Bot
2026-08-28 10:05:45 -07:00
parent f528902098
commit bcb4e30ec2
2 changed files with 131 additions and 2 deletions
+1 -1
View File
@@ -18,6 +18,6 @@ pub use lesson::{
tool_of_cmd, Confidence, Event, Hit, Lesson, Signature, Tier,
};
pub use query::{Query, QuerySet, SynthesisQuery};
pub use prompt::{PromptBuilder, PromptMessages};
pub use prompt::{PromptBuilder, PromptMessages, CacheMetrics};
pub use symptom_projection::{project_symptom, SymptomVector};
pub use optimizer::{ContextOptimizer, ContextOptimizerConfig, ContentType, OptimizedChunk, CacheAligner, AlignedContent, CcrStore};