@remnic/core 10.0.144 → 10.0.145

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 (329) hide show
  1. package/dist/access-admin-ops-surface.js +163 -161
  2. package/dist/access-cli.js +163 -161
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-extraction-force-flush-preempt.js +163 -161
  5. package/dist/access-extraction-force-flush.js +163 -161
  6. package/dist/access-http-briefing.js +163 -161
  7. package/dist/access-http-query.js +163 -161
  8. package/dist/access-http.js +163 -161
  9. package/dist/access-identity-continuity-surface.js +163 -161
  10. package/dist/access-lcm-surface.js +163 -161
  11. package/dist/access-mcp.js +163 -161
  12. package/dist/access-observe-write-category.js +10 -10
  13. package/dist/access-observe-write-surface.d.ts.map +1 -1
  14. package/dist/access-observe-write-surface.js +163 -161
  15. package/dist/access-offline-manifest.js +6 -6
  16. package/dist/access-operations-batch.js +163 -161
  17. package/dist/access-operations.js +163 -161
  18. package/dist/access-recall-concurrency.js +163 -161
  19. package/dist/access-recall-diagnostics.js +2 -2
  20. package/dist/access-recall-response.js +163 -161
  21. package/dist/access-recall-surface.js +163 -161
  22. package/dist/access-schema.js +9 -9
  23. package/dist/access-service.js +163 -161
  24. package/dist/active-recall.js +28 -28
  25. package/dist/adapters/index.js +4 -4
  26. package/dist/adapters/registry.js +2 -2
  27. package/dist/briefing.js +20 -20
  28. package/dist/buffer-add-turns-bounded.d.ts +27 -0
  29. package/dist/buffer-add-turns-bounded.d.ts.map +1 -0
  30. package/dist/buffer-add-turns-bounded.js +13 -0
  31. package/dist/buffer-admission-idempotency.d.ts +18 -0
  32. package/dist/buffer-admission-idempotency.d.ts.map +1 -0
  33. package/dist/buffer-admission-idempotency.js +18 -0
  34. package/dist/buffer-persistence.d.ts +4 -0
  35. package/dist/buffer-persistence.d.ts.map +1 -1
  36. package/dist/buffer-persistence.js +1 -1
  37. package/dist/buffer-turn-helpers.d.ts.map +1 -1
  38. package/dist/buffer-turn-helpers.js +1 -1
  39. package/dist/buffer-types.d.ts.map +1 -1
  40. package/dist/buffer.d.ts +11 -0
  41. package/dist/buffer.d.ts.map +1 -1
  42. package/dist/buffer.js +14 -9
  43. package/dist/calibration.js +3 -3
  44. package/dist/{capsule-crypto-YO5QJ6L3.js → capsule-crypto-GWVG7LGC.js} +2 -2
  45. package/dist/capsule-crypto-GWVG7LGC.js.map +1 -0
  46. package/dist/causal-behavior.js +2 -2
  47. package/dist/causal-chain.js +2 -2
  48. package/dist/causal-consolidation.js +23 -23
  49. package/dist/causal-retrieval.js +2 -2
  50. package/dist/causal-trajectory-graph.js +2 -2
  51. package/dist/causal-trajectory.js +1 -1
  52. package/dist/{chunk-AOZYOS4G.js → chunk-2UOU6CZZ.js} +2 -2
  53. package/dist/{chunk-AZFQXYIJ.js → chunk-33VVVP57.js} +9 -2
  54. package/dist/{chunk-AZFQXYIJ.js.map → chunk-33VVVP57.js.map} +1 -1
  55. package/dist/{chunk-BFPF5N3H.js → chunk-4RASUAN3.js} +4 -4
  56. package/dist/{chunk-MZCGHPIJ.js → chunk-4XINO77L.js} +2 -2
  57. package/dist/{chunk-WVV54HL2.js → chunk-4Y4LPKFV.js} +7 -7
  58. package/dist/chunk-5EP2V675.js +60 -0
  59. package/dist/chunk-5EP2V675.js.map +1 -0
  60. package/dist/{chunk-2IMKMMUS.js → chunk-5JW2QIFH.js} +11 -11
  61. package/dist/{chunk-MPQQIHA7.js → chunk-5LL2X5SO.js} +2 -2
  62. package/dist/{chunk-VEPT6DXJ.js → chunk-63MKTHYT.js} +5 -5
  63. package/dist/{chunk-CBJRI6VJ.js → chunk-64TIBZPZ.js} +2 -2
  64. package/dist/{chunk-LL7WIK2Z.js → chunk-6NPLVV6M.js} +2 -2
  65. package/dist/{chunk-GOZXQNIM.js → chunk-6P7U3HWG.js} +3 -3
  66. package/dist/{chunk-PKPW7MXT.js → chunk-7TDJZV2S.js} +2 -2
  67. package/dist/{chunk-B72X3KWL.js → chunk-7TY5ZHFA.js} +2 -2
  68. package/dist/chunk-7ZFB4VZS.js +73 -0
  69. package/dist/chunk-7ZFB4VZS.js.map +1 -0
  70. package/dist/{chunk-B4I37XX6.js → chunk-ADBON4FI.js} +14 -14
  71. package/dist/{chunk-MEALRZYB.js → chunk-BKR2YCQ5.js} +2 -2
  72. package/dist/{chunk-R45L4TV6.js → chunk-BUKK5SWA.js} +6 -6
  73. package/dist/{chunk-2JAT4S7N.js → chunk-CIEEYVUB.js} +2 -2
  74. package/dist/{chunk-6CSWINXA.js → chunk-D3ZISMKY.js} +14 -14
  75. package/dist/{chunk-DLX277NS.js → chunk-DBNZYQCL.js} +2 -2
  76. package/dist/{chunk-2LQUPEWF.js → chunk-DCLOMXQL.js} +25 -22
  77. package/dist/chunk-DCLOMXQL.js.map +1 -0
  78. package/dist/{chunk-MIG4KRYU.js → chunk-DK3T3Q6A.js} +9 -9
  79. package/dist/{chunk-JVSHXYOO.js → chunk-E7WMDXAW.js} +2 -2
  80. package/dist/{chunk-6MEQHJTF.js → chunk-ENPJX3BB.js} +3 -3
  81. package/dist/{chunk-XGDWR2L6.js → chunk-ETUMOYGL.js} +2 -2
  82. package/dist/{chunk-RQBYC7EK.js → chunk-F4ZHKDBW.js} +2 -2
  83. package/dist/{chunk-6DHSEJIO.js → chunk-FBV4QGXT.js} +2 -2
  84. package/dist/{chunk-OYHGCAGQ.js → chunk-FZ6QUOTL.js} +2 -2
  85. package/dist/{chunk-A3EWNU5V.js → chunk-G2TK5YYU.js} +2 -2
  86. package/dist/{chunk-RVUD4WN3.js → chunk-G3ZUQZGM.js} +2 -2
  87. package/dist/{chunk-CBTERRF5.js → chunk-GA3Y7GZR.js} +2 -2
  88. package/dist/{chunk-AWKD2A73.js → chunk-GB442ZFG.js} +8 -8
  89. package/dist/{chunk-RSRHWNNM.js → chunk-GDREJ32D.js} +3 -3
  90. package/dist/{chunk-VEFGHRKV.js → chunk-GKL6QYZO.js} +1 -1
  91. package/dist/{chunk-Y6IRNAWT.js → chunk-GQDO6KHO.js} +2 -2
  92. package/dist/{chunk-FYH62SF3.js → chunk-GTW6GPQU.js} +3 -3
  93. package/dist/{chunk-M43GO34S.js → chunk-HASIFVWH.js} +2 -2
  94. package/dist/{chunk-VAVCFMMQ.js → chunk-IBPE3Q5M.js} +2 -2
  95. package/dist/{chunk-YLTU2DC4.js → chunk-IHCXMYSE.js} +2 -2
  96. package/dist/{chunk-WWQMZBDI.js → chunk-IJVU4ILJ.js} +4 -4
  97. package/dist/{chunk-N7LYEA3K.js → chunk-JOQZRIL4.js} +2 -2
  98. package/dist/{chunk-BNQJKWWZ.js → chunk-K3FH3LAQ.js} +4 -4
  99. package/dist/{chunk-EDGWAJLS.js → chunk-KBMJWNSY.js} +2 -2
  100. package/dist/{chunk-RHQSAXN3.js → chunk-KCU2ZWBS.js} +2 -2
  101. package/dist/{chunk-JVNGFQJN.js → chunk-KJ3Z7JHF.js} +1 -1
  102. package/dist/{chunk-JVNGFQJN.js.map → chunk-KJ3Z7JHF.js.map} +1 -1
  103. package/dist/{chunk-NLSMLRH4.js → chunk-KYZFW4LW.js} +2 -2
  104. package/dist/{chunk-L6CMR5OI.js → chunk-L2DACC2T.js} +2 -2
  105. package/dist/{chunk-3KQPFIVV.js → chunk-LMFINE37.js} +2 -2
  106. package/dist/{chunk-NWS4I4K7.js → chunk-LS5VJO5O.js} +2 -2
  107. package/dist/{chunk-OV3XHQAB.js → chunk-LYSE5FNF.js} +43 -48
  108. package/dist/chunk-LYSE5FNF.js.map +1 -0
  109. package/dist/{chunk-DC55RIEZ.js → chunk-M4IEZGCK.js} +4 -4
  110. package/dist/{chunk-FJVWKIDV.js → chunk-MEYPQLXV.js} +2 -2
  111. package/dist/{chunk-AGJJTD3Q.js → chunk-MONIOXEG.js} +2 -2
  112. package/dist/{chunk-5IGWEYNV.js → chunk-MVTMKFBW.js} +3 -3
  113. package/dist/{chunk-OYUTSLBU.js → chunk-ODHFX5JX.js} +3 -3
  114. package/dist/{chunk-I3UBDUHO.js → chunk-OMPX3KLG.js} +2 -2
  115. package/dist/{chunk-BXLOS5AJ.js → chunk-OWHERGF2.js} +2 -2
  116. package/dist/{chunk-QJJURIZV.js → chunk-P4YYUDR5.js} +3 -3
  117. package/dist/{chunk-77SYM565.js → chunk-PDVEY4QS.js} +2 -2
  118. package/dist/{chunk-LE27GU4M.js → chunk-QCJ7Q5BM.js} +2 -2
  119. package/dist/{chunk-74BX5NCU.js → chunk-QFBBSKEU.js} +2 -2
  120. package/dist/{chunk-YCNSMVWG.js → chunk-SDGD6MYV.js} +64 -3
  121. package/dist/chunk-SDGD6MYV.js.map +1 -0
  122. package/dist/{chunk-QPOWOQYH.js → chunk-SEIFDQ6U.js} +6 -6
  123. package/dist/{chunk-XUKBX3GO.js → chunk-SV6OLWPF.js} +8 -8
  124. package/dist/{chunk-JY3WATTF.js → chunk-T3M5KJRV.js} +2 -2
  125. package/dist/{chunk-YWXFO7G2.js → chunk-TFHL4WWY.js} +2 -2
  126. package/dist/{chunk-4Y26S76X.js → chunk-TRFSTCQK.js} +14 -2
  127. package/dist/chunk-TRFSTCQK.js.map +1 -0
  128. package/dist/{chunk-POXJ3KXJ.js → chunk-U62EINFH.js} +3 -3
  129. package/dist/{chunk-WZ55LEUN.js → chunk-UIFWZMO7.js} +22 -22
  130. package/dist/{chunk-DQEMWVMT.js → chunk-UVYI6VIX.js} +1 -1
  131. package/dist/{chunk-2S4XW47C.js → chunk-UWP6PGWN.js} +2 -2
  132. package/dist/{chunk-2VS3DAXE.js → chunk-V3D2OOVE.js} +2 -2
  133. package/dist/{chunk-UH3FPX3L.js → chunk-W7K5BP3M.js} +2 -2
  134. package/dist/{chunk-MFDEEOOZ.js → chunk-WN2DASTS.js} +4 -4
  135. package/dist/{chunk-TFA6HPOA.js → chunk-WQUGCOKF.js} +4 -4
  136. package/dist/{chunk-IJBOJJVS.js → chunk-X2FEUBKD.js} +2 -2
  137. package/dist/{chunk-XF2QQQXO.js → chunk-XIWRF7TG.js} +2 -2
  138. package/dist/{chunk-UC3KG7KX.js → chunk-YGPRFYV6.js} +3 -3
  139. package/dist/{chunk-E23BTVB2.js → chunk-YIOP7IFD.js} +2 -2
  140. package/dist/{chunk-EZ25VE3G.js → chunk-YNDLCWXS.js} +4 -4
  141. package/dist/{chunk-FWDVW2BD.js → chunk-Z2OKWO35.js} +328 -318
  142. package/dist/chunk-Z2OKWO35.js.map +1 -0
  143. package/dist/{chunk-FAPJG3OG.js → chunk-ZDZJNXL6.js} +4 -4
  144. package/dist/cli.js +163 -161
  145. package/dist/coding/export-okf-codegraph.js +19 -19
  146. package/dist/coding/pre-action-gate.js +2 -2
  147. package/dist/compounding/engine.js +21 -21
  148. package/dist/config.js +28 -28
  149. package/dist/connectors/codex-materialize-runner.js +20 -20
  150. package/dist/connectors/index.js +20 -20
  151. package/dist/convergence-refresh.js +22 -22
  152. package/dist/conversation-index/backend.js +2 -2
  153. package/dist/corpus-watermark.js +22 -22
  154. package/dist/dashboard-runtime.js +2 -2
  155. package/dist/deep-recall-http-glue.js +10 -10
  156. package/dist/deep-recall.js +2 -2
  157. package/dist/entity-retrieval.js +22 -22
  158. package/dist/event-order-recall.js +4 -4
  159. package/dist/explicit-capture.js +163 -161
  160. package/dist/extraction.js +28 -28
  161. package/dist/{graph-edge-decay-EKWXRBWF.js → graph-edge-decay-OEX5OGMI.js} +5 -5
  162. package/dist/graph-edge-decay-OEX5OGMI.js.map +1 -0
  163. package/dist/graph-jsonl.js +3 -3
  164. package/dist/graph-snapshot.js +3 -3
  165. package/dist/graph.js +2 -2
  166. package/dist/harmonic-retrieval.js +20 -20
  167. package/dist/index.js +216 -214
  168. package/dist/lcm/engine.js +2 -2
  169. package/dist/lcm/index.js +2 -2
  170. package/dist/local-llm.js +3 -3
  171. package/dist/location/index.js +21 -21
  172. package/dist/maintenance/memory-governance.js +20 -20
  173. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +20 -20
  174. package/dist/maintenance/rebuild-memory-projection-runner.js +22 -22
  175. package/dist/maintenance/rebuild-memory-projection.js +21 -21
  176. package/dist/memory-browse.js +6 -6
  177. package/dist/namespaces/migrate.js +21 -21
  178. package/dist/namespaces/search.js +9 -9
  179. package/dist/namespaces/storage.js +20 -20
  180. package/dist/offline-sync-changeset-generations.js +3 -3
  181. package/dist/offline-sync-embedding-generation.js +2 -2
  182. package/dist/offline-sync-snapshot-stream.js +6 -6
  183. package/dist/offline-sync.js +5 -5
  184. package/dist/operator-doctor-corpus.js +23 -23
  185. package/dist/operator-toolkit.js +37 -37
  186. package/dist/orchestration/backlog-scheduler.js +164 -162
  187. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  188. package/dist/orchestration/buffer-drain-runner.js +164 -162
  189. package/dist/orchestration/maintenance.js +31 -31
  190. package/dist/orchestration/turn-ingestion-buffered.d.ts +13 -0
  191. package/dist/orchestration/turn-ingestion-buffered.d.ts.map +1 -0
  192. package/dist/orchestration/turn-ingestion.d.ts +2 -2
  193. package/dist/orchestration/turn-ingestion.d.ts.map +1 -1
  194. package/dist/orchestrator.js +163 -161
  195. package/dist/qmd.js +3 -3
  196. package/dist/recall-explain-renderer.js +3 -3
  197. package/dist/recall-navigate-access.js +2 -2
  198. package/dist/recall-navigate-disclosure.js +2 -2
  199. package/dist/recall-navigate.js +2 -2
  200. package/dist/recall-navigation.js +163 -161
  201. package/dist/recall-state-view-admission.js +6 -6
  202. package/dist/recall-why-service.js +6 -6
  203. package/dist/recall-xray-cli.js +4 -4
  204. package/dist/recall-xray-renderer.js +3 -3
  205. package/dist/recall-xray.js +2 -2
  206. package/dist/resume-bundles.js +29 -29
  207. package/dist/search/factory.js +8 -8
  208. package/dist/search/index.js +12 -12
  209. package/dist/semantic-consolidation.js +21 -21
  210. package/dist/semantic-rule-promotion.js +20 -20
  211. package/dist/semantic-rule-verifier.js +20 -20
  212. package/dist/source-agent-qualifier.js +23 -23
  213. package/dist/standup/build.js +20 -20
  214. package/dist/storage/buffer-drain-claims.js +2 -2
  215. package/dist/storage/buffer-session-files.d.ts +4 -0
  216. package/dist/storage/buffer-session-files.d.ts.map +1 -1
  217. package/dist/storage/buffer-session-files.js +2 -2
  218. package/dist/storage.d.ts +1 -0
  219. package/dist/storage.d.ts.map +1 -1
  220. package/dist/storage.js +20 -20
  221. package/dist/summarizer.js +4 -4
  222. package/dist/support-passport/index.js +4 -4
  223. package/dist/transfer/autodetect.js +1 -1
  224. package/dist/transfer/backup.js +2 -2
  225. package/dist/transfer/capsule-export.js +3 -3
  226. package/dist/transfer/capsule-import.js +2 -2
  227. package/dist/transfer/export-okf.js +21 -21
  228. package/dist/types.d.ts +2 -0
  229. package/dist/types.d.ts.map +1 -1
  230. package/dist/types.js +1 -1
  231. package/dist/verified-recall.js +20 -20
  232. package/dist/who-knows-cli.js +21 -21
  233. package/dist/who-knows.js +20 -20
  234. package/package.json +2 -2
  235. package/src/access-observe-write-surface.ts +10 -0
  236. package/src/buffer-add-turns-bounded.ts +97 -0
  237. package/src/buffer-admission-idempotency.test.ts +297 -0
  238. package/src/buffer-admission-idempotency.ts +67 -0
  239. package/src/buffer-drain-handover.test.ts +1 -0
  240. package/src/buffer-persistence.ts +19 -1
  241. package/src/buffer-turn-helpers.ts +8 -1
  242. package/src/buffer-types.ts +1 -0
  243. package/src/buffer.ts +40 -43
  244. package/src/orchestration/turn-ingestion-buffered.ts +74 -0
  245. package/src/orchestration/turn-ingestion.ts +4 -78
  246. package/src/storage/buffer-session-files.ts +71 -0
  247. package/src/storage.ts +1 -0
  248. package/src/types.ts +2 -0
  249. package/dist/chunk-2LQUPEWF.js.map +0 -1
  250. package/dist/chunk-4Y26S76X.js.map +0 -1
  251. package/dist/chunk-FWDVW2BD.js.map +0 -1
  252. package/dist/chunk-OV3XHQAB.js.map +0 -1
  253. package/dist/chunk-YCNSMVWG.js.map +0 -1
  254. /package/dist/{capsule-crypto-YO5QJ6L3.js.map → buffer-add-turns-bounded.js.map} +0 -0
  255. /package/dist/{graph-edge-decay-EKWXRBWF.js.map → buffer-admission-idempotency.js.map} +0 -0
  256. /package/dist/{chunk-AOZYOS4G.js.map → chunk-2UOU6CZZ.js.map} +0 -0
  257. /package/dist/{chunk-BFPF5N3H.js.map → chunk-4RASUAN3.js.map} +0 -0
  258. /package/dist/{chunk-MZCGHPIJ.js.map → chunk-4XINO77L.js.map} +0 -0
  259. /package/dist/{chunk-WVV54HL2.js.map → chunk-4Y4LPKFV.js.map} +0 -0
  260. /package/dist/{chunk-2IMKMMUS.js.map → chunk-5JW2QIFH.js.map} +0 -0
  261. /package/dist/{chunk-MPQQIHA7.js.map → chunk-5LL2X5SO.js.map} +0 -0
  262. /package/dist/{chunk-VEPT6DXJ.js.map → chunk-63MKTHYT.js.map} +0 -0
  263. /package/dist/{chunk-CBJRI6VJ.js.map → chunk-64TIBZPZ.js.map} +0 -0
  264. /package/dist/{chunk-LL7WIK2Z.js.map → chunk-6NPLVV6M.js.map} +0 -0
  265. /package/dist/{chunk-GOZXQNIM.js.map → chunk-6P7U3HWG.js.map} +0 -0
  266. /package/dist/{chunk-PKPW7MXT.js.map → chunk-7TDJZV2S.js.map} +0 -0
  267. /package/dist/{chunk-B72X3KWL.js.map → chunk-7TY5ZHFA.js.map} +0 -0
  268. /package/dist/{chunk-B4I37XX6.js.map → chunk-ADBON4FI.js.map} +0 -0
  269. /package/dist/{chunk-MEALRZYB.js.map → chunk-BKR2YCQ5.js.map} +0 -0
  270. /package/dist/{chunk-R45L4TV6.js.map → chunk-BUKK5SWA.js.map} +0 -0
  271. /package/dist/{chunk-2JAT4S7N.js.map → chunk-CIEEYVUB.js.map} +0 -0
  272. /package/dist/{chunk-6CSWINXA.js.map → chunk-D3ZISMKY.js.map} +0 -0
  273. /package/dist/{chunk-DLX277NS.js.map → chunk-DBNZYQCL.js.map} +0 -0
  274. /package/dist/{chunk-MIG4KRYU.js.map → chunk-DK3T3Q6A.js.map} +0 -0
  275. /package/dist/{chunk-JVSHXYOO.js.map → chunk-E7WMDXAW.js.map} +0 -0
  276. /package/dist/{chunk-6MEQHJTF.js.map → chunk-ENPJX3BB.js.map} +0 -0
  277. /package/dist/{chunk-XGDWR2L6.js.map → chunk-ETUMOYGL.js.map} +0 -0
  278. /package/dist/{chunk-RQBYC7EK.js.map → chunk-F4ZHKDBW.js.map} +0 -0
  279. /package/dist/{chunk-6DHSEJIO.js.map → chunk-FBV4QGXT.js.map} +0 -0
  280. /package/dist/{chunk-OYHGCAGQ.js.map → chunk-FZ6QUOTL.js.map} +0 -0
  281. /package/dist/{chunk-A3EWNU5V.js.map → chunk-G2TK5YYU.js.map} +0 -0
  282. /package/dist/{chunk-RVUD4WN3.js.map → chunk-G3ZUQZGM.js.map} +0 -0
  283. /package/dist/{chunk-CBTERRF5.js.map → chunk-GA3Y7GZR.js.map} +0 -0
  284. /package/dist/{chunk-AWKD2A73.js.map → chunk-GB442ZFG.js.map} +0 -0
  285. /package/dist/{chunk-RSRHWNNM.js.map → chunk-GDREJ32D.js.map} +0 -0
  286. /package/dist/{chunk-VEFGHRKV.js.map → chunk-GKL6QYZO.js.map} +0 -0
  287. /package/dist/{chunk-Y6IRNAWT.js.map → chunk-GQDO6KHO.js.map} +0 -0
  288. /package/dist/{chunk-FYH62SF3.js.map → chunk-GTW6GPQU.js.map} +0 -0
  289. /package/dist/{chunk-M43GO34S.js.map → chunk-HASIFVWH.js.map} +0 -0
  290. /package/dist/{chunk-VAVCFMMQ.js.map → chunk-IBPE3Q5M.js.map} +0 -0
  291. /package/dist/{chunk-YLTU2DC4.js.map → chunk-IHCXMYSE.js.map} +0 -0
  292. /package/dist/{chunk-WWQMZBDI.js.map → chunk-IJVU4ILJ.js.map} +0 -0
  293. /package/dist/{chunk-N7LYEA3K.js.map → chunk-JOQZRIL4.js.map} +0 -0
  294. /package/dist/{chunk-BNQJKWWZ.js.map → chunk-K3FH3LAQ.js.map} +0 -0
  295. /package/dist/{chunk-EDGWAJLS.js.map → chunk-KBMJWNSY.js.map} +0 -0
  296. /package/dist/{chunk-RHQSAXN3.js.map → chunk-KCU2ZWBS.js.map} +0 -0
  297. /package/dist/{chunk-NLSMLRH4.js.map → chunk-KYZFW4LW.js.map} +0 -0
  298. /package/dist/{chunk-L6CMR5OI.js.map → chunk-L2DACC2T.js.map} +0 -0
  299. /package/dist/{chunk-3KQPFIVV.js.map → chunk-LMFINE37.js.map} +0 -0
  300. /package/dist/{chunk-NWS4I4K7.js.map → chunk-LS5VJO5O.js.map} +0 -0
  301. /package/dist/{chunk-DC55RIEZ.js.map → chunk-M4IEZGCK.js.map} +0 -0
  302. /package/dist/{chunk-FJVWKIDV.js.map → chunk-MEYPQLXV.js.map} +0 -0
  303. /package/dist/{chunk-AGJJTD3Q.js.map → chunk-MONIOXEG.js.map} +0 -0
  304. /package/dist/{chunk-5IGWEYNV.js.map → chunk-MVTMKFBW.js.map} +0 -0
  305. /package/dist/{chunk-OYUTSLBU.js.map → chunk-ODHFX5JX.js.map} +0 -0
  306. /package/dist/{chunk-I3UBDUHO.js.map → chunk-OMPX3KLG.js.map} +0 -0
  307. /package/dist/{chunk-BXLOS5AJ.js.map → chunk-OWHERGF2.js.map} +0 -0
  308. /package/dist/{chunk-QJJURIZV.js.map → chunk-P4YYUDR5.js.map} +0 -0
  309. /package/dist/{chunk-77SYM565.js.map → chunk-PDVEY4QS.js.map} +0 -0
  310. /package/dist/{chunk-LE27GU4M.js.map → chunk-QCJ7Q5BM.js.map} +0 -0
  311. /package/dist/{chunk-74BX5NCU.js.map → chunk-QFBBSKEU.js.map} +0 -0
  312. /package/dist/{chunk-QPOWOQYH.js.map → chunk-SEIFDQ6U.js.map} +0 -0
  313. /package/dist/{chunk-XUKBX3GO.js.map → chunk-SV6OLWPF.js.map} +0 -0
  314. /package/dist/{chunk-JY3WATTF.js.map → chunk-T3M5KJRV.js.map} +0 -0
  315. /package/dist/{chunk-YWXFO7G2.js.map → chunk-TFHL4WWY.js.map} +0 -0
  316. /package/dist/{chunk-POXJ3KXJ.js.map → chunk-U62EINFH.js.map} +0 -0
  317. /package/dist/{chunk-WZ55LEUN.js.map → chunk-UIFWZMO7.js.map} +0 -0
  318. /package/dist/{chunk-DQEMWVMT.js.map → chunk-UVYI6VIX.js.map} +0 -0
  319. /package/dist/{chunk-2S4XW47C.js.map → chunk-UWP6PGWN.js.map} +0 -0
  320. /package/dist/{chunk-2VS3DAXE.js.map → chunk-V3D2OOVE.js.map} +0 -0
  321. /package/dist/{chunk-UH3FPX3L.js.map → chunk-W7K5BP3M.js.map} +0 -0
  322. /package/dist/{chunk-MFDEEOOZ.js.map → chunk-WN2DASTS.js.map} +0 -0
  323. /package/dist/{chunk-TFA6HPOA.js.map → chunk-WQUGCOKF.js.map} +0 -0
  324. /package/dist/{chunk-IJBOJJVS.js.map → chunk-X2FEUBKD.js.map} +0 -0
  325. /package/dist/{chunk-XF2QQQXO.js.map → chunk-XIWRF7TG.js.map} +0 -0
  326. /package/dist/{chunk-UC3KG7KX.js.map → chunk-YGPRFYV6.js.map} +0 -0
  327. /package/dist/{chunk-E23BTVB2.js.map → chunk-YIOP7IFD.js.map} +0 -0
  328. /package/dist/{chunk-EZ25VE3G.js.map → chunk-YNDLCWXS.js.map} +0 -0
  329. /package/dist/{chunk-FAPJG3OG.js.map → chunk-ZDZJNXL6.js.map} +0 -0
@@ -453,12 +453,19 @@ export function normalizeBufferState(state: BufferState): BufferState {
453
453
  extractionCount: state.extractionCount ?? 0,
454
454
  };
455
455
  }
456
- return {
456
+ const normalized: BufferState = {
457
457
  turns: entries.default.turns,
458
458
  lastExtractionAt: entries.default.lastExtractionAt,
459
459
  extractionCount: entries.default.extractionCount,
460
460
  entries,
461
461
  };
462
+ if (state.admissionIdempotency) {
463
+ normalized.admissionIdempotency = Object.assign(Object.create(null), state.admissionIdempotency);
464
+ if (state.admissionIdempotencyOrder) {
465
+ normalized.admissionIdempotencyOrder = [...state.admissionIdempotencyOrder];
466
+ }
467
+ }
468
+ return normalized;
462
469
  }
463
470
 
464
471
  /** Trigger-mode decision for a buffer entry (extracted from SmartBuffer to
@@ -1,6 +1,7 @@
1
1
  /** Types split out of buffer.ts (structural ratchet, issue #1995). */
2
2
 
3
3
  import type { BufferTurn, CodingContext, SignalLevel } from "./types.js";
4
+
4
5
  import type { ResolvedScopeProfilePlan } from "./namespaces/scope-profiles.js";
5
6
 
6
7
  export type TriggerDecision = "extract_now" | "extract_batch" | "keep_buffering";
package/src/buffer.ts CHANGED
@@ -36,7 +36,8 @@ import {
36
36
  } from "./buffer-turn-helpers.js";
37
37
  import { BufferAdmissionRefusedError, BufferSessionTurnRefusedError, canAdmitNewEntryUnlocked } from "./buffer-admission.js";
38
38
  import { BufferIngressCounters } from "./buffer-ingress-counters.js";
39
- import { refuseOverCapBatch, refuseOverCapSingle, resolveMaxTurnsPerSession, sessionTurnCapReached } from "./buffer-session-cap.js";
39
+ import { addTurnsBoundedWithAdmissionKey, type AddTurnsBoundedHost } from "./buffer-add-turns-bounded.js";
40
+ import { refuseOverCapSingle, resolveMaxTurnsPerSession, sessionTurnCapReached } from "./buffer-session-cap.js";
40
41
  export { BufferAdmissionRefusedError, BufferSessionTurnRefusedError } from "./buffer-admission.js";
41
42
  import type { AddTurnMutationResult, AddTurnOutcome, RetainedTurnCleanupOptions, TriggerDecision } from "./buffer-types.js";
42
43
 
@@ -48,6 +49,7 @@ import type { BufferSurpriseProbe, SurpriseTelemetryQueueEntry } from "./buffer-
48
49
  // Raised from 200 in #3303: live captures were being dropped at busy hours
49
50
  // while the single extraction worker drained a backlog.
50
51
  const FALLBACK_MAX_BUFFER_SESSIONS = 1000;
52
+ export { BUFFER_ADMISSION_IDEMPOTENCY_CAP } from "./buffer-admission-idempotency.js";
51
53
 
52
54
  /**
53
55
  * Upper bound on how long a debounced buffer save may be deferred under
@@ -510,52 +512,47 @@ export class SmartBuffer {
510
512
  * Preflight every new key under the mutation lock before persisting any
511
513
  * turn; refusal records nothing and drops nothing.
512
514
  */
515
+
516
+ private addTurnsBoundedHost(): AddTurnsBoundedHost {
517
+ const self = this;
518
+ return {
519
+ get config() {
520
+ return self.config;
521
+ },
522
+ get maxSessionEntries() {
523
+ return self.maxSessionEntries;
524
+ },
525
+ get state() {
526
+ return self.state;
527
+ },
528
+ get persistence() {
529
+ return self.persistence;
530
+ },
531
+ get ingress() {
532
+ return self.ingress;
533
+ },
534
+ enqueueMutation: (work) => self.enqueueMutation(work),
535
+ loadUnlocked: () => self.loadUnlocked(),
536
+ peekEntry: (bufferKey) => self.peekEntry(bufferKey),
537
+ recordTurnUnlocked: (bufferKey, turn) => self.recordTurnUnlocked(bufferKey, turn),
538
+ completeAddTurnOutcome: (bufferKey, turn, mutation) =>
539
+ self.completeAddTurnOutcome(bufferKey, turn, mutation),
540
+ };
541
+ }
542
+
513
543
  async addTurnsBounded(
514
544
  batches: readonly { bufferKey: string; turns: readonly BufferTurn[] }[],
515
545
  ): Promise<Array<{ bufferKey: string; turn: BufferTurn; outcome: AddTurnOutcome }> | null> {
516
- const pending = await this.enqueueMutation(async () => {
517
- await this.loadUnlocked();
518
- const additions: Array<{ bufferKey: string; turn: BufferTurn }> = [];
519
- for (const batch of batches) {
520
- for (const turn of batch.turns) {
521
- additions.push({ bufferKey: batch.bufferKey, turn });
522
- }
523
- }
524
-
525
- if (refuseOverCapBatch((key) => this.peekEntry(key), batches, resolveMaxTurnsPerSession(this.config.bufferMaxTurnsPerSession))) return this.ingress.refuseAll(additions);
526
- const entries = this.state.entries ?? {};
527
- const newKeys = [...new Set(
528
- additions
529
- .map(({ bufferKey }) => bufferKey)
530
- .filter((bufferKey) => this.peekEntry(bufferKey) === null),
531
- )];
532
- const count = Object.keys(entries).length;
533
- const requiredEvictions = Math.max(0, count + newKeys.length - this.maxSessionEntries);
534
- if (requiredEvictions > 0) {
535
- const target = Math.max(0, this.maxSessionEntries - newKeys.length);
536
- const evicted = selectEvictedBufferKeys(entries, newKeys, target, EVICTION_HOOKS);
537
- if (newKeys.length > 0 && evicted.length < requiredEvictions) return this.ingress.refuseAll(additions);
538
- for (const key of evicted) delete entries[key];
539
- this.persistence.markEvicted(evicted);
540
- }
541
-
542
- const recorded: Array<{ bufferKey: string; turn: BufferTurn; mutation: AddTurnMutationResult }> = [];
543
- for (const { bufferKey, turn } of additions) {
544
- recorded.push({ bufferKey, turn, mutation: await this.recordTurnUnlocked(bufferKey, turn) });
545
- }
546
- return recorded;
547
- });
548
- if (pending === null) return null;
546
+ const result = await addTurnsBoundedWithAdmissionKey(this.addTurnsBoundedHost(), batches);
547
+ return result === "duplicate" ? null : result;
548
+ }
549
549
 
550
- const outcomes: Array<{ bufferKey: string; turn: BufferTurn; outcome: AddTurnOutcome }> = [];
551
- for (const item of pending) {
552
- outcomes.push({
553
- bufferKey: item.bufferKey,
554
- turn: item.turn,
555
- outcome: await this.completeAddTurnOutcome(item.bufferKey, item.turn, item.mutation),
556
- });
557
- }
558
- return outcomes;
550
+ /** #3368 durable observe replay only; duplicate means the scoped client key already landed. */
551
+ async addTurnsBoundedForObserveReplay(
552
+ batches: readonly { bufferKey: string; turns: readonly BufferTurn[] }[],
553
+ admissionKey: string,
554
+ ): Promise<Array<{ bufferKey: string; turn: BufferTurn; outcome: AddTurnOutcome }> | null | "duplicate"> {
555
+ return addTurnsBoundedWithAdmissionKey(this.addTurnsBoundedHost(), batches, admissionKey.trim());
559
556
  }
560
557
 
561
558
  /** Free one slot only when an empty entry can be reclaimed. */
@@ -0,0 +1,74 @@
1
+ /** Buffered durable replay ingest (#3368 split from turn-ingestion.ts — 1200-line ratchet). */
2
+
3
+ import { ReplayAdmissionRefusedError, StorageTargetRequiredError } from "../buffer-admission.js";
4
+ import { resolveNamespaceCapabilities } from "../capabilities.js";
5
+ import type { BufferTurn, CodingContext } from "../types.js";
6
+ import type { ResolvedScopeProfilePlan } from "../namespaces/scope-profiles.js";
7
+ import { queueBufferedCaptureScopeGroups } from "./extraction-task-queueing.js";
8
+ import type { TurnIngestionDeps } from "./turn-ingestion.js";
9
+
10
+ export async function ingestReplayBatchBuffered(
11
+ deps: Pick<TurnIngestionDeps, "config" | "buffer" | "lcmEngine" | "queueBufferedExtraction">,
12
+ bySession: Map<string, BufferTurn[]>,
13
+ options: {
14
+ archiveLcm?: boolean;
15
+ writeNamespaceOverride?: string;
16
+ principalOverride?: string;
17
+ scopeProfileWritePlan?: ResolvedScopeProfilePlan | null;
18
+ codingContext?: CodingContext;
19
+ bufferAdmissionIdempotencyKey?: string;
20
+ },
21
+ ): Promise<void> {
22
+ const resolvedWriteTarget =
23
+ options.writeNamespaceOverride ??
24
+ (resolveNamespaceCapabilities(deps.config).namespaces === true
25
+ ? options.scopeProfileWritePlan?.writeNamespace
26
+ : deps.config.defaultNamespace);
27
+ if (!resolvedWriteTarget) {
28
+ throw new StorageTargetRequiredError(
29
+ "accepted capture requires an explicit storage target (writeNamespaceOverride or scopeProfileWritePlan.writeNamespace)",
30
+ );
31
+ }
32
+ const pin = (turn: BufferTurn): BufferTurn => {
33
+ const pinned: BufferTurn = { ...turn, acceptedCapture: true, writeNamespaceOverride: resolvedWriteTarget };
34
+ if (options.codingContext) pinned.codingContext = options.codingContext;
35
+ if (options.principalOverride) pinned.principalOverride = options.principalOverride;
36
+ if (options.scopeProfileWritePlan) pinned.scopeProfileWritePlan = options.scopeProfileWritePlan;
37
+ return pinned;
38
+ };
39
+ const admissionKey = options.bufferAdmissionIdempotencyKey?.trim();
40
+ const batches = [...bySession].map(([bufferKey, sessionTurns]) => ({ bufferKey, turns: sessionTurns.map(pin) }));
41
+ const outcomes = admissionKey
42
+ ? await deps.buffer.addTurnsBoundedForObserveReplay(batches, admissionKey)
43
+ : await deps.buffer.addTurnsBounded(batches);
44
+ if (outcomes === "duplicate") return;
45
+ if (outcomes === null) {
46
+ const refusedKey = batches.find((batch) => batch.turns.length > 0)?.bufferKey ?? "unknown";
47
+ throw new ReplayAdmissionRefusedError(
48
+ `durable observe capture refused: extraction buffer at entry capacity for batch containing ${refusedKey}`,
49
+ );
50
+ }
51
+
52
+ await deps.buffer.flushPendingSave({ throwOnFailure: true });
53
+
54
+ if (options.archiveLcm !== false && deps.lcmEngine?.enabled) {
55
+ for (const [bufferKey, sessionTurns] of bySession) {
56
+ await deps.lcmEngine.observeMessages(
57
+ bufferKey,
58
+ sessionTurns.map((turn) => ({
59
+ role: turn.role,
60
+ content: turn.content,
61
+ parts: turn.parts,
62
+ rawContent: turn.rawContent,
63
+ sourceFormat: turn.sourceFormat,
64
+ })),
65
+ );
66
+ }
67
+ }
68
+
69
+ for (const { bufferKey, outcome } of outcomes) {
70
+ if (outcome.decision !== "keep_buffering" && outcome.extractionTurns) {
71
+ queueBufferedCaptureScopeGroups(deps.queueBufferedExtraction, outcome.extractionTurns, bufferKey, options);
72
+ }
73
+ }
74
+ }
@@ -42,6 +42,7 @@ import { TranscriptManager } from "../transcript.js";
42
42
  import type { BufferTurn, PluginConfig, SourceConnectorProvenance } from "../types.js";
43
43
 
44
44
  import { groupTurnsByExtractionScope, bufferTurnsEqual } from "../buffer-turn-helpers.js";
45
+ import { ingestReplayBatchBuffered } from "./turn-ingestion-buffered.js";
45
46
  import { ExtractionDrain } from "./extraction-drain.js";
46
47
  import { skipClaimedSession } from "./buffer-drain-gate.js";
47
48
  import { queueBufferedCaptureScopeGroups, type CaptureScopeGroupQueueOptions, type ExtractionTaskExecutionContext } from "./extraction-task-queueing.js";
@@ -281,6 +282,8 @@ export class TurnIngestionCoordinator {
281
282
  extractionMode?: "immediate" | "buffered";
282
283
  /** #3251: invoked per trigger-queued extraction promise (buffered mode). */
283
284
  onExtractionQueued?: (extraction: Promise<void>) => void;
285
+ /** #3368: durable observe retry — skip buffer add when key already admitted. */
286
+ bufferAdmissionIdempotencyKey?: string;
284
287
  /**
285
288
  * #3251: the ALREADY-resolved native coding context for this capture
286
289
  * (buffered mode). Pinned on the durable turns so drains re-resolve
@@ -322,7 +325,7 @@ export class TurnIngestionCoordinator {
322
325
  // applies to extraction, never to durable admission. The abort pre-check
323
326
  // below guards only the immediate (forced-queue) path.
324
327
  if (options.extractionMode === "buffered") {
325
- return this.ingestReplayBatchBuffered(bySession, options);
328
+ return ingestReplayBatchBuffered(this.deps, bySession, options);
326
329
  }
327
330
 
328
331
  if (options.abortSignal?.aborted) {
@@ -404,83 +407,6 @@ export class TurnIngestionCoordinator {
404
407
  }
405
408
  }
406
409
 
407
- /** #3251 buffered capture: durable scope-pinned admission; await settles at durability. */
408
- private async ingestReplayBatchBuffered(
409
- bySession: Map<string, BufferTurn[]>,
410
- options: {
411
- deadlineMs?: number;
412
- archiveLcm?: boolean;
413
- abortSignal?: AbortSignal;
414
- writeNamespaceOverride?: string;
415
- principalOverride?: string;
416
- scopeProfileWritePlan?: ResolvedScopeProfilePlan | null;
417
- codingContext?: import("../types.js").CodingContext;
418
- onExtractionQueued?: (extraction: Promise<void>) => void;
419
- },
420
- ): Promise<void> {
421
- // #3251: resolve the original actual storage target ONCE at method entry,
422
- // BEFORE any LCM archival or buffer admission. Explicit override is
423
- // authoritative; otherwise namespaces OFF → the collapsed default store;
424
- // namespaces ON → the plan's writeNamespace. Reject before any side
425
- // effect if neither is available.
426
- const resolvedWriteTarget =
427
- options.writeNamespaceOverride ??
428
- (resolveNamespaceCapabilities(this.deps.config).namespaces === true
429
- ? options.scopeProfileWritePlan?.writeNamespace
430
- : this.deps.config.defaultNamespace);
431
- if (!resolvedWriteTarget) {
432
- throw new StorageTargetRequiredError(
433
- "accepted capture requires an explicit storage target (writeNamespaceOverride or scopeProfileWritePlan.writeNamespace)",
434
- );
435
- }
436
- const pin = (turn: BufferTurn): BufferTurn => {
437
- const pinned: BufferTurn = { ...turn, acceptedCapture: true, writeNamespaceOverride: resolvedWriteTarget };
438
- if (options.codingContext) pinned.codingContext = options.codingContext;
439
- if (options.principalOverride) pinned.principalOverride = options.principalOverride;
440
- if (options.scopeProfileWritePlan) pinned.scopeProfileWritePlan = options.scopeProfileWritePlan;
441
- return pinned;
442
- };
443
- const batches = [...bySession].map(([bufferKey, sessionTurns]) => ({ bufferKey, turns: sessionTurns.map(pin) }));
444
- const outcomes = await this.deps.buffer.addTurnsBounded(batches);
445
- if (outcomes === null) {
446
- const refusedKey = batches.find((batch) => batch.turns.length > 0)?.bufferKey ?? "unknown";
447
- throw new ReplayAdmissionRefusedError(
448
- `durable observe capture refused: extraction buffer at entry capacity for batch containing ${refusedKey}`,
449
- );
450
- }
451
-
452
- // All requested session keys were capacity-admitted together before any
453
- // turn was saved. There is no retry identity: a repeat after a crash that
454
- // persisted only a prefix duplicates that prefix, as on main.
455
- await this.deps.buffer.flushPendingSave({ throwOnFailure: true });
456
-
457
- if (options.archiveLcm !== false && this.deps.lcmEngine?.enabled) {
458
- for (const [bufferKey, sessionTurns] of bySession) {
459
- await this.deps.lcmEngine.observeMessages(
460
- bufferKey,
461
- sessionTurns.map((turn) => ({
462
- role: turn.role,
463
- content: turn.content,
464
- parts: turn.parts,
465
- rawContent: turn.rawContent,
466
- sourceFormat: turn.sourceFormat,
467
- })),
468
- );
469
- }
470
- }
471
-
472
- for (const { bufferKey, outcome } of outcomes) {
473
- if (outcome.decision !== "keep_buffering" && outcome.extractionTurns) {
474
- queueBufferedCaptureScopeGroups(
475
- this.deps.queueBufferedExtraction,
476
- outcome.extractionTurns,
477
- bufferKey,
478
- options,
479
- );
480
- }
481
- }
482
- }
483
-
484
410
  /**
485
411
  * Ingest a batch of bulk-import turns (#460). Like ingestReplayBatch, this
486
412
  * normalizes user/assistant turns into the extraction buffer and awaits
@@ -66,6 +66,13 @@ interface SessionFileBody {
66
66
  extractionCount?: number;
67
67
  }
68
68
 
69
+ const ADMISSION_IDEMPOTENCY_FILE = "_admission-idempotency.json";
70
+
71
+ interface AdmissionIdempotencyFileBody {
72
+ keys?: Record<string, number>;
73
+ order?: string[];
74
+ }
75
+
69
76
  function entryFromBody(body: SessionFileBody): { key: string; entry: BufferEntryState } | null {
70
77
  if (!body || !Array.isArray(body.turns) || (body.key?.length ?? 0) === 0) return null;
71
78
  const entry: BufferEntryState = {
@@ -116,6 +123,68 @@ export class BufferSessionFiles {
116
123
  return path.join(this.dir, bufferSessionFileName(key));
117
124
  }
118
125
 
126
+ private admissionMetaPath(): string {
127
+ return path.join(this.dir, ADMISSION_IDEMPOTENCY_FILE);
128
+ }
129
+
130
+ private async readAdmissionIdempotency(): Promise<Pick<BufferState, "admissionIdempotency" | "admissionIdempotencyOrder">> {
131
+ let raw: string;
132
+ try {
133
+ raw = await this.io.read(this.admissionMetaPath());
134
+ } catch (err) {
135
+ if (err instanceof Error && isMissing(asFsError(err))) return {};
136
+ throw err;
137
+ }
138
+ try {
139
+ const body: AdmissionIdempotencyFileBody = JSON.parse(raw);
140
+ const rawKeys = body.keys;
141
+ if (rawKeys == null || Array.isArray(rawKeys)) return {};
142
+ // SAFETY: admission file contract — keys is a plain record of finite turn counts.
143
+ const map = Object.create(null) as Record<string, number>;
144
+ for (const [key, value] of Object.entries(rawKeys)) {
145
+ const count = Number(value);
146
+ if (Number.isFinite(count)) map[key] = count;
147
+ }
148
+ const loaded: Pick<BufferState, "admissionIdempotency" | "admissionIdempotencyOrder"> = {
149
+ admissionIdempotency: map,
150
+ };
151
+ if (Array.isArray(body.order) && body.order.length > 0) {
152
+ const order: string[] = [];
153
+ for (const entry of body.order) {
154
+ const slot = String(entry);
155
+ if (Object.hasOwn(map, slot)) order.push(slot);
156
+ }
157
+ if (order.length > 0) loaded.admissionIdempotencyOrder = order;
158
+ }
159
+ return loaded;
160
+ } catch (err) {
161
+ log.warn(
162
+ `buffer: unreadable admission idempotency file; starting empty (${err instanceof Error ? err.message : String(err)})`,
163
+ );
164
+ return {};
165
+ }
166
+ }
167
+
168
+ /** Persist observe-buffer idempotency metadata (production storage path). */
169
+ async saveAdmissionIdempotency(state: BufferState): Promise<void> {
170
+ const keys = state.admissionIdempotency;
171
+ if (!keys || Object.keys(keys).length === 0) {
172
+ await this.assertDirSafe();
173
+ try {
174
+ await unlink(this.admissionMetaPath());
175
+ } catch (err) {
176
+ if (!(err instanceof Error) || !isMissing(asFsError(err))) throw err;
177
+ }
178
+ return;
179
+ }
180
+ await this.assertDirSafe();
181
+ const order = state.admissionIdempotencyOrder ?? Object.keys(keys);
182
+ await this.io.write(
183
+ this.admissionMetaPath(),
184
+ JSON.stringify({ keys, order }),
185
+ );
186
+ }
187
+
119
188
  /**
120
189
  * Refuse a symlinked buffer directory: following it would send buffered
121
190
  * conversation data (and deletions) outside the memory root. One lstat of
@@ -269,11 +338,13 @@ export class BufferSessionFiles {
269
338
  const out: NonNullable<BufferState["entries"]> = Object.create(null);
270
339
  for (const [key, entry] of entries) out[key] = entry;
271
340
  const def = entries.get("default");
341
+ const admission = await this.readAdmissionIdempotency();
272
342
  return {
273
343
  turns: def?.turns ?? [],
274
344
  lastExtractionAt: def?.lastExtractionAt ?? null,
275
345
  extractionCount: def?.extractionCount ?? 0,
276
346
  entries: out,
347
+ ...admission,
277
348
  };
278
349
  }
279
350
 
package/src/storage.ts CHANGED
@@ -5518,6 +5518,7 @@ export class StorageManager extends TombstoneBlockedCaptureIndexHost {
5518
5518
  async loadBuffer(): Promise<BufferState> { return this.bufferSessionFiles().load(); }
5519
5519
  async saveBuffer(state: BufferState): Promise<void> { await this.bufferSessionFiles().reconcile(state); }
5520
5520
  async saveBufferSession(key: string, entry: BufferEntryState): Promise<BufferSessionSaveOutcome> { return await this.bufferSessionFiles().save(key, entry); }
5521
+ async saveBufferAdmissionIdempotency(state: BufferState): Promise<void> { await this.bufferSessionFiles().saveAdmissionIdempotency(state); }
5521
5522
  async deleteBufferSession(key: string): Promise<void> { await this.bufferSessionFiles().remove(key); }
5522
5523
  /** Sync gate check for the extraction queue: is this session claimed by a buffer drain? */
5523
5524
  isBufferSessionClaimed(key: string): boolean { return this.bufferSessionFiles().isClaimed(key); }
package/src/types.ts CHANGED
@@ -2700,6 +2700,8 @@ export interface BufferState {
2700
2700
  lastExtractionAt: string | null;
2701
2701
  extractionCount: number;
2702
2702
  entries?: Record<string, BufferEntryState>;
2703
+ admissionIdempotency?: Record<string, number>;
2704
+ admissionIdempotencyOrder?: string[];
2703
2705
  }
2704
2706
 
2705
2707
  export interface BehaviorLoopAdjustment {