@remnic/core 9.48.1 → 9.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (616) hide show
  1. package/dist/abstraction-nodes.d.ts +12 -1
  2. package/dist/abstraction-nodes.js +9 -2
  3. package/dist/access-admin-ops-surface.d.ts +11 -10
  4. package/dist/access-admin-ops-surface.js +46 -45
  5. package/dist/access-audit.js +2 -2
  6. package/dist/access-authorization-probe.d.ts +11 -10
  7. package/dist/access-authorization-probe.js +47 -46
  8. package/dist/access-boundary.d.ts +11 -10
  9. package/dist/access-boundary.js +46 -45
  10. package/dist/access-cli.js +127 -121
  11. package/dist/access-cli.js.map +1 -1
  12. package/dist/access-coding-context-resolution.d.ts +1 -1
  13. package/dist/access-extraction-force-flush.d.ts +11 -10
  14. package/dist/access-extraction-force-flush.js +46 -45
  15. package/dist/access-health-types.d.ts +1 -1
  16. package/dist/access-http-lcm-compaction.d.ts +11 -10
  17. package/dist/access-http-lifecycle-flush.d.ts +11 -10
  18. package/dist/access-http-offline-stream.d.ts +11 -10
  19. package/dist/access-http-query.js +46 -45
  20. package/dist/access-http.d.ts +11 -10
  21. package/dist/access-http.js +57 -56
  22. package/dist/access-identity-continuity-surface.d.ts +9 -8
  23. package/dist/access-identity-continuity-surface.js +46 -45
  24. package/dist/access-lcm-surface.d.ts +11 -10
  25. package/dist/access-lcm-surface.js +46 -45
  26. package/dist/access-mcp.d.ts +11 -10
  27. package/dist/access-mcp.js +52 -51
  28. package/dist/access-memory-search-fanout.d.ts +2 -2
  29. package/dist/{access-namespace-preflight--H6HwN85.d.ts → access-namespace-preflight-DuDU301-.d.ts} +1 -1
  30. package/dist/access-namespace-preflight.d.ts +3 -3
  31. package/dist/access-namespace-preflight.js +46 -45
  32. package/dist/access-observe-write-surface.d.ts +11 -10
  33. package/dist/access-observe-write-surface.js +46 -45
  34. package/dist/access-offline-manifest.d.ts +9 -8
  35. package/dist/access-offline-manifest.js +3 -3
  36. package/dist/access-operations-batch.js +48 -47
  37. package/dist/access-operations.d.ts +14 -13
  38. package/dist/access-operations.js +51 -50
  39. package/dist/access-recall-concurrency.d.ts +11 -10
  40. package/dist/access-recall-concurrency.js +46 -45
  41. package/dist/access-recall-response.d.ts +11 -10
  42. package/dist/access-recall-response.js +46 -45
  43. package/dist/access-recall-surface.d.ts +11 -10
  44. package/dist/access-recall-surface.js +46 -45
  45. package/dist/access-schema.d.ts +105 -105
  46. package/dist/access-schema.js +3 -3
  47. package/dist/{access-service-andNjwfD.d.ts → access-service--_3T_v23.d.ts} +7 -7
  48. package/dist/access-service-helpers.d.ts +11 -10
  49. package/dist/access-service.d.ts +11 -10
  50. package/dist/access-service.js +46 -45
  51. package/dist/access-surface-catalog.d.ts +11 -10
  52. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  53. package/dist/action-confidence.d.ts +1 -1
  54. package/dist/active-memory-bridge.d.ts +1 -1
  55. package/dist/active-recall.d.ts +1 -1
  56. package/dist/active-recall.js +3 -2
  57. package/dist/active-recall.js.map +1 -1
  58. package/dist/adapters/index.js +4 -4
  59. package/dist/adapters/registry.js +2 -2
  60. package/dist/ambient-provenance.d.ts +1 -1
  61. package/dist/artifact-search.d.ts +1 -1
  62. package/dist/{auto-sync-7O6RP2RT.js → auto-sync-QFQGOEO2.js} +4 -4
  63. package/dist/behavior-learner.d.ts +1 -1
  64. package/dist/behavior-signals.d.ts +1 -1
  65. package/dist/bootstrap.d.ts +9 -8
  66. package/dist/briefing.d.ts +3 -2
  67. package/dist/briefing.js +15 -14
  68. package/dist/buffer-surprise-report.d.ts +1 -1
  69. package/dist/buffer-turn-helpers.d.ts +1 -1
  70. package/dist/buffer.d.ts +3 -2
  71. package/dist/buffer.js +4 -4
  72. package/dist/bulk-import/index.d.ts +3 -3
  73. package/dist/calibration.d.ts +1 -1
  74. package/dist/calibration.js +1 -1
  75. package/dist/capabilities.d.ts +1 -1
  76. package/dist/{capsule-merge-Q6AR3XL7.js → capsule-merge-KXTRZ23Z.js} +6 -6
  77. package/dist/{catalog-Iwbk9h5E.d.ts → catalog-DjUmUIal.d.ts} +1 -1
  78. package/dist/causal-behavior.d.ts +1 -1
  79. package/dist/causal-behavior.js +3 -3
  80. package/dist/causal-chain.js +3 -3
  81. package/dist/causal-consolidation.d.ts +1 -1
  82. package/dist/causal-consolidation.js +19 -18
  83. package/dist/causal-consolidation.js.map +1 -1
  84. package/dist/causal-retrieval.js +3 -3
  85. package/dist/causal-trajectory-graph.d.ts +1 -1
  86. package/dist/causal-trajectory.d.ts +51 -2
  87. package/dist/causal-trajectory.js +8 -2
  88. package/dist/{chunk-PLCZD3LG.js → chunk-24BKGKGO.js} +91 -45
  89. package/dist/chunk-24BKGKGO.js.map +1 -0
  90. package/dist/{chunk-ICP53SKG.js → chunk-2HIJHXB3.js} +2 -2
  91. package/dist/{chunk-LZGCJSQR.js → chunk-3LD4N2TF.js} +151 -37
  92. package/dist/chunk-3LD4N2TF.js.map +1 -0
  93. package/dist/{chunk-FJ2ND6CZ.js → chunk-47J4EDGR.js} +2 -2
  94. package/dist/{chunk-S55OAS5P.js → chunk-4EABKPZS.js} +4 -4
  95. package/dist/{chunk-GD7UPIBG.js → chunk-4JWJMRPJ.js} +2 -2
  96. package/dist/{chunk-3NDN5P55.js → chunk-4S3ECH3U.js} +2 -2
  97. package/dist/chunk-5GINB5LC.js +13 -0
  98. package/dist/chunk-5GINB5LC.js.map +1 -0
  99. package/dist/{chunk-CGASUJVP.js → chunk-5V6IXHPI.js} +4 -4
  100. package/dist/{chunk-A4JMGKCD.js → chunk-5XCN4XBU.js} +4 -4
  101. package/dist/{chunk-2RPJ4NEE.js → chunk-64BHFFKZ.js} +2 -2
  102. package/dist/{chunk-FQC3DHH2.js → chunk-66SE3BNH.js} +2 -2
  103. package/dist/{chunk-TERNBNJB.js → chunk-6FC3IZ26.js} +2 -2
  104. package/dist/{chunk-53AJILXF.js → chunk-6XGEBQ3R.js} +4 -4
  105. package/dist/{chunk-IP3DHDU2.js → chunk-7BLWBSRL.js} +3 -3
  106. package/dist/{chunk-A2TFK5PG.js → chunk-7NDM2PNK.js} +3 -3
  107. package/dist/{chunk-HRMEYQRO.js → chunk-7VWZ4LRW.js} +2 -2
  108. package/dist/{chunk-RN53QBM4.js → chunk-A4QMKFFO.js} +5 -1
  109. package/dist/chunk-A4QMKFFO.js.map +1 -0
  110. package/dist/chunk-ACPCA4NO.js +321 -0
  111. package/dist/chunk-ACPCA4NO.js.map +1 -0
  112. package/dist/chunk-AMTEYNYK.js +72 -0
  113. package/dist/chunk-AMTEYNYK.js.map +1 -0
  114. package/dist/{chunk-R6YJI3HE.js → chunk-AW4QUFQF.js} +1 -1
  115. package/dist/{chunk-P65YJEEL.js → chunk-AXFWMRKI.js} +2 -2
  116. package/dist/{chunk-WG5HSQ4P.js → chunk-BAKXNQ3C.js} +2 -2
  117. package/dist/{chunk-NM2WP3B7.js → chunk-BJYET5TX.js} +2 -2
  118. package/dist/{chunk-HLKPRWF4.js → chunk-DATDLJAO.js} +6 -6
  119. package/dist/chunk-DJUKBGAD.js +260 -0
  120. package/dist/chunk-DJUKBGAD.js.map +1 -0
  121. package/dist/{chunk-DX3XRGLH.js → chunk-DQTCGVFK.js} +2 -2
  122. package/dist/{chunk-HIDEBEAN.js → chunk-E633OXMH.js} +11 -11
  123. package/dist/{chunk-J7T4MX7P.js → chunk-EEAMSNSG.js} +12 -1
  124. package/dist/chunk-EEAMSNSG.js.map +1 -0
  125. package/dist/{chunk-EZNXW27Q.js → chunk-ELQCS47S.js} +4 -4
  126. package/dist/{chunk-HAYSYUAB.js → chunk-EURCX6PS.js} +2 -2
  127. package/dist/{chunk-RSPSHRZA.js → chunk-FV7YQTN3.js} +2 -2
  128. package/dist/chunk-G73MCJKL.js +20 -0
  129. package/dist/chunk-G73MCJKL.js.map +1 -0
  130. package/dist/{chunk-GWHPQOUC.js → chunk-GGBSF2X7.js} +2 -2
  131. package/dist/{chunk-SYUBB3WM.js → chunk-GKEYXXKX.js} +2 -2
  132. package/dist/{chunk-PELT6ADC.js → chunk-GSEPRIZC.js} +3 -3
  133. package/dist/{chunk-UTVZKHJK.js → chunk-GUKBW4HL.js} +2 -2
  134. package/dist/chunk-GXSOUIA4.js +293 -0
  135. package/dist/chunk-GXSOUIA4.js.map +1 -0
  136. package/dist/{chunk-2F6NP3NT.js → chunk-HDQUQBPW.js} +2 -2
  137. package/dist/{chunk-6HMYUWXR.js → chunk-HTP6XRUI.js} +2 -2
  138. package/dist/{chunk-UYUYZ4WY.js → chunk-IARXXZU4.js} +2 -2
  139. package/dist/{chunk-MNB5RMAY.js → chunk-IIFFC3RL.js} +2 -2
  140. package/dist/{chunk-KQAFEZQX.js → chunk-IPLYGWQF.js} +5 -5
  141. package/dist/{chunk-NZBZ7IS2.js → chunk-JDCQK3C5.js} +2 -2
  142. package/dist/{chunk-ANCC3JJH.js → chunk-JI62YGPI.js} +2 -2
  143. package/dist/{chunk-LULR4IUW.js → chunk-KATEWTQJ.js} +2 -2
  144. package/dist/{chunk-IJ7HK452.js → chunk-KMAP7SNQ.js} +2 -2
  145. package/dist/{chunk-PRVJH7CY.js → chunk-KMWYZTIE.js} +2 -2
  146. package/dist/{chunk-JGSKJHF7.js → chunk-KQS72GCR.js} +2 -2
  147. package/dist/{chunk-3S63QIFQ.js → chunk-LAQ33B5D.js} +1 -1
  148. package/dist/chunk-LAQ33B5D.js.map +1 -0
  149. package/dist/chunk-LNTUXKBT.js +224 -0
  150. package/dist/chunk-LNTUXKBT.js.map +1 -0
  151. package/dist/{chunk-FMCHFSZF.js → chunk-LQKXVQZR.js} +12 -12
  152. package/dist/{chunk-M4DMO67I.js → chunk-LTOAJXZB.js} +4 -4
  153. package/dist/{chunk-NIS256NW.js → chunk-LYMNZZIM.js} +2 -2
  154. package/dist/{chunk-W4FBGYGK.js → chunk-M4MP34AQ.js} +189 -5
  155. package/dist/chunk-M4MP34AQ.js.map +1 -0
  156. package/dist/{chunk-3PY7VHV7.js → chunk-MCA2X4WH.js} +2 -2
  157. package/dist/{chunk-S5NZBKKQ.js → chunk-N3CXAYPJ.js} +3 -3
  158. package/dist/{chunk-WQIHRA5F.js → chunk-N3LL5NEU.js} +2 -2
  159. package/dist/{chunk-G2RBWVFQ.js → chunk-NKL25FCF.js} +2 -2
  160. package/dist/{chunk-LMDRGRJ2.js → chunk-NOB2T2FC.js} +2 -2
  161. package/dist/{chunk-P2OTGMTR.js → chunk-NSGU76YO.js} +2 -2
  162. package/dist/{chunk-D5NGH2EW.js → chunk-O76MWTVS.js} +2 -2
  163. package/dist/{chunk-WZFAPHIK.js → chunk-OIOZ6MOP.js} +3 -3
  164. package/dist/{chunk-DNHVPZOD.js → chunk-P26YHAQH.js} +201 -1
  165. package/dist/chunk-P26YHAQH.js.map +1 -0
  166. package/dist/{chunk-UMOO7IY7.js → chunk-P2KBDJJ6.js} +2 -2
  167. package/dist/{chunk-KVJRXN2E.js → chunk-P4QOYG52.js} +125 -13
  168. package/dist/chunk-P4QOYG52.js.map +1 -0
  169. package/dist/chunk-P77QX3ID.js +332 -0
  170. package/dist/chunk-P77QX3ID.js.map +1 -0
  171. package/dist/{chunk-SXWHN7GC.js → chunk-PDEKQWDV.js} +2 -2
  172. package/dist/{chunk-2EJNXE53.js → chunk-PLCHU56K.js} +3 -3
  173. package/dist/{chunk-45OTV7FZ.js → chunk-PWIMF7LP.js} +38 -38
  174. package/dist/{chunk-7YKVM5H3.js → chunk-PWLB4TRK.js} +3 -3
  175. package/dist/{chunk-RVYVMQK4.js → chunk-QSYL5CXK.js} +3 -3
  176. package/dist/{chunk-NXUJRXSF.js → chunk-QWLW3VQH.js} +2 -2
  177. package/dist/chunk-RBOJCG4T.js +77 -0
  178. package/dist/chunk-RBOJCG4T.js.map +1 -0
  179. package/dist/{chunk-2P3GQVM2.js → chunk-RBPH3GZV.js} +418 -105
  180. package/dist/chunk-RBPH3GZV.js.map +1 -0
  181. package/dist/{chunk-JBPKEARU.js → chunk-RKNJBZ55.js} +4 -4
  182. package/dist/{chunk-QCECHYZL.js → chunk-RVO6TCTU.js} +6 -6
  183. package/dist/{chunk-5L7PTX2Q.js → chunk-S2SJEOTM.js} +2 -2
  184. package/dist/{chunk-52I3YZZ6.js → chunk-S75UQ3T3.js} +3 -3
  185. package/dist/{chunk-LXOM6IQU.js → chunk-SEF4IOFE.js} +2 -2
  186. package/dist/{chunk-DUEEQCTT.js → chunk-SHYIMIX5.js} +2 -2
  187. package/dist/{chunk-KSGEGHYA.js → chunk-T35UJI5R.js} +78 -74
  188. package/dist/chunk-T35UJI5R.js.map +1 -0
  189. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  190. package/dist/{chunk-3JUYWPFJ.js → chunk-VFS3MK5F.js} +2 -2
  191. package/dist/chunk-VUDMT5CP.js +86 -0
  192. package/dist/chunk-VUDMT5CP.js.map +1 -0
  193. package/dist/{chunk-CMQZNEIF.js → chunk-WFLBP5GC.js} +8 -1
  194. package/dist/chunk-WFLBP5GC.js.map +1 -0
  195. package/dist/{chunk-WOEVJKKQ.js → chunk-WPZX7MEA.js} +4 -4
  196. package/dist/{chunk-ZRWB5D4H.js → chunk-WT6UL3UA.js} +2 -2
  197. package/dist/{chunk-MC6XO7T4.js → chunk-YLBE6PLR.js} +2 -2
  198. package/dist/{chunk-GF22HWS2.js → chunk-Z54EM5YZ.js} +4 -4
  199. package/dist/{chunk-GVX3NAUU.js → chunk-ZDAYWJV6.js} +2 -2
  200. package/dist/{chunk-4WBGZYZZ.js → chunk-ZJIFYUJI.js} +7 -7
  201. package/dist/chunk-ZJIFYUJI.js.map +1 -0
  202. package/dist/{chunk-JYPO7L3G.js → chunk-ZN4EYMKJ.js} +2 -2
  203. package/dist/{cli-p_WmVo2h.d.ts → cli-BLNmNEMT.d.ts} +16 -14
  204. package/dist/cli.d.ts +14 -13
  205. package/dist/cli.js +90 -87
  206. package/dist/coding/pre-action-gate.d.ts +66 -0
  207. package/dist/coding/pre-action-gate.js +22 -0
  208. package/dist/commitment-ledger.js +2 -2
  209. package/dist/compounding/engine.d.ts +3 -2
  210. package/dist/compounding/engine.js +16 -15
  211. package/dist/compounding/preference-consolidator.d.ts +1 -1
  212. package/dist/compression-optimizer.d.ts +1 -1
  213. package/dist/config.d.ts +1 -1
  214. package/dist/config.js +3 -2
  215. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  216. package/dist/connectors/codex-materialize-runner.js +15 -14
  217. package/dist/connectors/codex-materialize.d.ts +1 -1
  218. package/dist/connectors/index.d.ts +1 -1
  219. package/dist/connectors/index.js +15 -14
  220. package/dist/consolidation-provenance-check.d.ts +3 -2
  221. package/dist/consolidation-provenance-check.js +6 -6
  222. package/dist/consolidation-undo.d.ts +3 -2
  223. package/dist/consolidation-undo.js +5 -5
  224. package/dist/contradiction/index.d.ts +3 -2
  225. package/dist/contradiction/index.js +3 -3
  226. package/dist/converge-config.d.ts +1 -1
  227. package/dist/convergence-refresh.d.ts +3 -2
  228. package/dist/convergence-refresh.js +18 -17
  229. package/dist/conversation-index/backend.d.ts +1 -1
  230. package/dist/conversation-index/chunker.d.ts +1 -1
  231. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  232. package/dist/conversation-index/indexer.d.ts +1 -1
  233. package/dist/conversation-index/search.d.ts +1 -1
  234. package/dist/corpus-read-cancellation.d.ts +38 -0
  235. package/dist/corpus-read-cancellation.js +9 -0
  236. package/dist/corpus-read-cancellation.js.map +1 -0
  237. package/dist/corpus-watermark.d.ts +1 -1
  238. package/dist/corpus-watermark.js +21 -20
  239. package/dist/cue-anchors.d.ts +19 -1
  240. package/dist/cue-anchors.js +10 -2
  241. package/dist/day-summary.d.ts +1 -1
  242. package/dist/delinearize.d.ts +1 -1
  243. package/dist/dependency-propagation-config.d.ts +10 -0
  244. package/dist/dependency-propagation-config.js +10 -0
  245. package/dist/dependency-propagation-config.js.map +1 -0
  246. package/dist/deterministic-order.d.ts +4 -0
  247. package/dist/deterministic-order.js +10 -0
  248. package/dist/deterministic-order.js.map +1 -0
  249. package/dist/direct-answer-wiring.d.ts +1 -1
  250. package/dist/direct-answer.d.ts +1 -1
  251. package/dist/embedding-fallback.d.ts +1 -1
  252. package/dist/enrichment/index.d.ts +1 -1
  253. package/dist/entity-retrieval.d.ts +3 -2
  254. package/dist/entity-retrieval.js +15 -14
  255. package/dist/entity-schema.d.ts +1 -1
  256. package/dist/evals.js +2 -2
  257. package/dist/explicit-capture.d.ts +9 -8
  258. package/dist/explicit-capture.js +6 -6
  259. package/dist/external-wiki-access.d.ts +11 -10
  260. package/dist/external-wiki-access.js +47 -46
  261. package/dist/external-wiki-collection-registration.d.ts +1 -1
  262. package/dist/external-wiki-collection.d.ts +1 -1
  263. package/dist/external-wiki-mcp-tools.d.ts +11 -10
  264. package/dist/extraction-error-classification.d.ts +1 -1
  265. package/dist/extraction-faithfulness.d.ts +1 -1
  266. package/dist/extraction-judge-telemetry.d.ts +1 -1
  267. package/dist/extraction-judge-training.d.ts +1 -1
  268. package/dist/extraction-judge.d.ts +1 -1
  269. package/dist/extraction-liveness.d.ts +1 -1
  270. package/dist/extraction-normalization.d.ts +14 -0
  271. package/dist/extraction-normalization.js +22 -0
  272. package/dist/extraction-normalization.js.map +1 -0
  273. package/dist/extraction-prompt.d.ts +4 -3
  274. package/dist/extraction-prompt.js +3 -1
  275. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  276. package/dist/extraction-source-grounding.d.ts +1 -1
  277. package/dist/extraction.d.ts +18 -1
  278. package/dist/extraction.js +24 -21
  279. package/dist/fallback-llm.d.ts +1 -1
  280. package/dist/{first-start-migration-ZSHEFEI3.js → first-start-migration-626C5554.js} +5 -5
  281. package/dist/{forget-DNAJ66ZD.js → forget-GJ42LCBW.js} +2 -2
  282. package/dist/graph-dashboard-diff.d.ts +1 -1
  283. package/dist/graph-dashboard-key.d.ts +1 -1
  284. package/dist/graph-dashboard-parser.d.ts +1 -1
  285. package/dist/graph-edge-reinforcement.d.ts +1 -1
  286. package/dist/graph-snapshot.d.ts +1 -1
  287. package/dist/graph.d.ts +1 -1
  288. package/dist/harmonic-construction.d.ts +43 -0
  289. package/dist/harmonic-construction.js +26 -0
  290. package/dist/harmonic-construction.js.map +1 -0
  291. package/dist/harmonic-retrieval.d.ts +1 -0
  292. package/dist/harmonic-retrieval.js +10 -4
  293. package/dist/importance.d.ts +1 -1
  294. package/dist/importers/index.d.ts +1 -1
  295. package/dist/in-flight-reads.d.ts +47 -3
  296. package/dist/in-flight-reads.js +5 -3
  297. package/dist/index.d.ts +699 -696
  298. package/dist/index.js +197 -150
  299. package/dist/intent.d.ts +1 -1
  300. package/dist/json-store.d.ts +15 -1
  301. package/dist/json-store.js +11 -3
  302. package/dist/lcm/engine.d.ts +1 -1
  303. package/dist/lcm/engine.js +2 -2
  304. package/dist/lcm/index.d.ts +1 -1
  305. package/dist/lcm/index.js +7 -7
  306. package/dist/lcm/tools.d.ts +1 -1
  307. package/dist/lifecycle.d.ts +1 -1
  308. package/dist/live-connectors-runner.d.ts +1 -1
  309. package/dist/local-llm.d.ts +1 -1
  310. package/dist/local-model-endpoint.d.ts +1 -1
  311. package/dist/maintenance/archive-observations.js +2 -2
  312. package/dist/maintenance/atomic-file.d.ts +5 -0
  313. package/dist/maintenance/atomic-file.js +12 -0
  314. package/dist/maintenance/atomic-file.js.map +1 -0
  315. package/dist/maintenance/memory-governance.d.ts +1 -1
  316. package/dist/maintenance/memory-governance.js +15 -14
  317. package/dist/maintenance/migrate-observations.js +3 -3
  318. package/dist/maintenance/observation-ledger-utils.d.ts +1 -1
  319. package/dist/maintenance/observation-ledger-utils.js +2 -2
  320. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  321. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +16 -15
  322. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  323. package/dist/maintenance/rebuild-memory-projection.js +17 -16
  324. package/dist/maintenance/rebuild-observations.js +3 -3
  325. package/dist/{maintenance-BfcuwfJS.d.ts → maintenance-DKbKZi3u.d.ts} +3 -3
  326. package/dist/mcp-memory-inspector-app.d.ts +11 -10
  327. package/dist/memory-action-policy.d.ts +1 -1
  328. package/dist/memory-cache.d.ts +1 -1
  329. package/dist/memory-corpus-version.js +2 -2
  330. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  331. package/dist/memory-projection-store.d.ts +1 -1
  332. package/dist/memory-provenance.d.ts +1 -1
  333. package/dist/memory-snapshot.d.ts +1 -1
  334. package/dist/memory-worth-outcomes.d.ts +3 -2
  335. package/dist/models-json.d.ts +1 -1
  336. package/dist/namespaces/migrate.d.ts +4 -3
  337. package/dist/namespaces/migrate.js +20 -19
  338. package/dist/namespaces/principal.d.ts +1 -1
  339. package/dist/namespaces/search.d.ts +1 -1
  340. package/dist/namespaces/search.js +4 -4
  341. package/dist/namespaces/storage.d.ts +4 -3
  342. package/dist/namespaces/storage.js +15 -14
  343. package/dist/native-knowledge.d.ts +1 -1
  344. package/dist/objective-state-writers.js +3 -3
  345. package/dist/objective-state.js +2 -2
  346. package/dist/offline-sync-impression-drain.d.ts +1 -1
  347. package/dist/offline-sync-impression-drain.js +2 -2
  348. package/dist/operator-doctor-corpus.d.ts +1 -1
  349. package/dist/operator-doctor-corpus.js +22 -21
  350. package/dist/operator-doctor-replica.d.ts +1 -1
  351. package/dist/operator-toolkit.d.ts +4 -3
  352. package/dist/operator-toolkit.js +31 -29
  353. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  354. package/dist/orchestration/maintenance.d.ts +5 -4
  355. package/dist/orchestration/maintenance.js +21 -20
  356. package/dist/{orchestrator-B7nLo4z1.d.ts → orchestrator-BRwD7ceU.d.ts} +7 -7
  357. package/dist/orchestrator.d.ts +9 -8
  358. package/dist/orchestrator.js +127 -121
  359. package/dist/page-versioning.js +5 -5
  360. package/dist/patterns-cli.d.ts +1 -1
  361. package/dist/{pipeline-1h2GpiHP.d.ts → pipeline-DC-1C9T8.d.ts} +1 -1
  362. package/dist/policy-runtime.d.ts +1 -1
  363. package/dist/proactive-contention.d.ts +1 -1
  364. package/dist/provenance.d.ts +1 -1
  365. package/dist/{qmd-UdwoF71D.d.ts → qmd-DdeCEZdb.d.ts} +1 -1
  366. package/dist/qmd-preflight.d.ts +2 -2
  367. package/dist/qmd-recall-cache.d.ts +1 -1
  368. package/dist/qmd.d.ts +2 -2
  369. package/dist/qmd.js +4 -4
  370. package/dist/recall-concurrency-config.d.ts +1 -1
  371. package/dist/recall-disclosure-escalation.d.ts +1 -1
  372. package/dist/recall-explain-renderer.d.ts +1 -1
  373. package/dist/recall-explain-renderer.js +3 -3
  374. package/dist/recall-memory-map.d.ts +1 -1
  375. package/dist/recall-planner-llm.d.ts +1 -1
  376. package/dist/recall-state.d.ts +1 -1
  377. package/dist/recall-state.js +2 -2
  378. package/dist/recall-tag-filter.d.ts +1 -1
  379. package/dist/recall-timings.d.ts +1 -1
  380. package/dist/recall-xray-cli.d.ts +1 -1
  381. package/dist/recall-xray-cli.js +4 -4
  382. package/dist/recall-xray-renderer.d.ts +1 -1
  383. package/dist/recall-xray-renderer.js +3 -3
  384. package/dist/recall-xray.d.ts +1 -1
  385. package/dist/recall-xray.js +2 -2
  386. package/dist/reconcile/cursor.d.ts +1 -1
  387. package/dist/reconcile/manifest.d.ts +1 -1
  388. package/dist/reconcile/plan.d.ts +1 -1
  389. package/dist/relevance.js +2 -2
  390. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  391. package/dist/replay/normalizers/claude.d.ts +1 -1
  392. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  393. package/dist/replay/normalizers/shared.d.ts +1 -1
  394. package/dist/replay/runner.d.ts +1 -1
  395. package/dist/replay/types.d.ts +1 -1
  396. package/dist/replica-divergence.d.ts +1 -1
  397. package/dist/replica-peers-config.d.ts +1 -1
  398. package/dist/{resolution-3K27T4VO.js → resolution-MDPNOEG6.js} +4 -4
  399. package/dist/resolution-MDPNOEG6.js.map +1 -0
  400. package/dist/resolve-auth-token.d.ts +1 -1
  401. package/dist/resume-bundles.js +8 -7
  402. package/dist/retrieval-agents.d.ts +2 -2
  403. package/dist/retrieval-tiers.d.ts +1 -1
  404. package/dist/routing/engine.d.ts +1 -1
  405. package/dist/routing/store.d.ts +1 -1
  406. package/dist/salvage-envelope.d.ts +1 -1
  407. package/dist/salvage-envelope.js +3 -3
  408. package/dist/schemas.d.ts +213 -116
  409. package/dist/schemas.js +1 -1
  410. package/dist/{scope-profiles-APjhSe-w.d.ts → scope-profiles-BXVq4Jv0.d.ts} +1 -1
  411. package/dist/search/embed-helper.d.ts +1 -1
  412. package/dist/search/factory.d.ts +1 -1
  413. package/dist/search/factory.js +3 -3
  414. package/dist/search/index.d.ts +1 -1
  415. package/dist/search/index.js +3 -3
  416. package/dist/search/lancedb-backend.d.ts +1 -1
  417. package/dist/search/meilisearch-backend.d.ts +1 -1
  418. package/dist/search/noop-backend.d.ts +1 -1
  419. package/dist/search/orama-backend.d.ts +1 -1
  420. package/dist/search/port.d.ts +1 -1
  421. package/dist/search/remote-backend.d.ts +1 -1
  422. package/dist/{semantic-consolidation-CrySDbk3.d.ts → semantic-consolidation-CGYxfa8F.d.ts} +1 -1
  423. package/dist/semantic-consolidation.d.ts +2 -2
  424. package/dist/semantic-consolidation.js +16 -15
  425. package/dist/semantic-rule-promotion.js +15 -14
  426. package/dist/semantic-rule-verifier.d.ts +1 -1
  427. package/dist/semantic-rule-verifier.js +15 -14
  428. package/dist/{service-B5W5IYCx.d.ts → service-CBDBQFCN.d.ts} +2 -2
  429. package/dist/session-observer-bands.d.ts +1 -1
  430. package/dist/session-observer-state.d.ts +1 -1
  431. package/dist/shared-context/manager.d.ts +11 -11
  432. package/dist/signal.d.ts +1 -1
  433. package/dist/source-agent-qualifier.d.ts +1 -1
  434. package/dist/source-agent-qualifier.js +19 -18
  435. package/dist/{storage-COL907QF.d.ts → storage-V--MQi7w.d.ts} +5 -4
  436. package/dist/storage.d.ts +3 -2
  437. package/dist/storage.js +14 -13
  438. package/dist/summarizer.d.ts +1 -1
  439. package/dist/summary-snapshot.d.ts +1 -1
  440. package/dist/temporal-supersession.d.ts +14 -2
  441. package/dist/temporal-supersession.js +1 -1
  442. package/dist/temporal-timeline-recall.d.ts +1 -1
  443. package/dist/temporal-validity.d.ts +1 -1
  444. package/dist/threading.d.ts +1 -1
  445. package/dist/tier-migration.d.ts +3 -2
  446. package/dist/tier-routing.d.ts +1 -1
  447. package/dist/{tier-stats-OPTSBNRH.js → tier-stats-2JCZYEF7.js} +5 -5
  448. package/dist/topics.d.ts +1 -1
  449. package/dist/transcript.d.ts +1 -1
  450. package/dist/transfer/autodetect.js +1 -1
  451. package/dist/transfer/backup.js +1 -1
  452. package/dist/transfer/capsule-export.js +2 -2
  453. package/dist/transfer/capsule-import.js +6 -6
  454. package/dist/transfer/types.d.ts +66 -66
  455. package/dist/trust-score-stage.d.ts +1 -1
  456. package/dist/trust-score.d.ts +1 -1
  457. package/dist/trust-zones.js +2 -2
  458. package/dist/{types-D_Au9qJO.d.ts → types-D_a6Sqjz.d.ts} +25 -8
  459. package/dist/types.d.ts +1 -1
  460. package/dist/types.js +1 -1
  461. package/dist/utility-learner.js +3 -3
  462. package/dist/utility-runtime.d.ts +1 -1
  463. package/dist/utility-runtime.js +4 -4
  464. package/dist/utility-telemetry.js +2 -2
  465. package/dist/verified-recall.js +15 -14
  466. package/dist/work-product-ledger.js +2 -2
  467. package/dist/write-envelope.d.ts +1 -1
  468. package/dist/write-envelope.js +2 -2
  469. package/package.json +32 -2
  470. package/src/abstraction-nodes.ts +182 -4
  471. package/src/causal-trajectory.ts +258 -3
  472. package/src/cli/harmonic-search.ts +23 -0
  473. package/src/cli/research-status-commands.ts +2 -1
  474. package/src/cli.ts +1 -24
  475. package/src/coding/pre-action-gate.test.ts +516 -0
  476. package/src/coding/pre-action-gate.ts +320 -0
  477. package/src/config.test.ts +85 -0
  478. package/src/config.ts +2 -0
  479. package/src/corpus-read-cancellation.ts +42 -0
  480. package/src/cue-anchors.test.ts +90 -0
  481. package/src/cue-anchors.ts +264 -11
  482. package/src/dependency-frontmatter.test.ts +83 -0
  483. package/src/dependency-propagation-config.ts +94 -0
  484. package/src/deterministic-order.ts +14 -0
  485. package/src/entity-retrieval.ts +4 -4
  486. package/src/extraction-normalization.ts +71 -0
  487. package/src/extraction-prompt.ts +45 -11
  488. package/src/extraction.ts +48 -32
  489. package/src/faithfulness-graph-guard.test.ts +27 -0
  490. package/src/harmonic-construction.test.ts +1799 -0
  491. package/src/harmonic-construction.ts +367 -0
  492. package/src/harmonic-retrieval.ts +166 -25
  493. package/src/in-flight-reads.ts +119 -6
  494. package/src/index.ts +4 -5
  495. package/src/json-store.ts +354 -12
  496. package/src/orchestration/consolidation-run.ts +192 -0
  497. package/src/orchestration/contradiction-linking-coordinator.ts +35 -1
  498. package/src/orchestration/dependency-propagation-triggers.test.ts +286 -0
  499. package/src/orchestration/dependency-propagation.test.ts +487 -0
  500. package/src/orchestration/dependency-propagation.ts +263 -0
  501. package/src/orchestration/dependency-revalidation.ts +173 -0
  502. package/src/orchestration/extraction-persist-deps.ts +93 -0
  503. package/src/orchestration/extraction-persist.ts +101 -94
  504. package/src/orchestration/harmonic-construction-persist.ts +86 -0
  505. package/src/orchestration/namespace-read-fanout.ts +13 -2
  506. package/src/orchestration/recall-internal-deps.ts +2 -0
  507. package/src/orchestration/recall-internal.ts +5 -1
  508. package/src/orchestration/recall-search-pipeline.ts +2 -0
  509. package/src/orchestration/recall-search-prefilter.ts +5 -1
  510. package/src/orchestrator.ts +7 -6
  511. package/src/schemas.ts +15 -0
  512. package/src/storage/entity-store.ts +9 -2
  513. package/src/storage/memory-read-store.ts +33 -4
  514. package/src/storage-contract/corpus-read-cancellation.test.ts +408 -0
  515. package/src/storage.ts +75 -19
  516. package/src/temporal-supersession.ts +29 -1
  517. package/src/testing/orchestrator-lite.ts +27 -8
  518. package/src/testing/subjects/extraction-lifecycle.test.ts +91 -50
  519. package/src/types.ts +22 -7
  520. package/dist/chunk-2P3GQVM2.js.map +0 -1
  521. package/dist/chunk-3S63QIFQ.js.map +0 -1
  522. package/dist/chunk-4WBGZYZZ.js.map +0 -1
  523. package/dist/chunk-CMQZNEIF.js.map +0 -1
  524. package/dist/chunk-DNHVPZOD.js.map +0 -1
  525. package/dist/chunk-FZZ2QTJI.js +0 -111
  526. package/dist/chunk-FZZ2QTJI.js.map +0 -1
  527. package/dist/chunk-J7T4MX7P.js.map +0 -1
  528. package/dist/chunk-KSGEGHYA.js.map +0 -1
  529. package/dist/chunk-KVJRXN2E.js.map +0 -1
  530. package/dist/chunk-LPSF4OQH.js +0 -47
  531. package/dist/chunk-LPSF4OQH.js.map +0 -1
  532. package/dist/chunk-LZGCJSQR.js.map +0 -1
  533. package/dist/chunk-OADWQ5CR.js +0 -115
  534. package/dist/chunk-OADWQ5CR.js.map +0 -1
  535. package/dist/chunk-PDJTHRAW.js +0 -36
  536. package/dist/chunk-PDJTHRAW.js.map +0 -1
  537. package/dist/chunk-PLCZD3LG.js.map +0 -1
  538. package/dist/chunk-RN53QBM4.js.map +0 -1
  539. package/dist/chunk-W4FBGYGK.js.map +0 -1
  540. /package/dist/{auto-sync-7O6RP2RT.js.map → auto-sync-QFQGOEO2.js.map} +0 -0
  541. /package/dist/{capsule-merge-Q6AR3XL7.js.map → capsule-merge-KXTRZ23Z.js.map} +0 -0
  542. /package/dist/{chunk-ICP53SKG.js.map → chunk-2HIJHXB3.js.map} +0 -0
  543. /package/dist/{chunk-FJ2ND6CZ.js.map → chunk-47J4EDGR.js.map} +0 -0
  544. /package/dist/{chunk-S55OAS5P.js.map → chunk-4EABKPZS.js.map} +0 -0
  545. /package/dist/{chunk-GD7UPIBG.js.map → chunk-4JWJMRPJ.js.map} +0 -0
  546. /package/dist/{chunk-3NDN5P55.js.map → chunk-4S3ECH3U.js.map} +0 -0
  547. /package/dist/{chunk-CGASUJVP.js.map → chunk-5V6IXHPI.js.map} +0 -0
  548. /package/dist/{chunk-A4JMGKCD.js.map → chunk-5XCN4XBU.js.map} +0 -0
  549. /package/dist/{chunk-2RPJ4NEE.js.map → chunk-64BHFFKZ.js.map} +0 -0
  550. /package/dist/{chunk-FQC3DHH2.js.map → chunk-66SE3BNH.js.map} +0 -0
  551. /package/dist/{chunk-TERNBNJB.js.map → chunk-6FC3IZ26.js.map} +0 -0
  552. /package/dist/{chunk-53AJILXF.js.map → chunk-6XGEBQ3R.js.map} +0 -0
  553. /package/dist/{chunk-IP3DHDU2.js.map → chunk-7BLWBSRL.js.map} +0 -0
  554. /package/dist/{chunk-A2TFK5PG.js.map → chunk-7NDM2PNK.js.map} +0 -0
  555. /package/dist/{chunk-HRMEYQRO.js.map → chunk-7VWZ4LRW.js.map} +0 -0
  556. /package/dist/{chunk-R6YJI3HE.js.map → chunk-AW4QUFQF.js.map} +0 -0
  557. /package/dist/{chunk-P65YJEEL.js.map → chunk-AXFWMRKI.js.map} +0 -0
  558. /package/dist/{chunk-WG5HSQ4P.js.map → chunk-BAKXNQ3C.js.map} +0 -0
  559. /package/dist/{chunk-NM2WP3B7.js.map → chunk-BJYET5TX.js.map} +0 -0
  560. /package/dist/{chunk-HLKPRWF4.js.map → chunk-DATDLJAO.js.map} +0 -0
  561. /package/dist/{chunk-DX3XRGLH.js.map → chunk-DQTCGVFK.js.map} +0 -0
  562. /package/dist/{chunk-HIDEBEAN.js.map → chunk-E633OXMH.js.map} +0 -0
  563. /package/dist/{chunk-EZNXW27Q.js.map → chunk-ELQCS47S.js.map} +0 -0
  564. /package/dist/{chunk-HAYSYUAB.js.map → chunk-EURCX6PS.js.map} +0 -0
  565. /package/dist/{chunk-RSPSHRZA.js.map → chunk-FV7YQTN3.js.map} +0 -0
  566. /package/dist/{chunk-GWHPQOUC.js.map → chunk-GGBSF2X7.js.map} +0 -0
  567. /package/dist/{chunk-SYUBB3WM.js.map → chunk-GKEYXXKX.js.map} +0 -0
  568. /package/dist/{chunk-PELT6ADC.js.map → chunk-GSEPRIZC.js.map} +0 -0
  569. /package/dist/{chunk-UTVZKHJK.js.map → chunk-GUKBW4HL.js.map} +0 -0
  570. /package/dist/{chunk-2F6NP3NT.js.map → chunk-HDQUQBPW.js.map} +0 -0
  571. /package/dist/{chunk-6HMYUWXR.js.map → chunk-HTP6XRUI.js.map} +0 -0
  572. /package/dist/{chunk-UYUYZ4WY.js.map → chunk-IARXXZU4.js.map} +0 -0
  573. /package/dist/{chunk-MNB5RMAY.js.map → chunk-IIFFC3RL.js.map} +0 -0
  574. /package/dist/{chunk-KQAFEZQX.js.map → chunk-IPLYGWQF.js.map} +0 -0
  575. /package/dist/{chunk-NZBZ7IS2.js.map → chunk-JDCQK3C5.js.map} +0 -0
  576. /package/dist/{chunk-ANCC3JJH.js.map → chunk-JI62YGPI.js.map} +0 -0
  577. /package/dist/{chunk-LULR4IUW.js.map → chunk-KATEWTQJ.js.map} +0 -0
  578. /package/dist/{chunk-IJ7HK452.js.map → chunk-KMAP7SNQ.js.map} +0 -0
  579. /package/dist/{chunk-PRVJH7CY.js.map → chunk-KMWYZTIE.js.map} +0 -0
  580. /package/dist/{chunk-JGSKJHF7.js.map → chunk-KQS72GCR.js.map} +0 -0
  581. /package/dist/{chunk-FMCHFSZF.js.map → chunk-LQKXVQZR.js.map} +0 -0
  582. /package/dist/{chunk-M4DMO67I.js.map → chunk-LTOAJXZB.js.map} +0 -0
  583. /package/dist/{chunk-NIS256NW.js.map → chunk-LYMNZZIM.js.map} +0 -0
  584. /package/dist/{chunk-3PY7VHV7.js.map → chunk-MCA2X4WH.js.map} +0 -0
  585. /package/dist/{chunk-S5NZBKKQ.js.map → chunk-N3CXAYPJ.js.map} +0 -0
  586. /package/dist/{chunk-WQIHRA5F.js.map → chunk-N3LL5NEU.js.map} +0 -0
  587. /package/dist/{chunk-G2RBWVFQ.js.map → chunk-NKL25FCF.js.map} +0 -0
  588. /package/dist/{chunk-LMDRGRJ2.js.map → chunk-NOB2T2FC.js.map} +0 -0
  589. /package/dist/{chunk-P2OTGMTR.js.map → chunk-NSGU76YO.js.map} +0 -0
  590. /package/dist/{chunk-D5NGH2EW.js.map → chunk-O76MWTVS.js.map} +0 -0
  591. /package/dist/{chunk-WZFAPHIK.js.map → chunk-OIOZ6MOP.js.map} +0 -0
  592. /package/dist/{chunk-UMOO7IY7.js.map → chunk-P2KBDJJ6.js.map} +0 -0
  593. /package/dist/{chunk-SXWHN7GC.js.map → chunk-PDEKQWDV.js.map} +0 -0
  594. /package/dist/{chunk-2EJNXE53.js.map → chunk-PLCHU56K.js.map} +0 -0
  595. /package/dist/{chunk-45OTV7FZ.js.map → chunk-PWIMF7LP.js.map} +0 -0
  596. /package/dist/{chunk-7YKVM5H3.js.map → chunk-PWLB4TRK.js.map} +0 -0
  597. /package/dist/{chunk-RVYVMQK4.js.map → chunk-QSYL5CXK.js.map} +0 -0
  598. /package/dist/{chunk-NXUJRXSF.js.map → chunk-QWLW3VQH.js.map} +0 -0
  599. /package/dist/{chunk-JBPKEARU.js.map → chunk-RKNJBZ55.js.map} +0 -0
  600. /package/dist/{chunk-QCECHYZL.js.map → chunk-RVO6TCTU.js.map} +0 -0
  601. /package/dist/{chunk-5L7PTX2Q.js.map → chunk-S2SJEOTM.js.map} +0 -0
  602. /package/dist/{chunk-52I3YZZ6.js.map → chunk-S75UQ3T3.js.map} +0 -0
  603. /package/dist/{chunk-LXOM6IQU.js.map → chunk-SEF4IOFE.js.map} +0 -0
  604. /package/dist/{chunk-DUEEQCTT.js.map → chunk-SHYIMIX5.js.map} +0 -0
  605. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  606. /package/dist/{chunk-3JUYWPFJ.js.map → chunk-VFS3MK5F.js.map} +0 -0
  607. /package/dist/{chunk-WOEVJKKQ.js.map → chunk-WPZX7MEA.js.map} +0 -0
  608. /package/dist/{chunk-ZRWB5D4H.js.map → chunk-WT6UL3UA.js.map} +0 -0
  609. /package/dist/{chunk-MC6XO7T4.js.map → chunk-YLBE6PLR.js.map} +0 -0
  610. /package/dist/{chunk-GF22HWS2.js.map → chunk-Z54EM5YZ.js.map} +0 -0
  611. /package/dist/{chunk-GVX3NAUU.js.map → chunk-ZDAYWJV6.js.map} +0 -0
  612. /package/dist/{chunk-JYPO7L3G.js.map → chunk-ZN4EYMKJ.js.map} +0 -0
  613. /package/dist/{resolution-3K27T4VO.js.map → coding/pre-action-gate.js.map} +0 -0
  614. /package/dist/{first-start-migration-ZSHEFEI3.js.map → first-start-migration-626C5554.js.map} +0 -0
  615. /package/dist/{forget-DNAJ66ZD.js.map → forget-GJ42LCBW.js.map} +0 -0
  616. /package/dist/{tier-stats-OPTSBNRH.js.map → tier-stats-2JCZYEF7.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/schemas.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const MemoryActionTypeSchema = z.enum([\n \"store_episode\",\n \"store_note\",\n \"update_note\",\n \"create_artifact\",\n \"summarize_node\",\n \"discard\",\n \"link_graph\",\n]);\n\nexport const MemoryActionEligibilityContextSchema = z\n .object({\n confidence: z.number().min(0).max(1),\n lifecycleState: z.enum([\"active\", \"validated\", \"candidate\", \"stale\", \"archived\"]),\n importance: z.number().min(0).max(1),\n source: z.enum([\"extraction\", \"consolidation\", \"replay\", \"manual\", \"unknown\"]),\n })\n .strict();\n\nexport function parseMemoryActionType(value: unknown): z.infer<typeof MemoryActionTypeSchema> {\n const parsed = MemoryActionTypeSchema.safeParse(value);\n return parsed.success ? parsed.data : \"discard\";\n}\n\nexport function parseMemoryActionEligibilityContext(\n value: unknown,\n): z.infer<typeof MemoryActionEligibilityContextSchema> {\n const parsed = MemoryActionEligibilityContextSchema.safeParse(value);\n if (parsed.success) return parsed.data;\n return {\n confidence: 0,\n lifecycleState: \"candidate\",\n importance: 0,\n source: \"unknown\",\n };\n}\n\nexport const ProcedureStepExtractSchema = z.object({\n order: z.number(),\n intent: z.string(),\n toolCall: z\n .object({\n kind: z.string(),\n signature: z.string(),\n })\n .optional()\n .nullable(),\n expectedOutcome: z.string().optional().nullable(),\n optional: z.boolean().optional().nullable(),\n});\n\nexport const ExtractedFactSchema = z.object({\n category: z.enum([\n \"fact\",\n \"preference\",\n \"correction\",\n \"entity\",\n \"decision\",\n \"relationship\",\n \"principle\",\n \"commitment\",\n \"moment\",\n \"skill\",\n \"rule\",\n \"procedure\",\n \"reasoning_trace\",\n ]),\n content: z\n .string()\n .describe(\"The memory content — a clear, standalone statement\"),\n confidence: z\n .number()\n .min(0)\n .max(1)\n .describe(\"How confident are you this is correct (0-1)\"),\n tags: z.array(z.string()).describe(\"Relevant tags for categorization\"),\n entityRef: z\n .string()\n .optional()\n .nullable()\n .describe(\"If about an entity, its normalized name (e.g. person-jane-doe)\"),\n promptedByQuestion: z\n .string()\n .optional()\n .nullable()\n .describe(\"Optional proactive follow-up question that surfaced this fact.\"),\n scope: z\n .enum([\"project\", \"global\"])\n .optional()\n .nullable()\n .describe(\n 'Scope classification: \"global\" for cross-project knowledge (framework bugs, library behavior, API patterns, user preferences, general coding patterns); \"project\" for project-specific knowledge (file paths, env configs, deployment details, project workarounds) and for tool, command, or CLI-flag instructions tied to one agent, since the same tool name can mean different things across agents. When keeping such an agent-tied instruction, begin the fact with a leading \"In <agent>,\" clause naming that agent. Defaults to \"project\" when a coding context is active.',\n ),\n quote: z\n .string()\n .optional()\n .nullable()\n .describe(\n \"The EXACT verbatim words from the conversation that support this fact. Copy a contiguous span from a single speaker turn (not a paraphrase). Cap at ~300 characters. This is the grounding evidence for downstream faithfulness verification (issue #1575).\",\n ),\n structuredAttributes: z\n .record(z.string(), z.string())\n .optional()\n .nullable()\n .describe(\"Structured key-value attributes when the fact contains measurable or categorical data (e.g., {\\\"price\\\": \\\"29.99\\\", \\\"color\\\": \\\"blue\\\", \\\"date\\\": \\\"2024-03-15\\\"}).\"),\n procedureSteps: z\n .array(ProcedureStepExtractSchema)\n .optional()\n .nullable()\n .describe(\n 'For category \"procedure\" only: ordered steps (intent per step). At least two steps; include explicit trigger phrasing in content (e.g. \"When you deploy…\").',\n ),\n reasoningTrace: z\n .object({\n steps: z\n .array(\n z.object({\n order: z.number(),\n description: z.string(),\n }),\n )\n // Prompts and normalizer require >=2 ordered steps; enforce it at\n // the schema layer so gateway-path parsing rejects malformed traces\n // rather than persisting them (local/direct-client normalization\n // already enforces this, keeping the two paths symmetric).\n .min(2)\n .describe(\"Ordered reasoning steps the user walked through (require >=2).\"),\n // Accept snake_case aliases so a loose gateway model using\n // `final_answer` / `observed_outcome` does not fail schema parsing\n // and drop the entire extraction result. Local/direct-client\n // normalization already tolerates these keys; the gateway path must\n // too. Zod's `union` keeps the parse successful either way.\n finalAnswer: z\n .string()\n .optional()\n .nullable()\n .describe(\"The conclusion, decision, or answer the chain arrived at.\"),\n final_answer: z\n .string()\n .optional()\n .nullable()\n .describe(\"Alias for finalAnswer (snake_case). Gateway-tolerance shim.\"),\n observedOutcome: z\n .string()\n .optional()\n .nullable()\n .describe(\"Optional note about how the answer actually played out.\"),\n observed_outcome: z\n .string()\n .optional()\n .nullable()\n .describe(\"Alias for observedOutcome (snake_case). Gateway-tolerance shim.\"),\n })\n // Either finalAnswer OR final_answer must be present — enforce here so\n // the rest of the pipeline can assume a usable string downstream.\n .refine(\n (v) =>\n (typeof v.finalAnswer === \"string\" && v.finalAnswer.trim().length > 0) ||\n (typeof v.final_answer === \"string\" && v.final_answer.trim().length > 0),\n { message: \"reasoningTrace requires finalAnswer (or final_answer)\" },\n )\n .optional()\n .nullable()\n .describe(\n 'For category \"reasoning_trace\" only: a stored solution chain with ordered steps, a final answer, and an optional observed outcome. Require at least two steps.',\n ),\n eventTime: z\n .string()\n .optional()\n .nullable()\n .describe(\n 'Optional event-time expression for bi-temporal validity (#1578). An ISO date (\"2025-03-01\") or a relative expression verbatim (\"last March\", \"yesterday\", \"since 2024\", \"until 2025-06-01\"). Resolved against the source turn timestamp at write time — NOT wall-clock. Omit when the fact has no explicit temporal anchor.',\n ),\n event_time: z\n .string()\n .optional()\n .nullable()\n .describe(\"Alias for eventTime (snake_case). Gateway-tolerance shim (#1578).\"),\n}).superRefine((value, ctx) => {\n if (value.category === \"procedure\" && (!Array.isArray(value.procedureSteps) || value.procedureSteps.length < 2)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"procedureSteps\"],\n message: \"procedure facts require at least two procedureSteps\",\n });\n }\n\n if (value.category === \"reasoning_trace\" && value.reasoningTrace == null) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: [\"reasoningTrace\"],\n message: \"reasoning_trace facts require reasoningTrace\",\n });\n }\n});\n\nexport const EntityMentionSchema = z.object({\n name: z\n .string()\n .describe(\"Normalized entity name (e.g. jane-doe, acme-corp, my-project)\"),\n type: z.enum([\"person\", \"project\", \"tool\", \"company\", \"place\", \"other\"]),\n facts: z\n .array(z.string())\n .describe(\"New facts learned about this entity in this conversation\"),\n promptedByQuestion: z\n .string()\n .optional()\n .nullable()\n .describe(\"Optional proactive follow-up question that surfaced this entity.\"),\n structuredSections: z\n .array(z.object({\n key: z.string(),\n title: z.string(),\n facts: z.array(z.string()),\n }))\n .optional()\n .nullable()\n .describe(\"Optional named sections for entity-specific facts. Use when facts clearly belong under a durable heading such as Beliefs or Building / Working On.\"),\n});\n\nexport const ExtractedQuestionSchema = z.object({\n question: z.string().describe(\"A genuine question the AI is curious about based on this conversation\"),\n context: z.string().describe(\"Why this question matters or what prompted it\"),\n priority: z.number().min(0).max(1).describe(\"How important/urgent this question is (0-1)\"),\n});\n\nexport const ProactiveQuestionsResultSchema = z.object({\n questions: z\n .array(ExtractedQuestionSchema)\n .describe(\"Additional follow-up questions discovered in a proactive second-pass extraction.\"),\n});\n\nexport const ExtractedRelationshipSchema = z.object({\n source: z.string().describe(\"Source entity name (normalized, e.g. person-jane-doe)\"),\n target: z.string().describe(\"Target entity name (normalized, e.g. company-acme-corp)\"),\n label: z.string().describe(\"Relationship label (e.g. 'works at', 'created', 'manages')\"),\n promptedByQuestion: z\n .string()\n .optional()\n .nullable()\n .describe(\"Optional proactive follow-up question that surfaced this relationship.\"),\n});\n\nexport const ProactiveExtractionResultSchema = z.object({\n facts: z\n .array(ExtractedFactSchema)\n .describe(\n \"Additional high-confidence memories recovered only after answering proactive follow-up questions from the same buffered conversation.\",\n ),\n profileUpdates: z\n .array(z.string())\n .describe(\n \"Additional profile updates directly supported by the buffered conversation. Omit anything speculative.\",\n ),\n entities: z\n .array(EntityMentionSchema)\n .describe(\n \"Additional entities or entity facts surfaced by the proactive follow-up pass.\",\n ),\n relationships: z\n .array(ExtractedRelationshipSchema)\n .optional()\n .nullable()\n .describe(\n \"Additional relationships surfaced by the proactive follow-up pass.\",\n ),\n});\n\nexport const ExtractionResultSchema = z.object({\n facts: z\n .array(ExtractedFactSchema)\n .describe(\n \"Extracted memories from the conversation. Include facts, preferences, corrections, and decisions. Only extract genuinely new, durable information — skip transient task state.\",\n ),\n profileUpdates: z\n .array(z.string())\n .describe(\n \"Updates to the user's behavioral profile. Each string is a standalone statement about the user's preferences, habits, or personality. Only include genuinely new insights.\",\n ),\n entities: z\n .array(EntityMentionSchema)\n .describe(\n \"Entities mentioned in the conversation with new facts about them.\",\n ),\n questions: z\n .array(ExtractedQuestionSchema)\n .describe(\n \"Zero to three source-grounded questions useful in future sessions. Return an empty array when the conversation supports none.\",\n ),\n identityReflection: z\n .string()\n .optional()\n .nullable()\n .describe(\n \"A brief reflection on what you learned about yourself as an agent in this interaction — patterns in your behavior, growth, things you did well or could improve.\",\n ),\n relationships: z\n .array(ExtractedRelationshipSchema)\n .optional()\n .nullable()\n .describe(\n \"Relationships between entities discovered in this conversation. Max 5 per extraction. Format: {source, target, label}.\",\n ),\n});\n\nexport const ConsolidationItemSchema = z.object({\n existingId: z\n .string()\n .describe(\"The ID of the existing memory being evaluated\"),\n action: z.enum([\"ADD\", \"MERGE\", \"UPDATE\", \"INVALIDATE\", \"SKIP\"]),\n mergeWith: z\n .string()\n .optional()\n .nullable()\n .describe(\"If MERGE, the ID of the memory to merge with\"),\n updatedContent: z\n .string()\n .optional()\n .nullable()\n .describe(\"If UPDATE or MERGE, the new content\"),\n reason: z.string().describe(\"Brief reason for this decision\"),\n});\n\nexport const ConsolidationResultSchema = z.object({\n items: z\n .array(ConsolidationItemSchema)\n .describe(\n \"Decisions for each existing memory: ADD (keep as-is), MERGE (combine with another), UPDATE (revise content), INVALIDATE (mark as outdated/wrong), SKIP (no action needed)\",\n ),\n profileUpdates: z\n .array(z.string())\n .describe(\"New profile statements to add or update\"),\n entityUpdates: z\n .array(EntityMentionSchema)\n .describe(\"Entity updates from consolidation analysis\"),\n});\n\nexport function buildProfileConsolidationResultSchema(targetLines: number) {\n return z.object({\n consolidatedProfile: z\n .string()\n .describe(\n `The full consolidated profile as markdown. Preserve all ## section headers. Merge duplicate or near-duplicate bullets into single clear statements. Remove stale or superseded information. Keep the most important and durable observations. Target roughly ${targetLines} lines.`,\n ),\n removedCount: z\n .number()\n .describe(\"Number of bullets removed or merged during consolidation\"),\n summary: z\n .string()\n .describe(\"Brief summary of what was consolidated\"),\n });\n}\n\nexport const ProfileConsolidationResultSchema = buildProfileConsolidationResultSchema(50);\n\nexport const IdentityConsolidationResultSchema = z.object({\n learnedPatterns: z\n .array(z.string())\n .describe(\n \"Consolidated behavioral patterns and lessons learned, each a concise standalone statement\",\n ),\n summary: z\n .string()\n .describe(\n \"A brief paragraph summarizing the agent's core identity insights\",\n ),\n});\n\nexport type IdentityConsolidationResultParsed = z.infer<\n typeof IdentityConsolidationResultSchema\n>;\n\n// Contradiction Verification (Phase 2B)\nexport const ContradictionVerificationSchema = z.object({\n isContradiction: z\n .boolean()\n .describe(\"Whether the two memories truly contradict each other\"),\n confidence: z\n .number()\n .min(0)\n .max(1)\n .describe(\"How confident are you in this assessment (0-1)\"),\n reasoning: z\n .string()\n .describe(\"Explanation of why these are or are not contradictory\"),\n whichIsNewer: z\n .enum([\"first\", \"second\", \"unclear\"])\n .describe(\"Which memory represents the more recent/current state\"),\n});\n\nexport type ContradictionVerificationResult = z.infer<\n typeof ContradictionVerificationSchema\n>;\n\n// Memory Linking (Phase 3A)\nexport const MemoryLinkSchema = z.object({\n targetId: z\n .string()\n .describe(\"The ID of the memory this links to\"),\n linkType: z\n .enum([\"follows\", \"references\", \"contradicts\", \"supports\", \"related\"])\n .describe(\"The type of relationship\"),\n strength: z\n .number()\n .min(0)\n .max(1)\n .describe(\"How strong is this relationship (0-1)\"),\n reason: z\n .string()\n .optional()\n .nullable()\n .describe(\"Why this link exists\"),\n});\n\nexport const SuggestedLinksSchema = z.object({\n links: z\n .array(MemoryLinkSchema)\n .describe(\"Suggested links between memories based on semantic analysis\"),\n});\n\nexport type MemoryLink = z.infer<typeof MemoryLinkSchema>;\nexport type SuggestedLinks = z.infer<typeof SuggestedLinksSchema>;\n\n// Memory Summarization (Phase 4A)\nexport const MemorySummarySchema = z.object({\n summaryText: z\n .string()\n .describe(\"A concise summary of the batch of memories\"),\n keyFacts: z\n .array(z.string())\n .describe(\"The most important facts extracted from these memories\"),\n keyEntities: z\n .array(z.string())\n .describe(\"Key entities mentioned across these memories\"),\n});\n\nexport type MemorySummaryResult = z.infer<typeof MemorySummarySchema>;\n\nexport const DaySummaryResultSchema = z.object({\n summary: z.string().min(1).describe(\"A concise end-of-day summary paragraph.\"),\n bullets: z.array(z.string()).default([]).describe(\"The most important moments from the day.\"),\n next_actions: z.array(z.string()).default([]).describe(\"Concrete next actions for tomorrow.\"),\n risks_or_open_loops: z.array(z.string()).default([]).describe(\"Open loops, blockers, or fragile assumptions still needing attention.\"),\n});\n\n// v8.15 behavior-loop auto-tuning state contracts\nexport const BehaviorLoopAdjustmentSchema = z.object({\n parameter: z.string().min(1),\n previousValue: z.number(),\n nextValue: z.number(),\n delta: z.number(),\n evidenceCount: z.number().int().min(0),\n confidence: z.number().min(0).max(1),\n reason: z.string(),\n appliedAt: z.string(),\n});\n\nexport const BehaviorLoopPolicyStateSchema = z.object({\n version: z.number().int().min(0),\n windowDays: z.number().int().min(0),\n minSignalCount: z.number().int().min(0),\n maxDeltaPerCycle: z.number().min(0).max(1),\n protectedParams: z.array(z.string()),\n adjustments: z.array(BehaviorLoopAdjustmentSchema),\n updatedAt: z.string(),\n});\n\nexport type BehaviorLoopAdjustmentParsed = z.infer<typeof BehaviorLoopAdjustmentSchema>;\nexport type BehaviorLoopPolicyStateParsed = z.infer<typeof BehaviorLoopPolicyStateSchema>;\n\nexport type MemoryActionTypeParsed = z.infer<typeof MemoryActionTypeSchema>;\nexport type MemoryActionEligibilityContextParsed = z.infer<typeof MemoryActionEligibilityContextSchema>;\nexport type ExtractedFactParsed = z.infer<typeof ExtractedFactSchema>;\nexport type EntityMentionParsed = z.infer<typeof EntityMentionSchema>;\nexport type ExtractedQuestionParsed = z.infer<typeof ExtractedQuestionSchema>;\nexport type ProactiveQuestionsResultParsed = z.infer<typeof ProactiveQuestionsResultSchema>;\nexport type ExtractionResultParsed = z.infer<typeof ExtractionResultSchema>;\nexport type ConsolidationItemParsed = z.infer<typeof ConsolidationItemSchema>;\nexport type ConsolidationResultParsed = z.infer<\n typeof ConsolidationResultSchema\n>;\n"],"mappings":";AAAA,SAAS,SAAS;AAEX,IAAM,yBAAyB,EAAE,KAAK;AAAA,EAC3C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uCAAuC,EACjD,OAAO;AAAA,EACN,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACnC,gBAAgB,EAAE,KAAK,CAAC,UAAU,aAAa,aAAa,SAAS,UAAU,CAAC;AAAA,EAChF,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACnC,QAAQ,EAAE,KAAK,CAAC,cAAc,iBAAiB,UAAU,UAAU,SAAS,CAAC;AAC/E,CAAC,EACA,OAAO;AAEH,SAAS,sBAAsB,OAAwD;AAC5F,QAAM,SAAS,uBAAuB,UAAU,KAAK;AACrD,SAAO,OAAO,UAAU,OAAO,OAAO;A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O;AAAA,EACxB,WAAW,EAAE,OAAO;AAAA,EACpB,OAAO,EAAE,OAAO;AAAA,EAChB,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,EACrC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACnC,QAAQ,EAAE,OAAO;AAAA,EACjB,WAAW,EAAE,OAAO;AACtB,CAAC;AAEM,IAAM,gCAAgC,EAAE,OAAO;AAAA,EACpD,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,EAC/B,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,EAClC,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,EACtC,kBAAkB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAAA,EACzC,iBAAiB,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EACnC,aAAa,EAAE,MAAM,4BAA4B;AAAA,EACjD,WAAW,EAAE,OAAO;AACtB,CAAC;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/temporal-supersession.ts"],"sourcesContent":["/**\n * Temporal Supersession (issue #375)\n *\n * When a new fact lands with `structuredAttributes` keyed on a known\n * `entityRef`, any prior fact whose supersession key collides with the new\n * fact's key is marked `status: \"superseded\"` and linked via\n * `supersededBy` / `supersededAt`. Recall filters those superseded memories\n * by default so agents see only the \"current\" value per entity attribute.\n *\n * The algorithm is intentionally O(N) over the memory corpus per write, but\n * skips cheaply when the new fact has no structuredAttributes. It reuses the\n * cached `readAllMemories()` path so cost is amortized with the rest of the\n * write pipeline.\n */\nimport type { MemoryFile, MemoryFrontmatter } from \"./types.js\";\nimport type { StorageManager } from \"./storage.js\";\nimport { log } from \"./logger.js\";\nimport { effectiveValidAt } from \"./temporal-validity.js\";\n\n/**\n * Shared normalization for supersession key components.\n *\n * Trims surrounding whitespace, lowercases, then collapses any run of\n * whitespace OR hyphens to a single hyphen, and strips any leading/trailing\n * hyphens that result. Both `computeSupersessionKey` and\n * `lookupAttributeByNormalizedKey` must use this so that keys produced at\n * write time and keys used at lookup time are identical regardless of how\n * the LLM encoded whitespace, hyphens, or casing (Finding B fix).\n *\n * Symmetry guarantee: `\"foo bar\"`, `\"foo-bar\"`, `\"foo - bar\"`, and\n * `\"foo bar\"` all canonicalize to `\"foo-bar\"`.\n *\n * Exported so external tests can verify the canonical form.\n */\nexport function normalizeSupersessionKey(raw: string): string {\n return raw\n .trim()\n .toLowerCase()\n .replace(/[\\s\\-]+/g, \"-\")\n // The previous line already collapsed runs to single hyphens, so ^-|-$ is\n // equivalent to ^-+|-+$ here and drops the anchored quantifier flagged by\n // CodeQL js/polynomial-redos.\n .replace(/^-|-$/g, \"\");\n}\n\n/**\n * Stable supersession key for an (entityRef, attributeName) pair.\n *\n * The algorithm is:\n * - normalize the entityRef (trim, lower-case, collapse whitespace)\n * - normalize the attributeName the same way\n * - join with `::`\n *\n * Exported so tests and tools can recompute it without depending on storage.\n */\nexport function computeSupersessionKey(\n entityRef: string | undefined,\n attributeName: string,\n): string | null {\n if (!entityRef || typeof entityRef !== \"string\") return null;\n if (!attributeName || typeof attributeName !== \"string\") return null;\n const entity = normalizeSupersessionKey(entityRef);\n const attr = normalizeSupersessionKey(attributeName);\n if (entity.length === 0 || attr.length === 0) return null;\n return `${entity}::${attr}`;\n}\n\n/**\n * Compute the full set of supersession keys for a fact with structured\n * attributes. Returns an empty array if no keys can be derived.\n */\nexport function supersessionKeysForFact(spec: {\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n}): string[] {\n if (!spec.entityRef) return [];\n if (!spec.structuredAttributes) return [];\n const keys: string[] = [];\n for (const attrName of Object.keys(spec.structuredAttributes)) {\n const key = computeSupersessionKey(spec.entityRef, attrName);\n if (key) keys.push(key);\n }\n return keys;\n}\n\n/**\n * Look up a structured-attribute value by a raw key, normalizing both sides\n * with `normalizeSupersessionKey` before comparing. This ensures that keys\n * written by the LLM with mixed case, surrounding whitespace, or internal\n * whitespace (e.g. `\"City\"`, `\" city \"`, `\"job title\"`, `\"job-title\"`)\n * are all matched against normalized keys produced by `computeSupersessionKey`\n * (Finding B fix — uses the same helper so both sides are identical).\n *\n * The storage format is NOT changed — we only normalize at lookup time.\n */\nexport function lookupAttributeByNormalizedKey(\n attributes: Record<string, unknown>,\n rawKey: string,\n): unknown {\n const normalizedTarget = normalizeSupersessionKey(rawKey);\n for (const [k, v] of Object.entries(attributes)) {\n if (normalizeSupersessionKey(k) === normalizedTarget) return v;\n }\n return undefined;\n}\n\n/**\n * Decide whether an existing memory should be superseded by a newly-written\n * memory that carries the supplied supersession key set.\n *\n * Only memories that:\n * - are currently `active`\n * - share an `entityRef` with the new fact\n * - share at least one supersession key with the new fact\n * - are older than the new fact\n * - have a conflicting value (different string) for the overlapping key\n * are eligible. This keeps supersession local to the attribute that actually\n * changed — if fact A sets `{city: Austin, tool: vim}` and fact B sets\n * `{city: NYC}`, only the city attribute is superseded, not the tool.\n */\nexport function shouldSupersedeExisting(args: {\n candidate: MemoryFrontmatter;\n newEntityRef: string;\n newAttributes: Record<string, string>;\n newCreatedAt: string;\n newMemoryId: string;\n}): { matchedKeys: string[] } | null {\n const { candidate, newEntityRef, newAttributes, newCreatedAt, newMemoryId } = args;\n\n if (candidate.id === newMemoryId) return null;\n if (candidate.status && candidate.status !== \"active\") return null;\n if (!candidate.entityRef) return null;\n if (!candidate.structuredAttributes) return null;\n\n // Reuse the shared `normalizeSupersessionKey` helper so this comparison\n // cannot drift from the canonical form used to build supersession keys\n // elsewhere in this file.\n const candidateEntityNorm = normalizeSupersessionKey(candidate.entityRef);\n const newEntityNorm = normalizeSupersessionKey(newEntityRef);\n if (candidateEntityNorm !== newEntityNorm) return null;\n\n // Must be older than the new fact's effective validity start — equal\n // timestamps are ignored to avoid races within the same millisecond. When\n // replay/import supplies source time, valid_at must drive ordering instead\n // of wall-clock persistence time.\n const candidateCreated = Date.parse(effectiveValidAt(candidate));\n const newCreated = Date.parse(newCreatedAt);\n if (!Number.isFinite(candidateCreated) || !Number.isFinite(newCreated)) return null;\n if (candidateCreated >= newCreated) return null;\n\n const matchedKeys: string[] = [];\n for (const [attrName, newValue] of Object.entries(newAttributes)) {\n // Use normalized key lookup so mixed-case or whitespace-padded keys\n // stored by the LLM are matched correctly (Finding 2 fix).\n const candidateValue = lookupAttributeByNormalizedKey(\n candidate.structuredAttributes,\n attrName,\n );\n if (candidateValue === undefined) continue;\n // Only supersede on conflicting values — identical values are a no-op.\n if (normalizeValue(String(candidateValue)) === normalizeValue(newValue)) continue;\n const key = computeSupersessionKey(newEntityRef, attrName);\n if (key) matchedKeys.push(key);\n }\n\n return matchedKeys.length > 0 ? { matchedKeys } : null;\n}\n\nfunction normalizeValue(v: string): string {\n return v.trim().toLowerCase();\n}\n\nasync function expireChildChunksForSupersededParent(args: {\n storage: StorageManager;\n allCandidates: MemoryFile[];\n parentId: string;\n newMemoryId: string;\n supersededAt: string;\n invalidAt?: string;\n}): Promise<void> {\n const processedChunkIds = new Set<string>();\n const chunks = args.allCandidates.filter(\n (candidate) => candidate.frontmatter.parentId === args.parentId,\n );\n\n for (const chunk of chunks) {\n const chunkKey = chunk.frontmatter.id ?? chunk.path;\n if (processedChunkIds.has(chunkKey)) continue;\n\n try {\n const freshChunk = await args.storage.readMemoryByPath(chunk.path);\n if (!freshChunk) continue;\n processedChunkIds.add(chunkKey);\n const freshStatus = freshChunk.frontmatter.status ?? \"active\";\n if (freshStatus !== \"active\" || freshChunk.frontmatter.supersededBy) continue;\n\n await args.storage.writeMemoryFrontmatter(\n freshChunk,\n {\n status: \"superseded\",\n supersededBy: args.newMemoryId,\n supersededAt: args.supersededAt,\n updated: args.supersededAt,\n ...(args.invalidAt && !freshChunk.frontmatter.invalid_at\n ? { invalid_at: args.invalidAt }\n : {}),\n },\n {\n actor: \"temporal-supersession\",\n reasonCode: \"structured-attribute-update-child-chunk\",\n relatedMemoryIds: [args.newMemoryId, args.parentId],\n },\n );\n } catch (err) {\n log.warn(\n `temporal-supersession: failed to expire child chunk ${chunk.frontmatter.id} for parent ${args.parentId}: ${err}`,\n );\n }\n }\n}\n\nexport interface TemporalSupersessionResult {\n supersededIds: string[];\n matchedKeys: string[];\n}\n\n/**\n * Scan existing memories and mark any that are superseded by the\n * just-written memory. Fails open on I/O errors — the new memory is already\n * on disk, and supersession is a best-effort hygiene step.\n */\nexport async function applyTemporalSupersession(args: {\n storage: StorageManager;\n newMemoryId: string;\n entityRef?: string;\n structuredAttributes?: Record<string, string>;\n createdAt: string;\n enabled: boolean;\n /**\n * When true, skip the persisted `frontmatter.created` lookup and use\n * `args.createdAt` directly as the ordering anchor. Set this on the\n * hash-dedup short-circuit path where `newMemoryId` points to an existing\n * OLD fact (no new file is written) and its persisted timestamp would be\n * stale relative to the incoming promotion event (PR #402 Finding Uyui).\n */\n useCallerTimestamp?: boolean;\n}): Promise<TemporalSupersessionResult> {\n const empty: TemporalSupersessionResult = { supersededIds: [], matchedKeys: [] };\n if (!args.enabled) return empty;\n if (!args.entityRef) return empty;\n if (!args.structuredAttributes) return empty;\n if (Object.keys(args.structuredAttributes).length === 0) return empty;\n\n const newKeys = supersessionKeysForFact({\n entityRef: args.entityRef,\n structuredAttributes: args.structuredAttributes,\n });\n if (newKeys.length === 0) return empty;\n\n let hotMemories: MemoryFile[];\n try {\n hotMemories = await args.storage.readAllMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllMemories failed: ${err}`);\n return empty;\n }\n\n // Finding 1 fix: use the on-disk effective validity start of the\n // newly-written memory rather than a wall-clock timestamp sampled after\n // `writeMemory` returns. In concurrent writers the two can differ by enough\n // to cause wrong-direction supersession. If source replay/import provided\n // valid_at, it must drive ordering; otherwise created remains the legacy\n // fallback. If the memory is not yet visible in the cache (edge case during\n // fast concurrent writes) fall back to args.createdAt.\n //\n // PR #402 round-12 (Finding Uyui): on the hash-dedup early-return path the\n // caller supplies the OLD matching fact's id as `newMemoryId` (no new file is\n // written). That makes `newMemoryFile.frontmatter.created` an arbitrarily\n // old timestamp. When `args.useCallerTimestamp` is set the caller explicitly\n // opts out of the persisted-timestamp lookup so `args.createdAt` (the\n // incoming event time: source valid_at when present, otherwise wall-clock) is\n // used directly, keeping ordering correct regardless of how old the matching\n // fact is.\n const newMemoryFile = hotMemories.find((m) => m.frontmatter.id === args.newMemoryId);\n const persistedCreatedAt = args.useCallerTimestamp\n ? args.createdAt\n : (newMemoryFile ? effectiveValidAt(newMemoryFile.frontmatter) : args.createdAt);\n\n const supersededIds: string[] = [];\n const matchedKeys = new Set<string>();\n\n // Process hot then cold. Hot-then-cold ordering is safer because hot\n // writes are more frequent and the CAS re-read guards against double-writes.\n // A Set<string> of already-processed ids ensures that a memory visible in\n // both tiers (same logical memory with different filesystem paths during a\n // migration race) is processed at most once. Keying on `frontmatter.id`\n // is correct because the same logical memory has the same id regardless of\n // which tier's directory it currently lives in (PR #402 Finding 1 fix).\n // Fall back to path-based keying when id is absent (defensive).\n const processedIds = new Set<string>();\n\n // Finding UOGi fix (round-6): readAllColdMemories() performs a full uncached\n // recursive directory scan of cold/. After Finding UTsP broadened the scan\n // to cover the entire cold root (not just facts/+corrections/), the per-call\n // cost grows with the cold tree size.\n //\n // The fix is a TTL-based in-memory cache inside StorageManager\n // (readAllColdMemories caches its result for COLD_SCAN_CACHE_TTL_MS) that is\n // shared across consecutive supersession calls within the same write burst.\n // The cache is invalidated automatically on any hot→cold demotion (which\n // calls invalidateAllMemoriesCache, which also clears the cold cache) and\n // expires after the TTL as a safety net.\n //\n // This means back-to-back structured-attribute writes in the same burst\n // (e.g. batch extraction) pay the cold I/O cost at most once, not N times.\n // Correctness is preserved because the cache TTL ensures eventual consistency\n // and the invalidation hook covers the hot→cold path.\n\n let coldMemories: MemoryFile[];\n try {\n coldMemories = await args.storage.readAllColdMemories();\n } catch (err) {\n log.warn(`temporal-supersession: readAllColdMemories failed: ${err}`);\n coldMemories = [];\n }\n\n // Combine hot and cold memories into a single scan. New memory itself is\n // excluded inline. We do NOT skip cold scan when hot produced zero\n // supersessions — the P1 finding is precisely that stale cold facts leak\n // when hot has no hits.\n const allCandidates: MemoryFile[] = [...hotMemories, ...coldMemories];\n\n for (const memory of allCandidates) {\n if (memory.frontmatter.id === args.newMemoryId) continue;\n const dedupeKey = memory.frontmatter.id ?? memory.path;\n if (processedIds.has(dedupeKey)) continue;\n const snapshotStatus = memory.frontmatter.status ?? \"active\";\n if (snapshotStatus !== \"active\") {\n // A stale non-active snapshot entry must not suppress an active copy of\n // the same logical memory that appears later in another tier. This can\n // happen during hot/cold migration races where the hot snapshot is already\n // superseded but the cold copy is still active and should be evaluated.\n continue;\n }\n // NOTE: do NOT call processedIds.add(dedupeKey) here. We defer marking\n // the id as processed until AFTER the CAS re-read succeeds. If we mark\n // it here and the re-read fails (e.g. the hot entry has already been\n // migrated to cold storage), the same logical id that appears later in\n // the cold tier scan would be silently skipped, leaving a stale cold\n // fact unsuperseded. Deferring ensures that a failed primary-tier read\n // grants the alternate tier a chance to process the same id (PR #402\n // round-6 Finding 1 fix).\n\n const decision = shouldSupersedeExisting({\n candidate: memory.frontmatter,\n newEntityRef: args.entityRef,\n newAttributes: args.structuredAttributes,\n newCreatedAt: persistedCreatedAt,\n newMemoryId: args.newMemoryId,\n });\n if (!decision) {\n // No supersession decision — safe to mark as processed now so the\n // alternate tier doesn't re-evaluate an identical non-matching entry.\n processedIds.add(dedupeKey);\n continue;\n }\n\n try {\n // CAS-style re-read immediately before the write. `readAllMemories()`\n // is a snapshot — with concurrent writers, another run may have already\n // superseded this candidate since we loaded it. If we blindly trust the\n // snapshot we can clobber a newer `supersededBy` link with a stale one.\n //\n // File storage offers no true locking, so the best we can do is:\n // 1. re-read the exact file we're about to mutate\n // 2. verify status is still \"active\" and no `supersededBy` is set\n // 3. only then issue the write\n // If the re-read shows a newer concurrent writer beat us to it, skip.\n // This CAS pattern applies equally to hot and cold tier candidates.\n // Mark as processed AFTER confirming the candidate is readable so that\n // a migration-race read failure on the hot entry does not silently\n // prevent the cold entry from being evaluated (Finding 1, round 6).\n const fresh = await args.storage.readMemoryByPath(memory.path);\n if (!fresh) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: no longer readable at ${memory.path} — leaving id available for alternate tier`,\n );\n // Do NOT add to processedIds — allow the cold-tier copy to be\n // evaluated in the next iteration of the same scan.\n continue;\n }\n // Candidate is readable — mark the id as processed now to prevent the\n // alternate tier from double-writing.\n processedIds.add(dedupeKey);\n const freshStatus = fresh.frontmatter.status ?? \"active\";\n if (freshStatus !== \"active\" || fresh.frontmatter.supersededBy) {\n log.debug(\n `[engram] temporal supersession skipped candidate ${memory.frontmatter.id}: already superseded by concurrent writer`,\n );\n continue;\n }\n\n // Finding 2 fix: the `supersededAt` / `updated` timestamps written to the\n // old fact must never run backwards relative to its own persisted\n // `created` timestamp. If the caller-supplied `args.createdAt` (which\n // represents \"when the new replacing fact was authored\") is earlier than\n // either the new fact's persisted `created` (T_new) or the old fact's\n // persisted `created` (T_old), we'd be writing a nonsensical\n // `supersededAt` that precedes the old memory's own creation. Clamp to\n // the monotonic maximum so time only moves forward.\n // This monotonic clamp is applied for both hot and cold tier writes.\n const oldCreatedMs = new Date(fresh.frontmatter.created).getTime();\n const newCreatedMs = new Date(persistedCreatedAt).getTime();\n const argCreatedMs = new Date(args.createdAt).getTime();\n const maxMs = Math.max(\n Number.isFinite(oldCreatedMs) ? oldCreatedMs : 0,\n Number.isFinite(newCreatedMs) ? newCreatedMs : 0,\n Number.isFinite(argCreatedMs) ? argCreatedMs : 0,\n );\n const supersededAt = new Date(maxMs).toISOString();\n\n // Issue #680 — explicit fact lifecycle. When the new fact\n // supersedes this one, set the predecessor's `invalid_at` to the\n // successor's effective valid_at. Skip when the predecessor\n // already carries an `invalid_at` so manual / earlier values\n // are preserved (idempotent).\n //\n // Codex P1 on PR #713: in the hash-dedup early-return path\n // (`useCallerTimestamp: true`), `newMemoryFile` is actually the\n // OLD matching fact — no new file was written — so its\n // `valid_at` is the predecessor's own old timestamp, not the\n // successor's effective time. Use `persistedCreatedAt`\n // directly in that path so the predecessor's invalid_at lines\n // up with the caller's wall-clock, not the matching fact's old\n // valid_at. The non-dedup path keeps the previous behavior\n // (prefer the new file's explicit valid_at, fall back to its\n // persisted created).\n let invalidAtPatch: string | undefined;\n if (!fresh.frontmatter.invalid_at) {\n if (args.useCallerTimestamp) {\n invalidAtPatch = persistedCreatedAt;\n } else {\n const newValidAt = newMemoryFile?.frontmatter.valid_at?.trim();\n invalidAtPatch =\n newValidAt && newValidAt.length > 0 ? newValidAt : persistedCreatedAt;\n }\n }\n const wrote = await args.storage.writeMemoryFrontmatter(\n fresh,\n {\n status: \"superseded\",\n supersededBy: args.newMemoryId,\n supersededAt,\n updated: supersededAt,\n ...(invalidAtPatch ? { invalid_at: invalidAtPatch } : {}),\n },\n {\n actor: \"temporal-supersession\",\n reasonCode: \"structured-attribute-update\",\n relatedMemoryIds: [args.newMemoryId],\n },\n );\n if (wrote) {\n supersededIds.push(memory.frontmatter.id);\n for (const key of decision.matchedKeys) matchedKeys.add(key);\n await expireChildChunksForSupersededParent({\n storage: args.storage,\n allCandidates,\n parentId: fresh.frontmatter.id,\n newMemoryId: args.newMemoryId,\n supersededAt,\n invalidAt: invalidAtPatch ?? fresh.frontmatter.invalid_at,\n });\n // Issue #1579 — emit a tombstone for the superseded memory so it\n // cannot resurrect through re-extraction / import / consolidation /\n // dreams / pattern-reinforcement. The supersession key is the first\n // matched key (the write-time supersession identity). Best-effort:\n // a tombstone append failure is logged but never fails supersession\n // (gotcha #13).\n // Issue #1579 thread ObteS: persist ALL matched supersession keys, not\n // just the first. A later paraphrased re-observation may derive the\n // same entity but place the tombstoned attribute at a different\n // position in structuredAttributes; without an entry for every matched\n // key, the keyed tier would miss and the fact could resurrect as\n // active. Pass the canonical contentHash from the retired memory's\n // frontmatter so the tombstone's exact tier matches re-extraction\n // (review: citation-hash alignment). The rawContent is the stored body;\n // the StorageManager.appendTombstone chokepoint strips citation\n // annotations for the normalized-text tier.\n const keysToTombstone =\n decision.matchedKeys.length > 0 ? decision.matchedKeys : [undefined];\n for (const key of keysToTombstone) {\n try {\n await args.storage.appendTombstone({\n reason: \"supersession\",\n createdBy: \"supersession\",\n sourceMemoryId: fresh.frontmatter.id,\n ...(fresh.frontmatter.contentHash\n ? { contentHash: fresh.frontmatter.contentHash }\n : {}),\n rawContent: fresh.content,\n ...(fresh.frontmatter.entityRef ? { entityRef: fresh.frontmatter.entityRef } : {}),\n ...(key ? { supersessionKey: key } : {}),\n createdAt: supersededAt,\n });\n } catch (tombErr) {\n log.warn(\n `temporal-supersession: tombstone emit failed for ${fresh.frontmatter.id}${key ? ` (key=${key})` : \"\"} : ${tombErr}`,\n );\n }\n }\n }\n } catch (err) {\n log.warn(\n `temporal-supersession: failed to mark ${memory.frontmatter.id} superseded: ${err}`,\n );\n }\n }\n\n if (supersededIds.length > 0) {\n log.debug(\n `temporal-supersession: marked ${supersededIds.length} memories superseded by ${args.newMemoryId} (keys=${Array.from(matchedKeys).join(\",\")})`,\n );\n }\n\n return { supersededIds, matchedKeys: Array.from(matchedKeys) };\n}\n\n/**\n * Recall-side filter: returns true when the candidate should be excluded\n * from recall because it has been temporally superseded. When\n * `includeInRecall` is true, this always returns false (the fact is kept),\n * matching the audit/history opt-in described in the config.\n */\nexport function shouldFilterSupersededFromRecall(\n frontmatter: MemoryFrontmatter,\n options: { enabled: boolean; includeInRecall: boolean },\n): boolean {\n if (!options.enabled) return false;\n if (options.includeInRecall) return false;\n return frontmatter.status === \"superseded\";\n}\n"],"mappings":";;;;;;;;AAkCO,SAAS,yBAAyB,KAAqB;AAC5D,SAAO,IACJ,KAAK,EACL,YAAY,EACZ,QAAQ,YAAY,GAAG,EAIvB,QAAQ,UAAU,EAAE;AACzB;AAYO,SAAS,uBACd,WACA,eACe;AACf,MAAI,CAAC,aAAa,OAAO,cAAc,SAAU,QAAO;AACxD,MAAI,CAAC,iBA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C,WAAW;AAAA,YACb,CAAC;AAAA,UACH,SAAS,SAAS;AAChB,gBAAI;AAAA,cACF,oDAAoD,MAAM,YAAY,EAAE,GAAG,MAAM,SAAS,GAAG,MAAM,EAAE,MAAM,OAAO;AAAA,YACpH;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF,SAAS,KAAK;AACZ,UAAI;AAAA,QACF,yCAAyC,OAAO,YAAY,EAAE,gBAAgB,GAAG;AAAA,MACnF;AAAA,IACF;AAAA,EACF;AAEA,MAAI,cAAc,SAAS,GAAG;AAC5B,QAAI;AAAA,MACF,iCAAiC,cAAc,MAAM,2BAA2B,KAAK,WAAW,UAAU,MAAM,KAAK,WAAW,EAAE,KAAK,GAAG,CAAC;AAAA,IAC7I;AAAA,EACF;AAEA,SAAO,EAAE,eAAe,aAAa,MAAM,KAAK,WAAW,EAAE;AAC/D;AAQO,SAAS,iCACd,aACA,SACS;AACT,MAAI,CAAC,QAAQ,QAAS,QAAO;AAC7B,MAAI,QAAQ,gBAAiB,QAAO;AACpC,SAAO,YAAY,WAAW;AAChC;","names":[]}
@@ -1,111 +0,0 @@
1
- import {
2
- assertIsoRecordedAt,
3
- assertSafePathSegment,
4
- assertString,
5
- isRecord,
6
- optionalStringArray,
7
- validateStringRecord
8
- } from "./chunk-A2IYSXDQ.js";
9
- import {
10
- listJsonFiles,
11
- readJsonFile
12
- } from "./chunk-LPSF4OQH.js";
13
-
14
- // src/cue-anchors.ts
15
- import path from "path";
16
- import { mkdir, writeFile } from "fs/promises";
17
- function validateAnchorType(raw) {
18
- const value = assertString(raw, "anchorType");
19
- if (!["entity", "file", "tool", "outcome", "constraint", "date"].includes(value)) {
20
- throw new Error("anchorType must be one of entity|file|tool|outcome|constraint|date");
21
- }
22
- return value;
23
- }
24
- function validateNodeRefs(raw) {
25
- const nodeRefs = optionalStringArray(raw, "nodeRefs");
26
- if (!nodeRefs || nodeRefs.length === 0) {
27
- throw new Error("nodeRefs must contain at least one node reference");
28
- }
29
- return nodeRefs.map((nodeRef, index) => assertSafePathSegment(nodeRef, `nodeRefs[${index}]`));
30
- }
31
- function resolveCueAnchorStoreDir(abstractionNodeStoreDir, overrideDir) {
32
- if (typeof overrideDir === "string" && overrideDir.trim().length > 0) {
33
- return overrideDir.trim();
34
- }
35
- return path.join(abstractionNodeStoreDir, "anchors");
36
- }
37
- function validateCueAnchor(raw) {
38
- if (!isRecord(raw)) throw new Error("cue anchor must be an object");
39
- if (raw.schemaVersion !== 1) throw new Error("schemaVersion must be 1");
40
- return {
41
- schemaVersion: 1,
42
- anchorId: assertSafePathSegment(assertString(raw.anchorId, "anchorId"), "anchorId"),
43
- anchorType: validateAnchorType(raw.anchorType),
44
- anchorValue: assertString(raw.anchorValue, "anchorValue"),
45
- normalizedCue: assertString(raw.normalizedCue, "normalizedCue"),
46
- recordedAt: assertIsoRecordedAt(assertString(raw.recordedAt, "recordedAt")),
47
- sessionKey: assertString(raw.sessionKey, "sessionKey"),
48
- nodeRefs: validateNodeRefs(raw.nodeRefs),
49
- tags: optionalStringArray(raw.tags, "tags"),
50
- metadata: validateStringRecord(raw.metadata, "metadata")
51
- };
52
- }
53
- async function recordCueAnchor(options) {
54
- const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length ? options.abstractionNodeStoreDir.trim() : path.join(options.memoryDir, "state", "abstraction-nodes");
55
- const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);
56
- const validated = validateCueAnchor(options.anchor);
57
- const anchorDir = path.join(rootDir, validated.anchorType);
58
- const filePath = path.join(anchorDir, `${validated.anchorId}.json`);
59
- await mkdir(anchorDir, { recursive: true });
60
- await writeFile(filePath, JSON.stringify(validated, null, 2), "utf8");
61
- return filePath;
62
- }
63
- async function getCueAnchorStoreStatus(options) {
64
- const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length ? options.abstractionNodeStoreDir.trim() : path.join(options.memoryDir, "state", "abstraction-nodes");
65
- const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);
66
- const files = await listJsonFiles(rootDir);
67
- const anchors = [];
68
- const invalidAnchors = [];
69
- for (const filePath of files) {
70
- try {
71
- anchors.push(validateCueAnchor(await readJsonFile(filePath)));
72
- } catch (error) {
73
- invalidAnchors.push({
74
- path: filePath,
75
- error: error instanceof Error ? error.message : String(error)
76
- });
77
- }
78
- }
79
- anchors.sort((a, b) => b.recordedAt.localeCompare(a.recordedAt));
80
- const byType = {};
81
- let totalNodeRefs = 0;
82
- for (const anchor of anchors) {
83
- byType[anchor.anchorType] = (byType[anchor.anchorType] ?? 0) + 1;
84
- totalNodeRefs += anchor.nodeRefs.length;
85
- }
86
- return {
87
- enabled: options.enabled,
88
- anchorsEnabled: options.anchorsEnabled,
89
- rootDir,
90
- anchors: {
91
- total: files.length,
92
- valid: anchors.length,
93
- invalid: invalidAnchors.length,
94
- byType,
95
- totalNodeRefs,
96
- latestAnchorId: anchors[0]?.anchorId,
97
- latestRecordedAt: anchors[0]?.recordedAt,
98
- latestSessionKey: anchors[0]?.sessionKey
99
- },
100
- latestAnchor: anchors[0],
101
- invalidAnchors
102
- };
103
- }
104
-
105
- export {
106
- resolveCueAnchorStoreDir,
107
- validateCueAnchor,
108
- recordCueAnchor,
109
- getCueAnchorStoreStatus
110
- };
111
- //# sourceMappingURL=chunk-FZZ2QTJI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/cue-anchors.ts"],"sourcesContent":["import path from \"node:path\";\nimport { mkdir, writeFile } from \"node:fs/promises\";\nimport { listJsonFiles, readJsonFile } from \"./json-store.js\";\nimport {\n assertIsoRecordedAt,\n assertSafePathSegment,\n assertString,\n isRecord,\n optionalStringArray,\n validateStringRecord,\n} from \"./store-contract.js\";\n\nexport type CueAnchorType = \"entity\" | \"file\" | \"tool\" | \"outcome\" | \"constraint\" | \"date\";\n\nexport interface CueAnchor {\n schemaVersion: 1;\n anchorId: string;\n anchorType: CueAnchorType;\n anchorValue: string;\n normalizedCue: string;\n recordedAt: string;\n sessionKey: string;\n nodeRefs: string[];\n tags?: string[];\n metadata?: Record<string, string>;\n}\n\nexport interface CueAnchorStoreStatus {\n enabled: boolean;\n anchorsEnabled: boolean;\n rootDir: string;\n anchors: {\n total: number;\n valid: number;\n invalid: number;\n byType: Partial<Record<CueAnchorType, number>>;\n totalNodeRefs: number;\n latestAnchorId?: string;\n latestRecordedAt?: string;\n latestSessionKey?: string;\n };\n latestAnchor?: CueAnchor;\n invalidAnchors: Array<{\n path: string;\n error: string;\n }>;\n}\n\nfunction validateAnchorType(raw: unknown): CueAnchorType {\n const value = assertString(raw, \"anchorType\");\n if (![\"entity\", \"file\", \"tool\", \"outcome\", \"constraint\", \"date\"].includes(value)) {\n throw new Error(\"anchorType must be one of entity|file|tool|outcome|constraint|date\");\n }\n return value as CueAnchorType;\n}\n\nfunction validateNodeRefs(raw: unknown): string[] {\n const nodeRefs = optionalStringArray(raw, \"nodeRefs\");\n if (!nodeRefs || nodeRefs.length === 0) {\n throw new Error(\"nodeRefs must contain at least one node reference\");\n }\n return nodeRefs.map((nodeRef, index) => assertSafePathSegment(nodeRef, `nodeRefs[${index}]`));\n}\n\nexport function resolveCueAnchorStoreDir(\n abstractionNodeStoreDir: string,\n overrideDir?: string,\n): string {\n if (typeof overrideDir === \"string\" && overrideDir.trim().length > 0) {\n return overrideDir.trim();\n }\n return path.join(abstractionNodeStoreDir, \"anchors\");\n}\n\nexport function validateCueAnchor(raw: unknown): CueAnchor {\n if (!isRecord(raw)) throw new Error(\"cue anchor must be an object\");\n if (raw.schemaVersion !== 1) throw new Error(\"schemaVersion must be 1\");\n\n return {\n schemaVersion: 1,\n anchorId: assertSafePathSegment(assertString(raw.anchorId, \"anchorId\"), \"anchorId\"),\n anchorType: validateAnchorType(raw.anchorType),\n anchorValue: assertString(raw.anchorValue, \"anchorValue\"),\n normalizedCue: assertString(raw.normalizedCue, \"normalizedCue\"),\n recordedAt: assertIsoRecordedAt(assertString(raw.recordedAt, \"recordedAt\")),\n sessionKey: assertString(raw.sessionKey, \"sessionKey\"),\n nodeRefs: validateNodeRefs(raw.nodeRefs),\n tags: optionalStringArray(raw.tags, \"tags\"),\n metadata: validateStringRecord(raw.metadata, \"metadata\"),\n };\n}\n\nexport async function recordCueAnchor(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n anchor: CueAnchor;\n}): Promise<string> {\n const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length\n ? options.abstractionNodeStoreDir.trim()\n : path.join(options.memoryDir, \"state\", \"abstraction-nodes\");\n const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const validated = validateCueAnchor(options.anchor);\n const anchorDir = path.join(rootDir, validated.anchorType);\n const filePath = path.join(anchorDir, `${validated.anchorId}.json`);\n await mkdir(anchorDir, { recursive: true });\n await writeFile(filePath, JSON.stringify(validated, null, 2), \"utf8\");\n return filePath;\n}\n\nexport async function getCueAnchorStoreStatus(options: {\n memoryDir: string;\n abstractionNodeStoreDir?: string;\n cueAnchorStoreDir?: string;\n enabled: boolean;\n anchorsEnabled: boolean;\n}): Promise<CueAnchorStoreStatus> {\n const abstractionNodeStoreDir = options.abstractionNodeStoreDir?.trim().length\n ? options.abstractionNodeStoreDir.trim()\n : path.join(options.memoryDir, \"state\", \"abstraction-nodes\");\n const rootDir = resolveCueAnchorStoreDir(abstractionNodeStoreDir, options.cueAnchorStoreDir);\n const files = await listJsonFiles(rootDir);\n const anchors: CueAnchor[] = [];\n const invalidAnchors: Array<{ path: string; error: string }> = [];\n\n for (const filePath of files) {\n try {\n anchors.push(validateCueAnchor(await readJsonFile(filePath)));\n } catch (error) {\n invalidAnchors.push({\n path: filePath,\n error: error instanceof Error ? error.message : String(error),\n });\n }\n }\n\n anchors.sort((a, b) => b.recordedAt.localeCompare(a.recordedAt));\n\n const byType: Partial<Record<CueAnchorType, number>> = {};\n let totalNodeRefs = 0;\n for (const anchor of anchors) {\n byType[anchor.anchorType] = (byType[anchor.anchorType] ?? 0) + 1;\n totalNodeRefs += anchor.nodeRefs.length;\n }\n\n return {\n enabled: options.enabled,\n anchorsEnabled: options.anchorsEnabled,\n rootDir,\n anchors: {\n total: files.length,\n valid: anchors.length,\n invalid: invalidAnchors.length,\n byType,\n totalNodeRefs,\n latestAnchorId: anchors[0]?.anchorId,\n latestRecordedAt: anchors[0]?.recordedAt,\n latestSessionKey: anchors[0]?.sessionKey,\n },\n latestAnchor: anchors[0],\n invalidAnchors,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,OAAO,UAAU;AACjB,SAAS,OAAO,iBAAiB;AA+CjC,SAAS,mBAAmB,KAA6B;AACvD,QAAM,QAAQ,aAAa,KAAK,YAAY;AAC5C,MAAI,CAAC,CAAC,UAAU,QAAQ,QAAQ,WAAW,cAAc,MAAM,EAAE,SAAS,KAAK,GAAG;AAChF,UAAM,IAAI,MAAM,oEAAoE;AAAA,EACtF;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,KAAwB;AAChD,QAAM,WAAW,oBAAoB,KAAK,UAAU;AACpD,MAAI,CAAC,YAAY,SAAS,WAAW,GAAG;AACtC,UAAM,IAAI,MAAM,mDAAmD;AAAA,EACrE;AACA,SAAO,SAAS,IAAI,CAAC,SAAS,UAAU,sBAAsB,SAAS,YAAY,KAAK,GAAG,CAAC;AAC9F;AAEO,SAAS,yBACd,yBACA,aACQ;AACR,MAAI,OAAO,gBAAgB,YAAY,YAAY,KAAK,EAAE,SAAS,GAAG;AACpE,WAAO,YAAY,KAAK;AAAA,EAC1B;AACA,SAAO,KAAK,KAAK,yBAAyB,SAAS;AACrD;AAEO,SAAS,kBAAkB,KAAyB;AACzD,MAAI,CAAC,SAAS,GAAG,EAAG,OAAM,IAAI,MAAM,8BAA8B;AAClE,MAAI,IAAI,kBAAkB,EAAG,OAAM,IAAI,MAAM,yBAAyB;AAEtE,SAAO;AAAA,IACL,eAAe;AAAA,IACf,U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QAAI;AACF,cAAQ,KAAK,kBAAkB,MAAM,aAAa,QAAQ,CAAC,CAAC;AAAA,IAC9D,SAAS,OAAO;AACd,qBAAe,KAAK;AAAA,QAClB,MAAM;AAAA,QACN,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,CAAC;AAAA,IACH;AAAA,EACF;AAEA,UAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,WAAW,cAAc,EAAE,UAAU,CAAC;AAE/D,QAAM,SAAiD,CAAC;AACxD,MAAI,gBAAgB;AACpB,aAAW,UAAU,SAAS;AAC5B,WAAO,OAAO,UAAU,KAAK,OAAO,OAAO,UAAU,KAAK,KAAK;AAC/D,qBAAiB,OAAO,SAAS;AAAA,EACnC;AAEA,SAAO;AAAA,IACL,SAAS,QAAQ;AAAA,IACjB,gBAAgB,QAAQ;AAAA,IACxB;AAAA,IACA,SAAS;AAAA,MACP,OAAO,MAAM;AAAA,MACb,OAAO,QAAQ;AAAA,MACf,SAAS,eAAe;AAAA,MACxB;AAAA,MACA;AAAA,MACA,gBAAgB,QAAQ,CAAC,GAAG;AAAA,MAC5B,kBAAkB,QAAQ,CAAC,GAAG;AAAA,MAC9B,kBAAkB,QAAQ,CAAC,GAAG;AAAA,IAChC;AAAA,IACA,cAAc,QAAQ,CAAC;AAAA,IACvB;AAAA,EACF;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/extraction-prompt.ts"],"sourcesContent":["/**\n * Extraction prompt construction (issue #1995 sibling extraction).\n *\n * The system prompt, its JSON response shape, and the placeholder table\n * derived from that shape are prompt DATA, not engine behavior. They live here\n * so `extraction.ts` holds the pipeline and one module owns the text every\n * extraction path — local LLM, direct client, gateway fallback — sends.\n */\n\nimport { AMBIENT_CAPTURE_PROMPT_SECTION, AMBIENT_SPECULATIVE_TIER_CLAUSE } from \"./ambient-provenance.js\";\nimport { resolveMemoryLifecycleCapabilities, resolveRecallAuxiliaryCapabilities } from \"./capabilities.js\";\nimport type { PluginConfig } from \"./types.js\";\n\nexport const EXTRACTION_RESPONSE_SHAPE = `{\n \"facts\": [{\n \"category\": \"<category>\",\n \"content\": \"<source-grounded statement>\",\n \"confidence\": 0.0,\n \"tags\": [\"<tag>\"],\n \"entityRef\": \"<optional normalized-name>\",\n \"promptedByQuestion\": \"<optional source-grounded question>\",\n \"quote\": \"<optional exact contiguous source span>\",\n \"scope\": \"<optional project-or-global>\",\n \"structuredAttributes\": {\"<key>\": \"<value>\"},\n \"procedureSteps\": [{\"order\": 1, \"intent\": \"<step>\"}, {\"order\": 2, \"intent\": \"<step>\"}],\n \"reasoningTrace\": {\n \"steps\": [{\"order\": 1, \"description\": \"<step>\"}, {\"order\": 2, \"description\": \"<step>\"}],\n \"finalAnswer\": \"<answer>\",\n \"observedOutcome\": \"<optional outcome>\"\n },\n \"eventTime\": \"<optional source temporal expression>\"\n }],\n \"entities\": [{\n \"name\": \"<normalized-name>\",\n \"type\": \"<entity-type>\",\n \"facts\": [\"<source-grounded statement>\"],\n \"promptedByQuestion\": \"<optional source-grounded question>\",\n \"structuredSections\": [{\"key\": \"<section-key>\", \"title\": \"<section-title>\", \"facts\": [\"<source-grounded statement>\"]}]\n }],\n \"profileUpdates\": [\"<source-grounded profile update>\"],\n \"questions\": [{\"question\": \"<source-grounded unresolved question>\", \"context\": \"<source-grounded context>\", \"priority\": 0.0}],\n \"identityReflection\": \"<conversation-grounded agent reflection>\",\n \"relationships\": [{\"source\": \"<normalized-name>\", \"target\": \"<normalized-name>\", \"label\": \"<source-grounded relationship>\"}]\n}`;\nexport const EXTRACTION_RESPONSE_PLACEHOLDERS: Record<string, true> = {};\nfor (const placeholder of EXTRACTION_RESPONSE_SHAPE.match(/<[^<>\\r\\n]+>/g) ?? []) {\n EXTRACTION_RESPONSE_PLACEHOLDERS[placeholder] = true;\n}\n\n/**\n * Bi-temporal event-time extraction instruction (#1578 PR2). Emitted on\n * every extraction entry path when `temporal.biTemporal` is on so the LLM\n * emits an optional per-fact `eventTime` expression. The expression is\n * resolved against the source turn timestamp at write time — never\n * wall-clock — so replay/import of old transcripts anchors correctly.\n * Returns an empty string when the gate is off (byte-identical prompt).\n */\nexport function eventTimePromptInstruction(config: PluginConfig): string {\n if (!config.temporalBiTemporal) return \"\";\n return `\nWhen a fact states when it became or stopped being true, copy that explicit temporal expression verbatim into \"eventTime\". Omit \"eventTime\" when no such expression appears; never infer dates.`;\n}\n\n/**\n * Build extraction instructions shared between local and cloud LLM.\n *\n * `ambientCapture` marks input from an always-on recorder, which may carry\n * speech the user never authored (issue #2294).\n */\nexport function buildExtractionInstructions(config: PluginConfig, existingEntities?: string[], ambientCapture = false): string {\n const lifecycleCaps = resolveMemoryLifecycleCapabilities(config);\n return `You are a memory extraction system. Analyze the following conversation and extract durable, reusable memories.\n\nMemory categories:\n- fact: Objective information about the world\n- preference: User likes, dislikes, or stylistic choices\n- correction: User correcting a mistake or misconception (highest priority)\n- entity: Information about a specific person, project, tool, or company\n- decision: A choice that was made with rationale\n- relationship: How two entities relate to each other (e.g., \"Alice is Bob's manager\", \"Acme Corp uses Shopify\")\n- principle: Durable rules, values, or operating beliefs (e.g., \"never use Chat Completions API\")\n- commitment: Promises, obligations, or deadlines (e.g., \"deploy by Friday\", \"call accountant Monday\")\n- moment: Emotionally significant events or milestones (e.g., \"first successful deployment of engram\")\n- skill: Capabilities the user or agent has demonstrated (e.g., \"user is proficient with Kubernetes\")${resolveRecallAuxiliaryCapabilities(config).causalRuleExtraction ? `\n- rule: Causal rules discovered through experience (format: \"IF <condition> THEN <action/outcome>\", e.g., \"IF Shopify API returns 401 THEN the admin token is missing read_products scope\")` : \"\"}\n- procedure: A reusable workflow the user wants remembered the same way across sessions. Set category to \"procedure\". Use \"content\" for a short title that includes explicit trigger phrasing (e.g. \"When you deploy to production…\", \"Whenever you ship a release…\"). Add \"procedureSteps\": an array of at least two objects {\"order\": number, \"intent\": \"concrete step description\"} in execution order. Optional per-step \"toolCall\": {\"kind\": \"…\", \"signature\": \"…\"}, \"expectedOutcome\", \"optional\": true.\n- reasoning_trace: A stored solution chain / chain-of-thought the user walked through to solve a problem (e.g. \"Here's how I debugged the latency spike: first I checked…, then I…, finally I…\"). Set category to \"reasoning_trace\". Use \"content\" for a short title summarising the problem (e.g. \"How I debugged the staging latency spike\"). Add \"reasoningTrace\": {\"steps\": [{\"order\": number, \"description\": \"what happened at this step\"}, …], \"finalAnswer\": \"the conclusion or answer\", \"observedOutcome\": \"optional confirmation of how it played out\"}. Require at least two ordered steps AND a finalAnswer. Use this category only when the user explicitly narrates their reasoning — not for ordinary decisions (use \"decision\") or reusable workflows (use \"procedure\").\n\nRules:\n- Only extract genuinely new information worth remembering across sessions.\n- Statements must be grounded in the conversation.\n- Do not treat instruction text, schema placeholders, or examples as conversation evidence.\n- Lines labelled [context user] or [context assistant] are reference context only. They may resolve references or complete a question-and-answer pair in a normal turn, but never alone establish durable information.\n- Skip transient task details and operational noise, including routine scheduler, monitoring, or automation status.\n- Priority: corrections > principles${resolveRecallAuxiliaryCapabilities(config).causalRuleExtraction ? \" > rules\" : \"\"} > preferences > commitments > decisions > relationships > entities > moments > skills > facts\n- Corrections get highest confidence.\n- Each fact should be a standalone, self-contained statement.\n- Entity references should use normalized names (lowercase, hyphenated: \"jane-doe\", \"acme-corp\")\n- CRITICAL: Entity names must be CANONICAL. Always use the hyphenated multi-word form: \"acme-corp\" NOT \"acmecorp\" or \"acme\". \"jane-doe\" NOT \"janedoe\" or \"jane\". If unsure, prefer the most specific full name.\n- Avoid creating entities typed as \"other\" when a more specific type fits (company, project, tool, person, place)\n- When entity facts clearly belong under a durable named heading, add them to entity.structuredSections as {key, title, facts}. Example person headings: \"Beliefs\", \"Communication Style\", \"Building / Working On\". Leave structuredSections empty when no stable heading fits.\n- Tags should be concise and reusable (e.g., \"coding-style\", \"personal\", \"tools\")\n- When a fact contains measurable, categorical, or precisely valued data, include a \"structuredAttributes\" field with key-value string pairs (e.g., {\"price\": \"29.99\", \"brand\": \"Sony\"}, {\"date\": \"2024-03-15\", \"location\": \"SF\"}, {\"chosen\": \"PostgreSQL\", \"rejected\": \"MongoDB\"}). Only for concrete values, not narrative content.\n- Set confidence using these tiers:\n * Explicit (0.95-1.0): Direct user statements — \"I prefer X\", \"my name is Y\"\n * Implied (0.70-0.94): Strong contextual inference — user consistently does X, clear from conversation flow\n * Inferred (0.40-0.69): Pattern recognition — reasonable guess from limited evidence\n * Speculative (0.00-0.39): Tentative hypothesis — weak signal, needs future confirmation. Speculative memories auto-expire after 30 days if not confirmed.${ambientCapture ? AMBIENT_SPECULATIVE_TIER_CLAUSE : \"\"}${config.provenance?.enabled ? `\n- Source quotes: For each fact, include a \"quote\" field containing the EXACT verbatim words from the conversation that support the fact. Copy a contiguous span from a single speaker turn (not a paraphrase, not a summary). Cap at ~300 characters. This grounds every memory in the literal utterance that created it.` : \"\"}\n- For commitments: include any deadline or timeframe mentioned${lifecycleCaps.extractionScopeClassification ? `\n\nScope classification:\nFor each fact, set \"scope\" to one of:\n- \"global\" — knowledge that applies across projects: core framework/library bugs, API behavior patterns, user preferences (editor, language, style), general coding patterns, infrastructure knowledge, technology facts not tied to one codebase\n- \"project\" — knowledge specific to one codebase: file paths, environment configs, deployment details, project-specific workarounds, team/stakeholder info tied to one project, repo-specific conventions. Tool, command, or CLI-flag instructions TIED TO ONE AGENT are also \"project\", because the same tool name means different things in different agent integrations (a \"search\" tool may search repository code in one agent and the web in another); when keeping such an agent-tied instruction, the fact text MUST name the originating agent as a leading \"In <agent>,\" clause (e.g. \"In Pi, use the search tool with a repository path.\"). A tool/command fact that holds in every agent and every repo is NOT agent-tied — leave it \"global\" and do not add a qualifier (e.g. \"\\`git status --short\\` emits compact output\"). Examples: \"In Pi, the search tool takes a repository path\" -> \"project\"; \"\\`git status --short\\` emits compact output\" -> \"global\".\nWhen in doubt, prefer \"project\" — it is safer to keep knowledge scoped narrowly.` : \"\"}\n${ambientCapture ? `${AMBIENT_CAPTURE_PROMPT_SECTION}\n` : \"\"}\nEntity creation rules (STRICT):\n- Only create entities for DURABLE things: real people, companies, products, tools, ongoing projects\n- NEVER create entities for transient items: individual PRs, branches, Jira tickets, meetings, agent task IDs, log files, database tables, cron job runs, sessions\n- When you learn something about a transient item (e.g., PR #58 fixed a bug), store it as a FACT with an entityRef to the parent project — do NOT create an entity for the PR itself\n- Prefer attaching facts to broad parent entities rather than creating sub-entities. E.g., \"acme-store uses Algolia for search\" is a fact on entity \"acme-store\", NOT a new entity \"acme-store-algolia-connector\"\n- The entity list should be SHORT — think \"things that would have their own Wikipedia page\" not \"things mentioned in passing\"\n\n${existingEntities && existingEntities.length > 0 ? `\nKNOWN ENTITIES (use these exact names when referencing existing things):\n${existingEntities.join(\", \")}\n\nWhen you see something that matches a known entity, use THAT name exactly. Only create a NEW entity if nothing in this list represents it.\n` : \"\"}\n${eventTimePromptInstruction(config)}\nAlso extract relationships between entities mentioned in the conversation.\n- Format: {source: \"entity-name\", target: \"entity-name\", label: \"relationship description\"}\n- Max 5 relationships per extraction\n- Only include clear, durable relationships (e.g., \"works at\", \"created\", \"manages\", \"uses\")\n- Use normalized entity names (e.g., \"person-jane-doe\", \"company-acme-corp\")\n\nQuestions are optional. Include only source-grounded unresolved questions that would be useful in future sessions; otherwise return an empty array.\n\nFinally, write a brief identity reflection about the agent who had this conversation, based only on the conversation. Do not write about the extraction process.`;\n}\n"],"mappings":";;;;;;;;;;AAaO,IAAM,4BAA4B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA+BlC,IAAM,mCAAyD,CAAC;AACvE,WAAW,eAAe,0BAA0B,MAAM,eAAe,KAAK,CAAC,GAAG;AAChF,mCAAiC,WAAW,IAAI;AAClD;AAUO,SAAS,2BAA2B,QAA8B;AACvE,MAAI,CAAC,OAA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