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 ships compact, RDF boundary I/O, and host-controlled
Parquet/Arrow import, but no RocksDB sources, so the persistent engine remains
wheel-only.
Published wheels and source builds expose atomic local-file copy-in through
import_columnar_file. The target relation must already exist; the format is
explicit and the call releases Python's GIL while decoding and committing:
report = db.import_columnar_file(
"events",
"events.parquet",
format="parquet", # or arrow_ipc_file / arrow_ipc_stream
columns={"event_id": "id"},
batch_rows=8192,
max_rows=1_000_000,
)
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.
RDF at the boundary — and what it means for the wheel's trust posture
The wheel ships the rdf-io engine feature: RdfReader reads Turtle,
N-Triples, N-Quads and TriG into a fixed 6-column relational shape
(subject, predicate, object, graph, language_tag, datatype) straight from
CozoScript, and IRI helper functions (iri_valid, iri_resolve,
curie_expand, curie_compact) handle boundary identity:
db.run_script("""
triples[s, p, o, g, lang, dt] <~ RdfReader(url: 'file://./data.ttl')
?[s, o] := triples[s, 'http://xmlns.com/foaf/0.1/knows', o, _, _, _]
""", {}, True)
Read this before running untrusted CozoScript. rdf-io implies the
engine's data-import trust gate, so this wheel — deliberately reversing the
0.14.0 posture — again registers script-controlled readers: RdfReader,
CsvReader and JsonReader can read any file the process can read, and
because the wheel also compiles HTTP support (requests), a script can fetch
non-file:// URLs. Only run CozoScript from callers you trust with those
capabilities, or build the binding from source without the rdf-io feature
for a locked-down deployment.
New in 0.18.0
This release corrects string decoding, nested JSON conversion and single-term FTS prefixes. Review these result changes before upgrading:
- BREAKING (results): double-quoted
"a\nb"now contains a newline. Use_"a\nb"_for a literal backslash or bind parameters. Literal edge whitespace and comments are preserved; trim explicitly when intended. Raw fences require adjacent matching underscores. Audit stored-query bodies as well as scripts. - BREAKING (results): nested UUIDs become strings, bytes become base64 strings,
and scalar infinities become
"INFINITY"/"NEGATIVE_INFINITY", including newJson-column writes andto_string. Stored JSON stays unchanged; migrate only known typed fields or adapt consumers. Old infinity-derived nulls are irreversible. - FTS prefixes apply configured lowercase and ASCII-folding filters:
Di*matchesDiwankon a lowercase index without rebuilding it. Prefixes match indexed terms, including stems; exact terms retain the full analyzer pipeline. Use an index without those filters when case/accent distinctions must be preserved. - Integer FTS boosts such as
Di*^3no longer panic.
There is no storage-format migration or bridge release. Python native conversions
remain unchanged; \uXXXX escapes remain BMP-only (bind parameters or use literal
non-BMP text). The temporary string migration warning is scheduled for removal
in 0.19.0.
Full upgrade guidance is in the fork changelog.
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.
Metadata
Release files for mnestic 0.18.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mnestic-0.18.0.tar.gz | 780.8 kB | With provenance | Details for mnestic-0.18.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| mnestic-0.18.0-cp37-abi3-win_amd64.whl | CPython 3.7 | abi3 | Windows x86-64 | Details for mnestic-0.18.0-cp37-abi3-win_amd64.whl |
| mnestic-0.18.0-cp37-abi3-manylinux_2_28_x86_64.whl | CPython 3.7 | abi3 | Linux glibc 2.28+ x86-64 | Details for mnestic-0.18.0-cp37-abi3-manylinux_2_28_x86_64.whl |
| mnestic-0.18.0-cp37-abi3-manylinux_2_28_aarch64.whl | CPython 3.7 | abi3 | Linux glibc 2.28+ ARM64 | Details for mnestic-0.18.0-cp37-abi3-manylinux_2_28_aarch64.whl |
| mnestic-0.18.0-cp37-abi3-macosx_11_0_x86_64.whl | CPython 3.7 | abi3 | macOS 11.0+ x86-64 | Details for mnestic-0.18.0-cp37-abi3-macosx_11_0_x86_64.whl |
| mnestic-0.18.0-cp37-abi3-macosx_11_0_arm64.whl | CPython 3.7 | abi3 | macOS 11.0+ ARM64 | Details for mnestic-0.18.0-cp37-abi3-macosx_11_0_arm64.whl |
Total release size: 70.6 MB
Release files / mnestic-0.18.0.tar.gz
| Download URL | mnestic-0.18.0.tar.gz |
|---|---|
| Size | 780.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4021b722509dd75088918679bc9cdc2324114225925c97eae9e231ac9871b024
|
|
BLAKE2b-256 checksum How to use checksums |
7d0d1085428653a2602efdc993103da43cc1fb4ddf941ed31bf2451379be80d9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / mnestic-0.18.0-cp37-abi3-win_amd64.whl
| Download URL | mnestic-0.18.0-cp37-abi3-win_amd64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | CPython 3.7 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
9d9e9e85bdb36c23757f7ec1fe56b8ba402df9d8fce3fe576806ada6da4b5f32
|
|
BLAKE2b-256 checksum How to use checksums |
c0b6824ec5403bc5be873459a3be05ba557e309f98e5cfcfa8f664287dd3b538
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / mnestic-0.18.0-cp37-abi3-manylinux_2_28_x86_64.whl
| Download URL | mnestic-0.18.0-cp37-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 15.6 MB |
| Tags | CPython 3.7 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5ac23fd285f9439db4df0d29b54db8b883ebead0ed1e494bb0bcd161fde74dcc
|
|
BLAKE2b-256 checksum How to use checksums |
864a28e0134ecadd048cc32fdf53b142b210a8196cc1ab4285d621bf1c708e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / mnestic-0.18.0-cp37-abi3-manylinux_2_28_aarch64.whl
| Download URL | mnestic-0.18.0-cp37-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 15.5 MB |
| Tags | CPython 3.7 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
15acf7fe2c9e8768e01d2dea263302551b087d3db7cefda37daa74c6d3bf1e40
|
|
BLAKE2b-256 checksum How to use checksums |
6638d1b7a6ff5c783f6338bf16c8d9f6f8d2f8d2e1db4e306a7b58421379681a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / mnestic-0.18.0-cp37-abi3-macosx_11_0_x86_64.whl
| Download URL | mnestic-0.18.0-cp37-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 13.7 MB |
| Tags | CPython 3.7 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
76481ccb60c9631fdd8a86261fd36542e884eea9e8bbe1a95cf60d150b128fd9
|
|
BLAKE2b-256 checksum How to use checksums |
ae30341bbd98a65819a7c38eb247c182efb01aa4f034e2001cd47595b7cd5a52
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logRelease files / mnestic-0.18.0-cp37-abi3-macosx_11_0_arm64.whl
| Download URL | mnestic-0.18.0-cp37-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.4 MB |
| Tags | CPython 3.7 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1c042b400ad3ad464e1c6a0923e4f933b36f59d367dddbb3bc2866d57cbe7abc
|
|
BLAKE2b-256 checksum How to use checksums |
50850bde90110b3d461b0148a9e95ae6d07942629203b323f7399d14764c31bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logSecurity for mnestic 0.18.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 6 files in this release have been uploaded with provenance metadata.
Attestation for mnestic-0.18.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.