mnemo-engine 0.14.0__tar.gz → 0.15.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.14.0 → mnemo_engine-0.15.0}/PKG-INFO +23 -9
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/README.md +22 -8
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/Cargo.lock +1617 -128
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/Cargo.toml +85 -10
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/README.md +266 -16
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/deny.toml +27 -1
- mnemo_engine-0.15.0/mnemo/examples/candle_hard.rs +206 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/shared_bench.rs +40 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/thread_profile.rs +1 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/bin/mnemo/inspect.rs +11 -29
- mnemo_engine-0.15.0/mnemo/src/bin/mnemo/mcp_install.rs +712 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/bin/mnemo.rs +1168 -232
- mnemo_engine-0.15.0/mnemo/src/builtin.rs +710 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/crypto.rs +63 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/embed.rs +129 -14
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/embed_cmd.rs +46 -4
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/error.rs +14 -9
- mnemo_engine-0.15.0/mnemo/src/ident.rs +204 -0
- mnemo_engine-0.15.0/mnemo/src/keys/display.rs +132 -0
- mnemo_engine-0.15.0/mnemo/src/keys/mod.rs +994 -0
- mnemo_engine-0.15.0/mnemo/src/keys/os_store.rs +120 -0
- mnemo_engine-0.15.0/mnemo/src/keys/recovery.rs +259 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/lib.rs +33 -6
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/mcp.rs +374 -32
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/memory.rs +1 -1
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/shared/call.rs +21 -1
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/shared/lock.rs +190 -8
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/shared/mod.rs +1 -1
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/shared/sidecar.rs +32 -4
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/flush.rs +1 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/hooks.rs +57 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/keyed.rs +158 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/maintenance.rs +348 -23
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/mod.rs +114 -16
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/open.rs +155 -47
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/recall.rs +33 -4
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/records.rs +67 -4
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/shared.rs +11 -5
- mnemo_engine-0.15.0/mnemo/src/text.rs +597 -0
- mnemo_engine-0.15.0/mnemo-python/Cargo.lock +2920 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo-python/Cargo.toml +13 -2
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo-python/README.md +22 -8
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo-python/src/lib.rs +313 -39
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo-python/test_mnemo.py +252 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/pyproject.toml +1 -1
- mnemo_engine-0.14.0/mnemo/src/text.rs +0 -268
- mnemo_engine-0.14.0/mnemo-python/Cargo.lock +0 -1223
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/.gitignore +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/benches/corpus.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/build.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/ann_diagnose.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/ann_recall_grid.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/ann_recall_grid_v2.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/embedder_server.py +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/file_size_breakdown.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/open_rss.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/quickstart.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/ranking_v2.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/examples/session.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/bin/mnemo/export.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/bin/mnemo/inspect.html +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/cache.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/format.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/freelist.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/index.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/keyslot.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/pager.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/result_cache.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/session.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/shared/fscheck.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/ann.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/cache_api.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/continuation.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/crud.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/essence.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/header_graft_tests.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/load.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/snapshots.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/store/threads.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/transcript.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/veccol.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo/src/wal.rs +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.0}/mnemo-python/.gitignore +0 -0
- {mnemo_engine-0.14.0 → mnemo_engine-0.15.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.15.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,18 @@ its own agent.
|
|
|
156
156
|
|
|
157
157
|
## API
|
|
158
158
|
|
|
159
|
-
`mnemo.open(path, passphrase, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
159
|
+
`mnemo.open(path, passphrase=None, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
160
|
+
|
|
161
|
+
**No passphrase** (v0.15, 12.3): `mnemo.open(path)` opens an existing file
|
|
162
|
+
through the key-source chain, by the file's kind. A key comes from
|
|
163
|
+
`MNEMO_KEY`, `MNEMO_KEY_FILE`, `MNEMO_KEY_COMMAND` or the OS keychain (a
|
|
164
|
+
brain made by `mnemo init`, or kept there by `mnemo unlock`); a passphrase
|
|
165
|
+
from `MNEMO_PASSPHRASE` or the keychain. It never prompts. A missing file
|
|
166
|
+
raises `ValueError` (create one with `mnemo init`), and so does a file no
|
|
167
|
+
source has a secret for. It works with `read_only=True` and `shared=True`,
|
|
168
|
+
and one process can hold a keychain brain and a `MNEMO_PASSPHRASE` brain at
|
|
169
|
+
once. The released wheels carry the keychain; a wheel built from source
|
|
170
|
+
needs `--features keychain`.
|
|
160
171
|
|
|
161
172
|
**Shared mode** (v0.14, `shared=True`): several processes and sessions use
|
|
162
173
|
one file at once. The handle takes the file's lock for each call and holds
|
|
@@ -181,7 +192,7 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
|
181
192
|
|
|
182
193
|
| Method | Purpose |
|
|
183
194
|
|---|---|
|
|
184
|
-
| `remember(content, memory_type, vector, *, agent_id, importance, session_id, ttl_secs, shared, metadata)` | Store a memory; returns its id |
|
|
195
|
+
| `remember(content, memory_type, vector, *, agent_id, importance, session_id, ttl_secs, shared, metadata, key, supersedes)` | Store a memory; returns its id. With `key`, a keyed write that supersedes the key's live record (returns `{"id", "outcome"}`). **`supersedes` (v0.15, with `key`):** the id of a memory written without a key, which becomes the key's first version and is superseded; matching content adopts it as is (`"updated"`) |
|
|
185
196
|
| `recall(query, top_k=10, memory_types=None, agent_id=None, track_access=True, n_probe=None, n_rerank=None)` | Multi-signal ranked retrieval. `track_access=False` skips access-stat updates (fully read-only recall). `n_probe` / `n_rerank` (PR ANN-1): per-query ANN tuning — `None` uses the index's build-time defaults (ANN-1 auto-formulas: `(partitions+1)/2` and `500`) |
|
|
186
197
|
| `search(query, top_k=10)` | Exact nearest-neighbour search |
|
|
187
198
|
| `get(id)` / `delete(id)` | Fetch / soft-delete by id |
|
|
@@ -207,17 +218,18 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
|
207
218
|
| `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 |
|
|
208
219
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
209
220
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
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) |
|
|
221
|
+
| `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. Without it the new passphrase keeps the file's KDF parameters and never gets less than `KdfParams::secure()`, even on a file made with `open_with_key` (v0.15). 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
222
|
| `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 |
|
|
212
|
-
| `
|
|
213
|
-
| `
|
|
214
|
-
| `
|
|
223
|
+
| `use_builtin_embedder(*, model_dir=None)` | **v0.15:** register the built-in embedder (snowflake-arctic-embed-xs on candle, 384 dimensions) instead of a callable. Its model (91.0 MB) is fetched into the cache directory on first use, said on stderr, and each file's SHA-256 is checked before it loads; `model_dir` loads the three files from a directory of your own and never downloads. With it, `recall_text` is identifier-aware: the question's plain words aren't matched by keyword and its identifiers (`snapshot_list`, `store.rs`, `--features`) are, unless you pass `keywords`. Raises `RuntimeError` offline or in a build without it |
|
|
224
|
+
| `set_embedder(fn, *, name, dimensions, normalize=True, query_fn=None, query_convention=None)` | 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 records) the file's embedder identity, so swapping embedders between opens fails loudly. **`query_fn` and `query_convention` (v0.15)**, both or neither: a callable of `fn`'s shape that embeds `recall_text`'s queries, for a model that embeds queries differently, and a short name for the difference (`"bge-query-instruction"`), which becomes part of the identity |
|
|
225
|
+
| `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`, `key`, `supersedes`) |
|
|
226
|
+
| `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`. **Hybrid by default since v0.15** (v9 files): `query` itself is also matched by keyword (BM25) with weight 0.25. `keywords`: identifiers or exact terms the question doesn't contain (a version, a PR number, a function name), which replace the query for that score, with weight 0.5; `keyword_weight` sets either. `keywords=""` is vector-only. The query goes through `query_fn` when `set_embedder` was given one |
|
|
215
227
|
| `cache_get_semantic_text(namespace, text, threshold=0.97)` | Text-side semantic cache lookup; uses the embedder's `name` as the semantic cache's `model` component |
|
|
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 |
|
|
228
|
+
| `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. Since v0.15 `keyword_tokenizer`: `"2"` (whole words and their parts, a file v0.15 made or rebuilt), `"1"` (whole words, an older file until `mnemo compact`), `"mixed"` (a build before v0.15 wrote to it), or `None` on v8 |
|
|
217
229
|
| `export_encrypted(dest)` | Copy the (already-encrypted) file elsewhere |
|
|
218
230
|
| `len(db)` | Live memory count |
|
|
219
231
|
| `shared` | `True` for a handle opened with `shared=True` |
|
|
220
|
-
| `notices()` |
|
|
232
|
+
| `notices()` | What the handle warns about once; each is also raised as a `UserWarning` at open. Shared mode: a sidecar directory it can't use, a synced folder, an allowed network filesystem. Any handle (v0.15): a passphrase on raw-key KDF parameters, with the fix (`mnemo rekey` or `mnemo compact`) |
|
|
221
233
|
| `set_cancel(token)` | Shared mode: give the handle a new `CancelToken` (or `None`) for its later calls, after a cancel |
|
|
222
234
|
|
|
223
235
|
Plus two module-level functions:
|
|
@@ -227,6 +239,8 @@ Plus two module-level functions:
|
|
|
227
239
|
| `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}` |
|
|
228
240
|
| `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
241
|
| `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 |
|
|
242
|
+
| `mnemo.install_builtin_embedder()` | **v0.15:** fetch the built-in embedder's model (91.0 MB) into the cache directory, checking each file's SHA-256, and return the directory; nothing is fetched when it's there. The size and the place are said on stderr first. `MNEMO_CACHE_DIR` moves the cache, `MNEMO_MODEL_URL` points at a mirror |
|
|
243
|
+
| `mnemo.builtin_embedder_info()` | **v0.15:** `{"available": bool}`, and when the wheel has the built-in embedder, `model`, `revision`, `identity`, `dimensions`, `cache_dir`, `installed` and `download_bytes` |
|
|
230
244
|
| `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+ |
|
|
231
245
|
|
|
232
246
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|
|
@@ -142,7 +142,18 @@ its own agent.
|
|
|
142
142
|
|
|
143
143
|
## API
|
|
144
144
|
|
|
145
|
-
`mnemo.open(path, passphrase, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
145
|
+
`mnemo.open(path, passphrase=None, dimensions=None, read_only=False, *, shared=False, wait=10.0, allow_network_fs=False, cancel=None) -> Mnemo`
|
|
146
|
+
|
|
147
|
+
**No passphrase** (v0.15, 12.3): `mnemo.open(path)` opens an existing file
|
|
148
|
+
through the key-source chain, by the file's kind. A key comes from
|
|
149
|
+
`MNEMO_KEY`, `MNEMO_KEY_FILE`, `MNEMO_KEY_COMMAND` or the OS keychain (a
|
|
150
|
+
brain made by `mnemo init`, or kept there by `mnemo unlock`); a passphrase
|
|
151
|
+
from `MNEMO_PASSPHRASE` or the keychain. It never prompts. A missing file
|
|
152
|
+
raises `ValueError` (create one with `mnemo init`), and so does a file no
|
|
153
|
+
source has a secret for. It works with `read_only=True` and `shared=True`,
|
|
154
|
+
and one process can hold a keychain brain and a `MNEMO_PASSPHRASE` brain at
|
|
155
|
+
once. The released wheels carry the keychain; a wheel built from source
|
|
156
|
+
needs `--features keychain`.
|
|
146
157
|
|
|
147
158
|
**Shared mode** (v0.14, `shared=True`): several processes and sessions use
|
|
148
159
|
one file at once. The handle takes the file's lock for each call and holds
|
|
@@ -167,7 +178,7 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
|
167
178
|
|
|
168
179
|
| Method | Purpose |
|
|
169
180
|
|---|---|
|
|
170
|
-
| `remember(content, memory_type, vector, *, agent_id, importance, session_id, ttl_secs, shared, metadata)` | Store a memory; returns its id |
|
|
181
|
+
| `remember(content, memory_type, vector, *, agent_id, importance, session_id, ttl_secs, shared, metadata, key, supersedes)` | Store a memory; returns its id. With `key`, a keyed write that supersedes the key's live record (returns `{"id", "outcome"}`). **`supersedes` (v0.15, with `key`):** the id of a memory written without a key, which becomes the key's first version and is superseded; matching content adopts it as is (`"updated"`) |
|
|
171
182
|
| `recall(query, top_k=10, memory_types=None, agent_id=None, track_access=True, n_probe=None, n_rerank=None)` | Multi-signal ranked retrieval. `track_access=False` skips access-stat updates (fully read-only recall). `n_probe` / `n_rerank` (PR ANN-1): per-query ANN tuning — `None` uses the index's build-time defaults (ANN-1 auto-formulas: `(partitions+1)/2` and `500`) |
|
|
172
183
|
| `search(query, top_k=10)` | Exact nearest-neighbour search |
|
|
173
184
|
| `get(id)` / `delete(id)` | Fetch / soft-delete by id |
|
|
@@ -193,17 +204,18 @@ db.notices() # what the handle warns about (also raised as UserWarning at open)
|
|
|
193
204
|
| `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 |
|
|
194
205
|
| `memories()` | Enumerate every live (non-deleted, non-expired) memory as a list of dicts |
|
|
195
206
|
| `dimensions()` | Embedding dimensionality this database was created with (also on `stats()["dimensions"]`) |
|
|
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) |
|
|
207
|
+
| `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. Without it the new passphrase keeps the file's KDF parameters and never gets less than `KdfParams::secure()`, even on a file made with `open_with_key` (v0.15). 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
208
|
| `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 |
|
|
198
|
-
| `
|
|
199
|
-
| `
|
|
200
|
-
| `
|
|
209
|
+
| `use_builtin_embedder(*, model_dir=None)` | **v0.15:** register the built-in embedder (snowflake-arctic-embed-xs on candle, 384 dimensions) instead of a callable. Its model (91.0 MB) is fetched into the cache directory on first use, said on stderr, and each file's SHA-256 is checked before it loads; `model_dir` loads the three files from a directory of your own and never downloads. With it, `recall_text` is identifier-aware: the question's plain words aren't matched by keyword and its identifiers (`snapshot_list`, `store.rs`, `--features`) are, unless you pass `keywords`. Raises `RuntimeError` offline or in a build without it |
|
|
210
|
+
| `set_embedder(fn, *, name, dimensions, normalize=True, query_fn=None, query_convention=None)` | 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 records) the file's embedder identity, so swapping embedders between opens fails loudly. **`query_fn` and `query_convention` (v0.15)**, both or neither: a callable of `fn`'s shape that embeds `recall_text`'s queries, for a model that embeds queries differently, and a short name for the difference (`"bge-query-instruction"`), which becomes part of the identity |
|
|
211
|
+
| `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`, `key`, `supersedes`) |
|
|
212
|
+
| `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`. **Hybrid by default since v0.15** (v9 files): `query` itself is also matched by keyword (BM25) with weight 0.25. `keywords`: identifiers or exact terms the question doesn't contain (a version, a PR number, a function name), which replace the query for that score, with weight 0.5; `keyword_weight` sets either. `keywords=""` is vector-only. The query goes through `query_fn` when `set_embedder` was given one |
|
|
201
213
|
| `cache_get_semantic_text(namespace, text, threshold=0.97)` | Text-side semantic cache lookup; uses the embedder's `name` as the semantic cache's `model` component |
|
|
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 |
|
|
214
|
+
| `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. Since v0.15 `keyword_tokenizer`: `"2"` (whole words and their parts, a file v0.15 made or rebuilt), `"1"` (whole words, an older file until `mnemo compact`), `"mixed"` (a build before v0.15 wrote to it), or `None` on v8 |
|
|
203
215
|
| `export_encrypted(dest)` | Copy the (already-encrypted) file elsewhere |
|
|
204
216
|
| `len(db)` | Live memory count |
|
|
205
217
|
| `shared` | `True` for a handle opened with `shared=True` |
|
|
206
|
-
| `notices()` |
|
|
218
|
+
| `notices()` | What the handle warns about once; each is also raised as a `UserWarning` at open. Shared mode: a sidecar directory it can't use, a synced folder, an allowed network filesystem. Any handle (v0.15): a passphrase on raw-key KDF parameters, with the fix (`mnemo rekey` or `mnemo compact`) |
|
|
207
219
|
| `set_cancel(token)` | Shared mode: give the handle a new `CancelToken` (or `None`) for its later calls, after a cancel |
|
|
208
220
|
|
|
209
221
|
Plus two module-level functions:
|
|
@@ -213,6 +225,8 @@ Plus two module-level functions:
|
|
|
213
225
|
| `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}` |
|
|
214
226
|
| `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
227
|
| `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 |
|
|
228
|
+
| `mnemo.install_builtin_embedder()` | **v0.15:** fetch the built-in embedder's model (91.0 MB) into the cache directory, checking each file's SHA-256, and return the directory; nothing is fetched when it's there. The size and the place are said on stderr first. `MNEMO_CACHE_DIR` moves the cache, `MNEMO_MODEL_URL` points at a mirror |
|
|
229
|
+
| `mnemo.builtin_embedder_info()` | **v0.15:** `{"available": bool}`, and when the wheel has the built-in embedder, `model`, `revision`, `identity`, `dimensions`, `cache_dir`, `installed` and `download_bytes` |
|
|
216
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+ |
|
|
217
231
|
|
|
218
232
|
`Session` methods: `add_turn(turn)`, `recall(query, top_k=10, memory_types=None)`,
|