@remnic/core 1.1.11 → 1.1.13

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 (1462) hide show
  1. package/README.md +3 -3
  2. package/dist/access-cli.d.ts +2 -1
  3. package/dist/access-cli.js +293 -104
  4. package/dist/access-cli.js.map +1 -1
  5. package/dist/access-http.d.ts +31 -62
  6. package/dist/access-http.js +53 -35
  7. package/dist/access-mcp.d.ts +31 -8
  8. package/dist/access-mcp.js +45 -34
  9. package/dist/access-schema.d.ts +197 -14
  10. package/dist/access-schema.js +16 -5
  11. package/dist/access-service-DcCDmNYC.d.ts +1542 -0
  12. package/dist/access-service.d.ts +30 -9
  13. package/dist/access-service.js +42 -32
  14. package/dist/action-confidence.d.ts +83 -0
  15. package/dist/action-confidence.js +22 -0
  16. package/dist/active-memory-bridge.d.ts +1 -1
  17. package/dist/active-memory-bridge.js +2 -2
  18. package/dist/active-recall.d.ts +1 -1
  19. package/dist/active-recall.js +11 -3
  20. package/dist/active-recall.js.map +1 -1
  21. package/dist/adapters/claude-code.d.ts +24 -0
  22. package/dist/adapters/claude-code.js +9 -0
  23. package/dist/adapters/codex.d.ts +25 -0
  24. package/dist/adapters/codex.js +9 -0
  25. package/dist/adapters/hermes.d.ts +35 -0
  26. package/dist/adapters/hermes.js +9 -0
  27. package/dist/adapters/index.d.ts +6 -0
  28. package/dist/adapters/index.js +26 -0
  29. package/dist/adapters/registry.d.ts +20 -0
  30. package/dist/adapters/registry.js +13 -0
  31. package/dist/adapters/replit.d.ts +28 -0
  32. package/dist/adapters/replit.js +9 -0
  33. package/dist/adapters/types.d.ts +43 -0
  34. package/dist/adapters/types.js +8 -0
  35. package/dist/behavior-learner.d.ts +1 -1
  36. package/dist/behavior-signals.d.ts +1 -1
  37. package/dist/bootstrap.d.ts +23 -6
  38. package/dist/boxes.d.ts +7 -0
  39. package/dist/boxes.js +1 -1
  40. package/dist/briefing.d.ts +5 -3
  41. package/dist/briefing.js +10 -7
  42. package/dist/buffer-surprise-report.d.ts +1 -1
  43. package/dist/buffer-surprise-report.js +1 -1
  44. package/dist/buffer.d.ts +18 -4
  45. package/dist/buffer.js +1 -1
  46. package/dist/calibration.d.ts +1 -1
  47. package/dist/calibration.js +6 -6
  48. package/dist/capsule-cli.d.ts +4 -4
  49. package/dist/capsule-cli.js +1 -1
  50. package/dist/capsule-crypto-5CYAGVC5.js +18 -0
  51. package/dist/capsule-merge-4MGKE7C5.js +189 -0
  52. package/dist/causal-behavior.d.ts +9 -29
  53. package/dist/causal-behavior.js +6 -3
  54. package/dist/causal-behavior.js.map +1 -1
  55. package/dist/causal-chain.js +3 -2
  56. package/dist/causal-consolidation.d.ts +2 -2
  57. package/dist/causal-consolidation.js +28 -17
  58. package/dist/causal-consolidation.js.map +1 -1
  59. package/dist/causal-retrieval.js +3 -3
  60. package/dist/causal-trajectory.js +1 -1
  61. package/dist/chunk-25MQ7IHJ.js +427 -0
  62. package/dist/chunk-25MQ7IHJ.js.map +1 -0
  63. package/dist/chunk-2F2W355T.js +256 -0
  64. package/dist/chunk-2F2W355T.js.map +1 -0
  65. package/dist/chunk-2KI4QFHU.js +228 -0
  66. package/dist/chunk-2KI4QFHU.js.map +1 -0
  67. package/dist/chunk-2PRQG7PV.js +86 -0
  68. package/dist/chunk-2PRQG7PV.js.map +1 -0
  69. package/dist/chunk-2QR3XXIC.js +2272 -0
  70. package/dist/chunk-2QR3XXIC.js.map +1 -0
  71. package/dist/chunk-2WWLHTZY.js +121 -0
  72. package/dist/chunk-326G7DJK.js +2185 -0
  73. package/dist/chunk-326G7DJK.js.map +1 -0
  74. package/dist/chunk-34DQE4KF.js +174 -0
  75. package/dist/chunk-34DQE4KF.js.map +1 -0
  76. package/dist/chunk-3APJ5EVB.js +601 -0
  77. package/dist/chunk-3APJ5EVB.js.map +1 -0
  78. package/dist/chunk-3HPAPHUK.js +51 -0
  79. package/dist/chunk-3HPAPHUK.js.map +1 -0
  80. package/dist/chunk-3JXBXXM2.js +69 -0
  81. package/dist/chunk-3JXBXXM2.js.map +1 -0
  82. package/dist/chunk-3KW65B36.js +681 -0
  83. package/dist/chunk-3KW65B36.js.map +1 -0
  84. package/dist/chunk-3UXOZBHV.js +20 -0
  85. package/dist/chunk-3UXOZBHV.js.map +1 -0
  86. package/dist/chunk-3VAL7ZL2.js +266 -0
  87. package/dist/chunk-3VAL7ZL2.js.map +1 -0
  88. package/dist/chunk-3Y4P7RXM.js +31 -0
  89. package/dist/chunk-3Y4P7RXM.js.map +1 -0
  90. package/dist/chunk-47VWKCAF.js +273 -0
  91. package/dist/chunk-47VWKCAF.js.map +1 -0
  92. package/dist/chunk-4CRG46BG.js +271 -0
  93. package/dist/chunk-4RA3C3EV.js +60 -0
  94. package/dist/chunk-4RA3C3EV.js.map +1 -0
  95. package/dist/chunk-5375UYTQ.js +914 -0
  96. package/dist/chunk-5375UYTQ.js.map +1 -0
  97. package/dist/chunk-56K5QLHX.js +506 -0
  98. package/dist/chunk-56K5QLHX.js.map +1 -0
  99. package/dist/chunk-5NXIJZFX.js +180 -0
  100. package/dist/chunk-5NXIJZFX.js.map +1 -0
  101. package/dist/chunk-5RGLBDQF.js +596 -0
  102. package/dist/chunk-5RGLBDQF.js.map +1 -0
  103. package/dist/chunk-5UZXUTVO.js +9 -0
  104. package/dist/chunk-5UZXUTVO.js.map +1 -0
  105. package/dist/chunk-65PG43EQ.js +105 -0
  106. package/dist/chunk-65PG43EQ.js.map +1 -0
  107. package/dist/chunk-66DHUKLO.js +57 -0
  108. package/dist/chunk-66DHUKLO.js.map +1 -0
  109. package/dist/chunk-6FC5EGNV.js +46 -0
  110. package/dist/chunk-6FC5EGNV.js.map +1 -0
  111. package/dist/chunk-6H2TESSP.js +62 -0
  112. package/dist/chunk-6H2TESSP.js.map +1 -0
  113. package/dist/chunk-6LVVDPJ4.js +32 -0
  114. package/dist/chunk-6LVVDPJ4.js.map +1 -0
  115. package/dist/chunk-6NKAQ74D.js +2237 -0
  116. package/dist/chunk-6NKAQ74D.js.map +1 -0
  117. package/dist/chunk-6RVI47ZR.js +159 -0
  118. package/dist/chunk-6RVI47ZR.js.map +1 -0
  119. package/dist/chunk-7AAT6G4Q.js +5117 -0
  120. package/dist/chunk-7AAT6G4Q.js.map +1 -0
  121. package/dist/chunk-7DTASS5T.js +29 -0
  122. package/dist/chunk-7DTASS5T.js.map +1 -0
  123. package/dist/chunk-7IASACLB.js +596 -0
  124. package/dist/chunk-7MNMYOFP.js +32 -0
  125. package/dist/chunk-7MNMYOFP.js.map +1 -0
  126. package/dist/chunk-7N4KAIGN.js +133 -0
  127. package/dist/chunk-7N4KAIGN.js.map +1 -0
  128. package/dist/chunk-7OZ53EXP.js +101 -0
  129. package/dist/chunk-7OZ53EXP.js.map +1 -0
  130. package/dist/chunk-7XYTQGCC.js +134 -0
  131. package/dist/chunk-7XYTQGCC.js.map +1 -0
  132. package/dist/chunk-A2XUIMJ3.js +341 -0
  133. package/dist/chunk-A2XUIMJ3.js.map +1 -0
  134. package/dist/chunk-AC5LO7IU.js +308 -0
  135. package/dist/chunk-AC5LO7IU.js.map +1 -0
  136. package/dist/chunk-AGZQD76C.js +201 -0
  137. package/dist/chunk-AGZQD76C.js.map +1 -0
  138. package/dist/chunk-AH2JUU6X.js +336 -0
  139. package/dist/chunk-AH2JUU6X.js.map +1 -0
  140. package/dist/chunk-APO3DCMU.js +361 -0
  141. package/dist/chunk-APO3DCMU.js.map +1 -0
  142. package/dist/chunk-BFBF3XEF.js +283 -0
  143. package/dist/chunk-BFBF3XEF.js.map +1 -0
  144. package/dist/chunk-BJ3KMYTB.js +1974 -0
  145. package/dist/chunk-BJ3KMYTB.js.map +1 -0
  146. package/dist/chunk-C5BCH4ZS.js +317 -0
  147. package/dist/chunk-C5BCH4ZS.js.map +1 -0
  148. package/dist/chunk-CHEL3SKB.js +6758 -0
  149. package/dist/chunk-CHEL3SKB.js.map +1 -0
  150. package/dist/chunk-CQZRLNMV.js +1491 -0
  151. package/dist/chunk-CQZRLNMV.js.map +1 -0
  152. package/dist/chunk-D46YSIYX.js +892 -0
  153. package/dist/chunk-D46YSIYX.js.map +1 -0
  154. package/dist/chunk-DB5A3NHS.js +906 -0
  155. package/dist/chunk-DB5A3NHS.js.map +1 -0
  156. package/dist/chunk-DINWEURR.js +648 -0
  157. package/dist/chunk-DINWEURR.js.map +1 -0
  158. package/dist/chunk-DK5LDEQM.js +530 -0
  159. package/dist/chunk-DK5LDEQM.js.map +1 -0
  160. package/dist/chunk-DOM4GKSW.js +34 -0
  161. package/dist/chunk-DOM4GKSW.js.map +1 -0
  162. package/dist/chunk-EDTHC6UD.js +1075 -0
  163. package/dist/chunk-EDTHC6UD.js.map +1 -0
  164. package/dist/chunk-EFJ3MQ4V.js +721 -0
  165. package/dist/chunk-EHRTFRWW.js +89 -0
  166. package/dist/chunk-EHRTFRWW.js.map +1 -0
  167. package/dist/chunk-FAJ7FZYM.js +11 -0
  168. package/dist/chunk-FAJ7FZYM.js.map +1 -0
  169. package/dist/chunk-FBYESMQ2.js +570 -0
  170. package/dist/chunk-FBYESMQ2.js.map +1 -0
  171. package/dist/chunk-FDU6HUUL.js +147 -0
  172. package/dist/chunk-FF4KLI5W.js +99 -0
  173. package/dist/chunk-FF4KLI5W.js.map +1 -0
  174. package/dist/chunk-FIT6DMX6.js +310 -0
  175. package/dist/chunk-FIT6DMX6.js.map +1 -0
  176. package/dist/chunk-FJ43PRLT.js +272 -0
  177. package/dist/chunk-FJ43PRLT.js.map +1 -0
  178. package/dist/chunk-FKFMOY3N.js +32 -0
  179. package/dist/chunk-FKFMOY3N.js.map +1 -0
  180. package/dist/chunk-FLTNHQK6.js +262 -0
  181. package/dist/chunk-FLTNHQK6.js.map +1 -0
  182. package/dist/chunk-GA454ALV.js +12436 -0
  183. package/dist/chunk-GA454ALV.js.map +1 -0
  184. package/dist/chunk-GGKRUQOO.js +228 -0
  185. package/dist/chunk-GIF42EW3.js +63 -0
  186. package/dist/chunk-GIF42EW3.js.map +1 -0
  187. package/dist/chunk-GL6I6MEQ.js +647 -0
  188. package/dist/chunk-H3ME6L6D.js +709 -0
  189. package/dist/chunk-H3ME6L6D.js.map +1 -0
  190. package/dist/chunk-HHLLAQGZ.js +1 -0
  191. package/dist/chunk-HXXBL2KD.js +2040 -0
  192. package/dist/chunk-I5V2VDIW.js +219 -0
  193. package/dist/chunk-I5V2VDIW.js.map +1 -0
  194. package/dist/chunk-I6K5FBRQ.js +35 -0
  195. package/dist/chunk-I6K5FBRQ.js.map +1 -0
  196. package/dist/chunk-ICRIXAP2.js +121 -0
  197. package/dist/chunk-ICRIXAP2.js.map +1 -0
  198. package/dist/chunk-J4EB7DNW.js +11 -0
  199. package/dist/chunk-J4EB7DNW.js.map +1 -0
  200. package/dist/chunk-JLFA7DQG.js +62 -0
  201. package/dist/chunk-JLFA7DQG.js.map +1 -0
  202. package/dist/chunk-KJTKLXTH.js +9 -0
  203. package/dist/chunk-KJTKLXTH.js.map +1 -0
  204. package/dist/chunk-KLAO5DGL.js +917 -0
  205. package/dist/chunk-KLAO5DGL.js.map +1 -0
  206. package/dist/chunk-KNKUID7G.js +183 -0
  207. package/dist/chunk-KOSORCJG.js +624 -0
  208. package/dist/chunk-KOSORCJG.js.map +1 -0
  209. package/dist/chunk-KUJVMMZQ.js +1262 -0
  210. package/dist/chunk-KUJVMMZQ.js.map +1 -0
  211. package/dist/chunk-LCR46JY5.js +123 -0
  212. package/dist/chunk-LCR46JY5.js.map +1 -0
  213. package/dist/chunk-LLQ2LLWF.js +148 -0
  214. package/dist/chunk-LLQ2LLWF.js.map +1 -0
  215. package/dist/chunk-LPMVBPA3.js +236 -0
  216. package/dist/chunk-LT3NLYSI.js +50 -0
  217. package/dist/chunk-LT3NLYSI.js.map +1 -0
  218. package/dist/chunk-LUDTDZLK.js +287 -0
  219. package/dist/chunk-LUDTDZLK.js.map +1 -0
  220. package/dist/chunk-M23FSH32.js +3963 -0
  221. package/dist/chunk-M23FSH32.js.map +1 -0
  222. package/dist/chunk-MC26UJIM.js +118 -0
  223. package/dist/chunk-ME6ESPZU.js +119 -0
  224. package/dist/chunk-ME6ESPZU.js.map +1 -0
  225. package/dist/chunk-MGKYQQYF.js +272 -0
  226. package/dist/chunk-MGKYQQYF.js.map +1 -0
  227. package/dist/chunk-MJFNCJXV.js +66 -0
  228. package/dist/chunk-MJFNCJXV.js.map +1 -0
  229. package/dist/chunk-MSWG7JI6.js +237 -0
  230. package/dist/chunk-MSWG7JI6.js.map +1 -0
  231. package/dist/chunk-MT25YHYH.js +141 -0
  232. package/dist/chunk-MT25YHYH.js.map +1 -0
  233. package/dist/chunk-MT4HVDUZ.js +53 -0
  234. package/dist/chunk-MY6TPVXW.js +219 -0
  235. package/dist/chunk-N2D6GXBM.js +267 -0
  236. package/dist/chunk-N2D6GXBM.js.map +1 -0
  237. package/dist/chunk-NJ3MJQZX.js +46 -0
  238. package/dist/chunk-NJ3MJQZX.js.map +1 -0
  239. package/dist/chunk-NMZY542O.js +335 -0
  240. package/dist/chunk-NMZY542O.js.map +1 -0
  241. package/dist/chunk-NNVTUXEB.js +23 -0
  242. package/dist/chunk-NZL6GGQE.js +375 -0
  243. package/dist/chunk-NZL6GGQE.js.map +1 -0
  244. package/dist/chunk-OAZ5MFUB.js +4124 -0
  245. package/dist/chunk-OAZ5MFUB.js.map +1 -0
  246. package/dist/chunk-OIGNEXKZ.js +237 -0
  247. package/dist/chunk-OIGNEXKZ.js.map +1 -0
  248. package/dist/chunk-OZKZ2TRP.js +3729 -0
  249. package/dist/chunk-OZKZ2TRP.js.map +1 -0
  250. package/dist/chunk-P4NEIHUT.js +108 -0
  251. package/dist/chunk-P7FMDTKL.js +103 -0
  252. package/dist/chunk-P7FMDTKL.js.map +1 -0
  253. package/dist/chunk-PD6O7AXF.js +110 -0
  254. package/dist/chunk-PD6O7AXF.js.map +1 -0
  255. package/dist/chunk-PHK3HARR.js +32 -0
  256. package/dist/chunk-PHK3HARR.js.map +1 -0
  257. package/dist/chunk-PIRJPV5T.js +98 -0
  258. package/dist/chunk-PIRJPV5T.js.map +1 -0
  259. package/dist/chunk-PK7H5L6Y.js +159 -0
  260. package/dist/chunk-PK7H5L6Y.js.map +1 -0
  261. package/dist/chunk-PR5FBTFU.js +233 -0
  262. package/dist/chunk-PR5FBTFU.js.map +1 -0
  263. package/dist/chunk-PU63GXWS.js +174 -0
  264. package/dist/chunk-PU63GXWS.js.map +1 -0
  265. package/dist/chunk-PYPOFEMK.js +294 -0
  266. package/dist/chunk-PYPOFEMK.js.map +1 -0
  267. package/dist/chunk-PZIAX57I.js +124 -0
  268. package/dist/chunk-PZIAX57I.js.map +1 -0
  269. package/dist/chunk-Q7P4WJDP.js +26 -0
  270. package/dist/chunk-Q7P4WJDP.js.map +1 -0
  271. package/dist/chunk-QDZ2RLEC.js +908 -0
  272. package/dist/chunk-QDZ2RLEC.js.map +1 -0
  273. package/dist/chunk-QQUAB63I.js +63 -0
  274. package/dist/chunk-QQUAB63I.js.map +1 -0
  275. package/dist/chunk-QRNI5JBH.js +18 -0
  276. package/dist/chunk-RHY3HH7P.js +601 -0
  277. package/dist/chunk-RHY3HH7P.js.map +1 -0
  278. package/dist/chunk-RK6F44Y6.js +84 -0
  279. package/dist/chunk-RK6F44Y6.js.map +1 -0
  280. package/dist/chunk-RRF5UOBJ.js +91 -0
  281. package/dist/chunk-RXDLTSWT.js +124 -0
  282. package/dist/chunk-RXDLTSWT.js.map +1 -0
  283. package/dist/chunk-RYED3SPJ.js +42 -0
  284. package/dist/chunk-RYED3SPJ.js.map +1 -0
  285. package/dist/chunk-S7KDBTWT.js +106 -0
  286. package/dist/chunk-S7KDBTWT.js.map +1 -0
  287. package/dist/chunk-SEDEKFYQ.js +1 -0
  288. package/dist/chunk-SOAU2OE2.js +125 -0
  289. package/dist/chunk-SOAU2OE2.js.map +1 -0
  290. package/dist/chunk-TECVW3JP.js +36 -0
  291. package/dist/chunk-TECVW3JP.js.map +1 -0
  292. package/dist/chunk-TFO23QT4.js +88 -0
  293. package/dist/chunk-TFO23QT4.js.map +1 -0
  294. package/dist/chunk-TK4UEOSK.js +76 -0
  295. package/dist/chunk-TK4UEOSK.js.map +1 -0
  296. package/dist/chunk-TKWGAOLV.js +122 -0
  297. package/dist/chunk-TKWGAOLV.js.map +1 -0
  298. package/dist/chunk-TMM4S4IJ.js +597 -0
  299. package/dist/chunk-TMM4S4IJ.js.map +1 -0
  300. package/dist/chunk-TMQLARTH.js +188 -0
  301. package/dist/chunk-TMQLARTH.js.map +1 -0
  302. package/dist/chunk-TPDBFYEG.js +130 -0
  303. package/dist/chunk-TPDBFYEG.js.map +1 -0
  304. package/dist/chunk-TPMQ3G6Z.js +145 -0
  305. package/dist/chunk-TPMQ3G6Z.js.map +1 -0
  306. package/dist/chunk-TZOLIGIG.js +61 -0
  307. package/dist/chunk-TZOLIGIG.js.map +1 -0
  308. package/dist/chunk-U3PN77QT.js +113 -0
  309. package/dist/chunk-U3WSW6PZ.js +277 -0
  310. package/dist/chunk-U4SCL7B7.js +640 -0
  311. package/dist/chunk-U4SCL7B7.js.map +1 -0
  312. package/dist/chunk-UWK5OXUJ.js +156 -0
  313. package/dist/chunk-UWK5OXUJ.js.map +1 -0
  314. package/dist/chunk-UWVJF25J.js +74 -0
  315. package/dist/chunk-UXHQAFNA.js +1317 -0
  316. package/dist/chunk-UXHQAFNA.js.map +1 -0
  317. package/dist/chunk-V5OCT34X.js +1 -0
  318. package/dist/chunk-V5OCT34X.js.map +1 -0
  319. package/dist/chunk-VLXA6PI2.js +304 -0
  320. package/dist/chunk-VLXA6PI2.js.map +1 -0
  321. package/dist/chunk-VNO6ZJ35.js +500 -0
  322. package/dist/chunk-VNO6ZJ35.js.map +1 -0
  323. package/dist/chunk-VW676BEI.js +827 -0
  324. package/dist/chunk-VW676BEI.js.map +1 -0
  325. package/dist/chunk-VWT3F4IV.js +2161 -0
  326. package/dist/chunk-VWT3F4IV.js.map +1 -0
  327. package/dist/chunk-W3LR522O.js +2296 -0
  328. package/dist/chunk-W3LR522O.js.map +1 -0
  329. package/dist/chunk-W4L6CZKA.js +96 -0
  330. package/dist/chunk-W4L6CZKA.js.map +1 -0
  331. package/dist/chunk-W4RVMTHR.js +372 -0
  332. package/dist/chunk-W4RVMTHR.js.map +1 -0
  333. package/dist/chunk-WEHSQBFR.js +188 -0
  334. package/dist/chunk-WEHSQBFR.js.map +1 -0
  335. package/dist/chunk-WELDCG6C.js +380 -0
  336. package/dist/chunk-WELDCG6C.js.map +1 -0
  337. package/dist/chunk-WZYKANL3.js +2800 -0
  338. package/dist/chunk-WZYKANL3.js.map +1 -0
  339. package/dist/chunk-XIG5PDM7.js +48 -0
  340. package/dist/chunk-XJNBEDFE.js +193 -0
  341. package/dist/chunk-XJNBEDFE.js.map +1 -0
  342. package/dist/chunk-XVVIG67A.js +291 -0
  343. package/dist/chunk-XVVIG67A.js.map +1 -0
  344. package/dist/chunk-XVZ7B3HG.js +135 -0
  345. package/dist/chunk-YBPYIAA5.js +73 -0
  346. package/dist/chunk-YBPYIAA5.js.map +1 -0
  347. package/dist/chunk-Z734BLO3.js +21 -0
  348. package/dist/chunk-Z734BLO3.js.map +1 -0
  349. package/dist/chunk-ZKSK55RC.js +269 -0
  350. package/dist/chunk-ZKSK55RC.js.map +1 -0
  351. package/dist/chunk-ZTFCYYEZ.js +69 -0
  352. package/dist/chunk-ZTFCYYEZ.js.map +1 -0
  353. package/dist/chunk-ZY2MNJR6.js +329 -0
  354. package/dist/chunk-ZY2MNJR6.js.map +1 -0
  355. package/dist/cli-D3VpkVwB.d.ts +1136 -0
  356. package/dist/cli.d.ts +42 -10
  357. package/dist/cli.js +121 -58
  358. package/dist/codex-cli-fallback.d.ts +1 -0
  359. package/dist/codex-cli-fallback.js +1 -1
  360. package/dist/commitment-ledger.js +1 -1
  361. package/dist/compat/checks.d.ts +5 -0
  362. package/dist/compat/checks.js +11 -0
  363. package/dist/compat/checks.js.map +1 -0
  364. package/dist/compat/types.d.ts +30 -0
  365. package/dist/compat/types.js +1 -0
  366. package/dist/compat/types.js.map +1 -0
  367. package/dist/compounding/engine.d.ts +221 -0
  368. package/dist/compounding/engine.js +32 -0
  369. package/dist/compounding/engine.js.map +1 -0
  370. package/dist/compounding/preference-consolidator.d.ts +92 -0
  371. package/dist/compounding/preference-consolidator.js +553 -0
  372. package/dist/compounding/preference-consolidator.js.map +1 -0
  373. package/dist/compression-optimizer.d.ts +1 -1
  374. package/dist/config.d.ts +5 -3
  375. package/dist/config.js +9 -4
  376. package/dist/conflict-policy-DyJ2wd-h.d.ts +4 -0
  377. package/dist/connectors/codex-materialize-runner.d.ts +64 -0
  378. package/dist/connectors/codex-materialize-runner.js +33 -0
  379. package/dist/connectors/codex-materialize-runner.js.map +1 -0
  380. package/dist/connectors/codex-materialize.d.ts +195 -0
  381. package/dist/connectors/codex-materialize.js +38 -0
  382. package/dist/connectors/codex-materialize.js.map +1 -0
  383. package/dist/connectors/index.d.ts +444 -0
  384. package/dist/connectors/index.js +115 -0
  385. package/dist/connectors/index.js.map +1 -0
  386. package/dist/connectors-cli-CwbyjGR7.d.ts +257 -0
  387. package/dist/connectors-cli.d.ts +1 -1
  388. package/dist/consolidation-provenance-check.d.ts +4 -2
  389. package/dist/consolidation-undo.d.ts +4 -2
  390. package/dist/contradiction/index.d.ts +258 -0
  391. package/dist/contradiction/index.js +43 -0
  392. package/dist/contradiction/index.js.map +1 -0
  393. package/dist/contradiction-review-ATP4S6IC.js +30 -0
  394. package/dist/contradiction-review-ATP4S6IC.js.map +1 -0
  395. package/dist/contradiction-scan-5A4IDZV5.js +13 -0
  396. package/dist/contradiction-scan-5A4IDZV5.js.map +1 -0
  397. package/dist/conversation-index/backend.d.ts +97 -0
  398. package/dist/conversation-index/backend.js +13 -0
  399. package/dist/conversation-index/backend.js.map +1 -0
  400. package/dist/conversation-index/chunker.d.ts +16 -0
  401. package/dist/conversation-index/chunker.js +8 -0
  402. package/dist/conversation-index/chunker.js.map +1 -0
  403. package/dist/conversation-index/cleanup.d.ts +11 -0
  404. package/dist/conversation-index/cleanup.js +9 -0
  405. package/dist/conversation-index/cleanup.js.map +1 -0
  406. package/dist/conversation-index/faiss-adapter.d.ts +6 -0
  407. package/dist/conversation-index/faiss-adapter.js +16 -0
  408. package/dist/conversation-index/faiss-adapter.js.map +1 -0
  409. package/dist/conversation-index/indexer.d.ts +23 -0
  410. package/dist/conversation-index/indexer.js +15 -0
  411. package/dist/conversation-index/indexer.js.map +1 -0
  412. package/dist/conversation-index/search.d.ts +6 -0
  413. package/dist/conversation-index/search.js +11 -0
  414. package/dist/conversation-index/search.js.map +1 -0
  415. package/dist/day-summary.d.ts +1 -1
  416. package/dist/delinearize.d.ts +1 -1
  417. package/dist/direct-answer-wiring.d.ts +1 -1
  418. package/dist/direct-answer-wiring.js +1 -1
  419. package/dist/direct-answer.d.ts +1 -1
  420. package/dist/embedding-fallback.d.ts +1 -1
  421. package/dist/embedding-fallback.js +2 -2
  422. package/dist/enrichment/index.d.ts +163 -0
  423. package/dist/enrichment/index.js +18 -0
  424. package/dist/enrichment/index.js.map +1 -0
  425. package/dist/entity-retrieval.d.ts +4 -2
  426. package/dist/entity-retrieval.js +9 -6
  427. package/dist/entity-schema.d.ts +1 -1
  428. package/dist/evals.js +1 -1
  429. package/dist/event-order-recall.d.ts +17 -0
  430. package/dist/event-order-recall.js +11 -0
  431. package/dist/event-order-recall.js.map +1 -0
  432. package/dist/evidence-pack.d.ts +3 -1
  433. package/dist/evidence-pack.js +5 -3
  434. package/dist/explicit-capture.d.ts +23 -6
  435. package/dist/explicit-capture.js +2 -2
  436. package/dist/explicit-cue-recall.d.ts +4 -1
  437. package/dist/explicit-cue-recall.js +4 -2
  438. package/dist/extraction-judge-telemetry.d.ts +1 -1
  439. package/dist/extraction-judge-training.d.ts +1 -1
  440. package/dist/extraction-judge-training.js +1 -1
  441. package/dist/extraction-judge.d.ts +1 -1
  442. package/dist/extraction.d.ts +1 -1
  443. package/dist/extraction.js +11 -10
  444. package/dist/faiss-adapter-CzPghc4C.d.ts +70 -0
  445. package/dist/fallback-llm.d.ts +4 -1
  446. package/dist/fallback-llm.js +6 -6
  447. package/dist/focused-list-recall.d.ts +17 -0
  448. package/dist/focused-list-recall.js +11 -0
  449. package/dist/focused-list-recall.js.map +1 -0
  450. package/dist/graph-edge-decay-5DI5GUNL.js +207 -0
  451. package/dist/identity-continuity.d.ts +1 -1
  452. package/dist/importance.d.ts +1 -1
  453. package/dist/index-DJ9QWMw-.d.ts +35 -0
  454. package/dist/index.d.ts +107 -715
  455. package/dist/index.js +657 -2611
  456. package/dist/index.js.map +1 -1
  457. package/dist/intent.d.ts +1 -1
  458. package/dist/intent.js +1 -1
  459. package/dist/lcm/archive.d.ts +89 -0
  460. package/dist/lcm/archive.js +12 -0
  461. package/dist/lcm/archive.js.map +1 -0
  462. package/dist/lcm/dag.d.ts +48 -0
  463. package/dist/lcm/dag.js +8 -0
  464. package/dist/lcm/dag.js.map +1 -0
  465. package/dist/lcm/engine.d.ts +116 -0
  466. package/dist/lcm/engine.js +20 -0
  467. package/dist/lcm/engine.js.map +1 -0
  468. package/dist/lcm/index.d.ts +12 -0
  469. package/dist/lcm/index.js +44 -0
  470. package/dist/lcm/index.js.map +1 -0
  471. package/dist/lcm/queue.d.ts +62 -0
  472. package/dist/lcm/queue.js +8 -0
  473. package/dist/lcm/queue.js.map +1 -0
  474. package/dist/lcm/recall.d.ts +20 -0
  475. package/dist/lcm/recall.js +8 -0
  476. package/dist/lcm/recall.js.map +1 -0
  477. package/dist/lcm/schema.d.ts +16 -0
  478. package/dist/lcm/schema.js +14 -0
  479. package/dist/lcm/schema.js.map +1 -0
  480. package/dist/lcm/summarizer.d.ts +38 -0
  481. package/dist/lcm/summarizer.js +12 -0
  482. package/dist/lcm/summarizer.js.map +1 -0
  483. package/dist/lcm/tools.d.ts +29 -0
  484. package/dist/lcm/tools.js +8 -0
  485. package/dist/lcm/tools.js.map +1 -0
  486. package/dist/lifecycle.d.ts +1 -1
  487. package/dist/live-connectors-runner.d.ts +1 -1
  488. package/dist/live-connectors-runner.js +5 -5
  489. package/dist/local-llm.d.ts +8 -4
  490. package/dist/local-llm.js +3 -3
  491. package/dist/maintenance/archive-observations.d.ts +18 -0
  492. package/dist/maintenance/archive-observations.js +8 -0
  493. package/dist/maintenance/archive-observations.js.map +1 -0
  494. package/dist/maintenance/backup-stamp.d.ts +3 -0
  495. package/dist/maintenance/backup-stamp.js +8 -0
  496. package/dist/maintenance/backup-stamp.js.map +1 -0
  497. package/dist/maintenance/memory-governance-cron.d.ts +85 -0
  498. package/dist/maintenance/memory-governance-cron.js +22 -0
  499. package/dist/maintenance/memory-governance-cron.js.map +1 -0
  500. package/dist/maintenance/memory-governance.d.ts +137 -0
  501. package/dist/maintenance/memory-governance.js +40 -0
  502. package/dist/maintenance/memory-governance.js.map +1 -0
  503. package/dist/maintenance/migrate-observations.d.ts +18 -0
  504. package/dist/maintenance/migrate-observations.js +9 -0
  505. package/dist/maintenance/migrate-observations.js.map +1 -0
  506. package/dist/maintenance/observation-ledger-utils.d.ts +10 -0
  507. package/dist/maintenance/observation-ledger-utils.js +10 -0
  508. package/dist/maintenance/observation-ledger-utils.js.map +1 -0
  509. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +15 -0
  510. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -0
  511. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js.map +1 -0
  512. package/dist/maintenance/rebuild-memory-projection.d.ts +77 -0
  513. package/dist/maintenance/rebuild-memory-projection.js +35 -0
  514. package/dist/maintenance/rebuild-memory-projection.js.map +1 -0
  515. package/dist/maintenance/rebuild-observations.d.ts +17 -0
  516. package/dist/maintenance/rebuild-observations.js +9 -0
  517. package/dist/maintenance/rebuild-observations.js.map +1 -0
  518. package/dist/mcp-memory-inspector-app.d.ts +124 -0
  519. package/dist/mcp-memory-inspector-app.js +20 -0
  520. package/dist/mcp-memory-inspector-app.js.map +1 -0
  521. package/dist/memory-action-policy.d.ts +1 -1
  522. package/dist/memory-cache.d.ts +1 -1
  523. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  524. package/dist/memory-projection-store.d.ts +108 -3
  525. package/dist/memory-projection-store.js +2 -1
  526. package/dist/memory-provenance.d.ts +57 -0
  527. package/dist/memory-provenance.js +13 -0
  528. package/dist/memory-provenance.js.map +1 -0
  529. package/dist/memory-worth-outcomes.d.ts +4 -2
  530. package/dist/migrate/from-engram.d.ts +24 -0
  531. package/dist/migrate/from-engram.js +12 -0
  532. package/dist/migrate/from-engram.js.map +1 -0
  533. package/dist/models-json.d.ts +1 -1
  534. package/dist/namespaces/migrate.d.ts +50 -0
  535. package/dist/namespaces/migrate.js +50 -0
  536. package/dist/namespaces/migrate.js.map +1 -0
  537. package/dist/namespaces/principal.d.ts +17 -0
  538. package/dist/namespaces/principal.js +16 -0
  539. package/dist/namespaces/principal.js.map +1 -0
  540. package/dist/namespaces/search.d.ts +46 -0
  541. package/dist/namespaces/search.js +28 -0
  542. package/dist/namespaces/search.js.map +1 -0
  543. package/dist/namespaces/storage.d.ts +32 -0
  544. package/dist/namespaces/storage.js +28 -0
  545. package/dist/namespaces/storage.js.map +1 -0
  546. package/dist/native-knowledge.d.ts +1 -1
  547. package/dist/network/tailscale.d.ts +41 -0
  548. package/dist/network/tailscale.js +9 -0
  549. package/dist/network/tailscale.js.map +1 -0
  550. package/dist/network/webdav.d.ts +39 -0
  551. package/dist/network/webdav.js +10 -0
  552. package/dist/network/webdav.js.map +1 -0
  553. package/dist/objective-state-writers.d.ts +1 -1
  554. package/dist/objective-state-writers.js +2 -2
  555. package/dist/operator-toolkit.d.ts +4 -2
  556. package/dist/operator-toolkit.js +35 -17
  557. package/dist/opik-exporter.js +2 -2
  558. package/dist/opik-exporter.js.map +1 -1
  559. package/dist/orchestrator-DuWl9Hwx.d.ts +1244 -0
  560. package/dist/orchestrator.d.ts +24 -7
  561. package/dist/orchestrator.js +107 -65
  562. package/dist/path-MR5JPYOP.js +9 -0
  563. package/dist/path-MR5JPYOP.js.map +1 -0
  564. package/dist/patterns-cli.d.ts +1 -1
  565. package/dist/policy-runtime.d.ts +1 -1
  566. package/dist/qmd-recall-cache.d.ts +2 -2
  567. package/dist/qmd.d.ts +103 -4
  568. package/dist/qmd.js +23 -5
  569. package/dist/recall-disclosure-escalation.d.ts +1 -1
  570. package/dist/recall-explain-renderer.d.ts +3 -1
  571. package/dist/recall-explain-renderer.js +5 -3
  572. package/dist/recall-state.d.ts +1 -1
  573. package/dist/recall-tag-filter.d.ts +3 -1
  574. package/dist/recall-xray-cli.d.ts +3 -1
  575. package/dist/recall-xray-cli.js +6 -4
  576. package/dist/recall-xray-renderer.d.ts +3 -1
  577. package/dist/recall-xray-renderer.js +5 -3
  578. package/dist/recall-xray.d.ts +8 -1
  579. package/dist/recall-xray.js +4 -2
  580. package/dist/replay/normalizers/chatgpt.d.ts +6 -0
  581. package/dist/replay/normalizers/chatgpt.js +11 -0
  582. package/dist/replay/normalizers/chatgpt.js.map +1 -0
  583. package/dist/replay/normalizers/claude.d.ts +6 -0
  584. package/dist/replay/normalizers/claude.js +11 -0
  585. package/dist/replay/normalizers/claude.js.map +1 -0
  586. package/dist/replay/normalizers/openclaw.d.ts +6 -0
  587. package/dist/replay/normalizers/openclaw.js +11 -0
  588. package/dist/replay/normalizers/openclaw.js.map +1 -0
  589. package/dist/replay/normalizers/shared.d.ts +16 -0
  590. package/dist/replay/normalizers/shared.js +14 -0
  591. package/dist/replay/normalizers/shared.js.map +1 -0
  592. package/dist/replay/runner.d.ts +35 -0
  593. package/dist/replay/runner.js +16 -0
  594. package/dist/replay/runner.js.map +1 -0
  595. package/dist/replay/types.d.ts +57 -0
  596. package/dist/replay/types.js +19 -0
  597. package/dist/replay/types.js.map +1 -0
  598. package/dist/resolution-B7FNQSSP.js +12 -0
  599. package/dist/resolution-B7FNQSSP.js.map +1 -0
  600. package/dist/resolve-auth-token.d.ts +1 -1
  601. package/dist/resolve-provider-secret.js +2 -2
  602. package/dist/response-guidance-recall.d.ts +18 -0
  603. package/dist/response-guidance-recall.js +11 -0
  604. package/dist/response-guidance-recall.js.map +1 -0
  605. package/dist/resume-bundles.js +7 -5
  606. package/dist/retrieval-agents.d.ts +2 -2
  607. package/dist/retrieval-tiers.d.ts +1 -1
  608. package/dist/routing/engine.d.ts +35 -0
  609. package/dist/routing/engine.js +16 -0
  610. package/dist/routing/engine.js.map +1 -0
  611. package/dist/routing/store.d.ts +27 -0
  612. package/dist/routing/store.js +10 -0
  613. package/dist/routing/store.js.map +1 -0
  614. package/dist/runtime/better-sqlite.d.ts +8 -0
  615. package/dist/runtime/better-sqlite.js +10 -0
  616. package/dist/runtime/better-sqlite.js.map +1 -0
  617. package/dist/runtime/child-process.d.ts +32 -0
  618. package/dist/runtime/child-process.js +10 -0
  619. package/dist/runtime/child-process.js.map +1 -0
  620. package/dist/runtime/env.d.ts +5 -0
  621. package/dist/runtime/env.js +12 -0
  622. package/dist/runtime/env.js.map +1 -0
  623. package/dist/sdk-compat.js +1 -1
  624. package/dist/search/document-scanner.d.ts +22 -0
  625. package/dist/search/document-scanner.js +8 -0
  626. package/dist/search/document-scanner.js.map +1 -0
  627. package/dist/search/embed-helper.d.ts +35 -0
  628. package/dist/search/embed-helper.js +9 -0
  629. package/dist/search/embed-helper.js.map +1 -0
  630. package/dist/search/factory.d.ts +32 -0
  631. package/dist/search/factory.js +29 -0
  632. package/dist/search/factory.js.map +1 -0
  633. package/dist/search/index.d.ts +15 -0
  634. package/dist/search/index.js +50 -0
  635. package/dist/search/index.js.map +1 -0
  636. package/dist/search/lancedb-backend.d.ts +51 -0
  637. package/dist/search/lancedb-backend.js +10 -0
  638. package/dist/search/lancedb-backend.js.map +1 -0
  639. package/dist/search/meilisearch-backend.d.ts +48 -0
  640. package/dist/search/meilisearch-backend.js +10 -0
  641. package/dist/search/meilisearch-backend.js.map +1 -0
  642. package/dist/search/noop-backend.d.ts +26 -0
  643. package/dist/search/noop-backend.js +8 -0
  644. package/dist/search/noop-backend.js.map +1 -0
  645. package/dist/search/orama-backend.d.ts +53 -0
  646. package/dist/search/orama-backend.js +10 -0
  647. package/dist/search/orama-backend.js.map +1 -0
  648. package/dist/search/port.d.ts +61 -0
  649. package/dist/search/port.js +1 -0
  650. package/dist/search/port.js.map +1 -0
  651. package/dist/search/remote-backend.d.ts +39 -0
  652. package/dist/search/remote-backend.js +9 -0
  653. package/dist/search/remote-backend.js.map +1 -0
  654. package/dist/secure-store/index.d.ts +890 -0
  655. package/dist/secure-store/index.js +156 -0
  656. package/dist/secure-store/index.js.map +1 -0
  657. package/dist/semantic-VwGI14Ok.d.ts +69 -0
  658. package/dist/semantic-consolidation-4HkHWgeI.d.ts +180 -0
  659. package/dist/semantic-consolidation.d.ts +3 -3
  660. package/dist/semantic-consolidation.js +15 -8
  661. package/dist/semantic-rule-promotion.js +9 -6
  662. package/dist/semantic-rule-verifier.d.ts +1 -1
  663. package/dist/semantic-rule-verifier.js +10 -7
  664. package/dist/session-observer-bands.d.ts +1 -1
  665. package/dist/session-observer-state.d.ts +1 -1
  666. package/dist/shared-context/manager.d.ts +131 -0
  667. package/dist/shared-context/manager.js +15 -0
  668. package/dist/shared-context/manager.js.map +1 -0
  669. package/dist/signal.d.ts +1 -1
  670. package/dist/skills-registry.js +13 -1
  671. package/dist/skills-registry.js.map +1 -1
  672. package/dist/state-store-VZU2IA53.js +16 -0
  673. package/dist/state-store-VZU2IA53.js.map +1 -0
  674. package/dist/storage-paths.d.ts +9 -0
  675. package/dist/storage-paths.js +20 -0
  676. package/dist/storage-paths.js.map +1 -0
  677. package/dist/storage.d.ts +6 -2
  678. package/dist/storage.js +8 -5
  679. package/dist/summarizer.d.ts +6 -1
  680. package/dist/summarizer.js +11 -10
  681. package/dist/summary-snapshot.d.ts +1 -1
  682. package/dist/summary-snapshot.js +2 -1
  683. package/dist/surfaces/dreams.d.ts +16 -0
  684. package/dist/surfaces/dreams.js +282 -0
  685. package/dist/surfaces/dreams.js.map +1 -0
  686. package/dist/surfaces/heartbeat.d.ts +17 -0
  687. package/dist/surfaces/heartbeat.js +265 -0
  688. package/dist/surfaces/heartbeat.js.map +1 -0
  689. package/dist/targeted-fact-recall.d.ts +17 -0
  690. package/dist/targeted-fact-recall.js +11 -0
  691. package/dist/targeted-fact-recall.js.map +1 -0
  692. package/dist/telemetry-transcript.d.ts +7 -0
  693. package/dist/telemetry-transcript.js +16 -0
  694. package/dist/telemetry-transcript.js.map +1 -0
  695. package/dist/temporal-supersession.d.ts +4 -2
  696. package/dist/temporal-supersession.js +2 -1
  697. package/dist/temporal-validity.d.ts +1 -1
  698. package/dist/threading.d.ts +6 -1
  699. package/dist/threading.js +2 -1
  700. package/dist/tier-migration.d.ts +5 -3
  701. package/dist/tier-routing.d.ts +1 -1
  702. package/dist/tokens.js +2 -2
  703. package/dist/topics.d.ts +1 -1
  704. package/dist/transcript.d.ts +16 -2
  705. package/dist/transcript.js +2 -1
  706. package/dist/transfer/autodetect.d.ts +4 -0
  707. package/dist/transfer/autodetect.js +15 -0
  708. package/dist/transfer/autodetect.js.map +1 -0
  709. package/dist/transfer/backup.d.ts +21 -0
  710. package/dist/transfer/backup.js +17 -0
  711. package/dist/transfer/backup.js.map +1 -0
  712. package/dist/transfer/capsule-export.d.ts +113 -0
  713. package/dist/transfer/capsule-export.js +19 -0
  714. package/dist/transfer/capsule-export.js.map +1 -0
  715. package/dist/transfer/capsule-import.d.ts +124 -0
  716. package/dist/transfer/capsule-import.js +16 -0
  717. package/dist/transfer/capsule-import.js.map +1 -0
  718. package/dist/transfer/constants.d.ts +13 -0
  719. package/dist/transfer/constants.js +12 -0
  720. package/dist/transfer/constants.js.map +1 -0
  721. package/dist/transfer/export-json.d.ts +11 -0
  722. package/dist/transfer/export-json.js +11 -0
  723. package/dist/transfer/export-json.js.map +1 -0
  724. package/dist/transfer/export-md.d.ts +10 -0
  725. package/dist/transfer/export-md.js +13 -0
  726. package/dist/transfer/export-md.js.map +1 -0
  727. package/dist/transfer/export-sqlite.d.ts +9 -0
  728. package/dist/transfer/export-sqlite.js +12 -0
  729. package/dist/transfer/export-sqlite.js.map +1 -0
  730. package/dist/transfer/fs-utils.d.ts +61 -0
  731. package/dist/transfer/fs-utils.js +40 -0
  732. package/dist/transfer/fs-utils.js.map +1 -0
  733. package/dist/transfer/import-json.d.ts +16 -0
  734. package/dist/transfer/import-json.js +13 -0
  735. package/dist/transfer/import-json.js.map +1 -0
  736. package/dist/transfer/import-md.d.ts +14 -0
  737. package/dist/transfer/import-md.js +11 -0
  738. package/dist/transfer/import-md.js.map +1 -0
  739. package/dist/transfer/import-sqlite.d.ts +14 -0
  740. package/dist/transfer/import-sqlite.js +12 -0
  741. package/dist/transfer/import-sqlite.js.map +1 -0
  742. package/dist/transfer/sqlite-schema.d.ts +4 -0
  743. package/dist/transfer/sqlite-schema.js +10 -0
  744. package/dist/transfer/sqlite-schema.js.map +1 -0
  745. package/dist/transfer/types.d.ts +916 -0
  746. package/dist/transfer/types.js +30 -0
  747. package/dist/transfer/types.js.map +1 -0
  748. package/dist/trust-zones.d.ts +3 -2
  749. package/dist/trust-zones.js +1 -1
  750. package/dist/types.d.ts +88 -3
  751. package/dist/types.js +1 -1
  752. package/dist/user-model.d.ts +37 -0
  753. package/dist/user-model.js +28 -0
  754. package/dist/user-model.js.map +1 -0
  755. package/dist/utility-runtime.d.ts +1 -1
  756. package/dist/verified-recall.js +11 -8
  757. package/dist/work/board.d.ts +43 -0
  758. package/dist/work/board.js +14 -0
  759. package/dist/work/board.js.map +1 -0
  760. package/dist/work/boundary.d.ts +8 -0
  761. package/dist/work/boundary.js +14 -0
  762. package/dist/work/boundary.js.map +1 -0
  763. package/dist/work/storage.d.ts +39 -0
  764. package/dist/work/storage.js +11 -0
  765. package/dist/work/storage.js.map +1 -0
  766. package/dist/work/types.d.ts +75 -0
  767. package/dist/work/types.js +1 -0
  768. package/dist/work/types.js.map +1 -0
  769. package/package.json +2767 -6
  770. package/scripts/faiss_index.py +816 -0
  771. package/scripts/faiss_requirements.txt +3 -0
  772. package/skills/remnic-entities/SKILL.md +51 -0
  773. package/skills/remnic-memory-workflow/SKILL.md +61 -0
  774. package/skills/remnic-recall/SKILL.md +51 -0
  775. package/skills/remnic-remember/SKILL.md +56 -0
  776. package/skills/remnic-search/SKILL.md +51 -0
  777. package/skills/remnic-status/SKILL.md +51 -0
  778. package/src/abort-error.test.ts +49 -0
  779. package/src/abort-error.ts +46 -0
  780. package/src/abstraction-nodes.ts +162 -0
  781. package/src/access-audit.test.ts +178 -0
  782. package/src/access-audit.ts +125 -0
  783. package/src/access-cli.test.ts +439 -0
  784. package/src/access-cli.ts +438 -0
  785. package/src/access-http.test.ts +225 -0
  786. package/src/access-http.ts +1899 -0
  787. package/src/access-idempotency.ts +232 -0
  788. package/src/access-mcp.test.ts +568 -0
  789. package/src/access-mcp.ts +3056 -0
  790. package/src/access-schema-pi.test.ts +60 -0
  791. package/src/access-schema.ts +522 -0
  792. package/src/access-service-namespace.test.ts +123 -0
  793. package/src/access-service.ts +5629 -0
  794. package/src/action-confidence.test.ts +206 -0
  795. package/src/action-confidence.ts +466 -0
  796. package/src/active-memory-bridge.test.ts +285 -0
  797. package/src/active-memory-bridge.ts +217 -0
  798. package/src/active-recall.test.ts +484 -0
  799. package/src/active-recall.ts +459 -0
  800. package/src/adapters/claude-code.ts +56 -0
  801. package/src/adapters/codex.ts +57 -0
  802. package/src/adapters/hermes.ts +64 -0
  803. package/src/adapters/index.ts +6 -0
  804. package/src/adapters/registry.ts +41 -0
  805. package/src/adapters/replit.ts +55 -0
  806. package/src/adapters/types.ts +51 -0
  807. package/src/behavior-learner.ts +144 -0
  808. package/src/behavior-signals.ts +73 -0
  809. package/src/binary-lifecycle/backend.ts +117 -0
  810. package/src/binary-lifecycle/index.ts +35 -0
  811. package/src/binary-lifecycle/manifest.ts +79 -0
  812. package/src/binary-lifecycle/pipeline.ts +352 -0
  813. package/src/binary-lifecycle/scanner.ts +89 -0
  814. package/src/binary-lifecycle/types.ts +89 -0
  815. package/src/bootstrap.ts +178 -0
  816. package/src/boxes.ts +521 -0
  817. package/src/briefing.test.ts +1535 -0
  818. package/src/briefing.ts +1382 -0
  819. package/src/buffer-session.test.ts +443 -0
  820. package/src/buffer-surprise-report.ts +176 -0
  821. package/src/buffer-surprise-telemetry.test.ts +606 -0
  822. package/src/buffer-surprise-trigger.test.ts +766 -0
  823. package/src/buffer-surprise.test.ts +339 -0
  824. package/src/buffer-surprise.ts +203 -0
  825. package/src/buffer.ts +900 -0
  826. package/src/bulk-import/cli-command.test.ts +204 -0
  827. package/src/bulk-import/index.ts +34 -0
  828. package/src/bulk-import/pipeline.test.ts +445 -0
  829. package/src/bulk-import/pipeline.ts +178 -0
  830. package/src/bulk-import/registry.test.ts +151 -0
  831. package/src/bulk-import/registry.ts +72 -0
  832. package/src/bulk-import/types.test.ts +272 -0
  833. package/src/bulk-import/types.ts +145 -0
  834. package/src/calibration.ts +394 -0
  835. package/src/capsule-cli.test.ts +398 -0
  836. package/src/capsule-cli.ts +565 -0
  837. package/src/causal-behavior.ts +308 -0
  838. package/src/causal-chain.ts +419 -0
  839. package/src/causal-consolidation.ts +370 -0
  840. package/src/causal-retrieval.ts +286 -0
  841. package/src/causal-trajectory-graph.ts +60 -0
  842. package/src/causal-trajectory.ts +303 -0
  843. package/src/chunking.ts +220 -0
  844. package/src/citations.ts +232 -0
  845. package/src/cli.ts +9403 -0
  846. package/src/codex-cli-fallback.ts +162 -0
  847. package/src/codex-thread-key.ts +1 -0
  848. package/src/coding/access-coding-context.test.ts +197 -0
  849. package/src/coding/coding-branch-scope.test.ts +281 -0
  850. package/src/coding/coding-namespace.test.ts +360 -0
  851. package/src/coding/coding-namespace.ts +412 -0
  852. package/src/coding/coding-orchestrator.test.ts +249 -0
  853. package/src/coding/git-context.test.ts +507 -0
  854. package/src/coding/git-context.ts +336 -0
  855. package/src/coding/mcp-set-coding-context.test.ts +174 -0
  856. package/src/coding/review-context.test.ts +316 -0
  857. package/src/coding/review-context.ts +349 -0
  858. package/src/coding/wire-coding-context.test.ts +468 -0
  859. package/src/commitment-ledger.test.ts +78 -0
  860. package/src/commitment-ledger.ts +337 -0
  861. package/src/compat/checks.test.ts +206 -0
  862. package/src/compat/checks.ts +716 -0
  863. package/src/compat/types.ts +33 -0
  864. package/src/compounding/engine.ts +1686 -0
  865. package/src/compounding/preference-consolidator.ts +778 -0
  866. package/src/compression-optimizer.ts +312 -0
  867. package/src/config.test.ts +930 -0
  868. package/src/config.ts +3807 -0
  869. package/src/connectors/codex/instructions.md +160 -0
  870. package/src/connectors/codex/resources/namespace-cheatsheet.md +48 -0
  871. package/src/connectors/codex-marketplace.ts +500 -0
  872. package/src/connectors/codex-materialize-runner.ts +212 -0
  873. package/src/connectors/codex-materialize.ts +983 -0
  874. package/src/connectors/coerce.ts +62 -0
  875. package/src/connectors/index.test.ts +1570 -0
  876. package/src/connectors/index.ts +3222 -0
  877. package/src/connectors/live/framework.ts +164 -0
  878. package/src/connectors/live/github.test.ts +1218 -0
  879. package/src/connectors/live/github.ts +1068 -0
  880. package/src/connectors/live/gmail.test.ts +1706 -0
  881. package/src/connectors/live/gmail.ts +1293 -0
  882. package/src/connectors/live/google-drive.test.ts +696 -0
  883. package/src/connectors/live/google-drive.ts +724 -0
  884. package/src/connectors/live/index.ts +101 -0
  885. package/src/connectors/live/live-connectors.test.ts +689 -0
  886. package/src/connectors/live/notion.test.ts +1109 -0
  887. package/src/connectors/live/notion.ts +978 -0
  888. package/src/connectors/live/registry.ts +103 -0
  889. package/src/connectors/live/state-store.ts +399 -0
  890. package/src/connectors/live/transient-errors.ts +150 -0
  891. package/src/connectors/weclone-installer.test.ts +850 -0
  892. package/src/connectors-cli.ts +513 -0
  893. package/src/console/state.test.ts +224 -0
  894. package/src/console/state.ts +514 -0
  895. package/src/console/trace.test.ts +813 -0
  896. package/src/console/trace.ts +603 -0
  897. package/src/console/tui.test.ts +582 -0
  898. package/src/console/tui.ts +508 -0
  899. package/src/consolidation-operator.ts +182 -0
  900. package/src/consolidation-provenance-check.ts +551 -0
  901. package/src/consolidation-undo.ts +718 -0
  902. package/src/contradiction/contradiction-judge.test.ts +189 -0
  903. package/src/contradiction/contradiction-judge.ts +333 -0
  904. package/src/contradiction/contradiction-review.ts +574 -0
  905. package/src/contradiction/contradiction-scan.ts +504 -0
  906. package/src/contradiction/contradiction.test.ts +2230 -0
  907. package/src/contradiction/index.ts +37 -0
  908. package/src/contradiction/resolution.ts +383 -0
  909. package/src/conversation-index/backend.ts +323 -0
  910. package/src/conversation-index/chunker.ts +47 -0
  911. package/src/conversation-index/cleanup.ts +53 -0
  912. package/src/conversation-index/faiss-adapter.ts +384 -0
  913. package/src/conversation-index/indexer.test.ts +164 -0
  914. package/src/conversation-index/indexer.ts +192 -0
  915. package/src/conversation-index/search.ts +37 -0
  916. package/src/cross-namespace-budget.test.ts +275 -0
  917. package/src/cross-namespace-budget.ts +365 -0
  918. package/src/cue-anchors.ts +163 -0
  919. package/src/curation/index.ts +544 -0
  920. package/src/dashboard-runtime.ts +337 -0
  921. package/src/day-summary.ts +122 -0
  922. package/src/dedup/index.ts +330 -0
  923. package/src/dedup/semantic.test.ts +1577 -0
  924. package/src/dedup/semantic.ts +148 -0
  925. package/src/delinearize.ts +193 -0
  926. package/src/direct-answer-wiring.test.ts +473 -0
  927. package/src/direct-answer-wiring.ts +180 -0
  928. package/src/direct-answer.test.ts +484 -0
  929. package/src/direct-answer.ts +273 -0
  930. package/src/embedding-fallback.ts +565 -0
  931. package/src/enrichment/audit.ts +89 -0
  932. package/src/enrichment/index.ts +27 -0
  933. package/src/enrichment/pipeline.ts +197 -0
  934. package/src/enrichment/provider-registry.ts +85 -0
  935. package/src/enrichment/types.ts +100 -0
  936. package/src/enrichment/web-search-provider.ts +63 -0
  937. package/src/entity-retrieval.ts +774 -0
  938. package/src/entity-schema.ts +239 -0
  939. package/src/evals.ts +1312 -0
  940. package/src/event-order-recall.test.ts +4164 -0
  941. package/src/event-order-recall.ts +2802 -0
  942. package/src/evidence-pack.test.ts +89 -0
  943. package/src/evidence-pack.ts +388 -0
  944. package/src/explicit-capture.ts +530 -0
  945. package/src/explicit-cue-recall.test.ts +3019 -0
  946. package/src/explicit-cue-recall.ts +5545 -0
  947. package/src/extraction-judge-telemetry.ts +234 -0
  948. package/src/extraction-judge-training.ts +221 -0
  949. package/src/extraction-judge.ts +846 -0
  950. package/src/extraction-timeout.test.ts +265 -0
  951. package/src/extraction.ts +2719 -0
  952. package/src/fallback-llm.test.ts +1060 -0
  953. package/src/fallback-llm.ts +918 -0
  954. package/src/focused-list-recall.test.ts +734 -0
  955. package/src/focused-list-recall.ts +1160 -0
  956. package/src/graph-dashboard-diff.ts +35 -0
  957. package/src/graph-dashboard-key.ts +5 -0
  958. package/src/graph-dashboard-parser.ts +104 -0
  959. package/src/graph-edge-reinforcement.ts +192 -0
  960. package/src/graph-events.ts +151 -0
  961. package/src/graph-recall.test.ts +164 -0
  962. package/src/graph-recall.ts +189 -0
  963. package/src/graph-retrieval.test.ts +809 -0
  964. package/src/graph-retrieval.ts +823 -0
  965. package/src/graph-snapshot.ts +329 -0
  966. package/src/graph.ts +813 -0
  967. package/src/harmonic-retrieval.ts +223 -0
  968. package/src/himem.ts +154 -0
  969. package/src/hygiene.ts +87 -0
  970. package/src/identity-continuity.ts +333 -0
  971. package/src/importance.ts +328 -0
  972. package/src/importers/base.test.ts +294 -0
  973. package/src/importers/base.ts +436 -0
  974. package/src/importers/index.ts +21 -0
  975. package/src/index.ts +1204 -0
  976. package/src/intent.ts +154 -0
  977. package/src/json-extract.ts +85 -0
  978. package/src/json-store.ts +42 -0
  979. package/src/lcm/archive.ts +617 -0
  980. package/src/lcm/dag.ts +199 -0
  981. package/src/lcm/engine.ts +645 -0
  982. package/src/lcm/index.ts +7 -0
  983. package/src/lcm/queue.test.ts +178 -0
  984. package/src/lcm/queue.ts +200 -0
  985. package/src/lcm/recall.ts +117 -0
  986. package/src/lcm/schema.ts +154 -0
  987. package/src/lcm/summarizer.ts +235 -0
  988. package/src/lcm/tools.ts +191 -0
  989. package/src/lcm-engine.test.ts +660 -0
  990. package/src/legacy-hook-compat.test.ts +20 -0
  991. package/src/legacy-hook-compat.ts +45 -0
  992. package/src/lifecycle.ts +289 -0
  993. package/src/live-connectors-runner.ts +385 -0
  994. package/src/local-llm-qos.test.ts +303 -0
  995. package/src/local-llm-thinking.test.ts +292 -0
  996. package/src/local-llm.ts +1464 -0
  997. package/src/logger.ts +49 -0
  998. package/src/maintenance/archive-observations.ts +147 -0
  999. package/src/maintenance/backup-stamp.ts +3 -0
  1000. package/src/maintenance/dreams-ledger.ts +516 -0
  1001. package/src/maintenance/first-start-migration.ts +362 -0
  1002. package/src/maintenance/forget.test.ts +206 -0
  1003. package/src/maintenance/forget.ts +126 -0
  1004. package/src/maintenance/graph-edge-decay.test.ts +409 -0
  1005. package/src/maintenance/graph-edge-decay.ts +394 -0
  1006. package/src/maintenance/memory-governance-cron.ts +447 -0
  1007. package/src/maintenance/memory-governance.ts +1039 -0
  1008. package/src/maintenance/migrate-observations.ts +216 -0
  1009. package/src/maintenance/observation-ledger-utils.ts +54 -0
  1010. package/src/maintenance/pattern-reinforcement.test.ts +875 -0
  1011. package/src/maintenance/pattern-reinforcement.ts +369 -0
  1012. package/src/maintenance/purge.ts +334 -0
  1013. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +78 -0
  1014. package/src/maintenance/rebuild-memory-projection.ts +1234 -0
  1015. package/src/maintenance/rebuild-observations.ts +178 -0
  1016. package/src/maintenance/tier-stats.test.ts +378 -0
  1017. package/src/maintenance/tier-stats.ts +222 -0
  1018. package/src/mcp-memory-inspector-app.ts +421 -0
  1019. package/src/memory-action-policy.ts +80 -0
  1020. package/src/memory-cache.ts +208 -0
  1021. package/src/memory-extension/claude-code-publisher.ts +51 -0
  1022. package/src/memory-extension/codex-publisher.ts +149 -0
  1023. package/src/memory-extension/hermes-publisher.ts +51 -0
  1024. package/src/memory-extension/index.ts +100 -0
  1025. package/src/memory-extension/shared-instructions.ts +133 -0
  1026. package/src/memory-extension/types.ts +86 -0
  1027. package/src/memory-extension-host/host-discovery.ts +276 -0
  1028. package/src/memory-extension-host/index.ts +14 -0
  1029. package/src/memory-extension-host/render-extensions-block.ts +73 -0
  1030. package/src/memory-extension-host/types.ts +21 -0
  1031. package/src/memory-lifecycle-ledger-utils.ts +116 -0
  1032. package/src/memory-projection-format.ts +11 -0
  1033. package/src/memory-projection-store.ts +951 -0
  1034. package/src/memory-provenance.test.ts +196 -0
  1035. package/src/memory-provenance.ts +484 -0
  1036. package/src/memory-worth-bench.test.ts +71 -0
  1037. package/src/memory-worth-bench.ts +265 -0
  1038. package/src/memory-worth-filter.test.ts +209 -0
  1039. package/src/memory-worth-filter.ts +204 -0
  1040. package/src/memory-worth-frontmatter.test.ts +311 -0
  1041. package/src/memory-worth-outcomes.test.ts +316 -0
  1042. package/src/memory-worth-outcomes.ts +286 -0
  1043. package/src/memory-worth.test.ts +317 -0
  1044. package/src/memory-worth.ts +215 -0
  1045. package/src/message-parts/index.ts +806 -0
  1046. package/src/message-parts/message-parts.test.ts +421 -0
  1047. package/src/migrate/from-engram.ts +789 -0
  1048. package/src/model-registry.ts +313 -0
  1049. package/src/models-json.ts +76 -0
  1050. package/src/namespaces/migrate.ts +187 -0
  1051. package/src/namespaces/path.ts +25 -0
  1052. package/src/namespaces/principal.test.ts +195 -0
  1053. package/src/namespaces/principal.ts +86 -0
  1054. package/src/namespaces/search.test.ts +105 -0
  1055. package/src/namespaces/search.ts +233 -0
  1056. package/src/namespaces/storage.ts +74 -0
  1057. package/src/native-knowledge.ts +1823 -0
  1058. package/src/negative.ts +72 -0
  1059. package/src/network/tailscale.ts +179 -0
  1060. package/src/network/webdav.ts +385 -0
  1061. package/src/objective-state-writers.ts +951 -0
  1062. package/src/objective-state.ts +320 -0
  1063. package/src/onboarding/index.ts +529 -0
  1064. package/src/openai-chat-compat.ts +56 -0
  1065. package/src/operator-toolkit.ts +2132 -0
  1066. package/src/opik-exporter.test.ts +72 -0
  1067. package/src/opik-exporter.ts +587 -0
  1068. package/src/orchestrator-extraction-queue.test.ts +197 -0
  1069. package/src/orchestrator-flush.test.ts +1171 -0
  1070. package/src/orchestrator-pattern-reinforcement.test.ts +128 -0
  1071. package/src/orchestrator-source-attribution.test.ts +701 -0
  1072. package/src/orchestrator.ts +16368 -0
  1073. package/src/page-versioning.ts +450 -0
  1074. package/src/patterns-cli.ts +574 -0
  1075. package/src/peers/index.ts +54 -0
  1076. package/src/peers/migrate-from-identity-anchor.test.ts +291 -0
  1077. package/src/peers/migrate-from-identity-anchor.ts +350 -0
  1078. package/src/peers/peers.test.ts +419 -0
  1079. package/src/peers/profile-reasoner.ts +694 -0
  1080. package/src/peers/storage.ts +1350 -0
  1081. package/src/peers/types.ts +138 -0
  1082. package/src/plugin-id.ts +84 -0
  1083. package/src/policy-runtime.ts +209 -0
  1084. package/src/procedural/procedure-miner.ts +150 -0
  1085. package/src/procedural/procedure-recall.ts +93 -0
  1086. package/src/procedural/procedure-stats.ts +213 -0
  1087. package/src/procedural/procedure-types.ts +132 -0
  1088. package/src/procedural/reinforcement-core.test.ts +132 -0
  1089. package/src/procedural/reinforcement-core.ts +73 -0
  1090. package/src/profiling.test.ts +263 -0
  1091. package/src/profiling.ts +435 -0
  1092. package/src/projection/index.ts +398 -0
  1093. package/src/qmd-recall-cache.test.ts +138 -0
  1094. package/src/qmd-recall-cache.ts +111 -0
  1095. package/src/qmd.test.ts +257 -0
  1096. package/src/qmd.ts +2614 -0
  1097. package/src/reasoning-trace-recall.ts +201 -0
  1098. package/src/reasoning-trace-types.ts +235 -0
  1099. package/src/recall-audit-anomaly.test.ts +246 -0
  1100. package/src/recall-audit-anomaly.ts +297 -0
  1101. package/src/recall-audit.test.ts +51 -0
  1102. package/src/recall-audit.ts +72 -0
  1103. package/src/recall-budget-config.test.ts +87 -0
  1104. package/src/recall-disclosure-escalation.test.ts +196 -0
  1105. package/src/recall-disclosure-escalation.ts +158 -0
  1106. package/src/recall-disclosure-shaping.test.ts +146 -0
  1107. package/src/recall-disclosure.test.ts +214 -0
  1108. package/src/recall-explain-renderer.test.ts +140 -0
  1109. package/src/recall-explain-renderer.ts +356 -0
  1110. package/src/recall-mmr.test.ts +808 -0
  1111. package/src/recall-mmr.ts +607 -0
  1112. package/src/recall-qos.test.ts +85 -0
  1113. package/src/recall-qos.ts +82 -0
  1114. package/src/recall-query-policy.ts +221 -0
  1115. package/src/recall-state.test.ts +233 -0
  1116. package/src/recall-state.ts +456 -0
  1117. package/src/recall-tag-filter.ts +143 -0
  1118. package/src/recall-tokenization.ts +35 -0
  1119. package/src/recall-xray-cli.test.ts +118 -0
  1120. package/src/recall-xray-cli.ts +100 -0
  1121. package/src/recall-xray-disclosure-telemetry.test.ts +183 -0
  1122. package/src/recall-xray-renderer.test.ts +539 -0
  1123. package/src/recall-xray-renderer.ts +487 -0
  1124. package/src/recall-xray.test.ts +503 -0
  1125. package/src/recall-xray.ts +621 -0
  1126. package/src/reconstruct.ts +41 -0
  1127. package/src/release-changelog.ts +35 -0
  1128. package/src/relevance.ts +67 -0
  1129. package/src/replay/normalizers/chatgpt.ts +133 -0
  1130. package/src/replay/normalizers/claude.ts +102 -0
  1131. package/src/replay/normalizers/openclaw.ts +119 -0
  1132. package/src/replay/normalizers/shared.ts +69 -0
  1133. package/src/replay/runner.ts +197 -0
  1134. package/src/replay/types.ts +143 -0
  1135. package/src/rerank.test.ts +48 -0
  1136. package/src/rerank.ts +176 -0
  1137. package/src/resolve-auth-token.test.ts +226 -0
  1138. package/src/resolve-auth-token.ts +151 -0
  1139. package/src/resolve-provider-secret.test.ts +187 -0
  1140. package/src/resolve-provider-secret.ts +410 -0
  1141. package/src/response-guidance-recall.test.ts +3952 -0
  1142. package/src/response-guidance-recall.ts +4431 -0
  1143. package/src/resume-bundles.ts +415 -0
  1144. package/src/retrieval-agents.ts +623 -0
  1145. package/src/retrieval-tiers.ts +25 -0
  1146. package/src/retrieval.ts +104 -0
  1147. package/src/review/index.test.ts +201 -0
  1148. package/src/review/index.ts +536 -0
  1149. package/src/routing/engine.ts +162 -0
  1150. package/src/routing/store.ts +321 -0
  1151. package/src/runtime/better-sqlite.test.ts +32 -0
  1152. package/src/runtime/better-sqlite.ts +76 -0
  1153. package/src/runtime/child-process.ts +67 -0
  1154. package/src/runtime/env.ts +48 -0
  1155. package/src/sanitize.ts +58 -0
  1156. package/src/schemas.ts +449 -0
  1157. package/src/sdk-compat.ts +87 -0
  1158. package/src/search/document-scanner.ts +96 -0
  1159. package/src/search/embed-helper.ts +142 -0
  1160. package/src/search/factory.ts +189 -0
  1161. package/src/search/index.ts +10 -0
  1162. package/src/search/lancedb-backend.ts +342 -0
  1163. package/src/search/meilisearch-backend.ts +232 -0
  1164. package/src/search/noop-backend.ts +57 -0
  1165. package/src/search/orama-backend.ts +358 -0
  1166. package/src/search/port.ts +86 -0
  1167. package/src/search/remote-backend.ts +124 -0
  1168. package/src/secure-store/cipher.ts +271 -0
  1169. package/src/secure-store/cli-handlers.ts +355 -0
  1170. package/src/secure-store/cli-renderer.ts +131 -0
  1171. package/src/secure-store/header.ts +373 -0
  1172. package/src/secure-store/index.ts +137 -0
  1173. package/src/secure-store/kdf.ts +263 -0
  1174. package/src/secure-store/keyring.ts +106 -0
  1175. package/src/secure-store/metadata.ts +394 -0
  1176. package/src/secure-store/passphrase-reader.ts +252 -0
  1177. package/src/secure-store/secure-fs.ts +571 -0
  1178. package/src/secure-store/secure-store.test.ts +755 -0
  1179. package/src/semantic-chunking.ts +545 -0
  1180. package/src/semantic-consolidation.test.ts +182 -0
  1181. package/src/semantic-consolidation.ts +432 -0
  1182. package/src/semantic-rule-promotion.ts +183 -0
  1183. package/src/semantic-rule-verifier.ts +160 -0
  1184. package/src/session-integrity.ts +569 -0
  1185. package/src/session-observer-bands.ts +11 -0
  1186. package/src/session-observer-state.ts +346 -0
  1187. package/src/session-toggles.test.ts +96 -0
  1188. package/src/session-toggles.ts +159 -0
  1189. package/src/shared-context/manager.ts +810 -0
  1190. package/src/signal.ts +84 -0
  1191. package/src/skills-registry.test.ts +277 -0
  1192. package/src/skills-registry.ts +120 -0
  1193. package/src/source-attribution-roundtrip.test.ts +215 -0
  1194. package/src/source-attribution.test.ts +1425 -0
  1195. package/src/source-attribution.ts +639 -0
  1196. package/src/spaces/index.ts +627 -0
  1197. package/src/storage-paths.ts +117 -0
  1198. package/src/storage.ts +6657 -0
  1199. package/src/store-contract.ts +55 -0
  1200. package/src/summarizer.ts +844 -0
  1201. package/src/summary-snapshot.test.ts +681 -0
  1202. package/src/summary-snapshot.ts +238 -0
  1203. package/src/surfaces/dreams.test.ts +394 -0
  1204. package/src/surfaces/dreams.ts +346 -0
  1205. package/src/surfaces/heartbeat.test.ts +415 -0
  1206. package/src/surfaces/heartbeat.ts +325 -0
  1207. package/src/sync/index.ts +308 -0
  1208. package/src/targeted-fact-recall.test.ts +1694 -0
  1209. package/src/targeted-fact-recall.ts +2905 -0
  1210. package/src/taxonomy/default-taxonomy.ts +87 -0
  1211. package/src/taxonomy/index.ts +26 -0
  1212. package/src/taxonomy/resolver-doc-generator.ts +57 -0
  1213. package/src/taxonomy/resolver.ts +184 -0
  1214. package/src/taxonomy/taxonomy-loader.ts +186 -0
  1215. package/src/taxonomy/types.ts +48 -0
  1216. package/src/telemetry-transcript.ts +70 -0
  1217. package/src/temporal-index.ts +890 -0
  1218. package/src/temporal-supersession.test.ts +2703 -0
  1219. package/src/temporal-supersession.ts +493 -0
  1220. package/src/temporal-validity.test.ts +448 -0
  1221. package/src/temporal-validity.ts +123 -0
  1222. package/src/threading.ts +395 -0
  1223. package/src/tier-migration.ts +124 -0
  1224. package/src/tier-routing.ts +102 -0
  1225. package/src/tmt.ts +462 -0
  1226. package/src/tokens.test.ts +178 -0
  1227. package/src/tokens.ts +279 -0
  1228. package/src/topics.ts +147 -0
  1229. package/src/training-export/cli-date-validation.test.ts +258 -0
  1230. package/src/training-export/converter.test.ts +452 -0
  1231. package/src/training-export/converter.ts +319 -0
  1232. package/src/training-export/date-parse.ts +117 -0
  1233. package/src/training-export/index.ts +26 -0
  1234. package/src/training-export/registry.test.ts +85 -0
  1235. package/src/training-export/registry.ts +57 -0
  1236. package/src/training-export/types.ts +31 -0
  1237. package/src/transcript.ts +1179 -0
  1238. package/src/transfer/autodetect.ts +30 -0
  1239. package/src/transfer/backup.ts +138 -0
  1240. package/src/transfer/capsule-crypto.ts +485 -0
  1241. package/src/transfer/capsule-encrypt.test.ts +690 -0
  1242. package/src/transfer/capsule-export.ts +543 -0
  1243. package/src/transfer/capsule-fork.ts +375 -0
  1244. package/src/transfer/capsule-import.ts +564 -0
  1245. package/src/transfer/capsule-merge.ts +433 -0
  1246. package/src/transfer/conflict-policy.ts +16 -0
  1247. package/src/transfer/constants.ts +13 -0
  1248. package/src/transfer/exclusions.ts +37 -0
  1249. package/src/transfer/export-json.ts +65 -0
  1250. package/src/transfer/export-md.ts +59 -0
  1251. package/src/transfer/export-sqlite.ts +52 -0
  1252. package/src/transfer/fs-utils.ts +269 -0
  1253. package/src/transfer/import-json.ts +108 -0
  1254. package/src/transfer/import-md.ts +84 -0
  1255. package/src/transfer/import-sqlite.ts +100 -0
  1256. package/src/transfer/integrity.ts +71 -0
  1257. package/src/transfer/sqlite-schema.ts +16 -0
  1258. package/src/transfer/types.ts +297 -0
  1259. package/src/trust-zones.ts +1186 -0
  1260. package/src/types.ts +3074 -0
  1261. package/src/user-model.test.ts +124 -0
  1262. package/src/user-model.ts +162 -0
  1263. package/src/utility-learner.ts +353 -0
  1264. package/src/utility-runtime.ts +88 -0
  1265. package/src/utility-telemetry.ts +215 -0
  1266. package/src/utils/category-dir.ts +44 -0
  1267. package/src/utils/errno.ts +6 -0
  1268. package/src/utils/iso-timestamp.test.ts +37 -0
  1269. package/src/utils/iso-timestamp.ts +164 -0
  1270. package/src/utils/path.ts +26 -0
  1271. package/src/verified-recall.ts +138 -0
  1272. package/src/version-utils.test.ts +10 -0
  1273. package/src/version-utils.ts +9 -0
  1274. package/src/whitespace.ts +10 -0
  1275. package/src/work/board.ts +359 -0
  1276. package/src/work/boundary.ts +107 -0
  1277. package/src/work/storage.ts +436 -0
  1278. package/src/work/types.ts +82 -0
  1279. package/src/work-product-ledger.ts +265 -0
  1280. package/dist/access-service-BkXt3di1.d.ts +0 -2039
  1281. package/dist/capsule-crypto-SJS5VVAP.js +0 -18
  1282. package/dist/capsule-export-LLEVB2RG.js +0 -17
  1283. package/dist/capsule-import-UW45R2MZ.js +0 -16
  1284. package/dist/capsule-merge-DI7PNQ2H.js +0 -189
  1285. package/dist/chunk-2LGMW3DJ.js +0 -111
  1286. package/dist/chunk-2YMTO4ZJ.js +0 -265
  1287. package/dist/chunk-2YMTO4ZJ.js.map +0 -1
  1288. package/dist/chunk-363MWCD3.js +0 -9683
  1289. package/dist/chunk-363MWCD3.js.map +0 -1
  1290. package/dist/chunk-36CTNQY7.js +0 -1554
  1291. package/dist/chunk-36CTNQY7.js.map +0 -1
  1292. package/dist/chunk-457A4P3L.js +0 -119
  1293. package/dist/chunk-457A4P3L.js.map +0 -1
  1294. package/dist/chunk-4DXC6HQQ.js +0 -1837
  1295. package/dist/chunk-4DXC6HQQ.js.map +0 -1
  1296. package/dist/chunk-4IS4SXIQ.js +0 -2040
  1297. package/dist/chunk-57QNCUEZ.js +0 -1914
  1298. package/dist/chunk-57QNCUEZ.js.map +0 -1
  1299. package/dist/chunk-6AUUAZEX.js +0 -150
  1300. package/dist/chunk-6AUUAZEX.js.map +0 -1
  1301. package/dist/chunk-6TBWYBJ3.js +0 -236
  1302. package/dist/chunk-6XA7UN4Z.js +0 -135
  1303. package/dist/chunk-6Z6UH6TK.js +0 -2129
  1304. package/dist/chunk-6Z6UH6TK.js.map +0 -1
  1305. package/dist/chunk-74EMIVE4.js +0 -329
  1306. package/dist/chunk-74EMIVE4.js.map +0 -1
  1307. package/dist/chunk-74WWN7ZW.js +0 -82
  1308. package/dist/chunk-74WWN7ZW.js.map +0 -1
  1309. package/dist/chunk-767ODGE6.js +0 -183
  1310. package/dist/chunk-A4ACKWIW.js +0 -289
  1311. package/dist/chunk-A4ACKWIW.js.map +0 -1
  1312. package/dist/chunk-ASAITVLA.js +0 -64
  1313. package/dist/chunk-ASAITVLA.js.map +0 -1
  1314. package/dist/chunk-C5HUWVH2.js +0 -891
  1315. package/dist/chunk-C5HUWVH2.js.map +0 -1
  1316. package/dist/chunk-D54LZC5L.js +0 -147
  1317. package/dist/chunk-DF3RVK3X.js +0 -119
  1318. package/dist/chunk-DF3RVK3X.js.map +0 -1
  1319. package/dist/chunk-E6K4NIEU.js +0 -747
  1320. package/dist/chunk-E6K4NIEU.js.map +0 -1
  1321. package/dist/chunk-EEQLFRUM.js +0 -89
  1322. package/dist/chunk-EQINRHYR.js +0 -672
  1323. package/dist/chunk-EQINRHYR.js.map +0 -1
  1324. package/dist/chunk-ETOW6ACV.js +0 -158
  1325. package/dist/chunk-ETOW6ACV.js.map +0 -1
  1326. package/dist/chunk-EYNQTST2.js +0 -721
  1327. package/dist/chunk-FYIYMQ5N.js +0 -221
  1328. package/dist/chunk-FYIYMQ5N.js.map +0 -1
  1329. package/dist/chunk-G2WADRQ3.js +0 -219
  1330. package/dist/chunk-G4SK7DSQ.js +0 -121
  1331. package/dist/chunk-GGD5W7TB.js +0 -105
  1332. package/dist/chunk-GGD5W7TB.js.map +0 -1
  1333. package/dist/chunk-GVPWB7EY.js +0 -390
  1334. package/dist/chunk-GVPWB7EY.js.map +0 -1
  1335. package/dist/chunk-HJYHRE4S.js +0 -647
  1336. package/dist/chunk-I6BQZSML.js +0 -1451
  1337. package/dist/chunk-I6BQZSML.js.map +0 -1
  1338. package/dist/chunk-IBX3VFOM.js +0 -446
  1339. package/dist/chunk-IBX3VFOM.js.map +0 -1
  1340. package/dist/chunk-IXEJRKCZ.js +0 -18
  1341. package/dist/chunk-JBMSGZEQ.js +0 -441
  1342. package/dist/chunk-JBMSGZEQ.js.map +0 -1
  1343. package/dist/chunk-JRNQ3RNA.js +0 -284
  1344. package/dist/chunk-JRNQ3RNA.js.map +0 -1
  1345. package/dist/chunk-K6WK37A6.js +0 -865
  1346. package/dist/chunk-K6WK37A6.js.map +0 -1
  1347. package/dist/chunk-KBYWQWSB.js +0 -271
  1348. package/dist/chunk-KUHRUM6B.js +0 -14397
  1349. package/dist/chunk-KUHRUM6B.js.map +0 -1
  1350. package/dist/chunk-KWBPHZUU.js +0 -83
  1351. package/dist/chunk-KWBPHZUU.js.map +0 -1
  1352. package/dist/chunk-LIO5X3CM.js +0 -596
  1353. package/dist/chunk-MARWOCVP.js +0 -48
  1354. package/dist/chunk-MCC6KDQF.js +0 -5095
  1355. package/dist/chunk-MCC6KDQF.js.map +0 -1
  1356. package/dist/chunk-N5AKDXAI.js +0 -74
  1357. package/dist/chunk-NN3LPQ5D.js +0 -936
  1358. package/dist/chunk-NN3LPQ5D.js.map +0 -1
  1359. package/dist/chunk-O4XJUPSF.js +0 -533
  1360. package/dist/chunk-O4XJUPSF.js.map +0 -1
  1361. package/dist/chunk-OA3L7BFR.js +0 -183
  1362. package/dist/chunk-OA3L7BFR.js.map +0 -1
  1363. package/dist/chunk-OR64ZGRZ.js +0 -23
  1364. package/dist/chunk-P73JTV34.js +0 -275
  1365. package/dist/chunk-P73JTV34.js.map +0 -1
  1366. package/dist/chunk-P77UEOU2.js +0 -1521
  1367. package/dist/chunk-P77UEOU2.js.map +0 -1
  1368. package/dist/chunk-PB5KW5PL.js +0 -118
  1369. package/dist/chunk-PHNGXFQ6.js +0 -623
  1370. package/dist/chunk-PHNGXFQ6.js.map +0 -1
  1371. package/dist/chunk-QIGOEM65.js +0 -228
  1372. package/dist/chunk-RXTFCYQF.js +0 -108
  1373. package/dist/chunk-S2JJBLJG.js +0 -2101
  1374. package/dist/chunk-S2JJBLJG.js.map +0 -1
  1375. package/dist/chunk-S3IP6R6K.js +0 -219
  1376. package/dist/chunk-S3IP6R6K.js.map +0 -1
  1377. package/dist/chunk-SRBJUAMP.js +0 -403
  1378. package/dist/chunk-SRBJUAMP.js.map +0 -1
  1379. package/dist/chunk-URB2WSKZ.js +0 -350
  1380. package/dist/chunk-URB2WSKZ.js.map +0 -1
  1381. package/dist/chunk-VQXK37XA.js +0 -26
  1382. package/dist/chunk-VQXK37XA.js.map +0 -1
  1383. package/dist/chunk-VTU2B4VF.js +0 -146
  1384. package/dist/chunk-VTU2B4VF.js.map +0 -1
  1385. package/dist/chunk-VX2IUQFE.js +0 -613
  1386. package/dist/chunk-VX2IUQFE.js.map +0 -1
  1387. package/dist/chunk-WGK4VHGP.js +0 -4292
  1388. package/dist/chunk-WGK4VHGP.js.map +0 -1
  1389. package/dist/chunk-WTFWLUSX.js +0 -827
  1390. package/dist/chunk-WTFWLUSX.js.map +0 -1
  1391. package/dist/chunk-XJKFSSDW.js +0 -726
  1392. package/dist/chunk-XJKFSSDW.js.map +0 -1
  1393. package/dist/chunk-XMHBH5H6.js +0 -283
  1394. package/dist/chunk-XMHBH5H6.js.map +0 -1
  1395. package/dist/chunk-XMVFHBHT.js +0 -277
  1396. package/dist/chunk-Y5KDIOKF.js +0 -2403
  1397. package/dist/chunk-Y5KDIOKF.js.map +0 -1
  1398. package/dist/chunk-YNB73F22.js +0 -137
  1399. package/dist/chunk-YNB73F22.js.map +0 -1
  1400. package/dist/chunk-Z2E7VW55.js +0 -335
  1401. package/dist/chunk-Z2E7VW55.js.map +0 -1
  1402. package/dist/chunk-Z5S5HNGY.js +0 -2280
  1403. package/dist/chunk-Z5S5HNGY.js.map +0 -1
  1404. package/dist/chunk-ZL4S7ARC.js +0 -53
  1405. package/dist/chunk-ZTSE2ZJ6.js +0 -190
  1406. package/dist/chunk-ZTSE2ZJ6.js.map +0 -1
  1407. package/dist/cli-Cvy2SNhF.d.ts +0 -1259
  1408. package/dist/codex-materialize-CQlLTzke.d.ts +0 -139
  1409. package/dist/connectors-cli-DFGtY2DB.d.ts +0 -257
  1410. package/dist/contradiction-review-5LTTVDQV.js +0 -22
  1411. package/dist/contradiction-scan-3Z6YW7YA.js +0 -413
  1412. package/dist/contradiction-scan-3Z6YW7YA.js.map +0 -1
  1413. package/dist/engine-FOC3IJLA.js +0 -28
  1414. package/dist/fs-utils-IRVUFB6G.js +0 -30
  1415. package/dist/graph-edge-decay-PWB63GRE.js +0 -207
  1416. package/dist/index-1qIcnbG1.d.ts +0 -34
  1417. package/dist/memory-governance-F3QOJGEY.js +0 -37
  1418. package/dist/memory-projection-store-CY8TU40w.d.ts +0 -222
  1419. package/dist/orchestrator-AOQMo7QI.d.ts +0 -1784
  1420. package/dist/path-RMTY5Y5A.js +0 -9
  1421. package/dist/port-B6VEDIkC.d.ts +0 -53
  1422. package/dist/resolution-YGIBORXI.js +0 -101
  1423. package/dist/resolution-YGIBORXI.js.map +0 -1
  1424. package/dist/secure-store-4R2GSO7S.js +0 -156
  1425. package/dist/semantic-consolidation-ByBXb-sf.d.ts +0 -180
  1426. package/dist/state-store-3EH7HYIN.js +0 -16
  1427. package/dist/types-V3FJ26TF.js +0 -30
  1428. /package/dist/{capsule-crypto-SJS5VVAP.js.map → action-confidence.js.map} +0 -0
  1429. /package/dist/{capsule-export-LLEVB2RG.js.map → adapters/claude-code.js.map} +0 -0
  1430. /package/dist/{capsule-import-UW45R2MZ.js.map → adapters/codex.js.map} +0 -0
  1431. /package/dist/{contradiction-review-5LTTVDQV.js.map → adapters/hermes.js.map} +0 -0
  1432. /package/dist/{engine-FOC3IJLA.js.map → adapters/index.js.map} +0 -0
  1433. /package/dist/{fs-utils-IRVUFB6G.js.map → adapters/registry.js.map} +0 -0
  1434. /package/dist/{memory-governance-F3QOJGEY.js.map → adapters/replit.js.map} +0 -0
  1435. /package/dist/{path-RMTY5Y5A.js.map → adapters/types.js.map} +0 -0
  1436. /package/dist/{secure-store-4R2GSO7S.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
  1437. /package/dist/{capsule-merge-DI7PNQ2H.js.map → capsule-merge-4MGKE7C5.js.map} +0 -0
  1438. /package/dist/{chunk-G4SK7DSQ.js.map → chunk-2WWLHTZY.js.map} +0 -0
  1439. /package/dist/{chunk-KBYWQWSB.js.map → chunk-4CRG46BG.js.map} +0 -0
  1440. /package/dist/{chunk-LIO5X3CM.js.map → chunk-7IASACLB.js.map} +0 -0
  1441. /package/dist/{chunk-EYNQTST2.js.map → chunk-EFJ3MQ4V.js.map} +0 -0
  1442. /package/dist/{chunk-D54LZC5L.js.map → chunk-FDU6HUUL.js.map} +0 -0
  1443. /package/dist/{chunk-QIGOEM65.js.map → chunk-GGKRUQOO.js.map} +0 -0
  1444. /package/dist/{chunk-HJYHRE4S.js.map → chunk-GL6I6MEQ.js.map} +0 -0
  1445. /package/dist/{state-store-3EH7HYIN.js.map → chunk-HHLLAQGZ.js.map} +0 -0
  1446. /package/dist/{chunk-4IS4SXIQ.js.map → chunk-HXXBL2KD.js.map} +0 -0
  1447. /package/dist/{chunk-767ODGE6.js.map → chunk-KNKUID7G.js.map} +0 -0
  1448. /package/dist/{chunk-6TBWYBJ3.js.map → chunk-LPMVBPA3.js.map} +0 -0
  1449. /package/dist/{chunk-PB5KW5PL.js.map → chunk-MC26UJIM.js.map} +0 -0
  1450. /package/dist/{chunk-ZL4S7ARC.js.map → chunk-MT4HVDUZ.js.map} +0 -0
  1451. /package/dist/{chunk-G2WADRQ3.js.map → chunk-MY6TPVXW.js.map} +0 -0
  1452. /package/dist/{chunk-OR64ZGRZ.js.map → chunk-NNVTUXEB.js.map} +0 -0
  1453. /package/dist/{chunk-RXTFCYQF.js.map → chunk-P4NEIHUT.js.map} +0 -0
  1454. /package/dist/{chunk-IXEJRKCZ.js.map → chunk-QRNI5JBH.js.map} +0 -0
  1455. /package/dist/{chunk-EEQLFRUM.js.map → chunk-RRF5UOBJ.js.map} +0 -0
  1456. /package/dist/{types-V3FJ26TF.js.map → chunk-SEDEKFYQ.js.map} +0 -0
  1457. /package/dist/{chunk-2LGMW3DJ.js.map → chunk-U3PN77QT.js.map} +0 -0
  1458. /package/dist/{chunk-XMVFHBHT.js.map → chunk-U3WSW6PZ.js.map} +0 -0
  1459. /package/dist/{chunk-N5AKDXAI.js.map → chunk-UWVJF25J.js.map} +0 -0
  1460. /package/dist/{chunk-MARWOCVP.js.map → chunk-XIG5PDM7.js.map} +0 -0
  1461. /package/dist/{chunk-6XA7UN4Z.js.map → chunk-XVZ7B3HG.js.map} +0 -0
  1462. /package/dist/{graph-edge-decay-PWB63GRE.js.map → graph-edge-decay-5DI5GUNL.js.map} +0 -0
@@ -0,0 +1,2132 @@
1
+ import path from "node:path";
2
+ import { constants as fsConstants } from "node:fs";
3
+ import { access, mkdir, readFile, readdir, stat, unlink, writeFile } from "node:fs/promises";
4
+ import { lintWorkspaceFiles } from "./hygiene.js";
5
+ import { parseConfig } from "./config.js";
6
+ import { readEnvVar, resolveHomeDir } from "./runtime/env.js";
7
+ import { resolveRemnicPluginEntry } from "./plugin-id.js";
8
+ import {
9
+ resolveCuratedIncludeFilesStatePath,
10
+ resolveNativeKnowledgeStatePath,
11
+ resolveOpenClawWorkspaceStatePath,
12
+ } from "./native-knowledge.js";
13
+ import { StorageManager } from "./storage.js";
14
+ import { listNamespaces } from "./namespaces/migrate.js";
15
+ import {
16
+ createEvalBaselineSnapshot,
17
+ getEvalHarnessStatus,
18
+ runEvalBaselineDeltaReport,
19
+ runEvalBenchmarkCiGate,
20
+ validateEvalBenchmarkPack,
21
+ type EvalBaselineDeltaReport,
22
+ type EvalCiGateReport,
23
+ type EvalHarnessStatus,
24
+ } from "./evals.js";
25
+ import { analyzeGraphHealth, type GraphHealthReport } from "./graph.js";
26
+ import {
27
+ analyzeSessionIntegrity,
28
+ applySessionRepair,
29
+ planSessionRepair,
30
+ type SessionIntegrityReport,
31
+ type SessionRepairApplyResult,
32
+ type SessionRepairPlan,
33
+ } from "./session-integrity.js";
34
+ import {
35
+ listMemoryGovernanceRuns,
36
+ readMemoryGovernanceRunArtifact,
37
+ } from "./maintenance/memory-governance.js";
38
+ import {
39
+ runConsolidationProvenanceCheck,
40
+ type ConsolidationProvenanceReport,
41
+ } from "./consolidation-provenance-check.js";
42
+ import type {
43
+ BufferSurpriseEvent,
44
+ DreamsPhasesConfig,
45
+ FileHygieneConfig,
46
+ MemoryFile,
47
+ PluginConfig,
48
+ } from "./types.js";
49
+ import { reportBufferSurpriseDistribution } from "./buffer-surprise-report.js";
50
+ import { readJudgeVerdictStats } from "./extraction-judge-telemetry.js";
51
+
52
+ interface QmdRuntimeLike {
53
+ probe(): Promise<boolean>;
54
+ isAvailable(): boolean;
55
+ ensureCollection(memoryDir: string): Promise<"present" | "missing" | "unknown" | "skipped">;
56
+ debugStatus(): string;
57
+ }
58
+
59
+ function isMissingPathError(error: unknown): boolean {
60
+ return typeof error === "object"
61
+ && error !== null
62
+ && "code" in error
63
+ && (error as { code?: unknown }).code === "ENOENT";
64
+ }
65
+
66
+ function formatUnknownError(error: unknown): string {
67
+ return error instanceof Error ? error.message : String(error);
68
+ }
69
+
70
+ interface ConversationIndexLike {
71
+ getConversationIndexHealth(): Promise<{
72
+ enabled: boolean;
73
+ backend: "qmd" | "faiss";
74
+ status: "ok" | "degraded" | "disabled";
75
+ chunkDocCount: number;
76
+ lastUpdateAt: string | null;
77
+ qmdAvailable?: boolean;
78
+ faiss?: {
79
+ ok: boolean;
80
+ status: "ok" | "degraded" | "error";
81
+ indexPath: string;
82
+ message?: string;
83
+ manifest?: {
84
+ version: number;
85
+ modelId: string;
86
+ normalizedModelId: string;
87
+ dimension: number;
88
+ chunkCount: number;
89
+ updatedAt: string;
90
+ lastSuccessfulRebuildAt: string;
91
+ };
92
+ };
93
+ }>;
94
+ rebuildConversationIndex(
95
+ sessionKey?: string,
96
+ hours?: number,
97
+ opts?: { embed?: boolean },
98
+ ): Promise<{
99
+ chunks: number;
100
+ skipped: boolean;
101
+ reason?: string;
102
+ embedded?: boolean;
103
+ rebuilt?: boolean;
104
+ }>;
105
+ }
106
+
107
+ export interface OperatorToolkitOrchestrator extends ConversationIndexLike {
108
+ config: PluginConfig;
109
+ storage: StorageManager;
110
+ qmd: QmdRuntimeLike;
111
+ }
112
+
113
+ export interface OperatorConfigLoadResult {
114
+ found: boolean;
115
+ path: string;
116
+ parsed: boolean;
117
+ memoryDir?: string;
118
+ workspaceDir?: string;
119
+ error?: string;
120
+ }
121
+
122
+ export interface OperatorSetupReport {
123
+ schemaVersion: 1;
124
+ generatedAt: string;
125
+ config: OperatorConfigLoadResult;
126
+ memoryDir: string;
127
+ workspaceDir: string;
128
+ directories: Array<{ path: string; exists: boolean; writable: boolean }>;
129
+ qmd: {
130
+ enabled: boolean;
131
+ available: boolean;
132
+ collectionState: "present" | "missing" | "unknown" | "skipped";
133
+ debugStatus: string;
134
+ };
135
+ nativeKnowledge: {
136
+ enabled: boolean;
137
+ includeFiles: string[];
138
+ curatedIncludeSync: {
139
+ statePath: string;
140
+ exists: boolean;
141
+ updatedAt: string | null;
142
+ fileCount: number;
143
+ activeChunkCount: number;
144
+ deletedFileCount: number;
145
+ };
146
+ openclawWorkspaceAdapterEnabled: boolean;
147
+ obsidianVaultAdapterEnabled: boolean;
148
+ obsidianSync: {
149
+ statePath: string;
150
+ exists: boolean;
151
+ updatedAt: string | null;
152
+ vaultCount: number;
153
+ activeChunkCount: number;
154
+ deletedNoteCount: number;
155
+ };
156
+ openclawWorkspaceSync: {
157
+ statePath: string;
158
+ exists: boolean;
159
+ updatedAt: string | null;
160
+ fileCount: number;
161
+ activeChunkCount: number;
162
+ deletedFileCount: number;
163
+ };
164
+ };
165
+ explicitCapture: {
166
+ captureMode: string;
167
+ enabled: boolean;
168
+ memoryDocPath: string;
169
+ memoryDocExists: boolean;
170
+ memoryDocInstalled: boolean;
171
+ memoryDocUpdated: boolean;
172
+ memoryDocRemoved: boolean;
173
+ preview: string | null;
174
+ };
175
+ nextSteps: string[];
176
+ verificationCommands: string[];
177
+ }
178
+
179
+ export interface OperatorDoctorCheck {
180
+ key: string;
181
+ status: "ok" | "warn" | "error";
182
+ summary: string;
183
+ remediation?: string;
184
+ details?: unknown;
185
+ }
186
+
187
+ export interface OperatorConfigReviewFinding {
188
+ key: string;
189
+ status: "recommend" | "problem";
190
+ setting: string;
191
+ currentValue: string;
192
+ defaultValue: string;
193
+ recommendedValue: string;
194
+ summary: string;
195
+ rationale: string;
196
+ }
197
+
198
+ export interface OperatorConfigReviewReport {
199
+ schemaVersion: 1;
200
+ generatedAt: string;
201
+ ok: boolean;
202
+ config: OperatorConfigLoadResult;
203
+ profile: {
204
+ memoryOsPreset?: string;
205
+ searchBackend: string;
206
+ qmdEnabled: boolean;
207
+ qmdDaemonEnabled: boolean;
208
+ nativeKnowledgeEnabled: boolean;
209
+ fileHygieneEnabled: boolean;
210
+ conversationIndexEnabled: boolean;
211
+ };
212
+ summary: {
213
+ recommend: number;
214
+ problem: number;
215
+ };
216
+ findings: OperatorConfigReviewFinding[];
217
+ }
218
+
219
+ export interface OperatorDoctorReport {
220
+ schemaVersion: 1;
221
+ generatedAt: string;
222
+ ok: boolean;
223
+ summary: {
224
+ ok: number;
225
+ warn: number;
226
+ error: number;
227
+ };
228
+ config: OperatorConfigLoadResult;
229
+ checks: OperatorDoctorCheck[];
230
+ }
231
+
232
+ export interface OperatorInventoryNamespaceSummary {
233
+ namespace: string;
234
+ memoryCount: number;
235
+ entityCount: number;
236
+ }
237
+
238
+ export interface OperatorInventoryReport {
239
+ schemaVersion: 1;
240
+ generatedAt: string;
241
+ memoryDir: string;
242
+ totals: {
243
+ memories: number;
244
+ entities: number;
245
+ namespaces: number;
246
+ reviewQueue: number;
247
+ storageBytes: number;
248
+ };
249
+ categories: Record<string, number>;
250
+ statuses: Record<string, number>;
251
+ namespaces: OperatorInventoryNamespaceSummary[];
252
+ ageBands: Record<string, number>;
253
+ profile: {
254
+ exists: boolean;
255
+ chars: number;
256
+ lines: number;
257
+ };
258
+ storageFootprint: {
259
+ bytes: number;
260
+ byTopLevel: Record<string, number>;
261
+ };
262
+ archivePressure: {
263
+ archived: number;
264
+ pendingReview: number;
265
+ quarantined: number;
266
+ rejected: number;
267
+ };
268
+ conversationIndex: {
269
+ enabled: boolean;
270
+ backend: "qmd" | "faiss";
271
+ status: "ok" | "degraded" | "disabled";
272
+ chunkDocCount: number;
273
+ lastUpdateAt: string | null;
274
+ };
275
+ nativeKnowledge: {
276
+ enabled: boolean;
277
+ curatedIncludeSync: {
278
+ exists: boolean;
279
+ updatedAt: string | null;
280
+ fileCount: number;
281
+ activeChunkCount: number;
282
+ deletedFileCount: number;
283
+ };
284
+ obsidianSync: {
285
+ exists: boolean;
286
+ updatedAt: string | null;
287
+ vaultCount: number;
288
+ activeChunkCount: number;
289
+ deletedNoteCount: number;
290
+ };
291
+ openclawWorkspaceSync: {
292
+ exists: boolean;
293
+ updatedAt: string | null;
294
+ fileCount: number;
295
+ activeChunkCount: number;
296
+ deletedFileCount: number;
297
+ };
298
+ };
299
+ }
300
+
301
+ export interface BenchmarkRecallReport {
302
+ schemaVersion: 1;
303
+ generatedAt: string;
304
+ mode: "status" | "validate" | "baseline-report" | "ci-gate" | "snapshot";
305
+ status: EvalHarnessStatus;
306
+ validate?: Awaited<ReturnType<typeof validateEvalBenchmarkPack>>;
307
+ baselineReport?: EvalBaselineDeltaReport;
308
+ ciGate?: EvalCiGateReport;
309
+ snapshot?: {
310
+ targetPath: string;
311
+ snapshotId: string;
312
+ };
313
+ }
314
+
315
+ export interface OperatorRepairReport {
316
+ schemaVersion: 1;
317
+ generatedAt: string;
318
+ dryRun: boolean;
319
+ sessionCheck: SessionIntegrityReport;
320
+ sessionRepairPlan: SessionRepairPlan;
321
+ sessionRepairApply: SessionRepairApplyResult;
322
+ graphHealth: GraphHealthReport;
323
+ }
324
+
325
+ export interface OperatorSetupOptions {
326
+ orchestrator: OperatorToolkitOrchestrator;
327
+ installCaptureInstructions?: boolean;
328
+ captureInstructionsMode?: "preview" | "install" | "remove";
329
+ configPath?: string;
330
+ now?: Date;
331
+ }
332
+
333
+ export interface OperatorDoctorOptions {
334
+ orchestrator: OperatorToolkitOrchestrator;
335
+ configPath?: string;
336
+ now?: Date;
337
+ }
338
+
339
+ export interface OperatorConfigReviewOptions {
340
+ orchestrator: OperatorToolkitOrchestrator;
341
+ configPath?: string;
342
+ now?: Date;
343
+ }
344
+
345
+ export interface OperatorInventoryOptions {
346
+ orchestrator: OperatorToolkitOrchestrator;
347
+ now?: Date;
348
+ }
349
+
350
+ export interface BenchmarkRecallOptions {
351
+ config: Pick<
352
+ PluginConfig,
353
+ | "memoryDir"
354
+ | "evalStoreDir"
355
+ | "evalHarnessEnabled"
356
+ | "evalShadowModeEnabled"
357
+ | "benchmarkBaselineSnapshotsEnabled"
358
+ | "benchmarkDeltaReporterEnabled"
359
+ | "memoryRedTeamBenchEnabled"
360
+ >;
361
+ validatePath?: string;
362
+ baseEvalStoreDir?: string;
363
+ candidateEvalStoreDir?: string;
364
+ snapshotId?: string;
365
+ createSnapshot?: boolean;
366
+ snapshotNotes?: string;
367
+ gitRef?: string;
368
+ createdAt?: string;
369
+ now?: Date;
370
+ }
371
+
372
+ export interface OperatorRepairOptions {
373
+ config: Pick<
374
+ PluginConfig,
375
+ "memoryDir" | "entityGraphEnabled" | "timeGraphEnabled" | "causalGraphEnabled"
376
+ >;
377
+ apply?: boolean;
378
+ dryRun?: boolean;
379
+ allowSessionFileRepair?: boolean;
380
+ sessionFilesDir?: string;
381
+ now?: Date;
382
+ }
383
+
384
+ function resolveConfigPath(explicitPath?: string): string {
385
+ if (explicitPath && explicitPath.trim().length > 0) return explicitPath.trim();
386
+ const configured =
387
+ readEnvVar("OPENCLAW_CONFIG_PATH") ||
388
+ readEnvVar("OPENCLAW_ENGRAM_CONFIG_PATH");
389
+ if (configured && configured.trim().length > 0) return configured.trim();
390
+ return path.join(resolveHomeDir(), ".openclaw", "openclaw.json");
391
+ }
392
+
393
+ async function loadCliPluginConfig(configPath?: string): Promise<OperatorConfigLoadResult> {
394
+ const resolvedPath = resolveConfigPath(configPath);
395
+ try {
396
+ const raw = JSON.parse(await readFile(resolvedPath, "utf-8")) as Record<string, unknown>;
397
+ // Delegate slot → PLUGIN_ID → LEGACY_PLUGIN_ID resolution to the shared
398
+ // helper so all config loaders stay in sync (#403).
399
+ const entry = resolveRemnicPluginEntry(raw);
400
+ const parsedConfig = parseConfig(
401
+ entry && typeof entry === "object"
402
+ ? ((entry["config"] as Record<string, unknown> | undefined) ?? {})
403
+ : {},
404
+ );
405
+ return {
406
+ found: true,
407
+ path: resolvedPath,
408
+ parsed: true,
409
+ memoryDir: parsedConfig.memoryDir,
410
+ workspaceDir: parsedConfig.workspaceDir,
411
+ };
412
+ } catch (error) {
413
+ const message = error instanceof Error ? error.message : String(error);
414
+ return {
415
+ found: !/ENOENT/i.test(message),
416
+ path: resolvedPath,
417
+ parsed: false,
418
+ error: message,
419
+ };
420
+ }
421
+ }
422
+
423
+ async function isWritable(targetPath: string): Promise<boolean> {
424
+ try {
425
+ await access(targetPath, fsConstants.W_OK);
426
+ return true;
427
+ } catch {
428
+ return false;
429
+ }
430
+ }
431
+
432
+ async function pathExists(targetPath: string): Promise<boolean> {
433
+ try {
434
+ await access(targetPath, fsConstants.F_OK);
435
+ return true;
436
+ } catch {
437
+ return false;
438
+ }
439
+ }
440
+
441
+ function formatConfigValue(value: unknown): string {
442
+ if (value === undefined || value === null) return "(unset)";
443
+ if (typeof value === "string") return value.length > 0 ? value : "(unset)";
444
+ if (typeof value === "number" || typeof value === "boolean") return String(value);
445
+ return JSON.stringify(value);
446
+ }
447
+
448
+ async function gatherDirectoryStatus(
449
+ paths: string[],
450
+ ): Promise<Array<{ path: string; exists: boolean; writable: boolean }>> {
451
+ return Promise.all(paths.map(async (targetPath) => {
452
+ try {
453
+ await access(targetPath, fsConstants.F_OK);
454
+ return {
455
+ path: targetPath,
456
+ exists: true,
457
+ writable: await isWritable(targetPath),
458
+ };
459
+ } catch {
460
+ return {
461
+ path: targetPath,
462
+ exists: false,
463
+ writable: false,
464
+ };
465
+ }
466
+ }));
467
+ }
468
+
469
+ function getSetupPaths(config: PluginConfig): string[] {
470
+ return [
471
+ config.memoryDir,
472
+ config.workspaceDir,
473
+ path.join(config.memoryDir, "facts"),
474
+ path.join(config.memoryDir, "entities"),
475
+ path.join(config.memoryDir, "state"),
476
+ path.join(config.memoryDir, "questions"),
477
+ path.join(config.memoryDir, "artifacts"),
478
+ path.join(config.memoryDir, "config"),
479
+ ];
480
+ }
481
+
482
+ async function readJsonIfExists(filePath: string): Promise<unknown | null> {
483
+ try {
484
+ return JSON.parse(await readFile(filePath, "utf-8")) as unknown;
485
+ } catch {
486
+ return null;
487
+ }
488
+ }
489
+
490
+ async function summarizeNativeKnowledgeStatus(config: PluginConfig): Promise<{
491
+ enabled: boolean;
492
+ includeFiles: string[];
493
+ curatedIncludeSync: {
494
+ statePath: string;
495
+ exists: boolean;
496
+ updatedAt: string | null;
497
+ fileCount: number;
498
+ activeChunkCount: number;
499
+ deletedFileCount: number;
500
+ };
501
+ openclawWorkspaceAdapterEnabled: boolean;
502
+ obsidianVaultAdapterEnabled: boolean;
503
+ obsidianSync: {
504
+ statePath: string;
505
+ exists: boolean;
506
+ updatedAt: string | null;
507
+ vaultCount: number;
508
+ activeChunkCount: number;
509
+ deletedNoteCount: number;
510
+ };
511
+ openclawWorkspaceSync: {
512
+ statePath: string;
513
+ exists: boolean;
514
+ updatedAt: string | null;
515
+ fileCount: number;
516
+ activeChunkCount: number;
517
+ deletedFileCount: number;
518
+ };
519
+ }> {
520
+ const nativeKnowledge = config.nativeKnowledge;
521
+ const nativeKnowledgeStateDir = nativeKnowledge?.stateDir ?? "state/native-knowledge";
522
+ const curatedStatePath = nativeKnowledge
523
+ ? resolveCuratedIncludeFilesStatePath(config.memoryDir, nativeKnowledge)
524
+ : path.join(config.memoryDir, nativeKnowledgeStateDir, "curated-include-sync.json");
525
+ const obsidianStatePath = nativeKnowledge
526
+ ? resolveNativeKnowledgeStatePath(config.memoryDir, nativeKnowledge)
527
+ : path.join(config.memoryDir, nativeKnowledgeStateDir, "obsidian-sync.json");
528
+ const openclawStatePath = nativeKnowledge
529
+ ? resolveOpenClawWorkspaceStatePath(config.memoryDir, nativeKnowledge)
530
+ : path.join(config.memoryDir, nativeKnowledgeStateDir, "openclaw-workspace-sync.json");
531
+ const [curatedRaw, obsidianRaw, openclawRaw] = await Promise.all([
532
+ readJsonIfExists(curatedStatePath),
533
+ readJsonIfExists(obsidianStatePath),
534
+ readJsonIfExists(openclawStatePath),
535
+ ]);
536
+
537
+ const curatedFiles = curatedRaw && typeof curatedRaw === "object" && curatedRaw !== null
538
+ && "files" in curatedRaw && typeof (curatedRaw as { files?: unknown }).files === "object"
539
+ && (curatedRaw as { files?: unknown }).files !== null
540
+ ? (curatedRaw as {
541
+ updatedAt?: unknown;
542
+ files: Record<string, { deleted?: boolean; chunks?: unknown[] }>;
543
+ })
544
+ : null;
545
+
546
+ let curatedActiveChunkCount = 0;
547
+ let curatedDeletedFileCount = 0;
548
+ for (const file of Object.values(curatedFiles?.files ?? {})) {
549
+ if (file.deleted) {
550
+ curatedDeletedFileCount += 1;
551
+ continue;
552
+ }
553
+ curatedActiveChunkCount += Array.isArray(file.chunks) ? file.chunks.length : 0;
554
+ }
555
+
556
+ const obsidianVaults = obsidianRaw && typeof obsidianRaw === "object" && obsidianRaw !== null
557
+ && "vaults" in obsidianRaw && typeof (obsidianRaw as { vaults?: unknown }).vaults === "object"
558
+ && (obsidianRaw as { vaults?: unknown }).vaults !== null
559
+ ? (obsidianRaw as {
560
+ updatedAt?: unknown;
561
+ vaults: Record<string, { notes?: Record<string, { deleted?: boolean; chunks?: unknown[] }> }>;
562
+ })
563
+ : null;
564
+
565
+ let obsidianActiveChunkCount = 0;
566
+ let obsidianDeletedNoteCount = 0;
567
+ for (const vault of Object.values(obsidianVaults?.vaults ?? {})) {
568
+ for (const note of Object.values(vault.notes ?? {})) {
569
+ if (note.deleted) {
570
+ obsidianDeletedNoteCount += 1;
571
+ continue;
572
+ }
573
+ obsidianActiveChunkCount += Array.isArray(note.chunks) ? note.chunks.length : 0;
574
+ }
575
+ }
576
+
577
+ const openclawFiles = openclawRaw && typeof openclawRaw === "object" && openclawRaw !== null
578
+ && "files" in openclawRaw && typeof (openclawRaw as { files?: unknown }).files === "object"
579
+ && (openclawRaw as { files?: unknown }).files !== null
580
+ ? (openclawRaw as {
581
+ updatedAt?: unknown;
582
+ files: Record<string, { deleted?: boolean; chunks?: unknown[] }>;
583
+ })
584
+ : null;
585
+
586
+ let openclawActiveChunkCount = 0;
587
+ let openclawDeletedFileCount = 0;
588
+ for (const file of Object.values(openclawFiles?.files ?? {})) {
589
+ if (file.deleted) {
590
+ openclawDeletedFileCount += 1;
591
+ continue;
592
+ }
593
+ openclawActiveChunkCount += Array.isArray(file.chunks) ? file.chunks.length : 0;
594
+ }
595
+
596
+ return {
597
+ enabled: nativeKnowledge?.enabled === true,
598
+ includeFiles: nativeKnowledge?.includeFiles ?? [],
599
+ curatedIncludeSync: {
600
+ statePath: curatedStatePath,
601
+ exists: curatedFiles !== null,
602
+ updatedAt: typeof curatedFiles?.updatedAt === "string" ? curatedFiles.updatedAt : null,
603
+ fileCount: Object.keys(curatedFiles?.files ?? {}).length,
604
+ activeChunkCount: curatedActiveChunkCount,
605
+ deletedFileCount: curatedDeletedFileCount,
606
+ },
607
+ openclawWorkspaceAdapterEnabled: nativeKnowledge?.openclawWorkspace?.enabled === true,
608
+ obsidianVaultAdapterEnabled: (nativeKnowledge?.obsidianVaults?.length ?? 0) > 0,
609
+ obsidianSync: {
610
+ statePath: obsidianStatePath,
611
+ exists: obsidianVaults !== null,
612
+ updatedAt: typeof obsidianVaults?.updatedAt === "string" ? obsidianVaults.updatedAt : null,
613
+ vaultCount: Object.keys(obsidianVaults?.vaults ?? {}).length,
614
+ activeChunkCount: obsidianActiveChunkCount,
615
+ deletedNoteCount: obsidianDeletedNoteCount,
616
+ },
617
+ openclawWorkspaceSync: {
618
+ statePath: openclawStatePath,
619
+ exists: openclawFiles !== null,
620
+ updatedAt: typeof openclawFiles?.updatedAt === "string" ? openclawFiles.updatedAt : null,
621
+ fileCount: Object.keys(openclawFiles?.files ?? {}).length,
622
+ activeChunkCount: openclawActiveChunkCount,
623
+ deletedFileCount: openclawDeletedFileCount,
624
+ },
625
+ };
626
+ }
627
+
628
+ const CAPTURE_INSTRUCTIONS_START = "<!-- BEGIN ENGRAM EXPLICIT CAPTURE INSTRUCTIONS -->";
629
+ const CAPTURE_INSTRUCTIONS_END = "<!-- END ENGRAM EXPLICIT CAPTURE INSTRUCTIONS -->";
630
+
631
+ function buildCaptureInstructions(): string {
632
+ return [
633
+ CAPTURE_INSTRUCTIONS_START,
634
+ "# Memory",
635
+ "",
636
+ "Use this file for explicit memory capture notes when Engram runs in explicit or hybrid mode.",
637
+ "",
638
+ "## Suggested format",
639
+ "",
640
+ "- Write durable facts, decisions, commitments, or corrections.",
641
+ "- Keep entries concise and specific.",
642
+ "- Avoid secrets, tokens, and private credentials.",
643
+ "",
644
+ "## Example",
645
+ "",
646
+ "- Decision: recall benchmark packs live under `state/evals/benchmarks/`.",
647
+ "- Commitment: rerun `openclaw engram doctor --json` after changing retrieval settings.",
648
+ "",
649
+ CAPTURE_INSTRUCTIONS_END,
650
+ ].join("\n");
651
+ }
652
+
653
+ function upsertManagedCaptureInstructions(existing: string | null, snippet: string): { content: string; updated: boolean; installed: boolean } {
654
+ if (!existing || existing.trim().length === 0) {
655
+ return { content: `${snippet}\n`, updated: false, installed: true };
656
+ }
657
+ if (existing.includes(CAPTURE_INSTRUCTIONS_START) && existing.includes(CAPTURE_INSTRUCTIONS_END)) {
658
+ const next = existing.replace(
659
+ new RegExp(`${CAPTURE_INSTRUCTIONS_START}[\\s\\S]*?${CAPTURE_INSTRUCTIONS_END}`),
660
+ snippet,
661
+ );
662
+ return { content: next.endsWith("\n") ? next : `${next}\n`, updated: next !== existing, installed: false };
663
+ }
664
+ const trimmed = existing.trimEnd();
665
+ return {
666
+ content: `${trimmed}\n\n${snippet}\n`,
667
+ updated: false,
668
+ installed: true,
669
+ };
670
+ }
671
+
672
+ function removeManagedCaptureInstructions(existing: string): { content: string; removed: boolean } {
673
+ if (!existing.includes(CAPTURE_INSTRUCTIONS_START) || !existing.includes(CAPTURE_INSTRUCTIONS_END)) {
674
+ return { content: existing, removed: false };
675
+ }
676
+ const stripped = existing
677
+ .replace(new RegExp(`\\n*${CAPTURE_INSTRUCTIONS_START}[\\s\\S]*?${CAPTURE_INSTRUCTIONS_END}\\n*`), "\n")
678
+ .replace(/\n{3,}/g, "\n\n")
679
+ .trim();
680
+ return {
681
+ content: stripped.length > 0 ? `${stripped}\n` : "",
682
+ removed: true,
683
+ };
684
+ }
685
+
686
+ export async function runOperatorSetup(options: OperatorSetupOptions): Promise<OperatorSetupReport> {
687
+ const now = options.now ?? new Date();
688
+ const configStatus = await loadCliPluginConfig(options.configPath);
689
+ const storage = options.orchestrator.storage;
690
+ await storage.ensureDirectories();
691
+ await mkdir(options.orchestrator.config.workspaceDir, { recursive: true });
692
+
693
+ const qmdAvailable = await options.orchestrator.qmd.probe();
694
+ const collectionState = options.orchestrator.config.qmdEnabled
695
+ ? await options.orchestrator.qmd.ensureCollection(options.orchestrator.config.memoryDir)
696
+ : "skipped";
697
+ const nativeKnowledgeStatus = await summarizeNativeKnowledgeStatus(options.orchestrator.config);
698
+
699
+ const memoryDocPath = path.join(options.orchestrator.config.workspaceDir, "MEMORY.md");
700
+ const captureInstructionsMode =
701
+ options.captureInstructionsMode
702
+ ?? (options.installCaptureInstructions ? "install" : undefined);
703
+ let memoryDocExists = false;
704
+ try {
705
+ await access(memoryDocPath, fsConstants.F_OK);
706
+ memoryDocExists = true;
707
+ } catch {
708
+ memoryDocExists = false;
709
+ }
710
+ let memoryDocInstalled = false;
711
+ let memoryDocUpdated = false;
712
+ let memoryDocRemoved = false;
713
+ const explicitCaptureEnabled = options.orchestrator.config.captureMode === "explicit"
714
+ || options.orchestrator.config.captureMode === "hybrid";
715
+ const captureInstructionsPreview = captureInstructionsMode ? buildCaptureInstructions() : null;
716
+ if (captureInstructionsMode) {
717
+ if (captureInstructionsMode === "preview") {
718
+ // no-op, preview only
719
+ } else if (captureInstructionsMode === "install") {
720
+ const existing = memoryDocExists ? await readFile(memoryDocPath, "utf-8") : null;
721
+ const next = upsertManagedCaptureInstructions(existing, captureInstructionsPreview ?? "");
722
+ if (!existing || next.content !== existing) {
723
+ await writeFile(memoryDocPath, next.content, "utf-8");
724
+ }
725
+ memoryDocExists = true;
726
+ memoryDocInstalled = next.installed;
727
+ memoryDocUpdated = next.updated;
728
+ } else if (captureInstructionsMode === "remove" && memoryDocExists) {
729
+ const existing = await readFile(memoryDocPath, "utf-8");
730
+ const next = removeManagedCaptureInstructions(existing);
731
+ if (next.removed) {
732
+ if (next.content.length === 0) {
733
+ await unlink(memoryDocPath);
734
+ memoryDocExists = false;
735
+ } else {
736
+ await writeFile(memoryDocPath, next.content, "utf-8");
737
+ memoryDocExists = true;
738
+ }
739
+ memoryDocRemoved = true;
740
+ }
741
+ }
742
+ }
743
+
744
+ const directories = await gatherDirectoryStatus(getSetupPaths(options.orchestrator.config));
745
+ const nextSteps = [
746
+ `Run \`openclaw engram doctor${options.installCaptureInstructions ? "" : " --json"}\` to verify runtime health.`,
747
+ "Run `openclaw engram inventory --json` to capture a baseline footprint.",
748
+ "If QMD is enabled and the collection is missing, add the collection to `~/.config/qmd/index.yml` and run `qmd update && qmd embed`.",
749
+ ];
750
+ if (explicitCaptureEnabled && !memoryDocExists) {
751
+ nextSteps.push("Run `openclaw engram setup --preview-capture-instructions` to review the managed explicit-capture snippet, then `--install-capture-instructions` to write it.");
752
+ }
753
+
754
+ return {
755
+ schemaVersion: 1,
756
+ generatedAt: now.toISOString(),
757
+ config: configStatus,
758
+ memoryDir: options.orchestrator.config.memoryDir,
759
+ workspaceDir: options.orchestrator.config.workspaceDir,
760
+ directories,
761
+ qmd: {
762
+ enabled: options.orchestrator.config.qmdEnabled,
763
+ available: qmdAvailable,
764
+ collectionState,
765
+ debugStatus: options.orchestrator.qmd.debugStatus(),
766
+ },
767
+ nativeKnowledge: nativeKnowledgeStatus,
768
+ explicitCapture: {
769
+ captureMode: options.orchestrator.config.captureMode,
770
+ enabled: explicitCaptureEnabled,
771
+ memoryDocPath,
772
+ memoryDocExists,
773
+ memoryDocInstalled,
774
+ memoryDocUpdated,
775
+ memoryDocRemoved,
776
+ preview: captureInstructionsMode === "preview" ? captureInstructionsPreview : null,
777
+ },
778
+ nextSteps,
779
+ verificationCommands: [
780
+ "openclaw engram doctor --json",
781
+ "openclaw engram inventory --json",
782
+ "openclaw engram benchmark recall --json",
783
+ ],
784
+ };
785
+ }
786
+
787
+ function summarizeHygieneWarnings(
788
+ warnings: Awaited<ReturnType<typeof lintWorkspaceFiles>>,
789
+ hygiene: FileHygieneConfig | undefined,
790
+ ): OperatorDoctorCheck {
791
+ if (!hygiene?.enabled || hygiene.lintEnabled !== true) {
792
+ return {
793
+ key: "file_hygiene",
794
+ status: "warn",
795
+ summary: "File hygiene linting is disabled; bootstrap file truncation warnings are not active.",
796
+ remediation: "Enable `fileHygiene.enabled` and `fileHygiene.lintEnabled` if large workspace bootstrap files are common.",
797
+ details: {
798
+ enabled: hygiene?.enabled === true,
799
+ lintEnabled: hygiene?.lintEnabled === true,
800
+ },
801
+ };
802
+ }
803
+ if (warnings.length > 0) {
804
+ return {
805
+ key: "file_hygiene",
806
+ status: "warn",
807
+ summary: `${warnings.length} bootstrap file(s) are near or above the configured budget.`,
808
+ remediation: "Archive/split the listed files or adjust `fileHygiene` budgets.",
809
+ details: { warnings },
810
+ };
811
+ }
812
+ return {
813
+ key: "file_hygiene",
814
+ status: "ok",
815
+ summary: "Bootstrap file hygiene is within budget.",
816
+ details: {
817
+ enabled: true,
818
+ lintPaths: hygiene.lintPaths,
819
+ budgetBytes: hygiene.lintBudgetBytes,
820
+ },
821
+ };
822
+ }
823
+
824
+ function buildConfigReviewFinding(input: {
825
+ key: string;
826
+ status: "recommend" | "problem";
827
+ setting: string;
828
+ currentValue: unknown;
829
+ defaultValue: unknown;
830
+ recommendedValue: unknown;
831
+ summary: string;
832
+ rationale: string;
833
+ }): OperatorConfigReviewFinding {
834
+ return {
835
+ key: input.key,
836
+ status: input.status,
837
+ setting: input.setting,
838
+ currentValue: formatConfigValue(input.currentValue),
839
+ defaultValue: formatConfigValue(input.defaultValue),
840
+ recommendedValue: formatConfigValue(input.recommendedValue),
841
+ summary: input.summary,
842
+ rationale: input.rationale,
843
+ };
844
+ }
845
+
846
+ export async function runOperatorConfigReview(
847
+ options: OperatorConfigReviewOptions,
848
+ ): Promise<OperatorConfigReviewReport> {
849
+ const now = options.now ?? new Date();
850
+ const configStatus = await loadCliPluginConfig(options.configPath);
851
+ return buildOperatorConfigReviewReport({
852
+ now,
853
+ configStatus,
854
+ config: options.orchestrator.config,
855
+ });
856
+ }
857
+
858
+ async function buildOperatorConfigReviewReport(input: {
859
+ now: Date;
860
+ configStatus: OperatorConfigLoadResult;
861
+ config: PluginConfig;
862
+ }): Promise<OperatorConfigReviewReport> {
863
+ const { now, configStatus, config } = input;
864
+ const findings: OperatorConfigReviewFinding[] = [];
865
+ const searchBackend = config.searchBackend ?? "qmd";
866
+ const workspaceBootstrapFiles = [
867
+ path.join(config.workspaceDir, "IDENTITY.md"),
868
+ path.join(config.workspaceDir, "MEMORY.md"),
869
+ path.join(config.workspaceDir, "USER.md"),
870
+ ];
871
+ const workspaceBootstrapExists = (await Promise.all(workspaceBootstrapFiles.map(pathExists))).some(Boolean);
872
+
873
+ if (
874
+ config.memoryOsPreset !== "conservative" &&
875
+ config.memoryOsPreset !== "balanced" &&
876
+ config.memoryOsPreset !== "research-max" &&
877
+ config.memoryOsPreset !== "local-llm-heavy" &&
878
+ config.queryAwareIndexingEnabled === false &&
879
+ config.verbatimArtifactsEnabled === false &&
880
+ config.rerankEnabled === false
881
+ ) {
882
+ findings.push(buildConfigReviewFinding({
883
+ key: "balanced_preset",
884
+ status: "recommend",
885
+ setting: "memoryOsPreset",
886
+ currentValue: config.memoryOsPreset,
887
+ defaultValue: "(unset)",
888
+ recommendedValue: "balanced",
889
+ summary: "Adopt the balanced preset as the baseline configuration profile.",
890
+ rationale:
891
+ "The balanced preset enables the recommended indexing, reranking, and artifact defaults without turning on the higher-churn graph and learning loops.",
892
+ }));
893
+ }
894
+
895
+ if (config.qmdEnabled && config.qmdDaemonEnabled === false) {
896
+ findings.push(buildConfigReviewFinding({
897
+ key: "qmd_daemon",
898
+ status: "recommend",
899
+ setting: "qmdDaemonEnabled",
900
+ currentValue: config.qmdDaemonEnabled,
901
+ defaultValue: true,
902
+ recommendedValue: true,
903
+ summary: "Enable the QMD daemon path when QMD powers recall.",
904
+ rationale:
905
+ "The daemon path reduces recall/search contention by preferring the MCP transport instead of repeated subprocess calls when QMD is available.",
906
+ }));
907
+ }
908
+
909
+ if (workspaceBootstrapExists && config.nativeKnowledge?.enabled !== true) {
910
+ findings.push(buildConfigReviewFinding({
911
+ key: "native_knowledge_enabled",
912
+ status: "recommend",
913
+ setting: "nativeKnowledge.enabled",
914
+ currentValue: config.nativeKnowledge?.enabled,
915
+ defaultValue: false,
916
+ recommendedValue: true,
917
+ summary: "Enable native knowledge recall for workspace bootstrap documents.",
918
+ rationale:
919
+ "When files like IDENTITY.md or MEMORY.md already exist, native knowledge recall can chunk and inject them directly instead of relying only on extracted memories.",
920
+ }));
921
+ }
922
+
923
+ if (workspaceBootstrapExists && config.fileHygiene?.enabled !== true) {
924
+ findings.push(buildConfigReviewFinding({
925
+ key: "file_hygiene_enabled",
926
+ status: "recommend",
927
+ setting: "fileHygiene.enabled",
928
+ currentValue: config.fileHygiene?.enabled,
929
+ defaultValue: false,
930
+ recommendedValue: true,
931
+ summary: "Enable file hygiene to avoid silent workspace-file truncation.",
932
+ rationale:
933
+ "OpenClaw bootstrap files can grow quietly; file hygiene warns before oversized files are truncated during prompt bootstrap.",
934
+ }));
935
+ }
936
+
937
+ if (searchBackend === "qmd" && config.qmdEnabled === false) {
938
+ findings.push(buildConfigReviewFinding({
939
+ key: "qmd_search_backend_disabled",
940
+ status: "problem",
941
+ setting: "qmdEnabled",
942
+ currentValue: config.qmdEnabled,
943
+ defaultValue: true,
944
+ recommendedValue: true,
945
+ summary: "QMD search is selected but QMD is disabled.",
946
+ rationale:
947
+ "When searchBackend resolves to qmd while qmdEnabled is false, Engram falls back to the noop backend and disables the primary search path.",
948
+ }));
949
+ }
950
+
951
+ if (config.qmdColdTierEnabled === true && config.qmdEnabled === false) {
952
+ findings.push(buildConfigReviewFinding({
953
+ key: "qmd_cold_tier_requires_qmd",
954
+ status: "problem",
955
+ setting: "qmdEnabled",
956
+ currentValue: config.qmdEnabled,
957
+ defaultValue: true,
958
+ recommendedValue: true,
959
+ summary: "Cold-tier QMD recall is enabled while QMD itself is disabled.",
960
+ rationale:
961
+ "The cold tier depends on the same QMD runtime as the hot tier, so turning QMD off leaves the extra tiering path unusable.",
962
+ }));
963
+ }
964
+
965
+ if (config.qmdTierMigrationEnabled && config.qmdColdTierEnabled !== true) {
966
+ findings.push(buildConfigReviewFinding({
967
+ key: "qmd_tier_migration_requires_cold_tier",
968
+ status: "problem",
969
+ setting: "qmdColdTierEnabled",
970
+ currentValue: config.qmdColdTierEnabled,
971
+ defaultValue: false,
972
+ recommendedValue: true,
973
+ summary: "Hot/cold tier migration is enabled without the cold tier itself.",
974
+ rationale:
975
+ "Tier migration depends on the cold-tier collection and recall path, so enabling migration while the cold tier is off leaves the feature in a contradictory state.",
976
+ }));
977
+ }
978
+
979
+ if (config.conversationIndexEnabled && config.conversationIndexBackend === "qmd" && config.qmdEnabled === false) {
980
+ findings.push(buildConfigReviewFinding({
981
+ key: "conversation_index_qmd_requires_qmd",
982
+ status: "problem",
983
+ setting: "qmdEnabled",
984
+ currentValue: config.qmdEnabled,
985
+ defaultValue: true,
986
+ recommendedValue: true,
987
+ summary: "The conversation index is configured for QMD while QMD is disabled.",
988
+ rationale:
989
+ "A QMD-backed conversation index cannot rebuild or serve queries when the underlying QMD runtime is disabled.",
990
+ }));
991
+ }
992
+
993
+ const summary = findings.reduce(
994
+ (acc, finding) => {
995
+ acc[finding.status] += 1;
996
+ return acc;
997
+ },
998
+ { recommend: 0, problem: 0 },
999
+ );
1000
+
1001
+ return {
1002
+ schemaVersion: 1,
1003
+ generatedAt: now.toISOString(),
1004
+ ok: configStatus.parsed && summary.problem === 0,
1005
+ config: configStatus,
1006
+ profile: {
1007
+ memoryOsPreset: config.memoryOsPreset,
1008
+ searchBackend,
1009
+ qmdEnabled: config.qmdEnabled,
1010
+ qmdDaemonEnabled: config.qmdDaemonEnabled,
1011
+ nativeKnowledgeEnabled: config.nativeKnowledge?.enabled === true,
1012
+ fileHygieneEnabled: config.fileHygiene?.enabled === true,
1013
+ conversationIndexEnabled: config.conversationIndexEnabled,
1014
+ },
1015
+ summary,
1016
+ findings,
1017
+ };
1018
+ }
1019
+
1020
+ export async function runOperatorDoctor(options: OperatorDoctorOptions): Promise<OperatorDoctorReport> {
1021
+ const now = options.now ?? new Date();
1022
+ const configStatus = await loadCliPluginConfig(options.configPath);
1023
+ const checks: OperatorDoctorCheck[] = [];
1024
+ const config = options.orchestrator.config;
1025
+ const storage = options.orchestrator.storage;
1026
+ const configReview = await buildOperatorConfigReviewReport({
1027
+ now,
1028
+ configStatus,
1029
+ config,
1030
+ });
1031
+ const nativeKnowledgeStatus = await summarizeNativeKnowledgeStatus(config);
1032
+ const setupPaths = await gatherDirectoryStatus(getSetupPaths(config));
1033
+ const missingPaths = setupPaths.filter((entry) => !entry.exists).map((entry) => entry.path);
1034
+
1035
+ checks.push({
1036
+ key: "config",
1037
+ status: configStatus.parsed
1038
+ ? "ok"
1039
+ : options.configPath
1040
+ ? "error"
1041
+ : "warn",
1042
+ summary: configStatus.parsed ? "OpenClaw config loaded and Engram config parsed successfully." : "Config file could not be parsed.",
1043
+ remediation: configStatus.parsed ? undefined : "Fix the config file or set OPENCLAW_ENGRAM_CONFIG_PATH/OPENCLAW_CONFIG_PATH.",
1044
+ details: configStatus,
1045
+ });
1046
+
1047
+ checks.push({
1048
+ key: "memory_dir",
1049
+ status: missingPaths.length === 0 ? "ok" : "warn",
1050
+ summary: missingPaths.length === 0
1051
+ ? "Expected Engram directories exist."
1052
+ : `${missingPaths.length} expected directory path(s) are missing.`,
1053
+ remediation: missingPaths.length === 0 ? undefined : "Run `openclaw engram setup` to create missing directories.",
1054
+ details: { directories: setupPaths },
1055
+ });
1056
+
1057
+ checks.push({
1058
+ key: "config_review",
1059
+ status: configReview.summary.problem > 0 ? "error" : configReview.summary.recommend > 0 ? "warn" : "ok",
1060
+ summary: configReview.summary.problem > 0
1061
+ ? `${configReview.summary.problem} configuration problem(s) detected.`
1062
+ : configReview.summary.recommend > 0
1063
+ ? `No configuration problems detected; ${configReview.summary.recommend} optional recommendation(s) are available.`
1064
+ : "No configuration problems detected.",
1065
+ remediation: configReview.summary.problem > 0 || configReview.summary.recommend > 0
1066
+ ? "Run `openclaw engram config-review` to inspect and fix the flagged configuration combinations."
1067
+ : undefined,
1068
+ details: configReview,
1069
+ });
1070
+
1071
+ const qmdAvailable = await options.orchestrator.qmd.probe();
1072
+ const collectionState = config.qmdEnabled
1073
+ ? await options.orchestrator.qmd.ensureCollection(config.memoryDir)
1074
+ : "skipped";
1075
+ checks.push({
1076
+ key: "qmd",
1077
+ status: !config.qmdEnabled
1078
+ ? "warn"
1079
+ : !qmdAvailable
1080
+ ? "error"
1081
+ : collectionState === "present"
1082
+ ? "ok"
1083
+ : collectionState === "missing"
1084
+ ? "error"
1085
+ : "warn",
1086
+ summary: !config.qmdEnabled
1087
+ ? "QMD is disabled in config."
1088
+ : qmdAvailable
1089
+ ? `QMD is reachable (${collectionState}).`
1090
+ : "QMD is not currently reachable.",
1091
+ remediation: !config.qmdEnabled
1092
+ ? "Enable `qmdEnabled` if you expect hybrid search."
1093
+ : !qmdAvailable
1094
+ ? "Ensure the `qmd` binary is installed and on PATH, or set `qmdPath`."
1095
+ : collectionState === "missing"
1096
+ ? "Add the configured collection to `~/.config/qmd/index.yml`."
1097
+ : collectionState === "present"
1098
+ ? undefined
1099
+ : "Re-run `openclaw engram setup` after restoring QMD access.",
1100
+ details: {
1101
+ available: qmdAvailable,
1102
+ collectionState,
1103
+ debugStatus: options.orchestrator.qmd.debugStatus(),
1104
+ },
1105
+ });
1106
+
1107
+ const conversationIndex = await options.orchestrator.getConversationIndexHealth();
1108
+ checks.push({
1109
+ key: "conversation_index",
1110
+ status: conversationIndex.status === "ok"
1111
+ ? "ok"
1112
+ : conversationIndex.enabled
1113
+ ? "error"
1114
+ : "warn",
1115
+ summary: conversationIndex.enabled
1116
+ ? `Conversation index backend is ${conversationIndex.status}.`
1117
+ : "Conversation index is disabled.",
1118
+ remediation: conversationIndex.enabled && conversationIndex.status !== "ok"
1119
+ ? "Run `openclaw engram rebuild-index` to refresh the conversation index artifacts."
1120
+ : undefined,
1121
+ details: conversationIndex,
1122
+ });
1123
+
1124
+ const meta = await storage.loadMeta();
1125
+ checks.push({
1126
+ key: "maintenance",
1127
+ status: meta.lastExtractionAt || meta.lastConsolidationAt ? "ok" : "warn",
1128
+ summary: meta.lastExtractionAt || meta.lastConsolidationAt
1129
+ ? "Extraction/consolidation metadata is present."
1130
+ : "No extraction or consolidation metadata found yet.",
1131
+ remediation: meta.lastExtractionAt || meta.lastConsolidationAt
1132
+ ? undefined
1133
+ : "Run a normal agent turn or `openclaw engram consolidate` after seeding memory.",
1134
+ details: meta,
1135
+ });
1136
+
1137
+ const syncedChunkCount =
1138
+ nativeKnowledgeStatus.curatedIncludeSync.activeChunkCount +
1139
+ nativeKnowledgeStatus.obsidianSync.activeChunkCount +
1140
+ nativeKnowledgeStatus.openclawWorkspaceSync.activeChunkCount;
1141
+ const hasSyncState =
1142
+ nativeKnowledgeStatus.curatedIncludeSync.exists ||
1143
+ nativeKnowledgeStatus.obsidianSync.exists ||
1144
+ nativeKnowledgeStatus.openclawWorkspaceSync.exists;
1145
+ checks.push({
1146
+ key: "native_knowledge",
1147
+ status: !nativeKnowledgeStatus.enabled
1148
+ ? "warn"
1149
+ : hasSyncState
1150
+ ? "ok"
1151
+ : "warn",
1152
+ summary: !nativeKnowledgeStatus.enabled
1153
+ ? "Native knowledge sync is disabled."
1154
+ : hasSyncState
1155
+ ? `Native knowledge sync state is present (${syncedChunkCount} active chunks).`
1156
+ : "Native knowledge sync is enabled but no sync state has been written yet.",
1157
+ remediation: !nativeKnowledgeStatus.enabled
1158
+ ? "Enable `nativeKnowledge.enabled` if curated workspace recall should participate in retrieval."
1159
+ : hasSyncState
1160
+ ? undefined
1161
+ : "Run a recall, sync, or setup flow that touches native knowledge sources, then rerun `openclaw engram doctor --json`.",
1162
+ details: nativeKnowledgeStatus,
1163
+ });
1164
+
1165
+ const agentAccessEnabled = config.agentAccessHttp?.enabled === true;
1166
+ // A SecretRef object counts as "configured" (issue #757) — resolution
1167
+ // happens at service-start time, not at doctor-time. We only check that
1168
+ // *something* is set; we never log the resolved value.
1169
+ const rawAuthToken = config.agentAccessHttp?.authToken;
1170
+ const authTokenConfigured =
1171
+ (typeof rawAuthToken === "string" && rawAuthToken.length > 0) ||
1172
+ (rawAuthToken !== null &&
1173
+ typeof rawAuthToken === "object" &&
1174
+ typeof (rawAuthToken as { source?: unknown }).source === "string");
1175
+ checks.push({
1176
+ key: "access_http_auth",
1177
+ status: !agentAccessEnabled
1178
+ ? "warn"
1179
+ : authTokenConfigured
1180
+ ? "ok"
1181
+ : "error",
1182
+ summary: !agentAccessEnabled
1183
+ ? "Agent access HTTP bridge is disabled."
1184
+ : authTokenConfigured
1185
+ ? "Agent access HTTP bridge has an auth token configured."
1186
+ : "Agent access HTTP bridge is enabled without an auth token.",
1187
+ remediation: !agentAccessEnabled
1188
+ ? "Ignore unless you plan to enable the HTTP bridge."
1189
+ : authTokenConfigured
1190
+ ? undefined
1191
+ : "Set `agentAccessHttp.authToken` before exposing the bridge.",
1192
+ });
1193
+
1194
+ const warnings = config.fileHygiene?.lintEnabled
1195
+ ? await lintWorkspaceFiles({
1196
+ workspaceDir: config.workspaceDir,
1197
+ paths: config.fileHygiene.lintPaths,
1198
+ budgetBytes: config.fileHygiene.lintBudgetBytes,
1199
+ warnRatio: config.fileHygiene.lintWarnRatio,
1200
+ })
1201
+ : [];
1202
+ checks.push(summarizeHygieneWarnings(warnings, config.fileHygiene));
1203
+
1204
+ // Memory Worth legacy counter audit (issue #560 PR 1).
1205
+ // Memories written before #560 have no `mw_success` / `mw_fail` frontmatter
1206
+ // fields. That is fully supported — readers treat the absence as a uniform
1207
+ // Beta(1,1) prior — but surfacing the count helps operators understand how
1208
+ // much history will bootstrap the scoring pipeline landed in later PRs.
1209
+ // This is an informational check, never an error.
1210
+ checks.push(await summarizeMemoryWorthLegacyCounters(storage));
1211
+
1212
+ // Buffer surprise telemetry distribution (issue #563 PR 3).
1213
+ // Surfaces recent surprise scores so operators can calibrate the
1214
+ // `bufferSurpriseThreshold` from real traffic. Never an error — an empty
1215
+ // ledger is the expected state until the flag is turned on.
1216
+ checks.push(
1217
+ await summarizeBufferSurpriseDistribution(storage, config),
1218
+ );
1219
+
1220
+ // Consolidation provenance integrity (issue #561 PR 4).
1221
+ // Validates that every `derived_from` entry resolves to an on-disk
1222
+ // page-version snapshot and every `derived_via` is a known operator.
1223
+ // Broken provenance emits warnings with the offending file path — the
1224
+ // check is informational (never an error) because a missing snapshot
1225
+ // can legitimately occur after log pruning or versioning being disabled
1226
+ // retroactively; operators need visibility, not a hard fail. Review
1227
+ // feedback (PR #634): the summarizer threads the configured
1228
+ // `versioningSidecarDir` into the scan so deployments that override
1229
+ // the default `.versions` directory get accurate results instead of
1230
+ // false-missing warnings.
1231
+ checks.push(await summarizeConsolidationProvenance(storage, config));
1232
+
1233
+ // Graph-edge decay maintenance status (issue #681 PR 2/3).
1234
+ // Reports whether the periodic decay job has run and surfaces last-run
1235
+ // counts. Disabled is "ok" with a note; enabled-but-never-run is "warn".
1236
+ checks.push(await summarizeGraphEdgeDecayStatus(config));
1237
+
1238
+ // Tier distribution (issue #686 retention-completion).
1239
+ // Shows hot/cold counts, per-status breakdown, and forgotten-memory count.
1240
+ // Informational only — never errors, never blocks doctor from returning ok.
1241
+ checks.push(await summarizeTierDistribution(options.orchestrator.storage));
1242
+
1243
+ // Dreams phases thresholds and last-run timestamps (issue #678 PR 2/4).
1244
+ // Surfaces per-phase: enabled status, cadence, threshold values, and the
1245
+ // best-available last-run timestamp for each of the three pipeline phases.
1246
+ checks.push(await summarizeDreamsPhases(config, storage));
1247
+
1248
+ // Security mitigation status (issue #565).
1249
+ // Reports whether the cross-namespace budget and anomaly detection
1250
+ // mitigations are enabled and surfaces config values for operator review.
1251
+ checks.push(summarizeSecurityMitigations(config));
1252
+
1253
+ // Observation throughput + judge acceptance rate (issue #685).
1254
+ // Surfaces the total verdict count, accept/reject/defer breakdown, and the
1255
+ // most recent `observedAt` timestamp from the extraction-judge telemetry
1256
+ // ledger. This closes the *(future)* item deferred in
1257
+ // `docs/trace-to-primitive.md`. The check is purely informational — it
1258
+ // always resolves to `ok`; an empty ledger is the expected cold-install
1259
+ // state and is never an error.
1260
+ checks.push(await summarizeObservationThroughput(config.memoryDir));
1261
+
1262
+ const summary = checks.reduce(
1263
+ (acc, check) => {
1264
+ acc[check.status] += 1;
1265
+ return acc;
1266
+ },
1267
+ { ok: 0, warn: 0, error: 0 },
1268
+ );
1269
+
1270
+ return {
1271
+ schemaVersion: 1,
1272
+ generatedAt: now.toISOString(),
1273
+ ok: summary.error === 0,
1274
+ summary,
1275
+ config: configStatus,
1276
+ checks,
1277
+ };
1278
+ }
1279
+
1280
+ /**
1281
+ * Categories whose memories are eligible for Memory Worth instrumentation.
1282
+ *
1283
+ * Memory Worth is a per-fact utility signal: the counters ride on extracted
1284
+ * facts whose retrieval outcome can be judged (success/fail) by the feedback
1285
+ * pipeline landing in issue #560 PR 3. Procedures, corrections, and other
1286
+ * non-fact memory kinds are out of scope — they are not expected to be
1287
+ * instrumented, and counting them as "legacy" would permanently inflate the
1288
+ * legacy bucket and make rollout progress misleading even when every fact
1289
+ * memory is instrumented.
1290
+ *
1291
+ * If a later PR widens Memory Worth to additional categories, extend this set
1292
+ * alongside the scoring/increment logic so the doctor audit stays in sync.
1293
+ */
1294
+ const MEMORY_WORTH_ELIGIBLE_CATEGORIES: ReadonlySet<MemoryFile["frontmatter"]["category"]> =
1295
+ new Set(["fact"]);
1296
+
1297
+ /**
1298
+ * Count memories that pre-date the Memory Worth counters introduced in issue
1299
+ * #560 — i.e., neither `mw_success` nor `mw_fail` is set on the frontmatter.
1300
+ *
1301
+ * Only memories whose category is eligible for Memory Worth (see
1302
+ * `MEMORY_WORTH_ELIGIBLE_CATEGORIES`) are considered. Procedures, corrections,
1303
+ * and other kinds that are not instrumented are excluded entirely — they're
1304
+ * neither "legacy" nor "instrumented" for the purposes of this audit. The
1305
+ * total in the returned details reflects only eligible memories.
1306
+ *
1307
+ * Returned as an `ok` check regardless of count, since legacy memories are
1308
+ * fully functional (readers treat missing counters as zero observations). The
1309
+ * numbers are informational for operators following the #560 rollout.
1310
+ *
1311
+ * Exported so unit tests can exercise the classification logic without
1312
+ * booting a full orchestrator.
1313
+ */
1314
+ export async function summarizeMemoryWorthLegacyCounters(
1315
+ storage: StorageManager,
1316
+ ): Promise<OperatorDoctorCheck> {
1317
+ let legacy = 0;
1318
+ let instrumented = 0;
1319
+ let ineligible = 0;
1320
+ try {
1321
+ const memories = await storage.readAllMemories();
1322
+ for (const memory of memories) {
1323
+ if (!MEMORY_WORTH_ELIGIBLE_CATEGORIES.has(memory.frontmatter.category)) {
1324
+ ineligible += 1;
1325
+ continue;
1326
+ }
1327
+ const { mw_success, mw_fail } = memory.frontmatter;
1328
+ if (mw_success === undefined && mw_fail === undefined) {
1329
+ legacy += 1;
1330
+ } else {
1331
+ instrumented += 1;
1332
+ }
1333
+ }
1334
+ } catch (err) {
1335
+ return {
1336
+ key: "memory_worth_legacy",
1337
+ status: "warn",
1338
+ summary: "Could not enumerate memories to count Memory Worth instrumentation.",
1339
+ remediation: "Retry `remnic doctor` after ensuring the memory directory is readable.",
1340
+ details: { error: String(err) },
1341
+ };
1342
+ }
1343
+
1344
+ const total = legacy + instrumented;
1345
+ return {
1346
+ key: "memory_worth_legacy",
1347
+ status: "ok",
1348
+ summary:
1349
+ total === 0
1350
+ ? "No Memory Worth–eligible memories on disk yet — counters will populate as facts are extracted."
1351
+ : `${legacy} of ${total} eligible memories have no Memory Worth counters yet (${instrumented} instrumented).`,
1352
+ details: { legacy, instrumented, total, ineligible },
1353
+ };
1354
+ }
1355
+
1356
+ /**
1357
+ * Summarize the recent buffer-surprise telemetry distribution for the
1358
+ * Doctor report (issue #563 PR 3).
1359
+ *
1360
+ * Reports mean/median/p90 surprise scores and the triggered-flush rate
1361
+ * over the most recent window of ledger rows. An empty ledger is the
1362
+ * expected state until `bufferSurpriseTriggerEnabled` is turned on — the
1363
+ * check never escalates beyond `ok` / `warn` (ledger unreadable).
1364
+ *
1365
+ * Exported so tests can exercise the formatting without booting a real
1366
+ * orchestrator.
1367
+ */
1368
+ export async function summarizeBufferSurpriseDistribution(
1369
+ storage: StorageManager,
1370
+ config: PluginConfig,
1371
+ ): Promise<OperatorDoctorCheck> {
1372
+ const storageWithLedger = storage as StorageManager & {
1373
+ readBufferSurpriseEvents?: (
1374
+ opts: { limit?: number },
1375
+ ) => Promise<BufferSurpriseEvent[]>;
1376
+ };
1377
+
1378
+ // Defensive: older StorageManager builds (not yet rebuilt) may lack the
1379
+ // reader. Do not fail the entire Doctor run in that case.
1380
+ if (typeof storageWithLedger.readBufferSurpriseEvents !== "function") {
1381
+ return {
1382
+ key: "buffer_surprise_distribution",
1383
+ status: "ok",
1384
+ summary: "Buffer-surprise telemetry reader unavailable in this build.",
1385
+ details: { available: false },
1386
+ };
1387
+ }
1388
+
1389
+ try {
1390
+ const dist = await reportBufferSurpriseDistribution(
1391
+ async (opts) =>
1392
+ storageWithLedger.readBufferSurpriseEvents!({ limit: opts.limit }),
1393
+ { limit: 200 },
1394
+ );
1395
+
1396
+ if (dist.count === 0) {
1397
+ return {
1398
+ key: "buffer_surprise_distribution",
1399
+ status: "ok",
1400
+ summary: config.bufferSurpriseTriggerEnabled
1401
+ ? "Surprise trigger is enabled but no telemetry has been recorded yet."
1402
+ : "Surprise trigger is disabled; no telemetry expected.",
1403
+ details: {
1404
+ enabled: config.bufferSurpriseTriggerEnabled,
1405
+ distribution: dist,
1406
+ },
1407
+ };
1408
+ }
1409
+
1410
+ const pct = (value: number) => (value * 100).toFixed(1);
1411
+ return {
1412
+ key: "buffer_surprise_distribution",
1413
+ status: "ok",
1414
+ summary: `Recent surprise: mean=${dist.mean.toFixed(3)}, median=${dist.median.toFixed(3)}, p90=${dist.p90.toFixed(3)}, triggered=${pct(dist.triggeredRate)}% over ${dist.count} turns (threshold=${dist.currentThreshold ?? config.bufferSurpriseThreshold}).`,
1415
+ details: {
1416
+ enabled: config.bufferSurpriseTriggerEnabled,
1417
+ distribution: dist,
1418
+ },
1419
+ };
1420
+ } catch (err) {
1421
+ return {
1422
+ key: "buffer_surprise_distribution",
1423
+ status: "warn",
1424
+ summary: "Could not read buffer-surprise telemetry ledger.",
1425
+ remediation:
1426
+ "Retry `remnic doctor` after ensuring the memory state directory is readable.",
1427
+ details: { error: String(err) },
1428
+ };
1429
+ }
1430
+ }
1431
+
1432
+ /**
1433
+ * Summarize the consolidation-provenance integrity scan for the doctor
1434
+ * report (issue #561 PR 4). Returns an `ok` check when no issues are
1435
+ * found, `warn` otherwise. Never returns `error` — a broken provenance
1436
+ * pointer is informational because it can legitimately result from log
1437
+ * pruning, versioning being disabled retroactively, or operator-driven
1438
+ * archive operations.
1439
+ *
1440
+ * Exported so unit tests can exercise the summarization without booting a
1441
+ * full orchestrator.
1442
+ */
1443
+
1444
+ async function summarizeGraphEdgeDecayStatus(
1445
+ config: Pick<
1446
+ PluginConfig,
1447
+ "memoryDir" | "graphEdgeDecayEnabled" | "graphEdgeDecayCadenceMs"
1448
+ >,
1449
+ ): Promise<OperatorDoctorCheck> {
1450
+ // Lazy import to keep the doctor fast when the feature is disabled.
1451
+ const { readGraphEdgeDecayStatus } = await import("./maintenance/graph-edge-decay.js");
1452
+ const enabled = config.graphEdgeDecayEnabled === true;
1453
+ if (!enabled) {
1454
+ return {
1455
+ key: "graph_edge_decay",
1456
+ status: "ok",
1457
+ summary: "Graph-edge decay maintenance is disabled (graphEdgeDecayEnabled = false).",
1458
+ remediation: "Set graphEdgeDecayEnabled = true to opt into the periodic decay job (issue #681).",
1459
+ details: { enabled: false },
1460
+ };
1461
+ }
1462
+
1463
+ const status = await readGraphEdgeDecayStatus(config.memoryDir);
1464
+ if (!status) {
1465
+ return {
1466
+ key: "graph_edge_decay",
1467
+ status: "warn",
1468
+ summary: "Graph-edge decay is enabled but has not run yet (no status file present).",
1469
+ remediation:
1470
+ "Trigger the cron, run `engram.graph_edge_decay_run` via MCP, or wait for the scheduled cadence to fire.",
1471
+ details: { enabled: true, lastRun: null, cadenceMs: config.graphEdgeDecayCadenceMs },
1472
+ };
1473
+ }
1474
+
1475
+ return {
1476
+ key: "graph_edge_decay",
1477
+ status: "ok",
1478
+ summary:
1479
+ `Graph-edge decay last ran at ${status.ranAt} ` +
1480
+ `(${status.edgesDecayed}/${status.edgesTotal} edges decayed, ` +
1481
+ `${status.edgesBelowVisibilityThreshold} below visibility threshold).`,
1482
+ details: {
1483
+ enabled: true,
1484
+ lastRun: status.ranAt,
1485
+ durationMs: status.durationMs,
1486
+ edgesTotal: status.edgesTotal,
1487
+ edgesDecayed: status.edgesDecayed,
1488
+ edgesBelowVisibilityThreshold: status.edgesBelowVisibilityThreshold,
1489
+ topDecayedEntities: status.topDecayedEntities,
1490
+ cadenceMs: config.graphEdgeDecayCadenceMs,
1491
+ },
1492
+ };
1493
+ }
1494
+
1495
+ /**
1496
+ * Summarize hot/cold tier distribution for the Doctor report
1497
+ * (issue #686 retention-completion).
1498
+ *
1499
+ * Shows:
1500
+ * - hot vs cold memory counts
1501
+ * - forgotten-memory count
1502
+ * - top per-status breakdown
1503
+ * - recent migrations in the last 7 days (from the tier-migration journal)
1504
+ * - top demotion reasons from the journal
1505
+ *
1506
+ * Always returns an `ok` check — this section is informational, never
1507
+ * a gate. A missing journal or unreadable corpus is surfaced as a note,
1508
+ * not an error.
1509
+ *
1510
+ * Exported so tests can exercise the summarizer without a full orchestrator.
1511
+ */
1512
+ export async function summarizeTierDistribution(
1513
+ storage: StorageManager,
1514
+ ): Promise<OperatorDoctorCheck> {
1515
+ try {
1516
+ const { summarizeTiers } = await import("./maintenance/tier-stats.js");
1517
+ const summary = await summarizeTiers(storage);
1518
+
1519
+ // Read recent migration journal entries (last 7 days)
1520
+ const storageDir = (storage as unknown as { dir?: string }).dir ?? "";
1521
+ const journalPath = storageDir.length > 0
1522
+ ? path.join(storageDir, "state", "tier-migration-journal.jsonl")
1523
+ : null;
1524
+ let recentMigrations = 0;
1525
+ const demotionReasons: Record<string, number> = {};
1526
+ const sevenDaysAgoMs = Date.now() - 7 * 86_400_000;
1527
+
1528
+ if (journalPath) {
1529
+ try {
1530
+ const { readFile } = await import("node:fs/promises");
1531
+ const raw = await readFile(journalPath, "utf-8");
1532
+ for (const line of raw.split("\n")) {
1533
+ const trimmed = line.trim();
1534
+ if (trimmed.length === 0) continue;
1535
+ try {
1536
+ const entry = JSON.parse(trimmed) as {
1537
+ ts?: string;
1538
+ changed?: boolean;
1539
+ fromTier?: string;
1540
+ toTier?: string;
1541
+ reason?: string;
1542
+ };
1543
+ const tsMs = entry.ts ? Date.parse(entry.ts) : NaN;
1544
+ if (Number.isFinite(tsMs) && tsMs >= sevenDaysAgoMs && entry.changed === true) {
1545
+ recentMigrations += 1;
1546
+ if (entry.fromTier === "hot" && entry.toTier === "cold" && typeof entry.reason === "string") {
1547
+ const reason = entry.reason;
1548
+ demotionReasons[reason] = (demotionReasons[reason] ?? 0) + 1;
1549
+ }
1550
+ }
1551
+ } catch {
1552
+ // Malformed line — skip
1553
+ }
1554
+ }
1555
+ } catch {
1556
+ // Journal not present yet — expected on fresh installs
1557
+ }
1558
+ }
1559
+
1560
+ const topDemotionReasons = Object.entries(demotionReasons)
1561
+ .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
1562
+ .slice(0, 5)
1563
+ .map(([reason, count]) => ({ reason, count }));
1564
+
1565
+ const statusParts = Object.entries(summary.byStatus)
1566
+ .sort((a, b) => b[1] - a[1] || a[0].localeCompare(b[0]))
1567
+ .slice(0, 6)
1568
+ .map(([s, n]) => `${s}: ${n}`)
1569
+ .join(", ");
1570
+
1571
+ return {
1572
+ key: "tier_distribution",
1573
+ status: "ok",
1574
+ summary:
1575
+ `Tier distribution: hot=${summary.byTier.hot}, cold=${summary.byTier.cold}` +
1576
+ (summary.forgottenCount > 0 ? `, forgotten=${summary.forgottenCount}` : "") +
1577
+ `. Total: ${summary.total}.` +
1578
+ (recentMigrations > 0 ? ` Recent migrations (7d): ${recentMigrations}.` : ""),
1579
+ details: {
1580
+ total: summary.total,
1581
+ byTier: summary.byTier,
1582
+ byStatus: summary.byStatus,
1583
+ forgottenCount: summary.forgottenCount,
1584
+ statusSummary: statusParts,
1585
+ recentMigrations,
1586
+ topDemotionReasons,
1587
+ },
1588
+ };
1589
+ } catch (err) {
1590
+ return {
1591
+ key: "tier_distribution",
1592
+ status: "ok",
1593
+ summary: "Tier distribution unavailable — could not enumerate memories.",
1594
+ details: { error: String(err) },
1595
+ };
1596
+ }
1597
+ }
1598
+
1599
+ /**
1600
+ * Dreams phases doctor check (issue #678 PR 2/4).
1601
+ *
1602
+ * Reports per-phase: enabled status, cadence, threshold values, and last-run
1603
+ * timestamp sourced from `meta.json` (the existing maintenance ledger).
1604
+ *
1605
+ * Last-run mapping (best available in PR 2; PR 3/4 will emit per-phase events):
1606
+ * light sleep → `meta.lastExtractionAt` (lifecycle pass runs with extraction)
1607
+ * REM → `meta.lastConsolidationAt` (semantic consolidation)
1608
+ * deep sleep → latest governance run manifest when present, otherwise null
1609
+ */
1610
+ export async function summarizeDreamsPhases(
1611
+ config: Pick<PluginConfig, "memoryDir" | "dreamsPhases">,
1612
+ storage: StorageManager = new StorageManager(config.memoryDir),
1613
+ ): Promise<OperatorDoctorCheck> {
1614
+ const phases: DreamsPhasesConfig = config.dreamsPhases;
1615
+
1616
+ // Load meta.json for best-available last-run timestamps.
1617
+ const meta = await storage.loadMeta();
1618
+
1619
+ let deepSleepLastRun: string | null = null;
1620
+ let deepSleepLastRunWarning: string | null = null;
1621
+ try {
1622
+ // Read the latest governance run's manifest from the real on-disk format
1623
+ // rather than treating every failure as "no runs yet".
1624
+ const runsDir = path.join(config.memoryDir, "state", "memory-governance", "runs");
1625
+ const runIds = (await readdir(runsDir)).sort().reverse();
1626
+ if (runIds.length > 0) {
1627
+ const latestRunId = runIds[0];
1628
+ const manifestPath = path.join(
1629
+ runsDir,
1630
+ latestRunId,
1631
+ "manifest.json",
1632
+ );
1633
+ const raw = await readFile(manifestPath, "utf-8");
1634
+ const parsed = JSON.parse(raw) as Record<string, unknown>;
1635
+ if (typeof parsed.createdAt === "string" && parsed.createdAt.length > 0) {
1636
+ deepSleepLastRun = parsed.createdAt;
1637
+ }
1638
+ }
1639
+ } catch (error) {
1640
+ if (!isMissingPathError(error)) {
1641
+ deepSleepLastRunWarning = `Could not read latest governance run manifest: ${formatUnknownError(error)}`;
1642
+ }
1643
+ }
1644
+
1645
+ // Build per-phase summary lines for the human-readable `summary` field.
1646
+ const phaseLines: string[] = [
1647
+ `lightSleep: enabled=${phases.lightSleep.enabled}, cadenceMs=${phases.lightSleep.cadenceMs}, promoteHeat=${phases.lightSleep.promoteHeatThreshold}, staleDecay=${phases.lightSleep.staleDecayThreshold}, archiveDecay=${phases.lightSleep.archiveDecayThreshold}, filterStale=${phases.lightSleep.filterStaleEnabled}, lastRun=${meta.lastExtractionAt ?? "never"}`,
1648
+ `rem: enabled=${phases.rem.enabled}, cadenceMs=${phases.rem.cadenceMs}, similarity=${phases.rem.similarityThreshold}, minCluster=${phases.rem.minClusterSize}, maxPerRun=${phases.rem.maxPerRun}, minIntervalMs=${phases.rem.minIntervalMs}, lastRun=${meta.lastConsolidationAt ?? "never"}`,
1649
+ `deepSleep: enabled=${phases.deepSleep.enabled}, cadenceMs=${phases.deepSleep.cadenceMs}, versioning=${phases.deepSleep.versioningEnabled}, versioningMaxPerPage=${phases.deepSleep.versioningMaxPerPage}, lastRun=${deepSleepLastRun ?? "never"}`,
1650
+ ];
1651
+
1652
+ return {
1653
+ key: "dreams_phases",
1654
+ status: deepSleepLastRunWarning ? "warn" : "ok",
1655
+ summary: `Dreams pipeline phases: ${phaseLines.join("; ")}${deepSleepLastRunWarning ? `; ${deepSleepLastRunWarning}` : ""}`,
1656
+ remediation: deepSleepLastRunWarning
1657
+ ? "Inspect state/memory-governance/runs and repair or remove unreadable governance run artifacts."
1658
+ : undefined,
1659
+ details: {
1660
+ lightSleep: {
1661
+ enabled: phases.lightSleep.enabled,
1662
+ cadenceMs: phases.lightSleep.cadenceMs,
1663
+ promoteHeatThreshold: phases.lightSleep.promoteHeatThreshold,
1664
+ staleDecayThreshold: phases.lightSleep.staleDecayThreshold,
1665
+ archiveDecayThreshold: phases.lightSleep.archiveDecayThreshold,
1666
+ filterStaleEnabled: phases.lightSleep.filterStaleEnabled,
1667
+ lastRun: meta.lastExtractionAt ?? null,
1668
+ },
1669
+ rem: {
1670
+ enabled: phases.rem.enabled,
1671
+ cadenceMs: phases.rem.cadenceMs,
1672
+ similarityThreshold: phases.rem.similarityThreshold,
1673
+ minClusterSize: phases.rem.minClusterSize,
1674
+ maxPerRun: phases.rem.maxPerRun,
1675
+ minIntervalMs: phases.rem.minIntervalMs,
1676
+ lastRun: meta.lastConsolidationAt ?? null,
1677
+ },
1678
+ deepSleep: {
1679
+ enabled: phases.deepSleep.enabled,
1680
+ cadenceMs: phases.deepSleep.cadenceMs,
1681
+ versioningEnabled: phases.deepSleep.versioningEnabled,
1682
+ versioningMaxPerPage: phases.deepSleep.versioningMaxPerPage,
1683
+ lastRun: deepSleepLastRun,
1684
+ warning: deepSleepLastRunWarning,
1685
+ },
1686
+ },
1687
+ };
1688
+ }
1689
+
1690
+ function summarizeSecurityMitigations(
1691
+ config: Pick<
1692
+ PluginConfig,
1693
+ | "recallCrossNamespaceBudgetEnabled"
1694
+ | "recallCrossNamespaceBudgetWindowMs"
1695
+ | "recallCrossNamespaceBudgetSoftLimit"
1696
+ | "recallCrossNamespaceBudgetHardLimit"
1697
+ | "recallAuditAnomalyDetectionEnabled"
1698
+ | "recallAuditAnomalyWindowMs"
1699
+ | "recallAuditAnomalyRepeatQueryLimit"
1700
+ | "recallAuditAnomalyNamespaceWalkLimit"
1701
+ | "recallAuditAnomalyHighCardinalityLimit"
1702
+ | "recallAuditAnomalyRapidFireLimit"
1703
+ >,
1704
+ ): OperatorDoctorCheck {
1705
+ const budgetEnabled = config.recallCrossNamespaceBudgetEnabled === true;
1706
+ const anomalyEnabled = config.recallAuditAnomalyDetectionEnabled === true;
1707
+
1708
+ if (!budgetEnabled && !anomalyEnabled) {
1709
+ return {
1710
+ key: "security_mitigations",
1711
+ status: "warn",
1712
+ summary: "Memory-extraction mitigations are disabled (cross-namespace budget and anomaly detection off).",
1713
+ remediation: "Enable recallCrossNamespaceBudgetEnabled and/or recallAuditAnomalyDetectionEnabled for production deployments. See docs/security/memory-extraction-threat-model.md.",
1714
+ details: {
1715
+ budgetEnabled: false,
1716
+ anomalyDetectionEnabled: false,
1717
+ },
1718
+ };
1719
+ }
1720
+
1721
+ const details: Record<string, unknown> = {
1722
+ budgetEnabled,
1723
+ anomalyDetectionEnabled: anomalyEnabled,
1724
+ };
1725
+
1726
+ if (budgetEnabled) {
1727
+ details.budgetConfig = {
1728
+ windowMs: config.recallCrossNamespaceBudgetWindowMs,
1729
+ softLimit: config.recallCrossNamespaceBudgetSoftLimit,
1730
+ hardLimit: config.recallCrossNamespaceBudgetHardLimit,
1731
+ };
1732
+ }
1733
+
1734
+ if (anomalyEnabled) {
1735
+ details.anomalyConfig = {
1736
+ windowMs: config.recallAuditAnomalyWindowMs,
1737
+ repeatQueryLimit: config.recallAuditAnomalyRepeatQueryLimit,
1738
+ namespaceWalkLimit: config.recallAuditAnomalyNamespaceWalkLimit,
1739
+ highCardinalityLimit: config.recallAuditAnomalyHighCardinalityLimit,
1740
+ rapidFireLimit: config.recallAuditAnomalyRapidFireLimit,
1741
+ };
1742
+ }
1743
+
1744
+ return {
1745
+ key: "security_mitigations",
1746
+ status: "ok",
1747
+ summary: `Memory-extraction mitigation config enabled: ${budgetEnabled ? "budget" : ""}${budgetEnabled && anomalyEnabled ? ", " : ""}${anomalyEnabled ? "anomaly detection" : ""}.`,
1748
+ details: { ...details, configOnly: true },
1749
+ };
1750
+ }
1751
+
1752
+ /**
1753
+ * Observation throughput check for `remnic doctor` (issue #685).
1754
+ *
1755
+ * Reads the extraction-judge verdict ledger to surface:
1756
+ * - total observations (verdicts) recorded
1757
+ * - accept / reject / defer breakdown
1758
+ * - most-recent `observedAt` timestamp
1759
+ *
1760
+ * The check is purely informational (always `ok`): a missing or empty
1761
+ * ledger is the expected state on a fresh install and is never an error.
1762
+ * This closes the `*(future)*` item deferred in `docs/trace-to-primitive.md`.
1763
+ */
1764
+ export async function summarizeObservationThroughput(
1765
+ memoryDir: string,
1766
+ ): Promise<OperatorDoctorCheck> {
1767
+ try {
1768
+ const stats = await readJudgeVerdictStats(memoryDir);
1769
+ if (stats.total === 0) {
1770
+ return {
1771
+ key: "observations",
1772
+ status: "ok",
1773
+ summary: "No observations recorded yet (extraction-judge telemetry ledger is empty or missing).",
1774
+ details: { total: 0, accept: 0, reject: 0, defer: 0, lastObservedAt: null },
1775
+ };
1776
+ }
1777
+ const acceptPct = ((stats.accept / stats.total) * 100).toFixed(1);
1778
+ const rejectPct = ((stats.reject / stats.total) * 100).toFixed(1);
1779
+ const deferPct = ((stats.defer / stats.total) * 100).toFixed(1);
1780
+ return {
1781
+ key: "observations",
1782
+ status: "ok",
1783
+ summary: `${stats.total} observations recorded: accept=${acceptPct}%, reject=${rejectPct}%, defer=${deferPct}%. Last observed: ${stats.lastTs ?? "unknown"}.`,
1784
+ details: {
1785
+ total: stats.total,
1786
+ accept: stats.accept,
1787
+ reject: stats.reject,
1788
+ defer: stats.defer,
1789
+ deferCapTriggered: stats.deferCapTriggered,
1790
+ deferRate: stats.deferRate,
1791
+ meanElapsedMs: stats.meanElapsedMs,
1792
+ firstObservedAt: stats.firstTs ?? null,
1793
+ lastObservedAt: stats.lastTs ?? null,
1794
+ },
1795
+ };
1796
+ } catch (err) {
1797
+ return {
1798
+ key: "observations",
1799
+ status: "warn",
1800
+ summary: "Could not read observation telemetry ledger.",
1801
+ remediation: "Retry `remnic doctor` after ensuring the memory state directory is readable.",
1802
+ details: { error: String(err) },
1803
+ };
1804
+ }
1805
+ }
1806
+
1807
+ export async function summarizeConsolidationProvenance(
1808
+ storage: StorageManager,
1809
+ config: Pick<PluginConfig, "memoryDir"> & { versioningSidecarDir?: string },
1810
+ ): Promise<OperatorDoctorCheck> {
1811
+ let report: ConsolidationProvenanceReport;
1812
+ try {
1813
+ report = await runConsolidationProvenanceCheck({
1814
+ storage,
1815
+ memoryDir: config.memoryDir,
1816
+ // Honor the configured sidecar directory (PR #634 review): when an
1817
+ // operator overrides `versioningSidecarDir`, the default `.versions`
1818
+ // would point at the wrong location and every entry would report as
1819
+ // missing. Undefined falls back to the helper's default.
1820
+ sidecarDir: config.versioningSidecarDir,
1821
+ });
1822
+ } catch (err) {
1823
+ return {
1824
+ key: "consolidation_provenance",
1825
+ status: "warn",
1826
+ summary: "Could not run consolidation-provenance integrity check.",
1827
+ remediation: "Ensure the memory directory is readable and rerun `remnic doctor`.",
1828
+ details: { error: String(err) },
1829
+ };
1830
+ }
1831
+
1832
+ if (report.issues.length === 0) {
1833
+ return {
1834
+ key: "consolidation_provenance",
1835
+ status: "ok",
1836
+ summary:
1837
+ report.withProvenance === 0
1838
+ ? "No consolidation-provenance memories on disk yet."
1839
+ : `${report.withProvenance} consolidation-provenance memories verified (no broken references).`,
1840
+ details: report,
1841
+ };
1842
+ }
1843
+
1844
+ return {
1845
+ key: "consolidation_provenance",
1846
+ status: "warn",
1847
+ summary: `${report.issues.length} consolidation-provenance integrity issue(s) detected across ${report.withProvenance} memories with provenance frontmatter.`,
1848
+ remediation:
1849
+ "Broken pointers are informational. Inspect flagged memories, and if they should resolve, re-snapshot via a consolidation pass or accept pruning.",
1850
+ details: report,
1851
+ };
1852
+ }
1853
+
1854
+ function getMemoryAgeBand(memory: MemoryFile, now: Date): string {
1855
+ const created = Date.parse(memory.frontmatter.created ?? "");
1856
+ if (!Number.isFinite(created)) return "unknown";
1857
+ const ageDays = Math.max(0, Math.floor((now.getTime() - created) / 86_400_000));
1858
+ if (ageDays < 7) return "0_6d";
1859
+ if (ageDays < 30) return "7_29d";
1860
+ if (ageDays < 90) return "30_89d";
1861
+ return "90d_plus";
1862
+ }
1863
+
1864
+ async function dirSize(targetPath: string): Promise<number> {
1865
+ try {
1866
+ const info = await stat(targetPath);
1867
+ if (info.isFile()) return info.size;
1868
+ if (!info.isDirectory()) return 0;
1869
+ } catch {
1870
+ return 0;
1871
+ }
1872
+
1873
+ let total = 0;
1874
+ let entries;
1875
+ try {
1876
+ entries = await readdir(targetPath, { withFileTypes: true });
1877
+ } catch {
1878
+ return 0;
1879
+ }
1880
+ for (const entry of entries) {
1881
+ total += await dirSize(path.join(targetPath, entry.name));
1882
+ }
1883
+ return total;
1884
+ }
1885
+
1886
+ async function summarizeStorageFootprint(memoryDir: string): Promise<{ bytes: number; byTopLevel: Record<string, number> }> {
1887
+ const topLevel = [
1888
+ "facts",
1889
+ "entities",
1890
+ "questions",
1891
+ "corrections",
1892
+ "artifacts",
1893
+ "state",
1894
+ "identity",
1895
+ "namespaces",
1896
+ "summaries",
1897
+ "profile.md",
1898
+ ];
1899
+ const byTopLevel: Record<string, number> = {};
1900
+ let bytes = 0;
1901
+ for (const name of topLevel) {
1902
+ const size = await dirSize(path.join(memoryDir, name));
1903
+ if (size > 0) {
1904
+ byTopLevel[name] = size;
1905
+ bytes += size;
1906
+ }
1907
+ }
1908
+ return { bytes, byTopLevel };
1909
+ }
1910
+
1911
+ export async function runOperatorInventory(options: OperatorInventoryOptions): Promise<OperatorInventoryReport> {
1912
+ const now = options.now ?? new Date();
1913
+ const config = options.orchestrator.config;
1914
+ const namespaceEntries = await listNamespaces({ config });
1915
+ const uniqueRootEntries = new Map<string, { namespace: string; rootDir: string }>();
1916
+ for (const entry of namespaceEntries) {
1917
+ if (!uniqueRootEntries.has(entry.rootDir)) {
1918
+ uniqueRootEntries.set(entry.rootDir, { namespace: entry.namespace, rootDir: entry.rootDir });
1919
+ }
1920
+ }
1921
+ const categories: Record<string, number> = {};
1922
+ const statuses: Record<string, number> = {};
1923
+ const ageBands: Record<string, number> = {
1924
+ "0_6d": 0,
1925
+ "7_29d": 0,
1926
+ "30_89d": 0,
1927
+ "90d_plus": 0,
1928
+ unknown: 0,
1929
+ };
1930
+ const namespaces: OperatorInventoryNamespaceSummary[] = [];
1931
+ let totalMemories = 0;
1932
+ let totalEntities = 0;
1933
+ let archived = 0;
1934
+ let pendingReview = 0;
1935
+ let quarantined = 0;
1936
+ let rejected = 0;
1937
+
1938
+ for (const entry of uniqueRootEntries.values()) {
1939
+ const storage = new StorageManager(entry.rootDir);
1940
+ const memories = await storage.readAllMemories();
1941
+ const entities = await storage.readAllEntityFiles();
1942
+ namespaces.push({
1943
+ namespace: entry.namespace,
1944
+ memoryCount: memories.length,
1945
+ entityCount: entities.length,
1946
+ });
1947
+ totalMemories += memories.length;
1948
+ totalEntities += entities.length;
1949
+ for (const memory of memories) {
1950
+ const category = memory.frontmatter.category;
1951
+ categories[category] = (categories[category] ?? 0) + 1;
1952
+ const status = memory.frontmatter.status ?? "active";
1953
+ statuses[status] = (statuses[status] ?? 0) + 1;
1954
+ ageBands[getMemoryAgeBand(memory, now)] += 1;
1955
+ if (status === "archived") archived += 1;
1956
+ if (status === "pending_review") pendingReview += 1;
1957
+ if (status === "quarantined") quarantined += 1;
1958
+ if (status === "rejected") rejected += 1;
1959
+ }
1960
+ }
1961
+
1962
+ const defaultStorage = new StorageManager(config.memoryDir);
1963
+ const profile = await defaultStorage.readProfile();
1964
+ const footprint = await summarizeStorageFootprint(config.memoryDir);
1965
+ const reviewRunId = (await listMemoryGovernanceRuns(config.memoryDir))[0];
1966
+ let reviewQueue = 0;
1967
+ if (reviewRunId) {
1968
+ try {
1969
+ reviewQueue = (await readMemoryGovernanceRunArtifact(config.memoryDir, reviewRunId)).reviewQueue.length;
1970
+ } catch {
1971
+ reviewQueue = 0;
1972
+ }
1973
+ }
1974
+ const conversationIndex = await options.orchestrator.getConversationIndexHealth();
1975
+ const nativeKnowledgeStatus = await summarizeNativeKnowledgeStatus(config);
1976
+
1977
+ return {
1978
+ schemaVersion: 1,
1979
+ generatedAt: now.toISOString(),
1980
+ memoryDir: config.memoryDir,
1981
+ totals: {
1982
+ memories: totalMemories,
1983
+ entities: totalEntities,
1984
+ namespaces: namespaceEntries.length,
1985
+ reviewQueue,
1986
+ storageBytes: footprint.bytes,
1987
+ },
1988
+ categories,
1989
+ statuses,
1990
+ namespaces,
1991
+ ageBands,
1992
+ profile: {
1993
+ exists: profile.length > 0,
1994
+ chars: profile.length,
1995
+ lines: profile.length > 0 ? profile.split("\n").length : 0,
1996
+ },
1997
+ storageFootprint: footprint,
1998
+ archivePressure: {
1999
+ archived,
2000
+ pendingReview,
2001
+ quarantined,
2002
+ rejected,
2003
+ },
2004
+ conversationIndex: {
2005
+ enabled: conversationIndex.enabled,
2006
+ backend: conversationIndex.backend,
2007
+ status: conversationIndex.status,
2008
+ chunkDocCount: conversationIndex.chunkDocCount,
2009
+ lastUpdateAt: conversationIndex.lastUpdateAt,
2010
+ },
2011
+ nativeKnowledge: {
2012
+ enabled: nativeKnowledgeStatus.enabled,
2013
+ curatedIncludeSync: nativeKnowledgeStatus.curatedIncludeSync,
2014
+ obsidianSync: nativeKnowledgeStatus.obsidianSync,
2015
+ openclawWorkspaceSync: nativeKnowledgeStatus.openclawWorkspaceSync,
2016
+ },
2017
+ };
2018
+ }
2019
+
2020
+ export async function runBenchmarkRecall(options: BenchmarkRecallOptions): Promise<BenchmarkRecallReport> {
2021
+ const now = options.now ?? new Date();
2022
+ const status = await getEvalHarnessStatus({
2023
+ memoryDir: options.config.memoryDir,
2024
+ evalStoreDir: options.config.evalStoreDir,
2025
+ enabled: options.config.evalHarnessEnabled,
2026
+ shadowModeEnabled: options.config.evalShadowModeEnabled,
2027
+ baselineSnapshotsEnabled: options.config.benchmarkBaselineSnapshotsEnabled,
2028
+ memoryRedTeamBenchEnabled: options.config.memoryRedTeamBenchEnabled,
2029
+ });
2030
+
2031
+ if (options.createSnapshot && options.snapshotId) {
2032
+ const snapshot = await createEvalBaselineSnapshot({
2033
+ memoryDir: options.config.memoryDir,
2034
+ evalStoreDir: options.config.evalStoreDir,
2035
+ baselineSnapshotsEnabled: options.config.benchmarkBaselineSnapshotsEnabled,
2036
+ snapshotId: options.snapshotId,
2037
+ notes: options.snapshotNotes,
2038
+ gitRef: options.gitRef,
2039
+ createdAt: options.createdAt,
2040
+ });
2041
+ return {
2042
+ schemaVersion: 1,
2043
+ generatedAt: now.toISOString(),
2044
+ mode: "snapshot",
2045
+ status,
2046
+ snapshot: {
2047
+ targetPath: snapshot.targetPath,
2048
+ snapshotId: snapshot.snapshot.snapshotId,
2049
+ },
2050
+ };
2051
+ }
2052
+
2053
+ if (options.baseEvalStoreDir && options.candidateEvalStoreDir) {
2054
+ const ciGate = await runEvalBenchmarkCiGate({
2055
+ baseEvalStoreDir: options.baseEvalStoreDir,
2056
+ candidateEvalStoreDir: options.candidateEvalStoreDir,
2057
+ });
2058
+ return {
2059
+ schemaVersion: 1,
2060
+ generatedAt: now.toISOString(),
2061
+ mode: "ci-gate",
2062
+ status,
2063
+ ciGate,
2064
+ };
2065
+ }
2066
+
2067
+ if (options.snapshotId) {
2068
+ const baselineReport = await runEvalBaselineDeltaReport({
2069
+ memoryDir: options.config.memoryDir,
2070
+ evalStoreDir: options.config.evalStoreDir,
2071
+ benchmarkDeltaReporterEnabled: options.config.benchmarkDeltaReporterEnabled,
2072
+ snapshotId: options.snapshotId,
2073
+ });
2074
+ return {
2075
+ schemaVersion: 1,
2076
+ generatedAt: now.toISOString(),
2077
+ mode: "baseline-report",
2078
+ status,
2079
+ baselineReport,
2080
+ };
2081
+ }
2082
+
2083
+ if (options.validatePath) {
2084
+ const validate = await validateEvalBenchmarkPack(options.validatePath, {
2085
+ memoryRedTeamBenchEnabled: options.config.memoryRedTeamBenchEnabled,
2086
+ });
2087
+ return {
2088
+ schemaVersion: 1,
2089
+ generatedAt: now.toISOString(),
2090
+ mode: "validate",
2091
+ status,
2092
+ validate,
2093
+ };
2094
+ }
2095
+
2096
+ return {
2097
+ schemaVersion: 1,
2098
+ generatedAt: now.toISOString(),
2099
+ mode: "status",
2100
+ status,
2101
+ };
2102
+ }
2103
+
2104
+ export async function runOperatorRepair(options: OperatorRepairOptions): Promise<OperatorRepairReport> {
2105
+ const now = options.now ?? new Date();
2106
+ const dryRun = options.dryRun === true || options.apply !== true;
2107
+ const sessionCheck = await analyzeSessionIntegrity({ memoryDir: options.config.memoryDir });
2108
+ const sessionRepairPlan = planSessionRepair({
2109
+ report: sessionCheck,
2110
+ dryRun,
2111
+ allowSessionFileRepair: options.allowSessionFileRepair,
2112
+ sessionFilesDir: options.sessionFilesDir,
2113
+ });
2114
+ const sessionRepairApply = await applySessionRepair({
2115
+ plan: sessionRepairPlan,
2116
+ });
2117
+ const graphHealth = await analyzeGraphHealth(options.config.memoryDir, {
2118
+ entityGraphEnabled: options.config.entityGraphEnabled,
2119
+ timeGraphEnabled: options.config.timeGraphEnabled,
2120
+ causalGraphEnabled: options.config.causalGraphEnabled,
2121
+ includeRepairGuidance: true,
2122
+ });
2123
+ return {
2124
+ schemaVersion: 1,
2125
+ generatedAt: now.toISOString(),
2126
+ dryRun,
2127
+ sessionCheck,
2128
+ sessionRepairPlan,
2129
+ sessionRepairApply,
2130
+ graphHealth,
2131
+ };
2132
+ }