pub struct FidelityConfig {Show 20 fields
pub enabled: bool,
pub w_semantic: f32,
pub w_temporal: f32,
pub w_importance: f32,
pub w_plan: f32,
pub full_threshold: f32,
pub compressed_threshold: f32,
pub compressed_max_tokens: usize,
pub regrade_threshold: f32,
pub min_query_length: usize,
pub max_scored_messages: usize,
pub exempt_tail_messages: usize,
pub compress_provider: Option<ProviderName>,
pub semantic_scoring_provider: Option<ProviderName>,
pub lookahead_depth: u8,
pub embed_concurrency: usize,
pub max_embed_input_tokens: Option<usize>,
pub max_compress_input_tokens: Option<usize>,
pub embed_timeout_secs: u64,
pub compress_timeout_secs: u64,
}Expand description
Configuration for the heuristic fidelity scorer (CAM §8.1).
All weight fields must be positive. Weights are normalised at runtime by the sum of active weights (INV-05).
§Examples
use zeph_config::fidelity::FidelityConfig;
let cfg = FidelityConfig::default();
assert!(!cfg.enabled, "fidelity scoring is off by default");
assert!((cfg.w_semantic - 0.3).abs() < f32::EPSILON);Fields§
§enabled: boolMaster switch. When false, no fidelity scoring occurs.
w_semantic: f32Cosine/keyword semantic relevance weight.
Previously named w_keyword in config — that name is still accepted for compatibility.
w_temporal: f32Recency weight.
w_importance: f32Role-based importance weight.
w_plan: f32Plan-hint relevance weight (active only when planned_tools is non-empty).
full_threshold: f32Score threshold above which a message retains Full fidelity.
compressed_threshold: f32Score threshold above which a message is Compressed (not Placeholder).
compressed_max_tokens: usizeMaximum tokens kept when rendering a Compressed message.
regrade_threshold: f32Budget ratio at which AgeMem triggers a proactive regrade.
min_query_length: usizeMinimum query length for semantic signal to be active.
max_scored_messages: usizeMaximum number of messages scored per turn (performance cap).
exempt_tail_messages: usizeNumber of the newest messages exempt from scoring when the window exceeds
max_scored_messages. These messages default to Full fidelity.
A value of 0 (the default) means no tail exemption beyond the hard
max_scored_messages cap.
compress_provider: Option<ProviderName>LLM provider name (from [[llm.providers]]) used to summarize messages during
Compressed rendering. When None, truncation is used instead.
semantic_scoring_provider: Option<ProviderName>Embedding provider name (from [[llm.providers]]) used for semantic similarity scoring.
When None, keyword overlap is used instead.
lookahead_depth: u8Maximum BFS depth for PAACE lookahead hints derived from the orchestration DAG.
Controls how many steps ahead in the active task graph are converted to
PlannedToolHint values and passed to FidelityScorer.
0 disables lookahead (returns an empty hint slice). Valid range: 0..=5.
embed_concurrency: usizeMaximum number of concurrent provider.embed() calls during the cold-start pre-pass.
Controls the buffer_unordered(N) bound. Higher values reduce latency on cold starts
at the cost of more concurrent API requests. Default is 32.
max_embed_input_tokens: Option<usize>Hard cap on message content length (in approximate tokens) fed to provider.embed().
When Some(n), message content is truncated to approximately n * 4 characters
(at a valid UTF-8 char boundary) before the embed call. None means no cap.
max_compress_input_tokens: Option<usize>Hard cap on message content length (in approximate tokens) fed to the LLM compress call.
When Some(n), the input is truncated to approximately n * 4 characters before
the compress call. None means no cap. Independent of the existing 2× cost guard.
embed_timeout_secs: u64Timeout in seconds for embed calls in fidelity scoring (default: 30).
Applies to both the query embed and each per-message embed in the pre-pass.
Timed-out calls are skipped with a warn-level log; scoring falls back to keyword overlap.
compress_timeout_secs: u64Timeout in seconds for the LLM compress call in fidelity scoring (default: 30).
When the LLM compress call exceeds this limit it is cancelled and truncation is used as a fallback. Set higher if your compress provider has high cold-start latency.
Implementations§
Source§impl FidelityConfig
impl FidelityConfig
Sourcepub fn default_lookahead_depth() -> u8
pub fn default_lookahead_depth() -> u8
Default value for lookahead_depth: 3 BFS steps.
Used as the serde default function and for callers that need the fallback value without
constructing a full FidelityConfig.
Sourcepub fn validate(&self) -> Result<(), String>
pub fn validate(&self) -> Result<(), String>
Validate threshold ordering: full_threshold >= compressed_threshold >= 0.0.
Call this at config load time to catch inverted thresholds before they silently
misclassify messages (score in compressed_threshold..full_threshold becomes Full
instead of Compressed when the invariant is violated).
§Errors
Returns an error string describing the violated constraint.
§Examples
use zeph_config::fidelity::FidelityConfig;
let valid = FidelityConfig::default();
assert!(valid.validate().is_ok());
let invalid = FidelityConfig { full_threshold: 0.2, compressed_threshold: 0.5, ..FidelityConfig::default() };
assert!(invalid.validate().is_err());Trait Implementations§
Source§impl Clone for FidelityConfig
impl Clone for FidelityConfig
Source§fn clone(&self) -> FidelityConfig
fn clone(&self) -> FidelityConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more