@remnic/core 9.69.32 → 9.69.34

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 (775) hide show
  1. package/dist/access-admin-ops-surface.d.ts +13 -11
  2. package/dist/access-admin-ops-surface.js +64 -59
  3. package/dist/access-authorization-probe.d.ts +13 -11
  4. package/dist/access-authorization-probe.js +65 -60
  5. package/dist/access-boundary.d.ts +13 -11
  6. package/dist/access-boundary.js +64 -59
  7. package/dist/access-cli.js +140 -136
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-coding-context-resolution.d.ts +2 -1
  10. package/dist/access-coding-context-resolution.js +3 -3
  11. package/dist/access-extraction-force-flush.d.ts +13 -11
  12. package/dist/access-extraction-force-flush.js +64 -59
  13. package/dist/access-health-types.d.ts +2 -1
  14. package/dist/access-http-briefing.d.ts +13 -11
  15. package/dist/access-http-briefing.js +65 -60
  16. package/dist/access-http-lcm-compaction.d.ts +13 -11
  17. package/dist/access-http-lifecycle-flush.d.ts +13 -11
  18. package/dist/access-http-offline-stream.d.ts +13 -11
  19. package/dist/access-http-query.d.ts +3 -2
  20. package/dist/access-http-query.js +66 -61
  21. package/dist/access-http.d.ts +14 -12
  22. package/dist/access-http.js +86 -82
  23. package/dist/access-identity-continuity-surface.d.ts +11 -9
  24. package/dist/access-identity-continuity-surface.js +64 -59
  25. package/dist/access-lcm-surface.d.ts +13 -11
  26. package/dist/access-lcm-surface.js +64 -59
  27. package/dist/access-mcp.d.ts +13 -11
  28. package/dist/access-mcp.js +73 -69
  29. package/dist/access-memory-search-fanout.d.ts +3 -2
  30. package/dist/{access-namespace-preflight-BsvmyENS.d.ts → access-namespace-preflight-kXG8MvYx.d.ts} +1 -1
  31. package/dist/access-namespace-preflight.d.ts +4 -3
  32. package/dist/access-namespace-preflight.js +64 -59
  33. package/dist/access-observe-transcript.d.ts +11 -9
  34. package/dist/access-observe-transcript.js +3 -3
  35. package/dist/access-observe-write-surface.d.ts +15 -13
  36. package/dist/access-observe-write-surface.js +64 -59
  37. package/dist/access-offline-manifest.d.ts +47 -11
  38. package/dist/access-offline-manifest.js +18 -16
  39. package/dist/access-operations-batch.js +67 -63
  40. package/dist/access-operations.d.ts +18 -16
  41. package/dist/access-operations.js +72 -68
  42. package/dist/access-recall-concurrency.d.ts +13 -11
  43. package/dist/access-recall-concurrency.js +64 -59
  44. package/dist/access-recall-response.d.ts +13 -11
  45. package/dist/access-recall-response.js +64 -59
  46. package/dist/access-recall-surface.d.ts +13 -11
  47. package/dist/access-recall-surface.js +64 -59
  48. package/dist/access-schema.d.ts +138 -96
  49. package/dist/access-schema.js +15 -1
  50. package/dist/{access-service-CCpOuS46.d.ts → access-service-WUm2LnXZ.d.ts} +110 -108
  51. package/dist/access-service-helpers.d.ts +13 -11
  52. package/dist/access-service.d.ts +13 -11
  53. package/dist/access-service.js +64 -59
  54. package/dist/access-surface-catalog.d.ts +13 -11
  55. package/dist/access-surface-catalog.js +66 -61
  56. package/dist/access-surface-catalog.js.map +1 -1
  57. package/dist/access-wearables-meetings-surface.d.ts +4 -3
  58. package/dist/action-confidence.d.ts +2 -1
  59. package/dist/active-memory-bridge.d.ts +2 -1
  60. package/dist/active-memory-bridge.js +2 -2
  61. package/dist/active-recall.d.ts +2 -1
  62. package/dist/active-recall.js +14 -12
  63. package/dist/active-recall.js.map +1 -1
  64. package/dist/activity/digest.d.ts +56 -0
  65. package/dist/activity/digest.js +32 -0
  66. package/dist/adapters/index.d.ts +46 -1
  67. package/dist/adapters/index.js +13 -9
  68. package/dist/adapters/registry.js +3 -3
  69. package/dist/ambient-provenance.d.ts +2 -1
  70. package/dist/artifact-search.d.ts +2 -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 +2 -1
  74. package/dist/behavior-signals.d.ts +2 -1
  75. package/dist/bootstrap.d.ts +11 -9
  76. package/dist/briefing-window.d.ts +3 -2
  77. package/dist/briefing.d.ts +3 -2
  78. package/dist/briefing.js +28 -27
  79. package/dist/buffer-surprise-report.d.ts +2 -1
  80. package/dist/buffer-turn-helpers.d.ts +2 -1
  81. package/dist/buffer.d.ts +3 -2
  82. package/dist/buffer.js +12 -11
  83. package/dist/bulk-import/index.d.ts +4 -3
  84. package/dist/calibration.d.ts +2 -1
  85. package/dist/calibration.js +3 -2
  86. package/dist/calibration.js.map +1 -1
  87. package/dist/capabilities.d.ts +2 -1
  88. package/dist/{capsule-merge-IPG4IOFP.js → capsule-merge-ZCXUPLNJ.js} +2 -2
  89. package/dist/{catalog-CDZLyiXL.d.ts → catalog-BaCx29iv.d.ts} +1 -1
  90. package/dist/causal-behavior.d.ts +2 -1
  91. package/dist/causal-consolidation.d.ts +2 -1
  92. package/dist/causal-consolidation.js +29 -28
  93. package/dist/causal-consolidation.js.map +1 -1
  94. package/dist/causal-trajectory-graph.d.ts +2 -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-IY2FVXM6.js → chunk-2AU4D4HQ.js} +3 -3
  99. package/dist/{chunk-QDY6KYTN.js → chunk-2JCA2PQT.js} +3 -3
  100. package/dist/{chunk-RSVEP77Y.js → chunk-2UZ5ZH6W.js} +3 -3
  101. package/dist/{chunk-XQ2Q43XD.js → chunk-326KUXIR.js} +15 -648
  102. package/dist/chunk-326KUXIR.js.map +1 -0
  103. package/dist/{chunk-NWWXSJX5.js → chunk-34QW2LK2.js} +2 -2
  104. package/dist/{chunk-S7DPKM5W.js → chunk-353C5UNV.js} +1 -1
  105. package/dist/{chunk-GQOMZ3MK.js → chunk-36UBSLFN.js} +2 -2
  106. package/dist/{chunk-DBQWVT2H.js → chunk-3CBI2ZSA.js} +2 -2
  107. package/dist/{chunk-NZXEK3UF.js → chunk-3Q3N35W7.js} +2 -2
  108. package/dist/{chunk-YYGZJPOK.js → chunk-42DJ235G.js} +2 -2
  109. package/dist/{chunk-7VJXIDOC.js → chunk-4JVQRFZD.js} +9 -9
  110. package/dist/{chunk-22FVR2KE.js → chunk-4MIS4CQW.js} +6 -2
  111. package/dist/chunk-4MIS4CQW.js.map +1 -0
  112. package/dist/{chunk-WHBVXTUI.js → chunk-4PB2MBY6.js} +9 -9
  113. package/dist/{chunk-TEYN7ZYF.js → chunk-4WCNPQQ5.js} +4 -4
  114. package/dist/{chunk-Z4PCVRTN.js → chunk-5A7ZUOBA.js} +217 -396
  115. package/dist/chunk-5A7ZUOBA.js.map +1 -0
  116. package/dist/chunk-5HYUUFMQ.js +1280 -0
  117. package/dist/chunk-5HYUUFMQ.js.map +1 -0
  118. package/dist/{chunk-RBGREYVJ.js → chunk-5QBDLMGG.js} +2 -2
  119. package/dist/{chunk-RKBLRTNT.js → chunk-5SDSVX7N.js} +2 -2
  120. package/dist/{chunk-LPECRQO4.js → chunk-5THU7NFP.js} +3 -3
  121. package/dist/{chunk-N7RWREIQ.js → chunk-65RENJGB.js} +6 -1
  122. package/dist/chunk-65RENJGB.js.map +1 -0
  123. package/dist/{chunk-LWA7MDVO.js → chunk-6CCRSQWT.js} +2 -2
  124. package/dist/{chunk-TIT2C6WX.js → chunk-6XYC7NM4.js} +2 -2
  125. package/dist/{chunk-FHQSPTPZ.js → chunk-6YAIN5XJ.js} +2 -2
  126. package/dist/{chunk-PV36INNL.js → chunk-757NP436.js} +3 -3
  127. package/dist/{chunk-WJBZMNNS.js → chunk-7CAY3YKP.js} +742 -29
  128. package/dist/chunk-7CAY3YKP.js.map +1 -0
  129. package/dist/{chunk-6H5JYDOM.js → chunk-7J2CGXG3.js} +2 -2
  130. package/dist/{chunk-FBMYGNOC.js → chunk-A2YQL2FF.js} +6 -6
  131. package/dist/chunk-A5UQ52YQ.js +211 -0
  132. package/dist/chunk-A5UQ52YQ.js.map +1 -0
  133. package/dist/{chunk-X2NFFBTO.js → chunk-A7GQBJP5.js} +4 -4
  134. package/dist/{chunk-MPYD657E.js → chunk-A7WOWDZK.js} +2 -2
  135. package/dist/{chunk-C4OTC6WY.js → chunk-AIKTQVV3.js} +3 -3
  136. package/dist/{chunk-CGC5UQCF.js → chunk-AKE4GGQ3.js} +2 -2
  137. package/dist/{chunk-VP67GZ7T.js → chunk-APFKZVJS.js} +2 -2
  138. package/dist/{chunk-M75RYSHS.js → chunk-AQIRQUCP.js} +2 -2
  139. package/dist/{chunk-S7T2TY65.js → chunk-AXFR2NQ5.js} +3 -3
  140. package/dist/{chunk-PSPABFN2.js → chunk-BD7JTBYP.js} +4 -4
  141. package/dist/{chunk-FCSZ4K2X.js → chunk-BJJWRWER.js} +3 -3
  142. package/dist/{chunk-JT3EB7ZL.js → chunk-BNGHPYZU.js} +5 -5
  143. package/dist/chunk-BRZWWUCJ.js +13 -0
  144. package/dist/{chunk-FYDW33ZB.js.map → chunk-BRZWWUCJ.js.map} +1 -1
  145. package/dist/{chunk-MFJBANPX.js → chunk-C2BFTYD7.js} +2 -2
  146. package/dist/{chunk-3JVLGJCY.js → chunk-C6KRO3SU.js} +2 -2
  147. package/dist/{chunk-Q3O3VKRB.js → chunk-CRUFVJOX.js} +16 -15
  148. package/dist/chunk-CRUFVJOX.js.map +1 -0
  149. package/dist/{chunk-AOCP6JA7.js → chunk-D3IZCN5P.js} +4 -4
  150. package/dist/{chunk-ROKKIMON.js → chunk-EJIEQOPB.js} +5 -5
  151. package/dist/{chunk-ET356KSB.js → chunk-F4TWWUMP.js} +2 -2
  152. package/dist/{chunk-CLLPJ6QT.js → chunk-FQXJAC3T.js} +2 -2
  153. package/dist/{chunk-DD5JFCWM.js → chunk-GCBIXUPT.js} +2 -2
  154. package/dist/{chunk-ROGRI25A.js → chunk-I3H5LFOI.js} +2 -2
  155. package/dist/{chunk-S65WXHNK.js → chunk-IFFLUCCU.js} +2 -2
  156. package/dist/{chunk-MYMNC6O5.js → chunk-ISYZ5DUI.js} +64 -60
  157. package/dist/{chunk-MYMNC6O5.js.map → chunk-ISYZ5DUI.js.map} +1 -1
  158. package/dist/{chunk-D5LORF7A.js → chunk-JZDH2ZZK.js} +3 -3
  159. package/dist/{chunk-2GPE5UCR.js → chunk-K6IPSW5B.js} +2 -2
  160. package/dist/{chunk-HG6HXVHQ.js → chunk-KDJHLOZP.js} +10 -10
  161. package/dist/{chunk-I27RSQRR.js → chunk-KYGOQV37.js} +2 -2
  162. package/dist/{chunk-JEIXTYVG.js → chunk-L2QLDZJC.js} +46 -17
  163. package/dist/chunk-L2QLDZJC.js.map +1 -0
  164. package/dist/{chunk-A7XEPMQ6.js → chunk-LAVJC57X.js} +3 -3
  165. package/dist/chunk-LAVJC57X.js.map +1 -0
  166. package/dist/{chunk-VZWXFXLX.js → chunk-LMCD5W5B.js} +2 -2
  167. package/dist/{chunk-3QQTXYZ6.js → chunk-LSLCFCCQ.js} +2 -1
  168. package/dist/chunk-LSLCFCCQ.js.map +1 -0
  169. package/dist/{chunk-MKD3OMPS.js → chunk-M3MYMWXG.js} +2 -2
  170. package/dist/{chunk-DITMGZOL.js → chunk-MMG5K6XJ.js} +2 -2
  171. package/dist/{chunk-VGXM5B4H.js → chunk-MNIPH6LD.js} +2 -2
  172. package/dist/{chunk-CZYYJZB6.js → chunk-ND2O2PVN.js} +1014 -1318
  173. package/dist/chunk-ND2O2PVN.js.map +1 -0
  174. package/dist/chunk-NPNSKE76.js +220 -0
  175. package/dist/chunk-NPNSKE76.js.map +1 -0
  176. package/dist/{chunk-MKWKYHXJ.js → chunk-OB3XMWX5.js} +4 -4
  177. package/dist/{chunk-XU6OEECT.js → chunk-OQQXGYMX.js} +3 -3
  178. package/dist/{chunk-GTWHVXPA.js → chunk-OZUXKUPD.js} +6 -4
  179. package/dist/{chunk-GTWHVXPA.js.map → chunk-OZUXKUPD.js.map} +1 -1
  180. package/dist/chunk-PCEYGOSL.js +66 -0
  181. package/dist/chunk-PCEYGOSL.js.map +1 -0
  182. package/dist/{chunk-47DEYNMR.js → chunk-PEXW2JCK.js} +2 -2
  183. package/dist/{chunk-EEOUMG3J.js → chunk-PWPIERBM.js} +38 -6
  184. package/dist/chunk-PWPIERBM.js.map +1 -0
  185. package/dist/chunk-Q4AUIFUA.js +111 -0
  186. package/dist/chunk-Q4AUIFUA.js.map +1 -0
  187. package/dist/{chunk-SO7SV523.js → chunk-Q6LCCIZN.js} +1 -1
  188. package/dist/chunk-Q6LCCIZN.js.map +1 -0
  189. package/dist/{chunk-42SDNZCU.js → chunk-QF4J3KMV.js} +19 -19
  190. package/dist/{chunk-SB6PSOP7.js → chunk-QLJ6762U.js} +2 -2
  191. package/dist/{chunk-XOVKXJEP.js → chunk-R3TLVTWW.js} +3 -3
  192. package/dist/{chunk-PHNAB54Q.js → chunk-RQO3J4MR.js} +2 -2
  193. package/dist/{chunk-5N53UBH2.js → chunk-RR7G2X7C.js} +5 -5
  194. package/dist/{chunk-DCJ3YFIC.js → chunk-S2ULTQZR.js} +2 -2
  195. package/dist/{chunk-GY5WZBA6.js → chunk-S76KRJDG.js} +3 -3
  196. package/dist/{chunk-H272ZPQ3.js → chunk-SHEHQBCG.js} +124 -23
  197. package/dist/chunk-SHEHQBCG.js.map +1 -0
  198. package/dist/{chunk-EEC4PCG5.js → chunk-SZDLX763.js} +2 -2
  199. package/dist/{chunk-SQJ3SDIW.js → chunk-SZWEDG3H.js} +13 -7
  200. package/dist/chunk-SZWEDG3H.js.map +1 -0
  201. package/dist/{chunk-E2ZHGBAK.js → chunk-T2JSUEH6.js} +2 -2
  202. package/dist/{chunk-QMGXMJ2O.js → chunk-T2YFZ27G.js} +9 -9
  203. package/dist/{chunk-LEPOP46W.js → chunk-TFA6HPOA.js} +4 -4
  204. package/dist/{chunk-BA6WOZOT.js → chunk-TK4FHQRN.js} +4 -4
  205. package/dist/chunk-TLHNF6GA.js +647 -0
  206. package/dist/chunk-TLHNF6GA.js.map +1 -0
  207. package/dist/{chunk-ZNJSBIP4.js → chunk-TNSCIPBQ.js} +4 -4
  208. package/dist/{chunk-YUMDFDUA.js → chunk-TWYTGIBR.js} +4 -4
  209. package/dist/{chunk-FDLDOEO6.js → chunk-UBG4GAEP.js} +51 -6
  210. package/dist/chunk-UBG4GAEP.js.map +1 -0
  211. package/dist/{chunk-EZZV7OQL.js → chunk-UEZKN6VR.js} +2 -2
  212. package/dist/{chunk-HY55QQD7.js → chunk-UJX4I26O.js} +2 -2
  213. package/dist/{chunk-BLUYQFRH.js → chunk-VELCIWJZ.js} +15 -11
  214. package/dist/chunk-VELCIWJZ.js.map +1 -0
  215. package/dist/{chunk-CBCNKKZD.js → chunk-VIZR45AN.js} +2 -2
  216. package/dist/{chunk-ZG74PWRW.js → chunk-VZAKYDMJ.js} +2 -2
  217. package/dist/{chunk-ITPS5DDH.js → chunk-W5BLTZZJ.js} +8 -8
  218. package/dist/chunk-W6IJMWTZ.js +72 -0
  219. package/dist/chunk-W6IJMWTZ.js.map +1 -0
  220. package/dist/{chunk-H3TKENU4.js → chunk-WIKO4SCR.js} +5 -5
  221. package/dist/{chunk-YFLLGRXO.js → chunk-X2QPKLPL.js} +2 -2
  222. package/dist/{chunk-FGGYSN4P.js → chunk-X424T5JQ.js} +2 -2
  223. package/dist/{chunk-NAXDPKVM.js → chunk-XPJNT6PI.js} +4 -4
  224. package/dist/{chunk-2JVJ7UHC.js → chunk-XQU3CPF2.js} +4 -2
  225. package/dist/chunk-XQU3CPF2.js.map +1 -0
  226. package/dist/chunk-XW2T4QAW.js +1 -0
  227. package/dist/{chunk-VED2YHUD.js → chunk-YEDVOYL2.js} +2 -2
  228. package/dist/{chunk-TLPZ6MKZ.js → chunk-YEN4TREG.js} +541 -5
  229. package/dist/chunk-YEN4TREG.js.map +1 -0
  230. package/dist/{chunk-RC5DXXWC.js → chunk-YM7YN37H.js} +2 -2
  231. package/dist/{chunk-VLXBE57O.js → chunk-YVGXH72Y.js} +2 -2
  232. package/dist/{chunk-YQAXP5AC.js → chunk-YXLUTALO.js} +5 -5
  233. package/dist/{chunk-565C6ZFO.js → chunk-Z7YDVHDI.js} +2 -2
  234. package/dist/{chunk-O75CRYGF.js → chunk-ZEFVK7XC.js} +1 -1
  235. package/dist/chunk-ZEFVK7XC.js.map +1 -0
  236. package/dist/{chunk-XUE46UYW.js → chunk-ZLN7AROH.js} +6 -6
  237. package/dist/{chunk-GVG3JYBI.js → chunk-ZMKYCFJ7.js} +640 -199
  238. package/dist/chunk-ZMKYCFJ7.js.map +1 -0
  239. package/dist/{chunk-HK32G473.js → chunk-ZWEZXVYH.js} +2 -2
  240. package/dist/{cli-NEEdq5Rt.d.ts → cli-5mTYh1Tn.d.ts} +5 -5
  241. package/dist/cli-fallback.d.ts +11 -4
  242. package/dist/cli-fallback.js +5 -1
  243. package/dist/cli.d.ts +15 -13
  244. package/dist/cli.js +110 -106
  245. package/dist/coding/export-okf-codegraph.d.ts +2 -1
  246. package/dist/coding/export-okf-codegraph.js +34 -32
  247. package/dist/coding/export-okf-codegraph.js.map +1 -1
  248. package/dist/coding/pre-action-gate.d.ts +2 -1
  249. package/dist/compat/checks.js +2 -2
  250. package/dist/compat/codex-cli-fallback.d.ts +1 -1
  251. package/dist/compat/codex-cli-fallback.js +5 -1
  252. package/dist/compat/codex-cli-fallback.js.map +1 -1
  253. package/dist/compounding/engine.d.ts +3 -2
  254. package/dist/compounding/engine.js +29 -28
  255. package/dist/compounding/preference-consolidator.d.ts +2 -1
  256. package/dist/compression-optimizer.d.ts +2 -1
  257. package/dist/config.d.ts +2 -1
  258. package/dist/config.js +14 -12
  259. package/dist/connectors/codex-materialize-runner.d.ts +2 -1
  260. package/dist/connectors/codex-materialize-runner.js +28 -27
  261. package/dist/connectors/codex-materialize.d.ts +2 -1
  262. package/dist/connectors/index.d.ts +2 -1
  263. package/dist/connectors/index.js +30 -29
  264. package/dist/consolidation-provenance-check.d.ts +3 -2
  265. package/dist/consolidation-undo.d.ts +3 -2
  266. package/dist/contradiction/index.d.ts +4 -3
  267. package/dist/contradiction/index.js +5 -5
  268. package/dist/{contradiction-scan-NOYMFG66.js → contradiction-scan-GVD4JJ7B.js} +3 -3
  269. package/dist/converge-config.d.ts +2 -1
  270. package/dist/convergence-refresh.d.ts +3 -2
  271. package/dist/convergence-refresh.js +30 -29
  272. package/dist/conversation-index/backend.d.ts +2 -1
  273. package/dist/conversation-index/backend.js +3 -3
  274. package/dist/conversation-index/chunker.d.ts +2 -1
  275. package/dist/conversation-index/faiss-adapter.d.ts +2 -1
  276. package/dist/conversation-index/faiss-adapter.js +2 -2
  277. package/dist/conversation-index/indexer.d.ts +2 -1
  278. package/dist/conversation-index/search.d.ts +2 -1
  279. package/dist/corpus-watermark.d.ts +2 -1
  280. package/dist/corpus-watermark.js +31 -30
  281. package/dist/cross-lingual-recall.d.ts +2 -1
  282. package/dist/day-summary.d.ts +2 -1
  283. package/dist/deep-recall-http-glue.d.ts +13 -11
  284. package/dist/deep-recall-http-glue.js +12 -2
  285. package/dist/deep-recall-mcp-tools.d.ts +13 -11
  286. package/dist/deep-recall-policy-llm.d.ts +2 -1
  287. package/dist/deep-recall-policy-llm.js +4 -3
  288. package/dist/deep-recall-seeds.d.ts +2 -1
  289. package/dist/delinearize.d.ts +2 -1
  290. package/dist/dependency-propagation-config.d.ts +2 -1
  291. package/dist/{dependency-propagation-delivery-CQPCu0o5.d.ts → dependency-propagation-delivery-CDQCxNll.d.ts} +1 -1
  292. package/dist/direct-answer-wiring.d.ts +2 -1
  293. package/dist/direct-answer.d.ts +2 -1
  294. package/dist/embedding-fallback.d.ts +2 -1
  295. package/dist/enrichment/index.d.ts +2 -1
  296. package/dist/entity-origin-fields.d.ts +2 -1
  297. package/dist/entity-retrieval.d.ts +3 -2
  298. package/dist/entity-retrieval.js +28 -27
  299. package/dist/entity-schema.d.ts +2 -1
  300. package/dist/episodic-context.d.ts +2 -1
  301. package/dist/eval-trajectory-contracts.d.ts +2 -1
  302. package/dist/eval-trajectory-store.d.ts +2 -1
  303. package/dist/eval-trajectory.d.ts +2 -1
  304. package/dist/explicit-capture.d.ts +11 -9
  305. package/dist/explicit-capture.js +6 -6
  306. package/dist/external-wiki-access.d.ts +13 -11
  307. package/dist/external-wiki-access.js +65 -60
  308. package/dist/external-wiki-collection-registration.d.ts +2 -1
  309. package/dist/external-wiki-collection.d.ts +2 -1
  310. package/dist/external-wiki-mcp-tools.d.ts +13 -11
  311. package/dist/extraction-error-classification.d.ts +2 -1
  312. package/dist/extraction-faithfulness.d.ts +2 -1
  313. package/dist/extraction-faithfulness.js +4 -3
  314. package/dist/extraction-judge-telemetry.d.ts +2 -1
  315. package/dist/extraction-judge-training.d.ts +2 -1
  316. package/dist/extraction-judge.d.ts +2 -1
  317. package/dist/extraction-judge.js +5 -4
  318. package/dist/extraction-liveness.d.ts +2 -1
  319. package/dist/extraction-normalization.d.ts +2 -1
  320. package/dist/extraction-prompt.d.ts +2 -1
  321. package/dist/extraction-source-grounding-rules.d.ts +2 -1
  322. package/dist/extraction-source-grounding.d.ts +2 -1
  323. package/dist/extraction.d.ts +2 -1
  324. package/dist/extraction.js +40 -38
  325. package/dist/fallback-llm.d.ts +2 -1
  326. package/dist/fallback-llm.js +3 -2
  327. package/dist/{first-start-migration-RC345GPL.js → first-start-migration-L3UFX5CU.js} +3 -3
  328. package/dist/generic-recall-paths-CqAZyXKX.d.ts +23 -0
  329. package/dist/graph-append-error.d.ts +2 -1
  330. package/dist/graph-dashboard-diff.d.ts +2 -1
  331. package/dist/graph-dashboard-key.d.ts +2 -1
  332. package/dist/graph-dashboard-parser.d.ts +2 -1
  333. package/dist/graph-edge-reinforcement.d.ts +2 -1
  334. package/dist/graph-jsonl.d.ts +2 -1
  335. package/dist/graph-path-reconstruction.d.ts +2 -1
  336. package/dist/graph-path-scoring.d.ts +2 -1
  337. package/dist/graph-snapshot.d.ts +2 -1
  338. package/dist/graph.d.ts +2 -1
  339. package/dist/harmonic-retrieval.js +2 -2
  340. package/dist/importance.d.ts +2 -1
  341. package/dist/importers/index.d.ts +2 -1
  342. package/dist/importers/test-utils.d.ts +2 -1
  343. package/dist/in-flight-reads.d.ts +2 -1
  344. package/dist/{index-C9VXenR8.d.ts → index-BNluTxBp.d.ts} +2 -2
  345. package/dist/index.d.ts +963 -945
  346. package/dist/index.js +323 -221
  347. package/dist/intent.d.ts +2 -1
  348. package/dist/lcm/engine.d.ts +2 -1
  349. package/dist/lcm/engine.js +2 -2
  350. package/dist/lcm/index.d.ts +2 -1
  351. package/dist/lcm/index.js +7 -7
  352. package/dist/lcm/tools.d.ts +2 -1
  353. package/dist/lifecycle.d.ts +2 -1
  354. package/dist/live-connectors-runner.d.ts +2 -1
  355. package/dist/local-llm.d.ts +4 -1
  356. package/dist/local-llm.js +2 -2
  357. package/dist/local-model-endpoint.d.ts +2 -1
  358. package/dist/location/index.d.ts +4 -3
  359. package/dist/location/index.js +33 -32
  360. package/dist/maintenance/memory-governance.d.ts +2 -1
  361. package/dist/maintenance/memory-governance.js +28 -27
  362. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +3 -2
  363. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +28 -27
  364. package/dist/maintenance/rebuild-memory-projection.d.ts +3 -2
  365. package/dist/maintenance/rebuild-memory-projection.js +29 -28
  366. package/dist/{maintenance-C14sorKa.d.ts → maintenance-8hmWOMY_.d.ts} +378 -4
  367. package/dist/mcp-memory-inspector-app.d.ts +13 -11
  368. package/dist/memory-action-policy.d.ts +2 -1
  369. package/dist/memory-cache.d.ts +2 -1
  370. package/dist/memory-controller.d.ts +2 -1
  371. package/dist/memory-lifecycle-ledger-utils.d.ts +2 -1
  372. package/dist/memory-projection-store.d.ts +2 -1
  373. package/dist/memory-provenance.d.ts +2 -1
  374. package/dist/memory-snapshot.d.ts +2 -1
  375. package/dist/memory-subject-cli.d.ts +13 -11
  376. package/dist/memory-subject.d.ts +13 -11
  377. package/dist/memory-worth-outcomes.d.ts +3 -2
  378. package/dist/migrate/from-engram.js +2 -2
  379. package/dist/models-json.d.ts +2 -1
  380. package/dist/namespaces/migrate.d.ts +4 -3
  381. package/dist/namespaces/migrate.js +29 -28
  382. package/dist/namespaces/principal.d.ts +2 -1
  383. package/dist/namespaces/search.d.ts +2 -1
  384. package/dist/namespaces/search.js +11 -11
  385. package/dist/namespaces/storage.d.ts +4 -3
  386. package/dist/namespaces/storage.js +28 -27
  387. package/dist/native-knowledge.d.ts +2 -1
  388. package/dist/network/tailscale.js +2 -2
  389. package/dist/offline-sync-impression-drain.d.ts +2 -1
  390. package/dist/offline-sync-impression-drain.js +6 -6
  391. package/dist/operator-doctor-corpus.d.ts +2 -1
  392. package/dist/operator-doctor-corpus.js +32 -31
  393. package/dist/operator-doctor-replica.d.ts +2 -1
  394. package/dist/operator-toolkit.d.ts +4 -3
  395. package/dist/operator-toolkit.js +48 -46
  396. package/dist/orchestration/compression-guideline-coordinator.d.ts +3 -2
  397. package/dist/orchestration/maintenance.d.ts +5 -4
  398. package/dist/orchestration/maintenance.js +47 -42
  399. package/dist/{orchestrator-kqSzGv7e.d.ts → orchestrator-BUd_3Q86.d.ts} +17 -29
  400. package/dist/orchestrator.d.ts +11 -9
  401. package/dist/orchestrator.js +144 -138
  402. package/dist/patterns-cli.d.ts +2 -1
  403. package/dist/{pipeline-DRUwHb1X.d.ts → pipeline-Dv1Bv0ma.d.ts} +1 -1
  404. package/dist/policy-runtime.d.ts +2 -1
  405. package/dist/proactive-contention.d.ts +2 -1
  406. package/dist/provenance.d.ts +2 -1
  407. package/dist/{public-http-CW3l0g3P.d.ts → public-http-L-IymRBN.d.ts} +1 -1
  408. package/dist/{qmd-BVWlg1YS.d.ts → qmd-Mj508lHA.d.ts} +1 -1
  409. package/dist/qmd-preflight.d.ts +3 -2
  410. package/dist/qmd-recall-cache.d.ts +2 -1
  411. package/dist/qmd.d.ts +3 -2
  412. package/dist/qmd.js +2 -2
  413. package/dist/recall-concurrency-config.d.ts +2 -1
  414. package/dist/recall-disclosure-escalation.d.ts +2 -1
  415. package/dist/recall-explain-renderer.d.ts +2 -1
  416. package/dist/recall-explain-renderer.js +3 -3
  417. package/dist/recall-memory-map.d.ts +2 -1
  418. package/dist/recall-navigate-access.d.ts +2 -1
  419. package/dist/recall-navigate-access.js +2 -2
  420. package/dist/recall-navigate-disclosure.d.ts +2 -1
  421. package/dist/recall-navigate-disclosure.js +1 -1
  422. package/dist/recall-navigate.d.ts +2 -1
  423. package/dist/recall-navigate.js +2 -2
  424. package/dist/recall-planner-llm.d.ts +2 -1
  425. package/dist/recall-planner-llm.js +3 -2
  426. package/dist/recall-planner-llm.js.map +1 -1
  427. package/dist/recall-state-view-admission.d.ts +56 -0
  428. package/dist/recall-state-view-admission.js +39 -0
  429. package/dist/recall-state-view-admission.js.map +1 -0
  430. package/dist/recall-state-view-inject.js +2 -2
  431. package/dist/recall-state-view-render.js +2 -2
  432. package/dist/recall-state-view-widen.d.ts +18 -1
  433. package/dist/recall-state-view-widen.js +2 -2
  434. package/dist/recall-state-view-wire.d.ts +1 -1
  435. package/dist/recall-state-view-wire.js +3 -3
  436. package/dist/recall-state-view.d.ts +1 -0
  437. package/dist/recall-state-view.js +1 -1
  438. package/dist/recall-state.d.ts +2 -1
  439. package/dist/recall-tag-filter.d.ts +2 -1
  440. package/dist/recall-timings.d.ts +2 -1
  441. package/dist/recall-xray-cli.d.ts +2 -1
  442. package/dist/recall-xray-cli.js +4 -4
  443. package/dist/recall-xray-renderer.d.ts +2 -1
  444. package/dist/recall-xray-renderer.js +3 -3
  445. package/dist/recall-xray.d.ts +9 -1
  446. package/dist/recall-xray.js +2 -2
  447. package/dist/reconcile/cursor.d.ts +11 -2
  448. package/dist/reconcile/cursor.js +6 -4
  449. package/dist/reconcile/cursor.js.map +1 -1
  450. package/dist/reconcile/manifest.d.ts +37 -2
  451. package/dist/reconcile/manifest.js +15 -5
  452. package/dist/reconcile/plan.d.ts +2 -1
  453. package/dist/replay/normalizers/chatgpt.d.ts +2 -1
  454. package/dist/replay/normalizers/claude.d.ts +2 -1
  455. package/dist/replay/normalizers/openclaw.d.ts +2 -1
  456. package/dist/replay/normalizers/shared.d.ts +2 -1
  457. package/dist/replay/runner.d.ts +2 -1
  458. package/dist/replay/types.d.ts +2 -1
  459. package/dist/replica-divergence.d.ts +2 -1
  460. package/dist/replica-peers-config.d.ts +2 -1
  461. package/dist/{resolution-VKATP2HT.js → resolution-OHJZG45O.js} +6 -6
  462. package/dist/resolution-OHJZG45O.js.map +1 -0
  463. package/dist/resolve-auth-token.d.ts +2 -1
  464. package/dist/resume-bundles.js +15 -13
  465. package/dist/retrieval-agents.d.ts +3 -2
  466. package/dist/retrieval-tiers.d.ts +2 -1
  467. package/dist/routing/engine.d.ts +2 -1
  468. package/dist/routing/store.d.ts +2 -1
  469. package/dist/runtime/child-process.d.ts +1 -1
  470. package/dist/runtime/child-process.js +1 -1
  471. package/dist/salvage-envelope.d.ts +2 -1
  472. package/dist/salvage-envelope.js +2 -2
  473. package/dist/schemas.d.ts +176 -176
  474. package/dist/{scope-profiles-Vl00B1KU.d.ts → scope-profiles-B6BGVbxm.d.ts} +1 -1
  475. package/dist/search/embed-helper.d.ts +2 -1
  476. package/dist/search/factory.d.ts +2 -1
  477. package/dist/search/factory.js +10 -10
  478. package/dist/search/index.d.ts +2 -1
  479. package/dist/search/index.js +14 -14
  480. package/dist/search/lancedb-backend.d.ts +2 -1
  481. package/dist/search/lancedb-backend.js +2 -2
  482. package/dist/search/meilisearch-backend.d.ts +2 -1
  483. package/dist/search/meilisearch-backend.js +2 -2
  484. package/dist/search/noop-backend.d.ts +2 -1
  485. package/dist/search/orama-backend.d.ts +2 -1
  486. package/dist/search/orama-backend.js +2 -2
  487. package/dist/search/port.d.ts +2 -1
  488. package/dist/search/remote-backend.d.ts +2 -1
  489. package/dist/{semantic-consolidation-BC9-GFuT.d.ts → semantic-consolidation-J-598F5M.d.ts} +1 -1
  490. package/dist/semantic-consolidation.d.ts +3 -2
  491. package/dist/semantic-consolidation.js +29 -28
  492. package/dist/semantic-rule-promotion.js +28 -27
  493. package/dist/semantic-rule-verifier.d.ts +2 -1
  494. package/dist/semantic-rule-verifier.js +28 -27
  495. package/dist/{service-BOy6dHfc.d.ts → service-ZQkJ52cz.d.ts} +2 -2
  496. package/dist/session-observer-bands.d.ts +2 -1
  497. package/dist/session-observer-state.d.ts +2 -1
  498. package/dist/shared-context/manager.d.ts +8 -7
  499. package/dist/signal.d.ts +2 -1
  500. package/dist/source-agent-qualifier.d.ts +2 -1
  501. package/dist/source-agent-qualifier.js +38 -36
  502. package/dist/standup/build.js +29 -28
  503. package/dist/{storage-BLJRnFi6.d.ts → storage-CU_hZUgP.d.ts} +67 -6
  504. package/dist/storage.d.ts +4 -3
  505. package/dist/storage.js +27 -26
  506. package/dist/subject-config.d.ts +2 -1
  507. package/dist/subject-config.js +2 -2
  508. package/dist/summarizer.d.ts +2 -1
  509. package/dist/summarizer.js +5 -5
  510. package/dist/summary-snapshot.d.ts +2 -1
  511. package/dist/support-passport/index.d.ts +49 -15
  512. package/dist/support-passport/index.js +72 -63
  513. package/dist/temporal-supersession.d.ts +3 -2
  514. package/dist/temporal-timeline-recall.d.ts +2 -1
  515. package/dist/temporal-validity.d.ts +2 -1
  516. package/dist/threading.d.ts +2 -1
  517. package/dist/tier-migration.d.ts +3 -2
  518. package/dist/tier-routing.d.ts +2 -1
  519. package/dist/tier-routing.js +2 -2
  520. package/dist/{tier-stats-KA6OZX2C.js → tier-stats-VK5PCO2L.js} +3 -3
  521. package/dist/topics.d.ts +2 -1
  522. package/dist/transcript.d.ts +2 -1
  523. package/dist/transfer/capsule-import.js +1 -1
  524. package/dist/transfer/export-okf.d.ts +2 -1
  525. package/dist/transfer/export-okf.js +29 -28
  526. package/dist/transfer/types.d.ts +102 -102
  527. package/dist/trust-score-stage.d.ts +2 -1
  528. package/dist/trust-score.d.ts +2 -1
  529. package/dist/{types-YY-eKKU7.d.ts → types-BGxTvLBO.d.ts} +58 -13
  530. package/dist/types.d.ts +2 -1
  531. package/dist/types.js +1 -1
  532. package/dist/utility-runtime.d.ts +2 -1
  533. package/dist/verified-recall.js +28 -27
  534. package/dist/who-knows-cli.d.ts +13 -11
  535. package/dist/who-knows-cli.js +29 -28
  536. package/dist/who-knows.d.ts +13 -11
  537. package/dist/who-knows.js +28 -27
  538. package/dist/write-envelope.d.ts +4 -2
  539. package/dist/write-envelope.js +3 -1
  540. package/package.json +12 -2
  541. package/src/access-category-alias.test.ts +216 -0
  542. package/src/access-mcp.test.ts +73 -0
  543. package/src/access-mcp.ts +6 -6
  544. package/src/access-observe-write-surface.ts +19 -4
  545. package/src/access-offline-manifest.ts +297 -16
  546. package/src/access-recall-surface.ts +5 -5
  547. package/src/access-schema.ts +76 -7
  548. package/src/access-service.ts +11 -2
  549. package/src/activity/config.test.ts +124 -1
  550. package/src/activity/config.ts +150 -18
  551. package/src/activity/index.ts +3 -0
  552. package/src/activity/journal-extract-storage.test.ts +129 -0
  553. package/src/activity/journal-extract.test.ts +314 -0
  554. package/src/activity/journal-extract.ts +247 -0
  555. package/src/activity/journal-heading.test.ts +24 -1
  556. package/src/activity/journal-heading.ts +36 -0
  557. package/src/activity/journal-read.test.ts +242 -0
  558. package/src/activity/journal-read.ts +183 -0
  559. package/src/activity/journal-source.test.ts +15 -15
  560. package/src/activity/journal-source.ts +21 -14
  561. package/src/activity/journal-state.lock-worker.ts +30 -0
  562. package/src/activity/journal-state.test.ts +144 -0
  563. package/src/activity/journal-state.ts +107 -0
  564. package/src/activity/journal-strip.test.ts +106 -52
  565. package/src/activity/journal-strip.ts +35 -10
  566. package/src/activity/journal-vault-integration.test.ts +230 -0
  567. package/src/activity/journal-vault-provenance.test.ts +9 -7
  568. package/src/activity/journal-vault-provenance.ts +4 -10
  569. package/src/activity/journal-vault-read.test.ts +3 -2
  570. package/src/activity/journal-vault-read.ts +9 -139
  571. package/src/activity/journal.test.ts +74 -23
  572. package/src/activity/runner.test.ts +116 -1
  573. package/src/activity/runner.ts +25 -0
  574. package/src/activity/scheduler.ts +4 -0
  575. package/src/activity/store.test.ts +18 -0
  576. package/src/activity/store.ts +14 -0
  577. package/src/activity/sync-registration.ts +4 -0
  578. package/src/activity/timeline/analysis-metadata.ts +2 -0
  579. package/src/activity/timeline/analysis-provider.ts +140 -0
  580. package/src/activity/timeline/analysis-run.test.ts +419 -0
  581. package/src/activity/timeline/analysis-run.ts +106 -0
  582. package/src/activity/timeline/analysis.ts +66 -37
  583. package/src/activity/timeline/corrections.ts +9 -0
  584. package/src/activity/timeline/index.ts +3 -0
  585. package/src/activity/timeline/query.test.ts +71 -0
  586. package/src/activity/timeline/query.ts +57 -8
  587. package/src/activity/timeline/regenerate.test.ts +505 -0
  588. package/src/activity/timeline/regenerate.ts +373 -0
  589. package/src/activity/types.ts +40 -5
  590. package/src/adapters/grok-opencode.test.ts +146 -0
  591. package/src/adapters/grok.ts +53 -0
  592. package/src/adapters/index.ts +2 -0
  593. package/src/adapters/opencode.ts +52 -0
  594. package/src/adapters/registry.ts +4 -0
  595. package/src/cli-fallback.ts +13 -4
  596. package/src/config.test.ts +3 -1
  597. package/src/config.ts +4 -0
  598. package/src/dedup/merge.test.ts +732 -25
  599. package/src/fallback-llm.test.ts +53 -0
  600. package/src/fallback-llm.ts +12 -0
  601. package/src/index.ts +2 -0
  602. package/src/local-llm.ts +3 -1
  603. package/src/orchestration/dependency-propagation-recovery-replay.ts +1 -1
  604. package/src/orchestration/extraction-persist-deps.ts +9 -0
  605. package/src/orchestration/extraction-persist-promotion.test.ts +265 -6
  606. package/src/orchestration/extraction-persist-promotion.ts +42 -3
  607. package/src/orchestration/extraction-persist.ts +3 -3
  608. package/src/orchestration/harmonic-construction-persist.test.ts +115 -4
  609. package/src/orchestration/harmonic-construction-persist.ts +34 -6
  610. package/src/orchestration/maintenance.ts +1 -0
  611. package/src/orchestration/orchestrator-helpers.ts +6 -0
  612. package/src/orchestration/recall-entry.ts +16 -0
  613. package/src/orchestration/recall-internal-deps.ts +14 -0
  614. package/src/orchestration/recall-internal.ts +41 -58
  615. package/src/orchestration/recall-result-formatter.ts +11 -1
  616. package/src/orchestration/recall-search-pipeline.ts +121 -11
  617. package/src/orchestration/recall-state-view-pipeline.test.ts +211 -0
  618. package/src/orchestration/semantic-merge-commit-effects.ts +76 -17
  619. package/src/orchestration/semantic-merge-persist.ts +121 -16
  620. package/src/orchestration/semantic-merge-promotion-payload.ts +133 -54
  621. package/src/orchestrator.ts +7 -35
  622. package/src/providers/codex-subscription.test.ts +666 -0
  623. package/src/providers/codex-subscription.ts +743 -0
  624. package/src/recall-disclosure.test.ts +20 -0
  625. package/src/recall-state-view-admission.ts +114 -0
  626. package/src/recall-state-view-asof.test.ts +176 -0
  627. package/src/recall-state-view-call.test.ts +175 -0
  628. package/src/recall-state-view-config.test.ts +16 -0
  629. package/src/recall-state-view-widen.test.ts +70 -0
  630. package/src/recall-state-view-widen.ts +28 -7
  631. package/src/recall-state-view-wire.ts +3 -1
  632. package/src/recall-state-view-zero-diff.test.ts +20 -11
  633. package/src/recall-state-view.test.ts +142 -0
  634. package/src/recall-state-view.ts +72 -24
  635. package/src/recall-xray-renderer.test.ts +27 -0
  636. package/src/recall-xray-renderer.ts +4 -0
  637. package/src/recall-xray.ts +13 -0
  638. package/src/reconcile/cursor.ts +23 -33
  639. package/src/reconcile/manifest.ts +96 -11
  640. package/src/reconcile-identity-cache.test.ts +378 -0
  641. package/src/runtime/child-process.ts +1 -1
  642. package/src/storage/cas-revision-host.ts +75 -0
  643. package/src/storage/cas-revision-store.test.ts +459 -0
  644. package/src/storage/cas-revision-store.ts +661 -0
  645. package/src/storage/deletion-revision-store.ts +80 -6
  646. package/src/storage/tombstone-blocked-capture-index.ts +15 -0
  647. package/src/storage/tombstone-blocked-capture-mutation.ts +67 -7
  648. package/src/storage/tombstone-blocked-capture-sync.ts +55 -20
  649. package/src/storage-contract/failure-semantics.test.ts +1 -1
  650. package/src/storage-frontmatter-cas.test.ts +698 -1
  651. package/src/storage-replay.test.ts +166 -3
  652. package/src/storage.ts +41 -41
  653. package/src/support-passport/card-projection.ts +82 -33
  654. package/src/temporal-supersession.test.ts +10 -10
  655. package/src/types.ts +7 -7
  656. package/src/write-envelope.ts +1 -1
  657. package/dist/chunk-22FVR2KE.js.map +0 -1
  658. package/dist/chunk-2JVJ7UHC.js.map +0 -1
  659. package/dist/chunk-3QQTXYZ6.js.map +0 -1
  660. package/dist/chunk-4UDQUPT5.js +0 -560
  661. package/dist/chunk-4UDQUPT5.js.map +0 -1
  662. package/dist/chunk-A7XEPMQ6.js.map +0 -1
  663. package/dist/chunk-AU7Q3LSC.js +0 -56
  664. package/dist/chunk-AU7Q3LSC.js.map +0 -1
  665. package/dist/chunk-BLUYQFRH.js.map +0 -1
  666. package/dist/chunk-CZYYJZB6.js.map +0 -1
  667. package/dist/chunk-EEOUMG3J.js.map +0 -1
  668. package/dist/chunk-FDLDOEO6.js.map +0 -1
  669. package/dist/chunk-FYDW33ZB.js +0 -13
  670. package/dist/chunk-GVG3JYBI.js.map +0 -1
  671. package/dist/chunk-H272ZPQ3.js.map +0 -1
  672. package/dist/chunk-HVAEXYPL.js.map +0 -1
  673. package/dist/chunk-JEIXTYVG.js.map +0 -1
  674. package/dist/chunk-LRICZIGN.js +0 -52
  675. package/dist/chunk-LRICZIGN.js.map +0 -1
  676. package/dist/chunk-N7RWREIQ.js.map +0 -1
  677. package/dist/chunk-O75CRYGF.js.map +0 -1
  678. package/dist/chunk-Q3O3VKRB.js.map +0 -1
  679. package/dist/chunk-SEDEKFYQ.js +0 -1
  680. package/dist/chunk-SO7SV523.js.map +0 -1
  681. package/dist/chunk-SQJ3SDIW.js.map +0 -1
  682. package/dist/chunk-TLPZ6MKZ.js.map +0 -1
  683. package/dist/chunk-WJBZMNNS.js.map +0 -1
  684. package/dist/chunk-XQ2Q43XD.js.map +0 -1
  685. package/dist/chunk-Z4PCVRTN.js.map +0 -1
  686. package/src/activity/journal-mode.test.ts +0 -32
  687. package/src/activity/journal-mode.ts +0 -20
  688. /package/dist/{chunk-SEDEKFYQ.js.map → activity/digest.js.map} +0 -0
  689. /package/dist/{capsule-merge-IPG4IOFP.js.map → capsule-merge-ZCXUPLNJ.js.map} +0 -0
  690. /package/dist/{chunk-CDKHKZL5.js.map → chunk-2524MOWK.js.map} +0 -0
  691. /package/dist/{chunk-IY2FVXM6.js.map → chunk-2AU4D4HQ.js.map} +0 -0
  692. /package/dist/{chunk-QDY6KYTN.js.map → chunk-2JCA2PQT.js.map} +0 -0
  693. /package/dist/{chunk-RSVEP77Y.js.map → chunk-2UZ5ZH6W.js.map} +0 -0
  694. /package/dist/{chunk-NWWXSJX5.js.map → chunk-34QW2LK2.js.map} +0 -0
  695. /package/dist/{chunk-S7DPKM5W.js.map → chunk-353C5UNV.js.map} +0 -0
  696. /package/dist/{chunk-GQOMZ3MK.js.map → chunk-36UBSLFN.js.map} +0 -0
  697. /package/dist/{chunk-DBQWVT2H.js.map → chunk-3CBI2ZSA.js.map} +0 -0
  698. /package/dist/{chunk-NZXEK3UF.js.map → chunk-3Q3N35W7.js.map} +0 -0
  699. /package/dist/{chunk-YYGZJPOK.js.map → chunk-42DJ235G.js.map} +0 -0
  700. /package/dist/{chunk-7VJXIDOC.js.map → chunk-4JVQRFZD.js.map} +0 -0
  701. /package/dist/{chunk-WHBVXTUI.js.map → chunk-4PB2MBY6.js.map} +0 -0
  702. /package/dist/{chunk-TEYN7ZYF.js.map → chunk-4WCNPQQ5.js.map} +0 -0
  703. /package/dist/{chunk-RBGREYVJ.js.map → chunk-5QBDLMGG.js.map} +0 -0
  704. /package/dist/{chunk-RKBLRTNT.js.map → chunk-5SDSVX7N.js.map} +0 -0
  705. /package/dist/{chunk-LPECRQO4.js.map → chunk-5THU7NFP.js.map} +0 -0
  706. /package/dist/{chunk-LWA7MDVO.js.map → chunk-6CCRSQWT.js.map} +0 -0
  707. /package/dist/{chunk-TIT2C6WX.js.map → chunk-6XYC7NM4.js.map} +0 -0
  708. /package/dist/{chunk-FHQSPTPZ.js.map → chunk-6YAIN5XJ.js.map} +0 -0
  709. /package/dist/{chunk-PV36INNL.js.map → chunk-757NP436.js.map} +0 -0
  710. /package/dist/{chunk-6H5JYDOM.js.map → chunk-7J2CGXG3.js.map} +0 -0
  711. /package/dist/{chunk-FBMYGNOC.js.map → chunk-A2YQL2FF.js.map} +0 -0
  712. /package/dist/{chunk-X2NFFBTO.js.map → chunk-A7GQBJP5.js.map} +0 -0
  713. /package/dist/{chunk-MPYD657E.js.map → chunk-A7WOWDZK.js.map} +0 -0
  714. /package/dist/{chunk-C4OTC6WY.js.map → chunk-AIKTQVV3.js.map} +0 -0
  715. /package/dist/{chunk-CGC5UQCF.js.map → chunk-AKE4GGQ3.js.map} +0 -0
  716. /package/dist/{chunk-VP67GZ7T.js.map → chunk-APFKZVJS.js.map} +0 -0
  717. /package/dist/{chunk-M75RYSHS.js.map → chunk-AQIRQUCP.js.map} +0 -0
  718. /package/dist/{chunk-S7T2TY65.js.map → chunk-AXFR2NQ5.js.map} +0 -0
  719. /package/dist/{chunk-PSPABFN2.js.map → chunk-BD7JTBYP.js.map} +0 -0
  720. /package/dist/{chunk-FCSZ4K2X.js.map → chunk-BJJWRWER.js.map} +0 -0
  721. /package/dist/{chunk-JT3EB7ZL.js.map → chunk-BNGHPYZU.js.map} +0 -0
  722. /package/dist/{chunk-MFJBANPX.js.map → chunk-C2BFTYD7.js.map} +0 -0
  723. /package/dist/{chunk-3JVLGJCY.js.map → chunk-C6KRO3SU.js.map} +0 -0
  724. /package/dist/{chunk-AOCP6JA7.js.map → chunk-D3IZCN5P.js.map} +0 -0
  725. /package/dist/{chunk-ROKKIMON.js.map → chunk-EJIEQOPB.js.map} +0 -0
  726. /package/dist/{chunk-ET356KSB.js.map → chunk-F4TWWUMP.js.map} +0 -0
  727. /package/dist/{chunk-CLLPJ6QT.js.map → chunk-FQXJAC3T.js.map} +0 -0
  728. /package/dist/{chunk-DD5JFCWM.js.map → chunk-GCBIXUPT.js.map} +0 -0
  729. /package/dist/{chunk-ROGRI25A.js.map → chunk-I3H5LFOI.js.map} +0 -0
  730. /package/dist/{chunk-S65WXHNK.js.map → chunk-IFFLUCCU.js.map} +0 -0
  731. /package/dist/{chunk-D5LORF7A.js.map → chunk-JZDH2ZZK.js.map} +0 -0
  732. /package/dist/{chunk-2GPE5UCR.js.map → chunk-K6IPSW5B.js.map} +0 -0
  733. /package/dist/{chunk-HG6HXVHQ.js.map → chunk-KDJHLOZP.js.map} +0 -0
  734. /package/dist/{chunk-I27RSQRR.js.map → chunk-KYGOQV37.js.map} +0 -0
  735. /package/dist/{chunk-VZWXFXLX.js.map → chunk-LMCD5W5B.js.map} +0 -0
  736. /package/dist/{chunk-MKD3OMPS.js.map → chunk-M3MYMWXG.js.map} +0 -0
  737. /package/dist/{chunk-DITMGZOL.js.map → chunk-MMG5K6XJ.js.map} +0 -0
  738. /package/dist/{chunk-VGXM5B4H.js.map → chunk-MNIPH6LD.js.map} +0 -0
  739. /package/dist/{chunk-MKWKYHXJ.js.map → chunk-OB3XMWX5.js.map} +0 -0
  740. /package/dist/{chunk-XU6OEECT.js.map → chunk-OQQXGYMX.js.map} +0 -0
  741. /package/dist/{chunk-47DEYNMR.js.map → chunk-PEXW2JCK.js.map} +0 -0
  742. /package/dist/{chunk-42SDNZCU.js.map → chunk-QF4J3KMV.js.map} +0 -0
  743. /package/dist/{chunk-SB6PSOP7.js.map → chunk-QLJ6762U.js.map} +0 -0
  744. /package/dist/{chunk-XOVKXJEP.js.map → chunk-R3TLVTWW.js.map} +0 -0
  745. /package/dist/{chunk-PHNAB54Q.js.map → chunk-RQO3J4MR.js.map} +0 -0
  746. /package/dist/{chunk-5N53UBH2.js.map → chunk-RR7G2X7C.js.map} +0 -0
  747. /package/dist/{chunk-DCJ3YFIC.js.map → chunk-S2ULTQZR.js.map} +0 -0
  748. /package/dist/{chunk-GY5WZBA6.js.map → chunk-S76KRJDG.js.map} +0 -0
  749. /package/dist/{chunk-EEC4PCG5.js.map → chunk-SZDLX763.js.map} +0 -0
  750. /package/dist/{chunk-E2ZHGBAK.js.map → chunk-T2JSUEH6.js.map} +0 -0
  751. /package/dist/{chunk-QMGXMJ2O.js.map → chunk-T2YFZ27G.js.map} +0 -0
  752. /package/dist/{chunk-LEPOP46W.js.map → chunk-TFA6HPOA.js.map} +0 -0
  753. /package/dist/{chunk-BA6WOZOT.js.map → chunk-TK4FHQRN.js.map} +0 -0
  754. /package/dist/{chunk-ZNJSBIP4.js.map → chunk-TNSCIPBQ.js.map} +0 -0
  755. /package/dist/{chunk-YUMDFDUA.js.map → chunk-TWYTGIBR.js.map} +0 -0
  756. /package/dist/{chunk-EZZV7OQL.js.map → chunk-UEZKN6VR.js.map} +0 -0
  757. /package/dist/{chunk-HY55QQD7.js.map → chunk-UJX4I26O.js.map} +0 -0
  758. /package/dist/{chunk-CBCNKKZD.js.map → chunk-VIZR45AN.js.map} +0 -0
  759. /package/dist/{chunk-ZG74PWRW.js.map → chunk-VZAKYDMJ.js.map} +0 -0
  760. /package/dist/{chunk-ITPS5DDH.js.map → chunk-W5BLTZZJ.js.map} +0 -0
  761. /package/dist/{chunk-H3TKENU4.js.map → chunk-WIKO4SCR.js.map} +0 -0
  762. /package/dist/{chunk-YFLLGRXO.js.map → chunk-X2QPKLPL.js.map} +0 -0
  763. /package/dist/{chunk-FGGYSN4P.js.map → chunk-X424T5JQ.js.map} +0 -0
  764. /package/dist/{chunk-NAXDPKVM.js.map → chunk-XPJNT6PI.js.map} +0 -0
  765. /package/dist/{contradiction-scan-NOYMFG66.js.map → chunk-XW2T4QAW.js.map} +0 -0
  766. /package/dist/{chunk-VED2YHUD.js.map → chunk-YEDVOYL2.js.map} +0 -0
  767. /package/dist/{chunk-RC5DXXWC.js.map → chunk-YM7YN37H.js.map} +0 -0
  768. /package/dist/{chunk-VLXBE57O.js.map → chunk-YVGXH72Y.js.map} +0 -0
  769. /package/dist/{chunk-YQAXP5AC.js.map → chunk-YXLUTALO.js.map} +0 -0
  770. /package/dist/{chunk-565C6ZFO.js.map → chunk-Z7YDVHDI.js.map} +0 -0
  771. /package/dist/{chunk-XUE46UYW.js.map → chunk-ZLN7AROH.js.map} +0 -0
  772. /package/dist/{chunk-HK32G473.js.map → chunk-ZWEZXVYH.js.map} +0 -0
  773. /package/dist/{resolution-VKATP2HT.js.map → contradiction-scan-GVD4JJ7B.js.map} +0 -0
  774. /package/dist/{first-start-migration-RC345GPL.js.map → first-start-migration-L3UFX5CU.js.map} +0 -0
  775. /package/dist/{tier-stats-KA6OZX2C.js.map → tier-stats-VK5PCO2L.js.map} +0 -0
@@ -6,36 +6,36 @@ import {
6
6
  loadSyncState,
7
7
  syncWearableSource,
8
8
  wearableSourceLabel
9
- } from "./chunk-YQAXP5AC.js";
9
+ } from "./chunk-YXLUTALO.js";
10
10
  import {
11
11
  CompressionGuidelineCoordinator
12
12
  } from "./chunk-UXREWVW4.js";
13
13
  import {
14
14
  ActivityStore,
15
15
  MaintenanceScheduler
16
- } from "./chunk-WJBZMNNS.js";
16
+ } from "./chunk-7CAY3YKP.js";
17
17
  import {
18
18
  runPeerProfileReasoner
19
19
  } from "./chunk-I74SUMNI.js";
20
20
  import {
21
21
  migrateFromEngram
22
- } from "./chunk-ZG74PWRW.js";
22
+ } from "./chunk-VZAKYDMJ.js";
23
23
  import {
24
24
  LcmEngine
25
- } from "./chunk-X2NFFBTO.js";
26
- import {
27
- chunkTranscriptEntries
28
- } from "./chunk-TECVW3JP.js";
25
+ } from "./chunk-A7GQBJP5.js";
29
26
  import {
30
27
  cleanupConversationChunks
31
28
  } from "./chunk-C5JF6EZ7.js";
32
29
  import {
33
30
  CompoundingEngine,
34
31
  defaultTierMigrationCycleBudget
35
- } from "./chunk-IY2FVXM6.js";
32
+ } from "./chunk-2AU4D4HQ.js";
36
33
  import {
37
34
  SharedContextManager
38
35
  } from "./chunk-CARRTDKC.js";
36
+ import {
37
+ chunkTranscriptEntries
38
+ } from "./chunk-TECVW3JP.js";
39
39
  import {
40
40
  cleanArchivedUserMessage
41
41
  } from "./chunk-47DU4SGJ.js";
@@ -47,6 +47,9 @@ import {
47
47
  import {
48
48
  extractTopics
49
49
  } from "./chunk-KVDUKH5E.js";
50
+ import {
51
+ buildTemporalTimelineRecallSection
52
+ } from "./chunk-2NKY7OC6.js";
50
53
  import {
51
54
  CODEX_THREAD_KEY_PREFIX
52
55
  } from "./chunk-4EX5WZ4M.js";
@@ -55,7 +58,7 @@ import {
55
58
  } from "./chunk-YRFAYOFQ.js";
56
59
  import {
57
60
  decideTierTransition
58
- } from "./chunk-DD5JFCWM.js";
61
+ } from "./chunk-GCBIXUPT.js";
59
62
  import {
60
63
  TmtBuilder
61
64
  } from "./chunk-ECZU5BJH.js";
@@ -63,9 +66,6 @@ import {
63
66
  buildTargetedFactRecallSection,
64
67
  shouldRecallTargetedFactEvidence
65
68
  } from "./chunk-T67LUYCR.js";
66
- import {
67
- buildTemporalTimelineRecallSection
68
- } from "./chunk-2NKY7OC6.js";
69
69
  import {
70
70
  SessionObserverState
71
71
  } from "./chunk-ODZKV2F7.js";
@@ -108,9 +108,14 @@ import {
108
108
  reorderByRankedKeys,
109
109
  rerankLocalOrNoop
110
110
  } from "./chunk-LUDXM7MD.js";
111
+ import {
112
+ filterRecentScanMemoriesForStateView,
113
+ indexStateViewAnnotatedResults,
114
+ resolveRecallStateViewActive
115
+ } from "./chunk-W6IJMWTZ.js";
111
116
  import {
112
117
  applyRecallStateViews
113
- } from "./chunk-FYDW33ZB.js";
118
+ } from "./chunk-BRZWWUCJ.js";
114
119
  import {
115
120
  reorderRecallResultsWithMmr
116
121
  } from "./chunk-YDBIWGNI.js";
@@ -153,7 +158,7 @@ import {
153
158
  } from "./chunk-XXSOVESA.js";
154
159
  import {
155
160
  ExtractionEngine
156
- } from "./chunk-QMGXMJ2O.js";
161
+ } from "./chunk-T2YFZ27G.js";
157
162
  import {
158
163
  parseMemoryActionEligibilityContext
159
164
  } from "./chunk-AJTG3CP7.js";
@@ -170,7 +175,7 @@ import {
170
175
  getVerdictKind,
171
176
  judgeFactDurability,
172
177
  validateProcedureExtraction
173
- } from "./chunk-JT3EB7ZL.js";
178
+ } from "./chunk-BNGHPYZU.js";
174
179
  import {
175
180
  pickFactEventTimeAnchor,
176
181
  resolveFactEventTime
@@ -194,7 +199,7 @@ import {
194
199
  buildEntityRecallSection,
195
200
  entityRecentTranscriptLookbackHours,
196
201
  readRecentEntityTranscriptEntries
197
- } from "./chunk-VP67GZ7T.js";
202
+ } from "./chunk-APFKZVJS.js";
198
203
  import {
199
204
  tryDirectAnswer
200
205
  } from "./chunk-VY47VI2T.js";
@@ -203,7 +208,7 @@ import {
203
208
  } from "./chunk-LVXBC6YB.js";
204
209
  import {
205
210
  refreshConvergedNamespaces
206
- } from "./chunk-CBCNKKZD.js";
211
+ } from "./chunk-VIZR45AN.js";
207
212
  import {
208
213
  builtInConnectorPackageSpecifier,
209
214
  ensureBuiltInWearableConnectors,
@@ -212,24 +217,24 @@ import {
212
217
  runTimelinePublishCli,
213
218
  screenCandidateFact,
214
219
  summarizeVaultPublish
215
- } from "./chunk-MYMNC6O5.js";
216
- import {
217
- RoutingRulesStore
218
- } from "./chunk-TBUEE7XF.js";
220
+ } from "./chunk-ISYZ5DUI.js";
219
221
  import {
220
222
  normalizeReplaySessionKey
221
223
  } from "./chunk-AJVLDJU6.js";
224
+ import {
225
+ RoutingRulesStore
226
+ } from "./chunk-TBUEE7XF.js";
222
227
  import {
223
228
  compareVerifiedEpisodeResults,
224
229
  searchVerifiedEpisodes
225
- } from "./chunk-MPYD657E.js";
230
+ } from "./chunk-A7WOWDZK.js";
226
231
  import {
227
232
  ThreadingManager
228
233
  } from "./chunk-OJP3N7UK.js";
229
234
  import {
230
235
  compareVerifiedSemanticRuleResults,
231
236
  searchVerifiedSemanticRules
232
- } from "./chunk-FGGYSN4P.js";
237
+ } from "./chunk-X424T5JQ.js";
233
238
  import {
234
239
  searchWorkProductLedgerEntries
235
240
  } from "./chunk-G7NYVKD6.js";
@@ -242,10 +247,10 @@ import {
242
247
  import {
243
248
  runNamespaceMaintenanceFanout,
244
249
  summarizeNamespaceMaintenanceHealth
245
- } from "./chunk-WHBVXTUI.js";
250
+ } from "./chunk-4PB2MBY6.js";
246
251
  import {
247
252
  planNamespaceMaintenance
248
- } from "./chunk-AOCP6JA7.js";
253
+ } from "./chunk-D3IZCN5P.js";
249
254
  import {
250
255
  isAboveImportanceThreshold,
251
256
  scoreImportance
@@ -274,7 +279,7 @@ import {
274
279
  materializeAfterSemanticConsolidation,
275
280
  parseConsolidationResponse,
276
281
  parseOperatorAwareConsolidationResponse
277
- } from "./chunk-47DEYNMR.js";
282
+ } from "./chunk-PEXW2JCK.js";
278
283
  import {
279
284
  BoxBuilder
280
285
  } from "./chunk-B7RWBZXW.js";
@@ -286,7 +291,7 @@ import {
286
291
  } from "./chunk-6TBIWIAG.js";
287
292
  import {
288
293
  SmartBuffer
289
- } from "./chunk-VED2YHUD.js";
294
+ } from "./chunk-YEDVOYL2.js";
290
295
  import {
291
296
  REFUSED_MERGE_CATEGORIES,
292
297
  applyNoveltyGate,
@@ -295,7 +300,7 @@ import {
295
300
  detectMeetings,
296
301
  embeddingsFromCosineHits,
297
302
  normalizeConnectorScope
298
- } from "./chunk-SQJ3SDIW.js";
303
+ } from "./chunk-SZWEDG3H.js";
299
304
  import {
300
305
  compileCorrectionRule,
301
306
  correctionsFilePath,
@@ -303,8 +308,10 @@ import {
303
308
  saveCorrectionsFile
304
309
  } from "./chunk-ZKOPY4WW.js";
305
310
  import {
306
- resolveJournalSource
307
- } from "./chunk-4UDQUPT5.js";
311
+ isAnalysisFailureKind,
312
+ resolveJournalSource,
313
+ resolveVaultNotePath
314
+ } from "./chunk-5HYUUFMQ.js";
308
315
  import {
309
316
  AMBIENT_CAPTURE_PROMPT_RULE,
310
317
  isHighImpactPersonalFact
@@ -327,7 +334,7 @@ import {
327
334
  } from "./chunk-MI2OTWV5.js";
328
335
  import {
329
336
  MeetingsInputError
330
- } from "./chunk-42SDNZCU.js";
337
+ } from "./chunk-QF4J3KMV.js";
331
338
  import {
332
339
  WearablesInputError,
333
340
  describeErrorForOperator
@@ -345,19 +352,14 @@ import {
345
352
  } from "./chunk-DGS34QSY.js";
346
353
  import {
347
354
  NamespaceCatalog
348
- } from "./chunk-565C6ZFO.js";
355
+ } from "./chunk-Z7YDVHDI.js";
349
356
  import {
350
357
  RecallResultFormatter,
351
358
  SessionContextCoordinator,
352
359
  capturePassiveCorrections,
353
360
  clusterByKey,
354
- detectPassiveCorrections,
355
- filterRecallCandidates,
356
- isGenericRecallExcludedPath,
357
- isTopLevelArchivePath,
358
- journalPath,
359
- writeJournalFile
360
- } from "./chunk-Z4PCVRTN.js";
361
+ detectPassiveCorrections
362
+ } from "./chunk-5A7ZUOBA.js";
361
363
  import {
362
364
  importCapsule
363
365
  } from "./chunk-ZHXSOMYH.js";
@@ -377,23 +379,30 @@ import {
377
379
  } from "./chunk-ROBHL3GL.js";
378
380
  import {
379
381
  HourlySummarizer
380
- } from "./chunk-FCSZ4K2X.js";
382
+ } from "./chunk-BJJWRWER.js";
381
383
  import {
382
384
  LastRecallStore,
383
385
  RecallHandleHistoryStore,
384
386
  TierMigrationStatusStore,
385
387
  clampGraphRecallExpandedEntries
386
388
  } from "./chunk-5UBH37SL.js";
389
+ import {
390
+ filterRecallCandidates,
391
+ isGenericRecallExcludedPath,
392
+ isTopLevelArchivePath,
393
+ journalPath,
394
+ writeJournalFile
395
+ } from "./chunk-A5UQ52YQ.js";
387
396
  import {
388
397
  buildXraySnapshot
389
- } from "./chunk-2JVJ7UHC.js";
398
+ } from "./chunk-XQU3CPF2.js";
390
399
  import {
391
400
  objectiveStateStoreOverrideForNamespace,
392
401
  searchObjectiveStateSnapshots
393
402
  } from "./chunk-HM7RHKS4.js";
394
403
  import {
395
404
  searchHarmonicRetrieval
396
- } from "./chunk-SB6PSOP7.js";
405
+ } from "./chunk-QLJ6762U.js";
397
406
  import {
398
407
  ProfilingCollector
399
408
  } from "./chunk-NLE6TSLG.js";
@@ -402,14 +411,14 @@ import {
402
411
  } from "./chunk-WLZYGLJ4.js";
403
412
  import {
404
413
  LocalLlmClient
405
- } from "./chunk-A7XEPMQ6.js";
414
+ } from "./chunk-LAVJC57X.js";
406
415
  import {
407
416
  contentMatchesRedactionRules,
408
417
  loadRedactionRules
409
418
  } from "./chunk-LTHVM4XN.js";
410
419
  import {
411
420
  shouldSkipImplicitExtraction
412
- } from "./chunk-XUE46UYW.js";
421
+ } from "./chunk-ZLN7AROH.js";
413
422
  import {
414
423
  boundRecallContextComposition,
415
424
  composeRecallContext,
@@ -423,7 +432,7 @@ import {
423
432
  } from "./chunk-BMWN7B3Y.js";
424
433
  import {
425
434
  NamespaceStorageRouter
426
- } from "./chunk-ROKKIMON.js";
435
+ } from "./chunk-EJIEQOPB.js";
427
436
  import {
428
437
  GraphIndex
429
438
  } from "./chunk-5FAGCOZD.js";
@@ -432,7 +441,7 @@ import {
432
441
  } from "./chunk-GKCXTSFF.js";
433
442
  import {
434
443
  buildChainFollowupGenerator
435
- } from "./chunk-5N53UBH2.js";
444
+ } from "./chunk-RR7G2X7C.js";
436
445
  import {
437
446
  QmdResultResolver,
438
447
  StorageManager,
@@ -451,7 +460,10 @@ import {
451
460
  reconstructFusionInputs,
452
461
  selfDeps,
453
462
  serializeFusionDay
454
- } from "./chunk-GVG3JYBI.js";
463
+ } from "./chunk-ZMKYCFJ7.js";
464
+ import {
465
+ buildRetiredFactTombstoneInputs
466
+ } from "./chunk-46WM6JX2.js";
455
467
  import {
456
468
  bodyIsEscaped,
457
469
  decodeTranscriptBody,
@@ -462,18 +474,15 @@ import {
462
474
  saveSpeakerRegistry,
463
475
  speakerRegistryKey
464
476
  } from "./chunk-UHVXE24Y.js";
465
- import {
466
- buildRetiredFactTombstoneInputs
467
- } from "./chunk-46WM6JX2.js";
468
477
  import {
469
478
  NamespaceSearchRouter,
470
479
  namespaceCollectionName
471
- } from "./chunk-FHQSPTPZ.js";
480
+ } from "./chunk-6YAIN5XJ.js";
472
481
  import {
473
482
  createConversationIndexRuntime,
474
483
  createSearchBackend,
475
484
  isSearchBackendEnabled
476
- } from "./chunk-7VJXIDOC.js";
485
+ } from "./chunk-4JVQRFZD.js";
477
486
  import {
478
487
  NoopSearchBackend
479
488
  } from "./chunk-CYEPCZN5.js";
@@ -487,7 +496,7 @@ import {
487
496
  } from "./chunk-S2V7RUCL.js";
488
497
  import {
489
498
  confidenceTier
490
- } from "./chunk-SO7SV523.js";
499
+ } from "./chunk-Q6LCCIZN.js";
491
500
  import {
492
501
  lintWorkspaceFiles,
493
502
  rotateMarkdownFileToArchive
@@ -496,7 +505,10 @@ import {
496
505
  applyFaithfulnessVerdict,
497
506
  createFaithfulnessCounters,
498
507
  runFaithfulnessGateBatch
499
- } from "./chunk-DCJ3YFIC.js";
508
+ } from "./chunk-S2ULTQZR.js";
509
+ import {
510
+ casCommittedRevisionOf
511
+ } from "./chunk-SHEHQBCG.js";
500
512
  import {
501
513
  checkCorpusReadAbort
502
514
  } from "./chunk-5GINB5LC.js";
@@ -537,18 +549,20 @@ import {
537
549
  isValidAsOf,
538
550
  isValidityExpiredNow
539
551
  } from "./chunk-6CIAGZ6X.js";
552
+ import {
553
+ ExtractionDeadlineError,
554
+ ExtractionRunCoordinator,
555
+ classifyExtractionOrigin
556
+ } from "./chunk-326KUXIR.js";
540
557
  import {
541
558
  ARTIFACT_STATUS_CACHE_TTL_MS,
542
559
  BulkImportBatchPartialFailureError,
543
560
  COMPACTION_SIGNAL_MAX_AGE_MS,
544
- ExtractionDeadlineError,
545
- ExtractionRunCoordinator,
546
561
  abortRecallError,
547
562
  appendMemoryToGraphContext,
548
563
  applyQueryAwareCandidateFilter,
549
564
  buildMemoryPathById,
550
565
  buildQmdIntentHint,
551
- classifyExtractionOrigin,
552
566
  computeArtifactCandidateFetchLimit,
553
567
  computeArtifactRecallLimit,
554
568
  computeQmdHybridFetchLimit,
@@ -578,21 +592,13 @@ import {
578
592
  throwIfRecallAborted,
579
593
  tokenizeRecallQuery,
580
594
  utcDateKeysForLocalDay
581
- } from "./chunk-XQ2Q43XD.js";
595
+ } from "./chunk-TLHNF6GA.js";
582
596
  import {
583
597
  inferIntentFromText,
584
598
  intentCompatibilityScore,
585
599
  isTaskInitiationIntent,
586
600
  planRecallMode
587
601
  } from "./chunk-CSAKJVXW.js";
588
- import {
589
- TAG_LIMITS,
590
- composeMemoryEnvelope,
591
- isMemoryCategory
592
- } from "./chunk-3QQTXYZ6.js";
593
- import {
594
- normalizeTags
595
- } from "./chunk-BT7NVCML.js";
596
602
  import {
597
603
  buildQmdRecallCacheKey,
598
604
  getCachedQmdRecall,
@@ -602,10 +608,7 @@ import {
602
608
  FallbackLlmClient,
603
609
  fallbackLlmRuntimeContextFromConfig,
604
610
  gatewayTaskChainOptions
605
- } from "./chunk-TLPZ6MKZ.js";
606
- import {
607
- extractJsonCandidates
608
- } from "./chunk-RGMVMVMF.js";
611
+ } from "./chunk-YEN4TREG.js";
609
612
  import {
610
613
  assertExternalWikiRootOutsideMemoryDirCanonical
611
614
  } from "./chunk-JV3C2MNQ.js";
@@ -621,16 +624,14 @@ import {
621
624
  hashActivityBody,
622
625
  isValidActivityDate,
623
626
  timezoneOffsetIso
624
- } from "./chunk-S7DPKM5W.js";
625
- import {
626
- evaluateSubjectGuard,
627
- isSharedPromotionTarget,
628
- resolveWriteSubject
629
- } from "./chunk-VYCOJKSX.js";
627
+ } from "./chunk-353C5UNV.js";
630
628
  import {
631
629
  isUntrustedOrigin,
632
630
  parseOriginClass
633
631
  } from "./chunk-6Q3ZTEF6.js";
632
+ import {
633
+ extractJsonCandidates
634
+ } from "./chunk-RGMVMVMF.js";
634
635
  import {
635
636
  createBoundedCoreSectionRunner,
636
637
  createRecallSectionMetricRecorder,
@@ -660,16 +661,13 @@ import {
660
661
  getConfiguredNamespaces,
661
662
  resolveNamespaceFromStorageDir,
662
663
  resolveScopePlan
663
- } from "./chunk-XU6OEECT.js";
664
+ } from "./chunk-OQQXGYMX.js";
664
665
  import {
665
666
  attachCitation,
666
667
  hasCitationForTemplate,
667
668
  lastCitationMarkerForTemplate,
668
669
  stripCitationForTemplate
669
670
  } from "./chunk-TG3FAM2S.js";
670
- import {
671
- openBetterSqlite3
672
- } from "./chunk-RL6NEVXT.js";
673
671
  import {
674
672
  assertPathInsideRoot
675
673
  } from "./chunk-C7HJ3NEI.js";
@@ -678,26 +676,10 @@ import {
678
676
  isActiveMemoryStatus,
679
677
  toMemoryPathRel
680
678
  } from "./chunk-7RJUVTVF.js";
681
- import {
682
- ContentHashIndex
683
- } from "./chunk-NB3LRY4T.js";
684
679
  import {
685
680
  excludeSupportPassportPrivateMemories,
686
681
  isSupportPassportPrivateMemory
687
- } from "./chunk-EEOUMG3J.js";
688
- import {
689
- normalizeAttributePairs,
690
- stripAttributesSuffix
691
- } from "./chunk-JDSVLVCG.js";
692
- import {
693
- sanitizeMemoryContent
694
- } from "./chunk-5GKPFL3S.js";
695
- import {
696
- MEMORY_ID_PATTERN,
697
- parseIdOrHandle,
698
- resolveHandle,
699
- stripHandles
700
- } from "./chunk-JAKIDQB2.js";
682
+ } from "./chunk-PWPIERBM.js";
701
683
  import {
702
684
  CAPSULE_ID_PATTERN
703
685
  } from "./chunk-WEHSQBFR.js";
@@ -705,6 +687,19 @@ import {
705
687
  keyring_exports,
706
688
  secureStoreDir
707
689
  } from "./chunk-BJMBJZ2Y.js";
690
+ import {
691
+ TAG_LIMITS,
692
+ composeMemoryEnvelope,
693
+ isMemoryCategory
694
+ } from "./chunk-LSLCFCCQ.js";
695
+ import {
696
+ normalizeTags
697
+ } from "./chunk-BT7NVCML.js";
698
+ import {
699
+ evaluateSubjectGuard,
700
+ isSharedPromotionTarget,
701
+ resolveWriteSubject
702
+ } from "./chunk-VYCOJKSX.js";
708
703
  import {
709
704
  buildRetrievedMemoryProvenance
710
705
  } from "./chunk-I4WBNM3M.js";
@@ -712,6 +707,25 @@ import {
712
707
  assertIsDirectoryNotSymlink,
713
708
  assertRealpathInsideRoot
714
709
  } from "./chunk-GCGJW34D.js";
710
+ import {
711
+ ContentHashIndex
712
+ } from "./chunk-NB3LRY4T.js";
713
+ import {
714
+ withHeldFileLock
715
+ } from "./chunk-FFAZ2XFU.js";
716
+ import {
717
+ normalizeAttributePairs,
718
+ stripAttributesSuffix
719
+ } from "./chunk-JDSVLVCG.js";
720
+ import {
721
+ sanitizeMemoryContent
722
+ } from "./chunk-5GKPFL3S.js";
723
+ import {
724
+ MEMORY_ID_PATTERN,
725
+ parseIdOrHandle,
726
+ resolveHandle,
727
+ stripHandles
728
+ } from "./chunk-JAKIDQB2.js";
715
729
  import {
716
730
  parseFlexibleIsoTimestamp
717
731
  } from "./chunk-P7FMDTKL.js";
@@ -754,7 +768,7 @@ import {
754
768
  import {
755
769
  lcmSessionKeyForNamespace,
756
770
  resolveCodingNamespaceOverlay
757
- } from "./chunk-NZXEK3UF.js";
771
+ } from "./chunk-3Q3N35W7.js";
758
772
  import {
759
773
  expandTildePath
760
774
  } from "./chunk-6KH5NLQS.js";
@@ -2348,7 +2362,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2348
2362
  namespaces,
2349
2363
  {
2350
2364
  readNamespaceMemories: async (ns) => (await this.getStorage(ns)).readAllMemories(),
2351
- readMemoryFrontmatter: async (path39, preferredNamespace) => {
2365
+ readMemoryFrontmatter: async (path40, preferredNamespace) => {
2352
2366
  if (!fallbackReader) {
2353
2367
  for (const ns of namespaces) {
2354
2368
  try {
@@ -2360,7 +2374,7 @@ var RecallRerankCoordinator = class _RecallRerankCoordinator {
2360
2374
  }
2361
2375
  if (!fallbackReader) return null;
2362
2376
  const memory = await this.readQmdResultMemory(
2363
- path39,
2377
+ path40,
2364
2378
  fallbackReader,
2365
2379
  namespaces,
2366
2380
  preferredNamespace
@@ -4909,6 +4923,89 @@ async function decideSemanticDedup(content, lookup, options) {
4909
4923
  };
4910
4924
  }
4911
4925
 
4926
+ // src/orchestration/semantic-merge-promotion-payload.ts
4927
+ async function buildMergedTargetPromotionPayload(storage, merge) {
4928
+ if (!merge.provenancePatched) {
4929
+ log.warn(
4930
+ `semantic-merge: skipping merged-target promotion for ${merge.targetId} \u2014 provenance patch did not land; the record still holds pre-merge trust metadata`
4931
+ );
4932
+ return { payload: null, readFailed: false };
4933
+ }
4934
+ let committed;
4935
+ try {
4936
+ committed = await storage.getMemoryByIdIncludingArchived(merge.targetId);
4937
+ } catch (err) {
4938
+ log.warn(
4939
+ `semantic-merge: merged-target promotion reread failed for ${merge.targetId} (non-fatal; promotion skipped, the committed merge stands): ${err instanceof Error ? err.message : String(err)}`
4940
+ );
4941
+ return { payload: null, readFailed: true };
4942
+ }
4943
+ if (!committed || committed.content !== merge.mergedContent) {
4944
+ return { payload: null, readFailed: false };
4945
+ }
4946
+ if (inferMemoryStatus(committed.frontmatter, committed.path) !== "active") {
4947
+ return { payload: null, readFailed: false };
4948
+ }
4949
+ const fm = committed.frontmatter;
4950
+ const snapshotDigest = typeof storage.readDurableFileDigest === "function" ? await storage.readDurableFileDigest(committed.path).catch(() => null) : null;
4951
+ const receipt = await readPromotionReceiptStatus(storage, committed.path);
4952
+ if (!receipt.available) {
4953
+ log.warn(
4954
+ `semantic-merge: merged-target promotion refused for ${merge.targetId} \u2014 the CAS revision receipt for ${committed.path} is unavailable (${receipt.reason}); promotion and reconciliation retry on the next merge`
4955
+ );
4956
+ return { payload: null, readFailed: true };
4957
+ }
4958
+ if (receipt.committedDigest !== void 0 && snapshotDigest !== receipt.committedDigest) {
4959
+ log.warn(
4960
+ snapshotDigest == null ? `semantic-merge: merged-target promotion refused for ${merge.targetId} \u2014 the record snapshot digest is unavailable while the CAS receipt carries committed digest ${receipt.committedDigest}; promotion and reconciliation retry on the next merge` : `semantic-merge: merged-target promotion refused for ${merge.targetId} \u2014 record snapshot digest (${snapshotDigest}) does not match committed receipt digest (${receipt.committedDigest}); record metadata was mutated concurrently`
4961
+ );
4962
+ return { payload: null, readFailed: true };
4963
+ }
4964
+ return {
4965
+ payload: {
4966
+ category: fm.category,
4967
+ content: committed.content,
4968
+ confidence: fm.confidence,
4969
+ tags: fm.tags ?? [],
4970
+ sourceMemoryId: fm.id,
4971
+ origin: parseOriginClass(fm.origin),
4972
+ source: fm.source,
4973
+ ...fm.entityRef !== void 0 ? { entityRef: fm.entityRef } : {},
4974
+ ...fm.structuredAttributes !== void 0 ? { structuredAttributes: { ...fm.structuredAttributes } } : {},
4975
+ ...fm.importance !== void 0 ? { importance: fm.importance } : {},
4976
+ ...fm.intentGoal !== void 0 ? { intentGoal: fm.intentGoal } : {},
4977
+ ...fm.intentActionType !== void 0 ? { intentActionType: fm.intentActionType } : {},
4978
+ ...fm.intentEntityTypes !== void 0 ? { intentEntityTypes: [...fm.intentEntityTypes] } : {},
4979
+ ...fm.memoryKind !== void 0 ? { memoryKind: fm.memoryKind } : {},
4980
+ ...fm.valid_at !== void 0 ? { validAt: fm.valid_at } : {},
4981
+ ...fm.invalid_at !== void 0 ? { invalidAt: fm.invalid_at } : {},
4982
+ ...fm.observedAt !== void 0 ? { observedAt: fm.observedAt } : {},
4983
+ ...fm.eventTimeSource !== void 0 ? { eventTimeSource: fm.eventTimeSource } : {},
4984
+ ...fm.sources && fm.sources.length > 0 ? { sources: fm.sources.map((source) => ({ ...source })) } : {},
4985
+ ...fm.provenance !== void 0 ? { provenance: fm.provenance } : {},
4986
+ ...fm.subject !== void 0 ? { subject: fm.subject } : {},
4987
+ ...fm.toolScoped === true ? { toolScoped: true } : {},
4988
+ ...fm.sourceConnector !== void 0 ? { sourceConnector: fm.sourceConnector } : {},
4989
+ ...receipt.revision !== void 0 ? { committedRevision: receipt.revision } : {},
4990
+ ...receipt.committedDigest !== void 0 ? { committedDigest: receipt.committedDigest } : snapshotDigest !== null ? { committedDigest: snapshotDigest } : {}
4991
+ },
4992
+ readFailed: false
4993
+ };
4994
+ }
4995
+ async function readPromotionReceiptStatus(storage, filePath) {
4996
+ try {
4997
+ const status = await storage.readCasRevisionStatus(filePath);
4998
+ if (status.status === "unavailable") return { available: false, reason: status.reason };
4999
+ return {
5000
+ available: true,
5001
+ revision: status.status === "present" ? status.revision : void 0,
5002
+ committedDigest: status.status === "present" ? status.committedDigest : void 0
5003
+ };
5004
+ } catch (err) {
5005
+ return { available: false, reason: err instanceof Error ? err.message : String(err) };
5006
+ }
5007
+ }
5008
+
4912
5009
  // src/orchestration/extraction-persist-promotion.ts
4913
5010
  var confidenceTierOrder = [
4914
5011
  "explicit",
@@ -5045,16 +5142,30 @@ function createBatchPromotedCopyProbe(config, getStorageRouter, scopeProfileWrit
5045
5142
  };
5046
5143
  }
5047
5144
  async function promoteAndReconcileMergedTarget(args) {
5145
+ if (args.mergedPromotion === null && args.mergedPromotionReadFailed === true) {
5146
+ log.warn(
5147
+ `persistExtraction: merged-target promotion reconciliation skipped for ${args.sourceMemoryId} \u2014 the committed record was unreadable at payload-build time, so no promotion outcome is confirmed`
5148
+ );
5149
+ return;
5150
+ }
5048
5151
  let promotedCopyId;
5049
5152
  if (args.mergedPromotion) {
5050
5153
  const payload = args.mergedPromotion;
5051
5154
  const current = await args.sourceStorage.getMemoryByIdIncludingArchived(args.sourceMemoryId).catch(() => null);
5052
- if (!current || inferMemoryStatus(current.frontmatter, current.path) !== "active" || current.content !== payload.content || (current.frontmatter.updated ?? void 0) !== (payload.committedRevision ?? void 0)) {
5155
+ if (!current || inferMemoryStatus(current.frontmatter, current.path) !== "active" || current.content !== payload.content) {
5053
5156
  log.warn(
5054
5157
  `persistExtraction: merged-target promotion abandoned for ${args.sourceMemoryId} \u2014 the committed record advanced past the cached payload, so the newer writer's copy stands`
5055
5158
  );
5056
5159
  return;
5057
5160
  }
5161
+ const standingReceipt = await readPromotionReceiptStatus(args.sourceStorage, current.path);
5162
+ const standingDigest = typeof args.sourceStorage.readDurableFileDigest === "function" ? await args.sourceStorage.readDurableFileDigest(current.path).catch(() => null) : null;
5163
+ if (!standingReceipt.available || (standingReceipt.revision ?? void 0) !== (payload.committedRevision ?? void 0) || payload.committedDigest !== void 0 && standingReceipt.committedDigest !== void 0 && standingReceipt.committedDigest !== payload.committedDigest || payload.committedDigest !== void 0 && standingDigest !== null && standingDigest !== payload.committedDigest) {
5164
+ log.warn(
5165
+ `persistExtraction: merged-target promotion abandoned for ${args.sourceMemoryId} \u2014 the committed record's CAS receipt or digest ${standingReceipt.available ? "does not match the cached payload's" : "is unreadable"}, so the cached body is not confirmed`
5166
+ );
5167
+ return;
5168
+ }
5058
5169
  try {
5059
5170
  promotedCopyId = await args.promote(payload);
5060
5171
  } catch (err) {
@@ -5140,22 +5251,35 @@ function filterHarmonicEntityMentions(facts, entityMentions) {
5140
5251
  return activeFacts.length > 0 ? [{ ...entity, facts: activeFacts.map((fact) => fact.content) }] : [];
5141
5252
  });
5142
5253
  }
5143
- function enqueueMergedTargetForHarmonicConstruction(entries, storage, fact, memoryId, content, insertedAt) {
5254
+ async function enqueueMergedTargetForHarmonicConstruction(entries, storage, fact, memoryId, content, insertedAt) {
5255
+ let committed = null;
5256
+ try {
5257
+ committed = await storage.getMemoryByIdIncludingArchived(memoryId);
5258
+ } catch {
5259
+ committed = null;
5260
+ }
5261
+ const derived = committed && committed.content === content ? {
5262
+ ...fact,
5263
+ category: committed.frontmatter.category,
5264
+ tags: [.../* @__PURE__ */ new Set([...committed.frontmatter.tags ?? [], ...fact.tags])],
5265
+ entityRef: committed.frontmatter.entityRef ?? fact.entityRef,
5266
+ validAt: committed.frontmatter.valid_at ?? fact.validAt
5267
+ } : fact;
5144
5268
  const entry = entries.get(storage.dir) ?? { storage, facts: [] };
5145
5269
  const prior = entry.facts.findIndex((existing) => existing.memoryId === memoryId);
5146
5270
  if (prior !== -1) {
5147
5271
  entry.facts[prior] = {
5148
- ...fact,
5272
+ ...derived,
5149
5273
  content,
5150
5274
  memoryId,
5151
5275
  insertedAt,
5152
5276
  cueAnchors: [
5153
5277
  ...entry.facts[prior].cueAnchors ?? [],
5154
- ...fact.cueAnchors ?? []
5278
+ ...derived.cueAnchors ?? []
5155
5279
  ]
5156
5280
  };
5157
5281
  } else {
5158
- entry.facts.push({ ...fact, content, memoryId, insertedAt });
5282
+ entry.facts.push({ ...derived, content, memoryId, insertedAt });
5159
5283
  }
5160
5284
  entries.set(storage.dir, entry);
5161
5285
  }
@@ -5236,16 +5360,42 @@ async function readTargetSnapshot(storage, target) {
5236
5360
  if (!current || current.frontmatter.id !== target.frontmatter.id) return null;
5237
5361
  return current;
5238
5362
  }
5239
- async function revertMergedContent(storage, target, mergedContent) {
5363
+ async function revertMergedContent(storage, target, mergedContent, committedRevision) {
5240
5364
  try {
5241
5365
  const current = await readTargetSnapshot(storage, target);
5242
- if (!current) return false;
5243
- if (current.content !== mergedContent) return true;
5366
+ if (!current) return "stands";
5367
+ if (current.content !== mergedContent) return "reverted";
5368
+ if (committedRevision !== void 0) {
5369
+ let standing;
5370
+ try {
5371
+ standing = await storage.readCasRevisionStatus(target.path);
5372
+ } catch (err) {
5373
+ standing = {
5374
+ status: "unavailable",
5375
+ reason: err instanceof Error ? err.message : String(err)
5376
+ };
5377
+ }
5378
+ if (standing.status === "present") {
5379
+ if (standing.revision !== committedRevision) {
5380
+ return "superseded";
5381
+ }
5382
+ } else if (standing.status === "unavailable") {
5383
+ log.warn(
5384
+ `revertMergedContent: CAS revision status for ${target.path} is unavailable (${standing.reason}); ownership cannot be verified \u2014 keeping the recovery snapshot instead of discarding or reverting`
5385
+ );
5386
+ return "stands";
5387
+ } else {
5388
+ log.warn(
5389
+ `revertMergedContent: CAS revision receipt for ${target.path} is absent although this writer holds receipt ${committedRevision}; ownership cannot be verified \u2014 keeping the recovery snapshot`
5390
+ );
5391
+ return "stands";
5392
+ }
5393
+ }
5244
5394
  return await storage.updateMemoryIfUnchanged(current, target.content, {
5245
5395
  actor: "semantic-merge-rollback"
5246
- });
5396
+ }) ? "reverted" : "stands";
5247
5397
  } catch {
5248
- return false;
5398
+ return "stands";
5249
5399
  }
5250
5400
  }
5251
5401
  async function persistMergedTargetThreadEpisode(threading, threadId, targetId) {
@@ -5270,7 +5420,11 @@ async function rewriteMergedTargetGraphEdges(storage, input) {
5270
5420
  try {
5271
5421
  appended = await input.build() ?? void 0;
5272
5422
  const committedNow = await storage.getMemoryByIdIncludingArchived(input.targetId);
5273
- if (!committedNow || committedNow.content !== input.mergedContent || committedNow.frontmatter.updated !== input.revisionChecked) {
5423
+ const committedRevision = committedNow === null ? void 0 : await storage.readCasRevision(committedNow.path).catch((err) => {
5424
+ log.warn(`rewriteMergedTargetGraphEdges: failed to read CAS revision for ${committedNow.path}: ${err}`);
5425
+ return void 0;
5426
+ });
5427
+ if (!committedNow || committedNow.content !== input.mergedContent || committedRevision !== input.revisionChecked) {
5274
5428
  await rollbackNodeEdgeRewrite(storage.dir, input.memoryRelPath, input.rewriteTypes, removedEdges, input.targetId, appended);
5275
5429
  return false;
5276
5430
  }
@@ -5730,7 +5884,7 @@ async function applySemanticMergeAtPersist(deps, options) {
5730
5884
  }
5731
5885
  };
5732
5886
  const nowIso = (options.now ? options.now() : /* @__PURE__ */ new Date()).toISOString();
5733
- let contentCommitted = false;
5887
+ let casRevision;
5734
5888
  let mergePatch;
5735
5889
  try {
5736
5890
  mergePatch = buildMergeFrontmatterUpdate({
@@ -5752,7 +5906,7 @@ async function applySemanticMergeAtPersist(deps, options) {
5752
5906
  );
5753
5907
  return { action: "created", reason: "target_changed" };
5754
5908
  }
5755
- contentCommitted = true;
5909
+ casRevision = updated;
5756
5910
  const merged = await readTargetSnapshot(options.storage, target);
5757
5911
  if (!merged || merged.content !== committedContent) {
5758
5912
  throw new Error("target replaced before the provenance patch");
@@ -5770,6 +5924,8 @@ async function applySemanticMergeAtPersist(deps, options) {
5770
5924
  const patched = await options.storage.writeMemoryFrontmatterIfUnchanged(
5771
5925
  merged,
5772
5926
  {
5927
+ // #2807: business/event time, exactly what an ordinary write would
5928
+ // stamp — receipt identity is the sidecar token storage mints.
5773
5929
  updated: mergePatch.updated,
5774
5930
  derived_via: mergePatch.derived_via,
5775
5931
  reinforcement_count: mergePatch.reinforcement_count,
@@ -5800,7 +5956,67 @@ async function applySemanticMergeAtPersist(deps, options) {
5800
5956
  if (!patched) throw new Error("frontmatter patch rejected (target changed)");
5801
5957
  } catch (err) {
5802
5958
  const detail = err instanceof Error ? err.message : String(err);
5803
- if (contentCommitted && !await revertMergedContent(options.storage, target, committedContent)) {
5959
+ const committedRevision = casCommittedRevisionOf(err) ?? casRevision;
5960
+ const landed = committedRevision !== void 0;
5961
+ if (!landed) {
5962
+ let observed = null;
5963
+ try {
5964
+ observed = await readTargetSnapshot(options.storage, target);
5965
+ } catch {
5966
+ }
5967
+ if (observed?.content === committedContent) {
5968
+ await discardMergedTargetSnapshot(
5969
+ target.path,
5970
+ versioning,
5971
+ options.storage.dir,
5972
+ decision.targetId,
5973
+ versionId
5974
+ );
5975
+ await repairIndexes(committedMergedFactHash(deps, options.category, committedContent));
5976
+ log.warn(
5977
+ `semantic-merge: update failed for ${decision.targetId} (the compare-and-swap threw before this writer's mutation; the standing merged body is another writer's identical commit \u2014 snapshot ${versionId} discarded, the concurrent commit left untouched): ${detail}`
5978
+ );
5979
+ return {
5980
+ action: "merged",
5981
+ targetId: decision.targetId,
5982
+ mergedContent: committedContent,
5983
+ provenancePatched: false
5984
+ };
5985
+ } else if (observed?.content === target.content) {
5986
+ await discardMergedTargetSnapshot(
5987
+ target.path,
5988
+ versioning,
5989
+ options.storage.dir,
5990
+ decision.targetId,
5991
+ versionId
5992
+ );
5993
+ log.warn(
5994
+ `semantic-merge: update failed for ${decision.targetId} (the compare-and-swap threw before changing the target; snapshot ${versionId} discarded \u2014 the reread holds the pre-merge body): ${detail}`
5995
+ );
5996
+ return { action: "created", reason: "update_failed" };
5997
+ }
5998
+ }
5999
+ const revert = landed ? await revertMergedContent(options.storage, target, committedContent, committedRevision) : void 0;
6000
+ if (revert === "superseded") {
6001
+ await discardMergedTargetSnapshot(
6002
+ target.path,
6003
+ versioning,
6004
+ options.storage.dir,
6005
+ decision.targetId,
6006
+ versionId
6007
+ );
6008
+ await repairIndexes(committedMergedFactHash(deps, options.category, committedContent));
6009
+ log.warn(
6010
+ `semantic-merge: update failed for ${decision.targetId} (the standing merged body advanced past this writer's commit receipt \u2014 another writer's identical commit stands; snapshot ${versionId} discarded, the concurrent commit left untouched): ${detail}`
6011
+ );
6012
+ return {
6013
+ action: "merged",
6014
+ targetId: decision.targetId,
6015
+ mergedContent: committedContent,
6016
+ provenancePatched: false
6017
+ };
6018
+ }
6019
+ if (landed && revert !== "reverted") {
5804
6020
  log.error(
5805
6021
  `semantic-merge: ${decision.targetId} holds merged content without provenance metadata and the rollback failed (${detail}); snapshot ${versionId} holds the pre-merge state \u2014 recover with revertToVersion. Not creating a duplicate fact.`
5806
6022
  );
@@ -5813,7 +6029,7 @@ async function applySemanticMergeAtPersist(deps, options) {
5813
6029
  provenancePatched: false
5814
6030
  };
5815
6031
  }
5816
- if (contentCommitted) {
6032
+ if (landed) {
5817
6033
  await discardMergedTargetSnapshot(
5818
6034
  target.path,
5819
6035
  versioning,
@@ -5823,7 +6039,7 @@ async function applySemanticMergeAtPersist(deps, options) {
5823
6039
  );
5824
6040
  }
5825
6041
  log.warn(
5826
- `semantic-merge: update failed for ${decision.targetId}${contentCommitted ? ` (content rolled back; snapshot ${versionId} rolled back out of history)` : ` (snapshot ${versionId} staged)`}: ${detail}`
6042
+ `semantic-merge: update failed for ${decision.targetId}${landed ? ` (content rolled back; snapshot ${versionId} rolled back out of history)` : ` (snapshot ${versionId} staged)`}: ${detail}`
5827
6043
  );
5828
6044
  return { action: "created", reason: "update_failed" };
5829
6045
  }
@@ -5880,6 +6096,7 @@ async function runMergedTargetPostEffects(deps, storage, merge, input) {
5880
6096
  episodes.push(merge.targetId);
5881
6097
  }
5882
6098
  if (!input.graphCaps.multiGraphMemory) return signals;
6099
+ let rewriteInstalled = false;
5883
6100
  try {
5884
6101
  const committed = await storage.getMemoryByIdIncludingArchived(merge.targetId);
5885
6102
  if (!committed || committed.content !== merge.mergedContent) return signals;
@@ -5897,11 +6114,12 @@ async function runMergedTargetPostEffects(deps, storage, merge, input) {
5897
6114
  if (input.graphCaps.entityGraph) rewriteTypes.push("entity");
5898
6115
  if (input.graphCaps.timeGraph) rewriteTypes.push("time");
5899
6116
  if (input.graphCaps.causalGraph) rewriteTypes.push("causal");
5900
- const installed = await rewriteMergedTargetGraphEdges(storage, {
6117
+ rewriteInstalled = await rewriteMergedTargetGraphEdges(storage, {
5901
6118
  targetId: merge.targetId,
5902
6119
  memoryRelPath,
5903
6120
  mergedContent: merge.mergedContent,
5904
- revisionChecked: committed.frontmatter.updated,
6121
+ // #2807: the dedicated CAS revision token, not public `updated`.
6122
+ revisionChecked: await storage.readCasRevision(committed.path),
5905
6123
  rewriteTypes,
5906
6124
  build: () => deps.buildGraphEdge(
5907
6125
  storage,
@@ -5917,60 +6135,13 @@ async function runMergedTargetPostEffects(deps, storage, merge, input) {
5917
6135
  input.graphCaps
5918
6136
  )
5919
6137
  });
5920
- if (installed) input.graphContext.previousPersistedRelPath = memoryRelPath;
6138
+ if (rewriteInstalled) input.graphContext.previousPersistedRelPath = memoryRelPath;
5921
6139
  } catch {
5922
6140
  }
5923
- return signals;
5924
- }
5925
-
5926
- // src/orchestration/semantic-merge-promotion-payload.ts
5927
- async function buildMergedTargetPromotionPayload(storage, merge) {
5928
- if (!merge.provenancePatched) {
5929
- log.warn(
5930
- `semantic-merge: skipping merged-target promotion for ${merge.targetId} \u2014 provenance patch did not land; the record still holds pre-merge trust metadata`
5931
- );
5932
- return null;
5933
- }
5934
- let committed;
5935
- try {
5936
- committed = await storage.getMemoryByIdIncludingArchived(merge.targetId);
5937
- } catch (err) {
5938
- log.warn(
5939
- `semantic-merge: merged-target promotion reread failed for ${merge.targetId} (non-fatal; promotion skipped, the committed merge stands): ${err instanceof Error ? err.message : String(err)}`
5940
- );
5941
- return null;
5942
- }
5943
- if (!committed || committed.content !== merge.mergedContent) return null;
5944
- if (inferMemoryStatus(committed.frontmatter, committed.path) !== "active") {
5945
- return null;
6141
+ if (!rewriteInstalled) {
6142
+ deps.invalidateGraphEdgeCache?.(storage);
5946
6143
  }
5947
- const fm = committed.frontmatter;
5948
- return {
5949
- category: fm.category,
5950
- content: committed.content,
5951
- confidence: fm.confidence,
5952
- tags: fm.tags ?? [],
5953
- sourceMemoryId: fm.id,
5954
- origin: parseOriginClass(fm.origin),
5955
- source: fm.source,
5956
- ...fm.entityRef !== void 0 ? { entityRef: fm.entityRef } : {},
5957
- ...fm.structuredAttributes !== void 0 ? { structuredAttributes: { ...fm.structuredAttributes } } : {},
5958
- ...fm.importance !== void 0 ? { importance: fm.importance } : {},
5959
- ...fm.intentGoal !== void 0 ? { intentGoal: fm.intentGoal } : {},
5960
- ...fm.intentActionType !== void 0 ? { intentActionType: fm.intentActionType } : {},
5961
- ...fm.intentEntityTypes !== void 0 ? { intentEntityTypes: [...fm.intentEntityTypes] } : {},
5962
- ...fm.memoryKind !== void 0 ? { memoryKind: fm.memoryKind } : {},
5963
- ...fm.valid_at !== void 0 ? { validAt: fm.valid_at } : {},
5964
- ...fm.invalid_at !== void 0 ? { invalidAt: fm.invalid_at } : {},
5965
- ...fm.observedAt !== void 0 ? { observedAt: fm.observedAt } : {},
5966
- ...fm.eventTimeSource !== void 0 ? { eventTimeSource: fm.eventTimeSource } : {},
5967
- ...fm.sources && fm.sources.length > 0 ? { sources: fm.sources.map((source) => ({ ...source })) } : {},
5968
- ...fm.provenance !== void 0 ? { provenance: fm.provenance } : {},
5969
- ...fm.subject !== void 0 ? { subject: fm.subject } : {},
5970
- ...fm.toolScoped === true ? { toolScoped: true } : {},
5971
- ...fm.sourceConnector !== void 0 ? { sourceConnector: fm.sourceConnector } : {},
5972
- ...fm.updated !== void 0 ? { committedRevision: fm.updated } : {}
5973
- };
6144
+ return signals;
5974
6145
  }
5975
6146
 
5976
6147
  // src/orchestration/extraction-anchor-snapshot.ts
@@ -7486,11 +7657,11 @@ var ExtractionPersistCoordinator = class {
7486
7657
  semanticMergedCount++;
7487
7658
  await anchorSnapshots.replace(targetStorage, semanticMerge.targetId, writeCategory, memoryPathById);
7488
7659
  const mergedPromotion = await buildMergedTargetPromotionPayload(targetStorage, semanticMerge);
7489
- await promoteAndReconcileMergedTarget({ promote: (payload) => promoteMemoryToShared({ sourceStorage: targetStorage, ...payload }), config: this.deps.config, getStorageRouter: this.deps.getStorageRouter, scopeProfileWritePlan, sourceStorage: targetStorage, sourceMemoryId: semanticMerge.targetId, mergedPromotion, normalize: normalizeStoredHashSource, onReconciled: () => promotedCopyProbe.invalidate() });
7660
+ await promoteAndReconcileMergedTarget({ promote: (payload) => promoteMemoryToShared({ sourceStorage: targetStorage, ...payload }), config: this.deps.config, getStorageRouter: this.deps.getStorageRouter, scopeProfileWritePlan, sourceStorage: targetStorage, sourceMemoryId: semanticMerge.targetId, mergedPromotion: mergedPromotion.payload, mergedPromotionReadFailed: mergedPromotion.readFailed, normalize: normalizeStoredHashSource, onReconciled: () => promotedCopyProbe.invalidate() });
7490
7661
  trackPersistedId(targetStorage, semanticMerge.targetId, { includeReturnedIds: false });
7491
7662
  await persistMergedTargetThreadEpisode(this.deps.getThreading(), threadIdForExtraction, semanticMerge.targetId);
7492
7663
  if (harmonicConstructionEnabled) {
7493
- enqueueMergedTargetForHarmonicConstruction(harmonicFactsByStorage, targetStorage, harmonicFact, semanticMerge.targetId, semanticMerge.mergedContent, new Date(harmonicSourceInsertedAtBase + harmonicSourceOrder++).toISOString());
7664
+ await enqueueMergedTargetForHarmonicConstruction(harmonicFactsByStorage, targetStorage, harmonicFact, semanticMerge.targetId, semanticMerge.mergedContent, new Date(harmonicSourceInsertedAtBase + harmonicSourceOrder++).toISOString());
7494
7665
  }
7495
7666
  trackBehaviorSignals(targetStorage, await runMergedTargetPostEffects(this.deps, targetStorage, semanticMerge, {
7496
7667
  category: writeCategory,
@@ -10070,6 +10241,7 @@ var RecallInternalCoordinator = class {
10070
10241
  cronConversationRecallMode: this.deps.config.cronConversationRecallMode
10071
10242
  });
10072
10243
  const retrievalQuery = queryPolicy.retrievalQuery || prompt;
10244
+ const stateViewActive = resolveRecallStateViewActive(options, this.deps.config, retrievalQuery);
10073
10245
  const retrievalQueryHash = createHash5("sha256").update(retrievalQuery).digest("hex");
10074
10246
  const policyVersion = this.deps.currentPolicyVersion();
10075
10247
  let recallSource = "none";
@@ -12798,6 +12970,7 @@ ${tmtNode.summary}`
12798
12970
  void 0,
12799
12971
  {
12800
12972
  asOfMs,
12973
+ stateViewActive,
12801
12974
  // If QMD had already settled before the ordered assembly reached it,
12802
12975
  // do not let unrelated slow enrichment turn those known results into
12803
12976
  // unchecked misses. QMD that only settles during its own wait remains
@@ -12816,7 +12989,7 @@ ${tmtNode.summary}`
12816
12989
  recallNamespaces,
12817
12990
  retrievalQuery,
12818
12991
  qmdBoostInput.memoryByPath,
12819
- { asOfMs, requestingConnector: options.sourceConnector }
12992
+ { asOfMs, stateViewActive, requestingConnector: options.sourceConnector }
12820
12993
  ),
12821
12994
  qmdBoostInput.results
12822
12995
  );
@@ -12957,6 +13130,8 @@ ${tmtNode.summary}`
12957
13130
  injectedChars: identityInjectedChars,
12958
13131
  truncated: identityInjectionTruncated
12959
13132
  },
13133
+ stateViewActive,
13134
+ asOfMs,
12960
13135
  trustByPath: recallTrustByPath
12961
13136
  });
12962
13137
  recalledMemoryPaths = memoryResults.map((result) => result.path).filter(Boolean);
@@ -12990,7 +13165,7 @@ ${tmtNode.summary}`
12990
13165
  recallNamespaces,
12991
13166
  retrievalQuery,
12992
13167
  void 0,
12993
- { asOfMs, requestingConnector: options.sourceConnector }
13168
+ { asOfMs, stateViewActive, requestingConnector: options.sourceConnector }
12994
13169
  );
12995
13170
  xrayBranchPoolSize.hot_embedding = Math.max(
12996
13171
  xrayBranchPoolSize.hot_embedding,
@@ -13062,6 +13237,8 @@ ${tmtNode.summary}`
13062
13237
  injectedChars: identityInjectedChars,
13063
13238
  truncated: identityInjectionTruncated
13064
13239
  },
13240
+ stateViewActive,
13241
+ asOfMs,
13065
13242
  trustByPath: recallTrustByPath
13066
13243
  });
13067
13244
  recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
@@ -13070,6 +13247,7 @@ ${tmtNode.summary}`
13070
13247
  const coldPartitionSink = options.xrayCapture === true ? { partition: null } : void 0;
13071
13248
  const longTerm = await this.deps.applyColdFallbackPipeline({
13072
13249
  prompt: retrievalQuery,
13250
+ stateViewActive,
13073
13251
  recallNamespaces,
13074
13252
  recallResultLimit,
13075
13253
  recallMode,
@@ -13110,6 +13288,8 @@ ${tmtNode.summary}`
13110
13288
  injectedChars: identityInjectedChars,
13111
13289
  truncated: identityInjectionTruncated
13112
13290
  },
13291
+ stateViewActive,
13292
+ asOfMs,
13113
13293
  trustByPath: recallTrustByPath
13114
13294
  });
13115
13295
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
@@ -13178,7 +13358,7 @@ ${tmtNode.summary}`
13178
13358
  recallNamespaces,
13179
13359
  retrievalQuery,
13180
13360
  void 0,
13181
- { asOfMs, requestingConnector: options.sourceConnector }
13361
+ { asOfMs, stateViewActive, requestingConnector: options.sourceConnector }
13182
13362
  );
13183
13363
  xrayBranchPoolSize.hot_embedding = Math.max(
13184
13364
  xrayBranchPoolSize.hot_embedding,
@@ -13250,6 +13430,8 @@ ${tmtNode.summary}`
13250
13430
  injectedChars: identityInjectedChars,
13251
13431
  truncated: identityInjectionTruncated
13252
13432
  },
13433
+ stateViewActive,
13434
+ asOfMs,
13253
13435
  trustByPath: recallTrustByPath
13254
13436
  });
13255
13437
  recalledMemoryPaths = scoped.map((result) => result.path).filter(Boolean);
@@ -13263,22 +13445,15 @@ ${tmtNode.summary}`
13263
13445
  []
13264
13446
  );
13265
13447
  if (memories.length > 0) {
13266
- const supersessionOptions = {
13267
- enabled: lifecycleCaps.temporalSupersession,
13268
- includeInRecall: this.deps.config.temporalSupersessionIncludeInRecall
13269
- };
13270
- const asOfActive = typeof asOfMs === "number" && Number.isFinite(asOfMs);
13271
- const activeMemories = memories.filter(
13272
- (m) => {
13273
- if (isGenericRecallExcludedPath(m.path, this.deps.config)) return false;
13274
- const status = m.frontmatter.status;
13275
- if (!status || status === "active") return true;
13276
- if (status === "superseded") {
13277
- if (asOfActive) return true;
13278
- return !shouldFilterSupersededFromRecall(m.frontmatter, supersessionOptions);
13279
- }
13280
- return false;
13281
- }
13448
+ const activeMemories = filterRecentScanMemoriesForStateView(
13449
+ memories,
13450
+ this.deps.config,
13451
+ {
13452
+ enabled: lifecycleCaps.temporalSupersession,
13453
+ includeInRecall: this.deps.config.temporalSupersessionIncludeInRecall
13454
+ },
13455
+ stateViewActive,
13456
+ asOfMs
13282
13457
  );
13283
13458
  const queryAwareScopedMemories = queryAwarePrefilter.candidatePaths ? activeMemories.filter(
13284
13459
  (memory) => queryAwarePrefilter.candidatePaths?.has(memory.path)
@@ -13287,6 +13462,7 @@ ${tmtNode.summary}`
13287
13462
  const coldPartitionSink = options.xrayCapture === true ? { partition: null } : void 0;
13288
13463
  const longTerm = await this.deps.applyColdFallbackPipeline({
13289
13464
  prompt: retrievalQuery,
13465
+ stateViewActive,
13290
13466
  recallNamespaces,
13291
13467
  recallResultLimit,
13292
13468
  recallMode,
@@ -13321,6 +13497,8 @@ ${tmtNode.summary}`
13321
13497
  injectedChars: identityInjectedChars,
13322
13498
  truncated: identityInjectionTruncated
13323
13499
  },
13500
+ stateViewActive,
13501
+ asOfMs,
13324
13502
  trustByPath: recallTrustByPath
13325
13503
  });
13326
13504
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
@@ -13351,7 +13529,7 @@ ${tmtNode.summary}`
13351
13529
  recallNamespaces,
13352
13530
  retrievalQuery,
13353
13531
  preloadedMap,
13354
- { asOfMs, requestingConnector: options.sourceConnector }
13532
+ { asOfMs, stateViewActive, requestingConnector: options.sourceConnector }
13355
13533
  )).sort((a, b) => b.score - a.score);
13356
13534
  xrayBranchPoolSize.recent_scan = Math.max(
13357
13535
  xrayBranchPoolSize.recent_scan,
@@ -13426,6 +13604,8 @@ ${tmtNode.summary}`
13426
13604
  injectedChars: identityInjectedChars,
13427
13605
  truncated: identityInjectionTruncated
13428
13606
  },
13607
+ stateViewActive,
13608
+ asOfMs,
13429
13609
  trustByPath: recallTrustByPath
13430
13610
  });
13431
13611
  recalledMemoryPaths = recent.map((result) => result.path).filter(Boolean);
@@ -13434,6 +13614,7 @@ ${tmtNode.summary}`
13434
13614
  const coldPartitionSink = options.xrayCapture === true ? { partition: null } : void 0;
13435
13615
  const longTerm = await this.deps.applyColdFallbackPipeline({
13436
13616
  prompt: retrievalQuery,
13617
+ stateViewActive,
13437
13618
  recallNamespaces,
13438
13619
  recallResultLimit,
13439
13620
  recallMode,
@@ -13474,6 +13655,8 @@ ${tmtNode.summary}`
13474
13655
  injectedChars: identityInjectedChars,
13475
13656
  truncated: identityInjectionTruncated
13476
13657
  },
13658
+ stateViewActive,
13659
+ asOfMs,
13477
13660
  trustByPath: recallTrustByPath
13478
13661
  });
13479
13662
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
@@ -13485,6 +13668,7 @@ ${tmtNode.summary}`
13485
13668
  const coldPartitionSink = options.xrayCapture === true ? { partition: null } : void 0;
13486
13669
  const longTerm = await this.deps.applyColdFallbackPipeline({
13487
13670
  prompt: retrievalQuery,
13671
+ stateViewActive,
13488
13672
  recallNamespaces,
13489
13673
  recallResultLimit,
13490
13674
  recallMode,
@@ -13525,6 +13709,8 @@ ${tmtNode.summary}`
13525
13709
  injectedChars: identityInjectedChars,
13526
13710
  truncated: identityInjectionTruncated
13527
13711
  },
13712
+ stateViewActive,
13713
+ asOfMs,
13528
13714
  trustByPath: recallTrustByPath
13529
13715
  });
13530
13716
  recalledMemoryPaths = longTerm.map((result) => result.path).filter(Boolean);
@@ -13769,8 +13955,12 @@ ${tmtNode.summary}`
13769
13955
  const match = p.match(/([^/\\]+)\.md$/);
13770
13956
  return match ? match[1] ?? null : null;
13771
13957
  };
13772
- const xrayResultByPath = new Map(
13773
- xrayRecalledResults.map((xr) => [`${xr.namespace ?? ""}\0${xr.path}`, xr])
13958
+ const xrayResultByPath = indexStateViewAnnotatedResults(
13959
+ xrayRecalledResults,
13960
+ retrievalQuery,
13961
+ this.deps.config,
13962
+ stateViewActive,
13963
+ asOfMs
13774
13964
  );
13775
13965
  const results = [];
13776
13966
  for (let xrayIdx = 0; xrayIdx < recalledMemoryPaths.length; xrayIdx += 1) {
@@ -13815,6 +14005,7 @@ ${tmtNode.summary}`
13815
14005
  servedBy,
13816
14006
  scoreDecomposition,
13817
14007
  admittedBy: [],
14008
+ ...xrayResult?.stateLabel ? { stateView: xrayResult.stateLabel } : {},
13818
14009
  ...xrayResult?.pathNodeIds ? { pathNodeIds: xrayResult.pathNodeIds } : {},
13819
14010
  ...typeof xrayResult?.pathPenaltyApplied === "boolean" ? { pathPenaltyApplied: xrayResult.pathPenaltyApplied } : {},
13820
14011
  ...provenance ? { provenance } : {},
@@ -14582,7 +14773,8 @@ var RecallSearchPipelineCoordinator = class {
14582
14773
  abortSignal: options.abortSignal,
14583
14774
  dropUnresolved: true,
14584
14775
  recallNamespaces: options.recallNamespaces,
14585
- requestingConnector: options.requestingConnector
14776
+ requestingConnector: options.requestingConnector,
14777
+ stateViewActive: options.stateViewActive
14586
14778
  }
14587
14779
  );
14588
14780
  results = boostInput.results;
@@ -14599,6 +14791,7 @@ var RecallSearchPipelineCoordinator = class {
14599
14791
  {
14600
14792
  allowLifecycleFiltered: true,
14601
14793
  asOfMs: options.asOfMs,
14794
+ stateViewActive: options.stateViewActive,
14602
14795
  requestingConnector: options.requestingConnector
14603
14796
  }
14604
14797
  ),
@@ -14616,6 +14809,7 @@ var RecallSearchPipelineCoordinator = class {
14616
14809
  {
14617
14810
  allowLifecycleFiltered: true,
14618
14811
  asOfMs: options.asOfMs,
14812
+ stateViewActive: options.stateViewActive,
14619
14813
  requestingConnector: options.requestingConnector
14620
14814
  }
14621
14815
  ));
@@ -14796,6 +14990,24 @@ var RecallSearchPipelineCoordinator = class {
14796
14990
  return { memoryByPath, checkedPaths, unreadablePaths, completed: true };
14797
14991
  }
14798
14992
  filterSearchResultsByRecallSafety(results, memoryByPath, options) {
14993
+ const stateViewActive = options?.stateViewActive === true;
14994
+ const stateViewSurvivorIds = stateViewActive ? /* @__PURE__ */ new Set() : null;
14995
+ const stateViewDeferred = [];
14996
+ const stateViewBuilt = stateViewActive ? new Array(results.length).fill(null) : null;
14997
+ const buildRecallRow = (r, memory) => ({
14998
+ ...r,
14999
+ sourceConnector: memory ? memory.frontmatter.sourceConnector : void 0,
15000
+ origin: memory ? memory.frontmatter.origin : void 0,
15001
+ // #1952: an active state view carries the chain fields the inject
15002
+ // seam labels from (id/status/supersededBy/supersededAt).
15003
+ ...stateViewActive && memory ? {
15004
+ id: memory.frontmatter.id,
15005
+ status: memory.frontmatter.status,
15006
+ supersededBy: memory.frontmatter.supersededBy,
15007
+ supersededAt: memory.frontmatter.supersededAt
15008
+ } : {}
15009
+ });
15010
+ let stateViewAdmittedCount = 0;
14799
15011
  const lifecycleCaps = resolveMemoryLifecycleCapabilities(this.deps.config);
14800
15012
  let lifecycleFilteredCount = 0;
14801
15013
  let temporalSupersededFilteredCount = 0;
@@ -14806,7 +15018,9 @@ var RecallSearchPipelineCoordinator = class {
14806
15018
  let connectorPartitionFilteredCount = 0;
14807
15019
  let supportPassportFilteredCount = 0;
14808
15020
  const filtered = [];
14809
- for (const r of results) {
15021
+ for (let resultIdx = 0; resultIdx < results.length; resultIdx += 1) {
15022
+ const r = results[resultIdx];
15023
+ let stateViewPending = false;
14810
15024
  if (options?.blockedPaths && resultHasKey(options.blockedPaths, r)) {
14811
15025
  blockedPathFilteredCount += 1;
14812
15026
  continue;
@@ -14849,16 +15063,23 @@ var RecallSearchPipelineCoordinator = class {
14849
15063
  // allowLifecycleFiltered=true to include archived/retired
14850
15064
  // candidates, but superseded memories must still be filtered
14851
15065
  // unless temporalSupersessionIncludeInRecall is set.
14852
- // Skipped entirely when `as_of` is active (above branch); the
14853
- // half-open `[valid_at, invalid_at)` evaluation in isValidAsOf
14854
- // is the authoritative gate for historical recall.
15066
+ // #1952: an active state view ADMITS the superseded row when its
15067
+ // successor also survives this filter — history never renders
15068
+ // unanchored, and a successor rejected by any gate here can
15069
+ // never anchor. Admission defers to the post-pass fixpoint.
15070
+ // Skipped entirely when `as_of` is active (above branch);
15071
+ // isValidAsOf stays the authoritative historical gate.
14855
15072
  shouldFilterSupersededFromRecall(memory.frontmatter, {
14856
15073
  enabled: lifecycleCaps.temporalSupersession,
14857
15074
  includeInRecall: this.deps.config.temporalSupersessionIncludeInRecall
14858
15075
  })
14859
15076
  ) {
14860
- temporalSupersededFilteredCount += 1;
14861
- continue;
15077
+ if (stateViewActive) {
15078
+ stateViewPending = true;
15079
+ } else {
15080
+ temporalSupersededFilteredCount += 1;
15081
+ continue;
15082
+ }
14862
15083
  }
14863
15084
  if (!asOfActive && this.deps.config.temporalBiTemporal && !this.deps.config.temporalExpiredInInjection && isValidityExpiredNow(memory.frontmatter, Date.now())) {
14864
15085
  biTemporalExpiredFilteredCount += 1;
@@ -14869,16 +15090,54 @@ var RecallSearchPipelineCoordinator = class {
14869
15090
  continue;
14870
15091
  }
14871
15092
  }
14872
- filtered.push({
14873
- ...r,
14874
- sourceConnector: memory ? memory.frontmatter.sourceConnector : void 0,
14875
- origin: memory ? memory.frontmatter.origin : void 0
14876
- });
14877
- }
14878
- if (connectorPartitionFilteredCount > 0) {
14879
- log.debug(
14880
- `connector partition filter removed ${connectorPartitionFilteredCount} tool-scoped candidates from recall`
14881
- );
15093
+ if (stateViewPending) {
15094
+ stateViewDeferred.push(resultIdx);
15095
+ continue;
15096
+ }
15097
+ const builtRow = buildRecallRow(r, memory);
15098
+ if (stateViewBuilt !== null) {
15099
+ stateViewBuilt[resultIdx] = builtRow;
15100
+ if (memory) {
15101
+ const id = memory.frontmatter.id;
15102
+ if (typeof id === "string" && id.length > 0) stateViewSurvivorIds.add(id);
15103
+ }
15104
+ }
15105
+ filtered.push(builtRow);
15106
+ }
15107
+ if (stateViewDeferred.length > 0) {
15108
+ const admitted = /* @__PURE__ */ new Set();
15109
+ for (let progress = true; progress; ) {
15110
+ progress = false;
15111
+ for (const deferredIdx of stateViewDeferred) {
15112
+ if (admitted.has(deferredIdx)) continue;
15113
+ const deferredMemory = memoryForResult(memoryByPath, results[deferredIdx]);
15114
+ if (!deferredMemory) continue;
15115
+ if (stateViewSurvivorIds.has(deferredMemory.frontmatter.supersededBy ?? "")) {
15116
+ admitted.add(deferredIdx);
15117
+ const id = deferredMemory.frontmatter.id;
15118
+ if (typeof id === "string" && id.length > 0) stateViewSurvivorIds.add(id);
15119
+ progress = true;
15120
+ }
15121
+ }
15122
+ }
15123
+ for (const deferredIdx of stateViewDeferred) {
15124
+ const deferredMemory = memoryForResult(memoryByPath, results[deferredIdx]);
15125
+ if (admitted.has(deferredIdx) && deferredMemory) {
15126
+ stateViewAdmittedCount += 1;
15127
+ stateViewBuilt[deferredIdx] = buildRecallRow(results[deferredIdx], deferredMemory);
15128
+ } else {
15129
+ temporalSupersededFilteredCount += 1;
15130
+ }
15131
+ }
15132
+ filtered.length = 0;
15133
+ for (const builtRow of stateViewBuilt) {
15134
+ if (builtRow) filtered.push(builtRow);
15135
+ }
15136
+ }
15137
+ if (connectorPartitionFilteredCount > 0) {
15138
+ log.debug(
15139
+ `connector partition filter removed ${connectorPartitionFilteredCount} tool-scoped candidates from recall`
15140
+ );
14882
15141
  }
14883
15142
  if (supportPassportFilteredCount > 0) {
14884
15143
  log.debug(
@@ -14895,6 +15154,11 @@ var RecallSearchPipelineCoordinator = class {
14895
15154
  `temporal supersession filter removed ${temporalSupersededFilteredCount} superseded candidates`
14896
15155
  );
14897
15156
  }
15157
+ if (stateViewAdmittedCount > 0) {
15158
+ log.debug(
15159
+ `state views admitted ${stateViewAdmittedCount} superseded candidates anchored on in-set successors (#1952)`
15160
+ );
15161
+ }
14898
15162
  if (biTemporalExpiredFilteredCount > 0) {
14899
15163
  log.debug(
14900
15164
  `bi-temporal validity filter removed ${biTemporalExpiredFilteredCount} expired-validity candidates from injection (temporal.biTemporal on)`
@@ -16683,7 +16947,7 @@ var OrchestratorInitCoordinator = class {
16683
16947
  if (signal.aborted) return;
16684
16948
  if (lifecycleCaps.lifecyclePolicy && resolveQmdCapabilities(this.deps.config).qmdTierMigration) {
16685
16949
  try {
16686
- const { runFirstStartMigration } = await import("./first-start-migration-RC345GPL.js");
16950
+ const { runFirstStartMigration } = await import("./first-start-migration-L3UFX5CU.js");
16687
16951
  const result = await runFirstStartMigration({
16688
16952
  storage: this.deps.storage,
16689
16953
  config: this.deps.config,
@@ -16706,7 +16970,7 @@ var OrchestratorInitCoordinator = class {
16706
16970
  if (signal.aborted) return;
16707
16971
  if (!this.deps.wearablesAutoSyncHandle && this.deps.config.wearables.enabled && this.deps.config.wearables.autoSyncEnabled && Object.values(this.deps.config.wearables.sources).some((source) => source.enabled)) {
16708
16972
  try {
16709
- const { startWearablesAutoSync } = await import("./auto-sync-NSHLUAQI.js");
16973
+ const { startWearablesAutoSync } = await import("./auto-sync-4YFATLFQ.js");
16710
16974
  if (signal.aborted) return;
16711
16975
  this.deps.wearablesAutoSyncHandle = startWearablesAutoSync(
16712
16976
  {
@@ -20248,7 +20512,9 @@ var RecallEntryCoordinator = class {
20248
20512
  const injectable = applyRecallStateViews(
20249
20513
  trustByPath ? options.results.filter((r) => !trustResultFor(trustByPath, r)?.quarantined) : options.results,
20250
20514
  options.retrievalQuery,
20251
- this.deps.config
20515
+ this.deps.config,
20516
+ options.stateViewActive === true,
20517
+ options.asOfMs
20252
20518
  );
20253
20519
  if (injectable.length === 0) return;
20254
20520
  const formatted = this.deps.recallResultFormatter.formatQmdResultEntries(
@@ -20612,6 +20878,7 @@ var Orchestrator = class {
20612
20878
  storageDirNamespace: (storageDir) => this.storageDirNamespace(storageDir),
20613
20879
  indexPersistedMemory: (storage, memoryId) => this.indexPersistedMemory(storage, memoryId),
20614
20880
  buildGraphEdge: (storage, memoryRelPath, entityRef, memoryId, factContent, allMemsForGraph, memoryPathById, threadIdForEdge, threadEpisodeIdsForGraph, fallbackCausalPredecessor, graphCaps) => this.buildGraphEdge(storage, memoryRelPath, entityRef, memoryId, factContent, allMemsForGraph, memoryPathById, threadIdForEdge, threadEpisodeIdsForGraph, fallbackCausalPredecessor, graphCaps),
20881
+ invalidateGraphEdgeCache: (storage) => this.graphIndexFor(storage).invalidateEdgeCache(),
20615
20882
  updateTemporalTagIndexes: (storage, persistedIds) => this.updateTemporalTagIndexes(storage, persistedIds)
20616
20883
  });
20617
20884
  }
@@ -22236,20 +22503,9 @@ ${doc.content}` : doc.content,
22236
22503
  memoryId
22237
22504
  );
22238
22505
  }
22506
+ /** Delegation wrapper so the persist wiring and root-test stubs route through `this` (#2813 CI-0). */
22239
22507
  async buildGraphEdge(storage, memoryRelPath, entityRef, memoryId, factContent, allMemsForGraph, memoryPathById, threadIdForEdge, threadEpisodeIdsForGraph, fallbackCausalPredecessor, graphCaps = resolveGraphConstructionCapabilities(this.config)) {
22240
- return this.persistenceIndexCoordinator.buildGraphEdge(
22241
- storage,
22242
- memoryRelPath,
22243
- entityRef,
22244
- memoryId,
22245
- factContent,
22246
- allMemsForGraph,
22247
- memoryPathById,
22248
- threadIdForEdge,
22249
- threadEpisodeIdsForGraph,
22250
- fallbackCausalPredecessor,
22251
- graphCaps
22252
- );
22508
+ return this.persistenceIndexCoordinator.buildGraphEdge(storage, memoryRelPath, entityRef, memoryId, factContent, allMemsForGraph, memoryPathById, threadIdForEdge, threadEpisodeIdsForGraph, fallbackCausalPredecessor, graphCaps);
22253
22509
  }
22254
22510
  graphIndexFor(storage) {
22255
22511
  const key = storage.dir;
@@ -23366,9 +23622,9 @@ function readStructuralSymbol(entry) {
23366
23622
  const rec = entry;
23367
23623
  const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
23368
23624
  if (!symbol) return null;
23369
- const path39 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
23625
+ const path40 = typeof rec.path === "string" && rec.path.length > 0 ? rec.path : void 0;
23370
23626
  const kind = typeof rec.kind === "string" && rec.kind.length > 0 ? rec.kind : void 0;
23371
- const item = path39 !== void 0 && kind !== void 0 ? { symbol, path: path39, kind } : path39 !== void 0 ? { symbol, path: path39 } : kind !== void 0 ? { symbol, kind } : { symbol };
23627
+ const item = path40 !== void 0 && kind !== void 0 ? { symbol, path: path40, kind } : path40 !== void 0 ? { symbol, path: path40 } : kind !== void 0 ? { symbol, kind } : { symbol };
23372
23628
  return item;
23373
23629
  }
23374
23630
  function classifySpawnError(err) {
@@ -26932,438 +27188,6 @@ function publisherForConnector(connectorId) {
26932
27188
  return publisherFor(hostIdForConnector(connectorId));
26933
27189
  }
26934
27190
 
26935
- // src/activity/timeline/categories.ts
26936
- var TIMELINE_RESERVED_UNKNOWN = "system.unknown";
26937
- var TIMELINE_RESERVED_IDLE = "system.idle";
26938
- var TIMELINE_RESERVED_PAUSE = "system.pause";
26939
- var COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/;
26940
- function isTimelineCategoryId(id) {
26941
- const parts = id.split(".");
26942
- if (parts.length === 0) return false;
26943
- for (const part of parts) {
26944
- if (part.length === 0) return false;
26945
- const first = part.charCodeAt(0);
26946
- if (first < 97 || first > 122) return false;
26947
- for (let i = 1; i < part.length; i += 1) {
26948
- const code = part.charCodeAt(i);
26949
- const ok = code >= 97 && code <= 122 || code >= 48 && code <= 57 || code === 45;
26950
- if (!ok) return false;
26951
- }
26952
- }
26953
- return true;
26954
- }
26955
- var DEFAULT_TIMELINE_CATEGORIES = [
26956
- { id: "development", name: "Development", color: "#3b82f6", description: "Editors, terminals, IDEs, and code forges.", order: 10 },
26957
- { id: "communication", name: "Communication", color: "#f59e0b", description: "Mail, chat, and meetings.", order: 20 },
26958
- { id: "browsing", name: "Browsing", color: "#6366f1", description: "Web browsing without a more specific domain match.", order: 30 },
26959
- { id: "documents", name: "Documents", color: "#10b981", description: "Writing, notes, and PDFs.", order: 40 },
26960
- { id: "design", name: "Design & Media", color: "#ec4899", description: "Design, audio, and video tools.", order: 50 },
26961
- { id: "data", name: "Data & Analysis", color: "#84cc16", description: "Spreadsheets, dashboards, and databases.", order: 60 },
26962
- { id: "admin", name: "Admin", color: "#64748b", description: "File managers, settings, and system utilities.", order: 70 },
26963
- { id: "entertainment", name: "Entertainment", color: "#ef4444", description: "Video, music, and games.", order: 80 },
26964
- { id: TIMELINE_RESERVED_UNKNOWN, name: "Uncategorized", color: "#9ca3af", description: "Activity with no matching classification signal. Kept visible, never silently reassigned.", order: 990, system: true },
26965
- { id: TIMELINE_RESERVED_IDLE, name: "Idle", color: "#d1d5db", description: "Derived gap between cards where no activity was observed.", order: 991, system: true, idle: true },
26966
- { id: TIMELINE_RESERVED_PAUSE, name: "Paused", color: "#a78bfa", description: "User-declared pause interval.", order: 992, system: true }
26967
- ];
26968
- function validateTimelineCategories(categories) {
26969
- if (!Array.isArray(categories) || categories.length === 0) {
26970
- throw new RangeError("timeline categories must be a non-empty array");
26971
- }
26972
- const seen = /* @__PURE__ */ new Set();
26973
- for (const category of categories) {
26974
- if (typeof category.id !== "string" || !isTimelineCategoryId(category.id)) {
26975
- throw new RangeError(`timeline category id must be dotted kebab-case: ${String(category.id)}`);
26976
- }
26977
- if (seen.has(category.id)) {
26978
- throw new RangeError(`timeline category id must be unique: ${category.id}`);
26979
- }
26980
- seen.add(category.id);
26981
- if (typeof category.name !== "string" || category.name.length === 0) {
26982
- throw new RangeError(`timeline category ${category.id}: name must be a non-empty string`);
26983
- }
26984
- if (typeof category.color !== "string" || !COLOR_PATTERN.test(category.color)) {
26985
- throw new RangeError(`timeline category ${category.id}: color must be #RRGGBB`);
26986
- }
26987
- if (typeof category.description !== "string" || category.description.length === 0) {
26988
- throw new RangeError(`timeline category ${category.id}: description must be a non-empty string`);
26989
- }
26990
- if (!Number.isInteger(category.order)) {
26991
- throw new RangeError(`timeline category ${category.id}: order must be an integer`);
26992
- }
26993
- const isReserved = category.id === TIMELINE_RESERVED_UNKNOWN || category.id === TIMELINE_RESERVED_IDLE || category.id === TIMELINE_RESERVED_PAUSE;
26994
- if (isReserved && category.system !== true) {
26995
- throw new RangeError(`timeline category ${category.id} is reserved and must set system: true`);
26996
- }
26997
- if (!isReserved) {
26998
- if (category.id.startsWith("system.")) {
26999
- throw new RangeError(`timeline category id namespace "system." is reserved: ${category.id}`);
27000
- }
27001
- if (category.system === true || category.idle === true) {
27002
- throw new RangeError(`timeline category ${category.id}: only reserved categories may set system/idle flags`);
27003
- }
27004
- }
27005
- }
27006
- const idle = categories.find((category) => category.id === TIMELINE_RESERVED_IDLE);
27007
- if (idle !== void 0 && idle.idle !== true) {
27008
- throw new RangeError(`timeline category ${TIMELINE_RESERVED_IDLE} must set idle: true`);
27009
- }
27010
- for (const reserved of [TIMELINE_RESERVED_UNKNOWN, TIMELINE_RESERVED_IDLE, TIMELINE_RESERVED_PAUSE]) {
27011
- if (!categories.some((category) => category.id === reserved)) {
27012
- throw new RangeError(`timeline categories must include the reserved "${reserved}" category`);
27013
- }
27014
- }
27015
- }
27016
- function sortTimelineCategories(categories) {
27017
- return [...categories].sort((a, b) => a.order - b.order || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0));
27018
- }
27019
-
27020
- // src/activity/timeline/classify.ts
27021
- var DOMAIN_CONFIDENCE = 0.85;
27022
- var APP_CONFIDENCE = 0.9;
27023
- var TITLE_CONFIDENCE = 0.7;
27024
- var UNKNOWN_CONFIDENCE = 0;
27025
- var RULES = [
27026
- { categoryId: "development", domains: ["github.com", "gitlab.com", "stackoverflow.com", "linear.app", "atlassian.net"] },
27027
- { categoryId: "communication", domains: ["mail.google.com", "gmail.com", "outlook.com", "outlook.office.com", "slack.com"] },
27028
- { categoryId: "design", domains: ["figma.com", "canva.com"] },
27029
- { categoryId: "documents", domains: ["docs.google.com", "notion.so", "dropbox.com"] },
27030
- { categoryId: "entertainment", domains: ["youtube.com", "netflix.com", "spotify.com"] },
27031
- { categoryId: "data", domains: ["metabase", "tableau", "grafana"] },
27032
- { categoryId: "development", apps: ["code", "cursor", "neovim", "vim", "emacs", "xcode", "intellij", "terminal", "iterm", "warp", "wezterm", "kitty", "alacritty", "zed", "sublime", "datagrip"] },
27033
- { categoryId: "communication", apps: ["slack", "discord", "teams", "mail", "outlook", "thunderbird", "messages", "signal", "whatsapp", "telegram", "zoom", "facetime", "meet"] },
27034
- { categoryId: "design", apps: ["figma", "sketch", "photoshop", "illustrator", "indesign", "premiere", "after effects", "davinci", "blender", "ableton", "logic pro", "final cut"] },
27035
- { categoryId: "documents", apps: ["word", "pages", "notion", "obsidian", "notes", "typora", "bear", "preview", "acrobat"] },
27036
- { categoryId: "data", apps: ["excel", "numbers", "sheets", "tableau"] },
27037
- { categoryId: "admin", apps: ["finder", "settings", "system preferences", "activity monitor", "files", "explorer"] },
27038
- { categoryId: "entertainment", apps: ["spotify", "music", "youtube", "vlc", "quicktime", "steam", "netflix", "podcast", "tv"] },
27039
- { categoryId: "browsing", apps: ["chrome", "safari", "firefox", "edge", "arc", "brave", "browser"] },
27040
- { categoryId: "development", titles: ["pull request", "merge conflict", "terminal \u2014", "repository"] },
27041
- { categoryId: "communication", titles: ["inbox"] },
27042
- { categoryId: "data", titles: ["spreadsheet", "pivot table"] }
27043
- ];
27044
- function classifyTimelineObservation(observation, categories) {
27045
- const app = observation.app.toLowerCase();
27046
- const title = observation.windowTitle.toLowerCase();
27047
- const domain = observation.browserUrl === void 0 ? "" : hostOf(observation.browserUrl);
27048
- for (const rule of RULES) {
27049
- if (rule.domains !== void 0 && domain !== "" && rule.domains.some((pattern) => domain.includes(pattern))) {
27050
- return checkedRule(rule, DOMAIN_CONFIDENCE, categories);
27051
- }
27052
- }
27053
- for (const rule of RULES) {
27054
- if (rule.apps !== void 0 && rule.apps.some((pattern) => app.includes(pattern))) {
27055
- return checkedRule(rule, APP_CONFIDENCE, categories);
27056
- }
27057
- }
27058
- for (const rule of RULES) {
27059
- if (rule.titles !== void 0 && rule.titles.some((pattern) => title.includes(pattern))) {
27060
- return checkedRule(rule, TITLE_CONFIDENCE, categories);
27061
- }
27062
- }
27063
- return { categoryId: TIMELINE_RESERVED_UNKNOWN, confidence: UNKNOWN_CONFIDENCE };
27064
- }
27065
- function checkedRule(rule, confidence, categories) {
27066
- if (!categories.some((category) => category.id === rule.categoryId)) {
27067
- throw new RangeError(`timeline classification rule targets unknown category: ${rule.categoryId}`);
27068
- }
27069
- return { categoryId: rule.categoryId, confidence };
27070
- }
27071
- function hostOf(url) {
27072
- try {
27073
- return new URL(url).hostname.toLowerCase();
27074
- } catch {
27075
- return url.toLowerCase();
27076
- }
27077
- }
27078
-
27079
- // src/activity/timeline/build.ts
27080
- import { createHash as createHash9 } from "crypto";
27081
- var TIMELINE_FORMAT_VERSION = 1;
27082
- var TIMELINE_MERGE_GAP_MS = 12e4;
27083
- var TIMELINE_MAX_DWELL_MS = 15 * 6e4;
27084
- function canonicalMs(iso) {
27085
- const parsed = Date.parse(iso);
27086
- return Number.isFinite(parsed) ? parsed : Number.NaN;
27087
- }
27088
- function isoOf(ms) {
27089
- return new Date(ms).toISOString();
27090
- }
27091
- function evidenceKeyOf(observation) {
27092
- return `${observation.machine}|${isoOf(canonicalMs(observation.capturedAtUtc))}|${observation.contentHash}`;
27093
- }
27094
- function stableCardId(identity) {
27095
- return `tlc_${createHash9("sha256").update(identity, "utf8").digest("hex").slice(0, 16)}`;
27096
- }
27097
- function formatDurationMinutes(ms) {
27098
- return `${Math.round(ms / 6e4)}m`;
27099
- }
27100
- function unionIntervals(intervals) {
27101
- const sorted = [...intervals].sort((a, b) => a[0] - b[0] || a[1] - b[1]);
27102
- const merged = [];
27103
- for (const interval of sorted) {
27104
- const last = merged[merged.length - 1];
27105
- if (last !== void 0 && interval[0] <= last[1]) {
27106
- last[1] = Math.max(last[1], interval[1]);
27107
- } else {
27108
- merged.push([interval[0], interval[1]]);
27109
- }
27110
- }
27111
- return merged;
27112
- }
27113
- function subtractInterval(start, end, cutStart, cutEnd) {
27114
- if (cutEnd <= start || cutStart >= end) return [[start, end]];
27115
- const pieces = [];
27116
- if (cutStart > start) pieces.push([start, cutStart]);
27117
- if (cutEnd < end) pieces.push([cutEnd, end]);
27118
- return pieces;
27119
- }
27120
- function mergeTrack(machine, track, pauses) {
27121
- const cards = [];
27122
- let current = [];
27123
- const pauseStartsAfter = (fromMs, toMs) => pauses.some(([ps, pe]) => ps >= fromMs && ps < toMs && pe > ps);
27124
- for (const observation of track) {
27125
- const last = current[current.length - 1];
27126
- if (last !== void 0) {
27127
- const gap = canonicalMs(observation.capturedAtUtc) - canonicalMs(last.capturedAtUtc);
27128
- const sameKey = observation.app === last.app && observation.windowTitle === last.windowTitle;
27129
- const pauseBetween = pauseStartsAfter(canonicalMs(last.capturedAtUtc), canonicalMs(observation.capturedAtUtc));
27130
- if (!sameKey || gap > TIMELINE_MERGE_GAP_MS || pauseBetween) {
27131
- cards.push({ machine, observations: current });
27132
- current = [];
27133
- }
27134
- }
27135
- current.push(observation);
27136
- }
27137
- if (current.length > 0) cards.push({ machine, observations: current });
27138
- return cards;
27139
- }
27140
- function buildTimelineDay(input) {
27141
- const categories = input.categories ?? DEFAULT_TIMELINE_CATEGORIES;
27142
- validateTimelineCategories(categories);
27143
- const window = activityDayWindow(input.date, input.timezone);
27144
- const dayStartMs = Date.parse(window.startUtc);
27145
- const dayEndMs = Date.parse(window.endUtc);
27146
- const observations = input.observations.filter((observation) => Number.isFinite(canonicalMs(observation.capturedAtUtc))).filter((observation) => {
27147
- const ms = canonicalMs(observation.capturedAtUtc);
27148
- return ms >= dayStartMs && ms < dayEndMs;
27149
- });
27150
- for (const pause of input.pauses ?? []) {
27151
- const startMs = canonicalMs(pause.startUtc);
27152
- const endMs = canonicalMs(pause.endUtc);
27153
- if (!Number.isFinite(startMs) || !Number.isFinite(endMs) || startMs >= endMs) {
27154
- throw new RangeError("timeline pause must be a valid half-open [startUtc, endUtc) interval");
27155
- }
27156
- }
27157
- const pauseIntervals = unionIntervals(
27158
- (input.pauses ?? []).map((pause) => [canonicalMs(pause.startUtc), canonicalMs(pause.endUtc)]).map(([startMs, endMs]) => [Math.max(startMs, dayStartMs), Math.min(endMs, dayEndMs)]).filter(([startMs, endMs]) => endMs > startMs)
27159
- );
27160
- const tracks = /* @__PURE__ */ new Map();
27161
- for (const observation of observations) {
27162
- const track = tracks.get(observation.machine) ?? [];
27163
- track.push(observation);
27164
- tracks.set(observation.machine, track);
27165
- }
27166
- for (const track of tracks.values()) {
27167
- track.sort(
27168
- (a, b) => canonicalMs(a.capturedAtUtc) - canonicalMs(b.capturedAtUtc) || (a.contentHash < b.contentHash ? -1 : a.contentHash > b.contentHash ? 1 : 0)
27169
- );
27170
- }
27171
- const cards = [];
27172
- const machines = [...tracks.keys()].sort();
27173
- for (const machine of machines) {
27174
- const track = tracks.get(machine) ?? [];
27175
- const merged = mergeTrack(machine, track, pauseIntervals);
27176
- const trackIntervals = [];
27177
- for (let index = 0; index < merged.length; index++) {
27178
- const group = merged[index];
27179
- const first = group.observations[0];
27180
- const last = group.observations[group.observations.length - 1];
27181
- const startMs = canonicalMs(first.capturedAtUtc);
27182
- const lastMs = canonicalMs(last.capturedAtUtc);
27183
- const nextObsMs = index + 1 < merged.length ? canonicalMs(merged[index + 1].observations[0].capturedAtUtc) : Number.POSITIVE_INFINITY;
27184
- const pauseStartMs = pauseIntervals.find(([ps]) => ps > lastMs)?.[0] ?? Number.POSITIVE_INFINITY;
27185
- const endMs = Math.max(lastMs, Math.min(lastMs + TIMELINE_MAX_DWELL_MS, nextObsMs, pauseStartMs, dayEndMs));
27186
- trackIntervals.push([startMs, endMs]);
27187
- const evidenceIds = group.observations.map((observation) => observation.id);
27188
- const classification = classifyTimelineObservation(first, categories);
27189
- cards.push({
27190
- id: stableCardId(`activity|${machine}|${evidenceKeyOf(first)}|${evidenceKeyOf(last)}`),
27191
- kind: "activity",
27192
- title: first.windowTitle.length > 0 ? first.windowTitle : first.app,
27193
- summary: `${first.app} \xB7 ${machine} \xB7 ${evidenceIds.length} obs \xB7 ${formatDurationMinutes(endMs - startMs)}`,
27194
- categoryId: classification.categoryId,
27195
- confidence: classification.confidence,
27196
- startUtc: isoOf(startMs),
27197
- endUtc: isoOf(endMs),
27198
- dayKey: input.date,
27199
- timezone: input.timezone,
27200
- machine,
27201
- evidenceIds,
27202
- evidenceRange: { firstKey: evidenceKeyOf(first), lastKey: evidenceKeyOf(last) }
27203
- });
27204
- }
27205
- for (let index = 0; index + 1 < trackIntervals.length; index++) {
27206
- const gapStart = trackIntervals[index][1];
27207
- const gapEnd = trackIntervals[index + 1][0];
27208
- if (gapEnd <= gapStart) continue;
27209
- let pieces = [[gapStart, gapEnd]];
27210
- for (const [pauseStart, pauseEnd] of pauseIntervals) {
27211
- pieces = pieces.flatMap(([start, end]) => subtractInterval(start, end, pauseStart, pauseEnd));
27212
- }
27213
- for (const [start, end] of pieces) {
27214
- cards.push({
27215
- id: stableCardId(`idle|${machine}|${isoOf(start)}|${isoOf(end)}`),
27216
- kind: "idle",
27217
- title: "Idle",
27218
- summary: `${formatDurationMinutes(end - start)} gap on ${machine}`,
27219
- categoryId: TIMELINE_RESERVED_IDLE,
27220
- confidence: 1,
27221
- startUtc: isoOf(start),
27222
- endUtc: isoOf(end),
27223
- dayKey: input.date,
27224
- timezone: input.timezone,
27225
- machine,
27226
- evidenceIds: [],
27227
- evidenceRange: null
27228
- });
27229
- }
27230
- }
27231
- }
27232
- for (const [pauseStart, pauseEnd] of pauseIntervals) {
27233
- const reason = (input.pauses ?? []).find((pause) => canonicalMs(pause.startUtc) === pauseStart)?.reason;
27234
- cards.push({
27235
- id: stableCardId(`pause|${isoOf(pauseStart)}|${isoOf(pauseEnd)}`),
27236
- kind: "pause",
27237
- title: "Paused",
27238
- summary: reason === void 0 ? `${formatDurationMinutes(pauseEnd - pauseStart)} user pause` : `${formatDurationMinutes(pauseEnd - pauseStart)} user pause \u2014 ${reason}`,
27239
- categoryId: TIMELINE_RESERVED_PAUSE,
27240
- confidence: 1,
27241
- startUtc: isoOf(pauseStart),
27242
- endUtc: isoOf(pauseEnd),
27243
- dayKey: input.date,
27244
- timezone: input.timezone,
27245
- machine: null,
27246
- evidenceIds: [],
27247
- evidenceRange: null
27248
- });
27249
- }
27250
- cards.sort((a, b) => a.startUtc < b.startUtc ? -1 : a.startUtc > b.startUtc ? 1 : a.endUtc < b.endUtc ? -1 : a.endUtc > b.endUtc ? 1 : (a.machine ?? "") < (b.machine ?? "") ? -1 : (a.machine ?? "") > (b.machine ?? "") ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
27251
- return {
27252
- formatVersion: TIMELINE_FORMAT_VERSION,
27253
- date: input.date,
27254
- timezone: input.timezone,
27255
- startUtc: window.startUtc,
27256
- endUtc: window.endUtc,
27257
- cards
27258
- };
27259
- }
27260
- function serializeTimelineDay(day) {
27261
- return JSON.stringify(day);
27262
- }
27263
-
27264
- // src/activity/timeline/corrections.ts
27265
- import { mkdirSync } from "fs";
27266
- import path33 from "path";
27267
- function timelineCorrectionDatabasePath(memoryDir) {
27268
- return path33.join(memoryDir, "state", "activity-timeline.sqlite");
27269
- }
27270
- function rowToCorrection(row) {
27271
- return {
27272
- cardId: row.card_id,
27273
- categoryId: row.category_id ?? void 0,
27274
- title: row.title ?? void 0,
27275
- editedAtUtc: row.edited_at_utc
27276
- };
27277
- }
27278
- var TimelineCorrectionStore = class _TimelineCorrectionStore {
27279
- db;
27280
- constructor(db) {
27281
- this.db = db;
27282
- }
27283
- static open(memoryDir) {
27284
- mkdirSync(path33.join(memoryDir, "state"), { recursive: true });
27285
- const db = openBetterSqlite3(timelineCorrectionDatabasePath(memoryDir));
27286
- db.pragma("journal_mode = WAL");
27287
- db.pragma("busy_timeout = 5000");
27288
- db.exec(`
27289
- CREATE TABLE IF NOT EXISTS timeline_corrections (
27290
- card_id TEXT PRIMARY KEY,
27291
- category_id TEXT,
27292
- title TEXT,
27293
- edited_at_utc TEXT NOT NULL
27294
- );
27295
- `);
27296
- return new _TimelineCorrectionStore(db);
27297
- }
27298
- /**
27299
- * Persist one correction. `categoryId`, when set, must exist in `categories`
27300
- * (defaults to the built-in registry) — an unknown category is a malformed
27301
- * edit and must fail rather than silently strand the card.
27302
- */
27303
- upsert(correction, categories = DEFAULT_TIMELINE_CATEGORIES) {
27304
- validateTimelineCategories(categories);
27305
- if (typeof correction.cardId !== "string" || correction.cardId.length === 0) {
27306
- throw new RangeError("timeline correction requires a non-empty cardId");
27307
- }
27308
- if (typeof correction.editedAtUtc !== "string" || Number.isNaN(Date.parse(correction.editedAtUtc))) {
27309
- throw new RangeError("timeline correction requires a valid editedAtUtc instant");
27310
- }
27311
- if (correction.categoryId === void 0 && correction.title === void 0 || correction.title !== void 0 && correction.title.length === 0) {
27312
- throw new RangeError("timeline correction must set a categoryId and/or a non-empty title");
27313
- }
27314
- if (correction.categoryId !== void 0 && !categories.some((category) => category.id === correction.categoryId)) {
27315
- throw new RangeError(`timeline correction targets unknown category: ${correction.categoryId}`);
27316
- }
27317
- this.db.prepare(
27318
- `INSERT INTO timeline_corrections (card_id, category_id, title, edited_at_utc)
27319
- VALUES (?, ?, ?, ?)
27320
- ON CONFLICT(card_id) DO UPDATE SET category_id = excluded.category_id, title = excluded.title, edited_at_utc = excluded.edited_at_utc`
27321
- ).run(correction.cardId, correction.categoryId ?? null, correction.title ?? null, correction.editedAtUtc);
27322
- }
27323
- get(cardId) {
27324
- const row = this.db.prepare("SELECT card_id, category_id, title, edited_at_utc FROM timeline_corrections WHERE card_id = ?").get(cardId);
27325
- return row === void 0 ? void 0 : rowToCorrection(row);
27326
- }
27327
- /** All corrections ordered by card id (deterministic listing). */
27328
- list() {
27329
- return this.db.prepare("SELECT card_id, category_id, title, edited_at_utc FROM timeline_corrections ORDER BY card_id ASC").all().map((row) => rowToCorrection(row));
27330
- }
27331
- /** Explicitly reset a card to its derived values; true when a correction existed. */
27332
- reset(cardId) {
27333
- return this.db.prepare("DELETE FROM timeline_corrections WHERE card_id = ?").run(cardId).changes > 0;
27334
- }
27335
- close() {
27336
- this.db.close();
27337
- }
27338
- };
27339
- function applyTimelineCorrections(cards, corrections) {
27340
- const byCardId = new Map(corrections.map((correction) => [correction.cardId, correction]));
27341
- return cards.map((card) => {
27342
- const correction = byCardId.get(card.id);
27343
- if (correction === void 0) return card;
27344
- return {
27345
- id: card.id,
27346
- kind: card.kind,
27347
- title: correction.title ?? card.title,
27348
- summary: card.summary,
27349
- categoryId: correction.categoryId ?? card.categoryId,
27350
- confidence: 1,
27351
- startUtc: card.startUtc,
27352
- endUtc: card.endUtc,
27353
- dayKey: card.dayKey,
27354
- timezone: card.timezone,
27355
- machine: card.machine,
27356
- evidenceIds: card.evidenceIds,
27357
- evidenceRange: card.evidenceRange,
27358
- manualEdit: {
27359
- ...correction.categoryId !== void 0 ? { categoryId: correction.categoryId } : {},
27360
- ...correction.title !== void 0 ? { title: correction.title } : {},
27361
- editedAtUtc: correction.editedAtUtc
27362
- }
27363
- };
27364
- });
27365
- }
27366
-
27367
27191
  // src/activity/timeline/query.ts
27368
27192
  var RANGE_FORMATS = ["cards", "compact"];
27369
27193
  var MS_PER_DAY = 864e5;
@@ -27406,6 +27230,18 @@ function assertRange(fromMs, toMs, maxRangeDays) {
27406
27230
  throw new RangeError(`range exceeds timeline.qa.maxRangeDays (${maxRangeDays})`);
27407
27231
  }
27408
27232
  }
27233
+ function validateTimelineRangeQuery(query) {
27234
+ if (!RANGE_FORMATS.includes(query.format)) {
27235
+ throw new TypeError(`format must be one of: ${RANGE_FORMATS.join(", ")}`);
27236
+ }
27237
+ const maxRangeDays = query.maxRangeDays ?? DEFAULT_MAX_RANGE_DAYS;
27238
+ assertRange(parseInstant(query.from, "from"), parseInstant(query.to, "to"), maxRangeDays);
27239
+ }
27240
+ function validateTimelineSearchBounds(bounds) {
27241
+ const fromMs = parseInstant(bounds.from ?? bounds.to, "from");
27242
+ const toMs = parseInstant(bounds.to ?? bounds.from, "to");
27243
+ assertRange(fromMs, toMs, DEFAULT_MAX_RANGE_DAYS);
27244
+ }
27409
27245
  function cardOverlaps(card, fromMs, toMs) {
27410
27246
  const start = Date.parse(card.startUtc);
27411
27247
  const end = Date.parse(card.endUtc);
@@ -27548,16 +27384,18 @@ async function runTimelineCliCommand(deps, args, io) {
27548
27384
  const from = flagString(flags, "--from");
27549
27385
  const to = flagString(flags, "--to");
27550
27386
  if (!from || !to) throw new TypeError("range requires --from and --to");
27551
- if (!Array.isArray(deps.cards)) {
27552
- io.stderr.write("store_unreadable\n");
27553
- return 1;
27554
- }
27555
27387
  const formatRaw = flagString(flags, "--format") ?? "compact";
27556
27388
  if (formatRaw !== "cards" && formatRaw !== "compact") {
27557
27389
  throw new TypeError("format must be one of: cards, compact");
27558
27390
  }
27391
+ validateTimelineRangeQuery({ from, to, format: formatRaw, maxRangeDays: deps.qa.maxRangeDays });
27392
+ const cards = Array.isArray(deps.cards) ? deps.cards : deps.loadCards === void 0 ? null : await deps.loadCards({ from, to });
27393
+ if (!Array.isArray(cards)) {
27394
+ io.stderr.write("store_unreadable\n");
27395
+ return 1;
27396
+ }
27559
27397
  const categoriesRaw = flagString(flags, "--categories");
27560
- const result = queryTimelineRange(deps.cards, {
27398
+ const result = queryTimelineRange(cards, {
27561
27399
  from,
27562
27400
  to,
27563
27401
  format: formatRaw,
@@ -27577,10 +27415,16 @@ async function runTimelineCliCommand(deps, args, io) {
27577
27415
  if (limitRaw !== void 0 && !Number.isInteger(limit)) {
27578
27416
  throw new RangeError("limit must be an integer from 1 to 50");
27579
27417
  }
27580
- const result = queryTimelineSearch(deps.cards, {
27418
+ const from = flagString(flags, "--from");
27419
+ const to = flagString(flags, "--to");
27420
+ if (from !== void 0 || to !== void 0) {
27421
+ validateTimelineSearchBounds({ from, to });
27422
+ }
27423
+ const cards = Array.isArray(deps.cards) ? deps.cards : deps.loadCards === void 0 ? null : await deps.loadCards({ from, to });
27424
+ const result = queryTimelineSearch(cards, {
27581
27425
  query: q,
27582
- from: flagString(flags, "--from"),
27583
- to: flagString(flags, "--to"),
27426
+ from,
27427
+ to,
27584
27428
  limit
27585
27429
  });
27586
27430
  io.stdout.write(`${JSON.stringify(result)}
@@ -27853,10 +27697,10 @@ function buildWeeklyActivitySummary(cards, options) {
27853
27697
 
27854
27698
  // src/activity/timeline/weekly-persist.ts
27855
27699
  import { randomBytes as randomBytes3 } from "crypto";
27856
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "fs";
27857
- import path34 from "path";
27700
+ import { mkdirSync, readFileSync as readFileSync2, renameSync, unlinkSync, writeFileSync } from "fs";
27701
+ import path33 from "path";
27858
27702
  var WEEKLY_SNAPSHOT_FORMAT_VERSION = 1;
27859
- var WEEKLY_SNAPSHOT_DIR = path34.join("activity", "weekly");
27703
+ var WEEKLY_SNAPSHOT_DIR = path33.join("activity", "weekly");
27860
27704
  function requireToken(value, name) {
27861
27705
  if (typeof value !== "string" || value.trim().length === 0) {
27862
27706
  throw new TypeError(`${name} must be a non-empty string`);
@@ -27879,8 +27723,8 @@ function weeklySnapshotPath(input) {
27879
27723
  const identity = hashActivityBody(
27880
27724
  `${input.summary.weekStartUtc}\0${input.summary.weekEndUtc}\0${sourceRevision}\0${configHash}`
27881
27725
  );
27882
- return path34.join(
27883
- path34.resolve(memoryDir),
27726
+ return path33.join(
27727
+ path33.resolve(memoryDir),
27884
27728
  WEEKLY_SNAPSHOT_DIR,
27885
27729
  namespaceIdentityToken(namespace),
27886
27730
  `${weekDate}--${identity}.json`
@@ -27910,7 +27754,7 @@ function persistWeeklySnapshot(input) {
27910
27754
  throw error;
27911
27755
  }
27912
27756
  }
27913
- mkdirSync2(path34.dirname(filePath), { recursive: true, mode: 448 });
27757
+ mkdirSync(path33.dirname(filePath), { recursive: true, mode: 448 });
27914
27758
  const tmpPath = `${filePath}.${process.pid}.${randomBytes3(8).toString("hex")}.tmp`;
27915
27759
  writeFileSync(tmpPath, text, { encoding: "utf8", mode: 384 });
27916
27760
  try {
@@ -27925,264 +27769,6 @@ function persistWeeklySnapshot(input) {
27925
27769
  return { path: filePath, written: true };
27926
27770
  }
27927
27771
 
27928
- // src/activity/timeline/analysis.ts
27929
- var TIMELINE_ANALYSIS_PROMPT_VERSION = 1;
27930
- var TIMELINE_ANALYSIS_BATCH_SIZE = 40;
27931
- var TIMELINE_ANALYSIS_BATCH_OVERLAP = 2;
27932
- var TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS = 15e3;
27933
- var TimelineAnalysisConfigError = class extends Error {
27934
- name = "TimelineAnalysisConfigError";
27935
- code = "invalid_config";
27936
- constructor(message) {
27937
- super(message);
27938
- }
27939
- };
27940
- var INSTRUCTIONS = [
27941
- "Use only supplied evidence.",
27942
- "Preserve chronology.",
27943
- "Do not invent people, places, or tasks.",
27944
- "Avoid productivity or emotional claims.",
27945
- "Merge adjacent activity only when the evidence justifies it.",
27946
- 'Return strict JSON: {"ops":[...]} with evidenceRange, title, summary, categoryId, confidence, uncertainty.',
27947
- "Cite evidence ranges for every op. Empty ops is a valid no-op."
27948
- ].join(" ");
27949
- function fail(status, cards, provider, model) {
27950
- log.info(`timeline analysis status=${status} provider=${provider} model=${model} promptVersion=${TIMELINE_ANALYSIS_PROMPT_VERSION}`);
27951
- return {
27952
- status,
27953
- cards,
27954
- provider,
27955
- model,
27956
- promptVersion: TIMELINE_ANALYSIS_PROMPT_VERSION
27957
- };
27958
- }
27959
- function requiredToken(value, name) {
27960
- if (typeof value !== "string" || value.trim().length === 0) {
27961
- throw new TimelineAnalysisConfigError(`${name} is required`);
27962
- }
27963
- return value.trim();
27964
- }
27965
- function evidenceKeyOf2(observation) {
27966
- const parsed = Date.parse(observation.capturedAtUtc);
27967
- const instant = Number.isFinite(parsed) ? new Date(parsed).toISOString() : observation.capturedAtUtc;
27968
- return `${observation.machine}|${instant}|${observation.contentHash}`;
27969
- }
27970
- function sortObservations(observations) {
27971
- return [...observations].sort((a, b) => {
27972
- const time = Date.parse(a.capturedAtUtc) - Date.parse(b.capturedAtUtc);
27973
- if (time !== 0) return time;
27974
- if (a.contentHash !== b.contentHash) return a.contentHash < b.contentHash ? -1 : 1;
27975
- return a.id - b.id;
27976
- });
27977
- }
27978
- function batchObservations(observations) {
27979
- if (observations.length === 0) return [[]];
27980
- const size = TIMELINE_ANALYSIS_BATCH_SIZE;
27981
- const overlap = TIMELINE_ANALYSIS_BATCH_OVERLAP;
27982
- const step = size - overlap;
27983
- const batches = [];
27984
- for (let start = 0; start < observations.length; start += step) {
27985
- batches.push(observations.slice(start, start + size));
27986
- if (start + size >= observations.length) break;
27987
- }
27988
- return batches;
27989
- }
27990
- function safeObservation(observation) {
27991
- return {
27992
- id: observation.id,
27993
- machine: observation.machine,
27994
- capturedAtUtc: observation.capturedAtUtc,
27995
- app: observation.app,
27996
- windowTitle: observation.windowTitle,
27997
- ...observation.browserUrl ? { browserUrl: observation.browserUrl } : {},
27998
- contentHash: observation.contentHash
27999
- };
28000
- }
28001
- function safeCard(card) {
28002
- return {
28003
- id: card.id,
28004
- kind: card.kind,
28005
- title: card.title,
28006
- summary: card.summary,
28007
- categoryId: card.categoryId,
28008
- confidence: card.confidence,
28009
- startUtc: card.startUtc,
28010
- endUtc: card.endUtc,
28011
- machine: card.machine,
28012
- evidenceIds: card.evidenceIds,
28013
- evidenceRange: card.evidenceRange,
28014
- ...card.manualEdit ? { manualEdit: card.manualEdit } : {}
28015
- };
28016
- }
28017
- function buildTimelineAnalysisPrompt(input) {
28018
- const payload = {
28019
- date: input.date ?? null,
28020
- timezone: input.timezone ?? null,
28021
- categories: input.categories.map((category) => ({ id: category.id, name: category.name })),
28022
- preferences: input.preferences ?? [],
28023
- priorEdits: input.priorEdits ?? [],
28024
- cards: input.cards.map(safeCard),
28025
- observations: input.observations.map(safeObservation)
28026
- };
28027
- return `${INSTRUCTIONS}
28028
- ${JSON.stringify(payload)}`;
28029
- }
28030
- async function callComplete(complete, prompt, provider, model, timeoutMs, parent) {
28031
- const { promise: timeoutPromise, reject } = Promise.withResolvers();
28032
- const failOnce = (message, name) => {
28033
- reject(Object.assign(new Error(message), { name }));
28034
- };
28035
- const timer = setTimeout(() => failOnce("timeline analysis timed out", "TimeoutError"), timeoutMs);
28036
- if (parent?.aborted) {
28037
- clearTimeout(timer);
28038
- throw Object.assign(new Error("timeline analysis aborted"), { name: "AbortError" });
28039
- }
28040
- const onAbort = () => failOnce("timeline analysis aborted", "AbortError");
28041
- parent?.addEventListener("abort", onAbort, { once: true });
28042
- const signal = parent ? AbortSignal.any([parent, AbortSignal.timeout(timeoutMs)]) : AbortSignal.timeout(timeoutMs);
28043
- try {
28044
- return await Promise.race([complete({ prompt, provider, model, signal }), timeoutPromise]);
28045
- } finally {
28046
- clearTimeout(timer);
28047
- parent?.removeEventListener("abort", onAbort);
28048
- }
28049
- }
28050
- function parseOps(raw) {
28051
- if (typeof raw !== "string" || raw.trim().length === 0) return null;
28052
- for (const candidate of extractJsonCandidates(raw)) {
28053
- try {
28054
- const parsed = JSON.parse(candidate);
28055
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed) || !("ops" in parsed)) continue;
28056
- const ops = parsed.ops;
28057
- if (!Array.isArray(ops)) continue;
28058
- const out = [];
28059
- let valid = true;
28060
- for (const item of ops) {
28061
- const op = asOp(item);
28062
- if (!op) {
28063
- valid = false;
28064
- break;
28065
- }
28066
- out.push(op);
28067
- }
28068
- if (valid) return out;
28069
- } catch {
28070
- continue;
28071
- }
28072
- }
28073
- return null;
28074
- }
28075
- function asOp(value) {
28076
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
28077
- if (!("cardId" in value) || typeof value.cardId !== "string" || value.cardId.length === 0) return null;
28078
- if (!("evidenceRange" in value)) return null;
28079
- const range = value.evidenceRange;
28080
- if (!range || typeof range !== "object" || Array.isArray(range)) return null;
28081
- if (!("firstKey" in range) || typeof range.firstKey !== "string" || range.firstKey.length === 0) return null;
28082
- if (!("lastKey" in range) || typeof range.lastKey !== "string" || range.lastKey.length === 0) return null;
28083
- if ("title" in value && value.title !== void 0 && typeof value.title !== "string") return null;
28084
- if ("summary" in value && value.summary !== void 0 && typeof value.summary !== "string") return null;
28085
- if ("categoryId" in value && value.categoryId !== void 0 && typeof value.categoryId !== "string") return null;
28086
- if ("uncertainty" in value && value.uncertainty !== void 0 && typeof value.uncertainty !== "string") return null;
28087
- if ("confidence" in value && value.confidence !== void 0 && (typeof value.confidence !== "number" || value.confidence < 0 || value.confidence > 1)) {
28088
- return null;
28089
- }
28090
- return {
28091
- cardId: value.cardId,
28092
- title: "title" in value && typeof value.title === "string" ? value.title : void 0,
28093
- summary: "summary" in value && typeof value.summary === "string" ? value.summary : void 0,
28094
- categoryId: "categoryId" in value && typeof value.categoryId === "string" ? value.categoryId : void 0,
28095
- confidence: "confidence" in value && typeof value.confidence === "number" ? value.confidence : void 0,
28096
- uncertainty: "uncertainty" in value && typeof value.uncertainty === "string" ? value.uncertainty : void 0,
28097
- evidenceRange: { firstKey: range.firstKey, lastKey: range.lastKey }
28098
- };
28099
- }
28100
- function knownEvidenceKeys(cards, observations) {
28101
- const keys = /* @__PURE__ */ new Set();
28102
- for (const observation of observations) keys.add(evidenceKeyOf2(observation));
28103
- for (const card of cards) {
28104
- if (card.evidenceRange) {
28105
- keys.add(card.evidenceRange.firstKey);
28106
- keys.add(card.evidenceRange.lastKey);
28107
- }
28108
- }
28109
- return keys;
28110
- }
28111
- function applyOps(cards, ops, categories, evidenceKeys) {
28112
- if (ops.length === 0) return cards;
28113
- const byId = new Map(cards.map((card) => [card.id, card]));
28114
- const allowedCategories = new Set(categories.map((category) => category.id));
28115
- const next = /* @__PURE__ */ new Map();
28116
- for (const op of ops) {
28117
- const card = byId.get(op.cardId);
28118
- if (!card) return null;
28119
- if (!evidenceKeys.has(op.evidenceRange.firstKey) || !evidenceKeys.has(op.evidenceRange.lastKey)) return null;
28120
- if (op.categoryId !== void 0 && !allowedCategories.has(op.categoryId)) return null;
28121
- if (card.manualEdit) continue;
28122
- next.set(card.id, {
28123
- ...card,
28124
- ...op.title !== void 0 ? { title: op.title } : {},
28125
- ...op.summary !== void 0 ? { summary: op.summary } : {},
28126
- ...op.categoryId !== void 0 ? { categoryId: op.categoryId } : {},
28127
- ...op.confidence !== void 0 ? { confidence: op.confidence } : {}
28128
- });
28129
- }
28130
- if (next.size === 0) return cards;
28131
- return cards.map((card) => next.get(card.id) ?? card);
28132
- }
28133
- async function analyzeTimelineCards(input) {
28134
- const cards = input.cards;
28135
- if (!input.enabled) {
28136
- return { status: "disabled", cards };
28137
- }
28138
- const provider = requiredToken(input.provider, "provider");
28139
- const model = requiredToken(input.model, "model");
28140
- const complete = input.complete;
28141
- if (typeof complete !== "function") {
28142
- throw new TimelineAnalysisConfigError("complete is required");
28143
- }
28144
- const timeoutMs = input.timeoutMs ?? TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS;
28145
- if (!Number.isInteger(timeoutMs) || timeoutMs <= 0) {
28146
- throw new TimelineAnalysisConfigError("timeoutMs must be a positive integer");
28147
- }
28148
- if (input.cards.length === 0 && input.observations.length === 0) {
28149
- return fail("invalid_output", cards, provider, model);
28150
- }
28151
- const categories = input.categories ?? DEFAULT_TIMELINE_CATEGORIES;
28152
- const ordered = sortObservations(input.observations);
28153
- const batches = batchObservations(ordered);
28154
- const merged = /* @__PURE__ */ new Map();
28155
- try {
28156
- for (const batch of batches) {
28157
- const prompt = buildTimelineAnalysisPrompt({
28158
- date: input.date,
28159
- timezone: input.timezone,
28160
- cards: input.cards,
28161
- observations: batch,
28162
- categories,
28163
- preferences: input.preferences,
28164
- priorEdits: input.priorEdits
28165
- });
28166
- const raw = await callComplete(complete, prompt, provider, model, timeoutMs, input.signal);
28167
- const ops = parseOps(raw);
28168
- if (!ops) return fail("invalid_output", cards, provider, model);
28169
- for (const op of ops) merged.set(op.cardId, op);
28170
- }
28171
- } catch {
28172
- return fail("provider_failed", cards, provider, model);
28173
- }
28174
- const applied = applyOps(cards, [...merged.values()], categories, knownEvidenceKeys(cards, ordered));
28175
- if (!applied) return fail("invalid_output", cards, provider, model);
28176
- log.info(`timeline analysis status=ok provider=${provider} model=${model} promptVersion=${TIMELINE_ANALYSIS_PROMPT_VERSION}`);
28177
- return {
28178
- status: "ok",
28179
- cards: applied,
28180
- provider,
28181
- model,
28182
- promptVersion: TIMELINE_ANALYSIS_PROMPT_VERSION
28183
- };
28184
- }
28185
-
28186
27772
  // src/activity/timeline/recap-export.ts
28187
27773
  function compareCardIds(a, b) {
28188
27774
  if (a.id < b.id) return -1;
@@ -28383,7 +27969,7 @@ function compareObservations(a, b) {
28383
27969
  if (time !== 0) return time;
28384
27970
  return a.id - b.id;
28385
27971
  }
28386
- function batchObservations2(observations, options) {
27972
+ function batchObservations(observations, options) {
28387
27973
  const { maxBatch, overlap } = options;
28388
27974
  if (!Number.isInteger(overlap) || overlap < 0) {
28389
27975
  throw new RangeError("overlap must be a non-negative integer");
@@ -28414,14 +28000,14 @@ function boundEvidence(claims, observations) {
28414
28000
  }
28415
28001
 
28416
28002
  // src/activity/timeline/analysis-prompt.ts
28417
- var INSTRUCTIONS2 = "Use only supplied evidence. Preserve chronology. Do not invent people, places, or tasks. Return strict JSON.";
28003
+ var INSTRUCTIONS = "Use only supplied evidence. Preserve chronology. Do not invent people, places, or tasks. Return strict JSON.";
28418
28004
  function listedObservation(observation) {
28419
28005
  return { id: observation.id, capturedAtUtc: observation.capturedAtUtc };
28420
28006
  }
28421
28007
  function buildAnalysisPrompt(input) {
28422
28008
  const listed = [...input.observations].sort((a, b) => a.id - b.id).map(listedObservation);
28423
28009
  const body = listed.length === 0 ? "(empty)" : JSON.stringify(listed);
28424
- return `${INSTRUCTIONS2}
28010
+ return `${INSTRUCTIONS}
28425
28011
  Observations: ${body}`;
28426
28012
  }
28427
28013
 
@@ -28470,43 +28056,6 @@ function clipCardsToRecapWindow(cards, windowStartMs, windowEndMs) {
28470
28056
  return out;
28471
28057
  }
28472
28058
 
28473
- // src/activity/timeline/analysis-failure.ts
28474
- var ANALYSIS_FAILURE_KINDS = [
28475
- "provider_unavailable",
28476
- "timeout",
28477
- "aborted",
28478
- "rate_limited",
28479
- "malformed_json",
28480
- "invalid_schema",
28481
- "partial_output",
28482
- "invalid_config"
28483
- ];
28484
- var RETRYABLE_BY_KIND = {
28485
- provider_unavailable: true,
28486
- timeout: true,
28487
- rate_limited: true,
28488
- aborted: false,
28489
- malformed_json: false,
28490
- invalid_schema: false,
28491
- partial_output: false,
28492
- invalid_config: false
28493
- };
28494
- function isAnalysisFailureKind(value) {
28495
- return typeof value === "string" && ANALYSIS_FAILURE_KINDS.includes(value);
28496
- }
28497
- function classifyAnalysisFailure(kind) {
28498
- if (!isAnalysisFailureKind(kind)) {
28499
- throw new TypeError(
28500
- `unknown analysis failure kind: ${String(kind)}; allowed kinds: ${ANALYSIS_FAILURE_KINDS.join(", ")}`
28501
- );
28502
- }
28503
- return {
28504
- kind,
28505
- retryable: RETRYABLE_BY_KIND[kind],
28506
- preservesDeterministic: true
28507
- };
28508
- }
28509
-
28510
28059
  // src/activity/timeline/recap-merge-edits.ts
28511
28060
  function dedupeByFirst(list) {
28512
28061
  const seen = /* @__PURE__ */ new Set();
@@ -28546,55 +28095,6 @@ function mergeRecapUserEdits(input) {
28546
28095
  return { sections, preserved, regenerated };
28547
28096
  }
28548
28097
 
28549
- // src/activity/timeline/analysis-metadata.ts
28550
- var ANALYSIS_METADATA_MAX_FIELD_LENGTH = 120;
28551
- var IDENTIFIER = /^[A-Za-z0-9][A-Za-z0-9._:\-\/]*$/;
28552
- var FIELD_PATTERNS = {
28553
- provider: IDENTIFIER,
28554
- model: IDENTIFIER,
28555
- promptVersion: IDENTIFIER
28556
- };
28557
- function validateMetadataField(field, value) {
28558
- if (typeof value !== "string") {
28559
- throw new RangeError(
28560
- `analysis run metadata ${field} must be a string; received ${typeof value}`
28561
- );
28562
- }
28563
- if (value.length === 0) {
28564
- throw new RangeError(`analysis run metadata ${field} must not be empty`);
28565
- }
28566
- if (value.length > ANALYSIS_METADATA_MAX_FIELD_LENGTH) {
28567
- throw new RangeError(
28568
- `analysis run metadata ${field} is too long (max ${ANALYSIS_METADATA_MAX_FIELD_LENGTH} characters)`
28569
- );
28570
- }
28571
- if (/[\n\r\u2028\u2029]/.test(value)) {
28572
- throw new RangeError(`analysis run metadata ${field} must not contain a line break`);
28573
- }
28574
- const pattern = FIELD_PATTERNS[field];
28575
- if (pattern === void 0) {
28576
- throw new RangeError(`analysis run metadata has no pattern for field ${field}`);
28577
- }
28578
- if (!pattern.test(value)) {
28579
- throw new RangeError(
28580
- `analysis run metadata ${field} must be an identifier (letters, digits, and ._:-/ only)`
28581
- );
28582
- }
28583
- return value;
28584
- }
28585
- function buildAnalysisRunMetadata(input) {
28586
- const provider = validateMetadataField("provider", input.provider);
28587
- const model = validateMetadataField("model", input.model);
28588
- const promptVersion = validateMetadataField("promptVersion", input.promptVersion);
28589
- const observationCount = input.observationCount;
28590
- if (typeof observationCount !== "number" || !Number.isInteger(observationCount) || observationCount < 0) {
28591
- throw new RangeError(
28592
- `analysis run metadata observationCount must be a non-negative integer; received ${typeof observationCount}`
28593
- );
28594
- }
28595
- return { provider, model, promptVersion, observationCount };
28596
- }
28597
-
28598
28098
  // src/activity/timeline/recap-fallback.ts
28599
28099
  var RECAP_SOURCE_KINDS = ["ai", "deterministic", "previous"];
28600
28100
  var SLOT_ORDER = [
@@ -28644,234 +28144,12 @@ function selectRecapForDay(input) {
28644
28144
  return failure === void 0 ? { ok: false, error: "no_recap_available" } : { ok: false, error: "no_recap_available", failure };
28645
28145
  }
28646
28146
 
28647
- // src/activity/journal-vault-read.ts
28648
- var REMNIC_OPEN = "<!-- remnic:";
28649
- function readVaultJournal(input) {
28650
- if (input.fileText === null || input.fileText === void 0) {
28651
- return { ok: true, exists: false, reason: "missing_file" };
28652
- }
28653
- if (input.journalSection.length === 0) {
28654
- return { ok: true, exists: false, reason: "missing_heading" };
28655
- }
28656
- const lines = splitFileLines(input.fileText);
28657
- const hits = [];
28658
- const levels = [];
28659
- for (let i = 0; i < lines.length; i++) {
28660
- const heading = parseAtxHeading(lines[i]);
28661
- if (heading && heading.text === input.journalSection) {
28662
- hits.push(i + 1);
28663
- levels.push(heading.level);
28664
- }
28665
- }
28666
- if (hits.length === 0) return { ok: true, exists: false, reason: "missing_heading" };
28667
- if (hits.length > 1) return { ok: false, reason: "duplicate_heading", lines: hits };
28668
- const headingIndex = hits[0] - 1;
28669
- const level = levels[0];
28670
- let endIndex = lines.length;
28671
- for (let i = headingIndex + 1; i < lines.length; i++) {
28672
- const heading = parseAtxHeading(lines[i]);
28673
- if (heading && heading.level <= level) {
28674
- endIndex = i;
28675
- break;
28676
- }
28677
- }
28678
- const body = lines.slice(headingIndex + 1, endIndex).join("\n");
28679
- const stripped = stripRemnicOwnedRegions(body, input.publishSectionNames ?? []);
28680
- return {
28681
- ok: true,
28682
- exists: true,
28683
- text: trimNewlines(stripped.text),
28684
- heading: input.journalSection,
28685
- warnings: stripped.warnings
28686
- };
28687
- }
28688
- function stripRemnicOwnedRegions(text, publishSectionNames = []) {
28689
- const marked = cutIntervals(text, remnicIntervals(text));
28690
- return {
28691
- text: stripPublishHeadings(marked.text, publishSectionNames),
28692
- warnings: marked.warnings
28693
- };
28694
- }
28695
- function splitFileLines(fileText) {
28696
- const lines = fileText.split("\n");
28697
- for (let i = 0; i < lines.length; i++) {
28698
- const line = lines[i];
28699
- if (line.endsWith("\r")) lines[i] = line.slice(0, -1);
28700
- }
28701
- return lines;
28702
- }
28703
- function parseAtxHeading(line) {
28704
- let level = 0;
28705
- while (level < line.length && level < 6 && line[level] === "#") level++;
28706
- if (level === 0) return null;
28707
- const after = line[level];
28708
- if (after !== " " && after !== " ") return null;
28709
- let start = level + 1;
28710
- let end = line.length;
28711
- while (start < end && (line[start] === " " || line[start] === " ")) start++;
28712
- while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
28713
- let hashEnd = end;
28714
- while (hashEnd > start && line[hashEnd - 1] === "#") hashEnd--;
28715
- if (hashEnd < end && hashEnd > start && (line[hashEnd - 1] === " " || line[hashEnd - 1] === " ")) {
28716
- end = hashEnd;
28717
- while (end > start && (line[end - 1] === " " || line[end - 1] === " ")) end--;
28718
- }
28719
- return { level, text: line.slice(start, end) };
28720
- }
28721
- function remnicIntervals(text) {
28722
- const starts = [];
28723
- const ends = [];
28724
- let from = 0;
28725
- while (from < text.length) {
28726
- const open = text.indexOf(REMNIC_OPEN, from);
28727
- if (open === -1) break;
28728
- const afterOpen = open + REMNIC_OPEN.length;
28729
- const commentEnd = text.indexOf("-->", afterOpen);
28730
- if (commentEnd === -1) break;
28731
- const inner = text.slice(afterOpen, commentEnd).trim();
28732
- if (inner.endsWith(":start")) {
28733
- const name = inner.slice(0, -":start".length);
28734
- if (name.length > 0) starts.push({ name, start: open, after: commentEnd + 3 });
28735
- } else if (inner.endsWith(":end")) {
28736
- const name = inner.slice(0, -":end".length);
28737
- if (name.length > 0) ends.push({ name, start: open, end: commentEnd + 3 });
28738
- }
28739
- from = commentEnd + 3;
28740
- }
28741
- const usedEnds = /* @__PURE__ */ new Set();
28742
- const intervals = [];
28743
- const warnings = [];
28744
- for (const start of starts) {
28745
- const match = ends.find((end) => end.name === start.name && end.start >= start.after && !usedEnds.has(end.start));
28746
- if (match) {
28747
- usedEnds.add(match.start);
28748
- intervals.push({ start: start.start, end: eatTrailingNewline(text, match.end) });
28749
- } else {
28750
- intervals.push({ start: start.start, end: text.length });
28751
- warnings.push(`unclosed remnic region "${start.name}"`);
28752
- }
28753
- }
28754
- for (const end of ends) {
28755
- if (usedEnds.has(end.start)) continue;
28756
- const startBefore = starts.some((start) => start.start < end.start);
28757
- if (!startBefore) intervals.push({ start: 0, end: eatTrailingNewline(text, end.end) });
28758
- }
28759
- return { intervals: mergeIntervals2(intervals), warnings };
28760
- }
28761
- function eatTrailingNewline(text, index) {
28762
- if (text[index] === "\n") return index + 1;
28763
- if (text[index] === "\r" && text[index + 1] === "\n") return index + 2;
28764
- if (text[index] === "\r") return index + 1;
28765
- return index;
28766
- }
28767
- function mergeIntervals2(items) {
28768
- if (items.length === 0) return [];
28769
- const sorted = items.slice().sort((a, b) => a.start - b.start || a.end - b.end);
28770
- const out = [{ start: sorted[0].start, end: sorted[0].end }];
28771
- for (let i = 1; i < sorted.length; i++) {
28772
- const cur = sorted[i];
28773
- const last = out[out.length - 1];
28774
- if (cur.start <= last.end) last.end = Math.max(last.end, cur.end);
28775
- else out.push({ start: cur.start, end: cur.end });
28776
- }
28777
- return out;
28778
- }
28779
- function cutIntervals(text, found) {
28780
- let out = "";
28781
- let pos = 0;
28782
- for (const interval of found.intervals) {
28783
- if (interval.start > pos) out += text.slice(pos, interval.start);
28784
- pos = Math.max(pos, interval.end);
28785
- }
28786
- if (pos < text.length) out += text.slice(pos);
28787
- return { text: out, warnings: found.warnings };
28788
- }
28789
- function stripPublishHeadings(text, names) {
28790
- if (names.length === 0 || text.length === 0) return text;
28791
- const lines = text.split("\n");
28792
- const keep = lines.map(() => true);
28793
- for (let i = 0; i < lines.length; i++) {
28794
- if (!keep[i]) continue;
28795
- const heading = parseAtxHeading(lines[i]);
28796
- if (!heading || !names.includes(heading.text)) continue;
28797
- keep[i] = false;
28798
- for (let j = i + 1; j < lines.length; j++) {
28799
- const next = parseAtxHeading(lines[j]);
28800
- if (next && next.level <= heading.level) break;
28801
- keep[j] = false;
28802
- }
28803
- }
28804
- return lines.filter((_, i) => keep[i]).join("\n");
28805
- }
28806
- function trimNewlines(text) {
28807
- let start = 0;
28808
- let end = text.length;
28809
- while (start < end && (text[start] === "\n" || text[start] === "\r")) start++;
28810
- while (end > start && (text[end - 1] === "\n" || text[end - 1] === "\r")) end--;
28811
- return text.slice(start, end);
28812
- }
28813
-
28814
- // src/activity/journal-vault-prereq.ts
28815
- var VAULT_JOURNAL_PREREQUISITES = [
28816
- "vault.enabled",
28817
- "vault.dailyNotePath",
28818
- "vault.readback.journalSection"
28819
- ];
28820
- function checkVaultJournalPrerequisites(input) {
28821
- const missing = [];
28822
- if (input.vaultEnabled !== true) missing.push("vault.enabled");
28823
- if (typeof input.dailyNotePath !== "string" || input.dailyNotePath.trim().length === 0) {
28824
- missing.push("vault.dailyNotePath");
28825
- }
28826
- if (typeof input.journalSection !== "string" || input.journalSection.trim().length === 0) {
28827
- missing.push("vault.readback.journalSection");
28828
- }
28829
- if (missing.length === 0) return { ok: true };
28830
- return {
28831
- ok: false,
28832
- missing,
28833
- message: `vault journal read-back prerequisites unmet: ${missing.join(", ")}`
28834
- };
28835
- }
28836
-
28837
- // src/activity/journal-vault-provenance.ts
28838
- var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
28839
- function buildJournalMemoryProvenance(input) {
28840
- if (typeof input.source !== "string") {
28841
- throw new RangeError("journal provenance source must be a string");
28842
- }
28843
- const resolved = resolveJournalSource({
28844
- source: input.source,
28845
- // Provenance never consumes the heading; vault mode just requires a
28846
- // non-empty one to resolve.
28847
- heading: "journal"
28848
- });
28849
- if (!resolved.ok) {
28850
- throw new RangeError(
28851
- `journal provenance source must be one of "file", "vault": ${JSON.stringify(input.source)}`
28852
- );
28853
- }
28854
- if (typeof input.date !== "string" || !DAY_PATTERN.test(input.date)) {
28855
- throw new RangeError(
28856
- `journal provenance date must be exactly YYYY-MM-DD: ${JSON.stringify(input.date)}`
28857
- );
28858
- }
28859
- const [year, month, day] = input.date.split("-").map(Number);
28860
- const utc = new Date(Date.UTC(year, month - 1, day));
28861
- if (utc.getUTCFullYear() !== year || utc.getUTCMonth() !== month - 1 || utc.getUTCDate() !== day) {
28862
- throw new RangeError(
28863
- `journal provenance date must be a real calendar day: ${input.date}`
28864
- );
28865
- }
28866
- return {
28867
- tags: ["journal", `journal-day:${input.date}`],
28868
- structuredAttributes: { journalSource: resolved.mode },
28869
- validAt: `${input.date}T00:00:00.000Z`
28870
- };
28871
- }
28147
+ // src/activity/journal-read.ts
28148
+ import { closeSync, constants as fsConstants, fstatSync, lstatSync, openSync, readFileSync as readFileSync3, realpathSync, statSync as statSync2 } from "fs";
28149
+ import path34 from "path";
28872
28150
 
28873
28151
  // src/activity/journal-section.ts
28874
- function parseAtxHeading2(line) {
28152
+ function parseAtxHeading(line) {
28875
28153
  let level = 0;
28876
28154
  while (level < line.length && level < 6 && line[level] === "#") level++;
28877
28155
  if (level === 0) return null;
@@ -28895,10 +28173,12 @@ var MARKER_OPEN = "<!-- remnic:";
28895
28173
  var MARKER_CLOSE = "-->";
28896
28174
  var START_SUFFIX = ":start";
28897
28175
  var END_SUFFIX = ":end";
28898
- function stripRemnicOwnedRegions2(sectionText, ownedHeadings) {
28899
- return stripOwnedHeadings(stripMarkerRegions(sectionText), ownedHeadings);
28176
+ function stripRemnicOwnedRegions(sectionText, ownedHeadings) {
28177
+ const warnings = [];
28178
+ const marked = stripMarkerRegions(sectionText, warnings);
28179
+ return { text: stripOwnedHeadings(marked, ownedHeadings), warnings };
28900
28180
  }
28901
- function stripMarkerRegions(text) {
28181
+ function stripMarkerRegions(text, warnings) {
28902
28182
  const lines = text.split("\n");
28903
28183
  const keep = lines.map(() => true);
28904
28184
  let openName = null;
@@ -28911,9 +28191,17 @@ function stripMarkerRegions(text) {
28911
28191
  }
28912
28192
  if (marker) {
28913
28193
  keep[i] = false;
28914
- if (marker.kind === "start") openName = marker.name;
28194
+ if (marker.kind === "start") {
28195
+ openName = marker.name;
28196
+ } else {
28197
+ for (let j = 0; j < i; j++) keep[j] = false;
28198
+ warnings.push(`unmatched remnic region end "${marker.name}"`);
28199
+ }
28915
28200
  }
28916
28201
  }
28202
+ if (openName !== null) {
28203
+ warnings.push(`unclosed remnic region "${openName}"`);
28204
+ }
28917
28205
  return emitKeptLines(lines, keep);
28918
28206
  }
28919
28207
  function stripOwnedHeadings(text, ownedHeadings) {
@@ -28923,11 +28211,11 @@ function stripOwnedHeadings(text, ownedHeadings) {
28923
28211
  const keep = lines.map(() => true);
28924
28212
  for (let i = 0; i < lines.length; i++) {
28925
28213
  if (!keep[i]) continue;
28926
- const heading = parseAtxHeading2(lines[i]);
28214
+ const heading = parseAtxHeading(lines[i]);
28927
28215
  if (!heading || !wanted.has(heading.text)) continue;
28928
28216
  keep[i] = false;
28929
28217
  for (let j = i + 1; j < lines.length; j++) {
28930
- const next = parseAtxHeading2(lines[j]);
28218
+ const next = parseAtxHeading(lines[j]);
28931
28219
  if (next && next.level <= heading.level) break;
28932
28220
  keep[j] = false;
28933
28221
  }
@@ -28977,6 +28265,427 @@ function ownedHeadingSet(ownedHeadings) {
28977
28265
  return wanted;
28978
28266
  }
28979
28267
 
28268
+ // src/activity/journal-vault-read.ts
28269
+ function readVaultJournal(input) {
28270
+ if (input.fileText === null || input.fileText === void 0) {
28271
+ return { ok: true, exists: false, reason: "missing_file" };
28272
+ }
28273
+ if (input.journalSection.length === 0) {
28274
+ return { ok: true, exists: false, reason: "missing_heading" };
28275
+ }
28276
+ const lines = splitFileLines(input.fileText);
28277
+ const hits = [];
28278
+ const levels = [];
28279
+ for (let i = 0; i < lines.length; i++) {
28280
+ const heading = parseAtxHeading(lines[i]);
28281
+ if (heading && heading.text === input.journalSection) {
28282
+ hits.push(i + 1);
28283
+ levels.push(heading.level);
28284
+ }
28285
+ }
28286
+ if (hits.length === 0) return { ok: true, exists: false, reason: "missing_heading" };
28287
+ if (hits.length > 1) return { ok: false, reason: "duplicate_heading", lines: hits };
28288
+ const headingIndex = hits[0] - 1;
28289
+ const level = levels[0];
28290
+ let endIndex = lines.length;
28291
+ for (let i = headingIndex + 1; i < lines.length; i++) {
28292
+ const heading = parseAtxHeading(lines[i]);
28293
+ if (heading && heading.level <= level) {
28294
+ endIndex = i;
28295
+ break;
28296
+ }
28297
+ }
28298
+ const body = lines.slice(headingIndex + 1, endIndex).join("\n");
28299
+ const stripped = stripRemnicOwnedRegions(body, input.publishSectionNames ?? []);
28300
+ return {
28301
+ ok: true,
28302
+ exists: true,
28303
+ text: trimNewlines(stripped.text),
28304
+ heading: input.journalSection,
28305
+ warnings: stripped.warnings
28306
+ };
28307
+ }
28308
+ function splitFileLines(fileText) {
28309
+ const lines = fileText.split("\n");
28310
+ for (let i = 0; i < lines.length; i++) {
28311
+ const line = lines[i];
28312
+ if (line.endsWith("\r")) lines[i] = line.slice(0, -1);
28313
+ }
28314
+ return lines;
28315
+ }
28316
+ function trimNewlines(text) {
28317
+ let start = 0;
28318
+ let end = text.length;
28319
+ while (start < end && (text[start] === "\n" || text[start] === "\r")) start++;
28320
+ while (end > start && (text[end - 1] === "\n" || text[end - 1] === "\r")) end--;
28321
+ return text.slice(start, end);
28322
+ }
28323
+
28324
+ // src/activity/journal-read.ts
28325
+ function publisherOwnedSectionNames(vault) {
28326
+ if (vault.sectionStrategy !== "heading") return [];
28327
+ const names = [];
28328
+ for (const target of Object.values(vault.publish)) {
28329
+ if (target.enabled && target.target === "daily" && target.section.trim().length > 0) {
28330
+ names.push(target.section);
28331
+ }
28332
+ }
28333
+ return names;
28334
+ }
28335
+ function readJournalForDate(input) {
28336
+ const journalSection = input.vault.readback.journalSection;
28337
+ const relative = resolveVaultNotePath(input.vault.dailyNotePath, input.date, {
28338
+ timezone: input.timezone
28339
+ });
28340
+ const root = path34.resolve(expandTildePath(input.vault.vaultPath));
28341
+ const filePath = path34.join(root, relative);
28342
+ try {
28343
+ const rootStat = lstatSync(root);
28344
+ if (rootStat.isSymbolicLink() || !rootStat.isDirectory()) {
28345
+ return { ok: false, reason: "not_directory", filePath };
28346
+ }
28347
+ } catch {
28348
+ return { ok: true, exists: false, reason: "missing_file", filePath };
28349
+ }
28350
+ const lexical = path34.relative(root, filePath);
28351
+ if (lexical.length === 0 || lexical === ".." || lexical.startsWith(`..${path34.sep}`) || path34.isAbsolute(lexical)) {
28352
+ return { ok: false, reason: "path_escape", filePath };
28353
+ }
28354
+ if (!containedBySymlinks(root, filePath)) {
28355
+ return { ok: false, reason: "symlink_escape", filePath };
28356
+ }
28357
+ let fileText;
28358
+ try {
28359
+ fileText = readVerifiedDailyNote(root, filePath);
28360
+ } catch (err) {
28361
+ const code = err.code;
28362
+ if (code === "ENOENT") {
28363
+ return { ok: true, exists: false, reason: "missing_file", filePath };
28364
+ }
28365
+ if (code === "ELOOP" || code === "EISDIR") {
28366
+ return { ok: false, reason: "symlink_escape", filePath };
28367
+ }
28368
+ throw err;
28369
+ }
28370
+ const result = readVaultJournal({
28371
+ fileText,
28372
+ journalSection,
28373
+ publishSectionNames: publisherOwnedSectionNames(input.vault)
28374
+ });
28375
+ return { ...result, filePath };
28376
+ }
28377
+ function containedBySymlinks(root, dest) {
28378
+ const realRoot = realpathSync(root);
28379
+ let probe = dest;
28380
+ for (; ; ) {
28381
+ try {
28382
+ if (statSync2(probe).isFile() || statSync2(probe).isDirectory()) {
28383
+ const real = realpathSync(probe);
28384
+ return real === realRoot || real.startsWith(`${realRoot}${path34.sep}`);
28385
+ }
28386
+ } catch {
28387
+ }
28388
+ const parent = path34.dirname(probe);
28389
+ if (parent === probe) return false;
28390
+ probe = parent;
28391
+ }
28392
+ }
28393
+ function symlinkRejected() {
28394
+ const err = new Error("symlink refused");
28395
+ err.code = "ELOOP";
28396
+ return err;
28397
+ }
28398
+ function readVerifiedDailyNote(root, filePath) {
28399
+ const relative = path34.relative(root, filePath);
28400
+ const parts = relative.split(path34.sep).filter((part) => part.length > 0 && part !== ".");
28401
+ let cursor = root;
28402
+ for (const part of parts) {
28403
+ cursor = path34.join(cursor, part);
28404
+ const st = lstatSync(cursor);
28405
+ if (st.isSymbolicLink()) throw symlinkRejected();
28406
+ }
28407
+ const parent = path34.dirname(filePath);
28408
+ const parentLstat = lstatSync(parent);
28409
+ if (parentLstat.isSymbolicLink() || !parentLstat.isDirectory()) throw symlinkRejected();
28410
+ const nofollow = fsConstants.O_NOFOLLOW ?? 0;
28411
+ const parentFd = openSync(parent, fsConstants.O_RDONLY | fsConstants.O_DIRECTORY | nofollow);
28412
+ try {
28413
+ const parentFstat = fstatSync(parentFd);
28414
+ if (parentFstat.ino !== parentLstat.ino || parentFstat.dev !== parentLstat.dev) {
28415
+ throw symlinkRejected();
28416
+ }
28417
+ } finally {
28418
+ closeSync(parentFd);
28419
+ }
28420
+ const fd = openSync(filePath, fsConstants.O_RDONLY | nofollow);
28421
+ try {
28422
+ const opened = fstatSync(fd);
28423
+ if (!opened.isFile()) throw symlinkRejected();
28424
+ const pathLstat = lstatSync(filePath);
28425
+ if (pathLstat.isSymbolicLink() || pathLstat.ino !== opened.ino || pathLstat.dev !== opened.dev) {
28426
+ throw symlinkRejected();
28427
+ }
28428
+ try {
28429
+ const fdPath = realpathSync(`/proc/self/fd/${fd}`);
28430
+ const realRoot = realpathSync(root);
28431
+ if (fdPath !== realRoot && !fdPath.startsWith(`${realRoot}${path34.sep}`)) {
28432
+ throw symlinkRejected();
28433
+ }
28434
+ } catch (err) {
28435
+ if (err.code === "ELOOP") throw err;
28436
+ }
28437
+ return readFileSync3(fd, "utf8");
28438
+ } finally {
28439
+ closeSync(fd);
28440
+ }
28441
+ }
28442
+
28443
+ // src/activity/journal-state.ts
28444
+ import { createHash as createHash9, randomBytes as randomBytes4 } from "crypto";
28445
+ import { mkdirSync as mkdirSync2, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync2 } from "fs";
28446
+ import path35 from "path";
28447
+ var STATE_DIR_NAME = "state";
28448
+ var STATE_FILE_NAME = "timeline.json";
28449
+ function timelineStatePath(memoryDir) {
28450
+ return path35.join(memoryDir, STATE_DIR_NAME, STATE_FILE_NAME);
28451
+ }
28452
+ function hashJournalText(text) {
28453
+ return createHash9("sha256").update(text, "utf8").digest("hex");
28454
+ }
28455
+ function readTimelineState(memoryDir) {
28456
+ const filePath = timelineStatePath(memoryDir);
28457
+ let parsed;
28458
+ try {
28459
+ parsed = JSON.parse(readFileSync4(filePath, "utf8"));
28460
+ } catch {
28461
+ return { version: 1, journal: {} };
28462
+ }
28463
+ if (typeof parsed !== "object" || parsed === null || !("journal" in parsed)) {
28464
+ return { version: 1, journal: {} };
28465
+ }
28466
+ const journal = parsed.journal;
28467
+ if (typeof journal !== "object" || journal === null) return { version: 1, journal: {} };
28468
+ const hashes = {};
28469
+ for (const [date, value] of Object.entries(journal)) {
28470
+ if (typeof value === "string" && value.length > 0) hashes[date] = value;
28471
+ }
28472
+ return { version: 1, journal: hashes };
28473
+ }
28474
+ function writeTimelineState(memoryDir, state) {
28475
+ const filePath = timelineStatePath(memoryDir);
28476
+ mkdirSync2(path35.dirname(filePath), { recursive: true });
28477
+ const tempPath = `${filePath}.${process.pid}.${randomBytes4(8).toString("hex")}.tmp`;
28478
+ writeFileSync2(tempPath, `${JSON.stringify(state, null, 2)}
28479
+ `);
28480
+ renameSync2(tempPath, filePath);
28481
+ }
28482
+ function journalDateLockPath(memoryDir, date) {
28483
+ return path35.join(memoryDir, STATE_DIR_NAME, `journal-extract-${date}.lock`);
28484
+ }
28485
+ function timelineStateLockPath(memoryDir) {
28486
+ return `${timelineStatePath(memoryDir)}.lock`;
28487
+ }
28488
+ var DATE_LOCK_OPTS = { staleMs: 12e4, maxWaitMs: 6e4 };
28489
+ var STATE_LOCK_OPTS = { staleMs: 3e4, maxWaitMs: 15e3 };
28490
+ async function withJournalDateLock(memoryDir, date, task) {
28491
+ return withHeldFileLock(journalDateLockPath(memoryDir, date), DATE_LOCK_OPTS, async (acquired) => {
28492
+ if (!acquired) {
28493
+ throw new Error(`journal: could not acquire the extract lock for ${date}`);
28494
+ }
28495
+ return task();
28496
+ });
28497
+ }
28498
+ async function commitJournalHash(memoryDir, date, hash) {
28499
+ await withHeldFileLock(timelineStateLockPath(memoryDir), STATE_LOCK_OPTS, async (acquired) => {
28500
+ if (!acquired) {
28501
+ throw new Error("journal: could not acquire the timeline state lock");
28502
+ }
28503
+ const latest = readTimelineState(memoryDir);
28504
+ writeTimelineState(memoryDir, setJournalHash(latest, date, hash));
28505
+ });
28506
+ }
28507
+ function setJournalHash(state, date, hash) {
28508
+ return { ...state, journal: { ...state.journal, [date]: hash } };
28509
+ }
28510
+ function journalUnchanged(state, date, text) {
28511
+ const stored = state.journal[date];
28512
+ return typeof stored === "string" && stored === hashJournalText(text);
28513
+ }
28514
+
28515
+ // src/activity/journal-vault-provenance.ts
28516
+ var DAY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
28517
+ function buildJournalMemoryProvenance(input) {
28518
+ if (typeof input.source !== "string") {
28519
+ throw new RangeError("journal provenance source must be a string");
28520
+ }
28521
+ const resolved = resolveJournalSource({ source: input.source });
28522
+ if (!resolved.ok) {
28523
+ throw new RangeError(
28524
+ `journal provenance source must be one of "memoryDir", "vault": ${JSON.stringify(input.source)}`
28525
+ );
28526
+ }
28527
+ if (typeof input.date !== "string" || !DAY_PATTERN.test(input.date)) {
28528
+ throw new RangeError(
28529
+ `journal provenance date must be exactly YYYY-MM-DD: ${JSON.stringify(input.date)}`
28530
+ );
28531
+ }
28532
+ const [year, month, day] = input.date.split("-").map(Number);
28533
+ const utc = new Date(Date.UTC(year, month - 1, day));
28534
+ if (utc.getUTCFullYear() !== year || utc.getUTCMonth() !== month - 1 || utc.getUTCDate() !== day) {
28535
+ throw new RangeError(
28536
+ `journal provenance date must be a real calendar day: ${input.date}`
28537
+ );
28538
+ }
28539
+ return {
28540
+ tags: ["journal", `journal-day:${input.date}`],
28541
+ structuredAttributes: { journalSource: resolved.mode },
28542
+ validAt: `${input.date}T00:00:00.000Z`
28543
+ };
28544
+ }
28545
+
28546
+ // src/activity/journal-extract.ts
28547
+ function createJournalMemoryWriter(storage) {
28548
+ return {
28549
+ writeSealedMemory: storage.writeSealedMemory.bind(storage),
28550
+ hasJournalMemoryContent: async (content) => {
28551
+ if (await storage.hasFactContentHash(content)) return true;
28552
+ const needle = stripAttributesSuffix(content);
28553
+ const memories = await storage.readAllMemories();
28554
+ return memories.some(
28555
+ (memory) => Array.isArray(memory.frontmatter.tags) && memory.frontmatter.tags.includes("journal") && stripAttributesSuffix(memory.content) === needle
28556
+ );
28557
+ }
28558
+ };
28559
+ }
28560
+ async function runJournalReviewExtraction(input) {
28561
+ const result = {
28562
+ pendingReview: 0,
28563
+ rejectedByJudge: 0,
28564
+ skipped: 0,
28565
+ completed: false,
28566
+ warnings: []
28567
+ };
28568
+ if (input.journalConfig.extractionMode !== "review") return result;
28569
+ if (input.journalText.trim().length === 0) {
28570
+ result.completed = true;
28571
+ return result;
28572
+ }
28573
+ const sanitized = sanitizeMemoryContent(input.journalText);
28574
+ if (!sanitized.clean) {
28575
+ result.warnings.push(
28576
+ `journal text for ${input.date} failed sanitization (${sanitized.violations.length} violation(s)); extraction skipped`
28577
+ );
28578
+ result.completed = true;
28579
+ return result;
28580
+ }
28581
+ const provenance = buildJournalMemoryProvenance({ source: input.source, date: input.date });
28582
+ let extracted;
28583
+ try {
28584
+ extracted = await input.deps.extract([
28585
+ {
28586
+ role: "user",
28587
+ content: sanitized.text,
28588
+ timestamp: (input.deps.now ?? (() => /* @__PURE__ */ new Date()))().toISOString()
28589
+ }
28590
+ ]);
28591
+ } catch (err) {
28592
+ log.warn(
28593
+ `journal extraction failed for ${input.date}: ${err instanceof Error ? err.message : String(err)}`
28594
+ );
28595
+ return result;
28596
+ }
28597
+ if (extracted.extractionFailure !== void 0) {
28598
+ log.warn(
28599
+ `journal extraction reported a failure for ${input.date}: ${extracted.extractionFailure}`
28600
+ );
28601
+ return result;
28602
+ }
28603
+ result.completed = true;
28604
+ let verdicts = /* @__PURE__ */ new Map();
28605
+ const candidates = dedupeInRun(extracted.facts, result);
28606
+ if (input.deps.judge !== void 0 && candidates.length > 0) {
28607
+ try {
28608
+ verdicts = await input.deps.judge(
28609
+ candidates.map((fact) => ({
28610
+ text: fact.content,
28611
+ category: fact.category,
28612
+ confidence: fact.confidence,
28613
+ tags: fact.tags,
28614
+ importanceLevel: scoreImportance(fact.content, fact.category, fact.tags).level
28615
+ }))
28616
+ );
28617
+ } catch (err) {
28618
+ log.warn(
28619
+ `journal extraction judge unavailable for ${input.date}: ${err instanceof Error ? err.message : String(err)} \u2014 review-only writes continue without verdicts`
28620
+ );
28621
+ }
28622
+ }
28623
+ let wrote = false;
28624
+ const ctx = { source: "journal", now: input.deps.now };
28625
+ for (let index = 0; index < candidates.length; index += 1) {
28626
+ const fact = candidates[index];
28627
+ const verdict = verdicts.get(index);
28628
+ const verdictKind = verdict === void 0 ? void 0 : getVerdictKind(verdict);
28629
+ if (verdictKind === "reject") {
28630
+ result.rejectedByJudge += 1;
28631
+ continue;
28632
+ }
28633
+ const normalizedKey = fact.content.trim().toLowerCase();
28634
+ if (await input.deps.writer.hasJournalMemoryContent(fact.content)) {
28635
+ result.skipped += 1;
28636
+ continue;
28637
+ }
28638
+ const envelope = composeMemoryEnvelope(
28639
+ {
28640
+ content: fact.content,
28641
+ category: fact.category,
28642
+ tags: [...fact.tags, ...provenance.tags],
28643
+ entityRef: fact.entityRef,
28644
+ confidence: fact.confidence,
28645
+ validAt: provenance.validAt,
28646
+ structuredAttributes: { ...provenance.structuredAttributes },
28647
+ sourceConnector: "journal",
28648
+ sourceReason: input.source === "vault" ? "vault daily-note journal" : "memoryDir journal"
28649
+ },
28650
+ ctx,
28651
+ { salvage: true }
28652
+ );
28653
+ if (envelope.salvageNotes.length > 0) {
28654
+ log.warn(`journal write salvaged invalid fields: ${envelope.salvageNotes.join("; ")}`);
28655
+ }
28656
+ const write = await input.deps.writer.writeSealedMemory(envelope, {
28657
+ status: "pending_review",
28658
+ contentHashSource: normalizedKey,
28659
+ importance: scoreImportance(fact.content, fact.category, fact.tags)
28660
+ });
28661
+ if (write.tombstoneBlocked) {
28662
+ result.skipped += 1;
28663
+ continue;
28664
+ }
28665
+ result.pendingReview += 1;
28666
+ wrote = true;
28667
+ }
28668
+ if (wrote && input.deps.afterWrites !== void 0) {
28669
+ try {
28670
+ await input.deps.afterWrites();
28671
+ } catch (err) {
28672
+ result.warnings.push(
28673
+ `reindex after journal writes failed: ${err instanceof Error ? err.message : String(err)}`
28674
+ );
28675
+ }
28676
+ }
28677
+ return result;
28678
+ }
28679
+ function dedupeInRun(facts, result) {
28680
+ const seen = /* @__PURE__ */ new Map();
28681
+ for (const fact of facts) {
28682
+ const key = fact.content.trim().toLowerCase();
28683
+ if (!seen.has(key)) seen.set(key, fact);
28684
+ else result.skipped += 1;
28685
+ }
28686
+ return [...seen.values()];
28687
+ }
28688
+
28980
28689
  // src/activity/memory-gen.ts
28981
28690
  var ACTIVITY_ALLOWED_CATEGORIES = {
28982
28691
  decision: true,
@@ -29488,7 +29197,7 @@ function applyVaultFrontmatter(existingYaml, updates) {
29488
29197
  }
29489
29198
 
29490
29199
  // src/activity/vault-wikilink.ts
29491
- import path35 from "path";
29200
+ import path36 from "path";
29492
29201
  function formatVaultWikilink(notePath) {
29493
29202
  if (typeof notePath !== "string" || notePath.trim().length === 0) {
29494
29203
  throw new RangeError("Vault wikilink path must be a non-empty relative path.");
@@ -29496,7 +29205,7 @@ function formatVaultWikilink(notePath) {
29496
29205
  if (notePath.includes("\n") || notePath.includes("\r")) {
29497
29206
  throw new RangeError("Vault wikilink path must not contain newlines.");
29498
29207
  }
29499
- if (path35.posix.isAbsolute(notePath) || path35.win32.isAbsolute(notePath)) {
29208
+ if (path36.posix.isAbsolute(notePath) || path36.win32.isAbsolute(notePath)) {
29500
29209
  throw new RangeError("Vault wikilink path must be relative; absolute paths are rejected.");
29501
29210
  }
29502
29211
  if (notePath.split(/[\\/]/).some((segment) => segment === "..")) {
@@ -29518,7 +29227,7 @@ function stripVaultMdSuffix(notePath) {
29518
29227
  }
29519
29228
 
29520
29229
  // src/activity/vault-join.ts
29521
- import path36 from "path";
29230
+ import path37 from "path";
29522
29231
  function joinVaultSegments(parts) {
29523
29232
  if (parts.length === 0) {
29524
29233
  throw new RangeError("Vault path parts must be a non-empty list.");
@@ -29533,7 +29242,7 @@ function joinVaultSegments(parts) {
29533
29242
  if (part.includes("\n") || part.includes("\r")) {
29534
29243
  throw new RangeError("Vault path part must not contain a newline.");
29535
29244
  }
29536
- if (path36.posix.isAbsolute(part) || path36.win32.isAbsolute(part)) {
29245
+ if (path37.posix.isAbsolute(part) || path37.win32.isAbsolute(part)) {
29537
29246
  throw new RangeError("Vault path part must be relative.");
29538
29247
  }
29539
29248
  if (part.split("/").includes("..")) {
@@ -29588,7 +29297,7 @@ function planVaultDryRun(inputs) {
29588
29297
  // src/session-summaries/index.ts
29589
29298
  import { createHash as createHash10 } from "crypto";
29590
29299
  import { lstat as lstat3, mkdir as mkdir7, readFile as readFile8, readdir as readdir4, rename, rm, stat as stat4, writeFile as writeFile7 } from "fs/promises";
29591
- import path37 from "path";
29300
+ import path38 from "path";
29592
29301
 
29593
29302
  // src/session-summaries/adapters.ts
29594
29303
  var VALID_ROLES = /* @__PURE__ */ new Set(["user", "assistant", "tool", "system", "other"]);
@@ -30093,7 +29802,7 @@ function shortHash(value, length = 16) {
30093
29802
  async function listTranscriptFiles(root, maxFiles) {
30094
29803
  const out = [];
30095
29804
  let truncated = false;
30096
- const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path37.sep}` : entryName;
29805
+ const entrySortKey = (entryName, isDirectory) => isDirectory ? `${entryName}${path38.sep}` : entryName;
30097
29806
  async function visit(dir) {
30098
29807
  if (truncated) return;
30099
29808
  const entries = (await readdir4(dir, { withFileTypes: true })).sort(
@@ -30103,13 +29812,13 @@ async function listTranscriptFiles(root, maxFiles) {
30103
29812
  if (truncated) return;
30104
29813
  if (entry.name.startsWith(".")) continue;
30105
29814
  if (entry.isSymbolicLink()) continue;
30106
- const fullPath = path37.join(dir, entry.name);
29815
+ const fullPath = path38.join(dir, entry.name);
30107
29816
  if (entry.isDirectory()) {
30108
29817
  await visit(fullPath);
30109
29818
  continue;
30110
29819
  }
30111
29820
  if (!entry.isFile()) continue;
30112
- const ext = path37.extname(entry.name).toLowerCase();
29821
+ const ext = path38.extname(entry.name).toLowerCase();
30113
29822
  if (!SUPPORTED_EXTENSIONS.has(ext)) continue;
30114
29823
  out.push(fullPath);
30115
29824
  if (out.length > maxFiles) {
@@ -30136,7 +29845,7 @@ function normalizeInputDir(inputDir) {
30136
29845
  if (typeof inputDir !== "string" || inputDir.trim().length === 0) {
30137
29846
  throw new Error("inputDir must be a non-empty string");
30138
29847
  }
30139
- return path37.resolve(expandTildePath(inputDir.trim()));
29848
+ return path38.resolve(expandTildePath(inputDir.trim()));
30140
29849
  }
30141
29850
  function initRoleCounts() {
30142
29851
  return {
@@ -30293,11 +30002,11 @@ async function collectLocalSessionSummaries(options) {
30293
30002
  continue;
30294
30003
  }
30295
30004
  seenFileHashes.add(fileHash);
30296
- const fileExtension = path37.extname(filePath).toLowerCase();
30005
+ const fileExtension = path38.extname(filePath).toLowerCase();
30297
30006
  const parsed = await adapter.parseFile(
30298
30007
  {
30299
30008
  content,
30300
- fileName: path37.basename(filePath),
30009
+ fileName: path38.basename(filePath),
30301
30010
  fileExtension,
30302
30011
  fileRef: fileHash
30303
30012
  },
@@ -30353,7 +30062,7 @@ async function collectLocalSessionSummaries(options) {
30353
30062
  }
30354
30063
  async function readRedactionConfig(pathLike) {
30355
30064
  if (!pathLike) return void 0;
30356
- const raw = await readFile8(path37.resolve(expandTildePath(pathLike)), "utf-8");
30065
+ const raw = await readFile8(path38.resolve(expandTildePath(pathLike)), "utf-8");
30357
30066
  const parsed = JSON.parse(raw);
30358
30067
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
30359
30068
  throw new Error("redaction config must be a JSON object");
@@ -30366,15 +30075,15 @@ function toJsonl(drafts) {
30366
30075
  }
30367
30076
  function defaultDraftOutputPath(memoryDir, generatedAt) {
30368
30077
  const stamp = generatedAt.replace(/[:.]/g, "-");
30369
- return path37.join(
30370
- path37.resolve(expandTildePath(memoryDir)),
30078
+ return path38.join(
30079
+ path38.resolve(expandTildePath(memoryDir)),
30371
30080
  "state",
30372
30081
  "session-summary-drafts",
30373
30082
  `session-summaries-${stamp}.jsonl`
30374
30083
  );
30375
30084
  }
30376
30085
  async function writeDrafts(filePath, drafts) {
30377
- await mkdir7(path37.dirname(filePath), { recursive: true });
30086
+ await mkdir7(path38.dirname(filePath), { recursive: true });
30378
30087
  const tempPath = `${filePath}.${process.pid}.${Date.now()}.tmp`;
30379
30088
  try {
30380
30089
  await writeFile7(tempPath, toJsonl(drafts), "utf-8");
@@ -30392,7 +30101,7 @@ async function runLocalSessionSummaryCliCommand(options) {
30392
30101
  });
30393
30102
  const wroteFiles = [];
30394
30103
  if (options.output) {
30395
- const outputPath = path37.resolve(expandTildePath(options.output));
30104
+ const outputPath = path38.resolve(expandTildePath(options.output));
30396
30105
  await writeDrafts(outputPath, report.drafts);
30397
30106
  wroteFiles.push(outputPath);
30398
30107
  }
@@ -30427,19 +30136,19 @@ async function runLocalSessionSummaryCliCommand(options) {
30427
30136
 
30428
30137
  // src/transfer/capsule-fork.ts
30429
30138
  import { lstat as lstat4, mkdir as mkdir8, readFile as readFile9, realpath as realpath3, writeFile as writeFile8 } from "fs/promises";
30430
- import path38 from "path";
30139
+ import path39 from "path";
30431
30140
  async function forkCapsule(opts) {
30432
30141
  validateForkId(opts.forkId);
30433
- const rootAbs = path38.resolve(opts.targetRoot);
30142
+ const rootAbs = path39.resolve(opts.targetRoot);
30434
30143
  await assertIsDirectoryNotSymlink(rootAbs, "forkCapsule", "targetRoot");
30435
- const forkDirAbs = path38.join(rootAbs, "forks", opts.forkId);
30144
+ const forkDirAbs = path39.join(rootAbs, "forks", opts.forkId);
30436
30145
  const forkEntryExists = await pathEntryExists(forkDirAbs);
30437
30146
  if (forkEntryExists) {
30438
30147
  throw new Error(
30439
30148
  `forkCapsule: fork path already exists \u2014 forkId "${opts.forkId}" is already in use at: ${forkDirAbs}`
30440
30149
  );
30441
30150
  }
30442
- const archiveAbs = path38.resolve(opts.sourceArchive);
30151
+ const archiveAbs = path39.resolve(opts.sourceArchive);
30443
30152
  const importResult = await importCapsule({
30444
30153
  archivePath: archiveAbs,
30445
30154
  root: rootAbs,
@@ -30461,10 +30170,10 @@ async function forkCapsule(opts) {
30461
30170
  importedRecords: importResult.imported.length,
30462
30171
  skippedRecords: importResult.skipped.length
30463
30172
  };
30464
- const lineagePath = path38.join(forkDirAbs, "lineage.json");
30173
+ const lineagePath = path39.join(forkDirAbs, "lineage.json");
30465
30174
  const rootReal = await realpath3(rootAbs);
30466
30175
  await assertRealpathInsideRoot(rootReal, lineagePath, `forks/${opts.forkId}/lineage.json`, "forkCapsule");
30467
- await mkdir8(path38.dirname(lineagePath), { recursive: true });
30176
+ await mkdir8(path39.dirname(lineagePath), { recursive: true });
30468
30177
  await writeFile8(lineagePath, JSON.stringify(lineage, null, 2) + "\n", "utf-8");
30469
30178
  return {
30470
30179
  archivePath: archiveAbs,
@@ -30478,11 +30187,11 @@ async function readForkLineage(targetRoot, forkId) {
30478
30187
  if (typeof forkId !== "string" || forkId.length === 0 || forkId.length > 64 || !CAPSULE_ID_PATTERN.test(forkId)) {
30479
30188
  return null;
30480
30189
  }
30481
- const rootAbs = path38.resolve(targetRoot);
30190
+ const rootAbs = path39.resolve(targetRoot);
30482
30191
  const rootReal = await realpath3(rootAbs).catch(() => rootAbs);
30483
- const lineagePath = path38.join(rootReal, "forks", forkId, "lineage.json");
30484
- const rel = path38.relative(rootReal, lineagePath);
30485
- if (rel.startsWith("..") || path38.isAbsolute(rel)) {
30192
+ const lineagePath = path39.join(rootReal, "forks", forkId, "lineage.json");
30193
+ const rel = path39.relative(rootReal, lineagePath);
30194
+ if (rel.startsWith("..") || path39.isAbsolute(rel)) {
30486
30195
  return null;
30487
30196
  }
30488
30197
  if (!await isLineagePathContained(rootReal, lineagePath)) {
@@ -30523,19 +30232,19 @@ async function pathEntryExists(absPath) {
30523
30232
  async function isLineagePathContained(rootReal, lineagePath) {
30524
30233
  let existing = lineagePath;
30525
30234
  const suffix = [];
30526
- while (existing !== path38.dirname(existing)) {
30235
+ while (existing !== path39.dirname(existing)) {
30527
30236
  const st = await lstat4(existing).catch(() => null);
30528
30237
  if (st !== null) break;
30529
- suffix.unshift(path38.basename(existing));
30530
- existing = path38.dirname(existing);
30238
+ suffix.unshift(path39.basename(existing));
30239
+ existing = path39.dirname(existing);
30531
30240
  }
30532
30241
  const existingReal = await realpath3(existing).catch(() => existing);
30533
- const targetReal = suffix.length > 0 ? path38.join(existingReal, ...suffix) : existingReal;
30534
- const rel = path38.relative(rootReal, targetReal);
30242
+ const targetReal = suffix.length > 0 ? path39.join(existingReal, ...suffix) : existingReal;
30243
+ const rel = path39.relative(rootReal, targetReal);
30535
30244
  if (rel === "") return true;
30536
30245
  if (rel === "..") return false;
30537
- if (rel.startsWith(`..${path38.sep}`)) return false;
30538
- if (path38.isAbsolute(rel)) return false;
30246
+ if (rel.startsWith(`..${path39.sep}`)) return false;
30247
+ if (path39.isAbsolute(rel)) return false;
30539
30248
  return true;
30540
30249
  }
30541
30250
 
@@ -30620,21 +30329,8 @@ export {
30620
30329
  getTaxonomyFilePath,
30621
30330
  WearablesService,
30622
30331
  locateTranscriptPath,
30623
- TIMELINE_RESERVED_UNKNOWN,
30624
- TIMELINE_RESERVED_IDLE,
30625
- TIMELINE_RESERVED_PAUSE,
30626
- DEFAULT_TIMELINE_CATEGORIES,
30627
- validateTimelineCategories,
30628
- sortTimelineCategories,
30629
- classifyTimelineObservation,
30630
- TIMELINE_FORMAT_VERSION,
30631
- TIMELINE_MERGE_GAP_MS,
30632
- TIMELINE_MAX_DWELL_MS,
30633
- buildTimelineDay,
30634
- serializeTimelineDay,
30635
- timelineCorrectionDatabasePath,
30636
- TimelineCorrectionStore,
30637
- applyTimelineCorrections,
30332
+ validateTimelineRangeQuery,
30333
+ validateTimelineSearchBounds,
30638
30334
  queryTimelineRange,
30639
30335
  queryTimelineSearch,
30640
30336
  runTimelineCliCommand,
@@ -30646,13 +30342,6 @@ export {
30646
30342
  WEEKLY_SNAPSHOT_DIR,
30647
30343
  weeklySnapshotPath,
30648
30344
  persistWeeklySnapshot,
30649
- TIMELINE_ANALYSIS_PROMPT_VERSION,
30650
- TIMELINE_ANALYSIS_BATCH_SIZE,
30651
- TIMELINE_ANALYSIS_BATCH_OVERLAP,
30652
- TIMELINE_ANALYSIS_DEFAULT_TIMEOUT_MS,
30653
- TimelineAnalysisConfigError,
30654
- buildTimelineAnalysisPrompt,
30655
- analyzeTimelineCards,
30656
30345
  exportDeterministicRecap,
30657
30346
  renderRecapMarkdown,
30658
30347
  exportDeterministicWeek,
@@ -30663,25 +30352,32 @@ export {
30663
30352
  findRecurringPatterns,
30664
30353
  WEEK_START_DAYS,
30665
30354
  computeWeeklyConfigHash,
30666
- batchObservations2 as batchObservations,
30355
+ batchObservations,
30667
30356
  boundEvidence,
30668
30357
  buildAnalysisPrompt,
30669
30358
  parseClaimObservationId,
30670
30359
  sortObservationIds,
30671
30360
  clipCardsToRecapWindow,
30672
- ANALYSIS_FAILURE_KINDS,
30673
- isAnalysisFailureKind,
30674
- classifyAnalysisFailure,
30675
30361
  mergeRecapUserEdits,
30676
- ANALYSIS_METADATA_MAX_FIELD_LENGTH,
30677
- buildAnalysisRunMetadata,
30678
30362
  RECAP_SOURCE_KINDS,
30679
30363
  selectRecapForDay,
30364
+ stripRemnicOwnedRegions,
30680
30365
  readVaultJournal,
30681
- VAULT_JOURNAL_PREREQUISITES,
30682
- checkVaultJournalPrerequisites,
30366
+ publisherOwnedSectionNames,
30367
+ readJournalForDate,
30368
+ timelineStatePath,
30369
+ hashJournalText,
30370
+ readTimelineState,
30371
+ writeTimelineState,
30372
+ journalDateLockPath,
30373
+ timelineStateLockPath,
30374
+ withJournalDateLock,
30375
+ commitJournalHash,
30376
+ setJournalHash,
30377
+ journalUnchanged,
30683
30378
  buildJournalMemoryProvenance,
30684
- stripRemnicOwnedRegions2 as stripRemnicOwnedRegions,
30379
+ createJournalMemoryWriter,
30380
+ runJournalReviewExtraction,
30685
30381
  isEligibleActivityFact,
30686
30382
  generateActivityMemories,
30687
30383
  MS_PER_DAY2 as MS_PER_DAY,
@@ -30733,4 +30429,4 @@ export {
30733
30429
  blendGraphExpandedRecallScore,
30734
30430
  Orchestrator
30735
30431
  };
30736
- //# sourceMappingURL=chunk-CZYYJZB6.js.map
30432
+ //# sourceMappingURL=chunk-ND2O2PVN.js.map