mnestic 0.8.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mnestic-0.8.3/Cargo.toml +26 -0
- mnestic-0.8.3/PKG-INFO +64 -0
- mnestic-0.8.3/README.md +44 -0
- mnestic-0.8.3/cozo-core/Cargo.toml +167 -0
- mnestic-0.8.3/cozo-core/README-mnestic.md +110 -0
- mnestic-0.8.3/cozo-core/README-zh.md +5 -0
- mnestic-0.8.3/cozo-core/README.md +5 -0
- mnestic-0.8.3/cozo-core/benches/point_lookup.rs +91 -0
- mnestic-0.8.3/cozo-core/benches/pokec.rs +1178 -0
- mnestic-0.8.3/cozo-core/benches/read_path.rs +114 -0
- mnestic-0.8.3/cozo-core/benches/time_travel.rs +278 -0
- mnestic-0.8.3/cozo-core/benches/wiki_pagerank.rs +93 -0
- mnestic-0.8.3/cozo-core/src/cozoscript.pest +279 -0
- mnestic-0.8.3/cozo-core/src/data/aggr.rs +1256 -0
- mnestic-0.8.3/cozo-core/src/data/expr.rs +949 -0
- mnestic-0.8.3/cozo-core/src/data/functions.rs +2671 -0
- mnestic-0.8.3/cozo-core/src/data/json.rs +101 -0
- mnestic-0.8.3/cozo-core/src/data/memcmp.rs +371 -0
- mnestic-0.8.3/cozo-core/src/data/mod.rs +21 -0
- mnestic-0.8.3/cozo-core/src/data/program.rs +1850 -0
- mnestic-0.8.3/cozo-core/src/data/relation.rs +457 -0
- mnestic-0.8.3/cozo-core/src/data/symb.rs +107 -0
- mnestic-0.8.3/cozo-core/src/data/tests/aggrs.rs +574 -0
- mnestic-0.8.3/cozo-core/src/data/tests/exprs.rs +32 -0
- mnestic-0.8.3/cozo-core/src/data/tests/functions.rs +1489 -0
- mnestic-0.8.3/cozo-core/src/data/tests/json.rs +21 -0
- mnestic-0.8.3/cozo-core/src/data/tests/memcmp.rs +137 -0
- mnestic-0.8.3/cozo-core/src/data/tests/mod.rs +15 -0
- mnestic-0.8.3/cozo-core/src/data/tests/validity.rs +196 -0
- mnestic-0.8.3/cozo-core/src/data/tests/values.rs +59 -0
- mnestic-0.8.3/cozo-core/src/data/tuple.rs +86 -0
- mnestic-0.8.3/cozo-core/src/data/value.rs +714 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/all_pairs_shortest_path.rs +176 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/astar.rs +180 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/bfs.rs +123 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/degree_centrality.rs +76 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/dfs.rs +122 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/kruskal.rs +129 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/label_propagation.rs +97 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/louvain.rs +318 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/mod.rs +43 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/pagerank.rs +109 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/prim.rs +118 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/random_walk.rs +138 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/shortest_path_bfs.rs +174 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/shortest_path_dijkstra.rs +432 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/strongly_connected_components.rs +149 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/top_sort.rs +86 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/triangles.rs +99 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/algos/yen.rs +211 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/mod.rs +936 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/constant.rs +145 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/csv.rs +215 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/jlines.rs +186 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/mmr.rs +186 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/mod.rs +21 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/reorder_sort.rs +153 -0
- mnestic-0.8.3/cozo-core/src/fixed_rule/utilities/rrf.rs +140 -0
- mnestic-0.8.3/cozo-core/src/fts/README.md +6 -0
- mnestic-0.8.3/cozo-core/src/fts/ast.rs +170 -0
- mnestic-0.8.3/cozo-core/src/fts/cangjie/mod.rs +9 -0
- mnestic-0.8.3/cozo-core/src/fts/cangjie/options.rs +19 -0
- mnestic-0.8.3/cozo-core/src/fts/cangjie/stream.rs +52 -0
- mnestic-0.8.3/cozo-core/src/fts/cangjie/tokenizer.rs +45 -0
- mnestic-0.8.3/cozo-core/src/fts/indexing.rs +573 -0
- mnestic-0.8.3/cozo-core/src/fts/mod.rs +280 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/alphanum_only.rs +91 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/ascii_folding_filter.rs +4047 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/empty_tokenizer.rs +41 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/lower_caser.rs +86 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/mod.rs +186 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/ngram_tokenizer.rs +455 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/raw_tokenizer.rs +68 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/remove_long.rs +96 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/simple_tokenizer.rs +86 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/split_compound_words.rs +249 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/stemmer.rs +125 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/stop_word_filter/gen_stopwords.py +23 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/stop_word_filter/mod.rs +178 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/stop_word_filter/stopwords.rs +21885 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/tokenized_string.rs +100 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/tokenizer_impl.rs +335 -0
- mnestic-0.8.3/cozo-core/src/fts/tokenizer/whitespace_tokenizer.rs +86 -0
- mnestic-0.8.3/cozo-core/src/lib.rs +689 -0
- mnestic-0.8.3/cozo-core/src/parse/expr.rs +513 -0
- mnestic-0.8.3/cozo-core/src/parse/fts.rs +163 -0
- mnestic-0.8.3/cozo-core/src/parse/imperative.rs +222 -0
- mnestic-0.8.3/cozo-core/src/parse/mod.rs +353 -0
- mnestic-0.8.3/cozo-core/src/parse/query.rs +1098 -0
- mnestic-0.8.3/cozo-core/src/parse/schema.rs +160 -0
- mnestic-0.8.3/cozo-core/src/parse/sys.rs +676 -0
- mnestic-0.8.3/cozo-core/src/query/compile.rs +665 -0
- mnestic-0.8.3/cozo-core/src/query/eval.rs +670 -0
- mnestic-0.8.3/cozo-core/src/query/graph.rs +193 -0
- mnestic-0.8.3/cozo-core/src/query/logical.rs +368 -0
- mnestic-0.8.3/cozo-core/src/query/magic.rs +659 -0
- mnestic-0.8.3/cozo-core/src/query/mod.rs +18 -0
- mnestic-0.8.3/cozo-core/src/query/ra.rs +2389 -0
- mnestic-0.8.3/cozo-core/src/query/reorder.rs +340 -0
- mnestic-0.8.3/cozo-core/src/query/sort.rs +52 -0
- mnestic-0.8.3/cozo-core/src/query/stored.rs +1229 -0
- mnestic-0.8.3/cozo-core/src/query/stratify.rs +336 -0
- mnestic-0.8.3/cozo-core/src/runtime/callback.rs +117 -0
- mnestic-0.8.3/cozo-core/src/runtime/db.rs +2164 -0
- mnestic-0.8.3/cozo-core/src/runtime/hnsw.rs +1119 -0
- mnestic-0.8.3/cozo-core/src/runtime/hybrid.rs +398 -0
- mnestic-0.8.3/cozo-core/src/runtime/imperative.rs +399 -0
- mnestic-0.8.3/cozo-core/src/runtime/minhash_lsh.rs +389 -0
- mnestic-0.8.3/cozo-core/src/runtime/mod.rs +19 -0
- mnestic-0.8.3/cozo-core/src/runtime/relation.rs +1575 -0
- mnestic-0.8.3/cozo-core/src/runtime/temp_store.rs +416 -0
- mnestic-0.8.3/cozo-core/src/runtime/tests.rs +1614 -0
- mnestic-0.8.3/cozo-core/src/runtime/transact.rs +141 -0
- mnestic-0.8.3/cozo-core/src/storage/mem.rs +542 -0
- mnestic-0.8.3/cozo-core/src/storage/mod.rs +191 -0
- mnestic-0.8.3/cozo-core/src/storage/newrocks.rs +560 -0
- mnestic-0.8.3/cozo-core/src/storage/rocks.rs +585 -0
- mnestic-0.8.3/cozo-core/src/storage/sled.rs +425 -0
- mnestic-0.8.3/cozo-core/src/storage/sqlite.rs +426 -0
- mnestic-0.8.3/cozo-core/src/storage/temp.rs +141 -0
- mnestic-0.8.3/cozo-core/src/storage/tikv.rs +320 -0
- mnestic-0.8.3/cozo-core/src/utils.rs +31 -0
- mnestic-0.8.3/cozo-lib-python/.github_disabled/workflows/CI.yml +69 -0
- mnestic-0.8.3/cozo-lib-python/.gitignore +73 -0
- mnestic-0.8.3/cozo-lib-python/Cargo.lock +2878 -0
- mnestic-0.8.3/cozo-lib-python/Cargo.toml +49 -0
- mnestic-0.8.3/cozo-lib-python/README-zh.md +15 -0
- mnestic-0.8.3/cozo-lib-python/README.md +44 -0
- mnestic-0.8.3/cozo-lib-python/build.sh +3 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/README.md +33 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/langchain_mnestic/__init__.py +6 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/langchain_mnestic/_core.py +157 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/langchain_mnestic/vectorstores.py +101 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/pyproject.toml +24 -0
- mnestic-0.8.3/cozo-lib-python/integrations/langchain-mnestic/tests/test_vectorstore.py +66 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/README.md +31 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/llama_index/vector_stores/mnestic/__init__.py +6 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/llama_index/vector_stores/mnestic/_core.py +157 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/llama_index/vector_stores/mnestic/base.py +113 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/pyproject.toml +26 -0
- mnestic-0.8.3/cozo-lib-python/integrations/llama-index-vector-stores-mnestic/tests/test_vectorstore.py +59 -0
- mnestic-0.8.3/cozo-lib-python/src/lib.rs +613 -0
- mnestic-0.8.3/cozorocks/.gitignore +86 -0
- mnestic-0.8.3/cozorocks/CMakeLists.txt +11 -0
- mnestic-0.8.3/cozorocks/Cargo.toml +38 -0
- mnestic-0.8.3/cozorocks/README-zh.md +3 -0
- mnestic-0.8.3/cozorocks/README.md +3 -0
- mnestic-0.8.3/cozorocks/bridge/bridge.h +17 -0
- mnestic-0.8.3/cozorocks/bridge/common.h +33 -0
- mnestic-0.8.3/cozorocks/bridge/db.cpp +153 -0
- mnestic-0.8.3/cozorocks/bridge/db.h +123 -0
- mnestic-0.8.3/cozorocks/bridge/iter.h +140 -0
- mnestic-0.8.3/cozorocks/bridge/opts.h +24 -0
- mnestic-0.8.3/cozorocks/bridge/slice.h +32 -0
- mnestic-0.8.3/cozorocks/bridge/status.cpp +24 -0
- mnestic-0.8.3/cozorocks/bridge/status.h +16 -0
- mnestic-0.8.3/cozorocks/bridge/tx.cpp +21 -0
- mnestic-0.8.3/cozorocks/bridge/tx.h +137 -0
- mnestic-0.8.3/cozorocks/build.rs +381 -0
- mnestic-0.8.3/cozorocks/build_version.cc +81 -0
- mnestic-0.8.3/cozorocks/rocksdb_lib_sources.txt +322 -0
- mnestic-0.8.3/cozorocks/src/bridge/db.rs +228 -0
- mnestic-0.8.3/cozorocks/src/bridge/iter.rs +157 -0
- mnestic-0.8.3/cozorocks/src/bridge/mod.rs +264 -0
- mnestic-0.8.3/cozorocks/src/bridge/tx.rs +191 -0
- mnestic-0.8.3/cozorocks/src/lib.rs +25 -0
- mnestic-0.8.3/pyproject.toml +34 -0
mnestic-0.8.3/Cargo.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[workspace]
|
|
2
|
+
resolver = "2"
|
|
3
|
+
members = [
|
|
4
|
+
"cozo-core",
|
|
5
|
+
"cozorocks",
|
|
6
|
+
"cozo-bin",
|
|
7
|
+
"cozo-core-examples",
|
|
8
|
+
]
|
|
9
|
+
# Language bindings are deferred in the mnestic fork — the fork targets a Rust
|
|
10
|
+
# agentic-memory substrate (consumed by mindgraph-rs). The binding crates are
|
|
11
|
+
# kept in-tree but excluded from the workspace build/maintenance for now.
|
|
12
|
+
exclude = [
|
|
13
|
+
"cozo-lib-c",
|
|
14
|
+
"cozo-lib-java",
|
|
15
|
+
"cozo-lib-wasm",
|
|
16
|
+
"cozo-lib-swift",
|
|
17
|
+
"cozo-lib-python",
|
|
18
|
+
"cozo-lib-nodejs",
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
[profile.bench]
|
|
22
|
+
lto = true
|
|
23
|
+
debug = true
|
|
24
|
+
|
|
25
|
+
[profile.dev.package."mnestic-rocks"]
|
|
26
|
+
opt-level = 3
|
mnestic-0.8.3/PKG-INFO
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mnestic
|
|
3
|
+
Version: 0.8.3
|
|
4
|
+
Classifier: Topic :: Database
|
|
5
|
+
Classifier: Topic :: Database :: Database Engines/Servers
|
|
6
|
+
Classifier: Programming Language :: Rust
|
|
7
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
8
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
9
|
+
Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
|
|
10
|
+
Summary: Embedded graph + vector + full-text database with Datalog — a maintained fork of CozoDB, tuned as a substrate for agentic memory.
|
|
11
|
+
Keywords: database,graph,vector,datalog,embeddings,rag,agentic-memory,cozodb
|
|
12
|
+
Home-Page: https://github.com/shuruheel/mnestic
|
|
13
|
+
Author: Shan Rizvi
|
|
14
|
+
License: MPL-2.0
|
|
15
|
+
Requires-Python: >=3.8
|
|
16
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
17
|
+
Project-URL: Homepage, https://github.com/shuruheel/mnestic
|
|
18
|
+
Project-URL: Repository, https://github.com/shuruheel/mnestic
|
|
19
|
+
|
|
20
|
+
# mnestic (Python)
|
|
21
|
+
|
|
22
|
+
Embedded **graph + vector + full-text** database with **Datalog** queries — a
|
|
23
|
+
maintained fork of [CozoDB](https://github.com/cozodb/cozo), tuned as a substrate
|
|
24
|
+
for **agentic memory**. This package is the in-process Python binding (no server
|
|
25
|
+
required).
|
|
26
|
+
|
|
27
|
+
> mnestic is **not** the official CozoDB and is not affiliated with or endorsed by
|
|
28
|
+
> its original authors. All credit for the original design belongs to Ziyang Hu and
|
|
29
|
+
> the Cozo Project Authors. See the
|
|
30
|
+
> [fork repository](https://github.com/shuruheel/mnestic) for provenance and
|
|
31
|
+
> licensing.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install mnestic
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```python
|
|
38
|
+
from mnestic import CozoDbPy
|
|
39
|
+
|
|
40
|
+
db = CozoDbPy("mem", "", "{}") # engines: "mem", "sqlite" (file path), ...
|
|
41
|
+
db.run_script("?[x] <- [[1],[2],[3]]", {}, False)
|
|
42
|
+
|
|
43
|
+
# One-call hybrid retrieval (HNSW + full-text fused with Reciprocal Rank Fusion),
|
|
44
|
+
# over a relation that has an HNSW index and an FTS index:
|
|
45
|
+
hits = db.hybrid_search({
|
|
46
|
+
"relation": "docs",
|
|
47
|
+
"vector_index": "vec", "query_vector": [0.1, 0.9], "vector_k": 5,
|
|
48
|
+
"fts_index": "fts", "query_text": "vector search", "fts_k": 5,
|
|
49
|
+
})
|
|
50
|
+
# -> {"headers": ["id", "score"], "rows": [["d3", 0.033], ...], "next": None}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For idiomatic LangChain / LlamaIndex usage, install the integration packages
|
|
54
|
+
(`langchain-mnestic`, `llama-index-vector-stores-mnestic`).
|
|
55
|
+
|
|
56
|
+
The query language (CozoScript / Datalog) and engine semantics follow CozoDB; see
|
|
57
|
+
the [upstream documentation](https://docs.cozodb.org/) and the
|
|
58
|
+
[fork changelog](https://github.com/shuruheel/mnestic/blob/main/CHANGELOG-FORK.md).
|
|
59
|
+
|
|
60
|
+
## License
|
|
61
|
+
|
|
62
|
+
Mozilla Public License 2.0. Original work © 2022 The Cozo Project Authors; fork
|
|
63
|
+
modifications © 2026 Shan Rizvi.
|
|
64
|
+
|
mnestic-0.8.3/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# mnestic (Python)
|
|
2
|
+
|
|
3
|
+
Embedded **graph + vector + full-text** database with **Datalog** queries — a
|
|
4
|
+
maintained fork of [CozoDB](https://github.com/cozodb/cozo), tuned as a substrate
|
|
5
|
+
for **agentic memory**. This package is the in-process Python binding (no server
|
|
6
|
+
required).
|
|
7
|
+
|
|
8
|
+
> mnestic is **not** the official CozoDB and is not affiliated with or endorsed by
|
|
9
|
+
> its original authors. All credit for the original design belongs to Ziyang Hu and
|
|
10
|
+
> the Cozo Project Authors. See the
|
|
11
|
+
> [fork repository](https://github.com/shuruheel/mnestic) for provenance and
|
|
12
|
+
> licensing.
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install mnestic
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
from mnestic import CozoDbPy
|
|
20
|
+
|
|
21
|
+
db = CozoDbPy("mem", "", "{}") # engines: "mem", "sqlite" (file path), ...
|
|
22
|
+
db.run_script("?[x] <- [[1],[2],[3]]", {}, False)
|
|
23
|
+
|
|
24
|
+
# One-call hybrid retrieval (HNSW + full-text fused with Reciprocal Rank Fusion),
|
|
25
|
+
# over a relation that has an HNSW index and an FTS index:
|
|
26
|
+
hits = db.hybrid_search({
|
|
27
|
+
"relation": "docs",
|
|
28
|
+
"vector_index": "vec", "query_vector": [0.1, 0.9], "vector_k": 5,
|
|
29
|
+
"fts_index": "fts", "query_text": "vector search", "fts_k": 5,
|
|
30
|
+
})
|
|
31
|
+
# -> {"headers": ["id", "score"], "rows": [["d3", 0.033], ...], "next": None}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For idiomatic LangChain / LlamaIndex usage, install the integration packages
|
|
35
|
+
(`langchain-mnestic`, `llama-index-vector-stores-mnestic`).
|
|
36
|
+
|
|
37
|
+
The query language (CozoScript / Datalog) and engine semantics follow CozoDB; see
|
|
38
|
+
the [upstream documentation](https://docs.cozodb.org/) and the
|
|
39
|
+
[fork changelog](https://github.com/shuruheel/mnestic/blob/main/CHANGELOG-FORK.md).
|
|
40
|
+
|
|
41
|
+
## License
|
|
42
|
+
|
|
43
|
+
Mozilla Public License 2.0. Original work © 2022 The Cozo Project Authors; fork
|
|
44
|
+
modifications © 2026 Shan Rizvi.
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "mnestic"
|
|
3
|
+
version = "0.8.3"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
description = "A transactional relational-graph-vector database using Datalog — a maintained fork of CozoDB, tuned as a substrate for agentic memory"
|
|
6
|
+
authors = ["Shan Rizvi", "Ziyang Hu (original CozoDB author)"]
|
|
7
|
+
license = "MPL-2.0"
|
|
8
|
+
repository = "https://github.com/shuruheel/mnestic"
|
|
9
|
+
readme = "README-mnestic.md"
|
|
10
|
+
keywords = ["database", "datalog", "graph", "vector", "embedded"]
|
|
11
|
+
categories = ["database", "database-implementations"]
|
|
12
|
+
exclude = [
|
|
13
|
+
"tests/*",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
# The published package is `mnestic`, but the importable Rust crate name stays
|
|
17
|
+
# `cozo` so that downstream `use cozo::...` (including this crate's own tests,
|
|
18
|
+
# benches, and doctests) continues to work unchanged. See FORK.md.
|
|
19
|
+
[lib]
|
|
20
|
+
name = "cozo"
|
|
21
|
+
|
|
22
|
+
[features]
|
|
23
|
+
#! # Features
|
|
24
|
+
|
|
25
|
+
default = ["compact"]
|
|
26
|
+
## Enables the `minimal`, `requests` and `graph-algo` features.
|
|
27
|
+
compact = ["minimal", "requests", "graph-algo"]
|
|
28
|
+
## Enables the `minimal`, `requests` and `graph-algo` features in single threaded mode.
|
|
29
|
+
compact-single-threaded = ["minimal", "requests", "graph-algo"]
|
|
30
|
+
## Enables the `storage-sqlite` feature.
|
|
31
|
+
minimal = ["storage-sqlite", "storage-sqlite-src"]
|
|
32
|
+
## Enables the [Sqlite](https://www.sqlite.org/index.html) backend,
|
|
33
|
+
## also allows backup and restore with Sqlite data files.
|
|
34
|
+
## Sqlite is easy to compile, has very low resource requirements and reasonable performance,
|
|
35
|
+
## but does not support much concurrency.
|
|
36
|
+
storage-sqlite = ["dep:sqlite"]
|
|
37
|
+
storage-sqlite-src = ["dep:sqlite3-src", "sqlite3-src/bundled"]
|
|
38
|
+
## Enables the [RocksDB](http://rocksdb.org/) backend.
|
|
39
|
+
## RocksDB is hard to compile on some platforms, uses more resources than SQLite,
|
|
40
|
+
## but is very performant and supports an extremely high level of concurrency.
|
|
41
|
+
## You can also [fine-tune](https://github.com/cozodb/cozo/blob/main/TUNING_ROCKSDB.md) RocksDB options.
|
|
42
|
+
storage-rocksdb = ["dep:cozorocks"]
|
|
43
|
+
storage-new-rocksdb = ["dep:rocksdb"]
|
|
44
|
+
## Enables the graph algorithms.
|
|
45
|
+
graph-algo = ["graph", "rayon"]
|
|
46
|
+
## Allows the utilities to make web requests to fetch data.
|
|
47
|
+
requests = ["dep:minreq"]
|
|
48
|
+
## Uses jemalloc as the global allocator, can make a difference in performance.
|
|
49
|
+
jemalloc = ["dep:tikv-jemallocator-global", "cozorocks?/jemalloc"]
|
|
50
|
+
## Enables io-uring option for the RocksDB storage
|
|
51
|
+
io-uring = ["cozorocks?/io-uring"]
|
|
52
|
+
## Polyfills for the WASM target
|
|
53
|
+
wasm = ["uuid/js", "dep:js-sys"]
|
|
54
|
+
|
|
55
|
+
#! The following features are highly experimental:
|
|
56
|
+
|
|
57
|
+
## Enables the [Sled](https://github.com/spacejam/sled) backend.
|
|
58
|
+
## Sled is slower than Sqlite for the usual workload of Cozo, can use quite a lot of disk space,
|
|
59
|
+
## and may not be stable enough. In general you should use RocksDB instead.
|
|
60
|
+
## The Sled engine does not support time travel.
|
|
61
|
+
storage-sled = ["dep:sled"]
|
|
62
|
+
## Enables the [TiKV](https://tikv.org/) client backend.
|
|
63
|
+
## The only reason that you may want to use this is that your data does not fit in a single machine.
|
|
64
|
+
## This engine is orders of magnitude slower than every other engine for graph traversals, due to the
|
|
65
|
+
## significant network overhead. Simple point-lookup queries are fine, though.
|
|
66
|
+
## The TiKV engine does not support time travel.
|
|
67
|
+
storage-tikv = ["dep:tikv-client", "dep:tokio"]
|
|
68
|
+
|
|
69
|
+
#! # Recommendation for features to enable
|
|
70
|
+
#!
|
|
71
|
+
#! Generally you will want the `storage-sqlite` and `graph-algo` features enabled,
|
|
72
|
+
#! unless your environment makes compiling them difficult. The backup/restore functionalities
|
|
73
|
+
#! are only available if `storage-sqlite` is on. Without `graph-algo` you cannot use any graph algorithms
|
|
74
|
+
#! (utilities are still available),
|
|
75
|
+
#! which could be OK if you only want to deal with pure Datalog.
|
|
76
|
+
#!
|
|
77
|
+
#! The `requests` feature allows the database to make outgoing HTTP requests to fetch data
|
|
78
|
+
#! into queries -- only enable it if you need it.
|
|
79
|
+
#!
|
|
80
|
+
#! The `wasm` feature simply patches some functions so that they can compile on WASM platform,
|
|
81
|
+
#! which lacks some std implementations at the moment. (On WASM you must also enable `nothread`).
|
|
82
|
+
#! This feature will not work on any other platform.
|
|
83
|
+
#!
|
|
84
|
+
#! The `jemalloc` feature only makes sense for desktop and servers. It could improve performance,
|
|
85
|
+
#! sometimes substantially, but you need to benchmark for your use case. It also tends to break
|
|
86
|
+
#! builds on untested platforms. None of our prebuilt binaries have it enabled.
|
|
87
|
+
#!
|
|
88
|
+
#! Enable `storage-rocksdb` if you expect high concurrency or want better performance than SQLite,
|
|
89
|
+
#! but note that RocksDB is much more resource-hungry and takes long to compile.
|
|
90
|
+
#!
|
|
91
|
+
#! The other storage options are just for experimentation. We do not recommend using them.
|
|
92
|
+
|
|
93
|
+
[dependencies]
|
|
94
|
+
casey = "0.4.0"
|
|
95
|
+
either = "1.11.0"
|
|
96
|
+
rand = "0.8.5"
|
|
97
|
+
miette = { version = "5.10.0", features = ["fancy"] }
|
|
98
|
+
lazy_static = "1.4.0"
|
|
99
|
+
log = "0.4.21"
|
|
100
|
+
smallvec = { version = "1.13.2", features = ["serde", "write", "union", "const_generics", "const_new"] }
|
|
101
|
+
smartstring = { version = "1.0.1", features = ["serde"] }
|
|
102
|
+
serde_json = "1.0.116"
|
|
103
|
+
serde = { version = "1.0.199" }
|
|
104
|
+
serde_derive = "1.0.199"
|
|
105
|
+
serde_bytes = "0.11.14"
|
|
106
|
+
rmp = "0.8.14"
|
|
107
|
+
rmp-serde = "1.2.0"
|
|
108
|
+
rmpv = "1.0.2"
|
|
109
|
+
base64 = "0.22.0"
|
|
110
|
+
chrono = "0.4.38"
|
|
111
|
+
chrono-tz = "0.9.0"
|
|
112
|
+
priority-queue = "1.4.0"
|
|
113
|
+
ordered-float = "4.2.0"
|
|
114
|
+
byteorder = "1.5.0"
|
|
115
|
+
num-traits = "0.2.18"
|
|
116
|
+
itertools = "0.12.1"
|
|
117
|
+
regex = "1.10.4"
|
|
118
|
+
pest = "2.7.9"
|
|
119
|
+
pest_derive = "2.7.9"
|
|
120
|
+
approx = "0.5.1"
|
|
121
|
+
unicode-normalization = "0.1.23"
|
|
122
|
+
thiserror = "1.0.59"
|
|
123
|
+
uuid = { version = "1.8.0", features = ["v1", "v4", "serde"] }
|
|
124
|
+
csv = "1.3.0"
|
|
125
|
+
document-features = "0.2.8"
|
|
126
|
+
rayon = { version = "1.10.0", optional = true }
|
|
127
|
+
minreq = { version = "2.11.2", features = ["https-rustls"], optional = true }
|
|
128
|
+
tikv-jemallocator-global = { version = "0.5.0", optional = true }
|
|
129
|
+
cozorocks = { package = "mnestic-rocks", path = "../cozorocks", version = "0.1.8", optional = true }
|
|
130
|
+
rocksdb = { version = "0.22.0", optional = true }
|
|
131
|
+
sled = { version = "0.34.7", optional = true }
|
|
132
|
+
tikv-client = { version = "0.3.0", optional = true }
|
|
133
|
+
tokio = { version = "1.37.0", optional = true }
|
|
134
|
+
sqlite = { version = "0.36.0", optional = true }
|
|
135
|
+
sqlite3-src = { version = "0.6.1", optional = true }
|
|
136
|
+
js-sys = { version = "0.3.60", optional = true }
|
|
137
|
+
graph = { version = "0.3.1", optional = true }
|
|
138
|
+
crossbeam = "0.8.4"
|
|
139
|
+
ndarray = { version = "0.15.6", features = ["serde"] }
|
|
140
|
+
sha2 = "0.10.8"
|
|
141
|
+
rustc-hash = "1.1.0"
|
|
142
|
+
twox-hash = "1.6.3"
|
|
143
|
+
quadrature = "0.1.2"
|
|
144
|
+
# For the FTS feature
|
|
145
|
+
jieba-rs = "0.7.0"
|
|
146
|
+
aho-corasick = "1.1.3"
|
|
147
|
+
rust-stemmers = "1.2.0"
|
|
148
|
+
fast2s = "0.3.1"
|
|
149
|
+
swapvec = "0.3.0"
|
|
150
|
+
|
|
151
|
+
[dev-dependencies]
|
|
152
|
+
tempfile = "3.14.0"
|
|
153
|
+
# Test-only: only `runtime/tests.rs` (cfg(test)) initializes a logger. Moved out
|
|
154
|
+
# of [dependencies] so it doesn't bloat downstream builds (upstream cozo #287).
|
|
155
|
+
env_logger = "0.11.3"
|
|
156
|
+
# CI/stable-runnable perf harness for fork work (the upstream pokec/wiki/
|
|
157
|
+
# time_travel benches use the nightly `#![feature(test)]` bencher + external data).
|
|
158
|
+
criterion = { version = "0.5", features = ["html_reports"] }
|
|
159
|
+
|
|
160
|
+
# mnestic fork perf baselines (stable, self-contained synthetic data).
|
|
161
|
+
[[bench]]
|
|
162
|
+
name = "point_lookup"
|
|
163
|
+
harness = false
|
|
164
|
+
|
|
165
|
+
[[bench]]
|
|
166
|
+
name = "read_path"
|
|
167
|
+
harness = false
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# mnestic
|
|
2
|
+
|
|
3
|
+
**mnestic** is an independently maintained fork of
|
|
4
|
+
[CozoDB](https://github.com/cozodb/cozo) — a transactional,
|
|
5
|
+
relational-graph-vector database that uses Datalog for queries ("the
|
|
6
|
+
hippocampus for AI"). The fork continues the project as a substrate for
|
|
7
|
+
**agentic memory**, with performance, correctness, and operational work on top
|
|
8
|
+
of upstream `481af05` (the last upstream commit, 2024-12-04).
|
|
9
|
+
|
|
10
|
+
> mnestic is **not** the official CozoDB and is not affiliated with or endorsed
|
|
11
|
+
> by its original authors. All credit for the original design belongs to Ziyang
|
|
12
|
+
> Hu and the Cozo Project Authors. See
|
|
13
|
+
> [`FORK.md`](https://github.com/shuruheel/mnestic/blob/main/FORK.md) for
|
|
14
|
+
> provenance and licensing, and
|
|
15
|
+
> [`CHANGELOG-FORK.md`](https://github.com/shuruheel/mnestic/blob/main/CHANGELOG-FORK.md)
|
|
16
|
+
> for what diverges from upstream.
|
|
17
|
+
|
|
18
|
+
## What mnestic adds over CozoDB
|
|
19
|
+
|
|
20
|
+
Highlights (full detail in
|
|
21
|
+
[`CHANGELOG-FORK.md`](https://github.com/shuruheel/mnestic/blob/main/CHANGELOG-FORK.md)):
|
|
22
|
+
|
|
23
|
+
**0.8.3**
|
|
24
|
+
|
|
25
|
+
- **Native 3-way fused recall** — `hybrid_search` now fuses a graph-proximity leg
|
|
26
|
+
*in-engine* alongside vector (HNSW) and full-text (FTS). A typed `GraphLeg`
|
|
27
|
+
generates a recursive bounded shortest-path rule (k-hop, `min(dist)` scoring) and
|
|
28
|
+
folds it into the same RRF, so one call returns the vector+FTS+graph ranking — a
|
|
29
|
+
capability no other embedded engine here offers. Measured **41.55 ms p50**, ~4×
|
|
30
|
+
faster than the hand-decomposed three-query path.
|
|
31
|
+
- **BM25-correct FTS, with O(1) `avgdl`** — the default `::fts` scorer is now Okapi
|
|
32
|
+
**`bm25`** (term-frequency saturation `k1` + document-length normalization `b`,
|
|
33
|
+
both tunable; `OR` sums per-term contributions). Average document length is an O(1)
|
|
34
|
+
read of a durable per-index counter rather than a per-query index scan. Measured:
|
|
35
|
+
fused recall **0.75 → 0.954** (parity with DuckDB / SQLite) at no net latency cost
|
|
36
|
+
(decomposed p50 927 → 175 ms, cold p99 2,900 → 258 ms). **Heads-up:** this changes
|
|
37
|
+
the default FTS score kind (a behaviour change); `tf`/`tf_idf` stay selectable for
|
|
38
|
+
byte-identical upstream scoring.
|
|
39
|
+
|
|
40
|
+
**0.8.2**
|
|
41
|
+
|
|
42
|
+
- **Non-blocking HNSW index builds** — `::hnsw create` no longer holds the base
|
|
43
|
+
relation's write lock during graph construction, so concurrent reads are no
|
|
44
|
+
longer stalled for the whole build (previously 10–20+ min in production). Built
|
|
45
|
+
off-lock under a snapshot and bulk-published via `SstFileWriter`/
|
|
46
|
+
`IngestExternalFile`; concurrent mutations reconciled under a brief final lock.
|
|
47
|
+
Measured: 90,507 reads completed (slowest 0.8 ms) during a ~5.6 s 40k-vector
|
|
48
|
+
build. RocksDB only.
|
|
49
|
+
|
|
50
|
+
**0.8.1**
|
|
51
|
+
|
|
52
|
+
- **One-call hybrid retrieval** — `DbInstance::hybrid_search` runs HNSW + FTS
|
|
53
|
+
(+ optional graph traversal), fuses with RRF, and optionally diversifies with
|
|
54
|
+
MMR in a single typed call (was ~7 hand-written Datalog rules).
|
|
55
|
+
- **HNSW index build ~3× faster** — the build no longer round-trips the whole
|
|
56
|
+
graph through the transaction's write-batch overlay (20k × 128: 135s → 43.6s,
|
|
57
|
+
measured release). Built graph is byte-identical.
|
|
58
|
+
- **`mnestic-rocks`** — the C++/RocksDB bridge is now a maintained fork
|
|
59
|
+
(importable name stays `cozorocks`), unblocking future bridge-level work.
|
|
60
|
+
|
|
61
|
+
**0.8.0 — fixes**
|
|
62
|
+
|
|
63
|
+
- **Equality pushdown** — `*rel[k, ..], k == <value>` now compiles to a keyed
|
|
64
|
+
`stored_prefix_join` instead of a full scan (**~28–29× faster** single-row
|
|
65
|
+
primary-key lookups, measured at 5k rows). Numeric equalities keep cross-type
|
|
66
|
+
`op_eq` semantics.
|
|
67
|
+
- **Parser fix** — identifiers that start with a keyword literal
|
|
68
|
+
(`nullable_column`, `trueValue`, `falsey`) now parse correctly (upstream #281).
|
|
69
|
+
- **Unreleased upstream fixes for free** — the fork point is 30 commits ahead of
|
|
70
|
+
the published 0.7.6, including the `stored_prefix_join` correctness fix.
|
|
71
|
+
- `env_logger` moved to a dev-dependency for a slimmer dependency graph
|
|
72
|
+
(upstream #287).
|
|
73
|
+
|
|
74
|
+
**0.8.0 — new: hybrid retrieval for agentic memory** (Datalog-composable fixed rules)
|
|
75
|
+
|
|
76
|
+
- `ReciprocalRankFusion` (alias `RRF`) — fuse vector (HNSW) + full-text (FTS) +
|
|
77
|
+
graph-traversal result lists into one ranking.
|
|
78
|
+
- `MaximalMarginalRelevance` (alias `MMR`) — diversity-aware reranking that avoids
|
|
79
|
+
near-duplicate recalls.
|
|
80
|
+
- `rand_ulid()` / `ulid_timestamp()` — lexicographically-sortable identifiers for
|
|
81
|
+
time-ordered scans (upstream #296).
|
|
82
|
+
|
|
83
|
+
## Importable name
|
|
84
|
+
|
|
85
|
+
The published crate is `mnestic`, but the importable Rust crate name is `cozo`,
|
|
86
|
+
so existing CozoDB code works unchanged:
|
|
87
|
+
|
|
88
|
+
```toml
|
|
89
|
+
[dependencies]
|
|
90
|
+
mnestic = "0.8.3"
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
```rust
|
|
94
|
+
use cozo::{DbInstance, ScriptMutability};
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The query language (CozoScript / Datalog) and engine semantics are unchanged
|
|
98
|
+
unless noted in the fork changelog.
|
|
99
|
+
|
|
100
|
+
## Features
|
|
101
|
+
|
|
102
|
+
Default is `compact` (SQLite backend). RocksDB, vector (HNSW), full-text search,
|
|
103
|
+
and graph-algorithm features match upstream Cozo 0.7.x. See the crate docs and
|
|
104
|
+
the [upstream CozoDB documentation](https://docs.cozodb.org/) for the query
|
|
105
|
+
language and feature flags.
|
|
106
|
+
|
|
107
|
+
## License
|
|
108
|
+
|
|
109
|
+
Mozilla Public License 2.0. Original work © 2022 The Cozo Project Authors;
|
|
110
|
+
fork modifications © 2026 Shan Rizvi.
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026, Shan Rizvi (mnestic fork).
|
|
3
|
+
*
|
|
4
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
5
|
+
* If a copy of the MPL was not distributed with this file,
|
|
6
|
+
* You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
//! Baseline for fork #1 (equality-pushdown). Times a single-row primary-key
|
|
10
|
+
//! lookup written three ways against an N-row stored relation on the SQLite
|
|
11
|
+
//! backend:
|
|
12
|
+
//! - `eq_postfilter_positional`: `*rel[uid, val], uid == $u` (the slow shape)
|
|
13
|
+
//! - `eq_postfilter_brace`: `*rel{uid, val}, uid == $u` (the slow shape)
|
|
14
|
+
//! - `binding_first`: `uid = $u, *rel{uid, val}` (the fast shape)
|
|
15
|
+
//!
|
|
16
|
+
//! Before the fix, the post-filter shapes do an O(N) `load_stored` scan; after,
|
|
17
|
+
//! all three compile to an O(log N) `stored_prefix_join`. Run:
|
|
18
|
+
//! cargo bench -p mnestic --bench point_lookup
|
|
19
|
+
|
|
20
|
+
use std::collections::BTreeMap;
|
|
21
|
+
|
|
22
|
+
use cozo::{DataValue, DbInstance, ScriptMutability};
|
|
23
|
+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
|
|
24
|
+
|
|
25
|
+
const N: usize = 5000;
|
|
26
|
+
|
|
27
|
+
fn make_db() -> (tempfile::TempDir, DbInstance) {
|
|
28
|
+
let dir = tempfile::tempdir().unwrap();
|
|
29
|
+
let db = DbInstance::new(
|
|
30
|
+
"sqlite",
|
|
31
|
+
dir.path().join("point_lookup.db").to_str().unwrap(),
|
|
32
|
+
Default::default(),
|
|
33
|
+
)
|
|
34
|
+
.unwrap();
|
|
35
|
+
db.run_script(
|
|
36
|
+
":create pk_test { uid: String => val: String }",
|
|
37
|
+
BTreeMap::new(),
|
|
38
|
+
ScriptMutability::Mutable,
|
|
39
|
+
)
|
|
40
|
+
.unwrap();
|
|
41
|
+
|
|
42
|
+
// Insert N rows in chunks via a constant relation.
|
|
43
|
+
let mut i = 0;
|
|
44
|
+
while i < N {
|
|
45
|
+
let end = (i + 500).min(N);
|
|
46
|
+
let rows: Vec<String> = (i..end)
|
|
47
|
+
.map(|k| format!(r#"["k{k}","v{k}"]"#))
|
|
48
|
+
.collect();
|
|
49
|
+
let script = format!(
|
|
50
|
+
"?[uid, val] <- [{}] :put pk_test {{ uid => val }}",
|
|
51
|
+
rows.join(",")
|
|
52
|
+
);
|
|
53
|
+
db.run_script(&script, BTreeMap::new(), ScriptMutability::Mutable)
|
|
54
|
+
.unwrap();
|
|
55
|
+
i = end;
|
|
56
|
+
}
|
|
57
|
+
(dir, db)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
fn bench_point_lookup(c: &mut Criterion) {
|
|
61
|
+
let (_dir, db) = make_db();
|
|
62
|
+
// Look up a key in the middle of the keyspace.
|
|
63
|
+
let mut params = BTreeMap::new();
|
|
64
|
+
params.insert("u".to_string(), DataValue::Str(format!("k{}", N / 2).into()));
|
|
65
|
+
|
|
66
|
+
let mut group = c.benchmark_group("point_lookup");
|
|
67
|
+
for (name, query) in [
|
|
68
|
+
(
|
|
69
|
+
"eq_postfilter_positional",
|
|
70
|
+
"?[uid, val] := *pk_test[uid, val], uid == $u",
|
|
71
|
+
),
|
|
72
|
+
(
|
|
73
|
+
"eq_postfilter_brace",
|
|
74
|
+
"?[uid, val] := *pk_test{uid, val}, uid == $u",
|
|
75
|
+
),
|
|
76
|
+
("binding_first", "?[uid, val] := uid = $u, *pk_test{uid, val}"),
|
|
77
|
+
] {
|
|
78
|
+
group.bench_with_input(BenchmarkId::from_parameter(name), &query, |b, q| {
|
|
79
|
+
b.iter(|| {
|
|
80
|
+
let res = db
|
|
81
|
+
.run_script(q, params.clone(), ScriptMutability::Immutable)
|
|
82
|
+
.unwrap();
|
|
83
|
+
assert_eq!(res.rows.len(), 1);
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
group.finish();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
criterion_group!(benches, bench_point_lookup);
|
|
91
|
+
criterion_main!(benches);
|