mnemo-engine 0.19.0__tar.gz → 0.20.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.
Files changed (97) hide show
  1. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/PKG-INFO +20 -4
  2. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/README.md +2 -1
  3. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/Cargo.lock +3 -3
  4. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/Cargo.toml +15 -7
  5. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/README.md +36 -20
  6. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/shared_bench.rs +314 -1
  7. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/guide/guide.md +3 -2
  8. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/inspect.html +2 -1
  9. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo.rs +66 -11
  10. mnemo_engine-0.20.0/mnemo/src/cache.rs +481 -0
  11. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/error.rs +4 -0
  12. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/index.rs +20 -0
  13. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/lib.rs +108 -5
  14. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/mcp.rs +14 -0
  15. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/pager.rs +282 -32
  16. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/lock.rs +1 -1
  17. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/mod.rs +1 -0
  18. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/ann.rs +112 -22
  19. mnemo_engine-0.20.0/mnemo/src/store/catchup.rs +638 -0
  20. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/flush.rs +242 -110
  21. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/hooks.rs +165 -0
  22. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/load.rs +20 -0
  23. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/maintenance.rs +65 -0
  24. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/mod.rs +34 -3
  25. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/open.rs +6 -3
  26. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/records.rs +7 -2
  27. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/shared.rs +191 -1
  28. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/snapshots.rs +2 -0
  29. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/wal.rs +4 -0
  30. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/Cargo.lock +2 -2
  31. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/Cargo.toml +4 -4
  32. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/README.md +2 -1
  33. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/src/lib.rs +33 -0
  34. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/test_mnemo.py +2 -0
  35. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/pyproject.toml +20 -3
  36. mnemo_engine-0.19.0/mnemo/src/cache.rs +0 -299
  37. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/.gitignore +0 -0
  38. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/benches/corpus.rs +0 -0
  39. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/build.rs +0 -0
  40. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/deny.toml +0 -0
  41. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
  42. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/ann_diagnose.rs +0 -0
  43. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/ann_recall_grid.rs +0 -0
  44. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/ann_recall_grid_v2.rs +0 -0
  45. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/candle_hard.rs +0 -0
  46. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/embedder_server.py +0 -0
  47. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/file_size_breakdown.rs +0 -0
  48. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/inspect_demo_brain.rs +0 -0
  49. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/open_rss.rs +0 -0
  50. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/perf2_split.rs +0 -0
  51. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/quickstart.rs +0 -0
  52. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/ranking_v2.rs +0 -0
  53. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/session.rs +0 -0
  54. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/examples/thread_profile.rs +0 -0
  55. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/export.rs +0 -0
  56. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/hook.rs +0 -0
  57. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/inspect.rs +0 -0
  58. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/mcp_install.rs +0 -0
  59. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/onboard.rs +0 -0
  60. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/bin/mnemo/project.rs +0 -0
  61. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/builtin.rs +0 -0
  62. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/crypto.rs +0 -0
  63. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/embed.rs +0 -0
  64. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/embed_cmd.rs +0 -0
  65. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/format.rs +0 -0
  66. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/freelist.rs +0 -0
  67. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/guide.rs +0 -0
  68. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/ident.rs +0 -0
  69. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/keys/display.rs +0 -0
  70. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/keys/mod.rs +0 -0
  71. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/keys/os_store.rs +0 -0
  72. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/keys/recovery.rs +0 -0
  73. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/keyslot.rs +0 -0
  74. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/mcp/context.rs +0 -0
  75. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/memory.rs +0 -0
  76. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/redact.rs +0 -0
  77. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/result_cache.rs +0 -0
  78. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/session.rs +0 -0
  79. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/call.rs +0 -0
  80. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/fscheck.rs +0 -0
  81. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/presence.rs +0 -0
  82. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/shared/sidecar.rs +0 -0
  83. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/cache_api.rs +0 -0
  84. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/continuation.rs +0 -0
  85. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/coordination.rs +0 -0
  86. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/crud.rs +0 -0
  87. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/essence.rs +0 -0
  88. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/findings.rs +0 -0
  89. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/header_graft_tests.rs +0 -0
  90. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/keyed.rs +0 -0
  91. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/recall.rs +0 -0
  92. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/store/threads.rs +0 -0
  93. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/text.rs +0 -0
  94. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/transcript.rs +0 -0
  95. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo/src/veccol.rs +0 -0
  96. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/mnemo-python/.gitignore +0 -0
  97. {mnemo_engine-0.19.0 → mnemo_engine-0.20.0}/python/mnemo_engine/__init__.py +0 -0
@@ -1,15 +1,30 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mnemo-engine
3
- Version: 0.19.0
3
+ Version: 0.20.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Developers
6
+ Classifier: License :: OSI Approved :: Apache Software License
7
+ Classifier: Operating System :: MacOS
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: POSIX :: Linux
4
10
  Classifier: Programming Language :: Rust
5
11
  Classifier: Programming Language :: Python :: 3
6
- Classifier: License :: OSI Approved :: Apache Software License
7
- Summary: Encrypted, portable agent-memory engine — Python bindings
12
+ Classifier: Programming Language :: Python :: 3 :: Only
13
+ Classifier: Topic :: Database
14
+ Classifier: Topic :: Database :: Database Engines/Servers
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Security :: Cryptography
17
+ Classifier: Topic :: Software Development :: Libraries
18
+ Summary: Shared memory for your coding agents, in one encrypted file: Python bindings for the embedded MNemo engine, with recall
19
+ Keywords: mcp,agent-memory,encryption,vector-search,embedded-database
8
20
  Home-Page: https://toarchkumar.github.io/mnemo/
9
21
  License: Apache-2.0
10
22
  Requires-Python: >=3.8
11
23
  Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
24
+ Project-URL: Changelog, https://github.com/toarchkumar/mnemo/blob/main/CHANGELOG.md
25
+ Project-URL: Documentation, https://github.com/toarchkumar/mnemo/blob/main/mnemo-python/README.md
12
26
  Project-URL: Homepage, https://github.com/toarchkumar/mnemo
27
+ Project-URL: Issues, https://github.com/toarchkumar/mnemo/issues
13
28
  Project-URL: Repository, https://github.com/toarchkumar/mnemo
14
29
 
15
30
  # Memory Nemo (MNemo) — Python bindings
@@ -225,6 +240,7 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
225
240
  | `session(agent_id)` | Begin a conversation `Session` |
226
241
  | `flush()` / `close()` | Persist pending changes |
227
242
  | `verify()` | Decrypt and re-validate every record |
243
+ | `verify_index()` | v0.19.1: read the persisted ANN index apart from the records: `{"status": "none" \| "ok" \| "unknown-layout" \| "damaged", ...}` with `vectors` and `delta_runs`, `layout`, or `error`. A damaged index loses no memories: recall scans exactly, says so once in `notices()`, and the handle's next write rebuilds it |
228
244
  | `build_index()` / `drop_index()` / `has_index()` | Approximate index control |
229
245
  | `snapshots()` / `restore_to(txn_id)` / `restore_to_time(unix_secs)` | Point-in-time recovery |
230
246
  | `set_cache_capacity(pages)` / `page_cache_stats()` | Page-cache tuning (renamed from `cache_stats` in v0.4.0 — that name now belongs to the result cache below) |
@@ -309,7 +325,7 @@ before the engine sees them, are still `ValueError`):
309
325
  | `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
310
326
  | `CancelledError` | shared mode: the call was cancelled while it waited for the lock; nothing changed | |
311
327
  | `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 |
312
- | `MaybeStoredError` | shared mode: a write failed after its commit point; it may be in the file | check whether it's there before retrying |
328
+ | `MaybeStoredError` | a write failed after its commit point (shared mode), or a flush after one did on this handle (since v0.20.0); it may be in the file | reopen the file and check whether it's there before retrying |
313
329
  | `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 |
314
330
  | `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 |
315
331
  | `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
@@ -211,6 +211,7 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
211
211
  | `session(agent_id)` | Begin a conversation `Session` |
212
212
  | `flush()` / `close()` | Persist pending changes |
213
213
  | `verify()` | Decrypt and re-validate every record |
214
+ | `verify_index()` | v0.19.1: read the persisted ANN index apart from the records: `{"status": "none" \| "ok" \| "unknown-layout" \| "damaged", ...}` with `vectors` and `delta_runs`, `layout`, or `error`. A damaged index loses no memories: recall scans exactly, says so once in `notices()`, and the handle's next write rebuilds it |
214
215
  | `build_index()` / `drop_index()` / `has_index()` | Approximate index control |
215
216
  | `snapshots()` / `restore_to(txn_id)` / `restore_to_time(unix_secs)` | Point-in-time recovery |
216
217
  | `set_cache_capacity(pages)` / `page_cache_stats()` | Page-cache tuning (renamed from `cache_stats` in v0.4.0 — that name now belongs to the result cache below) |
@@ -295,7 +296,7 @@ before the engine sees them, are still `ValueError`):
295
296
  | `CorruptError` | a page or the header failed its integrity check: corrupt or tampered | restore from a backup or an export |
296
297
  | `CancelledError` | shared mode: the call was cancelled while it waited for the lock; nothing changed | |
297
298
  | `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 |
298
- | `MaybeStoredError` | shared mode: a write failed after its commit point; it may be in the file | check whether it's there before retrying |
299
+ | `MaybeStoredError` | a write failed after its commit point (shared mode), or a flush after one did on this handle (since v0.20.0); it may be in the file | reopen the file and check whether it's there before retrying |
299
300
  | `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 |
300
301
  | `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 |
301
302
  | `MnemoError` (only) | I/O, cryptography, key derivation or serialization | the message says which |
@@ -1520,7 +1520,7 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
1520
1520
 
1521
1521
  [[package]]
1522
1522
  name = "mnemo-engine"
1523
- version = "0.19.0"
1523
+ version = "0.20.0"
1524
1524
  dependencies = [
1525
1525
  "aes-gcm",
1526
1526
  "apple-native-keyring-store",
@@ -1561,7 +1561,7 @@ dependencies = [
1561
1561
 
1562
1562
  [[package]]
1563
1563
  name = "mnemo-node"
1564
- version = "0.19.0"
1564
+ version = "0.20.0"
1565
1565
  dependencies = [
1566
1566
  "mnemo-engine",
1567
1567
  "napi",
@@ -1571,7 +1571,7 @@ dependencies = [
1571
1571
 
1572
1572
  [[package]]
1573
1573
  name = "mnemo-uniffi"
1574
- version = "0.19.0"
1574
+ version = "0.20.0"
1575
1575
  dependencies = [
1576
1576
  "mnemo-engine",
1577
1577
  "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.19.0"
13
+ version = "0.20.0"
14
14
  edition = "2021"
15
15
  rust-version = "1.94"
16
16
  # `benches/corpus.rs` is a shared helper module pulled into real benches
@@ -18,7 +18,7 @@ rust-version = "1.94"
18
18
  # auto-discovery so cargo doesn't try to build it as its own bench
19
19
  # executable; the `[[bench]]` entries below list every real target.
20
20
  autobenches = false
21
- description = "Encrypted, single-file, portable agent memory engine with multi-signal recall, sessions, snapshots, and an IVF+PQ index"
21
+ description = "Shared memory for your coding agents, in one encrypted file: an embedded Rust engine with recall, an MCP server and a CLI"
22
22
  license = "Apache-2.0"
23
23
  repository = "https://github.com/toarchkumar/mnemo"
24
24
  homepage = "https://toarchkumar.github.io/mnemo/"
@@ -41,11 +41,19 @@ exclude = [
41
41
  "examples/device_budget.rs",
42
42
  "examples/fmt9_proto.rs",
43
43
  ]
44
- # crates.io shows 5 keywords; pick the ones most likely to match how
45
- # people search for this. Each keyword must be ≤20 chars and lowercase.
46
- keywords = ["database", "encryption", "vector", "ai", "memory"]
47
- # Standard crates.io category slugs (https://crates.io/category_slugs).
48
- categories = ["database", "cryptography", "command-line-utilities"]
44
+ # crates.io takes at most 5 keywords, each at most 20 characters of ASCII
45
+ # letters, digits, `_`, `-` or `+`, starting with a letter; pick the ones
46
+ # people search for (v0200-d2).
47
+ keywords = ["mcp", "agent-memory", "encryption", "vector-search", "embedded-database"]
48
+ # Standard crates.io category slugs (https://crates.io/category_slugs), at
49
+ # most 5.
50
+ categories = [
51
+ "database-implementations",
52
+ "database",
53
+ "cryptography",
54
+ "development-tools",
55
+ "command-line-utilities",
56
+ ]
49
57
 
50
58
  # The core crate is the workspace root. The Node binding lives here as a
51
59
  # workspace member but is NOT a default member: a plain `cargo build` /
@@ -120,18 +120,29 @@ file that records another embedder, or when the model can't be loaded
120
120
  (offline, first use), it serves without one and says so on stderr:
121
121
  `recall`'s `text` is then matched by keyword only (v9 files).
122
122
 
123
- The server holds the file's lock for its whole life by default, so a second
124
- server or a CLI write on the same file gets `Locked`. **`--shared`** (v0.14,
125
- 12.4 shared mode) holds nothing between tool calls instead: each call takes
126
- the lock for itself (a read runs alongside other readers, a write waits with
127
- writer preference) for up to `--wait` (default 10 s), so several servers,
128
- the CLI and Python can use one brain. What the server warns about (a sidecar
129
- directory it can't use, a synced folder) goes to stderr once at start.
130
- Update every `mnemo` on the machine before you turn it on; see
131
- `docs/shared-mode.md`.
123
+ **The server is shared by default since v0.20** (12.4 shared mode, behind
124
+ `--shared` since v0.14): it holds nothing between tool calls, and each call
125
+ takes the lock for itself (a read runs alongside other readers, a write
126
+ waits with writer preference) for up to `--wait` (default 10 s), so several
127
+ servers, the CLI and Python can use one brain. What the server warns about
128
+ (a sidecar directory it can't use, a synced folder) goes to stderr once at
129
+ start. It refuses a network or synced folder unless you pass
130
+ `--allow-network-fs`. `--shared` is still accepted, so existing configs
131
+ keep working.
132
+
133
+ **`--exclusive`** keeps the behaviour from before v0.20: the server holds
134
+ the file's lock for its whole life, so a second server or a CLI write on
135
+ the same file gets `Locked`.
136
+
137
+ **Update every `mnemo` on the machine** before you rely on shared mode:
138
+ every CLI, the `mnemo-engine` wheel in every virtualenv, and any app built
139
+ on an older binding. A `mnemo compact` from before v0.14 releases its lock
140
+ before it renames, so a shared write in that gap is lost; it's reported
141
+ (`ReplacedDuringWrite`), never acknowledged. See `docs/shared-mode.md`.
132
142
 
133
143
  ```sh
134
- MNEMO_PASSPHRASE=... mnemo serve --mcp --shared team.mnemo
144
+ MNEMO_PASSPHRASE=... mnemo serve --mcp team.mnemo # shared
145
+ MNEMO_PASSPHRASE=... mnemo serve --mcp --exclusive solo.mnemo # holds the file
135
146
  ```
136
147
 
137
148
  #### Resources, prompts and instructions (v0.16, 12.2)
@@ -336,10 +347,11 @@ parts: `nosync` finds `mnemo.nosync`, `icloud` finds `iCloud's`. A file
336
347
  written before v0.15 keeps tokenizer 1 (whole words) until `mnemo compact`
337
348
  rebuilds its index; `mnemo info` shows which (`keywords:`).
338
349
 
339
- The server holds an exclusive write lock on the file for its lifetime
340
- (see [Concurrency](#concurrency--read-only-opens)), so two MCP servers
341
- on the same file will conflict — one will fail to start with
342
- `Locked`. That's intentional.
350
+ Since v0.20 the server is shared by default, so two MCP servers on the
351
+ same file work side by side. With `--exclusive` it holds an exclusive write
352
+ lock on the file for its lifetime (see
353
+ [Concurrency](#concurrency--read-only-opens)), and a second server fails
354
+ to start with `Locked`.
343
355
 
344
356
  ### Result caching
345
357
 
@@ -571,17 +583,21 @@ would need monotonic counters tracked outside the file.
571
583
 
572
584
  `flush()` is one **atomic transaction**, committed through a write-ahead log:
573
585
 
574
- 1. Record (vector) data pages are written copy-on-write to fresh pages and
575
- fsynced. Being unreferenced until the catalog below commits, they are
576
- crash-safe by construction.
586
+ 1. Record (vector) data pages are written copy-on-write to fresh pages, and
587
+ so is any control-plane run too big for the WAL (FMT-9c). Being
588
+ unreferenced until the catalog below commits, they are crash-safe by
589
+ construction. **One fsync, the barrier, makes them all durable** before
590
+ the commit (since v0.20.0; before, the big runs had a second one).
577
591
  2. The transaction's control plane — the new catalog, the ANN index, and the
578
592
  new header — is written into the WAL region as a run of
579
593
  `(txn_id, page_no, page_image)` frames followed by a checksummed `COMMIT`
580
594
  frame.
581
595
  3. **One fsync of the WAL is the commit point.** Before it the transaction
582
596
  does not exist; after it the transaction is durable even though no home
583
- page has changed.
584
- 4. A *checkpoint* copies each frame to its home page and rewrites page 0.
597
+ page has changed. It's never merged with the barrier: within one fsync
598
+ the disk may persist the commit frame before the pages it names.
599
+ 4. A *checkpoint* copies each frame to its home page and rewrites page 0,
600
+ and fsyncs: three fsyncs a commit.
585
601
 
586
602
  A crash *before* the commit fsync leaves the previous state untouched. A crash
587
603
  *after* it is repaired on open: [`recover`](src/wal.rs) replays the committed
@@ -1000,7 +1016,7 @@ cargo run --bin mnemo -- <command>
1000
1016
  | `search` | Exact nearest-neighbour search (similarity only); no path needed in a git repository (v0.16.1). Since v0.17 it leaves out coordination records, and private ones unless `--visibility` asks |
1001
1017
  | `recall` | Multi-signal ranked retrieval (sim + recency + …). Since v0.17 private records only with `--visibility private` (or `all`) |
1002
1018
  | `stale [PATH] [--mine] [--visibility L]` | The stale records, oldest first (private ones only when asked): past their `review_by`, or older than their kind's default (essence `state` and `next` 14 days, `open` 30; an `active` task with no update 3 days, a `blocked` one 7; an unread message 3). `--mine` keeps yours (`--as`, else `MNEMO_AGENT`) (v0.17) |
1003
- | `verify` | Decrypt and re-validate every live record |
1019
+ | `verify` | Decrypt and re-validate every live record; since v0.19.1 it also reads the ANN index and reports it on its own line (a damaged index is a warning: the memories are intact, and `mnemo index --rebuild` repairs it) |
1004
1020
  | `rekey` | Re-encrypt the data key under a new passphrase, or a new generated key (`--new-key`, v0.15, kept in the key store); `--rotate` also rewrites the file under a fresh data key (revokes the old secret) |
1005
1021
  | `compact` | Rebuild the file, dropping tombstones and expired; writes v9, which converts a v8 (or older) file. Since v0.13 that's the only way to make a v8 file writable again. Since v0.15 it also rebuilds the keyword index with tokenizer 2 |
1006
1022
  | `reembed` | Embed every live memory again with a new embedder (`--embed-cmd`, `--embed-name`, `--embed-query`, `--embed-dims`; without `--embed-cmd`, the built-in) and record its identity: a compaction with new vectors, so an interrupted run leaves the file as it was (v0.15) |
@@ -6,8 +6,20 @@
6
6
  //! cargo run --release --example shared_bench -- --cells 1,2,3,4 --sizes 1000,10000,100000
7
7
  //! cargo run --release --example shared_bench -- --cells 5,6,7,8 --sizes 10000,100000 --secs 8
8
8
  //! cargo run --release --example shared_bench -- --cells 9 --sizes 10000 --secs 20 --valve-ms 250,500,1000,2000
9
+ //! cargo run --release --features failpoints --example shared_bench -- --cells 10,11 --sizes 10000,100000
10
+ //! cargo run --release --example shared_bench -- --cells 12 --sizes 10000,100000
11
+ //! cargo run --release --features failpoints --example shared_bench -- --cells 10 --sizes 100000 --commits 500
9
12
  //! ```
10
13
  //!
14
+ //! Cells 10 and 11 (v0.20.0, v0200-3) are the incremental catch-up's
15
+ //! (`docs/design/catch-up.md`): 10 is a reader's catch-up after another
16
+ //! handle's one-memory commit, the recalls after it and the memory it
17
+ //! keeps (`--commits N` for the long run, `--reps N` for its loops); 11 is what the first recall
18
+ //! pays to rebuild each lazily built part a catch-up may drop; 12 is cell
19
+ //! 10's footprint control (as many recalls, no commit). With the
20
+ //! `failpoints` feature, cell 10 also counts incremental and full
21
+ //! catch-ups.
22
+ //!
11
23
  //! Child processes are this binary run again with `MNEMO_SB_ROLE` set
12
24
  //! (writers, readers, a compactor, an opener). Each child writes its counts
13
25
  //! and latencies to a file in the run's directory. The results are printed
@@ -24,7 +36,9 @@ use std::path::{Path, PathBuf};
24
36
  use std::process::{Child, Command, Stdio};
25
37
  use std::time::{Duration, Instant};
26
38
 
27
- use mnemo_engine::{Memory, MemoryType, Mnemo, MnemoError, SharedMnemo, SharedOptions, Ulid};
39
+ use mnemo_engine::{
40
+ Memory, MemoryType, Mnemo, MnemoError, RecallRequest, SharedMnemo, SharedOptions, Ulid,
41
+ };
28
42
  use rand::{Rng, SeedableRng};
29
43
  use serde_json::{json, Value};
30
44
 
@@ -434,6 +448,280 @@ fn cell4(n: usize, reps: usize, scratch: &Path) -> Value {
434
448
  })
435
449
  }
436
450
 
451
+ /// The physical footprint in MB (`vmmap --summary`, macOS): what memory
452
+ /// pressure acts on. `ps`'s RSS also counts freed pages the allocator
453
+ /// hasn't returned. `None` elsewhere.
454
+ fn footprint_mb() -> Option<f64> {
455
+ let o = Command::new("vmmap")
456
+ .args(["--summary", &std::process::id().to_string()])
457
+ .stderr(Stdio::null())
458
+ .output()
459
+ .ok()?;
460
+ let s = String::from_utf8_lossy(&o.stdout);
461
+ let v = s
462
+ .lines()
463
+ .find(|l| l.starts_with("Physical footprint:"))?
464
+ .split_whitespace()
465
+ .last()?
466
+ .to_string();
467
+ let (num, unit) = v.split_at(v.len() - 1);
468
+ let x: f64 = num.parse().ok()?;
469
+ match unit {
470
+ "K" => Some(x / 1024.0),
471
+ "M" => Some(x),
472
+ "G" => Some(x * 1024.0),
473
+ _ => None,
474
+ }
475
+ }
476
+
477
+ fn recall_req(rng: &mut impl Rng) -> RecallRequest {
478
+ RecallRequest::new(vector(rng))
479
+ .top_k(10)
480
+ .track_access(false)
481
+ }
482
+
483
+ #[cfg(feature = "failpoints")]
484
+ fn catch_ups(s: &SharedMnemo) -> Value {
485
+ let (inc, full) = s.__catch_ups();
486
+ json!({ "incremental": inc, "full": full })
487
+ }
488
+
489
+ #[cfg(not(feature = "failpoints"))]
490
+ fn catch_ups(_: &SharedMnemo) -> Value {
491
+ Value::Null
492
+ }
493
+
494
+ /// The handle's full reloads so far (0 without the counter).
495
+ #[cfg(feature = "failpoints")]
496
+ fn full_reloads(s: &SharedMnemo) -> u64 {
497
+ s.__catch_ups().1
498
+ }
499
+
500
+ #[cfg(not(feature = "failpoints"))]
501
+ fn full_reloads(_: &SharedMnemo) -> u64 {
502
+ 0
503
+ }
504
+
505
+ /// What the handle holds (the dev-hooks budget report, MB), with the
506
+ /// vector column's filled rows: live data, to set against the footprint.
507
+ fn held(s: &mut SharedMnemo) -> Value {
508
+ let (r, filled) = s
509
+ .read(|db| Ok((db.__budget_report()?, db.__column_filled().len())))
510
+ .unwrap();
511
+ let mb = |b: u64| round(b as f64 / 1_048_576.0);
512
+ json!({
513
+ "total_mb": mb(r.ram_total),
514
+ "catalog_mb": mb(r.ram_catalog),
515
+ "id_map_mb": mb(r.ram_id_map),
516
+ "ann_mb": mb(r.ram_ann_centroids
517
+ + r.ram_ann_codebook
518
+ + r.ram_ann_posting_ids
519
+ + r.ram_ann_posting_codes
520
+ + r.ram_ann_assignment),
521
+ "vector_column_mb": mb(r.ram_vector_column),
522
+ "column_rows_filled": filled,
523
+ })
524
+ }
525
+
526
+ /// Cell 10: a reader's catch-up after another handle's one-memory commit,
527
+ /// the recalls after it, and the memory the process keeps.
528
+ fn cell10(n: usize, reps: usize, commits: usize, scratch: &Path) -> Value {
529
+ let dir = tempfile::tempdir_in(scratch).unwrap();
530
+ let p = copy_of(dir.path(), n, "c10");
531
+ let mut rng = rand::rngs::StdRng::seed_from_u64(10);
532
+ let mut a = shared(&p);
533
+ let mut b = shared(&p);
534
+ for _ in 0..20 {
535
+ let q = recall_req(&mut rng);
536
+ a.read(|db| db.recall(&q)).unwrap();
537
+ }
538
+ let mut warm = Vec::new();
539
+ for _ in 0..reps {
540
+ let q = recall_req(&mut rng);
541
+ let t = Instant::now();
542
+ a.read(|db| db.recall(&q)).unwrap();
543
+ warm.push(ms(t.elapsed()));
544
+ }
545
+ // The control: a warm recall after the thread sleeps about as long as a
546
+ // commit takes, with no commit. On the machine this was measured on, a
547
+ // recall after any such pause runs slower, whatever the engine does,
548
+ // so the recalls after a commit are read against this row too.
549
+ let mut idle = Vec::new();
550
+ for _ in 0..reps {
551
+ std::thread::sleep(std::time::Duration::from_millis(20));
552
+ let q = recall_req(&mut rng);
553
+ let t = Instant::now();
554
+ a.read(|db| db.recall(&q)).unwrap();
555
+ idle.push(ms(t.elapsed()));
556
+ }
557
+ let start = (rss_kb() as f64 / 1024.0, footprint_mb());
558
+ let held_start = held(&mut a);
559
+ let (mut empty, mut first, mut second, mut direct) = (vec![], vec![], vec![], vec![]);
560
+ for i in 0..reps {
561
+ let m = mem(&mut rng, format!("other's write {i}"));
562
+ b.write(move |db| db.remember(m)).unwrap();
563
+ let t = Instant::now();
564
+ a.read(|_| Ok(())).unwrap();
565
+ empty.push(ms(t.elapsed()));
566
+ let q = recall_req(&mut rng);
567
+ let t = Instant::now();
568
+ a.read(|db| db.recall(&q)).unwrap();
569
+ first.push(ms(t.elapsed()));
570
+ let q = recall_req(&mut rng);
571
+ let t = Instant::now();
572
+ a.read(|db| db.recall(&q)).unwrap();
573
+ second.push(ms(t.elapsed()));
574
+ }
575
+ for i in 0..reps {
576
+ let m = mem(&mut rng, format!("other's write b{i}"));
577
+ b.write(move |db| db.remember(m)).unwrap();
578
+ let q = recall_req(&mut rng);
579
+ let t = Instant::now();
580
+ a.read(|db| db.recall(&q)).unwrap();
581
+ direct.push(ms(t.elapsed()));
582
+ }
583
+ // Warm recalls again, back to back with no commit: does the caught-up
584
+ // state recall as fast as the state it started from?
585
+ let mut warm_after = Vec::new();
586
+ for _ in 0..reps {
587
+ let q = recall_req(&mut rng);
588
+ let t = Instant::now();
589
+ a.read(|db| db.recall(&q)).unwrap();
590
+ warm_after.push(ms(t.elapsed()));
591
+ }
592
+ let after = (rss_kb() as f64 / 1024.0, footprint_mb());
593
+ let held_after = held(&mut a);
594
+ let counts = catch_ups(&a);
595
+ // The long run: `commits` more one-memory commits, each followed by a
596
+ // catch-up and a recall, with the footprint every 25.
597
+ let mut series = Vec::new();
598
+ let long_start = (rss_kb() as f64 / 1024.0, footprint_mb());
599
+ let mut long = Vec::new();
600
+ // Each commit's catch-up (an empty read) and the recall after it, split
601
+ // by the path the catch-up took: the full reloads here are the fallback
602
+ // that section 8 compares with today's reload.
603
+ let (mut cu_inc, mut cu_full, mut rec_inc, mut rec_full) = (vec![], vec![], vec![], vec![]);
604
+ for i in 0..commits {
605
+ let m = mem(&mut rng, format!("long run {i}"));
606
+ b.write(move |db| db.remember(m)).unwrap();
607
+ let before = full_reloads(&a);
608
+ let t = Instant::now();
609
+ a.read(|_| Ok(())).unwrap();
610
+ let cu = ms(t.elapsed());
611
+ let full = full_reloads(&a) != before;
612
+ let q = recall_req(&mut rng);
613
+ let t = Instant::now();
614
+ a.read(|db| db.recall(&q)).unwrap();
615
+ let r = ms(t.elapsed());
616
+ long.push(r);
617
+ if full {
618
+ cu_full.push(cu);
619
+ rec_full.push(r);
620
+ } else {
621
+ cu_inc.push(cu);
622
+ rec_inc.push(r);
623
+ }
624
+ if (i + 1) % 25 == 0 {
625
+ series.push(json!({
626
+ "commits": i + 1,
627
+ "rss_mb": round(rss_kb() as f64 / 1024.0),
628
+ "footprint_mb": footprint_mb().map(round),
629
+ }));
630
+ }
631
+ }
632
+ let long_end = (rss_kb() as f64 / 1024.0, footprint_mb());
633
+ json!({
634
+ "reps": reps,
635
+ "warm_recall_no_commit": stats(&mut warm),
636
+ "warm_recall_after_the_catch_ups": stats(&mut warm_after),
637
+ "warm_recall_after_20ms_sleep_no_commit": stats(&mut idle),
638
+ "catch_up_empty_read_after_commit": stats(&mut empty),
639
+ "first_recall_after_catch_up": stats(&mut first),
640
+ "second_recall_after_catch_up": stats(&mut second),
641
+ "recall_as_first_call_after_commit": stats(&mut direct),
642
+ "rss_mb_before_after": [round(start.0), round(after.0)],
643
+ "footprint_mb_before_after": [start.1.map(round), after.1.map(round)],
644
+ "held_before_after": [held_start, held_after],
645
+ "catch_ups": counts,
646
+ "long_run": {
647
+ "commits": commits,
648
+ "recall_after_each_catch_up": stats(&mut long),
649
+ "catch_up_incremental": stats(&mut cu_inc),
650
+ "catch_up_full": stats(&mut cu_full),
651
+ "recall_after_incremental": stats(&mut rec_inc),
652
+ "recall_after_full": stats(&mut rec_full),
653
+ "rss_mb_before_after": [round(long_start.0), round(long_end.0)],
654
+ "footprint_mb_before_after": [long_start.1.map(round), long_end.1.map(round)],
655
+ "series": series,
656
+ "catch_ups": catch_ups(&a),
657
+ },
658
+ })
659
+ }
660
+
661
+ /// Cell 12 (v0200-3): the control for cell 10's footprint, the same warm-up
662
+ /// and as many recalls as cell 10 makes, with no commit, so what the
663
+ /// recalls themselves fill (the vector column, the page cache) is measured
664
+ /// apart from what the catch-ups keep.
665
+ fn cell12(n: usize, reps: usize, scratch: &Path) -> Value {
666
+ let dir = tempfile::tempdir_in(scratch).unwrap();
667
+ let p = copy_of(dir.path(), n, "c12");
668
+ let mut rng = rand::rngs::StdRng::seed_from_u64(10);
669
+ let mut a = shared(&p);
670
+ for _ in 0..20 + 2 * reps {
671
+ let q = recall_req(&mut rng);
672
+ a.read(|db| db.recall(&q)).unwrap();
673
+ }
674
+ let start = (rss_kb() as f64 / 1024.0, footprint_mb());
675
+ for _ in 0..4 * reps {
676
+ let q = recall_req(&mut rng);
677
+ a.read(|db| db.recall(&q)).unwrap();
678
+ }
679
+ let after = (rss_kb() as f64 / 1024.0, footprint_mb());
680
+ json!({
681
+ "recalls": 4 * reps,
682
+ "rss_mb_before_after": [round(start.0), round(after.0)],
683
+ "footprint_mb_before_after": [start.1.map(round), after.1.map(round)],
684
+ })
685
+ }
686
+
687
+ /// Cell 11 (v0200-3, addition (d)): what the first recall pays to rebuild
688
+ /// each lazily built part, dropped alone on a warm handle.
689
+ fn cell11(n: usize, reps: usize, scratch: &Path) -> Value {
690
+ let dir = tempfile::tempdir_in(scratch).unwrap();
691
+ let p = copy_of(dir.path(), n, "c11");
692
+ let mut rng = rand::rngs::StdRng::seed_from_u64(11);
693
+ let mut a = shared(&p);
694
+ for _ in 0..20 {
695
+ let q = recall_req(&mut rng);
696
+ a.read(|db| db.recall(&q)).unwrap();
697
+ }
698
+ let mut out = serde_json::Map::new();
699
+ for which in [
700
+ "none",
701
+ "key_index",
702
+ "superseded",
703
+ "layers",
704
+ "agent_set",
705
+ "bm25_stats",
706
+ "bm25_dicts",
707
+ "ann",
708
+ "column",
709
+ ] {
710
+ let mut lat = Vec::new();
711
+ for _ in 0..reps {
712
+ if which != "none" {
713
+ a.read(|db| db.__drop_lazy_for_testing(which)).unwrap();
714
+ }
715
+ let q = recall_req(&mut rng);
716
+ let t = Instant::now();
717
+ a.read(|db| db.recall(&q)).unwrap();
718
+ lat.push(ms(t.elapsed()));
719
+ }
720
+ out.insert(which.into(), stats(&mut lat));
721
+ }
722
+ Value::Object(out)
723
+ }
724
+
437
725
  /// Cell 8: the open wait under compaction: an opener against a compaction every
438
726
  /// ~100 ms and three writers.
439
727
  fn cell8(n: usize, secs: f64, scratch: &Path) -> Value {
@@ -471,6 +759,13 @@ fn main() {
471
759
  .map(|c| c.parse().unwrap())
472
760
  .collect();
473
761
  let secs: f64 = arg("--secs", "8").parse().unwrap();
762
+ let commits: usize = arg("--commits", "0").parse().unwrap();
763
+ // Cell 10's loop count (default: 200 at 10K, 100 at 100K).
764
+ let reps10: Option<usize> = args
765
+ .iter()
766
+ .position(|a| a == "--reps")
767
+ .and_then(|i| args.get(i + 1))
768
+ .map(|r| r.parse().unwrap());
474
769
  let out_path = arg("--out", "");
475
770
  let scratch = PathBuf::from(arg(
476
771
  "--scratch",
@@ -502,6 +797,24 @@ fn main() {
502
797
  cell4(n, reps_for(n, 60), &scratch),
503
798
  );
504
799
  }
800
+ if cells.contains(&10) {
801
+ eprintln!("cell 10 at {n}");
802
+ cellv.insert(
803
+ "10_catch_up".into(),
804
+ cell10(n, reps10.unwrap_or(reps_for(n, 100) * 2), commits, &scratch),
805
+ );
806
+ }
807
+ if cells.contains(&12) {
808
+ eprintln!("cell 12 at {n}");
809
+ cellv.insert(
810
+ "12_recalls_alone".into(),
811
+ cell12(n, reps_for(n, 100) * 2, &scratch),
812
+ );
813
+ }
814
+ if cells.contains(&11) {
815
+ eprintln!("cell 11 at {n}");
816
+ cellv.insert("11_lazy_parts".into(), cell11(n, 20, &scratch));
817
+ }
505
818
  let mixes: [(&str, &[(&str, usize)]); 4] = [
506
819
  ("1w_1r", &[("writer", 1), ("reader", 1)]),
507
820
  ("1w_7r", &[("writer", 1), ("reader", 7)]),
@@ -85,8 +85,9 @@ as if started in `<dir>`.
85
85
 
86
86
  ## 2. Use the tools
87
87
 
88
- The MCP server is `mnemo serve --mcp --shared`. `onboard` starts it for
89
- your client. The tools you'll use most:
88
+ The MCP server is `mnemo serve --mcp`, in shared mode: each tool call
89
+ takes the brain's lock for itself, so several sessions and the CLI can use
90
+ one brain. `onboard` starts it for your client. The tools you'll use most:
90
91
 
91
92
  | Tool | What it does |
92
93
  |---|---|
@@ -442,7 +442,8 @@ async function header() {
442
442
  } catch (e) { fail(e); }
443
443
  }
444
444
  function selectTab(name) {
445
- if (!views[name]) return false;
445
+ // RB-015.2: own keys only, so `#__proto__` or `#toString` opens no tab.
446
+ if (!Object.hasOwn(views, name)) return false;
446
447
  view = name;
447
448
  for (const x of document.querySelectorAll("#tabs button")) x.classList.toggle("on", x.dataset.view === name);
448
449
  return true;