@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,85 @@
1
+ import { JudgeVerdictKind } from './extraction-judge.js';
2
+ import './types.js';
3
+ import './local-llm.js';
4
+ import './model-registry.js';
5
+ import './fallback-llm.js';
6
+
7
+ /**
8
+ * Extraction Judge Training Data Shim (issue #562, PR 4).
9
+ *
10
+ * Opt-in collector for `(candidate_text, verdict_kind, reason,
11
+ * ground_truth_label?)` tuples. Rows are appended to JSONL files under
12
+ * `~/.remnic/judge-training/<YYYY-MM-DD>.jsonl` so operators can ship the
13
+ * data into a future GRPO training pipeline without exfiltrating live
14
+ * memory content through the regular observation ledger.
15
+ *
16
+ * Gating:
17
+ * - Off by default. Must be explicitly enabled via
18
+ * `collectJudgeTrainingPairs: true` in plugin config.
19
+ * - The ground-truth label is always optional — labels are added out-of-
20
+ * band once reviewers disambiguate the candidate's fate.
21
+ *
22
+ * Privacy: the row carries only what the judge already sees — the
23
+ * candidate text and its metadata. It does NOT carry session keys,
24
+ * principal IDs, or any user identifiers. The file lives in the user's
25
+ * home directory rather than the shared memory directory so it is never
26
+ * committed, sync'd, or bundled into exports.
27
+ */
28
+
29
+ /**
30
+ * Persisted training row. Intentionally minimal: just the signal needed
31
+ * to train a judge replacement policy. Schema version is tagged so future
32
+ * readers can migrate older rows.
33
+ */
34
+ interface JudgeTrainingPair {
35
+ version: 1;
36
+ ts: string;
37
+ candidateText: string;
38
+ candidateCategory: string;
39
+ candidateConfidence?: number;
40
+ verdictKind: JudgeVerdictKind;
41
+ reason: string;
42
+ /**
43
+ * Number of prior deferrals when the verdict was resolved. `0` for the
44
+ * first resolution; only set when known (defer pathway).
45
+ */
46
+ priorDeferrals?: number;
47
+ /**
48
+ * Optional human-applied ground-truth label. Added after the fact by a
49
+ * reviewer / labelling script; not present on fresh rows.
50
+ */
51
+ groundTruthLabel?: JudgeVerdictKind;
52
+ }
53
+ interface JudgeTrainingOptions {
54
+ enabled: boolean;
55
+ /**
56
+ * Override for the output directory. Defaults to
57
+ * `~/.remnic/judge-training`. Tests pass a temp path here.
58
+ */
59
+ directory?: string;
60
+ }
61
+ declare function resolveTrainingDir(options: JudgeTrainingOptions): string;
62
+ declare function trainingFilePathFor(directory: string, iso: string): string;
63
+ /**
64
+ * Append a single training row. Fails open — write errors are logged at
65
+ * debug level and swallowed, same policy as the telemetry emitter.
66
+ * No-op when `options.enabled` is false.
67
+ */
68
+ declare function recordJudgeTrainingPair(row: JudgeTrainingPair, options: JudgeTrainingOptions): Promise<void>;
69
+ /**
70
+ * Read all training rows from the configured directory. Returns an empty
71
+ * array when the directory is missing. Malformed lines are skipped and
72
+ * counted in the returned `malformed` tally.
73
+ */
74
+ declare function readJudgeTrainingPairs(options: Pick<JudgeTrainingOptions, "directory">): Promise<{
75
+ rows: JudgeTrainingPair[];
76
+ malformed: number;
77
+ }>;
78
+ /**
79
+ * Structural validator matching the persisted schema. Forward-compat: an
80
+ * unknown `verdictKind` string is treated as malformed (strict training
81
+ * signal — we do not want to admit unlabelled gibberish into a trainer).
82
+ */
83
+ declare function isValidTrainingPair(value: unknown): value is JudgeTrainingPair;
84
+
85
+ export { type JudgeTrainingOptions, type JudgeTrainingPair, isValidTrainingPair, readJudgeTrainingPairs, recordJudgeTrainingPair, resolveTrainingDir, trainingFilePathFor };
@@ -0,0 +1,16 @@
1
+ import {
2
+ isValidTrainingPair,
3
+ readJudgeTrainingPairs,
4
+ recordJudgeTrainingPair,
5
+ resolveTrainingDir,
6
+ trainingFilePathFor
7
+ } from "./chunk-DF3RVK3X.js";
8
+ import "./chunk-2ODBA7MQ.js";
9
+ export {
10
+ isValidTrainingPair,
11
+ readJudgeTrainingPairs,
12
+ recordJudgeTrainingPair,
13
+ resolveTrainingDir,
14
+ trainingFilePathFor
15
+ };
16
+ //# sourceMappingURL=extraction-judge-training.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -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,18 +1,19 @@
1
1
  import {
2
2
  ExtractionEngine
3
- } from "./chunk-3SV6CQHO.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
7
  import "./chunk-FEMOX5AD.js";
7
8
  import "./chunk-JL2PU6AI.js";
8
- import "./chunk-GZCUW5IC.js";
9
9
  import "./chunk-VEWZZM3H.js";
10
+ import "./chunk-GZCUW5IC.js";
10
11
  import "./chunk-LK6SGL53.js";
11
12
  import "./chunk-EJI5XIBB.js";
12
- import "./chunk-44ICJRF3.js";
13
+ import "./chunk-3GXCSUXR.js";
13
14
  import "./chunk-XZ2TIKGC.js";
14
- import "./chunk-Y27UJK6V.js";
15
15
  import "./chunk-ODWDQNRE.js";
16
+ import "./chunk-Y27UJK6V.js";
16
17
  import "./chunk-UZB5KHKX.js";
17
18
  import "./chunk-MARWOCVP.js";
18
19
  import "./chunk-EEQLFRUM.js";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  FallbackLlmClient
3
- } from "./chunk-44ICJRF3.js";
3
+ } from "./chunk-3GXCSUXR.js";
4
4
  import "./chunk-XZ2TIKGC.js";
5
- import "./chunk-Y27UJK6V.js";
6
5
  import "./chunk-ODWDQNRE.js";
6
+ import "./chunk-Y27UJK6V.js";
7
7
  import "./chunk-UZB5KHKX.js";
8
8
  import "./chunk-MARWOCVP.js";
9
9
  import "./chunk-2ODBA7MQ.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":[]}