Skip to main content

Embedded graph + vector + full-text database with Datalog — a maintained fork of CozoDB, tuned as a substrate for agentic memory.

Project description

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.

New in 0.12.0: budgeted weighted traversal, straight from the wheel. BudgetedTraversal is a new fixed rule: cheapest-first expansion from a set of seed nodes, over non-negative edge weights, under a required global budget of distinct nodes (max_nodes), with an optional cost ceiling (max_cost), an exact hop bound (max_depth), and an optional admission gate (a gate relation plus an admit: predicate — a gated-out node spends no budget and is never a bridge). It emits each admitted node's cost, parent, and depth — parent pointers reconstruct any path in plain Datalog — and it runs from the wheel through run_script with nothing to register: db.run_script("?[n, c, p, d] <~ BudgetedTraversal(*edge[f, t, w], seeds[n], max_nodes: 200)", {}, False). Admission is deterministic (total-order tie-breaking), long expansions abort cleanly via a query timeout=, and the rule can consume a cached ::graph projection (graph: 'g') instead of positional edges — measured 2–4× faster than an equivalent host-side BFS at the release's merge gate. Weights are consumed as costs (apply -ln(weight)-style transforms yourself). Purely additive — no existing query changes result.

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.

Project details


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.12.0.tar.gz (625.5 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.12.0-cp37-abi3-win_amd64.whl (10.6 MB view details)

Uploaded CPython 3.7+Windows x86-64

mnestic-0.12.0-cp37-abi3-manylinux_2_28_x86_64.whl (13.2 MB view details)

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

mnestic-0.12.0-cp37-abi3-manylinux_2_28_aarch64.whl (13.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.12.0-cp37-abi3-macosx_11_0_x86_64.whl (11.7 MB view details)

Uploaded CPython 3.7+macOS 11.0+ x86-64

mnestic-0.12.0-cp37-abi3-macosx_11_0_arm64.whl (10.5 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: mnestic-0.12.0.tar.gz
  • Upload date:
  • Size: 625.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mnestic-0.12.0.tar.gz
Algorithm Hash digest
SHA256 61205ef007a13c85c622ccee54a7b7aaabe82573497b09b2d32405e8ed62abdf
MD5 710b9d1314973d1cb01fcbdbdf602090
BLAKE2b-256 bfc8f21e254523e96c1cd0f05cf6241247d174df9e3ed9a350a5870b04b81b9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.12.0-cp37-abi3-win_amd64.whl.

File metadata

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

File hashes

Hashes for mnestic-0.12.0-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 f1f816585f329396741a6712b3f5cf4fdf8be5dac4e8a8a40456e1a2427bd8af
MD5 df94825584e6b28654e2be554bc5e2ee
BLAKE2b-256 7944314bc2c9a5bf309491ac4f56082976ca1a0ab4e9f741a009f47e238fe93b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.12.0-cp37-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mnestic-0.12.0-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 120fe23972a9d251867623b13d37851f7cce871a3d54eb0bae8ca36990bb9898
MD5 6521565877cef5bb1a1ee41ea0661dae
BLAKE2b-256 3e1c17b49e2be61d325160ecc752f5bb4403e4fe6ae07637215d301c772d721d

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.12.0-cp37-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mnestic-0.12.0-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 3cf47d9727ad0457bb61cb2af6d3374e502106b71ba2c0509367969f7bde66ee
MD5 c1b57f46daadb7d26a80a73e7e625a85
BLAKE2b-256 d80bb5bdabd7ea2bea840d699b4eed12e4a1cecec15bbfe52f978401266d4b00

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.12.0-cp37-abi3-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for mnestic-0.12.0-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 c11d25832afcef5e406c4654ac8ef1672a2ee60e789cc41d7f6cff764f480c8c
MD5 2779989a238c48a8eae761160b94c48f
BLAKE2b-256 e4903a23973644746e743f11e3229ed5f2f9c0d29fe44c0225ba853f57300b4a

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.12.0-cp37-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mnestic-0.12.0-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19dd8c78f37e0f781fd80a64c0fac3afece9476ff4b17ccc3cefa5823b838d28
MD5 7635c02017ff0d41a09c3640efbe7f78
BLAKE2b-256 071e346253a410476e9496a54d8281d0ac810b2991a4f41dae0d1d20c7afdbd0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mnestic-0.12.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.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page