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.1: a correctness release — with one action to take if you use full-text search. Six bugs inherited from upstream Cozo are fixed; none is a regression the fork introduced. The one that needs something from you: full-text postings leaked whenever a row was updated in place on a relation carrying only an FTS index. Deletion of the old postings was gated on the relation also having a plain secondary index, so a :put over an existing key never removed them — terms the document no longer contained kept matching it, the index grew without bound, and BM25 scores drifted (a measured 55% score error on a two-document corpus). This affects every release through 0.12.0.

The fix stops new leakage but cannot evict postings already written. If you have an FTS-only relation that has ever been updated in place, its index is affected today and upgrading alone will not repair it — rebuild it once with the new ::reindex:

db.run_script("::reindex docs", {}, False)

::reindex rebuilds a relation's HNSW / FTS / LSH indexes in place, in one write transaction, from the index configuration the database already stores. It is also the repair path after import_relations or a backup restore — neither maintains these indexes (that is what makes bulk loading fast), and both now warn and point at ::reindex rather than leaving restored rows silently invisible to search.

Also fixed, and visible from this binding: a failed commit raised no exception. CozoDbMulTx.commit() (from db.multi_transact(True)) returned normally even when the underlying commit had errored, so a caller believed its data was durable when it was not; change callbacks fired for those failed commits too. Both now behave.

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

Uploaded CPython 3.7+Windows x86-64

mnestic-0.12.1-cp37-abi3-manylinux_2_28_x86_64.whl (13.3 MB view details)

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

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

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.12.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: mnestic-0.12.1.tar.gz
  • Upload date:
  • Size: 633.9 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.1.tar.gz
Algorithm Hash digest
SHA256 3d07c44b31b582ab5e0044b55f33eaa478732ae4e912bf278007e0d03efecae0
MD5 53b4f990736c3f63bd77159c59411ae4
BLAKE2b-256 4160de6e26b7fc4582d408f83e2119fd0cd639bcad70dc1d0e3e93fb9ffbb3e9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mnestic-0.12.1-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.1-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 81062f8cd04fbf48aceb0684cd05a2b7ef1c39f4cca6a50af3767aaa080c1dfd
MD5 f6897fdb0c66012d95ef103c9da2145c
BLAKE2b-256 fcbfdab368848b835062b0f5e12f48ef1d258edef81ecc7f6d3f84d92733be5a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.1-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8ea126c59218359ebaf18a08039ee093148617b9721f7b9ced2bd3728d6466c
MD5 2b581b724956f809bca8a2ff43e8e27d
BLAKE2b-256 1f54936fb4ef70d53d3f42a0268ef36e4bef017d1a4676512263593f2d299e82

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.1-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 fb5ad8e3d5dc2b453a3200ba3db844d055628f16beb1937474ad7080d6695850
MD5 089be24b64c6527866641d07c1929b90
BLAKE2b-256 982e28fbde3393bdca4fdd2a16daa6d8a85855f8d60ccb9c4946a34090312bdf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.1-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 878eddf99e0a765870a8129b2ef79d2bc1c824521e330c5ca314e97bbf6925f4
MD5 99a42d27bc94bcb6512e75daafb804c9
BLAKE2b-256 1a90ad24456cc2639bbd1e9197db98abc6460175eb5e4018baf1c2e6958b3428

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.1-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c10edc87b954fc30823216fe0e78754a7c6836b0aeaadc23c14cbd8740a0c71
MD5 9ccf50079d47e778322950f0089ec378
BLAKE2b-256 d764efc26b24e1f5a352de02294162e06bc00a8d18faeb44c701611c57f37d27

See more details on using hashes here.

Provenance

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