mnemo-engine 0.9.0__tar.gz → 0.10.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 (58) hide show
  1. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/PKG-INFO +2 -1
  2. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/README.md +1 -0
  3. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/Cargo.lock +2 -2
  4. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/Cargo.toml +6 -1
  5. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/README.md +10 -2
  6. mnemo_engine-0.10.0/mnemo/benches/thread.rs +162 -0
  7. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/ann_recall_grid_v2.rs +8 -0
  8. mnemo_engine-0.10.0/mnemo/examples/device_budget.rs +631 -0
  9. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/bin/mnemo.rs +35 -51
  10. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/crypto.rs +15 -1
  11. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/index.rs +334 -23
  12. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/lib.rs +42 -3
  13. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/mcp.rs +54 -23
  14. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/memory.rs +55 -2
  15. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/pager.rs +5 -2
  16. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/store.rs +1425 -517
  17. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/wal.rs +112 -7
  18. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/cli_smoke.rs +252 -3
  19. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/integration.rs +941 -0
  20. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/proptest_store.rs +374 -0
  21. mnemo_engine-0.10.0/mnemo/tests/wal_recover_alloc.rs +77 -0
  22. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/Cargo.lock +2 -2
  23. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/Cargo.toml +1 -1
  24. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/README.md +1 -0
  25. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/src/lib.rs +107 -18
  26. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/test_mnemo.py +118 -0
  27. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/pyproject.toml +1 -1
  28. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/.gitignore +0 -0
  29. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/cache.rs +0 -0
  30. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/corpus.rs +0 -0
  31. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/embed_overhead.rs +0 -0
  32. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/open.rs +0 -0
  33. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/recall.rs +0 -0
  34. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/benches/write.rs +0 -0
  35. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/deny.toml +0 -0
  36. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/ann_defaults_v0_6_0.rs +0 -0
  37. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/ann_diagnose.rs +0 -0
  38. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/ann_recall_grid.rs +0 -0
  39. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/embedder_server.py +0 -0
  40. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/file_size_breakdown.rs +0 -0
  41. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/open_rss.rs +0 -0
  42. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/quickstart.rs +0 -0
  43. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/ranking_v2.rs +0 -0
  44. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/examples/session.rs +0 -0
  45. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/cache.rs +0 -0
  46. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/embed.rs +0 -0
  47. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/embed_cmd.rs +0 -0
  48. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/error.rs +0 -0
  49. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/format.rs +0 -0
  50. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/result_cache.rs +0 -0
  51. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/session.rs +0 -0
  52. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/src/transcript.rs +0 -0
  53. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/dur1_torn_header.rs +0 -0
  54. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/fix1_correctness_sweep.rs +0 -0
  55. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/proptest_store.proptest-regressions +0 -0
  56. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo/tests/sec1_nonce_uniqueness.rs +0 -0
  57. {mnemo_engine-0.9.0 → mnemo_engine-0.10.0}/mnemo-python/.gitignore +0 -0
  58. {mnemo_engine-0.9.0 → mnemo_engine-0.10.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.9.0
3
+ Version: 0.10.0
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: Apache Software License
@@ -167,6 +167,7 @@ its own agent.
167
167
  | `search(query, top_k=10)` | Exact nearest-neighbour search |
168
168
  | `get(id)` / `delete(id)` | Fetch / soft-delete by id |
169
169
  | `about()` | Self-describing onboarding briefing — memories tagged `metadata.area="onboarding"`, manifest first |
170
+ | `about_essence()` | The project essence render for the briefing (markdown), or `None` when the file has none |
170
171
  | `insert_default_manifest()` | Insert the canonical scaffold manifest (same one `mnemo init` adds); returns its id |
171
172
  | `session(agent_id)` | Begin a conversation `Session` |
172
173
  | `flush()` / `close()` | Persist pending changes |
@@ -153,6 +153,7 @@ its own agent.
153
153
  | `search(query, top_k=10)` | Exact nearest-neighbour search |
154
154
  | `get(id)` / `delete(id)` | Fetch / soft-delete by id |
155
155
  | `about()` | Self-describing onboarding briefing — memories tagged `metadata.area="onboarding"`, manifest first |
156
+ | `about_essence()` | The project essence render for the briefing (markdown), or `None` when the file has none |
156
157
  | `insert_default_manifest()` | Insert the canonical scaffold manifest (same one `mnemo init` adds); returns its id |
157
158
  | `session(agent_id)` | Begin a conversation `Session` |
158
159
  | `flush()` / `close()` | Persist pending changes |
@@ -644,7 +644,7 @@ dependencies = [
644
644
 
645
645
  [[package]]
646
646
  name = "mnemo-engine"
647
- version = "0.9.0"
647
+ version = "0.10.0"
648
648
  dependencies = [
649
649
  "aes-gcm",
650
650
  "argon2",
@@ -669,7 +669,7 @@ dependencies = [
669
669
 
670
670
  [[package]]
671
671
  name = "mnemo-node"
672
- version = "0.9.0"
672
+ version = "0.10.0"
673
673
  dependencies = [
674
674
  "mnemo-engine",
675
675
  "napi",
@@ -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.9.0"
13
+ version = "0.10.0"
14
14
  edition = "2021"
15
15
  rust-version = "1.75"
16
16
  # `benches/corpus.rs` is a shared helper module pulled into real benches
@@ -148,6 +148,11 @@ name = "embed_overhead"
148
148
  harness = false
149
149
  required-features = ["benches"]
150
150
 
151
+ [[bench]]
152
+ name = "thread"
153
+ harness = false
154
+ required-features = ["benches"]
155
+
151
156
  [features]
152
157
  # When enabled, exposes crash-injection hooks used by the Phase 1.3
153
158
  # proptest under `mnemo_engine::__failpoints::*`. Always enabled during
@@ -439,7 +439,7 @@ Decrypted page payloads are held in a **bounded LRU cache** so repeated reads
439
439
  skip a decrypt. Eviction targets the least-recently-used *clean* page; a dirty
440
440
  page — the only copy of an un-flushed write — is never evicted, so the cap
441
441
  bounds retained clean pages without ever risking data. The default cap is
442
- 8192 pages (~64 MiB); `Mnemo::set_cache_capacity` tunes it, and
442
+ 1024 pages (~8 MiB; 8192 pages before v0.10.0); `Mnemo::set_cache_capacity` tunes it, and
443
443
  `Mnemo::cache_stats` reports occupancy. The LRU order is an intrusive linked
444
444
  list over a slab of indices, so it stays within the crate's
445
445
  `#![forbid(unsafe_code)]`.
@@ -695,9 +695,17 @@ knowledge. The `about` command surfaces that introduction:
695
695
  cargo run --bin mnemo -- about agent.mnemo
696
696
  # Prints a one-line stats header, then every memory tagged
697
697
  # metadata.area = "onboarding" sorted with the canonical manifest first,
698
- # then by importance descending, ending with a quick-start footer.
698
+ # then by importance descending, then the project essence (if any),
699
+ # ending with a quick-start footer.
699
700
  ```
700
701
 
702
+ Since v0.9.1 the briefing also carries the file's **project essence**: the
703
+ render of its project-scope essence items (conventions, lasting decisions,
704
+ open items), at the default 6 KB budget, after the manifest and onboarding
705
+ memories. `Mnemo::about_essence()` returns it (`None` when there is none),
706
+ `mnemo about --format json` adds it as `"essence"`, and the MCP `about` tool
707
+ appends it as a final `{"kind": "essence", "render": …}` element.
708
+
701
709
  The convention is two metadata keys on ordinary memories — no new schema, no
702
710
  extra file:
703
711
 
@@ -0,0 +1,162 @@
1
+ //! Phase 12.7d speed benches for the thread layers.
2
+ //!
3
+ //! Three entries, all with a trivial in-process embedder (a canned
4
+ //! 384-dim vector), so they measure the engine's cost rather than a
5
+ //! model's:
6
+ //!
7
+ //! 1. `thread/ingest_1000_turns`: `ingest_thread` of 1,000 ~200-byte
8
+ //! turns into an empty thread, plus the flush. Throughput is reported
9
+ //! in turns per second.
10
+ //! 2. `thread/essence_render_1000_items`: `essence(thread, 6144)` over a
11
+ //! thread holding 1,000 essence items (700 section items across the
12
+ //! seven sections, 300 timeline entries).
13
+ //! 3. `thread/about_with_essence_1000_items`: the full `about` briefing,
14
+ //! `about()` plus `about_essence()`, on a file with a manifest and
15
+ //! 1,000 project-scope essence items.
16
+
17
+ use std::hint::black_box;
18
+
19
+ use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput};
20
+ use mnemo_engine::{
21
+ Embedder, EmbedderIdentity, EssenceScope, EssenceSection, Memory, Mnemo, Result, ThreadTurn,
22
+ };
23
+ use tempfile::TempDir;
24
+
25
+ #[path = "corpus.rs"]
26
+ mod corpus;
27
+ use corpus::{fast_kdf_cfg, gen_clustered_vectors, DIMENSIONS, PASSPHRASE};
28
+
29
+ const ITEMS: usize = 1_000;
30
+ const TURNS: usize = 1_000;
31
+
32
+ struct CannedEmbedder {
33
+ vector: Vec<f32>,
34
+ }
35
+
36
+ impl Embedder for CannedEmbedder {
37
+ fn identity(&self) -> EmbedderIdentity {
38
+ EmbedderIdentity {
39
+ name: "bench-canned-embedder".into(),
40
+ dimensions: self.vector.len(),
41
+ normalize: true,
42
+ }
43
+ }
44
+
45
+ fn embed(&self, texts: &[&str]) -> Result<Vec<Vec<f32>>> {
46
+ Ok(texts.iter().map(|_| self.vector.clone()).collect())
47
+ }
48
+ }
49
+
50
+ fn canned_vector() -> Vec<f32> {
51
+ gen_clustered_vectors(1, DIMENSIONS, 1, 0x7E8D_0001)
52
+ .into_iter()
53
+ .next()
54
+ .unwrap()
55
+ }
56
+
57
+ fn make_db(td: &TempDir) -> Mnemo {
58
+ let path = td.path().join("thread-bench.mnemo");
59
+ let mut db = Mnemo::create(&path, PASSPHRASE, fast_kdf_cfg(DIMENSIONS)).expect("create");
60
+ db.remember(Memory::scaffold_manifest(DIMENSIONS))
61
+ .expect("manifest");
62
+ db.set_embedder(CannedEmbedder {
63
+ vector: canned_vector(),
64
+ })
65
+ .expect("set_embedder");
66
+ db
67
+ }
68
+
69
+ const SECTIONS: [EssenceSection; 7] = [
70
+ EssenceSection::Intent,
71
+ EssenceSection::Conventions,
72
+ EssenceSection::Decisions,
73
+ EssenceSection::State,
74
+ EssenceSection::Open,
75
+ EssenceSection::Next,
76
+ EssenceSection::Lessons,
77
+ ];
78
+
79
+ /// Fill `scope` with `ITEMS` essence items: 70% section items spread
80
+ /// over the seven sections, 30% timeline entries.
81
+ fn fill_essence(db: &mut Mnemo, scope: &EssenceScope) {
82
+ for i in 0..ITEMS {
83
+ if i % 10 < 7 {
84
+ let section = SECTIONS[i % SECTIONS.len()];
85
+ let text =
86
+ format!("item {i:04}: a one-line essence entry of typical length for a bench");
87
+ db.essence_add(scope.clone(), section, &text, None)
88
+ .expect("essence_add");
89
+ } else {
90
+ let text =
91
+ format!("milestone {i:04}: shipped a thing, measured it, and wrote down why");
92
+ db.essence_append_timeline(scope.clone(), &text, None)
93
+ .expect("essence_append_timeline");
94
+ }
95
+ }
96
+ db.flush().expect("flush");
97
+ }
98
+
99
+ fn bench_ingest(c: &mut Criterion) {
100
+ let turns: Vec<ThreadTurn> = (0..TURNS)
101
+ .map(|i| ThreadTurn {
102
+ turn_id: format!("turn-{i:05}"),
103
+ role: if i % 2 == 0 { "user" } else { "assistant" }.into(),
104
+ content: format!("turn {i:05}: {}", "lorem ipsum dolor sit amet ".repeat(7)),
105
+ timestamp: Some(1_700_000_000 + i as i64),
106
+ })
107
+ .collect();
108
+
109
+ let mut group = c.benchmark_group("thread");
110
+ group.sample_size(10);
111
+ group.throughput(Throughput::Elements(TURNS as u64));
112
+ group.bench_function("ingest_1000_turns", |b| {
113
+ b.iter_batched(
114
+ || {
115
+ let td = TempDir::new().expect("tempdir");
116
+ let db = make_db(&td);
117
+ (td, db)
118
+ },
119
+ |(_td, mut db)| {
120
+ let report = db.ingest_thread("bench", &turns).expect("ingest");
121
+ db.flush().expect("flush");
122
+ black_box(report);
123
+ },
124
+ BatchSize::PerIteration,
125
+ );
126
+ });
127
+ group.finish();
128
+ }
129
+
130
+ fn bench_render(c: &mut Criterion) {
131
+ let td = TempDir::new().expect("tempdir");
132
+ let mut db = make_db(&td);
133
+ let scope = EssenceScope::Thread("bench".into());
134
+ fill_essence(&mut db, &scope);
135
+
136
+ let mut group = c.benchmark_group("thread");
137
+ group.sample_size(20);
138
+ group.bench_function("essence_render_1000_items", |b| {
139
+ b.iter(|| black_box(db.essence(scope.clone(), 6144).expect("render")));
140
+ });
141
+ group.finish();
142
+ }
143
+
144
+ fn bench_about(c: &mut Criterion) {
145
+ let td = TempDir::new().expect("tempdir");
146
+ let mut db = make_db(&td);
147
+ fill_essence(&mut db, &EssenceScope::Project);
148
+
149
+ let mut group = c.benchmark_group("thread");
150
+ group.sample_size(20);
151
+ group.bench_function("about_with_essence_1000_items", |b| {
152
+ b.iter(|| {
153
+ let records = db.about().expect("about");
154
+ let essence = db.about_essence().expect("about_essence");
155
+ black_box((records, essence))
156
+ });
157
+ });
158
+ group.finish();
159
+ }
160
+
161
+ criterion_group!(thread_benches, bench_ingest, bench_render, bench_about);
162
+ criterion_main!(thread_benches);
@@ -284,6 +284,14 @@ fn main() {
284
284
  .map(|&n| sweep_tier(n))
285
285
  .collect();
286
286
 
287
+ // `ANN_GRID_OUT=path` writes only this block to `path` (PERF-1 used it
288
+ // to check the recall gate without rewriting the perf JSON).
289
+ if let Ok(alt) = std::env::var("ANN_GRID_OUT") {
290
+ let block = json!({ "tiers": tiers });
291
+ fs::write(&alt, serde_json::to_string_pretty(&block).unwrap() + "\n").unwrap();
292
+ println!("\n[ann-grid-v2] wrote {alt}");
293
+ return;
294
+ }
287
295
  let perf_path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
288
296
  .parent()
289
297
  .unwrap()