Skip to main content

MemoryStore

Trait MemoryStore 

Source
pub trait MemoryStore: Send + Sync {
    // Required methods
    fn store<'life0, 'async_trait>(
        &'life0 self,
        entry: MemoryEntry,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn search<'life0, 'life1, 'async_trait>(
        &'life0 self,
        query: &'life1 MemoryQuery,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredMemory>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryEntry>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn dedupe_check<'life0, 'life1, 'async_trait>(
        &'life0 self,
        content_hash: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn expire_stale<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn search_with_embedding<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        query: &'life1 MemoryQuery,
        _query_embedding: &'life2 [f32],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredMemory>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Trait for the recall memory storage backend.

Implementations use SQLite (sqlx for general, libSQL for vectors). All writes go through memory policies (dedupe, importance, TTL).

Required Methods§

Source

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

Store a new memory entry (after policy enforcement).

Source

fn search<'life0, 'life1, 'async_trait>( &'life0 self, query: &'life1 MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredMemory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Search memories using hybrid BM25 + vector + MMR + temporal decay.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryEntry>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get a memory entry by ID.

Source

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

Delete a memory entry by ID.

Source

fn dedupe_check<'life0, 'life1, 'async_trait>( &'life0 self, content_hash: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if content with this hash already exists. Returns the existing entry ID if found.

Source

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

Expire entries past their TTL. Returns count of expired entries.

Provided Methods§

Source

fn search_with_embedding<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, query: &'life1 MemoryQuery, _query_embedding: &'life2 [f32], ) -> Pin<Box<dyn Future<Output = Result<Vec<ScoredMemory>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Search memories using a caller-supplied query embedding when available.

Implementors§