mnemo-engine 0.13.0__tar.gz → 0.13.2__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.0 → mnemo_engine-0.13.2}/PKG-INFO +28 -23
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/README.md +27 -22
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/Cargo.lock +3 -3
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/Cargo.toml +1 -1
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/README.md +46 -10
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/bin/mnemo/inspect.html +37 -3
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/bin/mnemo/inspect.rs +293 -54
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/bin/mnemo.rs +142 -33
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/error.rs +2 -1
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/maintenance.rs +109 -7
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/mod.rs +3 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/open.rs +70 -15
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/Cargo.lock +2 -2
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/Cargo.toml +8 -6
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/README.md +27 -22
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/src/lib.rs +221 -4
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/test_mnemo.py +159 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/pyproject.toml +1 -1
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/.gitignore +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/benches/corpus.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/deny.toml +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/ann_diagnose.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/ann_recall_grid.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/ann_recall_grid_v2.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/embedder_server.py +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/file_size_breakdown.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/open_rss.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/quickstart.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/ranking_v2.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/session.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/examples/thread_profile.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/bin/mnemo/export.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/cache.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/crypto.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/embed.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/embed_cmd.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/format.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/freelist.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/index.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/keyslot.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/lib.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/mcp.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/memory.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/pager.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/result_cache.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/session.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/ann.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/cache_api.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/continuation.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/crud.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/essence.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/flush.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/header_graft_tests.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/hooks.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/keyed.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/load.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/recall.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/records.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/snapshots.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/store/threads.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/text.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/transcript.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/veccol.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo/src/wal.rs +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/mnemo-python/.gitignore +0 -0
- {mnemo_engine-0.13.0 → mnemo_engine-0.13.2}/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.13.
|
|
3
|
+
Version: 0.13.2
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: 3
|
|
6
6
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
@@ -188,7 +188,7 @@ its own agent.
|
|
|
188
188
|
| `set_turn_compress_after(secs)` | v9 files: compress thread turns once they're older than `secs` (default 7 days; `0` compresses at write). This handle only |
|
|
189
189
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
190
190
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
191
|
-
| `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 |
|
|
191
|
+
| `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) |
|
|
192
192
|
| `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
193
|
| `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
194
|
| `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) |
|
|
@@ -202,6 +202,7 @@ Plus two module-level functions:
|
|
|
202
202
|
| Function | Purpose |
|
|
203
203
|
|---|---|
|
|
204
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}` |
|
|
205
|
+
| `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) |
|
|
205
206
|
| `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+ |
|
|
206
207
|
|
|
207
208
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|
|
@@ -213,35 +214,39 @@ nested dict.
|
|
|
213
214
|
|
|
214
215
|
### Errors
|
|
215
216
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
Since v0.13.1 every engine error is an `mnemo_engine.MnemoError`, which
|
|
218
|
+
subclasses `RuntimeError`, so `except RuntimeError` keeps working. The
|
|
219
|
+
subclasses tell the cases apart (argument errors the binding catches itself,
|
|
220
|
+
before the engine sees them, are still `ValueError`):
|
|
220
221
|
|
|
221
|
-
|
|
|
222
|
+
| Exception | What happened | What to do |
|
|
222
223
|
|---|---|---|
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
229
|
-
| `
|
|
230
|
-
| `
|
|
231
|
-
| `
|
|
232
|
-
| `
|
|
233
|
-
| `
|
|
224
|
+
| `FormatTooOldError` | the file predates v9: a v8 file opens only with `read_only=True`, v4–v7 not at all | run `mnemo compact <file>` once (`--key-file` for a raw-key file, or `compact_file_with_key`); it keeps every live memory |
|
|
225
|
+
| `NeedsWriteOpenError` | the file has pending work (a committed write to finish, a torn header to repair) | open it read-write once; on a pre-v9 file the message says to run `mnemo compact` instead |
|
|
226
|
+
| `EmbedderMismatchError` | the embedder given isn't the one the file's vectors came from | use the original embedder, or create a new file for the new model |
|
|
227
|
+
| `WrongPassphraseError` | the passphrase or key doesn't open this file | check the secret |
|
|
228
|
+
| `LockedError` | another handle (another process, or one not yet closed) has the file | close it, or open read-only alongside a reader |
|
|
229
|
+
| `ReadOnlyError` | a write on a `read_only=True` handle | reopen read-write |
|
|
230
|
+
| `DimensionMismatchError` | a vector of the wrong width | embed with the file's model |
|
|
231
|
+
| `InvalidArgumentError` | a bad argument the engine refused (an all-zero vector, say) | fix the call |
|
|
232
|
+
| `NotFoundError` | the id isn't in the file | |
|
|
233
|
+
| `UnsupportedVersionError` | a file from a newer engine | upgrade `mnemo-engine` |
|
|
234
|
+
| `NotAMnemoFileError` | not a `.mnemo` file | check the path |
|
|
235
|
+
| `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
|
|
236
|
+
| `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
|
|
234
237
|
|
|
235
238
|
```python
|
|
239
|
+
import mnemo_engine as mnemo
|
|
240
|
+
|
|
236
241
|
try:
|
|
237
242
|
db = mnemo.open(path, passphrase)
|
|
238
|
-
except
|
|
239
|
-
|
|
240
|
-
db = mnemo.open(path, passphrase, read_only=True) # a v8 file; compact it later
|
|
241
|
-
else:
|
|
242
|
-
raise
|
|
243
|
+
except mnemo.FormatTooOldError:
|
|
244
|
+
db = mnemo.open(path, passphrase, read_only=True) # a v8 file; compact it later
|
|
243
245
|
```
|
|
244
246
|
|
|
247
|
+
Each message is the engine's own, unchanged from before, so code that
|
|
248
|
+
matched on a message's start keeps working too.
|
|
249
|
+
|
|
245
250
|
## Result caching
|
|
246
251
|
|
|
247
252
|
MNemo doubles as a durable result cache — memoize LLM tool-call outputs,
|
|
@@ -174,7 +174,7 @@ its own agent.
|
|
|
174
174
|
| `set_turn_compress_after(secs)` | v9 files: compress thread turns once they're older than `secs` (default 7 days; `0` compresses at write). This handle only |
|
|
175
175
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
176
176
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
177
|
-
| `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 |
|
|
177
|
+
| `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) |
|
|
178
178
|
| `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
179
|
| `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
180
|
| `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) |
|
|
@@ -188,6 +188,7 @@ Plus two module-level functions:
|
|
|
188
188
|
| Function | Purpose |
|
|
189
189
|
|---|---|
|
|
190
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}` |
|
|
191
|
+
| `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) |
|
|
191
192
|
| `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+ |
|
|
192
193
|
|
|
193
194
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|
|
@@ -199,35 +200,39 @@ nested dict.
|
|
|
199
200
|
|
|
200
201
|
### Errors
|
|
201
202
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
203
|
+
Since v0.13.1 every engine error is an `mnemo_engine.MnemoError`, which
|
|
204
|
+
subclasses `RuntimeError`, so `except RuntimeError` keeps working. The
|
|
205
|
+
subclasses tell the cases apart (argument errors the binding catches itself,
|
|
206
|
+
before the engine sees them, are still `ValueError`):
|
|
206
207
|
|
|
207
|
-
|
|
|
208
|
+
| Exception | What happened | What to do |
|
|
208
209
|
|---|---|---|
|
|
209
|
-
| `
|
|
210
|
-
| `
|
|
211
|
-
| `
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
215
|
-
| `
|
|
216
|
-
| `
|
|
217
|
-
| `
|
|
218
|
-
| `
|
|
219
|
-
| `
|
|
210
|
+
| `FormatTooOldError` | the file predates v9: a v8 file opens only with `read_only=True`, v4–v7 not at all | run `mnemo compact <file>` once (`--key-file` for a raw-key file, or `compact_file_with_key`); it keeps every live memory |
|
|
211
|
+
| `NeedsWriteOpenError` | the file has pending work (a committed write to finish, a torn header to repair) | open it read-write once; on a pre-v9 file the message says to run `mnemo compact` instead |
|
|
212
|
+
| `EmbedderMismatchError` | the embedder given isn't the one the file's vectors came from | use the original embedder, or create a new file for the new model |
|
|
213
|
+
| `WrongPassphraseError` | the passphrase or key doesn't open this file | check the secret |
|
|
214
|
+
| `LockedError` | another handle (another process, or one not yet closed) has the file | close it, or open read-only alongside a reader |
|
|
215
|
+
| `ReadOnlyError` | a write on a `read_only=True` handle | reopen read-write |
|
|
216
|
+
| `DimensionMismatchError` | a vector of the wrong width | embed with the file's model |
|
|
217
|
+
| `InvalidArgumentError` | a bad argument the engine refused (an all-zero vector, say) | fix the call |
|
|
218
|
+
| `NotFoundError` | the id isn't in the file | |
|
|
219
|
+
| `UnsupportedVersionError` | a file from a newer engine | upgrade `mnemo-engine` |
|
|
220
|
+
| `NotAMnemoFileError` | not a `.mnemo` file | check the path |
|
|
221
|
+
| `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
|
|
222
|
+
| `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
|
|
220
223
|
|
|
221
224
|
```python
|
|
225
|
+
import mnemo_engine as mnemo
|
|
226
|
+
|
|
222
227
|
try:
|
|
223
228
|
db = mnemo.open(path, passphrase)
|
|
224
|
-
except
|
|
225
|
-
|
|
226
|
-
db = mnemo.open(path, passphrase, read_only=True) # a v8 file; compact it later
|
|
227
|
-
else:
|
|
228
|
-
raise
|
|
229
|
+
except mnemo.FormatTooOldError:
|
|
230
|
+
db = mnemo.open(path, passphrase, read_only=True) # a v8 file; compact it later
|
|
229
231
|
```
|
|
230
232
|
|
|
233
|
+
Each message is the engine's own, unchanged from before, so code that
|
|
234
|
+
matched on a message's start keeps working too.
|
|
235
|
+
|
|
231
236
|
## Result caching
|
|
232
237
|
|
|
233
238
|
MNemo doubles as a durable result cache — memoize LLM tool-call outputs,
|
|
@@ -821,7 +821,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
|
|
|
821
821
|
|
|
822
822
|
[[package]]
|
|
823
823
|
name = "mnemo-engine"
|
|
824
|
-
version = "0.13.
|
|
824
|
+
version = "0.13.2"
|
|
825
825
|
dependencies = [
|
|
826
826
|
"aes-gcm",
|
|
827
827
|
"argon2",
|
|
@@ -850,7 +850,7 @@ dependencies = [
|
|
|
850
850
|
|
|
851
851
|
[[package]]
|
|
852
852
|
name = "mnemo-node"
|
|
853
|
-
version = "0.13.
|
|
853
|
+
version = "0.13.2"
|
|
854
854
|
dependencies = [
|
|
855
855
|
"mnemo-engine",
|
|
856
856
|
"napi",
|
|
@@ -860,7 +860,7 @@ dependencies = [
|
|
|
860
860
|
|
|
861
861
|
[[package]]
|
|
862
862
|
name = "mnemo-uniffi"
|
|
863
|
-
version = "0.13.
|
|
863
|
+
version = "0.13.2"
|
|
864
864
|
dependencies = [
|
|
865
865
|
"mnemo-engine",
|
|
866
866
|
"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.
|
|
13
|
+
version = "0.13.2"
|
|
14
14
|
edition = "2021"
|
|
15
15
|
rust-version = "1.75"
|
|
16
16
|
# `benches/corpus.rs` is a shared helper module pulled into real benches
|
|
@@ -332,6 +332,17 @@ rewrites the file under a fresh DEK. `Mnemo::export_rekeyed` writes a copy
|
|
|
332
332
|
under a fresh DEK and a new secret, sharing no key material with the
|
|
333
333
|
source. Rotation can't erase old ciphertext the storage hardware still holds: flash keeps rewritten blocks until it reuses them, and that's out of the engine's hands.
|
|
334
334
|
|
|
335
|
+
**A `rekey` that fails leaves the old secret in force** (REKEY-1, v0.13.2),
|
|
336
|
+
for the handle and for the file, including after later writes and a
|
|
337
|
+
close. It takes effect at one point, the write of the new page 0; a
|
|
338
|
+
failure before that puts the old header back. The one exception is a
|
|
339
|
+
failure to write the new page 0 followed by a failure to put the old one
|
|
340
|
+
back; the error then says the file may open with either secret. Once the
|
|
341
|
+
new page 0 is on disk, scrubbing the old key wrap from the file is
|
|
342
|
+
hygiene: if part of it fails, `rekey` still succeeds, and
|
|
343
|
+
`Mnemo::rekey_cleanup_error` (a warning in the CLI, a `RuntimeWarning` in
|
|
344
|
+
Python) says what was left. `--rotate` covers it.
|
|
345
|
+
|
|
335
346
|
The file is a sequence of fixed **8 KiB pages**:
|
|
336
347
|
|
|
337
348
|
- **Page 0** — the header (plaintext): magic, version, KDF parameters, salt,
|
|
@@ -862,6 +873,13 @@ The passphrase is resolved in this priority order:
|
|
|
862
873
|
passphrase follows the same chain via `--new-passphrase`,
|
|
863
874
|
`MNEMO_NEW_PASSPHRASE`, or a double-prompt.
|
|
864
875
|
|
|
876
|
+
**Raw-key files** (what `Mnemo::create_with_key` writes, and what the
|
|
877
|
+
phone libraries keep) open with `--key-file <path>` instead, on `info`,
|
|
878
|
+
`about`, `list`, `verify`, `recall`, `export`, `compact` and `inspect`
|
|
879
|
+
(since v0.13.1). The file holds the 32-byte key, raw or as 64 hex digits;
|
|
880
|
+
it can't be combined with `--passphrase`. `mnemo compact --key-file` is
|
|
881
|
+
how a raw-key v8 file becomes v9.
|
|
882
|
+
|
|
865
883
|
For real applications, prefer the library API and supply the passphrase
|
|
866
884
|
in-process.
|
|
867
885
|
|
|
@@ -905,15 +923,17 @@ cargo run --bin mnemo -- export agent.mnemo --git -o memory.md
|
|
|
905
923
|
`mnemo inspect` serves a read-only web view of a file on your machine:
|
|
906
924
|
|
|
907
925
|
```sh
|
|
908
|
-
cargo run --bin mnemo -- inspect agent.mnemo # prints a
|
|
926
|
+
cargo run --bin mnemo -- inspect agent.mnemo # prints a link that works once: open it in your browser
|
|
909
927
|
cargo run --bin mnemo -- inspect app.mnemo --key-file app.key # a raw-key file (32 bytes or 64 hex digits)
|
|
910
|
-
cargo run --bin mnemo -- inspect agent.mnemo --open # opens the browser for you
|
|
928
|
+
cargo run --bin mnemo -- inspect agent.mnemo --open # opens the browser for you
|
|
911
929
|
```
|
|
912
930
|
|
|
913
|
-
The passphrase comes from the prompt or `MNEMO_PASSPHRASE`.
|
|
914
|
-
printed URL
|
|
915
|
-
|
|
916
|
-
|
|
931
|
+
The passphrase comes from the prompt or `MNEMO_PASSPHRASE`. Copy the
|
|
932
|
+
printed URL into your browser, or pass `--open`, which hands the browser a
|
|
933
|
+
private local page (owner-only, deleted once it has loaded) that forwards
|
|
934
|
+
to the URL. On Linux, a browser installed as a snap or a flatpak (Ubuntu's
|
|
935
|
+
default Firefox is a snap) has its own private `/tmp` and can't read that
|
|
936
|
+
page, so copy the printed link instead.
|
|
917
937
|
|
|
918
938
|
- **Views:** memories (filter by type, agent, keyed or not, and thread;
|
|
919
939
|
keyword search with BM25, no embedder needed), keyed history (each
|
|
@@ -926,11 +946,27 @@ on a machine nobody else logs into.
|
|
|
926
946
|
reads it again (one passphrase derivation). If a writer has the file
|
|
927
947
|
open at that moment, it says so and keeps the last read.
|
|
928
948
|
- **It stays on your machine.** It binds `127.0.0.1` only (a random free
|
|
929
|
-
port unless `--port`)
|
|
930
|
-
|
|
949
|
+
port unless `--port`). The printed link carries a random one-time code,
|
|
950
|
+
which the page exchanges for a random session token on its first load
|
|
951
|
+
and keeps for that tab only. **The link works once** (since v0.13.2): the
|
|
952
|
+
code is refused after that, so the copy the browser's history records
|
|
953
|
+
(or `--open`'s forwarding page) opens nothing. A refresh keeps working;
|
|
954
|
+
another tab needs a new link (run `mnemo inspect` again). Every data
|
|
955
|
+
request must carry the token and a `Host` of the loopback address and
|
|
931
956
|
port, which stops other sites' pages (DNS rebinding included). Only `GET`
|
|
932
|
-
is served, with no CORS, and no endpoint writes the file.
|
|
933
|
-
|
|
957
|
+
is served, with no CORS, and no endpoint writes the file. **What it
|
|
958
|
+
writes to disk:** without `--open`, nothing. With `--open`, one small
|
|
959
|
+
page that forwards the browser to the link, in a new folder under the
|
|
960
|
+
system temp directory (on macOS and Linux, a folder only you can open,
|
|
961
|
+
holding a page only you can read). It's removed (with
|
|
962
|
+
its folder) as soon as the page has exchanged the link's code, or after
|
|
963
|
+
60 seconds if it never does. If the inspector is stopped before that, the
|
|
964
|
+
page can be left behind, holding a code that no longer works. The token
|
|
965
|
+
stops working when the inspector stops.
|
|
966
|
+
- **It stops when it's left alone.** After `--idle-timeout` without a
|
|
967
|
+
request from the page (30 minutes by default; `90s`, `1h`, or `0` for
|
|
968
|
+
never) it wipes the passphrase or key from memory and exits. It holds
|
|
969
|
+
the secret only so that Reload works.
|
|
934
970
|
- It works on v8 files too, and on passphrase exports from the phone
|
|
935
971
|
libraries.
|
|
936
972
|
|
|
@@ -91,15 +91,43 @@
|
|
|
91
91
|
<main id="main"></main>
|
|
92
92
|
<script>
|
|
93
93
|
"use strict";
|
|
94
|
-
|
|
94
|
+
// The printed link carries a one-time code, not the token. The page takes it
|
|
95
|
+
// out of the address bar and exchanges it once for the session token, which
|
|
96
|
+
// it keeps for this tab only. The server refuses the code after that, so the
|
|
97
|
+
// copy in the browser's history (and in `--open`'s forwarding page) is dead.
|
|
98
|
+
const TOKEN_KEY = "mnemo-inspect-token";
|
|
99
|
+
let TOKEN = "";
|
|
100
|
+
function storedToken() {
|
|
101
|
+
try { return sessionStorage.getItem(TOKEN_KEY) || ""; } catch (e) { return ""; }
|
|
102
|
+
}
|
|
103
|
+
async function session() {
|
|
104
|
+
const code = new URLSearchParams(location.search).get("c");
|
|
105
|
+
if (!code) return { token: storedToken() };
|
|
106
|
+
history.replaceState(null, "", location.pathname);
|
|
107
|
+
// A page the browser renders ahead of time waits until it's shown, so a
|
|
108
|
+
// prerender that's thrown away doesn't use up the link.
|
|
109
|
+
if (document.prerendering) {
|
|
110
|
+
await new Promise(r => document.addEventListener("prerenderingchange", r, { once: true }));
|
|
111
|
+
}
|
|
112
|
+
const r = await fetch("/api/session?" + new URLSearchParams({ c: code }).toString())
|
|
113
|
+
.catch(() => { throw new Error(STOPPED); });
|
|
114
|
+
if (!r.ok) return { token: storedToken(), used: true };
|
|
115
|
+
const { token } = await r.json();
|
|
116
|
+
try { sessionStorage.setItem(TOKEN_KEY, token); } catch (e) {}
|
|
117
|
+
return { token };
|
|
118
|
+
}
|
|
95
119
|
const main = document.getElementById("main");
|
|
96
120
|
let view = "memories";
|
|
97
121
|
const state = { q: "", type: "", agent: "", keyed: "", thread: "", key: null, threadId: null };
|
|
98
122
|
|
|
123
|
+
// RB-004.5 item 4: once the server has stopped (`--idle-timeout`, or
|
|
124
|
+
// Ctrl-C), a request can't connect; say that instead of the browser's text.
|
|
125
|
+
const STOPPED = "The inspector has stopped (after --idle-timeout without use, or Ctrl-C), " +
|
|
126
|
+
"so this page can't read the file any more. Run `mnemo inspect <file>` again for a new link.";
|
|
99
127
|
function api(path, params) {
|
|
100
128
|
const u = new URLSearchParams(params || {});
|
|
101
129
|
u.set("t", TOKEN);
|
|
102
|
-
return fetch(path + "?" + u.toString()).then(async r => {
|
|
130
|
+
return fetch(path + "?" + u.toString()).catch(() => { throw new Error(STOPPED); }).then(async r => {
|
|
103
131
|
const body = await r.json().catch(() => ({ error: r.statusText }));
|
|
104
132
|
if (!r.ok) throw new Error(body.error || r.statusText);
|
|
105
133
|
return body;
|
|
@@ -285,7 +313,13 @@ document.getElementById("reload").addEventListener("click", async () => {
|
|
|
285
313
|
catch (e) { document.getElementById("loaded").textContent = "reload failed: " + e.message; }
|
|
286
314
|
finally { btn.disabled = false; btn.textContent = "Reload"; }
|
|
287
315
|
});
|
|
288
|
-
|
|
316
|
+
session().then(s => {
|
|
317
|
+
TOKEN = s.token;
|
|
318
|
+
if (TOKEN) { header(); render(); return; }
|
|
319
|
+
main.replaceChildren(el("p", { class: "error" }, s.used
|
|
320
|
+
? "This link has already been used. Each link `mnemo inspect` prints opens one tab; run it again for a new one."
|
|
321
|
+
: "This tab has no access. Open the link that `mnemo inspect` printed."));
|
|
322
|
+
}, fail);
|
|
289
323
|
</script>
|
|
290
324
|
</body>
|
|
291
325
|
</html>
|