Skip to main content

EpisodicStore

Struct EpisodicStore 

Source
pub struct EpisodicStore<'a> { /* private fields */ }
Expand description

Dedicated persistence view over the episodic-record LMDB database.

Implementations§

Source§

impl<'a> EpisodicStore<'a>

Source

pub fn with_adaptive_aliases(self, aliases: AdaptiveAliases) -> Self

Attach adaptive aliases for query and ingest-time key expansion.

Source

pub fn with_enrichment(self, enrichment: VocabularyEnrichment) -> Self

Attach vocabulary enrichment for index-time term expansion.

Source

pub fn with_embedder(self, embedder: Arc<dyn Embedder + Send + Sync>) -> Self

Attach an embedder for vector reranking.

Source

pub fn append(&self, record: &EpisodicRecord) -> Result<()>

Append a source record without allowing an existing raw ID to be overwritten.

Source

pub fn append_batch(&self, records: &[EpisodicRecord]) -> Result<()>

Append many source records, then project them into the sidecar in one term-index transaction.

Source

pub fn rebuild_sidecar(&self) -> Result<usize>

Rebuild the DUP_SORT sidecar from the authoritative raw records.

Used when a store contains records but an empty v2 sidecar (legacy stores whose postings lived in the retired v1 database, or stores whose sidecar was lost). The raw lane is never touched; a failure leaves the sidecar empty and search falls back to the raw scan.

Source

pub fn sidecar_is_empty(&self) -> Result<bool>

Number of (term, id) postings in the sidecar.

LMDB 0.8 exposes no per-database stat, so emptiness is checked by peeking the first entry (cheap; whole-db counts are not needed). iter() (not iter_start) is used because iter_start unwraps MDB_FIRST, which fails NotFound on an empty database.

Source

pub fn record_count(&self) -> Result<u64>

Number of raw records in the authoritative lane.

Source

pub fn append_explicit( &self, record: &EpisodicRecord, policy: EpisodicCapturePolicy, ) -> Result<bool>

Append an explicit record according to the capture policy.

Source

pub fn append_explicit_batch( &self, records: &[EpisodicRecord], policy: EpisodicCapturePolicy, ) -> Result<usize>

Append many explicit records according to the capture policy.

Source

pub fn get(&self, id: EpisodicId) -> Result<Option<EpisodicRecord>>

Read an episodic record by its canonical ID.

Source

pub fn replace_content(&self, id: EpisodicId, new_content: &str) -> Result<bool>

Replace one raw record’s content in place (credential redaction / repair path), keeping the raw lane and the term sidecar consistent.

Returns false when no record with that id exists. Postings for terms the new content no longer contains are removed, and the new terms are posted in the same transaction. The raw record is overwritten even when private/model-excluded — the bytes must not survive anywhere, even in records the lane never indexes (2026-09-21 reviewer finding).

Source

pub fn transition( &self, id: EpisodicId, transition: MemoryTransition, ) -> Result<()>

Apply an explicit lifecycle transition to a persisted record.

Source

pub fn scan( &self, session_id: Option<Uuid>, limit: usize, ) -> Result<Vec<EpisodicRecord>>

Return records in sequence order, optionally restricted to a session.

Source

pub fn search( &self, query: &str, limit: usize, include_historical: bool, ) -> Result<Vec<EpisodicSearchResult>>

Search current episodic records using deterministic token overlap.

This is a v6 library path only. It does not alter the v5 MCP search route and keeps source records attached to every hit.

When the query asks for the current/latest value of something (see is_current_query), the topic cluster is reordered by deterministic chronology so the most recent statement outranks older ones — post-retrieval temporal resolution, not a scoring change.

Source

pub fn search_with_limits( &self, query: &str, limit: usize, candidate_limit: usize, include_historical: bool, ) -> Result<Vec<EpisodicSearchResult>>

Search with an explicit candidate budget before selective reranking.

Uses multi-query pool widening: the original query plus sub-queries focused on key content words generate candidate IDs. All candidates are then scored with the primary query’s deterministic scoring. This helps answer turns that match few original query terms but match the key entity strongly enter the candidate pool.

Source

pub fn search_with_rerank( &self, query: &str, limit: usize, candidate_limit: usize, include_historical: bool, alpha: f32, rerank_pool: usize, ) -> Result<Vec<EpisodicSearchResult>>

Search with vector reranking on top of deterministic scoring.

Pipeline: deterministic scoring → top-N candidates → embed query + candidates → reranking → top-K.

Modes by alpha:

  • alpha >= 2.0protected top-K (ConvMemory v2 pattern): fully reorder only the deterministic top-limit set by cosine similarity. Membership is fixed, so recall@limit is preserved by construction; only ordering (R@1/MRR) can change.
  • 1.0 <= alpha < 2.0tiebreaker mode: only reorder adjacent candidates whose deterministic scores are within δ=0.05, using cosine as the tiebreaker.
  • alpha < 1.0hybrid blending: score = α·det_norm + (1-α)·cosine.

Falls back to search_with_limits() when no embedder is attached.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for EpisodicStore<'a>

§

impl<'a> !UnwindSafe for EpisodicStore<'a>

§

impl<'a> Freeze for EpisodicStore<'a>

§

impl<'a> Send for EpisodicStore<'a>

§

impl<'a> Sync for EpisodicStore<'a>

§

impl<'a> Unpin for EpisodicStore<'a>

§

impl<'a> UnsafeUnpin for EpisodicStore<'a>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Fruit for T
where T: Send + Downcast,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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