@remnic/core 9.3.677 → 9.3.678

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 (53) hide show
  1. package/dist/access-cli.js +7 -7
  2. package/dist/access-http.js +6 -6
  3. package/dist/access-mcp.js +5 -5
  4. package/dist/access-service.js +4 -4
  5. package/dist/capabilities.d.ts +29 -1
  6. package/dist/capabilities.js +5 -3
  7. package/dist/causal-behavior.js +2 -2
  8. package/dist/causal-chain.js +2 -2
  9. package/dist/causal-consolidation.js +2 -2
  10. package/dist/causal-retrieval.js +2 -2
  11. package/dist/causal-trajectory-graph.js +1 -1
  12. package/dist/causal-trajectory.js +1 -1
  13. package/dist/{chunk-7UTCHQTB.js → chunk-2AP4QJX5.js} +3 -3
  14. package/dist/{chunk-Y56J7CXW.js → chunk-2LDBXPLB.js} +10 -5
  15. package/dist/chunk-2LDBXPLB.js.map +1 -0
  16. package/dist/{chunk-CZMLLVU2.js → chunk-4PPMUNV5.js} +3 -3
  17. package/dist/{chunk-YEQBJXVO.js → chunk-7AAKSHDG.js} +37 -22
  18. package/dist/chunk-7AAKSHDG.js.map +1 -0
  19. package/dist/{chunk-RP64QP7G.js → chunk-K2JYO6QV.js} +3 -3
  20. package/dist/{chunk-RI5XBIZ6.js → chunk-PBH4JUAB.js} +14 -2
  21. package/dist/{chunk-RI5XBIZ6.js.map → chunk-PBH4JUAB.js.map} +1 -1
  22. package/dist/{chunk-Z56KDLDK.js → chunk-PCGCQTU6.js} +7 -7
  23. package/dist/{chunk-B6IUW76R.js → chunk-Q2H5U37U.js} +1 -1
  24. package/dist/{chunk-WXGTC424.js → chunk-RC3AFF6Z.js} +1 -1
  25. package/dist/{chunk-HQCGRSRU.js → chunk-SECQS4G4.js} +2 -2
  26. package/dist/{chunk-2DKXY243.js → chunk-UNZLU2MX.js} +3 -3
  27. package/dist/{chunk-NE566K4E.js → chunk-YXWAILM4.js} +2 -2
  28. package/dist/cli.js +8 -8
  29. package/dist/compounding/engine.js +1 -1
  30. package/dist/{graph-edge-decay-PUFNHOBS.js → graph-edge-decay-KSVJGCZW.js} +2 -2
  31. package/dist/graph-snapshot.js +2 -2
  32. package/dist/graph.d.ts +11 -0
  33. package/dist/graph.js +1 -1
  34. package/dist/index.js +11 -11
  35. package/dist/operator-toolkit.js +2 -2
  36. package/dist/orchestrator.js +5 -5
  37. package/package.json +2 -2
  38. package/src/capabilities.test.ts +173 -0
  39. package/src/capabilities.ts +61 -0
  40. package/src/graph.ts +20 -4
  41. package/src/orchestrator.ts +35 -11
  42. package/dist/chunk-Y56J7CXW.js.map +0 -1
  43. package/dist/chunk-YEQBJXVO.js.map +0 -1
  44. /package/dist/{chunk-7UTCHQTB.js.map → chunk-2AP4QJX5.js.map} +0 -0
  45. /package/dist/{chunk-CZMLLVU2.js.map → chunk-4PPMUNV5.js.map} +0 -0
  46. /package/dist/{chunk-RP64QP7G.js.map → chunk-K2JYO6QV.js.map} +0 -0
  47. /package/dist/{chunk-Z56KDLDK.js.map → chunk-PCGCQTU6.js.map} +0 -0
  48. /package/dist/{chunk-B6IUW76R.js.map → chunk-Q2H5U37U.js.map} +0 -0
  49. /package/dist/{chunk-WXGTC424.js.map → chunk-RC3AFF6Z.js.map} +0 -0
  50. /package/dist/{chunk-HQCGRSRU.js.map → chunk-SECQS4G4.js.map} +0 -0
  51. /package/dist/{chunk-2DKXY243.js.map → chunk-UNZLU2MX.js.map} +0 -0
  52. /package/dist/{chunk-NE566K4E.js.map → chunk-YXWAILM4.js.map} +0 -0
  53. /package/dist/{graph-edge-decay-PUFNHOBS.js.map → graph-edge-decay-KSVJGCZW.js.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Orchestrator
3
- } from "./chunk-YEQBJXVO.js";
3
+ } from "./chunk-7AAKSHDG.js";
4
4
  import "./chunk-4SKKVWLQ.js";
5
5
  import "./chunk-7HYPN2GC.js";
6
6
  import "./chunk-666A3MOW.js";
@@ -14,7 +14,7 @@ import "./chunk-UWK5OXUJ.js";
14
14
  import "./chunk-T2PO5MUF.js";
15
15
  import "./chunk-HP5FMB6L.js";
16
16
  import "./chunk-7N4KAIGN.js";
17
- import "./chunk-B6IUW76R.js";
17
+ import "./chunk-Q2H5U37U.js";
18
18
  import "./chunk-DRD2Q7HQ.js";
19
19
  import "./chunk-TECVW3JP.js";
20
20
  import "./chunk-UHGBNIOS.js";
@@ -107,7 +107,7 @@ import "./chunk-B5XMS73R.js";
107
107
  import "./chunk-L2EXJQJP.js";
108
108
  import "./chunk-7SI52C65.js";
109
109
  import "./chunk-RK6F44Y6.js";
110
- import "./chunk-RI5XBIZ6.js";
110
+ import "./chunk-PBH4JUAB.js";
111
111
  import {
112
112
  parseConfig
113
113
  } from "./chunk-IUZWBCJX.js";
@@ -125,7 +125,7 @@ import "./chunk-OADWQ5CR.js";
125
125
  import "./chunk-7WV3F5DQ.js";
126
126
  import {
127
127
  EngramAccessService
128
- } from "./chunk-CZMLLVU2.js";
128
+ } from "./chunk-4PPMUNV5.js";
129
129
  import "./chunk-GDASG7NC.js";
130
130
  import "./chunk-GDB4J2H3.js";
131
131
  import "./chunk-ARV3AUOM.js";
@@ -160,7 +160,7 @@ import "./chunk-EIR5VLIH.js";
160
160
  import "./chunk-BMFZLLNI.js";
161
161
  import "./chunk-CI7RKSRE.js";
162
162
  import "./chunk-6HMYUWXR.js";
163
- import "./chunk-NE566K4E.js";
163
+ import "./chunk-YXWAILM4.js";
164
164
  import "./chunk-EI6V5UXY.js";
165
165
  import "./chunk-QY7YA7OL.js";
166
166
  import "./chunk-O75CRYGF.js";
@@ -168,7 +168,7 @@ import "./chunk-QDW3E4RD.js";
168
168
  import "./chunk-3ONXXHQO.js";
169
169
  import "./chunk-GKKAXVAJ.js";
170
170
  import "./chunk-ODPLEWB6.js";
171
- import "./chunk-Y56J7CXW.js";
171
+ import "./chunk-2LDBXPLB.js";
172
172
  import "./chunk-2LSZVONP.js";
173
173
  import "./chunk-DEUNUKTD.js";
174
174
  import "./chunk-ATRB6Q25.js";
@@ -191,7 +191,7 @@ import "./chunk-VF4XKTX3.js";
191
191
  import "./chunk-G7D6GZ5J.js";
192
192
  import "./chunk-RGMVMVMF.js";
193
193
  import "./chunk-ZY2MNJR6.js";
194
- import "./chunk-WXGTC424.js";
194
+ import "./chunk-RC3AFF6Z.js";
195
195
  import "./chunk-UZYLX7M6.js";
196
196
  import "./chunk-U3PN77QT.js";
197
197
  import "./chunk-4DJQYKMN.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  EngramAccessHttpServer
3
- } from "./chunk-2DKXY243.js";
3
+ } from "./chunk-UNZLU2MX.js";
4
4
  import "./chunk-SEDEKFYQ.js";
5
5
  import "./chunk-JBPKEARU.js";
6
6
  import "./chunk-TMSXWOBZ.js";
@@ -9,10 +9,10 @@ import "./chunk-RSUYKGGZ.js";
9
9
  import "./chunk-42NQ7AVG.js";
10
10
  import "./chunk-7RXCMVFQ.js";
11
11
  import "./chunk-7WV3F5DQ.js";
12
- import "./chunk-RP64QP7G.js";
12
+ import "./chunk-K2JYO6QV.js";
13
13
  import "./chunk-T4WDJPEZ.js";
14
14
  import "./chunk-D24OXEPB.js";
15
- import "./chunk-CZMLLVU2.js";
15
+ import "./chunk-4PPMUNV5.js";
16
16
  import "./chunk-GDASG7NC.js";
17
17
  import "./chunk-GDB4J2H3.js";
18
18
  import "./chunk-ARV3AUOM.js";
@@ -47,7 +47,7 @@ import "./chunk-EIR5VLIH.js";
47
47
  import "./chunk-BMFZLLNI.js";
48
48
  import "./chunk-CI7RKSRE.js";
49
49
  import "./chunk-6HMYUWXR.js";
50
- import "./chunk-NE566K4E.js";
50
+ import "./chunk-YXWAILM4.js";
51
51
  import "./chunk-EI6V5UXY.js";
52
52
  import "./chunk-QY7YA7OL.js";
53
53
  import "./chunk-O75CRYGF.js";
@@ -55,7 +55,7 @@ import "./chunk-QDW3E4RD.js";
55
55
  import "./chunk-3ONXXHQO.js";
56
56
  import "./chunk-GKKAXVAJ.js";
57
57
  import "./chunk-ODPLEWB6.js";
58
- import "./chunk-Y56J7CXW.js";
58
+ import "./chunk-2LDBXPLB.js";
59
59
  import "./chunk-2LSZVONP.js";
60
60
  import "./chunk-DEUNUKTD.js";
61
61
  import "./chunk-ATRB6Q25.js";
@@ -78,7 +78,7 @@ import "./chunk-VF4XKTX3.js";
78
78
  import "./chunk-G7D6GZ5J.js";
79
79
  import "./chunk-RGMVMVMF.js";
80
80
  import "./chunk-ZY2MNJR6.js";
81
- import "./chunk-WXGTC424.js";
81
+ import "./chunk-RC3AFF6Z.js";
82
82
  import "./chunk-UZYLX7M6.js";
83
83
  import "./chunk-U3PN77QT.js";
84
84
  import "./chunk-4DJQYKMN.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  EngramMcpServer
3
- } from "./chunk-RP64QP7G.js";
3
+ } from "./chunk-K2JYO6QV.js";
4
4
  import "./chunk-T4WDJPEZ.js";
5
5
  import "./chunk-D24OXEPB.js";
6
- import "./chunk-CZMLLVU2.js";
6
+ import "./chunk-4PPMUNV5.js";
7
7
  import "./chunk-GDASG7NC.js";
8
8
  import "./chunk-GDB4J2H3.js";
9
9
  import "./chunk-ARV3AUOM.js";
@@ -38,7 +38,7 @@ import "./chunk-EIR5VLIH.js";
38
38
  import "./chunk-BMFZLLNI.js";
39
39
  import "./chunk-CI7RKSRE.js";
40
40
  import "./chunk-6HMYUWXR.js";
41
- import "./chunk-NE566K4E.js";
41
+ import "./chunk-YXWAILM4.js";
42
42
  import "./chunk-EI6V5UXY.js";
43
43
  import "./chunk-QY7YA7OL.js";
44
44
  import "./chunk-O75CRYGF.js";
@@ -46,7 +46,7 @@ import "./chunk-QDW3E4RD.js";
46
46
  import "./chunk-3ONXXHQO.js";
47
47
  import "./chunk-GKKAXVAJ.js";
48
48
  import "./chunk-ODPLEWB6.js";
49
- import "./chunk-Y56J7CXW.js";
49
+ import "./chunk-2LDBXPLB.js";
50
50
  import "./chunk-2LSZVONP.js";
51
51
  import "./chunk-DEUNUKTD.js";
52
52
  import "./chunk-ATRB6Q25.js";
@@ -69,7 +69,7 @@ import "./chunk-VF4XKTX3.js";
69
69
  import "./chunk-G7D6GZ5J.js";
70
70
  import "./chunk-RGMVMVMF.js";
71
71
  import "./chunk-ZY2MNJR6.js";
72
- import "./chunk-WXGTC424.js";
72
+ import "./chunk-RC3AFF6Z.js";
73
73
  import "./chunk-UZYLX7M6.js";
74
74
  import "./chunk-U3PN77QT.js";
75
75
  import "./chunk-4DJQYKMN.js";
@@ -3,7 +3,7 @@ import {
3
3
  EngramAccessInputError,
4
4
  EngramAccessService,
5
5
  shapeMemorySummary
6
- } from "./chunk-CZMLLVU2.js";
6
+ } from "./chunk-4PPMUNV5.js";
7
7
  import "./chunk-GDASG7NC.js";
8
8
  import "./chunk-GDB4J2H3.js";
9
9
  import "./chunk-ARV3AUOM.js";
@@ -38,7 +38,7 @@ import "./chunk-EIR5VLIH.js";
38
38
  import "./chunk-BMFZLLNI.js";
39
39
  import "./chunk-CI7RKSRE.js";
40
40
  import "./chunk-6HMYUWXR.js";
41
- import "./chunk-NE566K4E.js";
41
+ import "./chunk-YXWAILM4.js";
42
42
  import "./chunk-EI6V5UXY.js";
43
43
  import "./chunk-QY7YA7OL.js";
44
44
  import "./chunk-O75CRYGF.js";
@@ -46,7 +46,7 @@ import "./chunk-QDW3E4RD.js";
46
46
  import "./chunk-3ONXXHQO.js";
47
47
  import "./chunk-GKKAXVAJ.js";
48
48
  import "./chunk-ODPLEWB6.js";
49
- import "./chunk-Y56J7CXW.js";
49
+ import "./chunk-2LDBXPLB.js";
50
50
  import "./chunk-2LSZVONP.js";
51
51
  import "./chunk-DEUNUKTD.js";
52
52
  import "./chunk-ATRB6Q25.js";
@@ -69,7 +69,7 @@ import "./chunk-VF4XKTX3.js";
69
69
  import "./chunk-G7D6GZ5J.js";
70
70
  import "./chunk-RGMVMVMF.js";
71
71
  import "./chunk-ZY2MNJR6.js";
72
- import "./chunk-WXGTC424.js";
72
+ import "./chunk-RC3AFF6Z.js";
73
73
  import "./chunk-UZYLX7M6.js";
74
74
  import "./chunk-U3PN77QT.js";
75
75
  import "./chunk-4DJQYKMN.js";
@@ -69,5 +69,33 @@ interface CapabilitySet {
69
69
  * so there is nothing for a toggle argument to compose at this layer.
70
70
  */
71
71
  declare function resolveCapabilities(config: PluginConfig): CapabilitySet;
72
+ /**
73
+ * Frozen projection of graph-construction feature gates.
74
+ *
75
+ * Every field is `readonly boolean`. Composition (including default-when-
76
+ * undefined semantics for the optional `graphWriteSessionAdjacencyEnabled`)
77
+ * lives ONLY in {@link resolveGraphConstructionCapabilities}.
78
+ */
79
+ interface GraphConstructionCapabilitySet {
80
+ /** `entityGraphEnabled` — maintain entity co-reference graph edges. */
81
+ readonly entityGraph: boolean;
82
+ /** `timeGraphEnabled` — maintain thread-adjacency graph edges. */
83
+ readonly timeGraph: boolean;
84
+ /** `causalGraphEnabled` — maintain causal-language graph edges. */
85
+ readonly causalGraph: boolean;
86
+ /** `multiGraphMemoryEnabled` — master switch for multi-graph writes/traversal. */
87
+ readonly multiGraphMemory: boolean;
88
+ /** `graphWriteSessionAdjacencyEnabled` — session-adjacency fallback for time edges (default-on). */
89
+ readonly graphWriteSessionAdjacency: boolean;
90
+ }
91
+ /**
92
+ * Resolve the {@link GraphConstructionCapabilitySet} from parsed config.
93
+ *
94
+ * Call this ONCE at graph build/write entry (extraction, recall graph
95
+ * expansion, graph-health/repair) and thread the result down — exactly the
96
+ * pattern {@link resolveCapabilities} established for recall.
97
+ */
98
+ type GraphConstructionConfigProjection = Pick<PluginConfig, "entityGraphEnabled" | "timeGraphEnabled" | "causalGraphEnabled" | "multiGraphMemoryEnabled" | "graphWriteSessionAdjacencyEnabled">;
99
+ declare function resolveGraphConstructionCapabilities(config: GraphConstructionConfigProjection): GraphConstructionCapabilitySet;
72
100
 
73
- export { type CapabilitySet, resolveCapabilities };
101
+ export { type CapabilitySet, type GraphConstructionCapabilitySet, type GraphConstructionConfigProjection, resolveCapabilities, resolveGraphConstructionCapabilities };
@@ -1,8 +1,10 @@
1
1
  import {
2
- resolveCapabilities
3
- } from "./chunk-RI5XBIZ6.js";
2
+ resolveCapabilities,
3
+ resolveGraphConstructionCapabilities
4
+ } from "./chunk-PBH4JUAB.js";
4
5
  import "./chunk-PZ5AY32C.js";
5
6
  export {
6
- resolveCapabilities
7
+ resolveCapabilities,
8
+ resolveGraphConstructionCapabilities
7
9
  };
8
10
  //# sourceMappingURL=capabilities.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  readChainIndex,
3
3
  resolveChainsDir
4
- } from "./chunk-HQCGRSRU.js";
4
+ } from "./chunk-SECQS4G4.js";
5
5
  import "./chunk-HQ6NIBL6.js";
6
6
  import {
7
7
  resolveCausalTrajectoryStoreDir
8
- } from "./chunk-WXGTC424.js";
8
+ } from "./chunk-RC3AFF6Z.js";
9
9
  import {
10
10
  normalizeRecallTokens
11
11
  } from "./chunk-ZBJMUXZH.js";
@@ -6,9 +6,9 @@ import {
6
6
  stitchCausalChain,
7
7
  validateCausalEdge,
8
8
  writeChainIndex
9
- } from "./chunk-HQCGRSRU.js";
9
+ } from "./chunk-SECQS4G4.js";
10
10
  import "./chunk-HQ6NIBL6.js";
11
- import "./chunk-WXGTC424.js";
11
+ import "./chunk-RC3AFF6Z.js";
12
12
  import "./chunk-ZBJMUXZH.js";
13
13
  import "./chunk-2ODBA7MQ.js";
14
14
  import "./chunk-A2IYSXDQ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  readChainIndex,
3
3
  resolveChainsDir
4
- } from "./chunk-HQCGRSRU.js";
4
+ } from "./chunk-SECQS4G4.js";
5
5
  import {
6
6
  buildExtensionsBlockForConsolidation
7
7
  } from "./chunk-V4ZHKCGA.js";
@@ -40,7 +40,7 @@ import "./chunk-G7D6GZ5J.js";
40
40
  import "./chunk-RGMVMVMF.js";
41
41
  import {
42
42
  resolveCausalTrajectoryStoreDir
43
- } from "./chunk-WXGTC424.js";
43
+ } from "./chunk-RC3AFF6Z.js";
44
44
  import "./chunk-U3PN77QT.js";
45
45
  import "./chunk-4DJQYKMN.js";
46
46
  import "./chunk-EYIEWJNI.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  readChainIndex,
3
3
  resolveChainsDir
4
- } from "./chunk-HQCGRSRU.js";
4
+ } from "./chunk-SECQS4G4.js";
5
5
  import "./chunk-HQ6NIBL6.js";
6
6
  import {
7
7
  readCausalTrajectoryRecords,
8
8
  searchCausalTrajectories
9
- } from "./chunk-WXGTC424.js";
9
+ } from "./chunk-RC3AFF6Z.js";
10
10
  import "./chunk-ZBJMUXZH.js";
11
11
  import {
12
12
  log
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  appendEdge
3
- } from "./chunk-Y56J7CXW.js";
3
+ } from "./chunk-2LDBXPLB.js";
4
4
  import "./chunk-2LSZVONP.js";
5
5
  import "./chunk-DEUNUKTD.js";
6
6
  import "./chunk-PZ5AY32C.js";
@@ -6,7 +6,7 @@ import {
6
6
  resolveCausalTrajectoryStoreDir,
7
7
  searchCausalTrajectories,
8
8
  validateCausalTrajectoryRecord
9
- } from "./chunk-WXGTC424.js";
9
+ } from "./chunk-RC3AFF6Z.js";
10
10
  import "./chunk-ZBJMUXZH.js";
11
11
  import "./chunk-A2IYSXDQ.js";
12
12
  import "./chunk-LPSF4OQH.js";
@@ -39,7 +39,7 @@ import {
39
39
  } from "./chunk-VL5JJOOY.js";
40
40
  import {
41
41
  analyzeGraphHealth
42
- } from "./chunk-Y56J7CXW.js";
42
+ } from "./chunk-2LDBXPLB.js";
43
43
  import {
44
44
  StorageManager
45
45
  } from "./chunk-EUM7CZFM.js";
@@ -777,7 +777,7 @@ async function summarizeBufferSurpriseDistribution(storage, config) {
777
777
  }
778
778
  }
779
779
  async function summarizeGraphEdgeDecayStatus(config) {
780
- const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-PUFNHOBS.js");
780
+ const { readGraphEdgeDecayStatus } = await import("./graph-edge-decay-KSVJGCZW.js");
781
781
  const enabled = config.graphEdgeDecayEnabled === true;
782
782
  if (!enabled) {
783
783
  return {
@@ -1336,4 +1336,4 @@ export {
1336
1336
  runBenchmarkRecall,
1337
1337
  runOperatorRepair
1338
1338
  };
1339
- //# sourceMappingURL=chunk-7UTCHQTB.js.map
1339
+ //# sourceMappingURL=chunk-2AP4QJX5.js.map
@@ -237,10 +237,15 @@ var GraphIndex = class _GraphIndex {
237
237
  * @param entitySiblings - paths of other memories that share the same entityRef (for entity graph)
238
238
  */
239
239
  async onMemoryWritten(opts) {
240
- if (!this.cfg.multiGraphMemoryEnabled) return;
240
+ const g = opts.graphCapsOverride;
241
+ const multiGraphOn = g ? g.multiGraphMemory : this.cfg.multiGraphMemoryEnabled;
242
+ if (!multiGraphOn) return;
243
+ const entityOn = g ? g.entityGraph : this.cfg.entityGraphEnabled;
244
+ const timeOn = g ? g.timeGraph : this.cfg.timeGraphEnabled;
245
+ const causalOn = g ? g.causalGraph : this.cfg.causalGraphEnabled;
241
246
  const ts = (/* @__PURE__ */ new Date()).toISOString();
242
247
  try {
243
- if (this.cfg.entityGraphEnabled && opts.entityRef && opts.entitySiblings?.length) {
248
+ if (entityOn && opts.entityRef && opts.entitySiblings?.length) {
244
249
  const siblings = opts.entitySiblings.slice(0, this.cfg.maxEntityGraphEdgesPerMemory);
245
250
  for (const sibling of siblings) {
246
251
  await appendEdge(this.memoryDir, {
@@ -253,7 +258,7 @@ var GraphIndex = class _GraphIndex {
253
258
  });
254
259
  }
255
260
  }
256
- if (this.cfg.timeGraphEnabled && opts.threadId && opts.recentInThread?.length) {
261
+ if (timeOn && opts.threadId && opts.recentInThread?.length) {
257
262
  const predecessor = opts.recentInThread[opts.recentInThread.length - 1];
258
263
  if (predecessor && predecessor !== opts.memoryPath) {
259
264
  await appendEdge(this.memoryDir, {
@@ -266,7 +271,7 @@ var GraphIndex = class _GraphIndex {
266
271
  });
267
272
  }
268
273
  }
269
- if (this.cfg.causalGraphEnabled && opts.causalPredecessor) {
274
+ if (causalOn && opts.causalPredecessor) {
270
275
  const phrase = detectCausalPhrase(opts.content);
271
276
  if (phrase) {
272
277
  await appendEdge(this.memoryDir, {
@@ -527,4 +532,4 @@ export {
527
532
  applyPageRankRefinement,
528
533
  applyLateralInhibition
529
534
  };
530
- //# sourceMappingURL=chunk-Y56J7CXW.js.map
535
+ //# sourceMappingURL=chunk-2LDBXPLB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/graph.ts"],"sourcesContent":["/**\n * Multi-Graph Memory (MAGMA/SYNAPSE-inspired, v8.2)\n *\n * Maintains three typed edge graphs:\n * entity.jsonl — memories sharing a named entity (entityRef)\n * time.jsonl — consecutive memories in the same thread/session\n * causal.jsonl — memories linked by causal language heuristics\n *\n * Stored under `<memoryDir>/state/graphs/`.\n * All writes are fail-open: errors are caught/logged, never thrown.\n */\n\nimport { appendFile, mkdir, readFile } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\nimport { readEdgeConfidence } from \"./graph-edge-reinforcement.js\";\nimport { emitGraphEvent } from \"./graph-events.js\";\n\nexport type GraphType = \"entity\" | \"time\" | \"causal\";\n\nexport interface GraphEdge {\n from: string; // relative memory path (e.g. \"facts/2026-02-22/abc.md\")\n to: string; // relative memory path\n type: GraphType;\n weight: number; // 1.0 default, decay applied during traversal\n label: string; // entity name, threadId, or matched causal phrase\n ts: string; // ISO timestamp of edge creation\n\n // Issue #681 — edge confidence + reinforcement (PR 1/3: schema + primitive only).\n // Both fields are optional so existing edges without confidence still validate.\n // Treat a missing `confidence` as 1.0 (legacy behavior) at read sites.\n // PR 2/3 wires the maintenance decay job; PR 3/3 weights PageRank traversal by confidence.\n confidence?: number; // [0, 1]; missing = 1.0\n lastReinforcedAt?: string; // ISO timestamp of most recent reinforcement\n}\n\nexport interface GraphConfig {\n multiGraphMemoryEnabled: boolean;\n entityGraphEnabled: boolean;\n timeGraphEnabled: boolean;\n causalGraphEnabled: boolean;\n maxGraphTraversalSteps: number;\n graphActivationDecay: number;\n maxEntityGraphEdgesPerMemory: number;\n graphLateralInhibitionEnabled: boolean;\n graphLateralInhibitionBeta: number;\n graphLateralInhibitionTopM: number;\n /**\n * Issue #681 PR 3/3 — minimum edge confidence required for traversal.\n * Edges with confidence below this floor are pruned. Legacy edges\n * (no `confidence` field) are treated as 1.0 and always pass.\n * Range `[0, 1]`. Default 0.2.\n */\n graphTraversalConfidenceFloor: number;\n /**\n * Issue #681 PR 3/3 — number of PageRank-style refinement iterations\n * applied on top of BFS activation. Set to 0 to disable refinement\n * and return raw BFS scores. Default 8.\n */\n graphTraversalPageRankIterations: number;\n}\n\n/** Default minimum edge confidence required for traversal (issue #681 PR 3/3). */\nexport const DEFAULT_GRAPH_TRAVERSAL_CONFIDENCE_FLOOR = 0.2;\n/** Default PageRank-style refinement iteration count (issue #681 PR 3/3). */\nexport const DEFAULT_GRAPH_TRAVERSAL_PAGERANK_ITERATIONS = 8;\n\n// Causal signal phrases — order matters (most specific first)\nexport const CAUSAL_PHRASES = [\"as a result\", \"led to\", \"because of\", \"therefore\", \"caused\", \"because\"];\n\nexport function graphsDir(memoryDir: string): string {\n return path.join(memoryDir, \"state\", \"graphs\");\n}\n\nexport function graphFilePath(memoryDir: string, type: GraphType): string {\n return path.join(graphsDir(memoryDir), `${type}.jsonl`);\n}\n\nexport async function ensureGraphsDir(memoryDir: string): Promise<void> {\n await mkdir(graphsDir(memoryDir), { recursive: true });\n}\n\n// ---------------------------------------------------------------------------\n// Per-graph-file write lock (gotcha #40 promise-chain pattern).\n//\n// Both the append path (`appendEdge`) and the rewrite path used by the\n// decay maintenance job must serialize on the same lock keyed by the\n// JSONL file path. Without this, an extraction can append a new edge\n// between the decay job's read-snapshot and rewrite, silently dropping\n// the appended edge during active traffic (issue #729 / Codex P1).\n// ---------------------------------------------------------------------------\nconst graphWriteLocks = new Map<string, Promise<void>>();\n\n/**\n * Run `fn` while holding the write lock for the given graph JSONL file.\n *\n * The lock is keyed by absolute file path so concurrent writes to\n * different graph types proceed independently. The chain recovers from\n * rejection (gotcha #40) so a single I/O failure does not poison all\n * future writers, but the original error is still surfaced to the\n * caller of `withGraphWriteLock`.\n */\nexport function withGraphWriteLock<T>(filePath: string, fn: () => Promise<T>): Promise<T> {\n const prev = graphWriteLocks.get(filePath) ?? Promise.resolve();\n const next = prev.then(fn, fn);\n graphWriteLocks.set(\n filePath,\n next.then(\n () => undefined,\n () => undefined\n )\n );\n return next;\n}\n\nexport async function appendEdge(memoryDir: string, edge: GraphEdge): Promise<void> {\n await ensureGraphsDir(memoryDir);\n const filePath = graphFilePath(memoryDir, edge.type);\n const line = `${JSON.stringify(edge)}\\n`;\n await withGraphWriteLock(filePath, async () => {\n await appendFile(filePath, line, \"utf8\");\n });\n // Emit edge-added event for SSE subscribers (issue #691 PR 5/5).\n // Fail-open: emitGraphEvent catches listener errors so a bad SSE client\n // can never surface into the extraction pipeline.\n emitGraphEvent(memoryDir, \"edge-added\", {\n source: edge.from,\n target: edge.to,\n kind: edge.type,\n weight: edge.weight,\n label: edge.label,\n confidence: typeof edge.confidence === \"number\" ? edge.confidence : 1.0,\n });\n}\n\nfunction isNodeError(err: unknown): err is NodeJS.ErrnoException {\n return typeof err === \"object\" && err !== null && \"code\" in err;\n}\n\nfunction parseEdgesJsonl(raw: string, expectedType: GraphType): GraphEdge[] {\n const edges: GraphEdge[] = [];\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n try {\n const parsed = JSON.parse(trimmed) as unknown;\n if (isValidGraphEdge(parsed, expectedType)) {\n edges.push(parsed);\n }\n } catch {\n // skip corrupt lines — fail-open for partial JSONL recovery\n }\n }\n return edges;\n}\n\n/**\n * Read all edges of a given type from the JSONL file.\n * Returns [] if the file doesn't exist or any read error occurs (fail-open).\n *\n * Production traversal callers (recall/PageRank) depend on this fail-open\n * posture so a temporarily missing or unreadable graph file never blocks\n * a recall. Maintenance jobs that need to distinguish ENOENT from real\n * I/O failures must use {@link readEdgesStrict} instead.\n */\nexport async function readEdges(memoryDir: string, type: GraphType): Promise<GraphEdge[]> {\n const filePath = graphFilePath(memoryDir, type);\n try {\n const raw = await readFile(filePath, \"utf8\");\n return parseEdgesJsonl(raw, type);\n } catch {\n return [];\n }\n}\n\n/**\n * Same as {@link readEdges} but only swallows `ENOENT`; all other read\n * errors (`EACCES`, `EIO`, …) are propagated. Used by the graph-edge\n * decay maintenance job so I/O outages surface as a failed run instead\n * of being silently reported as \"no edges to decay\" (issue #729 /\n * Codex P1, line 120).\n */\nexport async function readEdgesStrict(memoryDir: string, type: GraphType): Promise<GraphEdge[]> {\n const filePath = graphFilePath(memoryDir, type);\n try {\n const raw = await readFile(filePath, \"utf8\");\n return parseEdgesJsonl(raw, type);\n } catch (err) {\n if (isNodeError(err) && err.code === \"ENOENT\") {\n return [];\n }\n throw err;\n }\n}\n\n/**\n * Read edges from all enabled graph types.\n */\nexport async function readAllEdges(\n memoryDir: string,\n config: Pick<GraphConfig, \"entityGraphEnabled\" | \"timeGraphEnabled\" | \"causalGraphEnabled\">\n): Promise<GraphEdge[]> {\n const parts: GraphEdge[][] = await Promise.all([\n config.entityGraphEnabled ? readEdges(memoryDir, \"entity\") : Promise.resolve([]),\n config.timeGraphEnabled ? readEdges(memoryDir, \"time\") : Promise.resolve([]),\n config.causalGraphEnabled ? readEdges(memoryDir, \"causal\") : Promise.resolve([]),\n ]);\n return parts.flat();\n}\n\nexport interface GraphHealthFileStats {\n type: GraphType;\n filePath: string;\n exists: boolean;\n totalLines: number;\n validEdges: number;\n corruptLines: number;\n uniqueNodes: number;\n}\n\nexport interface GraphHealthReport {\n generatedAt: string;\n enabledTypes: GraphType[];\n totals: {\n totalLines: number;\n validEdges: number;\n corruptLines: number;\n uniqueNodes: number;\n };\n files: GraphHealthFileStats[];\n repairGuidance?: string[];\n}\n\nfunction isValidGraphEdge(raw: unknown, expectedType: GraphType): raw is GraphEdge {\n if (!raw || typeof raw !== \"object\") return false;\n const edge = raw as Record<string, unknown>;\n return (\n edge.type === expectedType &&\n typeof edge.from === \"string\" &&\n edge.from.length > 0 &&\n typeof edge.to === \"string\" &&\n edge.to.length > 0 &&\n typeof edge.weight === \"number\" &&\n Number.isFinite(edge.weight) &&\n typeof edge.label === \"string\" &&\n typeof edge.ts === \"string\"\n );\n}\n\nexport async function analyzeGraphHealth(\n memoryDir: string,\n options?: {\n entityGraphEnabled?: boolean;\n timeGraphEnabled?: boolean;\n causalGraphEnabled?: boolean;\n includeRepairGuidance?: boolean;\n }\n): Promise<GraphHealthReport> {\n const enabledTypes: GraphType[] = [];\n if (options?.entityGraphEnabled !== false) enabledTypes.push(\"entity\");\n if (options?.timeGraphEnabled !== false) enabledTypes.push(\"time\");\n if (options?.causalGraphEnabled !== false) enabledTypes.push(\"causal\");\n\n const files: GraphHealthFileStats[] = [];\n const globalNodes = new Set<string>();\n\n for (const type of enabledTypes) {\n const filePath = graphFilePath(memoryDir, type);\n let exists = true;\n let totalLines = 0;\n let validEdges = 0;\n let corruptLines = 0;\n const nodes = new Set<string>();\n\n try {\n const raw = await readFile(filePath, \"utf8\");\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed) continue;\n totalLines += 1;\n try {\n const parsed = JSON.parse(trimmed) as unknown;\n if (!isValidGraphEdge(parsed, type)) {\n corruptLines += 1;\n continue;\n }\n validEdges += 1;\n nodes.add(parsed.from);\n nodes.add(parsed.to);\n globalNodes.add(parsed.from);\n globalNodes.add(parsed.to);\n } catch {\n corruptLines += 1;\n }\n }\n } catch {\n exists = false;\n }\n\n files.push({\n type,\n filePath,\n exists,\n totalLines,\n validEdges,\n corruptLines,\n uniqueNodes: nodes.size,\n });\n }\n\n const totals = files.reduce(\n (acc, item) => {\n acc.totalLines += item.totalLines;\n acc.validEdges += item.validEdges;\n acc.corruptLines += item.corruptLines;\n return acc;\n },\n {\n totalLines: 0,\n validEdges: 0,\n corruptLines: 0,\n uniqueNodes: globalNodes.size,\n }\n );\n totals.uniqueNodes = globalNodes.size;\n\n const report: GraphHealthReport = {\n generatedAt: new Date().toISOString(),\n enabledTypes,\n totals,\n files,\n };\n\n if (options?.includeRepairGuidance === true) {\n const guidance: string[] = [];\n if (totals.corruptLines > 0) {\n guidance.push(\n \"Corrupt graph lines detected: back up memory/state/graphs, then rebuild graphs from clean memory replay/extraction runs.\"\n );\n }\n if (totals.validEdges === 0) {\n guidance.push(\n \"No valid edges detected yet: run normal extraction traffic (or replay ingestion) to seed graph files.\"\n );\n }\n if (guidance.length > 0) report.repairGuidance = guidance;\n }\n\n return report;\n}\n\n/**\n * Detect causal signal phrases in text. Returns the first matched phrase, or null.\n */\nexport function detectCausalPhrase(text: string): string | null {\n const lower = text.toLowerCase();\n for (const phrase of CAUSAL_PHRASES) {\n if (lower.includes(phrase)) return phrase;\n }\n return null;\n}\n\n/**\n * GraphIndex — builds and updates the three memory graphs.\n *\n * Usage (orchestrator):\n * this.graphIndex = new GraphIndex(config.memoryDir, config);\n *\n * // After each memory write:\n * await this.graphIndex.onMemoryWritten(memoryPath, frontmatter, threadId, recentInThread);\n */\nexport class GraphIndex {\n private readonly memoryDir: string;\n private readonly cfg: GraphConfig;\n\n // Cache for readAllEdges() result. With 30k+ entity edges (6 MB JSONL) the\n // file read + JSON parse takes 2-4 s per call. This instance-level cache\n // eliminates that overhead on every spreadingActivation() call; it is\n // invalidated (set to null) in onMemoryWritten() so new edges appear promptly.\n private edgeCache: { allEdges: GraphEdge[]; loadedAt: number } | null = null;\n private static readonly EDGE_CACHE_TTL_MS = 300_000; // 5 minutes\n\n constructor(memoryDir: string, cfg: GraphConfig) {\n this.memoryDir = memoryDir;\n this.cfg = cfg;\n }\n\n /** Clear the edge cache so the next spreadingActivation() re-reads from disk.\n * Call after any code path that appends edges outside of onMemoryWritten(). */\n invalidateEdgeCache(): void {\n this.edgeCache = null;\n }\n\n private async loadEdgesCached(): Promise<GraphEdge[]> {\n if (this.edgeCache && Date.now() - this.edgeCache.loadedAt < GraphIndex.EDGE_CACHE_TTL_MS) {\n return this.edgeCache.allEdges;\n }\n const allEdges = await readAllEdges(this.memoryDir, {\n entityGraphEnabled: this.cfg.entityGraphEnabled,\n timeGraphEnabled: this.cfg.timeGraphEnabled,\n causalGraphEnabled: this.cfg.causalGraphEnabled,\n });\n this.edgeCache = { allEdges, loadedAt: Date.now() };\n return allEdges;\n }\n\n /**\n * Called after a memory is written to disk.\n *\n * @param memoryPath - relative path from memoryDir (e.g. \"facts/2026-02-22/abc.md\")\n * @param entityRef - entityRef frontmatter field (if any)\n * @param content - full memory text (for causal detection)\n * @param created - ISO timestamp of this memory\n * @param threadId - current thread ID (for time graph)\n * @param recentInThread - paths of the N most-recent memories in this thread (for time graph)\n * @param entitySiblings - paths of other memories that share the same entityRef (for entity graph)\n */\n async onMemoryWritten(opts: {\n memoryPath: string;\n entityRef?: string;\n content: string;\n created: string;\n threadId?: string;\n recentInThread?: string[];\n entitySiblings?: string[];\n causalPredecessor?: string;\n /**\n * Optional frozen gate overrides (from GraphConstructionCapabilitySet).\n * When provided, these take precedence over `this.cfg` so the caller's\n * operation-scoped snapshot is the single source of truth (#1566).\n */\n graphCapsOverride?: {\n entityGraph: boolean;\n timeGraph: boolean;\n causalGraph: boolean;\n multiGraphMemory: boolean;\n };\n }): Promise<void> {\n const g = opts.graphCapsOverride;\n const multiGraphOn = g ? g.multiGraphMemory : this.cfg.multiGraphMemoryEnabled;\n if (!multiGraphOn) return;\n const entityOn = g ? g.entityGraph : this.cfg.entityGraphEnabled;\n const timeOn = g ? g.timeGraph : this.cfg.timeGraphEnabled;\n const causalOn = g ? g.causalGraph : this.cfg.causalGraphEnabled;\n const ts = new Date().toISOString();\n\n try {\n // Entity graph\n if (entityOn && opts.entityRef && opts.entitySiblings?.length) {\n const siblings = opts.entitySiblings.slice(0, this.cfg.maxEntityGraphEdgesPerMemory);\n for (const sibling of siblings) {\n await appendEdge(this.memoryDir, {\n from: opts.memoryPath,\n to: sibling,\n type: \"entity\",\n weight: 1.0,\n label: opts.entityRef,\n ts,\n });\n }\n }\n\n // Time graph — link to most recent memory in same thread\n if (timeOn && opts.threadId && opts.recentInThread?.length) {\n const predecessor = opts.recentInThread[opts.recentInThread.length - 1];\n if (predecessor && predecessor !== opts.memoryPath) {\n await appendEdge(this.memoryDir, {\n from: predecessor,\n to: opts.memoryPath,\n type: \"time\",\n weight: 1.0,\n label: opts.threadId,\n ts,\n });\n }\n }\n\n // Causal graph\n if (causalOn && opts.causalPredecessor) {\n const phrase = detectCausalPhrase(opts.content);\n if (phrase) {\n await appendEdge(this.memoryDir, {\n from: opts.causalPredecessor,\n to: opts.memoryPath,\n type: \"causal\",\n weight: 1.0,\n label: phrase,\n ts,\n });\n }\n }\n } catch (err) {\n // Fail-open: graph write errors must never surface to caller\n const { log } = await import(\"./logger.js\");\n log.warn(`[graph] onMemoryWritten error: ${err}`);\n } finally {\n // Invalidate edge cache so spreadingActivation() picks up new edges.\n // In `finally` so the cache is cleared even on partial write failure.\n this.edgeCache = null;\n }\n }\n\n /**\n * Spreading activation BFS (SYNAPSE-inspired).\n *\n * Starting from `seeds`, traverse the combined graph for up to `maxSteps` hops.\n * Each candidate gets an activation score = edge.weight × edgeConfidence × decay^hop.\n *\n * Issue #681 PR 3/3 — confidence-aware traversal:\n * - Each edge's `weight` is multiplied by its `confidence` (legacy edges\n * missing `confidence` are treated as 1.0, preserving prior behavior).\n * - Edges with `confidence < graphTraversalConfidenceFloor` are pruned and\n * contribute neither activation nor downstream neighbors.\n * - When `graphTraversalPageRankIterations > 0`, an additional PageRank-\n * style refinement pass redistributes activation along confidence-weighted\n * edges, sharpening the ranking among multi-hop candidates.\n * - Per-result provenance includes the highest-confidence edge that landed\n * on each candidate, so the X-ray surface can attribute pruning and\n * ranking decisions back to specific edges.\n *\n * @param seeds - initial memory paths to expand from (e.g. QMD top results)\n * @param maxSteps - max BFS hops (from config: maxGraphTraversalSteps)\n * @returns Array of {path, score, edgeConfidence, ...} sorted descending, not including seed paths\n */\n async spreadingActivation(\n seeds: string[],\n maxSteps?: number,\n opts?: {\n /**\n * Issue #681 — when `true`, bypasses the configured\n * `graphTraversalConfidenceFloor` and includes low-confidence\n * edges in traversal. Equivalent to forcing the floor to `0`.\n * Default `false` (floor from config is applied).\n */\n includeLowConfidence?: boolean;\n /** Absolute deadline in ms-since-epoch for post-retrieval assembly. */\n deadlineAtMs?: number;\n }\n ): Promise<\n Array<{\n path: string;\n score: number;\n seed: string;\n hopDepth: number;\n decayedWeight: number;\n graphType: \"entity\" | \"time\" | \"causal\";\n /**\n * Confidence of the edge that produced this candidate's recorded\n * provenance (the strongest edge along the chosen entry path).\n * In `[0, 1]`. Legacy edges without `confidence` surface as 1.0.\n */\n edgeConfidence: number;\n }>\n > {\n if (!this.cfg.multiGraphMemoryEnabled) return [];\n const steps = maxSteps ?? this.cfg.maxGraphTraversalSteps;\n const decay = this.cfg.graphActivationDecay;\n // When `includeLowConfidence` is set, use floor=0 so all edges\n // participate in traversal regardless of their decay state.\n // Otherwise clamp the configured floor into [0, 1] so misconfiguration\n // cannot (a) admit edges with negative confidence or (b) reject every\n // edge.\n const floor =\n opts?.includeLowConfidence === true ? 0 : clampConfidenceFloor(this.cfg.graphTraversalConfidenceFloor);\n const iterations = clampPageRankIterations(this.cfg.graphTraversalPageRankIterations);\n const deadlineAtMs = opts?.deadlineAtMs;\n const deadlineExpired = (): boolean =>\n typeof deadlineAtMs === \"number\" && Date.now() >= deadlineAtMs;\n\n try {\n if (deadlineExpired()) return [];\n const allEdges = await this.loadEdgesCached();\n if (deadlineExpired()) return [];\n\n // Build adjacency index: from → edges, to → edges (bidirectional for entity/time, directional for causal).\n // Edges below the confidence floor are pruned at index time so neither\n // direct activation nor downstream BFS expansion can re-introduce them.\n const adj = new Map<string, GraphEdge[]>();\n for (let i = 0; i < allEdges.length; i += 1) {\n if ((i & 1023) === 0 && deadlineExpired()) return [];\n const edge = allEdges[i];\n const conf = readEdgeConfidence(edge);\n if (conf < floor) continue;\n if (!adj.has(edge.from)) adj.set(edge.from, []);\n adj.get(edge.from)!.push(edge);\n // Entity and time edges are bidirectional\n if (edge.type !== \"causal\") {\n if (!adj.has(edge.to)) adj.set(edge.to, []);\n adj.get(edge.to)!.push({ ...edge, from: edge.to, to: edge.from });\n }\n }\n\n const seedSet = new Set(seeds);\n const scores = new Map<string, number>(); // candidate path → accumulated activation score\n const provenance = new Map<\n string,\n {\n seed: string;\n hopDepth: number;\n decayedWeight: number;\n graphType: \"entity\" | \"time\" | \"causal\";\n edgeConfidence: number;\n }\n >();\n let frontier = new Map<string, { node: string; seed: string; activation: number }>();\n const reachedBySeed = new Map<string, Set<string>>();\n for (const seed of seeds) {\n frontier.set(`${seed}\\0${seed}`, { node: seed, seed, activation: 1 });\n reachedBySeed.set(seed, new Set([seed]));\n }\n const finalizeScores = () =>\n Array.from(scores.entries())\n .map(([p, score]) => ({\n path: p,\n score,\n seed: provenance.get(p)?.seed ?? \"\",\n hopDepth: provenance.get(p)?.hopDepth ?? 0,\n decayedWeight: provenance.get(p)?.decayedWeight ?? 0,\n graphType: provenance.get(p)?.graphType ?? \"entity\",\n edgeConfidence: provenance.get(p)?.edgeConfidence ?? 1,\n }))\n .sort((a, b) => b.score - a.score);\n\n for (let hop = 0; hop < steps && frontier.size > 0; hop++) {\n if (deadlineExpired()) return finalizeScores();\n const nextFrontier = new Map<string, { node: string; seed: string; activation: number }>();\n\n for (const { node, seed: sourceSeed, activation } of frontier.values()) {\n const edges = adj.get(node) ?? [];\n for (let i = 0; i < edges.length; i += 1) {\n if ((i & 1023) === 0 && deadlineExpired()) return finalizeScores();\n const edge = edges[i];\n const neighbor = edge.to === node ? edge.from : edge.to;\n const conf = readEdgeConfidence(edge);\n // Defense in depth: the adjacency build already drops sub-floor\n // edges, but if a synthesized reverse edge ever bypassed that\n // path, this guard keeps spreading activation honest.\n if (conf < floor) continue;\n const score = activation * edge.weight * conf * decay;\n const reachedForSeed = reachedBySeed.get(sourceSeed);\n if (reachedForSeed?.has(neighbor)) {\n continue;\n }\n\n if (!seedSet.has(neighbor)) {\n const existing = scores.get(neighbor) ?? 0;\n scores.set(neighbor, existing + score);\n\n const prev = provenance.get(neighbor);\n if (!prev || hop + 1 < prev.hopDepth || (hop + 1 === prev.hopDepth && score > prev.decayedWeight)) {\n provenance.set(neighbor, {\n seed: sourceSeed,\n hopDepth: hop + 1,\n decayedWeight: score,\n graphType: edge.type,\n edgeConfidence: conf,\n });\n }\n\n if (hop + 1 < steps) {\n const frontierKey = `${sourceSeed}\\0${neighbor}`;\n const existingFrontier = nextFrontier.get(frontierKey);\n if (existingFrontier) {\n existingFrontier.activation += score;\n } else {\n nextFrontier.set(frontierKey, {\n node: neighbor,\n seed: sourceSeed,\n activation: score,\n });\n }\n }\n }\n }\n }\n\n for (const { node, seed } of nextFrontier.values()) {\n reachedBySeed.get(seed)?.add(node);\n }\n frontier = nextFrontier;\n }\n\n // Issue #681 PR 3/3 — optional PageRank-style refinement.\n // Redistributes a node's accumulated activation along its outgoing\n // edges, weighted by edge confidence. Damping is fixed at the\n // canonical 0.85 so the ranking stays comparable across queries;\n // the `iterations` knob bounds compute, not behavior shape.\n if (!deadlineExpired() && iterations > 0 && scores.size > 1) {\n applyPageRankRefinement(scores, adj, {\n iterations,\n floor,\n damping: 0.85,\n deadlineAtMs,\n });\n }\n\n // Apply lateral inhibition if enabled (Synapse-inspired competitive suppression)\n if (deadlineExpired()) return finalizeScores();\n if (this.cfg.graphLateralInhibitionEnabled && scores.size > 1) {\n const inhibited = applyLateralInhibition(scores, {\n beta: this.cfg.graphLateralInhibitionBeta,\n topM: this.cfg.graphLateralInhibitionTopM,\n });\n for (const [k, v] of inhibited) {\n scores.set(k, v);\n }\n }\n\n return finalizeScores();\n } catch (err) {\n const { log } = await import(\"./logger.js\");\n log.warn(`[graph] spreadingActivation error: ${err}`);\n return [];\n }\n }\n}\n\n/**\n * Clamp `graphTraversalConfidenceFloor` into the legal range `[0, 1]`.\n * Non-finite or non-numeric values fall back to the documented default\n * so misconfiguration cannot silently disable the floor or reject every edge.\n *\n * Exported for tests; call sites in `spreadingActivation` use it to make\n * the contract explicit at every boundary.\n */\nexport function clampConfidenceFloor(raw: unknown): number {\n if (typeof raw !== \"number\" || !Number.isFinite(raw)) {\n return DEFAULT_GRAPH_TRAVERSAL_CONFIDENCE_FLOOR;\n }\n if (raw < 0) return 0;\n if (raw > 1) return 1;\n return raw;\n}\n\n/**\n * Clamp `graphTraversalPageRankIterations` into a non-negative integer.\n * Negative or non-finite values fall back to 0 (disable refinement) so\n * misconfiguration cannot stall recall in an unbounded loop.\n */\nexport function clampPageRankIterations(raw: unknown): number {\n if (typeof raw !== \"number\" || !Number.isFinite(raw)) return 0;\n if (raw <= 0) return 0;\n return Math.floor(raw);\n}\n\n/**\n * PageRank-style refinement on top of the BFS activation map.\n *\n * Each iteration redistributes a fraction of every node's score along\n * its outgoing edges, scaled by edge confidence. Confidence below\n * `floor` is filtered out before redistribution, mirroring the BFS\n * pruning rule. Mutates `scores` in place.\n *\n * Exported for tests; in production, call sites pass the same adjacency\n * map already used by BFS so behavior stays consistent.\n */\nexport function applyPageRankRefinement(\n scores: Map<string, number>,\n adj: Map<string, GraphEdge[]>,\n opts: { iterations: number; floor: number; damping: number; deadlineAtMs?: number }\n): void {\n const { iterations, floor, damping, deadlineAtMs } = opts;\n if (iterations <= 0 || scores.size === 0) return;\n const safeDamping = Math.min(1, Math.max(0, damping));\n const deadlineExpired = (): boolean =>\n typeof deadlineAtMs === \"number\" && Date.now() >= deadlineAtMs;\n\n // Pre-compute confidence-weighted out-edge totals for normalization.\n // Done once per refinement, not per iteration, since adjacency is\n // immutable inside the loop.\n //\n // Codex P1 (#735): the denominator MUST be computed over the same\n // eligible-neighbor set the iteration redistributes into — i.e.\n // edges whose neighbor is in `scores`. Counting edges-to-seeds (or\n // edges-to-unseen-nodes) in the denominator while dropping their\n // flow during iteration leaks `safeDamping × score` every pass and\n // collapses leaf candidates' scores instead of just re-ranking them.\n const eligible = (edge: GraphEdge, fromNode: string): boolean => {\n if (readEdgeConfidence(edge) < floor) return false;\n const neighbor = edge.to === fromNode ? edge.from : edge.to;\n return scores.has(neighbor);\n };\n const outboundTotal = new Map<string, number>();\n for (const [node, edges] of adj.entries()) {\n if (deadlineExpired()) return;\n if (!scores.has(node)) continue; // only candidate nodes redistribute\n let sum = 0;\n for (const edge of edges) {\n if (!eligible(edge, node)) continue;\n sum += readEdgeConfidence(edge) * edge.weight;\n }\n if (sum > 0) outboundTotal.set(node, sum);\n }\n\n for (let i = 0; i < iterations; i += 1) {\n if (deadlineExpired()) return;\n const next = new Map<string, number>();\n // Teleport / damping floor: every node retains `(1 - damping) * score`\n // of its current activation so dangling nodes do not bleed to zero.\n for (const [node, score] of scores) {\n next.set(node, (1 - safeDamping) * score);\n }\n for (const [node, score] of scores) {\n const outEdges = adj.get(node);\n const total = outboundTotal.get(node);\n // Dangling-node fallback: when a candidate has zero eligible\n // outflow (no in-scores neighbors above the floor), the\n // `safeDamping × score` portion would otherwise evaporate. Keep\n // it on `node` so total mass is conserved and the score reflects\n // the candidate's standing rather than its in-degree topology.\n if (!outEdges || outEdges.length === 0 || !total || total <= 0) {\n next.set(node, (next.get(node) ?? 0) + safeDamping * score);\n continue;\n }\n for (let edgeIndex = 0; edgeIndex < outEdges.length; edgeIndex += 1) {\n if ((edgeIndex & 1023) === 0 && deadlineExpired()) return;\n const edge = outEdges[edgeIndex];\n if (!eligible(edge, node)) continue;\n const conf = readEdgeConfidence(edge);\n const neighbor = edge.to === node ? edge.from : edge.to;\n const flow = safeDamping * score * ((conf * edge.weight) / total);\n next.set(neighbor, (next.get(neighbor) ?? 0) + flow);\n }\n }\n for (const [node, score] of next) {\n scores.set(node, score);\n }\n }\n}\n\n/**\n * Lateral inhibition (Synapse-inspired).\n *\n * For each node, the top-M higher-activation competitors exert inhibition\n * proportional to their activation difference. Output is clamped to [0, ∞).\n *\n * No sigmoid is applied here — downstream `normalizeGraphActivationScore`\n * already applies x/(1+x) soft squash, so adding a sigmoid would double-\n * normalize and cap graph influence at ~50%.\n *\n * Formula: u_hat_i = max(0, u_i - beta * sum_{k in top-M where u_k > u_i}(u_k - u_i))\n *\n * When beta=0 or topM=0, returns original scores unchanged (no-op).\n */\nexport function applyLateralInhibition(\n scores: Map<string, number>,\n opts: { beta: number; topM: number }\n): Map<string, number> {\n const { beta, topM } = opts;\n if (beta === 0 || topM === 0) return new Map(scores);\n\n const sorted = Array.from(scores.entries()).sort((a, b) => b[1] - a[1]);\n const topCompetitors = sorted.slice(0, topM);\n\n const result = new Map<string, number>();\n for (const [node, u] of scores) {\n let inhibition = 0;\n for (const [, uK] of topCompetitors) {\n if (uK > u) {\n inhibition += uK - u;\n }\n }\n result.set(node, Math.max(0, u - beta * inhibition));\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;AAYA,SAAS,YAAY,OAAO,gBAAgB;AAC5C,YAAY,UAAU;AAkDf,IAAM,2CAA2C;AAEjD,IAAM,8CAA8C;AAGpD,IAAM,iBAAiB,CAAC,eAAe,UAAU,cAAc,aAAa,UAAU,SAAS;AAE/F,SAAS,UAAU,WAA2B;AACnD,SAAY,UAAK,WAAW,SAAS,QAAQ;AAC/C;AAEO,SAAS,cAAc,WAAmB,MAAyB;AACxE,SAAY,UAAK,UAAU,SAAS,GAAG,GAAG,IAAI,QAAQ;AACxD;AAEA,eAAsB,gBAAgB,WAAkC;AACtE,QAAM,MAAM,UAAU,SAAS,GAAG,EAAE,WAAW,KAAK,CAAC;AACvD;AAWA,IAAM,kBAAkB,oBAAI,IAA2B;AAWhD,SAAS,mBAAsB,UAAkB,IAAkC;AACxF,QAAM,OAAO,gBAAgB,IAAI,QAAQ,KAAK,QAAQ,QAAQ;AAC9D,QAAM,OAAO,KAAK,KAAK,IAAI,EAAE;AAC7B,kBAAgB;AAAA,IACd;AAAA,IACA,KAAK;AAAA,MACH,MAAM;AAAA,MACN,MAAM;AAAA,IACR;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,WAAW,WAAmB,MAAgC;AAClF,QAAM,gBAAgB,SAAS;A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;AAAA,MACrD;AAAA,IACF;AACA,eAAW,CAAC,MAAM,KAAK,KAAK,MAAM;AAChC,aAAO,IAAI,MAAM,KAAK;AAAA,IACxB;AAAA,EACF;AACF;AAgBO,SAAS,uBACd,QACA,MACqB;AACrB,QAAM,EAAE,MAAM,KAAK,IAAI;AACvB,MAAI,SAAS,KAAK,SAAS,EAAG,QAAO,IAAI,IAAI,MAAM;AAEnD,QAAM,SAAS,MAAM,KAAK,OAAO,QAAQ,CAAC,EAAE,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AACtE,QAAM,iBAAiB,OAAO,MAAM,GAAG,IAAI;AAE3C,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,CAAC,MAAM,CAAC,KAAK,QAAQ;AAC9B,QAAI,aAAa;AACjB,eAAW,CAAC,EAAE,EAAE,KAAK,gBAAgB;AACnC,UAAI,KAAK,GAAG;AACV,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AACA,WAAO,IAAI,MAAM,KAAK,IAAI,GAAG,IAAI,OAAO,UAAU,CAAC;AAAA,EACrD;AAEA,SAAO;AACT;","names":[]}
@@ -70,7 +70,7 @@ import {
70
70
  } from "./chunk-6HMYUWXR.js";
71
71
  import {
72
72
  buildGraphSnapshot
73
- } from "./chunk-NE566K4E.js";
73
+ } from "./chunk-YXWAILM4.js";
74
74
  import {
75
75
  wrapWorkLayerContext
76
76
  } from "./chunk-EI6V5UXY.js";
@@ -122,7 +122,7 @@ import {
122
122
  import {
123
123
  filterTrajectoriesByLookbackDays,
124
124
  readCausalTrajectoryRecords
125
- } from "./chunk-WXGTC424.js";
125
+ } from "./chunk-RC3AFF6Z.js";
126
126
  import {
127
127
  canReadNamespace,
128
128
  canWriteNamespace,
@@ -5579,4 +5579,4 @@ export {
5579
5579
  shapeMemorySummary,
5580
5580
  EngramAccessService
5581
5581
  };
5582
- //# sourceMappingURL=chunk-CZMLLVU2.js.map
5582
+ //# sourceMappingURL=chunk-4PPMUNV5.js.map