nexusmem 0.5.0 → 0.5.2

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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,53 @@ built from, matched by publish timestamp: `v0.1.0` → `67a4776`, `v0.1.1` → `
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.5.2] — 2026-08-18
13
+
14
+ ### Added
15
+
16
+ - **`nexusmem mark-stale <nodeId> --supersedes <newNodeId>`, `provenance`, and manual staleness
17
+ tracking.** A pre-Show-HN pass answering a public critique that this couldn't tell an observed
18
+ fact from a guess, or retire a stale conclusion. Every node now carries `provenance`
19
+ (`observed`/`inferred`, set per-collector: git commits, diffs, and shell commands are `observed`;
20
+ conversation turns, session summaries, and doc sections are `inferred`) and an optional
21
+ `supersedes` link. `mark-stale` writes that link; the ranker applies a flat down-weight to whatever
22
+ it points at, but never deletes it -- the old node stays queryable, just usually loses to its
23
+ replacement. `provenance` is shown as a `[observed]`/`[inferred]` tag on every query result (CLI
24
+ and MCP `search_memory` share the same renderer). This is deliberately not automatic: nothing
25
+ detects staleness on its own, a human or agent still has to notice the contradiction and run the
26
+ command. See the README's new "Manual staleness & provenance" section.
27
+
28
+ ### Verified
29
+
30
+ - **`forget` does not leak through vector search.** Checked whether `MemoryStore.forget` excludes a
31
+ tombstoned node from `sqlite-vec` results only via a query-time filter (which every vector query
32
+ path would need to apply consistently) or by deleting the embedding row outright. It already does
33
+ the latter -- `dropEmbedding` runs before the node row is deleted, in the same transaction, on both
34
+ query paths (`runHybridQuery` and `runCrossProjectQuery`, which both call the same
35
+ `MemoryStore.vectorSearch`). No fix was needed; added a regression test
36
+ (`tests/vector.test.ts`) that forgets an embedded node and asserts both `vectorSearch` returns
37
+ nothing and the `nodes_vec` row count drops to zero, so this can't silently regress.
38
+ - **`forget` survives `sync --rebuild`.** This was the point of v0.5.0 and was already covered
39
+ end-to-end in `tests/forget.test.ts`. Added a lower-level `tests/store.test.ts` case pinning the
40
+ exact mechanism: `clearProject` (what `--rebuild` calls before re-ingesting) only touches
41
+ `nodes`/`nodes_vec`/`sync_state`, never `deny_list`, so a re-ingest of the same content is denied
42
+ again rather than resurrected.
43
+
44
+ ## [0.5.1] — 2026-08-17
45
+
46
+ ### Added
47
+
48
+ - **`nexusmem forget --export <path>` / `forget --import <path>`: carry a deny-list across a clone or
49
+ restore.** `.nexusmem/` is gitignored by design, so `deny_list` never traveled with `git clone`/
50
+ `git push` — confirmed live 2026-08-17 that a fresh clone of the exact same repo resurrected a value
51
+ already forgotten elsewhere, with zero deny-list protection, because git history (what a fresh `sync`
52
+ re-derives from) is fully portable while the deny-list that would have blocked it was not. `--export`
53
+ writes the active entries to a plaintext JSON file (loudly warned as exactly as sensitive as the
54
+ values it holds — never meant for git, moved through whatever secure channel the user already
55
+ trusts); `--import` re-applies each new entry through `forget` itself, so an imported value is
56
+ deleted from the new checkout's nodes too, not just blocked going forward. Same dry-run-by-default /
57
+ `--yes` convention as the rest of `forget`. See `docs/forget-mechanism.md`.
58
+
12
59
  ## [0.5.0] — 2026-08-17
13
60
 
14
61
  ### Added
@@ -337,7 +384,8 @@ First public release.
337
384
  there is no local-model summarization pass, and the conversation collector has never been audited
338
385
  for the stale-node bug that was found and fixed in the docs collector.
339
386
 
340
- [Unreleased]: https://github.com/yaminbkk/NexusMem/compare/v0.5.0...HEAD
387
+ [Unreleased]: https://github.com/yaminbkk/NexusMem/compare/v0.5.1...HEAD
388
+ [0.5.1]: https://github.com/yaminbkk/NexusMem/compare/v0.5.0...v0.5.1
341
389
  [0.5.0]: https://github.com/yaminbkk/NexusMem/compare/v0.4.0...v0.5.0
342
390
  [0.4.0]: https://github.com/yaminbkk/NexusMem/compare/v0.3.3...v0.4.0
343
391
  [0.3.3]: https://github.com/yaminbkk/NexusMem/compare/v0.3.2...v0.3.3
package/README.md CHANGED
@@ -21,6 +21,13 @@ The shell history is the part worth caring about. Git tells an agent what shippe
21
21
  tells it what was attempted, in what order, and which commands exited non-zero. That information
22
22
  exists nowhere else, and it disappears when your terminal scrollback rolls over.
23
23
 
24
+ **Contents:** [Try it](#try-it) · [Exact shell capture](#optional-exact-shell-capture) ·
25
+ [Failure → fix chains](#failure--fix-chains-opt-in) · [How retrieval works](#how-retrieval-works) ·
26
+ [Session summaries](#session-summaries-optional-local-model) · [Use it from an agent](#use-it-from-an-agent)
27
+ · [What it costs you](#what-it-costs-you) · [Manual staleness & provenance](#manual-staleness--provenance) ·
28
+ [Where it breaks](#where-it-breaks) · [Commands](#commands) · [Cross-project recall](#recall-across-projects)
29
+ · [On disk](#on-disk) · [Development](#development)
30
+
24
31
  ## Try it
25
32
 
26
33
  From inside any git repository:
@@ -37,14 +44,17 @@ $ nexusmem query "windows spawn failure"
37
44
 
38
45
  Relevant history for: windows spawn failure
39
46
 
40
- - 2026-08-09 fix: distinguish a failed git spawn from "not a git repository"
47
+ - 2026-08-09 [observed] fix: distinguish a failed git spawn from "not a git repository"
41
48
  readRepoInfo collapsed three unrelated failures into one error: git running and reporting
42
49
  the path is not a work tree, git not being installed, and the process failing to spawn at
43
50
  all. Dogfooding hit the third case in two separate sessions...
44
- - 2026-08-09 README.md — Before a tagged release
51
+ - 2026-08-09 [inferred] README.md — Before a tagged release
45
52
  - [ ] Retry on transient process-spawn failures on Windows
46
53
  ```
47
54
 
55
+ `[observed]`/`[inferred]` is the provenance tag (see [Manual staleness & provenance](#manual-staleness--provenance))
56
+ — a commit is a directly observed event, a doc section is a written claim that could go stale.
57
+
48
58
  A commit and a docs section, ranked against each other, inside whatever token budget you gave it.
49
59
  Nothing was summarized by a model on the way out; the ranker just decided what not to send. (One
50
60
  optional source, session summaries, does run a local model — but at ingest time, never on the way
@@ -117,19 +127,17 @@ project they were found in.
117
127
  ```
118
128
  $ nexusmem query "why did npm whoami fail"
119
129
 
120
- - 2026-08-12 shell: npm whoami (exit 1)
121
- - 2026-08-12 shell: npm login (exit 0) -- linked as the fix
130
+ - 2026-08-12 [observed] shell: npm whoami (exit 1)
131
+ - 2026-08-12 [observed] shell: npm login (exit 0) -- linked as the fix
122
132
  ```
123
133
 
124
134
  ## How retrieval works
125
135
 
126
136
  Every source normalizes to the same `MemoryNode` shape, so a commit, a shell command and a docs
127
137
  section compete on equal terms. Retrieval runs BM25 over FTS5 and, if an embedding model is
128
- reachable, a vector search over `sqlite-vec`, then fuses the two with Reciprocal Rank Fusion.
129
-
130
- RRF fuses on rank *position* only, never on raw scores. That is the entire reason it is safe here: a
131
- BM25 cost and a vector distance live on unrelated, unbounded scales, and position is the only thing
132
- they agree on. No hand-tuned normalization constant sits between them.
138
+ reachable, a vector search over `sqlite-vec`, fused with Reciprocal Rank Fusion on rank *position*
139
+ only, never raw scores — a BM25 cost and a vector distance live on unrelated, unbounded scales, and
140
+ position is the only thing they agree on.
133
141
 
134
142
  Ranking then multiplies three factors:
135
143
 
@@ -137,27 +145,19 @@ Ranking then multiplies three factors:
137
145
  score = relevance × signal^0.215 × recency^0.288
138
146
  ```
139
147
 
140
- `relevance` comes from the query. `signal` (a `fix:` commit outranks a `chore:`; a command that
141
- exited non-zero outranks one that succeeded) and `recency` are priors that hold before any query
142
- exists. Each factor is floored into `[floor, 1]` rather than `[0, 1]`, so one weak dimension cannot
143
- zero out a strong match.
148
+ `relevance` comes from the query. `signal` (a `fix:` commit outranks a `chore:`; a failed command
149
+ outranks a successful one) and `recency` are priors that hold before any query exists. Each factor is
150
+ floored into `[floor, 1]` rather than `[0, 1]`, so one weak dimension can't zero out a strong match.
144
151
 
145
- Those exponents are derived, not tuned. Priors kept overturning the query: on one real query a `fix:`
146
- commit took rank 1 from a better-matching docs section on a 44% signal edge against a 15% relevance
147
- deficit. So the priors get a **shared** budget across their whole range they may overturn at most a
148
- relevance gap split evenly between them, and each is raised to the power that makes its own span
149
- worth exactly its share (`span^exponent = √2`). Priors still order equally-relevant hits exactly as
150
- before, since the transform is monotonic. They just cannot outvote the question anymore.
152
+ The exponents bound how far signal and recency, *together*, may overturn relevance: at most a gap
153
+ across their whole range, applied jointly rather than per-prior. That's deliberate the score
154
+ *multiplies* the two priors, so capping each at separately still let the pair overturn 4×, and
155
+ that hit hardest on fresh, high-signal commits made during an active working day. The bug that
156
+ exposed this: two unrelated same-day `fix:` commits outranked the docs section that actually answered
157
+ the query. See [`retrieval/rank.ts`](src/retrieval/rank.ts) for the full derivation.
151
158
 
152
- The budget is shared rather than per-prior for a reason found by dogfooding, not by reading the
153
- arithmetic: the score *multiplies* the priors, so capping each at 2× separately left the pair free to
154
- overturn 4×. That describes every commit made during an active working day — fresh and high-signal at
155
- once — so the failure landed on precisely the days with the most worth remembering. A query about the
156
- PowerShell hook returned two unrelated same-day `fix:` commits at ranks 3 and 4 while the section that
157
- answered it sat at rank 6. Adding a third prior now re-divides the same budget instead of enlarging it.
158
-
159
- Without Ollama, vector search is skipped and you get BM25 only. That path is fully supported, not a
160
- degraded error state; `sync` and `query` both succeed and simply do less.
159
+ Without Ollama, vector search is skipped and you get BM25 only fully supported, not a degraded
160
+ state; `sync` and `query` both succeed and simply do less.
161
161
 
162
162
  ## Session summaries (optional, local model)
163
163
 
@@ -228,27 +228,21 @@ and points it at a synced corpus can re-run from scratch:
228
228
  Both clear the original >70% target ("cut API token spend versus sending full context"), and the vite
229
229
  run is the first measurement at the scale that target was always described as applying to.
230
230
 
231
- **Read the methodology before quoting either number, because it is a narrower claim than it looks:**
232
-
233
- - The file set each query is graded against comes from NexusMem's *own* ranking whichever files the
234
- packed nodes for that query touch, not an outside judge's idea of the right answer. This isolates
235
- what the pack step (rank budget excerpt) saves once retrieval has already picked a candidate
236
- set; it does not independently verify that the candidate set was the right one to pick.
237
- - The vite query set is not hand-picked: an even sample, across the full commit history, of
238
- well-explained `fix`/`feat`/`perf`/`refactor` commits turned into "why does vite `<description>`"
239
- from the commit's own conventional-commit text, plus rationale-bearing doc section headings. This
240
- repo's own query set instead reuses real historical prompts verbatim from `conversation_turn`
241
- nodes several are broad task instructions rather than narrow questions, which pulls a wider file
242
- set into scope and is part of why its number, while still high, sits below vite's. Both derivations
243
- are mechanical and disclosed in `scripts/benchmark.ts`, neither is cherry-picked per-query.
244
- - `git log -p` on a file touched by thousands of commits is enormous one vite query's baseline hit
245
- 7.5M tokens because a file in its resolved set has that much history. That is itself a finding, not
246
- noise: at this scale, "just read the file's history instead" stops being a viable alternative at
247
- all, which is a big part of why that column rounds to ~100%.
248
- - **This supersedes the previous ~40% figure**, which was hand-tallied from two hand-picked queries
249
- against this repo alone, never instrumented, and used an unstated baseline. It was not wrong so much
250
- as underspecified — this number replaces it with a stated method and a script that reproduces it,
251
- rather than being a claim that the product got better.
231
+ **Read the methodology before quoting either number it's a narrower claim than it looks:**
232
+
233
+ - **Graded against NexusMem's own ranking**, not an outside answer key: the file set is whichever
234
+ files the packed nodes for that query touch. This measures what the pack step saves once retrieval
235
+ already picked a candidate set; it doesn't independently verify that set was the right one.
236
+ - **Query sets are mechanical, not cherry-picked** (see `scripts/benchmark.ts`): vite's is an even
237
+ sample of well-explained `fix`/`feat`/`perf`/`refactor` commits plus rationale-bearing doc headings;
238
+ this repo's reuses real historical prompts verbatim, several of which are broad task instructions
239
+ rather than narrow questions part of why its number sits below vite's.
240
+ - **`git log -p` baselines can be enormous** one vite query's baseline hit 7.5M tokens because a
241
+ file in its resolved set has that much history. At that scale, "just read the file's history
242
+ instead" stops being a viable alternative at all.
243
+ - **Supersedes the old ~40% figure**, which was hand-tallied from two hand-picked queries against
244
+ this repo alone with an unstated baseline. Not wrong, just underspecifiedthis replaces it with a
245
+ stated method and a script that reproduces it.
252
246
 
253
247
  One thing that is not a percentage: shell commands and conversation turns have no cheap `grep`
254
248
  equivalent. Without something recording them, they are gone, not merely more expensive to find.
@@ -269,6 +263,29 @@ Latency on a ~530-node corpus, warm, p50 over 10 runs:
269
263
  All the SQLite work totals about 5 ms. The embedding call is the only thing on this path worth
270
264
  optimizing, and it is somebody else's process.
271
265
 
266
+ ## Manual staleness & provenance
267
+
268
+ Two things a memory layer needs and this one only partly has: a way to tell an observed fact from a
269
+ guess, and a way to retire a conclusion once something contradicts it. Neither is automatic here —
270
+ this section is what exists and what doesn't.
271
+
272
+ Every node carries a `provenance`: `observed` (a commit that landed, a shell command's real exit
273
+ code) or `inferred` (a conversation turn, a session summary, a doc section — all readable as claims
274
+ that could be wrong or go stale). Set once per collector at ingest time, and shown as a `[observed]`
275
+ / `[inferred]` tag on every query result.
276
+
277
+ ```bash
278
+ nexusmem mark-stale <oldNodeId> --supersedes <newNodeId>
279
+ ```
280
+
281
+ Links `newNodeId` as the replacement for `oldNodeId`. The ranker down-weights the old node from then
282
+ on (it stays queryable, just usually loses to its replacement) — nothing is deleted, unlike `forget`.
283
+
284
+ **What this doesn't do:** nothing here detects staleness on its own. If a later commit contradicts an
285
+ earlier doc section, NexusMem has no way to notice that and flag it — a human or an agent has to spot
286
+ the contradiction and run `mark-stale` themselves. Automatic staleness detection is still an open
287
+ problem.
288
+
272
289
  ## Where it breaks
273
290
 
274
291
  - **Shell history without the hook is unscoped.** Scraped history has no directory context, so it is
@@ -322,11 +339,20 @@ optimizing, and it is somebody else's process.
322
339
  ran against (plus that repo's stale prior identities, same scope `--prune-source` already uses). A
323
340
  value that leaked into shell history from several repositories needs `forget` run once per repo —
324
341
  there is no shared, machine-wide deny-list across every project you have synced.
342
+ - **A deny-list doesn't survive a clone or restore on its own.** `.nexusmem/` is gitignored by design,
343
+ so `deny_list` never travels with `git clone`/`git push` — while git history itself, the thing a
344
+ fresh `sync` re-derives from, is fully portable and copied by every clone. A teammate's fresh
345
+ checkout, a new machine, or a restored backup starts with zero protection: the forgotten value comes
346
+ right back on the first sync. Confirmed live 2026-08-17, not just a theoretical read of the code.
347
+ `forget --export <path>` / `forget --import <path>` close this: export writes the active entries to
348
+ a plaintext JSON file you move through a channel you control (never git — the file is exactly as
349
+ sensitive as the value it holds), and import re-applies them in the new checkout, deleting any
350
+ copies that already synced back in. It is deliberately manual, not automatic on every `sync`.
325
351
 
326
352
  ## Commands
327
353
 
328
- `init`, `sync`, `query <text>`, `status`, `projects`, `mcp`, `forget <value>`, and
329
- `hook install|remove|status`.
354
+ `init`, `sync`, `query <text>`, `status`, `projects`, `mcp`, `forget <value>`,
355
+ `mark-stale <nodeId> --supersedes <newNodeId>`, and `hook install|remove|status`.
330
356
 
331
357
  There are also five dry-run previews (`scan-git`, `scan-diff`, `scan-shell`, `scan-docs`,
332
358
  `scan-conversation`)
@@ -344,8 +370,9 @@ is the finer-grained complement — it deletes every node matching one exact str
344
370
  pattern) *and* writes a standing deny-list entry so the value can never be re-ingested, even by a
345
371
  later `sync --rebuild` re-reading the append-only shell-hook log or a full transcript scan. Every
346
372
  removal leaves a hash-only tombstone, never the forgotten content itself. Both are dry-run by
347
- default; `--yes` confirms. See [`docs/forget-mechanism.md`](docs/forget-mechanism.md) for why this
348
- exists.
373
+ default; `--yes` confirms. `forget --list` shows active entries; `forget --export <path>` /
374
+ `forget --import <path>` carry them to another checkout of the same repo (see the limitation above).
375
+ See [`docs/forget-mechanism.md`](docs/forget-mechanism.md) for why this exists.
349
376
 
350
377
  ## Recall across projects
351
378
 
@@ -356,12 +383,12 @@ and tags each result with the repository it came from:
356
383
  $ nexusmem query --all-projects "why was the retry budget raised"
357
384
  scope 2 project(s): NexusMem, uploader
358
385
 
359
- - 2026-08-12 [uploader] fix: raise the retry budget after the S3 upload timeouts
360
- - 2026-08-12 [uploader] retry.ts @ 8d0f98b — fix: raise the retry budget after the S3 upload timeouts
386
+ - 2026-08-12 [observed] [uploader] fix: raise the retry budget after the S3 upload timeouts
387
+ - 2026-08-12 [observed] [uploader] retry.ts @ 8d0f98b — fix: raise the retry budget after the S3 upload timeouts
361
388
  @@ -1 +1 @@
362
389
  -export const RETRY_BUDGET = 3;
363
390
  +export const RETRY_BUDGET = 5;
364
- - 2026-08-09 [NexusMem] fix(git): retry a transient failure to spawn git
391
+ - 2026-08-09 [observed] [NexusMem] fix(git): retry a transient failure to spawn git
365
392
  ```
366
393
 
367
394
  Databases stay per-repository — there is no shared global store, and deleting one repo's
@@ -399,7 +426,7 @@ Deleting `.nexusmem/` loses nothing that `sync` cannot rebuild.
399
426
 
400
427
  ## Status
401
428
 
402
- Ingestion, hybrid retrieval, budgeted packing and the MCP server all work and are covered by 342
429
+ Ingestion, hybrid retrieval, budgeted packing and the MCP server all work and are covered by 493
403
430
  tests running on Linux and Windows across Node 22 and 24.
404
431
 
405
432
  ## Development