@remnic/core 1.0.3 → 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 (323) hide show
  1. package/dist/abort-error.d.ts +32 -0
  2. package/dist/abort-error.js +11 -0
  3. package/dist/access-audit.d.ts +56 -0
  4. package/dist/access-audit.js +9 -0
  5. package/dist/access-audit.js.map +1 -0
  6. package/dist/access-cli.js +72 -54
  7. package/dist/access-cli.js.map +1 -1
  8. package/dist/access-http.d.ts +16 -8
  9. package/dist/access-http.js +25 -17
  10. package/dist/access-mcp.d.ts +16 -8
  11. package/dist/access-mcp.js +28 -6
  12. package/dist/access-schema.d.ts +130 -39
  13. package/dist/access-schema.js +5 -1
  14. package/dist/access-service-Br8ZydTK.d.ts +827 -0
  15. package/dist/access-service.d.ts +20 -660
  16. package/dist/access-service.js +22 -14
  17. package/dist/bootstrap.d.ts +6 -3
  18. package/dist/briefing.d.ts +1 -0
  19. package/dist/briefing.js +6 -5
  20. package/dist/buffer-surprise-report.d.ts +70 -0
  21. package/dist/buffer-surprise-report.js +7 -0
  22. package/dist/buffer-surprise-report.js.map +1 -0
  23. package/dist/buffer-surprise.d.ts +98 -0
  24. package/dist/buffer-surprise.js +11 -0
  25. package/dist/buffer-surprise.js.map +1 -0
  26. package/dist/buffer.d.ts +100 -2
  27. package/dist/buffer.js +1 -1
  28. package/dist/calibration.js +5 -5
  29. package/dist/causal-behavior.js +4 -4
  30. package/dist/causal-chain.js +2 -2
  31. package/dist/causal-consolidation.js +17 -16
  32. package/dist/causal-consolidation.js.map +1 -1
  33. package/dist/causal-retrieval.js +4 -4
  34. package/dist/causal-trajectory.js +1 -1
  35. package/dist/{chunk-QNJMBKFK.js → chunk-2LGMW3DJ.js} +3 -2
  36. package/dist/chunk-2LGMW3DJ.js.map +1 -0
  37. package/dist/{chunk-QDYXG4CS.js → chunk-3FPTCC3Z.js} +4 -3
  38. package/dist/chunk-3FPTCC3Z.js.map +1 -0
  39. package/dist/chunk-3GPTTA4J.js +57 -0
  40. package/dist/chunk-3GPTTA4J.js.map +1 -0
  41. package/dist/{chunk-QKAH5B6E.js → chunk-3GXCSUXR.js} +94 -6
  42. package/dist/chunk-3GXCSUXR.js.map +1 -0
  43. package/dist/{chunk-POBPGDWI.js → chunk-3OGMS3PE.js} +2 -2
  44. package/dist/chunk-54V4BZWP.js +139 -0
  45. package/dist/chunk-54V4BZWP.js.map +1 -0
  46. package/dist/chunk-5JRF2PZA.js +67 -0
  47. package/dist/chunk-5JRF2PZA.js.map +1 -0
  48. package/dist/chunk-64NJRYU2.js +332 -0
  49. package/dist/chunk-64NJRYU2.js.map +1 -0
  50. package/dist/chunk-6AUUAZEX.js +150 -0
  51. package/dist/chunk-6AUUAZEX.js.map +1 -0
  52. package/dist/{chunk-HITJFT7E.js → chunk-7I7FKFZH.js} +28 -21
  53. package/dist/chunk-7I7FKFZH.js.map +1 -0
  54. package/dist/chunk-AJU4PJGY.js +126 -0
  55. package/dist/chunk-AJU4PJGY.js.map +1 -0
  56. package/dist/chunk-ASAITVLA.js +64 -0
  57. package/dist/chunk-ASAITVLA.js.map +1 -0
  58. package/dist/{chunk-X4WESCKA.js → chunk-B5WXLVDY.js} +187 -6
  59. package/dist/chunk-B5WXLVDY.js.map +1 -0
  60. package/dist/{chunk-RCICHSHL.js → chunk-BGJGXLZ7.js} +111 -2
  61. package/dist/{chunk-RCICHSHL.js.map → chunk-BGJGXLZ7.js.map} +1 -1
  62. package/dist/{chunk-OJFGVJS6.js → chunk-BK2EFTE2.js} +319 -18
  63. package/dist/chunk-BK2EFTE2.js.map +1 -0
  64. package/dist/chunk-C4SQJZAF.js +486 -0
  65. package/dist/chunk-C4SQJZAF.js.map +1 -0
  66. package/dist/{chunk-GJQPH5G3.js → chunk-CUPFXL3J.js} +2 -2
  67. package/dist/chunk-DF3RVK3X.js +119 -0
  68. package/dist/chunk-DF3RVK3X.js.map +1 -0
  69. package/dist/{chunk-PMB3WGDL.js → chunk-DFTTJYSO.js} +167 -7
  70. package/dist/chunk-DFTTJYSO.js.map +1 -0
  71. package/dist/chunk-DGVM5SFL.js +69 -0
  72. package/dist/chunk-DGVM5SFL.js.map +1 -0
  73. package/dist/chunk-EIR5VLIH.js +90 -0
  74. package/dist/chunk-EIR5VLIH.js.map +1 -0
  75. package/dist/{chunk-PAORGQRI.js → chunk-EPQJM2GC.js} +37 -23
  76. package/dist/chunk-EPQJM2GC.js.map +1 -0
  77. package/dist/{chunk-POMSFKTB.js → chunk-F5VP6YCB.js} +368 -10
  78. package/dist/chunk-F5VP6YCB.js.map +1 -0
  79. package/dist/{chunk-6ZH4TU6I.js → chunk-FAAFWE4G.js} +2 -1
  80. package/dist/chunk-FAAFWE4G.js.map +1 -0
  81. package/dist/{chunk-74JR4N5J.js → chunk-FVA6TGI3.js} +2 -2
  82. package/dist/chunk-GDFS42HT.js +206 -0
  83. package/dist/chunk-GDFS42HT.js.map +1 -0
  84. package/dist/{chunk-BKQJBXXX.js → chunk-GGD5W7TB.js} +2 -2
  85. package/dist/chunk-GGD5W7TB.js.map +1 -0
  86. package/dist/{chunk-V7XCAHIB.js → chunk-GKFXUTJ2.js} +508 -26
  87. package/dist/chunk-GKFXUTJ2.js.map +1 -0
  88. package/dist/{chunk-NSB3WSYS.js → chunk-HK3FGIEW.js} +278 -3
  89. package/dist/chunk-HK3FGIEW.js.map +1 -0
  90. package/dist/{chunk-AAI7JARD.js → chunk-HMDCOMYU.js} +8 -11
  91. package/dist/chunk-HMDCOMYU.js.map +1 -0
  92. package/dist/chunk-IISBCCWR.js +52 -0
  93. package/dist/chunk-IISBCCWR.js.map +1 -0
  94. package/dist/{chunk-YFYL2SIJ.js → chunk-INXV5JBT.js} +290 -46
  95. package/dist/chunk-INXV5JBT.js.map +1 -0
  96. package/dist/chunk-JBMSGZEQ.js +441 -0
  97. package/dist/chunk-JBMSGZEQ.js.map +1 -0
  98. package/dist/{chunk-UPMD5XND.js → chunk-JL2PU6AI.js} +16 -5
  99. package/dist/chunk-JL2PU6AI.js.map +1 -0
  100. package/dist/{chunk-J4IYOZZ5.js → chunk-JXS5PDQ7.js} +3 -1
  101. package/dist/chunk-JXS5PDQ7.js.map +1 -0
  102. package/dist/{chunk-AYPYCLR7.js → chunk-KUB6JU6H.js} +4 -4
  103. package/dist/chunk-KVBLZUKV.js +173 -0
  104. package/dist/chunk-KVBLZUKV.js.map +1 -0
  105. package/dist/chunk-LBLXEFWK.js +51 -0
  106. package/dist/chunk-LBLXEFWK.js.map +1 -0
  107. package/dist/{chunk-U2IQTSBY.js → chunk-LTCGGW2D.js} +1 -1
  108. package/dist/chunk-LTCGGW2D.js.map +1 -0
  109. package/dist/{chunk-UEYA6UC7.js → chunk-NZLQTHS5.js} +25 -2
  110. package/dist/chunk-NZLQTHS5.js.map +1 -0
  111. package/dist/chunk-PVGDJXVK.js +21 -0
  112. package/dist/chunk-PVGDJXVK.js.map +1 -0
  113. package/dist/chunk-PVPWZSSI.js +37 -0
  114. package/dist/chunk-PVPWZSSI.js.map +1 -0
  115. package/dist/{chunk-4NRAJUDS.js → chunk-RBBWYEFJ.js} +1 -1
  116. package/dist/chunk-RFYAYKTD.js +146 -0
  117. package/dist/chunk-RFYAYKTD.js.map +1 -0
  118. package/dist/{chunk-JROGC36Y.js → chunk-RGLL5SPU.js} +2 -2
  119. package/dist/{chunk-2VFW5K5U.js → chunk-S3EEFKNY.js} +103 -65
  120. package/dist/chunk-S3EEFKNY.js.map +1 -0
  121. package/dist/chunk-SOBJ6NEY.js +18 -0
  122. package/dist/chunk-SOBJ6NEY.js.map +1 -0
  123. package/dist/{chunk-MYQWXITD.js → chunk-SPI27QT6.js} +2 -2
  124. package/dist/chunk-TVVEYCNW.js +65 -0
  125. package/dist/chunk-TVVEYCNW.js.map +1 -0
  126. package/dist/chunk-ULYOGL6R.js +322 -0
  127. package/dist/chunk-ULYOGL6R.js.map +1 -0
  128. package/dist/{chunk-S4LX5EBI.js → chunk-VBVG2M5G.js} +64 -10
  129. package/dist/chunk-VBVG2M5G.js.map +1 -0
  130. package/dist/{chunk-KWP7T3DP.js → chunk-VDX363PS.js} +2 -2
  131. package/dist/{chunk-XMGSSBFX.js → chunk-VYM3VWOF.js} +1560 -244
  132. package/dist/chunk-VYM3VWOF.js.map +1 -0
  133. package/dist/{chunk-MTLYEMJB.js → chunk-WCLICCGB.js} +18 -3
  134. package/dist/chunk-WCLICCGB.js.map +1 -0
  135. package/dist/{chunk-ECKDIK5F.js → chunk-WVVA7F5A.js} +2 -2
  136. package/dist/chunk-X6GF3FX2.js +26 -0
  137. package/dist/chunk-X6GF3FX2.js.map +1 -0
  138. package/dist/{chunk-3QFQGRHO.js → chunk-XMHBH5H6.js} +4 -4
  139. package/dist/{chunk-KEG4GNGI.js → chunk-XZ2TIKGC.js} +38 -8
  140. package/dist/chunk-XZ2TIKGC.js.map +1 -0
  141. package/dist/chunk-Y4FHOFJ2.js +140 -0
  142. package/dist/chunk-Y4FHOFJ2.js.map +1 -0
  143. package/dist/chunk-YNB73F22.js +137 -0
  144. package/dist/chunk-YNB73F22.js.map +1 -0
  145. package/dist/{chunk-7PA4OZEU.js → chunk-YNQKWQT4.js} +55 -30
  146. package/dist/chunk-YNQKWQT4.js.map +1 -0
  147. package/dist/chunk-ZAIM4TUE.js +488 -0
  148. package/dist/chunk-ZAIM4TUE.js.map +1 -0
  149. package/dist/{chunk-BTY5RRRF.js → chunk-ZEM3OK2K.js} +5 -5
  150. package/dist/chunk-ZZTOURJI.js +91 -0
  151. package/dist/chunk-ZZTOURJI.js.map +1 -0
  152. package/dist/{cli-DwIBnp2g.d.ts → cli-BkeRaYfk.d.ts} +2 -2
  153. package/dist/cli.d.ts +13 -5
  154. package/dist/cli.js +45 -33
  155. package/dist/config.js +1 -1
  156. package/dist/consolidation-operator.d.ts +41 -0
  157. package/dist/consolidation-operator.js +11 -0
  158. package/dist/consolidation-operator.js.map +1 -0
  159. package/dist/consolidation-provenance-check.d.ts +68 -0
  160. package/dist/consolidation-provenance-check.js +9 -0
  161. package/dist/consolidation-provenance-check.js.map +1 -0
  162. package/dist/consolidation-undo.d.ts +123 -0
  163. package/dist/consolidation-undo.js +426 -0
  164. package/dist/consolidation-undo.js.map +1 -0
  165. package/dist/contradiction-review-WIUBAR52.js +21 -0
  166. package/dist/contradiction-review-WIUBAR52.js.map +1 -0
  167. package/dist/contradiction-scan-E3GJTI4F.js +412 -0
  168. package/dist/contradiction-scan-E3GJTI4F.js.map +1 -0
  169. package/dist/cross-namespace-budget.d.ts +133 -0
  170. package/dist/cross-namespace-budget.js +9 -0
  171. package/dist/cross-namespace-budget.js.map +1 -0
  172. package/dist/direct-answer-wiring.d.ts +77 -0
  173. package/dist/direct-answer-wiring.js +10 -0
  174. package/dist/direct-answer-wiring.js.map +1 -0
  175. package/dist/direct-answer.d.ts +106 -0
  176. package/dist/direct-answer.js +10 -0
  177. package/dist/direct-answer.js.map +1 -0
  178. package/dist/{engine-X7X3AAG3.js → engine-F3GOXGE5.js} +7 -6
  179. package/dist/engine-F3GOXGE5.js.map +1 -0
  180. package/dist/entity-retrieval.d.ts +1 -0
  181. package/dist/entity-retrieval.js +6 -5
  182. package/dist/explicit-capture.d.ts +6 -3
  183. package/dist/explicit-capture.js +2 -2
  184. package/dist/extraction-judge-telemetry.d.ts +113 -0
  185. package/dist/extraction-judge-telemetry.js +14 -0
  186. package/dist/extraction-judge-telemetry.js.map +1 -0
  187. package/dist/extraction-judge-training.d.ts +85 -0
  188. package/dist/extraction-judge-training.js +16 -0
  189. package/dist/extraction-judge-training.js.map +1 -0
  190. package/dist/extraction-judge.d.ts +124 -2
  191. package/dist/extraction-judge.js +11 -1
  192. package/dist/extraction.js +7 -6
  193. package/dist/fallback-llm.d.ts +11 -2
  194. package/dist/fallback-llm.js +2 -2
  195. package/dist/graph-recall.d.ts +100 -0
  196. package/dist/graph-recall.js +8 -0
  197. package/dist/graph-recall.js.map +1 -0
  198. package/dist/graph-retrieval.d.ts +271 -0
  199. package/dist/graph-retrieval.js +21 -0
  200. package/dist/graph-retrieval.js.map +1 -0
  201. package/dist/harmonic-retrieval.js +2 -1
  202. package/dist/importance.js +1 -1
  203. package/dist/index.d.ts +589 -138
  204. package/dist/index.js +531 -403
  205. package/dist/index.js.map +1 -1
  206. package/dist/intent.js +1 -1
  207. package/dist/local-llm.d.ts +10 -3
  208. package/dist/local-llm.js +1 -1
  209. package/dist/memory-worth-bench.d.ts +51 -0
  210. package/dist/memory-worth-bench.js +131 -0
  211. package/dist/memory-worth-bench.js.map +1 -0
  212. package/dist/memory-worth-filter.d.ts +128 -0
  213. package/dist/memory-worth-filter.js +10 -0
  214. package/dist/memory-worth-filter.js.map +1 -0
  215. package/dist/memory-worth-outcomes.d.ts +118 -0
  216. package/dist/memory-worth-outcomes.js +9 -0
  217. package/dist/memory-worth-outcomes.js.map +1 -0
  218. package/dist/memory-worth.d.ts +102 -0
  219. package/dist/memory-worth.js +7 -0
  220. package/dist/memory-worth.js.map +1 -0
  221. package/dist/operator-toolkit.d.ts +40 -1
  222. package/dist/operator-toolkit.js +24 -14
  223. package/dist/{orchestrator-B9kwlCep.d.ts → orchestrator-CmJ-NTdJ.d.ts} +254 -10
  224. package/dist/orchestrator.d.ts +6 -3
  225. package/dist/orchestrator.js +59 -48
  226. package/dist/page-versioning.d.ts +12 -1
  227. package/dist/page-versioning.js +5 -3
  228. package/dist/{port-C1GZFv8h.d.ts → port-BADbLZU5.d.ts} +2 -2
  229. package/dist/qmd-recall-cache.d.ts +1 -1
  230. package/dist/qmd.d.ts +5 -3
  231. package/dist/qmd.js +2 -1
  232. package/dist/reasoning-trace-recall.d.ts +90 -0
  233. package/dist/reasoning-trace-recall.js +13 -0
  234. package/dist/reasoning-trace-recall.js.map +1 -0
  235. package/dist/reasoning-trace-types.d.ts +54 -0
  236. package/dist/reasoning-trace-types.js +17 -0
  237. package/dist/reasoning-trace-types.js.map +1 -0
  238. package/dist/recall-audit-anomaly.d.ts +112 -0
  239. package/dist/recall-audit-anomaly.js +11 -0
  240. package/dist/recall-audit-anomaly.js.map +1 -0
  241. package/dist/recall-audit.js +5 -44
  242. package/dist/recall-audit.js.map +1 -1
  243. package/dist/recall-explain-renderer.d.ts +49 -0
  244. package/dist/recall-explain-renderer.js +18 -0
  245. package/dist/recall-explain-renderer.js.map +1 -0
  246. package/dist/recall-state.d.ts +39 -1
  247. package/dist/recall-state.js +1 -1
  248. package/dist/recall-xray-cli.d.ts +40 -0
  249. package/dist/recall-xray-cli.js +11 -0
  250. package/dist/recall-xray-cli.js.map +1 -0
  251. package/dist/recall-xray-renderer.d.ts +44 -0
  252. package/dist/recall-xray-renderer.js +18 -0
  253. package/dist/recall-xray-renderer.js.map +1 -0
  254. package/dist/recall-xray.d.ts +179 -0
  255. package/dist/recall-xray.js +13 -0
  256. package/dist/recall-xray.js.map +1 -0
  257. package/dist/resolution-QBTDHTG7.js +100 -0
  258. package/dist/resolution-QBTDHTG7.js.map +1 -0
  259. package/dist/resolve-provider-secret.d.ts +24 -1
  260. package/dist/resolve-provider-secret.js +3 -1
  261. package/dist/resume-bundles.js +6 -6
  262. package/dist/retrieval-agents.d.ts +1 -1
  263. package/dist/retrieval-tiers.d.ts +17 -0
  264. package/dist/retrieval-tiers.js +9 -0
  265. package/dist/retrieval-tiers.js.map +1 -0
  266. package/dist/schemas.d.ts +301 -45
  267. package/dist/schemas.js +1 -1
  268. package/dist/{semantic-consolidation-DrvSYRdB.d.ts → semantic-consolidation-CxJU6MJk.d.ts} +62 -1
  269. package/dist/semantic-consolidation.d.ts +2 -1
  270. package/dist/semantic-consolidation.js +20 -6
  271. package/dist/semantic-rule-promotion.js +6 -5
  272. package/dist/semantic-rule-verifier.js +6 -5
  273. package/dist/storage.d.ts +82 -1
  274. package/dist/storage.js +5 -4
  275. package/dist/summarizer.js +4 -4
  276. package/dist/temporal-supersession.d.ts +1 -0
  277. package/dist/tier-migration.d.ts +2 -1
  278. package/dist/types-DJhqDJUV.d.ts +50 -0
  279. package/dist/types.d.ts +309 -3
  280. package/dist/types.js +1 -1
  281. package/dist/verified-recall.js +6 -5
  282. package/package.json +1 -1
  283. package/dist/chunk-2VFW5K5U.js.map +0 -1
  284. package/dist/chunk-6ZH4TU6I.js.map +0 -1
  285. package/dist/chunk-7PA4OZEU.js.map +0 -1
  286. package/dist/chunk-AAI7JARD.js.map +0 -1
  287. package/dist/chunk-BKQJBXXX.js.map +0 -1
  288. package/dist/chunk-HITJFT7E.js.map +0 -1
  289. package/dist/chunk-J4IYOZZ5.js.map +0 -1
  290. package/dist/chunk-KEG4GNGI.js.map +0 -1
  291. package/dist/chunk-LAYN4LDC.js +0 -267
  292. package/dist/chunk-LAYN4LDC.js.map +0 -1
  293. package/dist/chunk-MTLYEMJB.js.map +0 -1
  294. package/dist/chunk-NSB3WSYS.js.map +0 -1
  295. package/dist/chunk-OJFGVJS6.js.map +0 -1
  296. package/dist/chunk-PAORGQRI.js.map +0 -1
  297. package/dist/chunk-PMB3WGDL.js.map +0 -1
  298. package/dist/chunk-POMSFKTB.js.map +0 -1
  299. package/dist/chunk-QDYXG4CS.js.map +0 -1
  300. package/dist/chunk-QKAH5B6E.js.map +0 -1
  301. package/dist/chunk-QNJMBKFK.js.map +0 -1
  302. package/dist/chunk-S4LX5EBI.js.map +0 -1
  303. package/dist/chunk-U2IQTSBY.js.map +0 -1
  304. package/dist/chunk-UEYA6UC7.js.map +0 -1
  305. package/dist/chunk-UPMD5XND.js.map +0 -1
  306. package/dist/chunk-UVJFDP7P.js +0 -202
  307. package/dist/chunk-UVJFDP7P.js.map +0 -1
  308. package/dist/chunk-V7XCAHIB.js.map +0 -1
  309. package/dist/chunk-X4WESCKA.js.map +0 -1
  310. package/dist/chunk-XMGSSBFX.js.map +0 -1
  311. package/dist/chunk-YFYL2SIJ.js.map +0 -1
  312. /package/dist/{engine-X7X3AAG3.js.map → abort-error.js.map} +0 -0
  313. /package/dist/{chunk-POBPGDWI.js.map → chunk-3OGMS3PE.js.map} +0 -0
  314. /package/dist/{chunk-GJQPH5G3.js.map → chunk-CUPFXL3J.js.map} +0 -0
  315. /package/dist/{chunk-74JR4N5J.js.map → chunk-FVA6TGI3.js.map} +0 -0
  316. /package/dist/{chunk-AYPYCLR7.js.map → chunk-KUB6JU6H.js.map} +0 -0
  317. /package/dist/{chunk-4NRAJUDS.js.map → chunk-RBBWYEFJ.js.map} +0 -0
  318. /package/dist/{chunk-JROGC36Y.js.map → chunk-RGLL5SPU.js.map} +0 -0
  319. /package/dist/{chunk-MYQWXITD.js.map → chunk-SPI27QT6.js.map} +0 -0
  320. /package/dist/{chunk-KWP7T3DP.js.map → chunk-VDX363PS.js.map} +0 -0
  321. /package/dist/{chunk-ECKDIK5F.js.map → chunk-WVVA7F5A.js.map} +0 -0
  322. /package/dist/{chunk-3QFQGRHO.js.map → chunk-XMHBH5H6.js.map} +0 -0
  323. /package/dist/{chunk-BTY5RRRF.js.map → chunk-ZEM3OK2K.js.map} +0 -0
@@ -26,10 +26,87 @@ interface JudgeCandidate {
26
26
  /** Local importance level, set by caller before judging. */
27
27
  importanceLevel?: ImportanceLevel;
28
28
  }
29
+ /**
30
+ * Verdict kinds (issue #562, PR 1).
31
+ *
32
+ * - `"accept"`: fact is durable, persist it.
33
+ * - `"reject"`: fact is not durable, drop it.
34
+ * - `"defer"`: fact is ambiguous; push it back into the buffer for another
35
+ * pass with fresh context. Inspired by MemReader (arxiv 2604.07877).
36
+ *
37
+ * PR 1 only introduces the type. No emit path produces `"defer"` yet — the
38
+ * defer-capable prompt, buffer re-routing, telemetry, and GRPO data
39
+ * collection are landing in PRs 2, 3, and 4 respectively.
40
+ */
41
+ type JudgeVerdictKind = "accept" | "reject" | "defer";
42
+ /**
43
+ * Judge verdict shape.
44
+ *
45
+ * Back-compat note: `kind` is optional. Verdicts serialized before PR 1
46
+ * (both in-memory cache entries and any persisted caches) only carry
47
+ * `{ durable, reason }`. Downstream consumers must either read `durable`
48
+ * directly, or use {@link getVerdictKind} / {@link isDurableVerdict} which
49
+ * gracefully fall back to the boolean when `kind` is missing, and ignore
50
+ * unknown future `kind` values rather than crashing.
51
+ */
29
52
  interface JudgeVerdict {
53
+ /**
54
+ * True iff the fact should be persisted. For `"defer"` verdicts this is
55
+ * `false` — a deferred fact is not (yet) persisted, so callers that only
56
+ * look at `durable` will treat defer as "skip this turn", which matches
57
+ * the pre-PR-1 fail-closed behavior for non-accepted verdicts.
58
+ */
30
59
  durable: boolean;
31
60
  reason: string;
61
+ /**
62
+ * Optional explicit verdict kind. Added in PR 1 of issue #562. Legacy
63
+ * verdicts (including cache entries produced before this field existed)
64
+ * do not set `kind`; use {@link getVerdictKind} to read this safely.
65
+ */
66
+ kind?: JudgeVerdictKind;
32
67
  }
68
+ /**
69
+ * Resolve a verdict's effective kind.
70
+ *
71
+ * - If `kind` is explicitly set to one of the known values, return it.
72
+ * - If `kind` is absent, infer from `durable` (back-compat with pre-PR-1
73
+ * cache entries and emit paths that have not been updated yet).
74
+ * - If `kind` is set to an unrecognised value (forward-compat, e.g. a
75
+ * future cache entry loaded by an older build), fall back to `durable`
76
+ * so we never crash on unknown strings.
77
+ */
78
+ declare function getVerdictKind(verdict: JudgeVerdict): JudgeVerdictKind;
79
+ /**
80
+ * Type guard: returns `true` only for verdicts that should be persisted.
81
+ * Treats both `"reject"` and `"defer"` as "not durable" — defer means the
82
+ * caller should re-evaluate later, not write now.
83
+ */
84
+ declare function isDurableVerdict(verdict: JudgeVerdict): boolean;
85
+ /**
86
+ * Validate a cache entry loaded from persistence / another process.
87
+ *
88
+ * Strict: accepts legacy `{ durable, reason }` entries and new entries
89
+ * whose `kind` is one of the three known `JudgeVerdictKind` values.
90
+ * Rejects structurally wrong types and unknown `kind` strings so the
91
+ * type-guard narrowing is sound — callers that receive
92
+ * `value is JudgeVerdict` can safely treat `kind` as the declared
93
+ * union.
94
+ *
95
+ * Forward-compat is handled by {@link normalizeCachedVerdict}, which
96
+ * drops unknown `kind` strings before validation so a newer build's
97
+ * cache entry still loads instead of being rejected.
98
+ */
99
+ declare function isValidCachedVerdict(value: unknown): value is JudgeVerdict;
100
+ /**
101
+ * Forward-compatible cache-entry loader.
102
+ *
103
+ * Drops unknown `kind` strings to `undefined` (so `getVerdictKind` can
104
+ * fall back to `durable`), then validates structurally. Non-string
105
+ * `kind` values are still treated as structural violations and rejected.
106
+ * Returns the sanitised verdict, or `null` when the entry is structurally
107
+ * unusable.
108
+ */
109
+ declare function normalizeCachedVerdict(value: unknown): JudgeVerdict | null;
33
110
  interface JudgeBatchResult {
34
111
  verdicts: Map<number, JudgeVerdict>;
35
112
  /** Number of verdicts served from cache. */
@@ -38,6 +115,45 @@ interface JudgeBatchResult {
38
115
  judged: number;
39
116
  /** Total wall-clock time in milliseconds. */
40
117
  elapsed: number;
118
+ /**
119
+ * Number of verdicts in this batch that resolved to `"defer"` (issue #562,
120
+ * PR 2). Callers can use this to decide whether to retain buffer turns for
121
+ * the next extraction pass.
122
+ */
123
+ deferred: number;
124
+ /**
125
+ * Number of defers that were forcibly converted to `"reject"` because the
126
+ * same candidate text had already been deferred at least
127
+ * `extractionJudgeMaxDeferrals` times. Rolled out of `deferred` — a
128
+ * candidate counted here is *not* also in `deferred`.
129
+ */
130
+ deferredCappedToReject: number;
131
+ }
132
+ /**
133
+ * Per-verdict observation emitted by `judgeFactDurability` when an
134
+ * `onVerdict` callback is supplied (issue #562, PR 3). Used to wire the
135
+ * observation ledger / telemetry stream without coupling the judge module
136
+ * directly to filesystem I/O. One event is emitted for every resolved
137
+ * verdict, including auto-approved and cache-hit paths.
138
+ */
139
+ interface JudgeVerdictObservation {
140
+ verdict: JudgeVerdict;
141
+ /** The original `JudgeCandidate` passed in (same reference). */
142
+ candidate: JudgeCandidate;
143
+ /** SHA-256 of `text\0category`, same key the cache/deferCounter use. */
144
+ contentHash: string;
145
+ /** Verdict resolution path. Useful for debugging + dashboards. */
146
+ source: "auto-approve" | "cache" | "llm" | "llm-cap-rejected" | "fail-open";
147
+ /**
148
+ * How many times this candidate had already been deferred before this
149
+ * verdict resolved. 0 when the candidate had never been deferred.
150
+ */
151
+ priorDeferrals: number;
152
+ /**
153
+ * Milliseconds from batch start to now. Shared across verdicts emitted in
154
+ * the same batch.
155
+ */
156
+ elapsedMs: number;
41
157
  }
42
158
  /**
43
159
  * Deterministic gate for extracted `procedure` memories: ≥2 steps with non-empty
@@ -55,12 +171,18 @@ declare function validateProcedureExtraction(input: {
55
171
  * checked against an in-memory content-hash cache, and sent to the LLM
56
172
  * for verdict.
57
173
  */
58
- declare function judgeFactDurability(candidates: JudgeCandidate[], config: PluginConfig, localLlm: LocalLlmClient | null, fallbackLlm: FallbackLlmClient | null, cache?: Map<string, JudgeVerdict>): Promise<JudgeBatchResult>;
174
+ declare function judgeFactDurability(candidates: JudgeCandidate[], config: PluginConfig, localLlm: LocalLlmClient | null, fallbackLlm: FallbackLlmClient | null, cache?: Map<string, JudgeVerdict>, deferCounts?: Map<string, number>, onVerdict?: (observation: JudgeVerdictObservation) => void): Promise<JudgeBatchResult>;
59
175
  /** Clear the in-memory default verdict cache. Primarily for tests. */
60
176
  declare function clearVerdictCache(): void;
61
177
  /** Return the current default verdict cache size. Primarily for tests. */
62
178
  declare function verdictCacheSize(): number;
63
179
  /** Create a new per-instance verdict cache. Orchestrators should hold one. */
64
180
  declare function createVerdictCache(): Map<string, JudgeVerdict>;
181
+ /**
182
+ * Create a new per-instance defer-counter map. Orchestrators should hold one
183
+ * alongside their verdict cache so defer counts survive across extraction
184
+ * passes within a single orchestrator but do not leak across orchestrators.
185
+ */
186
+ declare function createDeferCountMap(): Map<string, number>;
65
187
 
66
- export { type JudgeBatchResult, type JudgeCandidate, type JudgeVerdict, clearVerdictCache, createVerdictCache, judgeFactDurability, validateProcedureExtraction, verdictCacheSize };
188
+ export { type JudgeBatchResult, type JudgeCandidate, type JudgeVerdict, type JudgeVerdictKind, type JudgeVerdictObservation, clearVerdictCache, createDeferCountMap, createVerdictCache, getVerdictKind, isDurableVerdict, isValidCachedVerdict, judgeFactDurability, normalizeCachedVerdict, validateProcedureExtraction, verdictCacheSize };
@@ -1,17 +1,27 @@
1
1
  import {
2
2
  clearVerdictCache,
3
+ createDeferCountMap,
3
4
  createVerdictCache,
5
+ getVerdictKind,
6
+ isDurableVerdict,
7
+ isValidCachedVerdict,
4
8
  judgeFactDurability,
9
+ normalizeCachedVerdict,
5
10
  validateProcedureExtraction,
6
11
  verdictCacheSize
7
- } from "./chunk-LAYN4LDC.js";
12
+ } from "./chunk-C4SQJZAF.js";
8
13
  import "./chunk-UZB5KHKX.js";
9
14
  import "./chunk-QDW3E4RD.js";
10
15
  import "./chunk-2ODBA7MQ.js";
11
16
  export {
12
17
  clearVerdictCache,
18
+ createDeferCountMap,
13
19
  createVerdictCache,
20
+ getVerdictKind,
21
+ isDurableVerdict,
22
+ isValidCachedVerdict,
14
23
  judgeFactDurability,
24
+ normalizeCachedVerdict,
15
25
  validateProcedureExtraction,
16
26
  verdictCacheSize
17
27
  };
@@ -1,16 +1,17 @@
1
1
  import {
2
2
  ExtractionEngine
3
- } from "./chunk-2VFW5K5U.js";
4
- import "./chunk-UEYA6UC7.js";
3
+ } from "./chunk-S3EEFKNY.js";
4
+ import "./chunk-NZLQTHS5.js";
5
+ import "./chunk-54V4BZWP.js";
5
6
  import "./chunk-NBNN5GOB.js";
6
- import "./chunk-UPMD5XND.js";
7
7
  import "./chunk-FEMOX5AD.js";
8
+ import "./chunk-JL2PU6AI.js";
8
9
  import "./chunk-VEWZZM3H.js";
9
- import "./chunk-LK6SGL53.js";
10
10
  import "./chunk-GZCUW5IC.js";
11
+ import "./chunk-LK6SGL53.js";
11
12
  import "./chunk-EJI5XIBB.js";
12
- import "./chunk-QKAH5B6E.js";
13
- import "./chunk-KEG4GNGI.js";
13
+ import "./chunk-3GXCSUXR.js";
14
+ import "./chunk-XZ2TIKGC.js";
14
15
  import "./chunk-ODWDQNRE.js";
15
16
  import "./chunk-Y27UJK6V.js";
16
17
  import "./chunk-UZB5KHKX.js";
@@ -16,6 +16,10 @@ interface FallbackLlmResponse {
16
16
  totalTokens?: number;
17
17
  };
18
18
  }
19
+ interface FallbackLlmRuntimeContext {
20
+ agentDir?: string;
21
+ workspaceDir?: string;
22
+ }
19
23
  /**
20
24
  * Generic fallback LLM client that uses the gateway's default AI configuration
21
25
  * and walks through the full fallback chain (primary + fallbacks).
@@ -23,7 +27,8 @@ interface FallbackLlmResponse {
23
27
  */
24
28
  declare class FallbackLlmClient {
25
29
  private gatewayConfig;
26
- constructor(gatewayConfig?: GatewayConfig);
30
+ private runtimeContext;
31
+ constructor(gatewayConfig?: GatewayConfig, runtimeContext?: FallbackLlmRuntimeContext);
27
32
  /**
28
33
  * Check if fallback is available (gateway config has at least one model).
29
34
  */
@@ -105,10 +110,14 @@ declare class FallbackLlmClient {
105
110
  * Call OpenAI-compatible API.
106
111
  */
107
112
  private callOpenAI;
113
+ /**
114
+ * Call an OpenAI-compatible Responses API.
115
+ */
116
+ private callOpenAIResponses;
108
117
  /**
109
118
  * Call Anthropic Messages API.
110
119
  */
111
120
  private callAnthropic;
112
121
  }
113
122
 
114
- export { FallbackLlmClient, type FallbackLlmOptions, type FallbackLlmResponse };
123
+ export { FallbackLlmClient, type FallbackLlmOptions, type FallbackLlmResponse, type FallbackLlmRuntimeContext };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  FallbackLlmClient
3
- } from "./chunk-QKAH5B6E.js";
4
- import "./chunk-KEG4GNGI.js";
3
+ } from "./chunk-3GXCSUXR.js";
4
+ import "./chunk-XZ2TIKGC.js";
5
5
  import "./chunk-ODWDQNRE.js";
6
6
  import "./chunk-Y27UJK6V.js";
7
7
  import "./chunk-UZB5KHKX.js";
@@ -0,0 +1,100 @@
1
+ import { MemoryEdgeSource, RemnicGraph } from './graph-retrieval.js';
2
+
3
+ /**
4
+ * Graph-based retrieval integration (issue #559 PR 4 of 5).
5
+ *
6
+ * Pure helper that composes `extractGraphEdges` (PR 2) and `queryGraph`
7
+ * (PR 3) into a single retrieval surface. Operators opt in via the
8
+ * `recallGraphEnabled` config flag; until the `retrieval-graph` bench in
9
+ * PR 5 justifies flipping the default, this tier ships disabled.
10
+ *
11
+ * Kept as a pure function so the orchestrator can call it with whatever
12
+ * candidate pool it has (hot cache, recent window, QMD first-pass, etc.)
13
+ * without forcing a specific storage contract on this module.
14
+ */
15
+
16
+ /**
17
+ * Subset of `PluginConfig` that governs the graph retrieval tier. Kept
18
+ * as a local interface so this module does not pull in the full
19
+ * `PluginConfig` import — `orchestrator.ts` can pass the fields directly.
20
+ */
21
+ interface GraphRecallConfig {
22
+ /** Master enable flag. When false, `runGraphRecall` is a no-op. */
23
+ recallGraphEnabled: boolean;
24
+ /** PPR damping factor (default 0.85). */
25
+ recallGraphDamping: number;
26
+ /** PPR power-iteration cap (default 20). */
27
+ recallGraphIterations: number;
28
+ /**
29
+ * Max memories the graph tier returns. `0` disables the tier's
30
+ * contribution without touching `recallGraphEnabled`.
31
+ */
32
+ recallGraphTopK: number;
33
+ }
34
+ /** Per-invocation options for `runGraphRecall`. */
35
+ interface GraphRecallOptions {
36
+ /**
37
+ * Candidate memories to build the graph from. Typically the caller's
38
+ * recall candidate pool (hot cache + QMD first-pass). The extractor
39
+ * reads only the fields declared on `MemoryEdgeSource` — callers can
40
+ * safely pass richer memory objects.
41
+ */
42
+ memories: readonly MemoryEdgeSource[];
43
+ /**
44
+ * Seed memory / entity ids produced by the query-to-graph matcher.
45
+ * Typically the ids of the top QMD hits plus any entity-exact matches.
46
+ * If empty, PPR falls back to a uniform distribution over graph nodes.
47
+ */
48
+ seedIds: readonly string[];
49
+ /**
50
+ * Optional per-seed weights. When provided, PPR starts from the
51
+ * weighted distribution instead of uniform-over-seeds.
52
+ */
53
+ seedWeights?: ReadonlyMap<string, number> | Readonly<Record<string, number>>;
54
+ }
55
+ /** A single result from the graph tier. */
56
+ interface GraphRecallResult {
57
+ /** Memory id (the `to` of the highest-scoring `memory`-typed node). */
58
+ id: string;
59
+ /** PPR score in [0, 1]. Higher is better. */
60
+ score: number;
61
+ }
62
+ /** The full shape returned by `runGraphRecall`. */
63
+ interface GraphRecallRun {
64
+ /**
65
+ * Whether the graph tier actually ran. `false` when `recallGraphEnabled`
66
+ * is `false` or `recallGraphTopK <= 0` — in both cases `results` is `[]`
67
+ * and `reason` indicates which gate short-circuited.
68
+ */
69
+ ran: boolean;
70
+ /**
71
+ * Memory-typed ranked results. Entity / agent nodes are filtered out
72
+ * because the orchestrator merges this list with memory-typed QMD
73
+ * results via MMR.
74
+ */
75
+ results: GraphRecallResult[];
76
+ /** The graph that was built (or `null` if the tier did not run). */
77
+ graph: RemnicGraph | null;
78
+ /** Debugging tag for tier-explain surfaces. */
79
+ reason: "ran" | "disabled" | "topk-zero" | "empty-input";
80
+ /** Number of power-iteration rounds that executed. */
81
+ iterations: number;
82
+ /** Whether PPR's L1 delta fell below tolerance before the iter cap. */
83
+ converged: boolean;
84
+ }
85
+ /**
86
+ * Pure graph retrieval run.
87
+ *
88
+ * 1. Short-circuits to `{ ran: false }` when the feature flag is off,
89
+ * `topK <= 0`, or the memory pool is empty. No graph is built, no
90
+ * PPR runs — this preserves the zero-cost guarantee for
91
+ * `recallGraphEnabled: false` (the default).
92
+ * 2. Otherwise builds the retrieval graph from the candidate pool via
93
+ * `buildGraphFromMemories` (PR 2 extractor).
94
+ * 3. Runs Personalized PageRank via `queryGraph` (PR 3).
95
+ * 4. Projects ranked nodes to memory-typed ids only — entity and agent
96
+ * nodes never appear in the recall result set.
97
+ */
98
+ declare function runGraphRecall(config: GraphRecallConfig, options: GraphRecallOptions): GraphRecallRun;
99
+
100
+ export { type GraphRecallConfig, type GraphRecallOptions, type GraphRecallResult, type GraphRecallRun, runGraphRecall };
@@ -0,0 +1,8 @@
1
+ import {
2
+ runGraphRecall
3
+ } from "./chunk-DGVM5SFL.js";
4
+ import "./chunk-64NJRYU2.js";
5
+ export {
6
+ runGraphRecall
7
+ };
8
+ //# sourceMappingURL=graph-recall.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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":[]}
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  searchHarmonicRetrieval
3
- } from "./chunk-AAI7JARD.js";
3
+ } from "./chunk-HMDCOMYU.js";
4
4
  import "./chunk-C6QPK5GG.js";
5
+ import "./chunk-PVGDJXVK.js";
5
6
  import "./chunk-NGAVDO7E.js";
6
7
  import "./chunk-DT5TVLJE.js";
7
8
  import "./chunk-DGXUHMOV.js";