pub struct VerifiedCache { /* private fields */ }Expand description
A bounded, in-process store of verified answers.
Implementations§
Source§impl VerifiedCache
impl VerifiedCache
Sourcepub fn new(ttl: Duration, max_entries: usize) -> Self
pub fn new(ttl: Duration, max_entries: usize) -> Self
Build a cache holding at most max_entries for ttl.
Sourcepub fn get(
&self,
tenant: &str,
prompt_hash: &str,
ladder: &[String],
now: Instant,
) -> Option<Entry>
pub fn get( &self, tenant: &str, prompt_hash: &str, ladder: &[String], now: Instant, ) -> Option<Entry>
Look up a proven answer for this prompt under this ladder.
Sourcepub fn offer(
&self,
trace: &Trace,
response: &ModelResponse,
ladder: &[String],
now: Instant,
) -> bool
pub fn offer( &self, trace: &Trace, response: &ModelResponse, ladder: &[String], now: Instant, ) -> bool
Offer a finished decision to the cache.
Returns whether it was stored. Everything about the safety of this feature is in the rejection rules below, so they are checked here — in one place, against the receipt — rather than trusted to each call site to have got right.
Sourcepub fn retract(&self, source: Uuid) -> usize
pub fn retract(&self, source: Uuid) -> usize
Evict every entry proven by source, because that proof has been retracted.
Called when a deferred gate or downstream outcome reports a Fail for a decision. Without
this, an answer the world has since disproven keeps being replayed until its TTL expires —
and each replay carries a cache_source pointing at a receipt that now records a failure,
so the audit trail would actively contradict what was served.
Returns how many entries were dropped. A single decision can back several keys once the same prompt is seen under more than one ladder, so this scans by source rather than assuming one.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for VerifiedCache
impl RefUnwindSafe for VerifiedCache
impl Send for VerifiedCache
impl Sync for VerifiedCache
impl Unpin for VerifiedCache
impl UnsafeUnpin for VerifiedCache
impl UnwindSafe for VerifiedCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 more