Skip to main content

InMemoryMemoryStore

Struct InMemoryMemoryStore 

Source
pub struct InMemoryMemoryStore { /* private fields */ }
Expand description

A process-local MemoryStore. Same semantics as the SQLite store, nothing persisted. Lexical scores use word overlap.

Implementations§

Trait Implementations§

Source§

impl Default for InMemoryMemoryStore

Source§

fn default() -> Self

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

impl MemoryStore for InMemoryMemoryStore

Source§

fn upsert_fact<'life0, 'async_trait>( &'life0 self, fact: NewFact, embedding: Option<StoredEmbedding>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Insert, reinforce or supersede (see the trait docs). embedding describes the new value’s search text, when one was computed.
Source§

fn upsert_fact_with_access<'life0, 'life1, 'async_trait>( &'life0 self, fact: NewFact, embedding: Option<StoredEmbedding>, access: &'life1 FactAccess, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<UpsertOutcome>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

MemoryStore::upsert_fact that records who may see the fact, atomically with the write. A reinforced fact keeps the narrowest of its access and access (FactAccess::narrowest); a new version takes access. The default ignores access, which leaves the fact unclassified and so private.
Source§

fn fact_access<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, ids: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Who may see these facts, by id, for ids in scope the store knows. A fact absent from the map is unclassified and treated as private.
Source§

fn supersede_fact<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, scope: &'life1 str, category: &'life2 str, key: &'life3 str, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Mark the active fact for this key superseded. false if none.
Source§

fn active_facts<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<FactRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Every active fact in scope, with embeddings.
Source§

fn fact_graph_scores<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, seed_ids: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

How related each active fact in scope is to the seed_ids (facts that matched the query), 0.0-1.0 by fact id. The default has no graph: an empty map leaves the graph signal at 0 and ranking as it was. A store that keeps no edges can use related_fact_scores.
Source§

fn fact_history<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, scope: &'life1 str, category: &'life2 str, key: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Fact>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

All versions of one key, oldest first, superseded ones included.
Source§

fn record_fact_recalls<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [String], now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Bump recall_count and set last_recalled_at for these facts.
Source§

fn insert_episode<'life0, 'async_trait>( &'life0 self, episode: NewEpisode, embedding: Option<StoredEmbedding>, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Episode>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn insert_episode_with_access<'life0, 'life1, 'async_trait>( &'life0 self, episode: NewEpisode, embedding: Option<StoredEmbedding>, access: &'life1 FactAccess, now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<Episode>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

MemoryStore::insert_episode that records who may see the episode. The default ignores access, leaving the episode private.
Source§

fn episode_access<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, ids: &'life2 [String], ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, FactAccess>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Who may see these episodes; see MemoryStore::fact_access.
Source§

fn episodes<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<EpisodeRecord>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Every episode in scope, with embeddings.
Source§

fn record_episode_recalls<'life0, 'life1, 'async_trait>( &'life0 self, ids: &'life1 [String], now: DateTime<Utc>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn decay<'life0, 'life1, 'async_trait>( &'life0 self, now: DateTime<Utc>, config: &'life1 RetentionConfig, ) -> Pin<Box<dyn Future<Output = Result<DecayReport>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Apply recall decay and retention (see RetentionConfig). The default does nothing, for stores whose backend handles expiry.
Source§

fn stale_embeddings<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, model: &'life1 str, kind: RecordKind, after_id: Option<&'life2 str>, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<StaleEmbedding>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Up to limit records of kind with no vector or a vector from a model other than model, in ascending id order after after_id. Superseded facts are excluded: they are never compared. The default finds none, so such a store keeps lexical recall for old rows.
Source§

fn replace_embedding<'life0, 'life1, 'async_trait>( &'life0 self, stale: &'life1 StaleEmbedding, embedding: StoredEmbedding, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Replace a stale record’s vector, only if it still has the model stale reported; false otherwise. Changes nothing else about the record: updated_at feeds ranking and this is not a new statement.
Source§

fn stats<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<MemoryStats>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn fact_lexical_scores<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, query: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Lexical relevance (0.0-1.0) of active facts to query, by fact id. Facts absent from the map score 0. The default is word overlap over Fact::search_text.
Source§

fn search_facts<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _scope: &'life1 str, _query: &'life2 str, _query_embedding: Option<&'life3 StoredEmbedding>, _limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredFact>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Native ranked search. Return Some to bypass the scorer: the result is used as is (already filtered, ordered, at most limit). The default None lets crate::Memory score candidates itself.
Source§

fn episode_lexical_scores<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, scope: &'life1 str, query: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<HashMap<String, f32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Lexical relevance of episodes; default word overlap.
Source§

fn search_episodes<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _scope: &'life1 str, _query: &'life2 str, _query_embedding: Option<&'life3 StoredEmbedding>, _limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<ScoredEpisode>>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Native ranked episode search; see MemoryStore::search_facts.

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> 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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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