SDKs

Rust

Direct access to the core storage engine.

llms.txt

Installation

Terminal
cargo add mentedb

Or add to your Cargo.toml:

TOML
[dependencies]
mentedb = "0.43"

The crate is the core storage engine. Optional features: enrichment for the background pipeline.

Quick Start

Rust
use mentedb::{MenteDb, process_turn::ProcessTurnInput};
use mentedb::context::DeltaTracker;

let db = MenteDb::open(std::path::Path::new("./my-data"))?;
let mut delta = DeltaTracker::default();

let result = db.process_turn(&ProcessTurnInput {
    user_message: "I switched from Postgres to SQLite".into(),
    assistant_response: Some("Got it!".into()),
    turn_id: 0,
    project_context: None,
    agent_id: None,
    user_id: None,
    session_id: None,
}, &mut delta)?;

for memory in &result.context {
    println!("{}", memory.memory.content);
}

DeltaTracker is imported from mentedb_context, not from mentedb::process_turn. session_id, project_context, and agent_id are optional on ProcessTurnInput; pass None when unused.

API Methods

The Rust API provides direct access to the core storage engine.

MenteDb::open(path: &Path) -> MenteResult<Self>

Open or create a database at the given path with the default embedder.

Returns: MenteDb

process_turn(&self, input: &ProcessTurnInput, delta_tracker: &mut DeltaTracker) -> MenteResult<ProcessTurnResult>

Run the full conversation-turn pipeline in a single call. Handles context retrieval, episodic storage, write inference, fact extraction, pain signals, action detection, phantom tracking, trajectory, speculative caching, and auto-maintenance.

Returns: ProcessTurnResult

store(&self, node: MemoryNode) -> MenteResult<()>

Store a memory node. The node must have content and memory type, and optionally tags and embedding.

Returns: MenteResult<MemoryId>

recall_similar(&self, embedding: &[f32], k: usize) -> MenteResult<Vec<(MemoryId, f32)>>

Search memories by vector similarity (cosine). Returns top-k results with scores. Variants add filtering, hybrid BM25 matching, point-in-time queries, and multi-query fusion.

Returns: Vec<(MemoryId, f32)>

relate(&self, edge: MemoryEdge) -> MenteResult<()>

Create a typed, weighted edge between two memories.

Returns: MenteResult<()>

get_memory(&self, id: MemoryId) -> MenteResult<MemoryNode>

Retrieve a specific memory node by ID.

Returns: MenteResult<MemoryNode>

invalidate_memory(&self, id: MemoryId, at: Timestamp) -> MenteResult<()>

Mark a memory as invalid at a specific timestamp without deleting it. Keeps the memory but excludes it from searches.

Returns: MenteResult<()>

forget(&self, id: MemoryId) -> MenteResult<()>

Delete a memory by its ID.

Returns: MenteResult<()>

flush(&self) -> MenteResult<()> / close(&self) -> MenteResult<()>

Writes are already durable when they return. flush checkpoints the write ahead log (call it periodically, not after every write); close runs a full flush with every snapshot and releases all resources.

Returns: MenteResult<()>