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.2: a float in a validity position was silently read — and written — one million times too small, landing in 1970.

Validity timestamps are integer microseconds since the epoch. now() and parse_timestamp() return float seconds. The engine coerced one into the other without a word, so a :put of [parse_timestamp(…), true] into a Validity column succeeded and stamped the row at 1970 — a row that reads back correctly on an ordinary query, with the damage visible only under time travel. On the read side, @ parse_timestamp(…) returned zero rows and no error.

This is especially easy to hit from Python, because a Python float reaches the engine as a float: passing time.time() * 1_000_000 as a bound parameter worked only by luck (whenever the product happened to land on a whole number) and is now a clear error. Pass an int.

Upgrade action — and note carefully where it bites. The schema still compiles; it is the next write that now fails. The idiom Validity default [floor(now()), true] — and any spelling that yields a whole-numbered float, so floor(now()), round(now()), or parse_timestamp(...) on a whole second — has been silently writing 1970 into your valid-time axis. It now errors on write. (Bare [now(), true] already errored before this release, but only by luck: now() returns a fractional float, and the coercion only ever accepted whole-numbered ones.) Write instead:

last_seen: Validity default [to_int(now() * 1000000), true]

An integer in seconds (@ 1704067200) is still accepted and still silently returns nothing — valid time is an abstract logical clock (the tutorial queries @ 2019), so no magnitude check can tell a wrong unit from a legitimate small value. Use integer microseconds, or the string forms (@ '2024-06-01').

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

Uploaded CPython 3.7+Windows x86-64

mnestic-0.12.2-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.2-cp37-abi3-manylinux_2_28_aarch64.whl (13.0 MB view details)

Uploaded CPython 3.7+manylinux: glibc 2.28+ ARM64

mnestic-0.12.2-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.2-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.2.tar.gz.

File metadata

  • Download URL: mnestic-0.12.2.tar.gz
  • Upload date:
  • Size: 636.0 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.2.tar.gz
Algorithm Hash digest
SHA256 9fe08cc3dfe70ffa13691af0b4f3112b102d37ef4c0796669210649f94260d57
MD5 d77ae7829ee657df5abce972064e84ca
BLAKE2b-256 9894abbd2a01334b53328cf9d1726e42803b5ecd3203e545f7dc4ace5a7efd8d

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mnestic-0.12.2-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.2-cp37-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 6e394c311f4bf65625ca6b9c88d3df4c92b854926aa3cbe71325c4e745fb645d
MD5 0c70fb299472b08835f6e3246d2d6010
BLAKE2b-256 b23ca6bf9c1be0fb0d478a26496d37540c4bae50fb78079689ad08b4c6835a20

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.2-cp37-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e2b96f0bc08a94726258dfe5ebbc46003c5b98fe0f9040a226c9c09a303cb7c9
MD5 ef77991a3065b939f8d500800f0c2025
BLAKE2b-256 212d090508c460d34eef2a3da88fe72e08df39d10c7a2aaf3c94419dfc1686a9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.2-cp37-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ca073970f34cabcc8620bf51503e8749b61be39ba6dbf2149728b0cc157084ce
MD5 70b3812decb9f67876629f8e447d9a6b
BLAKE2b-256 55d4cb53c0f3eab3a7a4263f820d71db14b987d369ae53de28116149ca4ea5da

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.2-cp37-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 d7cdd70ea2e27e383d5fc6c91a5ee9af7db32d42ede082f8e838fcdb29b135a7
MD5 303108a0a98d7377ae509dfeb631f066
BLAKE2b-256 3beb7198ae12f70792adc29a9f4d191dcb716e24208536fcb56a14aa56fec108

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mnestic-0.12.2-cp37-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 77f6af1f9102b308398ec7556a7013d3a7f37ca0222804229f8ccb2fa2ea0d87
MD5 f3022284b2a6eaa0bdecea4792ca889d
BLAKE2b-256 9ff0a33a004136b4bec158da62265330249459970cc05c83270a62a20e255e5a

See more details on using hashes here.

Provenance

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