Skip to main content

Module fidelity

Module fidelity 

Source
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§

FidelityConfig
Configuration for the heuristic fidelity scorer (CAM §8.1).
FidelityScorer
Stateless heuristic scorer that assigns and applies fidelity levels to a message window.

Functions§

apply_input_cap
Truncate content in place using the max_tokens * 4 byte approximation.
embed_prepass
Run embed calls for messages concurrently, returning per-index embedding vectors.