mnemo-engine 0.13.2__tar.gz → 0.14.0__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.
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/PKG-INFO +32 -3
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/README.md +31 -2
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/Cargo.lock +5 -3
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/Cargo.toml +14 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/README.md +51 -0
- mnemo_engine-0.14.0/mnemo/build.rs +32 -0
- mnemo_engine-0.14.0/mnemo/examples/shared_bench.rs +555 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/bin/mnemo/inspect.rs +15 -6
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/bin/mnemo.rs +319 -82
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/error.rs +99 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/lib.rs +234 -3
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/mcp.rs +202 -10
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/pager.rs +101 -19
- mnemo_engine-0.14.0/mnemo/src/shared/call.rs +170 -0
- mnemo_engine-0.14.0/mnemo/src/shared/fscheck.rs +172 -0
- mnemo_engine-0.14.0/mnemo/src/shared/lock.rs +483 -0
- mnemo_engine-0.14.0/mnemo/src/shared/mod.rs +28 -0
- mnemo_engine-0.14.0/mnemo/src/shared/sidecar.rs +342 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/cache_api.rs +8 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/crud.rs +45 -15
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/flush.rs +15 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/hooks.rs +7 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/load.rs +278 -6
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/maintenance.rs +281 -50
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/mod.rs +28 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/open.rs +215 -13
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/recall.rs +10 -2
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/records.rs +9 -0
- mnemo_engine-0.14.0/mnemo/src/store/shared.rs +749 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/Cargo.lock +22 -2
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/Cargo.toml +1 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/README.md +31 -2
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/src/lib.rs +561 -193
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/test_mnemo.py +281 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/pyproject.toml +1 -1
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/.gitignore +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/benches/corpus.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/deny.toml +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/ann_diagnose.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/ann_recall_grid.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/ann_recall_grid_v2.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/embedder_server.py +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/file_size_breakdown.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/open_rss.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/quickstart.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/ranking_v2.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/session.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/examples/thread_profile.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/bin/mnemo/export.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/bin/mnemo/inspect.html +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/cache.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/crypto.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/embed.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/embed_cmd.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/format.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/freelist.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/index.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/keyslot.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/memory.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/result_cache.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/session.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/ann.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/continuation.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/essence.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/header_graft_tests.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/keyed.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/snapshots.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/store/threads.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/text.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/transcript.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/veccol.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo/src/wal.rs +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/mnemo-python/.gitignore +0 -0
- {mnemo_engine-0.13.2 → mnemo_engine-0.14.0}/python/mnemo_engine/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mnemo-engine
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.14.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
@@ -156,7 +156,26 @@ its own agent.
|
|
|
156
156
|
|
|
157
157
|
## API
|
|
158
158
|
|
|
159
|
-
`mnemo.open(path, passphrase, dimensions=None) -> Mnemo`
|
|
159
|
+
`mnemo.open(path, passphrase, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
160
|
+
|
|
161
|
+
**Shared mode** (v0.14, `shared=True`): several processes and sessions use
|
|
162
|
+
one file at once. The handle takes the file's lock for each call and holds
|
|
163
|
+
nothing between calls; every method below is one read or one write, and
|
|
164
|
+
each write commits before it returns (`flush()` does nothing). `wait` is how
|
|
165
|
+
long one call may wait for the lock, in seconds, before `LockedError`. The
|
|
166
|
+
file must already exist, and `shared=True` can't be combined with
|
|
167
|
+
`read_only=True`. Network and synced folders are refused unless
|
|
168
|
+
`allow_network_fs=True`. The handle keeps its passphrase in memory until it
|
|
169
|
+
closes. File-wide settings (`set_max_snapshots`, `set_cache_budget`,
|
|
170
|
+
`set_cache_flush_policy`, `set_turn_compress_after`) raise
|
|
171
|
+
`UnsupportedError`. Update every `mnemo-engine` that opens the file first.
|
|
172
|
+
See `docs/shared-mode.md` in the repository.
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
db = mnemo.open("team.mnemo", passphrase, shared=True) # in each process
|
|
176
|
+
db.remember("we ship on Fridays", "semantic", vector) # committed on return
|
|
177
|
+
db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
178
|
+
```
|
|
160
179
|
|
|
161
180
|
`Mnemo` methods:
|
|
162
181
|
|
|
@@ -189,6 +208,7 @@ its own agent.
|
|
|
189
208
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
190
209
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
191
210
|
| `rekey(new_passphrase, fast=False)` | Change the passphrase. Re-derives the KEK and re-wraps the DEK; encrypted pages are not rewritten (O(1) in db size). `fast=True` uses the cheap-Argon2 test params — omit for production. If it raises, the old passphrase is still in force (the one exception is an error that says the file may open with either). If it returns but couldn't scrub every copy of the old key wrap, it emits a `RuntimeWarning`: the call succeeded and the new passphrase is in force (where warnings are errors, it goes to `sys.unraisablehook` and the call still returns) |
|
|
211
|
+
| `rekey_cleanup_error()` | After a successful `rekey` / `rekey_with_key`: what couldn't be scrubbed of the old key wrap, or `None`. The same report as the `RuntimeWarning`, for code that filters warnings. Compact the file to be sure the old secret opens nothing |
|
|
192
212
|
| `set_embedder(fn, *, name, dimensions, normalize=True)` | Register a Python callable `embed(texts: list[str]) -> list[list[float]]` as this handle's text embedder (Phase 3). Dimension-checks against the database's width; identity-checks against (and on first use upserts) the scaffold manifest's `embedder_name` / `embedder_dimensions` / `embedder_normalize` keys, so swapping embedders between opens fails loudly |
|
|
193
213
|
| `remember_text(content, memory_type, **kwargs)` | Embed `content` via the registered embedder and `remember` the result. Accepts the same per-memory kwargs as `remember` (`agent_id`, `importance`, `session_id`, `ttl_secs`, `shared`, `metadata`) |
|
|
194
214
|
| `recall_text(query, top_k=10, memory_types=None, agent_id=None, track_access=True, n_probe=None, n_rerank=None, filter=None, max_bytes=None, keywords=None, keyword_weight=None)` | Embed `query` via the registered embedder and run `recall`. Same return shape and kwargs as `recall`. `keywords` (v9 files): identifiers or exact terms to match (a version, a PR number, a function name), not the question; their BM25 score is added with weight `keyword_weight` (default 0.5) |
|
|
@@ -196,13 +216,17 @@ its own agent.
|
|
|
196
216
|
| `stats()` | Summary statistics — includes `fsyncs_last_flush` (count of `sync_all` the most recent `flush()` on this handle issued; `0` on a fresh handle before any flush — Phase 6 instrumentation) and `recall_mode` (`"exact_resident"`: the live facts' vectors fit the vector cache budget and recall scans them in memory; `"exact_paged"`: over the budget, or a v8 file, so recall reads them from the file; `"indexed"`: an IVF+PQ index shortlists). Since v0.13 also `snapshots_retained`, `oldest_restorable_at` (unix seconds, or `None`) and `snapshot_pinned_bytes`: what a restore can reach now, which under churn can be far less than the retention policy |
|
|
197
217
|
| `export_encrypted(dest)` | Copy the (already-encrypted) file elsewhere |
|
|
198
218
|
| `len(db)` | Live memory count |
|
|
219
|
+
| `shared` | `True` for a handle opened with `shared=True` |
|
|
220
|
+
| `notices()` | Shared mode: what the handle warns about once (a sidecar directory it can't use, a synced folder, an allowed network filesystem); each is also raised as a `UserWarning` at open. Empty for a plain handle |
|
|
221
|
+
| `set_cancel(token)` | Shared mode: give the handle a new `CancelToken` (or `None`) for its later calls, after a cancel |
|
|
199
222
|
|
|
200
223
|
Plus two module-level functions:
|
|
201
224
|
|
|
202
225
|
| Function | Purpose |
|
|
203
226
|
|---|---|
|
|
204
|
-
| `mnemo.compact_file(path, passphrase)` | Rewrite the file out-of-place, dropping tombstoned and expired memories and reclaiming stale pages. Caller's own handle must be closed first. Returns `{"before": int, "after": int}` |
|
|
227
|
+
| `mnemo.compact_file(path, passphrase)` | Rewrite the file out-of-place, dropping tombstoned and expired memories and reclaiming stale pages. Caller's own plain handle must be closed first; since v0.14 it waits up to 10 s for shared handles' calls. Returns `{"before": int, "after": int}` |
|
|
205
228
|
| `mnemo.compact_file_with_key(path, key)` | The same for a raw-key file (`key`: 32 bytes, as from `generate_key()`), under the same key; converts a v8 file to v9 (since v0.13.1) |
|
|
229
|
+
| `mnemo.CancelToken()` | Shared mode: `token.cancel()` from another thread cancels a call that is waiting for the file's lock (`CancelledError`; nothing changes). Pass it as `open(..., cancel=token)`. A cancelled token stays cancelled |
|
|
206
230
|
| `mnemo.build_info()` | Returns `{"version", "target", "aes_backend", "polyval_backend"}` for the installed wheel. Lets you verify an ARM wheel picked up the hardware AES path — `aes_backend` should read `"armv8 hardware"` on Apple Silicon / Graviton (anything else, like `"armv8 software (constant-time fallback)"`, means the compile missed the fix). PR 11.0, v0.5.1+ |
|
|
207
231
|
|
|
208
232
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|
|
@@ -233,6 +257,11 @@ before the engine sees them, are still `ValueError`):
|
|
|
233
257
|
| `UnsupportedVersionError` | a file from a newer engine | upgrade `mnemo-engine` |
|
|
234
258
|
| `NotAMnemoFileError` | not a `.mnemo` file | check the path |
|
|
235
259
|
| `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
|
|
260
|
+
| `CancelledError` | shared mode: the call was cancelled while it waited for the lock; nothing changed | |
|
|
261
|
+
| `UnsupportedError` | shared mode isn't available here (a network or synced folder, an old Windows build), or a file-wide setting on a shared handle | pass `allow_network_fs=True` if you know the lock works there; drop the setting |
|
|
262
|
+
| `MaybeStoredError` | shared mode: a write failed after its commit point; it may be in the file | check whether it's there before retrying |
|
|
263
|
+
| `ReplacedDuringWriteError` | shared mode: another file was renamed over the path during the write (an older `mnemo compact`); the write isn't in the file at the path now | update every `mnemo` that opens the file, then write again |
|
|
264
|
+
| `ReplacedError` | the file at the path is no longer the one the handle opened: another file was renamed over it, or it was moved or removed; nothing was written. `shared` is `True` in a shared-mode write (an older `mnemo compact` renamed over the path just before the commit) | `shared` true: call again, and the call follows the new file. Otherwise reopen the path, or move a moved brain back |
|
|
236
265
|
| `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
|
|
237
266
|
|
|
238
267
|
```python
|
|
@@ -142,7 +142,26 @@ its own agent.
|
|
|
142
142
|
|
|
143
143
|
## API
|
|
144
144
|
|
|
145
|
-
`mnemo.open(path, passphrase, dimensions=None) -> Mnemo`
|
|
145
|
+
`mnemo.open(path, passphrase, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
146
|
+
|
|
147
|
+
**Shared mode** (v0.14, `shared=True`): several processes and sessions use
|
|
148
|
+
one file at once. The handle takes the file's lock for each call and holds
|
|
149
|
+
nothing between calls; every method below is one read or one write, and
|
|
150
|
+
each write commits before it returns (`flush()` does nothing). `wait` is how
|
|
151
|
+
long one call may wait for the lock, in seconds, before `LockedError`. The
|
|
152
|
+
file must already exist, and `shared=True` can't be combined with
|
|
153
|
+
`read_only=True`. Network and synced folders are refused unless
|
|
154
|
+
`allow_network_fs=True`. The handle keeps its passphrase in memory until it
|
|
155
|
+
closes. File-wide settings (`set_max_snapshots`, `set_cache_budget`,
|
|
156
|
+
`set_cache_flush_policy`, `set_turn_compress_after`) raise
|
|
157
|
+
`UnsupportedError`. Update every `mnemo-engine` that opens the file first.
|
|
158
|
+
See `docs/shared-mode.md` in the repository.
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
db = mnemo.open("team.mnemo", passphrase, shared=True) # in each process
|
|
162
|
+
db.remember("we ship on Fridays", "semantic", vector) # committed on return
|
|
163
|
+
db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
164
|
+
```
|
|
146
165
|
|
|
147
166
|
`Mnemo` methods:
|
|
148
167
|
|
|
@@ -175,6 +194,7 @@ its own agent.
|
|
|
175
194
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
176
195
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
177
196
|
| `rekey(new_passphrase, fast=False)` | Change the passphrase. Re-derives the KEK and re-wraps the DEK; encrypted pages are not rewritten (O(1) in db size). `fast=True` uses the cheap-Argon2 test params — omit for production. If it raises, the old passphrase is still in force (the one exception is an error that says the file may open with either). If it returns but couldn't scrub every copy of the old key wrap, it emits a `RuntimeWarning`: the call succeeded and the new passphrase is in force (where warnings are errors, it goes to `sys.unraisablehook` and the call still returns) |
|
|
197
|
+
| `rekey_cleanup_error()` | After a successful `rekey` / `rekey_with_key`: what couldn't be scrubbed of the old key wrap, or `None`. The same report as the `RuntimeWarning`, for code that filters warnings. Compact the file to be sure the old secret opens nothing |
|
|
178
198
|
| `set_embedder(fn, *, name, dimensions, normalize=True)` | Register a Python callable `embed(texts: list[str]) -> list[list[float]]` as this handle's text embedder (Phase 3). Dimension-checks against the database's width; identity-checks against (and on first use upserts) the scaffold manifest's `embedder_name` / `embedder_dimensions` / `embedder_normalize` keys, so swapping embedders between opens fails loudly |
|
|
179
199
|
| `remember_text(content, memory_type, **kwargs)` | Embed `content` via the registered embedder and `remember` the result. Accepts the same per-memory kwargs as `remember` (`agent_id`, `importance`, `session_id`, `ttl_secs`, `shared`, `metadata`) |
|
|
180
200
|
| `recall_text(query, top_k=10, memory_types=None, agent_id=None, track_access=True, n_probe=None, n_rerank=None, filter=None, max_bytes=None, keywords=None, keyword_weight=None)` | Embed `query` via the registered embedder and run `recall`. Same return shape and kwargs as `recall`. `keywords` (v9 files): identifiers or exact terms to match (a version, a PR number, a function name), not the question; their BM25 score is added with weight `keyword_weight` (default 0.5) |
|
|
@@ -182,13 +202,17 @@ its own agent.
|
|
|
182
202
|
| `stats()` | Summary statistics — includes `fsyncs_last_flush` (count of `sync_all` the most recent `flush()` on this handle issued; `0` on a fresh handle before any flush — Phase 6 instrumentation) and `recall_mode` (`"exact_resident"`: the live facts' vectors fit the vector cache budget and recall scans them in memory; `"exact_paged"`: over the budget, or a v8 file, so recall reads them from the file; `"indexed"`: an IVF+PQ index shortlists). Since v0.13 also `snapshots_retained`, `oldest_restorable_at` (unix seconds, or `None`) and `snapshot_pinned_bytes`: what a restore can reach now, which under churn can be far less than the retention policy |
|
|
183
203
|
| `export_encrypted(dest)` | Copy the (already-encrypted) file elsewhere |
|
|
184
204
|
| `len(db)` | Live memory count |
|
|
205
|
+
| `shared` | `True` for a handle opened with `shared=True` |
|
|
206
|
+
| `notices()` | Shared mode: what the handle warns about once (a sidecar directory it can't use, a synced folder, an allowed network filesystem); each is also raised as a `UserWarning` at open. Empty for a plain handle |
|
|
207
|
+
| `set_cancel(token)` | Shared mode: give the handle a new `CancelToken` (or `None`) for its later calls, after a cancel |
|
|
185
208
|
|
|
186
209
|
Plus two module-level functions:
|
|
187
210
|
|
|
188
211
|
| Function | Purpose |
|
|
189
212
|
|---|---|
|
|
190
|
-
| `mnemo.compact_file(path, passphrase)` | Rewrite the file out-of-place, dropping tombstoned and expired memories and reclaiming stale pages. Caller's own handle must be closed first. Returns `{"before": int, "after": int}` |
|
|
213
|
+
| `mnemo.compact_file(path, passphrase)` | Rewrite the file out-of-place, dropping tombstoned and expired memories and reclaiming stale pages. Caller's own plain handle must be closed first; since v0.14 it waits up to 10 s for shared handles' calls. Returns `{"before": int, "after": int}` |
|
|
191
214
|
| `mnemo.compact_file_with_key(path, key)` | The same for a raw-key file (`key`: 32 bytes, as from `generate_key()`), under the same key; converts a v8 file to v9 (since v0.13.1) |
|
|
215
|
+
| `mnemo.CancelToken()` | Shared mode: `token.cancel()` from another thread cancels a call that is waiting for the file's lock (`CancelledError`; nothing changes). Pass it as `open(..., cancel=token)`. A cancelled token stays cancelled |
|
|
192
216
|
| `mnemo.build_info()` | Returns `{"version", "target", "aes_backend", "polyval_backend"}` for the installed wheel. Lets you verify an ARM wheel picked up the hardware AES path — `aes_backend` should read `"armv8 hardware"` on Apple Silicon / Graviton (anything else, like `"armv8 software (constant-time fallback)"`, means the compile missed the fix). PR 11.0, v0.5.1+ |
|
|
193
217
|
|
|
194
218
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|
|
@@ -219,6 +243,11 @@ before the engine sees them, are still `ValueError`):
|
|
|
219
243
|
| `UnsupportedVersionError` | a file from a newer engine | upgrade `mnemo-engine` |
|
|
220
244
|
| `NotAMnemoFileError` | not a `.mnemo` file | check the path |
|
|
221
245
|
| `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
|
|
246
|
+
| `CancelledError` | shared mode: the call was cancelled while it waited for the lock; nothing changed | |
|
|
247
|
+
| `UnsupportedError` | shared mode isn't available here (a network or synced folder, an old Windows build), or a file-wide setting on a shared handle | pass `allow_network_fs=True` if you know the lock works there; drop the setting |
|
|
248
|
+
| `MaybeStoredError` | shared mode: a write failed after its commit point; it may be in the file | check whether it's there before retrying |
|
|
249
|
+
| `ReplacedDuringWriteError` | shared mode: another file was renamed over the path during the write (an older `mnemo compact`); the write isn't in the file at the path now | update every `mnemo` that opens the file, then write again |
|
|
250
|
+
| `ReplacedError` | the file at the path is no longer the one the handle opened: another file was renamed over it, or it was moved or removed; nothing was written. `shared` is `True` in a shared-mode write (an older `mnemo compact` renamed over the path just before the commit) | `shared` true: call again, and the call follows the new file. Otherwise reopen the path, or move a moved brain back |
|
|
222
251
|
| `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
|
|
223
252
|
|
|
224
253
|
```python
|
|
@@ -821,7 +821,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
|
821
821
|
|
|
822
822
|
[[package]]
|
|
823
823
|
name = "mnemo-engine"
|
|
824
|
-
version = "0.
|
|
824
|
+
version = "0.14.0"
|
|
825
825
|
dependencies = [
|
|
826
826
|
"aes-gcm",
|
|
827
827
|
"argon2",
|
|
@@ -837,6 +837,8 @@ dependencies = [
|
|
|
837
837
|
"rmp",
|
|
838
838
|
"rmp-serde",
|
|
839
839
|
"rpassword",
|
|
840
|
+
"rustix",
|
|
841
|
+
"same-file",
|
|
840
842
|
"serde",
|
|
841
843
|
"serde_json",
|
|
842
844
|
"sha2",
|
|
@@ -850,7 +852,7 @@ dependencies = [
|
|
|
850
852
|
|
|
851
853
|
[[package]]
|
|
852
854
|
name = "mnemo-node"
|
|
853
|
-
version = "0.
|
|
855
|
+
version = "0.14.0"
|
|
854
856
|
dependencies = [
|
|
855
857
|
"mnemo-engine",
|
|
856
858
|
"napi",
|
|
@@ -860,7 +862,7 @@ dependencies = [
|
|
|
860
862
|
|
|
861
863
|
[[package]]
|
|
862
864
|
name = "mnemo-uniffi"
|
|
863
|
-
version = "0.
|
|
865
|
+
version = "0.14.0"
|
|
864
866
|
dependencies = [
|
|
865
867
|
"mnemo-engine",
|
|
866
868
|
"serde_json",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# The CLI binary name stays `mnemo`, so users still invoke `mnemo` on
|
|
11
11
|
# the command line after `cargo install mnemo-engine`.
|
|
12
12
|
name = "mnemo-engine"
|
|
13
|
-
version = "0.
|
|
13
|
+
version = "0.14.0"
|
|
14
14
|
edition = "2021"
|
|
15
15
|
rust-version = "1.75"
|
|
16
16
|
# `benches/corpus.rs` is a shared helper module pulled into real benches
|
|
@@ -113,6 +113,12 @@ rpassword = "=7.3.1"
|
|
|
113
113
|
# See CHANGELOG's Phase 1.1 entry. If this fails to build on your
|
|
114
114
|
# toolchain, the fallback is `fd-lock`.
|
|
115
115
|
fs4 = { version = "=0.9.1", default-features = false, features = ["sync"] }
|
|
116
|
+
# The identity of an open file and of the file at a path, compared to tell
|
|
117
|
+
# whether the path still names the file a handle opened (`dev`/`ino` on
|
|
118
|
+
# Unix; the volume serial number and file index on Windows). Safe Rust over
|
|
119
|
+
# `winapi-util` on Windows, so it fits `#![forbid(unsafe_code)]`. Already in
|
|
120
|
+
# the lockfile through criterion's walkdir.
|
|
121
|
+
same-file = "=1.0.6"
|
|
116
122
|
# SHA-256 for the result-cache key hashing (Phase 10.1). Pure Rust,
|
|
117
123
|
# widely deployed, small. RustCrypto family, so it interops with the
|
|
118
124
|
# same digest traits `argon2` and `blake2` already pull in transitively.
|
|
@@ -148,6 +154,13 @@ zstd = { version = "=0.13.4", default-features = false }
|
|
|
148
154
|
# the format was frozen. Only built with `--features fmt9_proto`.
|
|
149
155
|
lz4_flex = { version = "=0.11.6", default-features = false, features = ["std", "safe-encode", "safe-decode"], optional = true }
|
|
150
156
|
|
|
157
|
+
# 12.4 step 2a, the shared lock layer: safe wrappers for `openat`,
|
|
158
|
+
# `mkdir`, `O_NOFOLLOW`, `fstat`, `statfs`, `geteuid` and `kill(pid, 0)`, so
|
|
159
|
+
# the sidecar directory is checked and used without `unsafe`. Already in the
|
|
160
|
+
# tree through fs4 (same version); this adds the `process` feature.
|
|
161
|
+
[target.'cfg(unix)'.dependencies]
|
|
162
|
+
rustix = { version = "=0.38.44", default-features = false, features = ["std", "fs", "process"] }
|
|
163
|
+
|
|
151
164
|
[dev-dependencies]
|
|
152
165
|
tempfile = "=3.10.1"
|
|
153
166
|
# Property-based testing (Phase 1.3). Pinned exactly; `=1.5.0`'s MSRV
|
|
@@ -45,6 +45,20 @@ would leak into shell history and process listings). Tools exposed:
|
|
|
45
45
|
`cache_put`, `cache_get`, `cache_stats`, `cache_put_semantic`,
|
|
46
46
|
`cache_get_semantic`. Every mutation flushes before returning.
|
|
47
47
|
|
|
48
|
+
The server holds the file's lock for its whole life by default, so a second
|
|
49
|
+
server or a CLI write on the same file gets `Locked`. **`--shared`** (v0.14,
|
|
50
|
+
12.4 shared mode) holds nothing between tool calls instead: each call takes
|
|
51
|
+
the lock for itself (a read runs alongside other readers, a write waits with
|
|
52
|
+
writer preference) for up to `--wait` (default 10 s), so several servers,
|
|
53
|
+
the CLI and Python can use one brain. What the server warns about (a sidecar
|
|
54
|
+
directory it can't use, a synced folder) goes to stderr once at start.
|
|
55
|
+
Update every `mnemo` on the machine before you turn it on; see
|
|
56
|
+
`docs/shared-mode.md`.
|
|
57
|
+
|
|
58
|
+
```sh
|
|
59
|
+
MNEMO_PASSPHRASE=... mnemo serve --mcp --shared team.mnemo
|
|
60
|
+
```
|
|
61
|
+
|
|
48
62
|
#### Text-in via `--embed-cmd` (Phase 3)
|
|
49
63
|
|
|
50
64
|
`remember`, `recall`, `cache_put_semantic`, and `cache_get_semantic`
|
|
@@ -438,6 +452,30 @@ with the default `track_access(true)` counts as a mutation (it bumps
|
|
|
438
452
|
catalog access stats) and requires `track_access(false)` on a read-only
|
|
439
453
|
handle. The matching CLI knob is `mnemo recall --no-track`.
|
|
440
454
|
|
|
455
|
+
**Compaction replaces the file, safely** (v0.14.0). `compact_file` writes
|
|
456
|
+
the compacted copy to a temp file next to the original and renames it over
|
|
457
|
+
the path while it still holds the old file's exclusive lock, so a process
|
|
458
|
+
waiting on the lock never commits to the file being replaced. Every open
|
|
459
|
+
checks, once it holds its lock, that the path still names the locked file,
|
|
460
|
+
and retries if not. A handle whose path was replaced while it was open
|
|
461
|
+
(another program moved a file over it) refuses its next commit with
|
|
462
|
+
`MnemoError::Replaced` and writes nothing; reopen the path. On Windows,
|
|
463
|
+
holding the lock through the rename needs the engine built with Rust 1.85
|
|
464
|
+
or later (the released binaries and wheels are); with an older toolchain
|
|
465
|
+
compaction closes the old file before the rename, and the identity check
|
|
466
|
+
before each commit is what catches a write that would land in the replaced
|
|
467
|
+
file.
|
|
468
|
+
|
|
469
|
+
**Shared mode** (v0.14, 12.4): `Mnemo::open_shared` returns a
|
|
470
|
+
`SharedMnemo`, which takes the lock for each call (`read` under the shared
|
|
471
|
+
lock, `write` under the exclusive one, committing before it returns) and
|
|
472
|
+
holds nothing between calls, so several processes use one file at once.
|
|
473
|
+
Long plain operations wait for shared callers instead of failing:
|
|
474
|
+
`compact_file` (and so `mnemo compact` and `rekey --rotate`), the CLI's
|
|
475
|
+
`import` and `rekey`, and your own through `Mnemo::open_exclusive`, which
|
|
476
|
+
also names the operation to a shared caller that times out. A plain
|
|
477
|
+
`Mnemo::open` still fails at once with `Locked`. See `docs/shared-mode.md`.
|
|
478
|
+
|
|
441
479
|
Two conditions block a read-only open and return `MnemoError::NeedsWriteOpen`:
|
|
442
480
|
a committed-but-uncheckpointed WAL transaction waiting to be replayed on
|
|
443
481
|
open, and an on-disk format version older than the current build. Both cases
|
|
@@ -772,6 +810,19 @@ cargo run --bin mnemo -- <command>
|
|
|
772
810
|
| `restore` | Roll the database back to a past snapshot |
|
|
773
811
|
| `demo` | Self-contained end-to-end demonstration |
|
|
774
812
|
|
|
813
|
+
**`--wait <duration>`** (v0.14, 12.4), on every command: how long to wait
|
|
814
|
+
for the file's lock when another process holds it (`10s` by default;
|
|
815
|
+
`500ms`, `2m`, or a number of seconds). Reads (`info`, `list`, `get`,
|
|
816
|
+
`search`, `history`, `export`, `verify`, `recall --no-track`, `inspect`,
|
|
817
|
+
...) run alongside other readers. Writes (`remember`, `update`, `forget`,
|
|
818
|
+
`import`, `compact`, `rekey`, and the other commands that change the file)
|
|
819
|
+
take the exclusive lock and leave a note naming the command while they hold
|
|
820
|
+
it; readers come first, so busy readers slow a write, and enough of them
|
|
821
|
+
can keep it waiting past `--wait` (`docs/shared-mode.md`, "How busy a file
|
|
822
|
+
can get"). When the wait runs out, the error names what holds the file if
|
|
823
|
+
it left a note. A hook that only reads should pass `--wait 2s`; a hook that
|
|
824
|
+
saves keeps the default.
|
|
825
|
+
|
|
775
826
|
### Self-describing databases
|
|
776
827
|
|
|
777
828
|
A `.mnemo` file should be able to introduce itself. The single-file philosophy
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//! 12.4 step 2a: on Windows, the engine's shared mode needs `std::fs::rename`
|
|
2
|
+
//! to replace a file another handle has open, which std does only from Rust
|
|
3
|
+
//! 1.85 (probed on CI, 2026-11-13: 1.75 to 1.84 refuse with os error 5). A
|
|
4
|
+
//! Windows build with an older compiler sets `mnemo_windows_old_rename`, and
|
|
5
|
+
//! shared mode then refuses to start with a clear error. Every other build,
|
|
6
|
+
//! the released binaries and wheels included, is unaffected.
|
|
7
|
+
|
|
8
|
+
use std::process::Command;
|
|
9
|
+
|
|
10
|
+
fn main() {
|
|
11
|
+
println!("cargo:rustc-check-cfg=cfg(mnemo_windows_old_rename)");
|
|
12
|
+
println!("cargo:rerun-if-changed=build.rs");
|
|
13
|
+
println!("cargo:rerun-if-env-changed=RUSTC");
|
|
14
|
+
let windows = std::env::var("CARGO_CFG_TARGET_OS").is_ok_and(|os| os == "windows");
|
|
15
|
+
if windows && rustc_minor().is_some_and(|minor| minor < 85) {
|
|
16
|
+
println!("cargo:rustc-cfg=mnemo_windows_old_rename");
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/// The minor version of the compiler building this crate (`rustc -V` reads
|
|
21
|
+
/// "rustc 1.84.1 (...)"), or `None` if it can't be read.
|
|
22
|
+
fn rustc_minor() -> Option<u32> {
|
|
23
|
+
let rustc = std::env::var_os("RUSTC").unwrap_or_else(|| "rustc".into());
|
|
24
|
+
let out = Command::new(rustc).arg("-V").output().ok()?;
|
|
25
|
+
let text = String::from_utf8(out.stdout).ok()?;
|
|
26
|
+
let version = text.split_whitespace().nth(1)?;
|
|
27
|
+
let mut parts = version.split('.');
|
|
28
|
+
if parts.next()? != "1" {
|
|
29
|
+
return None;
|
|
30
|
+
}
|
|
31
|
+
parts.next()?.parse().ok()
|
|
32
|
+
}
|