You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A **probabilistic B-tree**implementation in Rust that combines B-tree efficiency with Merkle tree cryptographic properties. Designed for distributed systems, version control, and verifiable data structures.
8
+
**Versioned, namespaced, semantically-searchable storage for AI agents**— built on a probabilistic B-tree with Merkle properties.
9
9
10
-
## Features
10
+
ProllyTree gives an agent a long-term memory it can branch, merge, and audit like source code: every write is committed to a real Git history, every memory is cryptographically verifiable, and the bundled text index lets the agent recall by meaning rather than exact key. Implemented in Rust with first-class Python bindings.
11
+
12
+
## Why ProllyTree for agent memory
11
13
12
-
-**High Performance**: O(log n) operations with cache-friendly probabilistic balancing
13
-
-**Cryptographically Verifiable**: Merkle tree properties for data integrity and inclusion proofs
14
-
-**Multiple Storage Backends**: In-memory, File, RocksDB, and Git-backed persistence
15
-
-**Distributed-Ready**: Efficient diff, sync, and three-way merge with pluggable conflict resolvers
16
-
-**Python Bindings**: Full API coverage via PyO3 with async support
17
-
-**SQL Interface**: Query trees with SQL via GlueSQL integration
14
+
-**Per-agent namespaces.** Run many isolated agents against one store — each gets its own prolly tree (key space, search index, history) inside the same Git repo. One commit covers every namespace atomically.
15
+
-**Semantic recall.** Vector / text indexes live inside any namespace. Search by meaning ("what did the user say about billing last week?") and resolve hits back to the original message via the primary tree.
16
+
-**Branchable scratch spaces.** Spin up an `experiment` branch for tool-call replays, A/B prompt strategies, or speculative reasoning. Discard or merge back. Real Git branches — `gh` / `git log` work.
17
+
-**Auditable.** Every memory mutation is a Git commit. Diff what an agent learned between two timestamps, rewind to a known-good state, or merge knowledge across agent instances with three-way conflict resolution.
18
+
-**Cryptographically verifiable.** Each value carries a Merkle inclusion proof. Useful when an agent's memory crosses trust boundaries (replicas, audit logs, ZK use cases).
19
+
-**No standalone vector database needed.** The text index and the primary store share one transaction. No syncing job, no eventual-consistency window between memory and embeddings.
18
20
19
-
## Quick Start
21
+
## Features
20
22
21
-
Add to your `Cargo.toml`:
23
+
| Capability | What it gives you |
24
+
|---|---|
25
+
|**Versioned KV store**| Git-backed branch / commit / diff / three-way merge on raw key-value state |
26
+
|**Namespaced KV store**| Many isolated prolly trees in one Git repo, atomic across namespaces |
27
+
|**Text / vector search**| Versioned ANN index inside any namespace; bundled MiniLM, hash, and callable embedders |
28
+
|**Multi-chunk indexing**| Split docs into chunks at index time, dedup on search by document |
29
+
|**Cascade mode**| One primary write auto-mirrors into every registered text index |
30
+
|**Drift detection + repair**|`audit_text_index` and `purge_text_index_orphans`|
31
+
|**Large-value externalization**| Values above a threshold land in content-addressed blobs; `gc_blobs()` reclaims them |
32
+
|**Cryptographic proofs**| Merkle inclusion / absence proofs on every value |
// → diff, merge, history available; see the user guide
65
133
```
66
134
67
-
See [`examples/`](examples/) for SQL queries, additional storage backends, and agent
68
-
memory patterns.
135
+
See [`examples/`](examples/) (Rust) and [`python/examples/`](python/examples/) (Python) for namespaces, text search, cascade, merge resolvers, and SQL.
136
+
137
+
## Embedders
138
+
139
+
The text-search surface ships three embedders. All three plug into `text_index_open(...)` the same way.
140
+
141
+
| Embedder | Pulls in | Use it for |
142
+
|---|---|---|
143
+
|`HashEmbedder`| nothing extra | Tests, demos, exact-match recall |
|`CallableEmbedder`| your callable | OpenAI, Cohere, sentence-transformers, your own model |
69
146
70
-
## Feature Flags
147
+
Embedder identity (`id` + `version`) is persisted with the index. Reopening with a mismatched embedder surfaces a clear error — no silent mixing of vectors from different models.
148
+
149
+
## Feature flags
71
150
72
151
| Feature | Description | Default |
73
-
|---------|-------------|---------|
74
-
|`git`| Git-backed versioned storage with branching, merging, and history | Yes |
152
+
|---|---|---|
153
+
|`git`| Git-backed versioned storage with branching, merging, history | Yes |
75
154
|`sql`| SQL query interface via GlueSQL | Yes |
155
+
|`proximity`| Vector index + text-search infrastructure (ML-free) | No |
156
+
|`proximity_text`| Bundled Candle + all-MiniLM-L6-v2 embedder | No |
76
157
|`rocksdb_storage`| RocksDB persistent storage backend | No |
77
158
|`python`| Python bindings via PyO3 | No |
78
159
|`tracing`| Observability via the `tracing` crate | No |
79
-
|`digest_base64`| Base64 encoding for digests | Yes |
features = ["git", "sql", "proximity", "proximity_text"]
85
167
```
86
168
87
169
## Performance
88
170
89
-
**Benchmarks (Apple M3 Pro, 18GB RAM):**
90
-
- Insert: ~8-21 us (scales O(log n))
91
-
- Lookup: ~1-3 us (sub-linear due to caching)
171
+
Benchmarks on Apple M3 Pro / 18 GB RAM:
172
+
173
+
- Insert: ~8–21 µs (scales O(log n))
174
+
- Lookup: ~1–3 µs (sub-linear due to caching)
92
175
- Memory: ~100 bytes per key-value pair
93
176
- Batch operations: ~25% faster than individual ops
94
177
95
-
Run benchmarks: `cargo bench`
178
+
Run `cargo bench` to reproduce. The vector index uses a lazy-rebuild pattern — mutations are amortised, the first search after a mutation pays the rebuild cost.
96
179
97
180
## Testing
98
181
99
182
```bash
100
183
# Rust tests
101
-
cargo test --features "git sql"
184
+
cargo test --features "git sql proximity"
102
185
103
-
# Python tests (build bindings first)
186
+
# Python tests (build bindings first; --all-features includes proximity)
104
187
./python/build_python.sh --all-features --install
105
188
python -m pytest python/tests/
106
189
```
107
190
108
-
## Documentation & Examples
191
+
## Documentation
109
192
110
-
-**[User Guide & Theory](https://zhangfengcdt.github.io/prollytree/)** – mkdocs site with the full tour (theory, CLI, Python, examples)
111
-
-**[Rust API Reference](https://docs.rs/prollytree)** – auto-generated from source
Copy file name to clipboardExpand all lines: docs/examples/text_search.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ Runnable Python examples for the text-index + vector-search surface on `Namespac
4
4
5
5
A complete runnable script — covering every snippet on this page plus a MiniLM end-to-end demo — lives at [`python/examples/text_index_example.py`](https://github.com/zhangfengcdt/prollytree/blob/main/python/examples/text_index_example.py).
6
6
7
+
!!! tip "Browser demo"
8
+
Want to see the workflow without installing anything? The [interactive demo](../text_search_demo.html) runs a toy search against a static corpus in your browser, and includes the same code snippets shown below.
Copy file name to clipboardExpand all lines: docs/text_search.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,9 @@
2
2
3
3
ProllyTree includes a **version-controlled approximate-nearest-neighbour (ANN) index** that sits inside any namespace of a `NamespacedKvStore`. You can do semantic similarity search on the same data that the rest of the store versions, branches, and merges — without standing up a separate vector database.
4
4
5
+
!!! tip "Try it in your browser"
6
+
Open the [interactive demo](text_search_demo.html) for a self-contained walkthrough — namespaced store + text indexes + cascade + live search, no install required.
7
+
5
8
For the conceptual model see [Architecture → Proximity / text-search layer](architecture.md#7-proximity-text-search-layer). For runnable code see [Examples → Text Search](examples/text_search.md).
0 commit comments