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 any prompt builder, planner, or runtime.
9//!
10//! What it delivers:
11//!
12//! - Schema migrations for every memory table (`memory_chunks`, `memory_vec`,
13//!   `memory_fts`, `memory_sessions`, `memory_summary_members`,
14//!   `memory_access_log`, `memory_eviction_log`).
15//! - `sqlite-vec` extension loaded into the connection at open time so the
16//!   `memory_vec` virtual table is available.
17//! - [`Embedder`] trait + [`MockEmbedder`] (always available) and
18//!   `FastEmbedEmbedder` (gated behind the `fastembed` feature) for the
19//!   real `bge-small-en-v1.5` model.
20//! - [`SqliteMemoryProvider`] implementing the full [`MemoryProvider`] surface:
21//!   writes, hybrid (vector + FTS + recency) retrieval with a TTL+LRU cache,
22//!   sessions, summarization and rollups (via an injected
23//!   [`cel_memory::Summarizer`]), aging sweeps, export, and stats. The only
24//!   method still returning `Err(NotImplemented)` is `re_embed_all`.
25//!
26//! [`MemoryProvider`]: cel_memory::MemoryProvider
27
28#![deny(missing_docs)]
29#![warn(rust_2018_idioms)]
30
31pub(crate) mod cache;
32pub mod embedder;
33pub mod error;
34pub mod migrations;
35pub mod provider;
36pub mod vec_extension;
37
38#[cfg(feature = "fastembed")]
39pub mod fastembed_impl;
40
41pub use embedder::{Embedder, MockEmbedder};
42pub use error::SqliteMemoryError;
43pub use provider::SqliteMemoryProvider;
44
45#[cfg(feature = "fastembed")]
46pub use fastembed_impl::FastEmbedEmbedder;