Skip to main content

cel_memory/
lib.rs

1//! cel-memory — the durable cross-turn memory contract for AI agents.
2//!
3//! This crate answers one question: **what should persist across turns?** It
4//! owns the memory *contract* — the [`MemoryProvider`] trait plus the value
5//! types every backend and caller share (chunks, sessions, queries, retrieval
6//! profiles, caller scopes, write hooks, summaries, rollups, aging, export).
7//! Storage backends implement the trait; callers depend only on it.
8//!
9//! The crate is deliberately narrow. It does **not** observe live environment
10//! state and it does **not** assemble per-turn LLM prompts. `cel-memory` owns
11//! persistence only.
12//!
13//! [`BasicMemoryProvider`] is the in-crate reference implementation — real
14//! bodies for [`MemoryProvider::retrieve`], [`MemoryProvider::write`], session
15//! lifecycle, export, stats, summarization, rollups, and re-embed metadata
16//! updates when a [`Summarizer`] is attached; no-ops for
17//! [`MemoryProvider::update_importance`] and [`MemoryProvider::supersede`].
18
19#![deny(missing_docs)]
20#![warn(rust_2018_idioms)]
21
22pub mod basic;
23pub mod chunk;
24pub mod error;
25pub mod importance;
26pub mod offdevice_hook;
27pub mod ops;
28pub mod provider;
29pub mod query;
30pub mod session;
31pub mod summarizer;
32pub mod write_hook;
33
34// Convenient re-exports — the symbols every caller will name.
35pub use basic::BasicMemoryProvider;
36pub use chunk::{ChunkKind, ChunkSource, MemoryChunk, MemoryTier, NewMemoryChunk};
37pub use error::{MemoryError, Result};
38pub use importance::score as score_importance;
39pub use offdevice_hook::{
40    ClosureOffdeviceHook, OffdeviceCallDescriptor, OffdeviceCallHook, OffdeviceDecision,
41};
42pub use ops::{
43    AccessEntry, AgingReport, EvictionEntry, EvictionReason, ExportBundle, ExportFilter,
44    MemoryStats, PurgeReport, ReEmbedReport,
45};
46pub use provider::MemoryProvider;
47pub use query::{CallerScope, MemoryPredicate, MemoryQuery, RetrievalProfile};
48pub use session::{MemorySession, NewMemorySession, SessionFilter, SessionOutcome};
49pub use summarizer::{
50    MockSummarizer, MockSummaryCall, Summarizer, SummarizerError, SummarizerResult, SummaryContext,
51};
52pub use write_hook::{ClosureHook, MemoryWriteHook, WriteDecision};