@remnic/core 9.30.1 → 9.32.0

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 (504) hide show
  1. package/dist/access-admin-ops-surface.d.ts +10 -10
  2. package/dist/access-admin-ops-surface.js +55 -44
  3. package/dist/access-authorization-probe.d.ts +10 -10
  4. package/dist/access-authorization-probe.js +56 -45
  5. package/dist/access-boundary.d.ts +13 -11
  6. package/dist/access-boundary.js +55 -44
  7. package/dist/access-cli.js +170 -126
  8. package/dist/access-cli.js.map +1 -1
  9. package/dist/access-extraction-force-flush.d.ts +119 -0
  10. package/dist/access-extraction-force-flush.js +171 -0
  11. package/dist/access-health-types.d.ts +1 -1
  12. package/dist/access-http-lcm-compaction.d.ts +47 -13
  13. package/dist/access-http-lcm-compaction.js +7 -3
  14. package/dist/access-http-lifecycle-flush.d.ts +132 -0
  15. package/dist/access-http-lifecycle-flush.js +9 -0
  16. package/dist/access-http-lifecycle-flush.js.map +1 -0
  17. package/dist/access-http.d.ts +11 -10
  18. package/dist/access-http.js +71 -59
  19. package/dist/access-identity-continuity-surface.d.ts +8 -8
  20. package/dist/access-identity-continuity-surface.js +55 -44
  21. package/dist/access-lcm-surface.d.ts +10 -10
  22. package/dist/access-lcm-surface.js +55 -44
  23. package/dist/access-mcp-output-schemas.js +1 -1
  24. package/dist/access-mcp.d.ts +16 -10
  25. package/dist/access-mcp.js +63 -52
  26. package/dist/access-memory-search-fanout.d.ts +2 -2
  27. package/dist/{access-namespace-preflight-VfXssvoI.d.ts → access-namespace-preflight-COhbXBqS.d.ts} +1 -1
  28. package/dist/access-namespace-preflight.d.ts +3 -3
  29. package/dist/access-namespace-preflight.js +55 -44
  30. package/dist/access-observe-helpers.d.ts +22 -0
  31. package/dist/access-observe-helpers.js +10 -0
  32. package/dist/access-observe-helpers.js.map +1 -0
  33. package/dist/access-observe-write-surface.d.ts +51 -47
  34. package/dist/access-observe-write-surface.js +55 -44
  35. package/dist/access-operations-batch.js +58 -47
  36. package/dist/access-operations.d.ts +11 -11
  37. package/dist/access-operations.js +60 -49
  38. package/dist/access-recall-concurrency.d.ts +10 -10
  39. package/dist/access-recall-concurrency.js +55 -44
  40. package/dist/access-recall-response.d.ts +10 -10
  41. package/dist/access-recall-response.js +55 -44
  42. package/dist/access-recall-surface.d.ts +10 -10
  43. package/dist/access-recall-surface.js +55 -44
  44. package/dist/access-schema.d.ts +37 -7
  45. package/dist/access-schema.js +5 -3
  46. package/dist/{access-service-B5RwVsTV.d.ts → access-service-BmBTtEKO.d.ts} +44 -20
  47. package/dist/access-service-helpers.d.ts +113 -0
  48. package/dist/access-service-helpers.js +8 -0
  49. package/dist/access-service-helpers.js.map +1 -0
  50. package/dist/access-service.d.ts +10 -10
  51. package/dist/access-service.js +55 -44
  52. package/dist/access-surface-catalog.d.ts +10 -10
  53. package/dist/access-surface-catalog.js +2 -0
  54. package/dist/access-surface-catalog.js.map +1 -1
  55. package/dist/access-wearables-meetings-surface.d.ts +3 -3
  56. package/dist/action-confidence.d.ts +1 -1
  57. package/dist/active-memory-bridge.d.ts +1 -1
  58. package/dist/active-recall.d.ts +1 -1
  59. package/dist/active-recall.js +2 -2
  60. package/dist/adapters/index.js +7 -7
  61. package/dist/adapters/registry.js +3 -3
  62. package/dist/behavior-learner.d.ts +1 -1
  63. package/dist/behavior-signals.d.ts +1 -1
  64. package/dist/bootstrap.d.ts +8 -8
  65. package/dist/briefing.d.ts +2 -2
  66. package/dist/briefing.js +14 -14
  67. package/dist/buffer-surprise-report.d.ts +1 -1
  68. package/dist/buffer-turn-helpers.d.ts +5 -0
  69. package/dist/buffer-turn-helpers.js +24 -0
  70. package/dist/buffer-turn-helpers.js.map +1 -0
  71. package/dist/buffer.d.ts +17 -4
  72. package/dist/buffer.js +21 -1
  73. package/dist/bulk-import/index.d.ts +3 -3
  74. package/dist/calibration.d.ts +1 -1
  75. package/dist/capabilities.d.ts +1 -1
  76. package/dist/{capsule-crypto-GWVG7LGC.js → capsule-crypto-7FJQINUR.js} +2 -2
  77. package/dist/capsule-crypto-7FJQINUR.js.map +1 -0
  78. package/dist/{capsule-merge-5KKJQBWQ.js → capsule-merge-2H2IUTBT.js} +4 -4
  79. package/dist/{catalog-V7inUQdp.d.ts → catalog-Dm-DvNBY.d.ts} +1 -1
  80. package/dist/causal-behavior.d.ts +1 -1
  81. package/dist/causal-behavior.js +2 -2
  82. package/dist/causal-chain.js +2 -2
  83. package/dist/causal-consolidation.d.ts +1 -1
  84. package/dist/causal-consolidation.js +21 -22
  85. package/dist/causal-consolidation.js.map +1 -1
  86. package/dist/causal-retrieval.js +2 -2
  87. package/dist/causal-trajectory-graph.d.ts +1 -1
  88. package/dist/causal-trajectory.js +1 -1
  89. package/dist/{chunk-LEPOP46W.js → chunk-227UFSEQ.js} +4 -4
  90. package/dist/{chunk-I5NLEENJ.js → chunk-27HHNYSQ.js} +3 -3
  91. package/dist/{chunk-2SA56WMI.js → chunk-2LTDWSR6.js} +4 -4
  92. package/dist/{chunk-OWHERGF2.js → chunk-2NLLXCJG.js} +2 -2
  93. package/dist/{chunk-SPJXKAVF.js → chunk-2NTGBZLZ.js} +14 -13
  94. package/dist/chunk-2NTGBZLZ.js.map +1 -0
  95. package/dist/{chunk-P5PXWTW7.js → chunk-2Q4JJ3FZ.js} +3 -3
  96. package/dist/{chunk-G5R3D5UP.js → chunk-2QIMTVEJ.js} +6 -5
  97. package/dist/chunk-2QIMTVEJ.js.map +1 -0
  98. package/dist/{chunk-H5CPS5JP.js → chunk-35IVNNRK.js} +3 -3
  99. package/dist/{chunk-LBOD4U5B.js → chunk-3EQ2XB3W.js} +6 -6
  100. package/dist/{chunk-YTSNAUXN.js → chunk-3F2LKUMU.js} +22 -8
  101. package/dist/chunk-3F2LKUMU.js.map +1 -0
  102. package/dist/chunk-3QL24R5Y.js +9 -0
  103. package/dist/chunk-3QL24R5Y.js.map +1 -0
  104. package/dist/chunk-4RNZMRAV.js +60 -0
  105. package/dist/chunk-4RNZMRAV.js.map +1 -0
  106. package/dist/chunk-5IVLTFOV.js +65 -0
  107. package/dist/chunk-5IVLTFOV.js.map +1 -0
  108. package/dist/{chunk-2EUVEDF5.js → chunk-5WZVQRHV.js} +2 -2
  109. package/dist/{chunk-ALSGMEJR.js → chunk-65ZPVYTA.js} +7 -7
  110. package/dist/{chunk-GIBMDSJ2.js → chunk-6P7MTSU5.js} +2 -2
  111. package/dist/{chunk-5VQJBH2G.js → chunk-6TAUHL33.js} +2 -2
  112. package/dist/{chunk-WVO4G37W.js → chunk-7TEZUUGM.js} +3 -3
  113. package/dist/{chunk-MJCGLM25.js → chunk-7VUAG236.js} +5 -5
  114. package/dist/{chunk-CZRYLSSW.js → chunk-AJL6NNX6.js} +2 -2
  115. package/dist/{chunk-LGHKJABJ.js → chunk-AQEJE3WO.js} +40 -18
  116. package/dist/chunk-AQEJE3WO.js.map +1 -0
  117. package/dist/{chunk-66772WBP.js → chunk-AQWVJURR.js} +5 -5
  118. package/dist/{chunk-RKNJBZ55.js → chunk-AU7Q3LSC.js} +7 -7
  119. package/dist/{chunk-IYZ5K7MU.js → chunk-BUE5E2HL.js} +4 -187
  120. package/dist/chunk-BUE5E2HL.js.map +1 -0
  121. package/dist/{chunk-NHWB6HG2.js → chunk-CE5355TT.js} +21 -5
  122. package/dist/chunk-CE5355TT.js.map +1 -0
  123. package/dist/{chunk-M3C2V3PV.js → chunk-CJDNT45S.js} +12 -12
  124. package/dist/{chunk-D2ANTDGO.js → chunk-E6BMSH7U.js} +2 -2
  125. package/dist/{chunk-CKMO4RDY.js → chunk-EMDLM3LW.js} +4 -4
  126. package/dist/chunk-ER7W6H4T.js +112 -0
  127. package/dist/chunk-ER7W6H4T.js.map +1 -0
  128. package/dist/{chunk-RGIWINDN.js → chunk-FHBITMRY.js} +30 -30
  129. package/dist/{chunk-6FUPCJUL.js → chunk-FMFLGS5Z.js} +54 -54
  130. package/dist/chunk-FMFLGS5Z.js.map +1 -0
  131. package/dist/{chunk-FDAMS4PK.js → chunk-G2YQ57YO.js} +4 -4
  132. package/dist/{chunk-6U7F52DE.js → chunk-HFQQWAMS.js} +62 -62
  133. package/dist/{chunk-5W4ZLBEZ.js → chunk-HKPJPOW7.js} +2 -2
  134. package/dist/{chunk-JCBWCYEJ.js → chunk-IGWFKW4B.js} +2 -2
  135. package/dist/{chunk-AITCS2RC.js → chunk-IJ7HK452.js} +4 -4
  136. package/dist/{chunk-4WKA6I65.js → chunk-J3ZGPYXB.js} +1135 -311
  137. package/dist/chunk-J3ZGPYXB.js.map +1 -0
  138. package/dist/{chunk-D3LMYTBV.js → chunk-J7WZUL2K.js} +9 -9
  139. package/dist/{chunk-5W7CTZ2E.js → chunk-KQAFEZQX.js} +4 -4
  140. package/dist/{chunk-YNQBRLC5.js → chunk-LUQ443JP.js} +520 -2011
  141. package/dist/chunk-LUQ443JP.js.map +1 -0
  142. package/dist/{chunk-Z54EM5YZ.js → chunk-MAXVH44E.js} +7 -7
  143. package/dist/{chunk-WZFAPHIK.js → chunk-MU7ZHSZE.js} +2 -2
  144. package/dist/chunk-N5Z4EVOR.js +123 -0
  145. package/dist/chunk-N5Z4EVOR.js.map +1 -0
  146. package/dist/{chunk-AZ5BTEKX.js → chunk-NQUF7XKR.js} +2 -2
  147. package/dist/{chunk-W4FBGYGK.js → chunk-NRV4Y3PM.js} +1 -1
  148. package/dist/{chunk-62U4J2GN.js → chunk-ODGOP7P2.js} +2 -2
  149. package/dist/{chunk-QJAQNXWI.js → chunk-ONHRRJZM.js} +6 -6
  150. package/dist/{chunk-ACXPX4AG.js → chunk-OPBTPRGY.js} +2 -2
  151. package/dist/{chunk-XOZ4ALGB.js → chunk-QDTZ2HF7.js} +3 -3
  152. package/dist/{chunk-GBJ4RDFR.js → chunk-QIHIHZYC.js} +66 -91
  153. package/dist/chunk-QIHIHZYC.js.map +1 -0
  154. package/dist/{chunk-ZPSVBSOF.js → chunk-QMWFQBIL.js} +3 -3
  155. package/dist/{chunk-W5EG6LE3.js → chunk-THCPRMRF.js} +3 -3
  156. package/dist/{chunk-4A6YGWQN.js → chunk-TL4TO3EA.js} +115 -120
  157. package/dist/chunk-TL4TO3EA.js.map +1 -0
  158. package/dist/{chunk-VI2JQPNQ.js → chunk-U7QYBSQJ.js} +2 -2
  159. package/dist/chunk-ULARSG5Z.js +203 -0
  160. package/dist/chunk-ULARSG5Z.js.map +1 -0
  161. package/dist/{chunk-TH2LSRMG.js → chunk-UORKJ34C.js} +2 -2
  162. package/dist/{chunk-4Z4XNEWZ.js → chunk-VCD4PSK2.js} +56 -12
  163. package/dist/chunk-VCD4PSK2.js.map +1 -0
  164. package/dist/{chunk-K5GB36ME.js → chunk-VMZ56EE3.js} +2 -2
  165. package/dist/{chunk-HUHX2OCX.js → chunk-VVDPPDDF.js} +1 -1
  166. package/dist/chunk-VVDPPDDF.js.map +1 -0
  167. package/dist/{chunk-RMMVQQA6.js → chunk-WDISJRMG.js} +2 -2
  168. package/dist/{chunk-B6JDYXL7.js → chunk-WWUVONGW.js} +7 -1
  169. package/dist/chunk-WWUVONGW.js.map +1 -0
  170. package/dist/{chunk-UVYI6VIX.js → chunk-X7Y7WX73.js} +1 -1
  171. package/dist/{chunk-CVILPI77.js → chunk-XOQSEF7X.js} +6 -6
  172. package/dist/{chunk-RPW2NOU6.js → chunk-YIAA2X3D.js} +41 -1
  173. package/dist/chunk-YIAA2X3D.js.map +1 -0
  174. package/dist/chunk-YPC7W6GA.js +1604 -0
  175. package/dist/chunk-YPC7W6GA.js.map +1 -0
  176. package/dist/{chunk-YTQNQ4KB.js → chunk-YX5LN6JR.js} +3 -3
  177. package/dist/{chunk-IC6CBHCA.js → chunk-Z7XKUWYS.js} +2 -2
  178. package/dist/{chunk-PHWUFPCO.js → chunk-ZCPP5OW6.js} +61 -53
  179. package/dist/chunk-ZCPP5OW6.js.map +1 -0
  180. package/dist/{cli-C4GbETPC.d.ts → cli-DRJLv1Xt.d.ts} +5 -5
  181. package/dist/cli.d.ts +12 -12
  182. package/dist/cli.js +96 -86
  183. package/dist/compounding/engine.d.ts +2 -2
  184. package/dist/compounding/engine.js +14 -14
  185. package/dist/compounding/preference-consolidator.d.ts +1 -1
  186. package/dist/compression-optimizer.d.ts +1 -1
  187. package/dist/config.d.ts +1 -1
  188. package/dist/config.js +2 -2
  189. package/dist/connectors/codex-materialize-runner.d.ts +1 -1
  190. package/dist/connectors/codex-materialize-runner.js +14 -15
  191. package/dist/connectors/codex-materialize.d.ts +1 -1
  192. package/dist/connectors/index.d.ts +3 -2
  193. package/dist/connectors/index.js +24 -23
  194. package/dist/consolidation-provenance-check.d.ts +2 -2
  195. package/dist/consolidation-provenance-check.js +5 -5
  196. package/dist/consolidation-undo.d.ts +2 -2
  197. package/dist/consolidation-undo.js +3 -3
  198. package/dist/contradiction/index.d.ts +2 -2
  199. package/dist/contradiction/index.js +4 -4
  200. package/dist/conversation-index/backend.d.ts +1 -1
  201. package/dist/conversation-index/backend.js +2 -2
  202. package/dist/conversation-index/chunker.d.ts +1 -1
  203. package/dist/conversation-index/faiss-adapter.d.ts +1 -1
  204. package/dist/conversation-index/indexer.d.ts +1 -1
  205. package/dist/conversation-index/search.d.ts +1 -1
  206. package/dist/corpus-watermark.d.ts +1 -1
  207. package/dist/corpus-watermark.js +26 -26
  208. package/dist/day-summary.d.ts +1 -1
  209. package/dist/delinearize.d.ts +1 -1
  210. package/dist/direct-answer-wiring.d.ts +1 -1
  211. package/dist/direct-answer.d.ts +1 -1
  212. package/dist/embedding-fallback.d.ts +1 -1
  213. package/dist/enrichment/index.d.ts +1 -1
  214. package/dist/entity-retrieval.d.ts +2 -2
  215. package/dist/entity-retrieval.js +14 -14
  216. package/dist/entity-schema.d.ts +1 -1
  217. package/dist/explicit-capture.d.ts +8 -8
  218. package/dist/extraction-error-classification.d.ts +1 -1
  219. package/dist/extraction-faithfulness.d.ts +1 -1
  220. package/dist/extraction-judge-telemetry.d.ts +1 -1
  221. package/dist/extraction-judge-training.d.ts +1 -1
  222. package/dist/extraction-judge.d.ts +1 -1
  223. package/dist/extraction-liveness.d.ts +1 -1
  224. package/dist/extraction-source-grounding-rules.d.ts +1 -1
  225. package/dist/extraction-source-grounding.d.ts +15 -2
  226. package/dist/extraction-source-grounding.js +10 -1
  227. package/dist/extraction.d.ts +2 -15
  228. package/dist/extraction.js +5 -4
  229. package/dist/fallback-llm.d.ts +1 -1
  230. package/dist/graph-dashboard-diff.d.ts +1 -1
  231. package/dist/graph-dashboard-key.d.ts +1 -1
  232. package/dist/graph-dashboard-parser.d.ts +1 -1
  233. package/dist/graph-edge-reinforcement.d.ts +1 -1
  234. package/dist/graph-snapshot.d.ts +1 -1
  235. package/dist/graph.d.ts +1 -1
  236. package/dist/importance.d.ts +1 -1
  237. package/dist/importers/index.d.ts +1 -1
  238. package/dist/in-flight-reads.d.ts +1 -1
  239. package/dist/index.d.ts +19 -19
  240. package/dist/index.js +253 -246
  241. package/dist/intent.d.ts +1 -1
  242. package/dist/lcm/engine.d.ts +1 -1
  243. package/dist/lcm/engine.js +3 -3
  244. package/dist/lcm/index.d.ts +1 -1
  245. package/dist/lcm/index.js +6 -6
  246. package/dist/lcm/tools.d.ts +1 -1
  247. package/dist/lifecycle.d.ts +1 -1
  248. package/dist/live-connectors-runner.d.ts +1 -1
  249. package/dist/local-llm-helpers.d.ts +7 -0
  250. package/dist/local-llm-helpers.js +16 -0
  251. package/dist/local-llm-helpers.js.map +1 -0
  252. package/dist/local-llm.d.ts +3 -6
  253. package/dist/local-llm.js +2 -1
  254. package/dist/local-model-endpoint.d.ts +1 -1
  255. package/dist/maintenance/memory-governance.d.ts +1 -1
  256. package/dist/maintenance/memory-governance.js +14 -14
  257. package/dist/maintenance/rebuild-memory-lifecycle-ledger.d.ts +2 -2
  258. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +14 -14
  259. package/dist/maintenance/rebuild-memory-projection.d.ts +2 -2
  260. package/dist/maintenance/rebuild-memory-projection.js +15 -15
  261. package/dist/{maintenance-CL30NWtc.d.ts → maintenance-C6Pffz30.d.ts} +3 -3
  262. package/dist/mcp-memory-inspector-app.d.ts +10 -10
  263. package/dist/memory-action-policy.d.ts +1 -1
  264. package/dist/memory-cache.d.ts +1 -1
  265. package/dist/memory-corpus-version.js +2 -2
  266. package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
  267. package/dist/memory-projection-store.d.ts +1 -1
  268. package/dist/memory-provenance.d.ts +1 -1
  269. package/dist/memory-worth-outcomes.d.ts +2 -2
  270. package/dist/models-json.d.ts +1 -1
  271. package/dist/namespaces/migrate.d.ts +3 -3
  272. package/dist/namespaces/migrate.js +24 -24
  273. package/dist/namespaces/principal.d.ts +1 -1
  274. package/dist/namespaces/search.d.ts +1 -1
  275. package/dist/namespaces/search.js +9 -9
  276. package/dist/namespaces/storage.d.ts +3 -3
  277. package/dist/namespaces/storage.js +14 -14
  278. package/dist/native-knowledge.d.ts +1 -1
  279. package/dist/offline-sync-impression-drain.d.ts +1 -1
  280. package/dist/offline-sync-impression-drain.js +6 -5
  281. package/dist/operator-doctor-corpus.d.ts +1 -1
  282. package/dist/operator-doctor-corpus.js +29 -29
  283. package/dist/operator-doctor-replica.d.ts +1 -1
  284. package/dist/operator-doctor-replica.js +3 -3
  285. package/dist/operator-toolkit.d.ts +3 -3
  286. package/dist/operator-toolkit.js +39 -38
  287. package/dist/orchestration/compression-guideline-coordinator.d.ts +2 -2
  288. package/dist/orchestration/maintenance.d.ts +4 -4
  289. package/dist/orchestration/maintenance.js +22 -21
  290. package/dist/{orchestrator-CKTCRwWV.d.ts → orchestrator-eQlmasno.d.ts} +72 -34
  291. package/dist/orchestrator.d.ts +8 -8
  292. package/dist/orchestrator.js +169 -162
  293. package/dist/page-versioning.js +3 -3
  294. package/dist/patterns-cli.d.ts +1 -1
  295. package/dist/{pipeline-B7wj4rRZ.d.ts → pipeline-CZGmAMQ2.d.ts} +1 -1
  296. package/dist/policy-runtime.d.ts +1 -1
  297. package/dist/proactive-contention.d.ts +1 -1
  298. package/dist/provenance.d.ts +1 -1
  299. package/dist/{qmd-q9tg4dHp.d.ts → qmd-DBj4MF8T.d.ts} +1 -1
  300. package/dist/qmd-preflight.d.ts +2 -2
  301. package/dist/qmd-recall-cache.d.ts +1 -1
  302. package/dist/qmd.d.ts +2 -2
  303. package/dist/qmd.js +4 -4
  304. package/dist/recall-concurrency-config.d.ts +1 -1
  305. package/dist/recall-disclosure-escalation.d.ts +1 -1
  306. package/dist/recall-explain-renderer.d.ts +1 -1
  307. package/dist/recall-explain-renderer.js +3 -3
  308. package/dist/recall-memory-map.d.ts +1 -1
  309. package/dist/recall-planner-llm.d.ts +1 -1
  310. package/dist/recall-state.d.ts +1 -1
  311. package/dist/recall-tag-filter.d.ts +1 -1
  312. package/dist/recall-timings.d.ts +1 -1
  313. package/dist/recall-xray-cli.d.ts +1 -1
  314. package/dist/recall-xray-cli.js +4 -4
  315. package/dist/recall-xray-renderer.d.ts +1 -1
  316. package/dist/recall-xray-renderer.js +3 -3
  317. package/dist/recall-xray.d.ts +1 -1
  318. package/dist/recall-xray.js +2 -2
  319. package/dist/replay/normalizers/chatgpt.d.ts +1 -1
  320. package/dist/replay/normalizers/claude.d.ts +1 -1
  321. package/dist/replay/normalizers/openclaw.d.ts +1 -1
  322. package/dist/replay/normalizers/shared.d.ts +1 -1
  323. package/dist/replay/runner.d.ts +1 -1
  324. package/dist/replay/types.d.ts +1 -1
  325. package/dist/replica-divergence.d.ts +1 -1
  326. package/dist/replica-divergence.js +2 -2
  327. package/dist/replica-peers-config.d.ts +1 -1
  328. package/dist/resolve-auth-token.d.ts +1 -1
  329. package/dist/resume-bundles.js +2 -2
  330. package/dist/retrieval-agents.d.ts +2 -2
  331. package/dist/retrieval-tiers.d.ts +1 -1
  332. package/dist/routing/engine.d.ts +1 -1
  333. package/dist/routing/store.d.ts +1 -1
  334. package/dist/salvage-envelope.d.ts +1 -1
  335. package/dist/{scope-profiles-CWDyglPM.d.ts → scope-profiles-S85lrsUn.d.ts} +1 -1
  336. package/dist/search/embed-helper.d.ts +1 -1
  337. package/dist/search/factory.d.ts +1 -1
  338. package/dist/search/factory.js +8 -8
  339. package/dist/search/index.d.ts +1 -1
  340. package/dist/search/index.js +12 -12
  341. package/dist/search/lancedb-backend.d.ts +1 -1
  342. package/dist/search/meilisearch-backend.d.ts +1 -1
  343. package/dist/search/noop-backend.d.ts +1 -1
  344. package/dist/search/orama-backend.d.ts +1 -1
  345. package/dist/search/port.d.ts +1 -1
  346. package/dist/search/remote-backend.d.ts +1 -1
  347. package/dist/{semantic-consolidation-BUE3deLn.d.ts → semantic-consolidation-DVzDcV6x.d.ts} +1 -1
  348. package/dist/semantic-consolidation.d.ts +2 -2
  349. package/dist/semantic-consolidation.js +17 -18
  350. package/dist/semantic-rule-promotion.js +14 -14
  351. package/dist/semantic-rule-verifier.d.ts +1 -1
  352. package/dist/semantic-rule-verifier.js +14 -14
  353. package/dist/{service-CXgM0bQG.d.ts → service-C2M-wD4W.d.ts} +2 -2
  354. package/dist/session-observer-bands.d.ts +1 -1
  355. package/dist/session-observer-state.d.ts +1 -1
  356. package/dist/shared-context/manager.d.ts +1 -1
  357. package/dist/signal.d.ts +1 -1
  358. package/dist/{storage-DysJq-XH.d.ts → storage-dyBC3Q84.d.ts} +1 -1
  359. package/dist/storage.d.ts +2 -2
  360. package/dist/storage.js +13 -13
  361. package/dist/summarizer.d.ts +1 -1
  362. package/dist/summarizer.js +3 -2
  363. package/dist/summary-snapshot.d.ts +1 -1
  364. package/dist/temporal-supersession.d.ts +2 -2
  365. package/dist/temporal-timeline-recall.d.ts +1 -1
  366. package/dist/temporal-validity.d.ts +1 -1
  367. package/dist/threading.d.ts +1 -1
  368. package/dist/tier-migration.d.ts +2 -2
  369. package/dist/tier-routing.d.ts +1 -1
  370. package/dist/tokens.js +2 -2
  371. package/dist/topics.d.ts +1 -1
  372. package/dist/transcript.d.ts +1 -1
  373. package/dist/transfer/backup.js +2 -2
  374. package/dist/transfer/capsule-export.js +2 -2
  375. package/dist/transfer/capsule-import.js +5 -5
  376. package/dist/trust-score-stage.d.ts +1 -1
  377. package/dist/trust-score.d.ts +1 -1
  378. package/dist/{types-aPPzhnjT.d.ts → types-D63ZI--P.d.ts} +23 -2
  379. package/dist/types.d.ts +1 -1
  380. package/dist/types.js +1 -1
  381. package/dist/utility-runtime.d.ts +1 -1
  382. package/dist/verified-recall.js +14 -14
  383. package/dist/write-envelope.d.ts +1 -1
  384. package/package.json +2 -2
  385. package/src/access-boundary.ts +3 -0
  386. package/src/access-cli.test.ts +93 -0
  387. package/src/access-cli.ts +56 -2
  388. package/src/access-extraction-force-flush.ts +177 -0
  389. package/src/access-http-extraction-force-flush.test.ts +132 -0
  390. package/src/access-http-lcm-compaction.ts +99 -22
  391. package/src/access-http-lifecycle-flush.ts +81 -0
  392. package/src/access-http.test.ts +227 -0
  393. package/src/access-http.ts +33 -40
  394. package/src/access-mcp-output-schemas.ts +6 -0
  395. package/src/access-mcp.test.ts +40 -0
  396. package/src/access-mcp.ts +32 -1
  397. package/src/access-observe-helpers.ts +180 -0
  398. package/src/access-observe-write-surface.ts +78 -19
  399. package/src/access-operations-batch.ts +2 -1
  400. package/src/access-schema-pi.test.ts +17 -0
  401. package/src/access-schema.ts +28 -11
  402. package/src/access-service-helpers.ts +46 -0
  403. package/src/access-service-observe-lcm-parity.test.ts +781 -31
  404. package/src/access-service-observe-scope.test.ts +88 -0
  405. package/src/access-service.ts +46 -128
  406. package/src/access-surface-catalog.test.ts +32 -0
  407. package/src/access-surface-catalog.ts +2 -0
  408. package/src/buffer-session.test.ts +148 -0
  409. package/src/buffer-turn-helpers.ts +152 -0
  410. package/src/buffer.ts +126 -201
  411. package/src/connectors/index.ts +1 -1
  412. package/src/connectors/label.ts +18 -0
  413. package/src/correction/correction-access-wiring.ts +79 -27
  414. package/src/correction/correction-executor.test.ts +542 -1
  415. package/src/correction/correction-executor.ts +309 -89
  416. package/src/correction/correction-planner.test.ts +35 -1
  417. package/src/correction/correction-planner.ts +50 -3
  418. package/src/correction/correction-service.ts +12 -7
  419. package/src/correction/correction-storage-integration.test.ts +172 -1
  420. package/src/correction/passive-capture.test.ts +35 -0
  421. package/src/correction/passive-capture.ts +17 -3
  422. package/src/extraction-source-grounding.ts +55 -1
  423. package/src/extraction-timeout.test.ts +51 -0
  424. package/src/extraction.ts +64 -90
  425. package/src/local-llm-headers-timeout.test.ts +48 -0
  426. package/src/local-llm-helpers.ts +58 -0
  427. package/src/local-llm.ts +62 -58
  428. package/src/orchestration/extraction-run-helpers.ts +309 -0
  429. package/src/orchestration/extraction-run.test.ts +350 -7
  430. package/src/orchestration/extraction-run.ts +327 -250
  431. package/src/orchestration/recall-result-formatter.ts +21 -2
  432. package/src/orchestration/recall-search-pipeline.test.ts +34 -0
  433. package/src/orchestration/recall-search-pipeline.ts +9 -1
  434. package/src/orchestration/session-context.ts +193 -18
  435. package/src/orchestration/turn-ingestion.ts +61 -11
  436. package/src/orchestrator-flush.test.ts +511 -5
  437. package/src/orchestrator.ts +8 -6
  438. package/src/recall-source-connector-label.test.ts +300 -0
  439. package/src/types.ts +3 -3
  440. package/dist/chunk-3UXOZBHV.js +0 -20
  441. package/dist/chunk-3UXOZBHV.js.map +0 -1
  442. package/dist/chunk-4A6YGWQN.js.map +0 -1
  443. package/dist/chunk-4WKA6I65.js.map +0 -1
  444. package/dist/chunk-4Z4XNEWZ.js.map +0 -1
  445. package/dist/chunk-6FUPCJUL.js.map +0 -1
  446. package/dist/chunk-B6JDYXL7.js.map +0 -1
  447. package/dist/chunk-G5R3D5UP.js.map +0 -1
  448. package/dist/chunk-GBJ4RDFR.js.map +0 -1
  449. package/dist/chunk-HUHX2OCX.js.map +0 -1
  450. package/dist/chunk-IYZ5K7MU.js.map +0 -1
  451. package/dist/chunk-LGHKJABJ.js.map +0 -1
  452. package/dist/chunk-NHWB6HG2.js.map +0 -1
  453. package/dist/chunk-PHWUFPCO.js.map +0 -1
  454. package/dist/chunk-RPW2NOU6.js.map +0 -1
  455. package/dist/chunk-SPJXKAVF.js.map +0 -1
  456. package/dist/chunk-YNQBRLC5.js.map +0 -1
  457. package/dist/chunk-YTSNAUXN.js.map +0 -1
  458. /package/dist/{capsule-crypto-GWVG7LGC.js.map → access-extraction-force-flush.js.map} +0 -0
  459. /package/dist/{capsule-merge-5KKJQBWQ.js.map → capsule-merge-2H2IUTBT.js.map} +0 -0
  460. /package/dist/{chunk-LEPOP46W.js.map → chunk-227UFSEQ.js.map} +0 -0
  461. /package/dist/{chunk-I5NLEENJ.js.map → chunk-27HHNYSQ.js.map} +0 -0
  462. /package/dist/{chunk-2SA56WMI.js.map → chunk-2LTDWSR6.js.map} +0 -0
  463. /package/dist/{chunk-OWHERGF2.js.map → chunk-2NLLXCJG.js.map} +0 -0
  464. /package/dist/{chunk-P5PXWTW7.js.map → chunk-2Q4JJ3FZ.js.map} +0 -0
  465. /package/dist/{chunk-H5CPS5JP.js.map → chunk-35IVNNRK.js.map} +0 -0
  466. /package/dist/{chunk-LBOD4U5B.js.map → chunk-3EQ2XB3W.js.map} +0 -0
  467. /package/dist/{chunk-2EUVEDF5.js.map → chunk-5WZVQRHV.js.map} +0 -0
  468. /package/dist/{chunk-ALSGMEJR.js.map → chunk-65ZPVYTA.js.map} +0 -0
  469. /package/dist/{chunk-GIBMDSJ2.js.map → chunk-6P7MTSU5.js.map} +0 -0
  470. /package/dist/{chunk-5VQJBH2G.js.map → chunk-6TAUHL33.js.map} +0 -0
  471. /package/dist/{chunk-WVO4G37W.js.map → chunk-7TEZUUGM.js.map} +0 -0
  472. /package/dist/{chunk-MJCGLM25.js.map → chunk-7VUAG236.js.map} +0 -0
  473. /package/dist/{chunk-CZRYLSSW.js.map → chunk-AJL6NNX6.js.map} +0 -0
  474. /package/dist/{chunk-66772WBP.js.map → chunk-AQWVJURR.js.map} +0 -0
  475. /package/dist/{chunk-RKNJBZ55.js.map → chunk-AU7Q3LSC.js.map} +0 -0
  476. /package/dist/{chunk-M3C2V3PV.js.map → chunk-CJDNT45S.js.map} +0 -0
  477. /package/dist/{chunk-D2ANTDGO.js.map → chunk-E6BMSH7U.js.map} +0 -0
  478. /package/dist/{chunk-CKMO4RDY.js.map → chunk-EMDLM3LW.js.map} +0 -0
  479. /package/dist/{chunk-RGIWINDN.js.map → chunk-FHBITMRY.js.map} +0 -0
  480. /package/dist/{chunk-FDAMS4PK.js.map → chunk-G2YQ57YO.js.map} +0 -0
  481. /package/dist/{chunk-6U7F52DE.js.map → chunk-HFQQWAMS.js.map} +0 -0
  482. /package/dist/{chunk-5W4ZLBEZ.js.map → chunk-HKPJPOW7.js.map} +0 -0
  483. /package/dist/{chunk-JCBWCYEJ.js.map → chunk-IGWFKW4B.js.map} +0 -0
  484. /package/dist/{chunk-AITCS2RC.js.map → chunk-IJ7HK452.js.map} +0 -0
  485. /package/dist/{chunk-D3LMYTBV.js.map → chunk-J7WZUL2K.js.map} +0 -0
  486. /package/dist/{chunk-5W7CTZ2E.js.map → chunk-KQAFEZQX.js.map} +0 -0
  487. /package/dist/{chunk-Z54EM5YZ.js.map → chunk-MAXVH44E.js.map} +0 -0
  488. /package/dist/{chunk-WZFAPHIK.js.map → chunk-MU7ZHSZE.js.map} +0 -0
  489. /package/dist/{chunk-AZ5BTEKX.js.map → chunk-NQUF7XKR.js.map} +0 -0
  490. /package/dist/{chunk-W4FBGYGK.js.map → chunk-NRV4Y3PM.js.map} +0 -0
  491. /package/dist/{chunk-62U4J2GN.js.map → chunk-ODGOP7P2.js.map} +0 -0
  492. /package/dist/{chunk-QJAQNXWI.js.map → chunk-ONHRRJZM.js.map} +0 -0
  493. /package/dist/{chunk-ACXPX4AG.js.map → chunk-OPBTPRGY.js.map} +0 -0
  494. /package/dist/{chunk-XOZ4ALGB.js.map → chunk-QDTZ2HF7.js.map} +0 -0
  495. /package/dist/{chunk-ZPSVBSOF.js.map → chunk-QMWFQBIL.js.map} +0 -0
  496. /package/dist/{chunk-W5EG6LE3.js.map → chunk-THCPRMRF.js.map} +0 -0
  497. /package/dist/{chunk-VI2JQPNQ.js.map → chunk-U7QYBSQJ.js.map} +0 -0
  498. /package/dist/{chunk-TH2LSRMG.js.map → chunk-UORKJ34C.js.map} +0 -0
  499. /package/dist/{chunk-K5GB36ME.js.map → chunk-VMZ56EE3.js.map} +0 -0
  500. /package/dist/{chunk-RMMVQQA6.js.map → chunk-WDISJRMG.js.map} +0 -0
  501. /package/dist/{chunk-UVYI6VIX.js.map → chunk-X7Y7WX73.js.map} +0 -0
  502. /package/dist/{chunk-CVILPI77.js.map → chunk-XOQSEF7X.js.map} +0 -0
  503. /package/dist/{chunk-YTQNQ4KB.js.map → chunk-YX5LN6JR.js.map} +0 -0
  504. /package/dist/{chunk-IC6CBHCA.js.map → chunk-Z7XKUWYS.js.map} +0 -0
@@ -24,17 +24,19 @@
24
24
  * (`markConsumed`) under `serializeMutations` keyed by plan id (rule 40).
25
25
  */
26
26
 
27
+ import { throwIfAborted } from "../abort-error.js";
28
+ import { log } from "../logger.js";
27
29
  import { serializeMutations } from "../utils/serialize-mutations.js";
28
- import type { CorrectionPlanner } from "./correction-planner.js";
29
30
  import {
30
- CorrectionContractError,
31
- validateCorrectionAction,
32
- validateRedactionPattern,
33
31
  type CorrectionAction,
34
32
  type CorrectionActionResult,
33
+ CorrectionContractError,
35
34
  type CorrectionOutcome,
36
35
  type CorrectionPlan,
36
+ validateCorrectionAction,
37
+ validateRedactionPattern,
37
38
  } from "./correction-contract.js";
39
+ import type { CorrectionPlanner } from "./correction-planner.js";
38
40
 
39
41
  // ---------------------------------------------------------------------------
40
42
  // Injected collaborators
@@ -69,8 +71,7 @@ export interface ExecutorMemory {
69
71
  }
70
72
 
71
73
  export interface ExecutorDeps {
72
- /** Lookup a memory by id within the plan's namespace. null if not found. */
73
- getMemory(namespace: string, memoryId: string): Promise<ExecutorMemory | null>;
74
+ getMemory(namespace: string, memoryId: string, abortSignal?: AbortSignal): Promise<ExecutorMemory | null>;
74
75
  /**
75
76
  * Persist a NEW memory through the orchestrator's normal write pipeline
76
77
  * (catalog/reindex/dedup fire — rule 43). Returns the new memory id.
@@ -89,17 +90,14 @@ export interface ExecutorDeps {
89
90
  structuredAttributes?: Record<string, string>;
90
91
  supersedes?: string;
91
92
  },
93
+ abortSignal?: AbortSignal
92
94
  ): Promise<string>;
93
95
  /**
94
96
  * Apply a versioned edit to an existing memory (page-versioning — every
95
97
  * change revertable). Returns the memory id. The patch is the NEW full
96
98
  * content; the implementation snapshots the prior version.
97
99
  */
98
- applyEdit(
99
- namespace: string,
100
- memoryId: string,
101
- patch: string,
102
- ): Promise<string>;
100
+ applyEdit(namespace: string, memoryId: string, patch: string, abortSignal?: AbortSignal): Promise<string>;
103
101
  /**
104
102
  * Flip a memory's status to superseded/retracted and stamp `validUntil`
105
103
  * when bi-temporal is gated on (#1578). Idempotent.
@@ -112,13 +110,14 @@ export interface ExecutorDeps {
112
110
  supersededBy?: string;
113
111
  validUntil?: string;
114
112
  },
113
+ abortSignal?: AbortSignal
115
114
  ): Promise<void>;
116
115
  /**
117
116
  * Move a memory to a different namespace (rescope). The destination
118
117
  * namespace is re-authorized by the service before the executor runs; the
119
118
  * implementation performs the move atomically (write-then-unlink).
120
119
  */
121
- rescopeMemory(namespace: string, memoryId: string, toNamespace: string): Promise<string>;
120
+ rescopeMemory(namespace: string, memoryId: string, toNamespace: string, abortSignal?: AbortSignal): Promise<string>;
122
121
  /**
123
122
  * Append a tombstone (#1579) for a retired memory. Returns the tombstone
124
123
  * id, or null if tombstones are disabled (off = pre-feature behavior).
@@ -141,12 +140,13 @@ export interface ExecutorDeps {
141
140
  /** Canonical contentHash from the retired memory's frontmatter (#1672 item 4). */
142
141
  contentHash?: string;
143
142
  },
143
+ abortSignal?: AbortSignal
144
144
  ): Promise<string | null>;
145
145
  /**
146
146
  * Persist a redaction rule so extraction consults it the same way tombstones
147
147
  * are consulted (route through the same chokepoint check). Idempotent.
148
148
  */
149
- registerRedactionRule(namespace: string, pattern: string): Promise<void>;
149
+ registerRedactionRule(namespace: string, pattern: string, abortSignal?: AbortSignal): Promise<void>;
150
150
  /**
151
151
  * Append an audit record under `corrections/` (existing storage category)
152
152
  * capturing plan + outcome. Returns the audit memory id.
@@ -159,6 +159,7 @@ export interface ExecutorDeps {
159
159
  outcome: CorrectionOutcome;
160
160
  requestText: string;
161
161
  },
162
+ abortSignal?: AbortSignal
162
163
  ): Promise<string>;
163
164
  /**
164
165
  * Post-write propagation: QMD reindex for touched files (checklist §31),
@@ -166,7 +167,7 @@ export interface ExecutorDeps {
166
167
  * here is recorded as a warning, never as a failed action (propagation is
167
168
  * not part of the §14 non-destructive-order guarantee; it runs after).
168
169
  */
169
- propagate(namespace: string, touchedMemoryIds: readonly string[]): Promise<void>;
170
+ propagate(namespace: string, touchedMemoryIds: readonly string[], abortSignal?: AbortSignal): Promise<void>;
170
171
  /** Whether the bi-temporal gate (#1578) is on. When off, validUntil is omitted. */
171
172
  readonly biTemporalEnabled: boolean;
172
173
  /** Injected clock for deterministic tests. */
@@ -180,7 +181,7 @@ export interface ExecutorDeps {
180
181
  export class CorrectionExecutor {
181
182
  constructor(
182
183
  private readonly deps: ExecutorDeps,
183
- private readonly planner: CorrectionPlanner,
184
+ private readonly planner: CorrectionPlanner
184
185
  ) {}
185
186
 
186
187
  /**
@@ -192,6 +193,7 @@ export class CorrectionExecutor {
192
193
  planId: string,
193
194
  opts: {
194
195
  confirm: boolean;
196
+ abortSignal?: AbortSignal;
195
197
  /**
196
198
  * Authorize a rescope destination namespace. Bound per-request by the
197
199
  * service from the namespace policy + principal so a plan can never
@@ -200,34 +202,42 @@ export class CorrectionExecutor {
200
202
  * source namespace already resolves to a writable scope (single-tenant).
201
203
  */
202
204
  canWriteDestination?: (namespace: string) => Promise<boolean>;
203
- },
205
+ }
204
206
  ): Promise<CorrectionOutcome> {
207
+ throwIfAborted(opts.abortSignal, "correction apply aborted");
205
208
  if (!opts.confirm) {
206
209
  throw new CorrectionContractError(
207
- "Correction apply requires explicit confirmation (correction.applyRequiresConfirm).",
210
+ "Correction apply requires explicit confirmation (correction.applyRequiresConfirm)."
208
211
  );
209
212
  }
210
213
  // serializeMutations on the plan id so two concurrent applies of the SAME
211
214
  // plan serialize — the second observes the consumed status and rejects.
212
215
  return serializeMutations(`correction-apply:${namespace}:${planId}`, () =>
213
- this.applyInternal(namespace, planId, opts.canWriteDestination),
216
+ this.applyInternal(namespace, planId, opts.canWriteDestination, opts.abortSignal)
214
217
  );
215
218
  }
216
219
 
217
- private async applyInternal(namespace: string, planId: string, canWriteDestination?: (namespace: string) => Promise<boolean>): Promise<CorrectionOutcome> {
220
+ private async applyInternal(
221
+ namespace: string,
222
+ planId: string,
223
+ canWriteDestination?: (namespace: string) => Promise<boolean>,
224
+ abortSignal?: AbortSignal
225
+ ): Promise<CorrectionOutcome> {
226
+ throwIfAborted(abortSignal, "correction apply aborted");
218
227
  const plan = await this.planner.loadPlan(namespace, planId);
228
+ throwIfAborted(abortSignal, "correction apply aborted");
219
229
  if (!plan) {
220
230
  throw new CorrectionContractError(`Correction plan not found: ${planId}`);
221
231
  }
222
232
  if (plan.namespace !== namespace) {
223
233
  // Cross-namespace foreign-id guard (rule 42 / checklist §16).
224
234
  throw new CorrectionContractError(
225
- `Correction plan ${planId} belongs to namespace '${plan.namespace}', not '${namespace}'.`,
235
+ `Correction plan ${planId} belongs to namespace '${plan.namespace}', not '${namespace}'.`
226
236
  );
227
237
  }
228
238
  if (plan.status === "applied" || plan.status === "partial" || plan.status === "applying") {
229
239
  throw new CorrectionContractError(
230
- `Correction plan ${planId} has already been applied or is in progress (status=${plan.status}).`,
240
+ `Correction plan ${planId} has already been applied or is in progress (status=${plan.status}).`
231
241
  );
232
242
  }
233
243
  if (plan.status === "discarded") {
@@ -237,7 +247,7 @@ export class CorrectionExecutor {
237
247
  if (this.deps.now().getTime() > new Date(plan.expiresAt).getTime()) {
238
248
  await this.planner.markConsumed(namespace, planId, "discarded");
239
249
  throw new CorrectionContractError(
240
- `Correction plan ${planId} expired at ${plan.expiresAt} and has been discarded.`,
250
+ `Correction plan ${planId} expired at ${plan.expiresAt} and has been discarded.`
241
251
  );
242
252
  }
243
253
 
@@ -252,36 +262,109 @@ export class CorrectionExecutor {
252
262
  // Optimistically mark the plan `applying` BEFORE any mutation (review
253
263
  // thread OgIqt). If the process dies mid-apply — or the final
254
264
  // markConsumed("applied"|"partial") fails — the plan stays `applying`
255
- // and is NOT silently retryable. A partially-applied plan must never be
256
- // re-applied wholesale: re-running succeeded actions would duplicate
257
- // replacements, tombstones, and audits. The operator inspects the
258
- // outcome and files a NEW plan for any failed actions. This mark runs
259
- // inside the serializeMutations lock so concurrent applies serialize.
265
+ // and is NOT silently retryable. If cancellation arrives before the
266
+ // first mutation, reset the plan to `pending` so it remains actionable.
267
+ // A partially-applied plan must never be re-applied wholesale: re-running
268
+ // succeeded actions would duplicate replacements, tombstones, and audits.
269
+ // This mark runs inside the serializeMutations lock so concurrent applies serialize.
270
+ throwIfAborted(abortSignal, "correction apply aborted");
260
271
  try {
261
272
  await this.planner.markConsumed(namespace, planId, "applying");
262
273
  } catch {
263
274
  // If we cannot even mark the plan in-progress, the filesystem is
264
275
  // likely unwritable and mutations would fail too — fail closed now.
265
276
  throw new CorrectionContractError(
266
- `Correction plan ${planId}: cannot mark in-progress (filesystem unwritable?) — aborting before any mutation.`,
277
+ `Correction plan ${planId}: cannot mark in-progress (filesystem unwritable?) — aborting before any mutation.`
267
278
  );
268
279
  }
269
280
 
281
+ const resetApplying = async (): Promise<void> => {
282
+ try {
283
+ await this.planner.resetApplying(namespace, planId);
284
+ } catch (resetError) {
285
+ log.warn(
286
+ `Correction plan ${planId}: cancellation reset failed; leaving plan applying: ${
287
+ resetError instanceof Error ? resetError.message : String(resetError)
288
+ }`
289
+ );
290
+ }
291
+ };
292
+ try {
293
+ throwIfAborted(abortSignal, "correction apply aborted");
294
+ } catch (error) {
295
+ await resetApplying();
296
+ throw error;
297
+ }
298
+
270
299
  const results: CorrectionActionResult[] = [];
271
300
  const appliedTouched: string[] = [];
301
+ const retiredReplacementActions = new Set<CorrectionAction>();
302
+ const removeFailedResultsFor = (action: CorrectionAction): void => {
303
+ for (let i = results.length - 1; i >= 0; i -= 1) {
304
+ if (results[i]?.action === action && results[i]?.status === "failed") {
305
+ results.splice(i, 1);
306
+ }
307
+ }
308
+ };
309
+ let mutationCommitted = false;
310
+ let cancellationSafeAfterCommit = false;
311
+ let cancellationRequestedAfterCommit = false;
312
+ const throwIfAbortedBeforeCommit = (): void => {
313
+ if (!mutationCommitted || !cancellationSafeAfterCommit) {
314
+ throwIfAborted(abortSignal, "correction apply aborted");
315
+ }
316
+ };
317
+ const stopBeforeNewAction = async (): Promise<boolean> => {
318
+ if (!abortSignal?.aborted) return false;
319
+ if (!mutationCommitted) {
320
+ try {
321
+ throwIfAborted(abortSignal, "correction apply aborted");
322
+ } catch (error) {
323
+ await resetApplying();
324
+ throw error;
325
+ }
326
+ }
327
+ cancellationRequestedAfterCommit = true;
328
+ return true;
329
+ };
330
+ const throwIfAbortedBeforeCommitAndReset = async (): Promise<void> => {
331
+ try {
332
+ throwIfAbortedBeforeCommit();
333
+ } catch (error) {
334
+ if (!mutationCommitted) await resetApplying();
335
+ const reason = abortSignal?.reason;
336
+ if (reason instanceof Error && reason.name !== "AbortError") throw reason;
337
+ throw error;
338
+ }
339
+ };
272
340
 
273
341
  // ── Phase 1: replacement / edit writes (new state first) ───────────────
274
342
  // For each supersede with a replacement, write the replacement FIRST. If
275
343
  // the write fails, the loser is NOT superseded (§14: never destroy old
276
344
  // state for an action whose replacement write failed).
277
345
  for (const action of plan.actions) {
346
+ if (await stopBeforeNewAction()) break;
347
+
278
348
  if (action.kind === "supersede" && action.replacement) {
279
349
  // Preflight the loser BEFORE writing the replacement (review thread
280
350
  // Of0pz): if the loser was deleted between plan and apply, writing a
281
351
  // replacement creates an orphan fact that supersedes nothing. Phase 2
282
352
  // (retireAndTombstone) re-checks via getMemory, so verifying here
283
353
  // keeps the two phases in agreement and avoids the orphan write.
284
- const loser = await this.deps.getMemory(namespace, action.loserId);
354
+ let loser: ExecutorMemory | null;
355
+ try {
356
+ loser = await this.deps.getMemory(namespace, action.loserId, abortSignal);
357
+ } catch (error) {
358
+ if (abortSignal?.aborted) {
359
+ if (!mutationCommitted) {
360
+ await resetApplying();
361
+ throwIfAborted(abortSignal, "correction apply aborted");
362
+ }
363
+ cancellationRequestedAfterCommit = true;
364
+ break;
365
+ }
366
+ throw error;
367
+ }
285
368
  if (!loser) {
286
369
  results.push({
287
370
  action,
@@ -291,22 +374,52 @@ export class CorrectionExecutor {
291
374
  continue;
292
375
  }
293
376
  try {
294
- const newId = await this.deps.writeReplacement(namespace, {
295
- content: action.replacement.content,
296
- ...(action.replacement.category ? { category: action.replacement.category } : {}),
297
- ...(action.replacement.confidence !== undefined ? { confidence: action.replacement.confidence } : {}),
298
- ...(action.replacement.tags ? { tags: action.replacement.tags } : {}),
299
- ...(action.replacement.entityRef ? { entityRef: action.replacement.entityRef } : {}),
300
- ...(action.replacement.validAt ? { validAt: action.replacement.validAt } : {}),
301
- ...(action.replacement.observedAt ? { observedAt: action.replacement.observedAt } : {}),
302
- ...(action.replacement.structuredAttributes
303
- ? { structuredAttributes: action.replacement.structuredAttributes }
304
- : {}),
305
- supersedes: action.loserId,
306
- });
377
+ const newId = await this.deps.writeReplacement(
378
+ namespace,
379
+ {
380
+ content: action.replacement.content,
381
+ ...(action.replacement.category ? { category: action.replacement.category } : {}),
382
+ ...(action.replacement.confidence !== undefined ? { confidence: action.replacement.confidence } : {}),
383
+ ...(action.replacement.tags ? { tags: action.replacement.tags } : {}),
384
+ ...(action.replacement.entityRef ? { entityRef: action.replacement.entityRef } : {}),
385
+ ...(action.replacement.validAt ? { validAt: action.replacement.validAt } : {}),
386
+ ...(action.replacement.observedAt ? { observedAt: action.replacement.observedAt } : {}),
387
+ ...(action.replacement.structuredAttributes
388
+ ? { structuredAttributes: action.replacement.structuredAttributes }
389
+ : {}),
390
+ supersedes: action.loserId,
391
+ },
392
+ abortSignal
393
+ );
394
+ mutationCommitted = true;
307
395
  results.push({ action, status: "applied", memoryId: newId });
308
396
  appliedTouched.push(newId);
397
+ // A replacement and retirement form one non-destructive transaction.
398
+ // Once the replacement is durable, cancellation cannot interrupt the
399
+ // retirement half and leave both memories active. This remains inside
400
+ // the apply plan's serializeMutations lock.
401
+ const retirementResultBeforePhase2 = results.at(-1);
402
+ await this.retireAndTombstone(namespace, action, "supersession", results, appliedTouched, {
403
+ supersededBy: newId,
404
+ });
405
+ const retirementResult = results.at(-1);
406
+ if (
407
+ retirementResult !== retirementResultBeforePhase2 &&
408
+ retirementResult?.action === action &&
409
+ retirementResult.status === "applied"
410
+ ) {
411
+ retiredReplacementActions.add(action);
412
+ cancellationSafeAfterCommit = true;
413
+ }
309
414
  } catch (err) {
415
+ if (abortSignal?.aborted) {
416
+ if (!mutationCommitted) {
417
+ await resetApplying();
418
+ throw err;
419
+ }
420
+ cancellationRequestedAfterCommit = true;
421
+ break;
422
+ }
310
423
  results.push({
311
424
  action,
312
425
  status: "failed",
@@ -315,17 +428,46 @@ export class CorrectionExecutor {
315
428
  }
316
429
  } else if (action.kind === "edit") {
317
430
  try {
318
- const editedId = await this.deps.applyEdit(namespace, action.memoryId, action.patch);
431
+ const editedId = await this.deps.applyEdit(
432
+ namespace,
433
+ action.memoryId,
434
+ action.patch,
435
+ abortSignal
436
+ );
437
+ mutationCommitted = true;
438
+ cancellationSafeAfterCommit = true;
319
439
  results.push({ action, status: "applied", memoryId: editedId });
320
440
  appliedTouched.push(editedId);
321
441
  } catch (err) {
442
+ if (abortSignal?.aborted) {
443
+ if (!mutationCommitted) {
444
+ await resetApplying();
445
+ throw err;
446
+ }
447
+ cancellationRequestedAfterCommit = true;
448
+ break;
449
+ }
322
450
  results.push({ action, status: "failed", error: errMsg(err) });
323
451
  }
324
452
  } else if (action.kind === "redaction_rule") {
325
453
  try {
326
- await this.deps.registerRedactionRule(namespace, action.pattern);
454
+ await this.deps.registerRedactionRule(
455
+ namespace,
456
+ action.pattern,
457
+ abortSignal
458
+ );
459
+ mutationCommitted = true;
460
+ cancellationSafeAfterCommit = true;
327
461
  results.push({ action, status: "applied" });
328
462
  } catch (err) {
463
+ if (abortSignal?.aborted) {
464
+ if (!mutationCommitted) {
465
+ await resetApplying();
466
+ throw err;
467
+ }
468
+ cancellationRequestedAfterCommit = true;
469
+ break;
470
+ }
329
471
  results.push({ action, status: "failed", error: errMsg(err) });
330
472
  }
331
473
  }
@@ -335,19 +477,52 @@ export class CorrectionExecutor {
335
477
  // Only run for supersede/retract actions whose replacement write (if any)
336
478
  // succeeded. A supersede WITHOUT a replacement is a pure retract.
337
479
  for (const action of plan.actions) {
480
+ const needsPhase2Work =
481
+ action.kind === "retract" ||
482
+ action.kind === "rescope" ||
483
+ (action.kind === "supersede" && !retiredReplacementActions.has(action));
484
+ if (needsPhase2Work && (await stopBeforeNewAction())) break;
485
+ try {
486
+ if (action.kind === "supersede" && retiredReplacementActions.has(action)) continue;
338
487
  if (action.kind === "supersede") {
339
- const replacementResult = results.find(
340
- (r) => r.action === action && r.status === "applied",
341
- );
488
+ const replacementResult = results.find((r) => r.action === action && r.status === "applied");
342
489
  // If the replacement write failed, skip retirement (§14).
343
490
  if (action.replacement && !replacementResult) {
344
491
  continue;
345
492
  }
346
- await this.retireAndTombstone(namespace, action, "supersession", results, appliedTouched, {
347
- supersededBy: replacementResult?.memoryId,
348
- });
493
+ await this.retireAndTombstone(
494
+ namespace,
495
+ action,
496
+ "supersession",
497
+ results,
498
+ appliedTouched,
499
+ { supersededBy: replacementResult?.memoryId },
500
+ abortSignal
501
+ );
502
+ if (results.at(-1)?.status === "applied") {
503
+ mutationCommitted = true;
504
+ cancellationSafeAfterCommit = true;
505
+ }
506
+ if (results.at(-1)?.action === action && results.at(-1)?.status === "applied") {
507
+ removeFailedResultsFor(action);
508
+ }
349
509
  } else if (action.kind === "retract") {
350
- await this.retireAndTombstone(namespace, action, "retraction", results, appliedTouched);
510
+ await this.retireAndTombstone(
511
+ namespace,
512
+ action,
513
+ "retraction",
514
+ results,
515
+ appliedTouched,
516
+ {},
517
+ abortSignal
518
+ );
519
+ if (results.at(-1)?.status === "applied") {
520
+ mutationCommitted = true;
521
+ cancellationSafeAfterCommit = true;
522
+ }
523
+ if (results.at(-1)?.action === action && results.at(-1)?.status === "applied") {
524
+ removeFailedResultsFor(action);
525
+ }
351
526
  } else if (action.kind === "rescope") {
352
527
  try {
353
528
  // Authorize the destination namespace BEFORE the move — the plan's
@@ -364,7 +539,14 @@ export class CorrectionExecutor {
364
539
  });
365
540
  continue;
366
541
  }
367
- const destId = await this.deps.rescopeMemory(namespace, action.memoryId, action.toNamespace);
542
+ const destId = await this.deps.rescopeMemory(
543
+ namespace,
544
+ action.memoryId,
545
+ action.toNamespace,
546
+ abortSignal
547
+ );
548
+ mutationCommitted = true;
549
+ cancellationSafeAfterCommit = true;
368
550
  // #1678 (thread OiiV6): report the DESTINATION memory id, not the
369
551
  // source. The source is archived by the move; callers that re-fetch
370
552
  // the reported id need the live (destination) memory, otherwise they
@@ -374,15 +556,32 @@ export class CorrectionExecutor {
374
556
  // Propagate the destination memory in its namespace too (review
375
557
  // thread: propagate-rescoped-destination) — best-effort.
376
558
  try {
377
- await this.deps.propagate(action.toNamespace, [destId]);
559
+ await this.deps.propagate(action.toNamespace, [destId], undefined);
378
560
  } catch {
379
561
  // non-fatal — the source propagation still fires.
380
562
  }
381
563
  } catch (err) {
564
+ if (abortSignal?.aborted) {
565
+ if (!mutationCommitted) throw err;
566
+ cancellationRequestedAfterCommit = true;
567
+ break;
568
+ }
382
569
  results.push({ action, status: "failed", error: errMsg(err) });
383
570
  }
384
571
  }
572
+ } catch (err) {
573
+ if (abortSignal?.aborted) {
574
+ if (!mutationCommitted) {
575
+ await resetApplying();
576
+ throw err;
577
+ }
578
+ cancellationRequestedAfterCommit = true;
579
+ break;
580
+ }
581
+ throw err;
582
+ }
385
583
  }
584
+ await throwIfAbortedBeforeCommitAndReset();
386
585
 
387
586
  // ── Phase 3: propagation (post-write reindex + graph) ─────────────────
388
587
  // Best-effort: a propagation failure is recorded as a warning on the
@@ -390,15 +589,18 @@ export class CorrectionExecutor {
390
589
  const propagationWarnings: string[] = [];
391
590
  if (appliedTouched.length > 0) {
392
591
  try {
393
- await this.deps.propagate(namespace, appliedTouched);
592
+ await this.deps.propagate(namespace, appliedTouched, cancellationSafeAfterCommit ? undefined : abortSignal);
394
593
  } catch (err) {
594
+ if ((!mutationCommitted || !cancellationSafeAfterCommit) && abortSignal?.aborted) throw err;
395
595
  propagationWarnings.push(`propagation failed (non-fatal): ${errMsg(err)}`);
396
596
  }
397
597
  }
398
598
 
599
+ await throwIfAbortedBeforeCommitAndReset();
399
600
  // ── Phase 4: audit record ─────────────────────────────────────────────
400
601
  const anyFailed = results.some((r) => r.status === "failed");
401
- const status: CorrectionOutcome["status"] = anyFailed ? "partial" : "applied";
602
+ const status: CorrectionOutcome["status"] =
603
+ anyFailed || cancellationRequestedAfterCommit ? "partial" : "applied";
402
604
  const appliedAt = this.deps.now().toISOString();
403
605
  const outcome: CorrectionOutcome = {
404
606
  planId,
@@ -411,21 +613,28 @@ export class CorrectionExecutor {
411
613
  (outcome as CorrectionOutcome & { warnings?: string[] }).warnings = propagationWarnings;
412
614
  }
413
615
  try {
414
- const auditId = await this.deps.appendAuditRecord(namespace, {
415
- planId,
416
- classification: plan.classification,
417
- outcome,
418
- requestText: plan.request.text,
419
- });
616
+ const auditId = await this.deps.appendAuditRecord(
617
+ namespace,
618
+ {
619
+ planId,
620
+ classification: plan.classification,
621
+ outcome,
622
+ requestText: plan.request.text,
623
+ },
624
+ cancellationSafeAfterCommit ? undefined : abortSignal
625
+ );
420
626
  outcome.auditMemoryId = auditId;
421
627
  } catch (err) {
628
+ if ((!mutationCommitted || !cancellationSafeAfterCommit) && abortSignal?.aborted) throw err;
422
629
  // The audit record is part of the contract but a failure to write it
423
- // must NOT undo the applied corrections. Record as a warning.
630
+ // must NOT propagate applied corrections are already durable. Record
631
+ // as a warning instead.
424
632
  (outcome as CorrectionOutcome & { warnings?: string[] }).warnings = [
425
633
  ...propagationWarnings,
426
634
  `audit record write failed (non-fatal): ${errMsg(err)}`,
427
635
  ];
428
636
  }
637
+ await throwIfAbortedBeforeCommitAndReset();
429
638
 
430
639
  // ── Phase 5: mark plan consumed ───────────────────────────────────────
431
640
  // Corrections are already applied (phases 1-4 succeeded). A markConsumed
@@ -448,12 +657,12 @@ export class CorrectionExecutor {
448
657
  results: CorrectionActionResult[],
449
658
  appliedTouched: string[],
450
659
  opts: { supersededBy?: string } = {},
660
+ abortSignal?: AbortSignal
451
661
  ): Promise<void> {
452
- const memoryId =
453
- action.kind === "supersede" ? action.loserId : action.kind === "retract" ? action.memoryId : null;
662
+ const memoryId = action.kind === "supersede" ? action.loserId : action.kind === "retract" ? action.memoryId : null;
454
663
  if (!memoryId) return;
455
664
  try {
456
- const memory = await this.deps.getMemory(namespace, memoryId);
665
+ const memory = await this.deps.getMemory(namespace, memoryId, abortSignal);
457
666
  if (!memory) {
458
667
  results.push({
459
668
  action,
@@ -469,27 +678,39 @@ export class CorrectionExecutor {
469
678
  // operates on un-mutated state with no resurrection window. A tombstone
470
679
  // for a still-active memory (if retire later fails) is benign — it only
471
680
  // blocks re-ingestion of the same content, which is exactly the intent.
472
- const tombstoneId = await this.deps.appendTombstone(namespace, {
473
- reason,
474
- sourceMemoryId: memoryId,
475
- rawContent: memory.rawContent,
476
- ...(memory.entityRef ? { entityRef: memory.entityRef } : {}),
477
- ...(memory.supersessionKey ? { supersessionKey: memory.supersessionKey } : {}),
478
- // #1672 item 4: carry the canonical contentHash (exact tier) and the
479
- // full supersession-key set (keyed tier) so paraphrased re-observations
480
- // of the same supersession identity are blocked, not just the literal
481
- // body. Without these the tombstone projected from a structured fact
482
- // dropped both fields and the fact could resurrect.
483
- ...(memory.contentHash ? { contentHash: memory.contentHash } : {}),
484
- ...(memory.supersessionKeys && memory.supersessionKeys.length > 0
485
- ? { supersessionKeys: memory.supersessionKeys }
486
- : {}),
487
- });
488
- await this.deps.retireMemory(namespace, memoryId, {
489
- status: reason === "supersession" ? "superseded" : "retracted",
490
- ...(opts.supersededBy ? { supersededBy: opts.supersededBy } : {}),
491
- ...(validUntil ? { validUntil } : {}),
492
- });
681
+ const tombstoneId = await this.deps.appendTombstone(
682
+ namespace,
683
+ {
684
+ reason,
685
+ sourceMemoryId: memoryId,
686
+ rawContent: memory.rawContent,
687
+ ...(memory.entityRef ? { entityRef: memory.entityRef } : {}),
688
+ ...(memory.supersessionKey ? { supersessionKey: memory.supersessionKey } : {}),
689
+ // #1672 item 4: carry the canonical contentHash (exact tier) and the
690
+ // full supersession-key set (keyed tier) so paraphrased re-observations
691
+ // of the same supersession identity are blocked, not just the literal
692
+ // body. Without these the tombstone projected from a structured fact
693
+ // dropped both fields and the fact could resurrect.
694
+ ...(memory.contentHash ? { contentHash: memory.contentHash } : {}),
695
+ ...(memory.supersessionKeys && memory.supersessionKeys.length > 0
696
+ ? { supersessionKeys: memory.supersessionKeys }
697
+ : {}),
698
+ },
699
+ abortSignal
700
+ );
701
+ // A committed tombstone and source retirement form one transaction from
702
+ // the caller's point of view. Once append succeeds, cancellation must
703
+ // not prevent retirement and leave an active source behind the block.
704
+ await this.deps.retireMemory(
705
+ namespace,
706
+ memoryId,
707
+ {
708
+ status: reason === "supersession" ? "superseded" : "retracted",
709
+ ...(opts.supersededBy ? { supersededBy: opts.supersededBy } : {}),
710
+ ...(validUntil ? { validUntil } : {}),
711
+ },
712
+ tombstoneId === null ? abortSignal : undefined
713
+ );
493
714
  results.push({
494
715
  action,
495
716
  status: "applied",
@@ -498,6 +719,7 @@ export class CorrectionExecutor {
498
719
  });
499
720
  appliedTouched.push(memoryId);
500
721
  } catch (err) {
722
+ if (abortSignal?.aborted) throw err;
501
723
  results.push({ action, status: "failed", error: errMsg(err) });
502
724
  }
503
725
  }
@@ -522,9 +744,7 @@ export function sanitizeErrorMessage(raw: string): string {
522
744
  .replace(/(^|[\s:'"(])\/(?:[^\s'">)\\]+\/)+[^\s'">)\\]*/g, "$1<path>")
523
745
  .replace(/(^|[\s:'"(])[A-Za-z]:\\[^\s'">)\\]+(?:\\[^\s'">) ]*)*/g, "$1<path>");
524
746
  const trimmed = stripped.trim();
525
- return trimmed.length > CORRECTION_ERROR_MAX
526
- ? `${trimmed.slice(0, CORRECTION_ERROR_MAX)}…`
527
- : trimmed;
747
+ return trimmed.length > CORRECTION_ERROR_MAX ? `${trimmed.slice(0, CORRECTION_ERROR_MAX)}…` : trimmed;
528
748
  }
529
749
 
530
750
  function errMsg(err: unknown): string {