Expand description
Heuristic fidelity scorer for Context-Adaptive Memory (CAM).
FidelityScorer is a stateless scoring engine that assigns a three-level
representation (ContextFidelity::Full / ContextFidelity::Compressed /
ContextFidelity::Placeholder) to each message in the context window. Scoring is
driven by weighted signals: temporal recency, role importance, keyword-based semantic
relevance, and optional plan hints.
FidelityConfig holds all tuning knobs; it is read from [memory.fidelity] in
config.toml. When enabled = false (the default), the scorer returns immediately
without modifying the message window.
§Embed pre-pass
The private embed_prepass_dyn helper runs concurrently via
futures::stream::buffer_unordered and populates per-message embedding vectors before
scoring. The public embed_prepass is a thin wrapper over the same helper for
closure-based callers (e.g. unit tests). The concurrency bound is controlled by
FidelityConfig::embed_concurrency (default 32).
Structs§
- Fidelity
Config - Configuration for the heuristic fidelity scorer (CAM §8.1).
- Fidelity
Scorer - Stateless heuristic scorer that assigns and applies fidelity levels to a message window.
Functions§
- apply_
input_ cap - Truncate
contentin place using themax_tokens * 4byte approximation. - embed_
prepass - Run embed calls for
messagesconcurrently, returning per-index embedding vectors.