1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Raised from the default 128 so the compiler can finish proving the worker's
// spawned future is `Send`: that proof recurses through the falkordb -> redis ->
// mio TcpStream type tree, which is deep but valid. The future is genuinely
// `Send`; only the proof depth exceeds the default.
//! Memoir memory substrate as an embeddable Rust library.
//!
//! Memoir stores what an agent is told and derives durable facts from it. A
//! write is an *episodic* memory (the raw utterance); a background worker runs
//! LLM extraction over it to produce *semantic* memories (the facts). See
//! [`memory::MemoryKind`]. Recall reads the semantic layer; the episodic layer
//! is the audit trail and the source the facts are re-derived from.
//!
//! Two contracts govern how that derived knowledge is ranked and corrected.
//!
//! # Selection
//!
//! Retrieval is not just cosine similarity. Each semantic memory carries a
//! [`memory::Confidence`] (how sure the extractor was) and, once the categorize
//! worker runs, a category label. [`client::Client::query`] blends these signals
//! — cosine, confidence, recency, and a category bonus — via a
//! [`client::RankingStrategy`] with tunable [`client::BlendWeights`]. Use
//! [`client::Client::search`] for raw nearest-neighbor hits, `query` when you
//! want ranked, prompt-shaped context. Hard filters (`min_confidence`,
//! `category`) exclude rows; the blend *weights* them — distinct mechanisms.
//!
//! # Correction
//!
//! Semantic memory is **always derived, never hand-written** — there is no API
//! to edit a semantic row's content. A consumer corrects a wrong fact by
//! *teaching*: [`client::Client::feedback`] supplies the correction, and memoir
//! re-derives from the episodic source. Editing the episodic source itself
//! ([`client::Client::edit`]) cascades the same way. Both retire the stale
//! derived rows and re-extract — see [`memory::RetirementReason`] for why a
//! retirement is `Rejected` (a wrong extraction, counts against extraction
//! accuracy) versus `Stale` (the source changed, does not). Retired rows are
//! kept (not deleted) so accuracy is measurable via
//! [`client::Client::extraction_stats`].
//!
//! # Categorization
//!
//! The category label is populated by a zero-shot NLI classifier
//! ([`nli::NliClassifier`]), opt-in via [`nli::NliConfig`] on the client builder.
//! Without it, categorization is skipped and the category-bonus blend term is
//! inert.
pub use ;
pub use ;
pub use DEFAULT_EXTRACTION_PROMPT;
/// Default Postgres schema for memoir-core's tables.
///
/// Consumers configuring a custom schema via `Client::builder().schema(...)`
/// can fall back to this when no override is supplied.
pub use DEFAULT_SCHEMA;