Skip to main content

mnestic (Python)

Embedded graph + vector + full-text database with Datalog queries — a maintained fork of CozoDB, tuned as a substrate for agentic memory. This package is the in-process Python binding (no server required).

mnestic is not the official CozoDB and is not affiliated with or endorsed by its original authors. All credit for the original design belongs to Ziyang Hu and the Cozo Project Authors. See the fork repository for provenance and licensing.

pip install mnestic
from mnestic import CozoDbPy

db = CozoDbPy("mem", "", "{}")  # engines: "mem", "sqlite" (file path), "rocksdb" (dir path)
db.run_script("?[x] <- [[1],[2],[3]]", {}, False)

# One-call hybrid retrieval (HNSW + full-text fused with Reciprocal Rank Fusion),
# over a relation that has an HNSW index and an FTS index:
hits = db.hybrid_search({
    "relation": "docs",
    "vector_index": "vec", "query_vector": [0.1, 0.9], "vector_k": 5,
    "fts_index": "fts", "query_text": "vector search", "fts_k": 5,
})
# -> {"headers": ["id", "score"], "rows": [["d3", 0.033], ...], "next": None}

# Pass "detailed": True for per-leg contributions — one row per (item, leg)
# with the within-leg rank the fusion used and the leg's raw score:
# headers ["id","score","list_id","leg_rank","leg_score"]

The "rocksdb" persistent backend now ships in the published wheel — CozoDbPy("rocksdb", "./my.db", "{}") works straight from pip install mnestic. The source distribution stays SQLite/compact-only, so the persistent engine is wheel-only.

Upgrade note (0.10.6): a persistent database whose relation catalogs were last written by a build older than 0.10.0 could fail to open with Cannot deserialize relation metadata from bytes after upgrading to 0.10.0–0.10.5. 0.10.6 fixes this — legacy catalogs open again with no migration, so upgrade to 0.10.6 if you carry a pre-0.10.0 database.

run_script takes an optional timeout= — a per-query wall-clock budget in seconds; on expiry the query raises an eval::timeout error. db.set_default_query_timeout(secs) sets a Db-wide default and db.default_query_timeout() reads it back; the effective budget for a query is the minimum of that default and any per-call timeout.

RDF at the boundary — and what it means for the wheel's trust posture

The wheel ships the rdf-io engine feature: RdfReader reads Turtle, N-Triples, N-Quads and TriG into a fixed 6-column relational shape (subject, predicate, object, graph, language_tag, datatype) straight from CozoScript, and IRI helper functions (iri_valid, iri_resolve, curie_expand, curie_compact) handle boundary identity:

db.run_script("""
    triples[s, p, o, g, lang, dt] <~ RdfReader(url: 'file://./data.ttl')
    ?[s, o] := triples[s, 'http://xmlns.com/foaf/0.1/knows', o, _, _, _]
""", {}, True)

Read this before running untrusted CozoScript. rdf-io implies the engine's data-import trust gate, so this wheel — deliberately reversing the 0.14.0 posture — again registers script-controlled readers: RdfReader, CsvReader and JsonReader can read any file the process can read, and because the wheel also compiles HTTP support (requests), a script can fetch non-file:// URLs. Only run CozoScript from callers you trust with those capabilities, or build the binding from source without the rdf-io feature for a locked-down deployment.

New in 0.15.0

The Python-facing highlights of this operations-and-interchange release:

  • Bound query memory. A script may set :mem_limit <bytes> and receives the typed eval::mem_budget_exceeded error before commit if it trips. Rust and server hosts also expose per-call and database-wide ceilings.
  • RDF import is included in wheels. RdfReader accepts Turtle, N-Triples, N-Quads, and TriG; IRI/CURIE helpers are available in CozoScript. The raw source remains relational rather than becoming a triple-native store.
  • Share RocksDB memory across databases. Pass a shared_memory object in the RocksDB options JSON to join the process-wide block-cache/write-buffer envelope. Detailed memory-stat accessors are currently Rust-only.
  • Model nested data deliberately. The runnable JSON-LD/tree guide covers parent/child rows, positional arrays, and heterogeneous adjacency.

Migration highlight: enabling RDF reach reverses the 0.14.0 wheel-reader default. The wheel registers RdfReader, CsvReader, and JsonReader, and its compiled HTTP support lets trusted CozoScript fetch non-file:// URLs. Run only trusted scripts, or build from source without rdf-io for a locked-down deployment. Memory budgets and shared RocksDB resources remain opt-in, and no storage migration is required.

See the fork changelog for the full accounting, and for 0.13.0's upgrade guidance if you are coming from an earlier release (::reindex for HNSW/FTS indexes, pre-1970 timestamps, and the hybrid-leg ranking changes).

For idiomatic LangChain / LlamaIndex usage, install the integration packages (langchain-mnestic, llama-index-vector-stores-mnestic).

The query language (CozoScript / Datalog) and engine semantics follow CozoDB; see the upstream documentation and the fork changelog.

License

Mozilla Public License 2.0. Original work © 2022 The Cozo Project Authors; fork modifications © 2026 Shan Rizvi.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mnestic-0.15.0.tar.gz (752.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mnestic-0.15.0-cp37-abi3-win_amd64.whl (10.9 MB view details)

Uploaded CPython 3.7+Windows x86-64

mnestic-0.15.0-cp37-abi3-manylinux_2_28_x86_64.whl (13.6 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ x86-64

mnestic-0.15.0-cp37-abi3-manylinux_2_28_aarch64.whl (13.4 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.15.0-cp37-abi3-macosx_11_0_x86_64.whl (12.0 MB view details)

Uploaded CPython 3.7+macOS 11.0+ x86-64

mnestic-0.15.0-cp37-abi3-macosx_11_0_arm64.whl (10.8 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

Details for the file mnestic-0.15.0.tar.gz.

File metadata

  • Download URL: mnestic-0.15.0.tar.gz
  • Upload date:
  • Size: 752.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mnestic-0.15.0.tar.gz
Algorithm Hash digest
SHA256 d79399d16c80b2375acc58dc392bb32c4f8ad0d4b370c37b4b4c33e0547c4c2a
MD5 58417d5ea8e9591a5a690434c5f53aa7
BLAKE2b-256 912d4a91deaaecd60ef94fe9e9fa9e552013c23aca6e33f1df0a232fd6ccc032

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0.tar.gz:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnestic-0.15.0-cp37-abi3-win_amd64.whl.

File metadata

  • Download URL: mnestic-0.15.0-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: CPython 3.7+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for mnestic-0.15.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1480d69ee9fbdd4125652a4ada917f8e2ae416042b1cbb30d0818c0760275346
MD5 49182a5b687d71fe8ed17988fee041bb
BLAKE2b-256 ed5f812f805e915d98613fd6380baeaeba37477990abc9f1d52b1cab84727f1e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0-cp37-abi3-win_amd64.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnestic-0.15.0-cp37-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mnestic-0.15.0-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80e13fb0fa2595a10d04a8784191e535147c159483b4c63f0e33d75db4a5fd70
MD5 96026959cf8c01230612e08b5ff0a847
BLAKE2b-256 724a0e549260b20a2c2018b2bfc9af546eff63a3df22e98dfaa1f3b91cab572c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0-cp37-abi3-manylinux_2_28_x86_64.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnestic-0.15.0-cp37-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mnestic-0.15.0-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eef3ba2731de9286162655fae49fc5bd3a7768d8b125b510bc39bdb991c53c9c
MD5 8e5a2fffec1324ef4bfc1af916b6f351
BLAKE2b-256 890934f270ba757414a8417660be6b5245216f7b1a19edc50d0e610f04e3adb9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0-cp37-abi3-manylinux_2_28_aarch64.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnestic-0.15.0-cp37-abi3-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mnestic-0.15.0-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 00341e66ecedb193242fa64d5b4ee8935d1658eec45af0f9444179650ead08cd
MD5 a4391497662f5e82310f870488ce394d
BLAKE2b-256 a75cf584dbe52c9b8bd7b209d2586fec19fc5fa4cb706a0816750f4f9992c0fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0-cp37-abi3-macosx_11_0_x86_64.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mnestic-0.15.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mnestic-0.15.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38699557b3b03dd6cc96c713aa1b570c5a93a02e970d791d7a465735a1a21401
MD5 c09b6f44b264dacb8920654aa8bfcd39
BLAKE2b-256 f12f1fea3d8740dc2f1e37779d5cabef918b8554f17b3675f99fa09866a1eb67

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.15.0-cp37-abi3-macosx_11_0_arm64.whl:

Publisher: python-publish.yml on shuruheel/mnestic

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.18.0

6 files

0.17.0

6 files

0.16.0

6 files

This release

0.15.0 This release

6 files

0.14.0

6 files

0.13.1

6 files

0.13.0

6 files

0.12.2

6 files

0.12.1

6 files

0.12.0

6 files

0.11.1

6 files

0.11.0

6 files

0.10.7

6 files

0.10.6

6 files

0.10.5

6 files

0.10.1

6 files

0.10.0

6 files

0.9.0

6 files

0.8.5

6 files

0.8.4

6 files

0.8.3

6 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page