a maintained fork of CozoDB · v0.19.4

An embedded Datalog database for agent memory.

mnestic stores relations, graphs, and vectors in one transactional engine that runs inside your process. It continues CozoDB, which called itself “the hippocampus for AI,” and is tuned for recall: search by meaning, keyword, and link in one query, and keep the history of every fact if you want it.

MPL-2.0 · Rust and Python · RocksDB, SQLite, or in-memory storage

recall.cozo · graph and vector in one query
1# every memory reachable from a seed, then the 12 nearest by meaning
2recall[to] := *recalls{ from: $seed, to }
3recall[to] := recall[via], *recalls{ from: via, to }
4 
5?[memory, dist] :=
6 recall[memory],
7 ~memory:embedding{ memory |
8 query: $cue, k: 12, ef: 80, bind_distance: dist
9 }
10:order dist
11:limit 12

Why a fork

CozoDB has had no release since December 2024. We forked it under the same MPL-2.0 license to keep it maintained and to tune it for agent memory. Every change from upstream is documented, and every original copyright is kept.

Compared with Postgres, DuckDB, and Neo4j.

Each is good at its own job. None of them does all of this inside your process: one request that searches by meaning, keyword, and link; long recursive chains; and a record of what used to be true.

PostgresDuckDBNeo4jmnestic
Where it runsSeparate serverIn your processSeparate server (JVM)In your process, or as a server
Long chains of linksRecursive CTEs, slow as chains growNot supportedGood for paths, weaker for general recursive rulesRecursive Datalog rules
Meaning, keyword, and link search in one requestpgvector and full-text, combined by youVector and full-text extensions, no graphVector index, combined with the rest by youOne call, fused and ranked by the engine
What used to be trueBuild it yourselfBuild it yourselfBuild it yourselfBuilt in, on two time axes

Structural differences, not a speed test. Each column uses that database's official tooling: pgvector and full-text search for Postgres, the vector and full-text extensions for DuckDB, Cypher and the vector index for Neo4j.

What you get from CozoDB.

Datalog, not SQL
Queries compose rule by rule, and recursion is built in. A safe subset of aggregations works inside recursion.
Relational, graph, and vector
One data model covers all three. Graph structure is just relations and rules, so there is no separate property-graph schema to maintain.
Embedded like SQLite
Runs in your process with no server and no setup. It can also run as a server when you need one.
Vector search
Disk-resident HNSW indexes join Datalog directly, so a nearest-neighbour search can sit inside a recursive query and be filtered by any other rule.
Full-text and near-duplicates
BM25 full-text search and MinHash-LSH near-duplicate detection are part of the engine, not extensions.
History on two time axes
A relation can record when a fact was true and when the database learned it. Query either axis, or both.

Upstream measured 100K+ QPS on mixed read and write transactions, 250K+ QPS read-only, and under 1 ms for a two-hop query on a graph of 1.6M vertices and 31M edges (2020 Mac mini, RocksDB).

What the fork adds.

The query language is unchanged. The work has gone into query speed, correctness, and the operations agent memory needs. A few of the measured changes:

Every fork release since 0.8.0

What did we believe in June about September?

Valid time is when a fact holds in the world. Transaction time is when the database learned it, and the engine stamps it at commit. With both, you can reproduce an old answer exactly and tell a change in the world apart from a correction.

  • Transaction time is set by the engine, never by the caller, so history cannot be backdated.
  • ::history, ::history_gc and ::evict manage the record; garbage collection keeps as-of reads exact.
  • Opt-in per relation. Current-value reads run within about 4–12% of a plain relation.
beliefs.cozo · two time axes
1# opt in: valid time + an engine-stamped transaction time
2:create beliefs {claim, vld: Validity, tt: TxTime => conf: Float}
3 
4# the engine stamps tt at commit; callers never set it
5?[c, v, conf] <- [['q3 pipeline is healthy', '2026-09-01', 0.35]]
6:put beliefs {c, v => conf}
7 
8# what did we believe on June 30 about September?
9?[conf] := *beliefs{claim: 'q3 pipeline is healthy', conf
10 @ (vt: '2026-09-01', tt: '2026-06-30')}
11 
12# the audit trail: every belief, correction, and cessation
13::history beliefs [['q3 pipeline is healthy']]

Vector, keyword, and graph search in one call.

hybrid_search runs all three searches in one transaction, merges them with reciprocal rank fusion, and can drop near-duplicates with MMR. Query vectors, text, and seeds go in as parameters, never as interpolated strings.

main.rs · hybrid_search
1use cozo::{DbInstance, GraphLeg, HybridSearch, MmrParams};
2 
3// HNSW + full-text + graph proximity in one call,
4// fused with reciprocal rank fusion, then MMR.
5let recalls = db.hybrid_search(&HybridSearch {
6 relation: "memory".into(),
7 vector_index: "embedding".into(),
8 query_vector: cue, // Vec<f32> from your embedder
9 vector_k: 24,
10 ef: 80,
11 fts_index: "summary_fts".into(),
12 query_text: "pricing decision",
13 fts_k: 24,
14 // graph leg: expand 2 hops from a seed over *recalls,
15 // ranked by hop distance and fused in the same call.
16 graph_legs: vec![GraphLeg {
17 edge_relation: "recalls".into(),
18 seeds: vec![seed.into()],
19 max_hops: 2,
20 ..GraphLeg::default()
21 }],
22 rrf_k: 60.0,
23 mmr: Some(MmrParams { lambda: 0.5, k: 12, embedding_col: "embedding".into() }),
24 ..HybridSearch::default()
25})?;

Recall, measured.

On 40,000 chunks and 1,000 queries, mnestic's recall@10 is 0.954, level with DuckDB and far above LanceDB, which has no graph signal. The difference is where the work happens: mnestic fuses all three signals in one call, so a new memory is searchable on every signal the moment it is written.

Enginerecall@10SignalsFusionSearchable right after a write
mnestic0.954vector, full-text, graphin the engine, one call100%
duckdb 1.5.30.957vector, full-text, graphin app code0% full-text †
sqlite 0.1.91.000*vector, full-text, graphin app code100%
lancedb 0.330.501vector, full-textin the engine, no graphn/a, no graph

The fused call takes about 42 ms at p50, roughly 4× faster than running the same three searches separately. It is not the lowest latency in the table.

† DuckDB's full-text index is built once and misses new rows until it is rebuilt. *SQLite's recall comes from an exact brute-force scan, not an approximate index. 40k chunks, 1,000 queries, k=10, two-hop graph; 2026-05-31, macOS arm64; numbers are hardware-specific. Recall uses synthetic embeddings on the SQLite build; latency was checked separately on RocksDB with real sentence-transformer embeddings. Kùzu is excluded because its extension host has been offline since the project was archived in October 2025. Methodology · raw results

What it's for.

Agent memory across sessions
An agent needs to recall last week's decision by meaning, by exact words, and by what it is linked to. In mnestic that is the single query in the hero, and it sees writes from a second ago.
Audit trails
A transaction was rated low risk in June and looks wrong in September. With transaction time you can replay exactly what the system knew in June, and nobody can backdate it.
Graphs without a second database
Fraud rings share devices, addresses, and cards several hops from the flagged account. Recursive rules find those links in the same database that holds the rest of your data.

Add it to your project.

Cargo.toml
1# default: in-memory and SQLite storage
2cargo add mnestic
3 
4# or, with RocksDB storage:
5# mnestic = { version = "0.19", features = ["storage-rocksdb"] }
main.rs
1use cozo::DbInstance;
2 
3let db = DbInstance::new("mem", "", "")?;
4db.run_default("?[x] := x in [1, 2, 3]")?;
Python, with LangChain and LlamaIndex adapters
1pip install mnestic # the engine (abi3 wheels)
2pip install langchain-mnestic # LangChain vector store
3pip install llama-index-vector-stores-mnestic

The import name is still cozo

The crate is published as mnestic, but the library name is still cozo, so existing use cozo::… code and downstream crates compile without changes.

Attribution

mnestic is not the official CozoDB and is not affiliated with or endorsed by its authors. The original design is the work of Ziyang Hu and the Cozo Project Authors.