@seanhogg/builderforce-memory 2026.9.34 → 2026.10.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.
Files changed (97) hide show
  1. package/dist/errors/SSMError.d.ts +1 -1
  2. package/dist/errors/SSMError.d.ts.map +1 -1
  3. package/dist/errors/SSMError.js.map +1 -1
  4. package/dist/handoff/index.d.ts +5 -5
  5. package/dist/handoff/index.js +5 -5
  6. package/dist/handoff/note.d.ts +1 -1
  7. package/dist/handoff/note.js +1 -1
  8. package/dist/handoff/pack.d.ts +13 -4
  9. package/dist/handoff/pack.d.ts.map +1 -1
  10. package/dist/handoff/pack.js +31 -10
  11. package/dist/handoff/pack.js.map +1 -1
  12. package/dist/memory/MemoryStore.d.ts +120 -181
  13. package/dist/memory/MemoryStore.d.ts.map +1 -1
  14. package/dist/memory/MemoryStore.js +201 -389
  15. package/dist/memory/MemoryStore.js.map +1 -1
  16. package/dist/memory/SemanticRecall.d.ts +64 -0
  17. package/dist/memory/SemanticRecall.d.ts.map +1 -0
  18. package/dist/memory/SemanticRecall.js +188 -0
  19. package/dist/memory/SemanticRecall.js.map +1 -0
  20. package/dist/memory/records.d.ts +26 -0
  21. package/dist/memory/records.d.ts.map +1 -0
  22. package/dist/memory/records.js +71 -0
  23. package/dist/memory/records.js.map +1 -0
  24. package/dist/memory/ttlSweeper.d.ts +12 -0
  25. package/dist/memory/ttlSweeper.d.ts.map +1 -0
  26. package/dist/memory/ttlSweeper.js +28 -0
  27. package/dist/memory/ttlSweeper.js.map +1 -0
  28. package/dist/memory/types.d.ts +142 -0
  29. package/dist/memory/types.d.ts.map +1 -0
  30. package/dist/memory/types.js +6 -0
  31. package/dist/memory/types.js.map +1 -0
  32. package/dist/storage/ScopedFactRepository.d.ts +156 -0
  33. package/dist/storage/ScopedFactRepository.d.ts.map +1 -0
  34. package/dist/storage/ScopedFactRepository.js +278 -0
  35. package/dist/storage/ScopedFactRepository.js.map +1 -0
  36. package/dist/storage/factImport.d.ts +21 -0
  37. package/dist/storage/factImport.d.ts.map +1 -0
  38. package/dist/storage/factImport.js +61 -0
  39. package/dist/storage/factImport.js.map +1 -0
  40. package/dist/storage/factMutations.d.ts +46 -0
  41. package/dist/storage/factMutations.d.ts.map +1 -0
  42. package/dist/storage/factMutations.js +73 -0
  43. package/dist/storage/factMutations.js.map +1 -0
  44. package/dist/storage/factQueries.d.ts +16 -0
  45. package/dist/storage/factQueries.d.ts.map +1 -0
  46. package/dist/storage/factQueries.js +36 -0
  47. package/dist/storage/factQueries.js.map +1 -0
  48. package/dist/storage/factRetention.d.ts +30 -0
  49. package/dist/storage/factRetention.d.ts.map +1 -0
  50. package/dist/storage/factRetention.js +65 -0
  51. package/dist/storage/factRetention.js.map +1 -0
  52. package/dist/storage/fileLock.d.ts +56 -0
  53. package/dist/storage/fileLock.d.ts.map +1 -0
  54. package/dist/storage/fileLock.js +138 -0
  55. package/dist/storage/fileLock.js.map +1 -0
  56. package/dist/storage/fileTransaction.d.ts +33 -0
  57. package/dist/storage/fileTransaction.d.ts.map +1 -0
  58. package/dist/storage/fileTransaction.js +108 -0
  59. package/dist/storage/fileTransaction.js.map +1 -0
  60. package/dist/storage/idbAdapter.d.ts +95 -0
  61. package/dist/storage/idbAdapter.d.ts.map +1 -0
  62. package/dist/storage/idbAdapter.js +311 -0
  63. package/dist/storage/idbAdapter.js.map +1 -0
  64. package/dist/storage/nodeFileAdapter.d.ts +127 -0
  65. package/dist/storage/nodeFileAdapter.d.ts.map +1 -0
  66. package/dist/storage/nodeFileAdapter.js +275 -0
  67. package/dist/storage/nodeFileAdapter.js.map +1 -0
  68. package/dist/storage/syncJournal.d.ts +19 -0
  69. package/dist/storage/syncJournal.d.ts.map +1 -0
  70. package/dist/storage/syncJournal.js +46 -0
  71. package/dist/storage/syncJournal.js.map +1 -0
  72. package/dist/storage/types.d.ts +207 -0
  73. package/dist/storage/types.d.ts.map +1 -0
  74. package/dist/storage/types.js +90 -0
  75. package/dist/storage/types.js.map +1 -0
  76. package/package.json +3 -3
  77. package/src/errors/SSMError.ts +1 -0
  78. package/src/handoff/handoff.test.ts +52 -2
  79. package/src/handoff/index.ts +5 -5
  80. package/src/handoff/note.ts +1 -1
  81. package/src/handoff/pack.ts +32 -9
  82. package/src/memory/MemoryStore.ts +245 -525
  83. package/src/memory/SemanticRecall.ts +204 -0
  84. package/src/memory/records.ts +79 -0
  85. package/src/memory/ttlSweeper.ts +29 -0
  86. package/src/memory/types.ts +149 -0
  87. package/src/storage/ScopedFactRepository.ts +373 -0
  88. package/src/storage/factImport.ts +73 -0
  89. package/src/storage/factMutations.ts +106 -0
  90. package/src/storage/factQueries.ts +41 -0
  91. package/src/storage/factRetention.ts +82 -0
  92. package/src/storage/fileLock.ts +162 -0
  93. package/src/storage/fileTransaction.ts +116 -0
  94. package/src/storage/idbAdapter.ts +373 -0
  95. package/src/storage/nodeFileAdapter.ts +331 -0
  96. package/src/storage/syncJournal.ts +47 -0
  97. package/src/storage/types.ts +262 -0
@@ -5,7 +5,7 @@
5
5
  * Runtime-level failures (bridge, distillation, memory) throw SSMError.
6
6
  * Both carry a typed `code` discriminant for programmatic handling.
7
7
  */
8
- export type SSMErrorCode = 'RUNTIME_DESTROYED' | 'BRIDGE_REQUEST_FAILED' | 'BRIDGE_RESPONSE_INVALID' | 'MEMORY_UNAVAILABLE' | 'DISTILL_FAILED' | 'UNKNOWN';
8
+ export type SSMErrorCode = 'RUNTIME_DESTROYED' | 'BRIDGE_REQUEST_FAILED' | 'BRIDGE_RESPONSE_INVALID' | 'MEMORY_UNAVAILABLE' | 'MEMORY_CONFLICT' | 'DISTILL_FAILED' | 'UNKNOWN';
9
9
  export declare class SSMError extends Error {
10
10
  readonly code: SSMErrorCode;
11
11
  readonly cause?: unknown | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"SSMError.d.ts","sourceRoot":"","sources":["../../src/errors/SSMError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,YAAY,GAClB,mBAAmB,GACnB,uBAAuB,GACvB,yBAAyB,GACzB,oBAAoB,GACpB,gBAAgB,GAChB,SAAS,CAAC;AAEhB,qBAAa,QAAS,SAAQ,KAAK;aAEX,IAAI,EAAE,YAAY;aAElB,KAAK,CAAC,EAAE,OAAO;gBAFf,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,OAAO,YAAA;CAKtC"}
1
+ {"version":3,"file":"SSMError.d.ts","sourceRoot":"","sources":["../../src/errors/SSMError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,MAAM,MAAM,YAAY,GAClB,mBAAmB,GACnB,uBAAuB,GACvB,yBAAyB,GACzB,oBAAoB,GACpB,iBAAiB,GACjB,gBAAgB,GAChB,SAAS,CAAC;AAEhB,qBAAa,QAAS,SAAQ,KAAK;aAEX,IAAI,EAAE,YAAY;aAElB,KAAK,CAAC,EAAE,OAAO;gBAFf,IAAI,EAAE,YAAY,EAClC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,OAAO,YAAA;CAKtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SSMError.js","sourceRoot":"","sources":["../../src/errors/SSMError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEX;IAEA;IAHpB,YACoB,IAAkB,EAClC,OAAe,EACC,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAc;QAElB,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;CACJ"}
1
+ {"version":3,"file":"SSMError.js","sourceRoot":"","sources":["../../src/errors/SSMError.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,MAAM,OAAO,QAAS,SAAQ,KAAK;IAEX;IAEA;IAHpB,YACoB,IAAkB,EAClC,OAAe,EACC,KAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;QAJC,SAAI,GAAJ,IAAI,CAAc;QAElB,UAAK,GAAL,KAAK,CAAU;QAG/B,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IAC3B,CAAC;CACJ"}
@@ -2,11 +2,11 @@
2
2
  * Model hand-off packing — the `@seanhogg/builderforce-memory/handoff` subpath (PRD 34 §3.3).
3
3
  *
4
4
  * When a conversation moves to another model (a local one with a small window, say),
5
- * {@link packHandoff} fits the transcript into that model's budget: the system message(s)
6
- * stay, the latest user directive stays verbatim, tool calls are never split from their
7
- * results, the verbatim tail takes what the budget allows, and the dropped middle becomes
8
- * ONE assistant note (summary → memory recall → elision marker, with a one-line hand-off
9
- * note when the models differ).
5
+ * {@link packHandoff} fits the transcript into that model's budget: the leading system
6
+ * message(s) stay first, the latest user directive stays verbatim, tool calls are never
7
+ * split from their results, the verbatim tail takes what the budget allows, and the
8
+ * dropped middle becomes ONE note (summary → memory recall → elision marker, with a
9
+ * one-line hand-off note when the models differ) whose role keeps turns alternating.
10
10
  *
11
11
  * Pure: no WebGPU, no IndexedDB, no `node:*` — runs in a Cloudflare Worker, a browser
12
12
  * page and Node alike.
@@ -2,11 +2,11 @@
2
2
  * Model hand-off packing — the `@seanhogg/builderforce-memory/handoff` subpath (PRD 34 §3.3).
3
3
  *
4
4
  * When a conversation moves to another model (a local one with a small window, say),
5
- * {@link packHandoff} fits the transcript into that model's budget: the system message(s)
6
- * stay, the latest user directive stays verbatim, tool calls are never split from their
7
- * results, the verbatim tail takes what the budget allows, and the dropped middle becomes
8
- * ONE assistant note (summary → memory recall → elision marker, with a one-line hand-off
9
- * note when the models differ).
5
+ * {@link packHandoff} fits the transcript into that model's budget: the leading system
6
+ * message(s) stay first, the latest user directive stays verbatim, tool calls are never
7
+ * split from their results, the verbatim tail takes what the budget allows, and the
8
+ * dropped middle becomes ONE note (summary → memory recall → elision marker, with a
9
+ * one-line hand-off note when the models differ) whose role keeps turns alternating.
10
10
  *
11
11
  * Pure: no WebGPU, no IndexedDB, no `node:*` — runs in a Cloudflare Worker, a browser
12
12
  * page and Node alike.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The ONE assistant note that stands in for the dropped middle of a handed-off
2
+ * The ONE note that stands in for the dropped middle of a handed-off
3
3
  * transcript: an optional one-line hand-off note, then the first body source that
4
4
  * succeeds — the `summarize` result, else the `recall` memory block for the latest
5
5
  * directive, else an elision marker. A failing, timing-out or empty source falls through
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The ONE assistant note that stands in for the dropped middle of a handed-off
2
+ * The ONE note that stands in for the dropped middle of a handed-off
3
3
  * transcript: an optional one-line hand-off note, then the first body source that
4
4
  * succeeds — the `summarize` result, else the `recall` memory block for the latest
5
5
  * directive, else an elision marker. A failing, timing-out or empty source falls through
@@ -4,13 +4,22 @@
4
4
  * Shape of the result, mirroring Builderforce's `assembleCompacted`
5
5
  * (brain-embedded/src/workingTranscript.ts):
6
6
  *
7
- * system message(s) · ONE assistant note for the dropped middle · the latest user
7
+ * leading system message(s) · ONE note for the dropped middle · the latest user
8
8
  * directive re-injected verbatim (only when it fell in the middle) · the verbatim tail
9
9
  *
10
+ * Only the LEADING run of system messages is the fixed prefix. A system message later in
11
+ * the conversation stays where it was: in the tail when the tail reaches it, else in the
12
+ * dropped middle — never hoisted to the front, where it would read as if it governed the
13
+ * whole conversation.
14
+ *
15
+ * The note's role keeps turns alternating: it is an `assistant` note when a user turn (the
16
+ * re-injected directive, or a tail that starts with one) follows it, and a `user` note
17
+ * when an assistant turn follows or nothing does — never two assistant turns in a row.
18
+ *
10
19
  * The tail is the longest run of whole units (see `segments.ts`) from the end that fits
11
- * what is left after the system message(s), the directive and room for an elision marker.
12
- * Whatever room the tail leaves is the note's: summary, else recall, else the marker.
13
- * The result never exceeds the budget unless the system message(s) + directive alone do.
20
+ * what is left after the prefix, the directive and room for an elision marker. Whatever
21
+ * room the tail leaves is the note's: summary, else recall, else the marker. The result
22
+ * never exceeds the budget unless the prefix + directive alone do.
14
23
  */
15
24
  import type { HandoffPack, HandoffPackInput } from './types.js';
16
25
  export declare function packHandoff(input: HandoffPackInput): Promise<HandoffPack>;
@@ -1 +1 @@
1
- {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/handoff/pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAkB,WAAW,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AA6DhG,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAqD/E"}
1
+ {"version":3,"file":"pack.d.ts","sourceRoot":"","sources":["../../src/handoff/pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAKH,OAAO,KAAK,EAAkB,WAAW,EAAE,gBAAgB,EAAkB,MAAM,YAAY,CAAC;AAyEhG,wBAAsB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,CAuD/E"}
@@ -4,17 +4,37 @@
4
4
  * Shape of the result, mirroring Builderforce's `assembleCompacted`
5
5
  * (brain-embedded/src/workingTranscript.ts):
6
6
  *
7
- * system message(s) · ONE assistant note for the dropped middle · the latest user
7
+ * leading system message(s) · ONE note for the dropped middle · the latest user
8
8
  * directive re-injected verbatim (only when it fell in the middle) · the verbatim tail
9
9
  *
10
+ * Only the LEADING run of system messages is the fixed prefix. A system message later in
11
+ * the conversation stays where it was: in the tail when the tail reaches it, else in the
12
+ * dropped middle — never hoisted to the front, where it would read as if it governed the
13
+ * whole conversation.
14
+ *
15
+ * The note's role keeps turns alternating: it is an `assistant` note when a user turn (the
16
+ * re-injected directive, or a tail that starts with one) follows it, and a `user` note
17
+ * when an assistant turn follows or nothing does — never two assistant turns in a row.
18
+ *
10
19
  * The tail is the longest run of whole units (see `segments.ts`) from the end that fits
11
- * what is left after the system message(s), the directive and room for an elision marker.
12
- * Whatever room the tail leaves is the note's: summary, else recall, else the marker.
13
- * The result never exceeds the budget unless the system message(s) + directive alone do.
20
+ * what is left after the prefix, the directive and room for an elision marker. Whatever
21
+ * room the tail leaves is the note's: summary, else recall, else the marker. The result
22
+ * never exceeds the budget unless the prefix + directive alone do.
14
23
  */
15
24
  import { defaultEstimateTokens, handoffBudget, messageTokens, tokensOf } from './budget.js';
16
25
  import { buildNote, composeNote, elisionMarker, handoffLine, noteTokens } from './note.js';
17
26
  import { segmentTranscript } from './segments.js';
27
+ /** Length of the leading run of `system` messages. */
28
+ function leadingSystemCount(all) {
29
+ let n = 0;
30
+ while (n < all.length && all[n].role === 'system')
31
+ n += 1;
32
+ return n;
33
+ }
34
+ /** The note's role: `user` before an assistant turn (or at the end), else `assistant`. */
35
+ function noteRole(next) {
36
+ return next === undefined || next.role === 'assistant' ? 'user' : 'assistant';
37
+ }
18
38
  /** Index of the last `user` message, or -1. */
19
39
  function latestDirectiveIndex(convo) {
20
40
  for (let i = convo.length - 1; i >= 0; i--)
@@ -64,8 +84,9 @@ export async function packHandoff(input) {
64
84
  // Under budget: hand the transcript over untouched.
65
85
  if (tokensOf(all, estimate) <= budget)
66
86
  return result(all.slice(), 0, estimate);
67
- const system = all.filter((m) => m.role === 'system');
68
- const convo = all.filter((m) => m.role !== 'system');
87
+ const prefixLen = leadingSystemCount(all);
88
+ const system = all.slice(0, prefixLen);
89
+ const convo = all.slice(prefixLen);
69
90
  const systemTokens = tokensOf(system, estimate);
70
91
  const directiveIdx = latestDirectiveIndex(convo);
71
92
  const directive = directiveIdx >= 0 ? convo[directiveIdx] : undefined;
@@ -96,12 +117,12 @@ export async function packHandoff(input) {
96
117
  timeoutMs: input.timeoutMs,
97
118
  })
98
119
  : null;
120
+ const after = reinject && directive ? [directive] : [];
121
+ after.push(...convo.slice(tail.start));
99
122
  const messages = [...system];
100
123
  if (note)
101
- messages.push({ role: 'assistant', content: note.text });
102
- if (reinject && directive)
103
- messages.push(directive);
104
- messages.push(...convo.slice(tail.start));
124
+ messages.push({ role: noteRole(after[0]), content: note.text });
125
+ messages.push(...after);
105
126
  return result(messages, droppedMsgs.length, estimate, {
106
127
  summarized: note?.summarized ?? false,
107
128
  recalled: note?.recalled ?? false,
@@ -1 +1 @@
1
- {"version":3,"file":"pack.js","sourceRoot":"","sources":["../../src/handoff/pack.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5F,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC3F,OAAO,EAAE,iBAAiB,EAAgB,MAAM,eAAe,CAAC;AAShE,+CAA+C;AAC/C,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;QAAE,IAAI,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,KAAK,MAAM;YAAE,OAAO,CAAC,CAAC;IACpF,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC;AAED;;;GAGG;AACH,SAAS,UAAU,CACjB,KAAgC,EAChC,IAAwB,EACxB,YAAoB,EACpB,eAAuB,EACvB,IAAY;IAEZ,IAAI,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IACzB,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;IACxB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAE,CAAC;QACrB,MAAM,gBAAgB,GAAG,YAAY,IAAI,CAAC,IAAI,YAAY,GAAG,GAAG,CA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AAC,GAAG,MAAM,CAAC,CAAC;IAC/C,IAAI,IAAI;QAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1E,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,EAAE;QACpD,UAAU,EAAE,IAAI,EAAE,UAAU,IAAI,KAAK;QACrC,QAAQ,EAAE,IAAI,EAAE,QAAQ,IAAI,KAAK;KAClC,CAAC,CAAC;AACL,CAAC"}
@@ -1,149 +1,104 @@
1
1
  /**
2
2
  * MemoryStore – persistent key-value fact store and weight checkpoint helper.
3
3
  *
4
- * Uses IndexedDB with a dedicated 'ssmjs' database containing two object stores:
5
- * - 'facts' : MemoryEntry records keyed by the fact key string
6
- * - 'weights' : a single ArrayBuffer keyed by `weightsKey`
4
+ * Persistence is delegated to a narrow {@link FactStoragePort} (M01) fronted by
5
+ * a {@link ScopedFactRepository} unit-of-work layer (M02–M06):
6
+ * - Browser default: IndexedDB via {@link IdbStorageAdapter}; every write
7
+ * resolves only after the transaction commits (M02).
8
+ * - Node.js: pass `storage: await NodeFileStorageAdapter.open(path)` for real
9
+ * durable storage. fake-indexeddb via `idbFactory` remains supported for
10
+ * TESTS, but is never durable and is not presented as such.
11
+ * - Facts live in an explicit {@link MemoryScope} partition (default: the
12
+ * unbound, never-connected scope) with durable revisions, operation
13
+ * identity, provenance and — when `sync: true` — a journaled tombstone
14
+ * trail that caps/TTL will not sacrifice (M03/M04/M06).
15
+ *
16
+ * Recall ranking and its derived embedding/index caches live in
17
+ * {@link SemanticRecall}; the public shapes in `./types.ts`.
7
18
  *
8
19
  * Weight save/load is delegated to the SSMRuntime passed to saveWeights/loadWeights.
9
20
  */
10
- import { type HybridRetrieveOptions } from '../retrieval/index.js';
11
- export type FactType = 'text' | 'json' | 'number' | 'boolean';
12
- export interface MemoryEntry {
13
- key: string;
14
- content: string;
15
- timestamp: number;
16
- /**
17
- * Monotonic write sequence, used only to break `timestamp` ties so that
18
- * ordering stays deterministic when several entries are written within the
19
- * same millisecond (Date.now() resolution). Higher = written later.
20
- * Optional for backward compatibility with entries persisted/imported
21
- * before this field existed (those sort as seq 0).
22
- */
23
- seq?: number;
24
- /** Optional time-to-live in milliseconds. */
25
- ttlMs?: number;
26
- /** Semantic type of the stored value. Default: 'text'. */
27
- type?: FactType;
28
- /** Tags for grouping and filtering. */
29
- tags?: string[];
30
- /** Importance weight in the range 0–1. Default: 0.5. */
31
- importance?: number;
32
- }
33
- /**
34
- * Which ranker produced a recall ordering. Matches the vocabulary the gateway's
35
- * Evermind recall/validate surfaces already report, so a host can render one chip
36
- * ("Semantic recall" / "Lexical recall (fallback)") regardless of which layer
37
- * answered.
38
- */
39
- export type RecallMethod = 'embedding' | 'lexical';
40
- /** A recalled entry with its relevance score (higher = closer). */
41
- export interface ScoredMemory {
42
- entry: MemoryEntry;
43
- score: number;
44
- }
45
- /** A ranked recall: the hits plus the ranker that ordered them. */
46
- export interface RankedRecall {
47
- hits: ScoredMemory[];
48
- method: RecallMethod;
49
- }
50
- export interface RememberOptions {
51
- /** Override the store-level defaultTtlMs for this entry. */
52
- ttlMs?: number;
53
- type?: FactType;
54
- tags?: string[];
55
- importance?: number;
56
- }
57
- export interface MemoryStoreOptions {
58
- /** IndexedDB database name. Default: 'ssmjs'. */
59
- dbName?: string;
60
- /** Key used for weight storage within the 'weights' object store. Default: 'ssmjs-weights'. */
61
- weightsKey?: string;
62
- /**
63
- * IDBFactory to use instead of the global `indexedDB`.
64
- * Use this in Node.js environments with fake-indexeddb:
65
- * import { IDBFactory } from 'fake-indexeddb';
66
- * const idbFactory = new IDBFactory();
67
- */
68
- idbFactory?: IDBFactory;
69
- /**
70
- * Default TTL applied to new entries when no per-entry ttlMs is provided.
71
- * Entries with an expired TTL are filtered from recallAll() and related methods.
72
- */
73
- defaultTtlMs?: number;
21
+ import type { HybridRetrieveOptions } from '../retrieval/index.js';
22
+ import { IdbStorageAdapter } from '../storage/idbAdapter.js';
23
+ import { ScopedFactRepository } from '../storage/ScopedFactRepository.js';
24
+ import { MemoryStorageError, type ConsistencyNote, type FactProvenance, type FactStoragePort, type MemoryScope, type StoredFactRecord, type TombstoneRecord, type JournalEntry } from '../storage/types.js';
25
+ import type { MemoryEntry, MemoryStoreOptions, RankedRecall, RememberOptions, SaveLoadRuntime, ScoredMemory, SSMRuntimeRef } from './types.js';
26
+ export type { FactType, MemoryEntry, MemoryStoreOptions, RankedRecall, RecallMethod, RememberOptions, ScoredMemory, } from './types.js';
27
+ export declare class MemoryStore {
28
+ private readonly _weightsKey;
29
+ private readonly _defaultTtl;
30
+ private readonly _maxEntries;
31
+ private readonly _scope;
32
+ /** The unit-of-work layer every durable operation flows through. */
33
+ readonly repository: ScopedFactRepository;
34
+ private readonly _storage;
35
+ /** Cross-context subscription, opened on the first operation (see `_ready`). */
36
+ private _unsubscribe;
37
+ private _subscribed;
38
+ private readonly _sweeper;
39
+ /** Ranking + its embedding / dense-index caches (EVM-1, EVM-1b, EVM-8). */
40
+ private readonly _recall;
41
+ /**
42
+ * Last store generation observed from a FOREIGN context (another tab,
43
+ * window or process). Monotonic, in-memory only; lets readers notice
44
+ * cross-context writes without a storage round-trip per recall (M05).
45
+ */
46
+ private _foreignRevision;
47
+ constructor(opts?: MemoryStoreOptions);
74
48
  /**
75
- * Fact count at/above which semantic recall switches from an exact O(N)
76
- * cosine scan to an O(log N) HNSW ANN index. Default 256 — small stores stay
77
- * exact (simpler + faster), large stores stay fast. (EVM-1)
49
+ * Cross-context invalidation (M05): a sibling tab/window/process that
50
+ * commits against the same storage invalidates this instance's derived
51
+ * caches. Subscribed lazily on the first operation: before it there are no
52
+ * caches to invalidate, and an eager subscription opened a global
53
+ * BroadcastChannel in the constructor that kept Node processes alive.
78
54
  */
79
- annThreshold?: number;
55
+ private _ready;
56
+ /** The scope partition this store is bound to (never widened implicitly). */
57
+ get scope(): MemoryScope;
58
+ /** The durable storage backend kind in use ('indexedDB' | 'node-file'). */
59
+ get storageKind(): FactStoragePort['kind'];
80
60
  /**
81
- * Hard cap on stored facts. When set, each write evicts the lowest-value
82
- * entries (expired first, then lowest importance, then oldest) so the store
83
- * stays bounded. Unset = unbounded (legacy). (EVM-7)
61
+ * Best-effort in-memory token that changes when another context writes to
62
+ * this store's database. Readers (e.g. EvermindCognition's recall cache)
63
+ * can fold it into their cache key so cross-context writes invalidate
64
+ * without a storage hit per recall.
84
65
  */
85
- maxEntries?: number;
66
+ get foreignRevision(): number;
67
+ private _onForeignChange;
86
68
  /**
87
- * Max content→embedding vectors held in the LRU recall cache. Default 2000.
88
- * (EVM-8 — bounded LRU instead of clear-on-overflow.)
69
+ * Stores or overwrites a fact. Resolves only after the underlying
70
+ * transaction commits durably (M02); the fact, its provenance and its sync
71
+ * journal entry commit atomically.
89
72
  */
90
- embedCacheMax?: number;
91
- }
92
- interface SaveLoadRuntime {
93
- save(opts?: {
94
- storage: 'indexedDB';
95
- key: string;
96
- }): Promise<void>;
97
- load(opts?: {
98
- key: string;
99
- }): Promise<boolean>;
100
- }
101
- type SSMRuntimeRef = any;
102
- export declare class MemoryStore {
103
- private readonly _dbName;
104
- private readonly _weightsKey;
105
- private readonly _idb;
106
- private readonly _defaultTtl;
107
- private readonly _annThreshold;
108
- private readonly _maxEntries;
109
- private readonly _embedCacheMax;
110
- private _db;
111
- private _sweepTimer;
112
- /** Content → L2-normalised embedding cache, used by recallSimilar. */
113
- private readonly _embedCache;
114
- /** Runtime whose embeddings populate `_embedCache`; a change invalidates it. */
115
- private _embedRuntime;
116
- private readonly _denseVectors;
117
- private _denseIndex;
118
- /** Signature of the fact set the current index was built from. */
119
- private _denseSig;
120
- /** Identity of the runtime whose embeddings populated the vectors. */
121
- private _denseRuntime;
122
- constructor(opts?: MemoryStoreOptions);
123
- private _open;
124
- private _isExpired;
125
- /** Stores or overwrites a fact. */
126
73
  remember(key: string, content: string, opts?: RememberOptions): Promise<void>;
127
74
  /**
128
- * Evicts the lowest-value entries until at most `maxEntries` remain. Eviction
129
- * priority (removed first): expired → lowest importance → oldest. No-op when
130
- * no cap is set or the store is under it. (EVM-7)
75
+ * Compare-and-set write (M04/M05): commits only if the record's current
76
+ * revision equals `expectedRevision` (`null` asserts the key is absent).
77
+ * Throws a MemoryStorageError otherwise (`code` 'MEMORY_CONFLICT',
78
+ * `storageCode` 'STORAGE_CONFLICT'; see `isStorageConflict`) — callers reconcile
79
+ * (re-read, re-evaluate evidence) instead of blindly overwriting a
80
+ * concurrent writer. Returns the committed entry.
131
81
  */
132
- private _enforceCap;
82
+ rememberCas(key: string, content: string, expectedRevision: number | null, opts?: RememberOptions): Promise<MemoryEntry>;
83
+ /** Fetches an entry WITH its durable revision, for CAS-based reconciliation. */
84
+ recallVersioned(key: string): Promise<MemoryEntry | undefined>;
133
85
  /**
134
- * Starts a background timer that periodically hard-deletes expired entries —
86
+ * Starts a background timer that periodically deletes expired entries —
135
87
  * TTL is otherwise only evaluated lazily on read, so an idle store would keep
136
88
  * dead entries forever. Idempotent; pair with {@link stopTtlSweeper}. (EVM-7)
89
+ *
90
+ * With sync enabled each expiry is a scoped deletion (tombstone + journal),
91
+ * not a silent drop (M06).
137
92
  */
138
93
  startTtlSweeper(intervalMs: number): void;
139
94
  /** Stops the background TTL sweeper started by {@link startTtlSweeper}. */
140
95
  stopTtlSweeper(): void;
141
96
  /**
142
- * Retrieves a fact by key.
97
+ * Retrieves a fact by key from this store's scope partition.
143
98
  * Returns `undefined` if the key does not exist or the entry has expired.
144
99
  */
145
100
  recall(key: string): Promise<MemoryEntry | undefined>;
146
- /** Returns all non-expired stored facts, newest first. */
101
+ /** Returns all non-expired stored facts in this store's scope, newest first. */
147
102
  recallAll(): Promise<MemoryEntry[]>;
148
103
  /**
149
104
  * Returns the N most recently updated non-expired facts.
@@ -152,19 +107,15 @@ export declare class MemoryStore {
152
107
  recallRecent(n: number): Promise<MemoryEntry[]>;
153
108
  /**
154
109
  * Returns all non-expired entries that contain the given tag.
110
+ * Looks the tag up on the facts `byTag` index when the storage adapter has
111
+ * one; a full scan is used only when that index is missing.
155
112
  */
156
113
  recallByTag(tag: string): Promise<MemoryEntry[]>;
157
114
  /**
158
- * Finds the top-K semantically similar entries to `query`.
159
- *
160
- * When `runtime` exposes an `embed()` method (the SSMRuntime does), similarity
161
- * is computed as cosine distance between SSM hidden-state embeddings — i.e. the
162
- * memory layer uses the very model it is attached to, and recall quality
163
- * improves automatically as that model is adapted/distilled. Embeddings are
164
- * cached per content string to avoid recomputing across calls.
165
- *
166
- * If no embedding-capable runtime is provided, or embedding fails for any
167
- * reason, it transparently falls back to Jaccard word-overlap similarity.
115
+ * Finds the top-K semantically similar entries to `query`: cosine over the
116
+ * attached SSM runtime's embeddings (so recall improves as that model is
117
+ * adapted), or Jaccard word overlap when no runtime can embed. See
118
+ * {@link SemanticRecall}.
168
119
  */
169
120
  recallSimilar(query: string, topK: number, runtime?: SSMRuntimeRef): Promise<MemoryEntry[]>;
170
121
  /**
@@ -173,80 +124,67 @@ export declare class MemoryStore {
173
124
  * so callers can rank/threshold by TRUE similarity instead of list position.
174
125
  * {@link recallSimilar} is the score-dropping convenience wrapper over this.
175
126
  */
176
- recallSimilarScored(query: string, topK: number, runtime?: SSMRuntimeRef): Promise<Array<{
177
- entry: MemoryEntry;
178
- score: number;
179
- }>>;
127
+ recallSimilarScored(query: string, topK: number, runtime?: SSMRuntimeRef): Promise<ScoredMemory[]>;
180
128
  /**
181
- * Hybrid recall: fuses dense (SSM-embedding cosine) and sparse (BM25 lexical)
182
- * rankings via Reciprocal Rank Fusion, then applies an MMR diversity rerank.
183
- *
184
- * This is the production RAG retrieval path — it catches both semantic matches
185
- * (embeddings) and exact-token matches (BM25 — identifiers, codes, rare names)
186
- * that cosine-only `recallSimilar` misses, and avoids returning near-duplicate
187
- * facts. Degrades to BM25-only when no embedding-capable runtime is available,
188
- * so it is always strictly at least as good as the lexical fallback.
129
+ * Hybrid recall: dense (SSM-embedding cosine) and sparse (BM25) rankings
130
+ * fused by Reciprocal Rank Fusion, then an MMR diversity rerank — catches
131
+ * exact-token matches cosine misses, and degrades to BM25 alone without a
132
+ * runtime. The production RAG path.
189
133
  */
190
134
  recallHybrid(query: string, topK: number, runtime?: SSMRuntimeRef, opts?: HybridRetrieveOptions): Promise<MemoryEntry[]>;
191
135
  /**
192
- * The hybrid retrieval path with its evidence attached: each hit's fused score,
193
- * plus WHICH ranker produced the ordering.
194
- *
195
- * {@link recallHybrid} is the convenience wrapper that throws both away, so
196
- * there is exactly one implementation of the blend — and it is the shared
197
- * `hybridRetrieve` → `reciprocalRankFusion` primitive, never a second hand-
198
- * rolled mix of cosine and word overlap.
199
- *
200
- * `method` is honest rather than aspirational: `'embedding'` means the query
201
- * really did embed and the dense ranking really did participate in the fusion;
202
- * `'lexical'` means no model was available (or embedding failed) and the
203
- * ordering is BM25 alone. Callers surface it so a user can tell semantic
204
- * recall from the fallback instead of guessing.
136
+ * {@link recallHybrid} with its evidence: each hit's fused score, and WHICH
137
+ * ranker produced the ordering — `'embedding'` only when the query and the
138
+ * candidates really embedded, `'lexical'` when the ordering is BM25 alone.
139
+ * One blend implementation: the shared `hybridRetrieve` primitive.
205
140
  */
206
141
  recallRanked(query: string, topK: number, runtime?: SSMRuntimeRef, opts?: HybridRetrieveOptions): Promise<RankedRecall>;
207
142
  /**
208
- * Returns a cached embedding for `text`, computing it via `runtime.embed()`
209
- * on a cache miss. Returns `null` (never throws) when embedding is
210
- * unavailable so callers can fall back to lexical similarity.
211
- */
212
- private _embedWithCache;
213
- /**
214
- * Synchronise the persistent dense vector store + HNSW index to `all` (EVM-1b).
215
- * Embeds ONLY new/changed facts (keyed by `key@seq`), prunes removed ones, and
216
- * rebuilds the index only when the fact set actually changed — so a read-heavy
217
- * workload reuses both the embeddings and the index across recalls. Returns
218
- * `null` (caller falls back to lexical) if any embedding is unavailable, or
219
- * resets everything when the runtime identity changes (embeddings are
220
- * model-specific).
221
- */
222
- private _syncDense;
223
- /**
224
- * Hard-deletes all entries whose TTL has expired.
143
+ * Deletes all entries whose TTL has expired. With sync enabled each expiry
144
+ * commits a tombstone + journal entry in the same transaction, so expiries
145
+ * propagate instead of resurrecting from a replica (M06).
225
146
  * @returns The number of entries deleted.
226
147
  */
227
148
  purgeExpired(): Promise<number>;
228
- /** Deletes a single fact. No-op if key does not exist. */
149
+ /**
150
+ * Deletes a single fact. No-op if key does not exist. With sync enabled the
151
+ * delete is a durable tombstone + journal entry committed atomically (M04).
152
+ */
229
153
  forget(key: string): Promise<void>;
230
- /** Deletes all facts. Does not affect saved weights. */
154
+ /** Deletes all facts in this store's scope. Does not affect saved weights. */
231
155
  clear(): Promise<void>;
156
+ /** Operations not yet acknowledged by sync — the pending knowledge set. */
157
+ pendingOps(): Promise<JournalEntry[]>;
158
+ /** Delete tombstones in this store's scope (or all scopes when omitted). */
159
+ tombstones(scope?: MemoryScope): Promise<TombstoneRecord[]>;
160
+ /**
161
+ * Acknowledges that the given operations reached the sync target. Their
162
+ * facts/tombstones stop being `pendingSync`, so retention may touch them
163
+ * again. Retention NEVER touches unacknowledged knowledge (M06).
164
+ */
165
+ markSynced(opIds: string[]): Promise<void>;
166
+ /** The current durable store generation. */
167
+ revision(): Promise<number>;
168
+ /** Releases cross-context subscriptions and the underlying connection. */
169
+ close(): void;
232
170
  /**
233
171
  * Returns all non-expired facts as a plain array for export.
234
- * Suitable for serialisation and import into another MemoryStore instance.
172
+ * Scope, revision and provenance travel with each entry (M03).
235
173
  */
236
174
  exportAll(): Promise<MemoryEntry[]>;
237
175
  /**
238
- * Imports entries from an external array.
176
+ * Imports entries from an external array INTO this store's scope partition.
177
+ * Source timestamps, sequences, tags, importance, TTL and provenance are
178
+ * preserved — import never rewrites source time (M06).
239
179
  *
240
180
  * - `'merge'` : only writes an entry if no existing entry with the same
241
181
  * key exists, or if the incoming entry has a newer timestamp.
242
182
  * - `'overwrite'` : writes all entries unconditionally.
243
183
  */
244
- importAll(entries: MemoryEntry[], strategy: 'merge' | 'overwrite'): Promise<void>;
245
- /** Writes a raw MemoryEntry directly (preserves original timestamp / metadata). */
246
- private _putRaw;
184
+ importAll(entries: MemoryEntry[], strategy: 'merge' | 'overwrite', importedFrom?: string): Promise<void>;
247
185
  /**
248
186
  * Saves SSM weights via `runtime.save()`.
249
- * The weights are stored under `weightsKey` in this store's IndexedDB,
187
+ * The weights are stored under `weightsKey` in the session's IndexedDB,
250
188
  * separate from MambaSession's own key.
251
189
  */
252
190
  saveWeights(runtime: SaveLoadRuntime): Promise<void>;
@@ -256,5 +194,6 @@ export declare class MemoryStore {
256
194
  */
257
195
  loadWeights(runtime: SaveLoadRuntime): Promise<boolean>;
258
196
  }
259
- export {};
197
+ export { IdbStorageAdapter, ScopedFactRepository, MemoryStorageError, };
198
+ export type { ConsistencyNote, FactProvenance, FactStoragePort, JournalEntry, MemoryScope, StoredFactRecord, TombstoneRecord, };
260
199
  //# sourceMappingURL=MemoryStore.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryStore.d.ts","sourceRoot":"","sources":["../../src/memory/MemoryStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAAmE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAEpI,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE9D,MAAM,WAAW,WAAW;IACxB,GAAG,EAAU,MAAM,CAAC;IACpB,OAAO,EAAM,MAAM,CAAC;IACpB,SAAS,EAAI,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,GAAG,CAAC,EAAS,MAAM,CAAC;IACpB,6CAA6C;IAC7C,KAAK,CAAC,EAAO,MAAM,CAAC;IACpB,0DAA0D;IAC1D,IAAI,CAAC,EAAQ,QAAQ,CAAC;IACtB,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