@remnic/core 9.69.22 → 9.69.24

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 (772) hide show
  1. package/dist/abstraction-nodes.js +3 -2
  2. package/dist/access-admin-ops-surface.d.ts +14 -12
  3. package/dist/access-admin-ops-surface.js +94 -91
  4. package/dist/access-authorization-probe.d.ts +14 -12
  5. package/dist/access-authorization-probe.js +95 -92
  6. package/dist/access-boundary.d.ts +14 -12
  7. package/dist/access-boundary.js +94 -91
  8. package/dist/access-citation-namespace.js +3 -3
  9. package/dist/access-cli.js +200 -195
  10. package/dist/access-cli.js.map +1 -1
  11. package/dist/access-coding-context-resolution.d.ts +2 -1
  12. package/dist/access-extraction-force-flush.d.ts +14 -12
  13. package/dist/access-extraction-force-flush.js +94 -91
  14. package/dist/access-health-types.d.ts +2 -1
  15. package/dist/access-http-briefing.d.ts +156 -0
  16. package/dist/access-http-briefing.js +233 -0
  17. package/dist/access-http-lcm-compaction.d.ts +14 -12
  18. package/dist/access-http-lifecycle-flush.d.ts +14 -12
  19. package/dist/access-http-offline-stream.d.ts +14 -12
  20. package/dist/access-http-query.d.ts +3 -2
  21. package/dist/access-http-query.js +96 -93
  22. package/dist/access-http.d.ts +15 -13
  23. package/dist/access-http.js +119 -114
  24. package/dist/access-identity-continuity-surface.d.ts +12 -10
  25. package/dist/access-identity-continuity-surface.js +94 -91
  26. package/dist/access-lcm-surface.d.ts +14 -12
  27. package/dist/access-lcm-surface.js +94 -91
  28. package/dist/access-mcp.d.ts +14 -12
  29. package/dist/access-mcp.js +105 -101
  30. package/dist/access-memory-search-fanout.d.ts +3 -2
  31. package/dist/{access-namespace-preflight-BMHhxoL9.d.ts → access-namespace-preflight-BsvmyENS.d.ts} +1 -1
  32. package/dist/access-namespace-preflight.d.ts +4 -3
  33. package/dist/access-namespace-preflight.js +94 -91
  34. package/dist/access-observe-transcript.d.ts +12 -10
  35. package/dist/access-observe-write-surface.d.ts +14 -12
  36. package/dist/access-observe-write-surface.js +94 -91
  37. package/dist/access-offline-manifest.d.ts +12 -10
  38. package/dist/access-offline-manifest.js +15 -15
  39. package/dist/access-operations-batch.js +99 -95
  40. package/dist/access-operations.d.ts +14 -12
  41. package/dist/access-operations.js +104 -100
  42. package/dist/access-recall-concurrency.d.ts +14 -12
  43. package/dist/access-recall-concurrency.js +94 -91
  44. package/dist/access-recall-response.d.ts +14 -12
  45. package/dist/access-recall-response.js +94 -91
  46. package/dist/access-recall-surface.d.ts +14 -12
  47. package/dist/access-recall-surface.js +94 -91
  48. package/dist/access-schema.js +8 -7
  49. package/dist/{access-service-BlsNXFwx.d.ts → access-service-DWdY9Mlk.d.ts} +7 -7
  50. package/dist/access-service-helpers.d.ts +14 -12
  51. package/dist/access-service.d.ts +14 -12
  52. package/dist/access-service.js +94 -91
  53. package/dist/access-surface-catalog.d.ts +14 -12
  54. package/dist/access-surface-catalog.js +97 -93
  55. package/dist/access-surface-catalog.js.map +1 -1
  56. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  57. package/dist/action-confidence.d.ts +2 -1
  58. package/dist/active-memory-bridge.d.ts +2 -1
  59. package/dist/active-recall.d.ts +2 -1
  60. package/dist/active-recall.js +16 -13
  61. package/dist/active-recall.js.map +1 -1
  62. package/dist/adapters/index.js +7 -7
  63. package/dist/adapters/registry.js +3 -3
  64. package/dist/ambient-provenance.d.ts +2 -1
  65. package/dist/artifact-search.d.ts +2 -1
  66. package/dist/{auto-sync-GRUJFD2F.js → auto-sync-WNGG2GC2.js} +9 -9
  67. package/dist/behavior-learner.d.ts +2 -1
  68. package/dist/behavior-signals.d.ts +2 -1
  69. package/dist/bootstrap.d.ts +12 -10
  70. package/dist/briefing-window.d.ts +3 -2
  71. package/dist/briefing.d.ts +3 -2
  72. package/dist/briefing.js +36 -36
  73. package/dist/buffer-surprise-report.d.ts +2 -1
  74. package/dist/buffer-turn-helpers.d.ts +2 -1
  75. package/dist/buffer.d.ts +3 -2
  76. package/dist/buffer.js +13 -13
  77. package/dist/bulk-import/index.d.ts +4 -3
  78. package/dist/calibration.d.ts +2 -1
  79. package/dist/calibration.js +2 -1
  80. package/dist/calibration.js.map +1 -1
  81. package/dist/capabilities.d.ts +2 -1
  82. package/dist/{capsule-crypto-7FJQINUR.js → capsule-crypto-YO5QJ6L3.js} +2 -2
  83. package/dist/{capsule-merge-SEHERWWP.js → capsule-merge-IPG4IOFP.js} +5 -5
  84. package/dist/{catalog-C1qHsGew.d.ts → catalog-CDZLyiXL.d.ts} +1 -1
  85. package/dist/causal-behavior.d.ts +2 -1
  86. package/dist/causal-behavior.js +4 -3
  87. package/dist/causal-behavior.js.map +1 -1
  88. package/dist/causal-chain.js +4 -3
  89. package/dist/causal-consolidation.d.ts +2 -1
  90. package/dist/causal-consolidation.js +42 -42
  91. package/dist/causal-retrieval.js +4 -3
  92. package/dist/causal-retrieval.js.map +1 -1
  93. package/dist/causal-trajectory-graph.d.ts +5 -2
  94. package/dist/causal-trajectory-graph.js +6 -2
  95. package/dist/causal-trajectory-graph.js.map +1 -1
  96. package/dist/causal-trajectory.js +3 -2
  97. package/dist/{chunk-KTVSPFCQ.js → chunk-22FVR2KE.js} +2 -2
  98. package/dist/{chunk-7Y5V3LAP.js → chunk-27QVNSQ3.js} +2 -2
  99. package/dist/{chunk-R7LY4YKF.js → chunk-2EKJDQZB.js} +2 -2
  100. package/dist/{chunk-FCATYKQA.js → chunk-2IOHTUP3.js} +263 -13
  101. package/dist/chunk-2IOHTUP3.js.map +1 -0
  102. package/dist/{chunk-HOUST5UX.js → chunk-2ITE4C2Z.js} +2 -2
  103. package/dist/{chunk-JOYC4RYC.js → chunk-2JVJ7UHC.js} +2 -2
  104. package/dist/{chunk-X2NFFBTO.js → chunk-2L5FSNPC.js} +7 -7
  105. package/dist/{chunk-DUAJKRR2.js → chunk-2SGLMP2E.js} +2 -2
  106. package/dist/{chunk-6FUMA6AA.js → chunk-2Z4GS5E6.js} +2 -2
  107. package/dist/{chunk-G6MXN2G5.js → chunk-37KUQPX4.js} +6 -6
  108. package/dist/{chunk-DDQQY2E3.js → chunk-3BTFBQLO.js} +7 -7
  109. package/dist/chunk-3BTFBQLO.js.map +1 -0
  110. package/dist/{chunk-UR6PBX2J.js → chunk-3K7V3HE6.js} +35 -60
  111. package/dist/chunk-3K7V3HE6.js.map +1 -0
  112. package/dist/{chunk-WKAXBXVA.js → chunk-3QQTXYZ6.js} +2 -2
  113. package/dist/{chunk-DJUKBGAD.js → chunk-46EST7JO.js} +5 -5
  114. package/dist/chunk-46EST7JO.js.map +1 -0
  115. package/dist/{chunk-4ZWCQJNM.js → chunk-46WM6JX2.js} +5 -5
  116. package/dist/{chunk-CASWJ2HM.js → chunk-46ZPIGWI.js} +3 -3
  117. package/dist/{chunk-HTIIXNJQ.js → chunk-4FIH6MPS.js} +6 -3
  118. package/dist/chunk-4FIH6MPS.js.map +1 -0
  119. package/dist/{chunk-MCA2X4WH.js → chunk-4IHBN6WU.js} +2 -2
  120. package/dist/{chunk-W7IGLX4G.js → chunk-4O6WRBGE.js} +7 -7
  121. package/dist/chunk-4O6WRBGE.js.map +1 -0
  122. package/dist/{chunk-FB7LAJQM.js → chunk-4TKJGOCJ.js} +2 -2
  123. package/dist/{chunk-H7BZBSP6.js → chunk-52II7PB6.js} +4 -4
  124. package/dist/{chunk-N4Y5T6VD.js → chunk-54WHLA65.js} +4 -4
  125. package/dist/chunk-56Y6EKZN.js +24 -0
  126. package/dist/chunk-56Y6EKZN.js.map +1 -0
  127. package/dist/{chunk-YVLENSNS.js → chunk-5ATKSPEQ.js} +2 -2
  128. package/dist/{chunk-OLT3YTDH.js → chunk-5FAGCOZD.js} +37 -24
  129. package/dist/chunk-5FAGCOZD.js.map +1 -0
  130. package/dist/{chunk-ZVZHG7AI.js → chunk-5UBH37SL.js} +3 -3
  131. package/dist/{chunk-N3WZU76A.js → chunk-66OJSCI6.js} +2 -2
  132. package/dist/{chunk-D35XLYQ7.js → chunk-6CVNSDCZ.js} +11 -11
  133. package/dist/{chunk-KA2HZCMG.js → chunk-6NXSYYGP.js} +2 -2
  134. package/dist/{chunk-2HIJHXB3.js → chunk-6WHJ2EAB.js} +2 -2
  135. package/dist/{chunk-ZZM476NV.js → chunk-6XL73HQ4.js} +4 -4
  136. package/dist/{chunk-EJ5RKUXW.js → chunk-AQ7SYDVO.js} +2 -2
  137. package/dist/{chunk-2Z3DG5CQ.js → chunk-B3O3IRZN.js} +2 -2
  138. package/dist/{chunk-P77QX3ID.js → chunk-B6O2YLUR.js} +21 -20
  139. package/dist/chunk-B6O2YLUR.js.map +1 -0
  140. package/dist/{chunk-RACZB5HT.js → chunk-BD7JTBYP.js} +4 -4
  141. package/dist/{chunk-I762GW7V.js → chunk-BLJWYCNO.js} +5 -5
  142. package/dist/{chunk-ACPCA4NO.js → chunk-BMWN7B3Y.js} +6 -6
  143. package/dist/chunk-BMWN7B3Y.js.map +1 -0
  144. package/dist/{chunk-2NLLXCJG.js → chunk-BXLOS5AJ.js} +2 -2
  145. package/dist/{chunk-KK66P5GQ.js → chunk-C553ZTLF.js} +46 -48
  146. package/dist/chunk-C553ZTLF.js.map +1 -0
  147. package/dist/{chunk-GCASGYIO.js → chunk-C7HJ3NEI.js} +2 -2
  148. package/dist/{chunk-C24UZSFW.js → chunk-CEH2AFXG.js} +6 -6
  149. package/dist/{chunk-WVGXCBOC.js → chunk-D5F7TKMH.js} +2 -2
  150. package/dist/chunk-DGS34QSY.js +141 -0
  151. package/dist/chunk-DGS34QSY.js.map +1 -0
  152. package/dist/{chunk-X7Y7WX73.js → chunk-DQEMWVMT.js} +1 -1
  153. package/dist/{chunk-2OXIPF3A.js → chunk-DZD3WGCD.js} +4 -4
  154. package/dist/{chunk-UMEOXLIZ.js → chunk-E2P7TZTF.js} +5 -5
  155. package/dist/{chunk-6FC3IZ26.js → chunk-EBA5DA77.js} +2 -2
  156. package/dist/{chunk-N7JK2RKG.js → chunk-EOQ6FSQP.js} +2 -2
  157. package/dist/chunk-EUT2WCWS.js +54 -0
  158. package/dist/chunk-EUT2WCWS.js.map +1 -0
  159. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  160. package/dist/{chunk-XDMI5VKE.js → chunk-FVOP3NT7.js} +2 -2
  161. package/dist/{chunk-NRLELHAY.js → chunk-G7NYVKD6.js} +2 -2
  162. package/dist/{chunk-B3W7GWQB.js → chunk-GHTSNGBZ.js} +2 -2
  163. package/dist/chunk-GKCXTSFF.js +17 -0
  164. package/dist/chunk-GKCXTSFF.js.map +1 -0
  165. package/dist/{chunk-LUDBXTBJ.js → chunk-H272ZPQ3.js} +5 -5
  166. package/dist/{chunk-SN4JXNLL.js → chunk-H3TKENU4.js} +2 -2
  167. package/dist/{chunk-4HYNMLT6.js → chunk-H4SEGIZY.js} +2 -2
  168. package/dist/{chunk-ACZN5ZXD.js → chunk-H54VWRPS.js} +13 -13
  169. package/dist/{chunk-HTP6XRUI.js → chunk-HM7RHKS4.js} +2 -2
  170. package/dist/{chunk-Z3SQEEB6.js → chunk-HWLIMQE2.js} +2 -2
  171. package/dist/{chunk-NQFCLAYT.js → chunk-ICKJ52PE.js} +99 -322
  172. package/dist/chunk-ICKJ52PE.js.map +1 -0
  173. package/dist/{chunk-2QSZNTDO.js → chunk-JBPKEARU.js} +7 -7
  174. package/dist/{chunk-DK6GMO6D.js → chunk-JEC4DVM3.js} +16 -16
  175. package/dist/chunk-JEC4DVM3.js.map +1 -0
  176. package/dist/{chunk-ET2CNMLD.js → chunk-JN72EPOE.js} +2 -2
  177. package/dist/{chunk-U62OK7BB.js → chunk-JPKK466T.js} +188 -21
  178. package/dist/chunk-JPKK466T.js.map +1 -0
  179. package/dist/{chunk-JCCWJHOP.js → chunk-JYZSRNR7.js} +2 -2
  180. package/dist/{chunk-7D6HXODY.js → chunk-K7724CH2.js} +2 -2
  181. package/dist/{chunk-X33MJFD2.js → chunk-KAXCYM66.js} +3 -3
  182. package/dist/{chunk-7RRUHJPG.js → chunk-KB2G2I6Q.js} +3 -3
  183. package/dist/{chunk-ZXBTTMGZ.js → chunk-KEF46KL2.js} +5 -5
  184. package/dist/{chunk-5UZXUTVO.js → chunk-KNA3BXXL.js} +6 -2
  185. package/dist/chunk-KNA3BXXL.js.map +1 -0
  186. package/dist/{chunk-UWTDARPF.js → chunk-KTWG7CNY.js} +6 -6
  187. package/dist/{chunk-XQYTSZW3.js → chunk-L7Z57SID.js} +6 -6
  188. package/dist/{chunk-JMAG7WZ7.js → chunk-LO4UKPKX.js} +3 -3
  189. package/dist/{chunk-LDWIPYJ6.js → chunk-LS2FHUML.js} +3 -3
  190. package/dist/{chunk-GDB4J2H3.js → chunk-MPC7TYTZ.js} +2 -2
  191. package/dist/{chunk-2GF27PGH.js → chunk-MRPOZBJC.js} +3 -3
  192. package/dist/{chunk-BR3OOQZQ.js → chunk-MWN6QEI2.js} +2 -2
  193. package/dist/{chunk-NZGO2GKL.js → chunk-MY5EDR46.js} +4 -4
  194. package/dist/{chunk-LCMUZDBZ.js → chunk-N3ZOP7KC.js} +3 -3
  195. package/dist/{chunk-TVW4C7PV.js → chunk-NB3LRY4T.js} +6 -6
  196. package/dist/{chunk-QJCWK2A7.js → chunk-ND6IQGSZ.js} +2 -2
  197. package/dist/{chunk-NOB2T2FC.js → chunk-NHLLKEKK.js} +2 -2
  198. package/dist/{chunk-7GSSHAXC.js → chunk-NLYVH66G.js} +6 -6
  199. package/dist/chunk-NLYVH66G.js.map +1 -0
  200. package/dist/{chunk-EJIWBTVM.js → chunk-O6ZNNVSP.js} +2 -2
  201. package/dist/{chunk-AG46P24C.js → chunk-OB3XMWX5.js} +4 -4
  202. package/dist/{chunk-NYRB7BKY.js → chunk-OEYZXDQI.js} +6 -6
  203. package/dist/chunk-OEYZXDQI.js.map +1 -0
  204. package/dist/{chunk-46QMN7I7.js → chunk-PAZY2ZKP.js} +6 -6
  205. package/dist/{chunk-EF4JUM55.js → chunk-PX4UMA5Z.js} +2 -2
  206. package/dist/chunk-QLK3SL7Q.js +242 -0
  207. package/dist/chunk-QLK3SL7Q.js.map +1 -0
  208. package/dist/{chunk-GGYDJJBO.js → chunk-QOOBICJF.js} +5 -5
  209. package/dist/chunk-QOOBICJF.js.map +1 -0
  210. package/dist/{chunk-NNZFPYYX.js → chunk-R7QY5ZVB.js} +2 -2
  211. package/dist/{chunk-RO2X2EYM.js → chunk-R7RTXEYG.js} +2 -2
  212. package/dist/{chunk-3LJPSRAN.js → chunk-RBCQVOVJ.js} +3 -3
  213. package/dist/{chunk-N4F7ZSSG.js → chunk-RC5DXXWC.js} +2 -2
  214. package/dist/{chunk-VLAQV4HT.js → chunk-RJYJ7KR7.js} +1636 -611
  215. package/dist/chunk-RJYJ7KR7.js.map +1 -0
  216. package/dist/{chunk-5CF2R4NS.js → chunk-RKBLRTNT.js} +2 -2
  217. package/dist/{chunk-5QZR2RA3.js → chunk-ROBHL3GL.js} +2 -2
  218. package/dist/{chunk-D5ZNOKR7.js → chunk-S7T2TY65.js} +3 -3
  219. package/dist/{chunk-C2JCVZWX.js → chunk-SCXURCVT.js} +25 -13
  220. package/dist/chunk-SCXURCVT.js.map +1 -0
  221. package/dist/{chunk-3LADWWMA.js → chunk-SJDQ5RSN.js} +3 -3
  222. package/dist/{chunk-45XVII3J.js → chunk-SMWTZLHE.js} +99 -89
  223. package/dist/{chunk-45XVII3J.js.map → chunk-SMWTZLHE.js.map} +1 -1
  224. package/dist/{chunk-XOQGUGJL.js → chunk-SO7SV523.js} +1 -1
  225. package/dist/{chunk-XOQGUGJL.js.map → chunk-SO7SV523.js.map} +1 -1
  226. package/dist/{chunk-CHWUICVY.js → chunk-SV4Z2S67.js} +4 -4
  227. package/dist/{chunk-JHP45LO5.js → chunk-SVXJLDDC.js} +9 -7
  228. package/dist/{chunk-JHP45LO5.js.map → chunk-SVXJLDDC.js.map} +1 -1
  229. package/dist/{chunk-SEF4IOFE.js → chunk-SWIKABKI.js} +2 -2
  230. package/dist/{chunk-JRRQ747T.js → chunk-TBXAY2SS.js} +13 -13
  231. package/dist/{chunk-J6A3CX5N.js → chunk-TG3FAM2S.js} +33 -8
  232. package/dist/{chunk-J6A3CX5N.js.map → chunk-TG3FAM2S.js.map} +1 -1
  233. package/dist/{chunk-XZBXINXZ.js → chunk-TNSCIPBQ.js} +4 -4
  234. package/dist/{chunk-S37NN23M.js → chunk-TVEONGBU.js} +2 -2
  235. package/dist/{chunk-5RPMTFB6.js → chunk-TWF35IC6.js} +3 -3
  236. package/dist/{chunk-BZTJEILZ.js → chunk-U6N5IBVY.js} +2 -2
  237. package/dist/{chunk-7TUB6JWA.js → chunk-UCKYTA2T.js} +3 -3
  238. package/dist/{chunk-PPOT6SPR.js → chunk-UNNPNBR2.js} +11 -11
  239. package/dist/{chunk-KQAFEZQX.js → chunk-VDX2J7OX.js} +2 -2
  240. package/dist/{chunk-J2R275FN.js → chunk-VVX5PZFS.js} +4 -4
  241. package/dist/{chunk-ME35HVDJ.js → chunk-VYCOJKSX.js} +2 -2
  242. package/dist/{chunk-F5UWQ4LX.js → chunk-W24T5YMW.js} +2 -2
  243. package/dist/{chunk-HDQUQBPW.js → chunk-W3K3HITK.js} +2 -2
  244. package/dist/{chunk-GDASG7NC.js → chunk-W4F3C7N7.js} +2 -2
  245. package/dist/{chunk-LFK623SF.js → chunk-WJHGDE7X.js} +5 -5
  246. package/dist/{chunk-DP4EBV7C.js → chunk-WMLEPWMO.js} +16 -16
  247. package/dist/chunk-WMLEPWMO.js.map +1 -0
  248. package/dist/{chunk-3Q6RD76J.js → chunk-WQZZDN5M.js} +5 -5
  249. package/dist/{chunk-ZJWDWPX6.js → chunk-X5K5TAQZ.js} +4 -4
  250. package/dist/{chunk-ZL3XX5LW.js → chunk-XM24CDZX.js} +3 -3
  251. package/dist/{chunk-JTWZKNUH.js → chunk-XOVKXJEP.js} +3 -3
  252. package/dist/{chunk-OGTKQ5MJ.js → chunk-XSGUMQQQ.js} +62 -50
  253. package/dist/chunk-XSGUMQQQ.js.map +1 -0
  254. package/dist/{chunk-X5YYSAZX.js → chunk-XUE46UYW.js} +3 -3
  255. package/dist/{chunk-DJORULH3.js → chunk-YRLHEEQT.js} +2 -2
  256. package/dist/{chunk-TA7UZZMW.js → chunk-Z3O53WZR.js} +2 -2
  257. package/dist/{chunk-4LG4CPOC.js → chunk-Z6COGHHN.js} +2 -2
  258. package/dist/{chunk-RE3H6Y2X.js → chunk-ZIW5JVRM.js} +2 -2
  259. package/dist/{cli-BNtvR-nU.d.ts → cli-DD0P-lu8.d.ts} +6 -6
  260. package/dist/cli.d.ts +16 -14
  261. package/dist/cli.js +154 -149
  262. package/dist/coding/export-okf-codegraph.d.ts +2 -1
  263. package/dist/coding/export-okf-codegraph.js +37 -37
  264. package/dist/coding/pre-action-gate.d.ts +2 -1
  265. package/dist/coding/pre-action-gate.js +4 -3
  266. package/dist/commitment-ledger.js +3 -2
  267. package/dist/compounding/engine.d.ts +3 -2
  268. package/dist/compounding/engine.js +37 -37
  269. package/dist/compounding/preference-consolidator.d.ts +2 -1
  270. package/dist/compression-optimizer.d.ts +2 -1
  271. package/dist/config.d.ts +2 -1
  272. package/dist/config.js +16 -13
  273. package/dist/connectors/codex-materialize-runner.d.ts +2 -1
  274. package/dist/connectors/codex-materialize-runner.js +38 -38
  275. package/dist/connectors/codex-materialize.d.ts +2 -1
  276. package/dist/connectors/codex-materialize.js +4 -4
  277. package/dist/connectors/index.d.ts +2 -1
  278. package/dist/connectors/index.js +38 -38
  279. package/dist/consolidation-provenance-check.d.ts +3 -2
  280. package/dist/consolidation-provenance-check.js +4 -4
  281. package/dist/consolidation-undo.d.ts +3 -2
  282. package/dist/consolidation-undo.js +3 -3
  283. package/dist/contradiction/index.d.ts +4 -3
  284. package/dist/contradiction/index.js +9 -9
  285. package/dist/converge-config.d.ts +2 -1
  286. package/dist/convergence-refresh.d.ts +3 -2
  287. package/dist/convergence-refresh.js +38 -38
  288. package/dist/conversation-index/backend.d.ts +2 -1
  289. package/dist/conversation-index/chunker.d.ts +2 -1
  290. package/dist/conversation-index/faiss-adapter.d.ts +2 -1
  291. package/dist/conversation-index/indexer.d.ts +2 -1
  292. package/dist/conversation-index/search.d.ts +2 -1
  293. package/dist/corpus-watermark.d.ts +2 -1
  294. package/dist/corpus-watermark.js +38 -38
  295. package/dist/cross-lingual-recall.d.ts +2 -1
  296. package/dist/cue-anchors.js +4 -3
  297. package/dist/dashboard-runtime.js +2 -2
  298. package/dist/day-summary.d.ts +2 -1
  299. package/dist/deep-recall-http-glue.d.ts +14 -12
  300. package/dist/deep-recall-http-glue.js +9 -8
  301. package/dist/deep-recall-mcp-tools.d.ts +14 -12
  302. package/dist/deep-recall-policy-llm.d.ts +2 -1
  303. package/dist/deep-recall-seeds.d.ts +2 -1
  304. package/dist/deep-recall.js +2 -2
  305. package/dist/delinearize.d.ts +2 -1
  306. package/dist/dependency-propagation-config.d.ts +2 -1
  307. package/dist/{dependency-propagation-delivery-DjpUlhLi.d.ts → dependency-propagation-delivery-CQPCu0o5.d.ts} +1 -1
  308. package/dist/direct-answer-wiring.d.ts +2 -1
  309. package/dist/direct-answer.d.ts +2 -1
  310. package/dist/embedding-fallback.d.ts +2 -1
  311. package/dist/enrichment/index.d.ts +2 -1
  312. package/dist/entity-origin-fields.d.ts +2 -1
  313. package/dist/entity-retrieval.d.ts +3 -2
  314. package/dist/entity-retrieval.js +36 -36
  315. package/dist/entity-schema.d.ts +2 -1
  316. package/dist/episodic-context.d.ts +2 -1
  317. package/dist/eval-trajectory-contracts.d.ts +2 -1
  318. package/dist/eval-trajectory-store.d.ts +2 -1
  319. package/dist/eval-trajectory-store.js +4 -3
  320. package/dist/eval-trajectory.d.ts +2 -1
  321. package/dist/eval-trajectory.js +4 -3
  322. package/dist/evals.js +3 -2
  323. package/dist/event-order-recall.js +2 -2
  324. package/dist/explicit-capture.d.ts +12 -10
  325. package/dist/explicit-capture.js +10 -10
  326. package/dist/external-wiki-access.d.ts +14 -12
  327. package/dist/external-wiki-access.js +95 -92
  328. package/dist/external-wiki-collection-registration.d.ts +2 -1
  329. package/dist/external-wiki-collection.d.ts +2 -1
  330. package/dist/external-wiki-mcp-tools.d.ts +14 -12
  331. package/dist/extraction-error-classification.d.ts +2 -1
  332. package/dist/extraction-faithfulness.d.ts +2 -1
  333. package/dist/extraction-judge-telemetry.d.ts +2 -1
  334. package/dist/extraction-judge-training.d.ts +2 -1
  335. package/dist/extraction-judge.d.ts +2 -1
  336. package/dist/extraction-liveness.d.ts +2 -1
  337. package/dist/extraction-normalization.d.ts +2 -1
  338. package/dist/extraction-prompt.d.ts +2 -1
  339. package/dist/extraction-source-grounding-rules.d.ts +2 -1
  340. package/dist/extraction-source-grounding.d.ts +2 -1
  341. package/dist/extraction.d.ts +2 -1
  342. package/dist/extraction.js +43 -43
  343. package/dist/fallback-llm.d.ts +2 -1
  344. package/dist/{first-start-migration-KHIMCBIC.js → first-start-migration-RC345GPL.js} +6 -5
  345. package/dist/{first-start-migration-KHIMCBIC.js.map → first-start-migration-RC345GPL.js.map} +1 -1
  346. package/dist/{forget-2AE4MDK3.js → forget-SZ2BXDGF.js} +3 -3
  347. package/dist/{graph-444E-DrF.d.ts → graph-DRkl22KE.d.ts} +10 -12
  348. package/dist/graph-append-error.d.ts +40 -0
  349. package/dist/graph-append-error.js +8 -0
  350. package/dist/graph-dashboard-diff.d.ts +5 -2
  351. package/dist/graph-dashboard-key.d.ts +5 -2
  352. package/dist/graph-dashboard-parser.d.ts +5 -2
  353. package/dist/{graph-edge-decay-DGTBFALQ.js → graph-edge-decay-MKIRZ762.js} +10 -4
  354. package/dist/graph-edge-decay-MKIRZ762.js.map +1 -0
  355. package/dist/graph-edge-reinforcement.d.ts +5 -2
  356. package/dist/graph-jsonl.d.ts +82 -0
  357. package/dist/graph-jsonl.js +23 -0
  358. package/dist/graph-jsonl.js.map +1 -0
  359. package/dist/graph-path-reconstruction.d.ts +5 -2
  360. package/dist/graph-path-scoring.d.ts +5 -2
  361. package/dist/graph-snapshot.d.ts +5 -2
  362. package/dist/graph-snapshot.js +7 -3
  363. package/dist/graph-write-lock.d.ts +84 -0
  364. package/dist/graph-write-lock.js +15 -0
  365. package/dist/graph-write-lock.js.map +1 -0
  366. package/dist/graph.d.ts +5 -2
  367. package/dist/graph.js +10 -3
  368. package/dist/harmonic-construction.js +5 -4
  369. package/dist/harmonic-retrieval.js +5 -4
  370. package/dist/importance.d.ts +2 -1
  371. package/dist/importers/index.d.ts +2 -1
  372. package/dist/in-flight-reads.d.ts +2 -1
  373. package/dist/{index-CsUrdMyL.d.ts → index-C9VXenR8.d.ts} +2 -2
  374. package/dist/index.d.ts +39 -25
  375. package/dist/index.js +291 -284
  376. package/dist/intent.d.ts +2 -1
  377. package/dist/json-store.js +2 -1
  378. package/dist/lcm/engine.d.ts +2 -1
  379. package/dist/lcm/engine.js +3 -3
  380. package/dist/lcm/index.d.ts +2 -1
  381. package/dist/lcm/index.js +6 -6
  382. package/dist/lcm/tools.d.ts +2 -1
  383. package/dist/lifecycle.d.ts +2 -1
  384. package/dist/live-connectors-runner.d.ts +2 -1
  385. package/dist/live-connectors-runner.js +3 -2
  386. package/dist/local-llm.d.ts +2 -1
  387. package/dist/local-model-endpoint.d.ts +2 -1
  388. package/dist/location/index.d.ts +4 -3
  389. package/dist/location/index.js +39 -39
  390. package/dist/maintenance/memory-governance.d.ts +2 -1
  391. package/dist/maintenance/memory-governance.js +36 -36
  392. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  393. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +36 -36
  394. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  395. package/dist/maintenance/rebuild-memory-projection.js +37 -37
  396. package/dist/{maintenance-D1GRGLTE.d.ts → maintenance-C14sorKa.d.ts} +3 -3
  397. package/dist/mcp-memory-inspector-app.d.ts +14 -12
  398. package/dist/memory-action-policy.d.ts +2 -1
  399. package/dist/memory-cache.d.ts +2 -1
  400. package/dist/memory-controller.d.ts +2 -1
  401. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  402. package/dist/memory-projection-mutations.js +3 -3
  403. package/dist/memory-projection-store.d.ts +2 -1
  404. package/dist/memory-provenance.d.ts +2 -1
  405. package/dist/memory-snapshot.d.ts +2 -1
  406. package/dist/memory-subject-cli.d.ts +14 -12
  407. package/dist/memory-subject.d.ts +14 -12
  408. package/dist/memory-subject.js +5 -5
  409. package/dist/memory-worth-outcomes.d.ts +3 -2
  410. package/dist/models-json.d.ts +2 -1
  411. package/dist/namespaces/migrate.d.ts +4 -3
  412. package/dist/namespaces/migrate.js +37 -37
  413. package/dist/namespaces/principal.d.ts +2 -1
  414. package/dist/namespaces/search.d.ts +2 -1
  415. package/dist/namespaces/search.js +11 -11
  416. package/dist/namespaces/storage.d.ts +4 -3
  417. package/dist/namespaces/storage.js +36 -36
  418. package/dist/native-knowledge.d.ts +2 -1
  419. package/dist/objective-state-writers.js +4 -3
  420. package/dist/objective-state.js +3 -2
  421. package/dist/offline-sync-file-io.js +4 -3
  422. package/dist/offline-sync-impression-drain.d.ts +2 -1
  423. package/dist/offline-sync-impression-drain.js +7 -7
  424. package/dist/offline-sync.js +5 -4
  425. package/dist/operator-doctor-corpus.d.ts +2 -1
  426. package/dist/operator-doctor-corpus.js +39 -39
  427. package/dist/operator-doctor-replica.d.ts +2 -1
  428. package/dist/operator-toolkit.d.ts +6 -4
  429. package/dist/operator-toolkit.js +61 -58
  430. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  431. package/dist/orchestration/maintenance.d.ts +5 -4
  432. package/dist/orchestration/maintenance.js +46 -46
  433. package/dist/{orchestrator-DeqaPGT5.d.ts → orchestrator-DgyvFfPR.d.ts} +9 -9
  434. package/dist/orchestrator.d.ts +12 -10
  435. package/dist/orchestrator.js +201 -196
  436. package/dist/page-versioning.d.ts +73 -4
  437. package/dist/page-versioning.js +11 -3
  438. package/dist/patterns-cli.d.ts +2 -1
  439. package/dist/{pipeline-umUzU0D1.d.ts → pipeline-DRUwHb1X.d.ts} +1 -1
  440. package/dist/policy-runtime.d.ts +2 -1
  441. package/dist/proactive-contention.d.ts +2 -1
  442. package/dist/provenance.d.ts +2 -1
  443. package/dist/{public-http-Bevrjll9.d.ts → public-http-C4i8Opxc.d.ts} +1 -1
  444. package/dist/{purge-OP6BEDFY.js → purge-TZKRE6ZQ.js} +5 -5
  445. package/dist/purge-TZKRE6ZQ.js.map +1 -0
  446. package/dist/{qmd-BasT78PP.d.ts → qmd-BVWlg1YS.d.ts} +1 -1
  447. package/dist/qmd-preflight.d.ts +3 -2
  448. package/dist/qmd-recall-cache.d.ts +2 -1
  449. package/dist/qmd.d.ts +3 -2
  450. package/dist/qmd.js +4 -4
  451. package/dist/recall-concurrency-config.d.ts +2 -1
  452. package/dist/recall-disclosure-escalation.d.ts +2 -1
  453. package/dist/recall-explain-renderer.d.ts +2 -1
  454. package/dist/recall-explain-renderer.js +3 -3
  455. package/dist/recall-memory-map.d.ts +2 -1
  456. package/dist/recall-navigate-access.d.ts +2 -1
  457. package/dist/recall-navigate-access.js +2 -2
  458. package/dist/recall-navigate-disclosure.d.ts +2 -1
  459. package/dist/recall-navigate-disclosure.js +1 -1
  460. package/dist/recall-navigate.d.ts +2 -1
  461. package/dist/recall-navigate.js +2 -2
  462. package/dist/recall-planner-llm.d.ts +2 -1
  463. package/dist/recall-state.d.ts +2 -1
  464. package/dist/recall-state.js +3 -3
  465. package/dist/recall-tag-filter.d.ts +2 -1
  466. package/dist/recall-timings.d.ts +2 -1
  467. package/dist/recall-xray-cli.d.ts +2 -1
  468. package/dist/recall-xray-cli.js +4 -4
  469. package/dist/recall-xray-renderer.d.ts +2 -1
  470. package/dist/recall-xray-renderer.js +3 -3
  471. package/dist/recall-xray.d.ts +2 -1
  472. package/dist/recall-xray.js +2 -2
  473. package/dist/reconcile/cursor.d.ts +2 -1
  474. package/dist/reconcile/manifest.d.ts +2 -1
  475. package/dist/reconcile/manifest.js +7 -7
  476. package/dist/reconcile/plan.d.ts +2 -1
  477. package/dist/replay/normalizers/chatgpt.d.ts +2 -1
  478. package/dist/replay/normalizers/claude.d.ts +2 -1
  479. package/dist/replay/normalizers/openclaw.d.ts +2 -1
  480. package/dist/replay/normalizers/shared.d.ts +2 -1
  481. package/dist/replay/runner.d.ts +2 -1
  482. package/dist/replay/types.d.ts +2 -1
  483. package/dist/replica-divergence.d.ts +2 -1
  484. package/dist/replica-peers-config.d.ts +2 -1
  485. package/dist/{resolution-4DLI3IOR.js → resolution-VKATP2HT.js} +10 -10
  486. package/dist/resolution-VKATP2HT.js.map +1 -0
  487. package/dist/resolve-auth-token.d.ts +2 -1
  488. package/dist/resume-bundles.js +21 -18
  489. package/dist/retrieval-agents.d.ts +3 -2
  490. package/dist/retrieval-tiers.d.ts +2 -1
  491. package/dist/routing/engine.d.ts +2 -1
  492. package/dist/routing/store.d.ts +2 -1
  493. package/dist/salvage-envelope.d.ts +2 -1
  494. package/dist/salvage-envelope.js +7 -7
  495. package/dist/{scope-profiles-DXYzyOXW.d.ts → scope-profiles-Vl00B1KU.d.ts} +1 -1
  496. package/dist/search/document-scanner.js +3 -3
  497. package/dist/search/embed-helper.d.ts +2 -1
  498. package/dist/search/factory.d.ts +2 -1
  499. package/dist/search/factory.js +10 -10
  500. package/dist/search/index.d.ts +2 -1
  501. package/dist/search/index.js +16 -16
  502. package/dist/search/lancedb-backend.d.ts +2 -1
  503. package/dist/search/lancedb-backend.js +4 -4
  504. package/dist/search/meilisearch-backend.d.ts +2 -1
  505. package/dist/search/meilisearch-backend.js +4 -4
  506. package/dist/search/noop-backend.d.ts +2 -1
  507. package/dist/search/orama-backend.d.ts +2 -1
  508. package/dist/search/orama-backend.js +4 -4
  509. package/dist/search/port.d.ts +2 -1
  510. package/dist/search/remote-backend.d.ts +2 -1
  511. package/dist/secure-store/index.js +3 -3
  512. package/dist/{semantic-consolidation-CqDeaY0U.d.ts → semantic-consolidation-BC9-GFuT.d.ts} +1 -1
  513. package/dist/semantic-consolidation.d.ts +3 -2
  514. package/dist/semantic-consolidation.js +39 -39
  515. package/dist/semantic-merge-config.d.ts +17 -0
  516. package/dist/semantic-merge-config.js +1 -0
  517. package/dist/semantic-merge-config.js.map +1 -0
  518. package/dist/semantic-rule-promotion.js +36 -36
  519. package/dist/semantic-rule-verifier.d.ts +2 -1
  520. package/dist/semantic-rule-verifier.js +36 -36
  521. package/dist/{service-BKD-DVYZ.d.ts → service-BOy6dHfc.d.ts} +2 -2
  522. package/dist/session-observer-bands.d.ts +2 -1
  523. package/dist/session-observer-state.d.ts +2 -1
  524. package/dist/shared-context/manager.d.ts +2 -1
  525. package/dist/signal.d.ts +2 -1
  526. package/dist/source-agent-qualifier.d.ts +2 -1
  527. package/dist/source-agent-qualifier.js +42 -42
  528. package/dist/source-attribution.d.ts +18 -6
  529. package/dist/source-attribution.js +3 -1
  530. package/dist/standup/build.js +36 -36
  531. package/dist/{storage-BcFd1lN_.d.ts → storage-BLJRnFi6.d.ts} +15 -8
  532. package/dist/storage.d.ts +3 -2
  533. package/dist/storage.js +35 -35
  534. package/dist/subject-config.d.ts +2 -1
  535. package/dist/subject-config.js +6 -6
  536. package/dist/summarizer.d.ts +2 -1
  537. package/dist/summary-snapshot.d.ts +2 -1
  538. package/dist/support-passport/index.d.ts +17 -15
  539. package/dist/support-passport/index.js +97 -94
  540. package/dist/temporal-supersession.d.ts +3 -2
  541. package/dist/temporal-timeline-recall.d.ts +2 -1
  542. package/dist/temporal-validity.d.ts +2 -1
  543. package/dist/threading.d.ts +2 -1
  544. package/dist/tier-migration.d.ts +3 -2
  545. package/dist/tier-routing.d.ts +2 -1
  546. package/dist/{tier-stats-2TOW3QNL.js → tier-stats-KA6OZX2C.js} +6 -5
  547. package/dist/{tier-stats-2TOW3QNL.js.map → tier-stats-KA6OZX2C.js.map} +1 -1
  548. package/dist/topics.d.ts +2 -1
  549. package/dist/transcript.d.ts +2 -1
  550. package/dist/transfer/backup.js +2 -2
  551. package/dist/transfer/capsule-export.js +2 -2
  552. package/dist/transfer/capsule-import.js +6 -6
  553. package/dist/transfer/export-okf.d.ts +2 -1
  554. package/dist/transfer/export-okf.js +37 -37
  555. package/dist/trust-score-stage.d.ts +2 -1
  556. package/dist/trust-score.d.ts +2 -1
  557. package/dist/trust-zones.js +3 -2
  558. package/dist/{types-BRg3tMyp.d.ts → types-YY-eKKU7.d.ts} +3 -0
  559. package/dist/types.d.ts +2 -1
  560. package/dist/types.js +1 -1
  561. package/dist/utility-learner.js +4 -3
  562. package/dist/utility-runtime.d.ts +2 -1
  563. package/dist/utility-runtime.js +5 -4
  564. package/dist/utility-telemetry.js +3 -2
  565. package/dist/verified-recall.js +36 -36
  566. package/dist/who-knows-cli.d.ts +14 -12
  567. package/dist/who-knows-cli.js +37 -37
  568. package/dist/who-knows.d.ts +14 -12
  569. package/dist/who-knows.js +36 -36
  570. package/dist/work/board.js +3 -3
  571. package/dist/work/storage.js +2 -2
  572. package/dist/work-product-ledger.js +3 -2
  573. package/dist/write-envelope.d.ts +2 -1
  574. package/dist/write-envelope.js +6 -6
  575. package/package.json +2 -2
  576. package/src/abstraction-nodes.ts +1 -4
  577. package/src/access-http-briefing.ts +35 -0
  578. package/src/access-http.test.ts +76 -0
  579. package/src/access-http.ts +20 -23
  580. package/src/access-surface-catalog.test.ts +9 -0
  581. package/src/access-surface-catalog.ts +1 -0
  582. package/src/binary-lifecycle/backend.ts +2 -1
  583. package/src/config.ts +2 -0
  584. package/src/connectors/live/github.ts +10 -17
  585. package/src/connectors/live/gmail.ts +8 -19
  586. package/src/connectors/live/google-drive.ts +6 -13
  587. package/src/connectors/live/notion.ts +11 -21
  588. package/src/cue-anchors.ts +1 -6
  589. package/src/dedup/connector-scope.ts +39 -0
  590. package/src/dedup/merge-content.test.ts +21 -0
  591. package/src/dedup/merge-content.ts +21 -7
  592. package/src/dedup/merge-judge.ts +146 -0
  593. package/src/dedup/merge.test.ts +3542 -0
  594. package/src/dedup/merge.ts +384 -0
  595. package/src/dedup/novelty-gate.ts +12 -10
  596. package/src/dedup/semantic.ts +7 -9
  597. package/src/graph-append-error.ts +28 -0
  598. package/src/graph-jsonl.ts +267 -0
  599. package/src/graph-write-lock.test.ts +228 -0
  600. package/src/graph-write-lock.ts +132 -0
  601. package/src/graph.ts +49 -45
  602. package/src/harmonic-construction.test.ts +329 -0
  603. package/src/json-store.ts +17 -20
  604. package/src/live-connectors-runner.ts +2 -1
  605. package/src/location/store.ts +1 -4
  606. package/src/maintenance/graph-edge-decay.ts +24 -13
  607. package/src/maintenance/purge.ts +2 -5
  608. package/src/maintenance/rebuild-memory-lifecycle-ledger.ts +3 -6
  609. package/src/maintenance/rebuild-memory-projection.ts +2 -5
  610. package/src/namespaces/catalog.ts +1 -9
  611. package/src/offline-sync-file-io.test.ts +39 -0
  612. package/src/offline-sync-file-io.ts +3 -7
  613. package/src/orchestration/contradiction-localization.integration.test.ts +35 -0
  614. package/src/orchestration/extraction-anchor-snapshot.ts +6 -1
  615. package/src/orchestration/extraction-persist-deps.ts +2 -1
  616. package/src/orchestration/extraction-persist-profile-promotion.test.ts +456 -0
  617. package/src/orchestration/extraction-persist-promotion.test.ts +534 -0
  618. package/src/orchestration/extraction-persist-promotion.ts +387 -1
  619. package/src/orchestration/extraction-persist.ts +95 -94
  620. package/src/orchestration/harmonic-construction-persist.test.ts +69 -0
  621. package/src/orchestration/harmonic-construction-persist.ts +55 -0
  622. package/src/orchestration/persistence-index.ts +35 -7
  623. package/src/orchestration/semantic-merge-commit-effects.ts +354 -0
  624. package/src/orchestration/semantic-merge-persist.ts +1095 -0
  625. package/src/orchestration/semantic-merge-promotion-payload.ts +161 -0
  626. package/src/orchestrator.ts +2 -2
  627. package/src/page-versioning.ts +396 -22
  628. package/src/procedural/procedure-miner.ts +1 -9
  629. package/src/search/document-scanner.ts +3 -6
  630. package/src/semantic-merge-config.ts +16 -0
  631. package/src/semantic-rule-promotion.ts +1 -4
  632. package/src/source-attribution-roundtrip.test.ts +21 -0
  633. package/src/source-attribution.ts +57 -17
  634. package/src/storage-contract/versioning.test.ts +500 -1
  635. package/src/storage.ts +30 -30
  636. package/src/testing/subjects/graph-edge-decay.test.ts +163 -0
  637. package/src/testing/subjects/semantic-merge-lifecycle.test.ts +1175 -0
  638. package/src/types.ts +2 -0
  639. package/src/utils/errno.test.ts +31 -0
  640. package/src/utils/errno.ts +5 -0
  641. package/src/wearables/index.ts +1 -0
  642. package/src/wearables/registry.ts +23 -0
  643. package/dist/chunk-5UZXUTVO.js.map +0 -1
  644. package/dist/chunk-7GSSHAXC.js.map +0 -1
  645. package/dist/chunk-ACPCA4NO.js.map +0 -1
  646. package/dist/chunk-C2JCVZWX.js.map +0 -1
  647. package/dist/chunk-DDQQY2E3.js.map +0 -1
  648. package/dist/chunk-DJUKBGAD.js.map +0 -1
  649. package/dist/chunk-DK6GMO6D.js.map +0 -1
  650. package/dist/chunk-DP4EBV7C.js.map +0 -1
  651. package/dist/chunk-FCATYKQA.js.map +0 -1
  652. package/dist/chunk-GGYDJJBO.js.map +0 -1
  653. package/dist/chunk-HTIIXNJQ.js.map +0 -1
  654. package/dist/chunk-KK66P5GQ.js.map +0 -1
  655. package/dist/chunk-NQFCLAYT.js.map +0 -1
  656. package/dist/chunk-NYRB7BKY.js.map +0 -1
  657. package/dist/chunk-OGTKQ5MJ.js.map +0 -1
  658. package/dist/chunk-OLT3YTDH.js.map +0 -1
  659. package/dist/chunk-P77QX3ID.js.map +0 -1
  660. package/dist/chunk-U62OK7BB.js.map +0 -1
  661. package/dist/chunk-UR6PBX2J.js.map +0 -1
  662. package/dist/chunk-VLAQV4HT.js.map +0 -1
  663. package/dist/chunk-W7IGLX4G.js.map +0 -1
  664. package/dist/purge-OP6BEDFY.js.map +0 -1
  665. /package/dist/{capsule-crypto-7FJQINUR.js.map → access-http-briefing.js.map} +0 -0
  666. /package/dist/{auto-sync-GRUJFD2F.js.map → auto-sync-WNGG2GC2.js.map} +0 -0
  667. /package/dist/{graph-edge-decay-DGTBFALQ.js.map → capsule-crypto-YO5QJ6L3.js.map} +0 -0
  668. /package/dist/{capsule-merge-SEHERWWP.js.map → capsule-merge-IPG4IOFP.js.map} +0 -0
  669. /package/dist/{chunk-KTVSPFCQ.js.map → chunk-22FVR2KE.js.map} +0 -0
  670. /package/dist/{chunk-7Y5V3LAP.js.map → chunk-27QVNSQ3.js.map} +0 -0
  671. /package/dist/{chunk-R7LY4YKF.js.map → chunk-2EKJDQZB.js.map} +0 -0
  672. /package/dist/{chunk-HOUST5UX.js.map → chunk-2ITE4C2Z.js.map} +0 -0
  673. /package/dist/{chunk-JOYC4RYC.js.map → chunk-2JVJ7UHC.js.map} +0 -0
  674. /package/dist/{chunk-X2NFFBTO.js.map → chunk-2L5FSNPC.js.map} +0 -0
  675. /package/dist/{chunk-DUAJKRR2.js.map → chunk-2SGLMP2E.js.map} +0 -0
  676. /package/dist/{chunk-6FUMA6AA.js.map → chunk-2Z4GS5E6.js.map} +0 -0
  677. /package/dist/{chunk-G6MXN2G5.js.map → chunk-37KUQPX4.js.map} +0 -0
  678. /package/dist/{chunk-WKAXBXVA.js.map → chunk-3QQTXYZ6.js.map} +0 -0
  679. /package/dist/{chunk-4ZWCQJNM.js.map → chunk-46WM6JX2.js.map} +0 -0
  680. /package/dist/{chunk-CASWJ2HM.js.map → chunk-46ZPIGWI.js.map} +0 -0
  681. /package/dist/{chunk-MCA2X4WH.js.map → chunk-4IHBN6WU.js.map} +0 -0
  682. /package/dist/{chunk-FB7LAJQM.js.map → chunk-4TKJGOCJ.js.map} +0 -0
  683. /package/dist/{chunk-H7BZBSP6.js.map → chunk-52II7PB6.js.map} +0 -0
  684. /package/dist/{chunk-N4Y5T6VD.js.map → chunk-54WHLA65.js.map} +0 -0
  685. /package/dist/{chunk-YVLENSNS.js.map → chunk-5ATKSPEQ.js.map} +0 -0
  686. /package/dist/{chunk-ZVZHG7AI.js.map → chunk-5UBH37SL.js.map} +0 -0
  687. /package/dist/{chunk-N3WZU76A.js.map → chunk-66OJSCI6.js.map} +0 -0
  688. /package/dist/{chunk-D35XLYQ7.js.map → chunk-6CVNSDCZ.js.map} +0 -0
  689. /package/dist/{chunk-KA2HZCMG.js.map → chunk-6NXSYYGP.js.map} +0 -0
  690. /package/dist/{chunk-2HIJHXB3.js.map → chunk-6WHJ2EAB.js.map} +0 -0
  691. /package/dist/{chunk-ZZM476NV.js.map → chunk-6XL73HQ4.js.map} +0 -0
  692. /package/dist/{chunk-EJ5RKUXW.js.map → chunk-AQ7SYDVO.js.map} +0 -0
  693. /package/dist/{chunk-2Z3DG5CQ.js.map → chunk-B3O3IRZN.js.map} +0 -0
  694. /package/dist/{chunk-RACZB5HT.js.map → chunk-BD7JTBYP.js.map} +0 -0
  695. /package/dist/{chunk-I762GW7V.js.map → chunk-BLJWYCNO.js.map} +0 -0
  696. /package/dist/{chunk-2NLLXCJG.js.map → chunk-BXLOS5AJ.js.map} +0 -0
  697. /package/dist/{chunk-GCASGYIO.js.map → chunk-C7HJ3NEI.js.map} +0 -0
  698. /package/dist/{chunk-C24UZSFW.js.map → chunk-CEH2AFXG.js.map} +0 -0
  699. /package/dist/{chunk-WVGXCBOC.js.map → chunk-D5F7TKMH.js.map} +0 -0
  700. /package/dist/{chunk-X7Y7WX73.js.map → chunk-DQEMWVMT.js.map} +0 -0
  701. /package/dist/{chunk-2OXIPF3A.js.map → chunk-DZD3WGCD.js.map} +0 -0
  702. /package/dist/{chunk-UMEOXLIZ.js.map → chunk-E2P7TZTF.js.map} +0 -0
  703. /package/dist/{chunk-6FC3IZ26.js.map → chunk-EBA5DA77.js.map} +0 -0
  704. /package/dist/{chunk-N7JK2RKG.js.map → chunk-EOQ6FSQP.js.map} +0 -0
  705. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  706. /package/dist/{chunk-XDMI5VKE.js.map → chunk-FVOP3NT7.js.map} +0 -0
  707. /package/dist/{chunk-NRLELHAY.js.map → chunk-G7NYVKD6.js.map} +0 -0
  708. /package/dist/{chunk-B3W7GWQB.js.map → chunk-GHTSNGBZ.js.map} +0 -0
  709. /package/dist/{chunk-LUDBXTBJ.js.map → chunk-H272ZPQ3.js.map} +0 -0
  710. /package/dist/{chunk-SN4JXNLL.js.map → chunk-H3TKENU4.js.map} +0 -0
  711. /package/dist/{chunk-4HYNMLT6.js.map → chunk-H4SEGIZY.js.map} +0 -0
  712. /package/dist/{chunk-ACZN5ZXD.js.map → chunk-H54VWRPS.js.map} +0 -0
  713. /package/dist/{chunk-HTP6XRUI.js.map → chunk-HM7RHKS4.js.map} +0 -0
  714. /package/dist/{chunk-Z3SQEEB6.js.map → chunk-HWLIMQE2.js.map} +0 -0
  715. /package/dist/{chunk-2QSZNTDO.js.map → chunk-JBPKEARU.js.map} +0 -0
  716. /package/dist/{chunk-ET2CNMLD.js.map → chunk-JN72EPOE.js.map} +0 -0
  717. /package/dist/{chunk-JCCWJHOP.js.map → chunk-JYZSRNR7.js.map} +0 -0
  718. /package/dist/{chunk-7D6HXODY.js.map → chunk-K7724CH2.js.map} +0 -0
  719. /package/dist/{chunk-X33MJFD2.js.map → chunk-KAXCYM66.js.map} +0 -0
  720. /package/dist/{chunk-7RRUHJPG.js.map → chunk-KB2G2I6Q.js.map} +0 -0
  721. /package/dist/{chunk-ZXBTTMGZ.js.map → chunk-KEF46KL2.js.map} +0 -0
  722. /package/dist/{chunk-UWTDARPF.js.map → chunk-KTWG7CNY.js.map} +0 -0
  723. /package/dist/{chunk-XQYTSZW3.js.map → chunk-L7Z57SID.js.map} +0 -0
  724. /package/dist/{chunk-JMAG7WZ7.js.map → chunk-LO4UKPKX.js.map} +0 -0
  725. /package/dist/{chunk-LDWIPYJ6.js.map → chunk-LS2FHUML.js.map} +0 -0
  726. /package/dist/{chunk-GDB4J2H3.js.map → chunk-MPC7TYTZ.js.map} +0 -0
  727. /package/dist/{chunk-2GF27PGH.js.map → chunk-MRPOZBJC.js.map} +0 -0
  728. /package/dist/{chunk-BR3OOQZQ.js.map → chunk-MWN6QEI2.js.map} +0 -0
  729. /package/dist/{chunk-NZGO2GKL.js.map → chunk-MY5EDR46.js.map} +0 -0
  730. /package/dist/{chunk-LCMUZDBZ.js.map → chunk-N3ZOP7KC.js.map} +0 -0
  731. /package/dist/{chunk-TVW4C7PV.js.map → chunk-NB3LRY4T.js.map} +0 -0
  732. /package/dist/{chunk-QJCWK2A7.js.map → chunk-ND6IQGSZ.js.map} +0 -0
  733. /package/dist/{chunk-NOB2T2FC.js.map → chunk-NHLLKEKK.js.map} +0 -0
  734. /package/dist/{chunk-EJIWBTVM.js.map → chunk-O6ZNNVSP.js.map} +0 -0
  735. /package/dist/{chunk-AG46P24C.js.map → chunk-OB3XMWX5.js.map} +0 -0
  736. /package/dist/{chunk-46QMN7I7.js.map → chunk-PAZY2ZKP.js.map} +0 -0
  737. /package/dist/{chunk-EF4JUM55.js.map → chunk-PX4UMA5Z.js.map} +0 -0
  738. /package/dist/{chunk-NNZFPYYX.js.map → chunk-R7QY5ZVB.js.map} +0 -0
  739. /package/dist/{chunk-RO2X2EYM.js.map → chunk-R7RTXEYG.js.map} +0 -0
  740. /package/dist/{chunk-3LJPSRAN.js.map → chunk-RBCQVOVJ.js.map} +0 -0
  741. /package/dist/{chunk-N4F7ZSSG.js.map → chunk-RC5DXXWC.js.map} +0 -0
  742. /package/dist/{chunk-5CF2R4NS.js.map → chunk-RKBLRTNT.js.map} +0 -0
  743. /package/dist/{chunk-5QZR2RA3.js.map → chunk-ROBHL3GL.js.map} +0 -0
  744. /package/dist/{chunk-D5ZNOKR7.js.map → chunk-S7T2TY65.js.map} +0 -0
  745. /package/dist/{chunk-3LADWWMA.js.map → chunk-SJDQ5RSN.js.map} +0 -0
  746. /package/dist/{chunk-CHWUICVY.js.map → chunk-SV4Z2S67.js.map} +0 -0
  747. /package/dist/{chunk-SEF4IOFE.js.map → chunk-SWIKABKI.js.map} +0 -0
  748. /package/dist/{chunk-JRRQ747T.js.map → chunk-TBXAY2SS.js.map} +0 -0
  749. /package/dist/{chunk-XZBXINXZ.js.map → chunk-TNSCIPBQ.js.map} +0 -0
  750. /package/dist/{chunk-S37NN23M.js.map → chunk-TVEONGBU.js.map} +0 -0
  751. /package/dist/{chunk-5RPMTFB6.js.map → chunk-TWF35IC6.js.map} +0 -0
  752. /package/dist/{chunk-BZTJEILZ.js.map → chunk-U6N5IBVY.js.map} +0 -0
  753. /package/dist/{chunk-7TUB6JWA.js.map → chunk-UCKYTA2T.js.map} +0 -0
  754. /package/dist/{chunk-PPOT6SPR.js.map → chunk-UNNPNBR2.js.map} +0 -0
  755. /package/dist/{chunk-KQAFEZQX.js.map → chunk-VDX2J7OX.js.map} +0 -0
  756. /package/dist/{chunk-J2R275FN.js.map → chunk-VVX5PZFS.js.map} +0 -0
  757. /package/dist/{chunk-ME35HVDJ.js.map → chunk-VYCOJKSX.js.map} +0 -0
  758. /package/dist/{chunk-F5UWQ4LX.js.map → chunk-W24T5YMW.js.map} +0 -0
  759. /package/dist/{chunk-HDQUQBPW.js.map → chunk-W3K3HITK.js.map} +0 -0
  760. /package/dist/{chunk-GDASG7NC.js.map → chunk-W4F3C7N7.js.map} +0 -0
  761. /package/dist/{chunk-LFK623SF.js.map → chunk-WJHGDE7X.js.map} +0 -0
  762. /package/dist/{chunk-3Q6RD76J.js.map → chunk-WQZZDN5M.js.map} +0 -0
  763. /package/dist/{chunk-ZJWDWPX6.js.map → chunk-X5K5TAQZ.js.map} +0 -0
  764. /package/dist/{chunk-ZL3XX5LW.js.map → chunk-XM24CDZX.js.map} +0 -0
  765. /package/dist/{chunk-JTWZKNUH.js.map → chunk-XOVKXJEP.js.map} +0 -0
  766. /package/dist/{chunk-X5YYSAZX.js.map → chunk-XUE46UYW.js.map} +0 -0
  767. /package/dist/{chunk-DJORULH3.js.map → chunk-YRLHEEQT.js.map} +0 -0
  768. /package/dist/{chunk-TA7UZZMW.js.map → chunk-Z3O53WZR.js.map} +0 -0
  769. /package/dist/{chunk-4LG4CPOC.js.map → chunk-Z6COGHHN.js.map} +0 -0
  770. /package/dist/{chunk-RE3H6Y2X.js.map → chunk-ZIW5JVRM.js.map} +0 -0
  771. /package/dist/{forget-2AE4MDK3.js.map → forget-SZ2BXDGF.js.map} +0 -0
  772. /package/dist/{resolution-4DLI3IOR.js.map → graph-append-error.js.map} +0 -0
@@ -6,23 +6,23 @@ import {
6
6
  loadSyncState,
7
7
  syncWearableSource,
8
8
  wearableSourceLabel
9
- } from "./chunk-46QMN7I7.js";
9
+ } from "./chunk-PAZY2ZKP.js";
10
+ import {
11
+ runPeerProfileReasoner
12
+ } from "./chunk-I74SUMNI.js";
10
13
  import {
11
14
  CompressionGuidelineCoordinator
12
15
  } from "./chunk-UXREWVW4.js";
13
16
  import {
14
17
  ActivityStore,
15
18
  MaintenanceScheduler
16
- } from "./chunk-PPOT6SPR.js";
17
- import {
18
- runPeerProfileReasoner
19
- } from "./chunk-I74SUMNI.js";
19
+ } from "./chunk-UNNPNBR2.js";
20
20
  import {
21
21
  migrateFromEngram
22
22
  } from "./chunk-7HYPN2GC.js";
23
23
  import {
24
24
  LcmEngine
25
- } from "./chunk-X2NFFBTO.js";
25
+ } from "./chunk-2L5FSNPC.js";
26
26
  import {
27
27
  chunkTranscriptEntries
28
28
  } from "./chunk-TECVW3JP.js";
@@ -32,27 +32,18 @@ import {
32
32
  import {
33
33
  CompoundingEngine,
34
34
  defaultTierMigrationCycleBudget
35
- } from "./chunk-ZL3XX5LW.js";
35
+ } from "./chunk-XM24CDZX.js";
36
36
  import {
37
37
  SharedContextManager
38
38
  } from "./chunk-IN673LEP.js";
39
- import {
40
- cleanArchivedUserMessage
41
- } from "./chunk-47DU4SGJ.js";
42
39
  import {
43
40
  applyUtilityPromotionRuntimePolicy,
44
41
  applyUtilityRankingRuntimeDelta,
45
42
  loadUtilityRuntimeValues
46
- } from "./chunk-SEF4IOFE.js";
47
- import {
48
- extractTopics
49
- } from "./chunk-KVDUKH5E.js";
43
+ } from "./chunk-SWIKABKI.js";
50
44
  import {
51
- buildTemporalTimelineRecallSection
52
- } from "./chunk-2NKY7OC6.js";
53
- import {
54
- CODEX_THREAD_KEY_PREFIX
55
- } from "./chunk-4EX5WZ4M.js";
45
+ cleanArchivedUserMessage
46
+ } from "./chunk-47DU4SGJ.js";
56
47
  import {
57
48
  TierMigrationExecutor
58
49
  } from "./chunk-YRFAYOFQ.js";
@@ -62,6 +53,15 @@ import {
62
53
  import {
63
54
  TmtBuilder
64
55
  } from "./chunk-ECZU5BJH.js";
56
+ import {
57
+ extractTopics
58
+ } from "./chunk-KVDUKH5E.js";
59
+ import {
60
+ buildTemporalTimelineRecallSection
61
+ } from "./chunk-2NKY7OC6.js";
62
+ import {
63
+ CODEX_THREAD_KEY_PREFIX
64
+ } from "./chunk-4EX5WZ4M.js";
65
65
  import {
66
66
  buildTargetedFactRecallSection,
67
67
  shouldRecallTargetedFactEvidence
@@ -69,10 +69,6 @@ import {
69
69
  import {
70
70
  SessionObserverState
71
71
  } from "./chunk-ODZKV2F7.js";
72
- import {
73
- buildResponseGuidanceRecallSection,
74
- shouldRecallResponseGuidance
75
- } from "./chunk-6TCXIRP5.js";
76
72
  import {
77
73
  mergeWithAgentResults,
78
74
  runDirectAgent,
@@ -97,9 +93,6 @@ import {
97
93
  import {
98
94
  applyRuntimeRetrievalPolicy
99
95
  } from "./chunk-5IZL4DCV.js";
100
- import {
101
- findUnresolvedEntityRefs
102
- } from "./chunk-X7XN6YU4.js";
103
96
  import {
104
97
  RelevanceStore
105
98
  } from "./chunk-KATEWTQJ.js";
@@ -108,6 +101,13 @@ import {
108
101
  reorderByRankedKeys,
109
102
  rerankLocalOrNoop
110
103
  } from "./chunk-LUDXM7MD.js";
104
+ import {
105
+ buildResponseGuidanceRecallSection,
106
+ shouldRecallResponseGuidance
107
+ } from "./chunk-6TCXIRP5.js";
108
+ import {
109
+ findUnresolvedEntityRefs
110
+ } from "./chunk-X7XN6YU4.js";
111
111
  import {
112
112
  applyRecallStateViews
113
113
  } from "./chunk-FYDW33ZB.js";
@@ -137,14 +137,14 @@ import {
137
137
  } from "./chunk-3GPTTA4J.js";
138
138
  import {
139
139
  runLiveConnectorsOnce
140
- } from "./chunk-HTIIXNJQ.js";
140
+ } from "./chunk-4FIH6MPS.js";
141
141
  import {
142
142
  deriveHarmonicRecords,
143
143
  harmonicEntityReferenceMatches,
144
144
  harmonicEntitySegment,
145
145
  normalizedHarmonicEntityIdentity,
146
146
  persistHarmonicRecords
147
- } from "./chunk-LDWIPYJ6.js";
147
+ } from "./chunk-LS2FHUML.js";
148
148
  import {
149
149
  classifyMemoryKind
150
150
  } from "./chunk-YAZNBMNF.js";
@@ -153,7 +153,7 @@ import {
153
153
  } from "./chunk-XXSOVESA.js";
154
154
  import {
155
155
  ExtractionEngine
156
- } from "./chunk-7RRUHJPG.js";
156
+ } from "./chunk-KB2G2I6Q.js";
157
157
  import {
158
158
  parseMemoryActionEligibilityContext
159
159
  } from "./chunk-AJTG3CP7.js";
@@ -161,9 +161,6 @@ import {
161
161
  buildFocusedListRecallSection,
162
162
  shouldRecallFocusedListEvidence
163
163
  } from "./chunk-OH7QLI6W.js";
164
- import {
165
- recordJudgeTrainingPair
166
- } from "./chunk-PWFCHOB3.js";
167
164
  import {
168
165
  createDeferCountMap,
169
166
  createVerdictCache,
@@ -171,12 +168,18 @@ import {
171
168
  judgeFactDurability,
172
169
  validateProcedureExtraction
173
170
  } from "./chunk-ODW5GDFE.js";
171
+ import {
172
+ recordJudgeTrainingPair
173
+ } from "./chunk-PWFCHOB3.js";
174
174
  import {
175
175
  buildExplicitCueRecallSection
176
176
  } from "./chunk-TVIVY7KU.js";
177
+ import {
178
+ planEpisodeWindowsWithFallback
179
+ } from "./chunk-T3GIETKV.js";
177
180
  import {
178
181
  buildEventOrderRecallSection
179
- } from "./chunk-H7BZBSP6.js";
182
+ } from "./chunk-52II7PB6.js";
180
183
  import {
181
184
  shouldRecallEventOrderEvidence
182
185
  } from "./chunk-BUYVPUEM.js";
@@ -188,10 +191,7 @@ import {
188
191
  buildEntityRecallSection,
189
192
  entityRecentTranscriptLookbackHours,
190
193
  readRecentEntityTranscriptEntries
191
- } from "./chunk-FB7LAJQM.js";
192
- import {
193
- planEpisodeWindowsWithFallback
194
- } from "./chunk-T3GIETKV.js";
194
+ } from "./chunk-4TKJGOCJ.js";
195
195
  import {
196
196
  tryDirectAnswer
197
197
  } from "./chunk-VY47VI2T.js";
@@ -203,7 +203,7 @@ import {
203
203
  } from "./chunk-LVXBC6YB.js";
204
204
  import {
205
205
  refreshConvergedNamespaces
206
- } from "./chunk-KA2HZCMG.js";
206
+ } from "./chunk-6NXSYYGP.js";
207
207
  import {
208
208
  builtInConnectorPackageSpecifier,
209
209
  ensureBuiltInWearableConnectors,
@@ -212,27 +212,27 @@ import {
212
212
  runTimelinePublishCli,
213
213
  screenCandidateFact,
214
214
  summarizeVaultPublish
215
- } from "./chunk-45XVII3J.js";
216
- import {
217
- RoutingRulesStore
218
- } from "./chunk-TBUEE7XF.js";
215
+ } from "./chunk-SMWTZLHE.js";
219
216
  import {
220
217
  normalizeReplaySessionKey
221
218
  } from "./chunk-AJVLDJU6.js";
219
+ import {
220
+ RoutingRulesStore
221
+ } from "./chunk-TBUEE7XF.js";
222
222
  import {
223
223
  compareVerifiedEpisodeResults,
224
224
  searchVerifiedEpisodes
225
- } from "./chunk-RO2X2EYM.js";
225
+ } from "./chunk-R7RTXEYG.js";
226
226
  import {
227
227
  ThreadingManager
228
228
  } from "./chunk-OJP3N7UK.js";
229
229
  import {
230
230
  compareVerifiedSemanticRuleResults,
231
231
  searchVerifiedSemanticRules
232
- } from "./chunk-YVLENSNS.js";
232
+ } from "./chunk-5ATKSPEQ.js";
233
233
  import {
234
234
  searchWorkProductLedgerEntries
235
- } from "./chunk-NRLELHAY.js";
235
+ } from "./chunk-G7NYVKD6.js";
236
236
  import {
237
237
  TranscriptManager
238
238
  } from "./chunk-AM4T6CHX.js";
@@ -242,10 +242,10 @@ import {
242
242
  import {
243
243
  runNamespaceMaintenanceFanout,
244
244
  summarizeNamespaceMaintenanceHealth
245
- } from "./chunk-ACZN5ZXD.js";
245
+ } from "./chunk-H54VWRPS.js";
246
246
  import {
247
247
  planNamespaceMaintenance
248
- } from "./chunk-3LADWWMA.js";
248
+ } from "./chunk-SJDQ5RSN.js";
249
249
  import {
250
250
  isAboveImportanceThreshold,
251
251
  scoreImportance
@@ -256,7 +256,7 @@ import {
256
256
  } from "./chunk-OZKOPQCM.js";
257
257
  import {
258
258
  recordEvalShadowRecall
259
- } from "./chunk-MCA2X4WH.js";
259
+ } from "./chunk-4IHBN6WU.js";
260
260
  import {
261
261
  collectNativeKnowledgeChunks,
262
262
  formatNativeKnowledgeSection,
@@ -264,7 +264,7 @@ import {
264
264
  } from "./chunk-2DQ2XREU.js";
265
265
  import {
266
266
  applyCommitmentLedgerLifecycle
267
- } from "./chunk-NOB2T2FC.js";
267
+ } from "./chunk-NHLLKEKK.js";
268
268
  import {
269
269
  buildConsolidationPrompt,
270
270
  buildExtensionsBlockForConsolidation,
@@ -274,7 +274,10 @@ import {
274
274
  materializeAfterSemanticConsolidation,
275
275
  parseConsolidationResponse,
276
276
  parseOperatorAwareConsolidationResponse
277
- } from "./chunk-F5UWQ4LX.js";
277
+ } from "./chunk-W24T5YMW.js";
278
+ import {
279
+ BoxBuilder
280
+ } from "./chunk-B7RWBZXW.js";
278
281
  import {
279
282
  semanticChunkContent
280
283
  } from "./chunk-2GBFKHBZ.js";
@@ -283,7 +286,25 @@ import {
283
286
  } from "./chunk-6TBIWIAG.js";
284
287
  import {
285
288
  SmartBuffer
286
- } from "./chunk-4LG4CPOC.js";
289
+ } from "./chunk-Z6COGHHN.js";
290
+ import {
291
+ REFUSED_MERGE_CATEGORIES,
292
+ applyNoveltyGate,
293
+ connectorMatchesScope,
294
+ decideSemanticMerge,
295
+ detectMeetings,
296
+ embeddingsFromCosineHits,
297
+ normalizeConnectorScope
298
+ } from "./chunk-2IOHTUP3.js";
299
+ import {
300
+ compileCorrectionRule,
301
+ correctionsFilePath,
302
+ loadCorrectionsFile,
303
+ saveCorrectionsFile
304
+ } from "./chunk-ZKOPY4WW.js";
305
+ import {
306
+ resolveJournalSource
307
+ } from "./chunk-OGUKSLYZ.js";
287
308
  import {
288
309
  AMBIENT_CAPTURE_PROMPT_RULE,
289
310
  isHighImpactPersonalFact
@@ -301,29 +322,12 @@ import {
301
322
  import {
302
323
  isDisagreementPrompt
303
324
  } from "./chunk-H3FZVNRN.js";
304
- import {
305
- BoxBuilder
306
- } from "./chunk-B7RWBZXW.js";
307
325
  import {
308
326
  evaluateMemoryActionPolicy
309
327
  } from "./chunk-MI2OTWV5.js";
310
- import {
311
- applyNoveltyGate,
312
- detectMeetings,
313
- embeddingsFromCosineHits
314
- } from "./chunk-FCATYKQA.js";
315
- import {
316
- compileCorrectionRule,
317
- correctionsFilePath,
318
- loadCorrectionsFile,
319
- saveCorrectionsFile
320
- } from "./chunk-ZKOPY4WW.js";
321
- import {
322
- resolveJournalSource
323
- } from "./chunk-OGUKSLYZ.js";
324
328
  import {
325
329
  MeetingsInputError
326
- } from "./chunk-KK66P5GQ.js";
330
+ } from "./chunk-C553ZTLF.js";
327
331
  import {
328
332
  WearablesInputError,
329
333
  describeErrorForOperator
@@ -335,9 +339,13 @@ import {
335
339
  foldQueueWaitTiming,
336
340
  recordRecallTiming
337
341
  } from "./chunk-CEN6DW6X.js";
342
+ import {
343
+ removeNodeEdgesForRewrite,
344
+ rollbackNodeEdgeRewrite
345
+ } from "./chunk-DGS34QSY.js";
338
346
  import {
339
347
  NamespaceCatalog
340
- } from "./chunk-GGYDJJBO.js";
348
+ } from "./chunk-QOOBICJF.js";
341
349
  import {
342
350
  RecallResultFormatter,
343
351
  SessionContextCoordinator,
@@ -349,10 +357,10 @@ import {
349
357
  isTopLevelArchivePath,
350
358
  journalPath,
351
359
  writeJournalFile
352
- } from "./chunk-NQFCLAYT.js";
360
+ } from "./chunk-ICKJ52PE.js";
353
361
  import {
354
362
  importCapsule
355
- } from "./chunk-J2R275FN.js";
363
+ } from "./chunk-VVX5PZFS.js";
356
364
  import {
357
365
  isCodingGraphInstalled
358
366
  } from "./chunk-VQ7B2Q6M.js";
@@ -366,7 +374,7 @@ import {
366
374
  import {
367
375
  listTrustZoneRecords,
368
376
  searchTrustZoneRecords
369
- } from "./chunk-5QZR2RA3.js";
377
+ } from "./chunk-ROBHL3GL.js";
370
378
  import {
371
379
  HourlySummarizer
372
380
  } from "./chunk-N3SS45OW.js";
@@ -375,17 +383,17 @@ import {
375
383
  RecallHandleHistoryStore,
376
384
  TierMigrationStatusStore,
377
385
  clampGraphRecallExpandedEntries
378
- } from "./chunk-ZVZHG7AI.js";
386
+ } from "./chunk-5UBH37SL.js";
379
387
  import {
380
388
  buildXraySnapshot
381
- } from "./chunk-JOYC4RYC.js";
389
+ } from "./chunk-2JVJ7UHC.js";
382
390
  import {
383
391
  objectiveStateStoreOverrideForNamespace,
384
392
  searchObjectiveStateSnapshots
385
- } from "./chunk-HTP6XRUI.js";
393
+ } from "./chunk-HM7RHKS4.js";
386
394
  import {
387
395
  searchHarmonicRetrieval
388
- } from "./chunk-ZZM476NV.js";
396
+ } from "./chunk-6XL73HQ4.js";
389
397
  import {
390
398
  ProfilingCollector
391
399
  } from "./chunk-NLE6TSLG.js";
@@ -401,7 +409,7 @@ import {
401
409
  } from "./chunk-LTHVM4XN.js";
402
410
  import {
403
411
  shouldSkipImplicitExtraction
404
- } from "./chunk-X5YYSAZX.js";
412
+ } from "./chunk-XUE46UYW.js";
405
413
  import {
406
414
  boundRecallContextComposition,
407
415
  composeRecallContext,
@@ -410,18 +418,21 @@ import {
410
418
  renderAuthorityBoundContent,
411
419
  selectCuriosityQuestion
412
420
  } from "./chunk-7ZNJN5WZ.js";
413
- import {
414
- NamespaceStorageRouter
415
- } from "./chunk-UMEOXLIZ.js";
416
421
  import {
417
422
  pruneOrphanCueAnchors
418
- } from "./chunk-ACPCA4NO.js";
423
+ } from "./chunk-BMWN7B3Y.js";
424
+ import {
425
+ NamespaceStorageRouter
426
+ } from "./chunk-E2P7TZTF.js";
419
427
  import {
420
428
  GraphIndex
421
- } from "./chunk-OLT3YTDH.js";
429
+ } from "./chunk-5FAGCOZD.js";
430
+ import {
431
+ GraphEdgeAppendError
432
+ } from "./chunk-GKCXTSFF.js";
422
433
  import {
423
434
  buildChainFollowupGenerator
424
- } from "./chunk-LFK623SF.js";
435
+ } from "./chunk-WJHGDE7X.js";
425
436
  import {
426
437
  QmdResultResolver,
427
438
  StorageManager,
@@ -440,7 +451,7 @@ import {
440
451
  reconstructFusionInputs,
441
452
  selfDeps,
442
453
  serializeFusionDay
443
- } from "./chunk-OGTKQ5MJ.js";
454
+ } from "./chunk-XSGUMQQQ.js";
444
455
  import {
445
456
  bodyIsEscaped,
446
457
  decodeTranscriptBody,
@@ -453,16 +464,16 @@ import {
453
464
  } from "./chunk-UHVXE24Y.js";
454
465
  import {
455
466
  buildRetiredFactTombstoneInputs
456
- } from "./chunk-4ZWCQJNM.js";
467
+ } from "./chunk-46WM6JX2.js";
457
468
  import {
458
469
  NamespaceSearchRouter,
459
470
  namespaceCollectionName
460
- } from "./chunk-6FUMA6AA.js";
471
+ } from "./chunk-2Z4GS5E6.js";
461
472
  import {
462
473
  createConversationIndexRuntime,
463
474
  createSearchBackend,
464
475
  isSearchBackendEnabled
465
- } from "./chunk-D35XLYQ7.js";
476
+ } from "./chunk-6CVNSDCZ.js";
466
477
  import {
467
478
  NoopSearchBackend
468
479
  } from "./chunk-CYEPCZN5.js";
@@ -476,7 +487,7 @@ import {
476
487
  } from "./chunk-S2V7RUCL.js";
477
488
  import {
478
489
  confidenceTier
479
- } from "./chunk-XOQGUGJL.js";
490
+ } from "./chunk-SO7SV523.js";
480
491
  import {
481
492
  lintWorkspaceFiles,
482
493
  rotateMarkdownFileToArchive
@@ -494,6 +505,12 @@ import {
494
505
  dominantCorpusLanguage,
495
506
  planCrossScript
496
507
  } from "./chunk-3WU7XOFN.js";
508
+ import {
509
+ createVersion,
510
+ pruneVersions,
511
+ recordStrandedCommit,
512
+ removeVersion
513
+ } from "./chunk-JPKK466T.js";
497
514
  import {
498
515
  bumpMemoryCorpusVersionForDir
499
516
  } from "./chunk-XCB6QDL6.js";
@@ -507,7 +524,7 @@ import {
507
524
  requestEntityCanonicalIdReconcile,
508
525
  requestEntityCanonicalIdReconcileSync,
509
526
  withRawEntityPageMutation
510
- } from "./chunk-NNZFPYYX.js";
527
+ } from "./chunk-R7QY5ZVB.js";
511
528
  import {
512
529
  applyTemporalSupersession,
513
530
  applyTemporalSupersessionPrimaryMutation,
@@ -560,7 +577,7 @@ import {
560
577
  throwIfRecallAborted,
561
578
  tokenizeRecallQuery,
562
579
  utcDateKeysForLocalDay
563
- } from "./chunk-XQYTSZW3.js";
580
+ } from "./chunk-L7Z57SID.js";
564
581
  import {
565
582
  inferIntentFromText,
566
583
  intentCompatibilityScore,
@@ -571,7 +588,7 @@ import {
571
588
  TAG_LIMITS,
572
589
  composeMemoryEnvelope,
573
590
  isMemoryCategory
574
- } from "./chunk-WKAXBXVA.js";
591
+ } from "./chunk-3QQTXYZ6.js";
575
592
  import {
576
593
  normalizeTags
577
594
  } from "./chunk-BT7NVCML.js";
@@ -588,19 +605,6 @@ import {
588
605
  import {
589
606
  extractJsonCandidates
590
607
  } from "./chunk-RGMVMVMF.js";
591
- import {
592
- createBoundedCoreSectionRunner,
593
- createRecallSectionMetricRecorder,
594
- resolveRecallCoreSectionDeadlineMs,
595
- runRecallSectionWithinDeadline
596
- } from "./chunk-4O4TKIXQ.js";
597
- import {
598
- decideLifecycleTransition,
599
- resolveLifecycleState
600
- } from "./chunk-TBBDFYXW.js";
601
- import {
602
- estimateTokenCount
603
- } from "./chunk-TOTT6S2V.js";
604
608
  import {
605
609
  assertExternalWikiRootOutsideMemoryDirCanonical
606
610
  } from "./chunk-JV3C2MNQ.js";
@@ -609,7 +613,7 @@ import {
609
613
  } from "./chunk-QDW3E4RD.js";
610
614
  import {
611
615
  searchCausalTrajectories
612
- } from "./chunk-2Z3DG5CQ.js";
616
+ } from "./chunk-B3O3IRZN.js";
613
617
  import {
614
618
  activityDayWindow,
615
619
  assertValidTimezone,
@@ -621,13 +625,27 @@ import {
621
625
  evaluateSubjectGuard,
622
626
  isSharedPromotionTarget,
623
627
  resolveWriteSubject
624
- } from "./chunk-ME35HVDJ.js";
628
+ } from "./chunk-VYCOJKSX.js";
625
629
  import {
630
+ isUntrustedOrigin,
626
631
  parseOriginClass
627
632
  } from "./chunk-6Q3ZTEF6.js";
633
+ import {
634
+ createBoundedCoreSectionRunner,
635
+ createRecallSectionMetricRecorder,
636
+ resolveRecallCoreSectionDeadlineMs,
637
+ runRecallSectionWithinDeadline
638
+ } from "./chunk-4O4TKIXQ.js";
639
+ import {
640
+ decideLifecycleTransition,
641
+ resolveLifecycleState
642
+ } from "./chunk-TBBDFYXW.js";
628
643
  import {
629
644
  normalizeRecallTokenSet
630
645
  } from "./chunk-YCVB7X56.js";
646
+ import {
647
+ estimateTokenCount
648
+ } from "./chunk-TOTT6S2V.js";
631
649
  import {
632
650
  coerceBool,
633
651
  coerceBooleanLike,
@@ -637,16 +655,6 @@ import {
637
655
  graphemeUnits,
638
656
  truncateGraphemeSafe
639
657
  } from "./chunk-PJKTFXE2.js";
640
- import {
641
- CAPSULE_ID_PATTERN
642
- } from "./chunk-WEHSQBFR.js";
643
- import {
644
- keyring_exports,
645
- secureStoreDir
646
- } from "./chunk-BJMBJZ2Y.js";
647
- import {
648
- buildRetrievedMemoryProvenance
649
- } from "./chunk-I4WBNM3M.js";
650
658
  import {
651
659
  getConfiguredNamespaces,
652
660
  resolveNamespaceFromStorageDir,
@@ -655,26 +663,27 @@ import {
655
663
  import {
656
664
  attachCitation,
657
665
  hasCitationForTemplate,
666
+ lastCitationMarkerForTemplate,
658
667
  stripCitationForTemplate
659
- } from "./chunk-J6A3CX5N.js";
668
+ } from "./chunk-TG3FAM2S.js";
669
+ import {
670
+ openBetterSqlite3
671
+ } from "./chunk-RL6NEVXT.js";
672
+ import {
673
+ assertPathInsideRoot
674
+ } from "./chunk-C7HJ3NEI.js";
660
675
  import {
661
676
  inferMemoryStatus,
662
677
  isActiveMemoryStatus,
663
678
  toMemoryPathRel
664
679
  } from "./chunk-7RJUVTVF.js";
665
680
  import {
666
- openBetterSqlite3
667
- } from "./chunk-RL6NEVXT.js";
668
- import {
669
- assertPathInsideRoot
670
- } from "./chunk-GCASGYIO.js";
681
+ ContentHashIndex
682
+ } from "./chunk-NB3LRY4T.js";
671
683
  import {
672
684
  excludeSupportPassportPrivateMemories,
673
685
  isSupportPassportPrivateMemory
674
686
  } from "./chunk-EEOUMG3J.js";
675
- import {
676
- ContentHashIndex
677
- } from "./chunk-TVW4C7PV.js";
678
687
  import {
679
688
  normalizeAttributePairs,
680
689
  stripAttributesSuffix
@@ -688,6 +697,16 @@ import {
688
697
  resolveHandle,
689
698
  stripHandles
690
699
  } from "./chunk-JAKIDQB2.js";
700
+ import {
701
+ CAPSULE_ID_PATTERN
702
+ } from "./chunk-WEHSQBFR.js";
703
+ import {
704
+ keyring_exports,
705
+ secureStoreDir
706
+ } from "./chunk-BJMBJZ2Y.js";
707
+ import {
708
+ buildRetrievedMemoryProvenance
709
+ } from "./chunk-I4WBNM3M.js";
691
710
  import {
692
711
  assertIsDirectoryNotSymlink,
693
712
  assertRealpathInsideRoot
@@ -755,14 +774,14 @@ import {
755
774
  listJsonFilesStrict,
756
775
  withJsonStoreMutationLock,
757
776
  writeJsonFileAtomic
758
- } from "./chunk-P77QX3ID.js";
777
+ } from "./chunk-B6O2YLUR.js";
759
778
  import {
760
779
  isPathInsideStorageRoot,
761
780
  resolveSafeStoragePath
762
781
  } from "./chunk-FF4KLI5W.js";
763
782
  import {
764
783
  SecureStoreLockedError
765
- } from "./chunk-ET2CNMLD.js";
784
+ } from "./chunk-JN72EPOE.js";
766
785
  import {
767
786
  ALL_CATEGORY_DIRS,
768
787
  ALL_CATEGORY_KEYS,
@@ -771,13 +790,13 @@ import {
771
790
  } from "./chunk-VS2IYZRU.js";
772
791
  import {
773
792
  isErrnoCode
774
- } from "./chunk-5UZXUTVO.js";
793
+ } from "./chunk-KNA3BXXL.js";
775
794
  import {
776
795
  log
777
796
  } from "./chunk-3WCASNQZ.js";
778
797
 
779
798
  // src/orchestrator.ts
780
- import path20 from "path";
799
+ import path21 from "path";
781
800
  import { createHash as createHash8 } from "crypto";
782
801
 
783
802
  // src/orchestration/tier-migration-coordinator.ts
@@ -2328,7 +2347,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2328
2347
  namespaces,
2329
2348
  {
2330
2349
  readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
2331
- readMemoryFrontmatter: async (path38, preferredNamespace) => {
2350
+ readMemoryFrontmatter: async (path39, preferredNamespace) => {
2332
2351
  if (!fallbackReader) {
2333
2352
  for (const ns of namespaces) {
2334
2353
  try {
@@ -2340,7 +2359,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2340
2359
  }
2341
2360
  if (!fallbackReader) return null;
2342
2361
  const memory = await this.readQmdResultMemory(
2343
- path38,
2362
+ path39,
2344
2363
  fallbackReader,
2345
2364
  namespaces,
2346
2365
  preferredNamespace
@@ -4837,7 +4856,7 @@ async function decideSemanticDedup(content, lookup, options) {
4837
4856
  if (!Array.isArray(hits) || hits.length === 0) {
4838
4857
  return { action: "keep", reason: "no_candidates" };
4839
4858
  }
4840
- const candidateConnector = typeof options.sourceConnector === "string" && options.sourceConnector.trim().length > 0 ? options.sourceConnector.trim() : void 0;
4859
+ const candidateConnector = normalizeConnectorScope(options.sourceConnector);
4841
4860
  let top;
4842
4861
  let sameConnectorTop;
4843
4862
  for (const hit of hits) {
@@ -4847,7 +4866,7 @@ async function decideSemanticDedup(content, lookup, options) {
4847
4866
  if (!top || hit.score > top.score) {
4848
4867
  top = hit;
4849
4868
  }
4850
- if (candidateConnector !== void 0 && typeof hit.sourceConnector === "string" && hit.sourceConnector.trim() === candidateConnector && (!sameConnectorTop || hit.score > sameConnectorTop.score)) {
4869
+ if (candidateConnector !== void 0 && connectorMatchesScope(hit.sourceConnector, candidateConnector) && (!sameConnectorTop || hit.score > sameConnectorTop.score)) {
4851
4870
  sameConnectorTop = hit;
4852
4871
  }
4853
4872
  }
@@ -4882,122 +4901,1079 @@ async function decideSemanticDedup(content, lookup, options) {
4882
4901
  };
4883
4902
  }
4884
4903
  return {
4885
- action: "keep",
4886
- reason: "no_near_duplicate",
4887
- topScore: top.score,
4888
- topId: top.id
4904
+ action: "keep",
4905
+ reason: "no_near_duplicate",
4906
+ topScore: top.score,
4907
+ topId: top.id
4908
+ };
4909
+ }
4910
+
4911
+ // src/orchestration/extraction-persist-promotion.ts
4912
+ var confidenceTierOrder = [
4913
+ "explicit",
4914
+ "implied",
4915
+ "inferred",
4916
+ "speculative"
4917
+ ];
4918
+ function profileAutoPromotionAllows(scopeProfileWritePlan, category, confidence) {
4919
+ if (!scopeProfileWritePlan) return false;
4920
+ const actualTier = confidenceTier(confidence);
4921
+ const actualRank = confidenceTierOrder.indexOf(actualTier);
4922
+ if (actualRank === -1) return false;
4923
+ const autoPromote = scopeProfileWritePlan.profile.autoPromote;
4924
+ if (!autoPromote.enabled) return false;
4925
+ if (!autoPromote.categories.includes(category)) return false;
4926
+ const minimumRank = confidenceTierOrder.indexOf(autoPromote.minConfidenceTier);
4927
+ return minimumRank !== -1 && actualRank <= minimumRank;
4928
+ }
4929
+ function sharedAutoPromotionAllows(config, scopeProfileWritePlan, category, confidence) {
4930
+ if (!scopeProfileWritePlan) {
4931
+ const actualTier = confidenceTier(confidence);
4932
+ const actualRank = confidenceTierOrder.indexOf(actualTier);
4933
+ if (actualRank === -1) return false;
4934
+ if (!resolveRecallEnhancementCapabilities(config).autoPromoteToShared) return false;
4935
+ if (!config.autoPromoteToSharedCategories.includes(category))
4936
+ return false;
4937
+ const minimumRank = confidenceTierOrder.indexOf(
4938
+ config.autoPromoteMinConfidenceTier
4939
+ );
4940
+ return minimumRank !== -1 && actualRank <= minimumRank;
4941
+ }
4942
+ return scopeProfileWritePlan.profile.autoPromote.targets.includes("serverShared") && profileAutoPromotionAllows(scopeProfileWritePlan, category, confidence);
4943
+ }
4944
+ function shouldPromoteToShared(config, scopeProfileWritePlan, profileAllowsSharedWrites, storageDirNamespace, targetStorage, category, confidence) {
4945
+ if (!resolveNamespaceCapabilities(config).namespaces || !profileAllowsSharedWrites || !sharedAutoPromotionAllows(config, scopeProfileWritePlan, category, confidence))
4946
+ return false;
4947
+ if (storageDirNamespace(targetStorage.dir) === config.sharedNamespace)
4948
+ return false;
4949
+ return true;
4950
+ }
4951
+ async function readActiveMemoriesBothTiers(storage) {
4952
+ const [hotMems, coldMems] = await Promise.all([
4953
+ storage.readAllMemories(),
4954
+ storage.readAllColdMemories()
4955
+ ]);
4956
+ return coldMems.length === 0 ? hotMems : [...hotMems, ...coldMems];
4957
+ }
4958
+ async function flushDeferredFactHashOnFailure(saveContentHashIndexes, deferred) {
4959
+ if (!deferred) return;
4960
+ await saveContentHashIndexes().catch(
4961
+ (err) => log.warn(`content-hash flush after post-write failure failed: ${err}`)
4962
+ );
4963
+ }
4964
+ function promotionWithholdsToolScope(options) {
4965
+ return options.toolScoped === true || withholdToolScopedFromSharedNamespace(options);
4966
+ }
4967
+ function makeSubjectGuardAllows(config) {
4968
+ return (subject, target, label) => {
4969
+ const decision = evaluateSubjectGuard({
4970
+ subject,
4971
+ sharedTarget: isSharedPromotionTarget(target),
4972
+ mode: config.subjectGuard
4973
+ });
4974
+ if (decision.action !== "allow") {
4975
+ log.warn(`subject-guard(${decision.action}) ${label}: ${decision.reason}`);
4976
+ }
4977
+ return decision.action !== "reject";
4978
+ };
4979
+ }
4980
+ function promotionScanNamespaces(config, scopeProfileWritePlan) {
4981
+ const namespaces = [];
4982
+ if (scopeProfileWritePlan) {
4983
+ for (const target of scopeProfileWritePlan.promotionTargets) {
4984
+ if (target.target !== "serverShared" && target.namespace) {
4985
+ namespaces.push(target.namespace);
4986
+ }
4987
+ }
4988
+ for (const layer of scopeProfileWritePlan.layers ?? []) {
4989
+ if (layer.id !== "serverShared" && layer.namespace) {
4990
+ namespaces.push(layer.namespace);
4991
+ }
4992
+ }
4993
+ }
4994
+ namespaces.push(config.sharedNamespace);
4995
+ return [...new Set(namespaces)];
4996
+ }
4997
+ function createBatchPromotedCopyProbe(config, getStorageRouter, scopeProfileWritePlan) {
4998
+ const scans = /* @__PURE__ */ new Map();
4999
+ const scanNamespace = (namespace) => {
5000
+ let entry = scans.get(namespace);
5001
+ if (entry === void 0) {
5002
+ entry = (async () => {
5003
+ try {
5004
+ const storage = await getStorageRouter().storageFor(namespace);
5005
+ const active = await readActiveMemoriesBothTiers(storage);
5006
+ return {
5007
+ dir: storage.dir,
5008
+ // Round N+11 (A): only ACTIVE copies count as promoted (§41 —
5009
+ // enumerate the active set). readActiveMemoriesBothTiers returns
5010
+ // every hot+cold copy, superseded ones included; a superseded
5011
+ // copy serves no body, so counting it made targetHasPromotedCopies
5012
+ // reject every later judge-approved merge and the supposedly
5013
+ // mergeable updates accumulated as new fragments instead.
5014
+ sourceIds: new Set(
5015
+ active.filter(
5016
+ (memory) => inferMemoryStatus(memory.frontmatter, toMemoryPathRel(storage.dir, memory.path)) === "active"
5017
+ ).map((memory) => memory.frontmatter.sourceMemoryId).filter((id) => typeof id === "string")
5018
+ )
5019
+ };
5020
+ } catch (err) {
5021
+ log.warn(
5022
+ `semantic-merge guard: promotion namespace "${namespace}" unreadable; bypassing the merge (finding C): ${err instanceof Error ? err.message : String(err)}`
5023
+ );
5024
+ return { dir: "", sourceIds: null };
5025
+ }
5026
+ })();
5027
+ scans.set(namespace, entry);
5028
+ }
5029
+ return entry;
5030
+ };
5031
+ return {
5032
+ check: async (sourceStorage, targetMemoryId) => {
5033
+ for (const namespace of promotionScanNamespaces(config, scopeProfileWritePlan)) {
5034
+ const entry = await scanNamespace(namespace);
5035
+ if (entry.sourceIds === null) return true;
5036
+ if (entry.dir === sourceStorage.dir) continue;
5037
+ if (entry.sourceIds.has(targetMemoryId)) return true;
5038
+ }
5039
+ return false;
5040
+ },
5041
+ invalidate: () => {
5042
+ scans.clear();
5043
+ }
5044
+ };
5045
+ }
5046
+ async function promoteAndReconcileMergedTarget(args) {
5047
+ let promotedCopyId;
5048
+ if (args.mergedPromotion) {
5049
+ const payload = args.mergedPromotion;
5050
+ const current = await args.sourceStorage.getMemoryByIdIncludingArchived(args.sourceMemoryId).catch(() => null);
5051
+ if (!current || inferMemoryStatus(current.frontmatter, current.path) !== "active" || current.content !== payload.content || (current.frontmatter.updated ?? void 0) !== (payload.committedRevision ?? void 0)) {
5052
+ log.warn(
5053
+ `persistExtraction: merged-target promotion abandoned for ${args.sourceMemoryId} \u2014 the committed record advanced past the cached payload, so the newer writer's copy stands`
5054
+ );
5055
+ return;
5056
+ }
5057
+ try {
5058
+ promotedCopyId = await args.promote(payload);
5059
+ } catch (err) {
5060
+ log.warn(
5061
+ `persistExtraction: merged-target promotion failed open for ${args.sourceMemoryId}: ${err}`
5062
+ );
5063
+ }
5064
+ }
5065
+ try {
5066
+ await retireStaleMergedTargetPromotionCopies({
5067
+ config: args.config,
5068
+ getStorageRouter: args.getStorageRouter,
5069
+ scopeProfileWritePlan: args.scopeProfileWritePlan,
5070
+ sourceStorage: args.sourceStorage,
5071
+ sourceMemoryId: args.sourceMemoryId,
5072
+ ...args.mergedPromotion ? { promotedContent: args.mergedPromotion.content } : {},
5073
+ ...promotedCopyId !== void 0 ? { promotedMemoryId: promotedCopyId } : {},
5074
+ normalize: args.normalize
5075
+ });
5076
+ args.onReconciled?.();
5077
+ } catch (err) {
5078
+ log.warn(
5079
+ `persistExtraction: merged-target promotion reconciliation failed open for ${args.sourceMemoryId}: ${err}`
5080
+ );
5081
+ }
5082
+ }
5083
+ async function retireStaleMergedTargetPromotionCopies(args) {
5084
+ const canonicalRecord = await args.sourceStorage.getMemoryByIdIncludingArchived(args.sourceMemoryId).catch(() => null);
5085
+ const canonicalBody = canonicalRecord?.content;
5086
+ if (typeof canonicalBody !== "string" || canonicalBody.length === 0) {
5087
+ log.warn(
5088
+ `persistExtraction: merged-target promotion reconciliation aborted for ${args.sourceMemoryId} \u2014 the canonical record could not be read, so no copy is retired`
5089
+ );
5090
+ return 0;
5091
+ }
5092
+ const canonicalForm = args.normalize(canonicalBody);
5093
+ const supersessionTarget = args.promotedContent !== void 0 && args.promotedMemoryId !== void 0 && args.normalize(args.promotedContent) === canonicalForm ? args.promotedMemoryId : args.sourceMemoryId;
5094
+ let retired = 0;
5095
+ for (const namespace of promotionScanNamespaces(args.config, args.scopeProfileWritePlan)) {
5096
+ try {
5097
+ const storage = await args.getStorageRouter().storageFor(namespace);
5098
+ if (storage.dir === args.sourceStorage.dir) continue;
5099
+ const active = await readActiveMemoriesBothTiers(storage);
5100
+ const stale = active.filter(
5101
+ (memory) => memory.frontmatter.sourceMemoryId === args.sourceMemoryId && (memory.frontmatter.status ?? "active") === "active" && args.normalize(memory.content ?? "") !== canonicalForm
5102
+ );
5103
+ for (const memory of stale) {
5104
+ const superseded = await storage.supersedeMemory(
5105
+ memory.frontmatter.id,
5106
+ supersessionTarget,
5107
+ "merged-target promotion reconciliation"
5108
+ );
5109
+ if (superseded) {
5110
+ retired++;
5111
+ log.warn(
5112
+ `persistExtraction: superseded stale promoted copy ${memory.frontmatter.id} of ${args.sourceMemoryId} \u2014 it carried the pre-merge body while ${supersessionTarget} serves the merged body`
5113
+ );
5114
+ }
5115
+ }
5116
+ } catch (err) {
5117
+ log.warn(
5118
+ `persistExtraction: merged-target promotion reconciliation failed open for namespace "${namespace}": ${err instanceof Error ? err.message : String(err)}`
5119
+ );
5120
+ }
5121
+ }
5122
+ return retired;
5123
+ }
5124
+
5125
+ // src/orchestration/harmonic-construction-persist.ts
5126
+ function filterHarmonicEntityMentions(facts, entityMentions) {
5127
+ const identitiesBySegment = /* @__PURE__ */ new Map();
5128
+ for (const entity of entityMentions) {
5129
+ const segment = harmonicEntitySegment(entity.name);
5130
+ const identities = identitiesBySegment.get(segment) ?? /* @__PURE__ */ new Set();
5131
+ identities.add(normalizedHarmonicEntityIdentity(entity.name));
5132
+ identitiesBySegment.set(segment, identities);
5133
+ }
5134
+ return entityMentions.flatMap((entity) => {
5135
+ const allowSegmentFallback = identitiesBySegment.get(harmonicEntitySegment(entity.name))?.size === 1;
5136
+ const activeFacts = facts.filter(
5137
+ (fact) => typeof fact.entityRef === "string" && harmonicEntityReferenceMatches(fact.entityRef, entity.name, allowSegmentFallback)
5138
+ );
5139
+ return activeFacts.length > 0 ? [{ ...entity, facts: activeFacts.map((fact) => fact.content) }] : [];
5140
+ });
5141
+ }
5142
+ function enqueueMergedTargetForHarmonicConstruction(entries, storage, fact, memoryId, content, insertedAt) {
5143
+ const entry = entries.get(storage.dir) ?? { storage, facts: [] };
5144
+ const prior = entry.facts.findIndex((existing) => existing.memoryId === memoryId);
5145
+ if (prior !== -1) {
5146
+ entry.facts[prior] = {
5147
+ ...fact,
5148
+ content,
5149
+ memoryId,
5150
+ insertedAt,
5151
+ cueAnchors: [
5152
+ ...entry.facts[prior].cueAnchors ?? [],
5153
+ ...fact.cueAnchors ?? []
5154
+ ]
5155
+ };
5156
+ } else {
5157
+ entry.facts.push({ ...fact, content, memoryId, insertedAt });
5158
+ }
5159
+ entries.set(storage.dir, entry);
5160
+ }
5161
+ async function persistConstructedHarmonicRecords(options) {
5162
+ const sessionKey = options.sessionKey?.trim();
5163
+ if (!sessionKey) {
5164
+ log.warn("harmonic construction skipped: extraction session key is missing");
5165
+ return;
5166
+ }
5167
+ const recordedAt = options.validAt && Number.isFinite(Date.parse(options.validAt)) ? new Date(options.validAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
5168
+ const entries = [...options.entries];
5169
+ const sharedEpisodeTitle = entries.length === 1 ? options.episodeTitle : void 0;
5170
+ for (const entry of entries) {
5171
+ try {
5172
+ const records = deriveHarmonicRecords({
5173
+ sessionKey,
5174
+ recordedAt,
5175
+ episodeTitle: sharedEpisodeTitle,
5176
+ persistedFacts: entry.facts,
5177
+ entityMentions: filterHarmonicEntityMentions(entry.facts, options.entityMentions).map((entity) => ({
5178
+ name: entity.name,
5179
+ type: entity.type,
5180
+ facts: entity.facts
5181
+ }))
5182
+ });
5183
+ await persistHarmonicRecords({
5184
+ memoryDir: entry.storage.dir,
5185
+ abstractionNodeStoreDir: entry.storage.dir === options.baseStorageDir ? options.abstractionNodeStoreDir : void 0,
5186
+ nodes: records.nodes,
5187
+ anchors: options.anchorsEnabled ? records.anchors : []
5188
+ });
5189
+ } catch (error) {
5190
+ log.warn(
5191
+ `harmonic construction failed open for namespace ${entry.storage.dir}: ${error instanceof Error ? error.message : String(error)}`
5192
+ );
5193
+ }
5194
+ }
5195
+ }
5196
+
5197
+ // src/orchestration/semantic-merge-persist.ts
5198
+ import path5 from "path";
5199
+
5200
+ // src/orchestration/semantic-merge-commit-effects.ts
5201
+ import { readFile as readFile2 } from "fs/promises";
5202
+ async function stageMergedTargetSnapshot(target, versioning, memoryDir) {
5203
+ const currentFile = await readFile2(target.path, "utf8");
5204
+ const version = await createVersion(
5205
+ target.path,
5206
+ currentFile,
5207
+ "semantic-merge",
5208
+ versioning,
5209
+ log,
5210
+ "judge-mediated merge-on-write (issue #2330)",
5211
+ memoryDir,
5212
+ { deferPrune: true }
5213
+ );
5214
+ return String(version.versionId);
5215
+ }
5216
+ async function finalizeMergedVersionPrune(targetPath, versioning, memoryDir, targetId, versionId) {
5217
+ await pruneVersions(targetPath, versioning, log, memoryDir, {
5218
+ committedVersionId: versionId
5219
+ }).catch(async (err) => {
5220
+ log.warn(
5221
+ `semantic-merge: version prune finalization failed for ${targetId} (non-fatal): ${err instanceof Error ? err.message : String(err)}`
5222
+ );
5223
+ await recordStrandedCommit(targetPath, versioning, versionId, log, memoryDir);
5224
+ });
5225
+ }
5226
+ async function discardMergedTargetSnapshot(targetPath, versioning, memoryDir, targetId, versionId) {
5227
+ await removeVersion(targetPath, versionId, versioning, log, memoryDir).catch(
5228
+ (err) => log.warn(
5229
+ `semantic-merge: staged snapshot ${versionId} removal failed for ${targetId} (non-fatal): ${err instanceof Error ? err.message : String(err)}`
5230
+ )
5231
+ );
5232
+ }
5233
+ async function readTargetSnapshot(storage, target) {
5234
+ const current = await storage.readMemoryByPath(target.path);
5235
+ if (!current || current.frontmatter.id !== target.frontmatter.id) return null;
5236
+ return current;
5237
+ }
5238
+ async function revertMergedContent(storage, target, mergedContent) {
5239
+ try {
5240
+ const current = await readTargetSnapshot(storage, target);
5241
+ if (!current) return false;
5242
+ if (current.content !== mergedContent) return true;
5243
+ return await storage.updateMemoryIfUnchanged(current, target.content, {
5244
+ actor: "semantic-merge-rollback"
5245
+ });
5246
+ } catch {
5247
+ return false;
5248
+ }
5249
+ }
5250
+ async function persistMergedTargetThreadEpisode(threading, threadId, targetId) {
5251
+ if (!threadId) return;
5252
+ try {
5253
+ const thread = await threading.loadThread(threadId);
5254
+ if (!thread) return;
5255
+ const existing = thread.episodeIds.lastIndexOf(targetId);
5256
+ if (existing !== -1) thread.episodeIds.splice(existing, 1);
5257
+ thread.episodeIds.push(targetId);
5258
+ thread.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
5259
+ await threading.saveThread(thread);
5260
+ } catch (err) {
5261
+ log.warn(
5262
+ `semantic-merge: thread episode persist failed for ${targetId} (non-fatal): ${err instanceof Error ? err.message : String(err)}`
5263
+ );
5264
+ }
5265
+ }
5266
+ async function rewriteMergedTargetGraphEdges(storage, input) {
5267
+ const removedEdges = await removeNodeEdgesForRewrite(storage.dir, input.memoryRelPath, input.rewriteTypes);
5268
+ let appended;
5269
+ try {
5270
+ appended = await input.build() ?? void 0;
5271
+ const committedNow = await storage.getMemoryByIdIncludingArchived(input.targetId);
5272
+ if (!committedNow || committedNow.content !== input.mergedContent || committedNow.frontmatter.updated !== input.revisionChecked) {
5273
+ await rollbackNodeEdgeRewrite(storage.dir, input.memoryRelPath, input.rewriteTypes, removedEdges, input.targetId, appended);
5274
+ return false;
5275
+ }
5276
+ return true;
5277
+ } catch (buildErr) {
5278
+ await rollbackNodeEdgeRewrite(
5279
+ storage.dir,
5280
+ input.memoryRelPath,
5281
+ input.rewriteTypes,
5282
+ removedEdges,
5283
+ input.targetId,
5284
+ appended ?? (buildErr instanceof GraphEdgeAppendError ? buildErr.appendedEdges : void 0)
5285
+ );
5286
+ throw buildErr;
5287
+ }
5288
+ }
5289
+ function rawPreCitationMergedBody(deps, mergedContent) {
5290
+ if (resolvePipelineProcessingCapabilities(deps.config).inlineSourceAttribution !== true) {
5291
+ return mergedContent;
5292
+ }
5293
+ const template = deps.config.inlineSourceAttributionFormat;
5294
+ return hasCitationForTemplate(mergedContent, template) ? stripCitationForTemplate(mergedContent, template) : mergedContent;
5295
+ }
5296
+ function committedMergedFactHash(deps, category, committedContent) {
5297
+ if (category !== "fact") return void 0;
5298
+ return ContentHashIndex.computeHash(sanitizeMemoryContent(rawPreCitationMergedBody(deps, committedContent)).text);
5299
+ }
5300
+ async function persistRepairedContentHash(storage, targetId, committedContent, contentHash) {
5301
+ try {
5302
+ const current = await storage.getMemoryByIdIncludingArchived(targetId);
5303
+ if (!current || current.content !== committedContent) return;
5304
+ if (inferMemoryStatus(current.frontmatter, current.path) !== "active") return;
5305
+ if (current.frontmatter.contentHash === contentHash) return;
5306
+ await storage.writeMemoryFrontmatterIfUnchanged(
5307
+ current,
5308
+ { contentHash },
5309
+ { actor: "semantic-merge" }
5310
+ );
5311
+ } catch (err) {
5312
+ log.warn(
5313
+ `semantic-merge: durable content-hash repair failed for ${targetId} (non-fatal; the in-memory index holds the merged body until restart): ${err instanceof Error ? err.message : String(err)}`
5314
+ );
5315
+ }
5316
+ }
5317
+
5318
+ // src/dedup/merge-provenance.ts
5319
+ var MERGE_DERIVED_VIA = "merge";
5320
+ var ISO_TIMESTAMP = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/;
5321
+ function assertIsoInstant(value, field) {
5322
+ if (typeof value !== "string" || !ISO_TIMESTAMP.test(value)) {
5323
+ throw new RangeError(`${field} must be a full ISO 8601 instant, got ${JSON.stringify(value)}`);
5324
+ }
5325
+ const ms = Date.parse(value);
5326
+ if (Number.isNaN(ms)) {
5327
+ throw new RangeError(`${field} must be a full ISO 8601 instant, got ${JSON.stringify(value)}`);
5328
+ }
5329
+ if (!new Date(ms).toISOString().startsWith(value.slice(0, 10))) {
5330
+ throw new RangeError(`${field} is not a real calendar date: ${JSON.stringify(value)}`);
5331
+ }
5332
+ return value;
5333
+ }
5334
+ function assertOffset(value, field) {
5335
+ if (value === void 0) return;
5336
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
5337
+ throw new RangeError(`${field} must be a non-negative integer when present, got ${String(value)}`);
5338
+ }
5339
+ }
5340
+ function normalizeSource(source, index) {
5341
+ const label = `sources[${index}]`;
5342
+ for (const field of ["sessionKey", "quote"]) {
5343
+ const value = source[field];
5344
+ if (typeof value !== "string" || value.trim() === "") {
5345
+ throw new RangeError(`${label}.${field} must be a non-blank string`);
5346
+ }
5347
+ }
5348
+ assertIsoInstant(source.observedAt, `${label}.observedAt`);
5349
+ if (source.turnId !== void 0 && (typeof source.turnId !== "string" || source.turnId.trim() === "")) {
5350
+ throw new RangeError(`${label}.turnId must be a non-blank string when present`);
5351
+ }
5352
+ assertOffset(source.charStart, `${label}.charStart`);
5353
+ assertOffset(source.charEnd, `${label}.charEnd`);
5354
+ if (source.charStart !== void 0 && source.charEnd !== void 0 && source.charEnd < source.charStart) {
5355
+ throw new RangeError(`${label}.charEnd must be >= charStart`);
5356
+ }
5357
+ const copy = {
5358
+ sessionKey: source.sessionKey,
5359
+ observedAt: source.observedAt,
5360
+ quote: source.quote
5361
+ };
5362
+ if (source.turnId !== void 0) copy.turnId = source.turnId;
5363
+ if (source.charStart !== void 0) copy.charStart = source.charStart;
5364
+ if (source.charEnd !== void 0) copy.charEnd = source.charEnd;
5365
+ return copy;
5366
+ }
5367
+ function sourceKey(source) {
5368
+ return JSON.stringify([
5369
+ source.sessionKey,
5370
+ source.turnId ?? null,
5371
+ source.observedAt,
5372
+ source.quote,
5373
+ source.charStart ?? null,
5374
+ source.charEnd ?? null
5375
+ ]);
5376
+ }
5377
+ function buildMergeFrontmatterUpdate(input) {
5378
+ const updated = assertIsoInstant(input.nowIso, "nowIso");
5379
+ const previous = input.targetReinforcementCount;
5380
+ if (previous !== void 0 && (typeof previous !== "number" || !Number.isInteger(previous) || previous < 0)) {
5381
+ throw new RangeError(
5382
+ `reinforcement_count must be a non-negative integer when supplied, got ${String(previous)}`
5383
+ );
5384
+ }
5385
+ const seen = /* @__PURE__ */ new Set();
5386
+ const sources = [];
5387
+ const append = (source, index) => {
5388
+ const copy = normalizeSource(source, index);
5389
+ const key = sourceKey(copy);
5390
+ if (seen.has(key)) return;
5391
+ seen.add(key);
5392
+ sources.push(copy);
5393
+ };
5394
+ const target = input.targetSources ?? [];
5395
+ target.forEach(append);
5396
+ input.incomingSources.forEach((source, i) => append(source, target.length + i));
5397
+ return {
5398
+ updated,
5399
+ derived_via: MERGE_DERIVED_VIA,
5400
+ reinforcement_count: (previous ?? 0) + 1,
5401
+ sources
5402
+ };
5403
+ }
5404
+
5405
+ // src/dedup/merge-judge.ts
5406
+ import { z } from "zod";
5407
+ var MERGE_JUDGE_SYSTEM_PROMPT = `You maintain a long-term memory store. Given a NEW memory and up to N EXISTING
5408
+ memories about a similar topic, decide:
5409
+ - "merge": the new memory describes the SAME underlying concept/state as one
5410
+ existing memory, and the two can be combined into one entry with no
5411
+ information loss. Return targetId (one of the existing ids, verbatim) and
5412
+ mergedContent: one entry containing EVERY concrete detail from BOTH texts
5413
+ (names, numbers, dates, qualifiers). Do not paraphrase away specifics.
5414
+ - "contradicts": the new memory conflicts with an existing one (state change,
5415
+ correction). Do NOT merge.
5416
+ - "create": different concept, or you are unsure.
5417
+ When unsure, choose "create".
5418
+ Respond with a single JSON object: {"decision": "merge"|"create"|"contradicts", "targetId": string|null, "mergedContent": string|null, "reason": string}`;
5419
+ var MergeVerdictSchema = z.object({
5420
+ decision: z.enum(["merge", "create", "contradicts"]),
5421
+ targetId: z.string().optional().nullable(),
5422
+ mergedContent: z.string().optional().nullable(),
5423
+ reason: z.string()
5424
+ });
5425
+ function parseVerdict(raw) {
5426
+ let parsed;
5427
+ try {
5428
+ parsed = JSON.parse(raw);
5429
+ } catch {
5430
+ for (const candidate of extractJsonCandidates(raw)) {
5431
+ try {
5432
+ parsed = JSON.parse(candidate);
5433
+ break;
5434
+ } catch {
5435
+ continue;
5436
+ }
5437
+ }
5438
+ }
5439
+ const checked = MergeVerdictSchema.safeParse(parsed);
5440
+ if (!checked.success) return null;
5441
+ return {
5442
+ decision: checked.data.decision,
5443
+ targetId: checked.data.targetId ?? null,
5444
+ mergedContent: checked.data.mergedContent ?? null,
5445
+ reason: checked.data.reason
5446
+ };
5447
+ }
5448
+ async function callMergeJudge(options) {
5449
+ const userPrompt = JSON.stringify({
5450
+ new: { category: options.category, content: options.content },
5451
+ existing: options.candidates.map((c) => ({
5452
+ id: c.memoryId,
5453
+ category: c.category,
5454
+ similarity: Number(c.similarity.toFixed(4)),
5455
+ content: c.content
5456
+ }))
5457
+ });
5458
+ const messages = [
5459
+ { role: "system", content: MERGE_JUDGE_SYSTEM_PROMPT },
5460
+ { role: "user", content: userPrompt }
5461
+ ];
5462
+ const modelOverride = options.config.extractionJudgeModel || void 0;
5463
+ const skipLocal = options.config.modelSource === "gateway";
5464
+ const gatewayChain = gatewayTaskChainOptions(options.config);
5465
+ const sharedCallOptions = {
5466
+ temperature: 0.1,
5467
+ maxTokens: 2048,
5468
+ ...modelOverride ? { model: modelOverride } : {}
5469
+ };
5470
+ if (options.localLlm && !skipLocal) {
5471
+ try {
5472
+ const result = await options.localLlm.chatCompletion(messages, {
5473
+ ...sharedCallOptions,
5474
+ timeoutMs: 1500,
5475
+ operation: "semantic-merge-judge",
5476
+ responseFormat: { type: "json_object" }
5477
+ });
5478
+ if (result?.content) {
5479
+ const verdict = parseVerdict(result.content);
5480
+ if (verdict) return verdict;
5481
+ }
5482
+ } catch (err) {
5483
+ log.debug(
5484
+ `semantic-merge judge: local LLM failed, trying fallback: ${err instanceof Error ? err.message : String(err)}`
5485
+ );
5486
+ }
5487
+ }
5488
+ if (options.fallbackLlm) {
5489
+ try {
5490
+ const result = await options.fallbackLlm.chatCompletion(
5491
+ messages,
5492
+ { ...sharedCallOptions, timeoutMs: 1500, ...gatewayChain }
5493
+ );
5494
+ if (result?.content) {
5495
+ const verdict = parseVerdict(result.content);
5496
+ if (verdict) return verdict;
5497
+ }
5498
+ } catch (err) {
5499
+ log.debug(
5500
+ `semantic-merge judge: fallback LLM failed: ${err instanceof Error ? err.message : String(err)}`
5501
+ );
5502
+ }
5503
+ }
5504
+ return null;
5505
+ }
5506
+
5507
+ // src/orchestration/semantic-merge-persist.ts
5508
+ var REFUSED = REFUSED_MERGE_CATEGORIES;
5509
+ var PROVENANCE_STRENGTH_RANK = {
5510
+ none: 0,
5511
+ unverified: 1,
5512
+ verified: 2
5513
+ };
5514
+ function provenanceRank(value) {
5515
+ return PROVENANCE_STRENGTH_RANK[value ?? "none"] ?? 0;
5516
+ }
5517
+ function effectiveFaithfulness(verdict) {
5518
+ if (verdict === void 0) return void 0;
5519
+ return verdict === "skipped_no_span" ? "unchecked" : verdict;
5520
+ }
5521
+ function createPathMergeParity(input) {
5522
+ const { target, untrustedOrigins } = input;
5523
+ const md = input.incoming;
5524
+ if (md?.structuredAttributes && Object.keys(md.structuredAttributes).length > 0) {
5525
+ return { ok: false, field: "structuredAttributes" };
5526
+ }
5527
+ if (md?.biTemporal === true) return { ok: false, field: "biTemporal" };
5528
+ if (md?.entityRef !== void 0 && md.entityRef !== target.frontmatter.entityRef) {
5529
+ return { ok: false, field: "entityRef" };
5530
+ }
5531
+ if (md?.validAt !== void 0 && md.validAt !== target.frontmatter.valid_at) {
5532
+ return { ok: false, field: "validAt" };
5533
+ }
5534
+ if (target.frontmatter.invalid_at !== void 0) {
5535
+ return { ok: false, field: "validity_bounds" };
5536
+ }
5537
+ if (target.frontmatter.valid_at !== void 0 && md?.validAt === void 0) {
5538
+ return { ok: false, field: "validity_bounds" };
5539
+ }
5540
+ const targetTags = new Set(target.frontmatter.tags ?? []);
5541
+ if ((md?.tags ?? []).some((tag) => !targetTags.has(tag))) {
5542
+ return { ok: false, field: "tags" };
5543
+ }
5544
+ if (md?.importanceScore !== void 0 && md.importanceScore > (target.frontmatter.importance?.score ?? 0)) {
5545
+ return { ok: false, field: "importance" };
5546
+ }
5547
+ const incomingProvenanceRank = provenanceRank(md?.provenanceStrength);
5548
+ const targetProvenanceRank = provenanceRank(target.frontmatter.provenance);
5549
+ if (incomingProvenanceRank > targetProvenanceRank) {
5550
+ return { ok: false, field: "provenance" };
5551
+ }
5552
+ const provenanceFloor = incomingProvenanceRank < targetProvenanceRank ? md?.provenanceStrength ?? "none" : void 0;
5553
+ if (md?.confidence !== void 0) {
5554
+ if (typeof md.confidence !== "number" || !Number.isFinite(md.confidence) || md.confidence < 0 || md.confidence > 1) {
5555
+ return { ok: false, field: "confidence" };
5556
+ }
5557
+ }
5558
+ const confidenceFloor = md?.confidence !== void 0 && md.confidence < (target.frontmatter.confidence ?? 0.8) ? md.confidence : void 0;
5559
+ if (normalizeConnectorScope(target.frontmatter.sourceConnector) !== normalizeConnectorScope(input.sourceConnector)) {
5560
+ return { ok: false, field: "sourceConnector" };
5561
+ }
5562
+ if (md?.toolScoped === true && target.frontmatter.toolScoped !== true) {
5563
+ return { ok: false, field: "toolScoped" };
5564
+ }
5565
+ if ((md?.subject ?? "user") !== (target.frontmatter.subject ?? "user")) {
5566
+ return { ok: false, field: "subject" };
5567
+ }
5568
+ if (md?.memoryKind !== void 0 && md.memoryKind !== target.frontmatter.memoryKind) {
5569
+ return { ok: false, field: "memoryKind" };
5570
+ }
5571
+ if (isUntrustedOrigin(parseOriginClass(md?.origin), untrustedOrigins) && !isUntrustedOrigin(parseOriginClass(target.frontmatter.origin), untrustedOrigins)) {
5572
+ return { ok: false, field: "origin" };
5573
+ }
5574
+ const incomingFaithfulness = effectiveFaithfulness(md?.faithfulness?.verdict);
5575
+ const targetFaithfulness = effectiveFaithfulness(target.frontmatter.faithfulness?.verdict);
5576
+ if (incomingFaithfulness !== targetFaithfulness) {
5577
+ return { ok: false, field: "faithfulness" };
5578
+ }
5579
+ if (targetFaithfulness === "entailed") {
5580
+ return { ok: false, field: "faithfulness" };
5581
+ }
5582
+ return {
5583
+ ok: true,
5584
+ ...provenanceFloor !== void 0 ? { provenanceFloor } : {},
5585
+ ...confidenceFloor !== void 0 ? { confidenceFloor } : {}
5586
+ };
5587
+ }
5588
+ function committedMergedBody(deps, mergedContent, incomingCitedContent) {
5589
+ if (resolvePipelineProcessingCapabilities(deps.config).inlineSourceAttribution !== true || incomingCitedContent === void 0) {
5590
+ return mergedContent;
5591
+ }
5592
+ const marker = lastCitationMarkerForTemplate(
5593
+ incomingCitedContent,
5594
+ deps.config.inlineSourceAttributionFormat
5595
+ );
5596
+ if (!marker || mergedContent.endsWith(marker)) return mergedContent;
5597
+ return `${mergedContent} ${marker}`;
5598
+ }
5599
+ function versioningConfigFrom(deps) {
5600
+ return {
5601
+ enabled: resolveRecallAuxiliaryCapabilities(deps.config).versioning,
5602
+ maxVersionsPerPage: deps.config.versioningMaxPerPage,
5603
+ sidecarDir: deps.config.versioningSidecarDir
5604
+ };
5605
+ }
5606
+ function mergeMemoryLinks(existing, incoming, survivingTargetId) {
5607
+ if (!incoming || incoming.length === 0) return void 0;
5608
+ const merged = [...existing ?? []];
5609
+ for (const link of incoming) {
5610
+ if (link.targetId === survivingTargetId) continue;
5611
+ if (!merged.some((l) => l.targetId === link.targetId && l.linkType === link.linkType)) {
5612
+ merged.push({ ...link });
5613
+ }
5614
+ }
5615
+ return merged.length > 0 ? merged : void 0;
5616
+ }
5617
+ async function applySemanticMergeAtPersist(deps, options) {
5618
+ const config = deps.config.semanticMerge;
5619
+ if (config?.enabled !== true || options.skip === true) {
5620
+ return { action: "created", reason: "disabled" };
5621
+ }
5622
+ if (REFUSED.includes(options.category)) {
5623
+ return { action: "created", reason: "disabled" };
5624
+ }
5625
+ const decision = await decideSemanticMerge({
5626
+ content: options.content,
5627
+ category: options.category,
5628
+ config,
5629
+ sourceConnector: options.sourceConnector,
5630
+ dedupThreshold: deps.config.semanticDedupThreshold,
5631
+ lookup: (content, limit) => deps.semanticDedupLookup(content, limit, options.storage),
5632
+ resolveCandidate: async (memoryId) => {
5633
+ const memory = await options.storage.getMemoryByIdIncludingArchived(memoryId);
5634
+ if (!memory) return null;
5635
+ return {
5636
+ content: memory.content,
5637
+ category: memory.frontmatter.category,
5638
+ status: inferMemoryStatus(memory.frontmatter, memory.path)
5639
+ };
5640
+ },
5641
+ judge: async (input) => {
5642
+ const call = options.judgeCall ?? callMergeJudge;
5643
+ const verdict = await call({
5644
+ ...input,
5645
+ candidates: [...input.candidates],
5646
+ config: deps.config,
5647
+ localLlm: deps.getLocalLlm(),
5648
+ fallbackLlm: new FallbackLlmClient(
5649
+ deps.config.gatewayConfig,
5650
+ fallbackLlmRuntimeContextFromConfig(deps.config)
5651
+ )
5652
+ });
5653
+ if (!verdict) throw new Error("merge judge unavailable or unparseable");
5654
+ return verdict;
5655
+ }
5656
+ });
5657
+ if (decision.action === "create") {
5658
+ if (config.shadowMode) {
5659
+ log.info(
5660
+ `semantic-merge[shadow]: would create category=${options.category} length=${options.content.length} reason="${decision.reason}"`
5661
+ );
5662
+ }
5663
+ return { action: "created", reason: decision.reason };
5664
+ }
5665
+ if (config.shadowMode) {
5666
+ log.info(
5667
+ `semantic-merge[shadow]: would merge into ${decision.targetId} reason="judge_merge"`
5668
+ );
5669
+ return { action: "created", reason: "shadow_would_merge" };
5670
+ }
5671
+ const target = await options.storage.getMemoryByIdIncludingArchived(decision.targetId);
5672
+ if (!target || inferMemoryStatus(target.frontmatter, target.path) !== "active") {
5673
+ return { action: "created", reason: "target_inactive" };
5674
+ }
5675
+ if (target.content !== decision.targetContent) {
5676
+ return { action: "created", reason: "target_changed" };
5677
+ }
5678
+ const committedContent = committedMergedBody(deps, decision.mergedContent, options.incomingCitedContent);
5679
+ const parity = createPathMergeParity({
5680
+ target,
5681
+ incoming: options.incomingMetadata,
5682
+ sourceConnector: options.sourceConnector,
5683
+ untrustedOrigins: deps.config.untrustedOrigins
5684
+ });
5685
+ if (!parity.ok) {
5686
+ return { action: "created", reason: "metadata_unpreservable" };
5687
+ }
5688
+ if (options.targetHasPromotedCopies && await options.targetHasPromotedCopies(decision.targetId)) {
5689
+ return { action: "created", reason: "promoted_copy_present" };
5690
+ }
5691
+ const versioning = versioningConfigFrom(deps);
5692
+ if (!versioning.enabled) {
5693
+ return { action: "created", reason: "snapshot_unavailable" };
5694
+ }
5695
+ let versionId;
5696
+ try {
5697
+ versionId = await stageMergedTargetSnapshot(target, versioning, options.storage.dir);
5698
+ } catch (err) {
5699
+ log.warn(
5700
+ `semantic-merge: snapshot failed for ${decision.targetId}; creating new fact instead: ${err instanceof Error ? err.message : String(err)}`
5701
+ );
5702
+ return { action: "created", reason: "snapshot_failed" };
5703
+ }
5704
+ const repairIndexes = async (committedFactHash) => {
5705
+ try {
5706
+ await options.storage.removeFactContentHashesForMemories([target]);
5707
+ if (committedFactHash !== void 0) {
5708
+ await options.storage.registerFactContentHash(decision.targetId, committedFactHash, committedContent);
5709
+ await persistRepairedContentHash(
5710
+ options.storage,
5711
+ decision.targetId,
5712
+ committedContent,
5713
+ committedFactHash
5714
+ );
5715
+ } else {
5716
+ await options.storage.restoreFactHashAfterApproval(decision.targetId);
5717
+ }
5718
+ } catch (err) {
5719
+ log.warn(
5720
+ `semantic-merge: hash-index sync failed for ${decision.targetId} (non-fatal; index rebuilds from corpus): ${err instanceof Error ? err.message : String(err)}`
5721
+ );
5722
+ }
5723
+ try {
5724
+ await deps.indexPersistedMemory(options.storage, decision.targetId);
5725
+ } catch (err) {
5726
+ log.warn(
5727
+ `semantic-merge: reindex failed for ${decision.targetId} (non-fatal): ${err instanceof Error ? err.message : String(err)}`
5728
+ );
5729
+ }
5730
+ };
5731
+ const nowIso = (options.now ? options.now() : /* @__PURE__ */ new Date()).toISOString();
5732
+ let contentCommitted = false;
5733
+ let mergePatch;
5734
+ try {
5735
+ mergePatch = buildMergeFrontmatterUpdate({
5736
+ targetSources: target.frontmatter.sources ?? [],
5737
+ incomingSources: options.sources ?? [],
5738
+ targetReinforcementCount: target.frontmatter.reinforcement_count,
5739
+ nowIso
5740
+ });
5741
+ const updated = await options.storage.updateMemoryIfUnchanged(target, committedContent, {
5742
+ actor: "semantic-merge"
5743
+ });
5744
+ if (!updated) {
5745
+ await discardMergedTargetSnapshot(
5746
+ target.path,
5747
+ versioning,
5748
+ options.storage.dir,
5749
+ decision.targetId,
5750
+ versionId
5751
+ );
5752
+ return { action: "created", reason: "target_changed" };
5753
+ }
5754
+ contentCommitted = true;
5755
+ const merged = await readTargetSnapshot(options.storage, target);
5756
+ if (!merged || merged.content !== committedContent) {
5757
+ throw new Error("target replaced before the provenance patch");
5758
+ }
5759
+ const mergedRawBody = rawPreCitationMergedBody(deps, committedContent);
5760
+ const mergedIntent = resolveConversationContextCapabilities(deps.config).intentRouting ? inferIntentFromText(
5761
+ `${merged.frontmatter.category} ${(merged.frontmatter.tags ?? []).join(" ")} ${mergedRawBody}`
5762
+ ) : void 0;
5763
+ const mergedFactHash = options.category === "fact" ? ContentHashIndex.computeHash(sanitizeMemoryContent(mergedRawBody).text) : void 0;
5764
+ const mergedLinks = mergeMemoryLinks(
5765
+ merged.frontmatter.links,
5766
+ options.incomingLinks,
5767
+ decision.targetId
5768
+ );
5769
+ const patched = await options.storage.writeMemoryFrontmatterIfUnchanged(
5770
+ merged,
5771
+ {
5772
+ updated: mergePatch.updated,
5773
+ derived_via: mergePatch.derived_via,
5774
+ reinforcement_count: mergePatch.reinforcement_count,
5775
+ sources: mergePatch.sources,
5776
+ ...mergedFactHash !== void 0 ? { contentHash: mergedFactHash } : {},
5777
+ // Finding B — a weaker incoming provenance retags the combined body
5778
+ // to the least-trusted value instead of letting unverified new
5779
+ // claims ride the target's stronger memory-level tag.
5780
+ ...parity.ok && parity.provenanceFloor !== void 0 ? { provenance: parity.provenanceFloor } : {},
5781
+ // Final round (A) — min(incoming, target) confidence: the merged
5782
+ // record keeps the lower score, and the tier that score maps to,
5783
+ // so lifecycle scoring and the committed-record promotion payload
5784
+ // can never treat the combined body as higher-confidence than the
5785
+ // create path would have stored for the incoming fact alone.
5786
+ ...parity.ok && parity.confidenceFloor !== void 0 ? {
5787
+ confidence: parity.confidenceFloor,
5788
+ confidenceTier: confidenceTier(parity.confidenceFloor)
5789
+ } : {},
5790
+ ...mergedLinks !== void 0 ? { links: mergedLinks } : {},
5791
+ ...mergedIntent !== void 0 ? {
5792
+ intentGoal: mergedIntent.goal,
5793
+ intentActionType: mergedIntent.actionType,
5794
+ intentEntityTypes: mergedIntent.entityTypes
5795
+ } : {}
5796
+ },
5797
+ { actor: "semantic-merge" }
5798
+ );
5799
+ if (!patched) throw new Error("frontmatter patch rejected (target changed)");
5800
+ } catch (err) {
5801
+ const detail = err instanceof Error ? err.message : String(err);
5802
+ if (contentCommitted && !await revertMergedContent(options.storage, target, committedContent)) {
5803
+ log.error(
5804
+ `semantic-merge: ${decision.targetId} holds merged content without provenance metadata and the rollback failed (${detail}); snapshot ${versionId} holds the pre-merge state \u2014 recover with revertToVersion. Not creating a duplicate fact.`
5805
+ );
5806
+ await finalizeMergedVersionPrune(target.path, versioning, options.storage.dir, decision.targetId, versionId);
5807
+ await repairIndexes(committedMergedFactHash(deps, options.category, committedContent));
5808
+ return {
5809
+ action: "merged",
5810
+ targetId: decision.targetId,
5811
+ mergedContent: committedContent,
5812
+ provenancePatched: false
5813
+ };
5814
+ }
5815
+ if (contentCommitted) {
5816
+ await discardMergedTargetSnapshot(
5817
+ target.path,
5818
+ versioning,
5819
+ options.storage.dir,
5820
+ decision.targetId,
5821
+ versionId
5822
+ );
5823
+ }
5824
+ log.warn(
5825
+ `semantic-merge: update failed for ${decision.targetId}${contentCommitted ? ` (content rolled back; snapshot ${versionId} rolled back out of history)` : ` (snapshot ${versionId} staged)`}: ${detail}`
5826
+ );
5827
+ return { action: "created", reason: "update_failed" };
5828
+ }
5829
+ await finalizeMergedVersionPrune(target.path, versioning, options.storage.dir, decision.targetId, versionId);
5830
+ await repairIndexes();
5831
+ log.info(
5832
+ `semantic-merge: merged fact into ${decision.targetId} (version ${versionId})`
5833
+ );
5834
+ return {
5835
+ action: "merged",
5836
+ targetId: decision.targetId,
5837
+ mergedContent: committedContent,
5838
+ provenancePatched: true
4889
5839
  };
4890
5840
  }
4891
-
4892
- // src/orchestration/extraction-persist-promotion.ts
4893
- var confidenceTierOrder = [
4894
- "explicit",
4895
- "implied",
4896
- "inferred",
4897
- "speculative"
4898
- ];
4899
- function profileAutoPromotionAllows(scopeProfileWritePlan, category, confidence) {
4900
- if (!scopeProfileWritePlan) return false;
4901
- const actualTier = confidenceTier(confidence);
4902
- const actualRank = confidenceTierOrder.indexOf(actualTier);
4903
- if (actualRank === -1) return false;
4904
- const autoPromote = scopeProfileWritePlan.profile.autoPromote;
4905
- if (!autoPromote.enabled) return false;
4906
- if (!autoPromote.categories.includes(category)) return false;
4907
- const minimumRank = confidenceTierOrder.indexOf(autoPromote.minConfidenceTier);
4908
- return minimumRank !== -1 && actualRank <= minimumRank;
4909
- }
4910
- function sharedAutoPromotionAllows(config, scopeProfileWritePlan, category, confidence) {
4911
- if (!scopeProfileWritePlan) {
4912
- const actualTier = confidenceTier(confidence);
4913
- const actualRank = confidenceTierOrder.indexOf(actualTier);
4914
- if (actualRank === -1) return false;
4915
- if (!resolveRecallEnhancementCapabilities(config).autoPromoteToShared) return false;
4916
- if (!config.autoPromoteToSharedCategories.includes(category))
4917
- return false;
4918
- const minimumRank = confidenceTierOrder.indexOf(
4919
- config.autoPromoteMinConfidenceTier
5841
+ async function writeMergedVerbatimArtifact(deps, storage, targetId, input) {
5842
+ if (!resolvePresentationCapabilities(deps.config).verbatimArtifacts) return;
5843
+ if (!deps.config.verbatimArtifactCategories.includes(input.category)) {
5844
+ return;
5845
+ }
5846
+ if (!(input.confidence >= deps.config.verbatimArtifactsMinConfidence)) return;
5847
+ try {
5848
+ await storage.writeArtifact(input.citedContent, {
5849
+ confidence: input.confidence,
5850
+ tags: [...input.tags, "artifact"],
5851
+ artifactType: deps.artifactTypeForCategory(input.category),
5852
+ sourceMemoryId: targetId,
5853
+ intentGoal: input.intent?.goal,
5854
+ intentActionType: input.intent?.actionType,
5855
+ intentEntityTypes: input.intent?.entityTypes,
5856
+ ...input.sourceConnector ? { sourceConnector: input.sourceConnector } : {},
5857
+ ...input.origin ? { origin: input.origin } : {},
5858
+ ...input.toolScoped ? { toolScoped: true } : {}
5859
+ });
5860
+ } catch (err) {
5861
+ log.warn(
5862
+ `semantic-merge: verbatim artifact write failed for ${targetId} (non-fatal; the committed target remains discoverable): ${err instanceof Error ? err.message : String(err)}`
4920
5863
  );
4921
- return minimumRank !== -1 && actualRank <= minimumRank;
4922
5864
  }
4923
- return scopeProfileWritePlan.profile.autoPromote.targets.includes("serverShared") && profileAutoPromotionAllows(scopeProfileWritePlan, category, confidence);
4924
- }
4925
- function shouldPromoteToShared(config, scopeProfileWritePlan, profileAllowsSharedWrites, storageDirNamespace, targetStorage, category, confidence) {
4926
- if (!resolveNamespaceCapabilities(config).namespaces || !profileAllowsSharedWrites || !sharedAutoPromotionAllows(config, scopeProfileWritePlan, category, confidence))
4927
- return false;
4928
- if (storageDirNamespace(targetStorage.dir) === config.sharedNamespace)
4929
- return false;
4930
- return true;
4931
- }
4932
- async function readActiveMemoriesBothTiers(storage) {
4933
- const [hotMems, coldMems] = await Promise.all([
4934
- storage.readAllMemories(),
4935
- storage.readAllColdMemories()
4936
- ]);
4937
- return coldMems.length === 0 ? hotMems : [...hotMems, ...coldMems];
4938
5865
  }
4939
- async function flushDeferredFactHashOnFailure(saveContentHashIndexes, deferred) {
4940
- if (!deferred) return;
4941
- await saveContentHashIndexes().catch(
4942
- (err) => log.warn(`content-hash flush after post-write failure failed: ${err}`)
4943
- );
5866
+ async function runMergedTargetPostEffects(deps, storage, merge, input) {
5867
+ const signals = buildBehaviorSignalsForMemory({
5868
+ memoryId: merge.targetId,
5869
+ category: input.category,
5870
+ content: input.incomingContent,
5871
+ namespace: input.namespace,
5872
+ confidence: input.incomingConfidence,
5873
+ source: "extraction"
5874
+ });
5875
+ if (input.threadEpisodeIdsForGraph) {
5876
+ const episodes = input.threadEpisodeIdsForGraph;
5877
+ const existing = episodes.lastIndexOf(merge.targetId);
5878
+ if (existing !== -1) episodes.splice(existing, 1);
5879
+ episodes.push(merge.targetId);
5880
+ }
5881
+ if (!input.graphCaps.multiGraphMemory) return signals;
5882
+ try {
5883
+ const committed = await storage.getMemoryByIdIncludingArchived(merge.targetId);
5884
+ if (!committed || committed.content !== merge.mergedContent) return signals;
5885
+ if (inferMemoryStatus(committed.frontmatter, committed.path) !== "active") return signals;
5886
+ const entityRef = committed.frontmatter.entityRef;
5887
+ const rawBody = rawPreCitationMergedBody(deps, merge.mergedContent);
5888
+ const memoryRelPath = path5.relative(storage.dir, committed.path);
5889
+ input.graphContext.memoryPathById.set(merge.targetId, memoryRelPath);
5890
+ const all = input.graphContext.allMemsForGraph;
5891
+ if (Array.isArray(all)) {
5892
+ const entry = all.find((m) => path5.relative(storage.dir, m.path) === memoryRelPath);
5893
+ if (entry) entry.content = rawBody;
5894
+ }
5895
+ const rewriteTypes = [];
5896
+ if (input.graphCaps.entityGraph) rewriteTypes.push("entity");
5897
+ if (input.graphCaps.timeGraph) rewriteTypes.push("time");
5898
+ if (input.graphCaps.causalGraph) rewriteTypes.push("causal");
5899
+ const installed = await rewriteMergedTargetGraphEdges(storage, {
5900
+ targetId: merge.targetId,
5901
+ memoryRelPath,
5902
+ mergedContent: merge.mergedContent,
5903
+ revisionChecked: committed.frontmatter.updated,
5904
+ rewriteTypes,
5905
+ build: () => deps.buildGraphEdge(
5906
+ storage,
5907
+ memoryRelPath,
5908
+ entityRef,
5909
+ merge.targetId,
5910
+ rawBody,
5911
+ all,
5912
+ input.graphContext.memoryPathById,
5913
+ input.threadIdForEdge,
5914
+ input.threadEpisodeIdsForGraph,
5915
+ input.graphContext.previousPersistedRelPath,
5916
+ input.graphCaps
5917
+ )
5918
+ });
5919
+ if (installed) input.graphContext.previousPersistedRelPath = memoryRelPath;
5920
+ } catch {
5921
+ }
5922
+ return signals;
4944
5923
  }
4945
5924
 
4946
- // src/orchestration/harmonic-construction-persist.ts
4947
- function filterHarmonicEntityMentions(facts, entityMentions) {
4948
- const identitiesBySegment = /* @__PURE__ */ new Map();
4949
- for (const entity of entityMentions) {
4950
- const segment = harmonicEntitySegment(entity.name);
4951
- const identities = identitiesBySegment.get(segment) ?? /* @__PURE__ */ new Set();
4952
- identities.add(normalizedHarmonicEntityIdentity(entity.name));
4953
- identitiesBySegment.set(segment, identities);
5925
+ // src/orchestration/semantic-merge-promotion-payload.ts
5926
+ async function buildMergedTargetPromotionPayload(storage, merge) {
5927
+ if (!merge.provenancePatched) {
5928
+ log.warn(
5929
+ `semantic-merge: skipping merged-target promotion for ${merge.targetId} \u2014 provenance patch did not land; the record still holds pre-merge trust metadata`
5930
+ );
5931
+ return null;
4954
5932
  }
4955
- return entityMentions.flatMap((entity) => {
4956
- const allowSegmentFallback = identitiesBySegment.get(harmonicEntitySegment(entity.name))?.size === 1;
4957
- const activeFacts = facts.filter(
4958
- (fact) => typeof fact.entityRef === "string" && harmonicEntityReferenceMatches(fact.entityRef, entity.name, allowSegmentFallback)
5933
+ let committed;
5934
+ try {
5935
+ committed = await storage.getMemoryByIdIncludingArchived(merge.targetId);
5936
+ } catch (err) {
5937
+ log.warn(
5938
+ `semantic-merge: merged-target promotion reread failed for ${merge.targetId} (non-fatal; promotion skipped, the committed merge stands): ${err instanceof Error ? err.message : String(err)}`
4959
5939
  );
4960
- return activeFacts.length > 0 ? [{ ...entity, facts: activeFacts.map((fact) => fact.content) }] : [];
4961
- });
4962
- }
4963
- async function persistConstructedHarmonicRecords(options) {
4964
- const sessionKey = options.sessionKey?.trim();
4965
- if (!sessionKey) {
4966
- log.warn("harmonic construction skipped: extraction session key is missing");
4967
- return;
5940
+ return null;
4968
5941
  }
4969
- const recordedAt = options.validAt && Number.isFinite(Date.parse(options.validAt)) ? new Date(options.validAt).toISOString() : (/* @__PURE__ */ new Date()).toISOString();
4970
- const entries = [...options.entries];
4971
- const sharedEpisodeTitle = entries.length === 1 ? options.episodeTitle : void 0;
4972
- for (const entry of entries) {
4973
- try {
4974
- const records = deriveHarmonicRecords({
4975
- sessionKey,
4976
- recordedAt,
4977
- episodeTitle: sharedEpisodeTitle,
4978
- persistedFacts: entry.facts,
4979
- entityMentions: filterHarmonicEntityMentions(entry.facts, options.entityMentions).map((entity) => ({
4980
- name: entity.name,
4981
- type: entity.type,
4982
- facts: entity.facts
4983
- }))
4984
- });
4985
- await persistHarmonicRecords({
4986
- memoryDir: entry.storage.dir,
4987
- abstractionNodeStoreDir: entry.storage.dir === options.baseStorageDir ? options.abstractionNodeStoreDir : void 0,
4988
- nodes: records.nodes,
4989
- anchors: options.anchorsEnabled ? records.anchors : []
4990
- });
4991
- } catch (error) {
4992
- log.warn(
4993
- `harmonic construction failed open for namespace ${entry.storage.dir}: ${error instanceof Error ? error.message : String(error)}`
4994
- );
4995
- }
5942
+ if (!committed || committed.content !== merge.mergedContent) return null;
5943
+ if (inferMemoryStatus(committed.frontmatter, committed.path) !== "active") {
5944
+ return null;
4996
5945
  }
5946
+ const fm = committed.frontmatter;
5947
+ return {
5948
+ category: fm.category,
5949
+ content: committed.content,
5950
+ confidence: fm.confidence,
5951
+ tags: fm.tags ?? [],
5952
+ sourceMemoryId: fm.id,
5953
+ origin: parseOriginClass(fm.origin),
5954
+ source: fm.source,
5955
+ ...fm.entityRef !== void 0 ? { entityRef: fm.entityRef } : {},
5956
+ ...fm.structuredAttributes !== void 0 ? { structuredAttributes: { ...fm.structuredAttributes } } : {},
5957
+ ...fm.importance !== void 0 ? { importance: fm.importance } : {},
5958
+ ...fm.intentGoal !== void 0 ? { intentGoal: fm.intentGoal } : {},
5959
+ ...fm.intentActionType !== void 0 ? { intentActionType: fm.intentActionType } : {},
5960
+ ...fm.intentEntityTypes !== void 0 ? { intentEntityTypes: [...fm.intentEntityTypes] } : {},
5961
+ ...fm.memoryKind !== void 0 ? { memoryKind: fm.memoryKind } : {},
5962
+ ...fm.valid_at !== void 0 ? { validAt: fm.valid_at } : {},
5963
+ ...fm.invalid_at !== void 0 ? { invalidAt: fm.invalid_at } : {},
5964
+ ...fm.observedAt !== void 0 ? { observedAt: fm.observedAt } : {},
5965
+ ...fm.eventTimeSource !== void 0 ? { eventTimeSource: fm.eventTimeSource } : {},
5966
+ ...fm.sources && fm.sources.length > 0 ? { sources: fm.sources.map((source) => ({ ...source })) } : {},
5967
+ ...fm.provenance !== void 0 ? { provenance: fm.provenance } : {},
5968
+ ...fm.subject !== void 0 ? { subject: fm.subject } : {},
5969
+ ...fm.toolScoped === true ? { toolScoped: true } : {},
5970
+ ...fm.sourceConnector !== void 0 ? { sourceConnector: fm.sourceConnector } : {},
5971
+ ...fm.updated !== void 0 ? { committedRevision: fm.updated } : {}
5972
+ };
4997
5973
  }
4998
5974
 
4999
5975
  // src/orchestration/extraction-anchor-snapshot.ts
5000
- import path5 from "path";
5976
+ import path6 from "path";
5001
5977
  var ExtractionAnchorSnapshot = class {
5002
5978
  constructor(options = {}) {
5003
5979
  this.options = options;
@@ -5035,7 +6011,8 @@ var ExtractionAnchorSnapshot = class {
5035
6011
  if (!cached) return;
5036
6012
  const snapshot = await cached;
5037
6013
  const relativePath = resolvePersistedMemoryRelativePath({ memoryId, pathById, category });
5038
- const memory = await storage.readMemoryByPath(path5.join(storage.dir, relativePath));
6014
+ let memory = await storage.readMemoryByPath(path6.join(storage.dir, relativePath));
6015
+ if (!memory) memory = await storage.getMemoryByIdIncludingArchived(memoryId);
5039
6016
  if (!memory) return;
5040
6017
  const existingIndex = snapshot.findIndex((entry) => entry.frontmatter.id === memoryId);
5041
6018
  if (existingIndex >= 0) snapshot.splice(existingIndex, 1);
@@ -5077,6 +6054,7 @@ var ExtractionPersistCoordinator = class {
5077
6054
  const harmonicFactsByStorage = /* @__PURE__ */ new Map();
5078
6055
  const harmonicSourceInsertedAtBase = Date.now();
5079
6056
  let harmonicSourceOrder = 0;
6057
+ const promotedCopyProbe = createBatchPromotedCopyProbe(this.deps.config, this.deps.getStorageRouter, scopeProfileWritePlan);
5080
6058
  const normalizeStoredHashSource = (raw) => ContentHashIndex.normalizeContent(
5081
6059
  sanitizeMemoryContent(
5082
6060
  citationEnabled && hasCitationForTemplate(raw, citationTemplate) ? stripCitationForTemplate(raw, citationTemplate) : raw
@@ -5137,7 +6115,7 @@ var ExtractionPersistCoordinator = class {
5137
6115
  memoryPathById.set(id, relPath);
5138
6116
  }
5139
6117
  };
5140
- let dedupedCount = 0;
6118
+ let dedupedCount = 0, semanticMergedCount = 0;
5141
6119
  let importanceGatedCount = 0;
5142
6120
  let batchBackendUnavailable = false;
5143
6121
  let redactionGatedCount = 0;
@@ -5180,28 +6158,19 @@ var ExtractionPersistCoordinator = class {
5180
6158
  const namespacesEnabled = resolveNamespaceCapabilities(this.deps.config).namespaces;
5181
6159
  const sourceConnector = sourceContext?.sourceConnector;
5182
6160
  const origin = classifyExtractionOrigin(sourceContext);
5183
- const subjectGuardAllows = (subject, target, label) => {
5184
- const decision = evaluateSubjectGuard({
5185
- subject,
5186
- sharedTarget: isSharedPromotionTarget(target),
5187
- mode: this.deps.config.subjectGuard
5188
- });
5189
- if (decision.action !== "allow") {
5190
- log.warn(`subject-guard(${decision.action}) ${label}: ${decision.reason}`);
5191
- }
5192
- return decision.action !== "reject";
5193
- };
6161
+ const subjectGuardAllows = makeSubjectGuardAllows(this.deps.config);
5194
6162
  const promoteMemoryToProfileTargets = async (options) => {
5195
6163
  if (!scopeProfileWritePlan || !profileAutoPromotionAllows(scopeProfileWritePlan, options.category, options.confidence))
5196
- return;
6164
+ return [];
5197
6165
  const autoTargets = new Set(scopeProfileWritePlan.profile.autoPromote.targets);
5198
6166
  const targets = scopeProfileWritePlan.promotionTargets.filter(
5199
6167
  (target) => target.target !== "serverShared" && autoTargets.has(target.target) && target.authorized && target.namespace
5200
6168
  );
5201
- if (targets.length === 0) return;
6169
+ if (targets.length === 0) return [];
5202
6170
  const rawContent = citationEnabled && hasCitationForTemplate(options.content, citationTemplate) ? stripCitationForTemplate(options.content, citationTemplate) : options.content;
5203
6171
  const citedContent = applyInlineCitation(rawContent);
5204
6172
  const sanitizedBase = sanitizeMemoryContent(rawContent);
6173
+ const writtenCopyIds = [];
5205
6174
  for (const target of targets) {
5206
6175
  if (!target.namespace) continue;
5207
6176
  try {
@@ -5212,7 +6181,7 @@ var ExtractionPersistCoordinator = class {
5212
6181
  {
5213
6182
  content: citedContent,
5214
6183
  category: options.category,
5215
- origin,
6184
+ origin: options.origin ?? origin,
5216
6185
  confidence: options.confidence,
5217
6186
  tags: withReservedMarkerTag(options.tags, `${target.target}-promotion`),
5218
6187
  entityRef: options.entityRef,
@@ -5302,6 +6271,7 @@ var ExtractionPersistCoordinator = class {
5302
6271
  }
5303
6272
  }
5304
6273
  if (!targetPromotion.tombstoneBlocked) {
6274
+ writtenCopyIds.push(promotedId);
5305
6275
  trackPersistedId(targetStorage, promotedId, {
5306
6276
  includeReturnedIds: false,
5307
6277
  category: options.category,
@@ -5326,14 +6296,15 @@ var ExtractionPersistCoordinator = class {
5326
6296
  );
5327
6297
  }
5328
6298
  }
6299
+ return writtenCopyIds;
5329
6300
  };
5330
6301
  const promoteMemoryToShared = async (options) => {
5331
- const toolScoped = withholdToolScopedFromSharedNamespace(options);
5332
- await promoteMemoryToProfileTargets({
6302
+ const toolScoped = promotionWithholdsToolScope(options);
6303
+ let promotedCopyId = (await promoteMemoryToProfileTargets({
5333
6304
  ...options,
5334
6305
  ...toolScoped ? { toolScoped: true } : {}
5335
- });
5336
- if (lifecycleCaps.extractionScopeClassification && toolScoped) return;
6306
+ })).at(-1);
6307
+ if (lifecycleCaps.extractionScopeClassification && toolScoped) return promotedCopyId;
5337
6308
  if (!shouldPromoteToShared(
5338
6309
  this.deps.config,
5339
6310
  scopeProfileWritePlan,
@@ -5343,8 +6314,9 @@ var ExtractionPersistCoordinator = class {
5343
6314
  options.category,
5344
6315
  options.confidence
5345
6316
  ))
5346
- return;
5347
- if (!subjectGuardAllows(options.subject, "serverShared", "shared promotion")) return;
6317
+ return promotedCopyId;
6318
+ if (!subjectGuardAllows(options.subject, "serverShared", "shared promotion"))
6319
+ return promotedCopyId;
5348
6320
  try {
5349
6321
  const sharedStorage = await this.deps.getStorageRouter().storageFor(
5350
6322
  this.deps.config.sharedNamespace
@@ -5356,7 +6328,7 @@ var ExtractionPersistCoordinator = class {
5356
6328
  {
5357
6329
  content: citedContent,
5358
6330
  category: options.category,
5359
- origin,
6331
+ origin: options.origin ?? origin,
5360
6332
  confidence: options.confidence,
5361
6333
  tags: withReservedMarkerTag(options.tags, "shared-promotion"),
5362
6334
  entityRef: options.entityRef,
@@ -5443,7 +6415,7 @@ var ExtractionPersistCoordinator = class {
5443
6415
  });
5444
6416
  if (hashDedupSupersession.supersededIds.length > 0) {
5445
6417
  }
5446
- return;
6418
+ return promotedCopyId;
5447
6419
  }
5448
6420
  log.debug(
5449
6421
  `persistExtraction: hash-dedup found no active same-entity shared fact for ${options.sourceMemoryId}; falling through to write`
@@ -5453,7 +6425,7 @@ var ExtractionPersistCoordinator = class {
5453
6425
  `persistExtraction: shared-namespace supersession on hash-dedup path failed open for ${options.sourceMemoryId}: ${hashDedupSupersessionErr}`
5454
6426
  );
5455
6427
  if (hashDedupLookupComplete && hashDedupMatchingFact) {
5456
- return;
6428
+ return promotedCopyId;
5457
6429
  }
5458
6430
  log.debug(
5459
6431
  `persistExtraction: hash-dedup catch: lookup incomplete or no candidate found for ${options.sourceMemoryId}; falling through to write`
@@ -5478,7 +6450,7 @@ var ExtractionPersistCoordinator = class {
5478
6450
  skipSharedPromotion = false;
5479
6451
  }
5480
6452
  if (skipSharedPromotion) {
5481
- return;
6453
+ return promotedCopyId;
5482
6454
  }
5483
6455
  }
5484
6456
  }
@@ -5538,10 +6510,13 @@ var ExtractionPersistCoordinator = class {
5538
6510
  })
5539
6511
  );
5540
6512
  }
6513
+ promotedCopyId = promotedId;
6514
+ return promotedId;
5541
6515
  } catch (err) {
5542
6516
  log.warn(
5543
6517
  `persistExtraction: shared promotion failed open for ${options.sourceMemoryId}: ${err}`
5544
6518
  );
6519
+ return promotedCopyId;
5545
6520
  }
5546
6521
  };
5547
6522
  const backfillTemporalBoundsOnPromotionCopies = async (args) => {
@@ -6493,6 +7468,42 @@ var ExtractionPersistCoordinator = class {
6493
7468
  const memoryKind = writeCategory === "procedure" ? void 0 : resolvePresentationCapabilities(this.deps.config).episodeNoteMode ? classifyMemoryKind(fact.content, fact.tags ?? [], writeCategory) : void 0;
6494
7469
  const rawPersistBody = writeCategory === "procedure" ? buildProcedurePersistBody(fact.content, fact.procedureSteps) : fact.content;
6495
7470
  const citedFactContent = applyInlineCitation(rawPersistBody);
7471
+ const semanticMerge = await applySemanticMergeAtPersist(this.deps, {
7472
+ storage: targetStorage,
7473
+ content: fact.content,
7474
+ category: writeCategory,
7475
+ sources: fact.sources,
7476
+ sourceConnector: extractionSourceConnector,
7477
+ incomingMetadata: { tags: [...fact.tags, ...injectionScreenTags], entityRef: fact.entityRef, structuredAttributes: fact.structuredAttributes, validAt: biTemporal ? biTemporal.validFrom : sourceContext?.validAt, biTemporal: biTemporal !== void 0, importanceScore: importance.score, confidence: fact.confidence, provenanceStrength: fact.provenance, toolScoped: factToolScoped, subject: factSubject, origin, faithfulness: faithfulnessFm, memoryKind },
7478
+ skip: contradictionDetected || faithfulnessEnforceStatus === "pending_review" || batchBackendUnavailable || novelty.decision === "add",
7479
+ incomingLinks: links.length > 0 ? links : void 0,
7480
+ incomingCitedContent: citedFactContent,
7481
+ targetHasPromotedCopies: (targetId) => promotedCopyProbe.check(targetStorage, targetId)
7482
+ });
7483
+ if (semanticMerge.action === "created" && semanticMerge.reason === "backend_unavailable") batchBackendUnavailable = true;
7484
+ if (semanticMerge.action === "merged") {
7485
+ semanticMergedCount++;
7486
+ await anchorSnapshots.replace(targetStorage, semanticMerge.targetId, writeCategory, memoryPathById);
7487
+ const mergedPromotion = await buildMergedTargetPromotionPayload(targetStorage, semanticMerge);
7488
+ await promoteAndReconcileMergedTarget({ promote: (payload) => promoteMemoryToShared({ sourceStorage: targetStorage, ...payload }), config: this.deps.config, getStorageRouter: this.deps.getStorageRouter, scopeProfileWritePlan, sourceStorage: targetStorage, sourceMemoryId: semanticMerge.targetId, mergedPromotion, normalize: normalizeStoredHashSource, onReconciled: () => promotedCopyProbe.invalidate() });
7489
+ trackPersistedId(targetStorage, semanticMerge.targetId, { includeReturnedIds: false });
7490
+ await persistMergedTargetThreadEpisode(this.deps.getThreading(), threadIdForExtraction, semanticMerge.targetId);
7491
+ if (harmonicConstructionEnabled) {
7492
+ enqueueMergedTargetForHarmonicConstruction(harmonicFactsByStorage, targetStorage, harmonicFact, semanticMerge.targetId, semanticMerge.mergedContent, new Date(harmonicSourceInsertedAtBase + harmonicSourceOrder++).toISOString());
7493
+ }
7494
+ trackBehaviorSignals(targetStorage, await runMergedTargetPostEffects(this.deps, targetStorage, semanticMerge, {
7495
+ category: writeCategory,
7496
+ incomingContent: fact.content,
7497
+ incomingConfidence: fact.confidence,
7498
+ namespace: this.deps.storageDirNamespace(targetStorage.dir),
7499
+ graphCaps,
7500
+ graphContext: await ensureGraphContext(targetStorage),
7501
+ threadIdForEdge: threadIdForExtraction ?? void 0,
7502
+ threadEpisodeIdsForGraph
7503
+ }));
7504
+ await writeMergedVerbatimArtifact(this.deps, targetStorage, semanticMerge.targetId, { category: writeCategory, citedContent: citedFactContent, confidence: fact.confidence, tags: fact.tags, intent: inferredIntent ?? void 0, sourceConnector: extractionSourceConnector, origin, toolScoped: factToolScoped });
7505
+ continue;
7506
+ }
6496
7507
  const factWriteEnvelope = composeSalvagedExtractionEnvelope(
6497
7508
  {
6498
7509
  content: citedFactContent,
@@ -6596,34 +7607,37 @@ var ExtractionPersistCoordinator = class {
6596
7607
  if (!postWriteGuard) {
6597
7608
  await this.deps.indexPersistedMemory(targetStorage, memoryId);
6598
7609
  }
6599
- if (!postWriteGuard) await promoteMemoryToShared({
6600
- sourceStorage: targetStorage,
6601
- category: writeCategory,
6602
- content: fact.content,
6603
- confidence: fact.confidence,
6604
- subject: factSubject,
6605
- tags: fact.tags,
6606
- entityRef: typeof fact.entityRef === "string" ? fact.entityRef : void 0,
6607
- structuredAttributes: fact.structuredAttributes,
6608
- sourceMemoryId: memoryId,
6609
- importance,
6610
- intentGoal: inferredIntent?.goal,
6611
- intentActionType: inferredIntent?.actionType,
6612
- intentEntityTypes: inferredIntent?.entityTypes,
6613
- memoryKind,
6614
- validAt: biTemporal ? biTemporal.validFrom : sourceContext?.validAt,
6615
- ...biTemporal ? {
6616
- observedAt: biTemporal.observedAt,
6617
- eventTimeSource: biTemporal.eventTimeSource,
6618
- ...biTemporal.validUntil ? { invalidAt: biTemporal.validUntil } : {}
6619
- } : {},
6620
- source: extractionWriteSource,
6621
- ...extractionSourceConnector ? { sourceConnector: extractionSourceConnector } : {},
6622
- ...fact.procedureSteps && fact.procedureSteps.length ? { procedureSteps: fact.procedureSteps } : {},
6623
- ...fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {},
6624
- ...fact.provenance ? { provenance: fact.provenance } : {},
6625
- harmonicFact
6626
- });
7610
+ if (!postWriteGuard) {
7611
+ await promoteMemoryToShared({
7612
+ sourceStorage: targetStorage,
7613
+ category: writeCategory,
7614
+ content: fact.content,
7615
+ confidence: fact.confidence,
7616
+ subject: factSubject,
7617
+ tags: fact.tags,
7618
+ entityRef: typeof fact.entityRef === "string" ? fact.entityRef : void 0,
7619
+ structuredAttributes: fact.structuredAttributes,
7620
+ sourceMemoryId: memoryId,
7621
+ importance,
7622
+ intentGoal: inferredIntent?.goal,
7623
+ intentActionType: inferredIntent?.actionType,
7624
+ intentEntityTypes: inferredIntent?.entityTypes,
7625
+ memoryKind,
7626
+ validAt: biTemporal ? biTemporal.validFrom : sourceContext?.validAt,
7627
+ ...biTemporal ? {
7628
+ observedAt: biTemporal.observedAt,
7629
+ eventTimeSource: biTemporal.eventTimeSource,
7630
+ ...biTemporal.validUntil ? { invalidAt: biTemporal.validUntil } : {}
7631
+ } : {},
7632
+ source: extractionWriteSource,
7633
+ ...extractionSourceConnector ? { sourceConnector: extractionSourceConnector } : {},
7634
+ ...fact.procedureSteps && fact.procedureSteps.length ? { procedureSteps: fact.procedureSteps } : {},
7635
+ ...fact.sources && fact.sources.length > 0 ? { sources: fact.sources } : {},
7636
+ ...fact.provenance ? { provenance: fact.provenance } : {},
7637
+ harmonicFact
7638
+ });
7639
+ promotedCopyProbe.invalidate();
7640
+ }
6627
7641
  if (graphCaps.multiGraphMemory && !postWriteGuard) {
6628
7642
  try {
6629
7643
  const graphContext = await ensureGraphContext(targetStorage);
@@ -6688,7 +7702,6 @@ var ExtractionPersistCoordinator = class {
6688
7702
  } catch (err) {
6689
7703
  await flushDeferredFactHashOnFailure(() => this.deps.saveContentHashIndexes(), factDedupEnabled);
6690
7704
  throw err;
6691
- } finally {
6692
7705
  }
6693
7706
  }
6694
7707
  let durableNonFactWritten = false;
@@ -6815,12 +7828,12 @@ ${q.context ?? ""}`], entityScreenOn);
6815
7828
  (err) => log.warn(`appendBehaviorSignals failed (non-fatal): ${err}`)
6816
7829
  );
6817
7830
  }
6818
- const dedupSuffix = dedupedCount > 0 ? ` (${dedupedCount} deduped)` : "";
7831
+ const dedupSuffix = `${dedupedCount > 0 ? ` (${dedupedCount} deduped)` : ""}${semanticMergedCount > 0 ? ` (${semanticMergedCount} merged)` : ""}`;
6819
7832
  const gatedSuffix = importanceGatedCount > 0 ? ` (${importanceGatedCount} gated)` : "";
6820
7833
  const judgeSuffix = judgeGatedCount > 0 ? ` (${judgeGatedCount} judge-rejected)` : "";
6821
7834
  const redactionSuffix = redactionGatedCount > 0 ? ` (${redactionGatedCount} redacted)` : "";
6822
7835
  log.info(
6823
- `persisted: ${facts.length - dedupedCount - importanceGatedCount - judgeGatedCount - redactionGatedCount} facts${dedupSuffix}${gatedSuffix}${judgeSuffix}${redactionSuffix}, ${entities.length} entities, ${questions.length} questions, ${profileUpdates.length} profile updates`
7836
+ `persisted: ${facts.length - dedupedCount - importanceGatedCount - judgeGatedCount - redactionGatedCount - semanticMergedCount} facts${dedupSuffix}${gatedSuffix}${judgeSuffix}${redactionSuffix}, ${entities.length} entities, ${questions.length} questions, ${profileUpdates.length} profile updates`
6824
7837
  );
6825
7838
  if (harmonicConstructionEnabled && harmonicFactsByStorage.size > 0) {
6826
7839
  await persistConstructedHarmonicRecords({
@@ -6870,8 +7883,8 @@ async function drainExtractionAndShutdownDependencyPropagation(extractionQueue,
6870
7883
 
6871
7884
  // src/orchestration/dependency-propagation-delivery.ts
6872
7885
  import { randomUUID } from "crypto";
6873
- import { readFile as readFile2, unlink } from "fs/promises";
6874
- import path6 from "path";
7886
+ import { readFile as readFile3, unlink } from "fs/promises";
7887
+ import path7 from "path";
6875
7888
 
6876
7889
  // src/orchestration/dependency-propagation-recovery-replay.ts
6877
7890
  import { createHash as createHash3 } from "crypto";
@@ -7047,7 +8060,7 @@ var DependencyPropagationDelivery = class {
7047
8060
  }, delayMs);
7048
8061
  timer.unref();
7049
8062
  });
7050
- this.readQueueFile = options.readQueueFile ?? ((filePath) => readFile2(filePath, "utf8"));
8063
+ this.readQueueFile = options.readQueueFile ?? ((filePath) => readFile3(filePath, "utf8"));
7051
8064
  this.writeQueueFile = options.writeQueueFile ?? ((filePath, content) => writeJsonFileAtomic(filePath, JSON.parse(content)));
7052
8065
  this.replayReconciliation = options.replayReconciliation;
7053
8066
  }
@@ -7554,13 +8567,13 @@ var DependencyPropagationDelivery = class {
7554
8567
  try {
7555
8568
  const job = validateJob(JSON.parse(await this.readQueueFile(filePath)), status);
7556
8569
  if (!job) {
7557
- log.warn(`dependency propagation ignored invalid job file ${path6.basename(filePath)}`);
8570
+ log.warn(`dependency propagation ignored invalid job file ${path7.basename(filePath)}`);
7558
8571
  continue;
7559
8572
  }
7560
8573
  entries.push({ job, filePath });
7561
8574
  } catch (error) {
7562
8575
  if (error instanceof SyntaxError || isNotFound(error)) {
7563
- log.warn(`dependency propagation ignored unreadable job file ${path6.basename(filePath)}: ${error}`);
8576
+ log.warn(`dependency propagation ignored unreadable job file ${path7.basename(filePath)}: ${error}`);
7564
8577
  continue;
7565
8578
  }
7566
8579
  throw error;
@@ -7631,7 +8644,7 @@ var DependencyPropagationDelivery = class {
7631
8644
  await this.writeQueueJob(targetPath, next);
7632
8645
  const terminal = status === "completed" || status === "dead_letter" || status === "canceled";
7633
8646
  for (const entry of entries) {
7634
- if (path6.resolve(entry.filePath) === path6.resolve(targetPath)) continue;
8647
+ if (path7.resolve(entry.filePath) === path7.resolve(targetPath)) continue;
7635
8648
  await unlink(entry.filePath).catch((error) => {
7636
8649
  if (isNotFound(error)) return;
7637
8650
  if (terminal) {
@@ -7695,7 +8708,7 @@ var DependencyPropagationDelivery = class {
7695
8708
  allowMissingDirectory: true
7696
8709
  });
7697
8710
  for (const filePath of files) {
7698
- if (path6.basename(filePath, ".json") !== jobId) continue;
8711
+ if (path7.basename(filePath, ".json") !== jobId) continue;
7699
8712
  try {
7700
8713
  await unlink(filePath);
7701
8714
  } catch (error) {
@@ -7895,12 +8908,12 @@ function createDependencyPropagationReplayReconciliation(host) {
7895
8908
 
7896
8909
  // src/orchestration/recall-internal.ts
7897
8910
  import { createHash as createHash5 } from "crypto";
7898
- import { readFile as readFile3, stat, unlink as unlink2 } from "fs/promises";
7899
- import path10 from "path";
8911
+ import { readFile as readFile4, stat, unlink as unlink2 } from "fs/promises";
8912
+ import path11 from "path";
7900
8913
 
7901
8914
  // src/orchestration/graph-path-state-loader.ts
7902
8915
  import { lstat, opendir, realpath } from "fs/promises";
7903
- import path7 from "path";
8916
+ import path8 from "path";
7904
8917
  function isArchivePathIndexUnavailable(index) {
7905
8918
  return "unavailable" in index;
7906
8919
  }
@@ -7919,11 +8932,11 @@ var GraphPathStateLoader = class {
7919
8932
  openArchiveDirectory = opendir;
7920
8933
  async readNode(storage, nodeId, deadlineAtMs, allowArchiveLookup) {
7921
8934
  if (typeof deadlineAtMs === "number" && Date.now() >= deadlineAtMs) return null;
7922
- const configuredStorageRoot = path7.resolve(storage.dir);
8935
+ const configuredStorageRoot = path8.resolve(storage.dir);
7923
8936
  const storageRoot = await realpath(configuredStorageRoot).catch(() => null);
7924
8937
  if (!storageRoot || storageRoot !== configuredStorageRoot) return null;
7925
- const logicalId = path7.basename(nodeId, path7.extname(nodeId));
7926
- const directRelativePaths = [nodeId, path7.join("cold", nodeId)];
8938
+ const logicalId = path8.basename(nodeId, path8.extname(nodeId));
8939
+ const directRelativePaths = [nodeId, path8.join("cold", nodeId)];
7927
8940
  let inactiveDirectMemory = null;
7928
8941
  for (const relativePath of directRelativePaths) {
7929
8942
  const safePath = await this.resolveContainedPath(storageRoot, relativePath);
@@ -7946,7 +8959,7 @@ var GraphPathStateLoader = class {
7946
8959
  if (!archiveIndex || isArchivePathIndexUnavailable(archiveIndex) || typeof deadlineAtMs === "number" && Date.now() >= deadlineAtMs) {
7947
8960
  return null;
7948
8961
  }
7949
- const archivePaths = archiveIndex.pathsByBasename.get(path7.basename(nodeId)) ?? [];
8962
+ const archivePaths = archiveIndex.pathsByBasename.get(path8.basename(nodeId)) ?? [];
7950
8963
  for (const archivePath of archivePaths) {
7951
8964
  if (typeof deadlineAtMs === "number" && Date.now() >= deadlineAtMs) return null;
7952
8965
  const memory = await storage.readMemoryByPath(archivePath);
@@ -7956,17 +8969,17 @@ var GraphPathStateLoader = class {
7956
8969
  return null;
7957
8970
  }
7958
8971
  async resolveContainedPath(storageRoot, relativePath) {
7959
- if (path7.isAbsolute(relativePath)) return null;
8972
+ if (path8.isAbsolute(relativePath)) return null;
7960
8973
  const rawSegments = relativePath.replace(/\\/g, "/").split("/");
7961
8974
  if (rawSegments.includes("..")) return null;
7962
- const candidate = path7.resolve(storageRoot, relativePath);
7963
- const lexicalRelative = path7.relative(storageRoot, candidate);
7964
- if (lexicalRelative.length > 0 && (lexicalRelative.startsWith("..") || path7.isAbsolute(lexicalRelative))) {
8975
+ const candidate = path8.resolve(storageRoot, relativePath);
8976
+ const lexicalRelative = path8.relative(storageRoot, candidate);
8977
+ if (lexicalRelative.length > 0 && (lexicalRelative.startsWith("..") || path8.isAbsolute(lexicalRelative))) {
7965
8978
  return null;
7966
8979
  }
7967
8980
  const canonical = await realpath(candidate).catch(() => candidate);
7968
- const canonicalRelative = path7.relative(storageRoot, canonical);
7969
- if (canonicalRelative.length > 0 && (canonicalRelative.startsWith("..") || path7.isAbsolute(canonicalRelative))) {
8981
+ const canonicalRelative = path8.relative(storageRoot, canonical);
8982
+ if (canonicalRelative.length > 0 && (canonicalRelative.startsWith("..") || path8.isAbsolute(canonicalRelative))) {
7970
8983
  return null;
7971
8984
  }
7972
8985
  return canonical;
@@ -8039,7 +9052,7 @@ var GraphPathStateLoader = class {
8039
9052
  }
8040
9053
  async buildArchivePathIndex(storageRoot, version) {
8041
9054
  const pathsByBasename = /* @__PURE__ */ new Map();
8042
- const archiveRoot = path7.join(storageRoot, "archive");
9055
+ const archiveRoot = path8.join(storageRoot, "archive");
8043
9056
  let archiveRootStatus;
8044
9057
  try {
8045
9058
  archiveRootStatus = await this.archiveLstat(archiveRoot);
@@ -8057,8 +9070,8 @@ var GraphPathStateLoader = class {
8057
9070
  if (isArchiveScanAbsenceError(error)) return { version, pathsByBasename };
8058
9071
  return null;
8059
9072
  }
8060
- const archiveRelative = path7.relative(storageRoot, canonicalArchiveRoot);
8061
- if (archiveRelative.length > 0 && (archiveRelative.startsWith("..") || path7.isAbsolute(archiveRelative))) {
9073
+ const archiveRelative = path8.relative(storageRoot, canonicalArchiveRoot);
9074
+ if (archiveRelative.length > 0 && (archiveRelative.startsWith("..") || path8.isAbsolute(archiveRelative))) {
8062
9075
  return { version, pathsByBasename };
8063
9076
  }
8064
9077
  const pending = [canonicalArchiveRoot];
@@ -8084,8 +9097,8 @@ var GraphPathStateLoader = class {
8084
9097
  if (isArchiveScanAbsenceError(error)) continue;
8085
9098
  return null;
8086
9099
  }
8087
- const currentRelative = path7.relative(storageRoot, canonicalCurrent);
8088
- if (currentRelative.length > 0 && (currentRelative.startsWith("..") || path7.isAbsolute(currentRelative))) {
9100
+ const currentRelative = path8.relative(storageRoot, canonicalCurrent);
9101
+ if (currentRelative.length > 0 && (currentRelative.startsWith("..") || path8.isAbsolute(currentRelative))) {
8089
9102
  continue;
8090
9103
  }
8091
9104
  let directory;
@@ -8102,7 +9115,7 @@ var GraphPathStateLoader = class {
8102
9115
  return { version, unavailable: "oversized" };
8103
9116
  }
8104
9117
  if (entry.isSymbolicLink()) continue;
8105
- const entryPath = path7.join(canonicalCurrent, entry.name);
9118
+ const entryPath = path8.join(canonicalCurrent, entry.name);
8106
9119
  if (entry.isDirectory()) {
8107
9120
  pending.push(entryPath);
8108
9121
  continue;
@@ -8118,8 +9131,8 @@ var GraphPathStateLoader = class {
8118
9131
  if (isArchiveScanAbsenceError(error)) continue;
8119
9132
  return null;
8120
9133
  }
8121
- const relative = path7.relative(storageRoot, canonical);
8122
- if (relative.length > 0 && (relative.startsWith("..") || path7.isAbsolute(relative))) {
9134
+ const relative = path8.relative(storageRoot, canonical);
9135
+ if (relative.length > 0 && (relative.startsWith("..") || path8.isAbsolute(relative))) {
8123
9136
  continue;
8124
9137
  }
8125
9138
  const paths = pathsByBasename.get(entry.name);
@@ -8145,7 +9158,7 @@ var GraphPathStateLoader = class {
8145
9158
  // src/orchestration/graph-recall-coordinator.ts
8146
9159
  import { createHash as createHash4 } from "crypto";
8147
9160
  import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
8148
- import path8 from "path";
9161
+ import path9 from "path";
8149
9162
  function mergeGraphExpandedResults(primary, expanded) {
8150
9163
  const mergedByNamespaceAndPath = /* @__PURE__ */ new Map();
8151
9164
  for (const item of [...primary, ...expanded]) {
@@ -8162,11 +9175,11 @@ function mergeGraphExpandedResults(primary, expanded) {
8162
9175
  return Array.from(mergedByNamespaceAndPath.values());
8163
9176
  }
8164
9177
  function graphPathRelativeToStorage(storageDir, candidatePath) {
8165
- const absolutePath = path8.isAbsolute(candidatePath) ? candidatePath : path8.resolve(storageDir, candidatePath);
8166
- const rel = path8.relative(storageDir, absolutePath);
9178
+ const absolutePath = path9.isAbsolute(candidatePath) ? candidatePath : path9.resolve(storageDir, candidatePath);
9179
+ const rel = path9.relative(storageDir, absolutePath);
8167
9180
  if (!rel || rel === ".") return null;
8168
9181
  if (rel.startsWith("..")) return null;
8169
- return rel.split(path8.sep).join("/");
9182
+ return rel.split(path9.sep).join("/");
8170
9183
  }
8171
9184
  function normalizeGraphActivationScore(score) {
8172
9185
  const bounded = Number.isFinite(score) && score > 0 ? score : 0;
@@ -8266,7 +9279,7 @@ var GraphRecallCoordinator = class {
8266
9279
  resolvedPath = resolvedCold.result.path;
8267
9280
  resolvedResult = resolvedCold.result;
8268
9281
  }
8269
- if (!path8.isAbsolute(resolvedPath)) {
9282
+ if (!path9.isAbsolute(resolvedPath)) {
8270
9283
  resolvedAmbiguousSeeds.set(result.path, null);
8271
9284
  return null;
8272
9285
  }
@@ -8291,7 +9304,7 @@ var GraphRecallCoordinator = class {
8291
9304
  }
8292
9305
  continue;
8293
9306
  }
8294
- if (path8.isAbsolute(result.path)) {
9307
+ if (path9.isAbsolute(result.path)) {
8295
9308
  const resolved = await resolveAmbiguousSeedOwner(result, null);
8296
9309
  if (resolved) {
8297
9310
  addResultForNamespace(resolved.namespace, resolved.result);
@@ -8337,7 +9350,7 @@ var GraphRecallCoordinator = class {
8337
9350
  0
8338
9351
  );
8339
9352
  seedPaths.push(
8340
- ...seedRelativePaths.map((rel) => path8.join(storage.dir, rel))
9353
+ ...seedRelativePaths.map((rel) => path9.join(storage.dir, rel))
8341
9354
  );
8342
9355
  const seedSet = new Set(seedRelativePaths);
8343
9356
  const nodeMemoryCache = /* @__PURE__ */ new Map();
@@ -8392,7 +9405,7 @@ var GraphRecallCoordinator = class {
8392
9405
  path: memory.path,
8393
9406
  score,
8394
9407
  namespace,
8395
- seed: path8.resolve(storage.dir, candidate.seed),
9408
+ seed: path9.resolve(storage.dir, candidate.seed),
8396
9409
  hopDepth: candidate.hopDepth,
8397
9410
  decayedWeight: candidate.decayedWeight,
8398
9411
  graphType: candidate.graphType,
@@ -8424,7 +9437,7 @@ var GraphRecallCoordinator = class {
8424
9437
  add(memory.frontmatter.id);
8425
9438
  if (relativePath) {
8426
9439
  add(relativePath);
8427
- if (relativePath.endsWith(".md")) add(path8.basename(relativePath, ".md"));
9440
+ if (relativePath.endsWith(".md")) add(path9.basename(relativePath, ".md"));
8428
9441
  }
8429
9442
  return state;
8430
9443
  };
@@ -8471,7 +9484,7 @@ var GraphRecallCoordinator = class {
8471
9484
  path: memory.path,
8472
9485
  score,
8473
9486
  namespace,
8474
- seed: path8.resolve(storage.dir, candidate.seed),
9487
+ seed: path9.resolve(storage.dir, candidate.seed),
8475
9488
  hopDepth: candidate.hopDepth,
8476
9489
  decayedWeight: candidate.decayedWeight,
8477
9490
  graphType: candidate.graphType,
@@ -8514,12 +9527,12 @@ var GraphRecallCoordinator = class {
8514
9527
  }
8515
9528
  async recordLastGraphRecallSnapshot(options) {
8516
9529
  try {
8517
- const snapshotPath = path8.join(
9530
+ const snapshotPath = path9.join(
8518
9531
  options.storage.dir,
8519
9532
  "state",
8520
9533
  "last_graph_recall.json"
8521
9534
  );
8522
- await mkdir3(path8.dirname(snapshotPath), { recursive: true });
9535
+ await mkdir3(path9.dirname(snapshotPath), { recursive: true });
8523
9536
  const now = (/* @__PURE__ */ new Date()).toISOString();
8524
9537
  const totalSeedCount = options.seedPaths.length;
8525
9538
  const totalExpandedCount = options.expandedPaths.length;
@@ -8814,11 +9827,11 @@ async function appendEpisodicContextSection(deps, options) {
8814
9827
  }
8815
9828
 
8816
9829
  // src/orchestration/recall-profile-storage.ts
8817
- import path9 from "path";
9830
+ import path10 from "path";
8818
9831
  function resolveCompositeProfileStorage(options) {
8819
9832
  const { profileStorages, memoryDir } = options;
8820
9833
  const emptyProfileStorage = new Proxy(
8821
- { dir: path9.join(memoryDir, ".empty-scope-profile") },
9834
+ { dir: path10.join(memoryDir, ".empty-scope-profile") },
8822
9835
  {
8823
9836
  get(target, prop) {
8824
9837
  if (prop in target) return Reflect.get(target, prop);
@@ -9197,7 +10210,7 @@ var RecallInternalCoordinator = class {
9197
10210
  const graphExpandedResultPaths = /* @__PURE__ */ new Set();
9198
10211
  const graphSourceLabelsForPath = (resultPath) => {
9199
10212
  const labels = [];
9200
- const normalizedPath = resultPath.split(path10.sep).join("/");
10213
+ const normalizedPath = resultPath.split(path11.sep).join("/");
9201
10214
  const isEntityPath = normalizedPath.startsWith("entities/") || normalizedPath.includes("/entities/");
9202
10215
  if (graphBaselinePaths.has(resultPath)) labels.push("baseline");
9203
10216
  if (graphExpandedResultPaths.has(resultPath))
@@ -10733,16 +11746,16 @@ ${formatted}`;
10733
11746
  if (!resolveRecallAuxiliaryCapabilities(this.deps.config).compactionReset) return null;
10734
11747
  const workspaceDir = compactionWorkspaceDir || this.deps.config.workspaceDir || defaultWorkspaceDir();
10735
11748
  const safeSessionKey = sanitizeSessionKeyForFilename(effectiveSessionKey);
10736
- const signalPath = path10.join(
11749
+ const signalPath = path11.join(
10737
11750
  workspaceDir,
10738
11751
  `.compaction-reset-signal-${safeSessionKey}`
10739
11752
  );
10740
- const bootPath = path10.join(workspaceDir, "BOOT.md");
11753
+ const bootPath = path11.join(workspaceDir, "BOOT.md");
10741
11754
  try {
10742
11755
  const signalStat = await stat(signalPath).catch(() => null);
10743
11756
  if (!signalStat) return null;
10744
11757
  const signalAge = Date.now() - signalStat.mtimeMs;
10745
- const signalData = JSON.parse(await readFile3(signalPath, "utf-8"));
11758
+ const signalData = JSON.parse(await readFile4(signalPath, "utf-8"));
10746
11759
  if (signalData.sessionKey !== effectiveSessionKey) {
10747
11760
  log.debug(
10748
11761
  `recall: compaction signal is for ${signalData.sessionKey}, not ${effectiveSessionKey} \u2014 skipping`
@@ -10762,7 +11775,7 @@ ${formatted}`;
10762
11775
 
10763
11776
  `;
10764
11777
  try {
10765
- const bootContent = await readFile3(bootPath, "utf-8");
11778
+ const bootContent = await readFile4(bootPath, "utf-8");
10766
11779
  section += "### BOOT.md (working state before compaction)\n\n";
10767
11780
  section += bootContent + "\n";
10768
11781
  } catch {
@@ -12996,10 +14009,10 @@ ${tmtNode.summary}`
12996
14009
 
12997
14010
  // src/orchestration/recall-search-pipeline.ts
12998
14011
  import { createHash as createHash6 } from "crypto";
12999
- import path12 from "path";
14012
+ import path13 from "path";
13000
14013
 
13001
14014
  // src/orchestration/recall-search-prefilter.ts
13002
- import path11 from "path";
14015
+ import path12 from "path";
13003
14016
  async function fetchActiveArtifactsForNamespace(deps, namespace, prompt, targetCount, options = {}) {
13004
14017
  const storage = await deps.storageRouter.storageFor(namespace);
13005
14018
  let fetchLimit = computeArtifactCandidateFetchLimit(targetCount);
@@ -13128,7 +14141,7 @@ async function searchEmbeddingFallback(deps, query, limit) {
13128
14141
  if (hits.length === 0) return [];
13129
14142
  const results = [];
13130
14143
  for (const hit of hits) {
13131
- const fullPath = path11.isAbsolute(hit.path) ? hit.path : path11.join(deps.config.memoryDir, hit.path);
14144
+ const fullPath = path12.isAbsolute(hit.path) ? hit.path : path12.join(deps.config.memoryDir, hit.path);
13132
14145
  const memory = await deps.storage.readMemoryByPath(fullPath);
13133
14146
  if (!memory) continue;
13134
14147
  results.push({
@@ -13506,7 +14519,7 @@ var RecallSearchPipelineCoordinator = class {
13506
14519
  const storage = await this.deps.storageRouter.storageFor(namespace);
13507
14520
  const storageDir = typeof storage.dir === "string" && storage.dir ? storage.dir : null;
13508
14521
  if (!storageDir) continue;
13509
- const recallRoot = path12.resolve(storageDir);
14522
+ const recallRoot = path13.resolve(storageDir);
13510
14523
  if (seenRecallRoots.has(recallRoot)) continue;
13511
14524
  seenRecallRoots.add(recallRoot);
13512
14525
  recallRoots.push(recallRoot);
@@ -13530,8 +14543,8 @@ var RecallSearchPipelineCoordinator = class {
13530
14543
  if (resolvedCold) scopedResults.push(resolvedCold.result);
13531
14544
  continue;
13532
14545
  }
13533
- if (path12.isAbsolute(result.path)) {
13534
- if (recallRoots.some((recallRoot) => isPathInsideStorageRoot(recallRoot, path12.resolve(result.path)))) {
14546
+ if (path13.isAbsolute(result.path)) {
14547
+ if (recallRoots.some((recallRoot) => isPathInsideStorageRoot(recallRoot, path13.resolve(result.path)))) {
13535
14548
  scopedResults.push(result);
13536
14549
  }
13537
14550
  continue;
@@ -14649,8 +15662,8 @@ var TurnIngestionCoordinator = class {
14649
15662
  };
14650
15663
 
14651
15664
  // src/orchestration/recall-introspection.ts
14652
- import { mkdir as mkdir5, readFile as readFile5, writeFile as writeFile5 } from "fs/promises";
14653
- import path14 from "path";
15665
+ import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile5 } from "fs/promises";
15666
+ import path15 from "path";
14654
15667
 
14655
15668
  // src/taxonomy/default-taxonomy.ts
14656
15669
  var DEFAULT_TAXONOMY = {
@@ -14772,8 +15785,8 @@ function generateResolverDocument(taxonomy) {
14772
15785
  }
14773
15786
 
14774
15787
  // src/taxonomy/taxonomy-loader.ts
14775
- import { readFile as readFile4, mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
14776
- import path13 from "path";
15788
+ import { readFile as readFile5, mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
15789
+ import path14 from "path";
14777
15790
  var TAXONOMY_DIR = ".taxonomy";
14778
15791
  var TAXONOMY_FILE = "taxonomy.json";
14779
15792
  var MAX_SLUG_LENGTH = 32;
@@ -14871,10 +15884,10 @@ function validateTaxonomy(taxonomy) {
14871
15884
  }
14872
15885
  }
14873
15886
  async function loadTaxonomy(memoryDir) {
14874
- const taxonomyPath = path13.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
15887
+ const taxonomyPath = path14.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
14875
15888
  let raw;
14876
15889
  try {
14877
- raw = await readFile4(taxonomyPath, "utf-8");
15890
+ raw = await readFile5(taxonomyPath, "utf-8");
14878
15891
  } catch (err) {
14879
15892
  if (err instanceof Error && err.code === "ENOENT") {
14880
15893
  return structuredClone(DEFAULT_TAXONOMY);
@@ -14921,16 +15934,16 @@ async function loadTaxonomy(memoryDir) {
14921
15934
  }
14922
15935
  async function saveTaxonomy(memoryDir, taxonomy) {
14923
15936
  validateTaxonomy(taxonomy);
14924
- const dir = path13.join(memoryDir, TAXONOMY_DIR);
15937
+ const dir = path14.join(memoryDir, TAXONOMY_DIR);
14925
15938
  await mkdir4(dir, { recursive: true });
14926
- const filePath = path13.join(dir, TAXONOMY_FILE);
15939
+ const filePath = path14.join(dir, TAXONOMY_FILE);
14927
15940
  await writeFile4(filePath, JSON.stringify(taxonomy, null, 2) + "\n", "utf-8");
14928
15941
  }
14929
15942
  function getTaxonomyDir(memoryDir) {
14930
- return path13.join(memoryDir, TAXONOMY_DIR);
15943
+ return path14.join(memoryDir, TAXONOMY_DIR);
14931
15944
  }
14932
15945
  function getTaxonomyFilePath(memoryDir) {
14933
- return path13.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
15946
+ return path14.join(memoryDir, TAXONOMY_DIR, TAXONOMY_FILE);
14934
15947
  }
14935
15948
 
14936
15949
  // src/orchestration/recall-introspection.ts
@@ -14954,13 +15967,13 @@ var RecallIntrospectionCoordinator = class {
14954
15967
  }
14955
15968
  async getLastGraphRecallSnapshot(namespace) {
14956
15969
  const storage = await this.deps.getStorage(namespace);
14957
- const snapshotPath = path14.join(
15970
+ const snapshotPath = path15.join(
14958
15971
  storage.dir,
14959
15972
  "state",
14960
15973
  "last_graph_recall.json"
14961
15974
  );
14962
15975
  try {
14963
- const raw = await readFile5(snapshotPath, "utf-8");
15976
+ const raw = await readFile6(snapshotPath, "utf-8");
14964
15977
  const parsed = JSON.parse(raw);
14965
15978
  if (!parsed || typeof parsed !== "object") return null;
14966
15979
  return {
@@ -14993,9 +16006,9 @@ var RecallIntrospectionCoordinator = class {
14993
16006
  }
14994
16007
  async getLastIntentSnapshot(namespace) {
14995
16008
  const storage = await this.deps.getStorage(namespace);
14996
- const snapshotPath = path14.join(storage.dir, "state", "last_intent.json");
16009
+ const snapshotPath = path15.join(storage.dir, "state", "last_intent.json");
14997
16010
  try {
14998
- const raw = await readFile5(snapshotPath, "utf-8");
16011
+ const raw = await readFile6(snapshotPath, "utf-8");
14999
16012
  const parsed = JSON.parse(raw);
15000
16013
  if (!parsed || typeof parsed !== "object") return null;
15001
16014
  const graphDecision = parsed.graphDecision && typeof parsed.graphDecision === "object" ? parsed.graphDecision : void 0;
@@ -15026,13 +16039,13 @@ var RecallIntrospectionCoordinator = class {
15026
16039
  }
15027
16040
  async getLastQmdRecallSnapshot(namespace) {
15028
16041
  const storage = await this.deps.getStorage(namespace);
15029
- const snapshotPath = path14.join(
16042
+ const snapshotPath = path15.join(
15030
16043
  storage.dir,
15031
16044
  "state",
15032
16045
  "last_qmd_recall.json"
15033
16046
  );
15034
16047
  try {
15035
- const raw = await readFile5(snapshotPath, "utf-8");
16048
+ const raw = await readFile6(snapshotPath, "utf-8");
15036
16049
  const parsed = JSON.parse(raw);
15037
16050
  if (!parsed || typeof parsed !== "object") return null;
15038
16051
  return {
@@ -15318,12 +16331,12 @@ var RecallIntrospectionCoordinator = class {
15318
16331
  }
15319
16332
  async recordLastIntentSnapshot(options) {
15320
16333
  try {
15321
- const snapshotPath = path14.join(
16334
+ const snapshotPath = path15.join(
15322
16335
  options.storage.dir,
15323
16336
  "state",
15324
16337
  "last_intent.json"
15325
16338
  );
15326
- await mkdir5(path14.dirname(snapshotPath), { recursive: true });
16339
+ await mkdir5(path15.dirname(snapshotPath), { recursive: true });
15327
16340
  await writeFile5(
15328
16341
  snapshotPath,
15329
16342
  JSON.stringify(options.snapshot, null, 2),
@@ -15335,12 +16348,12 @@ var RecallIntrospectionCoordinator = class {
15335
16348
  }
15336
16349
  async recordLastQmdRecallSnapshot(options) {
15337
16350
  try {
15338
- const snapshotPath = path14.join(
16351
+ const snapshotPath = path15.join(
15339
16352
  options.storage.dir,
15340
16353
  "state",
15341
16354
  "last_qmd_recall.json"
15342
16355
  );
15343
- await mkdir5(path14.dirname(snapshotPath), { recursive: true });
16356
+ await mkdir5(path15.dirname(snapshotPath), { recursive: true });
15344
16357
  await writeFile5(
15345
16358
  snapshotPath,
15346
16359
  JSON.stringify(options.snapshot, null, 2),
@@ -15355,8 +16368,8 @@ var RecallIntrospectionCoordinator = class {
15355
16368
  const stateDir = await this.deps.resolveStateDirForNamespace(
15356
16369
  options.namespace
15357
16370
  );
15358
- const snapshotPath = path14.join(stateDir, "last_intent.json");
15359
- await mkdir5(path14.dirname(snapshotPath), { recursive: true });
16371
+ const snapshotPath = path15.join(stateDir, "last_intent.json");
16372
+ await mkdir5(path15.dirname(snapshotPath), { recursive: true });
15360
16373
  await writeFile5(
15361
16374
  snapshotPath,
15362
16375
  JSON.stringify(options.snapshot, null, 2),
@@ -15370,7 +16383,7 @@ var RecallIntrospectionCoordinator = class {
15370
16383
 
15371
16384
  // src/orchestration/orchestrator-init.ts
15372
16385
  import { readdir as readdir2, stat as stat2, unlink as unlink3 } from "fs/promises";
15373
- import path15 from "path";
16386
+ import path16 from "path";
15374
16387
  var OrchestratorInitCoordinator = class {
15375
16388
  constructor(deps) {
15376
16389
  this.deps = deps;
@@ -15474,7 +16487,7 @@ var OrchestratorInitCoordinator = class {
15474
16487
  const files = await readdir2(wsDir).catch(() => []);
15475
16488
  for (const f of files) {
15476
16489
  if (!f.startsWith(".compaction-reset-signal-")) continue;
15477
- const fp = path15.join(wsDir, f);
16490
+ const fp = path16.join(wsDir, f);
15478
16491
  const s = await stat2(fp).catch(() => null);
15479
16492
  if (s && Date.now() - s.mtimeMs >= COMPACTION_SIGNAL_MAX_AGE_MS) {
15480
16493
  await unlink3(fp).catch(() => {
@@ -15669,7 +16682,7 @@ var OrchestratorInitCoordinator = class {
15669
16682
  if (signal.aborted) return;
15670
16683
  if (lifecycleCaps.lifecyclePolicy && resolveQmdCapabilities(this.deps.config).qmdTierMigration) {
15671
16684
  try {
15672
- const { runFirstStartMigration } = await import("./first-start-migration-KHIMCBIC.js");
16685
+ const { runFirstStartMigration } = await import("./first-start-migration-RC345GPL.js");
15673
16686
  const result = await runFirstStartMigration({
15674
16687
  storage: this.deps.storage,
15675
16688
  config: this.deps.config,
@@ -15692,7 +16705,7 @@ var OrchestratorInitCoordinator = class {
15692
16705
  if (signal.aborted) return;
15693
16706
  if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
15694
16707
  try {
15695
- const { startWearablesAutoSync } = await import("./auto-sync-GRUJFD2F.js");
16708
+ const { startWearablesAutoSync } = await import("./auto-sync-WNGG2GC2.js");
15696
16709
  if (signal.aborted) return;
15697
16710
  this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
15698
16711
  {
@@ -15826,7 +16839,7 @@ var OrchestratorInitCoordinator = class {
15826
16839
  };
15827
16840
 
15828
16841
  // src/orchestration/persistence-index.ts
15829
- import path16 from "path";
16842
+ import path17 from "path";
15830
16843
  var PersistenceIndexCoordinator = class {
15831
16844
  constructor(deps) {
15832
16845
  this.deps = deps;
@@ -15992,7 +17005,13 @@ var PersistenceIndexCoordinator = class {
15992
17005
  async indexPersistedMemory(storage, memoryId) {
15993
17006
  if (!resolveMemoryLifecycleCapabilities(this.deps.config).embeddingFallback) return;
15994
17007
  if (!await this.deps.embeddingFallback.isAvailable()) return;
15995
- const memory = await storage.getMemoryById(memoryId);
17008
+ let memory = await storage.getMemoryById(memoryId);
17009
+ if (!memory) {
17010
+ const coldAware = await storage.getMemoryByIdIncludingArchived(memoryId).catch(() => null);
17011
+ if (coldAware && isActiveMemoryStatus(coldAware.frontmatter.status)) {
17012
+ memory = coldAware;
17013
+ }
17014
+ }
15996
17015
  if (!memory) return;
15997
17016
  await this.deps.embeddingFallback.indexFile(
15998
17017
  memoryId,
@@ -16012,7 +17031,7 @@ var PersistenceIndexCoordinator = class {
16012
17031
  const allMems = allMemsForGraph ?? [];
16013
17032
  for (const m of allMems) {
16014
17033
  if (m.frontmatter.entityRef === entityRef) {
16015
- const rel = path16.relative(storage.dir, m.path);
17034
+ const rel = path17.relative(storage.dir, m.path);
16016
17035
  if (rel !== memoryRelPath) entitySiblings.push(rel);
16017
17036
  }
16018
17037
  }
@@ -16039,7 +17058,7 @@ var PersistenceIndexCoordinator = class {
16039
17058
  recentInThread.push(fallbackCausalPredecessor);
16040
17059
  }
16041
17060
  const causalPredecessor = recentInThread[recentInThread.length - 1] ?? fallbackCausalPredecessor;
16042
- await this.deps.graphIndexFor(storage).onMemoryWritten({
17061
+ return await this.deps.graphIndexFor(storage).onMemoryWritten({
16043
17062
  memoryPath: memoryRelPath,
16044
17063
  entityRef,
16045
17064
  content: factContent,
@@ -16078,9 +17097,15 @@ var PersistenceIndexCoordinator = class {
16078
17097
  ])
16079
17098
  )
16080
17099
  ) : await storage.readAllMemories();
16081
- const pool = needsFullRebuild ? allMemories.filter((m) => isActiveMemoryStatus(m.frontmatter.status)) : (() => {
17100
+ const pool = needsFullRebuild ? allMemories.filter((m) => isActiveMemoryStatus(m.frontmatter.status)) : await (async () => {
16082
17101
  const idSet = new Set(persistedIds);
16083
- return allMemories.filter((m) => idSet.has(m.frontmatter.id));
17102
+ const hot = allMemories.filter((m) => idSet.has(m.frontmatter.id));
17103
+ for (const id of persistedIds) {
17104
+ if (hot.some((m) => m.frontmatter.id === id)) continue;
17105
+ const cold = await storage.getMemoryByIdIncludingArchived(id).catch(() => null);
17106
+ if (cold) hot.push(cold);
17107
+ }
17108
+ return hot;
16084
17109
  })();
16085
17110
  const entries = [];
16086
17111
  for (const mem of pool) {
@@ -16160,8 +17185,8 @@ var PersistenceIndexCoordinator = class {
16160
17185
  };
16161
17186
 
16162
17187
  // src/orchestration/workspace-ops.ts
16163
- import { lstat as lstat2, mkdir as mkdir6, readFile as readFile6, readdir as readdir3, realpath as realpath2, writeFile as writeFile6 } from "fs/promises";
16164
- import path17 from "path";
17188
+ import { lstat as lstat2, mkdir as mkdir6, readFile as readFile7, readdir as readdir3, realpath as realpath2, writeFile as writeFile6 } from "fs/promises";
17189
+ import path18 from "path";
16165
17190
 
16166
17191
  // src/maintenance/pattern-reinforcement.ts
16167
17192
  function patternReinforcementKey(content) {
@@ -18064,8 +19089,8 @@ var MeetingsService = class {
18064
19089
  // src/orchestration/workspace-ops.ts
18065
19090
  var MEETINGS_BUILD_DEBOUNCE_MS = 5e3;
18066
19091
  function matchesMemoryPath(candidatePath, requestedPath, memoryDir) {
18067
- const normalizedCandidate = path17.resolve(candidatePath);
18068
- return normalizedCandidate === path17.resolve(requestedPath) || normalizedCandidate === path17.resolve(memoryDir, requestedPath);
19092
+ const normalizedCandidate = path18.resolve(candidatePath);
19093
+ return normalizedCandidate === path18.resolve(requestedPath) || normalizedCandidate === path18.resolve(memoryDir, requestedPath);
18069
19094
  }
18070
19095
  function accessTrackingPathCandidates(storageDir, memoryPath) {
18071
19096
  const candidates = qmdResultPathCandidates(storageDir, memoryPath);
@@ -18073,12 +19098,12 @@ function accessTrackingPathCandidates(storageDir, memoryPath) {
18073
19098
  if (!parts) return candidates;
18074
19099
  candidates.push(
18075
19100
  ...qmdResultPathCandidates(storageDir, parts.relativePath),
18076
- ...qmdResultPathCandidates(path17.join(storageDir, "cold"), parts.relativePath)
19101
+ ...qmdResultPathCandidates(path18.join(storageDir, "cold"), parts.relativePath)
18077
19102
  );
18078
19103
  return [...new Set(candidates)];
18079
19104
  }
18080
19105
  function canonicalMemoryPath(memoryPath, memoryDir) {
18081
- return path17.resolve(path17.isAbsolute(memoryPath) ? memoryPath : path17.resolve(memoryDir, memoryPath));
19106
+ return path18.resolve(path18.isAbsolute(memoryPath) ? memoryPath : path18.resolve(memoryDir, memoryPath));
18082
19107
  }
18083
19108
  var WorkspaceOpsCoordinator = class {
18084
19109
  constructor(deps) {
@@ -18160,15 +19185,15 @@ var WorkspaceOpsCoordinator = class {
18160
19185
  this.deps.lastFileHygieneRunAtMs = now;
18161
19186
  if (hygiene.rotateEnabled) {
18162
19187
  for (const rel of hygiene.rotatePaths) {
18163
- const abs = path17.isAbsolute(rel) ? rel : path17.join(this.deps.config.workspaceDir, rel);
19188
+ const abs = path18.isAbsolute(rel) ? rel : path18.join(this.deps.config.workspaceDir, rel);
18164
19189
  try {
18165
- const raw = await readFile6(abs, "utf-8");
19190
+ const raw = await readFile7(abs, "utf-8");
18166
19191
  if (raw.length > hygiene.rotateMaxBytes) {
18167
- const archiveDir = path17.join(
19192
+ const archiveDir = path18.join(
18168
19193
  this.deps.config.workspaceDir,
18169
19194
  hygiene.archiveDir
18170
19195
  );
18171
- const base = path17.basename(abs);
19196
+ const base = path18.basename(abs);
18172
19197
  const prefix = base.toUpperCase().replace(/\.MD$/i, "").replace(/[^A-Z0-9]+/g, "-") || "FILE";
18173
19198
  const { newContent } = await rotateMarkdownFileToArchive({
18174
19199
  filePath: abs,
@@ -18193,8 +19218,8 @@ var WorkspaceOpsCoordinator = class {
18193
19218
  log.warn(w.message);
18194
19219
  }
18195
19220
  if (hygiene.warningsLogEnabled && warnings.length > 0) {
18196
- const fp = path17.join(this.deps.config.memoryDir, hygiene.warningsLogPath);
18197
- await mkdir6(path17.dirname(fp), { recursive: true });
19221
+ const fp = path18.join(this.deps.config.memoryDir, hygiene.warningsLogPath);
19222
+ await mkdir6(path18.dirname(fp), { recursive: true });
18198
19223
  const stamp = (/* @__PURE__ */ new Date()).toISOString();
18199
19224
  const block = `
18200
19225
 
@@ -18203,7 +19228,7 @@ var WorkspaceOpsCoordinator = class {
18203
19228
  ` + warnings.map((w) => `- ${w.message}`).join("\n") + "\n";
18204
19229
  let existing = "";
18205
19230
  try {
18206
- existing = await readFile6(fp, "utf-8");
19231
+ existing = await readFile7(fp, "utf-8");
18207
19232
  } catch {
18208
19233
  existing = "# Engram File Hygiene Warnings\n";
18209
19234
  }
@@ -18234,7 +19259,7 @@ var WorkspaceOpsCoordinator = class {
18234
19259
  for (const categoryDir of RECALL_FALLBACK_DIRS) {
18235
19260
  if (memoryRootReal === null) break;
18236
19261
  for (const date of datesToScan) {
18237
- const dateDir = path17.join(storage.dir, categoryDir, date);
19262
+ const dateDir = path18.join(storage.dir, categoryDir, date);
18238
19263
  try {
18239
19264
  const dirStat = await lstat2(dateDir);
18240
19265
  if (dirStat.isSymbolicLink() || !dirStat.isDirectory()) continue;
@@ -18243,7 +19268,7 @@ var WorkspaceOpsCoordinator = class {
18243
19268
  for (const entry of entries) {
18244
19269
  if (entry.isSymbolicLink()) continue;
18245
19270
  if (!entry.name.endsWith(".md")) continue;
18246
- const fullPath = path17.join(dateDir, entry.name);
19271
+ const fullPath = path18.join(dateDir, entry.name);
18247
19272
  try {
18248
19273
  assertPathInsideRoot(memoryRootReal, await realpath2(fullPath), fullPath);
18249
19274
  const memory = await storage.readMemoryByPath(fullPath);
@@ -18265,15 +19290,15 @@ var WorkspaceOpsCoordinator = class {
18265
19290
  return a.frontmatter.created < b.frontmatter.created ? -1 : 1;
18266
19291
  });
18267
19292
  const hourlySummaries = [];
18268
- const hourlyBaseDir = path17.join(storage.dir, "summaries", "hourly");
19293
+ const hourlyBaseDir = path18.join(storage.dir, "summaries", "hourly");
18269
19294
  try {
18270
19295
  const sessionKeys = await readdir3(hourlyBaseDir, { withFileTypes: true });
18271
19296
  for (const sk of sessionKeys) {
18272
19297
  if (!sk.isDirectory()) continue;
18273
19298
  for (const date of datesToScan) {
18274
- const summaryFile = path17.join(hourlyBaseDir, sk.name, `${date}.md`);
19299
+ const summaryFile = path18.join(hourlyBaseDir, sk.name, `${date}.md`);
18275
19300
  try {
18276
- const raw = await readFile6(summaryFile, "utf-8");
19301
+ const raw = await readFile7(summaryFile, "utf-8");
18277
19302
  const filtered = filterHourlySummaryMarkdownForLocalDay(
18278
19303
  raw,
18279
19304
  date,
@@ -18735,18 +19760,18 @@ ${reflectionsContent.trim()}
18735
19760
  // src/orchestration/namespace-read-fanout.ts
18736
19761
  import { existsSync, readFileSync } from "fs";
18737
19762
  import { stat as stat3 } from "fs/promises";
18738
- import path19 from "path";
19763
+ import path20 from "path";
18739
19764
 
18740
19765
  // src/orchestration/orchestrator-namespace-scope.ts
18741
- import path18 from "path";
19766
+ import path19 from "path";
18742
19767
  function computeSemanticDedupScope(targetStorage, config) {
18743
19768
  if (!resolveNamespaceCapabilities(config).namespaces) return {};
18744
- const memoryDir = path18.resolve(config.memoryDir);
18745
- const storageDir = path18.resolve(targetStorage.dir);
19769
+ const memoryDir = path19.resolve(config.memoryDir);
19770
+ const storageDir = path19.resolve(targetStorage.dir);
18746
19771
  if (storageDir === memoryDir) {
18747
19772
  return { pathExcludePrefixes: ["namespaces/"] };
18748
19773
  }
18749
- let rel = path18.relative(memoryDir, storageDir);
19774
+ let rel = path19.relative(memoryDir, storageDir);
18750
19775
  if (!rel || rel.startsWith("..")) {
18751
19776
  log.debug(
18752
19777
  `semantic dedup: target storage dir ${storageDir} is outside memoryDir ${memoryDir}; scoping lookup to absolute path prefix`
@@ -18799,7 +19824,7 @@ var NamespaceReadFanoutCoordinator = class {
18799
19824
  loadNamespaceStorageDirHintsFromCatalog() {
18800
19825
  if (this.deps.namespaceStorageDirHintsLoaded || !this.deps.namespaceCatalog.enabled) return;
18801
19826
  this.deps.namespaceStorageDirHintsLoaded = true;
18802
- const catalogPath = path19.join(this.deps.config.memoryDir, "state", "namespaces.jsonl");
19827
+ const catalogPath = path20.join(this.deps.config.memoryDir, "state", "namespaces.jsonl");
18803
19828
  if (!existsSync(catalogPath)) return;
18804
19829
  let body;
18805
19830
  try {
@@ -18836,7 +19861,7 @@ var NamespaceReadFanoutCoordinator = class {
18836
19861
  if (!this.deps.storageDirMatchesNamespaceHint(record.namespace, record.storageDir)) {
18837
19862
  continue;
18838
19863
  }
18839
- const resolvedStorageDir = path19.resolve(record.storageDir);
19864
+ const resolvedStorageDir = path20.resolve(record.storageDir);
18840
19865
  const current = preferredByStorageDir.get(resolvedStorageDir);
18841
19866
  preferredByStorageDir.set(
18842
19867
  resolvedStorageDir,
@@ -19021,12 +20046,12 @@ var NamespaceReadFanoutCoordinator = class {
19021
20046
  }
19022
20047
  async resolveStateDirForNamespace(namespace) {
19023
20048
  if (!resolveNamespaceCapabilities(this.deps.config).namespaces) {
19024
- return path19.join(this.deps.config.memoryDir, "state");
20049
+ return path20.join(this.deps.config.memoryDir, "state");
19025
20050
  }
19026
20051
  if (namespace !== this.deps.config.defaultNamespace) {
19027
- return path19.join(this.deps.config.memoryDir, "namespaces", namespace, "state");
20052
+ return path20.join(this.deps.config.memoryDir, "namespaces", namespace, "state");
19028
20053
  }
19029
- const candidate = path19.join(
20054
+ const candidate = path20.join(
19030
20055
  this.deps.config.memoryDir,
19031
20056
  "namespaces",
19032
20057
  this.deps.config.defaultNamespace
@@ -19034,11 +20059,11 @@ var NamespaceReadFanoutCoordinator = class {
19034
20059
  try {
19035
20060
  const candidateStat = await stat3(candidate);
19036
20061
  if (candidateStat.isDirectory()) {
19037
- return path19.join(candidate, "state");
20062
+ return path20.join(candidate, "state");
19038
20063
  }
19039
20064
  } catch {
19040
20065
  }
19041
- return path19.join(this.deps.config.memoryDir, "state");
20066
+ return path20.join(this.deps.config.memoryDir, "state");
19042
20067
  }
19043
20068
  namespaceFromPath(p) {
19044
20069
  if (!resolveNamespaceCapabilities(this.deps.config).namespaces) return this.deps.config.defaultNamespace;
@@ -19486,7 +20511,7 @@ var Orchestrator = class {
19486
20511
  if (this.destroyed) throw new Error("orchestrator has been destroyed");
19487
20512
  if (!this._dependencyPropagationDelivery) {
19488
20513
  this._dependencyPropagationDelivery = new DependencyPropagationDelivery({
19489
- queueRoot: path20.join(this.config.memoryDir, "state", "dependency-propagation"),
20514
+ queueRoot: path21.join(this.config.memoryDir, "state", "dependency-propagation"),
19490
20515
  config: this.config,
19491
20516
  extraction: this.extraction,
19492
20517
  getStorage: (namespace) => this.getStorage(namespace),
@@ -19835,7 +20860,7 @@ var Orchestrator = class {
19835
20860
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
19836
20861
  if (ns !== defaultNs && !isSafeRouteNamespace(ns)) return;
19837
20862
  if (!this.storageDirMatchesNamespaceHint(ns, storageDir)) return;
19838
- const resolvedStorageDir = path20.resolve(storageDir);
20863
+ const resolvedStorageDir = path21.resolve(storageDir);
19839
20864
  let hints = this.namespaceStorageDirHints.get(resolvedStorageDir);
19840
20865
  if (!hints) {
19841
20866
  hints = /* @__PURE__ */ new Set();
@@ -19846,21 +20871,21 @@ var Orchestrator = class {
19846
20871
  storageDirMatchesNamespaceHint(namespace, storageDir) {
19847
20872
  const ns = normalizeNamespaceIdentity(namespace);
19848
20873
  if (!ns) return false;
19849
- const resolvedStorageDir = path20.resolve(storageDir);
19850
- const resolvedMemoryDir = path20.resolve(this.config.memoryDir);
20874
+ const resolvedStorageDir = path21.resolve(storageDir);
20875
+ const resolvedMemoryDir = path21.resolve(this.config.memoryDir);
19851
20876
  const defaultNs = normalizeNamespaceIdentity(this.config.defaultNamespace);
19852
20877
  if (resolvedStorageDir === resolvedMemoryDir) return ns === defaultNs;
19853
- const resolvedNamespacesDir = path20.join(resolvedMemoryDir, "namespaces");
20878
+ const resolvedNamespacesDir = path21.join(resolvedMemoryDir, "namespaces");
19854
20879
  if (!isPathInsideStorageRoot(resolvedNamespacesDir, resolvedStorageDir)) return false;
19855
- const rawRoot = path20.resolve(resolvedNamespacesDir, ns);
19856
- const tokenRoot = path20.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
20880
+ const rawRoot = path21.resolve(resolvedNamespacesDir, ns);
20881
+ const tokenRoot = path21.resolve(resolvedNamespacesDir, namespaceIdentityToken(ns));
19857
20882
  return resolvedStorageDir === rawRoot || resolvedStorageDir === tokenRoot;
19858
20883
  }
19859
20884
  namespaceStorageDirHintOwnershipRank(record, resolvedStorageDir, configured) {
19860
- if (resolvedStorageDir === path20.resolve(this.config.memoryDir)) {
20885
+ if (resolvedStorageDir === path21.resolve(this.config.memoryDir)) {
19861
20886
  return record.namespace === normalizeNamespaceIdentity(this.config.defaultNamespace) ? 0 : 3;
19862
20887
  }
19863
- const leaf = path20.basename(resolvedStorageDir);
20888
+ const leaf = path21.basename(resolvedStorageDir);
19864
20889
  const tokenOwnsRoot = namespaceIdentityToken(record.namespace) === leaf;
19865
20890
  if (tokenOwnsRoot && configured.has(record.namespace)) return 0;
19866
20891
  if (record.namespace === leaf) return 1;
@@ -20001,7 +21026,7 @@ var Orchestrator = class {
20001
21026
  StorageManager.setOkfConformanceDefault(config.memoryDir, config.okf?.conformanceEnabled);
20002
21027
  this.profiler = new ProfilingCollector({
20003
21028
  enabled: resolvePipelineProcessingCapabilities(this.config).profiling,
20004
- storageDir: config.profilingStorageDir || path20.join(config.memoryDir, "profiling"),
21029
+ storageDir: config.profilingStorageDir || path21.join(config.memoryDir, "profiling"),
20005
21030
  maxTraces: config.profilingMaxTraces
20006
21031
  });
20007
21032
  this.namespaceCatalog = new NamespaceCatalog(config);
@@ -20088,7 +21113,7 @@ var Orchestrator = class {
20088
21113
  this.compounding = resolveConsolidationCapabilities(config).compounding ? new CompoundingEngine(config, this.storage) : void 0;
20089
21114
  this.buffer = new SmartBuffer(config, this.storage);
20090
21115
  this.transcript = new TranscriptManager(config);
20091
- this.conversationIndexDir = path20.join(
21116
+ this.conversationIndexDir = path21.join(
20092
21117
  config.memoryDir,
20093
21118
  "conversation-index",
20094
21119
  "chunks"
@@ -20238,7 +21263,7 @@ var Orchestrator = class {
20238
21263
  saveContentHashIndexes: () => this.saveContentHashIndexes()
20239
21264
  });
20240
21265
  this.threading = new ThreadingManager(
20241
- path20.join(config.memoryDir, "threads"),
21266
+ path21.join(config.memoryDir, "threads"),
20242
21267
  config.threadingGapMinutes
20243
21268
  );
20244
21269
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(config);
@@ -22342,9 +23367,9 @@ function readStructuralSymbol(entry) {
22342
23367
  const rec = entry;
22343
23368
  const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
22344
23369
  if (!symbol) return null;
22345
- const path38 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
23370
+ const path39 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
22346
23371
  const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
22347
- const item = path38 !== void 0 && kind !== void 0 ? { symbol, path: path38, kind } : path38 !== void 0 ? { symbol, path: path38 } : kind !== void 0 ? { symbol, kind } : { symbol };
23372
+ const item = path39 !== void 0 && kind !== void 0 ? { symbol, path: path39, kind } : path39 !== void 0 ? { symbol, path: path39 } : kind !== void 0 ? { symbol, kind } : { symbol };
22348
23373
  return item;
22349
23374
  }
22350
23375
  function classifySpawnError(err) {
@@ -22418,7 +23443,7 @@ var DEFAULT_GRACE_PERIOD_DAYS = 7;
22418
23443
 
22419
23444
  // src/binary-lifecycle/backend.ts
22420
23445
  import fsp from "fs/promises";
22421
- import path21 from "path";
23446
+ import path22 from "path";
22422
23447
  var FilesystemBackend = class {
22423
23448
  type = "filesystem";
22424
23449
  basePath;
@@ -22426,19 +23451,19 @@ var FilesystemBackend = class {
22426
23451
  if (!basePath || basePath.trim().length === 0) {
22427
23452
  throw new Error("FilesystemBackend requires a non-empty basePath");
22428
23453
  }
22429
- this.basePath = path21.resolve(basePath);
23454
+ this.basePath = path22.resolve(basePath);
22430
23455
  }
22431
23456
  resolveRemotePath(remotePath) {
22432
- const resolved = path21.isAbsolute(remotePath) ? path21.resolve(remotePath) : path21.resolve(this.basePath, remotePath);
22433
- const relative = path21.relative(this.basePath, resolved);
22434
- if (relative === ".." || relative.startsWith(`..${path21.sep}`) || path21.isAbsolute(relative)) {
23457
+ const resolved = path22.isAbsolute(remotePath) ? path22.resolve(remotePath) : path22.resolve(this.basePath, remotePath);
23458
+ const relative = path22.relative(this.basePath, resolved);
23459
+ if (relative === ".." || relative.startsWith(`..${path22.sep}`) || path22.isAbsolute(relative)) {
22435
23460
  throw new Error(`FilesystemBackend remotePath escapes basePath: ${JSON.stringify(remotePath)}`);
22436
23461
  }
22437
23462
  return resolved;
22438
23463
  }
22439
23464
  isInsideBase(candidate, realBase) {
22440
- const relative = path21.relative(realBase, candidate);
22441
- return relative === "" || relative !== ".." && !relative.startsWith(`..${path21.sep}`) && !path21.isAbsolute(relative);
23465
+ const relative = path22.relative(realBase, candidate);
23466
+ return relative === "" || relative !== ".." && !relative.startsWith(`..${path22.sep}`) && !path22.isAbsolute(relative);
22442
23467
  }
22443
23468
  async realBasePathIfExists() {
22444
23469
  try {
@@ -22467,13 +23492,13 @@ var FilesystemBackend = class {
22467
23492
  }
22468
23493
  async ensureSafeParentDirectory(dest) {
22469
23494
  const realBase = await this.ensureBaseDirectory();
22470
- const destDir = path21.dirname(dest);
22471
- const relativeDir = path21.relative(this.basePath, destDir);
22472
- const segments = relativeDir === "" ? [] : relativeDir.split(path21.sep);
23495
+ const destDir = path22.dirname(dest);
23496
+ const relativeDir = path22.relative(this.basePath, destDir);
23497
+ const segments = relativeDir === "" ? [] : relativeDir.split(path22.sep);
22473
23498
  let current = this.basePath;
22474
23499
  for (const segment of segments) {
22475
23500
  if (segment === "." || segment === "") continue;
22476
- current = path21.join(current, segment);
23501
+ current = path22.join(current, segment);
22477
23502
  try {
22478
23503
  const stat5 = await fsp.lstat(current);
22479
23504
  if (stat5.isSymbolicLink()) {
@@ -22501,13 +23526,13 @@ var FilesystemBackend = class {
22501
23526
  if (realBase === null) {
22502
23527
  return null;
22503
23528
  }
22504
- const destDir = path21.dirname(dest);
22505
- const relativeDir = path21.relative(this.basePath, destDir);
22506
- const segments = relativeDir === "" ? [] : relativeDir.split(path21.sep);
23529
+ const destDir = path22.dirname(dest);
23530
+ const relativeDir = path22.relative(this.basePath, destDir);
23531
+ const segments = relativeDir === "" ? [] : relativeDir.split(path22.sep);
22507
23532
  let current = this.basePath;
22508
23533
  for (const segment of segments) {
22509
23534
  if (segment === "." || segment === "") continue;
22510
- current = path21.join(current, segment);
23535
+ current = path22.join(current, segment);
22511
23536
  let stat5;
22512
23537
  try {
22513
23538
  stat5 = await fsp.lstat(current);
@@ -22525,7 +23550,7 @@ var FilesystemBackend = class {
22525
23550
  }
22526
23551
  }
22527
23552
  const realParent = await fsp.realpath(destDir).catch((err) => {
22528
- if (err.code === "ENOENT") return null;
23553
+ if (isErrnoCode(err, "ENOENT")) return null;
22529
23554
  throw err;
22530
23555
  });
22531
23556
  if (realParent === null) {
@@ -22555,7 +23580,7 @@ var FilesystemBackend = class {
22555
23580
  return dest;
22556
23581
  }
22557
23582
  async upload(localPath, remotePath) {
22558
- if (path21.isAbsolute(remotePath)) {
23583
+ if (path22.isAbsolute(remotePath)) {
22559
23584
  throw new Error(`FilesystemBackend upload remotePath must be relative: ${JSON.stringify(remotePath)}`);
22560
23585
  }
22561
23586
  const dest = this.resolveRemotePath(remotePath);
@@ -22628,7 +23653,7 @@ function createBackend(cfg) {
22628
23653
 
22629
23654
  // src/binary-lifecycle/scanner.ts
22630
23655
  import fsp2 from "fs/promises";
22631
- import path22 from "path";
23656
+ import path23 from "path";
22632
23657
  import crypto from "crypto";
22633
23658
  function matchesPatterns(filename, patterns) {
22634
23659
  const lower = filename.toLowerCase();
@@ -22653,8 +23678,8 @@ async function scanForBinaries(memoryDir, config, manifest) {
22653
23678
  return;
22654
23679
  }
22655
23680
  for (const entry of entries) {
22656
- const fullPath = path22.join(dir, entry.name);
22657
- const relativePath = path22.relative(memoryDir, fullPath).split(path22.sep).join("/");
23681
+ const fullPath = path23.join(dir, entry.name);
23682
+ const relativePath = path23.relative(memoryDir, fullPath).split(path23.sep).join("/");
22658
23683
  if (entry.isDirectory()) {
22659
23684
  if (entry.name === ".binary-lifecycle") continue;
22660
23685
  await walk(fullPath);
@@ -22694,15 +23719,15 @@ async function hashFile(filePath) {
22694
23719
 
22695
23720
  // src/binary-lifecycle/manifest.ts
22696
23721
  import fsp3 from "fs/promises";
22697
- import path23 from "path";
23722
+ import path24 from "path";
22698
23723
  import crypto2 from "crypto";
22699
23724
  var MANIFEST_DIR = ".binary-lifecycle";
22700
23725
  var MANIFEST_FILE = "manifest.json";
22701
23726
  function manifestDir(memoryDir) {
22702
- return path23.join(memoryDir, MANIFEST_DIR);
23727
+ return path24.join(memoryDir, MANIFEST_DIR);
22703
23728
  }
22704
23729
  function manifestPath(memoryDir) {
22705
- return path23.join(memoryDir, MANIFEST_DIR, MANIFEST_FILE);
23730
+ return path24.join(memoryDir, MANIFEST_DIR, MANIFEST_FILE);
22706
23731
  }
22707
23732
  async function readManifest(memoryDir) {
22708
23733
  const filePath = manifestPath(memoryDir);
@@ -22754,13 +23779,13 @@ function emptyManifest() {
22754
23779
 
22755
23780
  // src/binary-lifecycle/pipeline.ts
22756
23781
  import fsp4 from "fs/promises";
22757
- import path24 from "path";
23782
+ import path25 from "path";
22758
23783
  import crypto3 from "crypto";
22759
23784
  var historicalIdCache = new HistoricalEntityCanonicalIdCache();
22760
23785
  function isRecallCorpusMarkdown(mdPath, memoryDir) {
22761
- const rel = path24.relative(memoryDir, mdPath);
22762
- if (rel.startsWith("..") || path24.isAbsolute(rel)) return false;
22763
- const top = rel.split(path24.sep)[0];
23786
+ const rel = path25.relative(memoryDir, mdPath);
23787
+ if (rel.startsWith("..") || path25.isAbsolute(rel)) return false;
23788
+ const top = rel.split(path25.sep)[0];
22764
23789
  return RECALL_FALLBACK_DIRS.includes(top);
22765
23790
  }
22766
23791
  async function hashFile2(filePath) {
@@ -22784,13 +23809,13 @@ function escapeRegex(s) {
22784
23809
  return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
22785
23810
  }
22786
23811
  function resolveManifestAssetPath(memoryDir, originalPath) {
22787
- if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") || path24.isAbsolute(originalPath) || path24.win32.isAbsolute(originalPath)) {
23812
+ if (originalPath.length === 0 || originalPath.includes("\0") || originalPath.includes("\\") || path25.isAbsolute(originalPath) || path25.win32.isAbsolute(originalPath)) {
22788
23813
  return null;
22789
23814
  }
22790
- const memoryRoot = path24.resolve(memoryDir);
22791
- const fullPath = path24.resolve(memoryRoot, originalPath);
22792
- const relative = path24.relative(memoryRoot, fullPath);
22793
- if (relative === "" || relative === ".." || relative.startsWith(`..${path24.sep}`) || path24.isAbsolute(relative)) {
23815
+ const memoryRoot = path25.resolve(memoryDir);
23816
+ const fullPath = path25.resolve(memoryRoot, originalPath);
23817
+ const relative = path25.relative(memoryRoot, fullPath);
23818
+ if (relative === "" || relative === ".." || relative.startsWith(`..${path25.sep}`) || path25.isAbsolute(relative)) {
22794
23819
  return null;
22795
23820
  }
22796
23821
  return fullPath;
@@ -22801,7 +23826,7 @@ function validateBinaryLifecycleConfig(config) {
22801
23826
  }
22802
23827
  }
22803
23828
  function remotePathForAsset(backend, relPath) {
22804
- const normalized = relPath.split(path24.sep).join("/");
23829
+ const normalized = relPath.split(path25.sep).join("/");
22805
23830
  if (backend.type === "filesystem") {
22806
23831
  return `.binary-lifecycle/mirrors/${normalized}`;
22807
23832
  }
@@ -22814,11 +23839,11 @@ async function stageMirror(memoryDir, newPaths, backend, assets, log2, dryRun) {
22814
23839
  let mirrored = 0;
22815
23840
  const errors = [];
22816
23841
  for (const relPath of newPaths) {
22817
- const fullPath = path24.join(memoryDir, relPath);
23842
+ const fullPath = path25.join(memoryDir, relPath);
22818
23843
  try {
22819
23844
  const stat5 = await fsp4.stat(fullPath);
22820
23845
  const contentHash = await hashFile2(fullPath);
22821
- const ext = path24.extname(relPath);
23846
+ const ext = path25.extname(relPath);
22822
23847
  const mimeType = guessMimeType(ext);
22823
23848
  const remotePath = remotePathForAsset(backend, relPath);
22824
23849
  let backendLocation = remotePath;
@@ -22969,7 +23994,7 @@ async function stageRedirect(memoryDir, assets, log2, dryRun, readMarkdownFile,
22969
23994
  for (const update of updates) {
22970
23995
  try {
22971
23996
  await withRawEntityPageMutation(memoryDir, update.mdPath, async () => {
22972
- const stateDir = path24.join(memoryDir, "state");
23997
+ const stateDir = path25.join(memoryDir, "state");
22973
23998
  const kind = classifyEntityRefWritePath(memoryDir, update.mdPath);
22974
23999
  if (kind === "memory") {
22975
24000
  const idsAtWrite = historicalIdCache.get(stateDir);
@@ -23062,10 +24087,10 @@ async function countRemainingLocalReferences(memoryDir, asset, assetAbsolute, md
23062
24087
  return { remaining, errors };
23063
24088
  }
23064
24089
  function markdownReferencePattern(asset, assetAbsolute, mdPath) {
23065
- const mdDir = path24.dirname(mdPath);
24090
+ const mdDir = path25.dirname(mdPath);
23066
24091
  const candidates = /* @__PURE__ */ new Set();
23067
24092
  const addCandidate = (candidate) => {
23068
- const normalized = candidate.split(path24.sep).join("/");
24093
+ const normalized = candidate.split(path25.sep).join("/");
23069
24094
  if (normalized.length === 0) return;
23070
24095
  candidates.add(normalized);
23071
24096
  const isParentTraversal = normalized === ".." || normalized.startsWith("../");
@@ -23073,10 +24098,10 @@ function markdownReferencePattern(asset, assetAbsolute, mdPath) {
23073
24098
  candidates.add(`./${normalized}`);
23074
24099
  }
23075
24100
  };
23076
- addCandidate(path24.relative(mdDir, assetAbsolute));
23077
- const originalPath = asset.originalPath.split(path24.sep).join("/");
23078
- const originalAsFileRelative = path24.resolve(mdDir, ...originalPath.split("/"));
23079
- if (path24.resolve(originalAsFileRelative) === path24.resolve(assetAbsolute)) {
24101
+ addCandidate(path25.relative(mdDir, assetAbsolute));
24102
+ const originalPath = asset.originalPath.split(path25.sep).join("/");
24103
+ const originalAsFileRelative = path25.resolve(mdDir, ...originalPath.split("/"));
24104
+ if (path25.resolve(originalAsFileRelative) === path25.resolve(assetAbsolute)) {
23080
24105
  addCandidate(originalPath);
23081
24106
  }
23082
24107
  addCandidate(`/${originalPath}`);
@@ -23172,7 +24197,7 @@ async function findMarkdownFiles(dir) {
23172
24197
  return;
23173
24198
  }
23174
24199
  for (const entry of entries) {
23175
- const full = path24.join(current, entry.name);
24200
+ const full = path25.join(current, entry.name);
23176
24201
  if (entry.isDirectory()) {
23177
24202
  if (entry.name === ".binary-lifecycle") continue;
23178
24203
  await walk(full);
@@ -23247,7 +24272,7 @@ async function runBinaryLifecyclePipeline(memoryDir, config, backend, log2, opts
23247
24272
 
23248
24273
  // src/projection/index.ts
23249
24274
  import fs from "fs";
23250
- import path25 from "path";
24275
+ import path26 from "path";
23251
24276
  var VALID_PROJECTION_CATEGORIES = new Set(ALL_CATEGORY_KEYS);
23252
24277
  async function generateContextTree(options) {
23253
24278
  const startTime = Date.now();
@@ -23262,8 +24287,8 @@ async function generateContextTree(options) {
23262
24287
  let nodesGenerated = 0;
23263
24288
  let nodesSkipped = 0;
23264
24289
  const categoryCounts = {};
23265
- const resolvedMemoryDir = path25.resolve(memoryDir);
23266
- const resolvedOutputDir = path25.resolve(outputDir);
24290
+ const resolvedMemoryDir = path26.resolve(memoryDir);
24291
+ const resolvedOutputDir = path26.resolve(outputDir);
23267
24292
  const requestedCategories = validateProjectionCategories(filterCategories);
23268
24293
  const realMemoryDir = assertSafeMemoryRoot(resolvedMemoryDir);
23269
24294
  assertNotSymlink(resolvedOutputDir, "context tree outputDir");
@@ -23301,7 +24326,7 @@ async function generateContextTree(options) {
23301
24326
  }
23302
24327
  }
23303
24328
  if (includeEntities) {
23304
- const entitiesDir = path25.join(memoryDir, "entities");
24329
+ const entitiesDir = path26.join(memoryDir, "entities");
23305
24330
  if (fs.existsSync(entitiesDir)) {
23306
24331
  assertSafeInputRoot(realMemoryDir, entitiesDir, "entities root");
23307
24332
  categoryCounts["entity"] = 0;
@@ -23313,7 +24338,7 @@ async function generateContextTree(options) {
23313
24338
  continue;
23314
24339
  }
23315
24340
  const content = fs.readFileSync(filePath, "utf8");
23316
- const fileName = path25.basename(filePath, ".md");
24341
+ const fileName = path26.basename(filePath, ".md");
23317
24342
  const node = projectEntityNode(fileName, content);
23318
24343
  const outputPath = resolveContainedOutputPath(realOutputDir, "entities", `${fileName}.md`);
23319
24344
  writeProjectedContent(realOutputDir, outputPath, node.content);
@@ -23325,7 +24350,7 @@ async function generateContextTree(options) {
23325
24350
  }
23326
24351
  const shouldIncludeQuestions = includeQuestions && (requestedCategories === void 0 || requestedCategories.includes("question"));
23327
24352
  if (shouldIncludeQuestions) {
23328
- const questionsDir = path25.join(memoryDir, "questions");
24353
+ const questionsDir = path26.join(memoryDir, "questions");
23329
24354
  if (fs.existsSync(questionsDir)) {
23330
24355
  assertSafeInputRoot(realMemoryDir, questionsDir, "questions root");
23331
24356
  categoryCounts["question"] = 0;
@@ -23366,8 +24391,8 @@ async function generateContextTree(options) {
23366
24391
  };
23367
24392
  }
23368
24393
  function isPathInside(root, candidate) {
23369
- const relative = path25.relative(root, candidate);
23370
- return relative === "" || !relative.startsWith("..") && !path25.isAbsolute(relative);
24394
+ const relative = path26.relative(root, candidate);
24395
+ return relative === "" || !relative.startsWith("..") && !path26.isAbsolute(relative);
23371
24396
  }
23372
24397
  function assertNotSymlink(targetPath, label) {
23373
24398
  try {
@@ -23404,12 +24429,12 @@ function assertSafeInputRoot(realMemoryDir, targetPath, label) {
23404
24429
  }
23405
24430
  function assertSafeOutputTarget(realOutputDir, outputPath) {
23406
24431
  let current = realOutputDir;
23407
- const relative = path25.relative(realOutputDir, outputPath);
23408
- if (relative.startsWith("..") || path25.isAbsolute(relative)) {
24432
+ const relative = path26.relative(realOutputDir, outputPath);
24433
+ if (relative.startsWith("..") || path26.isAbsolute(relative)) {
23409
24434
  throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
23410
24435
  }
23411
- for (const segment of relative.split(path25.sep).filter(Boolean)) {
23412
- current = path25.join(current, segment);
24436
+ for (const segment of relative.split(path26.sep).filter(Boolean)) {
24437
+ current = path26.join(current, segment);
23413
24438
  try {
23414
24439
  const stat5 = fs.lstatSync(current);
23415
24440
  if (stat5.isSymbolicLink()) {
@@ -23439,17 +24464,17 @@ function validateProjectionCategories(categories) {
23439
24464
  return validated;
23440
24465
  }
23441
24466
  function resolveContainedOutputPath(outputRoot, ...segments) {
23442
- const resolved = path25.resolve(outputRoot, ...segments);
23443
- const relative = path25.relative(outputRoot, resolved);
23444
- if (relative === "" || !relative.startsWith("..") && !path25.isAbsolute(relative)) {
24467
+ const resolved = path26.resolve(outputRoot, ...segments);
24468
+ const relative = path26.relative(outputRoot, resolved);
24469
+ if (relative === "" || !relative.startsWith("..") && !path26.isAbsolute(relative)) {
23445
24470
  return resolved;
23446
24471
  }
23447
24472
  throw new Error(`context tree output path escapes outputDir: ${segments.join("/")}`);
23448
24473
  }
23449
24474
  function writeProjectedContent(realOutputDir, outputPath, generatedContent) {
23450
24475
  assertSafeOutputTarget(realOutputDir, outputPath);
23451
- fs.mkdirSync(path25.dirname(outputPath), { recursive: true });
23452
- const realParent = fs.realpathSync(path25.dirname(outputPath));
24476
+ fs.mkdirSync(path26.dirname(outputPath), { recursive: true });
24477
+ const realParent = fs.realpathSync(path26.dirname(outputPath));
23453
24478
  if (!isPathInside(realOutputDir, realParent)) {
23454
24479
  throw new Error(`context tree output path escapes outputDir: ${outputPath}`);
23455
24480
  }
@@ -23488,7 +24513,7 @@ function walkR(dir, realMemoryDir) {
23488
24513
  const results = [];
23489
24514
  function walk(directory) {
23490
24515
  for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
23491
- const fullPath = path25.join(directory, entry.name);
24516
+ const fullPath = path26.join(directory, entry.name);
23492
24517
  if (entry.isSymbolicLink()) {
23493
24518
  throw new Error(`context tree input path contains symlink: ${fullPath}`);
23494
24519
  }
@@ -23541,13 +24566,13 @@ function extractBody(content) {
23541
24566
  }
23542
24567
  function projectNode(filePath, category, fm, rawContent) {
23543
24568
  const body = extractBody(rawContent);
23544
- const fileName = path25.basename(filePath, ".md");
23545
- const dateDir = path25.basename(path25.dirname(filePath));
24569
+ const fileName = path26.basename(filePath, ".md");
24570
+ const dateDir = path26.basename(path26.dirname(filePath));
23546
24571
  let relPath;
23547
24572
  if (/^\d{4}-\d{2}-\d{2}$/.test(dateDir)) {
23548
- relPath = path25.join(category, dateDir, `${fileName}.md`);
24573
+ relPath = path26.join(category, dateDir, `${fileName}.md`);
23549
24574
  } else {
23550
- relPath = path25.join(category, `${fileName}.md`);
24575
+ relPath = path26.join(category, `${fileName}.md`);
23551
24576
  }
23552
24577
  const generatedAt = (/* @__PURE__ */ new Date()).toISOString();
23553
24578
  const md = `# ${fm.id}
@@ -23593,7 +24618,7 @@ function projectEntityNode(fileName, content) {
23593
24618
  ${content}
23594
24619
  `;
23595
24620
  return {
23596
- path: path25.join("entities", `${fileName}.md`),
24621
+ path: path26.join("entities", `${fileName}.md`),
23597
24622
  category: "entity",
23598
24623
  title: fileName,
23599
24624
  content: md,
@@ -23646,7 +24671,7 @@ function generateIndex(categoryCounts, outputDir) {
23646
24671
 
23647
24672
  // src/onboarding/index.ts
23648
24673
  import fs2 from "fs";
23649
- import path26 from "path";
24674
+ import path27 from "path";
23650
24675
  var LANGUAGE_RULES = [
23651
24676
  {
23652
24677
  language: "TypeScript",
@@ -23748,7 +24773,7 @@ function onboard(options) {
23748
24773
  maxDepth = 6,
23749
24774
  excludeDirs = []
23750
24775
  } = options;
23751
- const directory = path26.resolve(options.directory ?? process.cwd());
24776
+ const directory = path27.resolve(options.directory ?? process.cwd());
23752
24777
  let rootStat;
23753
24778
  try {
23754
24779
  rootStat = fs2.statSync(directory);
@@ -23790,7 +24815,7 @@ function walkDir(root, exclude, maxDepth) {
23790
24815
  }
23791
24816
  for (const entry of entries) {
23792
24817
  if (exclude.has(entry.name)) continue;
23793
- const fullPath = path26.join(dir, entry.name);
24818
+ const fullPath = path27.join(dir, entry.name);
23794
24819
  if (entry.isDirectory()) {
23795
24820
  walk(fullPath, depth + 1);
23796
24821
  } else if (entry.isFile()) {
@@ -23805,11 +24830,11 @@ function detectLanguages(files, root) {
23805
24830
  const results = [];
23806
24831
  const extCounts = /* @__PURE__ */ new Map();
23807
24832
  for (const f of files) {
23808
- const ext = path26.extname(f).toLowerCase();
24833
+ const ext = path27.extname(f).toLowerCase();
23809
24834
  if (ext) extCounts.set(ext, (extCounts.get(ext) ?? 0) + 1);
23810
24835
  }
23811
24836
  const rootFiles = new Set(
23812
- files.filter((f) => path26.dirname(f) === root).map((f) => path26.basename(f))
24837
+ files.filter((f) => path27.dirname(f) === root).map((f) => path27.basename(f))
23813
24838
  );
23814
24839
  for (const rule of LANGUAGE_RULES) {
23815
24840
  const evidence = [];
@@ -23853,7 +24878,7 @@ function detectLanguages(files, root) {
23853
24878
  }
23854
24879
  function detectShape(files, root) {
23855
24880
  const rootFiles = new Set(
23856
- files.filter((f) => path26.dirname(f) === root).map((f) => path26.basename(f))
24881
+ files.filter((f) => path27.dirname(f) === root).map((f) => path27.basename(f))
23857
24882
  );
23858
24883
  const rootDirs = /* @__PURE__ */ new Set();
23859
24884
  try {
@@ -23864,7 +24889,7 @@ function detectShape(files, root) {
23864
24889
  }
23865
24890
  const evidence = [];
23866
24891
  if (rootFiles.has("package.json")) {
23867
- const pkg = readJsonSafe(path26.join(root, "package.json"));
24892
+ const pkg = readJsonSafe(path27.join(root, "package.json"));
23868
24893
  if (pkg?.workspaces) {
23869
24894
  evidence.push("package.json has workspaces");
23870
24895
  return { shape: "monorepo", evidence };
@@ -23878,13 +24903,13 @@ function detectShape(files, root) {
23878
24903
  evidence.push("workspace manifest found");
23879
24904
  return { shape: "workspace", evidence };
23880
24905
  }
23881
- const cargoToml = readTomlWorkspace(path26.join(root, "Cargo.toml"));
24906
+ const cargoToml = readTomlWorkspace(path27.join(root, "Cargo.toml"));
23882
24907
  if (cargoToml) {
23883
24908
  evidence.push("Cargo.toml has workspace");
23884
24909
  return { shape: "workspace", evidence };
23885
24910
  }
23886
24911
  if (rootFiles.has("package.json")) {
23887
- const pkg = readJsonSafe(path26.join(root, "package.json"));
24912
+ const pkg = readJsonSafe(path27.join(root, "package.json"));
23888
24913
  if (pkg?.exports || pkg?.main) {
23889
24914
  if (pkg?.bin) {
23890
24915
  evidence.push("package.json has bin");
@@ -23918,8 +24943,8 @@ function discoverDocs(files, root) {
23918
24943
  { pattern: /^\.editorconfig$/i, kind: "config" }
23919
24944
  ];
23920
24945
  for (const filePath of files) {
23921
- const basename = path26.basename(filePath).toLowerCase();
23922
- const relPath = path26.relative(root, filePath);
24946
+ const basename = path27.basename(filePath).toLowerCase();
24947
+ const relPath = path27.relative(root, filePath);
23923
24948
  let kind;
23924
24949
  for (const { pattern, kind: k } of docPatterns) {
23925
24950
  if (pattern.test(basename)) {
@@ -23931,7 +24956,7 @@ function discoverDocs(files, root) {
23931
24956
  kind = "docs";
23932
24957
  }
23933
24958
  if (!kind && (basename.endsWith(".md") || basename.endsWith(".mdx"))) {
23934
- if (path26.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
24959
+ if (path27.dirname(relPath) === "." || isUnderDocsDir(relPath)) {
23935
24960
  kind = "docs";
23936
24961
  }
23937
24962
  }
@@ -23952,7 +24977,7 @@ function discoverDocs(files, root) {
23952
24977
  return docs;
23953
24978
  }
23954
24979
  function isUnderDocsDir(relPath) {
23955
- const parts = relPath.split(path26.sep);
24980
+ const parts = relPath.split(path27.sep);
23956
24981
  return parts[0] === "docs" || parts[0] === "doc" || parts[0] === "documentation";
23957
24982
  }
23958
24983
  function buildPlan(languages, shape, docs, _root) {
@@ -23996,7 +25021,7 @@ function readTomlWorkspace(filePath) {
23996
25021
 
23997
25022
  // src/curation/index.ts
23998
25023
  import fs3 from "fs";
23999
- import path27 from "path";
25024
+ import path28 from "path";
24000
25025
  import crypto4 from "crypto";
24001
25026
  async function curate(options) {
24002
25027
  const startTime = Date.now();
@@ -24087,12 +25112,12 @@ function resolveTargets(targetPath) {
24087
25112
  const extensions = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
24088
25113
  function walk(dir) {
24089
25114
  for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
24090
- const fullPath = path27.join(dir, entry.name);
25115
+ const fullPath = path28.join(dir, entry.name);
24091
25116
  if (entry.isDirectory()) {
24092
25117
  if (entry.name !== "node_modules" && entry.name !== ".git") {
24093
25118
  walk(fullPath);
24094
25119
  }
24095
- } else if (extensions.has(path27.extname(entry.name).toLowerCase())) {
25120
+ } else if (extensions.has(path28.extname(entry.name).toLowerCase())) {
24096
25121
  results.push(fullPath);
24097
25122
  }
24098
25123
  }
@@ -24101,12 +25126,12 @@ function resolveTargets(targetPath) {
24101
25126
  return results;
24102
25127
  }
24103
25128
  function resolveProvenanceRoot(targetPath) {
24104
- const resolvedTarget = path27.resolve(targetPath);
25129
+ const resolvedTarget = path28.resolve(targetPath);
24105
25130
  const stat5 = fs3.statSync(resolvedTarget);
24106
- return stat5.isFile() ? path27.dirname(resolvedTarget) : resolvedTarget;
25131
+ return stat5.isFile() ? path28.dirname(resolvedTarget) : resolvedTarget;
24107
25132
  }
24108
25133
  function extractStatements(content, filePath, projectRoot, source, sourceFileHash, categoryOverride, confidence, entityRef, tags) {
24109
- const relativePath = path27.relative(projectRoot, path27.resolve(filePath)) || path27.basename(filePath);
25134
+ const relativePath = path28.relative(projectRoot, path28.resolve(filePath)) || path28.basename(filePath);
24110
25135
  const statements = [];
24111
25136
  const now = (/* @__PURE__ */ new Date()).toISOString();
24112
25137
  const paragraphs = content.split(/\n{2,}/).map((p) => p.trim()).filter((p) => p.length > 20 && p.length < 2e3);
@@ -24200,7 +25225,7 @@ function loadExistingMemories(memoryDir) {
24200
25225
  if (!fs3.existsSync(memoryDir)) return result;
24201
25226
  const dirs = ALL_CATEGORY_DIRS;
24202
25227
  for (const dir of dirs) {
24203
- const fullDir = path27.join(memoryDir, dir);
25228
+ const fullDir = path28.join(memoryDir, dir);
24204
25229
  if (!fs3.existsSync(fullDir)) continue;
24205
25230
  walkFiles(fullDir, (filePath) => {
24206
25231
  const content = readFileSafe(filePath);
@@ -24223,11 +25248,11 @@ function writeStatement(stmt, memoryDir) {
24223
25248
  const now = /* @__PURE__ */ new Date();
24224
25249
  const dateDir = now.toISOString().split("T")[0];
24225
25250
  const categoryDir = getCategoryDir(memoryDir, stmt.category);
24226
- const dir = path27.join(categoryDir, dateDir);
25251
+ const dir = path28.join(categoryDir, dateDir);
24227
25252
  fs3.mkdirSync(dir, { recursive: true });
24228
25253
  const fileName = `${stmt.category}-${Date.now()}-${stmt.id.slice(0, 8)}.md`;
24229
- const filePath = path27.join(dir, fileName);
24230
- const historicalIds = historicalIdCache2.get(path27.join(memoryDir, "state"));
25254
+ const filePath = path28.join(dir, fileName);
25255
+ const historicalIds = historicalIdCache2.get(path28.join(memoryDir, "state"));
24231
25256
  const rawBody = `${[
24232
25257
  "---",
24233
25258
  `id: ${stmt.id}`,
@@ -24250,7 +25275,7 @@ ${stmt.content}
24250
25275
  fs3.writeFileSync(filePath, body);
24251
25276
  try {
24252
25277
  repairContentAfterJournalMoveSync({
24253
- stateDir: path27.join(memoryDir, "state"),
25278
+ stateDir: path28.join(memoryDir, "state"),
24254
25279
  cache: historicalIdCache2,
24255
25280
  idsAtWrite: historicalIds,
24256
25281
  rawContent: rawBody,
@@ -24311,7 +25336,7 @@ function extractBody2(content) {
24311
25336
  }
24312
25337
  function walkFiles(dir, callback) {
24313
25338
  for (const entry of fs3.readdirSync(dir, { withFileTypes: true })) {
24314
- const fullPath = path27.join(dir, entry.name);
25339
+ const fullPath = path28.join(dir, entry.name);
24315
25340
  if (entry.isDirectory()) {
24316
25341
  walkFiles(fullPath, callback);
24317
25342
  } else if (entry.name.endsWith(".md")) {
@@ -24323,7 +25348,7 @@ function walkFiles(dir, callback) {
24323
25348
  // src/dedup/index.ts
24324
25349
  import crypto5 from "crypto";
24325
25350
  import fs4 from "fs";
24326
- import path28 from "path";
25351
+ import path29 from "path";
24327
25352
  var DEFAULT_DEDUP_THRESHOLD = 0.85;
24328
25353
  var DEFAULT_MAX_LOAD = 1e4;
24329
25354
  function normalizeThreshold(value, defaultValue) {
@@ -24530,7 +25555,7 @@ function loadMemories(memoryDir, categories, maxLoad = 1e4) {
24530
25555
  const memoryRootReal = fs4.realpathSync(memoryDir);
24531
25556
  for (const category of allCategories) {
24532
25557
  if (result.length >= maxLoad) break;
24533
- const dir = path28.join(memoryDir, category);
25558
+ const dir = path29.join(memoryDir, category);
24534
25559
  if (!fs4.existsSync(dir)) continue;
24535
25560
  const categoryStat = fs4.lstatSync(dir);
24536
25561
  if (categoryStat.isSymbolicLink()) {
@@ -24591,15 +25616,15 @@ function extractBody3(content) {
24591
25616
  return match ? match[1].trim() : content.trim();
24592
25617
  }
24593
25618
  function assertPathInsideRoot2(rootReal, targetReal, sourcePath) {
24594
- const rel = path28.relative(rootReal, targetReal);
24595
- if (rel === "" || !rel.startsWith("..") && !path28.isAbsolute(rel)) {
25619
+ const rel = path29.relative(rootReal, targetReal);
25620
+ if (rel === "" || !rel.startsWith("..") && !path29.isAbsolute(rel)) {
24596
25621
  return;
24597
25622
  }
24598
25623
  throw new Error(`Refusing to scan memory path outside root: ${sourcePath}`);
24599
25624
  }
24600
25625
  function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
24601
25626
  for (const entry of fs4.readdirSync(dir, { withFileTypes: true })) {
24602
- const fullPath = path28.join(dir, entry.name);
25627
+ const fullPath = path29.join(dir, entry.name);
24603
25628
  const entryStat = fs4.lstatSync(fullPath);
24604
25629
  if (entryStat.isSymbolicLink()) {
24605
25630
  throw new Error(`Refusing to scan symlinked memory path: ${fullPath}`);
@@ -24617,7 +25642,7 @@ function walkMdFiles(dir, memoryRootReal, categoryRootReal, callback) {
24617
25642
 
24618
25643
  // src/sync/index.ts
24619
25644
  import fs5 from "fs";
24620
- import path29 from "path";
25645
+ import path30 from "path";
24621
25646
  import crypto6 from "crypto";
24622
25647
  var DEFAULT_EXTENSIONS = /* @__PURE__ */ new Set([".md", ".txt", ".mdx", ".rst"]);
24623
25648
  var DEFAULT_EXCLUDE2 = /* @__PURE__ */ new Set([
@@ -24639,7 +25664,7 @@ function syncChanges(options) {
24639
25664
  } = options;
24640
25665
  const extSet = new Set(extensions);
24641
25666
  const excludeSet = /* @__PURE__ */ new Set([...DEFAULT_EXCLUDE2, ...excludeDirs]);
24642
- const stateFilePath = options.stateFile ?? path29.join(memoryDir, ".sync-state.json");
25667
+ const stateFilePath = options.stateFile ?? path30.join(memoryDir, ".sync-state.json");
24643
25668
  const prevState = loadState(stateFilePath);
24644
25669
  const currentFiles = scanFiles(sourceDir, extSet, excludeSet);
24645
25670
  const changes = computeDiff(currentFiles, prevState.fileHashes, sourceDir);
@@ -24655,7 +25680,7 @@ function syncChanges(options) {
24655
25680
  for (const [relPath, hash] of Object.entries(currentFiles)) {
24656
25681
  newState.fileHashes[relPath] = hash;
24657
25682
  }
24658
- fs5.mkdirSync(path29.dirname(stateFilePath), { recursive: true });
25683
+ fs5.mkdirSync(path30.dirname(stateFilePath), { recursive: true });
24659
25684
  fs5.writeFileSync(stateFilePath, JSON.stringify(newState, null, 2));
24660
25685
  }
24661
25686
  return {
@@ -24721,13 +25746,13 @@ function scanFiles(root, extensions, exclude) {
24721
25746
  }
24722
25747
  for (const entry of entries) {
24723
25748
  if (exclude.has(entry.name)) continue;
24724
- const fullPath = path29.join(dir, entry.name);
25749
+ const fullPath = path30.join(dir, entry.name);
24725
25750
  if (entry.isDirectory()) {
24726
25751
  walk(fullPath);
24727
25752
  } else if (entry.isFile()) {
24728
- const ext = path29.extname(entry.name).toLowerCase();
25753
+ const ext = path30.extname(entry.name).toLowerCase();
24729
25754
  if (!extensions.has(ext)) continue;
24730
- const relPath = path29.relative(root, fullPath);
25755
+ const relPath = path30.relative(root, fullPath);
24731
25756
  try {
24732
25757
  const content = fs5.readFileSync(fullPath, "utf8");
24733
25758
  result[relPath] = hashContent3(content);
@@ -24742,7 +25767,7 @@ function scanFiles(root, extensions, exclude) {
24742
25767
  function computeDiff(current, previous, sourceDir) {
24743
25768
  const changes = [];
24744
25769
  for (const [relPath, hash] of Object.entries(current)) {
24745
- const fullPath = path29.join(sourceDir, relPath);
25770
+ const fullPath = path30.join(sourceDir, relPath);
24746
25771
  if (!(relPath in previous)) {
24747
25772
  let size = 0;
24748
25773
  try {
@@ -24775,7 +25800,7 @@ function computeDiff(current, previous, sourceDir) {
24775
25800
  for (const relPath of Object.keys(previous)) {
24776
25801
  if (!(relPath in current)) {
24777
25802
  changes.push({
24778
- filePath: path29.join(sourceDir, relPath),
25803
+ filePath: path30.join(sourceDir, relPath),
24779
25804
  relativePath: relPath,
24780
25805
  type: "deleted",
24781
25806
  currentHash: "",
@@ -24805,21 +25830,21 @@ function hashContent3(content) {
24805
25830
  import { spawnSync } from "child_process";
24806
25831
  import crypto7 from "crypto";
24807
25832
  import fs6 from "fs";
24808
- import path30 from "path";
25833
+ import path31 from "path";
24809
25834
  var historicalIdCache3 = new HistoricalEntityCanonicalIdCache();
24810
25835
  var MANIFEST_VERSION = 1;
24811
25836
  var MANIFEST_LOCK_STALE_MS = 3e4;
24812
25837
  var MANIFEST_LOCK_TIMEOUT_MS = MANIFEST_LOCK_STALE_MS + 1e4;
24813
25838
  var MANIFEST_LOCK_SLEEP_MS = 20;
24814
25839
  function normalizeSpaceMemoryDir(memoryDir) {
24815
- return path30.resolve(memoryDir);
25840
+ return path31.resolve(memoryDir);
24816
25841
  }
24817
25842
  function getSpacesDir(baseDir) {
24818
25843
  const homeDir = baseDir ?? resolveHomeDir();
24819
- return path30.join(homeDir, ".config", "engram", "spaces");
25844
+ return path31.join(homeDir, ".config", "engram", "spaces");
24820
25845
  }
24821
25846
  function getManifestPath(baseDir) {
24822
- return path30.join(getSpacesDir(baseDir), "manifest.json");
25847
+ return path31.join(getSpacesDir(baseDir), "manifest.json");
24823
25848
  }
24824
25849
  function loadManifest(baseDir, memoryDirOverride) {
24825
25850
  if (fs6.existsSync(getManifestPath(baseDir))) {
@@ -24866,9 +25891,9 @@ function readManifestUnlocked(baseDir, memoryDirOverride, options = {}) {
24866
25891
  }
24867
25892
  function saveManifestUnlocked(manifest, baseDir) {
24868
25893
  const manifestPath2 = getManifestPath(baseDir);
24869
- const manifestDir2 = path30.dirname(manifestPath2);
25894
+ const manifestDir2 = path31.dirname(manifestPath2);
24870
25895
  fs6.mkdirSync(manifestDir2, { recursive: true });
24871
- const tempPath = path30.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
25896
+ const tempPath = path31.join(manifestDir2, `.manifest.${process.pid}.${Date.now()}.${crypto7.randomUUID()}.tmp`);
24872
25897
  try {
24873
25898
  fs6.writeFileSync(tempPath, `${JSON.stringify(manifest, null, 2)}
24874
25899
  `, { flag: "wx" });
@@ -24883,7 +25908,7 @@ function saveManifestUnlocked(manifest, baseDir) {
24883
25908
  }
24884
25909
  function withManifestLock(baseDir, operation) {
24885
25910
  const lockDir = `${getManifestPath(baseDir)}.lock`;
24886
- fs6.mkdirSync(path30.dirname(lockDir), { recursive: true });
25911
+ fs6.mkdirSync(path31.dirname(lockDir), { recursive: true });
24887
25912
  const lockOwner = acquireManifestLock(lockDir);
24888
25913
  try {
24889
25914
  return operation();
@@ -24909,7 +25934,7 @@ function acquireManifestLock(lockDir) {
24909
25934
  try {
24910
25935
  fs6.mkdirSync(lockDir, { recursive: false });
24911
25936
  try {
24912
- fs6.writeFileSync(path30.join(lockDir, "owner"), `${owner}
25937
+ fs6.writeFileSync(path31.join(lockDir, "owner"), `${owner}
24913
25938
  `, { flag: "wx" });
24914
25939
  } catch (error) {
24915
25940
  fs6.rmSync(lockDir, { recursive: true, force: true });
@@ -24939,7 +25964,7 @@ function acquireManifestLock(lockDir) {
24939
25964
  }
24940
25965
  function releaseManifestLock(lockDir, owner) {
24941
25966
  try {
24942
- const ownerPath = path30.join(lockDir, "owner");
25967
+ const ownerPath = path31.join(lockDir, "owner");
24943
25968
  if (fs6.readFileSync(ownerPath, "utf8").trim() === owner) {
24944
25969
  fs6.rmSync(lockDir, { recursive: true, force: true });
24945
25970
  }
@@ -24955,7 +25980,7 @@ function removeStaleManifestLock(lockDir) {
24955
25980
  try {
24956
25981
  fs6.mkdirSync(reclaimDir, { recursive: false });
24957
25982
  try {
24958
- fs6.writeFileSync(path30.join(reclaimDir, "owner"), `${reclaimOwner}
25983
+ fs6.writeFileSync(path31.join(reclaimDir, "owner"), `${reclaimOwner}
24959
25984
  `, { flag: "wx" });
24960
25985
  } catch (error) {
24961
25986
  fs6.rmSync(reclaimDir, { recursive: true, force: true });
@@ -25030,7 +26055,7 @@ function readManifestLockSnapshot(lockDir) {
25030
26055
  throw error;
25031
26056
  }
25032
26057
  try {
25033
- const owner = fs6.readFileSync(path30.join(lockDir, "owner"), "utf8").trim();
26058
+ const owner = fs6.readFileSync(path31.join(lockDir, "owner"), "utf8").trim();
25034
26059
  return { mtimeMs: stat5.mtimeMs, owner };
25035
26060
  } catch (error) {
25036
26061
  if (error.code === "ENOENT") {
@@ -25102,8 +26127,8 @@ function sleepSync(ms) {
25102
26127
  }
25103
26128
  function createPersonalSpace(baseDir, memoryDirOverride) {
25104
26129
  const homeDir = baseDir ?? resolveHomeDir();
25105
- const standalonePath = path30.join(homeDir, ".engram", "memory");
25106
- const openclawPath = path30.join(homeDir, ".openclaw", "workspace", "memory", "local");
26130
+ const standalonePath = path31.join(homeDir, ".engram", "memory");
26131
+ const openclawPath = path31.join(homeDir, ".openclaw", "workspace", "memory", "local");
25107
26132
  const memoryDir = memoryDirOverride ?? readEnvVar("REMNIC_MEMORY_DIR") ?? readEnvVar("ENGRAM_MEMORY_DIR") ?? (fs6.existsSync(standalonePath) ? standalonePath : fs6.existsSync(openclawPath) ? openclawPath : standalonePath);
25108
26133
  const normalizedMemoryDir = normalizeSpaceMemoryDir(memoryDir);
25109
26134
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -25132,7 +26157,7 @@ function createSpace(options) {
25132
26157
  const id = options.name.toLowerCase().replace(/[^a-z0-9-]/g, "-").replace(/-+/g, "-");
25133
26158
  const now = (/* @__PURE__ */ new Date()).toISOString();
25134
26159
  const memoryDir = normalizeSpaceMemoryDir(
25135
- options.memoryDir ?? path30.join(getSpacesDir(options.baseDir), id, "memory")
26160
+ options.memoryDir ?? path31.join(getSpacesDir(options.baseDir), id, "memory")
25136
26161
  );
25137
26162
  const space = updateManifest(options.baseDir, (manifest) => {
25138
26163
  if (manifest.spaces.some((s) => s.id === id)) {
@@ -25378,14 +26403,14 @@ async function mergeSpaces(sourceSpaceId, targetSpaceId, options) {
25378
26403
  };
25379
26404
  }
25380
26405
  function getAuditLog(baseDir) {
25381
- const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
26406
+ const auditPath = path31.join(getSpacesDir(baseDir), "audit.jsonl");
25382
26407
  if (!fs6.existsSync(auditPath)) return [];
25383
26408
  const lines = fs6.readFileSync(auditPath, "utf8").trim().split("\n");
25384
26409
  return lines.filter((l) => l.trim()).map((l) => JSON.parse(l));
25385
26410
  }
25386
26411
  function appendAudit(entry, baseDir) {
25387
- const auditPath = path30.join(getSpacesDir(baseDir), "audit.jsonl");
25388
- fs6.mkdirSync(path30.dirname(auditPath), { recursive: true });
26412
+ const auditPath = path31.join(getSpacesDir(baseDir), "audit.jsonl");
26413
+ fs6.mkdirSync(path31.dirname(auditPath), { recursive: true });
25389
26414
  const full = {
25390
26415
  id: crypto7.randomUUID(),
25391
26416
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -25406,11 +26431,11 @@ async function copyMemories(sourceDir, targetDir, options) {
25406
26431
  sourceFiles.filter((p) => {
25407
26432
  const rp = safeRealpath(p);
25408
26433
  if (!rp || !isPathInsideRoot(rp, sourceRoot)) return false;
25409
- const rel = path30.relative(sourceRoot, rp);
25410
- const mapped = path30.resolve(targetRoot, rel);
26434
+ const rel = path31.relative(sourceRoot, rp);
26435
+ const mapped = path31.resolve(targetRoot, rel);
25411
26436
  if (!isPathInsideRoot(mapped, targetRoot)) return false;
25412
26437
  return classifyEntityRefWritePath(targetRoot, mapped) === "entity";
25413
- }).map((p) => path30.basename(p, ".md"))
26438
+ }).map((p) => path31.basename(p, ".md"))
25414
26439
  );
25415
26440
  const firstEntityId = sourceEntityIds.values().next().value;
25416
26441
  if (firstEntityId === void 0) {
@@ -25418,7 +26443,7 @@ async function copyMemories(sourceDir, targetDir, options) {
25418
26443
  }
25419
26444
  return withRawEntityPageMutation(
25420
26445
  targetRoot,
25421
- path30.join(targetRoot, "entities", `${firstEntityId}.md`),
26446
+ path31.join(targetRoot, "entities", `${firstEntityId}.md`),
25422
26447
  async () => copyPreparedMemories(
25423
26448
  sourceFiles,
25424
26449
  sourceRoot,
@@ -25445,14 +26470,14 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25445
26470
  continue;
25446
26471
  }
25447
26472
  const content = fs6.readFileSync(sourcePath, "utf8");
25448
- const relativePath = path30.relative(sourceRoot, sourceRealPath);
25449
- const targetPath = path30.resolve(targetRoot, relativePath);
26473
+ const relativePath = path31.relative(sourceRoot, sourceRealPath);
26474
+ const targetPath = path31.resolve(targetRoot, relativePath);
25450
26475
  if (!isPathInsideRoot(targetPath, targetRoot)) {
25451
26476
  skipped++;
25452
26477
  continue;
25453
26478
  }
25454
26479
  const targetKind = classifyEntityRefWritePath(targetRoot, targetPath);
25455
- const idsAtCompare = historicalIdCache3.get(path30.join(targetRoot, "state"));
26480
+ const idsAtCompare = historicalIdCache3.get(path31.join(targetRoot, "state"));
25456
26481
  const sourceRef = targetKind === "memory" ? readEntityRefFromFrontmatter(content) : null;
25457
26482
  const refHasSourceClaimant = sourceRef !== null && sourceEntityIds.has(sourceRef);
25458
26483
  const canonicalContent = targetKind === "memory" && !refHasSourceClaimant ? canonicalizeEntityRefFrontmatter(content, idsAtCompare) : content;
@@ -25479,7 +26504,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25479
26504
  if (fs6.existsSync(targetPath) && !options?.force) {
25480
26505
  const targetContent = fs6.readFileSync(targetPath, "utf8");
25481
26506
  const targetHash = hashContent4(targetContent);
25482
- if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(path30.join(targetRoot, "state")) === idsAtCompare) {
26507
+ if (hashContent4(canonicalContent) === targetHash && historicalIdCache3.get(path31.join(targetRoot, "state")) === idsAtCompare) {
25483
26508
  skipped++;
25484
26509
  continue;
25485
26510
  }
@@ -25495,13 +26520,13 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25495
26520
  continue;
25496
26521
  }
25497
26522
  }
25498
- fs6.mkdirSync(path30.dirname(targetPath), { recursive: true });
25499
- const targetParentRealPath = safeRealpath(path30.dirname(targetPath));
26523
+ fs6.mkdirSync(path31.dirname(targetPath), { recursive: true });
26524
+ const targetParentRealPath = safeRealpath(path31.dirname(targetPath));
25500
26525
  if (!targetParentRealPath || !isPathInsideRoot(targetParentRealPath, targetRoot)) {
25501
26526
  skipped++;
25502
26527
  continue;
25503
26528
  }
25504
- const stateDir = path30.join(targetRoot, "state");
26529
+ const stateDir = path31.join(targetRoot, "state");
25505
26530
  if (targetKind === "memory" && !refHasSourceClaimant) {
25506
26531
  const idsAtWrite = historicalIdCache3.get(stateDir);
25507
26532
  const written = canonicalizeEntityRefFrontmatter(content, idsAtWrite);
@@ -25545,7 +26570,7 @@ function copyPreparedMemories(sourceFiles, sourceRoot, targetRoot, sourceEntityI
25545
26570
  bumpMemoryCorpusVersionForDir(targetRoot);
25546
26571
  }
25547
26572
  if (reconcileNeeded) {
25548
- requestEntityCanonicalIdReconcileSync(path30.join(targetRoot, "state"));
26573
+ requestEntityCanonicalIdReconcileSync(path31.join(targetRoot, "state"));
25549
26574
  }
25550
26575
  return { merged, conflicts, skipped };
25551
26576
  }
@@ -25556,7 +26581,7 @@ function walkMd(dir) {
25556
26581
  const results = [];
25557
26582
  function walk(d) {
25558
26583
  for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
25559
- const fullPath = path30.join(d, entry.name);
26584
+ const fullPath = path31.join(d, entry.name);
25560
26585
  if (entry.isSymbolicLink()) {
25561
26586
  continue;
25562
26587
  }
@@ -25585,8 +26610,8 @@ function safeRealpath(filePath) {
25585
26610
  }
25586
26611
  }
25587
26612
  function isPathInsideRoot(candidatePath, rootPath) {
25588
- const relative = path30.relative(rootPath, candidatePath);
25589
- return relative === "" || !relative.startsWith("..") && !path30.isAbsolute(relative);
26613
+ const relative = path31.relative(rootPath, candidatePath);
26614
+ return relative === "" || !relative.startsWith("..") && !path31.isAbsolute(relative);
25590
26615
  }
25591
26616
  function parseSimpleFrontmatter(content) {
25592
26617
  const match = content.match(/^---\n([\s\S]*?)\n---/);
@@ -25707,7 +26732,7 @@ var REMNIC_RECALL_DECISION_RULES = `## When to Use Recall vs Direct Read
25707
26732
  // src/memory-extension/codex-publisher.ts
25708
26733
  import fs7 from "fs";
25709
26734
  import os from "os";
25710
- import path31 from "path";
26735
+ import path32 from "path";
25711
26736
  var REMNIC_EXTENSION_DIR_NAME = "remnic";
25712
26737
  function resolveEnvHome(env) {
25713
26738
  if (env === void 0) return resolveHomeDir();
@@ -25716,12 +26741,12 @@ function resolveEnvHome(env) {
25716
26741
  function expandTildeWithHome(input, homeDir) {
25717
26742
  if (input === "~") return homeDir;
25718
26743
  if (input.startsWith("~/") || input.startsWith("~\\")) {
25719
- return path31.join(homeDir, input.slice(2));
26744
+ return path32.join(homeDir, input.slice(2));
25720
26745
  }
25721
26746
  return input;
25722
26747
  }
25723
26748
  function normalizeHostRoot(input, homeDir) {
25724
- return path31.resolve(expandTildeWithHome(input.trim(), homeDir));
26749
+ return path32.resolve(expandTildeWithHome(input.trim(), homeDir));
25725
26750
  }
25726
26751
  var CodexMemoryExtensionPublisher = class {
25727
26752
  hostId = "codex";
@@ -25735,12 +26760,12 @@ var CodexMemoryExtensionPublisher = class {
25735
26760
  async resolveExtensionRoot(env) {
25736
26761
  const homeDir = resolveEnvHome(env);
25737
26762
  const codexHomeInput = env === void 0 ? readEnvVar("CODEX_HOME")?.trim() : env.CODEX_HOME?.trim();
25738
- const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path31.resolve(homeDir, ".codex");
25739
- return path31.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
26763
+ const codexHome = codexHomeInput ? normalizeHostRoot(codexHomeInput, homeDir) : path32.resolve(homeDir, ".codex");
26764
+ return path32.join(codexHome, "memories_extensions", REMNIC_EXTENSION_DIR_NAME);
25740
26765
  }
25741
26766
  async isHostAvailable() {
25742
26767
  try {
25743
- const home = readEnvVar("CODEX_HOME")?.trim() || path31.join(resolveHomeDir(), ".codex");
26768
+ const home = readEnvVar("CODEX_HOME")?.trim() || path32.join(resolveHomeDir(), ".codex");
25744
26769
  return fs7.existsSync(home);
25745
26770
  } catch {
25746
26771
  return false;
@@ -25791,7 +26816,7 @@ When running inside the Codex phase-2 consolidation sandbox:
25791
26816
  }
25792
26817
  async publish(ctx) {
25793
26818
  const extensionRoot = await this.resolveExtensionRoot();
25794
- const instructionsPath = path31.join(extensionRoot, "instructions.md");
26819
+ const instructionsPath = path32.join(extensionRoot, "instructions.md");
25795
26820
  const filesWritten = [];
25796
26821
  const skipped = [];
25797
26822
  ctx.log.info(`Publishing Codex memory extension to ${extensionRoot}`);
@@ -26239,9 +27264,9 @@ function serializeTimelineDay(day) {
26239
27264
 
26240
27265
  // src/activity/timeline/corrections.ts
26241
27266
  import { mkdirSync } from "fs";
26242
- import path32 from "path";
27267
+ import path33 from "path";
26243
27268
  function timelineCorrectionDatabasePath(memoryDir) {
26244
- return path32.join(memoryDir, "state", "activity-timeline.sqlite");
27269
+ return path33.join(memoryDir, "state", "activity-timeline.sqlite");
26245
27270
  }
26246
27271
  function rowToCorrection(row) {
26247
27272
  return {
@@ -26257,7 +27282,7 @@ var TimelineCorrectionStore = class _TimelineCorrectionStore {
26257
27282
  this.db = db;
26258
27283
  }
26259
27284
  static open(memoryDir) {
26260
- mkdirSync(path32.join(memoryDir, "state"), { recursive: true });
27285
+ mkdirSync(path33.join(memoryDir, "state"), { recursive: true });
26261
27286
  const db = openBetterSqlite3(timelineCorrectionDatabasePath(memoryDir));
26262
27287
  db.pragma("journal_mode = WAL");
26263
27288
  db.pragma("busy_timeout = 5000");
@@ -26830,9 +27855,9 @@ function buildWeeklyActivitySummary(cards, options) {
26830
27855
  // src/activity/timeline/weekly-persist.ts
26831
27856
  import { randomBytes as randomBytes3 } from "crypto";
26832
27857
  import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "fs";
26833
- import path33 from "path";
27858
+ import path34 from "path";
26834
27859
  var WEEKLY_SNAPSHOT_FORMAT_VERSION = 1;
26835
- var WEEKLY_SNAPSHOT_DIR = path33.join("activity", "weekly");
27860
+ var WEEKLY_SNAPSHOT_DIR = path34.join("activity", "weekly");
26836
27861
  function requireToken(value, name) {
26837
27862
  if (typeof value !== "string" || value.trim().length === 0) {
26838
27863
  throw new TypeError(`${name} must be a non-empty string`);
@@ -26855,8 +27880,8 @@ function weeklySnapshotPath(input) {
26855
27880
  const identity = hashActivityBody(
26856
27881
  `${input.summary.weekStartUtc}\0${input.summary.weekEndUtc}\0${sourceRevision}\0${configHash}`
26857
27882
  );
26858
- return path33.join(
26859
- path33.resolve(memoryDir),
27883
+ return path34.join(
27884
+ path34.resolve(memoryDir),
26860
27885
  WEEKLY_SNAPSHOT_DIR,
26861
27886
  namespaceIdentityToken(namespace),
26862
27887
  `${weekDate}--${identity}.json`
@@ -26886,7 +27911,7 @@ function persistWeeklySnapshot(input) {
26886
27911
  throw error;
26887
27912
  }
26888
27913
  }
26889
- mkdirSync2(path33.dirname(filePath), { recursive: true, mode: 448 });
27914
+ mkdirSync2(path34.dirname(filePath), { recursive: true, mode: 448 });
26890
27915
  const tmpPath = `${filePath}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`;
26891
27916
  writeFileSync(tmpPath, text, { encoding: "utf8", mode: 384 });
26892
27917
  try {
@@ -28464,7 +29489,7 @@ function applyVaultFrontmatter(existingYaml, updates) {
28464
29489
  }
28465
29490
 
28466
29491
  // src/activity/vault-wikilink.ts
28467
- import path34 from "path";
29492
+ import path35 from "path";
28468
29493
  function formatVaultWikilink(notePath) {
28469
29494
  if (typeof notePath !== "string" || notePath.trim().length === 0) {
28470
29495
  throw new RangeError("Vault wikilink path must be a non-empty relative path.");
@@ -28472,7 +29497,7 @@ function formatVaultWikilink(notePath) {
28472
29497
  if (notePath.includes("\n") || notePath.includes("\r")) {
28473
29498
  throw new RangeError("Vault wikilink path must not contain newlines.");
28474
29499
  }
28475
- if (path34.posix.isAbsolute(notePath) || path34.win32.isAbsolute(notePath)) {
29500
+ if (path35.posix.isAbsolute(notePath) || path35.win32.isAbsolute(notePath)) {
28476
29501
  throw new RangeError("Vault wikilink path must be relative; absolute paths are rejected.");
28477
29502
  }
28478
29503
  if (notePath.split(/[\\/]/).some((segment) => segment === "..")) {
@@ -28494,7 +29519,7 @@ function stripVaultMdSuffix(notePath) {
28494
29519
  }
28495
29520
 
28496
29521
  // src/activity/vault-join.ts
28497
- import path35 from "path";
29522
+ import path36 from "path";
28498
29523
  function joinVaultSegments(parts) {
28499
29524
  if (parts.length === 0) {
28500
29525
  throw new RangeError("Vault path parts must be a non-empty list.");
@@ -28509,7 +29534,7 @@ function joinVaultSegments(parts) {
28509
29534
  if (part.includes("\n") || part.includes("\r")) {
28510
29535
  throw new RangeError("Vault path part must not contain a newline.");
28511
29536
  }
28512
- if (path35.posix.isAbsolute(part) || path35.win32.isAbsolute(part)) {
29537
+ if (path36.posix.isAbsolute(part) || path36.win32.isAbsolute(part)) {
28513
29538
  throw new RangeError("Vault path part must be relative.");
28514
29539
  }
28515
29540
  if (part.split("/").includes("..")) {
@@ -28563,8 +29588,8 @@ function planVaultDryRun(inputs) {
28563
29588
 
28564
29589
  // src/session-summaries/index.ts
28565
29590
  import { createHash as createHash10 } from "crypto";
28566
- import { lstat as lstat3, mkdir as mkdir7, readFile as readFile7, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
28567
- import path36 from "path";
29591
+ import { lstat as lstat3, mkdir as mkdir7, readFile as readFile8, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
29592
+ import path37 from "path";
28568
29593
 
28569
29594
  // src/session-summaries/adapters.ts
28570
29595
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
@@ -29069,7 +30094,7 @@ function shortHash(value, length = 16) {
29069
30094
  async function listTranscriptFiles(root, maxFiles) {
29070
30095
  const out = [];
29071
30096
  let truncated = false;
29072
- const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path36.sep}` : entryName;
30097
+ const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path37.sep}` : entryName;
29073
30098
  async function visit(dir) {
29074
30099
  if (truncated) return;
29075
30100
  const entries = (await readdir4(dir, { withFileTypes: true })).sort(
@@ -29079,13 +30104,13 @@ async function listTranscriptFiles(root, maxFiles) {
29079
30104
  if (truncated) return;
29080
30105
  if (entry.name.startsWith(".")) continue;
29081
30106
  if (entry.isSymbolicLink()) continue;
29082
- const fullPath = path36.join(dir, entry.name);
30107
+ const fullPath = path37.join(dir, entry.name);
29083
30108
  if (entry.isDirectory()) {
29084
30109
  await visit(fullPath);
29085
30110
  continue;
29086
30111
  }
29087
30112
  if (!entry.isFile()) continue;
29088
- const ext = path36.extname(entry.name).toLowerCase();
30113
+ const ext = path37.extname(entry.name).toLowerCase();
29089
30114
  if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
29090
30115
  out.push(fullPath);
29091
30116
  if (out.length > maxFiles) {
@@ -29112,7 +30137,7 @@ function normalizeInputDir(inputDir) {
29112
30137
  if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
29113
30138
  throw new Error("inputDir must be a non-empty string");
29114
30139
  }
29115
- return path36.resolve(expandTildePath(inputDir.trim()));
30140
+ return path37.resolve(expandTildePath(inputDir.trim()));
29116
30141
  }
29117
30142
  function initRoleCounts() {
29118
30143
  return {
@@ -29258,7 +30283,7 @@ async function collectLocalSessionSummaries(options) {
29258
30283
  });
29259
30284
  }
29260
30285
  for (const filePath of files) {
29261
- const content = await readFile7(filePath, "utf-8");
30286
+ const content = await readFile8(filePath, "utf-8");
29262
30287
  const fileHash = shortHash(content, 24);
29263
30288
  if (seenFileHashes.has(fileHash)) {
29264
30289
  warnings.push({
@@ -29269,11 +30294,11 @@ async function collectLocalSessionSummaries(options) {
29269
30294
  continue;
29270
30295
  }
29271
30296
  seenFileHashes.add(fileHash);
29272
- const fileExtension = path36.extname(filePath).toLowerCase();
30297
+ const fileExtension = path37.extname(filePath).toLowerCase();
29273
30298
  const parsed = await adapter.parseFile(
29274
30299
  {
29275
30300
  content,
29276
- fileName: path36.basename(filePath),
30301
+ fileName: path37.basename(filePath),
29277
30302
  fileExtension,
29278
30303
  fileRef: fileHash
29279
30304
  },
@@ -29329,7 +30354,7 @@ async function collectLocalSessionSummaries(options) {
29329
30354
  }
29330
30355
  async function readRedactionConfig(pathLike) {
29331
30356
  if (!pathLike) return void 0;
29332
- const raw = await readFile7(path36.resolve(expandTildePath(pathLike)), "utf-8");
30357
+ const raw = await readFile8(path37.resolve(expandTildePath(pathLike)), "utf-8");
29333
30358
  const parsed = JSON.parse(raw);
29334
30359
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
29335
30360
  throw new Error("redaction config must be a JSON object");
@@ -29342,15 +30367,15 @@ function toJsonl(drafts) {
29342
30367
  }
29343
30368
  function defaultDraftOutputPath(memoryDir, generatedAt) {
29344
30369
  const stamp = generatedAt.replace(/[:.]/g, "-");
29345
- return path36.join(
29346
- path36.resolve(expandTildePath(memoryDir)),
30370
+ return path37.join(
30371
+ path37.resolve(expandTildePath(memoryDir)),
29347
30372
  "state",
29348
30373
  "session-summary-drafts",
29349
30374
  `session-summaries-${stamp}.jsonl`
29350
30375
  );
29351
30376
  }
29352
30377
  async function writeDrafts(filePath, drafts) {
29353
- await mkdir7(path36.dirname(filePath), { recursive: true });
30378
+ await mkdir7(path37.dirname(filePath), { recursive: true });
29354
30379
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
29355
30380
  try {
29356
30381
  await writeFile7(tempPath, toJsonl(drafts), "utf-8");
@@ -29368,7 +30393,7 @@ async function runLocalSessionSummaryCliCommand(options) {
29368
30393
  });
29369
30394
  const wroteFiles = [];
29370
30395
  if (options.output) {
29371
- const outputPath = path36.resolve(expandTildePath(options.output));
30396
+ const outputPath = path37.resolve(expandTildePath(options.output));
29372
30397
  await writeDrafts(outputPath, report.drafts);
29373
30398
  wroteFiles.push(outputPath);
29374
30399
  }
@@ -29402,20 +30427,20 @@ async function runLocalSessionSummaryCliCommand(options) {
29402
30427
  }
29403
30428
 
29404
30429
  // src/transfer/capsule-fork.ts
29405
- import { lstat as lstat4, mkdir as mkdir8, readFile as readFile8, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
29406
- import path37 from "path";
30430
+ import { lstat as lstat4, mkdir as mkdir8, readFile as readFile9, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
30431
+ import path38 from "path";
29407
30432
  async function forkCapsule(opts) {
29408
30433
  validateForkId(opts.forkId);
29409
- const rootAbs = path37.resolve(opts.targetRoot);
30434
+ const rootAbs = path38.resolve(opts.targetRoot);
29410
30435
  await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
29411
- const forkDirAbs = path37.join(rootAbs, "forks", opts.forkId);
30436
+ const forkDirAbs = path38.join(rootAbs, "forks", opts.forkId);
29412
30437
  const forkEntryExists = await pathEntryExists(forkDirAbs);
29413
30438
  if (forkEntryExists) {
29414
30439
  throw new Error(
29415
30440
  `forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
29416
30441
  );
29417
30442
  }
29418
- const archiveAbs = path37.resolve(opts.sourceArchive);
30443
+ const archiveAbs = path38.resolve(opts.sourceArchive);
29419
30444
  const importResult = await importCapsule({
29420
30445
  archivePath: archiveAbs,
29421
30446
  root: rootAbs,
@@ -29437,10 +30462,10 @@ async function forkCapsule(opts) {
29437
30462
  importedRecords: importResult.imported.length,
29438
30463
  skippedRecords: importResult.skipped.length
29439
30464
  };
29440
- const lineagePath = path37.join(forkDirAbs, "lineage.json");
30465
+ const lineagePath = path38.join(forkDirAbs, "lineage.json");
29441
30466
  const rootReal = await realpath3(rootAbs);
29442
30467
  await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
29443
- await mkdir8(path37.dirname(lineagePath), { recursive: true });
30468
+ await mkdir8(path38.dirname(lineagePath), { recursive: true });
29444
30469
  await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
29445
30470
  return {
29446
30471
  archivePath: archiveAbs,
@@ -29454,17 +30479,17 @@ async function readForkLineage(targetRoot, forkId) {
29454
30479
  if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
29455
30480
  return null;
29456
30481
  }
29457
- const rootAbs = path37.resolve(targetRoot);
30482
+ const rootAbs = path38.resolve(targetRoot);
29458
30483
  const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
29459
- const lineagePath = path37.join(rootReal, "forks", forkId, "lineage.json");
29460
- const rel = path37.relative(rootReal, lineagePath);
29461
- if (rel.startsWith("..") || path37.isAbsolute(rel)) {
30484
+ const lineagePath = path38.join(rootReal, "forks", forkId, "lineage.json");
30485
+ const rel = path38.relative(rootReal, lineagePath);
30486
+ if (rel.startsWith("..") || path38.isAbsolute(rel)) {
29462
30487
  return null;
29463
30488
  }
29464
30489
  if (!await isLineagePathContained(rootReal, lineagePath)) {
29465
30490
  return null;
29466
30491
  }
29467
- const raw = await readFile8(lineagePath, "utf-8").catch(() => null);
30492
+ const raw = await readFile9(lineagePath, "utf-8").catch(() => null);
29468
30493
  if (raw === null) return null;
29469
30494
  try {
29470
30495
  const parsed = JSON.parse(raw);
@@ -29499,19 +30524,19 @@ async function pathEntryExists(absPath) {
29499
30524
  async function isLineagePathContained(rootReal, lineagePath) {
29500
30525
  let existing = lineagePath;
29501
30526
  const suffix = [];
29502
- while (existing !== path37.dirname(existing)) {
30527
+ while (existing !== path38.dirname(existing)) {
29503
30528
  const st = await lstat4(existing).catch(() => null);
29504
30529
  if (st !== null) break;
29505
- suffix.unshift(path37.basename(existing));
29506
- existing = path37.dirname(existing);
30530
+ suffix.unshift(path38.basename(existing));
30531
+ existing = path38.dirname(existing);
29507
30532
  }
29508
30533
  const existingReal = await realpath3(existing).catch(() => existing);
29509
- const targetReal = suffix.length > 0 ? path37.join(existingReal, ...suffix) : existingReal;
29510
- const rel = path37.relative(rootReal, targetReal);
30534
+ const targetReal = suffix.length > 0 ? path38.join(existingReal, ...suffix) : existingReal;
30535
+ const rel = path38.relative(rootReal, targetReal);
29511
30536
  if (rel === "") return true;
29512
30537
  if (rel === "..") return false;
29513
- if (rel.startsWith(`..${path37.sep}`)) return false;
29514
- if (path37.isAbsolute(rel)) return false;
30538
+ if (rel.startsWith(`..${path38.sep}`)) return false;
30539
+ if (path38.isAbsolute(rel)) return false;
29515
30540
  return true;
29516
30541
  }
29517
30542
 
@@ -29709,4 +30734,4 @@ export {
29709
30734
  blendGraphExpandedRecallScore,
29710
30735
  Orchestrator
29711
30736
  };
29712
- //# sourceMappingURL=chunk-VLAQV4HT.js.map
30737
+ //# sourceMappingURL=chunk-RJYJ7KR7.js.map