pub struct SqliteMemoryProvider { /* private fields */ }Expand description
SQLite-backed MemoryProvider.
Implementations§
Source§impl SqliteMemoryProvider
impl SqliteMemoryProvider
Sourcepub async fn open(
path: impl AsRef<Path>,
embedder: Arc<dyn Embedder>,
) -> Result<Self, SqliteMemoryError>
pub async fn open( path: impl AsRef<Path>, embedder: Arc<dyn Embedder>, ) -> Result<Self, SqliteMemoryError>
Open or create a memory database at the given path. Loads
sqlite-vec into the connection, runs pending migrations, returns
a ready-to-use provider.
The provided Embedder determines the dimensionality used at
write time. The migration schema currently hard-codes FLOAT[384]
for memory_vec; if the embedder’s dim is different, writes that
produce embeddings will fail with DimMismatch. Future migrations
will make the dim configurable.
Sourcepub fn with_write_hook(self, hook: Arc<dyn MemoryWriteHook>) -> Self
pub fn with_write_hook(self, hook: Arc<dyn MemoryWriteHook>) -> Self
Attach a MemoryWriteHook consulted
before every write. Use this to connect policy checks, redaction rules,
or application-specific write filters.
Sourcepub fn with_summarizer(self, summarizer: Arc<dyn Summarizer>) -> Self
pub fn with_summarizer(self, summarizer: Arc<dyn Summarizer>) -> Self
Attach a Summarizer used by
MemoryProvider::summarize_session, rollup_day, and
rollup_rule_week. Applications pass a concrete downstream
cel_memory::Summarizer implementation; tests can pass a
cel_memory::MockSummarizer.
Calling MemoryProvider::summarize_session without first
attaching a summarizer returns
cel_memory::MemoryError::NotImplemented when summarization is not
configured.
Sourcepub async fn open_in_memory(
embedder: Arc<dyn Embedder>,
) -> Result<Self, SqliteMemoryError>
pub async fn open_in_memory( embedder: Arc<dyn Embedder>, ) -> Result<Self, SqliteMemoryError>
Open an in-memory database for tests.
Trait Implementations§
Source§impl MemoryProvider for SqliteMemoryProvider
impl MemoryProvider for SqliteMemoryProvider
Source§fn retrieve<'life0, 'async_trait>(
&'life0 self,
query: MemoryQuery,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn retrieve<'life0, 'async_trait>(
&'life0 self,
query: MemoryQuery,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
query.k
chunks in descending relevance order.Source§fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<Option<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<Option<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<Option<MemorySession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<Option<MemorySession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn list_sessions<'life0, 'async_trait>(
&'life0 self,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemorySession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemorySession>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn write<'life0, 'async_trait>(
&'life0 self,
new_chunk: NewMemoryChunk,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write<'life0, 'async_trait>(
&'life0 self,
new_chunk: NewMemoryChunk,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
id, created_at,
tier, and embedding-model metadata.Source§fn write_batch<'life0, 'async_trait>(
&'life0 self,
chunks: Vec<NewMemoryChunk>,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn write_batch<'life0, 'async_trait>(
&'life0 self,
chunks: Vec<NewMemoryChunk>,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn open_session<'life0, 'async_trait>(
&'life0 self,
init: NewMemorySession,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemorySession>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn open_session<'life0, 'async_trait>(
&'life0 self,
init: NewMemorySession,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemorySession>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn close_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
outcome: SessionOutcome,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn close_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
outcome: SessionOutcome,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn rename_session<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
title: &'life2 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn rename_session<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
title: &'life2 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Err(NotFound) if the session
does not exist. The v1 BasicMemoryProvider implements this in-memory;
SqliteMemoryProvider updates the memory_sessions.title column.Source§fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
pinned: bool,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pin<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
pinned: bool,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn update_importance<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
importance: f32,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_importance<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
importance: f32,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
[0.0, 1.0]. The v1 stub no-ops (importance is not scored).Source§fn supersede<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
old_id: &'life1 str,
new_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn supersede<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
old_id: &'life1 str,
new_id: &'life2 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
old_id as superseded by new_id. Both chunks are retained;
retrieval surfaces the superseder. The v1 stub no-ops.Source§fn record_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
retrieved_by: &'life2 str,
used: bool,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn record_access<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
retrieved_by: &'life2 str,
used: bool,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
used=true
signals the consumer cited or acted on it (drives importance bumps
in the full impl).Source§fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
reason: EvictionReason,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
chunk_id: &'life1 str,
reason: EvictionReason,
) -> Pin<Box<dyn Future<Output = MemoryResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn delete_matching<'life0, 'async_trait>(
&'life0 self,
predicate: MemoryPredicate,
reason: EvictionReason,
) -> Pin<Box<dyn Future<Output = MemoryResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_matching<'life0, 'async_trait>(
&'life0 self,
predicate: MemoryPredicate,
reason: EvictionReason,
) -> Pin<Box<dyn Future<Output = MemoryResult<usize>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn purge_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MemoryResult<PurgeReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn purge_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MemoryResult<PurgeReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn summarize_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn summarize_session<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
JobSummary chunk synthesizing the named session. Inserted
into the store; returned to the caller. v1 stub returns
crate::MemoryError::NotImplemented.Source§fn rollup_day<'life0, 'async_trait>(
&'life0 self,
date: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rollup_day<'life0, 'async_trait>(
&'life0 self,
date: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Rollup chunks for the named day. v1 stub returns
crate::MemoryError::NotImplemented. Read moreSource§fn rollup_day_forced<'life0, 'async_trait>(
&'life0 self,
date: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn rollup_day_forced<'life0, 'async_trait>(
&'life0 self,
date: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<Vec<MemoryChunk>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Rollup chunks for the named day even
if a prior rollup exists. Default impl delegates to
Self::rollup_day for backward compatibility; the SQLite
provider overrides to actually honour the force flag.Source§fn rollup_rule_week<'life0, 'life1, 'async_trait>(
&'life0 self,
rule_id: &'life1 str,
week_start: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rollup_rule_week<'life0, 'life1, 'async_trait>(
&'life0 self,
rule_id: &'life1 str,
week_start: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Rollup chunk for the named rule across the named week.
v1 stub returns crate::MemoryError::NotImplemented. Read moreSource§fn rollup_rule_week_forced<'life0, 'life1, 'async_trait>(
&'life0 self,
rule_id: &'life1 str,
week_start: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn rollup_rule_week_forced<'life0, 'life1, 'async_trait>(
&'life0 self,
rule_id: &'life1 str,
week_start: NaiveDate,
) -> Pin<Box<dyn Future<Output = MemoryResult<MemoryChunk>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Rollup chunk for the named rule + week even if
a prior rollup exists. Default impl delegates to
Self::rollup_rule_week for backward compatibility; the SQLite
provider overrides to honour the force flag.Source§fn run_aging_sweep<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MemoryResult<AgingReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run_aging_sweep<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = MemoryResult<AgingReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn re_embed_all<'life0, 'life1, 'async_trait>(
&'life0 self,
target_model: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<ReEmbedReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn re_embed_all<'life0, 'life1, 'async_trait>(
&'life0 self,
target_model: &'life1 str,
) -> Pin<Box<dyn Future<Output = MemoryResult<ReEmbedReport>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
crate::MemoryError::NotImplemented.