mnemo-engine 0.6.1__tar.gz → 0.8.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 (55) hide show
  1. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/PKG-INFO +15 -9
  2. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/README.md +14 -8
  3. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/Cargo.lock +2 -2
  4. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/Cargo.toml +20 -6
  5. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/README.md +48 -11
  6. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/cache.rs +1 -1
  7. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/corpus.rs +1 -1
  8. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/embed_overhead.rs +1 -1
  9. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/open.rs +1 -1
  10. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/recall.rs +39 -1
  11. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/benches/write.rs +1 -1
  12. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/ann_defaults_v0_6_0.rs +1 -1
  13. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/ann_diagnose.rs +1 -1
  14. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/ann_recall_grid.rs +1 -1
  15. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/ann_recall_grid_v2.rs +1 -1
  16. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/file_size_breakdown.rs +1 -1
  17. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/quickstart.rs +1 -1
  18. mnemo_engine-0.8.0/mnemo/examples/ranking_v2.rs +483 -0
  19. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/session.rs +2 -2
  20. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/bin/mnemo.rs +455 -48
  21. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/lib.rs +9 -4
  22. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/mcp.rs +334 -13
  23. mnemo_engine-0.8.0/mnemo/src/memory.rs +624 -0
  24. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/session.rs +1 -1
  25. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/store.rs +716 -33
  26. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/cli_smoke.rs +212 -7
  27. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/dur1_torn_header.rs +7 -7
  28. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/fix1_correctness_sweep.rs +3 -1
  29. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/integration.rs +786 -25
  30. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/proptest_store.rs +7 -7
  31. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/sec1_nonce_uniqueness.rs +2 -2
  32. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/Cargo.lock +2 -2
  33. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/Cargo.toml +8 -3
  34. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/README.md +14 -8
  35. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/src/lib.rs +375 -26
  36. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/test_mnemo.py +59 -1
  37. mnemo_engine-0.8.0/pyproject.toml +45 -0
  38. mnemo_engine-0.8.0/python/mnemo_engine/__init__.py +23 -0
  39. mnemo_engine-0.6.1/mnemo/src/memory.rs +0 -319
  40. mnemo_engine-0.6.1/pyproject.toml +0 -32
  41. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/.gitignore +0 -0
  42. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/deny.toml +0 -0
  43. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/examples/embedder_server.py +0 -0
  44. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/cache.rs +0 -0
  45. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/crypto.rs +0 -0
  46. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/embed.rs +0 -0
  47. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/embed_cmd.rs +0 -0
  48. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/error.rs +0 -0
  49. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/format.rs +0 -0
  50. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/index.rs +0 -0
  51. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/pager.rs +0 -0
  52. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/result_cache.rs +0 -0
  53. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/src/wal.rs +0 -0
  54. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo/tests/proptest_store.proptest-regressions +0 -0
  55. {mnemo_engine-0.6.1 → mnemo_engine-0.8.0}/mnemo-python/.gitignore +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mnemo-engine
3
- Version: 0.6.1
3
+ Version: 0.8.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -24,10 +24,16 @@ sibling `mnemo/` crate — the storage engine, AES-256-GCM encryption, the
24
24
  write-ahead log, the IVF+PQ index, snapshots, and the agent-memory model all
25
25
  run as compiled Rust; Python only sees a small, ergonomic surface.
26
26
 
27
- > Distribution name on PyPI: `mnemo-engine` (both `mnemo` and `mnemo-db`
28
- > were already taken by unrelated projects). The import name stays
29
- > `mnemo`, so `pip install mnemo-engine` then `import mnemo` is the
30
- > full setup.
27
+ > Distribution name on PyPI: `mnemo-engine` (both `mnemo` and
28
+ > `mnemo-db` were already taken by unrelated projects). The import
29
+ > name is **`mnemo_engine`** starting in v0.7.0, so the full setup is
30
+ > `pip install mnemo-engine` then `import mnemo_engine`. The
31
+ > pre-v0.7.0 `import mnemo` keeps working for the v0.7.x series via a
32
+ > pure-Python shim that emits one `DeprecationWarning` on import; the
33
+ > shim is removed in v0.8.0. Code that wants to keep its call sites
34
+ > unchanged can `import mnemo_engine as mnemo` — same objects, no
35
+ > warning. See the "Breaking: import name" section in the CHANGELOG
36
+ > for the full migration.
31
37
 
32
38
  ## For AI agents
33
39
 
@@ -35,7 +41,7 @@ An agent that's been handed a `.mnemo` file and its passphrase can become
35
41
  productive in two calls — no external documentation required:
36
42
 
37
43
  ```python
38
- import mnemo, os
44
+ import mnemo_engine as mnemo, os
39
45
 
40
46
  db = mnemo.open("agent.mnemo", os.environ["MNEMO_PASSPHRASE"])
41
47
 
@@ -95,7 +101,7 @@ single wheel works on CPython 3.8 and newer.
95
101
  ## Usage
96
102
 
97
103
  ```python
98
- import mnemo
104
+ import mnemo_engine as mnemo
99
105
 
100
106
  # Open an existing database, or create one (dimensions required to create).
101
107
  db = mnemo.open("agent.mnemo", "passphrase", dimensions=4)
@@ -221,7 +227,7 @@ switches to semantic mode; otherwise it's an exact-key cache.
221
227
  """@db.cached — pure-Python helper on top of mnemo.Mnemo's cache API.
222
228
 
223
229
  Usage:
224
- import mnemo, json, os
230
+ import mnemo_engine as mnemo, json, os
225
231
  from mnemo_cached import cached
226
232
 
227
233
  db = mnemo.open("agent.mnemo", os.environ["MNEMO_PASSPHRASE"])
@@ -402,7 +408,7 @@ pass vectors by hand. Register once at open time; every subsequent
402
408
  the handle uses it.
403
409
 
404
410
  ```python
405
- import mnemo
411
+ import mnemo_engine as mnemo
406
412
  from sentence_transformers import SentenceTransformer
407
413
 
408
414
  model = SentenceTransformer("all-MiniLM-L6-v2") # 384-dim, normalized
@@ -10,10 +10,16 @@ sibling `mnemo/` crate — the storage engine, AES-256-GCM encryption, the
10
10
  write-ahead log, the IVF+PQ index, snapshots, and the agent-memory model all
11
11
  run as compiled Rust; Python only sees a small, ergonomic surface.
12
12
 
13
- > Distribution name on PyPI: `mnemo-engine` (both `mnemo` and `mnemo-db`
14
- > were already taken by unrelated projects). The import name stays
15
- > `mnemo`, so `pip install mnemo-engine` then `import mnemo` is the
16
- > full setup.
13
+ > Distribution name on PyPI: `mnemo-engine` (both `mnemo` and
14
+ > `mnemo-db` were already taken by unrelated projects). The import
15
+ > name is **`mnemo_engine`** starting in v0.7.0, so the full setup is
16
+ > `pip install mnemo-engine` then `import mnemo_engine`. The
17
+ > pre-v0.7.0 `import mnemo` keeps working for the v0.7.x series via a
18
+ > pure-Python shim that emits one `DeprecationWarning` on import; the
19
+ > shim is removed in v0.8.0. Code that wants to keep its call sites
20
+ > unchanged can `import mnemo_engine as mnemo` — same objects, no
21
+ > warning. See the "Breaking: import name" section in the CHANGELOG
22
+ > for the full migration.
17
23
 
18
24
  ## For AI agents
19
25
 
@@ -21,7 +27,7 @@ An agent that's been handed a `.mnemo` file and its passphrase can become
21
27
  productive in two calls — no external documentation required:
22
28
 
23
29
  ```python
24
- import mnemo, os
30
+ import mnemo_engine as mnemo, os
25
31
 
26
32
  db = mnemo.open("agent.mnemo", os.environ["MNEMO_PASSPHRASE"])
27
33
 
@@ -81,7 +87,7 @@ single wheel works on CPython 3.8 and newer.
81
87
  ## Usage
82
88
 
83
89
  ```python
84
- import mnemo
90
+ import mnemo_engine as mnemo
85
91
 
86
92
  # Open an existing database, or create one (dimensions required to create).
87
93
  db = mnemo.open("agent.mnemo", "passphrase", dimensions=4)
@@ -207,7 +213,7 @@ switches to semantic mode; otherwise it's an exact-key cache.
207
213
  """@db.cached — pure-Python helper on top of mnemo.Mnemo's cache API.
208
214
 
209
215
  Usage:
210
- import mnemo, json, os
216
+ import mnemo_engine as mnemo, json, os
211
217
  from mnemo_cached import cached
212
218
 
213
219
  db = mnemo.open("agent.mnemo", os.environ["MNEMO_PASSPHRASE"])
@@ -388,7 +394,7 @@ pass vectors by hand. Register once at open time; every subsequent
388
394
  the handle uses it.
389
395
 
390
396
  ```python
391
- import mnemo
397
+ import mnemo_engine as mnemo
392
398
  from sentence_transformers import SentenceTransformer
393
399
 
394
400
  model = SentenceTransformer("all-MiniLM-L6-v2") # 384-dim, normalized
@@ -610,7 +610,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
610
610
 
611
611
  [[package]]
612
612
  name = "mnemo-engine"
613
- version = "0.6.1"
613
+ version = "0.8.0"
614
614
  dependencies = [
615
615
  "aes-gcm",
616
616
  "argon2",
@@ -634,7 +634,7 @@ dependencies = [
634
634
 
635
635
  [[package]]
636
636
  name = "mnemo-node"
637
- version = "0.6.1"
637
+ version = "0.8.0"
638
638
  dependencies = [
639
639
  "mnemo-engine",
640
640
  "napi",
@@ -2,11 +2,15 @@
2
2
  # Distribution name on crates.io is `mnemo-engine`. The bare `mnemo` name
3
3
  # is held by an unrelated crate, and `mnemo-db` is held by a different
4
4
  # (MCP-native, DuckDB-backed) agent-memory project — see the v0.3.2 entry
5
- # in CHANGELOG.md for the full rationale. The library and CLI binary names
6
- # below stay `mnemo`, so consumers still write `use mnemo::...` and invoke
7
- # `mnemo` on the command line after `cargo add mnemo-engine`.
5
+ # in CHANGELOG.md for the full rationale. The library name becomes
6
+ # `mnemo_engine` (Cargo's default from the package name) starting in
7
+ # v0.7.0 per PR NAME-1; consumers write `use mnemo_engine::...`, or
8
+ # keep `use mnemo::...` via a dependency rename:
9
+ # mnemo = { package = "mnemo-engine", version = "0.7" }
10
+ # The CLI binary name stays `mnemo`, so users still invoke `mnemo` on
11
+ # the command line after `cargo install mnemo-engine`.
8
12
  name = "mnemo-engine"
9
- version = "0.6.1"
13
+ version = "0.8.0"
10
14
  edition = "2021"
11
15
  rust-version = "1.75"
12
16
  # `benches/corpus.rs` is a shared helper module pulled into real benches
@@ -38,10 +42,20 @@ categories = ["database", "cryptography", "command-line-utilities"]
38
42
  members = ["bindings/node"]
39
43
  default-members = ["."]
40
44
 
45
+ # NAME-1 (2026-11-05 Planner DECISION): the library/import name is now
46
+ # `mnemo_engine` — Cargo's default from the `mnemo-engine` package name
47
+ # (dashes become underscores). The pre-NAME-1 `[lib] name = "mnemo"`
48
+ # override is gone because it collided with crates.io's standalone
49
+ # `mnemo` crate (a terminal knowledge vault) and with PyPI's
50
+ # `mnemo-db` / `mnemo` top-level `mnemo/` modules. The distribution
51
+ # name (`mnemo-engine` on both PyPI and crates.io) is unchanged.
52
+ # Downstream crates write `use mnemo_engine::X`, or keep `use mnemo::X`
53
+ # via a Cargo dep rename: `mnemo = { package = "mnemo-engine" }`.
41
54
  [lib]
42
- name = "mnemo"
43
55
  path = "src/lib.rs"
44
56
 
57
+ # The CLI binary name stays `mnemo` — the executable users type at the
58
+ # shell is unchanged.
45
59
  [[bin]]
46
60
  name = "mnemo"
47
61
  path = "src/bin/mnemo.rs"
@@ -129,7 +143,7 @@ required-features = ["benches"]
129
143
 
130
144
  [features]
131
145
  # When enabled, exposes crash-injection hooks used by the Phase 1.3
132
- # proptest under `mnemo::__failpoints::*`. Always enabled during
146
+ # proptest under `mnemo_engine::__failpoints::*`. Always enabled during
133
147
  # `cargo test` via `#[cfg(test)]`; the feature is here so an external
134
148
  # fault-injection consumer (or a future integration test in a sibling
135
149
  # crate) can opt into the same hooks without touching this crate's
@@ -145,7 +145,7 @@ memoizing LLM tool-call outputs, prompt→completion pairs, expensive HTTP
145
145
  responses — anything reconstructible on cache miss:
146
146
 
147
147
  ```rust
148
- use mnemo::{Mnemo, CachePutOpts};
148
+ use mnemo_engine::{Mnemo, CachePutOpts};
149
149
 
150
150
  let mut db = Mnemo::open("agent.mnemo", "correct horse battery")?;
151
151
 
@@ -206,7 +206,7 @@ miss. Semantic caching bridges the gap by keying on an embedding
206
206
  vector and returning the closest hit above a similarity threshold:
207
207
 
208
208
  ```rust
209
- use mnemo::{Mnemo, SemanticCachePutOpts, DEFAULT_SEMANTIC_THRESHOLD};
209
+ use mnemo_engine::{Mnemo, SemanticCachePutOpts, DEFAULT_SEMANTIC_THRESHOLD};
210
210
 
211
211
  let mut db = Mnemo::open("agent.mnemo", "pw")?;
212
212
 
@@ -265,8 +265,20 @@ the memory of an agent is as portable and as private as a SQLite database.
265
265
  This repository implements a real, compiling, tested **core**. See
266
266
  [Scope](#scope-what-is-and-isnt-here) for what is deliberately left as roadmap.
267
267
 
268
- > The product is **Memory Nemo (MNemo)**. The crate, binary, Python package,
269
- > and `.mnemo` file extension all use the lowercase identifier `mnemo`.
268
+ > The product is **Memory Nemo (MNemo)**. The crate and Python package are
269
+ > distributed as `mnemo-engine` (both `mnemo` and `mnemo-db` were already
270
+ > taken by unrelated projects — see the "Breaking: import name" section in
271
+ > CHANGELOG.md for the full rationale). **Starting in v0.7.0, the Rust
272
+ > library name and Python import name are `mnemo_engine`:**
273
+ > `use mnemo_engine::...` and `import mnemo_engine` (or `import
274
+ > mnemo_engine as mnemo` if you want call sites unchanged). Rust code
275
+ > that wants to keep writing `use mnemo::...` can rename the dependency
276
+ > locally via `mnemo = { package = "mnemo-engine", version = "0.7" }` —
277
+ > that stays supported indefinitely because it's a Cargo-side alias.
278
+ > Python has no `import mnemo` shim: the old top-level `mnemo` module
279
+ > would still clash with `mnemo-db` and PyPI `mnemo`, which is exactly
280
+ > what the rename exists to end. The CLI command (`mnemo`) and the
281
+ > `.mnemo` file extension are unchanged.
270
282
 
271
283
  ---
272
284
 
@@ -434,16 +446,41 @@ list over a slab of indices, so it stays within the crate's
434
446
 
435
447
  ### Recall
436
448
 
437
- `recall` scores each candidate with
449
+ `recall` scores each candidate with the v0.7.0 scoring-v2 formula:
438
450
 
439
451
  ```
440
- score = α·similarity + β·recency + γ·importance + δ·ln(1 + access_count)
452
+ score = similarity
453
+ + max(similarity, 0)
454
+ · ( β · recency
455
+ + γ · (importance − 0.5)
456
+ + δ · tanh(access_count / 5) )
457
+
458
+ recency = exp( -ln(2) · age_secs / half_life_secs )
459
+ age_secs = now - memory.created_at # not accessed_at
441
460
  ```
442
461
 
443
- where `recency` decays exponentially (default 7-day half-life). It also
444
- filters by memory type and by agent scope (an agent sees its own memories
445
- plus any marked `Shared`), and skips TTL-expired entries. Weights and the
446
- similarity metric (cosine / dot / L2) are per-request.
462
+ Four deliberate shape changes from the pre-v0.7.0 additive formula
463
+ (`α·sim + β·recency + γ·importance + δ·ln(1 + uses)`):
464
+
465
+ - **Similarity-gated bonuses.** Recency / importance / usage are
466
+ multiplied by `max(similarity, 0)`, so a stale-but-off-topic memory
467
+ can't ride recency past a semantically-on-point one.
468
+ - **Importance centered at 0.5.** A default-importance memory
469
+ contributes zero importance bonus; importance only pushes a score
470
+ up or down from that reference point.
471
+ - **Saturating usage.** `tanh(access_count / 5)` caps the feedback
472
+ bonus so a heavily-returned memory stops accumulating weight past
473
+ ~5 uses.
474
+ - **Recency from `created_at`.** A `recall()` no longer bumps its own
475
+ results' recency on later queries.
476
+
477
+ `recency` still decays exponentially (default 7-day half-life).
478
+ `recall` also filters by memory type and by agent scope (an agent
479
+ sees its own memories plus any marked `Shared`), and skips
480
+ TTL-expired entries. Weights and the similarity metric (cosine /
481
+ dot / L2) are per-request. The raw `RecallResult.score` sits on
482
+ a different scale than pre-v0.7.0 — callers comparing raw scores
483
+ to a fixed threshold should re-pick the threshold.
447
484
 
448
485
  ### Sessions
449
486
 
@@ -601,7 +638,7 @@ existing files open on v0.5.2 unchanged.
601
638
  ## Quick start (library)
602
639
 
603
640
  ```rust
604
- use mnemo::{Mnemo, MnemoConfig, Memory, MemoryType, RecallRequest};
641
+ use mnemo_engine::{Mnemo, MnemoConfig, Memory, MemoryType, RecallRequest};
605
642
 
606
643
  fn main() -> mnemo::Result<()> {
607
644
  let cfg = MnemoConfig { dimensions: 3, ..Default::default() };
@@ -30,7 +30,7 @@ use std::hint::black_box;
30
30
  use std::time::Duration;
31
31
 
32
32
  use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
33
- use mnemo::{CacheFlushPolicy, CachePutOpts, Mnemo, SemanticCachePutOpts};
33
+ use mnemo_engine::{CacheFlushPolicy, CachePutOpts, Mnemo, SemanticCachePutOpts};
34
34
  use tempfile::TempDir;
35
35
 
36
36
  #[path = "corpus.rs"]
@@ -21,7 +21,7 @@
21
21
  use std::fs;
22
22
  use std::path::{Path, PathBuf};
23
23
 
24
- use mnemo::{IndexConfig, KdfParams, Memory, MemoryType, Mnemo, MnemoConfig};
24
+ use mnemo_engine::{IndexConfig, KdfParams, Memory, MemoryType, Mnemo, MnemoConfig};
25
25
 
26
26
  /// Passphrase used by every bench-created file. Not a secret; the files
27
27
  /// are throwaway and live in `target/`.
@@ -27,7 +27,7 @@
27
27
  use std::hint::black_box;
28
28
 
29
29
  use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
30
- use mnemo::{Embedder, EmbedderIdentity, Memory, MemoryType, Mnemo, Result};
30
+ use mnemo_engine::{Embedder, EmbedderIdentity, Memory, MemoryType, Mnemo, Result};
31
31
  use tempfile::TempDir;
32
32
 
33
33
  #[path = "corpus.rs"]
@@ -25,7 +25,7 @@ use std::hint::black_box;
25
25
  use std::path::PathBuf;
26
26
 
27
27
  use criterion::{criterion_group, criterion_main, Criterion};
28
- use mnemo::{Memory, MemoryType, Mnemo};
28
+ use mnemo_engine::{Memory, MemoryType, Mnemo};
29
29
 
30
30
  #[path = "corpus.rs"]
31
31
  mod corpus;
@@ -28,7 +28,7 @@
28
28
  use std::hint::black_box;
29
29
 
30
30
  use criterion::{criterion_group, criterion_main, Criterion};
31
- use mnemo::RecallRequest;
31
+ use mnemo_engine::RecallRequest;
32
32
 
33
33
  #[path = "corpus.rs"]
34
34
  mod corpus;
@@ -112,10 +112,48 @@ fn bench_recall_1m(c: &mut Criterion) {
112
112
  bench_recall_pair(c, 1_000_000, "1m", 10);
113
113
  }
114
114
 
115
+ /// Phase 12.1 lane-A REVIEW remeasure: first recall on a *fresh*
116
+ /// `Mnemo` handle. Opens the cached 100K corpus, issues a single
117
+ /// recall, closes the handle — repeated per Criterion iteration. The
118
+ /// pre-v0.8.0 code called `ensure_key_caches()` inside recall itself,
119
+ /// which decrypted every live record on the first call — roughly 1 s
120
+ /// at 100K with hardware AES. Post-fix, the first recall only decrypts
121
+ /// the ANN shortlist plus whatever the widen / exact-scan loop needs
122
+ /// (typically a few hundred records), so this cell should sit near
123
+ /// the pure per-query cost of `ivfpq_recall_100k`.
124
+ fn bench_first_recall_fresh_handle_100k(c: &mut Criterion) {
125
+ use mnemo_engine::{RecallRequest, ScoreWeights};
126
+ let cached = setup_cached_corpus(100_000, DIMENSIONS);
127
+ let queries = gen_clustered_vectors(DIMENSIONS, 20, 0xDEAD_BEEF, 100);
128
+ let mut group = c.benchmark_group("ivfpq_first_recall_fresh_handle_100k");
129
+ group.sample_size(20);
130
+ group.bench_function("first_recall", |b| {
131
+ let mut i = 0usize;
132
+ b.iter(|| {
133
+ // Open a *fresh* handle every iteration so the key-cache
134
+ // lazy init (removed in v0.8.0) and page-cache are cold.
135
+ // Use `open_corpus_with_index` so the IVF+PQ path is live;
136
+ // the "fresh handle" invariant we want to measure is the
137
+ // one that pre-v0.8.0 would have paid for key-cache init
138
+ // on every first recall.
139
+ let mut db = open_corpus_with_index(&cached);
140
+ let q = &queries[i % queries.len()];
141
+ i += 1;
142
+ let req = RecallRequest::new(q.clone())
143
+ .top_k(10)
144
+ .track_access(false)
145
+ .weights(ScoreWeights::default());
146
+ let _ = black_box(db.recall(&req).unwrap());
147
+ });
148
+ });
149
+ group.finish();
150
+ }
151
+
115
152
  criterion_group!(
116
153
  recall_benches,
117
154
  bench_recall_10k,
118
155
  bench_recall_100k,
119
156
  bench_recall_1m,
157
+ bench_first_recall_fresh_handle_100k,
120
158
  );
121
159
  criterion_main!(recall_benches);
@@ -25,7 +25,7 @@
25
25
  use std::hint::black_box;
26
26
 
27
27
  use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
28
- use mnemo::{Memory, MemoryType, Mnemo};
28
+ use mnemo_engine::{Memory, MemoryType, Mnemo};
29
29
  use tempfile::TempDir;
30
30
 
31
31
  #[path = "corpus.rs"]
@@ -29,7 +29,7 @@ use std::fs;
29
29
  use std::path::PathBuf;
30
30
  use std::time::Instant;
31
31
 
32
- use mnemo::{
32
+ use mnemo_engine::{
33
33
  IndexConfig, KdfParams, Memory, MemoryType, Metric, Mnemo, MnemoConfig, RecallRequest,
34
34
  };
35
35
  use serde_json::{json, Value};
@@ -30,7 +30,7 @@ use std::fs;
30
30
  use std::path::PathBuf;
31
31
  use std::time::Instant;
32
32
 
33
- use mnemo::{
33
+ use mnemo_engine::{
34
34
  IndexConfig, KdfParams, Memory, MemoryType, Metric, Mnemo, MnemoConfig, RecallRequest,
35
35
  };
36
36
  use serde_json::{json, Value};
@@ -31,7 +31,7 @@ use std::fs;
31
31
  use std::path::PathBuf;
32
32
  use std::time::Instant;
33
33
 
34
- use mnemo::{
34
+ use mnemo_engine::{
35
35
  IndexConfig, KdfParams, Memory, MemoryType, Metric, Mnemo, MnemoConfig, RecallRequest,
36
36
  };
37
37
  use serde_json::{json, Value};
@@ -39,7 +39,7 @@ use std::fs;
39
39
  use std::path::PathBuf;
40
40
  use std::time::Instant;
41
41
 
42
- use mnemo::{
42
+ use mnemo_engine::{
43
43
  IndexConfig, KdfParams, Memory, MemoryType, Metric, Mnemo, MnemoConfig, RecallRequest,
44
44
  };
45
45
  use serde_json::{json, Value};
@@ -34,7 +34,7 @@
34
34
  use std::fs;
35
35
  use std::path::PathBuf;
36
36
 
37
- use mnemo::Mnemo;
37
+ use mnemo_engine::Mnemo;
38
38
  use serde_json::{json, Value};
39
39
 
40
40
  const PASSPHRASE: &str = "bench-pw";
@@ -2,7 +2,7 @@
2
2
  //!
3
3
  //! Run with: `cargo run --example quickstart`
4
4
 
5
- use mnemo::{Memory, MemoryType, Mnemo, MnemoConfig, RecallRequest, Result};
5
+ use mnemo_engine::{Memory, MemoryType, Mnemo, MnemoConfig, RecallRequest, Result};
6
6
 
7
7
  fn main() -> Result<()> {
8
8
  // Use a temporary path so the example is self-cleaning.