@remnic/core 1.1.0 → 1.1.1

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 (287) hide show
  1. package/dist/access-audit.d.ts +56 -0
  2. package/dist/access-audit.js +9 -0
  3. package/dist/access-cli.js +62 -45
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +16 -9
  6. package/dist/access-http.js +25 -17
  7. package/dist/access-mcp.d.ts +16 -9
  8. package/dist/access-mcp.js +29 -7
  9. package/dist/access-schema.d.ts +124 -33
  10. package/dist/access-schema.js +5 -1
  11. package/dist/{access-service-HmO1Trrx.d.ts → access-service-Br8ZydTK.d.ts} +158 -63
  12. package/dist/access-service.d.ts +13 -6
  13. package/dist/access-service.js +22 -14
  14. package/dist/bootstrap.d.ts +6 -3
  15. package/dist/briefing.d.ts +1 -0
  16. package/dist/briefing.js +7 -6
  17. package/dist/buffer-surprise-report.d.ts +70 -0
  18. package/dist/buffer-surprise-report.js +7 -0
  19. package/dist/buffer-surprise-report.js.map +1 -0
  20. package/dist/buffer-surprise.d.ts +98 -0
  21. package/dist/buffer-surprise.js +11 -0
  22. package/dist/buffer-surprise.js.map +1 -0
  23. package/dist/buffer.d.ts +100 -2
  24. package/dist/buffer.js +1 -1
  25. package/dist/calibration.js +5 -5
  26. package/dist/causal-behavior.js +4 -4
  27. package/dist/causal-chain.js +2 -2
  28. package/dist/causal-consolidation.js +17 -16
  29. package/dist/causal-consolidation.js.map +1 -1
  30. package/dist/causal-retrieval.js +4 -4
  31. package/dist/causal-trajectory.js +1 -1
  32. package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
  33. package/dist/chunk-2LGMW3DJ.js.map +1 -0
  34. package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
  35. package/dist/chunk-3FPTCC3Z.js.map +1 -0
  36. package/dist/chunk-3GPTTA4J.js +57 -0
  37. package/dist/chunk-3GPTTA4J.js.map +1 -0
  38. package/dist/{chunk-44ICJRF3.js → chunk-3GXCSUXR.js} +4 -4
  39. package/dist/{chunk-ITRLGI2T.js → chunk-3OGMS3PE.js} +2 -2
  40. package/dist/chunk-54V4BZWP.js +139 -0
  41. package/dist/chunk-54V4BZWP.js.map +1 -0
  42. package/dist/chunk-5JRF2PZA.js +67 -0
  43. package/dist/chunk-5JRF2PZA.js.map +1 -0
  44. package/dist/chunk-64NJRYU2.js +332 -0
  45. package/dist/chunk-64NJRYU2.js.map +1 -0
  46. package/dist/{chunk-OIT5QGG4.js → chunk-6AUUAZEX.js} +72 -2
  47. package/dist/chunk-6AUUAZEX.js.map +1 -0
  48. package/dist/{chunk-ZVBB3T7V.js → chunk-7I7FKFZH.js} +24 -22
  49. package/dist/chunk-7I7FKFZH.js.map +1 -0
  50. package/dist/chunk-AJU4PJGY.js +126 -0
  51. package/dist/chunk-AJU4PJGY.js.map +1 -0
  52. package/dist/chunk-ASAITVLA.js +64 -0
  53. package/dist/chunk-ASAITVLA.js.map +1 -0
  54. package/dist/{chunk-3QHL5ABG.js → chunk-B5WXLVDY.js} +187 -6
  55. package/dist/chunk-B5WXLVDY.js.map +1 -0
  56. package/dist/{chunk-SYUK3VLY.js → chunk-BGJGXLZ7.js} +111 -2
  57. package/dist/{chunk-SYUK3VLY.js.map → chunk-BGJGXLZ7.js.map} +1 -1
  58. package/dist/{chunk-MBJHSA7F.js → chunk-BK2EFTE2.js} +258 -13
  59. package/dist/chunk-BK2EFTE2.js.map +1 -0
  60. package/dist/chunk-C4SQJZAF.js +486 -0
  61. package/dist/chunk-C4SQJZAF.js.map +1 -0
  62. package/dist/{chunk-6UJ47TVX.js → chunk-CUPFXL3J.js} +2 -2
  63. package/dist/chunk-DF3RVK3X.js +119 -0
  64. package/dist/chunk-DF3RVK3X.js.map +1 -0
  65. package/dist/{chunk-37UIFYWO.js → chunk-DFTTJYSO.js} +108 -9
  66. package/dist/chunk-DFTTJYSO.js.map +1 -0
  67. package/dist/chunk-DGVM5SFL.js +69 -0
  68. package/dist/chunk-DGVM5SFL.js.map +1 -0
  69. package/dist/chunk-EIR5VLIH.js +90 -0
  70. package/dist/chunk-EIR5VLIH.js.map +1 -0
  71. package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
  72. package/dist/chunk-EPQJM2GC.js.map +1 -0
  73. package/dist/{chunk-GV6NLQ4X.js → chunk-F5VP6YCB.js} +374 -16
  74. package/dist/chunk-F5VP6YCB.js.map +1 -0
  75. package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
  76. package/dist/chunk-FAAFWE4G.js.map +1 -0
  77. package/dist/{chunk-7WQ6SLIE.js → chunk-FVA6TGI3.js} +2 -2
  78. package/dist/chunk-GDFS42HT.js +206 -0
  79. package/dist/chunk-GDFS42HT.js.map +1 -0
  80. package/dist/{chunk-MVTHXUBX.js → chunk-GKFXUTJ2.js} +479 -20
  81. package/dist/chunk-GKFXUTJ2.js.map +1 -0
  82. package/dist/{chunk-NQEVYWX6.js → chunk-HK3FGIEW.js} +209 -5
  83. package/dist/chunk-HK3FGIEW.js.map +1 -0
  84. package/dist/chunk-IISBCCWR.js +52 -0
  85. package/dist/chunk-IISBCCWR.js.map +1 -0
  86. package/dist/{chunk-WBSAYXVI.js → chunk-INXV5JBT.js} +198 -42
  87. package/dist/chunk-INXV5JBT.js.map +1 -0
  88. package/dist/chunk-JBMSGZEQ.js +441 -0
  89. package/dist/chunk-JBMSGZEQ.js.map +1 -0
  90. package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
  91. package/dist/chunk-JXS5PDQ7.js.map +1 -0
  92. package/dist/{chunk-6LX5ORAS.js → chunk-KUB6JU6H.js} +4 -4
  93. package/dist/chunk-KVBLZUKV.js +173 -0
  94. package/dist/chunk-KVBLZUKV.js.map +1 -0
  95. package/dist/chunk-LBLXEFWK.js +51 -0
  96. package/dist/chunk-LBLXEFWK.js.map +1 -0
  97. package/dist/{chunk-3WHVNEN7.js → chunk-LTCGGW2D.js} +1 -1
  98. package/dist/chunk-LTCGGW2D.js.map +1 -0
  99. package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
  100. package/dist/chunk-NZLQTHS5.js.map +1 -0
  101. package/dist/chunk-PVPWZSSI.js +37 -0
  102. package/dist/chunk-PVPWZSSI.js.map +1 -0
  103. package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
  104. package/dist/chunk-RFYAYKTD.js +146 -0
  105. package/dist/chunk-RFYAYKTD.js.map +1 -0
  106. package/dist/{chunk-DHHP2Z4X.js → chunk-RGLL5SPU.js} +2 -2
  107. package/dist/{chunk-3SV6CQHO.js → chunk-S3EEFKNY.js} +101 -65
  108. package/dist/chunk-S3EEFKNY.js.map +1 -0
  109. package/dist/chunk-SOBJ6NEY.js +18 -0
  110. package/dist/chunk-SOBJ6NEY.js.map +1 -0
  111. package/dist/{chunk-JIU55F3X.js → chunk-SPI27QT6.js} +2 -2
  112. package/dist/chunk-TVVEYCNW.js +65 -0
  113. package/dist/chunk-TVVEYCNW.js.map +1 -0
  114. package/dist/chunk-ULYOGL6R.js +322 -0
  115. package/dist/chunk-ULYOGL6R.js.map +1 -0
  116. package/dist/{chunk-47UU5PU2.js → chunk-VBVG2M5G.js} +18 -3
  117. package/dist/chunk-VBVG2M5G.js.map +1 -0
  118. package/dist/{chunk-7ECD5ATE.js → chunk-VDX363PS.js} +2 -2
  119. package/dist/{chunk-DEPL3635.js → chunk-VYM3VWOF.js} +1432 -188
  120. package/dist/chunk-VYM3VWOF.js.map +1 -0
  121. package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
  122. package/dist/chunk-WCLICCGB.js.map +1 -0
  123. package/dist/{chunk-4LACOVZX.js → chunk-WVVA7F5A.js} +2 -2
  124. package/dist/chunk-X6GF3FX2.js +26 -0
  125. package/dist/chunk-X6GF3FX2.js.map +1 -0
  126. package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
  127. package/dist/{chunk-BLKTA7MM.js → chunk-YNQKWQT4.js} +50 -17
  128. package/dist/chunk-YNQKWQT4.js.map +1 -0
  129. package/dist/chunk-ZAIM4TUE.js +488 -0
  130. package/dist/chunk-ZAIM4TUE.js.map +1 -0
  131. package/dist/{chunk-N42IWANG.js → chunk-ZEM3OK2K.js} +2 -2
  132. package/dist/chunk-ZZTOURJI.js +91 -0
  133. package/dist/chunk-ZZTOURJI.js.map +1 -0
  134. package/dist/{cli-BneVIEvh.d.ts → cli-BkeRaYfk.d.ts} +2 -2
  135. package/dist/cli.d.ts +13 -6
  136. package/dist/cli.js +40 -29
  137. package/dist/config.js +1 -1
  138. package/dist/consolidation-operator.d.ts +41 -0
  139. package/dist/consolidation-operator.js +11 -0
  140. package/dist/consolidation-operator.js.map +1 -0
  141. package/dist/consolidation-provenance-check.d.ts +68 -0
  142. package/dist/consolidation-provenance-check.js +9 -0
  143. package/dist/consolidation-provenance-check.js.map +1 -0
  144. package/dist/consolidation-undo.d.ts +123 -0
  145. package/dist/consolidation-undo.js +426 -0
  146. package/dist/consolidation-undo.js.map +1 -0
  147. package/dist/{contradiction-scan-GR33PONM.js → contradiction-scan-E3GJTI4F.js} +43 -7
  148. package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
  149. package/dist/cross-namespace-budget.d.ts +133 -0
  150. package/dist/cross-namespace-budget.js +9 -0
  151. package/dist/cross-namespace-budget.js.map +1 -0
  152. package/dist/direct-answer-wiring.js +5 -70
  153. package/dist/direct-answer-wiring.js.map +1 -1
  154. package/dist/{engine-5TIQBYZR.js → engine-F3GOXGE5.js} +8 -7
  155. package/dist/engine-F3GOXGE5.js.map +1 -0
  156. package/dist/entity-retrieval.d.ts +1 -0
  157. package/dist/entity-retrieval.js +7 -6
  158. package/dist/explicit-capture.d.ts +6 -3
  159. package/dist/explicit-capture.js +2 -2
  160. package/dist/extraction-judge-telemetry.d.ts +113 -0
  161. package/dist/extraction-judge-telemetry.js +14 -0
  162. package/dist/extraction-judge-telemetry.js.map +1 -0
  163. package/dist/extraction-judge-training.d.ts +85 -0
  164. package/dist/extraction-judge-training.js +16 -0
  165. package/dist/extraction-judge-training.js.map +1 -0
  166. package/dist/extraction-judge.d.ts +124 -2
  167. package/dist/extraction-judge.js +11 -1
  168. package/dist/extraction.js +6 -5
  169. package/dist/fallback-llm.js +2 -2
  170. package/dist/graph-recall.d.ts +100 -0
  171. package/dist/graph-recall.js +8 -0
  172. package/dist/graph-recall.js.map +1 -0
  173. package/dist/graph-retrieval.d.ts +271 -0
  174. package/dist/graph-retrieval.js +21 -0
  175. package/dist/graph-retrieval.js.map +1 -0
  176. package/dist/importance.js +1 -1
  177. package/dist/index.d.ts +585 -20
  178. package/dist/index.js +503 -312
  179. package/dist/index.js.map +1 -1
  180. package/dist/memory-worth-bench.d.ts +51 -0
  181. package/dist/memory-worth-bench.js +131 -0
  182. package/dist/memory-worth-bench.js.map +1 -0
  183. package/dist/memory-worth-filter.d.ts +128 -0
  184. package/dist/memory-worth-filter.js +10 -0
  185. package/dist/memory-worth-filter.js.map +1 -0
  186. package/dist/memory-worth-outcomes.d.ts +118 -0
  187. package/dist/memory-worth-outcomes.js +9 -0
  188. package/dist/memory-worth-outcomes.js.map +1 -0
  189. package/dist/memory-worth.d.ts +102 -0
  190. package/dist/memory-worth.js +7 -0
  191. package/dist/memory-worth.js.map +1 -0
  192. package/dist/operator-toolkit.d.ts +40 -1
  193. package/dist/operator-toolkit.js +23 -14
  194. package/dist/{orchestrator-DRYA6_lW.d.ts → orchestrator-CmJ-NTdJ.d.ts} +233 -8
  195. package/dist/orchestrator.d.ts +6 -3
  196. package/dist/orchestrator.js +49 -39
  197. package/dist/page-versioning.d.ts +12 -1
  198. package/dist/page-versioning.js +5 -3
  199. package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
  200. package/dist/qmd-recall-cache.d.ts +1 -1
  201. package/dist/qmd.d.ts +5 -3
  202. package/dist/qmd.js +1 -1
  203. package/dist/reasoning-trace-recall.d.ts +90 -0
  204. package/dist/reasoning-trace-recall.js +13 -0
  205. package/dist/reasoning-trace-recall.js.map +1 -0
  206. package/dist/reasoning-trace-types.d.ts +54 -0
  207. package/dist/reasoning-trace-types.js +17 -0
  208. package/dist/reasoning-trace-types.js.map +1 -0
  209. package/dist/recall-audit-anomaly.d.ts +112 -0
  210. package/dist/recall-audit-anomaly.js +11 -0
  211. package/dist/recall-audit-anomaly.js.map +1 -0
  212. package/dist/recall-audit.js +5 -44
  213. package/dist/recall-audit.js.map +1 -1
  214. package/dist/recall-explain-renderer.d.ts +49 -0
  215. package/dist/recall-explain-renderer.js +18 -0
  216. package/dist/recall-explain-renderer.js.map +1 -0
  217. package/dist/recall-state.d.ts +12 -1
  218. package/dist/recall-state.js +1 -1
  219. package/dist/recall-xray-cli.d.ts +40 -0
  220. package/dist/recall-xray-cli.js +11 -0
  221. package/dist/recall-xray-cli.js.map +1 -0
  222. package/dist/recall-xray-renderer.d.ts +44 -0
  223. package/dist/recall-xray-renderer.js +18 -0
  224. package/dist/recall-xray-renderer.js.map +1 -0
  225. package/dist/recall-xray.d.ts +179 -0
  226. package/dist/recall-xray.js +13 -0
  227. package/dist/recall-xray.js.map +1 -0
  228. package/dist/resume-bundles.js +5 -5
  229. package/dist/retrieval-agents.d.ts +1 -1
  230. package/dist/retrieval-tiers.d.ts +17 -0
  231. package/dist/retrieval-tiers.js +9 -0
  232. package/dist/retrieval-tiers.js.map +1 -0
  233. package/dist/schemas.d.ts +287 -31
  234. package/dist/schemas.js +1 -1
  235. package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
  236. package/dist/semantic-consolidation.d.ts +2 -1
  237. package/dist/semantic-consolidation.js +21 -7
  238. package/dist/semantic-rule-promotion.js +7 -6
  239. package/dist/semantic-rule-verifier.js +7 -6
  240. package/dist/storage.d.ts +82 -1
  241. package/dist/storage.js +6 -5
  242. package/dist/summarizer.js +3 -3
  243. package/dist/temporal-supersession.d.ts +1 -0
  244. package/dist/tier-migration.d.ts +2 -1
  245. package/dist/types.d.ts +276 -2
  246. package/dist/types.js +1 -1
  247. package/dist/verified-recall.js +7 -6
  248. package/package.json +1 -1
  249. package/dist/chunk-37UIFYWO.js.map +0 -1
  250. package/dist/chunk-3QHL5ABG.js.map +0 -1
  251. package/dist/chunk-3SV6CQHO.js.map +0 -1
  252. package/dist/chunk-3WHVNEN7.js.map +0 -1
  253. package/dist/chunk-47UU5PU2.js.map +0 -1
  254. package/dist/chunk-6ZH4TU6I.js.map +0 -1
  255. package/dist/chunk-BLKTA7MM.js.map +0 -1
  256. package/dist/chunk-DEPL3635.js.map +0 -1
  257. package/dist/chunk-GV6NLQ4X.js.map +0 -1
  258. package/dist/chunk-J4IYOZZ5.js.map +0 -1
  259. package/dist/chunk-LAYN4LDC.js +0 -267
  260. package/dist/chunk-LAYN4LDC.js.map +0 -1
  261. package/dist/chunk-MBJHSA7F.js.map +0 -1
  262. package/dist/chunk-MTLYEMJB.js.map +0 -1
  263. package/dist/chunk-MVTHXUBX.js.map +0 -1
  264. package/dist/chunk-NQEVYWX6.js.map +0 -1
  265. package/dist/chunk-OIT5QGG4.js.map +0 -1
  266. package/dist/chunk-PAORGQRI.js.map +0 -1
  267. package/dist/chunk-QDYXG4CS.js.map +0 -1
  268. package/dist/chunk-QNJMBKFK.js.map +0 -1
  269. package/dist/chunk-UEYA6UC7.js.map +0 -1
  270. package/dist/chunk-UVJFDP7P.js +0 -202
  271. package/dist/chunk-UVJFDP7P.js.map +0 -1
  272. package/dist/chunk-WBSAYXVI.js.map +0 -1
  273. package/dist/chunk-ZVBB3T7V.js.map +0 -1
  274. package/dist/contradiction-scan-GR33PONM.js.map +0 -1
  275. /package/dist/{engine-5TIQBYZR.js.map → access-audit.js.map} +0 -0
  276. /package/dist/{chunk-44ICJRF3.js.map → chunk-3GXCSUXR.js.map} +0 -0
  277. /package/dist/{chunk-ITRLGI2T.js.map → chunk-3OGMS3PE.js.map} +0 -0
  278. /package/dist/{chunk-6UJ47TVX.js.map → chunk-CUPFXL3J.js.map} +0 -0
  279. /package/dist/{chunk-7WQ6SLIE.js.map → chunk-FVA6TGI3.js.map} +0 -0
  280. /package/dist/{chunk-6LX5ORAS.js.map → chunk-KUB6JU6H.js.map} +0 -0
  281. /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
  282. /package/dist/{chunk-DHHP2Z4X.js.map → chunk-RGLL5SPU.js.map} +0 -0
  283. /package/dist/{chunk-JIU55F3X.js.map → chunk-SPI27QT6.js.map} +0 -0
  284. /package/dist/{chunk-7ECD5ATE.js.map → chunk-VDX363PS.js.map} +0 -0
  285. /package/dist/{chunk-4LACOVZX.js.map → chunk-WVVA7F5A.js.map} +0 -0
  286. /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
  287. /package/dist/{chunk-N42IWANG.js.map → chunk-ZEM3OK2K.js.map} +0 -0
@@ -0,0 +1,271 @@
1
+ /**
2
+ * Graph-based retrieval types (issue #559, PR 1 of 5).
3
+ *
4
+ * This module defines the forward-looking type contract for Remnic's
5
+ * first-class retrieval graph (GAAMA / GAM inspired). It ships types
6
+ * and a no-op `queryGraph()` stub only — no behavior, no I/O, and
7
+ * no importers inside the codebase yet.
8
+ *
9
+ * Subsequent slices will land:
10
+ * - PR 2: Edge extraction from existing relationship facts + cross-memory
11
+ * entity references during indexing (writes `~/.remnic/graph.json`).
12
+ * - PR 3: Pure `personalizedPageRank()` implementation.
13
+ * - PR 4: Feature-flagged wiring into `retrieval.ts` behind
14
+ * `graphRetrievalEnabled` (default `false`).
15
+ * - PR 5: LoCoMo A/B bench harness + default flip decision.
16
+ *
17
+ * Keeping the node/edge type enums complete from PR 1 avoids type churn
18
+ * when later slices add reflection/concept node synthesis or additional
19
+ * edge semantics.
20
+ */
21
+ /**
22
+ * Kinds of nodes the retrieval graph can hold.
23
+ *
24
+ * - `memory`: a stored memory file (the primary retrieval target).
25
+ * - `entity`: a named entity referenced by one or more memories.
26
+ * - `episode`: a temporally-bounded interaction or session grouping.
27
+ * - `concept`: an abstract topic / idea (forward-looking; synthesis
28
+ * is out of scope for this issue, but the type is
29
+ * defined here to keep later slices additive).
30
+ * - `reflection`: an LLM-generated summary / meta-memory about other
31
+ * nodes (also forward-looking, same rationale).
32
+ */
33
+ type NodeType = "memory" | "entity" | "episode" | "concept" | "reflection";
34
+ /**
35
+ * Kinds of edges the retrieval graph can hold.
36
+ *
37
+ * Edges are directed. `from` → `to` semantics:
38
+ *
39
+ * - `references`: `from` contains an explicit reference to `to`
40
+ * (e.g., a memory referencing another memory).
41
+ * - `supersedes`: `from` supersedes `to` (newer memory replaces older).
42
+ * - `authored-by`: `from` was authored by the entity in `to`.
43
+ * - `mentions`: `from` mentions the entity/concept in `to` without
44
+ * a stronger relationship claim.
45
+ * - `derived-from`: `from` was derived from `to` (reflections,
46
+ * consolidations, summaries).
47
+ * - `temporal-next`: `from` immediately follows `to` in time (episodes).
48
+ * - `related-to`: generic weak relationship fallback for edges that
49
+ * do not fit a stronger type.
50
+ */
51
+ type EdgeType = "references" | "supersedes" | "authored-by" | "mentions" | "derived-from" | "temporal-next" | "related-to";
52
+ /**
53
+ * A single node in the retrieval graph.
54
+ *
55
+ * `id` is the caller-controlled stable identifier (typically a memory
56
+ * file path, entity slug, or episode id). `weight` is an optional prior
57
+ * importance score used as a starting bias during Personalized PageRank;
58
+ * it is intentionally optional because most nodes default to uniform
59
+ * priors.
60
+ *
61
+ * Named `RemnicGraphNode` (not `GraphNode`) to avoid colliding with the
62
+ * unrelated `GraphEdge` in `graph.ts`, which models Multi-Graph Memory
63
+ * (MAGMA/SYNAPSE) edges and is an incompatible shape.
64
+ */
65
+ interface RemnicGraphNode {
66
+ id: string;
67
+ type: NodeType;
68
+ weight?: number;
69
+ }
70
+ /**
71
+ * A directed edge between two nodes.
72
+ *
73
+ * `weight` is optional; when absent PPR implementations should treat
74
+ * the edge as weight `1`. We keep weight optional rather than defaulting
75
+ * at construction so producers can serialize a minimal edge shape.
76
+ *
77
+ * Named `RemnicGraphEdge` (not `GraphEdge`) to avoid colliding with the
78
+ * unrelated `GraphEdge` in `graph.ts` (Multi-Graph Memory).
79
+ */
80
+ interface RemnicGraphEdge {
81
+ from: string;
82
+ to: string;
83
+ type: EdgeType;
84
+ weight?: number;
85
+ }
86
+ /**
87
+ * The retrieval graph itself.
88
+ *
89
+ * Nodes are held in a `Map<string, RemnicGraphNode>` keyed by `id` so
90
+ * PPR lookups are O(1). Edges are kept as a flat array; adjacency
91
+ * indexing is a PR-3 concern (PPR will likely build a transient
92
+ * outgoing-adjacency map on demand).
93
+ */
94
+ interface RemnicGraph {
95
+ nodes: Map<string, RemnicGraphNode>;
96
+ edges: RemnicGraphEdge[];
97
+ }
98
+ /**
99
+ * Options for `queryGraph()`.
100
+ *
101
+ * Defaults (applied when undefined):
102
+ * - `damping`: 0.85 (standard PageRank value — higher values make the
103
+ * random walk follow edges longer before teleporting back
104
+ * to the seed distribution).
105
+ * - `iterations`: 20 (power-iteration cap).
106
+ * - `tolerance`: 1e-6 (L1 convergence threshold; iteration stops early
107
+ * when the L1 norm of the delta between successive
108
+ * rank vectors falls below this).
109
+ * - `topK`: unbounded — all nodes with positive score are returned,
110
+ * ordered by descending score.
111
+ */
112
+ interface QueryGraphOptions {
113
+ /** Number of top-ranked nodes to return. Defaults to unbounded. */
114
+ topK?: number;
115
+ /**
116
+ * PPR damping factor in (0, 1). The probability of following an outgoing
117
+ * edge at each step (vs. teleporting back to the seed distribution).
118
+ * Defaults to 0.85.
119
+ */
120
+ damping?: number;
121
+ /** Maximum PPR iterations before falling back to current rank vector. */
122
+ iterations?: number;
123
+ /** L1 convergence threshold. Defaults to 1e-6. */
124
+ tolerance?: number;
125
+ /**
126
+ * Optional per-seed weights. Keys must appear in `seedIds` or (if empty)
127
+ * in the graph. Values must be non-negative. Weights are normalized so
128
+ * they sum to 1 before seeding. If omitted, seed mass is distributed
129
+ * uniformly across `seedIds`.
130
+ */
131
+ seedWeights?: ReadonlyMap<string, number> | Readonly<Record<string, number>>;
132
+ }
133
+ /**
134
+ * A scored node returned by `queryGraph()`.
135
+ */
136
+ interface RankedGraphNode {
137
+ id: string;
138
+ score: number;
139
+ }
140
+ /**
141
+ * The shape returned by `queryGraph()`.
142
+ */
143
+ interface QueryGraphResult {
144
+ rankedNodes: RankedGraphNode[];
145
+ /** Number of power-iteration rounds actually executed. */
146
+ iterations: number;
147
+ /** L1 delta at the last iteration. */
148
+ converged: boolean;
149
+ }
150
+ /** PPR damping factor default. */
151
+ declare const DEFAULT_PPR_DAMPING = 0.85;
152
+ /** Power-iteration cap default. */
153
+ declare const DEFAULT_PPR_ITERATIONS = 20;
154
+ /** L1 convergence threshold default. */
155
+ declare const DEFAULT_PPR_TOLERANCE = 0.000001;
156
+ /**
157
+ * Personalized PageRank via power iteration.
158
+ *
159
+ * Pure function — no I/O. Deterministic given the same graph and options.
160
+ *
161
+ * Algorithm:
162
+ *
163
+ * r_{t+1}(v) = (1 - d) * s(v)
164
+ * + d * Σ_{u → v} r_t(u) * w(u,v) / Σ_w w(u,·)
165
+ * + d * (dangling mass) * s(v)
166
+ *
167
+ * where:
168
+ * - `d` is the damping factor (default 0.85).
169
+ * - `s` is the seed vector (normalized personalization distribution).
170
+ * - dangling mass is the total rank on nodes with no outgoing edges,
171
+ * redistributed over the seed vector so probability mass is conserved.
172
+ *
173
+ * The loop stops early when `|r_{t+1} - r_t|_1 < tolerance` or after
174
+ * `iterations` rounds, whichever comes first.
175
+ *
176
+ * Edge cases:
177
+ * - Empty graph → `{ rankedNodes: [], iterations: 0, converged: true }`.
178
+ * - Seed ids that are not in the graph are silently dropped.
179
+ * - If no in-graph seed mass remains (empty seed or all seeds missing),
180
+ * the uniform distribution over graph nodes is used — matching
181
+ * standard PageRank semantics.
182
+ * - `damping` is clamped to `[0, 1)` (a damping of exactly 1 would make
183
+ * the chain non-ergodic; damping of exactly 0 reduces to the seed
184
+ * distribution).
185
+ * - `topK <= 0` returns an empty ranked list (but the `iterations` and
186
+ * `converged` fields still reflect the actual computation).
187
+ */
188
+ declare function queryGraph(graph: RemnicGraph, seedIds: readonly string[], options?: QueryGraphOptions): QueryGraphResult;
189
+ /** Returns true iff `value` is a valid `NodeType`. */
190
+ declare function isNodeType(value: unknown): value is NodeType;
191
+ /** Returns true iff `value` is a valid `EdgeType`. */
192
+ declare function isEdgeType(value: unknown): value is EdgeType;
193
+ /**
194
+ * Minimum fields the edge extractor reads from a memory record. Structural
195
+ * typing is used so callers can pass any subset of `MemoryFrontmatter`
196
+ * (including richer loaded memories) without a cast.
197
+ *
198
+ * All reference fields are optional — memories written before earlier slices
199
+ * landed will simply contribute no edges for those dimensions.
200
+ */
201
+ interface MemoryEdgeSource {
202
+ /** Stable identifier for the memory (typically the file path). */
203
+ id: string;
204
+ /** Older memory id this memory supersedes (1:1). */
205
+ supersedes?: string;
206
+ /** Parent memory ids this memory was derived from (lineage). */
207
+ lineage?: string[];
208
+ /**
209
+ * Consolidation provenance — `"<memory-id>:<version-number>"` strings.
210
+ * The memory-id portion before the last `:` is used as the edge target.
211
+ */
212
+ derived_from?: string[];
213
+ /** Primary entity reference on the memory (e.g. `person:Jane Doe`). */
214
+ entityRef?: string;
215
+ /** Additional entity references (used by episodes and ledger records). */
216
+ entityRefs?: string[];
217
+ /** Raw memory body — scanned for inline `[Source: ...]` citation blocks. */
218
+ content?: string;
219
+ }
220
+ /** Options controlling edge extraction. */
221
+ interface ExtractGraphEdgesOptions {
222
+ /**
223
+ * When true, include edges whose `to` endpoint is not present in the
224
+ * provided node index. Defaults to `false` — dangling edges are silently
225
+ * skipped because PPR cannot propagate mass through a missing node.
226
+ */
227
+ includeDanglingEdges?: boolean;
228
+ }
229
+ /**
230
+ * Extract retrieval-graph edges from a collection of memories.
231
+ *
232
+ * Pure function — no I/O, no config access, no time-based side effects.
233
+ * Given the same inputs, always produces the same edges in the same order
234
+ * so dedup downstream is deterministic.
235
+ *
236
+ * Source → target semantics by edge type:
237
+ *
238
+ * - `supersedes`: memory → older memory (from `supersedes` field).
239
+ * - `derived-from`: memory → each parent in `lineage` OR `derived_from`.
240
+ * - `mentions`: memory → each entity in `entityRef` / `entityRefs`.
241
+ * - `authored-by`: memory → agent id parsed from inline `[Source: ...]`.
242
+ *
243
+ * `temporal-next`, `references`, `related-to`, and `concept` / `reflection`
244
+ * node synthesis are deferred to later slices — they require either episode
245
+ * sequencing or an abstraction synthesis pass that is out of scope for PR 2.
246
+ *
247
+ * @param memories Memories to scan. Order is preserved; duplicates are
248
+ * not deduped (the caller controls the input set).
249
+ * @param options Extraction knobs. See `ExtractGraphEdgesOptions`.
250
+ * @returns A `{ nodes, edges }` pair. `nodes` contains one
251
+ * `memory` node per input memory plus one `entity` node
252
+ * per distinct entity discovered across all mentions.
253
+ * Edges reference ids in the returned node map unless
254
+ * `includeDanglingEdges` is set.
255
+ */
256
+ declare function extractGraphEdges(memories: readonly MemoryEdgeSource[], options?: ExtractGraphEdgesOptions): {
257
+ nodes: Map<string, RemnicGraphNode>;
258
+ edges: RemnicGraphEdge[];
259
+ };
260
+ /**
261
+ * Build a `RemnicGraph` from a collection of memories by delegating to
262
+ * `extractGraphEdges()`. Convenience wrapper so callers do not have to
263
+ * re-wrap the `{ nodes, edges }` pair into the `RemnicGraph` interface.
264
+ *
265
+ * Pure function — no I/O. Persisting the graph (e.g. writing
266
+ * `~/.remnic/graph.json`) is left to the caller; that decision belongs with
267
+ * the maintenance / consolidation pass in PR 4, not the extractor.
268
+ */
269
+ declare function buildGraphFromMemories(memories: readonly MemoryEdgeSource[], options?: ExtractGraphEdgesOptions): RemnicGraph;
270
+
271
+ export { DEFAULT_PPR_DAMPING, DEFAULT_PPR_ITERATIONS, DEFAULT_PPR_TOLERANCE, type EdgeType, type ExtractGraphEdgesOptions, type MemoryEdgeSource, type NodeType, type QueryGraphOptions, type QueryGraphResult, type RankedGraphNode, type RemnicGraph, type RemnicGraphEdge, type RemnicGraphNode, buildGraphFromMemories, extractGraphEdges, isEdgeType, isNodeType, queryGraph };
@@ -0,0 +1,21 @@
1
+ import {
2
+ DEFAULT_PPR_DAMPING,
3
+ DEFAULT_PPR_ITERATIONS,
4
+ DEFAULT_PPR_TOLERANCE,
5
+ buildGraphFromMemories,
6
+ extractGraphEdges,
7
+ isEdgeType,
8
+ isNodeType,
9
+ queryGraph
10
+ } from "./chunk-64NJRYU2.js";
11
+ export {
12
+ DEFAULT_PPR_DAMPING,
13
+ DEFAULT_PPR_ITERATIONS,
14
+ DEFAULT_PPR_TOLERANCE,
15
+ buildGraphFromMemories,
16
+ extractGraphEdges,
17
+ isEdgeType,
18
+ isNodeType,
19
+ queryGraph
20
+ };
21
+ //# sourceMappingURL=graph-retrieval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -3,7 +3,7 @@ import {
3
3
  isAboveImportanceThreshold,
4
4
  rescoreMemoryImportance,
5
5
  scoreImportance
6
- } from "./chunk-J4IYOZZ5.js";
6
+ } from "./chunk-JXS5PDQ7.js";
7
7
  export {
8
8
  importanceLevel,
9
9
  isAboveImportanceThreshold,