@remnic/core 1.1.2 → 1.1.3

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 (485) hide show
  1. package/dist/abort-error.js +1 -0
  2. package/dist/abstraction-nodes.js +1 -0
  3. package/dist/access-audit.js +1 -0
  4. package/dist/access-cli.js +70 -45
  5. package/dist/access-cli.js.map +1 -1
  6. package/dist/access-http.d.ts +50 -5
  7. package/dist/access-http.js +37 -15
  8. package/dist/access-idempotency.js +1 -0
  9. package/dist/access-mcp.d.ts +10 -5
  10. package/dist/access-mcp.js +36 -13
  11. package/dist/access-schema.d.ts +133 -13
  12. package/dist/access-schema.js +20 -1
  13. package/dist/access-service-_AEUMVyX.d.ts +1981 -0
  14. package/dist/access-service.d.ts +11 -6
  15. package/dist/access-service.js +38 -14
  16. package/dist/active-memory-bridge.js +1 -0
  17. package/dist/active-recall.js +1 -0
  18. package/dist/active-recall.js.map +1 -1
  19. package/dist/behavior-learner.js +1 -0
  20. package/dist/behavior-learner.js.map +1 -1
  21. package/dist/behavior-signals.js +1 -0
  22. package/dist/bootstrap.d.ts +6 -4
  23. package/dist/bootstrap.js +1 -0
  24. package/dist/boxes.js +1 -0
  25. package/dist/briefing.d.ts +9 -5
  26. package/dist/briefing.js +9 -6
  27. package/dist/buffer-surprise-report.js +1 -0
  28. package/dist/buffer-surprise.js +1 -0
  29. package/dist/buffer.d.ts +1 -1
  30. package/dist/buffer.js +1 -0
  31. package/dist/calibration.d.ts +8 -1
  32. package/dist/calibration.js +10 -2
  33. package/dist/calibration.js.map +1 -1
  34. package/dist/capsule-cli.d.ts +137 -0
  35. package/dist/capsule-cli.js +34 -0
  36. package/dist/capsule-crypto-5CYAGVC5.js +18 -0
  37. package/dist/capsule-export-NZQPOTQ4.js +17 -0
  38. package/dist/capsule-export-NZQPOTQ4.js.map +1 -0
  39. package/dist/capsule-import-SDCUXLEV.js +16 -0
  40. package/dist/capsule-import-SDCUXLEV.js.map +1 -0
  41. package/dist/capsule-merge-DI7PNQ2H.js +189 -0
  42. package/dist/capsule-merge-DI7PNQ2H.js.map +1 -0
  43. package/dist/causal-behavior.js +1 -0
  44. package/dist/causal-behavior.js.map +1 -1
  45. package/dist/causal-chain.js +1 -0
  46. package/dist/causal-consolidation.js +11 -8
  47. package/dist/causal-consolidation.js.map +1 -1
  48. package/dist/causal-retrieval.js +2 -1
  49. package/dist/causal-retrieval.js.map +1 -1
  50. package/dist/causal-trajectory-graph.js +4 -1
  51. package/dist/causal-trajectory-graph.js.map +1 -1
  52. package/dist/causal-trajectory.js +2 -1
  53. package/dist/chunk-2LSZVONP.js +67 -0
  54. package/dist/chunk-2LSZVONP.js.map +1 -0
  55. package/dist/chunk-32KD5IHZ.js +245 -0
  56. package/dist/chunk-32KD5IHZ.js.map +1 -0
  57. package/dist/{chunk-VDX363PS.js → chunk-34F3PLWZ.js} +10 -3
  58. package/dist/chunk-34F3PLWZ.js.map +1 -0
  59. package/dist/chunk-3KIS4VGT.js +228 -0
  60. package/dist/chunk-3KIS4VGT.js.map +1 -0
  61. package/dist/chunk-3LCWFNVS.js +350 -0
  62. package/dist/chunk-3LCWFNVS.js.map +1 -0
  63. package/dist/chunk-43EKP2UK.js +26 -0
  64. package/dist/chunk-43EKP2UK.js.map +1 -0
  65. package/dist/chunk-457A4P3L.js +119 -0
  66. package/dist/chunk-457A4P3L.js.map +1 -0
  67. package/dist/{chunk-TMYO7B5P.js → chunk-47WOM4YW.js} +2 -2
  68. package/dist/{chunk-OC5OXUQ4.js → chunk-4PLGJRBV.js} +653 -17
  69. package/dist/chunk-4PLGJRBV.js.map +1 -0
  70. package/dist/{chunk-PVICZTKG.js → chunk-55FXRRSJ.js} +5 -5
  71. package/dist/{chunk-PVICZTKG.js.map → chunk-55FXRRSJ.js.map} +1 -1
  72. package/dist/{chunk-ULYOGL6R.js → chunk-5HRY2WRF.js} +7 -3
  73. package/dist/chunk-5HRY2WRF.js.map +1 -0
  74. package/dist/chunk-6TBWYBJ3.js +236 -0
  75. package/dist/chunk-6TBWYBJ3.js.map +1 -0
  76. package/dist/chunk-74EMIVE4.js +329 -0
  77. package/dist/chunk-74EMIVE4.js.map +1 -0
  78. package/dist/chunk-74WWN7ZW.js +82 -0
  79. package/dist/chunk-74WWN7ZW.js.map +1 -0
  80. package/dist/{chunk-6YJHX2DL.js → chunk-7GCMLT7J.js} +242 -22
  81. package/dist/chunk-7GCMLT7J.js.map +1 -0
  82. package/dist/chunk-A6XUJE5D.js +126 -0
  83. package/dist/chunk-A6XUJE5D.js.map +1 -0
  84. package/dist/chunk-AJA46VX5.js +393 -0
  85. package/dist/chunk-AJA46VX5.js.map +1 -0
  86. package/dist/{chunk-UWB5LMWY.js → chunk-AKUCB2OG.js} +525 -24
  87. package/dist/chunk-AKUCB2OG.js.map +1 -0
  88. package/dist/chunk-ASIQZXYO.js +277 -0
  89. package/dist/chunk-ASIQZXYO.js.map +1 -0
  90. package/dist/{chunk-DG6YMRDC.js → chunk-B2TL6GA2.js} +2 -2
  91. package/dist/chunk-BJMBJZ2Y.js +290 -0
  92. package/dist/chunk-BJMBJZ2Y.js.map +1 -0
  93. package/dist/chunk-BT7NVCML.js +79 -0
  94. package/dist/chunk-BT7NVCML.js.map +1 -0
  95. package/dist/chunk-CK5NTM2S.js +454 -0
  96. package/dist/chunk-CK5NTM2S.js.map +1 -0
  97. package/dist/{chunk-AYXIPSZO.js → chunk-CRU27Q4J.js} +2 -2
  98. package/dist/{chunk-F5VP6YCB.js → chunk-DCE6SQLA.js} +572 -155
  99. package/dist/chunk-DCE6SQLA.js.map +1 -0
  100. package/dist/{chunk-CUPFXL3J.js → chunk-DHRQHX36.js} +4 -4
  101. package/dist/chunk-DHRQHX36.js.map +1 -0
  102. package/dist/{chunk-STGWEHYR.js → chunk-DR7MCMPS.js} +981 -61
  103. package/dist/chunk-DR7MCMPS.js.map +1 -0
  104. package/dist/chunk-FP2373TW.js +149 -0
  105. package/dist/chunk-FP2373TW.js.map +1 -0
  106. package/dist/{chunk-RBBWYEFJ.js → chunk-G2WADRQ3.js} +1 -1
  107. package/dist/chunk-G7D6GZ5J.js +48 -0
  108. package/dist/chunk-G7D6GZ5J.js.map +1 -0
  109. package/dist/chunk-H7XKCNR6.js +60 -0
  110. package/dist/chunk-H7XKCNR6.js.map +1 -0
  111. package/dist/{chunk-3YGHKTBF.js → chunk-IM3JSE73.js} +953 -322
  112. package/dist/chunk-IM3JSE73.js.map +1 -0
  113. package/dist/chunk-IXEJRKCZ.js +18 -0
  114. package/dist/chunk-IXEJRKCZ.js.map +1 -0
  115. package/dist/chunk-IYY4MCPG.js +275 -0
  116. package/dist/chunk-IYY4MCPG.js.map +1 -0
  117. package/dist/{chunk-BECYBZLX.js → chunk-JWSENLQI.js} +502 -22
  118. package/dist/chunk-JWSENLQI.js.map +1 -0
  119. package/dist/chunk-KNKUID7G.js +183 -0
  120. package/dist/chunk-KNKUID7G.js.map +1 -0
  121. package/dist/chunk-L2IO2QPY.js +2036 -0
  122. package/dist/chunk-L2IO2QPY.js.map +1 -0
  123. package/dist/{chunk-SPI27QT6.js → chunk-L5IIGA5V.js} +9 -4
  124. package/dist/chunk-L5IIGA5V.js.map +1 -0
  125. package/dist/{chunk-XXVWLXSG.js → chunk-LVYGDT5V.js} +56 -82
  126. package/dist/chunk-LVYGDT5V.js.map +1 -0
  127. package/dist/{chunk-ZAIM4TUE.js → chunk-LW2NMHDW.js} +46 -1
  128. package/dist/chunk-LW2NMHDW.js.map +1 -0
  129. package/dist/{chunk-3OGMS3PE.js → chunk-LZRYQK6L.js} +3 -2
  130. package/dist/chunk-LZRYQK6L.js.map +1 -0
  131. package/dist/chunk-MDYG7VI7.js +48 -0
  132. package/dist/chunk-MDYG7VI7.js.map +1 -0
  133. package/dist/chunk-MXC3AP5I.js +74 -0
  134. package/dist/chunk-MXC3AP5I.js.map +1 -0
  135. package/dist/{chunk-DIXB44VE.js → chunk-N7X62G74.js} +25 -10
  136. package/dist/chunk-N7X62G74.js.map +1 -0
  137. package/dist/chunk-NN3TS5BM.js +147 -0
  138. package/dist/chunk-NN3TS5BM.js.map +1 -0
  139. package/dist/chunk-OA3L7BFR.js +183 -0
  140. package/dist/chunk-OA3L7BFR.js.map +1 -0
  141. package/dist/chunk-OZHRDTDX.js +240 -0
  142. package/dist/chunk-OZHRDTDX.js.map +1 -0
  143. package/dist/chunk-PCUKNJAZ.js +165 -0
  144. package/dist/chunk-PCUKNJAZ.js.map +1 -0
  145. package/dist/{chunk-6PFRXT4K.js → chunk-PFV5C235.js} +11 -6
  146. package/dist/chunk-PFV5C235.js.map +1 -0
  147. package/dist/chunk-PZ5AY32C.js +10 -0
  148. package/dist/chunk-PZ5AY32C.js.map +1 -0
  149. package/dist/{chunk-Y7R2XJ5Q.js → chunk-Q7FJ5ZHM.js} +6 -2
  150. package/dist/chunk-Q7FJ5ZHM.js.map +1 -0
  151. package/dist/{chunk-NBVAS5MT.js → chunk-R2L7SUX2.js} +6 -6
  152. package/dist/{chunk-WCLICCGB.js → chunk-RILIVK4O.js} +91 -4
  153. package/dist/chunk-RILIVK4O.js.map +1 -0
  154. package/dist/{chunk-C2EFFULQ.js → chunk-RK2Y4XOM.js} +163 -20
  155. package/dist/chunk-RK2Y4XOM.js.map +1 -0
  156. package/dist/{chunk-TP4FZJIZ.js → chunk-RULE4VG5.js} +5 -1
  157. package/dist/chunk-RULE4VG5.js.map +1 -0
  158. package/dist/{chunk-PVPWZSSI.js → chunk-SMA4IMHV.js} +19 -3
  159. package/dist/chunk-SMA4IMHV.js.map +1 -0
  160. package/dist/{chunk-L7IXWRYE.js → chunk-SS253RXF.js} +22 -13
  161. package/dist/chunk-SS253RXF.js.map +1 -0
  162. package/dist/chunk-TUFG6VXY.js +875 -0
  163. package/dist/chunk-TUFG6VXY.js.map +1 -0
  164. package/dist/chunk-TYEOAFH3.js +251 -0
  165. package/dist/chunk-TYEOAFH3.js.map +1 -0
  166. package/dist/chunk-UKJAGEXH.js +260 -0
  167. package/dist/chunk-UKJAGEXH.js.map +1 -0
  168. package/dist/{chunk-KVBLZUKV.js → chunk-USFPPRAF.js} +93 -3
  169. package/dist/chunk-USFPPRAF.js.map +1 -0
  170. package/dist/{chunk-GA5P7RST.js → chunk-VTJVUHRK.js} +22 -36
  171. package/dist/chunk-VTJVUHRK.js.map +1 -0
  172. package/dist/chunk-WIICJPET.js +45 -0
  173. package/dist/chunk-WIICJPET.js.map +1 -0
  174. package/dist/{chunk-VBVG2M5G.js → chunk-WPGJYVUH.js} +6 -2
  175. package/dist/chunk-WPGJYVUH.js.map +1 -0
  176. package/dist/{chunk-4HQS2HPX.js → chunk-WSZIHQBK.js} +29 -9
  177. package/dist/{chunk-4HQS2HPX.js.map → chunk-WSZIHQBK.js.map} +1 -1
  178. package/dist/{chunk-NZLQTHS5.js → chunk-WW3QQF4H.js} +4 -1
  179. package/dist/chunk-WW3QQF4H.js.map +1 -0
  180. package/dist/{chunk-FVA6TGI3.js → chunk-Y3WQ4ZWK.js} +42 -2
  181. package/dist/chunk-Y3WQ4ZWK.js.map +1 -0
  182. package/dist/chunk-YNJHCGDT.js +309 -0
  183. package/dist/chunk-YNJHCGDT.js.map +1 -0
  184. package/dist/{chunk-LOIMBRDE.js → chunk-ZGXSCMQN.js} +1993 -411
  185. package/dist/chunk-ZGXSCMQN.js.map +1 -0
  186. package/dist/{chunk-W6SL7OFG.js → chunk-ZTSE2ZJ6.js} +12 -2
  187. package/dist/{chunk-W6SL7OFG.js.map → chunk-ZTSE2ZJ6.js.map} +1 -1
  188. package/dist/chunking.js +1 -0
  189. package/dist/cipher-GVE2GQ5H.js +28 -0
  190. package/dist/cipher-GVE2GQ5H.js.map +1 -0
  191. package/dist/citations.js +1 -0
  192. package/dist/{cli-BkeRaYfk.d.ts → cli-x2APT9a6.d.ts} +26 -7
  193. package/dist/cli.d.ts +11 -6
  194. package/dist/cli.js +67 -33
  195. package/dist/codex-thread-key.js +1 -0
  196. package/dist/commitment-ledger.js +1 -0
  197. package/dist/compression-optimizer.js +1 -0
  198. package/dist/config.d.ts +2 -1
  199. package/dist/config.js +4 -1
  200. package/dist/connectors-cli-DFGtY2DB.d.ts +257 -0
  201. package/dist/connectors-cli.d.ts +2 -0
  202. package/dist/connectors-cli.js +22 -0
  203. package/dist/connectors-cli.js.map +1 -0
  204. package/dist/consolidation-operator.d.ts +65 -5
  205. package/dist/consolidation-operator.js +6 -1
  206. package/dist/consolidation-provenance-check.d.ts +1 -1
  207. package/dist/consolidation-provenance-check.js +3 -2
  208. package/dist/consolidation-undo.d.ts +1 -1
  209. package/dist/consolidation-undo.js +1 -0
  210. package/dist/consolidation-undo.js.map +1 -1
  211. package/dist/{contradiction-review-WIUBAR52.js → contradiction-review-5LTTVDQV.js} +2 -1
  212. package/dist/contradiction-review-5LTTVDQV.js.map +1 -0
  213. package/dist/{contradiction-scan-E3GJTI4F.js → contradiction-scan-3Z6YW7YA.js} +2 -1
  214. package/dist/{contradiction-scan-E3GJTI4F.js.map → contradiction-scan-3Z6YW7YA.js.map} +1 -1
  215. package/dist/cross-namespace-budget.js +1 -0
  216. package/dist/cue-anchors.js +1 -0
  217. package/dist/dashboard-runtime.js +1 -0
  218. package/dist/day-summary.js +1 -0
  219. package/dist/delinearize.js +1 -0
  220. package/dist/direct-answer-wiring.js +1 -0
  221. package/dist/direct-answer.js +1 -0
  222. package/dist/dreams-ledger-LR2NBAZE.js +286 -0
  223. package/dist/dreams-ledger-LR2NBAZE.js.map +1 -0
  224. package/dist/embedding-fallback.js +1 -0
  225. package/dist/{engine-72LSIWQP.js → engine-ICC2DSQF.js} +10 -7
  226. package/dist/engine-ICC2DSQF.js.map +1 -0
  227. package/dist/entity-retrieval.d.ts +1 -1
  228. package/dist/entity-retrieval.js +9 -6
  229. package/dist/entity-schema.js +1 -0
  230. package/dist/evals.js +1 -0
  231. package/dist/evidence-pack.d.ts +16 -0
  232. package/dist/evidence-pack.js +8 -0
  233. package/dist/evidence-pack.js.map +1 -0
  234. package/dist/explicit-capture.d.ts +6 -4
  235. package/dist/explicit-capture.js +1 -0
  236. package/dist/extraction-judge-telemetry.js +1 -0
  237. package/dist/extraction-judge-training.js +1 -0
  238. package/dist/extraction-judge.js +1 -0
  239. package/dist/extraction.js +7 -6
  240. package/dist/fallback-llm.js +3 -2
  241. package/dist/first-start-migration-4MHQEOSD.js +263 -0
  242. package/dist/first-start-migration-4MHQEOSD.js.map +1 -0
  243. package/dist/forget-PLR6J5DN.js +69 -0
  244. package/dist/forget-PLR6J5DN.js.map +1 -0
  245. package/dist/framework-CyHYDcri.d.ts +153 -0
  246. package/dist/fs-utils-IRVUFB6G.js +30 -0
  247. package/dist/fs-utils-IRVUFB6G.js.map +1 -0
  248. package/dist/graph-dashboard-diff.js +1 -0
  249. package/dist/graph-dashboard-key.js +1 -0
  250. package/dist/graph-dashboard-parser.js +1 -0
  251. package/dist/graph-edge-decay-PWB63GRE.js +207 -0
  252. package/dist/graph-edge-decay-PWB63GRE.js.map +1 -0
  253. package/dist/graph-edge-reinforcement.d.ts +81 -0
  254. package/dist/graph-edge-reinforcement.js +24 -0
  255. package/dist/graph-edge-reinforcement.js.map +1 -0
  256. package/dist/graph-events.d.ts +87 -0
  257. package/dist/graph-events.js +14 -0
  258. package/dist/graph-events.js.map +1 -0
  259. package/dist/graph-recall.js +1 -0
  260. package/dist/graph-retrieval.js +1 -0
  261. package/dist/graph-snapshot.d.ts +112 -0
  262. package/dist/graph-snapshot.js +19 -0
  263. package/dist/graph-snapshot.js.map +1 -0
  264. package/dist/graph.d.ts +105 -7
  265. package/dist/graph.js +20 -3
  266. package/dist/harmonic-retrieval.js +1 -0
  267. package/dist/himem.js +1 -0
  268. package/dist/hygiene.js +1 -0
  269. package/dist/identity-continuity.js +1 -0
  270. package/dist/importance.js +1 -0
  271. package/dist/index.d.ts +562 -13
  272. package/dist/index.js +329 -67
  273. package/dist/index.js.map +1 -1
  274. package/dist/intent.js +1 -0
  275. package/dist/json-extract.js +1 -0
  276. package/dist/json-store.js +1 -0
  277. package/dist/kdf-7S6RWKLZ.js +26 -0
  278. package/dist/kdf-7S6RWKLZ.js.map +1 -0
  279. package/dist/legacy-hook-compat.js +1 -0
  280. package/dist/legacy-hook-compat.js.map +1 -1
  281. package/dist/lifecycle.js +1 -0
  282. package/dist/live-connectors-runner.d.ts +48 -0
  283. package/dist/live-connectors-runner.js +17 -0
  284. package/dist/live-connectors-runner.js.map +1 -0
  285. package/dist/local-llm.js +1 -0
  286. package/dist/logger.js +1 -0
  287. package/dist/memory-action-policy.js +1 -0
  288. package/dist/memory-cache.d.ts +2 -1
  289. package/dist/memory-cache.js +4 -1
  290. package/dist/memory-governance-KG52RITE.js +37 -0
  291. package/dist/memory-governance-KG52RITE.js.map +1 -0
  292. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  293. package/dist/memory-lifecycle-ledger-utils.js +4 -1
  294. package/dist/memory-projection-format.js +1 -0
  295. package/dist/{memory-projection-store-DeSXPh1j.d.ts → memory-projection-store-D3vBHS4J.d.ts} +1 -0
  296. package/dist/memory-projection-store.d.ts +1 -1
  297. package/dist/memory-projection-store.js +1 -0
  298. package/dist/memory-worth-bench.js +1 -0
  299. package/dist/memory-worth-bench.js.map +1 -1
  300. package/dist/memory-worth-filter.js +1 -0
  301. package/dist/memory-worth-outcomes.d.ts +1 -1
  302. package/dist/memory-worth-outcomes.js +1 -0
  303. package/dist/memory-worth.js +1 -0
  304. package/dist/metadata-FC3XPDRQ.js +21 -0
  305. package/dist/metadata-FC3XPDRQ.js.map +1 -0
  306. package/dist/migrate-from-identity-anchor-TTEDEJGX.js +8 -0
  307. package/dist/migrate-from-identity-anchor-TTEDEJGX.js.map +1 -0
  308. package/dist/model-registry.js +1 -0
  309. package/dist/models-json.js +1 -0
  310. package/dist/native-knowledge.js +1 -0
  311. package/dist/negative.js +1 -0
  312. package/dist/objective-state-writers.js +1 -0
  313. package/dist/objective-state-writers.js.map +1 -1
  314. package/dist/objective-state.js +1 -0
  315. package/dist/openai-chat-compat.js +1 -0
  316. package/dist/operator-toolkit.d.ts +46 -2
  317. package/dist/operator-toolkit.js +28 -16
  318. package/dist/opik-exporter.js +1 -0
  319. package/dist/opik-exporter.js.map +1 -1
  320. package/dist/{orchestrator-CmJ-NTdJ.d.ts → orchestrator-ChkesB8U.d.ts} +177 -13
  321. package/dist/orchestrator.d.ts +6 -4
  322. package/dist/orchestrator.js +55 -39
  323. package/dist/page-versioning.js +1 -0
  324. package/dist/path-RMTY5Y5A.js +9 -0
  325. package/dist/path-RMTY5Y5A.js.map +1 -0
  326. package/dist/patterns-cli.d.ts +160 -0
  327. package/dist/patterns-cli.js +29 -0
  328. package/dist/patterns-cli.js.map +1 -0
  329. package/dist/peers-6OSQ3NK6.js +44 -0
  330. package/dist/peers-6OSQ3NK6.js.map +1 -0
  331. package/dist/plugin-id.js +1 -0
  332. package/dist/policy-runtime.js +1 -0
  333. package/dist/{port-BADbLZU5.d.ts → port-hqGnoStS.d.ts} +6 -0
  334. package/dist/profiling.js +1 -0
  335. package/dist/purge-6ATBGT77.js +205 -0
  336. package/dist/purge-6ATBGT77.js.map +1 -0
  337. package/dist/qmd-recall-cache.d.ts +1 -1
  338. package/dist/qmd-recall-cache.js +1 -0
  339. package/dist/qmd.d.ts +2 -1
  340. package/dist/qmd.js +4 -3
  341. package/dist/reasoning-trace-recall.js +1 -0
  342. package/dist/reasoning-trace-types.js +1 -0
  343. package/dist/recall-audit-anomaly.js +1 -0
  344. package/dist/recall-audit.js +1 -0
  345. package/dist/recall-disclosure-escalation.d.ts +84 -0
  346. package/dist/recall-disclosure-escalation.js +14 -0
  347. package/dist/recall-disclosure-escalation.js.map +1 -0
  348. package/dist/recall-explain-renderer.js +4 -1
  349. package/dist/recall-mmr.js +1 -0
  350. package/dist/recall-qos.js +1 -0
  351. package/dist/recall-query-policy.js +1 -0
  352. package/dist/recall-state.d.ts +7 -0
  353. package/dist/recall-state.js +2 -1
  354. package/dist/recall-tag-filter.d.ts +56 -0
  355. package/dist/recall-tag-filter.js +14 -0
  356. package/dist/recall-tag-filter.js.map +1 -0
  357. package/dist/recall-tokenization.js +1 -0
  358. package/dist/recall-xray-cli.d.ts +9 -2
  359. package/dist/recall-xray-cli.js +9 -4
  360. package/dist/recall-xray-renderer.js +4 -1
  361. package/dist/recall-xray.d.ts +116 -2
  362. package/dist/recall-xray.js +9 -3
  363. package/dist/reconstruct.js +1 -0
  364. package/dist/release-changelog.js +2 -0
  365. package/dist/release-changelog.js.map +1 -1
  366. package/dist/relevance.js +1 -0
  367. package/dist/rerank.js +1 -0
  368. package/dist/{resolution-QBTDHTG7.js → resolution-YGIBORXI.js} +2 -1
  369. package/dist/{resolution-QBTDHTG7.js.map → resolution-YGIBORXI.js.map} +1 -1
  370. package/dist/resolve-auth-token.d.ts +51 -0
  371. package/dist/resolve-auth-token.js +12 -0
  372. package/dist/resolve-auth-token.js.map +1 -0
  373. package/dist/resolve-provider-secret.d.ts +9 -1
  374. package/dist/resolve-provider-secret.js +4 -1
  375. package/dist/resume-bundles.js +4 -3
  376. package/dist/retrieval-agents.d.ts +1 -1
  377. package/dist/retrieval-agents.js +1 -0
  378. package/dist/retrieval-tiers.js +1 -0
  379. package/dist/retrieval.js +1 -0
  380. package/dist/sanitize.js +1 -0
  381. package/dist/schemas.d.ts +37 -24
  382. package/dist/schemas.js +2 -1
  383. package/dist/sdk-compat.js +1 -0
  384. package/dist/sdk-compat.js.map +1 -1
  385. package/dist/secure-store-4R2GSO7S.js +156 -0
  386. package/dist/secure-store-4R2GSO7S.js.map +1 -0
  387. package/dist/semantic-chunking.js +1 -0
  388. package/dist/{semantic-consolidation-CxJU6MJk.d.ts → semantic-consolidation-ByBXb-sf.d.ts} +3 -3
  389. package/dist/semantic-consolidation.d.ts +2 -2
  390. package/dist/semantic-consolidation.js +11 -6
  391. package/dist/semantic-rule-promotion.d.ts +1 -1
  392. package/dist/semantic-rule-promotion.js +9 -6
  393. package/dist/semantic-rule-verifier.d.ts +1 -1
  394. package/dist/semantic-rule-verifier.js +9 -6
  395. package/dist/session-integrity.js +1 -0
  396. package/dist/session-observer-bands.js +1 -0
  397. package/dist/session-observer-state.js +1 -0
  398. package/dist/session-toggles.js +2 -0
  399. package/dist/session-toggles.js.map +1 -1
  400. package/dist/signal.js +1 -0
  401. package/dist/skills-registry.js +2 -0
  402. package/dist/skills-registry.js.map +1 -1
  403. package/dist/source-attribution.js +1 -0
  404. package/dist/state-NCHQ4TRG.js +8 -0
  405. package/dist/state-NCHQ4TRG.js.map +1 -0
  406. package/dist/state-store-3EH7HYIN.js +16 -0
  407. package/dist/state-store-3EH7HYIN.js.map +1 -0
  408. package/dist/storage.d.ts +76 -2
  409. package/dist/storage.js +8 -5
  410. package/dist/store-contract.js +1 -0
  411. package/dist/summarizer.js +5 -4
  412. package/dist/summary-snapshot.js +1 -0
  413. package/dist/temporal-index.js +1 -0
  414. package/dist/temporal-supersession.d.ts +1 -1
  415. package/dist/temporal-supersession.js +2 -1
  416. package/dist/temporal-validity.d.ts +52 -0
  417. package/dist/temporal-validity.js +14 -0
  418. package/dist/temporal-validity.js.map +1 -0
  419. package/dist/threading.js +1 -0
  420. package/dist/tier-migration.d.ts +2 -2
  421. package/dist/tier-migration.js +1 -0
  422. package/dist/tier-routing.js +1 -0
  423. package/dist/tier-stats-62ZVDFKS.js +152 -0
  424. package/dist/tier-stats-62ZVDFKS.js.map +1 -0
  425. package/dist/tmt.js +1 -0
  426. package/dist/tokens.js +1 -0
  427. package/dist/topics.js +1 -0
  428. package/dist/trace-C5ETWBEF.js +290 -0
  429. package/dist/trace-C5ETWBEF.js.map +1 -0
  430. package/dist/transcript.js +1 -0
  431. package/dist/trust-zones.js +1 -0
  432. package/dist/tui-RI7P6PBS.js +13 -0
  433. package/dist/tui-RI7P6PBS.js.map +1 -0
  434. package/dist/types-V3FJ26TF.js +30 -0
  435. package/dist/types-V3FJ26TF.js.map +1 -0
  436. package/dist/types.d.ts +634 -9
  437. package/dist/types.js +10 -3
  438. package/dist/utility-learner.js +1 -0
  439. package/dist/utility-runtime.js +1 -0
  440. package/dist/utility-telemetry.js +1 -0
  441. package/dist/verified-recall.js +9 -6
  442. package/dist/version-utils.js +1 -0
  443. package/dist/whitespace.js +1 -0
  444. package/dist/work-product-ledger.js +1 -0
  445. package/package.json +2 -1
  446. package/dist/access-service-Br8ZydTK.d.ts +0 -827
  447. package/dist/chunk-3OGMS3PE.js.map +0 -1
  448. package/dist/chunk-3YGHKTBF.js.map +0 -1
  449. package/dist/chunk-6PFRXT4K.js.map +0 -1
  450. package/dist/chunk-6YJHX2DL.js.map +0 -1
  451. package/dist/chunk-BECYBZLX.js.map +0 -1
  452. package/dist/chunk-C2EFFULQ.js.map +0 -1
  453. package/dist/chunk-CUPFXL3J.js.map +0 -1
  454. package/dist/chunk-DIXB44VE.js.map +0 -1
  455. package/dist/chunk-F5VP6YCB.js.map +0 -1
  456. package/dist/chunk-FVA6TGI3.js.map +0 -1
  457. package/dist/chunk-GA5P7RST.js.map +0 -1
  458. package/dist/chunk-KVBLZUKV.js.map +0 -1
  459. package/dist/chunk-L7IXWRYE.js.map +0 -1
  460. package/dist/chunk-LOIMBRDE.js.map +0 -1
  461. package/dist/chunk-LTCGGW2D.js +0 -14
  462. package/dist/chunk-LTCGGW2D.js.map +0 -1
  463. package/dist/chunk-NZLQTHS5.js.map +0 -1
  464. package/dist/chunk-OC5OXUQ4.js.map +0 -1
  465. package/dist/chunk-PVPWZSSI.js.map +0 -1
  466. package/dist/chunk-SPI27QT6.js.map +0 -1
  467. package/dist/chunk-STGWEHYR.js.map +0 -1
  468. package/dist/chunk-TP4FZJIZ.js.map +0 -1
  469. package/dist/chunk-ULYOGL6R.js.map +0 -1
  470. package/dist/chunk-UWB5LMWY.js.map +0 -1
  471. package/dist/chunk-VBVG2M5G.js.map +0 -1
  472. package/dist/chunk-VDX363PS.js.map +0 -1
  473. package/dist/chunk-WCLICCGB.js.map +0 -1
  474. package/dist/chunk-X6GF3FX2.js +0 -26
  475. package/dist/chunk-X6GF3FX2.js.map +0 -1
  476. package/dist/chunk-XXVWLXSG.js.map +0 -1
  477. package/dist/chunk-Y7R2XJ5Q.js.map +0 -1
  478. package/dist/chunk-ZAIM4TUE.js.map +0 -1
  479. /package/dist/{contradiction-review-WIUBAR52.js.map → capsule-cli.js.map} +0 -0
  480. /package/dist/{engine-72LSIWQP.js.map → capsule-crypto-5CYAGVC5.js.map} +0 -0
  481. /package/dist/{chunk-TMYO7B5P.js.map → chunk-47WOM4YW.js.map} +0 -0
  482. /package/dist/{chunk-DG6YMRDC.js.map → chunk-B2TL6GA2.js.map} +0 -0
  483. /package/dist/{chunk-AYXIPSZO.js.map → chunk-CRU27Q4J.js.map} +0 -0
  484. /package/dist/{chunk-RBBWYEFJ.js.map → chunk-G2WADRQ3.js.map} +0 -0
  485. /package/dist/{chunk-NBVAS5MT.js.map → chunk-R2L7SUX2.js.map} +0 -0
@@ -2,20 +2,12 @@ import {
2
2
  CompoundingEngine,
3
3
  SharedContextManager,
4
4
  defaultTierMigrationCycleBudget
5
- } from "./chunk-XXVWLXSG.js";
6
- import {
7
- extractTopics
8
- } from "./chunk-UHGBNIOS.js";
5
+ } from "./chunk-LVYGDT5V.js";
9
6
  import {
10
7
  applyUtilityPromotionRuntimePolicy,
11
8
  applyUtilityRankingRuntimeDelta,
12
9
  loadUtilityRuntimeValues
13
10
  } from "./chunk-FSFEQI74.js";
14
- import {
15
- applyTemporalSupersession,
16
- normalizeSupersessionKey,
17
- shouldFilterSupersededFromRecall
18
- } from "./chunk-W6SL7OFG.js";
19
11
  import {
20
12
  TierMigrationExecutor
21
13
  } from "./chunk-Z5AAYHUC.js";
@@ -25,12 +17,29 @@ import {
25
17
  import {
26
18
  TmtBuilder
27
19
  } from "./chunk-TPB3I2AC.js";
20
+ import {
21
+ extractTopics
22
+ } from "./chunk-UHGBNIOS.js";
23
+ import {
24
+ HourlySummarizer
25
+ } from "./chunk-B2TL6GA2.js";
26
+ import {
27
+ applyTemporalSupersession,
28
+ normalizeSupersessionKey,
29
+ shouldFilterSupersededFromRecall
30
+ } from "./chunk-ZTSE2ZJ6.js";
31
+ import {
32
+ isValidAsOf
33
+ } from "./chunk-MDYG7VI7.js";
28
34
  import {
29
35
  SessionObserverState
30
36
  } from "./chunk-JR4ZC3G4.js";
31
37
  import {
32
- HourlySummarizer
33
- } from "./chunk-DG6YMRDC.js";
38
+ applyRuntimeRetrievalPolicy
39
+ } from "./chunk-5IZL4DCV.js";
40
+ import {
41
+ findUnresolvedEntityRefs
42
+ } from "./chunk-X7XN6YU4.js";
34
43
  import {
35
44
  RelevanceStore
36
45
  } from "./chunk-5NPGSAVB.js";
@@ -57,28 +66,19 @@ import {
57
66
  resolvePromptTagPrefilterAsync
58
67
  } from "./chunk-V3RXWQIE.js";
59
68
  import {
60
- applyRuntimeRetrievalPolicy
61
- } from "./chunk-5IZL4DCV.js";
69
+ createRecallSectionMetricRecorder
70
+ } from "./chunk-7DHTMOND.js";
62
71
  import {
63
72
  LastRecallStore,
64
73
  TierMigrationStatusStore,
65
74
  clampGraphRecallExpandedEntries
66
- } from "./chunk-VBVG2M5G.js";
67
- import {
68
- buildXraySnapshot
69
- } from "./chunk-KVBLZUKV.js";
70
- import {
71
- findUnresolvedEntityRefs
72
- } from "./chunk-X7XN6YU4.js";
75
+ } from "./chunk-WPGJYVUH.js";
73
76
  import {
74
77
  applyReasoningTraceBoost
75
78
  } from "./chunk-ZZTOURJI.js";
76
79
  import {
77
80
  reorderRecallResultsWithMmr
78
81
  } from "./chunk-YDBIWGNI.js";
79
- import {
80
- createRecallSectionMetricRecorder
81
- } from "./chunk-7DHTMOND.js";
82
82
  import {
83
83
  buildQmdRecallCacheKey,
84
84
  getCachedQmdRecall,
@@ -87,13 +87,19 @@ import {
87
87
  import {
88
88
  NegativeExampleStore
89
89
  } from "./chunk-D654IBA6.js";
90
- import {
91
- evaluateMemoryActionPolicy
92
- } from "./chunk-H63EDPFJ.js";
93
90
  import {
94
91
  applyMemoryWorthFilter,
95
92
  buildMemoryWorthCounterMap
96
93
  } from "./chunk-3GPTTA4J.js";
94
+ import {
95
+ runLiveConnectorsOnce
96
+ } from "./chunk-ASIQZXYO.js";
97
+ import {
98
+ evaluateMemoryActionPolicy
99
+ } from "./chunk-H63EDPFJ.js";
100
+ import {
101
+ classifyMemoryKind
102
+ } from "./chunk-YAZNBMNF.js";
97
103
  import {
98
104
  hasBroadGraphIntent,
99
105
  inferIntentFromText,
@@ -101,13 +107,6 @@ import {
101
107
  isTaskInitiationIntent,
102
108
  planRecallMode
103
109
  } from "./chunk-GGD5W7TB.js";
104
- import {
105
- classifyMemoryKind
106
- } from "./chunk-YAZNBMNF.js";
107
- import {
108
- EXTRACTION_JUDGE_VERDICT_CATEGORY,
109
- recordJudgeVerdict
110
- } from "./chunk-AJU4PJGY.js";
111
110
  import {
112
111
  recordJudgeTrainingPair
113
112
  } from "./chunk-DF3RVK3X.js";
@@ -120,10 +119,10 @@ import {
120
119
  } from "./chunk-C4SQJZAF.js";
121
120
  import {
122
121
  ExtractionEngine
123
- } from "./chunk-DIXB44VE.js";
122
+ } from "./chunk-N7X62G74.js";
124
123
  import {
125
124
  parseMemoryActionEligibilityContext
126
- } from "./chunk-NZLQTHS5.js";
125
+ } from "./chunk-WW3QQF4H.js";
127
126
  import {
128
127
  ProfilingCollector
129
128
  } from "./chunk-NBNN5GOB.js";
@@ -133,6 +132,9 @@ import {
133
132
  import {
134
133
  LocalLlmClient
135
134
  } from "./chunk-R2XRID2N.js";
135
+ import {
136
+ formatDaySummaryMemories
137
+ } from "./chunk-GZCUW5IC.js";
136
138
  import {
137
139
  tryDirectAnswer
138
140
  } from "./chunk-6AUUAZEX.js";
@@ -143,30 +145,38 @@ import {
143
145
  buildEntityRecallSection,
144
146
  entityRecentTranscriptLookbackHours,
145
147
  readRecentEntityTranscriptEntries
146
- } from "./chunk-FVA6TGI3.js";
148
+ } from "./chunk-Y3WQ4ZWK.js";
147
149
  import {
148
- formatDaySummaryMemories
149
- } from "./chunk-GZCUW5IC.js";
150
+ buildCompressionGuidelinesMarkdown,
151
+ computeCompressionGuidelineCandidate,
152
+ refineCompressionGuidelineCandidateSemantically,
153
+ renderCompressionGuidelinesMarkdown
154
+ } from "./chunk-2NMMFZ5T.js";
150
155
  import {
151
156
  RoutingRulesStore,
152
- expandTildePath,
153
157
  normalizeReplaySessionKey
154
- } from "./chunk-GA5P7RST.js";
158
+ } from "./chunk-VTJVUHRK.js";
155
159
  import {
156
160
  searchVerifiedEpisodes
157
- } from "./chunk-CUPFXL3J.js";
161
+ } from "./chunk-DHRQHX36.js";
158
162
  import {
159
163
  ThreadingManager
160
164
  } from "./chunk-JRNQ3RNA.js";
161
165
  import {
162
166
  searchVerifiedSemanticRules
163
- } from "./chunk-SPI27QT6.js";
167
+ } from "./chunk-L5IIGA5V.js";
164
168
  import {
165
169
  searchWorkProductLedgerEntries
166
170
  } from "./chunk-CULXMQJH.js";
167
171
  import {
168
172
  TranscriptManager
169
173
  } from "./chunk-E6K4NIEU.js";
174
+ import {
175
+ PolicyRuntimeManager
176
+ } from "./chunk-EABGC2TL.js";
177
+ import {
178
+ searchObjectiveStateSnapshots
179
+ } from "./chunk-LOBRX7VD.js";
170
180
  import {
171
181
  NamespaceSearchRouter,
172
182
  NamespaceStorageRouter,
@@ -174,16 +184,10 @@ import {
174
184
  createConversationIndexRuntime,
175
185
  createSearchBackend,
176
186
  writeConversationChunks
177
- } from "./chunk-NBVAS5MT.js";
187
+ } from "./chunk-R2L7SUX2.js";
178
188
  import {
179
189
  parseQmdExplain
180
- } from "./chunk-4HQS2HPX.js";
181
- import {
182
- PolicyRuntimeManager
183
- } from "./chunk-EABGC2TL.js";
184
- import {
185
- searchObjectiveStateSnapshots
186
- } from "./chunk-LOBRX7VD.js";
190
+ } from "./chunk-WSZIHQBK.js";
187
191
  import {
188
192
  searchHarmonicRetrieval
189
193
  } from "./chunk-HMDCOMYU.js";
@@ -192,31 +196,23 @@ import {
192
196
  scoreImportance
193
197
  } from "./chunk-JXS5PDQ7.js";
194
198
  import {
195
- launchProcessSync
196
- } from "./chunk-OR64ZGRZ.js";
199
+ recordEvalShadowRecall
200
+ } from "./chunk-K6WK37A6.js";
201
+ import {
202
+ EXTRACTION_JUDGE_VERDICT_CATEGORY,
203
+ recordJudgeVerdict
204
+ } from "./chunk-AJU4PJGY.js";
197
205
  import {
198
206
  collectNativeKnowledgeChunks,
199
207
  formatNativeKnowledgeSection,
200
208
  searchNativeKnowledge
201
209
  } from "./chunk-7SEAZFFB.js";
202
- import {
203
- recordEvalShadowRecall
204
- } from "./chunk-K6WK37A6.js";
205
- import {
206
- GraphIndex
207
- } from "./chunk-C2EFFULQ.js";
208
210
  import {
209
211
  CODEX_THREAD_KEY_PREFIX
210
212
  } from "./chunk-3PG3H5TD.js";
211
213
  import {
212
214
  applyCommitmentLedgerLifecycle
213
215
  } from "./chunk-FYIYMQ5N.js";
214
- import {
215
- buildCompressionGuidelinesMarkdown,
216
- computeCompressionGuidelineCandidate,
217
- refineCompressionGuidelineCandidateSemantically,
218
- renderCompressionGuidelinesMarkdown
219
- } from "./chunk-2NMMFZ5T.js";
220
216
  import {
221
217
  semanticChunkContent
222
218
  } from "./chunk-KVE7R4CG.js";
@@ -235,10 +231,10 @@ import {
235
231
  materializeAfterSemanticConsolidation,
236
232
  parseConsolidationResponse,
237
233
  parseOperatorAwareConsolidationResponse
238
- } from "./chunk-PVICZTKG.js";
234
+ } from "./chunk-55FXRRSJ.js";
239
235
  import {
240
236
  FallbackLlmClient
241
- } from "./chunk-AYXIPSZO.js";
237
+ } from "./chunk-CRU27Q4J.js";
242
238
  import {
243
239
  buildRecallQueryPolicy
244
240
  } from "./chunk-6HZ6AO2P.js";
@@ -260,22 +256,35 @@ import {
260
256
  isAbortError,
261
257
  throwIfAborted
262
258
  } from "./chunk-PVGDJXVK.js";
259
+ import {
260
+ clusterByKey,
261
+ stableHash
262
+ } from "./chunk-NN3TS5BM.js";
263
263
  import {
264
264
  listTrustZoneRecords,
265
265
  searchTrustZoneRecords
266
266
  } from "./chunk-EQINRHYR.js";
267
267
  import {
268
- buildProcedurePersistBody
269
- } from "./chunk-QDW3E4RD.js";
268
+ buildXraySnapshot
269
+ } from "./chunk-USFPPRAF.js";
270
270
  import {
271
271
  shouldSkipImplicitExtraction
272
272
  } from "./chunk-3FPTCC3Z.js";
273
273
  import {
274
274
  selectRouteRule
275
275
  } from "./chunk-2LGMW3DJ.js";
276
+ import {
277
+ launchProcessSync
278
+ } from "./chunk-OR64ZGRZ.js";
279
+ import {
280
+ buildProcedurePersistBody
281
+ } from "./chunk-QDW3E4RD.js";
282
+ import {
283
+ GraphIndex
284
+ } from "./chunk-RK2Y4XOM.js";
276
285
  import {
277
286
  searchCausalTrajectories
278
- } from "./chunk-RBBWYEFJ.js";
287
+ } from "./chunk-G2WADRQ3.js";
279
288
  import {
280
289
  canReadNamespace,
281
290
  defaultNamespaceForPrincipal,
@@ -294,15 +303,18 @@ import {
294
303
  normalizeAttributePairs,
295
304
  normalizeEntityName,
296
305
  parseEntityFile
297
- } from "./chunk-F5VP6YCB.js";
298
- import {
299
- confidenceTier
300
- } from "./chunk-LTCGGW2D.js";
306
+ } from "./chunk-DCE6SQLA.js";
301
307
  import {
302
308
  attachCitation,
303
309
  hasCitationForTemplate,
304
310
  stripCitationForTemplate
305
311
  } from "./chunk-4KAN3GZ3.js";
312
+ import {
313
+ confidenceTier
314
+ } from "./chunk-43EKP2UK.js";
315
+ import {
316
+ isActiveMemoryStatus
317
+ } from "./chunk-RULE4VG5.js";
306
318
  import {
307
319
  openBetterSqlite3
308
320
  } from "./chunk-BOUYNNYD.js";
@@ -319,9 +331,13 @@ import {
319
331
  import {
320
332
  log
321
333
  } from "./chunk-2ODBA7MQ.js";
334
+ import {
335
+ keyring_exports,
336
+ secureStoreDir
337
+ } from "./chunk-BJMBJZ2Y.js";
322
338
 
323
339
  // src/orchestrator.ts
324
- import path7 from "path";
340
+ import path6 from "path";
325
341
  import os from "os";
326
342
  import { createHash as createHash2, randomBytes } from "crypto";
327
343
  import { existsSync as existsSync2 } from "fs";
@@ -919,7 +935,7 @@ async function buildProcedureRecallSection(storage, prompt, config) {
919
935
  );
920
936
  const all = await storage.readAllMemories();
921
937
  const scored = all.filter(
922
- (m) => m.frontmatter.category === "procedure" && m.frontmatter.status !== "pending_review" && m.frontmatter.status !== "rejected" && m.frontmatter.status !== "quarantined" && m.frontmatter.status !== "superseded" && m.frontmatter.status !== "archived"
938
+ (m) => m.frontmatter.category === "procedure" && isActiveMemoryStatus(m.frontmatter.status)
923
939
  ).map((m) => ({ m, score: scoreProcedureForPrompt(m, trimmed, queryIntent) })).filter((x) => x.score > 0.04).sort((a, b) => b.score - a.score).slice(0, maxN);
924
940
  if (scored.length === 0) return null;
925
941
  const blocks = scored.map(({ m, score }) => {
@@ -943,6 +959,8 @@ var DAY_SUMMARY_CRON_ID = "engram-day-summary";
943
959
  var GOVERNANCE_CRON_ID = "engram-nightly-governance";
944
960
  var PROCEDURAL_MINING_CRON_ID = "engram-procedural-mining";
945
961
  var CONTRADICTION_SCAN_CRON_ID = "engram-contradiction-scan";
962
+ var PATTERN_REINFORCEMENT_CRON_ID = "engram-pattern-reinforcement";
963
+ var GRAPH_EDGE_DECAY_CRON_ID = "engram-graph-edge-decay";
946
964
  async function acquireCronJobsLock(jobsPath) {
947
965
  const lockPath2 = `${jobsPath}.lock`;
948
966
  const start = Date.now();
@@ -1103,6 +1121,202 @@ async function ensureContradictionScanCron(jobsPath, options) {
1103
1121
  delivery: { mode: "none" }
1104
1122
  }));
1105
1123
  }
1124
+ async function ensurePatternReinforcementCron(jobsPath, options) {
1125
+ const scheduleExpr = typeof options.scheduleExpr === "string" && options.scheduleExpr.trim().length > 0 ? options.scheduleExpr.trim() : "53 4 * * 0";
1126
+ const agentId = typeof options.agentId === "string" && options.agentId.trim().length > 0 ? options.agentId.trim() : "main";
1127
+ return ensureCronJob(jobsPath, PATTERN_REINFORCEMENT_CRON_ID, () => ({
1128
+ id: PATTERN_REINFORCEMENT_CRON_ID,
1129
+ agentId,
1130
+ name: "Remnic Pattern Reinforcement (weekly)",
1131
+ enabled: true,
1132
+ schedule: {
1133
+ kind: "cron",
1134
+ expr: scheduleExpr,
1135
+ tz: options.timezone
1136
+ },
1137
+ sessionTarget: "isolated",
1138
+ wakeMode: "now",
1139
+ payload: {
1140
+ kind: "agentTurn",
1141
+ timeoutSeconds: 900,
1142
+ thinking: "off",
1143
+ message: "You are OpenClaw automation. Call tool `engram.pattern_reinforcement_run` with empty params. If successful output exactly NO_REPLY. On error output one concise line. Do NOT use message tool."
1144
+ },
1145
+ delivery: { mode: "none" }
1146
+ }));
1147
+ }
1148
+ async function ensureGraphEdgeDecayCron(jobsPath, options) {
1149
+ const scheduleExpr = typeof options.scheduleExpr === "string" && options.scheduleExpr.trim().length > 0 ? options.scheduleExpr.trim() : "13 4 * * 0";
1150
+ const agentId = typeof options.agentId === "string" && options.agentId.trim().length > 0 ? options.agentId.trim() : "main";
1151
+ const scheduleLabel = graphEdgeDecayScheduleLabel(scheduleExpr);
1152
+ return ensureCronJob(jobsPath, GRAPH_EDGE_DECAY_CRON_ID, () => ({
1153
+ id: GRAPH_EDGE_DECAY_CRON_ID,
1154
+ agentId,
1155
+ // Schedule label reflects the actual cron expression (`daily` /
1156
+ // `weekly` / `custom`) so cron dashboards do not show "weekly"
1157
+ // when the schedule is in fact daily — Cursor review on PR #729.
1158
+ name: `Remnic Graph Edge Decay (${scheduleLabel})`,
1159
+ enabled: true,
1160
+ schedule: {
1161
+ kind: "cron",
1162
+ expr: scheduleExpr,
1163
+ tz: options.timezone
1164
+ },
1165
+ sessionTarget: "isolated",
1166
+ wakeMode: "now",
1167
+ payload: {
1168
+ kind: "agentTurn",
1169
+ timeoutSeconds: 900,
1170
+ thinking: "off",
1171
+ message: "You are OpenClaw automation. Call tool `engram.graph_edge_decay_run` with empty params. If successful output exactly NO_REPLY. On error output one concise line. Do NOT use message tool."
1172
+ },
1173
+ delivery: { mode: "none" }
1174
+ }));
1175
+ }
1176
+ function graphEdgeDecayCadenceToCronExpr(cadenceMs) {
1177
+ if (!Number.isFinite(cadenceMs) || cadenceMs <= 0) {
1178
+ return "13 4 * * 0";
1179
+ }
1180
+ const day = 24 * 60 * 60 * 1e3;
1181
+ if (cadenceMs < 7 * day) return "13 4 * * *";
1182
+ return "13 4 * * 0";
1183
+ }
1184
+ function graphEdgeDecayScheduleLabel(scheduleExpr) {
1185
+ if (scheduleExpr === "13 4 * * *") return "daily";
1186
+ if (scheduleExpr === "13 4 * * 0") return "weekly";
1187
+ return "custom";
1188
+ }
1189
+
1190
+ // src/maintenance/pattern-reinforcement.ts
1191
+ function patternReinforcementKey(content) {
1192
+ return content.trim().toLowerCase().replace(/\s+/g, " ").slice(0, 200);
1193
+ }
1194
+ function patternReinforcementClusterKey(category, content) {
1195
+ return `${category}::${patternReinforcementKey(content)}`;
1196
+ }
1197
+ function pickCanonical(memories) {
1198
+ let best = memories[0];
1199
+ let bestInstant = memoryInstant(best);
1200
+ let bestStamp = memoryStamp(best);
1201
+ for (let i = 1; i < memories.length; i += 1) {
1202
+ const candidate = memories[i];
1203
+ const instant = memoryInstant(candidate);
1204
+ const stamp = memoryStamp(candidate);
1205
+ let cmp;
1206
+ if (instant !== null && bestInstant !== null) {
1207
+ cmp = instant - bestInstant;
1208
+ } else {
1209
+ cmp = stamp.localeCompare(bestStamp);
1210
+ }
1211
+ if (cmp > 0 || cmp === 0 && candidate.frontmatter.id > best.frontmatter.id) {
1212
+ best = candidate;
1213
+ bestInstant = instant;
1214
+ bestStamp = stamp;
1215
+ }
1216
+ }
1217
+ return best;
1218
+ }
1219
+ function memoryStamp(memory) {
1220
+ return memory.frontmatter.updated || memory.frontmatter.created || "";
1221
+ }
1222
+ function memoryInstant(memory) {
1223
+ const stamp = memoryStamp(memory);
1224
+ if (stamp.length === 0) return null;
1225
+ const parsed = Date.parse(stamp);
1226
+ return Number.isFinite(parsed) ? parsed : null;
1227
+ }
1228
+ var ACTIVE_STATUS = "active";
1229
+ async function runPatternReinforcement(storage, options) {
1230
+ const minCount = Math.max(2, Math.floor(options.minCount));
1231
+ const targetCategories = new Set(options.categories);
1232
+ const now = options.now ?? (() => /* @__PURE__ */ new Date());
1233
+ const nowIso = now().toISOString();
1234
+ if (targetCategories.size === 0) {
1235
+ return emptyResult();
1236
+ }
1237
+ const memories = await storage.readAllMemories();
1238
+ const eligible = memories.filter((m) => {
1239
+ if (!targetCategories.has(m.frontmatter.category)) return false;
1240
+ const status = m.frontmatter.status ?? ACTIVE_STATUS;
1241
+ return status === ACTIVE_STATUS || status === "superseded";
1242
+ });
1243
+ if (eligible.length === 0) return emptyResult();
1244
+ const clusters = clusterByKey(
1245
+ eligible,
1246
+ (m) => patternReinforcementClusterKey(m.frontmatter.category, m.content)
1247
+ );
1248
+ const result = {
1249
+ clustersFound: 0,
1250
+ canonicalsUpdated: 0,
1251
+ duplicatesSuperseded: 0,
1252
+ clusters: []
1253
+ };
1254
+ for (const cluster of clusters.values()) {
1255
+ if (cluster.length < minCount) continue;
1256
+ const activeMembers = cluster.filter((m) => {
1257
+ const status = m.frontmatter.status ?? ACTIVE_STATUS;
1258
+ return status === ACTIVE_STATUS;
1259
+ });
1260
+ if (activeMembers.length === 0) continue;
1261
+ result.clustersFound += 1;
1262
+ const canonical = pickCanonical(activeMembers);
1263
+ const activeDuplicates = activeMembers.filter((m) => m !== canonical);
1264
+ const sourceIds = [...cluster].map((m) => m.frontmatter.id).filter((id) => typeof id === "string" && id.length > 0).sort();
1265
+ const previousCount = canonical.frontmatter.reinforcement_count ?? 0;
1266
+ const newCount = sourceIds.length;
1267
+ const reinforcementBumped = newCount > previousCount;
1268
+ const previousDerivedFrom = Array.isArray(canonical.frontmatter.derived_from) ? [...canonical.frontmatter.derived_from].sort() : [];
1269
+ const sortedSourceIds = [...sourceIds].sort();
1270
+ const membershipChanged = previousDerivedFrom.length !== sortedSourceIds.length || previousDerivedFrom.some((id, i) => id !== sortedSourceIds[i]);
1271
+ const previousVia = canonical.frontmatter.derived_via;
1272
+ const viaChanged = previousVia !== "pattern-reinforcement";
1273
+ const canonicalNeedsRefresh = reinforcementBumped || membershipChanged || viaChanged;
1274
+ if (canonicalNeedsRefresh) {
1275
+ const patch = {
1276
+ derived_from: sourceIds,
1277
+ derived_via: "pattern-reinforcement",
1278
+ updated: nowIso
1279
+ };
1280
+ if (reinforcementBumped) {
1281
+ patch.reinforcement_count = newCount;
1282
+ patch.last_reinforced_at = nowIso;
1283
+ } else {
1284
+ patch.reinforcement_count = canonical.frontmatter.reinforcement_count ?? newCount;
1285
+ patch.last_reinforced_at = canonical.frontmatter.last_reinforced_at ?? nowIso;
1286
+ }
1287
+ await storage.writeMemoryFrontmatter(canonical, patch);
1288
+ result.canonicalsUpdated += 1;
1289
+ }
1290
+ const supersededIds = [];
1291
+ for (const dup of activeDuplicates) {
1292
+ const patch = {
1293
+ status: "superseded",
1294
+ supersededBy: canonical.frontmatter.id,
1295
+ supersededAt: nowIso,
1296
+ updated: nowIso
1297
+ };
1298
+ await storage.writeMemoryFrontmatter(dup, patch);
1299
+ supersededIds.push(dup.frontmatter.id);
1300
+ result.duplicatesSuperseded += 1;
1301
+ }
1302
+ result.clusters.push({
1303
+ canonicalId: canonical.frontmatter.id,
1304
+ count: newCount,
1305
+ sourceIds,
1306
+ supersededIds,
1307
+ reinforcementBumped
1308
+ });
1309
+ }
1310
+ return result;
1311
+ }
1312
+ function emptyResult() {
1313
+ return {
1314
+ clustersFound: 0,
1315
+ canonicalsUpdated: 0,
1316
+ duplicatesSuperseded: 0,
1317
+ clusters: []
1318
+ };
1319
+ }
1106
1320
 
1107
1321
  // src/dedup/semantic.ts
1108
1322
  async function decideSemanticDedup(content, lookup, options) {
@@ -2706,119 +2920,6 @@ async function cleanupConversationChunks(rootDir, retentionDays) {
2706
2920
  }
2707
2921
  }
2708
2922
 
2709
- // src/coding/git-context.ts
2710
- import path6 from "path";
2711
- var DEFAULT_GIT_TIMEOUT_MS = 2e3;
2712
- function defaultGitInvoker() {
2713
- return (cwd, args) => {
2714
- const result = launchProcessSync("git", args, {
2715
- cwd,
2716
- encoding: "utf-8",
2717
- timeout: DEFAULT_GIT_TIMEOUT_MS,
2718
- shell: false
2719
- });
2720
- if (result.error) {
2721
- return { stdout: "", exitCode: 127 };
2722
- }
2723
- return {
2724
- stdout: typeof result.stdout === "string" ? result.stdout : "",
2725
- exitCode: typeof result.status === "number" ? result.status : 1
2726
- };
2727
- };
2728
- }
2729
- function stableHash(input) {
2730
- let hash = 2166136261;
2731
- for (let i = 0; i < input.length; i++) {
2732
- hash ^= input.charCodeAt(i);
2733
- hash = Math.imul(hash, 16777619) >>> 0;
2734
- }
2735
- return hash.toString(16).padStart(8, "0");
2736
- }
2737
- function normalizeOriginUrl(rawUrl) {
2738
- let url = rawUrl.trim();
2739
- if (!url) return "";
2740
- if (/\.git$/i.test(url)) url = url.slice(0, -4);
2741
- if (/^[A-Za-z]:[\\/]/.test(url)) {
2742
- return url.toLowerCase();
2743
- }
2744
- const protoMatch = /^[a-z][a-z0-9+.-]*:\/\/(?:[^@/]+@)?(\[[^\]]+\]|[^/:]*)(?::(\d+))?(\/.*)?$/i.exec(url);
2745
- if (protoMatch) {
2746
- let host = protoMatch[1] ?? "";
2747
- const wasBracketed = host.startsWith("[") && host.endsWith("]");
2748
- if (wasBracketed) host = host.slice(1, -1);
2749
- const port = protoMatch[2];
2750
- const repoPath = (protoMatch[3] ?? "").replace(/^\/+/, "");
2751
- const hostPort = port ? wasBracketed ? `[${host}]:${port}` : `${host}:${port}` : host;
2752
- const prefix = hostPort.length > 0 ? hostPort : "localhost";
2753
- return `${prefix}/${repoPath}`.toLowerCase();
2754
- }
2755
- const scpMatch = /^(?:([^@\s/]+)@)?(\[[^\]]+\]|[^:@\s/]+):(.+)$/.exec(url);
2756
- if (scpMatch) {
2757
- let host = scpMatch[2] ?? "";
2758
- if (host.startsWith("[") && host.endsWith("]")) host = host.slice(1, -1);
2759
- const repoPath = scpMatch[3] ?? "";
2760
- if (repoPath.startsWith("//")) {
2761
- return url.toLowerCase();
2762
- }
2763
- return `${host}/${repoPath.replace(/^\/+/, "")}`.toLowerCase();
2764
- }
2765
- return url.toLowerCase();
2766
- }
2767
- async function resolveGitContext(cwd, options = {}) {
2768
- try {
2769
- if (typeof cwd !== "string" || cwd.length === 0) return null;
2770
- const expanded = expandTildePath(cwd);
2771
- if (!path6.isAbsolute(expanded)) return null;
2772
- const invoker = options.invoker ?? defaultGitInvoker();
2773
- const topLevel = invoker(expanded, ["rev-parse", "--show-toplevel"]);
2774
- if (topLevel.exitCode !== 0) return null;
2775
- const rootPath = topLevel.stdout.trim();
2776
- if (!rootPath) return null;
2777
- const branchResult = invoker(rootPath, ["rev-parse", "--abbrev-ref", "HEAD"]);
2778
- let branch = null;
2779
- if (branchResult.exitCode === 0) {
2780
- const raw = branchResult.stdout.trim();
2781
- branch = raw && raw !== "HEAD" ? raw : null;
2782
- } else {
2783
- const unbornRef = invoker(rootPath, ["symbolic-ref", "--quiet", "HEAD"]);
2784
- if (unbornRef.exitCode === 0) {
2785
- const raw = unbornRef.stdout.trim();
2786
- const prefix = "refs/heads/";
2787
- if (raw.startsWith(prefix)) {
2788
- const candidate = raw.slice(prefix.length);
2789
- if (candidate) branch = candidate;
2790
- }
2791
- }
2792
- }
2793
- const originResult = invoker(rootPath, ["remote", "get-url", "origin"]);
2794
- let projectId;
2795
- if (originResult.exitCode === 0) {
2796
- const normalized = normalizeOriginUrl(originResult.stdout);
2797
- projectId = normalized ? `origin:${stableHash(normalized)}` : `root:${stableHash(rootPath)}`;
2798
- } else {
2799
- projectId = `root:${stableHash(rootPath)}`;
2800
- }
2801
- const headRef = invoker(rootPath, ["symbolic-ref", "--quiet", "refs/remotes/origin/HEAD"]);
2802
- let defaultBranch = null;
2803
- if (headRef.exitCode === 0) {
2804
- const raw = headRef.stdout.trim();
2805
- const prefix = "refs/remotes/origin/";
2806
- if (raw.startsWith(prefix)) {
2807
- const candidate = raw.slice(prefix.length);
2808
- if (candidate) defaultBranch = candidate;
2809
- }
2810
- }
2811
- return {
2812
- projectId,
2813
- branch,
2814
- rootPath,
2815
- defaultBranch
2816
- };
2817
- } catch {
2818
- return null;
2819
- }
2820
- }
2821
-
2822
2923
  // src/coding/coding-namespace.ts
2823
2924
  function sanitizeFragment(input) {
2824
2925
  if (typeof input !== "string") return "";
@@ -2889,27 +2990,30 @@ function branchNamespaceName(projectId, branch) {
2889
2990
  const suffixed = disambig ? `${base}-${stableHash(trimmedBranch)}` : base;
2890
2991
  return capLength(suffixed);
2891
2992
  }
2892
- function resolveCodingNamespaceOverlay(codingContext, config) {
2993
+ function resolveCodingNamespaceOverlay(codingContext, config, defaultNamespace) {
2893
2994
  if (!codingContext) return null;
2894
2995
  if (!config.projectScope) return null;
2895
2996
  const projectId = typeof codingContext.projectId === "string" ? codingContext.projectId.trim() : "";
2896
2997
  if (!projectId) return null;
2897
2998
  const projectNs = projectNamespaceName(projectId);
2999
+ const includeRoot = config.globalFallback === true;
2898
3000
  if (config.branchScope && typeof codingContext.branch === "string" && codingContext.branch.length > 0) {
2899
3001
  const branchNs = branchNamespaceName(projectId, codingContext.branch);
3002
+ const fallbacks = [projectNs];
3003
+ if (includeRoot) fallbacks.push("");
2900
3004
  return {
2901
3005
  namespace: branchNs,
2902
- readFallbacks: [projectNs],
3006
+ readFallbacks: fallbacks,
2903
3007
  scope: "branch"
2904
3008
  };
2905
3009
  }
2906
3010
  return {
2907
3011
  namespace: projectNs,
2908
- readFallbacks: [],
3012
+ readFallbacks: includeRoot ? [""] : [],
2909
3013
  scope: "project"
2910
3014
  };
2911
3015
  }
2912
- function describeCodingScope(codingContext, config) {
3016
+ function describeCodingScope(codingContext, config, defaultNamespace) {
2913
3017
  const projectId = codingContext?.projectId ?? null;
2914
3018
  const branch = codingContext?.branch ?? null;
2915
3019
  if (!codingContext) {
@@ -2943,7 +3047,7 @@ function describeCodingScope(codingContext, config) {
2943
3047
  disabledReason: "empty-project"
2944
3048
  };
2945
3049
  }
2946
- const overlay = resolveCodingNamespaceOverlay(codingContext, config);
3050
+ const overlay = resolveCodingNamespaceOverlay(codingContext, config, defaultNamespace);
2947
3051
  if (!overlay) {
2948
3052
  return {
2949
3053
  scope: "none",
@@ -3064,7 +3168,7 @@ async function raceRecallAbort(promise, signal, message = "recall aborted") {
3064
3168
  }
3065
3169
  var COMPACTION_SIGNAL_MAX_AGE_MS = 60 * 60 * 1e3;
3066
3170
  function defaultWorkspaceDir() {
3067
- return path7.join(os.homedir(), ".openclaw", "workspace");
3171
+ return path6.join(os.homedir(), ".openclaw", "workspace");
3068
3172
  }
3069
3173
  function sanitizeSessionKeyForFilename(sessionKey) {
3070
3174
  const readable = sessionKey.replace(/[^a-zA-Z0-9._-]/g, "_");
@@ -3232,11 +3336,11 @@ function mergeGraphExpandedResults(primary, expanded) {
3232
3336
  return Array.from(mergedByPath.values());
3233
3337
  }
3234
3338
  function graphPathRelativeToStorage(storageDir, candidatePath) {
3235
- const absolutePath = path7.isAbsolute(candidatePath) ? candidatePath : path7.resolve(storageDir, candidatePath);
3236
- const rel = path7.relative(storageDir, absolutePath);
3339
+ const absolutePath = path6.isAbsolute(candidatePath) ? candidatePath : path6.resolve(storageDir, candidatePath);
3340
+ const rel = path6.relative(storageDir, absolutePath);
3237
3341
  if (!rel || rel === ".") return null;
3238
3342
  if (rel.startsWith("..")) return null;
3239
- return rel.split(path7.sep).join("/");
3343
+ return rel.split(path6.sep).join("/");
3240
3344
  }
3241
3345
  function normalizeGraphActivationScore(score) {
3242
3346
  const bounded = Number.isFinite(score) && score > 0 ? score : 0;
@@ -3378,7 +3482,7 @@ function buildMemoryPathById(allMemsForGraph, storageDir) {
3378
3482
  for (const mem of allMemsForGraph ?? []) {
3379
3483
  const id = mem.frontmatter.id;
3380
3484
  if (!id) continue;
3381
- pathById.set(id, path7.relative(storageDir, mem.path));
3485
+ pathById.set(id, path6.relative(storageDir, mem.path));
3382
3486
  }
3383
3487
  return pathById;
3384
3488
  }
@@ -3386,7 +3490,7 @@ function appendMemoryToGraphContext(options) {
3386
3490
  if (!Array.isArray(options.allMemsForGraph)) return;
3387
3491
  const nowIso = (/* @__PURE__ */ new Date()).toISOString();
3388
3492
  options.allMemsForGraph.push({
3389
- path: path7.join(options.storageDir, options.memoryRelPath),
3493
+ path: path6.join(options.storageDir, options.memoryRelPath),
3390
3494
  content: options.content,
3391
3495
  frontmatter: {
3392
3496
  id: options.memoryId,
@@ -3406,16 +3510,16 @@ function resolvePersistedMemoryRelativePath(options) {
3406
3510
  const persisted = options.pathById.get(options.memoryId);
3407
3511
  if (persisted) return persisted;
3408
3512
  if (options.category === "correction") {
3409
- return path7.join("corrections", `${options.memoryId}.md`);
3513
+ return path6.join("corrections", `${options.memoryId}.md`);
3410
3514
  }
3411
3515
  const subtree = options.category === "procedure" ? "procedures" : options.category === "reasoning_trace" ? "reasoning-traces" : "facts";
3412
3516
  const idParts = options.memoryId.split("-");
3413
3517
  const maybeTimestamp = Number(idParts[1]);
3414
3518
  if (Number.isFinite(maybeTimestamp) && maybeTimestamp > 0) {
3415
3519
  const day = new Date(maybeTimestamp).toISOString().slice(0, 10);
3416
- return path7.join(subtree, day, `${options.memoryId}.md`);
3520
+ return path6.join(subtree, day, `${options.memoryId}.md`);
3417
3521
  }
3418
- return path7.join(subtree, `${options.memoryId}.md`);
3522
+ return path6.join(subtree, `${options.memoryId}.md`);
3419
3523
  }
3420
3524
  var Orchestrator = class _Orchestrator {
3421
3525
  storage;
@@ -3507,6 +3611,15 @@ var Orchestrator = class _Orchestrator {
3507
3611
  * through the same namespace layer).
3508
3612
  */
3509
3613
  _codingContextBySession = /* @__PURE__ */ new Map();
3614
+ /**
3615
+ * Per-session peer ID registry (issue #679 PR 3/5).
3616
+ * Set by connectors / hooks via `setPeerIdForSession` so `recallInternal`
3617
+ * can inject the peer's profile into recall context when
3618
+ * `peerProfileRecallEnabled` is true. Cleared when the session ends.
3619
+ * Keyed by sessionKey so concurrent sessions don't clobber each other
3620
+ * (rule 11 — scope globals per plugin ID / session).
3621
+ */
3622
+ _peerIdBySession = /* @__PURE__ */ new Map();
3510
3623
  routingRulesStore = null;
3511
3624
  contentHashIndex = null;
3512
3625
  artifactSourceStatusCache = /* @__PURE__ */ new WeakMap();
@@ -3533,6 +3646,13 @@ var Orchestrator = class _Orchestrator {
3533
3646
  lastTierMigrationRunAtMs = 0;
3534
3647
  conversationIndexLastUpdateAtMs = /* @__PURE__ */ new Map();
3535
3648
  lastFileHygieneRunAtMs = 0;
3649
+ // Pattern-reinforcement cadence gate (issue #687 PR 2/4). Tracks the
3650
+ // last successful run so `runPatternReinforcement` can short-circuit
3651
+ // when the configured cadence has not elapsed. Keyed by namespace
3652
+ // so MCP-triggered runs in tenant A don't suppress runs in tenant B
3653
+ // (PR #730 review feedback, Codex P2). The default-tenant path
3654
+ // uses the empty-string key.
3655
+ lastPatternReinforcementAtByNs = /* @__PURE__ */ new Map();
3536
3656
  lastRecallFailureLogAtMs = 0;
3537
3657
  lastRecallFailureAtMs = 0;
3538
3658
  suppressedRecallFailures = 0;
@@ -3660,14 +3780,58 @@ var Orchestrator = class _Orchestrator {
3660
3780
  applyCodingNamespaceOverlay(sessionKey, baseNamespace) {
3661
3781
  if (!this.config.namespacesEnabled) return baseNamespace;
3662
3782
  const codingContext = this.getCodingContextForSession(sessionKey);
3663
- const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode);
3783
+ const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode, this.config.defaultNamespace);
3664
3784
  if (!overlay) return baseNamespace;
3665
3785
  return combineNamespaces(baseNamespace, overlay.namespace);
3666
3786
  }
3787
+ /**
3788
+ * Register a peer ID for a session so recall can inject the peer's
3789
+ * profile into context (issue #679 PR 3/5). Pass `null` to clear.
3790
+ *
3791
+ * Connectors and the `before_agent_start` hook call this when the
3792
+ * session's counter-party is known. The ID is validated against
3793
+ * `PEER_ID_PATTERN` before storing.
3794
+ *
3795
+ * Fail-closed (Codex P1 review): an invalid peerId clears any
3796
+ * previously registered mapping for the session rather than silently
3797
+ * keeping stale data. This prevents a malformed metadata update from
3798
+ * mixing one peer's profile context into another session.
3799
+ *
3800
+ * Defensive init (Cursor review + rule 16): `Object.create(
3801
+ * Orchestrator.prototype)` stubs in legacy tests skip class-field
3802
+ * initializers, so `_peerIdBySession` may be undefined. Mirror the
3803
+ * same guard used by `setCodingContextForSession`.
3804
+ */
3805
+ setPeerIdForSession(sessionKey, peerId) {
3806
+ if (typeof sessionKey !== "string" || sessionKey.length === 0) return;
3807
+ if (!this._peerIdBySession) {
3808
+ this._peerIdBySession = /* @__PURE__ */ new Map();
3809
+ }
3810
+ if (peerId === null) {
3811
+ this._peerIdBySession.delete(sessionKey);
3812
+ return;
3813
+ }
3814
+ if (typeof peerId !== "string" || peerId.length === 0 || peerId.length > 64 || !/^[A-Za-z0-9]+(?:[._-][A-Za-z0-9]+)*$/.test(peerId)) {
3815
+ log.warn(`setPeerIdForSession: invalid peerId \u2014 clearing session mapping`);
3816
+ this._peerIdBySession.delete(sessionKey);
3817
+ return;
3818
+ }
3819
+ this._peerIdBySession.set(sessionKey, peerId);
3820
+ }
3821
+ /**
3822
+ * Return the peer ID registered for a session, or `null` when none
3823
+ * is set. Used by `recallInternal` to inject the peer profile section.
3824
+ * Defensive `_peerIdBySession` lookup — legacy orchestrator-flush tests
3825
+ * use `Object.create(Orchestrator.prototype)` which skips class-field
3826
+ * initializers, so the Map may be undefined on stubs.
3827
+ */
3828
+ getPeerIdForSession(sessionKey) {
3829
+ if (typeof sessionKey !== "string" || sessionKey.length === 0) return null;
3830
+ return this._peerIdBySession?.get(sessionKey) ?? null;
3831
+ }
3667
3832
  /**
3668
3833
  * Read-side overlay: returns the list of namespaces a session should read
3669
- * from, including any read fallbacks (branch → project asymmetry lands in
3670
- * PR 3; PR 2 returns an empty fallbacks list).
3834
+ * from, including any read fallbacks (branch → project, global root).
3671
3835
  *
3672
3836
  * Returns `null` when:
3673
3837
  * - `namespacesEnabled` is false (overlay would create false isolation)
@@ -3684,7 +3848,7 @@ var Orchestrator = class _Orchestrator {
3684
3848
  applyCodingRecallOverlay(sessionKey) {
3685
3849
  if (!this.config.namespacesEnabled) return null;
3686
3850
  const codingContext = this.getCodingContextForSession(sessionKey);
3687
- const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode);
3851
+ const overlay = resolveCodingNamespaceOverlay(codingContext, this.config.codingMode, this.config.defaultNamespace);
3688
3852
  if (!overlay) return null;
3689
3853
  return { namespace: overlay.namespace, readFallbacks: overlay.readFallbacks };
3690
3854
  }
@@ -3767,11 +3931,14 @@ var Orchestrator = class _Orchestrator {
3767
3931
  if (this.config.namespacesEnabled) return true;
3768
3932
  return this.qmd.isAvailable();
3769
3933
  }
3934
+ invalidateLiveContentHashIndex() {
3935
+ this.contentHashIndex = null;
3936
+ }
3770
3937
  constructor(config) {
3771
3938
  this.config = config;
3772
3939
  this.profiler = new ProfilingCollector({
3773
3940
  enabled: config.profilingEnabled,
3774
- storageDir: config.profilingStorageDir || path7.join(config.memoryDir, "profiling"),
3941
+ storageDir: config.profilingStorageDir || path6.join(config.memoryDir, "profiling"),
3775
3942
  maxTraces: config.profilingMaxTraces
3776
3943
  });
3777
3944
  this.storageRouter = new NamespaceStorageRouter(config);
@@ -3786,6 +3953,14 @@ var Orchestrator = class _Orchestrator {
3786
3953
  maxVersionsPerPage: config.versioningMaxPerPage,
3787
3954
  sidecarDir: config.versioningSidecarDir
3788
3955
  });
3956
+ if (config.secureStoreEnabled) {
3957
+ this.storage.setSecureStoreRequired(true);
3958
+ const storeId = secureStoreDir(config.memoryDir);
3959
+ const existingKey = keyring_exports.getKey(storeId);
3960
+ if (existingKey) {
3961
+ this.storage.setSecureStoreKey(existingKey, config.secureStoreEncryptOnWrite);
3962
+ }
3963
+ }
3789
3964
  this.qmd = createSearchBackend(config);
3790
3965
  const conversationIndexRuntime = createConversationIndexRuntime(config, {
3791
3966
  getQmd: () => this.conversationQmd,
@@ -3795,10 +3970,10 @@ var Orchestrator = class _Orchestrator {
3795
3970
  this.conversationFaiss = conversationIndexRuntime.faiss;
3796
3971
  this.conversationIndexBackend = conversationIndexRuntime.backend;
3797
3972
  this.sharedContext = config.sharedContextEnabled ? new SharedContextManager(config) : void 0;
3798
- this.compounding = config.compoundingEnabled ? new CompoundingEngine(config) : void 0;
3973
+ this.compounding = config.compoundingEnabled ? new CompoundingEngine(config, this.storage) : void 0;
3799
3974
  this.buffer = new SmartBuffer(config, this.storage);
3800
3975
  this.transcript = new TranscriptManager(config);
3801
- this.conversationIndexDir = path7.join(
3976
+ this.conversationIndexDir = path6.join(
3802
3977
  config.memoryDir,
3803
3978
  "conversation-index",
3804
3979
  "chunks"
@@ -3852,7 +4027,7 @@ var Orchestrator = class _Orchestrator {
3852
4027
  this.modelRegistry
3853
4028
  );
3854
4029
  this.threading = new ThreadingManager(
3855
- path7.join(config.memoryDir, "threads"),
4030
+ path6.join(config.memoryDir, "threads"),
3856
4031
  config.threadingGapMinutes
3857
4032
  );
3858
4033
  this.tmtBuilder = new TmtBuilder(config.memoryDir, {
@@ -4097,8 +4272,7 @@ var Orchestrator = class _Orchestrator {
4097
4272
  promotionByOutcomeEnabled: this.config.promotionByOutcomeEnabled
4098
4273
  });
4099
4274
  if (this.config.factDeduplicationEnabled) {
4100
- const stateDir = path7.join(this.config.memoryDir, "state");
4101
- this.contentHashIndex = new ContentHashIndex(stateDir);
4275
+ this.contentHashIndex = this.storage.createContentHashIndex();
4102
4276
  await this.contentHashIndex.load();
4103
4277
  log.info(
4104
4278
  `content-hash dedup: loaded ${this.contentHashIndex.size} hashes`
@@ -4126,7 +4300,7 @@ var Orchestrator = class _Orchestrator {
4126
4300
  const files = await readdir3(wsDir).catch(() => []);
4127
4301
  for (const f of files) {
4128
4302
  if (!f.startsWith(".compaction-reset-signal-")) continue;
4129
- const fp = path7.join(wsDir, f);
4303
+ const fp = path6.join(wsDir, f);
4130
4304
  const s = await stat3(fp).catch(() => null);
4131
4305
  if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
4132
4306
  await unlink2(fp).catch(() => {
@@ -4334,6 +4508,43 @@ var Orchestrator = class _Orchestrator {
4334
4508
  log.debug(`contradiction scan cron auto-register failed (non-fatal): ${err}`);
4335
4509
  }
4336
4510
  }
4511
+ if (this.config.patternReinforcementEnabled) {
4512
+ try {
4513
+ await this.autoRegisterPatternReinforcementCron();
4514
+ } catch (err) {
4515
+ log.debug(`pattern reinforcement cron auto-register failed (non-fatal): ${err}`);
4516
+ }
4517
+ }
4518
+ if (this.config.graphEdgeDecayEnabled) {
4519
+ try {
4520
+ await this.autoRegisterGraphEdgeDecayCron();
4521
+ } catch (err) {
4522
+ log.debug(`graph edge decay cron auto-register failed (non-fatal): ${err}`);
4523
+ }
4524
+ }
4525
+ if (signal.aborted) return;
4526
+ if (this.config.lifecyclePolicyEnabled && this.config.qmdTierMigrationEnabled) {
4527
+ try {
4528
+ const { runFirstStartMigration } = await import("./first-start-migration-4MHQEOSD.js");
4529
+ const result = await runFirstStartMigration({
4530
+ storage: this.storage,
4531
+ config: this.config,
4532
+ qmd: this.qmd,
4533
+ hotCollection: this.config.qmdCollection,
4534
+ coldCollection: this.config.qmdColdCollection,
4535
+ signal
4536
+ });
4537
+ if (!result.skipped) {
4538
+ log.info(
4539
+ `first-start lifecycle migration: demoted ${result.demotedCount} of ${result.candidateCount} candidates (cap=${result.cappedAt})`
4540
+ );
4541
+ } else {
4542
+ log.debug(`first-start lifecycle migration skipped: ${result.skipReason}`);
4543
+ }
4544
+ } catch (err) {
4545
+ log.warn(`first-start lifecycle migration failed (non-fatal): ${err}`);
4546
+ }
4547
+ }
4337
4548
  log.info("orchestrator initialized (full \u2014 deferred steps complete)");
4338
4549
  }
4339
4550
  /**
@@ -4441,7 +4652,7 @@ var Orchestrator = class _Orchestrator {
4441
4652
  */
4442
4653
  async autoRegisterDaySummaryCron() {
4443
4654
  const home = resolveHomeDir();
4444
- const jobsPath = path7.join(home, ".openclaw", "cron", "jobs.json");
4655
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4445
4656
  try {
4446
4657
  if (!existsSync2(jobsPath)) {
4447
4658
  log.debug(
@@ -4465,7 +4676,7 @@ var Orchestrator = class _Orchestrator {
4465
4676
  }
4466
4677
  async autoRegisterNightlyGovernanceCron() {
4467
4678
  const home = resolveHomeDir();
4468
- const jobsPath = path7.join(home, ".openclaw", "cron", "jobs.json");
4679
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4469
4680
  try {
4470
4681
  if (!existsSync2(jobsPath)) {
4471
4682
  log.debug("nightly governance cron: jobs.json not found, skipping auto-register");
@@ -4487,7 +4698,7 @@ var Orchestrator = class _Orchestrator {
4487
4698
  }
4488
4699
  async autoRegisterProceduralMiningCron() {
4489
4700
  const home = resolveHomeDir();
4490
- const jobsPath = path7.join(home, ".openclaw", "cron", "jobs.json");
4701
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4491
4702
  try {
4492
4703
  if (!existsSync2(jobsPath)) {
4493
4704
  log.debug("procedural mining cron: jobs.json not found, skipping auto-register");
@@ -4507,7 +4718,7 @@ var Orchestrator = class _Orchestrator {
4507
4718
  }
4508
4719
  async autoRegisterContradictionScanCron() {
4509
4720
  const home = resolveHomeDir();
4510
- const jobsPath = path7.join(home, ".openclaw", "cron", "jobs.json");
4721
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4511
4722
  try {
4512
4723
  if (!existsSync2(jobsPath)) {
4513
4724
  log.debug("contradiction scan cron: jobs.json not found, skipping auto-register");
@@ -4525,6 +4736,109 @@ var Orchestrator = class _Orchestrator {
4525
4736
  log.debug(`contradiction scan cron auto-register error: ${err}`);
4526
4737
  }
4527
4738
  }
4739
+ async autoRegisterPatternReinforcementCron() {
4740
+ const home = resolveHomeDir();
4741
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4742
+ try {
4743
+ if (!existsSync2(jobsPath)) {
4744
+ log.debug("pattern reinforcement cron: jobs.json not found, skipping auto-register");
4745
+ return;
4746
+ }
4747
+ const created = await ensurePatternReinforcementCron(jobsPath, {
4748
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone
4749
+ });
4750
+ if (created.created) {
4751
+ log.info(`pattern reinforcement cron auto-registered (${created.jobId})`);
4752
+ } else {
4753
+ log.debug("pattern reinforcement cron already exists, skipping auto-register");
4754
+ }
4755
+ } catch (err) {
4756
+ log.debug(`pattern reinforcement cron auto-register error: ${err}`);
4757
+ }
4758
+ }
4759
+ /**
4760
+ * Run the pattern-reinforcement maintenance job (issue #687 PR 2/4).
4761
+ *
4762
+ * Cadence-gated on `patternReinforcementCadenceMs` so every caller
4763
+ * (orchestrator cron path, MCP tool, CLI) shares a single floor —
4764
+ * none can call this on a hot loop and burn the corpus. When the
4765
+ * feature is disabled or the cadence has not elapsed, returns a
4766
+ * synthetic "skipped" result rather than throwing.
4767
+ *
4768
+ * Cadence tracking is per-namespace so a tenant-scoped MCP run in
4769
+ * one namespace does not silence a cron run in another (PR #730
4770
+ * review feedback, Codex P2). Pass `force: true` for ad-hoc
4771
+ * operator runs that must bypass the cadence floor — mirrors the
4772
+ * pattern used by other maintenance MCP tools.
4773
+ *
4774
+ * `force` deliberately does NOT bypass the master
4775
+ * `patternReinforcementEnabled` flag (PR #730 review feedback,
4776
+ * Cursor Medium). Operators who have explicitly disabled the
4777
+ * feature must not have their corpus mutated by an MCP tool call —
4778
+ * the only way to run the job is to enable the feature in config.
4779
+ */
4780
+ async runPatternReinforcement(options = {}) {
4781
+ const cadenceKey = options.namespace ?? "";
4782
+ if (!this.config.patternReinforcementEnabled) {
4783
+ return { ran: false, skippedReason: "disabled", namespace: cadenceKey };
4784
+ }
4785
+ const cadence = this.config.patternReinforcementCadenceMs;
4786
+ const lastAt = this.lastPatternReinforcementAtByNs.get(cadenceKey);
4787
+ if (!options.force && cadence > 0 && lastAt !== void 0 && Date.now() - lastAt < cadence) {
4788
+ return { ran: false, skippedReason: "cadence", namespace: cadenceKey };
4789
+ }
4790
+ const storage = options.namespace ? await this.getStorage(options.namespace) : this.storage;
4791
+ const result = await runPatternReinforcement(storage, {
4792
+ categories: this.config.patternReinforcementCategories,
4793
+ minCount: this.config.patternReinforcementMinCount
4794
+ });
4795
+ this.lastPatternReinforcementAtByNs.set(cadenceKey, Date.now());
4796
+ log.debug(
4797
+ `pattern reinforcement [ns=${cadenceKey || "(default)"}]: clusters=${result.clustersFound} canonicalsUpdated=${result.canonicalsUpdated} duplicatesSuperseded=${result.duplicatesSuperseded}`
4798
+ );
4799
+ return { ran: true, result, namespace: cadenceKey };
4800
+ }
4801
+ async autoRegisterGraphEdgeDecayCron() {
4802
+ const home = resolveHomeDir();
4803
+ const jobsPath = path6.join(home, ".openclaw", "cron", "jobs.json");
4804
+ try {
4805
+ if (!existsSync2(jobsPath)) {
4806
+ log.debug("graph edge decay cron: jobs.json not found, skipping auto-register");
4807
+ return;
4808
+ }
4809
+ const scheduleExpr = graphEdgeDecayCadenceToCronExpr(this.config.graphEdgeDecayCadenceMs);
4810
+ const created = await ensureGraphEdgeDecayCron(jobsPath, {
4811
+ timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
4812
+ scheduleExpr
4813
+ });
4814
+ if (created.created) {
4815
+ log.info(`graph edge decay cron auto-registered (${created.jobId}, ${scheduleExpr})`);
4816
+ } else {
4817
+ log.debug("graph edge decay cron already exists, skipping auto-register");
4818
+ }
4819
+ } catch (err) {
4820
+ log.debug(`graph edge decay cron auto-register error: ${err}`);
4821
+ }
4822
+ }
4823
+ async runLiveConnectors(options = {}) {
4824
+ return runLiveConnectorsOnce({
4825
+ memoryDir: this.config.memoryDir,
4826
+ connectors: this.config.connectors,
4827
+ force: options.force === true,
4828
+ abortSignal: options.abortSignal,
4829
+ ingestDocuments: async (docs) => {
4830
+ const fetchedAt = (/* @__PURE__ */ new Date()).toISOString();
4831
+ const turns = docs.map((doc) => ({
4832
+ role: "assistant",
4833
+ content: doc.title ? `# ${doc.title}
4834
+
4835
+ ${doc.content}` : doc.content,
4836
+ timestamp: fetchedAt
4837
+ }));
4838
+ await this.ingestBulkImportBatch(turns);
4839
+ }
4840
+ });
4841
+ }
4528
4842
  async applyBehaviorRuntimePolicy(state) {
4529
4843
  const result = await this.policyRuntime.applyFromBehaviorState(state);
4530
4844
  this.runtimePolicyValues = await this.policyRuntime.loadRuntimeValues();
@@ -4543,15 +4857,15 @@ var Orchestrator = class _Orchestrator {
4543
4857
  this.lastFileHygieneRunAtMs = now;
4544
4858
  if (hygiene.rotateEnabled) {
4545
4859
  for (const rel of hygiene.rotatePaths) {
4546
- const abs = path7.isAbsolute(rel) ? rel : path7.join(this.config.workspaceDir, rel);
4860
+ const abs = path6.isAbsolute(rel) ? rel : path6.join(this.config.workspaceDir, rel);
4547
4861
  try {
4548
4862
  const raw = await readFile4(abs, "utf-8");
4549
4863
  if (raw.length > hygiene.rotateMaxBytes) {
4550
- const archiveDir = path7.join(
4864
+ const archiveDir = path6.join(
4551
4865
  this.config.workspaceDir,
4552
4866
  hygiene.archiveDir
4553
4867
  );
4554
- const base = path7.basename(abs);
4868
+ const base = path6.basename(abs);
4555
4869
  const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
4556
4870
  const { newContent } = await rotateMarkdownFileToArchive({
4557
4871
  filePath: abs,
@@ -4576,8 +4890,8 @@ var Orchestrator = class _Orchestrator {
4576
4890
  log.warn(w.message);
4577
4891
  }
4578
4892
  if (hygiene.warningsLogEnabled && warnings.length > 0) {
4579
- const fp = path7.join(this.config.memoryDir, hygiene.warningsLogPath);
4580
- await mkdir5(path7.dirname(fp), { recursive: true });
4893
+ const fp = path6.join(this.config.memoryDir, hygiene.warningsLogPath);
4894
+ await mkdir5(path6.dirname(fp), { recursive: true });
4581
4895
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
4582
4896
  const block = `
4583
4897
 
@@ -4614,7 +4928,28 @@ var Orchestrator = class _Orchestrator {
4614
4928
  async runSemanticConsolidationNow(options) {
4615
4929
  return this.runSemanticConsolidation({ ...options, force: true });
4616
4930
  }
4931
+ async runDeepSleepGovernanceNow(options) {
4932
+ const targetStorage = options?.storage ?? this.storage;
4933
+ const { runMemoryGovernance } = await import("./memory-governance-KG52RITE.js");
4934
+ const { summarizeGovernanceResultForDreams } = await import("./dreams-ledger-LR2NBAZE.js");
4935
+ const govResult = await runMemoryGovernance({
4936
+ memoryDir: targetStorage.dir,
4937
+ mode: options?.dryRun === true ? "shadow" : "apply"
4938
+ });
4939
+ if (options?.dryRun !== true) {
4940
+ try {
4941
+ await this.processEntitySynthesisQueue(
4942
+ this.namespaceFromStorageDir(targetStorage.dir),
4943
+ 5
4944
+ );
4945
+ } catch (error) {
4946
+ log.debug(`deep-sleep governance: entity synthesis refresh failed after apply: ${error}`);
4947
+ }
4948
+ }
4949
+ return summarizeGovernanceResultForDreams(govResult, options?.dryRun === true);
4950
+ }
4617
4951
  async runSemanticConsolidation(options) {
4952
+ const targetStorage = options?.storage ?? this.storage;
4618
4953
  const result = {
4619
4954
  clustersFound: 0,
4620
4955
  memoriesConsolidated: 0,
@@ -4627,7 +4962,7 @@ var Orchestrator = class _Orchestrator {
4627
4962
  return result;
4628
4963
  }
4629
4964
  log.info("[semantic-consolidation] starting run");
4630
- const allMemories = await this.storage.readAllMemories();
4965
+ const allMemories = await targetStorage.readAllMemories();
4631
4966
  if (allMemories.length < 10) {
4632
4967
  log.debug("[semantic-consolidation] too few memories, skipping");
4633
4968
  return result;
@@ -4730,10 +5065,10 @@ var Orchestrator = class _Orchestrator {
4730
5065
  const derivedFromEntries = [];
4731
5066
  for (const m of cluster.memories) {
4732
5067
  if (!m.path) continue;
4733
- const entry = await this.storage.snapshotForProvenance(m.path);
5068
+ const entry = await targetStorage.snapshotForProvenance(m.path);
4734
5069
  if (entry) derivedFromEntries.push(entry);
4735
5070
  }
4736
- const canonicalId = await this.storage.writeMemory(
5071
+ const canonicalId = await targetStorage.writeMemory(
4737
5072
  newest.frontmatter.category,
4738
5073
  canonicalContent,
4739
5074
  {
@@ -4752,7 +5087,7 @@ var Orchestrator = class _Orchestrator {
4752
5087
  );
4753
5088
  result.memoriesConsolidated++;
4754
5089
  for (const m of cluster.memories) {
4755
- const archiveResult = await this.storage.archiveMemory(m, {
5090
+ const archiveResult = await targetStorage.archiveMemory(m, {
4756
5091
  actor: "semantic-consolidation",
4757
5092
  reasonCode: "semantic-consolidation",
4758
5093
  relatedMemoryIds: [canonicalId]
@@ -4771,7 +5106,7 @@ var Orchestrator = class _Orchestrator {
4771
5106
  await this.embeddingFallback.removeFromIndex(m.frontmatter.id);
4772
5107
  if (this.config.queryAwareIndexingEnabled && m.path && m.frontmatter?.created) {
4773
5108
  deindexMemory(
4774
- this.config.memoryDir,
5109
+ targetStorage.dir,
4775
5110
  m.path,
4776
5111
  m.frontmatter.created,
4777
5112
  m.frontmatter.tags ?? []
@@ -4803,13 +5138,39 @@ var Orchestrator = class _Orchestrator {
4803
5138
  try {
4804
5139
  await materializeAfterSemanticConsolidation({
4805
5140
  config: this.config,
4806
- memoryDir: this.config.memoryDir
5141
+ memoryDir: targetStorage.dir
4807
5142
  });
4808
5143
  } catch (err) {
4809
5144
  log.warn(
4810
5145
  `[semantic-consolidation] Codex materialize post-hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`
4811
5146
  );
4812
5147
  }
5148
+ if (this.config.peerProfileReasonerEnabled) {
5149
+ try {
5150
+ const { runPeerProfileReasoner } = await import("./peers-6OSQ3NK6.js");
5151
+ const llm2 = new FallbackLlmClient2(this.config.gatewayConfig);
5152
+ const peerResult = await runPeerProfileReasoner({
5153
+ memoryDir: targetStorage.dir,
5154
+ enabled: true,
5155
+ llm: llm2,
5156
+ model: this.config.peerProfileReasonerModel,
5157
+ minInteractions: this.config.peerProfileReasonerMinInteractions,
5158
+ maxFieldsPerRun: this.config.peerProfileReasonerMaxFieldsPerRun,
5159
+ log: {
5160
+ debug: (msg) => log.debug(msg),
5161
+ info: (msg) => log.info(msg),
5162
+ warn: (msg) => log.warn(msg)
5163
+ }
5164
+ });
5165
+ log.info(
5166
+ `[peer-profile-reasoner] complete: peers=${peerResult.peersConsidered}, processed=${peerResult.peersProcessed}, fields=${peerResult.fieldsApplied}`
5167
+ );
5168
+ } catch (err) {
5169
+ log.warn(
5170
+ `[peer-profile-reasoner] post-consolidation hook failed (non-fatal): ${err instanceof Error ? err.message : String(err)}`
5171
+ );
5172
+ }
5173
+ }
4813
5174
  return result;
4814
5175
  }
4815
5176
  async waitForExtractionIdle(timeoutMs = 6e4) {
@@ -4989,16 +5350,16 @@ ${evidenceText}`
4989
5350
  const datesToScan = [yesterday, utcToday].filter(
4990
5351
  (v, i, a) => a.indexOf(v) === i
4991
5352
  );
4992
- const factsBaseDir = path7.join(storage.dir, "facts");
5353
+ const factsBaseDir = path6.join(storage.dir, "facts");
4993
5354
  const MAX_CHARS = 1e5;
4994
5355
  const facts = [];
4995
5356
  for (const date of datesToScan) {
4996
- const factsDir = path7.join(factsBaseDir, date);
5357
+ const factsDir = path6.join(factsBaseDir, date);
4997
5358
  try {
4998
5359
  const entries = await readdir3(factsDir, { withFileTypes: true });
4999
5360
  for (const entry of entries) {
5000
5361
  if (!entry.name.endsWith(".md")) continue;
5001
- const fullPath = path7.join(factsDir, entry.name);
5362
+ const fullPath = path6.join(factsDir, entry.name);
5002
5363
  try {
5003
5364
  const raw = await readFile4(fullPath, "utf-8");
5004
5365
  const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
@@ -5014,7 +5375,7 @@ ${evidenceText}`
5014
5375
  facts.push({
5015
5376
  path: fullPath,
5016
5377
  frontmatter: {
5017
- id: fm.id || path7.basename(entry.name, ".md"),
5378
+ id: fm.id || path6.basename(entry.name, ".md"),
5018
5379
  category: fm.category || "fact",
5019
5380
  created: fm.created || "unknown",
5020
5381
  updated: fm.updated || fm.created || "unknown",
@@ -5035,13 +5396,13 @@ ${evidenceText}`
5035
5396
  (a, b) => a.frontmatter.created < b.frontmatter.created ? -1 : 1
5036
5397
  );
5037
5398
  const hourlySummaries = [];
5038
- const hourlyBaseDir = path7.join(storage.dir, "summaries", "hourly");
5399
+ const hourlyBaseDir = path6.join(storage.dir, "summaries", "hourly");
5039
5400
  try {
5040
5401
  const sessionKeys = await readdir3(hourlyBaseDir, { withFileTypes: true });
5041
5402
  for (const sk of sessionKeys) {
5042
5403
  if (!sk.isDirectory()) continue;
5043
5404
  for (const date of datesToScan) {
5044
- const summaryFile = path7.join(hourlyBaseDir, sk.name, `${date}.md`);
5405
+ const summaryFile = path6.join(hourlyBaseDir, sk.name, `${date}.md`);
5045
5406
  try {
5046
5407
  const raw = await readFile4(summaryFile, "utf-8");
5047
5408
  if (raw.trim().length > 0) {
@@ -5139,7 +5500,7 @@ ${evidenceText}`
5139
5500
  }
5140
5501
  async getLastGraphRecallSnapshot(namespace) {
5141
5502
  const storage = await this.getStorage(namespace);
5142
- const snapshotPath = path7.join(
5503
+ const snapshotPath = path6.join(
5143
5504
  storage.dir,
5144
5505
  "state",
5145
5506
  "last_graph_recall.json"
@@ -5178,7 +5539,7 @@ ${evidenceText}`
5178
5539
  }
5179
5540
  async getLastIntentSnapshot(namespace) {
5180
5541
  const storage = await this.getStorage(namespace);
5181
- const snapshotPath = path7.join(storage.dir, "state", "last_intent.json");
5542
+ const snapshotPath = path6.join(storage.dir, "state", "last_intent.json");
5182
5543
  try {
5183
5544
  const raw = await readFile4(snapshotPath, "utf-8");
5184
5545
  const parsed = JSON.parse(raw);
@@ -5211,7 +5572,7 @@ ${evidenceText}`
5211
5572
  }
5212
5573
  async getLastQmdRecallSnapshot(namespace) {
5213
5574
  const storage = await this.getStorage(namespace);
5214
- const snapshotPath = path7.join(
5575
+ const snapshotPath = path6.join(
5215
5576
  storage.dir,
5216
5577
  "state",
5217
5578
  "last_qmd_recall.json"
@@ -5272,9 +5633,10 @@ ${evidenceText}`
5272
5633
  `Seed paths (${snapshot.seedCount}):`,
5273
5634
  ...snapshot.seeds.map((p) => `- ${p}`),
5274
5635
  `Expanded paths (${snapshot.expandedCount}, showing ${expanded.length}):`,
5275
- ...expanded.map(
5276
- (e) => `- ${e.path} (score=${e.score.toFixed(3)}, ns=${e.namespace}, seed=${e.seed || "unknown"}, hop=${e.hopDepth}, w=${e.decayedWeight.toFixed(3)}, type=${e.graphType})`
5277
- ),
5636
+ ...expanded.map((e) => {
5637
+ const confLabel = typeof e.edgeConfidence === "number" && Number.isFinite(e.edgeConfidence) ? e.edgeConfidence.toFixed(2) : "n/a";
5638
+ return `- ${e.path} (score=${e.score.toFixed(3)}, ns=${e.namespace}, seed=${e.seed || "unknown"}, hop=${e.hopDepth}, w=${e.decayedWeight.toFixed(3)}, type=${e.graphType}, conf=${confLabel})`;
5639
+ }),
5278
5640
  `Final ranked results (${snapshot.finalResults?.length ?? 0}, showing ${finalResults.length}):`,
5279
5641
  ...finalResults.map(
5280
5642
  (entry) => `- ${entry.path} (score=${entry.score.toFixed(3)}, sources=${entry.sourceLabels.join(",") || "baseline"})`
@@ -5363,7 +5725,7 @@ ${r.snippet.trim()}
5363
5725
  const entries = await readdir3(dir, { withFileTypes: true });
5364
5726
  let total = 0;
5365
5727
  for (const entry of entries) {
5366
- const fullPath = path7.join(dir, entry.name);
5728
+ const fullPath = path6.join(dir, entry.name);
5367
5729
  if (entry.isDirectory()) {
5368
5730
  total += await this.countConversationChunkDocs(fullPath);
5369
5731
  continue;
@@ -5618,6 +5980,11 @@ ${r.snippet.trim()}
5618
5980
  log.warn("recall: init gate timed out \u2014 proceeding without full init");
5619
5981
  }
5620
5982
  }
5983
+ if (this.config.secureStoreEnabled && !this.storage.isSecureStoreUnlocked()) {
5984
+ const lockedMsg = "[secure-store locked] Memory store is encrypted and locked. Run `remnic secure-store unlock` then restart the daemon to decrypt.";
5985
+ log.warn("recall blocked: secure-store is locked");
5986
+ return lockedMsg;
5987
+ }
5621
5988
  try {
5622
5989
  const recallPromise = this.recallInternal(prompt, sessionKey, {
5623
5990
  ...options,
@@ -6240,17 +6607,18 @@ ${r.snippet.trim()}
6240
6607
  0
6241
6608
  );
6242
6609
  seedPaths.push(
6243
- ...seedRelativePaths.map((rel) => path7.join(storage.dir, rel))
6610
+ ...seedRelativePaths.map((rel) => path6.join(storage.dir, rel))
6244
6611
  );
6245
6612
  const seedSet = new Set(seedRelativePaths);
6246
6613
  const expanded = await this.graphIndexFor(storage).spreadingActivation(
6247
6614
  seedRelativePaths,
6248
- this.config.maxGraphTraversalSteps
6615
+ this.config.maxGraphTraversalSteps,
6616
+ options.includeLowConfidence === true ? { includeLowConfidence: true } : void 0
6249
6617
  );
6250
6618
  if (expanded.length === 0) continue;
6251
6619
  for (const candidate of expanded.slice(0, perNamespaceExpandedCap)) {
6252
6620
  if (seedSet.has(candidate.path)) continue;
6253
- const memoryPath = path7.resolve(storage.dir, candidate.path);
6621
+ const memoryPath = path6.resolve(storage.dir, candidate.path);
6254
6622
  const memory = await storage.readMemoryByPath(memoryPath);
6255
6623
  if (!memory) continue;
6256
6624
  if (isArtifactMemoryPath(memory.path)) continue;
@@ -6274,10 +6642,15 @@ ${r.snippet.trim()}
6274
6642
  path: memory.path,
6275
6643
  score,
6276
6644
  namespace,
6277
- seed: path7.resolve(storage.dir, candidate.seed),
6645
+ seed: path6.resolve(storage.dir, candidate.seed),
6278
6646
  hopDepth: candidate.hopDepth,
6279
6647
  decayedWeight: candidate.decayedWeight,
6280
- graphType: candidate.graphType
6648
+ graphType: candidate.graphType,
6649
+ // Issue #681 PR 3/3 — surface the per-edge confidence used for
6650
+ // PageRank weighting / floor pruning so downstream observability
6651
+ // (recall_xray, memory_graph_explain) can attribute ranking and
6652
+ // pruning decisions to specific edges.
6653
+ edgeConfidence: candidate.edgeConfidence
6281
6654
  });
6282
6655
  }
6283
6656
  }
@@ -6290,12 +6663,12 @@ ${r.snippet.trim()}
6290
6663
  }
6291
6664
  async recordLastGraphRecallSnapshot(options) {
6292
6665
  try {
6293
- const snapshotPath = path7.join(
6666
+ const snapshotPath = path6.join(
6294
6667
  options.storage.dir,
6295
6668
  "state",
6296
6669
  "last_graph_recall.json"
6297
6670
  );
6298
- await mkdir5(path7.dirname(snapshotPath), { recursive: true });
6671
+ await mkdir5(path6.dirname(snapshotPath), { recursive: true });
6299
6672
  const now = (/* @__PURE__ */ new Date()).toISOString();
6300
6673
  const totalSeedCount = options.seedPaths.length;
6301
6674
  const totalExpandedCount = options.expandedPaths.length;
@@ -6329,12 +6702,12 @@ ${r.snippet.trim()}
6329
6702
  }
6330
6703
  async recordLastIntentSnapshot(options) {
6331
6704
  try {
6332
- const snapshotPath = path7.join(
6705
+ const snapshotPath = path6.join(
6333
6706
  options.storage.dir,
6334
6707
  "state",
6335
6708
  "last_intent.json"
6336
6709
  );
6337
- await mkdir5(path7.dirname(snapshotPath), { recursive: true });
6710
+ await mkdir5(path6.dirname(snapshotPath), { recursive: true });
6338
6711
  await writeFile4(
6339
6712
  snapshotPath,
6340
6713
  JSON.stringify(options.snapshot, null, 2),
@@ -6346,12 +6719,12 @@ ${r.snippet.trim()}
6346
6719
  }
6347
6720
  async recordLastQmdRecallSnapshot(options) {
6348
6721
  try {
6349
- const snapshotPath = path7.join(
6722
+ const snapshotPath = path6.join(
6350
6723
  options.storage.dir,
6351
6724
  "state",
6352
6725
  "last_qmd_recall.json"
6353
6726
  );
6354
- await mkdir5(path7.dirname(snapshotPath), { recursive: true });
6727
+ await mkdir5(path6.dirname(snapshotPath), { recursive: true });
6355
6728
  await writeFile4(
6356
6729
  snapshotPath,
6357
6730
  JSON.stringify(options.snapshot, null, 2),
@@ -6366,8 +6739,8 @@ ${r.snippet.trim()}
6366
6739
  const stateDir = await this.resolveStateDirForNamespace(
6367
6740
  options.namespace
6368
6741
  );
6369
- const snapshotPath = path7.join(stateDir, "last_intent.json");
6370
- await mkdir5(path7.dirname(snapshotPath), { recursive: true });
6742
+ const snapshotPath = path6.join(stateDir, "last_intent.json");
6743
+ await mkdir5(path6.dirname(snapshotPath), { recursive: true });
6371
6744
  await writeFile4(
6372
6745
  snapshotPath,
6373
6746
  JSON.stringify(options.snapshot, null, 2),
@@ -6379,12 +6752,12 @@ ${r.snippet.trim()}
6379
6752
  }
6380
6753
  async resolveStateDirForNamespace(namespace) {
6381
6754
  if (!this.config.namespacesEnabled) {
6382
- return path7.join(this.config.memoryDir, "state");
6755
+ return path6.join(this.config.memoryDir, "state");
6383
6756
  }
6384
6757
  if (namespace !== this.config.defaultNamespace) {
6385
- return path7.join(this.config.memoryDir, "namespaces", namespace, "state");
6758
+ return path6.join(this.config.memoryDir, "namespaces", namespace, "state");
6386
6759
  }
6387
- const candidate = path7.join(
6760
+ const candidate = path6.join(
6388
6761
  this.config.memoryDir,
6389
6762
  "namespaces",
6390
6763
  this.config.defaultNamespace
@@ -6392,11 +6765,11 @@ ${r.snippet.trim()}
6392
6765
  try {
6393
6766
  const candidateStat = await stat3(candidate);
6394
6767
  if (candidateStat.isDirectory()) {
6395
- return path7.join(candidate, "state");
6768
+ return path6.join(candidate, "state");
6396
6769
  }
6397
6770
  } catch {
6398
6771
  }
6399
- return path7.join(this.config.memoryDir, "state");
6772
+ return path6.join(this.config.memoryDir, "state");
6400
6773
  }
6401
6774
  buildGraphRecallRankedResults(results, sourceLabelResolver, limit = 64) {
6402
6775
  return results.slice(0, limit).map((result) => ({
@@ -6430,12 +6803,12 @@ ${r.snippet.trim()}
6430
6803
  return Math.max(0, Math.floor(value));
6431
6804
  }
6432
6805
  appendRecallSection(sectionBuckets, sectionId, content) {
6433
- if (!this.isRecallSectionEnabled(sectionId)) return;
6806
+ if (!this.isRecallSectionEnabled(sectionId)) return false;
6434
6807
  const trimmed = content.trim();
6435
- if (trimmed.length === 0) return;
6808
+ if (trimmed.length === 0) return false;
6436
6809
  const maxChars = this.getRecallSectionMaxChars(sectionId);
6437
6810
  let finalContent = trimmed;
6438
- if (maxChars === 0) return;
6811
+ if (maxChars === 0) return false;
6439
6812
  if (typeof maxChars === "number" && finalContent.length > maxChars) {
6440
6813
  finalContent = `${finalContent.slice(0, maxChars)}
6441
6814
 
@@ -6445,6 +6818,7 @@ ${r.snippet.trim()}
6445
6818
  const existing = sectionBuckets.get(sectionId) ?? [];
6446
6819
  existing.push(finalContent);
6447
6820
  sectionBuckets.set(sectionId, existing);
6821
+ return true;
6448
6822
  }
6449
6823
  truncateRecallSectionToBudget(content, maxChars) {
6450
6824
  if (maxChars <= 0) return "";
@@ -6570,6 +6944,11 @@ ${r.snippet.trim()}
6570
6944
  }
6571
6945
  async recallInternal(prompt, sessionKey, options = {}) {
6572
6946
  const recallStart = Date.now();
6947
+ let asOfMs;
6948
+ if (typeof options.asOf === "string" && options.asOf.length > 0) {
6949
+ const parsed = Date.parse(options.asOf);
6950
+ if (Number.isFinite(parsed)) asOfMs = parsed;
6951
+ }
6573
6952
  const timings = {};
6574
6953
  const profileTraceId = this.profiler.startTrace("recall", sessionKey, {
6575
6954
  qmdEnabled: this.config.qmdEnabled,
@@ -6644,6 +7023,7 @@ ${r.snippet.trim()}
6644
7023
  let recalledMemoryCount = 0;
6645
7024
  let recalledMemoryIds = [];
6646
7025
  let recalledMemoryPaths = [];
7026
+ let xrayRecalledResults = [];
6647
7027
  const xrayBranchPoolSize = {
6648
7028
  hot_qmd: 0,
6649
7029
  hot_embedding: 0,
@@ -6756,7 +7136,7 @@ ${r.snippet.trim()}
6756
7136
  const graphExpandedResultPaths = /* @__PURE__ */ new Set();
6757
7137
  const graphSourceLabelsForPath = (resultPath) => {
6758
7138
  const labels = [];
6759
- const normalizedPath = resultPath.split(path7.sep).join("/");
7139
+ const normalizedPath = resultPath.split(path6.sep).join("/");
6760
7140
  const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
6761
7141
  if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
6762
7142
  if (graphExpandedResultPaths.has(resultPath))
@@ -6980,6 +7360,71 @@ ${trimmedBody}`;
6980
7360
  });
6981
7361
  return profile2 || null;
6982
7362
  })();
7363
+ let peerProfileXrayAnnotation = void 0;
7364
+ const peerProfileRecallPromise = (async () => {
7365
+ if (!this.config.peerProfileRecallEnabled) return null;
7366
+ if (this.config.peerProfileRecallMaxFields <= 0) return null;
7367
+ const peerId = this.getPeerIdForSession(sessionKey);
7368
+ if (!peerId) return null;
7369
+ const t0 = Date.now();
7370
+ try {
7371
+ const { readPeerProfile: _readPeerProfile } = await import("./peers-6OSQ3NK6.js");
7372
+ const peerProfile = await _readPeerProfile(this.config.memoryDir, peerId);
7373
+ recordRecallSectionMetric({
7374
+ section: "peerProfile",
7375
+ priority: "core",
7376
+ durationMs: Date.now() - t0,
7377
+ deadlineMs: recallSectionDeadlineMs,
7378
+ source: "fresh",
7379
+ success: true
7380
+ });
7381
+ if (!peerProfile) {
7382
+ peerProfileXrayAnnotation = null;
7383
+ return null;
7384
+ }
7385
+ const allFields = Object.entries(peerProfile.fields);
7386
+ if (allFields.length === 0) {
7387
+ peerProfileXrayAnnotation = null;
7388
+ return null;
7389
+ }
7390
+ const fieldsByRecency = allFields.map(([key, value]) => {
7391
+ const prov = peerProfile.provenance[key];
7392
+ let latestMs = 0;
7393
+ if (Array.isArray(prov) && prov.length > 0) {
7394
+ for (const p of prov) {
7395
+ if (typeof p.observedAt === "string") {
7396
+ const parsed = Date.parse(p.observedAt);
7397
+ if (Number.isFinite(parsed) && parsed > latestMs) {
7398
+ latestMs = parsed;
7399
+ }
7400
+ }
7401
+ }
7402
+ }
7403
+ return { key, value, latestMs };
7404
+ }).sort((a, b) => {
7405
+ if (b.latestMs !== a.latestMs) return b.latestMs - a.latestMs;
7406
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
7407
+ });
7408
+ const capped = fieldsByRecency.slice(0, this.config.peerProfileRecallMaxFields);
7409
+ const lines = capped.map(({ key, value }) => `**${key}**: ${value}`);
7410
+ peerProfileXrayAnnotation = { peerId, fieldsInjected: capped.length };
7411
+ return `## Peer Profile
7412
+
7413
+ ${lines.join("\n\n")}`;
7414
+ } catch (err) {
7415
+ recordRecallSectionMetric({
7416
+ section: "peerProfile",
7417
+ priority: "core",
7418
+ durationMs: Date.now() - t0,
7419
+ deadlineMs: recallSectionDeadlineMs,
7420
+ source: "fresh",
7421
+ success: false,
7422
+ timing: `error(${err instanceof Error ? err.message : String(err)})`
7423
+ });
7424
+ log.debug(`peer profile recall injection failed (non-fatal): ${err}`);
7425
+ return null;
7426
+ }
7427
+ })();
6983
7428
  const identityContinuityPromise = (async () => {
6984
7429
  if (!this.isRecallSectionEnabled(
6985
7430
  "identity-continuity",
@@ -7969,11 +8414,11 @@ ${formatted}`;
7969
8414
  if (!this.config.compactionResetEnabled) return null;
7970
8415
  const workspaceDir = compactionWorkspaceDir || this.config.workspaceDir || defaultWorkspaceDir();
7971
8416
  const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
7972
- const signalPath = path7.join(
8417
+ const signalPath = path6.join(
7973
8418
  workspaceDir,
7974
8419
  `.compaction-reset-signal-${safeSessionKey}`
7975
8420
  );
7976
- const bootPath = path7.join(workspaceDir, "BOOT.md");
8421
+ const bootPath = path6.join(workspaceDir, "BOOT.md");
7977
8422
  try {
7978
8423
  const signalStat = await stat3(signalPath).catch(() => null);
7979
8424
  if (!signalStat) return null;
@@ -8275,7 +8720,8 @@ ${formatted}`;
8275
8720
  transcriptSection,
8276
8721
  compactionSection,
8277
8722
  summariesSection,
8278
- conversationRecallSection
8723
+ conversationRecallSection,
8724
+ peerProfileSection
8279
8725
  ] = await raceRecallAbort(
8280
8726
  Promise.all(
8281
8727
  [
@@ -8297,7 +8743,8 @@ ${formatted}`;
8297
8743
  ["transcript", transcriptPromise],
8298
8744
  ["compaction", compactionPromise],
8299
8745
  ["summaries", summariesPromise],
8300
- ["convRecall", conversationRecallPromise]
8746
+ ["convRecall", conversationRecallPromise],
8747
+ ["peerProfile", peerProfileRecallPromise]
8301
8748
  ].map(
8302
8749
  ([name, p]) => p.then((v) => {
8303
8750
  log.debug(
@@ -8388,6 +8835,16 @@ ${formatted}`;
8388
8835
 
8389
8836
  ${profile}`
8390
8837
  );
8838
+ if (peerProfileSection) {
8839
+ const peerSectionAppended = this.appendRecallSection(
8840
+ sectionBuckets,
8841
+ "peer-profile",
8842
+ peerProfileSection
8843
+ );
8844
+ if (!peerSectionAppended) {
8845
+ peerProfileXrayAnnotation = null;
8846
+ }
8847
+ }
8391
8848
  if (calibrationSection) {
8392
8849
  this.appendRecallSection(
8393
8850
  sectionBuckets,
@@ -8615,7 +9072,8 @@ ${tmtNode.summary}`
8615
9072
  } = await this.expandResultsViaGraph({
8616
9073
  memoryResults,
8617
9074
  recallNamespaces,
8618
- recallResultLimit
9075
+ recallResultLimit,
9076
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
8619
9077
  });
8620
9078
  graphSnapshotStatus = "completed";
8621
9079
  graphDecisionStatus = "completed";
@@ -8669,7 +9127,9 @@ ${tmtNode.summary}`
8669
9127
  memoryResults = await this.boostSearchResults(
8670
9128
  memoryResults,
8671
9129
  recallNamespaces,
8672
- retrievalQuery
9130
+ retrievalQuery,
9131
+ void 0,
9132
+ { asOfMs }
8673
9133
  );
8674
9134
  if (this.config.rerankEnabled && this.config.rerankProvider === "local") {
8675
9135
  const ranked = await rerankLocalOrNoop({
@@ -8791,6 +9251,7 @@ ${tmtNode.summary}`
8791
9251
  });
8792
9252
  recalledMemoryIds = this.extractMemoryIdsFromResults(memoryResults);
8793
9253
  recalledMemoryPaths = memoryResults.map((result) => result.path).filter(Boolean);
9254
+ xrayRecalledResults = memoryResults;
8794
9255
  impressionRecorded = true;
8795
9256
  } else if (!confidenceGateRejected) {
8796
9257
  const queryAwarePrefilter = await queryAwarePrefilterPromise;
@@ -8814,7 +9275,9 @@ ${tmtNode.summary}`
8814
9275
  const boostedScoped = await this.boostSearchResults(
8815
9276
  scopedCandidates,
8816
9277
  recallNamespaces,
8817
- retrievalQuery
9278
+ retrievalQuery,
9279
+ void 0,
9280
+ { asOfMs }
8818
9281
  );
8819
9282
  xrayBranchPoolSize.hot_embedding = Math.max(
8820
9283
  xrayBranchPoolSize.hot_embedding,
@@ -8849,6 +9312,7 @@ ${tmtNode.summary}`
8849
9312
  });
8850
9313
  recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
8851
9314
  recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
9315
+ xrayRecalledResults = scoped;
8852
9316
  impressionRecorded = true;
8853
9317
  } else {
8854
9318
  const longTerm = await this.applyColdFallbackPipeline({
@@ -8858,7 +9322,9 @@ ${tmtNode.summary}`
8858
9322
  recallMode,
8859
9323
  queryAwarePrefilter,
8860
9324
  abortSignal: options.abortSignal,
8861
- xrayPoolSizeSink: xrayColdPoolSink
9325
+ xrayPoolSizeSink: xrayColdPoolSink,
9326
+ asOfMs,
9327
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
8862
9328
  });
8863
9329
  if (longTerm.length > 0) {
8864
9330
  if (shouldPersistGraphSnapshot) {
@@ -8883,6 +9349,7 @@ ${tmtNode.summary}`
8883
9349
  });
8884
9350
  recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
8885
9351
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
9352
+ xrayRecalledResults = longTerm;
8886
9353
  impressionRecorded = true;
8887
9354
  }
8888
9355
  }
@@ -8940,7 +9407,9 @@ ${tmtNode.summary}`
8940
9407
  const boostedScoped = await this.boostSearchResults(
8941
9408
  scopedCandidates,
8942
9409
  recallNamespaces,
8943
- retrievalQuery
9410
+ retrievalQuery,
9411
+ void 0,
9412
+ { asOfMs }
8944
9413
  );
8945
9414
  xrayBranchPoolSize.hot_embedding = Math.max(
8946
9415
  xrayBranchPoolSize.hot_embedding,
@@ -8975,6 +9444,7 @@ ${tmtNode.summary}`
8975
9444
  });
8976
9445
  recalledMemoryIds = this.extractMemoryIdsFromResults(scoped);
8977
9446
  recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
9447
+ xrayRecalledResults = scoped;
8978
9448
  impressionRecorded = true;
8979
9449
  } else {
8980
9450
  const memories = await this.readAllMemoriesForNamespaces(recallNamespaces);
@@ -8983,12 +9453,14 @@ ${tmtNode.summary}`
8983
9453
  enabled: this.config.temporalSupersessionEnabled,
8984
9454
  includeInRecall: this.config.temporalSupersessionIncludeInRecall
8985
9455
  };
9456
+ const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
8986
9457
  const activeMemories = memories.filter(
8987
9458
  (m) => {
8988
9459
  if (isArtifactMemoryPath(m.path)) return false;
8989
9460
  const status = m.frontmatter.status;
8990
9461
  if (!status || status === "active") return true;
8991
9462
  if (status === "superseded") {
9463
+ if (asOfActive) return true;
8992
9464
  return !shouldFilterSupersededFromRecall(m.frontmatter, supersessionOptions);
8993
9465
  }
8994
9466
  return false;
@@ -9005,7 +9477,9 @@ ${tmtNode.summary}`
9005
9477
  recallMode,
9006
9478
  queryAwarePrefilter,
9007
9479
  abortSignal: options.abortSignal,
9008
- xrayPoolSizeSink: xrayColdPoolSink
9480
+ xrayPoolSizeSink: xrayColdPoolSink,
9481
+ asOfMs,
9482
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
9009
9483
  });
9010
9484
  if (longTerm.length > 0) {
9011
9485
  recallSource = "cold_fallback";
@@ -9024,6 +9498,7 @@ ${tmtNode.summary}`
9024
9498
  });
9025
9499
  recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
9026
9500
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
9501
+ xrayRecalledResults = longTerm;
9027
9502
  impressionRecorded = true;
9028
9503
  }
9029
9504
  } else {
@@ -9045,7 +9520,8 @@ ${tmtNode.summary}`
9045
9520
  recentAsResults,
9046
9521
  recallNamespaces,
9047
9522
  retrievalQuery,
9048
- preloadedMap
9523
+ preloadedMap,
9524
+ { asOfMs }
9049
9525
  )).sort((a, b) => b.score - a.score);
9050
9526
  xrayBranchPoolSize.recent_scan = Math.max(
9051
9527
  xrayBranchPoolSize.recent_scan,
@@ -9080,6 +9556,7 @@ ${tmtNode.summary}`
9080
9556
  });
9081
9557
  recalledMemoryIds = this.extractMemoryIdsFromResults(recent);
9082
9558
  recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
9559
+ xrayRecalledResults = recent;
9083
9560
  impressionRecorded = true;
9084
9561
  } else {
9085
9562
  const longTerm = await this.applyColdFallbackPipeline({
@@ -9089,7 +9566,9 @@ ${tmtNode.summary}`
9089
9566
  recallMode,
9090
9567
  queryAwarePrefilter,
9091
9568
  abortSignal: options.abortSignal,
9092
- xrayPoolSizeSink: xrayColdPoolSink
9569
+ xrayPoolSizeSink: xrayColdPoolSink,
9570
+ asOfMs,
9571
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
9093
9572
  });
9094
9573
  if (longTerm.length > 0) {
9095
9574
  if (shouldPersistGraphSnapshot) {
@@ -9114,6 +9593,7 @@ ${tmtNode.summary}`
9114
9593
  });
9115
9594
  recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
9116
9595
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
9596
+ xrayRecalledResults = longTerm;
9117
9597
  impressionRecorded = true;
9118
9598
  }
9119
9599
  }
@@ -9126,7 +9606,9 @@ ${tmtNode.summary}`
9126
9606
  recallMode,
9127
9607
  queryAwarePrefilter,
9128
9608
  abortSignal: options.abortSignal,
9129
- xrayPoolSizeSink: xrayColdPoolSink
9609
+ xrayPoolSizeSink: xrayColdPoolSink,
9610
+ asOfMs,
9611
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
9130
9612
  });
9131
9613
  if (longTerm.length > 0) {
9132
9614
  if (shouldPersistGraphSnapshot) {
@@ -9151,6 +9633,7 @@ ${tmtNode.summary}`
9151
9633
  });
9152
9634
  recalledMemoryIds = this.extractMemoryIdsFromResults(longTerm);
9153
9635
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
9636
+ xrayRecalledResults = longTerm;
9154
9637
  impressionRecorded = true;
9155
9638
  }
9156
9639
  }
@@ -9311,15 +9794,25 @@ _Context: ${topQuestion.context}_`
9311
9794
  const match = p.match(/([^/]+)\.md$/);
9312
9795
  return match ? match[1] ?? null : null;
9313
9796
  };
9797
+ const xrayResultByPath = new Map(
9798
+ xrayRecalledResults.map((xr) => [xr.path, xr])
9799
+ );
9314
9800
  const results = [];
9315
9801
  for (const recalledPath of recalledMemoryPaths) {
9316
9802
  const derivedId = idFromPath(recalledPath);
9317
9803
  if (!derivedId) continue;
9804
+ const xrayResult = xrayResultByPath.get(recalledPath);
9805
+ const scoreDecomposition = {
9806
+ final: xrayResult?.score ?? 0
9807
+ };
9808
+ if (xrayResult?.explain?.reinforcementBoost !== void 0 && xrayResult.explain.reinforcementBoost > 0) {
9809
+ scoreDecomposition.reinforcementBoost = xrayResult.explain.reinforcementBoost;
9810
+ }
9318
9811
  results.push({
9319
9812
  memoryId: derivedId,
9320
9813
  path: recalledPath,
9321
9814
  servedBy,
9322
- scoreDecomposition: { final: 0 },
9815
+ scoreDecomposition,
9323
9816
  admittedBy: []
9324
9817
  });
9325
9818
  }
@@ -9365,7 +9858,14 @@ _Context: ${topQuestion.context}_`
9365
9858
  },
9366
9859
  sessionKey,
9367
9860
  namespace: selfNamespace,
9368
- traceId
9861
+ traceId,
9862
+ // Issue #679 completion: record peer-profile injection in the
9863
+ // xray snapshot. peerProfileXrayAnnotation is set inside
9864
+ // peerProfileRecallPromise when injection actually occurred,
9865
+ // and stays null otherwise. By the time xray capture runs,
9866
+ // phase-1 parallel work is complete so the annotation is
9867
+ // guaranteed to be populated.
9868
+ peerProfileInjection: peerProfileXrayAnnotation
9369
9869
  });
9370
9870
  } catch (err) {
9371
9871
  log.debug(`x-ray capture failed: ${err}`);
@@ -10093,7 +10593,7 @@ ${normalized}`).digest("hex");
10093
10593
  );
10094
10594
  this.tierMigrationInFlight = true;
10095
10595
  try {
10096
- const coldStorage = new StorageManager(path7.join(storage.dir, "cold"));
10596
+ const coldStorage = new StorageManager(path6.join(storage.dir, "cold"));
10097
10597
  const [hotMemories, coldMemories] = await Promise.all([
10098
10598
  storage.readAllMemories(),
10099
10599
  coldStorage.readAllMemories()
@@ -10659,6 +11159,7 @@ ${normalized}`).digest("hex");
10659
11159
  let writeCategory = fact.category;
10660
11160
  let targetStorage = storage;
10661
11161
  let routedRuleId;
11162
+ let routedNamespaceExplicit = false;
10662
11163
  if (routeRules.length > 0) {
10663
11164
  try {
10664
11165
  const routeText = `${fact.category} ${fact.tags.join(" ")} ${fact.content}`;
@@ -10669,6 +11170,7 @@ ${normalized}`).digest("hex");
10669
11170
  writeCategory = selected.target.category;
10670
11171
  }
10671
11172
  if (selected.target.namespace) {
11173
+ routedNamespaceExplicit = true;
10672
11174
  targetStorage = await this.storageRouter.storageFor(
10673
11175
  selected.target.namespace
10674
11176
  );
@@ -10680,6 +11182,23 @@ ${normalized}`).digest("hex");
10680
11182
  );
10681
11183
  }
10682
11184
  }
11185
+ if (this.config.extractionScopeClassificationEnabled && this.config.namespacesEnabled && fact.scope === "global" && !routedNamespaceExplicit) {
11186
+ const currentNs = this.namespaceFromStorageDir(targetStorage.dir);
11187
+ if (currentNs !== this.config.sharedNamespace) {
11188
+ try {
11189
+ targetStorage = await this.storageRouter.storageFor(
11190
+ this.config.sharedNamespace
11191
+ );
11192
+ log.debug(
11193
+ `scope-routing: fact "${fact.content.slice(0, 60)}\u2026" routed to shared namespace (scope=global)`
11194
+ );
11195
+ } catch (scopeRouteErr) {
11196
+ log.warn(
11197
+ `scope-routing: failed to resolve shared namespace storage; writing to session namespace (fail-open): ${scopeRouteErr}`
11198
+ );
11199
+ }
11200
+ }
11201
+ }
10683
11202
  const canonicalContentForHash = citationEnabled && hasCitationForTemplate(fact.content, citationTemplate) ? stripCitationForTemplate(fact.content, citationTemplate) : fact.content;
10684
11203
  const contentHashDedupKey = writeCategory === "procedure" ? buildProcedurePersistBody(fact.content, fact.procedureSteps) : canonicalContentForHash;
10685
11204
  if (this.contentHashIndex && this.contentHashIndex.has(contentHashDedupKey)) {
@@ -11266,7 +11785,7 @@ ${normalized}`).digest("hex");
11266
11785
  const allMems = allMemsForGraph ?? [];
11267
11786
  for (const m of allMems) {
11268
11787
  if (m.frontmatter.entityRef === entityRef) {
11269
- const rel = path7.relative(storage.dir, m.path);
11788
+ const rel = path6.relative(storage.dir, m.path);
11270
11789
  if (rel !== memoryRelPath) entitySiblings.push(rel);
11271
11790
  }
11272
11791
  }
@@ -11333,8 +11852,7 @@ ${normalized}`).digest("hex");
11333
11852
  ])
11334
11853
  )
11335
11854
  ) : await storage.readAllMemories();
11336
- const isActive = (m) => !m.frontmatter.status || m.frontmatter.status === "active";
11337
- const pool = needsFullRebuild ? allMemories.filter(isActive) : (() => {
11855
+ const pool = needsFullRebuild ? allMemories.filter((m) => isActiveMemoryStatus(m.frontmatter.status)) : (() => {
11338
11856
  const idSet = new Set(persistedIds);
11339
11857
  return allMemories.filter((m) => idSet.has(m.frontmatter.id));
11340
11858
  })();
@@ -11520,24 +12038,54 @@ ${normalized}`).digest("hex");
11520
12038
  }
11521
12039
  if (this.config.lifecyclePolicyEnabled) {
11522
12040
  try {
12041
+ const lightSleepStartedAt = (/* @__PURE__ */ new Date()).toISOString();
11523
12042
  const lifecycleCorpus = await this.storage.readAllMemories();
11524
12043
  await this.runLifecyclePolicyPass(lifecycleCorpus);
12044
+ await this.recordScheduledDreamsPhaseRun(
12045
+ "lightSleep",
12046
+ lifecycleCorpus.length,
12047
+ `scheduled lifecycle policy pass assessed ${lifecycleCorpus.length} memories`,
12048
+ {
12049
+ startedAt: lightSleepStartedAt,
12050
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
12051
+ }
12052
+ );
11525
12053
  } catch (err) {
11526
12054
  log.warn(`lifecycle policy pass failed (ignored): ${err}`);
11527
12055
  }
11528
12056
  }
11529
12057
  await this.runCompressionGuidelineLearningPass();
11530
- await this.runTierMigrationCycle(this.storage, "maintenance");
11531
- allMemories = await this.storage.readAllMemories();
11532
- if (this.config.factArchivalEnabled) {
11533
- const archived = await this.runFactArchival(allMemories);
11534
- if (archived > 0) {
11535
- log.info(`archived ${archived} old low-importance facts`);
12058
+ try {
12059
+ const deepSleepStartedAt = (/* @__PURE__ */ new Date()).toISOString();
12060
+ await this.runTierMigrationCycle(this.storage, "maintenance");
12061
+ allMemories = await this.storage.readAllMemories();
12062
+ if (this.config.factArchivalEnabled) {
12063
+ const archived = await this.runFactArchival(allMemories);
12064
+ if (archived > 0) {
12065
+ log.info(`archived ${archived} old low-importance facts`);
12066
+ }
12067
+ }
12068
+ await this.recordScheduledDreamsPhaseRun(
12069
+ "deepSleep",
12070
+ allMemories.length,
12071
+ `scheduled deep-sleep maintenance assessed ${allMemories.length} memories`,
12072
+ {
12073
+ startedAt: deepSleepStartedAt,
12074
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
12075
+ }
12076
+ );
12077
+ } catch (err) {
12078
+ log.warn(`deep-sleep maintenance pass failed (ignored): ${err}`);
12079
+ try {
12080
+ allMemories = await this.storage.readAllMemories();
12081
+ } catch (readErr) {
12082
+ log.warn(`deep-sleep maintenance recovery read failed: ${readErr}`);
12083
+ throw err;
11536
12084
  }
11537
12085
  }
11538
12086
  if (this.config.semanticConsolidationEnabled) {
11539
12087
  try {
11540
- const stateFilePath = path7.join(
12088
+ const stateFilePath = path6.join(
11541
12089
  this.config.memoryDir,
11542
12090
  "state",
11543
12091
  "semantic-consolidation-last-run.json"
@@ -11559,15 +12107,33 @@ ${normalized}`).digest("hex");
11559
12107
  } catch {
11560
12108
  }
11561
12109
  if (shouldRun) {
12110
+ const remStartedAt = (/* @__PURE__ */ new Date()).toISOString();
11562
12111
  const semResult = await this.runSemanticConsolidation();
12112
+ let remItemsProcessed = allMemories.length;
12113
+ try {
12114
+ allMemories = await this.storage.readAllMemories();
12115
+ remItemsProcessed = allMemories.length;
12116
+ } catch (err) {
12117
+ log.warn(
12118
+ `[semantic-consolidation] post-run telemetry refresh failed (non-fatal): ${err}`
12119
+ );
12120
+ }
12121
+ await this.recordScheduledDreamsPhaseRun(
12122
+ "rem",
12123
+ remItemsProcessed,
12124
+ `scheduled REM consolidation found ${semResult.clustersFound} clusters`,
12125
+ {
12126
+ startedAt: remStartedAt,
12127
+ completedAt: (/* @__PURE__ */ new Date()).toISOString()
12128
+ }
12129
+ );
11563
12130
  if (semResult.memoriesArchived > 0) {
11564
12131
  log.info(
11565
12132
  `[semantic-consolidation] archived ${semResult.memoriesArchived} memories during maintenance`
11566
12133
  );
11567
- allMemories = await this.storage.readAllMemories();
11568
12134
  }
11569
12135
  if (semResult.errors === 0 || semResult.memoriesArchived > 0) {
11570
- const stateDir = path7.join(this.config.memoryDir, "state");
12136
+ const stateDir = path6.join(this.config.memoryDir, "state");
11571
12137
  await mkdir5(stateDir, { recursive: true });
11572
12138
  await writeFile4(
11573
12139
  stateFilePath,
@@ -11618,7 +12184,7 @@ ${normalized}`).digest("hex");
11618
12184
  if (this.config.temporalMemoryTreeEnabled) {
11619
12185
  try {
11620
12186
  const tmtEntries = allMemories.filter(
11621
- (m) => m.frontmatter.status !== "superseded" && m.frontmatter.status !== "archived"
12187
+ (m) => m.frontmatter.status !== "superseded" && m.frontmatter.status !== "archived" && m.frontmatter.status !== "forgotten"
11622
12188
  ).map((m) => ({
11623
12189
  path: m.path,
11624
12190
  id: m.frontmatter.id,
@@ -11933,8 +12499,8 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
11933
12499
  return 0;
11934
12500
  }
11935
12501
  }
11936
- async buildLifecycleActionPriors() {
11937
- const events = await this.storage.readMemoryActionEvents(1200);
12502
+ async buildLifecycleActionPriors(storage = this.storage) {
12503
+ const events = await storage.readMemoryActionEvents(1200);
11938
12504
  if (events.length === 0) return /* @__PURE__ */ new Map();
11939
12505
  const nowMs = Date.now();
11940
12506
  const windowMs = 14 * 24 * 60 * 60 * 1e3;
@@ -11971,7 +12537,28 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
11971
12537
  }
11972
12538
  return out;
11973
12539
  }
11974
- async runLifecyclePolicyPass(allMemories) {
12540
+ async recordScheduledDreamsPhaseRun(phase, itemsProcessed, notes, timing = {}) {
12541
+ try {
12542
+ const { recordDreamsPhaseRun } = await import("./dreams-ledger-LR2NBAZE.js");
12543
+ await recordDreamsPhaseRun({
12544
+ memoryDir: this.storage.dir,
12545
+ phase,
12546
+ trigger: "scheduled",
12547
+ itemsProcessed,
12548
+ notes,
12549
+ startedAt: timing.startedAt,
12550
+ completedAt: timing.completedAt
12551
+ });
12552
+ } catch (error) {
12553
+ log.debug(`dreams ledger scheduled ${phase} write failed (non-fatal): ${error}`);
12554
+ }
12555
+ }
12556
+ async runLifecyclePolicyNow(storage = this.storage) {
12557
+ const lifecycleCorpus = await storage.readAllMemories();
12558
+ await this.runLifecyclePolicyPass(lifecycleCorpus, storage);
12559
+ return { memoriesAssessed: lifecycleCorpus.length };
12560
+ }
12561
+ async runLifecyclePolicyPass(allMemories, storage = this.storage) {
11975
12562
  const now = /* @__PURE__ */ new Date();
11976
12563
  const nowIso = now.toISOString();
11977
12564
  const countsByState = {
@@ -11992,9 +12579,9 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
11992
12579
  archiveDecayThreshold: thresholds.archiveDecayThreshold,
11993
12580
  protectedCategories: this.config.lifecycleProtectedCategories
11994
12581
  };
11995
- const actionPriors = await this.buildLifecycleActionPriors();
12582
+ const actionPriors = await this.buildLifecycleActionPriors(storage);
11996
12583
  for (const memory of allMemories) {
11997
- if (memory.frontmatter.status === "superseded") {
12584
+ if (memory.frontmatter.status === "superseded" || memory.frontmatter.status === "forgotten") {
11998
12585
  continue;
11999
12586
  }
12000
12587
  evaluatedCount += 1;
@@ -12016,7 +12603,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
12016
12603
  const scoreDelta = Math.abs((prevHeat ?? -1) - decision.heatScore) + Math.abs((prevDecay ?? -1) - decision.decayScore);
12017
12604
  const shouldPersist = memory.frontmatter.lifecycleState !== nextState || memory.frontmatter.heatScore === void 0 || memory.frontmatter.decayScore === void 0 || memory.frontmatter.lastValidatedAt === void 0 || scoreDelta >= 0.01;
12018
12605
  if (!shouldPersist) continue;
12019
- const wrote = await this.storage.writeMemoryFrontmatter(memory, {
12606
+ const wrote = await storage.writeMemoryFrontmatter(memory, {
12020
12607
  lifecycleState: nextState,
12021
12608
  heatScore: decision.heatScore,
12022
12609
  decayScore: decision.decayScore,
@@ -12041,12 +12628,12 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
12041
12628
  protectedCategories: this.config.lifecycleProtectedCategories
12042
12629
  }
12043
12630
  };
12044
- const metricsPath = path7.join(
12045
- this.storage.dir,
12631
+ const metricsPath = path6.join(
12632
+ storage.dir,
12046
12633
  "state",
12047
12634
  "lifecycle-metrics.json"
12048
12635
  );
12049
- await mkdir5(path7.dirname(metricsPath), { recursive: true });
12636
+ await mkdir5(path6.dirname(metricsPath), { recursive: true });
12050
12637
  await writeFile4(metricsPath, JSON.stringify(metrics, null, 2), "utf-8");
12051
12638
  }
12052
12639
  /**
@@ -12108,7 +12695,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
12108
12695
  */
12109
12696
  async runSummarization(allMemories) {
12110
12697
  const activeMemories = allMemories.filter(
12111
- (m) => !m.frontmatter.status || m.frontmatter.status === "active"
12698
+ (m) => isActiveMemoryStatus(m.frontmatter.status)
12112
12699
  );
12113
12700
  if (activeMemories.length < this.config.summarizationTriggerCount) {
12114
12701
  return;
@@ -12173,7 +12760,7 @@ ${texts.map((t, i) => `[${i + 1}] ${t}`).join("\n\n")}`;
12173
12760
  */
12174
12761
  async runTopicExtraction(allMemories) {
12175
12762
  const activeMemories = allMemories.filter(
12176
- (m) => !m.frontmatter.status || m.frontmatter.status === "active"
12763
+ (m) => isActiveMemoryStatus(m.frontmatter.status)
12177
12764
  );
12178
12765
  if (activeMemories.length === 0) return;
12179
12766
  const topics = extractTopics(
@@ -12573,7 +13160,7 @@ ${lines.join("\n\n")}`;
12573
13160
  nsMap = buildMemoryWorthCounterMap(memories);
12574
13161
  this.memoryWorthCounterCache.set(ns, { at: nowMs, counters: nsMap });
12575
13162
  }
12576
- for (const [path8, c] of nsMap) counters.set(path8, c);
13163
+ for (const [path7, c] of nsMap) counters.set(path7, c);
12577
13164
  } catch (err) {
12578
13165
  log.debug("memory-worth: failed to read namespace, skipping", {
12579
13166
  namespace: ns,
@@ -12744,12 +13331,12 @@ ${lines.join("\n\n")}`;
12744
13331
  */
12745
13332
  semanticDedupScopeFor(targetStorage) {
12746
13333
  if (!this.config.namespacesEnabled) return {};
12747
- const memoryDir = path7.resolve(this.config.memoryDir);
12748
- const storageDir = path7.resolve(targetStorage.dir);
13334
+ const memoryDir = path6.resolve(this.config.memoryDir);
13335
+ const storageDir = path6.resolve(targetStorage.dir);
12749
13336
  if (storageDir === memoryDir) {
12750
13337
  return { pathExcludePrefixes: ["namespaces/"] };
12751
13338
  }
12752
- let rel = path7.relative(memoryDir, storageDir);
13339
+ let rel = path6.relative(memoryDir, storageDir);
12753
13340
  if (!rel || rel.startsWith("..")) {
12754
13341
  log.debug(
12755
13342
  `semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
@@ -12768,7 +13355,7 @@ ${lines.join("\n\n")}`;
12768
13355
  if (hits.length === 0) return [];
12769
13356
  const results = [];
12770
13357
  for (const hit of hits) {
12771
- const fullPath = path7.isAbsolute(hit.path) ? hit.path : path7.join(this.config.memoryDir, hit.path);
13358
+ const fullPath = path6.isAbsolute(hit.path) ? hit.path : path6.join(this.config.memoryDir, hit.path);
12772
13359
  const memory = await this.storage.readMemoryByPath(fullPath);
12773
13360
  if (!memory) continue;
12774
13361
  results.push({
@@ -12900,7 +13487,8 @@ ${lines.join("\n\n")}`;
12900
13487
  const { merged } = await this.expandResultsViaGraph({
12901
13488
  memoryResults: results,
12902
13489
  recallNamespaces: options.recallNamespaces,
12903
- recallResultLimit: options.recallResultLimit
13490
+ recallResultLimit: options.recallResultLimit,
13491
+ ...options.includeLowConfidence === true ? { includeLowConfidence: true } : {}
12904
13492
  });
12905
13493
  results = merged;
12906
13494
  }
@@ -12909,7 +13497,7 @@ ${lines.join("\n\n")}`;
12909
13497
  options.recallNamespaces,
12910
13498
  options.prompt,
12911
13499
  void 0,
12912
- { allowLifecycleFiltered: true }
13500
+ { allowLifecycleFiltered: true, asOfMs: options.asOfMs }
12913
13501
  );
12914
13502
  if (this.config.rerankEnabled && this.config.rerankProvider === "local") {
12915
13503
  const ranked = await rerankLocalOrNoop({
@@ -13083,12 +13671,17 @@ ${lines.join("\n\n")}`;
13083
13671
  let lifecycleFilteredCount = 0;
13084
13672
  let temporalSupersededFilteredCount = 0;
13085
13673
  let dedicatedSurfaceFilteredCount = 0;
13674
+ let forgottenFilteredCount = 0;
13086
13675
  const boosted = [];
13087
13676
  const recencyWeight = this.effectiveRecencyWeight();
13088
13677
  for (const r of results) {
13089
13678
  const memory = memoryByPath.get(r.path);
13090
13679
  let score = r.score;
13091
13680
  if (memory) {
13681
+ if (memory.frontmatter.status === "forgotten") {
13682
+ forgottenFilteredCount += 1;
13683
+ continue;
13684
+ }
13092
13685
  if (options?.allowLifecycleFiltered !== true && shouldFilterLifecycleRecallCandidate(memory.frontmatter, {
13093
13686
  lifecyclePolicyEnabled: this.config.lifecyclePolicyEnabled,
13094
13687
  lifecycleFilterStaleEnabled: this.config.lifecycleFilterStaleEnabled
@@ -13096,10 +13689,28 @@ ${lines.join("\n\n")}`;
13096
13689
  lifecycleFilteredCount += 1;
13097
13690
  continue;
13098
13691
  }
13099
- if (shouldFilterSupersededFromRecall(memory.frontmatter, {
13100
- enabled: this.config.temporalSupersessionEnabled,
13101
- includeInRecall: this.config.temporalSupersessionIncludeInRecall
13102
- })) {
13692
+ const asOfActive = typeof options?.asOfMs === "number" && Number.isFinite(options.asOfMs);
13693
+ if (asOfActive) {
13694
+ if (!isValidAsOf(memory.frontmatter, options.asOfMs)) {
13695
+ temporalSupersededFilteredCount += 1;
13696
+ continue;
13697
+ }
13698
+ } else if (
13699
+ // Temporal supersession filter (issue #375): drop memories that
13700
+ // a newer fact has retired, unless the caller opted in to history.
13701
+ // NOTE: This check is intentionally independent of
13702
+ // allowLifecycleFiltered (Finding A fix) — cold fallback sets
13703
+ // allowLifecycleFiltered=true to include archived/retired
13704
+ // candidates, but superseded memories must still be filtered
13705
+ // unless temporalSupersessionIncludeInRecall is set.
13706
+ // Skipped entirely when `as_of` is active (above branch); the
13707
+ // half-open `[valid_at, invalid_at)` evaluation in isValidAsOf
13708
+ // is the authoritative gate for historical recall.
13709
+ shouldFilterSupersededFromRecall(memory.frontmatter, {
13710
+ enabled: this.config.temporalSupersessionEnabled,
13711
+ includeInRecall: this.config.temporalSupersessionIncludeInRecall
13712
+ })
13713
+ ) {
13103
13714
  temporalSupersededFilteredCount += 1;
13104
13715
  continue;
13105
13716
  }
@@ -13198,6 +13809,22 @@ ${lines.join("\n\n")}`;
13198
13809
  this.utilityRuntimeValues,
13199
13810
  lifecycleDelta >= 0 ? "boost" : "suppress"
13200
13811
  );
13812
+ let reinforcementBoost = 0;
13813
+ if (this.config.reinforcementRecallBoostEnabled && typeof memory.frontmatter.reinforcement_count === "number" && memory.frontmatter.reinforcement_count > 0) {
13814
+ reinforcementBoost = Math.min(
13815
+ memory.frontmatter.reinforcement_count * this.config.reinforcementRecallBoostWeight,
13816
+ this.config.reinforcementRecallBoostMax
13817
+ );
13818
+ score += reinforcementBoost;
13819
+ }
13820
+ if (reinforcementBoost > 0) {
13821
+ boosted.push({
13822
+ ...r,
13823
+ score,
13824
+ explain: { ...r.explain ?? {}, reinforcementBoost }
13825
+ });
13826
+ continue;
13827
+ }
13201
13828
  }
13202
13829
  boosted.push({ ...r, score });
13203
13830
  }
@@ -13216,6 +13843,11 @@ ${lines.join("\n\n")}`;
13216
13843
  `dedicated surface filter removed ${dedicatedSurfaceFilteredCount} dream/procedural candidates from generic recall`
13217
13844
  );
13218
13845
  }
13846
+ if (forgottenFilteredCount > 0) {
13847
+ log.debug(
13848
+ `forgotten status filter removed ${forgottenFilteredCount} candidates from recall`
13849
+ );
13850
+ }
13219
13851
  return boosted.sort((a, b) => b.score - a.score);
13220
13852
  }
13221
13853
  /**
@@ -13266,7 +13898,9 @@ ${lines.join("\n\n")}`;
13266
13898
  const resultStorage = await this.storageRouter.storageFor(resultNamespace);
13267
13899
  const existingMemory = await resultStorage.getMemoryById(memoryId);
13268
13900
  if (!existingMemory) continue;
13269
- if (existingMemory.frontmatter.status === "superseded") continue;
13901
+ if (existingMemory.frontmatter.status === "superseded" || existingMemory.frontmatter.status === "forgotten") {
13902
+ continue;
13903
+ }
13270
13904
  const verification = await this.extraction.verifyContradiction(
13271
13905
  { content, category },
13272
13906
  {
@@ -13330,7 +13964,7 @@ ${lines.join("\n\n")}`;
13330
13964
  if (resultNamespace !== namespaceScope) continue;
13331
13965
  const resultStorage = await this.storageRouter.storageFor(resultNamespace);
13332
13966
  const memory = await resultStorage.getMemoryById(memoryId);
13333
- if (memory && memory.frontmatter.status !== "superseded") {
13967
+ if (memory && memory.frontmatter.status !== "superseded" && memory.frontmatter.status !== "forgotten") {
13334
13968
  candidates.push({
13335
13969
  id: memory.frontmatter.id,
13336
13970
  content: memory.content,
@@ -13358,8 +13992,8 @@ ${lines.join("\n\n")}`;
13358
13992
  }
13359
13993
  namespaceFromStorageDir(storageDir) {
13360
13994
  if (!this.config.namespacesEnabled) return this.config.defaultNamespace;
13361
- const resolvedStorageDir = path7.resolve(storageDir);
13362
- const resolvedMemoryDir = path7.resolve(this.config.memoryDir);
13995
+ const resolvedStorageDir = path6.resolve(storageDir);
13996
+ const resolvedMemoryDir = path6.resolve(this.config.memoryDir);
13363
13997
  if (resolvedStorageDir === resolvedMemoryDir)
13364
13998
  return this.config.defaultNamespace;
13365
13999
  const m = resolvedStorageDir.match(/[\\/]namespaces[\\/]([^\\/]+)$/);
@@ -13400,9 +14034,6 @@ export {
13400
14034
  saveTaxonomy,
13401
14035
  getTaxonomyDir,
13402
14036
  getTaxonomyFilePath,
13403
- stableHash,
13404
- normalizeOriginUrl,
13405
- resolveGitContext,
13406
14037
  projectNamespaceName,
13407
14038
  branchNamespaceName,
13408
14039
  resolveCodingNamespaceOverlay,
@@ -13435,4 +14066,4 @@ export {
13435
14066
  resolvePersistedMemoryRelativePath,
13436
14067
  Orchestrator
13437
14068
  };
13438
- //# sourceMappingURL=chunk-3YGHKTBF.js.map
14069
+ //# sourceMappingURL=chunk-IM3JSE73.js.map