@remnic/core 10.0.136 → 10.0.138

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 (313) hide show
  1. package/dist/access-admin-ops-surface.js +152 -152
  2. package/dist/access-cli.js +152 -152
  3. package/dist/access-extraction-force-flush-preempt.d.ts +11 -0
  4. package/dist/access-extraction-force-flush-preempt.d.ts.map +1 -0
  5. package/dist/access-extraction-force-flush-preempt.js +576 -0
  6. package/dist/access-extraction-force-flush.js +152 -152
  7. package/dist/access-http-briefing.js +152 -152
  8. package/dist/access-http-query.js +152 -152
  9. package/dist/access-http.js +152 -152
  10. package/dist/access-identity-continuity-surface.js +152 -152
  11. package/dist/access-lcm-surface.js +152 -152
  12. package/dist/access-mcp.js +152 -152
  13. package/dist/access-observe-write-category.js +10 -10
  14. package/dist/access-observe-write-surface.d.ts.map +1 -1
  15. package/dist/access-observe-write-surface.js +152 -152
  16. package/dist/access-offline-manifest.js +15 -15
  17. package/dist/access-operations-batch.js +152 -152
  18. package/dist/access-operations.js +152 -152
  19. package/dist/access-recall-concurrency.js +152 -152
  20. package/dist/access-recall-diagnostics.js +8 -8
  21. package/dist/access-recall-response.js +152 -152
  22. package/dist/access-recall-surface.js +152 -152
  23. package/dist/access-schema.js +9 -9
  24. package/dist/access-service.js +152 -152
  25. package/dist/access-surface-catalog.js +4 -4
  26. package/dist/active-memory-bridge.js +7 -7
  27. package/dist/active-recall.js +31 -31
  28. package/dist/{auto-sync-BO5YZKM6.js → auto-sync-PSZJHHXB.js} +5 -5
  29. package/dist/briefing.js +21 -21
  30. package/dist/buffer-turn.d.ts +11 -0
  31. package/dist/buffer-turn.d.ts.map +1 -1
  32. package/dist/buffer.js +10 -10
  33. package/dist/calibration.js +3 -3
  34. package/dist/causal-consolidation.js +22 -22
  35. package/dist/{chunk-T4KY6UYF.js → chunk-274UY54Z.js} +2 -2
  36. package/dist/{chunk-3TVCG6ST.js → chunk-2DWTO7XP.js} +6 -6
  37. package/dist/{chunk-STKNZY7A.js → chunk-2NJ74RQU.js} +2 -2
  38. package/dist/{chunk-4H7TUVWQ.js → chunk-2VS3DAXE.js} +3 -3
  39. package/dist/{chunk-MEQPK3KG.js → chunk-3BRHOVRU.js} +3 -3
  40. package/dist/{chunk-HLWXCDUQ.js → chunk-3DAWHP5K.js} +5 -5
  41. package/dist/{chunk-KVCFAWBZ.js → chunk-3PZDG5ZH.js} +2 -2
  42. package/dist/{chunk-5RZ4DAP6.js → chunk-5IGWEYNV.js} +3 -3
  43. package/dist/{chunk-U5I2G4VU.js → chunk-5WZT6WQW.js} +4 -4
  44. package/dist/{chunk-TL6QIZT7.js → chunk-66MBMBSH.js} +2 -2
  45. package/dist/{chunk-KLUCX6OH.js → chunk-77SYM565.js} +14 -14
  46. package/dist/{chunk-ZGGFGUUF.js → chunk-A33VT7GC.js} +2 -2
  47. package/dist/{chunk-5RCXMLI5.js → chunk-AV6R66KO.js} +3 -3
  48. package/dist/{chunk-BL545EH7.js → chunk-CFSCKCT5.js} +15 -14
  49. package/dist/chunk-CFSCKCT5.js.map +1 -0
  50. package/dist/{chunk-S3LWB6K3.js → chunk-CKG7T4AD.js} +2 -2
  51. package/dist/{chunk-YNTVQWLX.js → chunk-DI2QWY6J.js} +16 -16
  52. package/dist/{chunk-3RW5ZCYO.js → chunk-DIBOWE53.js} +2 -2
  53. package/dist/{chunk-QRZNVNNS.js → chunk-EEY326VH.js} +3 -3
  54. package/dist/{chunk-OIGJZHDU.js → chunk-EUL3S3LE.js} +7 -7
  55. package/dist/{chunk-YNDLCWXS.js → chunk-EZ25VE3G.js} +4 -4
  56. package/dist/{chunk-DUTLMAUC.js → chunk-F4DXTUHY.js} +2 -2
  57. package/dist/{chunk-DK2VBJ6Q.js → chunk-FAPJG3OG.js} +4 -4
  58. package/dist/{chunk-M2XR6B6V.js → chunk-FEUWI5QH.js} +2 -2
  59. package/dist/{chunk-VO3HCFSR.js → chunk-GAVFANAB.js} +2 -2
  60. package/dist/{chunk-SPHBQTWE.js → chunk-GOYLBPSW.js} +3 -3
  61. package/dist/{chunk-37T5ZO5P.js → chunk-HOSS72UP.js} +2 -2
  62. package/dist/{chunk-3TU6OBI7.js → chunk-I3UBDUHO.js} +2 -2
  63. package/dist/{chunk-HA6V3CLH.js → chunk-JCWI43TO.js} +2 -2
  64. package/dist/{chunk-6LNWA6IT.js → chunk-JEAMQL63.js} +13 -13
  65. package/dist/{chunk-XBNGH2FV.js → chunk-JG6AHBJW.js} +2 -2
  66. package/dist/{chunk-3F6COEHZ.js → chunk-JVNGFQJN.js} +1 -1
  67. package/dist/chunk-JVNGFQJN.js.map +1 -0
  68. package/dist/{chunk-PA5FI6A5.js → chunk-JY327EH4.js} +2 -2
  69. package/dist/{chunk-WYSCN5TA.js → chunk-K4DBE5MH.js} +9 -9
  70. package/dist/{chunk-KIICCGSV.js → chunk-KCLHHANX.js} +3 -3
  71. package/dist/{chunk-QOI4PNVG.js → chunk-KCVPKFDG.js} +2 -2
  72. package/dist/{chunk-EFMAYZOB.js → chunk-L6CMR5OI.js} +2 -2
  73. package/dist/{chunk-Y3TA66MZ.js → chunk-LEH4FVBJ.js} +20 -20
  74. package/dist/{chunk-AHA5VQGP.js → chunk-LEII44QG.js} +4 -4
  75. package/dist/chunk-LEO4MQ3S.js +140 -0
  76. package/dist/chunk-LEO4MQ3S.js.map +1 -0
  77. package/dist/{chunk-4VL2H5Q3.js → chunk-LL7WIK2Z.js} +2 -2
  78. package/dist/{chunk-GW23JXGJ.js → chunk-LT35JWKZ.js} +2 -2
  79. package/dist/{chunk-U5OVNYJX.js → chunk-MP6V4CLP.js} +9 -9
  80. package/dist/{chunk-NEXJ3OOZ.js → chunk-MXE42X3I.js} +6 -6
  81. package/dist/{chunk-LR6QP72R.js → chunk-N6JGLQV7.js} +2 -2
  82. package/dist/{chunk-J6U6KUMK.js → chunk-N7IJEGSE.js} +2 -2
  83. package/dist/{chunk-5ZS73P3U.js → chunk-NB2BKYUS.js} +2 -2
  84. package/dist/{chunk-KN44QS5F.js → chunk-NOZDET3Q.js} +6 -6
  85. package/dist/{chunk-C2KE5DMD.js → chunk-O6ZSWHVR.js} +4 -4
  86. package/dist/{chunk-C73N66PR.js → chunk-OBPOIZNR.js} +2 -2
  87. package/dist/{chunk-TSJQ7C2T.js → chunk-OFMK76LD.js} +16 -16
  88. package/dist/{chunk-LK3LXSJQ.js → chunk-OI3UMEW3.js} +5 -5
  89. package/dist/{chunk-6Z7BRM7C.js → chunk-OJJ73HLA.js} +3 -3
  90. package/dist/{chunk-CLVILSBR.js → chunk-OZNBZJ3S.js} +22 -22
  91. package/dist/{chunk-GUI7MLKC.js → chunk-PKPW7MXT.js} +4 -4
  92. package/dist/{chunk-SCQO7JOF.js → chunk-PKV3NNM2.js} +2 -2
  93. package/dist/{chunk-XCZQ7MID.js → chunk-PNT3SZRY.js} +21 -21
  94. package/dist/{chunk-IXX4SKF5.js → chunk-POB7N5UM.js} +2 -2
  95. package/dist/{chunk-2OIQHXN4.js → chunk-PQ5FYNY2.js} +2 -2
  96. package/dist/{chunk-JDY34KBL.js → chunk-QUMKDRCF.js} +4 -4
  97. package/dist/{chunk-CGEOIR4F.js → chunk-QZ5JZNXN.js} +475 -329
  98. package/dist/chunk-QZ5JZNXN.js.map +1 -0
  99. package/dist/{chunk-V6JECHY6.js → chunk-SBRUTD5O.js} +6 -6
  100. package/dist/{chunk-ZKHDDEPF.js → chunk-SRW4IKHM.js} +2 -2
  101. package/dist/{chunk-BTY6DUFW.js → chunk-SU63UQPL.js} +7 -7
  102. package/dist/{chunk-TVDJEUV5.js → chunk-SX4BR26Y.js} +2 -2
  103. package/dist/{chunk-OIG4ZFMB.js → chunk-SZK2DX5U.js} +5 -5
  104. package/dist/{chunk-5BE3FLKL.js → chunk-TAUHAP5J.js} +4 -4
  105. package/dist/{chunk-NS7U4ZYU.js → chunk-TSUSHXBW.js} +2 -2
  106. package/dist/{chunk-YMFPFXEX.js → chunk-TYOS62PM.js} +5 -5
  107. package/dist/{chunk-BFDXJHYG.js → chunk-U3GJUARA.js} +2 -2
  108. package/dist/{chunk-P3WRNWWM.js → chunk-UPE7TJWN.js} +2 -2
  109. package/dist/{chunk-OE35LFBF.js → chunk-VF3EVRUN.js} +3 -3
  110. package/dist/{chunk-VY3DHUL7.js → chunk-VRWQUUZ7.js} +8 -8
  111. package/dist/{chunk-FEWOSD33.js → chunk-VSZEV7HG.js} +6 -6
  112. package/dist/{chunk-K2VRKCPA.js → chunk-XBW7U7GM.js} +4 -4
  113. package/dist/{chunk-UA2NDTIU.js → chunk-YAVIBVCU.js} +4 -4
  114. package/dist/{chunk-HKQ3LH34.js → chunk-YDOLJQ55.js} +5 -5
  115. package/dist/{chunk-JGM3OWPQ.js → chunk-YMNFHNZH.js} +2 -2
  116. package/dist/{chunk-DJ7WVEWX.js → chunk-YVXM5QFL.js} +2 -2
  117. package/dist/{chunk-FMFCQRDM.js → chunk-ZANNIXXE.js} +3 -3
  118. package/dist/{chunk-OJXK5C6Z.js → chunk-ZG4GNPRE.js} +7 -7
  119. package/dist/{chunk-B3DR2JBZ.js → chunk-ZZYJNT2J.js} +4 -4
  120. package/dist/cli.js +152 -152
  121. package/dist/coding/export-okf-codegraph.js +20 -20
  122. package/dist/compounding/engine.js +22 -22
  123. package/dist/config.d.ts.map +1 -1
  124. package/dist/config.js +31 -31
  125. package/dist/connectors/codex-materialize-runner.js +21 -21
  126. package/dist/connectors/index.js +23 -23
  127. package/dist/contradiction/index.js +12 -12
  128. package/dist/{contradiction-scan-IBPYGQZF.js → contradiction-scan-DTQFAW22.js} +6 -6
  129. package/dist/convergence-refresh.js +22 -22
  130. package/dist/corpus-watermark.js +23 -23
  131. package/dist/dashboard-runtime.js +2 -2
  132. package/dist/deep-recall-http-glue.js +10 -10
  133. package/dist/embedding-fallback.js +2 -2
  134. package/dist/entity-retrieval.js +20 -20
  135. package/dist/event-order-recall.js +2 -2
  136. package/dist/explicit-capture.js +152 -152
  137. package/dist/extraction-normalization.js +1 -1
  138. package/dist/extraction-window-drain.d.ts +21 -0
  139. package/dist/extraction-window-drain.d.ts.map +1 -1
  140. package/dist/extraction-window-drain.js +5 -3
  141. package/dist/extraction.js +32 -32
  142. package/dist/{first-start-migration-FILJH3RO.js → first-start-migration-BPVJ4HJQ.js} +8 -8
  143. package/dist/graph-edge-decay-EKWXRBWF.js +1 -1
  144. package/dist/harmonic-retrieval.js +20 -20
  145. package/dist/index.js +291 -291
  146. package/dist/lcm/engine.js +3 -3
  147. package/dist/lcm/index.js +8 -8
  148. package/dist/local-llm-config.js +2 -2
  149. package/dist/location/index.js +23 -23
  150. package/dist/maintenance/memory-governance.js +20 -20
  151. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +20 -20
  152. package/dist/maintenance/rebuild-memory-projection-runner.js +22 -22
  153. package/dist/maintenance/rebuild-memory-projection.js +21 -21
  154. package/dist/memory-browse.js +9 -9
  155. package/dist/namespaces/migrate.js +22 -22
  156. package/dist/namespaces/search.js +4 -4
  157. package/dist/namespaces/storage.js +21 -21
  158. package/dist/offline-sync-changeset-generations.js +3 -3
  159. package/dist/offline-sync-embedding-generation.js +2 -2
  160. package/dist/offline-sync-impression-drain.js +3 -3
  161. package/dist/offline-sync-snapshot-stream.js +6 -6
  162. package/dist/offline-sync.js +5 -5
  163. package/dist/operator-doctor-corpus.js +24 -24
  164. package/dist/operator-toolkit.js +41 -41
  165. package/dist/orchestration/backlog-scheduler.js +153 -153
  166. package/dist/orchestration/buffer-drain-runner.js +153 -153
  167. package/dist/orchestration/extraction-drain.d.ts +13 -0
  168. package/dist/orchestration/extraction-drain.d.ts.map +1 -1
  169. package/dist/orchestration/extraction-queue-coordinator.d.ts +10 -0
  170. package/dist/orchestration/extraction-queue-coordinator.d.ts.map +1 -1
  171. package/dist/orchestration/maintenance.js +34 -34
  172. package/dist/orchestrator.d.ts.map +1 -1
  173. package/dist/orchestrator.js +156 -156
  174. package/dist/qmd.js +4 -4
  175. package/dist/recall-explain-renderer.js +3 -3
  176. package/dist/recall-navigate-access.js +2 -2
  177. package/dist/recall-navigate-disclosure.js +2 -2
  178. package/dist/recall-navigate.js +2 -2
  179. package/dist/recall-navigation.js +152 -152
  180. package/dist/recall-state-view-admission.js +5 -5
  181. package/dist/recall-why-service.js +15 -15
  182. package/dist/recall-why.js +6 -6
  183. package/dist/recall-xray-cli.js +4 -4
  184. package/dist/recall-xray-renderer.js +3 -3
  185. package/dist/recall-xray.js +2 -2
  186. package/dist/reconcile/cursor.js +2 -2
  187. package/dist/reconcile/manifest.js +3 -3
  188. package/dist/reconcile/plan.js +2 -2
  189. package/dist/{resolution-G4SLHSEU.js → resolution-7XBNQVKU.js} +9 -9
  190. package/dist/resolution-7XBNQVKU.js.map +1 -0
  191. package/dist/resume-bundles.js +33 -33
  192. package/dist/search/factory.js +3 -3
  193. package/dist/search/index.js +3 -3
  194. package/dist/semantic-consolidation.js +22 -22
  195. package/dist/semantic-rule-promotion.js +20 -20
  196. package/dist/semantic-rule-verifier.js +20 -20
  197. package/dist/source-agent-qualifier.js +29 -29
  198. package/dist/standup/build.js +21 -21
  199. package/dist/storage.js +19 -19
  200. package/dist/summarizer.js +1 -1
  201. package/dist/support-passport/index.js +12 -12
  202. package/dist/tier-routing.js +4 -4
  203. package/dist/{tier-stats-FXEUJN73.js → tier-stats-FLFKN7Y6.js} +8 -8
  204. package/dist/transfer/export-okf.js +20 -20
  205. package/dist/types.d.ts +5 -6
  206. package/dist/types.d.ts.map +1 -1
  207. package/dist/types.js +1 -1
  208. package/dist/verified-recall.js +20 -20
  209. package/dist/who-knows-cli.js +21 -21
  210. package/dist/who-knows.js +20 -20
  211. package/package.json +2 -2
  212. package/src/access-extraction-force-flush-preempt-coordinator.test.ts +60 -0
  213. package/src/access-extraction-force-flush-preempt.test.ts +41 -0
  214. package/src/access-extraction-force-flush-preempt.ts +56 -0
  215. package/src/access-observe-write-surface.ts +2 -14
  216. package/src/buffer-turn.ts +8 -0
  217. package/src/config.ts +2 -0
  218. package/src/extraction-window-drain.test.ts +66 -0
  219. package/src/extraction-window-drain.ts +113 -2
  220. package/src/orchestration/extraction-drain-parts.test.ts +260 -0
  221. package/src/orchestration/extraction-drain.ts +186 -23
  222. package/src/orchestration/extraction-queue-coordinator.ts +23 -0
  223. package/src/orchestrator-flush.test.ts +3 -0
  224. package/src/orchestrator.ts +1 -0
  225. package/src/part-failure-threshold.test.ts +91 -0
  226. package/src/types.ts +5 -6
  227. package/dist/chunk-3F6COEHZ.js.map +0 -1
  228. package/dist/chunk-BL545EH7.js.map +0 -1
  229. package/dist/chunk-CGEOIR4F.js.map +0 -1
  230. package/dist/chunk-LZIOY7ZU.js +0 -57
  231. package/dist/chunk-LZIOY7ZU.js.map +0 -1
  232. /package/dist/{contradiction-scan-IBPYGQZF.js.map → access-extraction-force-flush-preempt.js.map} +0 -0
  233. /package/dist/{auto-sync-BO5YZKM6.js.map → auto-sync-PSZJHHXB.js.map} +0 -0
  234. /package/dist/{chunk-T4KY6UYF.js.map → chunk-274UY54Z.js.map} +0 -0
  235. /package/dist/{chunk-3TVCG6ST.js.map → chunk-2DWTO7XP.js.map} +0 -0
  236. /package/dist/{chunk-STKNZY7A.js.map → chunk-2NJ74RQU.js.map} +0 -0
  237. /package/dist/{chunk-4H7TUVWQ.js.map → chunk-2VS3DAXE.js.map} +0 -0
  238. /package/dist/{chunk-MEQPK3KG.js.map → chunk-3BRHOVRU.js.map} +0 -0
  239. /package/dist/{chunk-HLWXCDUQ.js.map → chunk-3DAWHP5K.js.map} +0 -0
  240. /package/dist/{chunk-KVCFAWBZ.js.map → chunk-3PZDG5ZH.js.map} +0 -0
  241. /package/dist/{chunk-5RZ4DAP6.js.map → chunk-5IGWEYNV.js.map} +0 -0
  242. /package/dist/{chunk-U5I2G4VU.js.map → chunk-5WZT6WQW.js.map} +0 -0
  243. /package/dist/{chunk-TL6QIZT7.js.map → chunk-66MBMBSH.js.map} +0 -0
  244. /package/dist/{chunk-KLUCX6OH.js.map → chunk-77SYM565.js.map} +0 -0
  245. /package/dist/{chunk-ZGGFGUUF.js.map → chunk-A33VT7GC.js.map} +0 -0
  246. /package/dist/{chunk-5RCXMLI5.js.map → chunk-AV6R66KO.js.map} +0 -0
  247. /package/dist/{chunk-S3LWB6K3.js.map → chunk-CKG7T4AD.js.map} +0 -0
  248. /package/dist/{chunk-YNTVQWLX.js.map → chunk-DI2QWY6J.js.map} +0 -0
  249. /package/dist/{chunk-3RW5ZCYO.js.map → chunk-DIBOWE53.js.map} +0 -0
  250. /package/dist/{chunk-QRZNVNNS.js.map → chunk-EEY326VH.js.map} +0 -0
  251. /package/dist/{chunk-OIGJZHDU.js.map → chunk-EUL3S3LE.js.map} +0 -0
  252. /package/dist/{chunk-YNDLCWXS.js.map → chunk-EZ25VE3G.js.map} +0 -0
  253. /package/dist/{chunk-DUTLMAUC.js.map → chunk-F4DXTUHY.js.map} +0 -0
  254. /package/dist/{chunk-DK2VBJ6Q.js.map → chunk-FAPJG3OG.js.map} +0 -0
  255. /package/dist/{chunk-M2XR6B6V.js.map → chunk-FEUWI5QH.js.map} +0 -0
  256. /package/dist/{chunk-VO3HCFSR.js.map → chunk-GAVFANAB.js.map} +0 -0
  257. /package/dist/{chunk-SPHBQTWE.js.map → chunk-GOYLBPSW.js.map} +0 -0
  258. /package/dist/{chunk-37T5ZO5P.js.map → chunk-HOSS72UP.js.map} +0 -0
  259. /package/dist/{chunk-3TU6OBI7.js.map → chunk-I3UBDUHO.js.map} +0 -0
  260. /package/dist/{chunk-HA6V3CLH.js.map → chunk-JCWI43TO.js.map} +0 -0
  261. /package/dist/{chunk-6LNWA6IT.js.map → chunk-JEAMQL63.js.map} +0 -0
  262. /package/dist/{chunk-XBNGH2FV.js.map → chunk-JG6AHBJW.js.map} +0 -0
  263. /package/dist/{chunk-PA5FI6A5.js.map → chunk-JY327EH4.js.map} +0 -0
  264. /package/dist/{chunk-WYSCN5TA.js.map → chunk-K4DBE5MH.js.map} +0 -0
  265. /package/dist/{chunk-KIICCGSV.js.map → chunk-KCLHHANX.js.map} +0 -0
  266. /package/dist/{chunk-QOI4PNVG.js.map → chunk-KCVPKFDG.js.map} +0 -0
  267. /package/dist/{chunk-EFMAYZOB.js.map → chunk-L6CMR5OI.js.map} +0 -0
  268. /package/dist/{chunk-Y3TA66MZ.js.map → chunk-LEH4FVBJ.js.map} +0 -0
  269. /package/dist/{chunk-AHA5VQGP.js.map → chunk-LEII44QG.js.map} +0 -0
  270. /package/dist/{chunk-4VL2H5Q3.js.map → chunk-LL7WIK2Z.js.map} +0 -0
  271. /package/dist/{chunk-GW23JXGJ.js.map → chunk-LT35JWKZ.js.map} +0 -0
  272. /package/dist/{chunk-U5OVNYJX.js.map → chunk-MP6V4CLP.js.map} +0 -0
  273. /package/dist/{chunk-NEXJ3OOZ.js.map → chunk-MXE42X3I.js.map} +0 -0
  274. /package/dist/{chunk-LR6QP72R.js.map → chunk-N6JGLQV7.js.map} +0 -0
  275. /package/dist/{chunk-J6U6KUMK.js.map → chunk-N7IJEGSE.js.map} +0 -0
  276. /package/dist/{chunk-5ZS73P3U.js.map → chunk-NB2BKYUS.js.map} +0 -0
  277. /package/dist/{chunk-KN44QS5F.js.map → chunk-NOZDET3Q.js.map} +0 -0
  278. /package/dist/{chunk-C2KE5DMD.js.map → chunk-O6ZSWHVR.js.map} +0 -0
  279. /package/dist/{chunk-C73N66PR.js.map → chunk-OBPOIZNR.js.map} +0 -0
  280. /package/dist/{chunk-TSJQ7C2T.js.map → chunk-OFMK76LD.js.map} +0 -0
  281. /package/dist/{chunk-LK3LXSJQ.js.map → chunk-OI3UMEW3.js.map} +0 -0
  282. /package/dist/{chunk-6Z7BRM7C.js.map → chunk-OJJ73HLA.js.map} +0 -0
  283. /package/dist/{chunk-CLVILSBR.js.map → chunk-OZNBZJ3S.js.map} +0 -0
  284. /package/dist/{chunk-GUI7MLKC.js.map → chunk-PKPW7MXT.js.map} +0 -0
  285. /package/dist/{chunk-SCQO7JOF.js.map → chunk-PKV3NNM2.js.map} +0 -0
  286. /package/dist/{chunk-XCZQ7MID.js.map → chunk-PNT3SZRY.js.map} +0 -0
  287. /package/dist/{chunk-IXX4SKF5.js.map → chunk-POB7N5UM.js.map} +0 -0
  288. /package/dist/{chunk-2OIQHXN4.js.map → chunk-PQ5FYNY2.js.map} +0 -0
  289. /package/dist/{chunk-JDY34KBL.js.map → chunk-QUMKDRCF.js.map} +0 -0
  290. /package/dist/{chunk-V6JECHY6.js.map → chunk-SBRUTD5O.js.map} +0 -0
  291. /package/dist/{chunk-ZKHDDEPF.js.map → chunk-SRW4IKHM.js.map} +0 -0
  292. /package/dist/{chunk-BTY6DUFW.js.map → chunk-SU63UQPL.js.map} +0 -0
  293. /package/dist/{chunk-TVDJEUV5.js.map → chunk-SX4BR26Y.js.map} +0 -0
  294. /package/dist/{chunk-OIG4ZFMB.js.map → chunk-SZK2DX5U.js.map} +0 -0
  295. /package/dist/{chunk-5BE3FLKL.js.map → chunk-TAUHAP5J.js.map} +0 -0
  296. /package/dist/{chunk-NS7U4ZYU.js.map → chunk-TSUSHXBW.js.map} +0 -0
  297. /package/dist/{chunk-YMFPFXEX.js.map → chunk-TYOS62PM.js.map} +0 -0
  298. /package/dist/{chunk-BFDXJHYG.js.map → chunk-U3GJUARA.js.map} +0 -0
  299. /package/dist/{chunk-P3WRNWWM.js.map → chunk-UPE7TJWN.js.map} +0 -0
  300. /package/dist/{chunk-OE35LFBF.js.map → chunk-VF3EVRUN.js.map} +0 -0
  301. /package/dist/{chunk-VY3DHUL7.js.map → chunk-VRWQUUZ7.js.map} +0 -0
  302. /package/dist/{chunk-FEWOSD33.js.map → chunk-VSZEV7HG.js.map} +0 -0
  303. /package/dist/{chunk-K2VRKCPA.js.map → chunk-XBW7U7GM.js.map} +0 -0
  304. /package/dist/{chunk-UA2NDTIU.js.map → chunk-YAVIBVCU.js.map} +0 -0
  305. /package/dist/{chunk-HKQ3LH34.js.map → chunk-YDOLJQ55.js.map} +0 -0
  306. /package/dist/{chunk-JGM3OWPQ.js.map → chunk-YMNFHNZH.js.map} +0 -0
  307. /package/dist/{chunk-DJ7WVEWX.js.map → chunk-YVXM5QFL.js.map} +0 -0
  308. /package/dist/{chunk-FMFCQRDM.js.map → chunk-ZANNIXXE.js.map} +0 -0
  309. /package/dist/{chunk-OJXK5C6Z.js.map → chunk-ZG4GNPRE.js.map} +0 -0
  310. /package/dist/{chunk-B3DR2JBZ.js.map → chunk-ZZYJNT2J.js.map} +0 -0
  311. /package/dist/{resolution-G4SLHSEU.js.map → contradiction-scan-DTQFAW22.js.map} +0 -0
  312. /package/dist/{first-start-migration-FILJH3RO.js.map → first-start-migration-BPVJ4HJQ.js.map} +0 -0
  313. /package/dist/{tier-stats-FXEUJN73.js.map → tier-stats-FLFKN7Y6.js.map} +0 -0
@@ -3,7 +3,12 @@
3
3
  import { createHash } from "node:crypto";
4
4
  import { isAbortError, preemptedExtractionError } from "../abort-error.js";
5
5
  import { describeError } from "../buffer-turn-helpers.js";
6
- import { chunkExtractionWindow, classifyDrainResult, mergeDrainResults } from "../extraction-window-drain.js";
6
+ import {
7
+ chunkExtractionWindow,
8
+ classifyDrainResult,
9
+ mergeDrainResults,
10
+ splitOversizedTurns,
11
+ } from "../extraction-window-drain.js";
7
12
  import { log } from "../logger.js";
8
13
  import type { BufferTurn } from "../types.js";
9
14
  import { type CollapsedDuplicates, collapseExactDuplicateTurns, markDuplicateTurns } from "./extraction-dedupe.js";
@@ -45,10 +50,16 @@ export interface ExtractionDrainDeps {
45
50
  };
46
51
  }
47
52
 
48
- /** Identity of a chunk: its failure count must not follow a buffer key to different content. */
53
+ /** Identity of a chunk: its failure count must not follow a buffer key to
54
+ * different content. Part copies carry the part ordinal: two slices of one
55
+ * oversized turn can be byte-identical, and their failure counts must not
56
+ * share a slot (a success on part 1 would erase part 2's count). */
49
57
  function chunkFingerprint(chunk: readonly BufferTurn[]): string {
50
58
  const hash = createHash("sha256");
51
- for (const turn of chunk) hash.update(`${turn.role}\u0000${turn.timestamp}\u0000${turn.content}\u0001`);
59
+ for (const turn of chunk) {
60
+ const part = turn.extractionPartOf ? `#${turn.extractionPartOf.part}/${turn.extractionPartOf.of}` : "";
61
+ hash.update(`${turn.role}\u0000${turn.timestamp}\u0000${turn.content}${part}\u0001`);
62
+ }
52
63
  return hash.digest("hex");
53
64
  }
54
65
 
@@ -57,6 +68,12 @@ interface ChunkPlan {
57
68
  singleRun: boolean;
58
69
  chunks: BufferTurn[][];
59
70
  resumed: boolean;
71
+ /** In-flight part copy → its source turn, for `extractionPartOf` splits. */
72
+ partParents?: Map<BufferTurn, BufferTurn>;
73
+ /** How many oversized turns hit the max-parts clamp. */
74
+ clampedParts: number;
75
+ /** Parents whose unemitted tail needs a recovery copy before clearing. */
76
+ clampedParents?: Set<BufferTurn>;
60
77
  }
61
78
 
62
79
  /** The drain-loop action for one chunk result. */
@@ -74,7 +91,7 @@ interface ChunkExecutionOptions {
74
91
 
75
92
  export class ExtractionDrain {
76
93
  /** Consecutive failed attempts on the head chunk, per buffer key. In memory on */
77
- private readonly failures = new Map<string, { fingerprint: string; count: number }>();
94
+ private readonly failures = new Map<string, number>();
78
95
 
79
96
  /**
80
97
  * Buffer key to the first turn of the chunk a qualified window stopped on.
@@ -105,14 +122,27 @@ export class ExtractionDrain {
105
122
  return total;
106
123
  }
107
124
 
125
+ /** Failure counts are keyed by buffer key AND chunk fingerprint: with one
126
+ * slot per key, a sibling chunk's success (count reset to 0) would delete
127
+ * a failing part's count and it would never reach the drop threshold. */
108
128
  private failureCount(bufferKey: string, chunk: readonly BufferTurn[]): number {
109
- const entry = this.failures.get(bufferKey);
110
- return entry && entry.fingerprint === chunkFingerprint(chunk) ? entry.count : 0;
129
+ return this.failures.get(this.failureSlot(bufferKey, chunk)) ?? 0;
111
130
  }
112
131
 
113
132
  private setFailureCount(bufferKey: string, chunk: readonly BufferTurn[], count: number): void {
114
- if (count <= 0) this.failures.delete(bufferKey);
115
- else this.failures.set(bufferKey, { fingerprint: chunkFingerprint(chunk), count });
133
+ const slot = this.failureSlot(bufferKey, chunk);
134
+ if (count <= 0) this.failures.delete(slot);
135
+ else this.failures.set(slot, count);
136
+ }
137
+
138
+ private failureSlot(bufferKey: string, chunk: readonly BufferTurn[]): string {
139
+ return `${bufferKey}\u0000${chunkFingerprint(chunk)}`;
140
+ }
141
+
142
+ private clearBufferFailures(bufferKey: string): void {
143
+ for (const slot of this.failures.keys()) {
144
+ if (slot.startsWith(`${bufferKey}\u0000`)) this.failures.delete(slot);
145
+ }
116
146
  }
117
147
 
118
148
  /**
@@ -148,9 +178,27 @@ export class ExtractionDrain {
148
178
  // sees each text once. Every original stays a distinct identity the chunk must
149
179
  // account for, so chunks carry the duplicates as marked copies — clearing and
150
180
  // drops remove representative and duplicates together.
151
- const collapsed = collapseExactDuplicateTurns(turns);
181
+ const partBudget = Math.min(budgetChars, this.deps.config.extractionMaxTurnChars);
182
+ const hasOversized =
183
+ Number.isFinite(partBudget) &&
184
+ partBudget > 0 &&
185
+ this.chunkable(runOptions, turns, budgetChars) &&
186
+ turns.some((turn) => turn.content.length > partBudget);
187
+ const collapsed = hasOversized
188
+ ? {
189
+ representatives: turns,
190
+ representativePositions: turns.map((_, index) => index),
191
+ duplicateFlags: turns.map(() => false),
192
+ duplicateCount: 0,
193
+ }
194
+ : collapseExactDuplicateTurns(turns);
152
195
  const window = collapsed.duplicateCount > 0 ? markDuplicateTurns(turns, collapsed) : turns;
153
- const plan = this.chunkPlan(turns, runOptions, budgetChars, collapsed);
196
+ const plan = this.chunkPlan(turns, runOptions, budgetChars, collapsed, partBudget);
197
+ if (plan.clampedParts > 0) {
198
+ log.warn(
199
+ `buffer[${runOptions.bufferKey}]: clamped ${plan.clampedParts} oversized turns at the part limit; the unemitted tail content stays buffered for the next drain`
200
+ );
201
+ }
154
202
  // The tail of a window that already qualified goes through the chunk loop even when it now fits in one
155
203
  // chunk, so its failures still count toward the drop threshold.
156
204
  if (plan.singleRun) {
@@ -181,7 +229,7 @@ export class ExtractionDrain {
181
229
  collapsed.duplicateCount > 0
182
230
  ? { ...runOptions, skipCharThreshold: true, skipUserTurnThreshold: true }
183
231
  : runOptions;
184
- return await this.runChunked(plan.chunks, options, preemptable, preemptHandle);
232
+ return await this.runChunked(plan.chunks, options, preemptable, preemptHandle, plan.partParents, plan.clampedParents);
185
233
  }
186
234
 
187
235
  /** Chunking plan for one trigger-drain window. Accepted-capture groups
@@ -192,10 +240,24 @@ export class ExtractionDrain {
192
240
  turns: readonly BufferTurn[],
193
241
  runOptions: DrainRunOptions,
194
242
  budgetChars: number,
195
- collapsed?: CollapsedDuplicates
243
+ collapsed?: CollapsedDuplicates,
244
+ partBudget = Number.POSITIVE_INFINITY
196
245
  ): ChunkPlan {
197
246
  const deduped = collapsed !== undefined && collapsed.duplicateCount > 0;
198
- const planning = deduped ? collapsed.representatives : turns;
247
+ // Long-turn split (payload-cap drain): a turn longer than the render clamp
248
+ // would lose its tail to the per-turn slice, so it becomes ordered verbatim
249
+ // part copies marked `extractionPartOf`. The parts pack like any turn; the
250
+ // parent clears only when its last part drains.
251
+ const split =
252
+ deduped || !this.chunkable(runOptions, turns, budgetChars)
253
+ ? {
254
+ turns: [...turns],
255
+ partParents: new Map<BufferTurn, BufferTurn>(),
256
+ clampedParents: new Set<BufferTurn>(),
257
+ clamped: false,
258
+ }
259
+ : splitOversizedTurns(turns, partBudget);
260
+ const planning = deduped ? collapsed.representatives : split.turns;
199
261
  const repChunks = this.chunkable(runOptions, turns, budgetChars)
200
262
  ? this.deps.measureRenderedTurns !== undefined
201
263
  ? this.chunkByRenderedSize(planning, budgetChars)
@@ -204,7 +266,15 @@ export class ExtractionDrain {
204
266
  const resumed =
205
267
  repChunks.length > 0 && this.qualified.get(runOptions.bufferKey) === chunkFingerprint(repChunks[0].slice(0, 1));
206
268
  const chunks = deduped ? this.expandedChunks(turns, collapsed, repChunks) : repChunks;
207
- return { singleRun: chunks.length <= 1 && !resumed, chunks, resumed };
269
+ const partParents = split.partParents.size > 0 ? split.partParents : undefined;
270
+ return {
271
+ singleRun: chunks.length <= 1 && !resumed && partParents === undefined,
272
+ chunks,
273
+ resumed,
274
+ partParents,
275
+ clampedParts: split.clampedParents.size,
276
+ clampedParents: split.clampedParents.size > 0 ? split.clampedParents : undefined,
277
+ };
208
278
  }
209
279
 
210
280
  /** Each representative chunk expands to a PARTITION slice of the original window:
@@ -267,7 +337,9 @@ export class ExtractionDrain {
267
337
  chunks: readonly BufferTurn[][],
268
338
  runOptions: DrainRunOptions,
269
339
  preemptable: boolean,
270
- preemptHandle?: ExtractionPreemptHandle
340
+ preemptHandle?: ExtractionPreemptHandle,
341
+ partParents?: Map<BufferTurn, BufferTurn>,
342
+ clampedParents?: Set<BufferTurn>
271
343
  ): Promise<ExtractionRunResult> {
272
344
  const baseOptions = { ...runOptions, skipCharThreshold: true, skipUserTurnThreshold: true };
273
345
  const bufferKey = runOptions.bufferKey;
@@ -293,11 +365,24 @@ export class ExtractionDrain {
293
365
  this.rethrowChunkAbort(err, preempt, runOptions.abortSignal?.aborted === true);
294
366
  // A successfully dropped thrown chunk does not end the drain: later
295
367
  // chunks still run this pass (live drop policy).
296
- aggregate = await this.settleThrownChunk(bufferKey, chunk, failures, dropAfter, err, byIdentity, aggregate);
368
+ aggregate = await this.settleThrownChunk(
369
+ bufferKey,
370
+ chunk,
371
+ failures,
372
+ dropAfter,
373
+ err,
374
+ byIdentity,
375
+ aggregate,
376
+ partParents
377
+ );
297
378
  continue;
298
379
  }
299
380
  const settled = this.settleVerdict(bufferKey, chunk, result, aggregate);
300
381
  if (settled.action === "continue") {
382
+ // Every part extracted: the slice copies match no buffered turn, so the
383
+ // run cleared only the chunk's real turns; the parent is dropped now
384
+ // that its last part drained.
385
+ await this.clearFinishedPartParents(bufferKey, chunk, partParents, clampedParents);
301
386
  aggregate = settled.result;
302
387
  continue;
303
388
  }
@@ -310,6 +395,7 @@ export class ExtractionDrain {
310
395
  result: settled.result,
311
396
  byIdentity,
312
397
  aggregate: settled.aggregate,
398
+ partParents,
313
399
  });
314
400
  if (failed.action === "continue") {
315
401
  aggregate = failed.result;
@@ -318,6 +404,7 @@ export class ExtractionDrain {
318
404
  return failed.result;
319
405
  }
320
406
  this.qualified.delete(bufferKey);
407
+ this.clearBufferFailures(bufferKey);
321
408
  return aggregate ?? { status: "skipped", persistedCount: 0, durableOutputCount: 0 };
322
409
  }
323
410
 
@@ -371,7 +458,8 @@ export class ExtractionDrain {
371
458
  dropAfter: number,
372
459
  cause: unknown,
373
460
  byIdentity: boolean,
374
- aggregate: ExtractionRunResult | null
461
+ aggregate: ExtractionRunResult | null,
462
+ partParents?: Map<BufferTurn, BufferTurn>
375
463
  ): Promise<ExtractionRunResult> {
376
464
  failures += 1;
377
465
  if (failures < dropAfter || !this.dropFailedChunks) {
@@ -384,7 +472,7 @@ export class ExtractionDrain {
384
472
  persistedCount: 0,
385
473
  durableOutputCount: 0,
386
474
  };
387
- if (!(await this.dropFailedChunk(bufferKey, chunk, dropAfter, thrown, byIdentity))) {
475
+ if (!(await this.dropFailedChunk(bufferKey, chunk, dropAfter, thrown, byIdentity, partParents))) {
388
476
  this.setFailureCount(bufferKey, chunk, failures);
389
477
  throw cause;
390
478
  }
@@ -424,10 +512,20 @@ export class ExtractionDrain {
424
512
  result: ExtractionRunResult;
425
513
  byIdentity: boolean;
426
514
  aggregate: ExtractionRunResult | null;
515
+ partParents?: Map<BufferTurn, BufferTurn>;
427
516
  }): Promise<{ action: "continue" | "return"; result: ExtractionRunResult }> {
428
517
  const failures = args.failures + 1;
429
518
  if (failures >= args.dropAfter && this.dropFailedChunks) {
430
- if (!(await this.dropFailedChunk(args.bufferKey, args.chunk, args.dropAfter, args.result, args.byIdentity))) {
519
+ if (
520
+ !(await this.dropFailedChunk(
521
+ args.bufferKey,
522
+ args.chunk,
523
+ args.dropAfter,
524
+ args.result,
525
+ args.byIdentity,
526
+ args.partParents
527
+ ))
528
+ ) {
431
529
  // No recovery copy: keep the only buffered copy and retry later.
432
530
  this.setFailureCount(args.bufferKey, args.chunk, failures);
433
531
  return { action: "return", result: mergeDrainResults(args.aggregate, args.result) };
@@ -462,16 +560,22 @@ export class ExtractionDrain {
462
560
  chunk: readonly BufferTurn[],
463
561
  dropAfter: number,
464
562
  result: ExtractionRunResult,
465
- byIdentity: boolean
563
+ byIdentity: boolean,
564
+ partParents?: Map<BufferTurn, BufferTurn>
466
565
  ): Promise<boolean> {
467
566
  const reason =
468
567
  `dropped after ${dropAfter} repeated extraction failures ` +
469
568
  `(last result: status=${result.status} reason=${result.reason ?? "n/a"})`;
470
- const copyPath = await this.saveRecoveryCopy(bufferKey, reason, chunk);
569
+ // Part copies match nothing buffered: their drop set is the parents (full
570
+ // content lands in the recovery copy, not slices).
571
+ const dropTurns = partParents === undefined ? chunk : this.dropSetForParts(chunk, partParents);
572
+ const copyPath = await this.saveRecoveryCopy(bufferKey, reason, dropTurns);
471
573
  if (copyPath === null) return false;
472
- log.warn(`buffer[${bufferKey}]: dropping ${chunk.length} turns — ${reason}; copy saved to ${copyPath}`);
574
+ log.warn(`buffer[${bufferKey}]: dropping ${dropTurns.length} turns — ${reason}; copy saved to ${copyPath}`);
473
575
  try {
474
- const dropped = await this.deps.buffer.dropExtractionChunk(bufferKey, chunk, { allowNonPrefix: byIdentity });
576
+ const dropped = await this.deps.buffer.dropExtractionChunk(bufferKey, dropTurns, {
577
+ allowNonPrefix: byIdentity || partParents !== undefined,
578
+ });
475
579
  if (dropped > 0) {
476
580
  log.warn(`buffer[${bufferKey}]: removed ${dropped} buffered turns — ${reason}`);
477
581
  return true;
@@ -504,4 +608,63 @@ export class ExtractionDrain {
504
608
  return null;
505
609
  }
506
610
  }
611
+
612
+ /** The buffered identities a part-carrying chunk actually removes on drop:
613
+ * real turns themselves plus each part copy's parent, once per parent. */
614
+ private dropSetForParts(
615
+ chunk: readonly BufferTurn[],
616
+ partParents: Map<BufferTurn, BufferTurn>
617
+ ): BufferTurn[] {
618
+ const seen = new Set<BufferTurn>();
619
+ const dropTurns: BufferTurn[] = [];
620
+ for (const turn of chunk) {
621
+ const target = partParents.get(turn) ?? turn;
622
+ if (seen.has(target)) continue;
623
+ seen.add(target);
624
+ dropTurns.push(target);
625
+ }
626
+ return dropTurns;
627
+ }
628
+
629
+ /** A part's slice never equals its parent's buffered content, so no drain
630
+ * clears a parent implicitly. When the LAST part of a parent drains, the
631
+ * whole turn has been extracted and the parent is removed by identity —
632
+ * non-prefix, since earlier chunks may leave it mid-buffer. */
633
+ private async clearFinishedPartParents(
634
+ bufferKey: string,
635
+ chunk: readonly BufferTurn[],
636
+ partParents?: Map<BufferTurn, BufferTurn>,
637
+ clampedParents?: Set<BufferTurn>
638
+ ): Promise<void> {
639
+ if (partParents === undefined) return;
640
+ for (const turn of chunk) {
641
+ const marker = turn.extractionPartOf;
642
+ if (marker === undefined || marker.part !== marker.of) continue;
643
+ const parent = partParents.get(turn);
644
+ if (parent === undefined) continue;
645
+ if (clampedParents?.has(parent) === true) {
646
+ // The emitted parts covered only the head: the tail stays out of the
647
+ // model, so the parent leaves the buffer through the recovery-copy
648
+ // path — removed, never lost. A failed copy keeps it for retry.
649
+ const copyPath = await this.saveRecoveryCopy(
650
+ bufferKey,
651
+ "clamped at the per-turn part limit; unemitted tail preserved",
652
+ [parent]
653
+ );
654
+ if (copyPath === null) continue;
655
+ log.warn(`buffer[${bufferKey}]: clamped turn removed after part extraction; copy saved to ${copyPath}`);
656
+ }
657
+ try {
658
+ const dropped = await this.deps.buffer.dropExtractionChunk(bufferKey, [parent], { allowNonPrefix: true });
659
+ if (dropped === 0) {
660
+ log.warn(`buffer[${bufferKey}]: extracted turn's parts drained but its parent no longer matches the buffer`);
661
+ }
662
+ } catch (err) {
663
+ log.warn(
664
+ `buffer[${bufferKey}]: failed to clear an extracted turn's parent (it stays buffered for retry): ${describeError(err)}`
665
+ );
666
+ }
667
+ }
668
+ }
507
669
  }
670
+
@@ -291,6 +291,29 @@ export class ExtractionQueueCoordinator {
291
291
  }
292
292
  }
293
293
 
294
+ /** Test + force-flush observability: register a keyed preempt slot the way
295
+ * `runEntry` does for a queued task, so callers can exercise the keyed
296
+ * preemption path without a full queue. */
297
+ registerPreemptSlot(key: string): ExtractionPreemptHandle {
298
+ const slot: PreemptSlot = {};
299
+ this.preemptSlots.set(slot, { key });
300
+ return this.createPreemptHandle(slot);
301
+ }
302
+
303
+ /** Force-flush-scoped preemption: abort EVERY armed slot whose key matches
304
+ * `key` and abort nothing when none does. Unlike `preemptRunning` there is
305
+ * deliberately no newest-slot fallback - a keyed caller (force-flush on
306
+ * session K) must never take out an unrelated background task just
307
+ * because K's own extraction is not (yet) armed. */
308
+ preemptKeyed(key: string): void {
309
+ for (const state of this.preemptSlots.values()) {
310
+ if (state.key !== key || state.armed === undefined) continue;
311
+ const abort = state.armed.abort;
312
+ state.armed = undefined;
313
+ abort();
314
+ }
315
+ }
316
+
294
317
  private createPreemptHandle(slot: PreemptSlot): ExtractionPreemptHandle {
295
318
  return {
296
319
  arm: (abort: () => void) => {
@@ -369,6 +369,7 @@ test("flushSession skips scoped ownership enforcement when namespaces are disabl
369
369
 
370
370
  test("flushSession waits for queued extraction task completion", async () => {
371
371
  const orchestrator = Object.create(Orchestrator.prototype) as any;
372
+ orchestrator.config = parseConfig({});
372
373
  let releaseExtraction!: () => void;
373
374
  let extractionStarted = false;
374
375
  let flushSettled = false;
@@ -477,7 +478,9 @@ test("queued extraction settles immediately when its caller aborts while waiting
477
478
  const queue = new ExtractionQueueCoordinator();
478
479
  let extractionStarted = false;
479
480
  let releaseExtraction!: () => void;
481
+ // SAFETY: fixture deps stub — only the queued-extraction path fields are exercised.
480
482
  const coordinator = new TurnIngestionCoordinator({
483
+ config: parseConfig({}),
481
484
  extractionQueueCoordinator: queue,
482
485
  shouldQueueExtraction: () => true,
483
486
  runExtraction: async () => {
@@ -3102,6 +3102,7 @@ export class Orchestrator {
3102
3102
  this.config.modelSource !== "gateway" && resolveLocalLlmCapabilities(this.config).localLlm,
3103
3103
  model: this.config.localLlmModel,
3104
3104
  maxContext: this.config.localLlmMaxContext,
3105
+ callMaxChars: this.config.extractionCallMaxChars,
3105
3106
  });
3106
3107
  }
3107
3108
 
@@ -0,0 +1,91 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtemp, rm } from "node:fs/promises";
3
+ import os from "node:os";
4
+ import path from "node:path";
5
+ import test from "node:test";
6
+ import { SmartBuffer } from "./buffer.js";
7
+ import { parseConfig } from "./config.js";
8
+ import { ExtractionDrain } from "./orchestration/extraction-drain.js";
9
+ import type { ExtractionRunResult } from "./orchestration/extraction-run.js";
10
+ import { StorageManager } from "./storage.js";
11
+ import type { BufferTurn } from "./types.js";
12
+
13
+ function makeTurn(sessionKey: string, content: string): BufferTurn {
14
+ return {
15
+ role: "user",
16
+ content,
17
+ timestamp: "2026-10-29T12:00:00.000Z",
18
+ sessionKey,
19
+ };
20
+ }
21
+
22
+ const DONE: ExtractionRunResult = {
23
+ status: "completed",
24
+ persistedCount: 0,
25
+ durableOutputCount: 0,
26
+ };
27
+
28
+ const FAILED: ExtractionRunResult = {
29
+ status: "skipped",
30
+ reason: "synthetic part failure",
31
+ retainedBuffer: true,
32
+ persistedCount: 0,
33
+ durableOutputCount: 0,
34
+ };
35
+
36
+ /** Two-part split of one oversized turn: part 1 extracts, part 2 keeps failing.
37
+ * The parent must reach the drop threshold (recovery copy) instead of looping. */
38
+ test("a repeatedly failing part still reaches the drop threshold across drain passes", async () => {
39
+ const root = await mkdtemp(path.join(os.tmpdir(), "remnic-part-drop-"));
40
+ try {
41
+ const buffer = new SmartBuffer(parseConfig({}), new StorageManager(root));
42
+ const parent = makeTurn("s1", "x".repeat(120));
43
+ await buffer.addTurn("s1", parent);
44
+ await buffer.flushPendingSave();
45
+
46
+ const seenChunks: string[] = [];
47
+ const droppedReasons: string[] = [];
48
+ const drain = new ExtractionDrain({
49
+ config: {
50
+ extractionMinUserTurns: 1,
51
+ extractionMinChars: 0,
52
+ extractionMaxTurnChars: 60,
53
+ extractionChunkDropAfterFailures: 3,
54
+ },
55
+ extractionWindowBudgetChars: () => 100,
56
+ runExtraction: async (turns) => {
57
+ seenChunks.push(turns.map((turn) => turn.content.length).join("+"));
58
+ return turns[0]?.extractionPartOf?.part === 1 ? DONE : FAILED;
59
+ },
60
+ getStorage: async () => ({
61
+ saveDroppedExtractionChunk: async (_bufferKey, reason) => {
62
+ droppedReasons.push(reason);
63
+ return "/recovery/part-parent.json";
64
+ },
65
+ }),
66
+ buffer,
67
+ });
68
+
69
+ const turns = [parent];
70
+ let lastResult: ExtractionRunResult | undefined;
71
+ for (let pass = 0; pass < 4; pass += 1) {
72
+ lastResult = await drain.run(turns, {
73
+ bufferKey: "s1",
74
+ clearBufferAfterExtraction: true,
75
+ clearMatchingTurns: false,
76
+ skipUserTurnThreshold: false,
77
+ failOnExtractionFailure: false,
78
+ forceExtractionAttempt: false,
79
+ });
80
+ }
81
+
82
+ assert.ok(
83
+ droppedReasons.length > 0,
84
+ `the failing part must reach the drop threshold; passes ran ${seenChunks.length} chunks, last ${JSON.stringify(lastResult)}`
85
+ );
86
+ // The recovery copy preserves the parent's full content, not a slice.
87
+ assert.ok(droppedReasons[0]?.includes("dropped after 3"), droppedReasons[0]);
88
+ } finally {
89
+ await rm(root, { recursive: true, force: true });
90
+ }
91
+ });
package/src/types.ts CHANGED
@@ -1703,13 +1703,12 @@ export interface PluginConfig
1703
1703
  extractionBreakerCooldownMs: number;
1704
1704
  /** Breaker open cooldown (ms) for auth/config failures (longer — provider is misconfigured). */
1705
1705
  extractionBreakerAuthCooldownMs: number;
1706
- /**
1707
- * Consecutive failed extraction attempts after which the failing
1708
- * trigger-drain chunk is dropped (with a side-file copy under
1709
- * `state/dropped/`) so a session whose window never extracts cannot stall
1710
- * the buffer forever. Default: `5`.
1711
- */
1706
+ /** Consecutive failed extraction attempts after which the failing
1707
+ * trigger-drain chunk is dropped (side-file copy under `state/dropped/`). Default: `5`. */
1712
1708
  extractionChunkDropAfterFailures: number;
1709
+ /** Maximum rendered characters per extraction call; oversized turns split
1710
+ * into verbatim `extractionPartOf` parts so every part is extracted. Default: `12000`. */
1711
+ extractionCallMaxChars: number;
1713
1712
  // Local LLM fast tier (v9.1) — smaller model for quick ops
1714
1713
  localLlmFastEnabled: boolean;
1715
1714
  localLlmFastModel: string;