Skip to main content

Crate mnemoria

Crate mnemoria 

Source
Expand description

§Mnemoria

Persistent, git-friendly memory storage for AI agents with hybrid semantic + full-text search.

Mnemoria provides a single-file, append-only memory store that AI assistants (Claude, GPT, Cursor, or any LLM-based tool) can use to remember information across conversations and sessions. Memories are stored in a binary log with CRC32 checksum chaining for corruption detection and crash recovery.

§Key features

  • Hybrid search — combines BM25 full-text search (via Tantivy) with semantic vector search (via model2vec) using Reciprocal Rank Fusion.
  • Git-friendly — the append-only binary format produces clean diffs and merges well in version control.
  • Corruption-resistant — CRC32 checksum chain with automatic crash recovery and log truncation on open.
  • Multi-process safe — advisory file locking and per-process ephemeral search indexes allow concurrent readers and writers.

§Quick start

use mnemoria::{Mnemoria, EntryType};
use std::path::Path;

// Create a new memory store
let memory = Mnemoria::create(Path::new("./my-memories")).await?;

// Store a memory
let id = memory.remember(
    "my-agent",
    EntryType::Discovery,
    "Rust async patterns",
    "Use tokio::spawn for CPU-bound work inside async contexts",
).await?;

// Search by meaning
let results = memory.search_memory("async concurrency", 5, None).await?;
for result in &results {
    println!("[{}] {} (score: {:.3})", result.entry.entry_type, result.entry.summary, result.score);
}

// Retrieve by ID
let entry = memory.get(&id).await?;

§Storage format

A memory store is a directory containing:

FilePurpose
log.binAppend-only binary log (rkyv)
manifest.jsonMetadata and checksum state
mnemoria.lockAdvisory file lock

The search index is ephemeral — rebuilt from log.bin on each open — and is stored in the OS temp directory, not in the memory store itself.

§Feature flags

FlagDefaultDescription
model2vecyesEnables semantic embeddings via model2vec.

Without model2vec, only BM25 keyword search is available.

Re-exports§

pub use api::Mnemoria;
pub use constants::APP_NAME;
pub use constants::DEFAULT_MODEL_ID;
pub use error::Error;
pub use error::Result;
pub use error::lock_mutex;
pub use types::Config;
pub use types::DurabilityMode;
pub use types::EntryType;
pub use types::MemoryEntry;
pub use types::MemoryStats;
pub use types::SearchResult;
pub use types::TimelineOptions;

Modules§

api
constants
embeddings
error
search
storage
Low-level storage primitives for the append-only binary log.
types