Skip to main content

cel_memory_sqlite/
lib.rs

1//! SQLite-backed [`MemoryProvider`] — one concrete persistence backend for the
2//! `cel-memory` crate.
3//!
4//! This crate implements the [`MemoryProvider`] contract on top of a single
5//! local SQLite file (plus `sqlite-vec` for vector search and FTS5 for lexical
6//! search). It owns persistence behavior only — schema, migrations, embeddings,
7//! hybrid retrieval, caching — and depends on `cel-memory` for the trait and
8//! value types. It does not depend on `cel-cortex` or `cel-brief`.
9//!
10//! Cellar is the motivating consumer, but the crate is a drop-in backend for
11//! any agent runtime that speaks `cel_memory::MemoryProvider`.
12//!
13//! What it delivers:
14//!
15//! - Schema migrations for every memory table (`memory_chunks`, `memory_vec`,
16//!   `memory_fts`, `memory_sessions`, `memory_summary_members`,
17//!   `memory_access_log`, `memory_eviction_log`).
18//! - `sqlite-vec` extension loaded into the connection at open time so the
19//!   `memory_vec` virtual table is available.
20//! - [`Embedder`] trait + [`MockEmbedder`] (always available) and
21//!   `FastEmbedEmbedder` (gated behind the `fastembed` feature) for the
22//!   real `bge-small-en-v1.5` model.
23//! - [`SqliteMemoryProvider`] implementing the full [`MemoryProvider`] surface:
24//!   writes, hybrid (vector + FTS + recency) retrieval with a TTL+LRU cache,
25//!   sessions, summarization and rollups (via an injected
26//!   [`cel_memory::Summarizer`]), aging sweeps, export, and stats. The only
27//!   method still returning `Err(NotImplemented)` is `re_embed_all`.
28//!
29//! [`MemoryProvider`]: cel_memory::MemoryProvider
30
31#![deny(missing_docs)]
32#![warn(rust_2018_idioms)]
33
34pub(crate) mod cache;
35pub mod embedder;
36pub mod error;
37pub mod migrations;
38pub mod provider;
39pub mod vec_extension;
40
41#[cfg(feature = "fastembed")]
42pub mod fastembed_impl;
43
44pub use embedder::{Embedder, MockEmbedder};
45pub use error::SqliteMemoryError;
46pub use provider::SqliteMemoryProvider;
47
48#[cfg(feature = "fastembed")]
49pub use fastembed_impl::FastEmbedEmbedder;