velesdb_memory/lib.rs
1#![deny(unsafe_code)]
2//! # VelesDB-memory
3//!
4//! Local-first **memory** layer for AI agents, exposed through a single MCP
5//! server. This crate is the domain core: it maps five memory operations onto
6//! `VelesDB`'s in-core Agent Memory SDK.
7//!
8//! | Operation | Meaning |
9//! |------------|----------------------------------------------------|
10//! | `remember` | store a fact (+ optional links to other memories) |
11//! | `recall` | semantic retrieval of similar facts |
12//! | `relate` | create a typed edge between two memories |
13//! | `forget` | delete a memory |
14//! | `why` | recall + multi-hop graph traversal |
15//!
16//! ## License boundary (non-negotiable)
17//!
18//! This crate exposes **memory semantics only** (results), never raw database
19//! capabilities (`query(velesql)`, `create_collection`, `upsert(vectors)`,
20//! `traverse(graph)`). Exposing the raw engine would constitute a "Substantial
21//! Set" of the Software's features and breach the `VelesDB` Core License 1.0
22//! (§1, No Hosted or Managed Service). See `VISION.md` §5 and `PLAN.md` Phase 4A.
23
24pub mod embedder;
25pub mod error;
26pub mod extract;
27/// Content-addressed memory ids — internal; ids surface through the service API.
28pub(crate) mod id;
29/// Resource caps (DoS limits) shared by every adapter — the single source of
30/// truth for fact size, recall limit, and `why` hop depth.
31pub mod limits;
32/// The MCP server transport. Gated behind the default `mcp` feature so library
33/// consumers (e.g. the language bindings) can depend on the memory core without
34/// pulling the `rmcp`/`tokio` server stack.
35#[cfg(feature = "mcp")]
36pub mod mcp;
37/// The domain data model — the value types the memory layer exchanges
38/// (`Link`, `Recollection`, `ColumnFilter`, `Explanation`, …), separate from the
39/// service that computes them.
40pub mod model;
41/// Shared JSON Schema post-processing (strips `schemars`' non-standard integer
42/// `format` keywords so strict MCP clients don't warn on every id field).
43mod schema;
44pub mod service;
45
46/// Default embedding dimension — the single source of truth, taken from the
47/// SDK's own default so the server, library, and tests never restate the value.
48pub const DEFAULT_DIMENSION: usize = velesdb_core::agent::DEFAULT_DIMENSION;
49
50pub use embedder::{DynEmbedder, EmbedError, Embedder, HashEmbedder};
51#[cfg(feature = "ollama")]
52pub use embedder::{OllamaEmbedder, DEFAULT_OLLAMA_MODEL, DEFAULT_OLLAMA_URL};
53pub use error::{ErrorCategory, MemoryError};
54#[cfg(feature = "extract")]
55pub use extract::OllamaExtractor;
56pub use extract::{DynExtractor, ExtractError, ExtractedFact, Extractor};
57#[cfg(feature = "mcp")]
58pub use mcp::McpServer;
59pub use model::{ColumnFilter, ColumnOp, Explanation, Link, MemoryEdge, MemoryNode, Recollection};
60pub use service::{MemoryService, Metadata};