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`] from [`cel_memory`] (re-exported here)
18//!   and `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//!   `re_embed_all` re-embeds stored vectors when the target model matches
25//!   the configured [`Embedder`].
26//!
27//! [`MemoryProvider`]: cel_memory::MemoryProvider
28
29#![deny(missing_docs)]
30#![warn(rust_2018_idioms)]
31
32pub(crate) mod cache;
33pub mod embedder;
34pub mod error;
35pub mod migrations;
36pub mod provider;
37pub mod vec_extension;
38
39#[cfg(feature = "fastembed")]
40pub mod fastembed_impl;
41
42pub use embedder::{Embedder, MockEmbedder};
43pub use error::SqliteMemoryError;
44pub use provider::SqliteMemoryProvider;
45
46#[cfg(feature = "fastembed")]
47pub use fastembed_impl::FastEmbedEmbedder;