@remnic/core 9.69.33 → 9.69.35

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 (766) hide show
  1. package/dist/access-admin-ops-surface.d.ts +14 -11
  2. package/dist/access-admin-ops-surface.js +65 -60
  3. package/dist/access-audit.js +2 -2
  4. package/dist/access-authorization-probe.d.ts +14 -11
  5. package/dist/access-authorization-probe.js +66 -61
  6. package/dist/access-boundary.d.ts +14 -11
  7. package/dist/access-boundary.js +65 -60
  8. package/dist/access-cli.js +137 -133
  9. package/dist/access-cli.js.map +1 -1
  10. package/dist/access-coding-context-resolution.d.ts +3 -1
  11. package/dist/access-coding-context-resolution.js +3 -3
  12. package/dist/access-extraction-force-flush.d.ts +14 -11
  13. package/dist/access-extraction-force-flush.js +65 -60
  14. package/dist/access-health-types.d.ts +3 -1
  15. package/dist/access-http-briefing.d.ts +14 -11
  16. package/dist/access-http-briefing.js +66 -61
  17. package/dist/access-http-lcm-compaction.d.ts +14 -11
  18. package/dist/access-http-lifecycle-flush.d.ts +14 -11
  19. package/dist/access-http-offline-stream.d.ts +14 -11
  20. package/dist/access-http-query.d.ts +4 -2
  21. package/dist/access-http-query.js +67 -62
  22. package/dist/access-http.d.ts +15 -12
  23. package/dist/access-http.js +86 -82
  24. package/dist/access-identity-continuity-surface.d.ts +12 -9
  25. package/dist/access-identity-continuity-surface.js +65 -60
  26. package/dist/access-lcm-surface.d.ts +14 -11
  27. package/dist/access-lcm-surface.js +65 -60
  28. package/dist/access-mcp.d.ts +14 -11
  29. package/dist/access-mcp.js +74 -70
  30. package/dist/access-memory-search-fanout.d.ts +4 -2
  31. package/dist/{access-namespace-preflight-DMR-jOMS.d.ts → access-namespace-preflight-D8qri11P.d.ts} +1 -1
  32. package/dist/access-namespace-preflight.d.ts +5 -3
  33. package/dist/access-namespace-preflight.js +65 -60
  34. package/dist/access-observe-transcript.d.ts +12 -9
  35. package/dist/access-observe-transcript.js +3 -3
  36. package/dist/access-observe-write-surface.d.ts +16 -13
  37. package/dist/access-observe-write-surface.js +65 -60
  38. package/dist/access-offline-manifest.d.ts +48 -11
  39. package/dist/access-offline-manifest.js +18 -16
  40. package/dist/access-operations-batch.js +68 -64
  41. package/dist/access-operations.d.ts +15 -12
  42. package/dist/access-operations.js +73 -69
  43. package/dist/access-recall-concurrency.d.ts +14 -11
  44. package/dist/access-recall-concurrency.js +65 -60
  45. package/dist/access-recall-response.d.ts +14 -11
  46. package/dist/access-recall-response.js +65 -60
  47. package/dist/access-recall-surface.d.ts +14 -11
  48. package/dist/access-recall-surface.js +65 -60
  49. package/dist/access-schema.d.ts +56 -13
  50. package/dist/access-schema.js +15 -1
  51. package/dist/{access-service-CJQoQvRa.d.ts → access-service-CKu5ixg9.d.ts} +52 -50
  52. package/dist/access-service-helpers.d.ts +14 -11
  53. package/dist/access-service.d.ts +14 -11
  54. package/dist/access-service.js +65 -60
  55. package/dist/access-surface-catalog.d.ts +14 -11
  56. package/dist/access-surface-catalog.js +67 -62
  57. package/dist/access-surface-catalog.js.map +1 -1
  58. package/dist/access-wearables-meetings-surface.d.ts +5 -3
  59. package/dist/action-confidence.d.ts +3 -1
  60. package/dist/active-memory-bridge.d.ts +3 -1
  61. package/dist/active-memory-bridge.js +2 -2
  62. package/dist/active-recall.d.ts +3 -1
  63. package/dist/active-recall.js +12 -10
  64. package/dist/active-recall.js.map +1 -1
  65. package/dist/activity/digest.d.ts +3 -1
  66. package/dist/adapters/index.d.ts +46 -1
  67. package/dist/adapters/index.js +10 -6
  68. package/dist/adapters/registry.js +2 -2
  69. package/dist/ambient-provenance.d.ts +3 -1
  70. package/dist/artifact-search.d.ts +3 -1
  71. package/dist/{auto-sync-NSHLUAQI.js → auto-sync-4YFATLFQ.js} +10 -9
  72. package/dist/{auto-sync-NSHLUAQI.js.map → auto-sync-4YFATLFQ.js.map} +1 -1
  73. package/dist/behavior-learner.d.ts +3 -1
  74. package/dist/behavior-signals.d.ts +3 -1
  75. package/dist/bootstrap.d.ts +12 -9
  76. package/dist/briefing-window.d.ts +4 -2
  77. package/dist/briefing.d.ts +4 -2
  78. package/dist/briefing.js +26 -25
  79. package/dist/buffer-surprise-report.d.ts +3 -1
  80. package/dist/buffer-turn-helpers.d.ts +3 -1
  81. package/dist/buffer.d.ts +4 -2
  82. package/dist/buffer.js +11 -10
  83. package/dist/bulk-import/index.d.ts +5 -3
  84. package/dist/calibration.d.ts +3 -1
  85. package/dist/calibration.js +3 -2
  86. package/dist/calibration.js.map +1 -1
  87. package/dist/capabilities.d.ts +3 -1
  88. package/dist/{capsule-merge-IPG4IOFP.js → capsule-merge-ZCXUPLNJ.js} +2 -2
  89. package/dist/{catalog-8O9KY9eA.d.ts → catalog-Bq1AxZwF.d.ts} +1 -1
  90. package/dist/causal-behavior.d.ts +3 -1
  91. package/dist/causal-consolidation.d.ts +3 -1
  92. package/dist/causal-consolidation.js +27 -26
  93. package/dist/causal-consolidation.js.map +1 -1
  94. package/dist/causal-trajectory-graph.d.ts +3 -1
  95. package/dist/{chunk-CDKHKZL5.js → chunk-2524MOWK.js} +2 -2
  96. package/dist/{chunk-HVAEXYPL.js → chunk-255PC37A.js} +47 -25
  97. package/dist/chunk-255PC37A.js.map +1 -0
  98. package/dist/{chunk-2C3S7J2S.js → chunk-2BQ4ZIWC.js} +741 -28
  99. package/dist/chunk-2BQ4ZIWC.js.map +1 -0
  100. package/dist/{chunk-RKBLRTNT.js → chunk-2YLMUME2.js} +2 -2
  101. package/dist/{chunk-QOIOACIE.js → chunk-326KUXIR.js} +15 -648
  102. package/dist/chunk-326KUXIR.js.map +1 -0
  103. package/dist/{chunk-DBQWVT2H.js → chunk-3CBI2ZSA.js} +2 -2
  104. package/dist/{chunk-MWFGUESQ.js → chunk-3FJKJ5UZ.js} +2 -2
  105. package/dist/{chunk-NZXEK3UF.js → chunk-3Q3N35W7.js} +2 -2
  106. package/dist/{chunk-YYGZJPOK.js → chunk-42DJ235G.js} +2 -2
  107. package/dist/{chunk-SO7SV523.js → chunk-4MDKNUV4.js} +1 -1
  108. package/dist/chunk-4MDKNUV4.js.map +1 -0
  109. package/dist/chunk-5HYUUFMQ.js +1280 -0
  110. package/dist/chunk-5HYUUFMQ.js.map +1 -0
  111. package/dist/{chunk-2JVJ7UHC.js → chunk-5JG5EBVL.js} +4 -2
  112. package/dist/chunk-5JG5EBVL.js.map +1 -0
  113. package/dist/{chunk-HV7OY4DM.js → chunk-5VAF4ID4.js} +643 -202
  114. package/dist/chunk-5VAF4ID4.js.map +1 -0
  115. package/dist/{chunk-N7RWREIQ.js → chunk-65RENJGB.js} +6 -1
  116. package/dist/chunk-65RENJGB.js.map +1 -0
  117. package/dist/{chunk-JTH2SE6B.js → chunk-6J6K3STG.js} +8 -8
  118. package/dist/{chunk-H4VH5VIB.js → chunk-776GVKL7.js} +2 -2
  119. package/dist/{chunk-BUTCAMJM.js → chunk-A2YQL2FF.js} +5 -5
  120. package/dist/chunk-A5UQ52YQ.js +211 -0
  121. package/dist/chunk-A5UQ52YQ.js.map +1 -0
  122. package/dist/{chunk-X2NFFBTO.js → chunk-A7GQBJP5.js} +4 -4
  123. package/dist/{chunk-CGC5UQCF.js → chunk-AKE4GGQ3.js} +2 -2
  124. package/dist/{chunk-B325AGLK.js → chunk-AZSKROVQ.js} +2 -2
  125. package/dist/{chunk-I5DZ3WGR.js → chunk-BJETIR53.js} +3 -3
  126. package/dist/{chunk-JT3EB7ZL.js → chunk-BNGHPYZU.js} +5 -5
  127. package/dist/chunk-BRZWWUCJ.js +13 -0
  128. package/dist/{chunk-FYDW33ZB.js.map → chunk-BRZWWUCJ.js.map} +1 -1
  129. package/dist/{chunk-3JVLGJCY.js → chunk-C6KRO3SU.js} +2 -2
  130. package/dist/{chunk-5NANRSCD.js → chunk-CNV2A557.js} +5 -5
  131. package/dist/{chunk-PBGVVDLY.js → chunk-DK4X5B6I.js} +2 -2
  132. package/dist/{chunk-MFDTVQJX.js → chunk-DVOBLPSQ.js} +22 -7
  133. package/dist/chunk-DVOBLPSQ.js.map +1 -0
  134. package/dist/{chunk-N2ZNPHA3.js → chunk-ECKG5WSI.js} +2 -2
  135. package/dist/{chunk-PYLL63BF.js → chunk-EEBQFG5E.js} +9 -9
  136. package/dist/{chunk-ET356KSB.js → chunk-F4TWWUMP.js} +2 -2
  137. package/dist/{chunk-RHQMKJFG.js → chunk-F6IVBYFS.js} +55 -51
  138. package/dist/{chunk-RHQMKJFG.js.map → chunk-F6IVBYFS.js.map} +1 -1
  139. package/dist/{chunk-CLLPJ6QT.js → chunk-FQXJAC3T.js} +2 -2
  140. package/dist/{chunk-JGHXXQ2G.js → chunk-FVJ4D6L7.js} +2 -2
  141. package/dist/{chunk-DD5JFCWM.js → chunk-GCBIXUPT.js} +2 -2
  142. package/dist/{chunk-MN3LK3KN.js → chunk-GLZH5VEN.js} +2 -2
  143. package/dist/{chunk-S7T2TY65.js → chunk-HC4GFLMQ.js} +3 -3
  144. package/dist/{chunk-EQHDH4C2.js → chunk-HUT2JR6I.js} +3 -3
  145. package/dist/{chunk-UUQG7HAD.js → chunk-HXSAWV3A.js} +4 -4
  146. package/dist/{chunk-XXIHX75O.js → chunk-J7PB5UQ4.js} +3 -3
  147. package/dist/{chunk-UGPUYIET.js → chunk-JHZCXUQI.js} +221 -400
  148. package/dist/chunk-JHZCXUQI.js.map +1 -0
  149. package/dist/{chunk-LTIZHLV7.js → chunk-JR6H5CYS.js} +2 -2
  150. package/dist/{chunk-FCSZ4K2X.js → chunk-JR6PP7UM.js} +3 -3
  151. package/dist/{chunk-TCUKRAMK.js → chunk-JRWW7GM6.js} +10 -10
  152. package/dist/{chunk-Q726HSJO.js → chunk-JSRVXI6E.js} +16 -15
  153. package/dist/chunk-JSRVXI6E.js.map +1 -0
  154. package/dist/{chunk-DB5TGMLZ.js → chunk-JZ2CHRLB.js} +6 -4
  155. package/dist/{chunk-DB5TGMLZ.js.map → chunk-JZ2CHRLB.js.map} +1 -1
  156. package/dist/{chunk-JEIXTYVG.js → chunk-L2QLDZJC.js} +46 -17
  157. package/dist/chunk-L2QLDZJC.js.map +1 -0
  158. package/dist/{chunk-PL7FYKHT.js → chunk-L2WQVSKP.js} +2 -2
  159. package/dist/{chunk-JSN44KIB.js → chunk-LEMD7WZJ.js} +9 -9
  160. package/dist/{chunk-VZWXFXLX.js → chunk-LMCD5W5B.js} +2 -2
  161. package/dist/{chunk-7BMXZCOT.js → chunk-LNDLXMH6.js} +3 -3
  162. package/dist/{chunk-3QQTXYZ6.js → chunk-LSLCFCCQ.js} +2 -1
  163. package/dist/chunk-LSLCFCCQ.js.map +1 -0
  164. package/dist/{chunk-EONF76DT.js → chunk-LYDJRF45.js} +2 -2
  165. package/dist/{chunk-MKD3OMPS.js → chunk-M3MYMWXG.js} +2 -2
  166. package/dist/{chunk-VGXM5B4H.js → chunk-MNIPH6LD.js} +2 -2
  167. package/dist/{chunk-A7XEPMQ6.js → chunk-MVAQ2WM3.js} +6 -6
  168. package/dist/chunk-MVAQ2WM3.js.map +1 -0
  169. package/dist/{chunk-6N3TQFZU.js → chunk-NN4JEFON.js} +3 -3
  170. package/dist/chunk-NPNSKE76.js +220 -0
  171. package/dist/chunk-NPNSKE76.js.map +1 -0
  172. package/dist/{chunk-MOZXTRC2.js → chunk-OQ7SSRXP.js} +19 -19
  173. package/dist/{chunk-XU6OEECT.js → chunk-OQQXGYMX.js} +3 -3
  174. package/dist/{chunk-4MHYKEOM.js → chunk-OS2AT2JU.js} +10 -10
  175. package/dist/{chunk-N57A4KPV.js → chunk-P3ONDDIJ.js} +2 -2
  176. package/dist/chunk-PCEYGOSL.js +66 -0
  177. package/dist/chunk-PCEYGOSL.js.map +1 -0
  178. package/dist/{chunk-R3HKWWUB.js → chunk-PHP3MUGF.js} +2 -2
  179. package/dist/{chunk-EEOUMG3J.js → chunk-PWPIERBM.js} +38 -6
  180. package/dist/chunk-PWPIERBM.js.map +1 -0
  181. package/dist/chunk-Q4AUIFUA.js +111 -0
  182. package/dist/chunk-Q4AUIFUA.js.map +1 -0
  183. package/dist/{chunk-P3SB5BNT.js → chunk-QATYVTP7.js} +2 -2
  184. package/dist/{chunk-LSYDG6MJ.js → chunk-QBLDCI6E.js} +2 -2
  185. package/dist/{chunk-KCB7F4J7.js → chunk-QURNMKME.js} +2 -2
  186. package/dist/{chunk-XOVKXJEP.js → chunk-R3TLVTWW.js} +3 -3
  187. package/dist/{chunk-XXE5P6HJ.js → chunk-RRZKTSFG.js} +2 -2
  188. package/dist/{chunk-44T3Y7SZ.js → chunk-RUXPVSML.js} +5 -5
  189. package/dist/{chunk-DCJ3YFIC.js → chunk-S2ULTQZR.js} +2 -2
  190. package/dist/{chunk-H272ZPQ3.js → chunk-SHEHQBCG.js} +124 -23
  191. package/dist/chunk-SHEHQBCG.js.map +1 -0
  192. package/dist/{chunk-EEC4PCG5.js → chunk-SZDLX763.js} +2 -2
  193. package/dist/{chunk-E2ZHGBAK.js → chunk-T2JSUEH6.js} +2 -2
  194. package/dist/{chunk-227UFSEQ.js → chunk-TFA6HPOA.js} +2 -2
  195. package/dist/{chunk-BA6WOZOT.js → chunk-TK4FHQRN.js} +4 -4
  196. package/dist/{chunk-W27OW7AB.js → chunk-TKFSXDOB.js} +2 -2
  197. package/dist/chunk-TLHNF6GA.js +647 -0
  198. package/dist/chunk-TLHNF6GA.js.map +1 -0
  199. package/dist/{chunk-7K5Q6COX.js → chunk-TVVEYCNW.js} +4 -4
  200. package/dist/{chunk-FDLDOEO6.js → chunk-UBG4GAEP.js} +51 -6
  201. package/dist/chunk-UBG4GAEP.js.map +1 -0
  202. package/dist/{chunk-CETXNLEX.js → chunk-UDZYNIDJ.js} +2 -2
  203. package/dist/{chunk-H5AFCNGA.js → chunk-UJX4I26O.js} +2 -2
  204. package/dist/{chunk-E6TDQRF6.js → chunk-UYUCCQ46.js} +2 -2
  205. package/dist/{chunk-BLUYQFRH.js → chunk-VELCIWJZ.js} +15 -11
  206. package/dist/chunk-VELCIWJZ.js.map +1 -0
  207. package/dist/{chunk-OQDPBRQ6.js → chunk-VYXDUPYE.js} +2 -2
  208. package/dist/{chunk-ZG74PWRW.js → chunk-VZAKYDMJ.js} +2 -2
  209. package/dist/chunk-W6IJMWTZ.js +72 -0
  210. package/dist/chunk-W6IJMWTZ.js.map +1 -0
  211. package/dist/{chunk-NB5BCFUY.js → chunk-WHHEPAO3.js} +4 -4
  212. package/dist/{chunk-H3TKENU4.js → chunk-WIKO4SCR.js} +5 -5
  213. package/dist/{chunk-TX2UTLXC.js → chunk-WPDKBUWX.js} +2 -2
  214. package/dist/{chunk-YFLLGRXO.js → chunk-X2QPKLPL.js} +2 -2
  215. package/dist/{chunk-PFFZWDPE.js → chunk-XCOV45MO.js} +3 -3
  216. package/dist/{chunk-5BCNEBEN.js → chunk-XPJNT6PI.js} +4 -4
  217. package/dist/chunk-XW2T4QAW.js +1 -0
  218. package/dist/{chunk-J7HFPA6O.js → chunk-Y63ZFP4X.js} +2 -2
  219. package/dist/{chunk-D223ZDQV.js → chunk-YEDVOYL2.js} +2 -2
  220. package/dist/{chunk-TLPZ6MKZ.js → chunk-YEN4TREG.js} +541 -5
  221. package/dist/chunk-YEN4TREG.js.map +1 -0
  222. package/dist/{chunk-22FVR2KE.js → chunk-YJ6VCDMZ.js} +6 -2
  223. package/dist/chunk-YJ6VCDMZ.js.map +1 -0
  224. package/dist/{chunk-RC5DXXWC.js → chunk-YM7YN37H.js} +2 -2
  225. package/dist/{chunk-BPJNF7J2.js → chunk-YNN26CIZ.js} +2 -2
  226. package/dist/{chunk-VLXBE57O.js → chunk-YVGXH72Y.js} +2 -2
  227. package/dist/{chunk-YQAXP5AC.js → chunk-YXLUTALO.js} +5 -5
  228. package/dist/{chunk-DGGB65KC.js → chunk-Z7ACR6MJ.js} +3 -3
  229. package/dist/{chunk-X35W4S3L.js → chunk-ZBEGS7OB.js} +4 -4
  230. package/dist/{chunk-O75CRYGF.js → chunk-ZEFVK7XC.js} +1 -1
  231. package/dist/chunk-ZEFVK7XC.js.map +1 -0
  232. package/dist/{chunk-XUE46UYW.js → chunk-ZLN7AROH.js} +6 -6
  233. package/dist/{chunk-E6JA6XWY.js → chunk-ZTG4P7NZ.js} +1013 -1317
  234. package/dist/chunk-ZTG4P7NZ.js.map +1 -0
  235. package/dist/{chunk-HK32G473.js → chunk-ZWEZXVYH.js} +2 -2
  236. package/dist/{cli-D57e2Mqt.d.ts → cli-Bk7Ctql4.d.ts} +5 -5
  237. package/dist/cli-fallback.d.ts +11 -4
  238. package/dist/cli-fallback.js +5 -1
  239. package/dist/cli.d.ts +16 -13
  240. package/dist/cli.js +107 -103
  241. package/dist/coding/export-okf-codegraph.d.ts +3 -1
  242. package/dist/coding/export-okf-codegraph.js +32 -30
  243. package/dist/coding/export-okf-codegraph.js.map +1 -1
  244. package/dist/coding/pre-action-gate.d.ts +3 -1
  245. package/dist/compat/checks.js +2 -2
  246. package/dist/compat/codex-cli-fallback.d.ts +1 -1
  247. package/dist/compat/codex-cli-fallback.js +5 -1
  248. package/dist/compat/codex-cli-fallback.js.map +1 -1
  249. package/dist/compounding/engine.d.ts +4 -2
  250. package/dist/compounding/engine.js +27 -26
  251. package/dist/compounding/preference-consolidator.d.ts +3 -1
  252. package/dist/compression-optimizer.d.ts +3 -1
  253. package/dist/config.d.ts +3 -1
  254. package/dist/config.js +12 -10
  255. package/dist/connectors/codex-materialize-runner.d.ts +3 -1
  256. package/dist/connectors/codex-materialize-runner.js +26 -25
  257. package/dist/connectors/codex-materialize.d.ts +3 -1
  258. package/dist/connectors/index.d.ts +3 -1
  259. package/dist/connectors/index.js +28 -27
  260. package/dist/consolidation-provenance-check.d.ts +4 -2
  261. package/dist/consolidation-undo.d.ts +4 -2
  262. package/dist/contradiction/index.d.ts +5 -3
  263. package/dist/contradiction/index.js +5 -5
  264. package/dist/{contradiction-scan-NOYMFG66.js → contradiction-scan-GVD4JJ7B.js} +3 -3
  265. package/dist/converge-config.d.ts +3 -1
  266. package/dist/convergence-refresh.d.ts +4 -2
  267. package/dist/convergence-refresh.js +28 -27
  268. package/dist/conversation-index/backend.d.ts +3 -1
  269. package/dist/conversation-index/backend.js +3 -3
  270. package/dist/conversation-index/chunker.d.ts +3 -1
  271. package/dist/conversation-index/faiss-adapter.d.ts +3 -1
  272. package/dist/conversation-index/faiss-adapter.js +2 -2
  273. package/dist/conversation-index/indexer.d.ts +3 -1
  274. package/dist/conversation-index/search.d.ts +3 -1
  275. package/dist/corpus-watermark.d.ts +3 -1
  276. package/dist/corpus-watermark.js +29 -28
  277. package/dist/cross-lingual-recall.d.ts +3 -1
  278. package/dist/day-summary.d.ts +3 -1
  279. package/dist/deep-recall-http-glue.d.ts +14 -11
  280. package/dist/deep-recall-http-glue.js +12 -2
  281. package/dist/deep-recall-mcp-tools.d.ts +14 -11
  282. package/dist/deep-recall-policy-llm.d.ts +3 -1
  283. package/dist/deep-recall-policy-llm.js +4 -3
  284. package/dist/deep-recall-seeds.d.ts +3 -1
  285. package/dist/delinearize.d.ts +3 -1
  286. package/dist/dependency-propagation-config.d.ts +3 -1
  287. package/dist/{dependency-propagation-delivery-CmniEsUK.d.ts → dependency-propagation-delivery-DLiAtj25.d.ts} +1 -1
  288. package/dist/direct-answer-wiring.d.ts +3 -1
  289. package/dist/direct-answer.d.ts +3 -1
  290. package/dist/embedding-fallback.d.ts +3 -1
  291. package/dist/enrichment/index.d.ts +3 -1
  292. package/dist/entity-origin-fields.d.ts +3 -1
  293. package/dist/entity-retrieval.d.ts +4 -2
  294. package/dist/entity-retrieval.js +26 -25
  295. package/dist/entity-schema.d.ts +3 -1
  296. package/dist/episodic-context.d.ts +3 -1
  297. package/dist/eval-trajectory-contracts.d.ts +3 -1
  298. package/dist/eval-trajectory-store.d.ts +3 -1
  299. package/dist/eval-trajectory.d.ts +3 -1
  300. package/dist/explicit-capture.d.ts +12 -9
  301. package/dist/explicit-capture.js +6 -6
  302. package/dist/external-wiki-access.d.ts +14 -11
  303. package/dist/external-wiki-access.js +66 -61
  304. package/dist/external-wiki-collection-registration.d.ts +3 -1
  305. package/dist/external-wiki-collection.d.ts +3 -1
  306. package/dist/external-wiki-mcp-tools.d.ts +14 -11
  307. package/dist/extraction-error-classification.d.ts +3 -1
  308. package/dist/extraction-faithfulness.d.ts +3 -1
  309. package/dist/extraction-faithfulness.js +4 -3
  310. package/dist/extraction-judge-telemetry.d.ts +3 -1
  311. package/dist/extraction-judge-training.d.ts +3 -1
  312. package/dist/extraction-judge.d.ts +3 -1
  313. package/dist/extraction-judge.js +5 -4
  314. package/dist/extraction-liveness.d.ts +3 -1
  315. package/dist/extraction-normalization.d.ts +3 -1
  316. package/dist/extraction-prompt.d.ts +3 -1
  317. package/dist/extraction-source-grounding-rules.d.ts +3 -1
  318. package/dist/extraction-source-grounding.d.ts +3 -1
  319. package/dist/extraction.d.ts +3 -1
  320. package/dist/extraction.js +38 -36
  321. package/dist/fallback-llm.d.ts +3 -1
  322. package/dist/fallback-llm.js +3 -2
  323. package/dist/{first-start-migration-RC345GPL.js → first-start-migration-L3UFX5CU.js} +3 -3
  324. package/dist/generic-recall-paths-DbitKJI5.d.ts +23 -0
  325. package/dist/graph-append-error.d.ts +3 -1
  326. package/dist/graph-dashboard-diff.d.ts +3 -1
  327. package/dist/graph-dashboard-key.d.ts +3 -1
  328. package/dist/graph-dashboard-parser.d.ts +3 -1
  329. package/dist/graph-edge-reinforcement.d.ts +3 -1
  330. package/dist/graph-jsonl.d.ts +3 -1
  331. package/dist/graph-path-reconstruction.d.ts +3 -1
  332. package/dist/graph-path-scoring.d.ts +3 -1
  333. package/dist/graph-snapshot.d.ts +3 -1
  334. package/dist/graph.d.ts +3 -1
  335. package/dist/harmonic-retrieval.js +2 -2
  336. package/dist/importance.d.ts +3 -1
  337. package/dist/importers/index.d.ts +3 -1
  338. package/dist/importers/test-utils.d.ts +3 -1
  339. package/dist/in-flight-reads.d.ts +3 -1
  340. package/dist/{index-BTAsSkPG.d.ts → index-BINUgPFo.d.ts} +2 -2
  341. package/dist/index.d.ts +303 -245
  342. package/dist/index.js +316 -214
  343. package/dist/intent.d.ts +3 -1
  344. package/dist/lcm/engine.d.ts +3 -1
  345. package/dist/lcm/engine.js +2 -2
  346. package/dist/lcm/index.d.ts +3 -1
  347. package/dist/lcm/index.js +7 -7
  348. package/dist/lcm/tools.d.ts +3 -1
  349. package/dist/lifecycle.d.ts +3 -1
  350. package/dist/live-connectors-runner.d.ts +3 -1
  351. package/dist/local-llm-config.d.ts +26 -0
  352. package/dist/local-llm-config.js +1 -0
  353. package/dist/local-llm.d.ts +5 -1
  354. package/dist/local-llm.js +3 -3
  355. package/dist/local-model-endpoint.d.ts +3 -1
  356. package/dist/location/index.d.ts +5 -3
  357. package/dist/location/index.js +29 -28
  358. package/dist/maintenance/memory-governance.d.ts +3 -1
  359. package/dist/maintenance/memory-governance.js +26 -25
  360. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +4 -2
  361. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +26 -25
  362. package/dist/maintenance/rebuild-memory-projection.d.ts +4 -2
  363. package/dist/maintenance/rebuild-memory-projection.js +27 -26
  364. package/dist/{maintenance-DCvQGTzL.d.ts → maintenance-ag1gYztC.d.ts} +378 -4
  365. package/dist/mcp-memory-inspector-app.d.ts +14 -11
  366. package/dist/memory-action-policy.d.ts +3 -1
  367. package/dist/memory-cache.d.ts +3 -1
  368. package/dist/memory-controller.d.ts +3 -1
  369. package/dist/memory-lifecycle-ledger-utils.d.ts +3 -1
  370. package/dist/memory-projection-store.d.ts +3 -1
  371. package/dist/memory-provenance.d.ts +3 -1
  372. package/dist/memory-snapshot.d.ts +3 -1
  373. package/dist/memory-subject-cli.d.ts +14 -11
  374. package/dist/memory-subject.d.ts +14 -11
  375. package/dist/memory-worth-outcomes.d.ts +4 -2
  376. package/dist/migrate/from-engram.js +2 -2
  377. package/dist/models-json.d.ts +3 -1
  378. package/dist/namespaces/migrate.d.ts +5 -3
  379. package/dist/namespaces/migrate.js +27 -26
  380. package/dist/namespaces/principal.d.ts +3 -1
  381. package/dist/namespaces/search.d.ts +3 -1
  382. package/dist/namespaces/search.js +8 -8
  383. package/dist/namespaces/storage.d.ts +5 -3
  384. package/dist/namespaces/storage.js +26 -25
  385. package/dist/native-knowledge.d.ts +3 -1
  386. package/dist/network/tailscale.js +2 -2
  387. package/dist/offline-sync-impression-drain.d.ts +3 -1
  388. package/dist/offline-sync-impression-drain.js +6 -6
  389. package/dist/operator-doctor-corpus.d.ts +3 -1
  390. package/dist/operator-doctor-corpus.js +30 -29
  391. package/dist/operator-doctor-replica.d.ts +3 -1
  392. package/dist/operator-toolkit.d.ts +5 -3
  393. package/dist/operator-toolkit.js +44 -42
  394. package/dist/orchestration/compression-guideline-coordinator.d.ts +4 -2
  395. package/dist/orchestration/maintenance.d.ts +6 -4
  396. package/dist/orchestration/maintenance.js +44 -39
  397. package/dist/{orchestrator-CvCsp1tz.d.ts → orchestrator-Cf3G-3Ed.d.ts} +17 -29
  398. package/dist/orchestrator.d.ts +12 -9
  399. package/dist/orchestrator.js +141 -135
  400. package/dist/patterns-cli.d.ts +3 -1
  401. package/dist/{pipeline-JAdwKBS7.d.ts → pipeline-AwB03fw_.d.ts} +1 -1
  402. package/dist/policy-runtime.d.ts +3 -1
  403. package/dist/proactive-contention.d.ts +3 -1
  404. package/dist/provenance.d.ts +3 -1
  405. package/dist/{public-http-h-yWu9rj.d.ts → public-http-BetSQn7q.d.ts} +1 -1
  406. package/dist/{qmd-Cvw9RWKr.d.ts → qmd-Bfaydrfm.d.ts} +1 -1
  407. package/dist/qmd-preflight.d.ts +4 -2
  408. package/dist/qmd-recall-cache.d.ts +3 -1
  409. package/dist/qmd.d.ts +4 -2
  410. package/dist/qmd.js +2 -2
  411. package/dist/recall-concurrency-config.d.ts +3 -1
  412. package/dist/recall-disclosure-escalation.d.ts +3 -1
  413. package/dist/recall-explain-renderer.d.ts +3 -1
  414. package/dist/recall-explain-renderer.js +3 -3
  415. package/dist/recall-memory-map.d.ts +3 -1
  416. package/dist/recall-navigate-access.d.ts +3 -1
  417. package/dist/recall-navigate-access.js +2 -2
  418. package/dist/recall-navigate-disclosure.d.ts +3 -1
  419. package/dist/recall-navigate-disclosure.js +1 -1
  420. package/dist/recall-navigate.d.ts +3 -1
  421. package/dist/recall-navigate.js +2 -2
  422. package/dist/recall-planner-llm.d.ts +3 -1
  423. package/dist/recall-planner-llm.js +3 -2
  424. package/dist/recall-planner-llm.js.map +1 -1
  425. package/dist/recall-state-view-admission.d.ts +57 -0
  426. package/dist/recall-state-view-admission.js +39 -0
  427. package/dist/recall-state-view-admission.js.map +1 -0
  428. package/dist/recall-state-view-inject.js +2 -2
  429. package/dist/recall-state-view-render.js +2 -2
  430. package/dist/recall-state-view-widen.d.ts +18 -1
  431. package/dist/recall-state-view-widen.js +2 -2
  432. package/dist/recall-state-view-wire.d.ts +1 -1
  433. package/dist/recall-state-view-wire.js +3 -3
  434. package/dist/recall-state-view.d.ts +1 -0
  435. package/dist/recall-state-view.js +1 -1
  436. package/dist/recall-state.d.ts +3 -1
  437. package/dist/recall-tag-filter.d.ts +3 -1
  438. package/dist/recall-timings.d.ts +3 -1
  439. package/dist/recall-xray-cli.d.ts +3 -1
  440. package/dist/recall-xray-cli.js +4 -4
  441. package/dist/recall-xray-renderer.d.ts +3 -1
  442. package/dist/recall-xray-renderer.js +3 -3
  443. package/dist/recall-xray.d.ts +10 -1
  444. package/dist/recall-xray.js +2 -2
  445. package/dist/reconcile/cursor.d.ts +12 -2
  446. package/dist/reconcile/cursor.js +6 -4
  447. package/dist/reconcile/cursor.js.map +1 -1
  448. package/dist/reconcile/manifest.d.ts +38 -2
  449. package/dist/reconcile/manifest.js +15 -5
  450. package/dist/reconcile/plan.d.ts +3 -1
  451. package/dist/replay/normalizers/chatgpt.d.ts +3 -1
  452. package/dist/replay/normalizers/claude.d.ts +3 -1
  453. package/dist/replay/normalizers/openclaw.d.ts +3 -1
  454. package/dist/replay/normalizers/shared.d.ts +3 -1
  455. package/dist/replay/runner.d.ts +3 -1
  456. package/dist/replay/types.d.ts +3 -1
  457. package/dist/replica-divergence.d.ts +3 -1
  458. package/dist/replica-peers-config.d.ts +3 -1
  459. package/dist/{resolution-VKATP2HT.js → resolution-OHJZG45O.js} +6 -6
  460. package/dist/resolution-OHJZG45O.js.map +1 -0
  461. package/dist/resolve-auth-token.d.ts +3 -1
  462. package/dist/resume-bundles.js +13 -11
  463. package/dist/retrieval-agents.d.ts +4 -2
  464. package/dist/retrieval-tiers.d.ts +3 -1
  465. package/dist/routing/engine.d.ts +3 -1
  466. package/dist/routing/store.d.ts +3 -1
  467. package/dist/runtime/child-process.d.ts +1 -1
  468. package/dist/runtime/child-process.js +1 -1
  469. package/dist/salvage-envelope.d.ts +3 -1
  470. package/dist/salvage-envelope.js +2 -2
  471. package/dist/{scope-profiles-BShpTPeV.d.ts → scope-profiles-nxTKvjE-.d.ts} +1 -1
  472. package/dist/search/embed-helper.d.ts +3 -1
  473. package/dist/search/factory.d.ts +3 -1
  474. package/dist/search/factory.js +7 -7
  475. package/dist/search/index.d.ts +3 -1
  476. package/dist/search/index.js +11 -11
  477. package/dist/search/lancedb-backend.d.ts +3 -1
  478. package/dist/search/meilisearch-backend.d.ts +3 -1
  479. package/dist/search/noop-backend.d.ts +3 -1
  480. package/dist/search/orama-backend.d.ts +3 -1
  481. package/dist/search/port.d.ts +3 -1
  482. package/dist/search/remote-backend.d.ts +3 -1
  483. package/dist/{semantic-consolidation-CusOpe9F.d.ts → semantic-consolidation-C83DVakV.d.ts} +1 -1
  484. package/dist/semantic-consolidation.d.ts +4 -2
  485. package/dist/semantic-consolidation.js +27 -26
  486. package/dist/semantic-rule-promotion.js +26 -25
  487. package/dist/semantic-rule-verifier.d.ts +3 -1
  488. package/dist/semantic-rule-verifier.js +26 -25
  489. package/dist/{service-BbuVh1eS.d.ts → service-q-xtOoAr.d.ts} +2 -2
  490. package/dist/session-observer-bands.d.ts +3 -1
  491. package/dist/session-observer-state.d.ts +3 -1
  492. package/dist/shared-context/manager.d.ts +3 -1
  493. package/dist/signal.d.ts +3 -1
  494. package/dist/source-agent-qualifier.d.ts +3 -1
  495. package/dist/source-agent-qualifier.js +35 -33
  496. package/dist/standup/build.js +26 -25
  497. package/dist/{storage-BBLLuVTF.d.ts → storage-Ca0MbTfm.d.ts} +67 -6
  498. package/dist/storage.d.ts +5 -3
  499. package/dist/storage.js +25 -24
  500. package/dist/subject-config.d.ts +3 -1
  501. package/dist/subject-config.js +2 -2
  502. package/dist/summarizer.d.ts +3 -1
  503. package/dist/summarizer.js +6 -6
  504. package/dist/summary-snapshot.d.ts +3 -1
  505. package/dist/support-passport/index.d.ts +50 -15
  506. package/dist/support-passport/index.js +73 -64
  507. package/dist/temporal-supersession.d.ts +4 -2
  508. package/dist/temporal-timeline-recall.d.ts +3 -1
  509. package/dist/temporal-validity.d.ts +3 -1
  510. package/dist/threading.d.ts +3 -1
  511. package/dist/tier-migration.d.ts +4 -2
  512. package/dist/tier-routing.d.ts +3 -1
  513. package/dist/tier-routing.js +2 -2
  514. package/dist/{tier-stats-KA6OZX2C.js → tier-stats-VK5PCO2L.js} +3 -3
  515. package/dist/topics.d.ts +3 -1
  516. package/dist/transcript.d.ts +3 -1
  517. package/dist/transfer/capsule-import.js +1 -1
  518. package/dist/transfer/export-okf.d.ts +3 -1
  519. package/dist/transfer/export-okf.js +27 -26
  520. package/dist/transfer/types.d.ts +24 -24
  521. package/dist/trust-score-stage.d.ts +3 -1
  522. package/dist/trust-score.d.ts +3 -1
  523. package/dist/{types-igV4-sbB.d.ts → types-yDgWDkrJ.d.ts} +60 -34
  524. package/dist/types.d.ts +3 -1
  525. package/dist/types.js +1 -1
  526. package/dist/utility-runtime.d.ts +3 -1
  527. package/dist/verified-recall.js +26 -25
  528. package/dist/who-knows-cli.d.ts +14 -11
  529. package/dist/who-knows-cli.js +27 -26
  530. package/dist/who-knows.d.ts +14 -11
  531. package/dist/who-knows.js +26 -25
  532. package/dist/write-envelope.d.ts +5 -2
  533. package/dist/write-envelope.js +3 -1
  534. package/package.json +2 -2
  535. package/src/access-category-alias.test.ts +216 -0
  536. package/src/access-mcp.test.ts +73 -0
  537. package/src/access-mcp.ts +6 -6
  538. package/src/access-observe-write-surface.ts +19 -4
  539. package/src/access-offline-manifest.ts +297 -16
  540. package/src/access-recall-surface.ts +5 -5
  541. package/src/access-schema.ts +76 -7
  542. package/src/access-service.ts +11 -2
  543. package/src/activity/config.test.ts +124 -1
  544. package/src/activity/config.ts +150 -18
  545. package/src/activity/index.ts +3 -0
  546. package/src/activity/journal-extract-storage.test.ts +129 -0
  547. package/src/activity/journal-extract.test.ts +314 -0
  548. package/src/activity/journal-extract.ts +247 -0
  549. package/src/activity/journal-heading.test.ts +24 -1
  550. package/src/activity/journal-heading.ts +36 -0
  551. package/src/activity/journal-read.test.ts +242 -0
  552. package/src/activity/journal-read.ts +183 -0
  553. package/src/activity/journal-source.test.ts +15 -15
  554. package/src/activity/journal-source.ts +21 -14
  555. package/src/activity/journal-state.lock-worker.ts +30 -0
  556. package/src/activity/journal-state.test.ts +144 -0
  557. package/src/activity/journal-state.ts +107 -0
  558. package/src/activity/journal-strip.test.ts +106 -52
  559. package/src/activity/journal-strip.ts +35 -10
  560. package/src/activity/journal-vault-integration.test.ts +230 -0
  561. package/src/activity/journal-vault-provenance.test.ts +9 -7
  562. package/src/activity/journal-vault-provenance.ts +4 -10
  563. package/src/activity/journal-vault-read.test.ts +3 -2
  564. package/src/activity/journal-vault-read.ts +9 -139
  565. package/src/activity/journal.test.ts +74 -23
  566. package/src/activity/runner.test.ts +116 -1
  567. package/src/activity/runner.ts +25 -0
  568. package/src/activity/scheduler.ts +4 -0
  569. package/src/activity/store.test.ts +18 -0
  570. package/src/activity/store.ts +14 -0
  571. package/src/activity/sync-registration.ts +4 -0
  572. package/src/activity/timeline/analysis-metadata.ts +2 -0
  573. package/src/activity/timeline/analysis-provider.ts +140 -0
  574. package/src/activity/timeline/analysis-run.test.ts +419 -0
  575. package/src/activity/timeline/analysis-run.ts +106 -0
  576. package/src/activity/timeline/analysis.ts +66 -37
  577. package/src/activity/timeline/corrections.ts +9 -0
  578. package/src/activity/timeline/index.ts +3 -0
  579. package/src/activity/timeline/query.test.ts +71 -0
  580. package/src/activity/timeline/query.ts +57 -8
  581. package/src/activity/timeline/regenerate.test.ts +505 -0
  582. package/src/activity/timeline/regenerate.ts +373 -0
  583. package/src/activity/types.ts +40 -5
  584. package/src/adapters/grok-opencode.test.ts +146 -0
  585. package/src/adapters/grok.ts +53 -0
  586. package/src/adapters/index.ts +2 -0
  587. package/src/adapters/opencode.ts +52 -0
  588. package/src/adapters/registry.ts +4 -0
  589. package/src/cli-fallback.ts +13 -4
  590. package/src/config.test.ts +27 -1
  591. package/src/config.ts +17 -1
  592. package/src/dedup/merge.test.ts +732 -25
  593. package/src/fallback-llm.test.ts +53 -0
  594. package/src/fallback-llm.ts +12 -0
  595. package/src/index.ts +2 -0
  596. package/src/local-llm-config.ts +25 -0
  597. package/src/local-llm.ts +3 -1
  598. package/src/orchestration/dependency-propagation-recovery-replay.ts +1 -1
  599. package/src/orchestration/extraction-persist-deps.ts +9 -0
  600. package/src/orchestration/extraction-persist-promotion.test.ts +265 -6
  601. package/src/orchestration/extraction-persist-promotion.ts +42 -3
  602. package/src/orchestration/extraction-persist.ts +3 -3
  603. package/src/orchestration/harmonic-construction-persist.test.ts +115 -4
  604. package/src/orchestration/harmonic-construction-persist.ts +34 -6
  605. package/src/orchestration/maintenance.ts +1 -0
  606. package/src/orchestration/orchestrator-helpers.ts +6 -0
  607. package/src/orchestration/recall-entry.ts +16 -0
  608. package/src/orchestration/recall-internal-deps.ts +14 -0
  609. package/src/orchestration/recall-internal.ts +41 -58
  610. package/src/orchestration/recall-result-formatter.ts +11 -1
  611. package/src/orchestration/recall-search-pipeline.ts +121 -11
  612. package/src/orchestration/recall-state-view-pipeline.test.ts +211 -0
  613. package/src/orchestration/semantic-merge-commit-effects.ts +76 -17
  614. package/src/orchestration/semantic-merge-persist.ts +121 -16
  615. package/src/orchestration/semantic-merge-promotion-payload.ts +133 -54
  616. package/src/orchestrator.ts +7 -35
  617. package/src/providers/codex-subscription.test.ts +666 -0
  618. package/src/providers/codex-subscription.ts +743 -0
  619. package/src/recall-disclosure.test.ts +20 -0
  620. package/src/recall-state-view-admission.ts +114 -0
  621. package/src/recall-state-view-asof.test.ts +176 -0
  622. package/src/recall-state-view-call.test.ts +175 -0
  623. package/src/recall-state-view-config.test.ts +16 -0
  624. package/src/recall-state-view-widen.test.ts +70 -0
  625. package/src/recall-state-view-widen.ts +28 -7
  626. package/src/recall-state-view-wire.ts +3 -1
  627. package/src/recall-state-view-zero-diff.test.ts +20 -11
  628. package/src/recall-state-view.test.ts +142 -0
  629. package/src/recall-state-view.ts +72 -24
  630. package/src/recall-xray-renderer.test.ts +27 -0
  631. package/src/recall-xray-renderer.ts +4 -0
  632. package/src/recall-xray.ts +13 -0
  633. package/src/reconcile/cursor.ts +23 -33
  634. package/src/reconcile/manifest.ts +96 -11
  635. package/src/reconcile-identity-cache.test.ts +378 -0
  636. package/src/runtime/child-process.ts +1 -1
  637. package/src/storage/cas-revision-host.ts +75 -0
  638. package/src/storage/cas-revision-store.test.ts +459 -0
  639. package/src/storage/cas-revision-store.ts +661 -0
  640. package/src/storage/deletion-revision-store.ts +80 -6
  641. package/src/storage/tombstone-blocked-capture-index.ts +15 -0
  642. package/src/storage/tombstone-blocked-capture-mutation.ts +67 -7
  643. package/src/storage/tombstone-blocked-capture-sync.ts +55 -20
  644. package/src/storage-contract/failure-semantics.test.ts +1 -1
  645. package/src/storage-frontmatter-cas.test.ts +698 -1
  646. package/src/storage-replay.test.ts +166 -3
  647. package/src/storage.ts +41 -41
  648. package/src/support-passport/card-projection.ts +82 -33
  649. package/src/temporal-supersession.test.ts +10 -10
  650. package/src/types.ts +10 -29
  651. package/src/write-envelope.ts +1 -1
  652. package/dist/chunk-22FVR2KE.js.map +0 -1
  653. package/dist/chunk-2C3S7J2S.js.map +0 -1
  654. package/dist/chunk-2JVJ7UHC.js.map +0 -1
  655. package/dist/chunk-2QSZNTDO.js +0 -56
  656. package/dist/chunk-2QSZNTDO.js.map +0 -1
  657. package/dist/chunk-3QQTXYZ6.js.map +0 -1
  658. package/dist/chunk-5VCDKQWQ.js +0 -560
  659. package/dist/chunk-5VCDKQWQ.js.map +0 -1
  660. package/dist/chunk-A7XEPMQ6.js.map +0 -1
  661. package/dist/chunk-BLUYQFRH.js.map +0 -1
  662. package/dist/chunk-E6JA6XWY.js.map +0 -1
  663. package/dist/chunk-EEOUMG3J.js.map +0 -1
  664. package/dist/chunk-FDLDOEO6.js.map +0 -1
  665. package/dist/chunk-FYDW33ZB.js +0 -13
  666. package/dist/chunk-H272ZPQ3.js.map +0 -1
  667. package/dist/chunk-HV7OY4DM.js.map +0 -1
  668. package/dist/chunk-HVAEXYPL.js.map +0 -1
  669. package/dist/chunk-JEIXTYVG.js.map +0 -1
  670. package/dist/chunk-LRICZIGN.js +0 -52
  671. package/dist/chunk-LRICZIGN.js.map +0 -1
  672. package/dist/chunk-MFDTVQJX.js.map +0 -1
  673. package/dist/chunk-N7RWREIQ.js.map +0 -1
  674. package/dist/chunk-O75CRYGF.js.map +0 -1
  675. package/dist/chunk-Q726HSJO.js.map +0 -1
  676. package/dist/chunk-QOIOACIE.js.map +0 -1
  677. package/dist/chunk-SEDEKFYQ.js +0 -1
  678. package/dist/chunk-SO7SV523.js.map +0 -1
  679. package/dist/chunk-TLPZ6MKZ.js.map +0 -1
  680. package/dist/chunk-UGPUYIET.js.map +0 -1
  681. package/src/activity/journal-mode.test.ts +0 -32
  682. package/src/activity/journal-mode.ts +0 -20
  683. /package/dist/{capsule-merge-IPG4IOFP.js.map → capsule-merge-ZCXUPLNJ.js.map} +0 -0
  684. /package/dist/{chunk-CDKHKZL5.js.map → chunk-2524MOWK.js.map} +0 -0
  685. /package/dist/{chunk-RKBLRTNT.js.map → chunk-2YLMUME2.js.map} +0 -0
  686. /package/dist/{chunk-DBQWVT2H.js.map → chunk-3CBI2ZSA.js.map} +0 -0
  687. /package/dist/{chunk-MWFGUESQ.js.map → chunk-3FJKJ5UZ.js.map} +0 -0
  688. /package/dist/{chunk-NZXEK3UF.js.map → chunk-3Q3N35W7.js.map} +0 -0
  689. /package/dist/{chunk-YYGZJPOK.js.map → chunk-42DJ235G.js.map} +0 -0
  690. /package/dist/{chunk-JTH2SE6B.js.map → chunk-6J6K3STG.js.map} +0 -0
  691. /package/dist/{chunk-H4VH5VIB.js.map → chunk-776GVKL7.js.map} +0 -0
  692. /package/dist/{chunk-BUTCAMJM.js.map → chunk-A2YQL2FF.js.map} +0 -0
  693. /package/dist/{chunk-X2NFFBTO.js.map → chunk-A7GQBJP5.js.map} +0 -0
  694. /package/dist/{chunk-CGC5UQCF.js.map → chunk-AKE4GGQ3.js.map} +0 -0
  695. /package/dist/{chunk-B325AGLK.js.map → chunk-AZSKROVQ.js.map} +0 -0
  696. /package/dist/{chunk-I5DZ3WGR.js.map → chunk-BJETIR53.js.map} +0 -0
  697. /package/dist/{chunk-JT3EB7ZL.js.map → chunk-BNGHPYZU.js.map} +0 -0
  698. /package/dist/{chunk-3JVLGJCY.js.map → chunk-C6KRO3SU.js.map} +0 -0
  699. /package/dist/{chunk-5NANRSCD.js.map → chunk-CNV2A557.js.map} +0 -0
  700. /package/dist/{chunk-PBGVVDLY.js.map → chunk-DK4X5B6I.js.map} +0 -0
  701. /package/dist/{chunk-N2ZNPHA3.js.map → chunk-ECKG5WSI.js.map} +0 -0
  702. /package/dist/{chunk-PYLL63BF.js.map → chunk-EEBQFG5E.js.map} +0 -0
  703. /package/dist/{chunk-ET356KSB.js.map → chunk-F4TWWUMP.js.map} +0 -0
  704. /package/dist/{chunk-CLLPJ6QT.js.map → chunk-FQXJAC3T.js.map} +0 -0
  705. /package/dist/{chunk-JGHXXQ2G.js.map → chunk-FVJ4D6L7.js.map} +0 -0
  706. /package/dist/{chunk-DD5JFCWM.js.map → chunk-GCBIXUPT.js.map} +0 -0
  707. /package/dist/{chunk-MN3LK3KN.js.map → chunk-GLZH5VEN.js.map} +0 -0
  708. /package/dist/{chunk-S7T2TY65.js.map → chunk-HC4GFLMQ.js.map} +0 -0
  709. /package/dist/{chunk-EQHDH4C2.js.map → chunk-HUT2JR6I.js.map} +0 -0
  710. /package/dist/{chunk-UUQG7HAD.js.map → chunk-HXSAWV3A.js.map} +0 -0
  711. /package/dist/{chunk-XXIHX75O.js.map → chunk-J7PB5UQ4.js.map} +0 -0
  712. /package/dist/{chunk-LTIZHLV7.js.map → chunk-JR6H5CYS.js.map} +0 -0
  713. /package/dist/{chunk-FCSZ4K2X.js.map → chunk-JR6PP7UM.js.map} +0 -0
  714. /package/dist/{chunk-TCUKRAMK.js.map → chunk-JRWW7GM6.js.map} +0 -0
  715. /package/dist/{chunk-PL7FYKHT.js.map → chunk-L2WQVSKP.js.map} +0 -0
  716. /package/dist/{chunk-JSN44KIB.js.map → chunk-LEMD7WZJ.js.map} +0 -0
  717. /package/dist/{chunk-VZWXFXLX.js.map → chunk-LMCD5W5B.js.map} +0 -0
  718. /package/dist/{chunk-7BMXZCOT.js.map → chunk-LNDLXMH6.js.map} +0 -0
  719. /package/dist/{chunk-EONF76DT.js.map → chunk-LYDJRF45.js.map} +0 -0
  720. /package/dist/{chunk-MKD3OMPS.js.map → chunk-M3MYMWXG.js.map} +0 -0
  721. /package/dist/{chunk-VGXM5B4H.js.map → chunk-MNIPH6LD.js.map} +0 -0
  722. /package/dist/{chunk-6N3TQFZU.js.map → chunk-NN4JEFON.js.map} +0 -0
  723. /package/dist/{chunk-MOZXTRC2.js.map → chunk-OQ7SSRXP.js.map} +0 -0
  724. /package/dist/{chunk-XU6OEECT.js.map → chunk-OQQXGYMX.js.map} +0 -0
  725. /package/dist/{chunk-4MHYKEOM.js.map → chunk-OS2AT2JU.js.map} +0 -0
  726. /package/dist/{chunk-N57A4KPV.js.map → chunk-P3ONDDIJ.js.map} +0 -0
  727. /package/dist/{chunk-R3HKWWUB.js.map → chunk-PHP3MUGF.js.map} +0 -0
  728. /package/dist/{chunk-P3SB5BNT.js.map → chunk-QATYVTP7.js.map} +0 -0
  729. /package/dist/{chunk-LSYDG6MJ.js.map → chunk-QBLDCI6E.js.map} +0 -0
  730. /package/dist/{chunk-KCB7F4J7.js.map → chunk-QURNMKME.js.map} +0 -0
  731. /package/dist/{chunk-XOVKXJEP.js.map → chunk-R3TLVTWW.js.map} +0 -0
  732. /package/dist/{chunk-XXE5P6HJ.js.map → chunk-RRZKTSFG.js.map} +0 -0
  733. /package/dist/{chunk-44T3Y7SZ.js.map → chunk-RUXPVSML.js.map} +0 -0
  734. /package/dist/{chunk-DCJ3YFIC.js.map → chunk-S2ULTQZR.js.map} +0 -0
  735. /package/dist/{chunk-EEC4PCG5.js.map → chunk-SZDLX763.js.map} +0 -0
  736. /package/dist/{chunk-E2ZHGBAK.js.map → chunk-T2JSUEH6.js.map} +0 -0
  737. /package/dist/{chunk-227UFSEQ.js.map → chunk-TFA6HPOA.js.map} +0 -0
  738. /package/dist/{chunk-BA6WOZOT.js.map → chunk-TK4FHQRN.js.map} +0 -0
  739. /package/dist/{chunk-W27OW7AB.js.map → chunk-TKFSXDOB.js.map} +0 -0
  740. /package/dist/{chunk-7K5Q6COX.js.map → chunk-TVVEYCNW.js.map} +0 -0
  741. /package/dist/{chunk-CETXNLEX.js.map → chunk-UDZYNIDJ.js.map} +0 -0
  742. /package/dist/{chunk-H5AFCNGA.js.map → chunk-UJX4I26O.js.map} +0 -0
  743. /package/dist/{chunk-E6TDQRF6.js.map → chunk-UYUCCQ46.js.map} +0 -0
  744. /package/dist/{chunk-OQDPBRQ6.js.map → chunk-VYXDUPYE.js.map} +0 -0
  745. /package/dist/{chunk-ZG74PWRW.js.map → chunk-VZAKYDMJ.js.map} +0 -0
  746. /package/dist/{chunk-NB5BCFUY.js.map → chunk-WHHEPAO3.js.map} +0 -0
  747. /package/dist/{chunk-H3TKENU4.js.map → chunk-WIKO4SCR.js.map} +0 -0
  748. /package/dist/{chunk-TX2UTLXC.js.map → chunk-WPDKBUWX.js.map} +0 -0
  749. /package/dist/{chunk-YFLLGRXO.js.map → chunk-X2QPKLPL.js.map} +0 -0
  750. /package/dist/{chunk-PFFZWDPE.js.map → chunk-XCOV45MO.js.map} +0 -0
  751. /package/dist/{chunk-5BCNEBEN.js.map → chunk-XPJNT6PI.js.map} +0 -0
  752. /package/dist/{chunk-SEDEKFYQ.js.map → chunk-XW2T4QAW.js.map} +0 -0
  753. /package/dist/{chunk-J7HFPA6O.js.map → chunk-Y63ZFP4X.js.map} +0 -0
  754. /package/dist/{chunk-D223ZDQV.js.map → chunk-YEDVOYL2.js.map} +0 -0
  755. /package/dist/{chunk-RC5DXXWC.js.map → chunk-YM7YN37H.js.map} +0 -0
  756. /package/dist/{chunk-BPJNF7J2.js.map → chunk-YNN26CIZ.js.map} +0 -0
  757. /package/dist/{chunk-VLXBE57O.js.map → chunk-YVGXH72Y.js.map} +0 -0
  758. /package/dist/{chunk-YQAXP5AC.js.map → chunk-YXLUTALO.js.map} +0 -0
  759. /package/dist/{chunk-DGGB65KC.js.map → chunk-Z7ACR6MJ.js.map} +0 -0
  760. /package/dist/{chunk-X35W4S3L.js.map → chunk-ZBEGS7OB.js.map} +0 -0
  761. /package/dist/{chunk-XUE46UYW.js.map → chunk-ZLN7AROH.js.map} +0 -0
  762. /package/dist/{chunk-HK32G473.js.map → chunk-ZWEZXVYH.js.map} +0 -0
  763. /package/dist/{contradiction-scan-NOYMFG66.js.map → contradiction-scan-GVD4JJ7B.js.map} +0 -0
  764. /package/dist/{first-start-migration-RC345GPL.js.map → first-start-migration-L3UFX5CU.js.map} +0 -0
  765. /package/dist/{resolution-VKATP2HT.js.map → local-llm-config.js.map} +0 -0
  766. /package/dist/{tier-stats-KA6OZX2C.js.map → tier-stats-VK5PCO2L.js.map} +0 -0
@@ -1,3 +1,9 @@
1
+ import {
2
+ TombstoneStore,
3
+ applyTombstoneResurrectionGate,
4
+ buildRetiredFactTombstoneInputs,
5
+ collectRetiredMemoriesForRebuild
6
+ } from "./chunk-46WM6JX2.js";
1
7
  import {
2
8
  WEARABLES_DIR_NAME,
3
9
  escapeSegmentText,
@@ -9,22 +15,25 @@ import {
9
15
  unescapeSegmentText,
10
16
  unescapeSpeakerLabel
11
17
  } from "./chunk-UHVXE24Y.js";
12
- import {
13
- TombstoneStore,
14
- applyTombstoneResurrectionGate,
15
- buildRetiredFactTombstoneInputs,
16
- collectRetiredMemoriesForRebuild
17
- } from "./chunk-46WM6JX2.js";
18
18
  import {
19
19
  normalizeQmdResultPath
20
- } from "./chunk-J7HFPA6O.js";
20
+ } from "./chunk-Y63ZFP4X.js";
21
21
  import {
22
22
  withholdToolScopedFromSharedNamespace
23
23
  } from "./chunk-S2V7RUCL.js";
24
+ import {
25
+ OKF_QUESTION_TYPE,
26
+ assertNotOkfReservedBasename,
27
+ okfTypeForEntityKind,
28
+ okfTypeForMemory
29
+ } from "./chunk-PCEYGOSL.js";
24
30
  import {
25
31
  SPECULATIVE_TTL_DAYS,
26
32
  confidenceTier
27
- } from "./chunk-SO7SV523.js";
33
+ } from "./chunk-4MDKNUV4.js";
34
+ import {
35
+ createMemorySnapshot
36
+ } from "./chunk-S2HLHAZ4.js";
28
37
  import {
29
38
  normalizeProjectionPreview,
30
39
  normalizeProjectionTags
@@ -33,9 +42,6 @@ import {
33
42
  rewriteProjectedEntityReferences,
34
43
  rewriteProjectedMemoryEntityReference
35
44
  } from "./chunk-MRPOZBJC.js";
36
- import {
37
- createMemorySnapshot
38
- } from "./chunk-S2HLHAZ4.js";
39
45
  import {
40
46
  rotateMarkdownFileToArchive
41
47
  } from "./chunk-DM2T26WE.js";
@@ -51,7 +57,7 @@ import {
51
57
  import {
52
58
  parseFaithfulnessField,
53
59
  serializeFaithfulnessFields
54
- } from "./chunk-DCJ3YFIC.js";
60
+ } from "./chunk-S2ULTQZR.js";
55
61
  import {
56
62
  DeletionRevisionStore,
57
63
  TombstoneBlockedCaptureIndexHost,
@@ -59,9 +65,12 @@ import {
59
65
  buildExplicitCaptureDedupKey,
60
66
  invalidationCommitFingerprint,
61
67
  isQueuedReviewMemory,
68
+ isValidManagedStoragePath,
69
+ nextCasRevisionIso,
62
70
  parseTombstoneBlockedOfflineSyncMemory,
63
- tombstoneBlocked
64
- } from "./chunk-H272ZPQ3.js";
71
+ tombstoneBlocked,
72
+ withCasCommitReceipt
73
+ } from "./chunk-SHEHQBCG.js";
65
74
  import {
66
75
  normalizeEntityName
67
76
  } from "./chunk-YXZG5TVN.js";
@@ -105,11 +114,6 @@ import {
105
114
  normalizeSupersessionKey,
106
115
  supersessionKeysForFact
107
116
  } from "./chunk-5WITETWU.js";
108
- import {
109
- composeMemoryEnvelope,
110
- isSealedMemoryEnvelope,
111
- sealedWriteToLegacyArgs
112
- } from "./chunk-3QQTXYZ6.js";
113
117
  import {
114
118
  clearMemoryCache,
115
119
  getCachedEntities,
@@ -187,6 +191,14 @@ import {
187
191
  isArchivedMemoryPath,
188
192
  toMemoryPathRel
189
193
  } from "./chunk-7RJUVTVF.js";
194
+ import {
195
+ isSupportPassportPrivateMemory
196
+ } from "./chunk-PWPIERBM.js";
197
+ import {
198
+ composeMemoryEnvelope,
199
+ isSealedMemoryEnvelope,
200
+ sealedWriteToLegacyArgs
201
+ } from "./chunk-LSLCFCCQ.js";
190
202
  import {
191
203
  CONTENT_HASH_INDEX_RETRY_MAX_DELAY_MS,
192
204
  ContentHashIndex,
@@ -198,9 +210,6 @@ import {
198
210
  import {
199
211
  withHeldFileLock
200
212
  } from "./chunk-FFAZ2XFU.js";
201
- import {
202
- isSupportPassportPrivateMemory
203
- } from "./chunk-EEOUMG3J.js";
204
213
  import {
205
214
  assemblePersistedBody,
206
215
  storedContentIdentityCandidates,
@@ -252,17 +261,17 @@ import {
252
261
  import {
253
262
  lstat as lstat3,
254
263
  readdir as readdir6,
255
- readFile as readFile2,
264
+ readFile as readFile3,
256
265
  realpath as realpath3,
257
266
  stat as stat3,
258
267
  writeFile as writeFile2,
259
- mkdir,
260
- unlink as unlink4,
268
+ mkdir as mkdir2,
269
+ unlink as unlink5,
261
270
  appendFile,
262
- open
271
+ open as open2
263
272
  } from "fs/promises";
264
273
  import { appendFileSync, createReadStream, mkdirSync, statSync as statSync2 } from "fs";
265
- import { createHash as createHash6 } from "crypto";
274
+ import { createHash as createHash7 } from "crypto";
266
275
 
267
276
  // src/preferences/drift-types.ts
268
277
  function serializeDriftProvenance(fm) {
@@ -1667,59 +1676,6 @@ function extractFrontmatterValue(frontmatter, key) {
1667
1676
  return null;
1668
1677
  }
1669
1678
 
1670
- // src/okf/type-mapping.ts
1671
- import path5 from "path";
1672
- var OKF_TYPE_BY_CATEGORY = Object.freeze({
1673
- fact: "Memory Fact",
1674
- decision: "Decision",
1675
- preference: "Preference",
1676
- commitment: "Commitment",
1677
- relationship: "Relationship",
1678
- principle: "Principle",
1679
- moment: "Moment",
1680
- skill: "Skill",
1681
- correction: "Correction",
1682
- rule: "Rule"
1683
- });
1684
- var OKF_TYPE_FALLBACK = "Memory";
1685
- function okfTypeForCategory(category) {
1686
- return OKF_TYPE_BY_CATEGORY[category] ?? OKF_TYPE_FALLBACK;
1687
- }
1688
- function okfTypeForMemory(fm) {
1689
- return fm.artifactType ? "Artifact" : okfTypeForCategory(fm.category);
1690
- }
1691
- var OKF_TYPE_BY_ENTITY_KIND = Object.freeze({
1692
- person: "Person",
1693
- company: "Company",
1694
- organization: "Organization",
1695
- project: "Project",
1696
- topic: "Topic",
1697
- technology: "Technology",
1698
- place: "Place",
1699
- event: "Event"
1700
- });
1701
- function okfTypeForEntityKind(kind) {
1702
- const normalized = kind?.trim().toLowerCase();
1703
- return normalized !== void 0 && OKF_TYPE_BY_ENTITY_KIND[normalized] || "Entity";
1704
- }
1705
- var OKF_PROFILE_TYPE = "Profile";
1706
- var OKF_QUESTION_TYPE = "Question";
1707
- var OKF_DECISION_RECORD_TYPE = "Decision Record";
1708
- var OKF_ARCHITECTURE_CARD_TYPE = "Architecture Card";
1709
- var OKF_CODE_MODULE_TYPE = "Code Module";
1710
- var OKF_RESERVED_BASENAMES = Object.freeze({
1711
- "index.md": true,
1712
- "log.md": true
1713
- });
1714
- function assertNotOkfReservedBasename(filePath) {
1715
- const basename = path5.basename(filePath);
1716
- if (OKF_RESERVED_BASENAMES[basename] === true) {
1717
- throw new Error(
1718
- `OKF reserved basename '${basename}' is not a valid memory file target (${filePath}); OKF \xA76/\xA77 reserves it for bundle-level files.`
1719
- );
1720
- }
1721
- }
1722
-
1723
1679
  // src/storage/context-transform-ledger.ts
1724
1680
  async function appendContextTransformRecords(host, records) {
1725
1681
  if (records.length === 0) return 0;
@@ -1766,7 +1722,7 @@ function selfDeps(self) {
1766
1722
 
1767
1723
  // src/storage/entity-store.ts
1768
1724
  import { readdir as readdir2, unlink } from "fs/promises";
1769
- import path6 from "path";
1725
+ import path5 from "path";
1770
1726
  var EntityStore = class {
1771
1727
  constructor(deps) {
1772
1728
  this.deps = deps;
@@ -1786,7 +1742,7 @@ var EntityStore = class {
1786
1742
  async readEntityForMutation(name, method, historicalIds) {
1787
1743
  const canonical = resolveHistoricalEntityCanonicalId(name, historicalIds);
1788
1744
  for (const candidate of canonical === name ? [name] : [canonical, name]) {
1789
- const filePath = path6.join(this.deps.entitiesDir, `${candidate}.md`);
1745
+ const filePath = path5.join(this.deps.entitiesDir, `${candidate}.md`);
1790
1746
  try {
1791
1747
  const entity = parseEntityFile(await this.deps.readStorageSecureFile(filePath), this.deps.entitySchemas);
1792
1748
  return { filePath, entity };
@@ -1811,7 +1767,7 @@ var EntityStore = class {
1811
1767
  * `mutate` returns false to skip the write. Resolves true when written.
1812
1768
  */
1813
1769
  async mutateEntityFile(name, method, mutate) {
1814
- const stateDir = path6.join(this.deps.baseDir, "state");
1770
+ const stateDir = path5.join(this.deps.baseDir, "state");
1815
1771
  return withEntityCanonicalMutationLock(stateDir, async () => {
1816
1772
  for (let attempt = 0; attempt < 3; attempt += 1) {
1817
1773
  const idsAtResolve = this.deps.currentHistoricalIds();
@@ -1866,7 +1822,7 @@ var EntityStore = class {
1866
1822
  async writeEntity(name, type, facts, options = {}) {
1867
1823
  await this.deps.ensureDirectories();
1868
1824
  return withEntityCanonicalMutationLock(
1869
- path6.join(this.deps.baseDir, "state"),
1825
+ path5.join(this.deps.baseDir, "state"),
1870
1826
  () => this.writeEntityUnlocked(name, type, facts, options)
1871
1827
  );
1872
1828
  }
@@ -1887,7 +1843,7 @@ var EntityStore = class {
1887
1843
  log.debug(`fuzzy match: "${normalized}" \u2192 existing "${match}"`);
1888
1844
  normalized = match;
1889
1845
  }
1890
- const filePath = path6.join(this.deps.entitiesDir, `${normalized}.md`);
1846
+ const filePath = path5.join(this.deps.entitiesDir, `${normalized}.md`);
1891
1847
  let entity = {
1892
1848
  name,
1893
1849
  type,
@@ -2008,7 +1964,7 @@ var EntityStore = class {
2008
1964
  /** Re-serialize every entity file into the compiled-truth timeline shape. */
2009
1965
  async migrateEntityFilesToCompiledTruthTimeline() {
2010
1966
  const entityNames = await this.listEntityNames();
2011
- const stateDir = path6.join(this.deps.baseDir, "state");
1967
+ const stateDir = path5.join(this.deps.baseDir, "state");
2012
1968
  let migrated = 0;
2013
1969
  for (const entityName of entityNames) {
2014
1970
  const wrote = await withEntityCanonicalMutationLock(stateDir, async () => {
@@ -2035,12 +1991,12 @@ var EntityStore = class {
2035
1991
  */
2036
1992
  async updateEntitySynthesis(name, synthesis, options = {}) {
2037
1993
  return withEntityCanonicalMutationLock(
2038
- path6.join(this.deps.baseDir, "state"),
1994
+ path5.join(this.deps.baseDir, "state"),
2039
1995
  () => this.updateEntitySynthesisUnlocked(name, synthesis, options)
2040
1996
  );
2041
1997
  }
2042
1998
  async updateEntitySynthesisUnlocked(name, synthesis, options = {}) {
2043
- const filePath = path6.join(this.deps.entitiesDir, `${name}.md`);
1999
+ const filePath = path5.join(this.deps.entitiesDir, `${name}.md`);
2044
2000
  let entity;
2045
2001
  try {
2046
2002
  const content = await this.deps.readStorageSecureFile(filePath);
@@ -2098,7 +2054,7 @@ var EntityStore = class {
2098
2054
  const results = await Promise.all(
2099
2055
  batch.map(async (entry) => {
2100
2056
  try {
2101
- return await this.deps.readStorageSecureFile(path6.join(this.deps.entitiesDir, entry));
2057
+ return await this.deps.readStorageSecureFile(path5.join(this.deps.entitiesDir, entry));
2102
2058
  } catch (err) {
2103
2059
  if (err instanceof SecureStoreLockedError) throw err;
2104
2060
  if (!isErrnoCode(err, "ENOENT")) throw err;
@@ -2173,7 +2129,7 @@ ${rows.join("\n")}
2173
2129
  */
2174
2130
  async mergeFragmentedEntities() {
2175
2131
  return withEntityCanonicalMutationLock(
2176
- path6.join(this.deps.baseDir, "state"),
2132
+ path5.join(this.deps.baseDir, "state"),
2177
2133
  () => this.mergeFragmentedEntitiesUnlocked()
2178
2134
  );
2179
2135
  }
@@ -2218,7 +2174,7 @@ ${rows.join("\n")}
2218
2174
  extraSections: []
2219
2175
  };
2220
2176
  for (const file of files) {
2221
- const filePath = path6.join(this.deps.entitiesDir, file);
2177
+ const filePath = path5.join(this.deps.entitiesDir, file);
2222
2178
  try {
2223
2179
  const content = await this.deps.readStorageSecureFile(filePath);
2224
2180
  const parsed = parseEntityFile(content, this.deps.entitySchemas);
@@ -2371,11 +2327,11 @@ ${rows.join("\n")}
2371
2327
  }
2372
2328
  mergedEntity.created = mergedEntity.created || mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2373
2329
  mergedEntity.updated = mergedEntity.updated || (/* @__PURE__ */ new Date()).toISOString();
2374
- const canonicalPath = path6.join(this.deps.entitiesDir, `${canonical}.md`);
2330
+ const canonicalPath = path5.join(this.deps.entitiesDir, `${canonical}.md`);
2375
2331
  await this.deps.writeStorageSecureFile(canonicalPath, serializeEntityFile(mergedEntity, this.deps.entitySchemas, this.deps.okfConformanceEnabled()));
2376
2332
  this.deps.bumpEntityMutationVersion();
2377
2333
  for (const file of files) {
2378
- const filePath = path6.join(this.deps.entitiesDir, file);
2334
+ const filePath = path5.join(this.deps.entitiesDir, file);
2379
2335
  if (filePath !== canonicalPath) {
2380
2336
  try {
2381
2337
  await unlink(filePath);
@@ -2393,6 +2349,494 @@ ${rows.join("\n")}
2393
2349
  }
2394
2350
  };
2395
2351
 
2352
+ // src/storage/cas-revision-store.ts
2353
+ import { createHash, randomUUID } from "crypto";
2354
+ import { mkdir, open, readFile, rename, unlink as unlink2 } from "fs/promises";
2355
+ import path6 from "path";
2356
+ var CAS_REVISION_LOCK_STALE_MS = 6e4;
2357
+ var CAS_REVISION_LOCK_MAX_WAIT_MS = 12e4;
2358
+ var SHA256_HEX = /^[0-9a-f]{64}$/;
2359
+ function isDigestOrNullOrUndefined(value) {
2360
+ if (value === void 0 || value === null) return true;
2361
+ return typeof value === "string" && SHA256_HEX.test(value);
2362
+ }
2363
+ function pendingWriteHasLanded(view) {
2364
+ if (view.writeLanded === true) return true;
2365
+ if (view.writeLanded === false) return false;
2366
+ return view.expectedDigest !== void 0;
2367
+ }
2368
+ var CasRevisionStore = class {
2369
+ baseDir;
2370
+ legacyMetadataPath;
2371
+ constructor(baseDir) {
2372
+ this.baseDir = baseDir;
2373
+ this.legacyMetadataPath = path6.join(baseDir, ".offline-sync", "cas-revisions.v1.json");
2374
+ }
2375
+ parseCasRevisionMetadata(raw) {
2376
+ let parsed;
2377
+ try {
2378
+ parsed = JSON.parse(raw);
2379
+ } catch {
2380
+ throw new Error("CAS revision metadata is invalid.");
2381
+ }
2382
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
2383
+ throw new Error("CAS revision metadata is invalid.");
2384
+ }
2385
+ const root = parsed;
2386
+ if (Object.keys(root).sort().join(",") !== "revisions,version" || root.version !== 1 || !Array.isArray(root.revisions)) {
2387
+ throw new Error("CAS revision metadata is invalid.");
2388
+ }
2389
+ const revisions = /* @__PURE__ */ new Map();
2390
+ for (const rawEntry of root.revisions) {
2391
+ if (!rawEntry || typeof rawEntry !== "object" || Array.isArray(rawEntry)) {
2392
+ throw new Error("CAS revision metadata is invalid.");
2393
+ }
2394
+ const entry = rawEntry;
2395
+ if (Object.keys(entry).sort().join(",") !== "path,revision" || typeof entry.path !== "string" || !isValidManagedStoragePath(entry.path) || typeof entry.revision !== "string" || entry.revision.length === 0 || revisions.has(entry.path)) {
2396
+ throw new Error("CAS revision metadata is invalid.");
2397
+ }
2398
+ revisions.set(entry.path, entry.revision);
2399
+ }
2400
+ return revisions;
2401
+ }
2402
+ async readLegacyMetadata() {
2403
+ const baseDir = path6.resolve(this.baseDir);
2404
+ const legacyPath = await resolveSafeStoragePath(baseDir, path6.relative(baseDir, this.legacyMetadataPath));
2405
+ let raw;
2406
+ try {
2407
+ raw = await readFile(legacyPath, "utf8");
2408
+ } catch (error) {
2409
+ if (isErrnoCode(error, "ENOENT")) return /* @__PURE__ */ new Map();
2410
+ throw new Error("CAS revision metadata is unavailable.");
2411
+ }
2412
+ return this.parseCasRevisionMetadata(raw);
2413
+ }
2414
+ /** #2813 (P1 A): every sidecar path is resolved (and symlink-audited)
2415
+ * inside the memory root before it is used for a lock, read, rename, or
2416
+ * unlink. A symlinked `.offline-sync`, `.offline-sync/cas-revisions`, or
2417
+ * shard file makes this throw, so no sidecar traffic can follow a link
2418
+ * out of the root. */
2419
+ async getSafeShardInfo(relativePath) {
2420
+ const baseDir = path6.resolve(this.baseDir);
2421
+ const hash = createHash("sha256").update(relativePath).digest("hex");
2422
+ const shardPath = await resolveSafeStoragePath(baseDir, ".offline-sync", "cas-revisions", `${hash}.json`);
2423
+ const lockPath2 = await resolveSafeStoragePath(baseDir, ".offline-sync", "cas-revisions", `${hash}.json.lock`);
2424
+ return { shardPath, lockPath: lockPath2 };
2425
+ }
2426
+ async readShardView(shardPath, relativePath) {
2427
+ let raw;
2428
+ try {
2429
+ raw = await readFile(shardPath, "utf8");
2430
+ } catch (error) {
2431
+ if (isErrnoCode(error, "ENOENT")) return { kind: "missing" };
2432
+ throw error;
2433
+ }
2434
+ let parsed;
2435
+ try {
2436
+ parsed = JSON.parse(raw);
2437
+ } catch {
2438
+ throw new Error("CAS revision shard is unreadable.");
2439
+ }
2440
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
2441
+ return { kind: "foreign" };
2442
+ }
2443
+ const root = parsed;
2444
+ if (root.state !== void 0) {
2445
+ if (root.version !== 1 || typeof root.path !== "string" || typeof root.revision !== "string" || root.revision.length === 0 || root.state !== "pending" && root.state !== "committed" || root.previous !== void 0 && (typeof root.previous !== "string" || root.previous.length === 0) || !isDigestOrNullOrUndefined(root.baselineDigest) || !isDigestOrNullOrUndefined(root.expectedDigest) || root.writeLanded !== void 0 && typeof root.writeLanded !== "boolean") {
2446
+ throw new Error("CAS revision shard is unreadable.");
2447
+ }
2448
+ const foreign = root.path !== relativePath;
2449
+ const committedDigest = typeof root.committedDigest === "string" ? root.committedDigest : void 0;
2450
+ return root.state === "pending" ? {
2451
+ kind: "pending",
2452
+ revision: root.revision,
2453
+ previous: root.previous,
2454
+ foreign,
2455
+ baselineDigest: root.baselineDigest,
2456
+ expectedDigest: root.expectedDigest,
2457
+ ...typeof root.writeLanded === "boolean" ? { writeLanded: root.writeLanded } : {}
2458
+ } : { kind: "committed", revision: root.revision, committedDigest, foreign };
2459
+ }
2460
+ if (root.version === 1 && root.path === relativePath && typeof root.revision === "string" && root.revision.length > 0) {
2461
+ const committedDigest = typeof root.committedDigest === "string" ? root.committedDigest : void 0;
2462
+ return { kind: "committed", revision: root.revision, committedDigest, foreign: false };
2463
+ }
2464
+ return { kind: "foreign" };
2465
+ }
2466
+ async readStandingRevision(relativePath) {
2467
+ try {
2468
+ return (await this.readStandingRevisionStrict(relativePath))?.revision;
2469
+ } catch (error) {
2470
+ log.warn(`CasRevisionStore failed to read standing revision for ${relativePath}: ${error}`);
2471
+ return void 0;
2472
+ }
2473
+ }
2474
+ /** #2813 (P1 A): strict core of {@link readStandingRevision}. Returns
2475
+ * undefined ONLY when no receipt exists for the target — the shard is
2476
+ * absent (or names another target) and the legacy metadata holds no
2477
+ * entry. THROWS when the standing receipt cannot be determined: an
2478
+ * unreadable or corrupt shard, a PENDING reservation awaiting
2479
+ * finalization or recovery, or unreadable or invalid legacy metadata.
2480
+ * Fail-open callers collapse the throw into undefined; truthful callers
2481
+ * ({@link readRevisionStatus}) report `unavailable` so a transaction can
2482
+ * refuse instead of mistaking the failure for absence. */
2483
+ async readStandingRevisionStrict(relativePath) {
2484
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2485
+ const view = await this.readShardView(shardPath, relativePath);
2486
+ if (view.kind === "pending") {
2487
+ throw new Error(
2488
+ `CAS revision receipt for ${relativePath} is pending finalization (recovery needed).`
2489
+ );
2490
+ }
2491
+ if (view.kind === "committed" && !view.foreign) {
2492
+ return { revision: view.revision, committedDigest: view.committedDigest };
2493
+ }
2494
+ const legacyMap = await this.readLegacyMetadata();
2495
+ const legacyRev = legacyMap.get(relativePath);
2496
+ return legacyRev === void 0 ? void 0 : { revision: legacyRev };
2497
+ }
2498
+ async writeShard(shardPath, relativePath, revision, lock, state, previous, evidence) {
2499
+ let payload;
2500
+ if (state === "committed") {
2501
+ payload = { version: 1, path: relativePath, revision, state };
2502
+ if (evidence?.committedDigest !== void 0) {
2503
+ payload.committedDigest = evidence.committedDigest;
2504
+ }
2505
+ } else {
2506
+ payload = { version: 1, path: relativePath, revision, state };
2507
+ if (previous !== void 0) payload.previous = previous;
2508
+ if (evidence !== void 0) {
2509
+ if (evidence.baselineDigest !== void 0) payload.baselineDigest = evidence.baselineDigest;
2510
+ if (evidence.expectedDigest !== void 0) payload.expectedDigest = evidence.expectedDigest;
2511
+ if (evidence.writeLanded !== void 0) payload.writeLanded = evidence.writeLanded;
2512
+ }
2513
+ }
2514
+ const baseDir = path6.resolve(this.baseDir);
2515
+ const temporaryPath = await resolveSafeStoragePath(
2516
+ baseDir,
2517
+ path6.relative(baseDir, `${shardPath}.${process.pid}.${randomUUID()}.tmp`)
2518
+ );
2519
+ let handle = null;
2520
+ try {
2521
+ await mkdir(path6.dirname(shardPath), { recursive: true });
2522
+ handle = await open(temporaryPath, "wx", 384);
2523
+ await handle.writeFile(`${JSON.stringify(payload)}
2524
+ `, "utf8");
2525
+ await handle.sync();
2526
+ await handle.close();
2527
+ handle = null;
2528
+ if (!await lock.refresh()) {
2529
+ throw new Error("CAS revision shard lock was lost.");
2530
+ }
2531
+ await rename(temporaryPath, shardPath);
2532
+ } finally {
2533
+ if (handle !== null) {
2534
+ await handle.close().catch((error) => {
2535
+ log.warn("failed to close CAS revision shard temporary file", error);
2536
+ });
2537
+ }
2538
+ await unlink2(temporaryPath).catch((error) => {
2539
+ if (!isErrnoCode(error, "ENOENT")) {
2540
+ log.warn("failed to clean up CAS revision shard temporary file", error);
2541
+ }
2542
+ });
2543
+ }
2544
+ }
2545
+ async resolveRelativePath(filePath) {
2546
+ const baseDir = path6.resolve(this.baseDir);
2547
+ const target = await resolveSafeStoragePath(baseDir, path6.relative(baseDir, path6.resolve(baseDir, filePath)));
2548
+ return path6.relative(baseDir, target).split(path6.sep).join("/");
2549
+ }
2550
+ async withShardLock(relativePath, task) {
2551
+ const { lockPath: lockPath2 } = await this.getSafeShardInfo(relativePath);
2552
+ return await withHeldFileLock(
2553
+ lockPath2,
2554
+ { staleMs: CAS_REVISION_LOCK_STALE_MS, maxWaitMs: CAS_REVISION_LOCK_MAX_WAIT_MS },
2555
+ async (acquired, lock) => {
2556
+ if (!acquired) throw new Error("CAS revision lock is unavailable.");
2557
+ return await task(lock);
2558
+ }
2559
+ );
2560
+ }
2561
+ /** The target's standing revision token, or undefined when no receipt was
2562
+ * ever minted for it. Fail-open on storage/read errors. */
2563
+ async readRevision(filePath) {
2564
+ try {
2565
+ const relativePath = await this.resolveRelativePath(filePath);
2566
+ return await this.readStandingRevision(relativePath);
2567
+ } catch (error) {
2568
+ log.warn(`CasRevisionStore.readRevision failed for ${filePath}: ${error}`);
2569
+ return void 0;
2570
+ }
2571
+ }
2572
+ /** #2813 (P1 A): the truthful standing-receipt read. `absent` means no
2573
+ * receipt was ever minted for the target — undefined semantics stay
2574
+ * correct for those records. `unavailable` means the sidecar could not
2575
+ * be read OR a reservation is pending finalization; callers that
2576
+ * transact on receipt identity MUST refuse rather than treat the
2577
+ * failure as absence. */
2578
+ async readRevisionStatus(filePath) {
2579
+ try {
2580
+ const relativePath = await this.resolveRelativePath(filePath);
2581
+ const standing = await this.readStandingRevisionStrict(relativePath);
2582
+ return standing === void 0 ? { status: "absent" } : {
2583
+ status: "present",
2584
+ revision: standing.revision,
2585
+ ...standing.committedDigest !== void 0 ? { committedDigest: standing.committedDigest } : {}
2586
+ };
2587
+ } catch (error) {
2588
+ return { status: "unavailable", reason: error instanceof Error ? error.message : String(error) };
2589
+ }
2590
+ }
2591
+ /** #2813 (P1 C): reserve the NEXT revision token as a durable PENDING
2592
+ * marker under the target's shard lock — the write-ahead record of a
2593
+ * receipt transaction. The token is strictly greater than the standing
2594
+ * token (max(clock, prev + 1ms)), so two commits can never share a
2595
+ * receipt — not within one millisecond, not across a backward clock
2596
+ * step. Refuses while another reservation is pending (recovery needed)
2597
+ * or the standing receipt cannot be determined. The caller MUST either
2598
+ * `commit` after its durable write lands or `abort` when it fails.
2599
+ * #2807: the marker records the reserve-time fingerprint (`baselineDigest`)
2600
+ * and optional expected post-write fingerprint (`expectedDigest`) with
2601
+ * `writeLanded: false`. {@link recoverPendingRevision} decides crashes
2602
+ * before or after the memory write from that evidence. */
2603
+ async beginRevisionTransaction(filePath, expectedContent) {
2604
+ const relativePath = await this.resolveRelativePath(filePath);
2605
+ return await this.withShardLock(relativePath, async (lock) => {
2606
+ const standingInfo = await this.readStandingRevisionStrict(relativePath);
2607
+ const standing = standingInfo?.revision;
2608
+ const next = nextCasRevisionIso(standing);
2609
+ const baselineDigest = await this.digestDurableFile(relativePath);
2610
+ const expectedDigest = expectedContent != null ? this.digestContent(expectedContent) : void 0;
2611
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2612
+ await this.writeShard(shardPath, relativePath, next, lock, "pending", standing, {
2613
+ baselineDigest,
2614
+ ...expectedDigest !== void 0 ? { expectedDigest } : {},
2615
+ writeLanded: false
2616
+ });
2617
+ return {
2618
+ pendingRevision: next,
2619
+ writeLanded: () => this.recordPendingWriteLanded(relativePath, next),
2620
+ commit: () => this.finalizeRevisionTransaction(relativePath, next, "commit"),
2621
+ abort: () => this.finalizeRevisionTransaction(relativePath, next, "abort")
2622
+ };
2623
+ });
2624
+ }
2625
+ digestContent(content) {
2626
+ const bytes = typeof content === "string" ? Buffer.from(content, "utf8") : content;
2627
+ return createHash("sha256").update(bytes).digest("hex");
2628
+ }
2629
+ async digestDurableFile(filePath) {
2630
+ const relativePath = await this.resolveRelativePath(filePath);
2631
+ const baseDir = path6.resolve(this.baseDir);
2632
+ const target = await resolveSafeStoragePath(baseDir, relativePath);
2633
+ let bytes;
2634
+ try {
2635
+ bytes = await readFile(target);
2636
+ } catch (error) {
2637
+ if (isErrnoCode(error, "ENOENT")) return null;
2638
+ throw new Error(
2639
+ `CAS revision evidence: durable memory file ${relativePath} is unreadable: ${error instanceof Error ? error.message : String(error)}`
2640
+ );
2641
+ }
2642
+ return createHash("sha256").update(bytes).digest("hex");
2643
+ }
2644
+ /** #2807: mark the reserved write as landed. Verifies a pre-recorded
2645
+ * expected digest against the durable file, or records the file digest
2646
+ * when none was reserved. Sets `writeLanded: true`. Idempotent. */
2647
+ async recordPendingWriteLanded(relativePath, token) {
2648
+ await this.withShardLock(relativePath, async (lock) => {
2649
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2650
+ const view = await this.readShardView(shardPath, relativePath);
2651
+ if (view.kind !== "pending" || view.foreign || view.revision !== token) {
2652
+ throw new Error(
2653
+ `CAS revision evidence recording refused for ${relativePath}: the pending marker does not match the reserved token.`
2654
+ );
2655
+ }
2656
+ if (pendingWriteHasLanded(view) && view.writeLanded !== false) return;
2657
+ const currentDigest = await this.digestDurableFile(relativePath);
2658
+ if (view.expectedDigest !== void 0 && currentDigest !== view.expectedDigest) {
2659
+ throw new Error(
2660
+ `CAS revision evidence recording refused for ${relativePath}: the durable file does not match the reserved expected digest.`
2661
+ );
2662
+ }
2663
+ await this.writeShard(shardPath, relativePath, token, lock, "pending", view.previous, {
2664
+ baselineDigest: view.baselineDigest === void 0 ? null : view.baselineDigest,
2665
+ expectedDigest: view.expectedDigest !== void 0 ? view.expectedDigest : currentDigest,
2666
+ writeLanded: true
2667
+ });
2668
+ });
2669
+ }
2670
+ async finalizeRevisionTransaction(relativePath, token, outcome) {
2671
+ await this.withShardLock(relativePath, async (lock) => {
2672
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2673
+ const view = await this.readShardView(shardPath, relativePath);
2674
+ if (view.kind === "pending" && !view.foreign && view.revision === token) {
2675
+ if (outcome === "commit") {
2676
+ const committedDigest = view.expectedDigest ?? await this.digestDurableFile(relativePath);
2677
+ await this.writeShard(shardPath, relativePath, token, lock, "committed", void 0, {
2678
+ committedDigest
2679
+ });
2680
+ } else if (view.previous !== void 0) {
2681
+ await this.writeShard(shardPath, relativePath, view.previous, lock, "committed");
2682
+ } else {
2683
+ await unlink2(shardPath);
2684
+ }
2685
+ return;
2686
+ }
2687
+ if (outcome === "commit" && view.kind === "committed" && !view.foreign && view.revision === token) {
2688
+ return;
2689
+ }
2690
+ if (outcome === "abort" && view.kind === "missing") {
2691
+ return;
2692
+ }
2693
+ throw new Error(
2694
+ `CAS revision transaction ${outcome} refused for ${relativePath}: the pending marker does not match the reserved token.`
2695
+ );
2696
+ });
2697
+ }
2698
+ /** #2813 (P1 C): recovery for a reservation left PENDING by a crash or a
2699
+ * failed publication. The caller supplies the KNOWN outcome of the
2700
+ * durable memory write: `fileWriteLanded` publishes the pending token as
2701
+ * the COMMITTED receipt; otherwise the reservation is discarded and the
2702
+ * previous standing token restored. Idempotent — an already-committed or
2703
+ * absent shard is reported, not mutated. */
2704
+ async reconcilePendingRevision(filePath, fileWriteLanded) {
2705
+ const relativePath = await this.resolveRelativePath(filePath);
2706
+ return await this.withShardLock(relativePath, async (lock) => {
2707
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2708
+ const view = await this.readShardView(shardPath, relativePath);
2709
+ if (view.kind === "committed") return "committed";
2710
+ if (view.kind !== "pending") return "absent";
2711
+ if (view.foreign) {
2712
+ throw new Error(
2713
+ `CAS revision pending marker for ${relativePath} names another target; manual recovery is required.`
2714
+ );
2715
+ }
2716
+ if (fileWriteLanded) {
2717
+ const committedDigest = view.expectedDigest ?? await this.digestDurableFile(relativePath);
2718
+ await this.writeShard(shardPath, relativePath, view.revision, lock, "committed", void 0, {
2719
+ committedDigest
2720
+ });
2721
+ } else if (view.previous !== void 0) {
2722
+ await this.writeShard(shardPath, relativePath, view.previous, lock, "committed");
2723
+ } else {
2724
+ await unlink2(shardPath);
2725
+ }
2726
+ return "reconciled";
2727
+ });
2728
+ }
2729
+ /** #2807 (P1): evidence-based recovery for a reservation left PENDING by
2730
+ * a crash between reserve and finalize. Under the shard lock, the durable
2731
+ * file's current fingerprint is compared against the marker:
2732
+ * - matches `expectedDigest` → publish the pending token as COMMITTED;
2733
+ * - matches `baselineDigest` (including both absent) → abort and restore;
2734
+ * - anything else THROWS. Recovery never guesses.
2735
+ *
2736
+ * `onlyWithWriteEvidence` is the unlocked read path. A marker whose write
2737
+ * has not landed (`writeLanded` false, or legacy with no expectedDigest)
2738
+ * may belong to a live writer, so it returns `reserved`. A landed marker
2739
+ * whose file no longer matches `expectedDigest` throws ambiguity. */
2740
+ async recoverPendingRevision(filePath, options) {
2741
+ const relativePath = await this.resolveRelativePath(filePath);
2742
+ return await this.withShardLock(relativePath, async (lock) => {
2743
+ const { shardPath } = await this.getSafeShardInfo(relativePath);
2744
+ const view = await this.readShardView(shardPath, relativePath);
2745
+ if (view.kind === "missing" || view.kind === "foreign") return "absent";
2746
+ if (view.kind === "committed") return view.foreign ? "absent" : "committed";
2747
+ if (view.foreign) {
2748
+ throw new Error(
2749
+ `CAS revision pending marker for ${relativePath} names another target; manual recovery is required.`
2750
+ );
2751
+ }
2752
+ const currentDigest = await this.digestDurableFile(relativePath);
2753
+ const landed = pendingWriteHasLanded(view);
2754
+ if (options?.onlyWithWriteEvidence && !landed) {
2755
+ return "reserved";
2756
+ }
2757
+ if (view.expectedDigest !== void 0 && currentDigest === view.expectedDigest) {
2758
+ await this.writeShard(shardPath, relativePath, view.revision, lock, "committed", void 0, {
2759
+ committedDigest: view.expectedDigest
2760
+ });
2761
+ return "committed";
2762
+ }
2763
+ if (options?.onlyWithWriteEvidence) {
2764
+ const evidence2 = view.expectedDigest === void 0 ? "the pending marker carries no crash evidence (written by an older version)" : "the durable file matches neither the expected commit fingerprint nor the reserve-time baseline";
2765
+ throw new Error(
2766
+ `CAS revision recovery for ${relativePath} is ambiguous: ${evidence2} (pending token ${view.revision}${view.previous !== void 0 ? `, previous ${view.previous}` : ""}). Inspect the durable file and the shard at ${shardPath}, then run reconcilePendingRevision with the known write outcome. Refusing to guess.`
2767
+ );
2768
+ }
2769
+ if (view.baselineDigest !== void 0 && currentDigest === view.baselineDigest) {
2770
+ if (view.previous !== void 0) {
2771
+ await this.writeShard(shardPath, relativePath, view.previous, lock, "committed");
2772
+ } else {
2773
+ await unlink2(shardPath);
2774
+ }
2775
+ return "aborted";
2776
+ }
2777
+ const evidence = view.baselineDigest === void 0 && view.expectedDigest === void 0 ? "the pending marker carries no crash evidence (written by an older version)" : "the durable file matches neither the expected commit fingerprint nor the reserve-time baseline";
2778
+ throw new Error(
2779
+ `CAS revision recovery for ${relativePath} is ambiguous: ${evidence} (pending token ${view.revision}${view.previous !== void 0 ? `, previous ${view.previous}` : ""}). Inspect the durable file and the shard at ${shardPath}, then run reconcilePendingRevision with the known write outcome. Refusing to guess.`
2780
+ );
2781
+ });
2782
+ }
2783
+ };
2784
+
2785
+ // src/storage/cas-revision-host.ts
2786
+ var CasRevisionHost = class extends CasRevisionStore {
2787
+ /** Standing CAS revision token — receipt identity, never public `updated` (#2807). Fail-open on read errors. */
2788
+ async readCasRevision(filePath) {
2789
+ try {
2790
+ return await this.readRevision(filePath);
2791
+ } catch (err) {
2792
+ log.warn(`storage.readCasRevision failed for ${filePath}: ${err}`);
2793
+ return void 0;
2794
+ }
2795
+ }
2796
+ /** #2813 (P1 A): truthful CAS receipt probe — distinguishes a genuinely
2797
+ * ABSENT receipt (target predates the sidecar; `undefined` semantics stay
2798
+ * correct) from an UNAVAILABLE one (unreadable shard: receipt identity is
2799
+ * unknown). Transactional callers that must refuse on unknown identity
2800
+ * route here; `readCasRevision` stays fail-open for advisory reads.
2801
+ * #2807 (P1): a PENDING marker left by a crash is lazily recovered on
2802
+ * this first read when its evidence is decisive; a reserve-only marker
2803
+ * may belong to a live writer and defers to the path-locked write path,
2804
+ * and ambiguity stays `unavailable` with an actionable reason. */
2805
+ async readCasRevisionStatus(filePath) {
2806
+ const status = await this.readRevisionStatus(filePath);
2807
+ if (status.status !== "unavailable" || !/pending/i.test(status.reason)) return status;
2808
+ try {
2809
+ const outcome = await this.recoverPendingRevision(filePath, {
2810
+ onlyWithWriteEvidence: true
2811
+ });
2812
+ if (outcome === "reserved") return status;
2813
+ } catch (error) {
2814
+ return {
2815
+ status: "unavailable",
2816
+ reason: error instanceof Error ? error.message : String(error)
2817
+ };
2818
+ }
2819
+ return await this.readRevisionStatus(filePath);
2820
+ }
2821
+ async readDurableFileDigest(filePath) {
2822
+ try {
2823
+ return await this.digestDurableFile(filePath);
2824
+ } catch (err) {
2825
+ log.warn(`storage.readDurableFileDigest failed for ${filePath}: ${err}`);
2826
+ return null;
2827
+ }
2828
+ }
2829
+ /** #2807 (P1): reconcile any crash-orphaned PENDING marker for this
2830
+ * target BEFORE the next semantic mutation reserves a new token —
2831
+ * otherwise a crashed reservation would make the memory permanently
2832
+ * unwritable. Decisive evidence heals; ambiguity throws so the
2833
+ * mutation fails closed with the actionable recovery error. */
2834
+ async beginRevision(pathname, expectedContent) {
2835
+ await this.recoverPendingRevision(pathname);
2836
+ return await this.beginRevisionTransaction(pathname, expectedContent);
2837
+ }
2838
+ };
2839
+
2396
2840
  // src/storage/identity-continuity-store.ts
2397
2841
  import { readdir as readdir3 } from "fs/promises";
2398
2842
  import path7 from "path";
@@ -2549,16 +2993,16 @@ var IdentityContinuityStore = class {
2549
2993
  };
2550
2994
 
2551
2995
  // src/storage/entity-canonical-id-migration.ts
2552
- import { createHash, randomUUID } from "crypto";
2996
+ import { createHash as createHash2, randomUUID as randomUUID2 } from "crypto";
2553
2997
  import {
2554
2998
  access,
2555
2999
  lstat as lstat2,
2556
- readFile,
3000
+ readFile as readFile2,
2557
3001
  readdir as readdir4,
2558
3002
  realpath as realpath2,
2559
- rename,
3003
+ rename as rename2,
2560
3004
  stat as statFile,
2561
- unlink as unlink2,
3005
+ unlink as unlink3,
2562
3006
  writeFile
2563
3007
  } from "fs/promises";
2564
3008
  import path8 from "path";
@@ -2600,7 +3044,7 @@ async function fingerprintEntityEntries(entitiesDir) {
2600
3044
  if (isErrnoCode(error, "ENOENT")) return "missing";
2601
3045
  throw error;
2602
3046
  }
2603
- const hash = createHash("sha256");
3047
+ const hash = createHash2("sha256");
2604
3048
  for (const name of names) {
2605
3049
  hash.update(`${name.length}:${name}:`);
2606
3050
  try {
@@ -2720,7 +3164,7 @@ async function readState(deps) {
2720
3164
  await assertSafeMigrationStateFile(deps);
2721
3165
  let raw;
2722
3166
  try {
2723
- raw = await readFile(statePath(deps), "utf-8");
3167
+ raw = await readFile2(statePath(deps), "utf-8");
2724
3168
  } catch (error) {
2725
3169
  if (isErrnoCode(error, "ENOENT")) return null;
2726
3170
  throw error;
@@ -2743,13 +3187,13 @@ async function readState(deps) {
2743
3187
  }
2744
3188
  async function writeState(deps, state) {
2745
3189
  const destination = statePath(deps);
2746
- const temporary = `${destination}.${process.pid}.${randomUUID()}.tmp`;
3190
+ const temporary = `${destination}.${process.pid}.${randomUUID2()}.tmp`;
2747
3191
  try {
2748
3192
  await writeFile(temporary, `${JSON.stringify(state, null, 2)}
2749
3193
  `, "utf-8");
2750
- await rename(temporary, destination);
3194
+ await rename2(temporary, destination);
2751
3195
  } finally {
2752
- await unlink2(temporary).catch(() => void 0);
3196
+ await unlink3(temporary).catch(() => void 0);
2753
3197
  }
2754
3198
  }
2755
3199
  async function publishState(deps, state) {
@@ -3142,7 +3586,7 @@ async function migrateEntityFilePair(deps, legacyId, canonicalId, refreshMigrati
3142
3586
  await deps.snapshotBeforeWrite(legacyPath, "write");
3143
3587
  await assertNotSymlink(legacyPath, legacyId);
3144
3588
  await assertEntityContentUnchanged(deps, legacyPath, legacyContent, legacyId);
3145
- await unlink2(legacyPath);
3589
+ await unlink3(legacyPath);
3146
3590
  return { deferred: false, progressed: true };
3147
3591
  }
3148
3592
  if (!legacyExists) return { deferred: false, progressed: false };
@@ -3166,13 +3610,13 @@ async function migrateEntityFilePair(deps, legacyId, canonicalId, refreshMigrati
3166
3610
  await deps.snapshotBeforeWrite(legacyPath, "write");
3167
3611
  await assertNotSymlink(legacyPath, legacyId);
3168
3612
  await assertEntityContentUnchanged(deps, legacyPath, entityContent, legacyId);
3169
- await unlink2(legacyPath);
3613
+ await unlink3(legacyPath);
3170
3614
  } catch (error) {
3171
3615
  if (!canonicalExists && canonicalFingerprintAfterWrite !== null) {
3172
3616
  try {
3173
3617
  if (await fingerprintPath(canonicalPath) === canonicalFingerprintAfterWrite) {
3174
3618
  await assertNotSymlink(canonicalPath, canonicalId);
3175
- await unlink2(canonicalPath);
3619
+ await unlink3(canonicalPath);
3176
3620
  }
3177
3621
  } catch {
3178
3622
  }
@@ -3198,7 +3642,7 @@ async function migrateLegacyEntityCanonicalIds(deps) {
3198
3642
  let reconcileRequested = await fileExists(consumingMarkerPath);
3199
3643
  if (await fileExists(reconcileMarkerPath)) {
3200
3644
  try {
3201
- await rename(reconcileMarkerPath, consumingMarkerPath);
3645
+ await rename2(reconcileMarkerPath, consumingMarkerPath);
3202
3646
  reconcileRequested = true;
3203
3647
  } catch (error) {
3204
3648
  if (!isErrnoCode(error, "ENOENT")) throw error;
@@ -3221,7 +3665,7 @@ async function migrateLegacyEntityCanonicalIds(deps) {
3221
3665
  );
3222
3666
  }
3223
3667
  if (reconcileRequested) {
3224
- await unlink2(consumingMarkerPath).catch((error) => {
3668
+ await unlink3(consumingMarkerPath).catch((error) => {
3225
3669
  if (!isErrnoCode(error, "ENOENT")) throw error;
3226
3670
  });
3227
3671
  }
@@ -3367,7 +3811,7 @@ async function migrateLegacyEntityCanonicalIds(deps) {
3367
3811
  }
3368
3812
 
3369
3813
  // src/storage/entity-ref-repair.ts
3370
- import { unlink as unlink3 } from "fs/promises";
3814
+ import { unlink as unlink4 } from "fs/promises";
3371
3815
  var EntityRefRepair = class {
3372
3816
  constructor(deps) {
3373
3817
  this.deps = deps;
@@ -3429,7 +3873,7 @@ ${body}
3429
3873
  if (opts.onFailRestore) {
3430
3874
  await this.restore(opts.onFailRestore);
3431
3875
  } else if (opts.onFailRemove) {
3432
- await unlink3(opts.onFailRemove).catch(() => void 0);
3876
+ await unlink4(opts.onFailRemove).catch(() => void 0);
3433
3877
  this.deps.invalidateAllMemoriesCache();
3434
3878
  }
3435
3879
  throw err;
@@ -4522,7 +4966,7 @@ function collectSpeakers(tagged) {
4522
4966
  }
4523
4967
 
4524
4968
  // src/wearables/fusion/fuse.ts
4525
- import { createHash as createHash2 } from "crypto";
4969
+ import { createHash as createHash3 } from "crypto";
4526
4970
  var FUSION_ID_PREFIX = "fusion";
4527
4971
  var FUSION_ALGO_VERSION = "2026-07-12-1";
4528
4972
  function canonicalInputsKey(date, inputs) {
@@ -4551,7 +4995,7 @@ function canonicalInputsKey(date, inputs) {
4551
4995
  ])
4552
4996
  ])
4553
4997
  ];
4554
- return createHash2("sha256").update(JSON.stringify(record), "utf-8").digest("hex");
4998
+ return createHash3("sha256").update(JSON.stringify(record), "utf-8").digest("hex");
4555
4999
  }
4556
5000
  function configFingerprint(options, sources) {
4557
5001
  const proximityGapMs = options.proximityGapMs ?? DEFAULT_PROXIMITY_GAP_MS;
@@ -4566,7 +5010,7 @@ function canonicalDayKey(date, inputs, options, algoVersion = FUSION_ALGO_VERSIO
4566
5010
  options,
4567
5011
  inputs.map((conv) => conv.source)
4568
5012
  );
4569
- return createHash2("sha256").update(inputsKey).update("\n").update(fingerprint).update("\n").update(algoVersion).digest("hex");
5013
+ return createHash3("sha256").update(inputsKey).update("\n").update(fingerprint).update("\n").update(algoVersion).digest("hex");
4570
5014
  }
4571
5015
  function buildProvenance(cluster, proximityGapMs, windowToleranceMs) {
4572
5016
  return {
@@ -4626,11 +5070,11 @@ function fuseDay(date, inputs, options = {}) {
4626
5070
  }
4627
5071
 
4628
5072
  // src/wearables/fusion/store.ts
4629
- import { createHash as createHash3 } from "crypto";
5073
+ import { createHash as createHash4 } from "crypto";
4630
5074
  import * as path11 from "path";
4631
5075
  var FUSION_KIND = "wearable-fusion";
4632
5076
  function hashFusionBody(conversations) {
4633
- return createHash3("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
5077
+ return createHash4("sha256").update(JSON.stringify(conversations), "utf-8").digest("hex");
4634
5078
  }
4635
5079
  function composeFusionDayMeta(date, conversations, sources, contentHash, fusedAt) {
4636
5080
  return {
@@ -5047,7 +5491,7 @@ function reconstructFusionInputs(date, dayTranscripts) {
5047
5491
  }
5048
5492
 
5049
5493
  // src/meetings/store.ts
5050
- import { createHash as createHash4 } from "crypto";
5494
+ import { createHash as createHash5 } from "crypto";
5051
5495
  import * as path12 from "path";
5052
5496
  var MEETINGS_DIR_NAME = "meetings";
5053
5497
  var MEETING_KIND = "meeting";
@@ -5078,7 +5522,7 @@ function canonicalContent(base, fused) {
5078
5522
  });
5079
5523
  }
5080
5524
  function composeMeetingRecord(base, fused) {
5081
- const contentHash = createHash4("sha256").update(canonicalContent(base, fused), "utf-8").digest("hex");
5525
+ const contentHash = createHash5("sha256").update(canonicalContent(base, fused), "utf-8").digest("hex");
5082
5526
  return {
5083
5527
  ...base,
5084
5528
  ...fused,
@@ -5485,7 +5929,7 @@ Reason: ${reason}`;
5485
5929
  }
5486
5930
 
5487
5931
  // src/storage/entity-timeline.ts
5488
- import { createHash as createHash5 } from "crypto";
5932
+ import { createHash as createHash6 } from "crypto";
5489
5933
  var ENTITY_TIMELINE_METADATA_MARKER = "remnic-meta-v1";
5490
5934
  function parseEntityTimelineBullet(bullet, fallbackTimestamp) {
5491
5935
  const trimmed = bullet.trim();
@@ -5927,7 +6371,7 @@ function fingerprintEntityStructuredFacts(entity) {
5927
6371
  (left, right) => left.key.localeCompare(right.key) || left.title.localeCompare(right.title) || left.facts.join("\n").localeCompare(right.facts.join("\n"))
5928
6372
  );
5929
6373
  if (normalizedSections.length === 0) return void 0;
5930
- return createHash5("sha256").update(JSON.stringify(normalizedSections)).digest("hex");
6374
+ return createHash6("sha256").update(JSON.stringify(normalizedSections)).digest("hex");
5931
6375
  }
5932
6376
  function isEntitySynthesisStale(entity) {
5933
6377
  const structuredFactCount = countEntityStructuredFacts(entity);
@@ -6972,6 +7416,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
6972
7416
  deletionRevisionLockPath: path14.join(baseDir, ".offline-sync", "deletion-revisions.v1.json.lock"),
6973
7417
  assertManagedStoragePath: (filePath, method) => this.assertManagedStoragePath(filePath, method)
6974
7418
  });
7419
+ this.casRevisions = new CasRevisionHost(baseDir);
6975
7420
  this.hotMemoriesCacheEnabled = hotMemoriesCacheEnabledOverride ?? _StorageManager.hotMemoriesCacheDefaultByDir.get(baseDir) ?? _StorageManager.hotMemoriesCacheDefault;
6976
7421
  this.loadAliasesSync();
6977
7422
  }
@@ -6979,6 +7424,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
6979
7424
  entitySchemas;
6980
7425
  knowledgeIndexCache = null;
6981
7426
  deletionRevisionStore;
7427
+ casRevisions;
6982
7428
  artifactIndexCache = null;
6983
7429
  projectionLedgerLagManager = new ProjectionLedgerLagManager();
6984
7430
  static loadedMemorySnapshots = /* @__PURE__ */ new WeakMap();
@@ -7604,7 +8050,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7604
8050
  writeFile: (p, c) => this.writeStorageSecureFile(p, c),
7605
8051
  readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
7606
8052
  readDir: (d) => readdir6(d),
7607
- deleteFile: (p) => unlink4(p),
8053
+ deleteFile: (p) => unlink5(p),
7608
8054
  realpath: (p) => realpath3(p),
7609
8055
  lstat: (p) => lstat3(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
7610
8056
  });
@@ -7622,7 +8068,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7622
8068
  writeFile: (p, c) => this.writeStorageSecureFile(p, c),
7623
8069
  readFile: (p) => readMaybeEncryptedFile(p, this._secureStoreKey, this.baseDir),
7624
8070
  readDir: (d) => readdir6(d),
7625
- deleteFile: (p) => unlink4(p),
8071
+ deleteFile: (p) => unlink5(p),
7626
8072
  realpath: (p) => realpath3(p),
7627
8073
  lstat: (p) => lstat3(p).then((st) => ({ isSymbolicLink: st.isSymbolicLink() }))
7628
8074
  });
@@ -7761,6 +8207,10 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7761
8207
  async hasCommittedInvalidation(memory) {
7762
8208
  return this.deletionRevisionStore.hasCommittedInvalidation(memory);
7763
8209
  }
8210
+ readCasRevision = (filePath) => this.casRevisions.readCasRevision(filePath);
8211
+ readCasRevisionStatus = (filePath) => this.casRevisions.readCasRevisionStatus(filePath);
8212
+ readDurableFileDigest = (filePath) => this.casRevisions.readDurableFileDigest(filePath);
8213
+ beginDurableMemoryRevision = (pathname, expectedContent) => this.casRevisions.beginRevision(pathname, expectedContent);
7764
8214
  async recordCommittedInvalidation(memory) {
7765
8215
  return this.deletionRevisionStore.recordCommittedInvalidation(memory);
7766
8216
  }
@@ -7797,11 +8247,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7797
8247
  if (encrypted) {
7798
8248
  const content = await readMaybeEncryptedFileBuffer(target, this._secureStoreKey, this.baseDir);
7799
8249
  digest = {
7800
- sha256: createHash6("sha256").update(content).digest("hex"),
8250
+ sha256: createHash7("sha256").update(content).digest("hex"),
7801
8251
  bytes: content.byteLength
7802
8252
  };
7803
8253
  } else {
7804
- const hash = createHash6("sha256");
8254
+ const hash = createHash7("sha256");
7805
8255
  let bytes = 0;
7806
8256
  for await (const rawChunk of createReadStream(target)) {
7807
8257
  const chunk = Buffer.isBuffer(rawChunk) ? rawChunk : Buffer.from(rawChunk);
@@ -7829,7 +8279,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7829
8279
  async readOfflineSyncDigestCache() {
7830
8280
  const cache = /* @__PURE__ */ new Map();
7831
8281
  try {
7832
- const raw = await readFile2(this.offlineSyncDigestCachePath, "utf-8");
8282
+ const raw = await readFile3(this.offlineSyncDigestCachePath, "utf-8");
7833
8283
  const parsed = JSON.parse(raw);
7834
8284
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return cache;
7835
8285
  const entries = parsed.entries;
@@ -7886,7 +8336,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7886
8336
  const cache = this.offlineSyncDigestCache;
7887
8337
  if (!cache) return;
7888
8338
  const entries = [...cache.entries()].sort(([a], [b]) => a.localeCompare(b)).map(([entryPath, entry]) => ({ path: entryPath, ...entry }));
7889
- await mkdir(path14.dirname(this.offlineSyncDigestCachePath), { recursive: true });
8339
+ await mkdir2(path14.dirname(this.offlineSyncDigestCachePath), { recursive: true });
7890
8340
  await writeFile2(this.offlineSyncDigestCachePath, `${JSON.stringify({ version: 1, entries })}
7891
8341
  `, "utf-8");
7892
8342
  }).catch((err) => {
@@ -7896,7 +8346,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7896
8346
  });
7897
8347
  }
7898
8348
  async offlineSyncFileIsEncrypted(filePath) {
7899
- const handle = await open(filePath, "r");
8349
+ const handle = await open2(filePath, "r");
7900
8350
  try {
7901
8351
  const header = Buffer.alloc(MAGIC_HEADER_SIZE);
7902
8352
  const { bytesRead } = await handle.read(header, 0, header.length, 0);
@@ -7955,7 +8405,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7955
8405
  }
7956
8406
  let handle;
7957
8407
  try {
7958
- handle = await open(filePath, "r");
8408
+ handle = await open2(filePath, "r");
7959
8409
  } catch (err) {
7960
8410
  if (isErrnoCode(err, "ENOENT")) return false;
7961
8411
  throw err;
@@ -7975,7 +8425,7 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
7975
8425
  }
7976
8426
  async appendStorageSecureFileUnlocked(filePath, content) {
7977
8427
  const writeKey = this.resolveWriteKey();
7978
- await mkdir(path14.dirname(filePath), { recursive: true });
8428
+ await mkdir2(path14.dirname(filePath), { recursive: true });
7979
8429
  if (writeKey === null) {
7980
8430
  try {
7981
8431
  if (await this.isEncryptedFileHeader(filePath)) {
@@ -8495,22 +8945,22 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8495
8945
  return completionFingerprint;
8496
8946
  }
8497
8947
  async ensureDirectories() {
8498
- await mkdir(this.baseDir, { recursive: true });
8948
+ await mkdir2(this.baseDir, { recursive: true });
8499
8949
  await validateRoots(this.baseDir, this.entitiesDir, this.stateDir, this.archiveDir);
8500
8950
  const today = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
8501
- await mkdir(path14.join(this.factsDir, today), { recursive: true });
8502
- await mkdir(path14.join(this.proceduresDir, today), { recursive: true });
8503
- await mkdir(path14.join(this.reasoningTracesDir, today), { recursive: true });
8504
- await mkdir(this.correctionsDir, { recursive: true });
8505
- await mkdir(this.entitiesDir, { recursive: true });
8506
- await mkdir(this.stateDir, { recursive: true });
8507
- await mkdir(this.questionsDir, { recursive: true });
8508
- await mkdir(this.artifactsDir, { recursive: true });
8509
- await mkdir(this.identityDir, { recursive: true });
8510
- await mkdir(this.identityIncidentsDir, { recursive: true });
8511
- await mkdir(this.identityAuditsWeeklyDir, { recursive: true });
8512
- await mkdir(this.identityAuditsMonthlyDir, { recursive: true });
8513
- await mkdir(path14.join(this.baseDir, "config"), { recursive: true });
8951
+ await mkdir2(path14.join(this.factsDir, today), { recursive: true });
8952
+ await mkdir2(path14.join(this.proceduresDir, today), { recursive: true });
8953
+ await mkdir2(path14.join(this.reasoningTracesDir, today), { recursive: true });
8954
+ await mkdir2(this.correctionsDir, { recursive: true });
8955
+ await mkdir2(this.entitiesDir, { recursive: true });
8956
+ await mkdir2(this.stateDir, { recursive: true });
8957
+ await mkdir2(this.questionsDir, { recursive: true });
8958
+ await mkdir2(this.artifactsDir, { recursive: true });
8959
+ await mkdir2(this.identityDir, { recursive: true });
8960
+ await mkdir2(this.identityIncidentsDir, { recursive: true });
8961
+ await mkdir2(this.identityAuditsWeeklyDir, { recursive: true });
8962
+ await mkdir2(this.identityAuditsMonthlyDir, { recursive: true });
8963
+ await mkdir2(path14.join(this.baseDir, "config"), { recursive: true });
8514
8964
  await this.entityCanonicalIdMigration.ensure();
8515
8965
  if (this.hotMemoriesCacheEnabled && this.getMemoryCorpusVersion() === 0) {
8516
8966
  this.bumpMemoryCorpusVersion();
@@ -8531,11 +8981,11 @@ var StorageManager3 = class _StorageManager extends TombstoneBlockedCaptureIndex
8531
8981
  */
8532
8982
  async resolveCategoryWritePath(category, id, today) {
8533
8983
  if (category === "correction") {
8534
- await mkdir(this.correctionsDir, { recursive: true });
8984
+ await mkdir2(this.correctionsDir, { recursive: true });
8535
8985
  return path14.join(this.correctionsDir, `${id}.md`);
8536
8986
  }
8537
8987
  const datedDir = path14.join(getCategoryDir(this.baseDir, category), today);
8538
- await mkdir(datedDir, { recursive: true });
8988
+ await mkdir2(datedDir, { recursive: true });
8539
8989
  return path14.join(datedDir, `${id}.md`);
8540
8990
  }
8541
8991
  async findExistingTombstoneBlockedMemory(content, category, sourceConnector) {
@@ -8707,7 +9157,7 @@ ${sanitized.text}
8707
9157
  }
8708
9158
  });
8709
9159
  } catch (err) {
8710
- await unlink4(filePath).catch(() => void 0);
9160
+ await unlink5(filePath).catch(() => void 0);
8711
9161
  this.invalidateAllMemoriesCache();
8712
9162
  await this.rebuildTombstoneBlockedCaptureAfterInvalidationForPath(filePath);
8713
9163
  throw err;
@@ -8924,7 +9374,7 @@ ${sanitized.text}
8924
9374
  const now = /* @__PURE__ */ new Date();
8925
9375
  const day = now.toISOString().slice(0, 10);
8926
9376
  const dir = path14.join(this.artifactsDir, day);
8927
- await mkdir(dir, { recursive: true });
9377
+ await mkdir2(dir, { recursive: true });
8928
9378
  const id = `artifact-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
8929
9379
  const fm = {
8930
9380
  id,
@@ -9507,7 +9957,7 @@ ${memory.content}
9507
9957
  {},
9508
9958
  this.baseDir
9509
9959
  );
9510
- const priorDest = await readFile2(targetPath).catch(() => null);
9960
+ const priorDest = await readFile3(targetPath).catch(() => null);
9511
9961
  await persist();
9512
9962
  if (typeof rawRef === "string") {
9513
9963
  const refBeforeRepair = frontmatter.entityRef;
@@ -9522,7 +9972,7 @@ ${memory.content}
9522
9972
  });
9523
9973
  } catch (err) {
9524
9974
  if (priorDest === null) {
9525
- await unlink4(targetPath).catch(() => void 0);
9975
+ await unlink5(targetPath).catch(() => void 0);
9526
9976
  } else {
9527
9977
  await writeFile2(targetPath, priorDest).catch(() => void 0);
9528
9978
  }
@@ -9619,7 +10069,7 @@ ${memory.content}
9619
10069
  const now = lifecycle?.at ?? /* @__PURE__ */ new Date();
9620
10070
  const today = now.toISOString().slice(0, 10);
9621
10071
  const destDir = path14.join(this.archiveDir, today);
9622
- await mkdir(destDir, { recursive: true });
10072
+ await mkdir2(destDir, { recursive: true });
9623
10073
  const refIdsAtWrite = this.currentHistoricalIds();
9624
10074
  const updatedFm = canonicalizeEntityRefOption(
9625
10075
  {
@@ -9651,7 +10101,7 @@ ${current.content}
9651
10101
  await recordArchiveDelete2(
9652
10102
  this.baseDir,
9653
10103
  destPath,
9654
- () => unlink4(destPath).then(
10104
+ () => unlink5(destPath).then(
9655
10105
  () => true,
9656
10106
  () => false
9657
10107
  )
@@ -9768,10 +10218,10 @@ ${current.content}
9768
10218
  });
9769
10219
  });
9770
10220
  }
10221
+ /** Commit the new body and return the CAS commit receipt — the sidecar
10222
+ * revision token, never `frontmatter.updated` (#2813 P1, #2807). */
9771
10223
  async updateMemoryFromCurrent(memory, newContent, options) {
9772
- const mergedLineage = [...memory.frontmatter.lineage ?? [], ...options?.lineage ?? []].filter(
9773
- (v, i, a) => a.indexOf(v) === i
9774
- );
10224
+ const mergedLineage = [...memory.frontmatter.lineage ?? [], ...options?.lineage ?? []].filter((v, i, a) => a.indexOf(v) === i);
9775
10225
  const refIdsAtWrite = this.currentHistoricalIds();
9776
10226
  const updated = canonicalizeEntityRefOption(
9777
10227
  {
@@ -9791,41 +10241,40 @@ ${current.content}
9791
10241
 
9792
10242
  ${sanitized.text}
9793
10243
  `;
9794
- await this.writeTombstoneBlockedUpdate(memory, fileContent, updated, sanitized.text, async () => {
10244
+ const receipt = await this.writeTombstoneBlockedUpdate(memory, fileContent, updated, sanitized.text, async () => {
9795
10245
  this.invalidateAllMemoriesCache();
9796
10246
  if (this.isColdOrArchiveTierPath(memory.path)) this.invalidateColdMemoriesCache();
9797
10247
  });
9798
- if (typeof memory.frontmatter.entityRef === "string") {
9799
- await this.entityRefRepair.repair(
9800
- memory.path,
9801
- updated,
9802
- memory.frontmatter.entityRef,
9803
- refIdsAtWrite,
9804
- sanitized.text,
9805
- { onFailRestore: memory }
9806
- );
9807
- }
9808
- await this.patchHotMemoriesCache({ addedPath: memory.path });
9809
- await this.appendGeneratedMemoryLifecycleEventFailOpen("storage.updateMemory", {
9810
- memoryId: memory.frontmatter.id,
9811
- eventType: "updated",
9812
- timestamp: updated.updated,
9813
- actor: options?.actor ?? "storage.updateMemory",
9814
- before: this.summarizeLifecycleState(memory.frontmatter, memory.path),
9815
- after: this.summarizeLifecycleState(updated, memory.path),
9816
- relatedMemoryIds: [
9817
- ...updated.supersedes ? [updated.supersedes] : [],
9818
- ...(updated.lineage ?? []).filter(Boolean)
9819
- ]
10248
+ if (receipt === void 0) throw new Error(`CAS revision receipt unavailable for ${memory.frontmatter.id}`);
10249
+ return await withCasCommitReceipt(receipt, async () => {
10250
+ if (typeof memory.frontmatter.entityRef === "string") {
10251
+ await this.entityRefRepair.repair(memory.path, updated, memory.frontmatter.entityRef, refIdsAtWrite, sanitized.text, { onFailRestore: memory });
10252
+ }
10253
+ await this.patchHotMemoriesCache({ addedPath: memory.path });
10254
+ await this.appendGeneratedMemoryLifecycleEventFailOpen("storage.updateMemory", {
10255
+ memoryId: memory.frontmatter.id,
10256
+ eventType: "updated",
10257
+ timestamp: updated.updated,
10258
+ actor: options?.actor ?? "storage.updateMemory",
10259
+ before: this.summarizeLifecycleState(memory.frontmatter, memory.path),
10260
+ after: this.summarizeLifecycleState(updated, memory.path),
10261
+ relatedMemoryIds: [
10262
+ ...updated.supersedes ? [updated.supersedes] : [],
10263
+ ...(updated.lineage ?? []).filter(Boolean)
10264
+ ]
10265
+ });
10266
+ log.debug(`updated memory ${memory.frontmatter.id}`);
10267
+ return receipt;
9820
10268
  });
9821
- log.debug(`updated memory ${memory.frontmatter.id}`);
9822
- return true;
9823
10269
  }
9824
10270
  async updateMemory(id, newContent, options) {
9825
10271
  const memory = (await this.readAllMemories()).find((candidate) => candidate.frontmatter.id === id);
9826
10272
  if (!memory) return false;
9827
- return await this.updateMemoryFromCurrent(memory, newContent, options);
10273
+ await this.updateMemoryFromCurrent(memory, newContent, options);
10274
+ return true;
9828
10275
  }
10276
+ /** CAS content update: false when the record moved past `expected`; on
10277
+ * success the commit receipt — the only identity that can attribute a standing body later (#2813 P1, #2807). */
9829
10278
  async updateMemoryIfUnchanged(expected, newContent, options) {
9830
10279
  const sanitized = sanitizeMemoryContent(newContent);
9831
10280
  const oldIdentity = buildExplicitCaptureDedupKey(
@@ -9849,8 +10298,7 @@ ${sanitized.text}
9849
10298
  );
9850
10299
  }
9851
10300
  /**
9852
- * Update frontmatter fields without changing memory content.
9853
- * Returns false when the memory is not found.
10301
+ * Update frontmatter fields without changing memory content. Returns false when the memory is not found.
9854
10302
  */
9855
10303
  async writeMemoryFrontmatter(memory, patch, lifecycle) {
9856
10304
  const beforeStatus = memory.frontmatter.status ?? "active";
@@ -10078,7 +10526,7 @@ ${memory.content}
10078
10526
  },
10079
10527
  (payload) => this.appendStorageSecureFile(target, payload),
10080
10528
  async () => {
10081
- await mkdir(path14.dirname(target), { recursive: true });
10529
+ await mkdir2(path14.dirname(target), { recursive: true });
10082
10530
  }
10083
10531
  );
10084
10532
  }
@@ -10338,7 +10786,7 @@ ${memory.content}
10338
10786
  return false;
10339
10787
  }
10340
10788
  if (draftState.contentHash) {
10341
- const contentHash = createHash6("sha256").update(draftContent).digest("hex");
10789
+ const contentHash = createHash7("sha256").update(draftContent).digest("hex");
10342
10790
  if (contentHash !== draftState.contentHash) return false;
10343
10791
  }
10344
10792
  await this.writeCompressionGuidelines(draftContent);
@@ -10347,8 +10795,8 @@ ${memory.content}
10347
10795
  activationState: "active"
10348
10796
  });
10349
10797
  await Promise.all([
10350
- unlink4(this.compressionGuidelineDraftPath).catch(() => void 0),
10351
- unlink4(this.compressionGuidelineDraftStatePath).catch(() => void 0)
10798
+ unlink5(this.compressionGuidelineDraftPath).catch(() => void 0),
10799
+ unlink5(this.compressionGuidelineDraftStatePath).catch(() => void 0)
10352
10800
  ]);
10353
10801
  return true;
10354
10802
  }
@@ -10400,7 +10848,7 @@ ${memory.content}
10400
10848
  return `${prefix}-${ts}-${rand}`;
10401
10849
  }
10402
10850
  async writeQuestion(question, context, priority) {
10403
- await mkdir(this.questionsDir, { recursive: true });
10851
+ await mkdir2(this.questionsDir, { recursive: true });
10404
10852
  const id = this.generateId("q");
10405
10853
  const frontmatter = {
10406
10854
  id,
@@ -10454,7 +10902,7 @@ ${question}
10454
10902
  async readIdentity(workspaceDir, namespace) {
10455
10903
  const identityPath = this.identityFilePath(workspaceDir, namespace);
10456
10904
  try {
10457
- return await readFile2(identityPath, "utf-8");
10905
+ return await readFile3(identityPath, "utf-8");
10458
10906
  } catch {
10459
10907
  return "";
10460
10908
  }
@@ -10472,7 +10920,7 @@ ${question}
10472
10920
  const identityPath = this.identityFilePath(workspaceDir, opts?.namespace);
10473
10921
  let existing = "";
10474
10922
  try {
10475
- existing = await readFile2(identityPath, "utf-8");
10923
+ existing = await readFile3(identityPath, "utf-8");
10476
10924
  } catch {
10477
10925
  }
10478
10926
  const hygiene = opts?.hygiene;
@@ -10532,7 +10980,7 @@ ${reflection}
10532
10980
  }
10533
10981
  }
10534
10982
  async writeIdentityReflections(content) {
10535
- await mkdir(this.identityDir, { recursive: true });
10983
+ await mkdir2(this.identityDir, { recursive: true });
10536
10984
  await this.writeStorageSecureFile(this.identityReflectionsPath, content);
10537
10985
  }
10538
10986
  async appendIdentityReflection(reflection) {
@@ -10564,7 +11012,7 @@ ${reflection}
10564
11012
 
10565
11013
  ${reflection}
10566
11014
  `;
10567
- await mkdir(this.identityDir, { recursive: true });
11015
+ await mkdir2(this.identityDir, { recursive: true });
10568
11016
  await this.writeStorageSecureFile(this.identityReflectionsPath, `${existing.trimEnd()}${section}`);
10569
11017
  log.debug(`appended namespace-local reflection to ${this.identityReflectionsPath}`);
10570
11018
  }
@@ -10620,7 +11068,7 @@ ${reflection}
10620
11068
  const rightTs = latestEntityTimelineTimestamp(right.entity) ?? "";
10621
11069
  return compareEntityTimestamps(rightTs, leftTs);
10622
11070
  }).map(({ entityName }) => entityName);
10623
- await mkdir(this.stateDir, { recursive: true });
11071
+ await mkdir2(this.stateDir, { recursive: true });
10624
11072
  await this.writeStorageSecureFile(
10625
11073
  this.entitySynthesisQueuePath,
10626
11074
  JSON.stringify(
@@ -10640,7 +11088,7 @@ ${reflection}
10640
11088
  if (queue.length === 0) return;
10641
11089
  const removals = new Set(entityNames);
10642
11090
  const nextQueue = queue.filter((name) => !removals.has(name));
10643
- await mkdir(this.stateDir, { recursive: true });
11091
+ await mkdir2(this.stateDir, { recursive: true });
10644
11092
  await this.writeStorageSecureFile(
10645
11093
  this.entitySynthesisQueuePath,
10646
11094
  JSON.stringify(
@@ -11039,7 +11487,7 @@ ${sanitized.text}
11039
11487
  }
11040
11488
  if (!oldMemory) return false;
11041
11489
  const requireActiveAtWrite = options.requireActive === true || inferMemoryStatus(oldMemory.frontmatter, toMemoryPathRel(this.baseDir, oldMemory.path)) === "active";
11042
- const operationId = createHash6("sha256").update(
11490
+ const operationId = createHash7("sha256").update(
11043
11491
  JSON.stringify({
11044
11492
  oldMemoryId,
11045
11493
  newMemoryId,
@@ -11171,7 +11619,7 @@ ${current.content}
11171
11619
  return path14.join(this.baseDir, "summaries");
11172
11620
  }
11173
11621
  async writeSummary(summary) {
11174
- await mkdir(this.summariesDir, { recursive: true });
11622
+ await mkdir2(this.summariesDir, { recursive: true });
11175
11623
  const filePath = path14.join(this.summariesDir, `${summary.id}.json`);
11176
11624
  await this.writeStorageSecureFile(filePath, JSON.stringify(summary, null, 2));
11177
11625
  log.debug(`wrote summary ${summary.id}`);
@@ -11253,7 +11701,7 @@ ${current.content}
11253
11701
  }
11254
11702
  async saveTopics(topics) {
11255
11703
  const metaPath = path14.join(this.stateDir, "topics.json");
11256
- await mkdir(this.stateDir, { recursive: true });
11704
+ await mkdir2(this.stateDir, { recursive: true });
11257
11705
  await this.writeStorageSecureFile(
11258
11706
  metaPath,
11259
11707
  JSON.stringify({ topics, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2)
@@ -11338,13 +11786,6 @@ ${current.content}
11338
11786
  export {
11339
11787
  serializeDriftProvenance,
11340
11788
  parseDriftProvenance,
11341
- okfTypeForCategory,
11342
- okfTypeForMemory,
11343
- OKF_PROFILE_TYPE,
11344
- OKF_DECISION_RECORD_TYPE,
11345
- OKF_ARCHITECTURE_CARD_TYPE,
11346
- OKF_CODE_MODULE_TYPE,
11347
- OKF_RESERVED_BASENAMES,
11348
11789
  selfDeps,
11349
11790
  qmdCollectionPathParts,
11350
11791
  qmdResultPathCandidates,
@@ -11386,4 +11827,4 @@ export {
11386
11827
  isValidBufferSurpriseEvent,
11387
11828
  StorageManager3 as StorageManager
11388
11829
  };
11389
- //# sourceMappingURL=chunk-HV7OY4DM.js.map
11830
+ //# sourceMappingURL=chunk-5VAF4ID4.js.map