Skip to main content

FidelityConfig

Struct FidelityConfig 

Source
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: bool

Master switch. When false, no fidelity scoring occurs.

§w_semantic: f32

Cosine/keyword semantic relevance weight.

Previously named w_keyword in config — that name is still accepted for compatibility.

§w_temporal: f32

Recency weight.

§w_importance: f32

Role-based importance weight.

§w_plan: f32

Plan-hint relevance weight (active only when planned_tools is non-empty).

§full_threshold: f32

Score threshold above which a message retains Full fidelity.

§compressed_threshold: f32

Score threshold above which a message is Compressed (not Placeholder).

§compressed_max_tokens: usize

Maximum tokens kept when rendering a Compressed message.

§regrade_threshold: f32

Budget ratio at which AgeMem triggers a proactive regrade.

§min_query_length: usize

Minimum query length for semantic signal to be active.

§max_scored_messages: usize

Maximum number of messages scored per turn (performance cap).

§exempt_tail_messages: usize

Number 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: u8

Maximum 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: usize

Maximum 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: u64

Timeout 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: u64

Timeout 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

Source

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.

Source

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

Source§

fn clone(&self) -> FidelityConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FidelityConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FidelityConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for FidelityConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for FidelityConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more