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.10.7: the engine's opt-in factorized-count() rewrite is now toggleable from Python. db.set_query_factorization(True) / db.query_factorization() control a Db-wide switch (default off); when on, an eligible count() over a positive join is counted per-key without materializing the join, for the same result — mirroring the previously Rust-only switch so Python benchmarks can measure it. Separately, 0.10.7 corrects a tie-break in the default greedy join reorder so a partial composite-key prefix is no longer mistaken for a point lookup on high-fan-out joins (no result change).

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

Uploaded CPython 3.7+Windows x86-64

mnestic-0.10.7-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.10.7-cp37-abi3-manylinux_2_28_aarch64.whl (12.7 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.10.7-cp37-abi3-macosx_11_0_x86_64.whl (11.6 MB view details)

Uploaded CPython 3.7+macOS 11.0+ x86-64

mnestic-0.10.7-cp37-abi3-macosx_11_0_arm64.whl (10.4 MB view details)

Uploaded CPython 3.7+macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for mnestic-0.10.7.tar.gz
Algorithm Hash digest
SHA256 1d49215188ce7dcbd6875d220c38f64baef6c980288a6c73072e0c58c8b5dffe
MD5 231781d17bd57698c58e3044b2031769
BLAKE2b-256 33cd10e2000de56189c4cc589509fbefd446f3c7d9860c91f12b358cb8ecb5dd

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mnestic-0.10.7-cp37-abi3-win_amd64.whl
  • Upload date:
  • Size: 10.5 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.10.7-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9ca260fbb1f2efa818009190d70821900812107d6f58b6aaf56cb9e5c98d9b9f
MD5 047d63883a7aa64034ee010f3468a6ea
BLAKE2b-256 5d2cd677fc824b57681f356aa8059b008cba71f2312a3fc7845c95efde47dccb

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.10.7-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fe7ea5cc315f6c99ed21016b201df5486ab0b27ec695d7c640f0fd93b938ce69
MD5 e056a6c20739d12355f98b7fa674d3cd
BLAKE2b-256 f1e5238c69cd4f2c1c744e7903d2cb813fa12f5f0f19087e5b10e5d1b8d05b5d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.10.7-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 4f6a70a1c47e18a27bf1750a4d5b376e516786ed09f3c543687e9a40091ee97c
MD5 3bd56b4b988542193f1371fff4aefa75
BLAKE2b-256 8eefa690aa3ff43ab4cadc57f7fb27061cf2684f33958c6f4fa9ef549bffd9ce

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.10.7-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2a22a10ab76d9a645d8c4bcaa9287c44d6541582bd738dd28b118b093dcb9c9c
MD5 f45a54a622f6624ef929518edaad31fb
BLAKE2b-256 3125853ff270384915e4a2066a527353981a5a34fef24cc22d94179b1a547e6f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.10.7-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f85e802bcc40a58b23b10f5ffaf95a7094b93688a49a67d8782c3f78dd609d88
MD5 ba54347b4951ddadca5a7cf2e4288a1a
BLAKE2b-256 400e4d6f29bc65e5813fba722cf51d2ecb5fb36785bf6f7220850629728eb8dd

See more details on using hashes here.

Provenance

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