@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
@@ -8,6 +8,7 @@ import {
8
8
  Orchestrator,
9
9
  } from "./orchestrator.js";
10
10
  import { ExtractionQueueCoordinator } from "./orchestration/extraction-queue-coordinator.js";
11
+ import { TurnIngestionCoordinator } from "./orchestration/turn-ingestion.js";
11
12
  import { SmartBuffer } from "./buffer.js";
12
13
  import { parseConfig } from "./config.js";
13
14
  import { stableHash } from "./coding/git-context.js";
@@ -17,15 +18,39 @@ import { namespaceIdentityToken } from "./namespaces/identity.js";
17
18
  import { readNamespaceMaintenanceStatuses } from "./maintenance/namespace-planner.js";
18
19
  import { stubPersistExtraction } from "./testing/orchestrator-lite.js";
19
20
 
20
- function makeTurn(sessionKey: string, content: string): BufferTurn {
21
+ function makeTurn(sessionKey: string, content: string, sessionOwnerPrincipal?: string): BufferTurn {
21
22
  return {
22
23
  role: "user",
23
24
  content,
24
25
  timestamp: "2026-04-12T12:00:00.000Z",
25
26
  sessionKey,
27
+ ...(sessionOwnerPrincipal ? { sessionOwnerPrincipal } : {}),
26
28
  };
27
29
  }
28
30
 
31
+ interface ScopedFlushTestDouble {
32
+ buffer: {
33
+ getTurns(bufferKey: string): BufferTurn[];
34
+ };
35
+ queueBufferedExtraction(
36
+ turns: BufferTurn[],
37
+ reason: string,
38
+ options?: Record<string, unknown>,
39
+ ): Promise<void>;
40
+ flushSession(
41
+ sessionKey: string,
42
+ options: {
43
+ reason: string;
44
+ abortSignal?: AbortSignal;
45
+ bufferKey?: string;
46
+ extractionDeadlineMs?: number;
47
+ writeNamespaceOverride?: string;
48
+ failOnExtractionFailure?: boolean;
49
+ principalOverride?: string;
50
+ },
51
+ ): Promise<void>;
52
+ }
53
+
29
54
  test("flushSession queues extraction for the targeted buffered session", async () => {
30
55
  const orchestrator = Object.create(Orchestrator.prototype) as any;
31
56
  const turns = [makeTurn("thread-a", "remember alpha")];
@@ -34,6 +59,7 @@ test("flushSession queues extraction for the targeted buffered session", async (
34
59
  reason: string;
35
60
  options: Record<string, unknown> | undefined;
36
61
  } | null = null;
62
+ let committed = 0;
37
63
 
38
64
  orchestrator.buffer = {
39
65
  getTurns(bufferKey: string) {
@@ -46,10 +72,16 @@ test("flushSession queues extraction for the targeted buffered session", async (
46
72
  options?: Record<string, unknown>,
47
73
  ) => {
48
74
  queued = { turns: queuedTurns, reason, options };
75
+ (options?.onDurableCommit as (() => void) | undefined)?.();
49
76
  (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
50
77
  };
51
-
52
- await orchestrator.flushSession("thread-a", { reason: "before_reset" });
78
+ await orchestrator.flushSession("thread-a", {
79
+ reason: "access_force_flush",
80
+ failOnExtractionFailure: true,
81
+ onCommitted: () => {
82
+ committed += 1;
83
+ },
84
+ });
53
85
 
54
86
  assert.ok(queued);
55
87
  const queuedCall = queued as {
@@ -61,7 +93,9 @@ test("flushSession queues extraction for the targeted buffered session", async (
61
93
  assert.equal(queuedCall.reason, "trigger_mode");
62
94
  assert.equal(queuedCall.options?.clearBufferAfterExtraction, true);
63
95
  assert.equal(queuedCall.options?.skipDedupeCheck, true);
96
+ assert.equal(queuedCall.options?.failOnExtractionFailure, true);
64
97
  assert.equal(queuedCall.options?.abortSignal, undefined);
98
+ assert.equal(committed, 1);
65
99
  });
66
100
 
67
101
  test("flushSession is a no-op when the targeted buffer is empty", async () => {
@@ -109,6 +143,178 @@ test("flushSession forwards abort signals into the queued extraction", async ()
109
143
  assert.equal(queuedOptions?.abortSignal, abortController.signal);
110
144
  });
111
145
 
146
+ test("flushSession preserves scoped force-drain routing and deadline options", async () => {
147
+ const orchestrator = Object.create(Orchestrator.prototype) as unknown as ScopedFlushTestDouble;
148
+ const abortController = new AbortController();
149
+ const extractionDeadlineMs = Date.now() + 10_000;
150
+ let queuedOptions: Record<string, unknown> | undefined;
151
+
152
+ orchestrator.buffer = {
153
+ getTurns(bufferKey: string) {
154
+ return bufferKey === "logical-session" ? [makeTurn("session-z", "remember gamma", "alice")] : [];
155
+ },
156
+ };
157
+ orchestrator.queueBufferedExtraction = async (
158
+ _queuedTurns: BufferTurn[],
159
+ _reason: string,
160
+ options?: Record<string, unknown>,
161
+ ) => {
162
+ queuedOptions = options;
163
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
164
+ };
165
+
166
+ await orchestrator.flushSession("session-z", {
167
+ reason: "access_force_flush",
168
+ bufferKey: "logical-session",
169
+ abortSignal: abortController.signal,
170
+ extractionDeadlineMs,
171
+ writeNamespaceOverride: "alice-project-example",
172
+ principalOverride: "alice",
173
+ });
174
+
175
+ assert.equal(queuedOptions?.bufferKey, "logical-session");
176
+ assert.equal(queuedOptions?.abortSignal, abortController.signal);
177
+ assert.equal(queuedOptions?.extractionDeadlineMs, extractionDeadlineMs);
178
+ assert.equal(queuedOptions?.writeNamespaceOverride, "alice-project-example");
179
+ assert.equal(queuedOptions?.principalOverride, "alice");
180
+ assert.equal(queuedOptions?.skipDedupeCheck, true);
181
+ assert.equal(queuedOptions?.skipCharThreshold, true);
182
+ assert.equal(queuedOptions?.skipUserTurnThreshold, true);
183
+ assert.equal(queuedOptions?.forceExtractionAttempt, true);
184
+ assert.equal(queuedOptions?.clearBufferAfterExtraction, true);
185
+ });
186
+
187
+ test("flushSession preserves retained context for other scoped sessions", async () => {
188
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
189
+ let retainedTurns = [
190
+ makeTurn("session-z", "old session A context", "alice"),
191
+ makeTurn("session-y", "session B context", "bob"),
192
+ ];
193
+ orchestrator.config = parseConfig({ namespacesEnabled: true });
194
+ orchestrator.buffer = {
195
+ flushPendingSave: async () => {},
196
+ findBufferKeysForSession: async () => ["provider-thread"],
197
+ getTurns: (bufferKey: string) =>
198
+ bufferKey === "provider-thread" ? [makeTurn("session-z", "active session A", "alice")] : [],
199
+ getRetainedDeferredTurns: (bufferKey: string) =>
200
+ bufferKey === "provider-thread" ? retainedTurns : [],
201
+ retainDeferredTurns: async (_bufferKey: string, turns: BufferTurn[]) => {
202
+ retainedTurns = turns;
203
+ },
204
+ };
205
+ orchestrator.queueBufferedExtraction = async (
206
+ _queuedTurns: BufferTurn[],
207
+ _reason: string,
208
+ options?: Record<string, unknown>,
209
+ ) => {
210
+ retainedTurns = [makeTurn("session-z", "new session A context", "alice")];
211
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
212
+ };
213
+
214
+ await orchestrator.flushSession("session-z", {
215
+ reason: "access_force_flush",
216
+ writeNamespaceOverride: "alice-project",
217
+ principalOverride: "alice",
218
+ });
219
+
220
+ assert.ok(retainedTurns.some((turn) => turn.content === "session B context"));
221
+ assert.ok(retainedTurns.some((turn) => turn.content === "new session A context"));
222
+ });
223
+
224
+ test("flushSession keeps all other-session retained turns ahead of the scoped cap", async () => {
225
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
226
+ const otherSessionTurns = Array.from({ length: 10 }, (_, index) =>
227
+ makeTurn("session-y", `session B context ${index}`, "bob"),
228
+ );
229
+ let retainedTurns = [...otherSessionTurns];
230
+ orchestrator.config = parseConfig({ namespacesEnabled: true });
231
+ orchestrator.buffer = {
232
+ flushPendingSave: async () => {},
233
+ findBufferKeysForSession: async () => ["provider-thread"],
234
+ getTurns: (bufferKey: string) =>
235
+ bufferKey === "provider-thread" ? [makeTurn("session-z", "active session A", "alice")] : [],
236
+ getRetainedDeferredTurns: (bufferKey: string) =>
237
+ bufferKey === "provider-thread" ? retainedTurns : [],
238
+ retainDeferredTurns: async (_bufferKey: string, turns: BufferTurn[], max = 10) => {
239
+ retainedTurns = turns.slice(-max);
240
+ },
241
+ };
242
+ orchestrator.queueBufferedExtraction = async (
243
+ _queuedTurns: BufferTurn[],
244
+ _reason: string,
245
+ options?: Record<string, unknown>,
246
+ ) => {
247
+ retainedTurns = [makeTurn("session-z", "new session A context", "alice")];
248
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
249
+ };
250
+
251
+ await orchestrator.flushSession("session-z", {
252
+ reason: "access_force_flush",
253
+ writeNamespaceOverride: "alice-project",
254
+ principalOverride: "alice",
255
+ });
256
+
257
+ assert.deepEqual(
258
+ retainedTurns.map((turn) => turn.content),
259
+ otherSessionTurns.map((turn) => turn.content),
260
+ );
261
+ });
262
+
263
+
264
+ test("flushSession rejects opaque buffers without trusted ownership", async () => {
265
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
266
+ let queued = false;
267
+ orchestrator.config = parseConfig({ namespacesEnabled: true });
268
+ orchestrator.buffer = {
269
+ flushPendingSave: async () => {},
270
+ findBufferKeysForSession: async () => ["provider-thread"],
271
+ getTurns: (bufferKey: string) =>
272
+ bufferKey === "provider-thread" ? [makeTurn("opaque-session", "remember gamma")] : [],
273
+ };
274
+ orchestrator.queueBufferedExtraction = async () => {
275
+ queued = true;
276
+ };
277
+
278
+ await assert.rejects(
279
+ orchestrator.flushSession("opaque-session", {
280
+ reason: "access_force_flush",
281
+ failOnExtractionFailure: true,
282
+ writeNamespaceOverride: "alice-project",
283
+ principalOverride: "alice",
284
+ }),
285
+ /without trusted ownership/,
286
+ );
287
+ assert.equal(queued, false);
288
+ });
289
+ test("flushSession skips scoped ownership enforcement when namespaces are disabled", async () => {
290
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
291
+ let queued = false;
292
+ orchestrator.config = parseConfig({ namespacesEnabled: false });
293
+ orchestrator.buffer = {
294
+ flushPendingSave: async () => {},
295
+ findBufferKeysForSession: async () => ["provider-thread"],
296
+ getTurns: (bufferKey: string) =>
297
+ bufferKey === "provider-thread" ? [makeTurn("opaque-session", "remember gamma")] : [],
298
+ };
299
+ orchestrator.queueBufferedExtraction = async (
300
+ _turns: BufferTurn[],
301
+ _reason: string,
302
+ options?: Record<string, unknown>,
303
+ ) => {
304
+ queued = true;
305
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
306
+ };
307
+
308
+ await orchestrator.flushSession("opaque-session", {
309
+ reason: "access_force_flush",
310
+ failOnExtractionFailure: true,
311
+ writeNamespaceOverride: "default",
312
+ principalOverride: "alice",
313
+ });
314
+
315
+ assert.equal(queued, true);
316
+ });
317
+
112
318
  test("flushSession waits for queued extraction task completion", async () => {
113
319
  const orchestrator = Object.create(Orchestrator.prototype) as any;
114
320
  let releaseExtraction!: () => void;
@@ -146,6 +352,7 @@ test("flushSession waits for queued extraction task completion", async () => {
146
352
  assert.equal(flushSettled, true);
147
353
  });
148
354
 
355
+
149
356
  test("flushSession flushes the pending debounced buffer save before extraction, so keep_buffering turns survive a failed/timed-out extraction (issue #1909, PR #2016)", async () => {
150
357
  // Regression: in steady-state debounced buffering a `keep_buffering` turn only
151
358
  // SCHEDULES a trailing-edge save, so the newest turns live only in memory
@@ -214,6 +421,119 @@ test("flushSession flushes the pending debounced buffer save before extraction,
214
421
  assert.equal(entryTurns.length, 1, "keep_buffering turn is durable after failed flush");
215
422
  assert.equal(entryTurns[0]?.content, "remember alpha");
216
423
  });
424
+ test("queued extraction settles immediately when its caller aborts while waiting", async () => {
425
+ const queue = new ExtractionQueueCoordinator();
426
+ let extractionStarted = false;
427
+ let releaseExtraction!: () => void;
428
+ const coordinator = new TurnIngestionCoordinator({
429
+ extractionQueueCoordinator: queue,
430
+ shouldQueueExtraction: () => true,
431
+ runExtraction: async () => {
432
+ extractionStarted = true;
433
+ await new Promise<void>((resolve) => {
434
+ releaseExtraction = resolve;
435
+ });
436
+ return {
437
+ status: "skipped",
438
+ reason: "test",
439
+ persistedCount: 0,
440
+ durableOutputCount: 0,
441
+ };
442
+ },
443
+ } as any);
444
+ const turns = [makeTurn("thread-a", "remember alpha")];
445
+
446
+ await coordinator.queueBufferedExtraction(turns, "trigger_mode", {
447
+ skipDedupeCheck: true,
448
+ });
449
+ for (let i = 0; i < 50 && !extractionStarted; i++) {
450
+ await new Promise<void>((resolve) => setImmediate(resolve));
451
+ }
452
+ assert.equal(extractionStarted, true, "the first extraction must occupy the queue");
453
+
454
+ const abortController = new AbortController();
455
+ const abortReason = new Error("caller disconnected");
456
+ const settled = Promise.withResolvers<unknown>();
457
+ await coordinator.queueBufferedExtraction(turns, "trigger_mode", {
458
+ skipDedupeCheck: true,
459
+ abortSignal: abortController.signal,
460
+ onTaskSettled: (error) => settled.resolve(error),
461
+ });
462
+
463
+ abortController.abort(abortReason);
464
+ assert.equal(await settled.promise, abortReason);
465
+
466
+ releaseExtraction();
467
+ assert.equal(await queue.waitForIdle(1_000), true);
468
+ });
469
+
470
+
471
+ test("flushSession aborts a blocked pre-drain save before queueing extraction", async () => {
472
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
473
+ const abortController = new AbortController();
474
+ let releaseSave!: () => void;
475
+ let saveStarted!: () => void;
476
+ const saveReady = new Promise<void>((resolve) => {
477
+ saveStarted = resolve;
478
+ });
479
+ let queued = false;
480
+
481
+ orchestrator.buffer = {
482
+ flushPendingSave: async () => {
483
+ saveStarted();
484
+ await new Promise<void>((resolve) => {
485
+ releaseSave = resolve;
486
+ });
487
+ },
488
+ findBufferKeysForSession: async () => ["thread-a"],
489
+ getTurns: () => [makeTurn("thread-a", "remember alpha")],
490
+ };
491
+ orchestrator.queueBufferedExtraction = async () => {
492
+ queued = true;
493
+ };
494
+
495
+ const flushPromise = orchestrator.flushSession("thread-a", {
496
+ reason: "access_force_flush",
497
+ abortSignal: abortController.signal,
498
+ extractionDeadlineMs: Date.now() + 10_000,
499
+ });
500
+ await saveReady;
501
+ abortController.abort();
502
+ await assert.rejects(flushPromise, /extraction force-flush aborted/);
503
+ assert.equal(queued, false);
504
+ releaseSave();
505
+ });
506
+
507
+ test("flushSession applies its deadline to a blocked pre-drain save", async () => {
508
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
509
+ let releaseSave!: () => void;
510
+ let queued = false;
511
+ const keepAlive = setInterval(() => undefined, 1_000);
512
+
513
+ orchestrator.buffer = {
514
+ flushPendingSave: async () =>
515
+ await new Promise<void>((resolve) => {
516
+ releaseSave = resolve;
517
+ }),
518
+ findBufferKeysForSession: async () => ["thread-a"],
519
+ getTurns: () => [makeTurn("thread-a", "remember alpha")],
520
+ };
521
+ orchestrator.queueBufferedExtraction = async () => {
522
+ queued = true;
523
+ };
524
+
525
+ try {
526
+ const flushPromise = orchestrator.flushSession("thread-a", {
527
+ reason: "access_force_flush",
528
+ extractionDeadlineMs: Date.now() + 25,
529
+ });
530
+ await assert.rejects(flushPromise, /replay extraction deadline exceeded \(before_buffer_flush\)/);
531
+ assert.equal(queued, false);
532
+ } finally {
533
+ clearInterval(keepAlive);
534
+ releaseSave?.();
535
+ }
536
+ });
217
537
 
218
538
  test("flushSession rejects and skips extraction when the durable buffer save fails, leaving turns and pending state intact (issue #1909, PR #2016)", async () => {
219
539
  // Fail-closed regression: if the pending debounced save cannot land durably,
@@ -331,6 +651,39 @@ test("ingestBulkImportBatch rejects when the extraction deadline expires in the
331
651
  );
332
652
  });
333
653
 
654
+ test("queued extraction clamps long deadline timers to the Node setTimeout limit", async () => {
655
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
656
+ orchestrator.config = parseConfig({});
657
+ orchestrator.extractionQueueCoordinator = new ExtractionQueueCoordinator();
658
+ orchestrator.extractionQueueCoordinator.setProcessingForTest(true);
659
+ orchestrator.runExtraction = async () => ({
660
+ status: "completed",
661
+ persistedCount: 0,
662
+ durableOutputCount: 0,
663
+ });
664
+
665
+ const timerGlobal = globalThis as unknown as { setTimeout: typeof setTimeout };
666
+ const realSetTimeout = timerGlobal.setTimeout;
667
+ const armedDelays: number[] = [];
668
+ timerGlobal.setTimeout = ((handler: (...args: unknown[]) => void, delay?: number, ...args: unknown[]) => {
669
+ if (typeof delay === "number") armedDelays.push(delay);
670
+ return realSetTimeout(handler, delay, ...args);
671
+ }) as typeof setTimeout;
672
+ try {
673
+ const pending = orchestrator.ingestBulkImportBatch(
674
+ [{ role: "user", timestamp: "2026-06-24T12:00:00.000Z", content: "Remember this long-deadline import." }],
675
+ { deadlineMs: Date.now() + 2_147_483_647 + 60_000, failOnExtractionFailure: true },
676
+ );
677
+ const queuedTask = orchestrator.extractionQueueCoordinator.shift();
678
+ assert.ok(queuedTask);
679
+ await queuedTask();
680
+ await pending;
681
+ } finally {
682
+ timerGlobal.setTimeout = realSetTimeout;
683
+ }
684
+ assert.ok(armedDelays.includes(2_147_483_647), `expected a clamped queue timer, got ${armedDelays.join(", ")}`);
685
+ });
686
+
334
687
  test("ingestBulkImportBatch does not report queue wait timeout after extraction starts", async () => {
335
688
  const orchestrator = Object.create(Orchestrator.prototype) as any;
336
689
  orchestrator.config = parseConfig({});
@@ -767,6 +1120,144 @@ test("flushSession drains every discovered buffer for the session", async () =>
767
1120
  ]);
768
1121
  });
769
1122
 
1123
+ test("flushSession filters shared-buffer turns before scoped extraction", async () => {
1124
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1125
+ const ownedTurn = makeTurn("session-z", "remember owned", "session-z");
1126
+ const foreignTurn = makeTurn("session-other", "remember foreign", "session-other");
1127
+ let queuedTurns: BufferTurn[] = [];
1128
+ let queuedOptions: Record<string, unknown> | undefined;
1129
+
1130
+ orchestrator.buffer = {
1131
+ async findBufferKeysForSession() {
1132
+ return ["codex-thread:shared"];
1133
+ },
1134
+ getTurns() {
1135
+ return [ownedTurn, foreignTurn];
1136
+ },
1137
+ };
1138
+ orchestrator.queueBufferedExtraction = async (
1139
+ turns: BufferTurn[],
1140
+ _reason: string,
1141
+ options?: Record<string, unknown>,
1142
+ ) => {
1143
+ queuedTurns = turns;
1144
+ queuedOptions = options;
1145
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
1146
+ };
1147
+
1148
+ await orchestrator.flushSession("session-z", {
1149
+ reason: "access_force_flush",
1150
+ writeNamespaceOverride: "session-z-project",
1151
+ principalOverride: "session-z",
1152
+ });
1153
+
1154
+ assert.deepEqual(queuedTurns, [ownedTurn]);
1155
+ assert.equal(queuedOptions?.clearMatchingTurns, true);
1156
+ });
1157
+
1158
+ test("flushSession filters shared-buffer turns when namespace capability is disabled", async () => {
1159
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1160
+ const ownedTurn = makeTurn("session-z", "remember owned");
1161
+ const foreignTurn = makeTurn("session-other", "remember foreign");
1162
+ let queuedTurns: BufferTurn[] = [];
1163
+
1164
+ orchestrator.config = parseConfig({ namespacesEnabled: false });
1165
+ orchestrator.buffer = {
1166
+ async findBufferKeysForSession() {
1167
+ return ["codex-thread:shared"];
1168
+ },
1169
+ getTurns() {
1170
+ return [ownedTurn, foreignTurn];
1171
+ },
1172
+ };
1173
+ orchestrator.queueBufferedExtraction = async (
1174
+ turns: BufferTurn[],
1175
+ _reason: string,
1176
+ options?: Record<string, unknown>,
1177
+ ) => {
1178
+ queuedTurns = turns;
1179
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
1180
+ };
1181
+
1182
+ await orchestrator.flushSession("session-z", {
1183
+ reason: "access_force_flush",
1184
+ writeNamespaceOverride: "default",
1185
+ });
1186
+
1187
+ assert.deepEqual(queuedTurns, [ownedTurn]);
1188
+ });
1189
+
1190
+ test("flushSession honors persisted ownership for opaque sessions", async () => {
1191
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1192
+ const ownedTurn = makeTurn("opaque-session", "remember owned", "alice");
1193
+ const foreignTurn = makeTurn("opaque-session", "remember foreign", "bob");
1194
+ let queuedTurns: BufferTurn[] = [];
1195
+
1196
+ orchestrator.buffer = {
1197
+ async findBufferKeysForSession() {
1198
+ return ["codex-thread:shared"];
1199
+ },
1200
+ getTurns() {
1201
+ return [ownedTurn, foreignTurn];
1202
+ },
1203
+ };
1204
+ orchestrator.queueBufferedExtraction = async (
1205
+ turns: BufferTurn[],
1206
+ _reason: string,
1207
+ options?: Record<string, unknown>,
1208
+ ) => {
1209
+ queuedTurns = turns;
1210
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
1211
+ };
1212
+
1213
+ await orchestrator.flushSession("opaque-session", {
1214
+ reason: "access_force_flush",
1215
+ writeNamespaceOverride: "alice-project",
1216
+ principalOverride: "alice",
1217
+ });
1218
+
1219
+ assert.deepEqual(queuedTurns, [ownedTurn]);
1220
+ });
1221
+
1222
+ test("flushSession preserves unstamped turns for a principal-keyed session", async () => {
1223
+ const config = parseConfig({
1224
+ namespacesEnabled: true,
1225
+ defaultNamespace: "default",
1226
+ sharedNamespace: "shared",
1227
+ principalFromSessionKeyMode: "prefix",
1228
+ principalFromSessionKeyRules: [{ match: "alice:", principal: "alice" }],
1229
+ });
1230
+ const orchestrator = Object.create(Orchestrator.prototype) as any;
1231
+ orchestrator.config = config;
1232
+ const unstampedTurn = makeTurn("alice:chat", "remember host-hook turn");
1233
+ let queuedTurns: BufferTurn[] = [];
1234
+
1235
+ orchestrator.buffer = {
1236
+ async findBufferKeysForSession() {
1237
+ return ["codex-thread:shared"];
1238
+ },
1239
+ getTurns() {
1240
+ return [unstampedTurn];
1241
+ },
1242
+ };
1243
+ orchestrator.queueBufferedExtraction = async (
1244
+ turns: BufferTurn[],
1245
+ _reason: string,
1246
+ options?: Record<string, unknown>,
1247
+ ) => {
1248
+ queuedTurns = turns;
1249
+ (options?.onTaskSettled as ((error?: unknown) => void) | undefined)?.();
1250
+ };
1251
+
1252
+ await orchestrator.flushSession("alice:chat", {
1253
+ reason: "access_force_flush",
1254
+ writeNamespaceOverride: "alice-project",
1255
+ principalOverride: "alice",
1256
+ });
1257
+
1258
+ assert.deepEqual(queuedTurns, [unstampedTurn]);
1259
+ });
1260
+
770
1261
  test("runExtraction skips active scope profile writes when no layer is writable", async () => {
771
1262
  const config = parseConfig({
772
1263
  namespacesEnabled: true,
@@ -1290,7 +1781,7 @@ test("runExtraction preserves empty-result buffers when fingerprint persistence
1290
1781
  assert.equal(clearCalls, 0);
1291
1782
  });
1292
1783
 
1293
- test("runExtraction preserves deduped buffers when the caller aborts before clearing", async () => {
1784
+ test("runExtraction preserves deduped buffers when the caller aborts during meta load", async () => {
1294
1785
  const config = parseConfig({});
1295
1786
  config.extractionMinChars = 0;
1296
1787
  config.extractionMinUserTurns = 1;
@@ -1357,7 +1848,7 @@ test("runExtraction preserves deduped buffers when the caller aborts before clea
1357
1848
  abortSignal: abortController.signal,
1358
1849
  },
1359
1850
  ),
1360
- /extraction aborted \(before_clear_buffer\)/,
1851
+ /extraction aborted \(during_load_meta\)/,
1361
1852
  );
1362
1853
 
1363
1854
  assert.equal(clearCalls, 0);
@@ -2002,6 +2493,9 @@ test("runExtraction still clears the session buffer after persistence even if re
2002
2493
  config.extractionMinUserTurns = 1;
2003
2494
 
2004
2495
  let clearCalls = 0;
2496
+ let retentionCalls = 0;
2497
+ let passiveCaptureCalls = 0;
2498
+ let tierMigrationCalls = 0;
2005
2499
  const abortController = new AbortController();
2006
2500
 
2007
2501
  const orchestrator = Object.create(Orchestrator.prototype) as any;
@@ -2010,6 +2504,9 @@ test("runExtraction still clears the session buffer after persistence even if re
2010
2504
  clearAfterExtraction: async () => {
2011
2505
  clearCalls += 1;
2012
2506
  },
2507
+ retainDeferredTurns: async () => {
2508
+ retentionCalls += 1;
2509
+ },
2013
2510
  };
2014
2511
  orchestrator.storageRouter = {
2015
2512
  storageFor: async () => ({
@@ -2044,6 +2541,12 @@ test("runExtraction still clears the session buffer after persistence even if re
2044
2541
  });
2045
2542
  orchestrator.maybeScheduleConsolidation = () => undefined;
2046
2543
  orchestrator.requestQmdMaintenance = () => undefined;
2544
+ orchestrator.maybeCapturePassiveCorrections = async () => {
2545
+ passiveCaptureCalls += 1;
2546
+ };
2547
+ orchestrator.runTierMigrationCycle = async () => {
2548
+ tierMigrationCalls += 1;
2549
+ };
2047
2550
  orchestrator.nonZeroExtractionsSinceConsolidation = 0;
2048
2551
 
2049
2552
  await assert.doesNotReject(async () => {
@@ -2052,6 +2555,9 @@ test("runExtraction still clears the session buffer after persistence even if re
2052
2555
  abortSignal: abortController.signal,
2053
2556
  });
2054
2557
  });
2558
+ assert.equal(retentionCalls, 0);
2559
+ assert.equal(passiveCaptureCalls, 0);
2560
+ assert.equal(tierMigrationCalls, 0);
2055
2561
 
2056
2562
  assert.equal(
2057
2563
  clearCalls,
@@ -127,7 +127,7 @@ import { WorkspaceOpsCoordinator } from "./orchestration/workspace-ops.js";
127
127
  import { NamespaceReadFanoutCoordinator } from "./orchestration/namespace-read-fanout.js";
128
128
  import { selfDeps } from "./orchestration/self-deps.js";
129
129
  import { RecallEntryCoordinator } from "./orchestration/recall-entry.js";
130
- import { SessionContextCoordinator } from "./orchestration/session-context.js";
130
+ import { SessionContextCoordinator, type SessionFlushOptions } from "./orchestration/session-context.js";
131
131
  import { drainRecallWrites, trackRecallWrite } from "./orchestration/recall-background-writes.js";
132
132
  import { XrayCaptureQueue } from "./orchestration/xray-capture-queue.js";
133
133
  import {
@@ -2928,11 +2928,7 @@ export class Orchestrator {
2928
2928
 
2929
2929
  async flushSession(
2930
2930
  sessionKey: string,
2931
- options: {
2932
- reason: string;
2933
- abortSignal?: AbortSignal;
2934
- bufferKey?: string;
2935
- },
2931
+ options: SessionFlushOptions,
2936
2932
  ): Promise<void> {
2937
2933
  return (this.sessionContextCoordinator ?? new SessionContextCoordinator(
2938
2934
  selfDeps<ConstructorParameters<typeof SessionContextCoordinator>[0]>(this),
@@ -2970,6 +2966,8 @@ export class Orchestrator {
2970
2966
  * `principalOverride` (issue #570 PR 4).
2971
2967
  */
2972
2968
  principalOverride?: string;
2969
+ /** Persist the authenticated session owner on buffered turns. */
2970
+ sessionOwnerPrincipal?: string;
2973
2971
  } = {},
2974
2972
  ): Promise<void> {
2975
2973
  return this.turnIngestionCoordinator.ingestReplayBatch(
@@ -3029,10 +3027,12 @@ export class Orchestrator {
3029
3027
  options: {
3030
3028
  skipDedupeCheck?: boolean;
3031
3029
  clearBufferAfterExtraction?: boolean;
3030
+ clearMatchingTurns?: boolean;
3032
3031
  skipCharThreshold?: boolean;
3033
3032
  skipUserTurnThreshold?: boolean;
3034
3033
  extractionDeadlineMs?: number;
3035
3034
  failOnExtractionFailure?: boolean;
3035
+ onDurableCommit?: () => void;
3036
3036
  forceExtractionAttempt?: boolean;
3037
3037
  onTaskSettled?: (
3038
3038
  error?: unknown,
@@ -3054,6 +3054,7 @@ export class Orchestrator {
3054
3054
  * authenticated principal instead of `resolvePrincipal(sessionKey)`.
3055
3055
  */
3056
3056
  principalOverride?: string;
3057
+ scopeProfileWritePlan?: ResolvedScopeProfilePlan | null;
3057
3058
  } = {},
3058
3059
  ): Promise<void> {
3059
3060
  return this.turnIngestionCoordinator.queueBufferedExtraction(
@@ -3086,6 +3087,7 @@ export class Orchestrator {
3086
3087
  namespace: string;
3087
3088
  bufferKey: string;
3088
3089
  isLiveSession: boolean;
3090
+ abortSignal?: AbortSignal;
3089
3091
  },
3090
3092
  ): Promise<void> {
3091
3093
  return this.turnIngestionCoordinator.maybeCapturePassiveCorrections(