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.13.1

A patch release. The Python-facing highlights:

  • The factorized count() rewrite is ON by default. Through 0.13.0 you had to opt in with db.set_query_factorization(True); the nightly soak that gated the flip has run green, so an eligible count()-over-join — including the inequality form handled by inclusion–exclusion — is now counted without materializing the join (measured on LSQB sf0.1: q1 72.4 s → 1.05 s, q6 42.1 s → 0.31 s, both returning LDBC's published count). Answers are unchanged; the rewrite fires only on a provably exact decomposition and leaves every query it declines byte-identical. Opt back out with db.set_query_factorization(False), and read the setting with db.query_factorization().

  • Parse errors name the expected tokens again. 0.13.0 shipped the help: line listing the literal tokens that would have been accepted, but pest 2.8 made the underlying tracking opt-in, so wheels built against it silently lost both the token list and the corrected caret position. Restored, and the tracking is now enabled only around a re-parse of a script that already failed — successful parses pay nothing for it.

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.

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.13.1.tar.gz (706.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.13.1-cp37-abi3-win_amd64.whl (10.7 MB view details)

Uploaded CPython 3.7+Windows x86-64

mnestic-0.13.1-cp37-abi3-manylinux_2_28_x86_64.whl (13.4 MB view details)

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

mnestic-0.13.1-cp37-abi3-manylinux_2_28_aarch64.whl (13.2 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.13.1-cp37-abi3-macosx_11_0_x86_64.whl (11.8 MB view details)

Uploaded CPython 3.7+macOS 11.0+ x86-64

mnestic-0.13.1-cp37-abi3-macosx_11_0_arm64.whl (10.6 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for mnestic-0.13.1.tar.gz
Algorithm Hash digest
SHA256 add3777164725f6a0efb14382e708c28d4eb603f766667658253e2c4d324b9b5
MD5 daf746275ef1775f34da2c6b4e6e18e2
BLAKE2b-256 dd914b0ac44d53705d75d64775a89194e8aa29f4d5462985833ad2ecc00e0039

See more details on using hashes here.

Provenance

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

File metadata

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

File hashes

Hashes for mnestic-0.13.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 96cfbb87745d8686d3b0373634cded60dbd3cec21e312cb8636ac9d5db02d4b2
MD5 c45fa7bfc121ff26138b282aff26a31e
BLAKE2b-256 6035d17b0afacfe9e53f6456964035de1f38f9fbe3869d33497f5322895b5c3a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.13.1-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 632ff24412912968ae9b610788711ea17af8bf604ad009c549db5caa06ab17d9
MD5 609cf2f9127fcfdba34f0876b51cb5cc
BLAKE2b-256 3532b36a5aa9bc944dcbf2a616c7661139ccc6879d292ab6459cbe46a9f1ec01

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.13.1-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8153f995d1329c20bb5723a9939658432f87f0c0d45fb238cc905b7bbc20b9c5
MD5 5f1a3e95d1f23c95ae711b1497d6cbf5
BLAKE2b-256 6ecf516426a881e85e0e802770256c7c50aa3a3e41ee45558e75f02fc99a2f72

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.13.1-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 cc96cae3ff3a284eb5de5ed3dda5af449bc73365250939a7ae0808781d0d8016
MD5 8eea6977367d799f7c8cd1442bb42949
BLAKE2b-256 09eaad32043431da789981c50fae9598605de858fc248d0f36d043e7b4d43c67

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.13.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24579190a700e0d8e15902de8e2875aec281c8f77e050f9b22e5c68189bcde15
MD5 f3bc831f443c172e70c767d9f083269f
BLAKE2b-256 b527219a9a9af3f11b87290643b7b9babfe8199adfe0dfef77a2ca59c5382556

See more details on using hashes here.

Provenance

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