pub struct AdmissionControl { /* private fields */ }Expand description
A-MAC adaptive memory admission controller (#2317).
Evaluates five factors (future utility, factual confidence, semantic novelty, temporal recency, content-type prior) and rejects messages below the configured composite score threshold before they are persisted.
Optionally extended with a goal-conditioned write gate (#2408) that adds a sixth factor based on the cosine similarity between the current goal embedding and the candidate memory.
§Examples
use zeph_memory::{AdmissionControl, AdmissionWeights};
let weights = AdmissionWeights {
future_utility: 0.3,
factual_confidence: 0.2,
semantic_novelty: 0.2,
temporal_recency: 0.1,
content_type_prior: 0.2,
goal_utility: 0.0,
};
let controller = AdmissionControl::new(0.4, 0.1, weights);Implementations§
Source§impl AdmissionControl
impl AdmissionControl
Sourcepub fn new(
threshold: f32,
fast_path_margin: f32,
weights: AdmissionWeights,
) -> Self
pub fn new( threshold: f32, fast_path_margin: f32, weights: AdmissionWeights, ) -> Self
Create a new admission controller.
threshold— composite score[0, 1]below which messages are rejected.fast_path_margin— when all non-LLM factors already push the score far above the threshold (by at least this margin), the LLMfuture_utilitycall is skipped.weights— factor weights; normalized automatically so they sum to1.0.
Sourcepub fn with_provider(self, provider: AnyProvider) -> Self
pub fn with_provider(self, provider: AnyProvider) -> Self
Attach a dedicated LLM provider for future_utility evaluation.
When set, this provider is used instead of the caller-supplied fallback.
Sourcepub fn with_goal_gate(self, config: GoalGateConfig) -> Self
pub fn with_goal_gate(self, config: GoalGateConfig) -> Self
Enable goal-conditioned write gate (#2408).
Sourcepub async fn evaluate(
&self,
content: &str,
role: &str,
fallback_provider: &AnyProvider,
qdrant: Option<&Arc<EmbeddingStore>>,
goal_text: Option<&str>,
) -> AdmissionDecision
pub async fn evaluate( &self, content: &str, role: &str, fallback_provider: &AnyProvider, qdrant: Option<&Arc<EmbeddingStore>>, goal_text: Option<&str>, ) -> AdmissionDecision
Evaluate admission for a message.
goal_text: optional current-turn goal context for goal-conditioned scoring.
Ignored when the goal gate is disabled or goal_text is None/trivial (< 10 chars).
Fast path: skips LLM when heuristic-only score is already above threshold + fast_path_margin.
Slow path: calls LLM for future_utility when borderline.
On LLM failure, future_utility defaults to 0.5 (neutral).
Auto Trait Implementations§
impl !Freeze for AdmissionControl
impl !RefUnwindSafe for AdmissionControl
impl Send for AdmissionControl
impl Sync for AdmissionControl
impl Unpin for AdmissionControl
impl UnsafeUnpin for AdmissionControl
impl !UnwindSafe for AdmissionControl
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request