@remnic/core 10.0.13 → 10.0.14

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 (476) hide show
  1. package/dist/access-admin-ops-surface.js +86 -84
  2. package/dist/access-authorization-probe.js +87 -85
  3. package/dist/access-boundary.js +86 -84
  4. package/dist/access-cli.js +183 -180
  5. package/dist/access-cli.js.map +1 -1
  6. package/dist/access-extraction-force-flush.js +86 -84
  7. package/dist/access-http-briefing.js +87 -85
  8. package/dist/access-http-query.js +88 -86
  9. package/dist/access-http.js +110 -108
  10. package/dist/access-idempotency.js +3 -2
  11. package/dist/access-identity-continuity-surface.js +86 -84
  12. package/dist/access-lcm-surface.js +86 -84
  13. package/dist/access-mcp.js +99 -97
  14. package/dist/access-namespace-preflight.js +86 -84
  15. package/dist/access-observe-write-category.js +17 -17
  16. package/dist/access-observe-write-surface.js +86 -84
  17. package/dist/access-offline-manifest.js +16 -15
  18. package/dist/access-operations-batch.js +90 -88
  19. package/dist/access-operations.js +97 -95
  20. package/dist/access-recall-concurrency.js +86 -84
  21. package/dist/access-recall-diagnostics.js +2 -2
  22. package/dist/access-recall-response.js +86 -84
  23. package/dist/access-recall-surface.js +86 -84
  24. package/dist/access-schema.d.ts +2 -2
  25. package/dist/access-schema.js +12 -12
  26. package/dist/access-service.js +86 -84
  27. package/dist/access-surface-catalog.js +88 -86
  28. package/dist/access-surface-catalog.js.map +1 -1
  29. package/dist/active-recall.js +39 -37
  30. package/dist/active-recall.js.map +1 -1
  31. package/dist/adapters/index.js +4 -4
  32. package/dist/adapters/registry.js +2 -2
  33. package/dist/{auto-sync-DGJOZYGT.js → auto-sync-7WWAKW6F.js} +8 -8
  34. package/dist/briefing.js +29 -27
  35. package/dist/buffer.js +13 -13
  36. package/dist/{capsule-merge-M4HETD27.js → capsule-merge-LGYURS3C.js} +6 -5
  37. package/dist/{capsule-merge-M4HETD27.js.map → capsule-merge-LGYURS3C.js.map} +1 -1
  38. package/dist/capture-write-lock-backoff.d.ts +50 -0
  39. package/dist/capture-write-lock-backoff.d.ts.map +1 -0
  40. package/dist/capture-write-lock-backoff.js +30 -0
  41. package/dist/capture-write-lock.d.ts +6 -0
  42. package/dist/capture-write-lock.d.ts.map +1 -0
  43. package/dist/capture-write-lock.js +15 -0
  44. package/dist/causal-behavior.js +2 -2
  45. package/dist/causal-chain.js +2 -2
  46. package/dist/causal-consolidation.js +32 -30
  47. package/dist/causal-consolidation.js.map +1 -1
  48. package/dist/causal-retrieval.js +2 -2
  49. package/dist/causal-trajectory-graph.js +7 -6
  50. package/dist/causal-trajectory-graph.js.map +1 -1
  51. package/dist/causal-trajectory.js +1 -1
  52. package/dist/{chunk-ZUMXY4KA.js → chunk-22W2XWGH.js} +3 -3
  53. package/dist/{chunk-AV2OQF2O.js → chunk-3F3HA3R2.js} +2 -2
  54. package/dist/{chunk-QZZPUREO.js → chunk-3GYSZHMT.js} +3 -3
  55. package/dist/{chunk-QWWMS4AE.js → chunk-3MO4LWYU.js} +1 -1
  56. package/dist/chunk-3MO4LWYU.js.map +1 -0
  57. package/dist/{chunk-AL6EHLB5.js → chunk-3X3PNU3T.js} +2 -2
  58. package/dist/{chunk-BTJ6CAIA.js → chunk-4IYIGN53.js} +10 -10
  59. package/dist/{chunk-BZTRPCCH.js → chunk-4KY5GSMB.js} +2 -2
  60. package/dist/{chunk-UZSBCQEC.js → chunk-4OSG5Y6M.js} +2 -2
  61. package/dist/{chunk-EHRE7ZG3.js → chunk-5B5WYAHQ.js} +2 -2
  62. package/dist/{chunk-WCGJK4NQ.js → chunk-5FNZ3G6X.js} +10 -10
  63. package/dist/{chunk-Y6DZ33PA.js → chunk-5GX5457J.js} +4 -4
  64. package/dist/{chunk-OFCHT2TN.js → chunk-5LRV557D.js} +2 -2
  65. package/dist/{chunk-CKUUP64O.js → chunk-5WCJLQTM.js} +2 -2
  66. package/dist/{chunk-MZBWIJJN.js → chunk-63B2IZYE.js} +19 -19
  67. package/dist/{chunk-DGRMWDQY.js → chunk-66BCOVW2.js} +7 -7
  68. package/dist/chunk-6EDW54SQ.js +298 -0
  69. package/dist/chunk-6EDW54SQ.js.map +1 -0
  70. package/dist/{chunk-P2S6P7X6.js → chunk-6LG7BWKW.js} +2 -2
  71. package/dist/chunk-77R7BQZ2.js +152 -0
  72. package/dist/chunk-77R7BQZ2.js.map +1 -0
  73. package/dist/{chunk-IPLYGWQF.js → chunk-7LCGFUMB.js} +6 -6
  74. package/dist/{chunk-KYY4EACB.js → chunk-7Z3DLNSD.js} +2 -2
  75. package/dist/{chunk-LNH76ZJX.js → chunk-AIYXVWUH.js} +27 -2
  76. package/dist/{chunk-LNH76ZJX.js.map → chunk-AIYXVWUH.js.map} +1 -1
  77. package/dist/{chunk-O4KYRDRT.js → chunk-B665A6BO.js} +2 -2
  78. package/dist/{chunk-AKREOU5F.js → chunk-CB6ANA2I.js} +2 -2
  79. package/dist/{chunk-5JMI26Q7.js → chunk-CBH2Z4UA.js} +2 -2
  80. package/dist/{chunk-YRH3C2OJ.js → chunk-CIIHIAJ2.js} +13 -5
  81. package/dist/chunk-CIIHIAJ2.js.map +1 -0
  82. package/dist/{chunk-6M56RFFJ.js → chunk-CJRENHVZ.js} +3 -3
  83. package/dist/{chunk-EGDYVYU7.js → chunk-CLWBFR7Q.js} +3 -3
  84. package/dist/{chunk-375ARKRS.js → chunk-D5SSBCYY.js} +70 -59
  85. package/dist/chunk-D5SSBCYY.js.map +1 -0
  86. package/dist/{chunk-KI6UOSNR.js → chunk-DEY7B77Y.js} +2 -2
  87. package/dist/chunk-DEY7B77Y.js.map +1 -0
  88. package/dist/{chunk-6VAHJ2F6.js → chunk-DMDWFQMR.js} +2 -2
  89. package/dist/{chunk-6OQ6N5RP.js → chunk-DPR2WTN3.js} +20 -20
  90. package/dist/{chunk-K4QY55XV.js → chunk-EH4BQ7LT.js} +2 -2
  91. package/dist/chunk-EHHQJTAU.js +131 -0
  92. package/dist/chunk-EHHQJTAU.js.map +1 -0
  93. package/dist/{chunk-5JCLELOP.js → chunk-EPJDSQHF.js} +2 -2
  94. package/dist/{chunk-K2FSASGZ.js → chunk-EU534WGS.js} +2 -2
  95. package/dist/{chunk-GD7BWGIB.js → chunk-EU6IRUCY.js} +6 -4
  96. package/dist/{chunk-GD7BWGIB.js.map → chunk-EU6IRUCY.js.map} +1 -1
  97. package/dist/{chunk-IWHEJXR2.js → chunk-EUAIYYYR.js} +8 -8
  98. package/dist/{chunk-7KYJNHGM.js → chunk-EUCYTCFP.js} +2 -2
  99. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  100. package/dist/{chunk-ON4ILX3G.js → chunk-FFOVKNQV.js} +2 -2
  101. package/dist/{chunk-2KRNPFPK.js → chunk-FLI6DEIU.js} +2 -2
  102. package/dist/{chunk-4G4B3Z2B.js → chunk-FP4JYE66.js} +2 -2
  103. package/dist/{chunk-B7CANWCA.js → chunk-FSIMZNBC.js} +2 -2
  104. package/dist/{chunk-OAIWPB2I.js → chunk-FT4UQYOV.js} +2 -2
  105. package/dist/{chunk-X3VID2TT.js → chunk-FUFAXVBA.js} +3 -3
  106. package/dist/{chunk-HYNEDMYJ.js → chunk-G2OYFTUD.js} +2 -2
  107. package/dist/{chunk-XTN54NML.js → chunk-G3T6YMBO.js} +4 -4
  108. package/dist/{chunk-XHWJRUVP.js → chunk-GELS5Z5Z.js} +3 -3
  109. package/dist/{chunk-RT6D3WN7.js → chunk-GH7AOMJD.js} +2 -2
  110. package/dist/{chunk-2LUSQV4U.js → chunk-GKJJNO7C.js} +2 -2
  111. package/dist/{chunk-6Z2AZ4AJ.js → chunk-GMXWTJNU.js} +2 -2
  112. package/dist/{chunk-B657ZGDH.js → chunk-HQSK2INQ.js} +2 -2
  113. package/dist/{chunk-RWRQ67OR.js → chunk-I7S55EOB.js} +2 -2
  114. package/dist/{chunk-KZO43HPY.js → chunk-J7JWFZHI.js} +100 -100
  115. package/dist/{chunk-EMFBC7L3.js → chunk-JDZFIR2S.js} +2 -2
  116. package/dist/{chunk-4THZGKQ2.js → chunk-JIHMUOOS.js} +3 -3
  117. package/dist/{chunk-YYO447A7.js → chunk-JNIVZNIB.js} +41 -253
  118. package/dist/chunk-JNIVZNIB.js.map +1 -0
  119. package/dist/{chunk-FZB4TS2W.js → chunk-JPTPS4OB.js} +5 -5
  120. package/dist/{chunk-CS2JEHTB.js → chunk-JQ7XU625.js} +8 -8
  121. package/dist/{chunk-3I3U6FFT.js → chunk-K7BN34IA.js} +2 -2
  122. package/dist/{chunk-7OAIOE5P.js → chunk-KH2LKDX7.js} +2 -2
  123. package/dist/{chunk-DA2INEB5.js → chunk-KR6ZKECI.js} +4 -4
  124. package/dist/{chunk-5AOAQR37.js → chunk-L5DAHSEZ.js} +3 -3
  125. package/dist/{chunk-RP5SJ3XR.js → chunk-LCKVXX5F.js} +2 -2
  126. package/dist/{chunk-ZI7LMSNI.js → chunk-LLHZZOIB.js} +2 -2
  127. package/dist/{chunk-OYKQ6T4V.js → chunk-MATDGSJ7.js} +2 -2
  128. package/dist/{chunk-3NFN4Y4P.js → chunk-MGCKZWAE.js} +5 -5
  129. package/dist/{chunk-6OMUHXHP.js → chunk-ML7ZJAKJ.js} +2 -2
  130. package/dist/{chunk-YDH2FSDI.js → chunk-N45NEBOD.js} +2 -2
  131. package/dist/{chunk-A2E4WNW4.js → chunk-N4C7QKOG.js} +2 -2
  132. package/dist/{chunk-B43NMCGQ.js → chunk-N7KYEVLK.js} +2 -2
  133. package/dist/{chunk-HT2C4EXO.js → chunk-NIRQGDYC.js} +4 -4
  134. package/dist/{chunk-DXHVD4DS.js → chunk-NW2E4CI2.js} +3 -3
  135. package/dist/{chunk-4NDWE44P.js → chunk-NZFFGO5O.js} +2 -2
  136. package/dist/{chunk-KC46VZR5.js → chunk-O2IPAX26.js} +8 -8
  137. package/dist/{chunk-M7V65M6H.js → chunk-O4SGYW7H.js} +2 -2
  138. package/dist/{chunk-QUA7RLK6.js → chunk-OP6N4H6A.js} +2 -2
  139. package/dist/{chunk-ZSJGYC3C.js → chunk-OQJKY3Z5.js} +2 -2
  140. package/dist/{chunk-OFEHITAZ.js → chunk-OXNTOHL6.js} +2 -2
  141. package/dist/{chunk-FQD2KPQH.js → chunk-P55FACBG.js} +2 -2
  142. package/dist/{chunk-XERVJYH2.js → chunk-P5NQN4JE.js} +3 -3
  143. package/dist/{chunk-XZLWYZ7C.js → chunk-P7TOIOT7.js} +2 -2
  144. package/dist/{chunk-Y3VDGK2O.js → chunk-PAZ35RJ4.js} +44 -31
  145. package/dist/chunk-PAZ35RJ4.js.map +1 -0
  146. package/dist/chunk-PGRZ3FYC.js +34 -0
  147. package/dist/chunk-PGRZ3FYC.js.map +1 -0
  148. package/dist/{chunk-PBVNVKYN.js → chunk-PIN5OPBA.js} +2 -2
  149. package/dist/{chunk-CNG2XVZG.js → chunk-PZHQWFR3.js} +2 -2
  150. package/dist/{chunk-SVDU4OHO.js → chunk-Q35L7TYB.js} +2 -2
  151. package/dist/{chunk-YEM7K3KD.js → chunk-QODKDRSP.js} +6 -6
  152. package/dist/{chunk-IZT3BVDW.js → chunk-QOZJCSFO.js} +2 -2
  153. package/dist/{chunk-6T42L5FI.js → chunk-QS3OLP5I.js} +2 -2
  154. package/dist/{chunk-PAAJWQH5.js → chunk-QUMKDRCF.js} +2 -2
  155. package/dist/{chunk-JFVCDEIC.js → chunk-QX6JN3O4.js} +7 -7
  156. package/dist/{chunk-KZEMFD6E.js → chunk-R2H4ZFBJ.js} +3 -3
  157. package/dist/{chunk-GKIXBH7Y.js → chunk-RTKV5XHL.js} +4 -4
  158. package/dist/{chunk-ZQ3WU6JO.js → chunk-RXFCU3CY.js} +2 -2
  159. package/dist/{chunk-BOOFTFFE.js → chunk-S2I7DL5Q.js} +1 -1
  160. package/dist/{chunk-2NCBDGND.js → chunk-SA6GMZJY.js} +3 -3
  161. package/dist/{chunk-NSFOERZQ.js → chunk-SIIRTDJ4.js} +2 -2
  162. package/dist/{chunk-A6TVQ3QP.js → chunk-SS3IS2JR.js} +3 -3
  163. package/dist/{chunk-VFTK5WKI.js → chunk-STBX5X6B.js} +2 -2
  164. package/dist/{chunk-WVHRNAXL.js → chunk-SWWHIJUJ.js} +2 -2
  165. package/dist/{chunk-WADSXS4K.js → chunk-SX4QDWXK.js} +2 -2
  166. package/dist/{chunk-ZIZ2G47N.js → chunk-TITG2NBS.js} +2 -2
  167. package/dist/{chunk-LZKOVXMX.js → chunk-TRMJ6BYC.js} +2 -2
  168. package/dist/{chunk-U7VPOXVM.js → chunk-TZNDKTX5.js} +65 -65
  169. package/dist/{chunk-WWSRLS4M.js → chunk-UMTCNEVQ.js} +15 -15
  170. package/dist/{chunk-4TTGRETU.js → chunk-UQDG3YLN.js} +5 -5
  171. package/dist/{chunk-AAM66QCP.js → chunk-UZRSI6NX.js} +2 -2
  172. package/dist/{chunk-2CXQZXWM.js → chunk-V4MB5ONM.js} +6 -6
  173. package/dist/{chunk-CYEK6Z3P.js → chunk-VW6VIJOS.js} +2 -2
  174. package/dist/{chunk-5ZJYHOJT.js → chunk-W47S5TIH.js} +8 -8
  175. package/dist/{chunk-CBP4HWCL.js → chunk-W5MCEVUS.js} +3 -3
  176. package/dist/{chunk-WETFW255.js → chunk-WLMZ2L5P.js} +2 -2
  177. package/dist/{chunk-XRBHXUTQ.js → chunk-WSGPFRBH.js} +5 -5
  178. package/dist/{chunk-UOKPJFO3.js → chunk-WVADKFWV.js} +3 -3
  179. package/dist/{chunk-P34FDDB5.js → chunk-XISROV24.js} +2 -2
  180. package/dist/{chunk-FZVROZKC.js → chunk-XVZA6VXC.js} +4 -4
  181. package/dist/{chunk-JUWJYXI4.js → chunk-Y4NKEXQT.js} +4 -4
  182. package/dist/{chunk-2ZQJLBV6.js → chunk-YE36AJL7.js} +4 -4
  183. package/dist/chunk-YET735EZ.js +99 -0
  184. package/dist/chunk-YET735EZ.js.map +1 -0
  185. package/dist/{chunk-PCWXLAJY.js → chunk-YFMBHQRG.js} +2 -2
  186. package/dist/{chunk-RBJQYMMT.js → chunk-YRULQW5J.js} +4 -4
  187. package/dist/{chunk-QUNDYIYZ.js → chunk-YYEOR4XN.js} +3 -3
  188. package/dist/{chunk-VYPFEVOM.js → chunk-ZJVMUBYF.js} +2 -2
  189. package/dist/{chunk-5MDM7UE4.js → chunk-ZSH2NRDV.js} +2 -2
  190. package/dist/{chunk-3J5JKBYD.js → chunk-ZV65I6ME.js} +67 -67
  191. package/dist/cli.js +138 -136
  192. package/dist/coding/export-okf-codegraph.js +29 -27
  193. package/dist/coding/export-okf-codegraph.js.map +1 -1
  194. package/dist/coding/pre-action-gate.js +2 -2
  195. package/dist/compounding/engine.js +31 -29
  196. package/dist/config.js +39 -37
  197. package/dist/connectors/codex-materialize-runner.js +29 -27
  198. package/dist/connectors/index.js +29 -27
  199. package/dist/console/trace.d.ts +5 -14
  200. package/dist/console/trace.d.ts.map +1 -1
  201. package/dist/consolidation-provenance-check.js +7 -6
  202. package/dist/consolidation-undo.js +5 -4
  203. package/dist/consolidation-undo.js.map +1 -1
  204. package/dist/contradiction/index.js +7 -6
  205. package/dist/converge-config.d.ts +2 -0
  206. package/dist/converge-config.d.ts.map +1 -1
  207. package/dist/converge-config.js +7 -3
  208. package/dist/convergence-refresh.js +31 -29
  209. package/dist/corpus-watermark.js +31 -29
  210. package/dist/dashboard-runtime.js +2 -2
  211. package/dist/deep-recall-http-glue.js +13 -13
  212. package/dist/deep-recall.js +2 -2
  213. package/dist/embedding-fallback.js +5 -4
  214. package/dist/embedding-generation-lock.js +4 -3
  215. package/dist/entity-retrieval.js +30 -28
  216. package/dist/explicit-capture.js +11 -8
  217. package/dist/external-wiki-access.js +87 -85
  218. package/dist/extraction-quote-grounding.d.ts +67 -0
  219. package/dist/extraction-quote-grounding.d.ts.map +1 -0
  220. package/dist/extraction-quote-grounding.js +27 -0
  221. package/dist/extraction-quote-grounding.js.map +1 -0
  222. package/dist/extraction-source-grounding-helpers.d.ts +8 -0
  223. package/dist/extraction-source-grounding-helpers.d.ts.map +1 -1
  224. package/dist/extraction-source-grounding-helpers.js +11 -1
  225. package/dist/extraction-source-grounding-rules.d.ts +3 -1
  226. package/dist/extraction-source-grounding-rules.d.ts.map +1 -1
  227. package/dist/extraction-source-grounding-rules.js +3 -2
  228. package/dist/extraction-source-grounding.d.ts +1 -1
  229. package/dist/extraction-source-grounding.d.ts.map +1 -1
  230. package/dist/extraction-source-grounding.js +4 -3
  231. package/dist/extraction-span-materialize.js +2 -2
  232. package/dist/extraction.js +40 -37
  233. package/dist/{first-start-migration-HYAMKJ6V.js → first-start-migration-6A5BJPDW.js} +4 -4
  234. package/dist/{forget-OHAJ6PSU.js → forget-GXBWFKRC.js} +5 -4
  235. package/dist/{forget-OHAJ6PSU.js.map → forget-GXBWFKRC.js.map} +1 -1
  236. package/dist/{graph-edge-decay-CZ3SYLM4.js → graph-edge-decay-BYPZVJT4.js} +10 -9
  237. package/dist/graph-edge-decay-BYPZVJT4.js.map +1 -0
  238. package/dist/graph-jsonl.js +8 -7
  239. package/dist/graph-snapshot.js +8 -7
  240. package/dist/graph-write-lock.js +4 -3
  241. package/dist/graph.js +9 -8
  242. package/dist/harmonic-retrieval.js +29 -27
  243. package/dist/http-retry.js +2 -1
  244. package/dist/http-retry.js.map +1 -1
  245. package/dist/index.d.ts +1 -1
  246. package/dist/index.d.ts.map +1 -1
  247. package/dist/index.js +223 -218
  248. package/dist/lcm/engine.js +4 -4
  249. package/dist/lcm/index.js +12 -12
  250. package/dist/location/index.js +32 -30
  251. package/dist/maintenance/memory-governance.js +29 -27
  252. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +29 -27
  253. package/dist/maintenance/rebuild-memory-projection-runner.js +31 -29
  254. package/dist/maintenance/rebuild-memory-projection.js +30 -28
  255. package/dist/memory-browse-operations.js +87 -85
  256. package/dist/memory-browse.js +7 -7
  257. package/dist/memory-subject.js +5 -4
  258. package/dist/namespaces/migrate.js +30 -28
  259. package/dist/namespaces/search.js +9 -9
  260. package/dist/namespaces/storage.js +29 -27
  261. package/dist/offline-sync-changeset-generations.js +7 -6
  262. package/dist/offline-sync-embedding-generation.js +6 -5
  263. package/dist/offline-sync-impression-drain.js +4 -4
  264. package/dist/offline-sync-snapshot-stream.js +9 -9
  265. package/dist/offline-sync.js +10 -10
  266. package/dist/operator-doctor-corpus.js +32 -30
  267. package/dist/operator-toolkit.js +53 -51
  268. package/dist/orchestration/maintenance.js +41 -39
  269. package/dist/orchestrator.js +185 -182
  270. package/dist/page-versioning.js +5 -4
  271. package/dist/qmd-daemon-session.js +2 -2
  272. package/dist/qmd.js +4 -4
  273. package/dist/recall-explain-renderer.js +3 -3
  274. package/dist/recall-navigate-access.js +2 -2
  275. package/dist/recall-navigate-disclosure.js +2 -2
  276. package/dist/recall-navigate.js +2 -2
  277. package/dist/recall-navigation-operations.js +87 -85
  278. package/dist/recall-navigation.js +86 -84
  279. package/dist/recall-state-view-admission.js +7 -7
  280. package/dist/recall-state.js +4 -3
  281. package/dist/recall-why-service.js +7 -7
  282. package/dist/recall-xray-cli.js +4 -4
  283. package/dist/recall-xray-renderer.js +3 -3
  284. package/dist/recall-xray.js +2 -2
  285. package/dist/reconcile/cursor.js +4 -2
  286. package/dist/reconcile/cursor.js.map +1 -1
  287. package/dist/reconcile/manifest.js +9 -6
  288. package/dist/reconcile/plan.js +4 -2
  289. package/dist/{resolution-EKJHREVJ.js → resolution-7AY36LGJ.js} +8 -7
  290. package/dist/resolution-7AY36LGJ.js.map +1 -0
  291. package/dist/resume-bundles.js +40 -38
  292. package/dist/salvage-envelope.js +7 -6
  293. package/dist/search/factory.js +8 -8
  294. package/dist/search/index.js +14 -14
  295. package/dist/semantic-consolidation.js +34 -32
  296. package/dist/semantic-rule-promotion.js +29 -27
  297. package/dist/semantic-rule-verifier.js +29 -27
  298. package/dist/source-agent-qualifier.js +37 -34
  299. package/dist/standup/build.js +29 -27
  300. package/dist/storage/content-hash-index.d.ts +10 -0
  301. package/dist/storage/content-hash-index.d.ts.map +1 -1
  302. package/dist/storage/tombstone-blocked-capture-index.d.ts +3 -0
  303. package/dist/storage/tombstone-blocked-capture-index.d.ts.map +1 -1
  304. package/dist/storage/tombstone-blocked-capture-mutation.d.ts +23 -3
  305. package/dist/storage/tombstone-blocked-capture-mutation.d.ts.map +1 -1
  306. package/dist/storage.d.ts +6 -0
  307. package/dist/storage.d.ts.map +1 -1
  308. package/dist/storage.js +30 -28
  309. package/dist/subject-config.js +6 -5
  310. package/dist/summarizer.js +4 -4
  311. package/dist/summary-snapshot.js +4 -3
  312. package/dist/support-passport/index.js +89 -87
  313. package/dist/{trace-LXXCMZJA.js → trace-QBQVS5BC.js} +5 -21
  314. package/dist/trace-QBQVS5BC.js.map +1 -0
  315. package/dist/transfer/autodetect.js +1 -1
  316. package/dist/transfer/backup.js +1 -1
  317. package/dist/transfer/capsule-export.js +3 -3
  318. package/dist/transfer/capsule-import.js +7 -6
  319. package/dist/transfer/export-okf.js +29 -27
  320. package/dist/types.d.ts +9 -0
  321. package/dist/types.d.ts.map +1 -1
  322. package/dist/types.js +1 -1
  323. package/dist/utils/serialize-mutations.js +3 -2
  324. package/dist/utils/sleep.d.ts +6 -0
  325. package/dist/utils/sleep.d.ts.map +1 -1
  326. package/dist/verified-recall.js +29 -27
  327. package/dist/who-knows-cli.js +30 -28
  328. package/dist/who-knows.js +29 -27
  329. package/dist/write-envelope.js +6 -5
  330. package/package.json +22 -2
  331. package/src/capture-write-lock-backoff.test.ts +534 -0
  332. package/src/capture-write-lock-backoff.ts +140 -0
  333. package/src/capture-write-lock.ts +8 -0
  334. package/src/console/trace.ts +5 -36
  335. package/src/converge-config.ts +80 -1
  336. package/src/extraction-quote-grounding.test.ts +546 -0
  337. package/src/extraction-quote-grounding.ts +232 -0
  338. package/src/extraction-source-grounding-helpers.ts +35 -0
  339. package/src/extraction-source-grounding-rules.ts +90 -65
  340. package/src/extraction-source-grounding.ts +11 -2
  341. package/src/index.ts +1 -1
  342. package/src/providers/codex-subscription.test.ts +15 -3
  343. package/src/storage/content-hash-index.ts +10 -0
  344. package/src/storage/tombstone-blocked-capture-index.ts +8 -1
  345. package/src/storage/tombstone-blocked-capture-mutation.ts +133 -43
  346. package/src/storage.ts +13 -0
  347. package/src/types.ts +9 -0
  348. package/src/utils/sleep.ts +28 -0
  349. package/dist/chunk-375ARKRS.js.map +0 -1
  350. package/dist/chunk-6MINUTGJ.js +0 -64
  351. package/dist/chunk-6MINUTGJ.js.map +0 -1
  352. package/dist/chunk-7LEQREP2.js +0 -9
  353. package/dist/chunk-7LEQREP2.js.map +0 -1
  354. package/dist/chunk-KI6UOSNR.js.map +0 -1
  355. package/dist/chunk-QWWMS4AE.js.map +0 -1
  356. package/dist/chunk-Y3VDGK2O.js.map +0 -1
  357. package/dist/chunk-YRH3C2OJ.js.map +0 -1
  358. package/dist/chunk-YYO447A7.js.map +0 -1
  359. package/dist/trace-LXXCMZJA.js.map +0 -1
  360. /package/dist/{auto-sync-DGJOZYGT.js.map → auto-sync-7WWAKW6F.js.map} +0 -0
  361. /package/dist/{graph-edge-decay-CZ3SYLM4.js.map → capture-write-lock-backoff.js.map} +0 -0
  362. /package/dist/{resolution-EKJHREVJ.js.map → capture-write-lock.js.map} +0 -0
  363. /package/dist/{chunk-ZUMXY4KA.js.map → chunk-22W2XWGH.js.map} +0 -0
  364. /package/dist/{chunk-AV2OQF2O.js.map → chunk-3F3HA3R2.js.map} +0 -0
  365. /package/dist/{chunk-QZZPUREO.js.map → chunk-3GYSZHMT.js.map} +0 -0
  366. /package/dist/{chunk-AL6EHLB5.js.map → chunk-3X3PNU3T.js.map} +0 -0
  367. /package/dist/{chunk-BTJ6CAIA.js.map → chunk-4IYIGN53.js.map} +0 -0
  368. /package/dist/{chunk-BZTRPCCH.js.map → chunk-4KY5GSMB.js.map} +0 -0
  369. /package/dist/{chunk-UZSBCQEC.js.map → chunk-4OSG5Y6M.js.map} +0 -0
  370. /package/dist/{chunk-EHRE7ZG3.js.map → chunk-5B5WYAHQ.js.map} +0 -0
  371. /package/dist/{chunk-WCGJK4NQ.js.map → chunk-5FNZ3G6X.js.map} +0 -0
  372. /package/dist/{chunk-Y6DZ33PA.js.map → chunk-5GX5457J.js.map} +0 -0
  373. /package/dist/{chunk-OFCHT2TN.js.map → chunk-5LRV557D.js.map} +0 -0
  374. /package/dist/{chunk-CKUUP64O.js.map → chunk-5WCJLQTM.js.map} +0 -0
  375. /package/dist/{chunk-MZBWIJJN.js.map → chunk-63B2IZYE.js.map} +0 -0
  376. /package/dist/{chunk-DGRMWDQY.js.map → chunk-66BCOVW2.js.map} +0 -0
  377. /package/dist/{chunk-P2S6P7X6.js.map → chunk-6LG7BWKW.js.map} +0 -0
  378. /package/dist/{chunk-IPLYGWQF.js.map → chunk-7LCGFUMB.js.map} +0 -0
  379. /package/dist/{chunk-KYY4EACB.js.map → chunk-7Z3DLNSD.js.map} +0 -0
  380. /package/dist/{chunk-O4KYRDRT.js.map → chunk-B665A6BO.js.map} +0 -0
  381. /package/dist/{chunk-AKREOU5F.js.map → chunk-CB6ANA2I.js.map} +0 -0
  382. /package/dist/{chunk-5JMI26Q7.js.map → chunk-CBH2Z4UA.js.map} +0 -0
  383. /package/dist/{chunk-6M56RFFJ.js.map → chunk-CJRENHVZ.js.map} +0 -0
  384. /package/dist/{chunk-EGDYVYU7.js.map → chunk-CLWBFR7Q.js.map} +0 -0
  385. /package/dist/{chunk-6VAHJ2F6.js.map → chunk-DMDWFQMR.js.map} +0 -0
  386. /package/dist/{chunk-6OQ6N5RP.js.map → chunk-DPR2WTN3.js.map} +0 -0
  387. /package/dist/{chunk-K4QY55XV.js.map → chunk-EH4BQ7LT.js.map} +0 -0
  388. /package/dist/{chunk-5JCLELOP.js.map → chunk-EPJDSQHF.js.map} +0 -0
  389. /package/dist/{chunk-K2FSASGZ.js.map → chunk-EU534WGS.js.map} +0 -0
  390. /package/dist/{chunk-IWHEJXR2.js.map → chunk-EUAIYYYR.js.map} +0 -0
  391. /package/dist/{chunk-7KYJNHGM.js.map → chunk-EUCYTCFP.js.map} +0 -0
  392. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  393. /package/dist/{chunk-ON4ILX3G.js.map → chunk-FFOVKNQV.js.map} +0 -0
  394. /package/dist/{chunk-2KRNPFPK.js.map → chunk-FLI6DEIU.js.map} +0 -0
  395. /package/dist/{chunk-4G4B3Z2B.js.map → chunk-FP4JYE66.js.map} +0 -0
  396. /package/dist/{chunk-B7CANWCA.js.map → chunk-FSIMZNBC.js.map} +0 -0
  397. /package/dist/{chunk-OAIWPB2I.js.map → chunk-FT4UQYOV.js.map} +0 -0
  398. /package/dist/{chunk-X3VID2TT.js.map → chunk-FUFAXVBA.js.map} +0 -0
  399. /package/dist/{chunk-HYNEDMYJ.js.map → chunk-G2OYFTUD.js.map} +0 -0
  400. /package/dist/{chunk-XTN54NML.js.map → chunk-G3T6YMBO.js.map} +0 -0
  401. /package/dist/{chunk-XHWJRUVP.js.map → chunk-GELS5Z5Z.js.map} +0 -0
  402. /package/dist/{chunk-RT6D3WN7.js.map → chunk-GH7AOMJD.js.map} +0 -0
  403. /package/dist/{chunk-2LUSQV4U.js.map → chunk-GKJJNO7C.js.map} +0 -0
  404. /package/dist/{chunk-6Z2AZ4AJ.js.map → chunk-GMXWTJNU.js.map} +0 -0
  405. /package/dist/{chunk-B657ZGDH.js.map → chunk-HQSK2INQ.js.map} +0 -0
  406. /package/dist/{chunk-RWRQ67OR.js.map → chunk-I7S55EOB.js.map} +0 -0
  407. /package/dist/{chunk-KZO43HPY.js.map → chunk-J7JWFZHI.js.map} +0 -0
  408. /package/dist/{chunk-EMFBC7L3.js.map → chunk-JDZFIR2S.js.map} +0 -0
  409. /package/dist/{chunk-4THZGKQ2.js.map → chunk-JIHMUOOS.js.map} +0 -0
  410. /package/dist/{chunk-FZB4TS2W.js.map → chunk-JPTPS4OB.js.map} +0 -0
  411. /package/dist/{chunk-CS2JEHTB.js.map → chunk-JQ7XU625.js.map} +0 -0
  412. /package/dist/{chunk-3I3U6FFT.js.map → chunk-K7BN34IA.js.map} +0 -0
  413. /package/dist/{chunk-7OAIOE5P.js.map → chunk-KH2LKDX7.js.map} +0 -0
  414. /package/dist/{chunk-DA2INEB5.js.map → chunk-KR6ZKECI.js.map} +0 -0
  415. /package/dist/{chunk-5AOAQR37.js.map → chunk-L5DAHSEZ.js.map} +0 -0
  416. /package/dist/{chunk-RP5SJ3XR.js.map → chunk-LCKVXX5F.js.map} +0 -0
  417. /package/dist/{chunk-ZI7LMSNI.js.map → chunk-LLHZZOIB.js.map} +0 -0
  418. /package/dist/{chunk-OYKQ6T4V.js.map → chunk-MATDGSJ7.js.map} +0 -0
  419. /package/dist/{chunk-3NFN4Y4P.js.map → chunk-MGCKZWAE.js.map} +0 -0
  420. /package/dist/{chunk-6OMUHXHP.js.map → chunk-ML7ZJAKJ.js.map} +0 -0
  421. /package/dist/{chunk-YDH2FSDI.js.map → chunk-N45NEBOD.js.map} +0 -0
  422. /package/dist/{chunk-A2E4WNW4.js.map → chunk-N4C7QKOG.js.map} +0 -0
  423. /package/dist/{chunk-B43NMCGQ.js.map → chunk-N7KYEVLK.js.map} +0 -0
  424. /package/dist/{chunk-HT2C4EXO.js.map → chunk-NIRQGDYC.js.map} +0 -0
  425. /package/dist/{chunk-DXHVD4DS.js.map → chunk-NW2E4CI2.js.map} +0 -0
  426. /package/dist/{chunk-4NDWE44P.js.map → chunk-NZFFGO5O.js.map} +0 -0
  427. /package/dist/{chunk-KC46VZR5.js.map → chunk-O2IPAX26.js.map} +0 -0
  428. /package/dist/{chunk-M7V65M6H.js.map → chunk-O4SGYW7H.js.map} +0 -0
  429. /package/dist/{chunk-QUA7RLK6.js.map → chunk-OP6N4H6A.js.map} +0 -0
  430. /package/dist/{chunk-ZSJGYC3C.js.map → chunk-OQJKY3Z5.js.map} +0 -0
  431. /package/dist/{chunk-OFEHITAZ.js.map → chunk-OXNTOHL6.js.map} +0 -0
  432. /package/dist/{chunk-FQD2KPQH.js.map → chunk-P55FACBG.js.map} +0 -0
  433. /package/dist/{chunk-XERVJYH2.js.map → chunk-P5NQN4JE.js.map} +0 -0
  434. /package/dist/{chunk-XZLWYZ7C.js.map → chunk-P7TOIOT7.js.map} +0 -0
  435. /package/dist/{chunk-PBVNVKYN.js.map → chunk-PIN5OPBA.js.map} +0 -0
  436. /package/dist/{chunk-CNG2XVZG.js.map → chunk-PZHQWFR3.js.map} +0 -0
  437. /package/dist/{chunk-SVDU4OHO.js.map → chunk-Q35L7TYB.js.map} +0 -0
  438. /package/dist/{chunk-YEM7K3KD.js.map → chunk-QODKDRSP.js.map} +0 -0
  439. /package/dist/{chunk-IZT3BVDW.js.map → chunk-QOZJCSFO.js.map} +0 -0
  440. /package/dist/{chunk-6T42L5FI.js.map → chunk-QS3OLP5I.js.map} +0 -0
  441. /package/dist/{chunk-PAAJWQH5.js.map → chunk-QUMKDRCF.js.map} +0 -0
  442. /package/dist/{chunk-JFVCDEIC.js.map → chunk-QX6JN3O4.js.map} +0 -0
  443. /package/dist/{chunk-KZEMFD6E.js.map → chunk-R2H4ZFBJ.js.map} +0 -0
  444. /package/dist/{chunk-GKIXBH7Y.js.map → chunk-RTKV5XHL.js.map} +0 -0
  445. /package/dist/{chunk-ZQ3WU6JO.js.map → chunk-RXFCU3CY.js.map} +0 -0
  446. /package/dist/{chunk-BOOFTFFE.js.map → chunk-S2I7DL5Q.js.map} +0 -0
  447. /package/dist/{chunk-2NCBDGND.js.map → chunk-SA6GMZJY.js.map} +0 -0
  448. /package/dist/{chunk-NSFOERZQ.js.map → chunk-SIIRTDJ4.js.map} +0 -0
  449. /package/dist/{chunk-A6TVQ3QP.js.map → chunk-SS3IS2JR.js.map} +0 -0
  450. /package/dist/{chunk-VFTK5WKI.js.map → chunk-STBX5X6B.js.map} +0 -0
  451. /package/dist/{chunk-WVHRNAXL.js.map → chunk-SWWHIJUJ.js.map} +0 -0
  452. /package/dist/{chunk-WADSXS4K.js.map → chunk-SX4QDWXK.js.map} +0 -0
  453. /package/dist/{chunk-ZIZ2G47N.js.map → chunk-TITG2NBS.js.map} +0 -0
  454. /package/dist/{chunk-LZKOVXMX.js.map → chunk-TRMJ6BYC.js.map} +0 -0
  455. /package/dist/{chunk-U7VPOXVM.js.map → chunk-TZNDKTX5.js.map} +0 -0
  456. /package/dist/{chunk-WWSRLS4M.js.map → chunk-UMTCNEVQ.js.map} +0 -0
  457. /package/dist/{chunk-4TTGRETU.js.map → chunk-UQDG3YLN.js.map} +0 -0
  458. /package/dist/{chunk-AAM66QCP.js.map → chunk-UZRSI6NX.js.map} +0 -0
  459. /package/dist/{chunk-2CXQZXWM.js.map → chunk-V4MB5ONM.js.map} +0 -0
  460. /package/dist/{chunk-CYEK6Z3P.js.map → chunk-VW6VIJOS.js.map} +0 -0
  461. /package/dist/{chunk-5ZJYHOJT.js.map → chunk-W47S5TIH.js.map} +0 -0
  462. /package/dist/{chunk-CBP4HWCL.js.map → chunk-W5MCEVUS.js.map} +0 -0
  463. /package/dist/{chunk-WETFW255.js.map → chunk-WLMZ2L5P.js.map} +0 -0
  464. /package/dist/{chunk-XRBHXUTQ.js.map → chunk-WSGPFRBH.js.map} +0 -0
  465. /package/dist/{chunk-UOKPJFO3.js.map → chunk-WVADKFWV.js.map} +0 -0
  466. /package/dist/{chunk-P34FDDB5.js.map → chunk-XISROV24.js.map} +0 -0
  467. /package/dist/{chunk-FZVROZKC.js.map → chunk-XVZA6VXC.js.map} +0 -0
  468. /package/dist/{chunk-JUWJYXI4.js.map → chunk-Y4NKEXQT.js.map} +0 -0
  469. /package/dist/{chunk-2ZQJLBV6.js.map → chunk-YE36AJL7.js.map} +0 -0
  470. /package/dist/{chunk-PCWXLAJY.js.map → chunk-YFMBHQRG.js.map} +0 -0
  471. /package/dist/{chunk-RBJQYMMT.js.map → chunk-YRULQW5J.js.map} +0 -0
  472. /package/dist/{chunk-QUNDYIYZ.js.map → chunk-YYEOR4XN.js.map} +0 -0
  473. /package/dist/{chunk-VYPFEVOM.js.map → chunk-ZJVMUBYF.js.map} +0 -0
  474. /package/dist/{chunk-5MDM7UE4.js.map → chunk-ZSH2NRDV.js.map} +0 -0
  475. /package/dist/{chunk-3J5JKBYD.js.map → chunk-ZV65I6ME.js.map} +0 -0
  476. /package/dist/{first-start-migration-HYAMKJ6V.js.map → first-start-migration-6A5BJPDW.js.map} +0 -0
@@ -9,10 +9,21 @@ import {
9
9
  writeOfflineUploadChunk,
10
10
  writeSafeFileFromUpload
11
11
  } from "./chunk-3E6DGSGZ.js";
12
+ import {
13
+ OFFLINE_SYNC_FAST_BASE_MTIME_TOLERANCE_MS,
14
+ SYNC_INTERNAL_DIR,
15
+ assertOfflineSyncMtimeMs,
16
+ isEncryptedOfflineSyncFile,
17
+ plainFileDigest,
18
+ readPlainOfflineSyncFileChunk,
19
+ setSafeFileMtime,
20
+ sha256OfflineSyncFile,
21
+ shouldExcludeOfflineSyncFile
22
+ } from "./chunk-EFHNFTWB.js";
12
23
  import {
13
24
  applyChangesetEmbeddingGenerations,
14
25
  normalizeChangesetGenerations
15
- } from "./chunk-AAM66QCP.js";
26
+ } from "./chunk-UZRSI6NX.js";
16
27
  import {
17
28
  applyIncomingEmbeddingGenerations,
18
29
  assertEmbeddingGenerationStillIncluded,
@@ -21,27 +32,16 @@ import {
21
32
  embeddingGenerationMembership,
22
33
  isEmbeddingGenerationDirPath,
23
34
  isPathInOmittedEmbeddingGeneration
24
- } from "./chunk-3NFN4Y4P.js";
25
- import {
26
- isCanonicalRuntimeStatePath,
27
- shouldDeleteAbsentIncomingOfflineRuntimeFile,
28
- shouldPreferIncomingOfflineRuntimeFile
29
- } from "./chunk-TYT4TEQV.js";
35
+ } from "./chunk-MGCKZWAE.js";
30
36
  import {
31
37
  isEmbeddingGenerationMarkerPath,
32
38
  matchesOfflineSyncDefaultExclude
33
39
  } from "./chunk-63LFM77Z.js";
34
40
  import {
35
- OFFLINE_SYNC_FAST_BASE_MTIME_TOLERANCE_MS,
36
- SYNC_INTERNAL_DIR,
37
- assertOfflineSyncMtimeMs,
38
- isEncryptedOfflineSyncFile,
39
- plainFileDigest,
40
- readPlainOfflineSyncFileChunk,
41
- setSafeFileMtime,
42
- sha256OfflineSyncFile,
43
- shouldExcludeOfflineSyncFile
44
- } from "./chunk-EFHNFTWB.js";
41
+ isCanonicalRuntimeStatePath,
42
+ shouldDeleteAbsentIncomingOfflineRuntimeFile,
43
+ shouldPreferIncomingOfflineRuntimeFile
44
+ } from "./chunk-TYT4TEQV.js";
45
45
  import {
46
46
  prepareSafeArchiveRoot,
47
47
  resolveSafeArchiveTarget,
@@ -51,7 +51,7 @@ import {
51
51
  import {
52
52
  withEmbeddingGenerationLock,
53
53
  withEmbeddingGenerationLockIter
54
- } from "./chunk-ZI7LMSNI.js";
54
+ } from "./chunk-LLHZZOIB.js";
55
55
  import {
56
56
  CENSUS_MAX_MTIME_MS,
57
57
  isSha256Hex
@@ -1787,4 +1787,4 @@ export {
1787
1787
  normalizeOfflineSyncState,
1788
1788
  fileStatesFromSnapshot
1789
1789
  };
1790
- //# sourceMappingURL=chunk-MZBWIJJN.js.map
1790
+ //# sourceMappingURL=chunk-63B2IZYE.js.map
@@ -1,6 +1,12 @@
1
1
  import {
2
2
  resolveEnsureCollectionArgs
3
3
  } from "./chunk-G26YNEOC.js";
4
+ import {
5
+ QmdDaemonSession
6
+ } from "./chunk-SWWHIJUJ.js";
7
+ import {
8
+ createInflightJoiner
9
+ } from "./chunk-TPSLVZHS.js";
4
10
  import {
5
11
  QMD_PROBE_RETRY_BACKOFF_MS,
6
12
  QMD_PROBE_TIMEOUT_MS,
@@ -19,12 +25,6 @@ import {
19
25
  embedQmdFiles,
20
26
  fetchQmdStatus
21
27
  } from "./chunk-IUM3VSHI.js";
22
- import {
23
- QmdDaemonSession
24
- } from "./chunk-WVHRNAXL.js";
25
- import {
26
- createInflightJoiner
27
- } from "./chunk-TPSLVZHS.js";
28
28
  import {
29
29
  clearQmdResultCaches,
30
30
  getCachedQmdSearch,
@@ -2028,4 +2028,4 @@ export {
2028
2028
  sharedDaemonSessionCountForTest,
2029
2029
  QmdClient
2030
2030
  };
2031
- //# sourceMappingURL=chunk-DGRMWDQY.js.map
2031
+ //# sourceMappingURL=chunk-66BCOVW2.js.map
@@ -0,0 +1,298 @@
1
+ import {
2
+ CAPTURE_WRITE_LOCK_BUSY_MESSAGE,
3
+ captureWriteLockDelayMs,
4
+ resolveCaptureWriteLockBackoffLimits
5
+ } from "./chunk-YET735EZ.js";
6
+ import {
7
+ withHeldFileLock
8
+ } from "./chunk-5B5WYAHQ.js";
9
+ import {
10
+ sleepAbortable
11
+ } from "./chunk-PGRZ3FYC.js";
12
+ import {
13
+ raceAbort,
14
+ throwIfAborted
15
+ } from "./chunk-BTTPKDIL.js";
16
+ import {
17
+ log
18
+ } from "./chunk-3WCASNQZ.js";
19
+
20
+ // src/storage/tombstone-blocked-capture-mutation.ts
21
+ import { AsyncLocalStorage } from "async_hooks";
22
+ import { createHash } from "crypto";
23
+ import { mkdir } from "fs/promises";
24
+ import path from "path";
25
+ var TOMBSTONE_CAPTURE_WRITE_LOCK_STALE_MS = 6e4;
26
+ var CAPTURE_WRITE_LOCK_PROBE_MS = 1;
27
+ var CAPTURE_WRITE_LOCK_RETRY = /* @__PURE__ */ Symbol("capture-write-lock-retry");
28
+ var CAPTURE_WRITE_LOCK_PERMANENT = /* @__PURE__ */ Symbol("capture-write-lock-permanent-failure");
29
+ function normalizeExplicitCaptureContent(value) {
30
+ return value.toLowerCase().replace(/\s+/g, " ").trim();
31
+ }
32
+ function buildExplicitCaptureDedupKey(content, category, sourceConnector) {
33
+ const encode = (label, value) => `${label} ${value.length} ${value}`;
34
+ return [
35
+ encode("category", category),
36
+ encode("connector", sourceConnector?.trim() ?? ""),
37
+ encode("content", normalizeExplicitCaptureContent(content))
38
+ ].join(" ");
39
+ }
40
+ function buildCapturePathLockIdentity(pathname) {
41
+ return `path ${pathname.length} ${pathname}`;
42
+ }
43
+ function captureIdentityHash(memory) {
44
+ return createHash("sha256").update(
45
+ buildExplicitCaptureDedupKey(memory.content, memory.frontmatter.category, memory.frontmatter.sourceConnector)
46
+ ).digest("hex");
47
+ }
48
+ var TombstoneBlockedCaptureWriteLock = class {
49
+ constructor(options) {
50
+ this.options = options;
51
+ }
52
+ options;
53
+ context = new AsyncLocalStorage();
54
+ captureWriteLockPathForHash(identityHash) {
55
+ const filename = identityHash.length === 0 ? "explicit-capture-write.lock" : `explicit-capture-write-${identityHash}.lock`;
56
+ return path.join(this.options.stateDir, "tombstone-blocked-capture", filename);
57
+ }
58
+ now() {
59
+ return this.options.now?.() ?? Date.now();
60
+ }
61
+ debug(message) {
62
+ if (this.options.logDebug) {
63
+ this.options.logDebug(message);
64
+ return;
65
+ }
66
+ log.debug(message);
67
+ }
68
+ warn(message) {
69
+ if (this.options.logWarn) {
70
+ this.options.logWarn(message);
71
+ return;
72
+ }
73
+ log.warn(message);
74
+ }
75
+ /** Prefer the constructor seam; converge installs the signal on lock options at acquire time. */
76
+ captureAbortSignal() {
77
+ return this.options.signal ?? this.options.lockOptions?.()?.captureWriteLockSignal;
78
+ }
79
+ /**
80
+ * One probe of a single lock file. Returns the retry symbol when the lock
81
+ * is busy and the permanent symbol on a filesystem error. Does not sleep:
82
+ * the caller backs off only after the whole chain has unwound.
83
+ */
84
+ async withSingleCaptureWriteLockOnce(lockPath, task) {
85
+ await mkdir(path.dirname(lockPath), { recursive: true });
86
+ const runWithHeldFileLock = this.options.withHeldFileLock ?? withHeldFileLock;
87
+ return await runWithHeldFileLock(
88
+ lockPath,
89
+ {
90
+ staleMs: TOMBSTONE_CAPTURE_WRITE_LOCK_STALE_MS,
91
+ maxWaitMs: CAPTURE_WRITE_LOCK_PROBE_MS,
92
+ pollMs: CAPTURE_WRITE_LOCK_PROBE_MS
93
+ },
94
+ async (acquired, controller) => {
95
+ if (acquired) return await task();
96
+ return controller.failure === "error" ? CAPTURE_WRITE_LOCK_PERMANENT : CAPTURE_WRITE_LOCK_RETRY;
97
+ }
98
+ );
99
+ }
100
+ async withPhysicalCaptureWriteLocks(task, identityHashes) {
101
+ const signal = this.captureAbortSignal();
102
+ const lockPaths = [...new Set(identityHashes.map((hash) => this.captureWriteLockPathForHash(hash)))];
103
+ const limits = resolveCaptureWriteLockBackoffLimits(this.options.lockOptions?.());
104
+ const deadline = this.now() + limits.deadlineMs;
105
+ const giveUp = () => {
106
+ throwIfAborted(signal);
107
+ this.warn(
108
+ `tombstone-blocked capture write lock remained busy after ${limits.deadlineMs}ms; failing this write so the rest of the cycle can continue`
109
+ );
110
+ throw new Error(CAPTURE_WRITE_LOCK_BUSY_MESSAGE);
111
+ };
112
+ const acquire = async (index) => {
113
+ throwIfAborted(signal);
114
+ const runTask = async () => {
115
+ if (this.now() >= deadline) giveUp();
116
+ return await task();
117
+ };
118
+ if (index === lockPaths.length) return await runTask();
119
+ const lockPath = lockPaths[index];
120
+ if (lockPath === void 0) return await runTask();
121
+ if (this.now() >= deadline) giveUp();
122
+ return await this.withSingleCaptureWriteLockOnce(lockPath, () => acquire(index + 1));
123
+ };
124
+ for (let attempt = 0; ; attempt += 1) {
125
+ throwIfAborted(signal);
126
+ const outcome = await acquire(0);
127
+ if (outcome === CAPTURE_WRITE_LOCK_PERMANENT) {
128
+ throw new Error("tombstone-blocked capture write lock acquisition failed");
129
+ }
130
+ if (outcome !== CAPTURE_WRITE_LOCK_RETRY) return outcome;
131
+ throwIfAborted(signal);
132
+ const now = this.now();
133
+ if (now >= deadline) giveUp();
134
+ const delay = Math.min(
135
+ captureWriteLockDelayMs(attempt, limits, this.options.random ?? Math.random),
136
+ deadline - now
137
+ );
138
+ if (delay <= 0) giveUp();
139
+ this.debug(`tombstone-blocked capture write lock busy; backing off ${delay}ms before retry ${attempt + 1}`);
140
+ await raceAbort((this.options.sleep ?? sleepAbortable)(delay, signal), signal);
141
+ }
142
+ }
143
+ async withCaptureWriteLock(task, identity) {
144
+ const identities = Array.isArray(identity) && identity.length > 0 ? identity : [typeof identity === "string" ? identity : ""];
145
+ return await this.withCaptureWriteLocks(task, identities, []);
146
+ }
147
+ async withCaptureWriteLockHashes(task, identityHashes) {
148
+ return await this.withCaptureWriteLocks(task, [], identityHashes);
149
+ }
150
+ async withCaptureWriteLockAndHashes(task, identity, identityHashes) {
151
+ const identities = Array.isArray(identity) && identity.length > 0 ? identity : [typeof identity === "string" ? identity : ""];
152
+ return await this.withCaptureWriteLocks(task, identities, identityHashes);
153
+ }
154
+ async withCaptureWriteLocks(task, identities, identityHashes) {
155
+ throwIfAborted(this.captureAbortSignal());
156
+ const current = this.context.getStore();
157
+ const hashToken = (key) => `\0${key.length === 0 ? "" : createHash("sha256").update(key).digest("hex")}`;
158
+ const identityHash = (key) => key.length === 0 ? "" : createHash("sha256").update(key).digest("hex");
159
+ const identityKeys = [...new Set(identities)];
160
+ const hashes = [...new Set(identityHashes)];
161
+ const requested = [
162
+ ...identityKeys.filter((key) => !current || !current.has(key) && !current.has(hashToken(key))).map((key) => ({ hash: identityHash(key), pathLock: key.startsWith("path ") })),
163
+ ...hashes.filter((hash) => !current || !current.has(`\0${hash}`)).map((hash) => ({ hash, pathLock: false }))
164
+ ].filter((entry, index, entries) => entries.findIndex((candidate) => candidate.hash === entry.hash) === index).sort(
165
+ (left, right) => Number(left.pathLock) - Number(right.pathLock) || this.captureWriteLockPathForHash(left.hash).localeCompare(this.captureWriteLockPathForHash(right.hash))
166
+ );
167
+ const physicalMissing = requested.map((entry) => entry.hash);
168
+ if (current && requested.length > 0) {
169
+ const held = [...current].filter((token) => token.startsWith("\0")).map((token) => {
170
+ const hash = token.slice(1);
171
+ const pathLock = [...current].some(
172
+ (key) => !key.startsWith("\0") && key.startsWith("path ") && hashToken(key) === token
173
+ );
174
+ return { hash, pathLock };
175
+ });
176
+ const requestedFirst = requested[0];
177
+ const heldLast = held.sort(
178
+ (left, right) => Number(left.pathLock) - Number(right.pathLock) || this.captureWriteLockPathForHash(left.hash).localeCompare(this.captureWriteLockPathForHash(right.hash))
179
+ ).at(-1);
180
+ if (heldLast && requestedFirst && (Number(requestedFirst.pathLock) < Number(heldLast.pathLock) || requestedFirst.pathLock === heldLast.pathLock && this.captureWriteLockPathForHash(requestedFirst.hash) < this.captureWriteLockPathForHash(heldLast.hash))) {
181
+ throw new Error(CAPTURE_WRITE_LOCK_BUSY_MESSAGE);
182
+ }
183
+ }
184
+ const next = new Set(current);
185
+ for (const key of identityKeys) {
186
+ next.add(key);
187
+ next.add(hashToken(key));
188
+ }
189
+ for (const hash of hashes) next.add(`\0${hash}`);
190
+ const run = () => {
191
+ throwIfAborted(this.captureAbortSignal());
192
+ return this.context.run(next, task);
193
+ };
194
+ if (physicalMissing.length === 0) return await run();
195
+ return await this.withPhysicalCaptureWriteLocks(run, physicalMissing);
196
+ }
197
+ };
198
+ async function runTombstoneBlockedMutation(host, mutation) {
199
+ let lockIdentity = mutation.identity;
200
+ for (; ; ) {
201
+ let retryIdentity;
202
+ let mintedRevision;
203
+ const mutate = async () => {
204
+ const current = await host.readCurrent();
205
+ const currentBlocked = host.isBlocked(current);
206
+ const currentQueuedReview = host.isQueuedReview(current);
207
+ if (current !== null && (mutation.coordinate === true || currentBlocked || currentQueuedReview)) {
208
+ const currentIdentity = host.memoryIdentity(current);
209
+ const heldIdentities = Array.isArray(lockIdentity) ? lockIdentity : [lockIdentity];
210
+ if (!heldIdentities.includes(currentIdentity)) {
211
+ retryIdentity = currentIdentity;
212
+ return;
213
+ }
214
+ }
215
+ const rebuildMarker = mutation.blocked || currentBlocked ? await host.prepareWrite() : void 0;
216
+ const discardRebuildMarker = async () => {
217
+ if (!rebuildMarker) return;
218
+ try {
219
+ await host.discardWrite(rebuildMarker);
220
+ } catch (cleanupError) {
221
+ host.markUntrusted();
222
+ host.logWarning(`storage.tombstoneBlocked failed to clear write marker: ${cleanupError}`);
223
+ }
224
+ };
225
+ let transaction;
226
+ try {
227
+ transaction = mutation.shouldMintRevision?.(current) ? await host.beginDurableMemoryRevision?.(mutation.pathname, mutation.fileContent) : void 0;
228
+ await host.writeStorageSecureFile(mutation.pathname, mutation.fileContent);
229
+ } catch (err) {
230
+ if (transaction) {
231
+ try {
232
+ await transaction.abort();
233
+ } catch (abortError) {
234
+ host.logWarning(
235
+ `storage.tombstoneBlocked failed to abort the reserved receipt (pending marker preserved): ${abortError}`
236
+ );
237
+ }
238
+ }
239
+ await discardRebuildMarker();
240
+ throw err;
241
+ }
242
+ if (transaction) {
243
+ try {
244
+ await transaction.writeLanded();
245
+ } catch (evidenceError) {
246
+ host.logWarning(
247
+ `storage.tombstoneBlocked failed to record receipt crash evidence (pending marker preserved): ${evidenceError}`
248
+ );
249
+ }
250
+ try {
251
+ await transaction.commit();
252
+ } catch (err) {
253
+ host.logWarning(
254
+ `storage.tombstoneBlocked receipt publication failed after the memory write (pending marker preserved for recovery): ${err}`
255
+ );
256
+ await discardRebuildMarker();
257
+ throw err;
258
+ }
259
+ }
260
+ mintedRevision = transaction?.pendingRevision;
261
+ if (rebuildMarker) {
262
+ try {
263
+ await host.commitWrite(rebuildMarker);
264
+ } catch (err) {
265
+ host.markUntrusted();
266
+ host.logWarning(`storage.tombstoneBlocked committed write marker failed: ${err}`);
267
+ }
268
+ }
269
+ if (rebuildMarker) await mutation.beforeIndexUpdate?.();
270
+ await mutation.updateIndex(rebuildMarker, currentBlocked && current !== null ? current : void 0);
271
+ };
272
+ await host.withCaptureWriteLock(mutate, lockIdentity);
273
+ if (retryIdentity === void 0) return mintedRevision;
274
+ const identities = Array.isArray(lockIdentity) ? [...lockIdentity, retryIdentity] : [lockIdentity, retryIdentity];
275
+ lockIdentity = [...new Set(identities)];
276
+ }
277
+ }
278
+ function tombstoneBlocked(frontmatter) {
279
+ return frontmatter.status === "pending_review" && Boolean(frontmatter.blockedBy);
280
+ }
281
+ function isQueuedReviewFrontmatter(frontmatter) {
282
+ return frontmatter.status === "pending_review" && (frontmatter.tags ?? []).includes("queued-review");
283
+ }
284
+ function isQueuedReviewMemory(memory) {
285
+ return memory !== null && isQueuedReviewFrontmatter(memory.frontmatter);
286
+ }
287
+
288
+ export {
289
+ normalizeExplicitCaptureContent,
290
+ buildExplicitCaptureDedupKey,
291
+ buildCapturePathLockIdentity,
292
+ captureIdentityHash,
293
+ TombstoneBlockedCaptureWriteLock,
294
+ runTombstoneBlockedMutation,
295
+ tombstoneBlocked,
296
+ isQueuedReviewMemory
297
+ };
298
+ //# sourceMappingURL=chunk-6EDW54SQ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/storage/tombstone-blocked-capture-mutation.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { createHash } from \"node:crypto\";\nimport { mkdir } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { raceAbort, throwIfAborted } from \"../abort-error.js\";\nimport {\n CAPTURE_WRITE_LOCK_BUSY_MESSAGE,\n type CaptureWriteLockLimitSource,\n captureWriteLockDelayMs,\n resolveCaptureWriteLockBackoffLimits,\n} from \"../capture-write-lock-backoff.js\";\nimport { log } from \"../logger.js\";\nimport type { MemoryFile, MemoryFrontmatter } from \"../types.js\";\nimport { withHeldFileLock } from \"../utils/serialize-mutations.js\";\nimport { sleepAbortable } from \"../utils/sleep.js\";\nimport type { CasRevisionTransaction } from \"./cas-revision-store.js\";\n\nexport { isTombstoneBlockedCaptureWriteLockBusy } from \"../capture-write-lock-backoff.js\";\n\nconst TOMBSTONE_CAPTURE_WRITE_LOCK_STALE_MS = 60_000;\n/**\n * One exclusive-create probe. The bounded wait lives in the outer backoff,\n * which runs only after every lock from this attempt has been released.\n * A multi-second poll here would hold an already-acquired sibling lock.\n */\nconst CAPTURE_WRITE_LOCK_PROBE_MS = 1;\nconst CAPTURE_WRITE_LOCK_RETRY = Symbol(\"capture-write-lock-retry\");\nconst CAPTURE_WRITE_LOCK_PERMANENT = Symbol(\"capture-write-lock-permanent-failure\");\n\nexport function normalizeExplicitCaptureContent(value: string): string {\n return value.toLowerCase().replace(/\\s+/g, \" \").trim();\n}\n\nexport function buildExplicitCaptureDedupKey(\n content: string,\n category: string,\n sourceConnector: string | undefined\n): string {\n const encode = (label: string, value: string): string => `${label} ${value.length} ${value}`;\n return [\n encode(\"category\", category),\n encode(\"connector\", sourceConnector?.trim() ?? \"\"),\n encode(\"content\", normalizeExplicitCaptureContent(content)),\n ].join(\" \");\n}\n\nexport function buildCapturePathLockIdentity(pathname: string): string {\n return `path ${pathname.length} ${pathname}`;\n}\n\nexport function captureIdentityHash(memory: MemoryFile): string {\n return createHash(\"sha256\")\n .update(\n buildExplicitCaptureDedupKey(memory.content, memory.frontmatter.category, memory.frontmatter.sourceConnector)\n )\n .digest(\"hex\");\n}\n\nexport type TombstoneBlockedCaptureWriteLockOptions = {\n readonly stateDir: string;\n readonly withHeldFileLock?: typeof withHeldFileLock;\n /** Read when an acquire starts, after the caller has installed converge config. */\n readonly lockOptions?: () => CaptureWriteLockLimitSource | undefined;\n readonly now?: () => number;\n readonly random?: () => number;\n readonly sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;\n readonly logDebug?: (message: string) => void;\n readonly logWarn?: (message: string) => void;\n /** Direct seam. Converge passes the same signal through `lockOptions` instead. */\n readonly signal?: AbortSignal;\n};\n\nexport class TombstoneBlockedCaptureWriteLock {\n private readonly context = new AsyncLocalStorage<ReadonlySet<string>>();\n\n constructor(private readonly options: TombstoneBlockedCaptureWriteLockOptions) {}\n\n private captureWriteLockPathForHash(identityHash: string): string {\n const filename =\n identityHash.length === 0 ? \"explicit-capture-write.lock\" : `explicit-capture-write-${identityHash}.lock`;\n return path.join(this.options.stateDir, \"tombstone-blocked-capture\", filename);\n }\n\n private now(): number {\n return this.options.now?.() ?? Date.now();\n }\n\n private debug(message: string): void {\n if (this.options.logDebug) {\n this.options.logDebug(message);\n return;\n }\n log.debug(message);\n }\n\n private warn(message: string): void {\n if (this.options.logWarn) {\n this.options.logWarn(message);\n return;\n }\n log.warn(message);\n }\n\n /** Prefer the constructor seam; converge installs the signal on lock options at acquire time. */\n private captureAbortSignal(): AbortSignal | undefined {\n return this.options.signal ?? this.options.lockOptions?.()?.captureWriteLockSignal;\n }\n\n /**\n * One probe of a single lock file. Returns the retry symbol when the lock\n * is busy and the permanent symbol on a filesystem error. Does not sleep:\n * the caller backs off only after the whole chain has unwound.\n */\n private async withSingleCaptureWriteLockOnce<T>(\n lockPath: string,\n task: () => Promise<T | typeof CAPTURE_WRITE_LOCK_RETRY>\n ): Promise<T | typeof CAPTURE_WRITE_LOCK_RETRY | typeof CAPTURE_WRITE_LOCK_PERMANENT> {\n await mkdir(path.dirname(lockPath), { recursive: true });\n const runWithHeldFileLock = this.options.withHeldFileLock ?? withHeldFileLock;\n return await runWithHeldFileLock(\n lockPath,\n {\n staleMs: TOMBSTONE_CAPTURE_WRITE_LOCK_STALE_MS,\n maxWaitMs: CAPTURE_WRITE_LOCK_PROBE_MS,\n pollMs: CAPTURE_WRITE_LOCK_PROBE_MS,\n },\n async (acquired, controller) => {\n if (acquired) return await task();\n return controller.failure === \"error\" ? CAPTURE_WRITE_LOCK_PERMANENT : CAPTURE_WRITE_LOCK_RETRY;\n }\n );\n }\n\n private async withPhysicalCaptureWriteLocks<T>(\n task: () => Promise<T>,\n identityHashes: readonly string[]\n ): Promise<T> {\n const signal = this.captureAbortSignal();\n const lockPaths = [...new Set(identityHashes.map((hash) => this.captureWriteLockPathForHash(hash)))];\n const limits = resolveCaptureWriteLockBackoffLimits(this.options.lockOptions?.());\n const deadline = this.now() + limits.deadlineMs;\n const giveUp = (): never => {\n throwIfAborted(signal);\n this.warn(\n `tombstone-blocked capture write lock remained busy after ${limits.deadlineMs}ms; failing this write so the rest of the cycle can continue`\n );\n throw new Error(CAPTURE_WRITE_LOCK_BUSY_MESSAGE);\n };\n const acquire = async (\n index: number\n ): Promise<T | typeof CAPTURE_WRITE_LOCK_RETRY | typeof CAPTURE_WRITE_LOCK_PERMANENT> => {\n throwIfAborted(signal);\n // The deadline gates each probe: a chain that started before the\n // deadline must not keep probing locks (or run the write) after it.\n const runTask = async (): Promise<T> => {\n if (this.now() >= deadline) giveUp();\n return await task();\n };\n if (index === lockPaths.length) return await runTask();\n const lockPath = lockPaths[index];\n if (lockPath === undefined) return await runTask();\n if (this.now() >= deadline) giveUp();\n return await this.withSingleCaptureWriteLockOnce(lockPath, () => acquire(index + 1));\n };\n for (let attempt = 0; ; attempt += 1) {\n throwIfAborted(signal);\n const outcome = await acquire(0);\n if (outcome === CAPTURE_WRITE_LOCK_PERMANENT) {\n throw new Error(\"tombstone-blocked capture write lock acquisition failed\");\n }\n if (outcome !== CAPTURE_WRITE_LOCK_RETRY) return outcome;\n throwIfAborted(signal);\n const now = this.now();\n if (now >= deadline) giveUp();\n const delay = Math.min(\n captureWriteLockDelayMs(attempt, limits, this.options.random ?? Math.random),\n deadline - now\n );\n if (delay <= 0) giveUp();\n this.debug(`tombstone-blocked capture write lock busy; backing off ${delay}ms before retry ${attempt + 1}`);\n // raceAbort covers seam sleeps that ignore the signal; the default\n // sleepAbortable also clears its timer so abort holds no Timeout.\n await raceAbort((this.options.sleep ?? sleepAbortable)(delay, signal), signal);\n }\n }\n\n async withCaptureWriteLock<T>(task: () => Promise<T>, identity?: string | readonly string[]): Promise<T> {\n const identities =\n Array.isArray(identity) && identity.length > 0 ? identity : [typeof identity === \"string\" ? identity : \"\"];\n return await this.withCaptureWriteLocks(task, identities, []);\n }\n\n async withCaptureWriteLockHashes<T>(task: () => Promise<T>, identityHashes: readonly string[]): Promise<T> {\n return await this.withCaptureWriteLocks(task, [], identityHashes);\n }\n\n async withCaptureWriteLockAndHashes<T>(\n task: () => Promise<T>,\n identity: string | readonly string[] | undefined,\n identityHashes: readonly string[]\n ): Promise<T> {\n const identities =\n Array.isArray(identity) && identity.length > 0 ? identity : [typeof identity === \"string\" ? identity : \"\"];\n return await this.withCaptureWriteLocks(task, identities, identityHashes);\n }\n\n private async withCaptureWriteLocks<T>(\n task: () => Promise<T>,\n identities: readonly string[],\n identityHashes: readonly string[]\n ): Promise<T> {\n throwIfAborted(this.captureAbortSignal());\n const current = this.context.getStore();\n const hashToken = (key: string): string =>\n `\\u0000${key.length === 0 ? \"\" : createHash(\"sha256\").update(key).digest(\"hex\")}`;\n const identityHash = (key: string): string =>\n key.length === 0 ? \"\" : createHash(\"sha256\").update(key).digest(\"hex\");\n const identityKeys = [...new Set(identities)];\n const hashes = [...new Set(identityHashes)];\n const requested = [\n ...identityKeys\n .filter((key) => !current || (!current.has(key) && !current.has(hashToken(key))))\n .map((key) => ({ hash: identityHash(key), pathLock: key.startsWith(\"path \") })),\n ...hashes.filter((hash) => !current || !current.has(`\\u0000${hash}`)).map((hash) => ({ hash, pathLock: false })),\n ]\n .filter((entry, index, entries) => entries.findIndex((candidate) => candidate.hash === entry.hash) === index)\n .sort(\n (left, right) =>\n Number(left.pathLock) - Number(right.pathLock) ||\n this.captureWriteLockPathForHash(left.hash).localeCompare(this.captureWriteLockPathForHash(right.hash))\n );\n const physicalMissing = requested.map((entry) => entry.hash);\n if (current && requested.length > 0) {\n const held = [...current]\n .filter((token) => token.startsWith(\"\\u0000\"))\n .map((token) => {\n const hash = token.slice(1);\n const pathLock = [...current].some(\n (key) => !key.startsWith(\"\\u0000\") && key.startsWith(\"path \") && hashToken(key) === token\n );\n return { hash, pathLock };\n });\n const requestedFirst = requested[0];\n const heldLast = held\n .sort(\n (left, right) =>\n Number(left.pathLock) - Number(right.pathLock) ||\n this.captureWriteLockPathForHash(left.hash).localeCompare(this.captureWriteLockPathForHash(right.hash))\n )\n .at(-1);\n if (\n heldLast &&\n requestedFirst &&\n (Number(requestedFirst.pathLock) < Number(heldLast.pathLock) ||\n (requestedFirst.pathLock === heldLast.pathLock &&\n this.captureWriteLockPathForHash(requestedFirst.hash) < this.captureWriteLockPathForHash(heldLast.hash)))\n ) {\n throw new Error(CAPTURE_WRITE_LOCK_BUSY_MESSAGE);\n }\n }\n const next = new Set(current);\n for (const key of identityKeys) {\n next.add(key);\n next.add(hashToken(key));\n }\n for (const hash of hashes) next.add(`\\u0000${hash}`);\n const run = () => {\n throwIfAborted(this.captureAbortSignal());\n return this.context.run(next, task);\n };\n if (physicalMissing.length === 0) return await run();\n return await this.withPhysicalCaptureWriteLocks(run, physicalMissing);\n }\n}\n\nexport type TombstoneBlockedMutationHost = {\n readCurrent: () => Promise<MemoryFile | null>;\n isBlocked: (memory: MemoryFile | null) => boolean;\n isQueuedReview: (memory: MemoryFile | null) => boolean;\n memoryIdentity: (memory: MemoryFile) => string;\n prepareWrite: () => Promise<string>;\n commitWrite: (marker: string) => Promise<void>;\n discardWrite: (marker: string) => Promise<void>;\n markUntrusted: () => void;\n writeStorageSecureFile: (pathname: string, fileContent: string) => Promise<void>;\n withCaptureWriteLock: (task: () => Promise<void>, identity: string | readonly string[]) => Promise<void>;\n logWarning: (message: string) => void;\n beginDurableMemoryRevision?: (\n pathname: string,\n expectedContent?: string | Buffer | null\n ) => Promise<CasRevisionTransaction | undefined>;\n};\n\nexport type TombstoneBlockedMutation = {\n blocked: boolean;\n pathname: string;\n fileContent: string;\n identity: string | readonly string[];\n updateIndex: (rebuildMarker?: string, current?: MemoryFile | null) => Promise<void>;\n beforeIndexUpdate?: () => Promise<void>;\n coordinate?: boolean;\n shouldMintRevision?: (current: MemoryFile | null) => boolean;\n};\n\nexport async function runTombstoneBlockedMutation(\n host: TombstoneBlockedMutationHost,\n mutation: TombstoneBlockedMutation\n): Promise<string | undefined> {\n let lockIdentity: string | readonly string[] = mutation.identity;\n for (;;) {\n let retryIdentity: string | undefined;\n let mintedRevision: string | undefined;\n const mutate = async (): Promise<void> => {\n const current = await host.readCurrent();\n const currentBlocked = host.isBlocked(current);\n const currentQueuedReview = host.isQueuedReview(current);\n if (current !== null && (mutation.coordinate === true || currentBlocked || currentQueuedReview)) {\n const currentIdentity = host.memoryIdentity(current);\n const heldIdentities = Array.isArray(lockIdentity) ? lockIdentity : [lockIdentity];\n if (!heldIdentities.includes(currentIdentity)) {\n retryIdentity = currentIdentity;\n return;\n }\n }\n const rebuildMarker = mutation.blocked || currentBlocked ? await host.prepareWrite() : undefined;\n const discardRebuildMarker = async (): Promise<void> => {\n if (!rebuildMarker) return;\n try {\n await host.discardWrite(rebuildMarker);\n } catch (cleanupError) {\n host.markUntrusted();\n host.logWarning(`storage.tombstoneBlocked failed to clear write marker: ${cleanupError}`);\n }\n };\n let transaction: CasRevisionTransaction | undefined;\n try {\n // #2813 (P1 C): a two-phase receipt transaction under this same\n // path lock. The PENDING reservation is minted BEFORE the durable\n // file publish, so a failed reservation leaves the memory file\n // untouched — never a mutated record without a receipt. The\n // COMMITTED receipt publishes only AFTER the write lands, so a\n // failed write can never leave the reservation posing as\n // ownership.\n transaction = mutation.shouldMintRevision?.(current)\n ? await host.beginDurableMemoryRevision?.(mutation.pathname, mutation.fileContent)\n : undefined;\n await host.writeStorageSecureFile(mutation.pathname, mutation.fileContent);\n } catch (err) {\n // The memory write failed (or never ran): abort the reservation so\n // no pending marker survives a write that did not land. A failed\n // abort keeps the marker — ambiguity, recovered later.\n if (transaction) {\n try {\n await transaction.abort();\n } catch (abortError) {\n host.logWarning(\n `storage.tombstoneBlocked failed to abort the reserved receipt (pending marker preserved): ${abortError}`\n );\n }\n }\n await discardRebuildMarker();\n throw err;\n }\n if (transaction) {\n // #2807: record the post-write fingerprint in the PENDING marker\n // BEFORE publishing, so a crash between the durable write and the\n // COMMITTED receipt is decisively recoverable. The evidence only\n // guards that crash window — a recording failure must not fail the\n // landed write, so commit still runs and publishes truthfully.\n try {\n await transaction.writeLanded();\n } catch (evidenceError) {\n host.logWarning(\n `storage.tombstoneBlocked failed to record receipt crash evidence (pending marker preserved): ${evidenceError}`\n );\n }\n try {\n await transaction.commit();\n } catch (err) {\n // #2813 (P1 C): the memory file LANDED but the COMMITTED receipt\n // never published. The PENDING marker stays: readers must see\n // unavailable/recovery-needed — never ownership, never absence —\n // and promotion/rollback refuse until recovery reconciles. The\n // reservation must NOT be aborted: the write is on disk.\n host.logWarning(\n `storage.tombstoneBlocked receipt publication failed after the memory write (pending marker preserved for recovery): ${err}`\n );\n await discardRebuildMarker();\n throw err;\n }\n }\n mintedRevision = transaction?.pendingRevision;\n if (rebuildMarker) {\n try {\n await host.commitWrite(rebuildMarker);\n } catch (err) {\n host.markUntrusted();\n host.logWarning(`storage.tombstoneBlocked committed write marker failed: ${err}`);\n }\n }\n if (rebuildMarker) await mutation.beforeIndexUpdate?.();\n await mutation.updateIndex(rebuildMarker, currentBlocked && current !== null ? current : undefined);\n };\n\n await host.withCaptureWriteLock(mutate, lockIdentity);\n if (retryIdentity === undefined) return mintedRevision;\n const identities = Array.isArray(lockIdentity) ? [...lockIdentity, retryIdentity] : [lockIdentity, retryIdentity];\n lockIdentity = [...new Set(identities)];\n }\n}\n\nexport function tombstoneBlocked(frontmatter: MemoryFrontmatter): boolean {\n return frontmatter.status === \"pending_review\" && Boolean(frontmatter.blockedBy);\n}\n\nexport function isQueuedReviewFrontmatter(frontmatter: MemoryFrontmatter): boolean {\n return frontmatter.status === \"pending_review\" && (frontmatter.tags ?? []).includes(\"queued-review\");\n}\n\nexport function isQueuedReviewMemory(memory: MemoryFile | null): memory is MemoryFile {\n return memory !== null && isQueuedReviewFrontmatter(memory.frontmatter);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,aAAa;AACtB,OAAO,UAAU;AAgBjB,IAAM,wCAAwC;AAM9C,IAAM,8BAA8B;AACpC,IAAM,2BAA2B,uBAAO,0BAA0B;AAClE,IAAM,+BAA+B,uBAAO,sCAAsC;AAE3E,SAAS,gCAAgC,OAAuB;AACrE,SAAO,MAAM,YAAY,EAAE,QAAQ,QAAQ,GAAG,EAAE,KAAK;AACvD;AAEO,SAAS,6BACd,SACA,UACA,iBACQ;AACR,QAAM,SAAS,CAAC,OAAe,UAA0B,GAAG,KAAK,IAAI,MAAM,MAAM,IAAI,KAAK;AAC1F,SAAO;AAAA,IACL,OAAO,YAAY,QAAQ;AAAA,IAC3B,OAAO,aAAa,iBAAiB,KAAK,KAAK,EAAE;AAAA,I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nB,eAAK,WAAW,2DAA2D,GAAG,EAAE;AAAA,QAClF;AAAA,MACF;AACA,UAAI,cAAe,OAAM,SAAS,oBAAoB;AACtD,YAAM,SAAS,YAAY,eAAe,kBAAkB,YAAY,OAAO,UAAU,MAAS;AAAA,IACpG;AAEA,UAAM,KAAK,qBAAqB,QAAQ,YAAY;AACpD,QAAI,kBAAkB,OAAW,QAAO;AACxC,UAAM,aAAa,MAAM,QAAQ,YAAY,IAAI,CAAC,GAAG,cAAc,aAAa,IAAI,CAAC,cAAc,aAAa;AAChH,mBAAe,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;AAAA,EACxC;AACF;AAEO,SAAS,iBAAiB,aAAyC;AACxE,SAAO,YAAY,WAAW,oBAAoB,QAAQ,YAAY,SAAS;AACjF;AAEO,SAAS,0BAA0B,aAAyC;AACjF,SAAO,YAAY,WAAW,qBAAqB,YAAY,QAAQ,CAAC,GAAG,SAAS,eAAe;AACrG;AAEO,SAAS,qBAAqB,QAAiD;AACpF,SAAO,WAAW,QAAQ,0BAA0B,OAAO,WAAW;AACxE;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  canonicalCategoryForAlias,
3
3
  categoryAliasCoercion
4
- } from "./chunk-CBP4HWCL.js";
4
+ } from "./chunk-W5MCEVUS.js";
5
5
 
6
6
  // src/access-observe-write-category.ts
7
7
  function splitCanonicalWriteRequest(request) {
@@ -22,4 +22,4 @@ function splitCanonicalWriteRequest(request) {
22
22
  export {
23
23
  splitCanonicalWriteRequest
24
24
  };
25
- //# sourceMappingURL=chunk-P2S6P7X6.js.map
25
+ //# sourceMappingURL=chunk-6LG7BWKW.js.map
@@ -0,0 +1,152 @@
1
+ import {
2
+ GROUNDING_MIN_SHARED_TOKENS,
3
+ areGroundingTokensCompatible,
4
+ entityNameStart,
5
+ hasDenialReporting,
6
+ hasNonAssertiveReporting,
7
+ isGroundedEntityName,
8
+ normalizedEntityIdentifierTokens,
9
+ sourceSentences,
10
+ tokenize
11
+ } from "./chunk-AIYXVWUH.js";
12
+
13
+ // src/extraction-quote-grounding.ts
14
+ var QUOTE_ANCHOR_MIN_CHARS = 12;
15
+ var QUOTE_ANCHOR_CONTEXT_CHARS = 400;
16
+ var QUOTE_ANCHOR_MIN_WINDOW_COVERAGE = 0.35;
17
+ var QUOTE_ANCHOR_MIN_SOURCE_COVERAGE = 0.75;
18
+ var QUOTE_ANCHOR_MAX_OCCURRENCES = 8;
19
+ var TURN_SEPARATOR = "\n\n";
20
+ var NEGATOR_PATTERN = /\b(?:not|no|never|cannot|without|neither|nor)\b|n't\b/iu;
21
+ var EXCLUSION_PATTERN = /\b(?:exclu\w*|avoid\w*|omit\w*|skip\w*|ignor\w*|forbid\w*|prohibit\w*|disallow\w*|prevent\w*|reject\w*|refus\w*|insufficient|instead|rather|unless|except)\b/iu;
22
+ function normalizeWhitespaceWithMap(source) {
23
+ const chars = [];
24
+ const originalIndex = [];
25
+ let inSpace = false;
26
+ for (let index = 0; index < source.length; index += 1) {
27
+ const char = source[index];
28
+ if (/\s/u.test(char)) {
29
+ if (inSpace) continue;
30
+ inSpace = true;
31
+ chars.push(" ");
32
+ } else {
33
+ inSpace = false;
34
+ chars.push(char);
35
+ }
36
+ originalIndex.push(index);
37
+ }
38
+ return { text: chars.join(""), originalIndex };
39
+ }
40
+ function findQuoteAnchors(quote, source) {
41
+ const needle = quote.replace(/\s+/gu, " ").trim();
42
+ if (needle.length < QUOTE_ANCHOR_MIN_CHARS) return [];
43
+ const normalized = normalizeWhitespaceWithMap(source);
44
+ const anchors = [];
45
+ let from = 0;
46
+ while (anchors.length < QUOTE_ANCHOR_MAX_OCCURRENCES) {
47
+ const at = normalized.text.indexOf(needle, from);
48
+ if (at < 0) break;
49
+ from = at + 1;
50
+ const start = normalized.originalIndex[at];
51
+ const end = normalized.originalIndex[at + needle.length - 1] + 1;
52
+ if (source.slice(start, end).includes(TURN_SEPARATOR)) continue;
53
+ let before = source.slice(Math.max(0, start - QUOTE_ANCHOR_CONTEXT_CHARS), start);
54
+ const turnStart = before.lastIndexOf(TURN_SEPARATOR);
55
+ if (turnStart >= 0) before = before.slice(turnStart + TURN_SEPARATOR.length);
56
+ else if (start > QUOTE_ANCHOR_CONTEXT_CHARS) before = before.replace(/^\S+/u, "");
57
+ let after = source.slice(end, end + QUOTE_ANCHOR_CONTEXT_CHARS);
58
+ const turnEnd = after.indexOf(TURN_SEPARATOR);
59
+ if (turnEnd >= 0) after = after.slice(0, turnEnd);
60
+ else if (source.length - end > QUOTE_ANCHOR_CONTEXT_CHARS) after = after.replace(/\S+$/u, "");
61
+ anchors.push({ quote: needle, window: `${before}${needle.replace(/;/gu, ",")}${after}` });
62
+ }
63
+ return anchors;
64
+ }
65
+ function quoteAnchors(quote, source, transformQuote) {
66
+ if (typeof quote !== "string") return [];
67
+ const exact = findQuoteAnchors(quote, source);
68
+ if (exact.length > 0 || transformQuote === void 0) return exact;
69
+ return findQuoteAnchors(transformQuote(quote), source);
70
+ }
71
+ function tokenPool(tokens) {
72
+ const list = [...tokens];
73
+ return (token) => tokens.has(token) || list.some((poolToken) => areGroundingTokensCompatible(token, poolToken));
74
+ }
75
+ function hasNegation(text) {
76
+ return NEGATOR_PATTERN.test(text.replace(/[\u2018\u2019]/gu, "'")) || hasDenialReporting(text);
77
+ }
78
+ function misstatesQuote(content, quote) {
79
+ const keepsNegation = hasNegation(content) || EXCLUSION_PATTERN.test(content);
80
+ const keepsReporting = hasNonAssertiveReporting(content) || content.trim().endsWith("?");
81
+ const contentHas = tokenPool(tokenize(content));
82
+ return (quote.match(/[^;.!?\n]+[;.!?]*/gu) ?? []).some((clause) => {
83
+ const negated = hasNegation(clause) && !keepsNegation;
84
+ const unasserted = (clause.trim().endsWith("?") || hasNonAssertiveReporting(clause)) && !keepsReporting;
85
+ if (!negated && !unasserted) return false;
86
+ const clauseTokens = [...tokenize(clause)];
87
+ const shared = clauseTokens.filter(contentHas).length;
88
+ return shared >= GROUNDING_MIN_SHARED_TOKENS && shared / clauseTokens.length >= 0.5;
89
+ });
90
+ }
91
+ function isQuoteAnchoredClaim(content, anchor, sourceHas) {
92
+ const contentTokens = [...tokenize(content)];
93
+ if (contentTokens.length === 0) return false;
94
+ const quoteHas = tokenPool(tokenize(anchor.quote));
95
+ if (contentTokens.filter(quoteHas).length < GROUNDING_MIN_SHARED_TOKENS) return false;
96
+ const windowHas = tokenPool(tokenize(anchor.window));
97
+ if (contentTokens.filter(windowHas).length / contentTokens.length < QUOTE_ANCHOR_MIN_WINDOW_COVERAGE) {
98
+ return false;
99
+ }
100
+ return contentTokens.filter(sourceHas).length / contentTokens.length >= QUOTE_ANCHOR_MIN_SOURCE_COVERAGE && !misstatesQuote(content, anchor.quote);
101
+ }
102
+ function filterEntityFacts(entity, isSupported) {
103
+ const facts = entity.facts.filter(isSupported);
104
+ const structuredSections = entity.structuredSections?.flatMap((section) => {
105
+ const groundedFacts = section.facts.filter(isSupported);
106
+ return groundedFacts.length > 0 ? [{ ...section, facts: groundedFacts }] : [];
107
+ });
108
+ if (facts.length === 0 && (structuredSections === void 0 || structuredSections.length === 0)) {
109
+ return void 0;
110
+ }
111
+ const { structuredSections: _structuredSections, ...entityWithoutSections } = entity;
112
+ return {
113
+ ...entityWithoutSections,
114
+ facts,
115
+ ...structuredSections && structuredSections.length > 0 ? { structuredSections } : {}
116
+ };
117
+ }
118
+ function quoteAnchoredEntitySupport(entity, anchors, sourceHas) {
119
+ const nameAnchors = anchors.filter((anchor) => isGroundedEntityName(entity.name, anchor.window));
120
+ if (nameAnchors.length === 0) return void 0;
121
+ return (fact) => nameAnchors.some((anchor) => isQuoteAnchoredClaim(fact, anchor, sourceHas));
122
+ }
123
+ function isQuoteAnchoredRelationship(relationship, anchors, sourceHas) {
124
+ const labelTokens = [...tokenize(relationship.label)];
125
+ if (labelTokens.length === 0) return false;
126
+ const relationText = [
127
+ normalizedEntityIdentifierTokens(relationship.source).join(" "),
128
+ relationship.label,
129
+ normalizedEntityIdentifierTokens(relationship.target).join(" ")
130
+ ].join(" ");
131
+ return anchors.some((anchor) => {
132
+ const windowHas = tokenPool(tokenize(anchor.window));
133
+ return labelTokens.every(windowHas) && sourceSentences(anchor.window).some((sentence) => {
134
+ const sourceStart = entityNameStart(relationship.source, sentence);
135
+ return sourceStart >= 0 && entityNameStart(relationship.target, sentence) > sourceStart;
136
+ }) && isQuoteAnchoredClaim(relationText, anchor, sourceHas);
137
+ });
138
+ }
139
+
140
+ export {
141
+ QUOTE_ANCHOR_MIN_CHARS,
142
+ QUOTE_ANCHOR_CONTEXT_CHARS,
143
+ QUOTE_ANCHOR_MIN_WINDOW_COVERAGE,
144
+ QUOTE_ANCHOR_MIN_SOURCE_COVERAGE,
145
+ quoteAnchors,
146
+ tokenPool,
147
+ isQuoteAnchoredClaim,
148
+ filterEntityFacts,
149
+ quoteAnchoredEntitySupport,
150
+ isQuoteAnchoredRelationship
151
+ };
152
+ //# sourceMappingURL=chunk-77R7BQZ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extraction-quote-grounding.ts"],"sourcesContent":["/**\n * Quote-anchored source grounding.\n *\n * An extracted fact carries the exact words that support it in `quote`. A quote\n * that is a verbatim substring of the source (whitespace-normalized) is real\n * evidence: the claim only has to be supported by the text around that span,\n * not by word overlap against the whole conversation. Items without such a\n * quote never get an anchor here and stay on the whole-source rules.\n */\n\nimport type { ExtractionResult } from \"./types.js\";\nimport {\n GROUNDING_MIN_SHARED_TOKENS,\n areGroundingTokensCompatible,\n entityNameStart,\n hasDenialReporting,\n hasNonAssertiveReporting,\n isGroundedEntityName,\n normalizedEntityIdentifierTokens,\n sourceSentences,\n tokenize,\n} from \"./extraction-source-grounding-helpers.js\";\n\n/** Shortest normalized quote that counts as evidence; \"the\" or \"I\" prove nothing. */\nexport const QUOTE_ANCHOR_MIN_CHARS = 12;\n/** Characters of context kept on each side of the quote inside its turn. */\nexport const QUOTE_ANCHOR_CONTEXT_CHARS = 400;\n/** Share of a claim's content words that must occur in the quote's window. */\nexport const QUOTE_ANCHOR_MIN_WINDOW_COVERAGE = 0.35;\n/** Share of a claim's content words that must occur anywhere in the source; the rest is invented. */\nexport const QUOTE_ANCHOR_MIN_SOURCE_COVERAGE = 0.75;\nconst QUOTE_ANCHOR_MAX_OCCURRENCES = 8;\nconst TURN_SEPARATOR = \"\\n\\n\";\nconst NEGATOR_PATTERN = /\\b(?:not|no|never|cannot|without|neither|nor)\\b|n't\\b/iu;\nconst EXCLUSION_PATTERN =\n /\\b(?:exclu\\w*|avoid\\w*|omit\\w*|skip\\w*|ignor\\w*|forbid\\w*|prohibit\\w*|disallow\\w*|prevent\\w*|reject\\w*|refus\\w*|insufficient|instead|rather|unless|except)\\b/iu;\n\n/** A verbatim quote and the text around it inside its turn. */\nexport interface QuoteAnchor {\n /** Whitespace-normalized quote, exactly as it appears in the source. */\n quote: string;\n /** `quote` with its turn-local context; `;` inside the quote is rewritten to `,`. */\n window: string;\n}\n\nexport type TokenPool = (token: string) => boolean;\n\ntype Entity = ExtractionResult[\"entities\"][number];\ntype Relationship = NonNullable<ExtractionResult[\"relationships\"]>[number];\n\nfunction normalizeWhitespaceWithMap(source: string): { text: string; originalIndex: number[] } {\n const chars: string[] = [];\n const originalIndex: number[] = [];\n let inSpace = false;\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]!;\n if (/\\s/u.test(char)) {\n if (inSpace) continue;\n inSpace = true;\n chars.push(\" \");\n } else {\n inSpace = false;\n chars.push(char);\n }\n originalIndex.push(index);\n }\n return { text: chars.join(\"\"), originalIndex };\n}\n\nfunction findQuoteAnchors(quote: string, source: string): QuoteAnchor[] {\n const needle = quote.replace(/\\s+/gu, \" \").trim();\n if (needle.length < QUOTE_ANCHOR_MIN_CHARS) return [];\n const normalized = normalizeWhitespaceWithMap(source);\n const anchors: QuoteAnchor[] = [];\n let from = 0;\n while (anchors.length < QUOTE_ANCHOR_MAX_OCCURRENCES) {\n const at = normalized.text.indexOf(needle, from);\n if (at < 0) break;\n from = at + 1;\n const start = normalized.originalIndex[at]!;\n const end = normalized.originalIndex[at + needle.length - 1]! + 1;\n if (source.slice(start, end).includes(TURN_SEPARATOR)) continue;\n\n let before = source.slice(Math.max(0, start - QUOTE_ANCHOR_CONTEXT_CHARS), start);\n const turnStart = before.lastIndexOf(TURN_SEPARATOR);\n if (turnStart >= 0) before = before.slice(turnStart + TURN_SEPARATOR.length);\n else if (start > QUOTE_ANCHOR_CONTEXT_CHARS) before = before.replace(/^\\S+/u, \"\");\n\n let after = source.slice(end, end + QUOTE_ANCHOR_CONTEXT_CHARS);\n const turnEnd = after.indexOf(TURN_SEPARATOR);\n if (turnEnd >= 0) after = after.slice(0, turnEnd);\n else if (source.length - end > QUOTE_ANCHOR_CONTEXT_CHARS) after = after.replace(/\\S+$/u, \"\");\n\n anchors.push({ quote: needle, window: `${before}${needle.replace(/;/gu, \",\")}${after}` });\n }\n return anchors;\n}\n\n/**\n * Returns one anchor per place `quote` occurs verbatim in `source`, or [] when\n * the quote is absent, too short, or not an exact substring. A quote that\n * spans a turn separator is not one turn's words and yields no anchor; windows\n * never extend past their turn.\n *\n * The quote is one evidence unit: a `;` inside it is rewritten to `,` in the\n * window so sentence splitting cannot cut it, or a claim that merges two of\n * its clauses could never be grounded in a single sentence.\n *\n * `source` may have been rewritten before grounding (temporal anchoring,\n * pronoun resolution) while the model quoted the original words. When the raw\n * quote is not found, `transformQuote` applies the same rewrite to the quote.\n */\nexport function quoteAnchors(\n quote: string | undefined,\n source: string,\n transformQuote?: (quote: string) => string,\n): QuoteAnchor[] {\n if (typeof quote !== \"string\") return [];\n const exact = findQuoteAnchors(quote, source);\n if (exact.length > 0 || transformQuote === undefined) return exact;\n return findQuoteAnchors(transformQuote(quote), source);\n}\n\nexport function tokenPool(tokens: ReadonlySet<string>): TokenPool {\n const list = [...tokens];\n return (token) => tokens.has(token) || list.some((poolToken) => areGroundingTokensCompatible(token, poolToken));\n}\n\nfunction hasNegation(text: string): boolean {\n return NEGATOR_PATTERN.test(text.replace(/[\\u2018\\u2019]/gu, \"'\")) || hasDenialReporting(text);\n}\n\n/**\n * True when the claim asserts what a quote clause denies or does not assert:\n * \"did not approve the budget\" or \"denied approving it\" restated as \"approved\n * the budget\", \"suspects Bob stole funds\" or \"Is Alice the CEO?\" restated as a\n * plain statement. A claim that keeps a negator, exclusion word, or reporting\n * marker (\"do not X\" reworded as \"X is excluded\") is not a misstatement.\n */\nfunction misstatesQuote(content: string, quote: string): boolean {\n const keepsNegation = hasNegation(content) || EXCLUSION_PATTERN.test(content);\n const keepsReporting = hasNonAssertiveReporting(content) || content.trim().endsWith(\"?\");\n const contentHas = tokenPool(tokenize(content));\n return (quote.match(/[^;.!?\\n]+[;.!?]*/gu) ?? []).some((clause) => {\n const negated = hasNegation(clause) && !keepsNegation;\n const unasserted = (clause.trim().endsWith(\"?\") || hasNonAssertiveReporting(clause)) && !keepsReporting;\n if (!negated && !unasserted) return false;\n const clauseTokens = [...tokenize(clause)];\n const shared = clauseTokens.filter(contentHas).length;\n return shared >= GROUNDING_MIN_SHARED_TOKENS && shared / clauseTokens.length >= 0.5;\n });\n}\n\n/**\n * A claim is supported by a verbatim quote when it shares at least\n * GROUNDING_MIN_SHARED_TOKENS content words with the quote, a good part of its\n * words sit in the text around the quote, nearly all of them occur in the\n * source at all, and it does not invert a negated clause of the quote. Reworded\n * and lightly elaborated claims pass; claims that bring words the conversation\n * never used, or that have nothing to do with the quote, do not.\n */\nexport function isQuoteAnchoredClaim(content: string, anchor: QuoteAnchor, sourceHas: TokenPool): boolean {\n const contentTokens = [...tokenize(content)];\n if (contentTokens.length === 0) return false;\n const quoteHas = tokenPool(tokenize(anchor.quote));\n if (contentTokens.filter(quoteHas).length < GROUNDING_MIN_SHARED_TOKENS) return false;\n const windowHas = tokenPool(tokenize(anchor.window));\n if (contentTokens.filter(windowHas).length / contentTokens.length < QUOTE_ANCHOR_MIN_WINDOW_COVERAGE) {\n return false;\n }\n return contentTokens.filter(sourceHas).length / contentTokens.length >= QUOTE_ANCHOR_MIN_SOURCE_COVERAGE\n && !misstatesQuote(content, anchor.quote);\n}\n\n/** Keeps the entity facts (flat and sectioned) `isSupported` accepts; undefined when none remain. */\nexport function filterEntityFacts(entity: Entity, isSupported: (fact: string) => boolean): Entity | undefined {\n const facts = entity.facts.filter(isSupported);\n const structuredSections = entity.structuredSections?.flatMap((section) => {\n const groundedFacts = section.facts.filter(isSupported);\n return groundedFacts.length > 0 ? [{ ...section, facts: groundedFacts }] : [];\n });\n if (facts.length === 0 && (structuredSections === undefined || structuredSections.length === 0)) {\n return undefined;\n }\n const { structuredSections: _structuredSections, ...entityWithoutSections } = entity;\n return {\n ...entityWithoutSections,\n facts,\n ...(structuredSections && structuredSections.length > 0 ? { structuredSections } : {}),\n };\n}\n\n/**\n * Entities carry no quote of their own; the anchors of facts that kept support\n * them. Returns a fact predicate, or undefined when no anchor window names the entity.\n */\nexport function quoteAnchoredEntitySupport(\n entity: Entity,\n anchors: readonly QuoteAnchor[],\n sourceHas: TokenPool,\n): ((fact: string) => boolean) | undefined {\n const nameAnchors = anchors.filter((anchor) => isGroundedEntityName(entity.name, anchor.window));\n if (nameAnchors.length === 0) return undefined;\n return (fact) => nameAnchors.some((anchor) => isQuoteAnchoredClaim(fact, anchor, sourceHas));\n}\n\n/**\n * The label words and both names must sit in one anchor-window sentence, source\n * before target, so an invented label or a reversed edge never passes.\n */\nexport function isQuoteAnchoredRelationship(\n relationship: Relationship,\n anchors: readonly QuoteAnchor[],\n sourceHas: TokenPool,\n): boolean {\n const labelTokens = [...tokenize(relationship.label)];\n if (labelTokens.length === 0) return false;\n const relationText = [\n normalizedEntityIdentifierTokens(relationship.source).join(\" \"),\n relationship.label,\n normalizedEntityIdentifierTokens(relationship.target).join(\" \"),\n ].join(\" \");\n return anchors.some((anchor) => {\n const windowHas = tokenPool(tokenize(anchor.window));\n return labelTokens.every(windowHas)\n && sourceSentences(anchor.window).some((sentence) => {\n const sourceStart = entityNameStart(relationship.source, sentence);\n return sourceStart >= 0 && entityNameStart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