Installation
mnestic is published to crates.io as mnestic, but its importable library
name stays cozo. That means every use cozo::… in existing CozoDB-based
code keeps working unchanged — adopting the fork is a dependency swap, not a
rewrite.
Add the crate
# default features = in-memory + SQLite backends
cargo add mnesticBecause the library name is cozo, you import it as:
use cozo::DbInstance;mnestic
If you are migrating an existing CozoDB project, you can keep the dependency
key as cozo using Cargo's rename idiom — see
Migrating from CozoDB.
Python
The PyO3 binding ships abi3 wheels for Linux (x86_64, aarch64), macOS (Intel,
Apple Silicon), and Windows — plus first-party LangChain and LlamaIndex
adapters that expose hybrid_search as a vector store:
pip install mnestic
pip install langchain-mnestic # LangChain VectorStore
pip install llama-index-vector-stores-mnestic # LlamaIndex vector storefrom mnestic import CozoDbPy
db = CozoDbPy("mem", "", "{}")
db.run_script("?[x] <- [[1],[2],[3]]", {}, False)mnestic
Specific to mnestic 0.10.5. The PyPI wheel now bundles the RocksDB backend
on every platform, so CozoDbPy("rocksdb", path) works straight from
pip install mnestic — earlier wheels were compact/SQLite-only. The sdist
stays compact, so the persistent backend is wheel-only.
Choosing a backend
mnestic inherits CozoDB's storage backends. Select them with Cargo features:
| Backend | Feature | Persistence | Notes |
|---|---|---|---|
| In-memory | compact (default) | None | Fastest; great for tests and ephemeral graphs. |
| SQLite | compact (default) | File | Single-file, portable, no native build step. |
| RocksDB | storage-rocksdb | Directory | Highest throughput and concurrency; the fork's non-blocking HNSW build path is RocksDB-only. |
# Cargo.toml — enable the RocksDB backend
mnestic = { version = "0.13.1", features = ["storage-rocksdb"] }Note
RocksDB compiles a C++ dependency, so the first build is slow. The in-memory and SQLite backends need no native toolchain.
mnestic
Specific to mnestic 0.13.0 and later (via mnestic-rocks 0.1.10). The RocksDB
BlockBasedTableOptions you configure — block cache, block size,
cache_index_and_filter_blocks — now actually reach RocksDB. Through 0.12.2 they
were loaded and then silently discarded on every open, so the read cache reverted
to RocksDB's 8 MB default and block_size to 4 KB regardless of your options
file. The fix changes what RocksDB writes as well as what it caches (new SSTs
pick up the configured block_size), but it is forward-compatible and needs no
migration — and it means any read-path benchmark you took before upgrading
measured a slower engine than mnestic actually is.
Caution
Upgrading to 0.12.2? Check your Validity column defaults first.
Validity default [floor(now()), true] — and every spelling built on
now(), parse_timestamp(), round(), floor() or ceil(), all of which
return float seconds where a validity stores integer microseconds — has
been stamping every row it wrote at 1970. Through 0.12.1 the engine
coerced the float silently; since 0.12.2 the write raises
eval::float_validity instead. The schema still compiles, so the first sign
will be a failing write. The correct spelling multiplies through and truncates:
last_seen: Validity default [to_int(now() * 1000000), true]default 'ASSERT' was always correct and stays correct. Rows already written
carry a valid time no upgrade can repair — they read back normally, and are
wrong only under time travel. See Time travel
and the 0.12.2 notes.
Caution
Upgrading to 0.12.1 with an existing database? If you use full-text search,
you have one action to take. Full-text postings leaked on every in-place
update of a relation carrying only an FTS index — a bug inherited from upstream
CozoDB that affects every release through 0.12.0. The fix stops new leakage
but cannot evict postings already written, so an existing index is affected
today and upgrading alone does not repair it. Rebuild each affected relation
once with the new ::reindex:
::reindex my_relationIt is a maintenance operation — it holds the relation's write lock for the rebuild. See Release history for the full 0.12.1 batch.
mnestic
Specific to mnestic 0.12.0. The optional rayon dependency is bounded
>=1.10, <1.11: rayon 1.11 breaks graph_builder 0.4.x, the CSR-builder
crate behind the graph-algo feature, so a fresh resolve could land on a
broken pair. The bound makes every fresh build work; it will be relaxed only
after a verified graph-algo build against a newer rayon.
Your first query
use cozo::DbInstance;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// engine, path, options — "mem" needs no path
let db = DbInstance::new("mem", "", "")?;
let result = db.run_default("?[x] := x in [1, 2, 3]")?;
println!("{:?}", result.rows);
Ok(())
}To open a persistent store, pass the backend and a path:
// SQLite file
let db = DbInstance::new("sqlite", "mnestic.db", "")?;
// RocksDB directory (requires the storage-rocksdb feature)
let db = DbInstance::new("rocksdb", "mnestic.rocksdb", "")?;Where to next
- Learn the query language in the Tutorial.
- See what the fork adds in What mnestic adds.
- Build a recall pipeline with Hybrid retrieval.