@remnic/core 10.0.173 → 10.0.174

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 (267) hide show
  1. package/dist/access-admin-ops-surface.js +71 -70
  2. package/dist/access-cli.js +71 -70
  3. package/dist/access-cli.js.map +1 -1
  4. package/dist/access-coding-context-resolution.js +3 -3
  5. package/dist/access-extraction-force-flush-preempt.js +71 -70
  6. package/dist/access-extraction-force-flush.js +71 -70
  7. package/dist/access-http-briefing.js +71 -70
  8. package/dist/access-http-query.js +71 -70
  9. package/dist/access-http.js +71 -70
  10. package/dist/access-identity-continuity-surface.js +71 -70
  11. package/dist/access-lcm-surface.js +71 -70
  12. package/dist/access-mcp.js +71 -70
  13. package/dist/access-memory-search-fanout.js +3 -3
  14. package/dist/access-observe-objective-state.js +2 -2
  15. package/dist/access-observe-write-surface.js +71 -70
  16. package/dist/access-offline-manifest.js +6 -6
  17. package/dist/access-operations-batch.js +71 -70
  18. package/dist/access-operations.js +71 -70
  19. package/dist/access-recall-concurrency.js +71 -70
  20. package/dist/access-recall-diagnostics.js +4 -4
  21. package/dist/access-recall-response.js +71 -70
  22. package/dist/access-recall-surface.js +71 -70
  23. package/dist/access-service.js +71 -70
  24. package/dist/active-memory-bridge.js +3 -3
  25. package/dist/active-recall.js +7 -7
  26. package/dist/{auto-sync-ACP5U5A3.js → auto-sync-IUKNPMNI.js} +5 -5
  27. package/dist/briefing.js +6 -6
  28. package/dist/buffer.js +5 -5
  29. package/dist/calibration.js +3 -3
  30. package/dist/capabilities.d.ts +5 -3
  31. package/dist/capabilities.d.ts.map +1 -1
  32. package/dist/capabilities.js +1 -1
  33. package/dist/causal-consolidation.js +7 -7
  34. package/dist/{chunk-A2XFG462.js → chunk-27BH67PT.js} +2 -2
  35. package/dist/{chunk-SA2YALFU.js → chunk-2GQVYLQK.js} +2 -2
  36. package/dist/{chunk-YVXM5QFL.js → chunk-2LWXBERZ.js} +2 -2
  37. package/dist/{chunk-XJTRIHTH.js → chunk-2WITFW6F.js} +3 -3
  38. package/dist/{chunk-YRD525ZO.js → chunk-3FEQNKMB.js} +3 -3
  39. package/dist/{chunk-QKBFVLDH.js → chunk-4ACKO4U2.js} +2 -2
  40. package/dist/{chunk-PQIFYBUX.js → chunk-4PBHMJRC.js} +2 -2
  41. package/dist/{chunk-LH57QATU.js → chunk-4WOEEMGK.js} +3 -3
  42. package/dist/{chunk-W35ICLYZ.js → chunk-5MTKGNZ5.js} +3 -3
  43. package/dist/{chunk-5PHOU5QI.js → chunk-5OBYISRA.js} +2 -2
  44. package/dist/{chunk-NDPS6OU2.js → chunk-63FIQIER.js} +2 -2
  45. package/dist/{chunk-7SNEJNA3.js → chunk-6OMSYPOL.js} +4 -4
  46. package/dist/{chunk-YSATDEBY.js → chunk-A6JDNYXE.js} +2 -2
  47. package/dist/{chunk-ETTV5F53.js → chunk-AM6H7BIY.js} +2 -2
  48. package/dist/{chunk-SOQOUZ2Y.js → chunk-ASWECJXS.js} +4 -4
  49. package/dist/{chunk-LAOJHOTG.js → chunk-BN5SK2RZ.js} +2 -2
  50. package/dist/{chunk-ESG6ITGP.js → chunk-CA5MRHBP.js} +2 -2
  51. package/dist/{chunk-JFMMEHVG.js → chunk-CWOMCAUE.js} +2 -2
  52. package/dist/{chunk-GUF2JKG5.js → chunk-DMPZABKG.js} +2 -2
  53. package/dist/{chunk-JVBAPAWZ.js → chunk-DPPIBEGC.js} +2 -2
  54. package/dist/{chunk-QRCE77YX.js → chunk-EXGY5TPU.js} +4 -4
  55. package/dist/{chunk-2OAFPBQB.js → chunk-FDXLO6CX.js} +3 -3
  56. package/dist/{chunk-YN2DQ2D6.js → chunk-FE43YKNJ.js} +2 -2
  57. package/dist/{chunk-ZYP4YEEI.js → chunk-G6V32Q4F.js} +2 -2
  58. package/dist/{chunk-LXSDEPEK.js → chunk-GFOLOYAR.js} +2 -2
  59. package/dist/{chunk-E53NLIAP.js → chunk-H4KIMZJD.js} +3 -3
  60. package/dist/{chunk-C6S353AG.js → chunk-HAB7LLE7.js} +2 -2
  61. package/dist/{chunk-RHQL2RIM.js → chunk-HB2PRTXX.js} +2 -2
  62. package/dist/{chunk-ZJ3CEAJD.js → chunk-IHB3JO4B.js} +2 -2
  63. package/dist/{chunk-QKAFFVSO.js → chunk-IO4AAVYZ.js} +2 -2
  64. package/dist/{chunk-EXYT52NR.js → chunk-IOBQMVVL.js} +2 -2
  65. package/dist/{chunk-7G5NTS7F.js → chunk-J66ZJW5U.js} +2 -2
  66. package/dist/{chunk-SAPC7N43.js → chunk-KMOH6W5B.js} +5 -5
  67. package/dist/{chunk-4AKPTHOO.js → chunk-KNYUEYB6.js} +2 -2
  68. package/dist/{chunk-KW4XA7GM.js → chunk-KPLKABGR.js} +2 -2
  69. package/dist/{chunk-TNRCDMQT.js → chunk-KQ473UMU.js} +2 -2
  70. package/dist/{chunk-LMJVP5CM.js → chunk-KUCMDUEZ.js} +2 -2
  71. package/dist/{chunk-EBI6FI5U.js → chunk-L3DDKXQJ.js} +4 -4
  72. package/dist/{chunk-YY5UXARJ.js → chunk-LKXW6W42.js} +3 -3
  73. package/dist/{chunk-PXY2B7BG.js → chunk-MEB4NJO7.js} +2 -2
  74. package/dist/{chunk-QCFZDYYG.js → chunk-MLNDSATI.js} +2 -2
  75. package/dist/{chunk-5JD4DXQX.js → chunk-MNDIM6JB.js} +3 -1
  76. package/dist/chunk-MNDIM6JB.js.map +1 -0
  77. package/dist/{chunk-C5LWPYS3.js → chunk-MOWZCAKS.js} +3 -1
  78. package/dist/{chunk-C5LWPYS3.js.map → chunk-MOWZCAKS.js.map} +1 -1
  79. package/dist/{chunk-SX4BR26Y.js → chunk-NT7JD6D6.js} +2 -2
  80. package/dist/{chunk-JNBSTHVT.js → chunk-NTR72OL5.js} +4 -4
  81. package/dist/{chunk-RK7SE3BL.js → chunk-NWZEDYHT.js} +2 -2
  82. package/dist/{chunk-Q7OKGBZY.js → chunk-OK3X3TBR.js} +2 -2
  83. package/dist/{chunk-X5MFCZDL.js → chunk-OWBI5477.js} +3 -3
  84. package/dist/{chunk-3MOL7YE7.js → chunk-OWD365QW.js} +6 -6
  85. package/dist/{chunk-L5EE2CXU.js → chunk-OY3IULYL.js} +2 -2
  86. package/dist/{chunk-5JCYPBY5.js → chunk-PDMGJH4K.js} +2 -2
  87. package/dist/{chunk-4LVQSHHN.js → chunk-QVXRE66C.js} +9 -9
  88. package/dist/{chunk-H6TCS5XX.js → chunk-RASE4TEF.js} +2 -2
  89. package/dist/{chunk-UFX24WNJ.js → chunk-RSUNBJ4I.js} +10 -10
  90. package/dist/{chunk-4E2Z44CV.js → chunk-SNI526DD.js} +2 -2
  91. package/dist/{chunk-QXTKN25V.js → chunk-SVXUH3FP.js} +2 -2
  92. package/dist/{chunk-BJOQQCYC.js → chunk-TOQK5A4Y.js} +3 -3
  93. package/dist/{chunk-BFZFNXOC.js → chunk-TQXKUQFX.js} +2 -2
  94. package/dist/{chunk-BGSYM3SH.js → chunk-U4ECSKQE.js} +3 -3
  95. package/dist/{chunk-Y65XX5PC.js → chunk-UBQ2ZOWA.js} +4 -4
  96. package/dist/{chunk-6VFMEBXY.js → chunk-V6MN37WG.js} +7 -7
  97. package/dist/{chunk-KSIDZDW3.js → chunk-V6UFCV6T.js} +194 -109
  98. package/dist/chunk-V6UFCV6T.js.map +1 -0
  99. package/dist/{chunk-5MA6ZQ4Z.js → chunk-VBQ3FIS2.js} +2 -2
  100. package/dist/{chunk-BVRZSI7Q.js → chunk-VN3RYYMS.js} +2 -2
  101. package/dist/chunk-VOVSZYCP.js +581 -0
  102. package/dist/chunk-VOVSZYCP.js.map +1 -0
  103. package/dist/{chunk-OGQL7QC7.js → chunk-WKNMKV52.js} +4 -4
  104. package/dist/{chunk-YE77U5HZ.js → chunk-WTFHZQXM.js} +4 -4
  105. package/dist/{chunk-UBG65KEY.js → chunk-WTYVXUKQ.js} +3 -3
  106. package/dist/{chunk-4DLGKTM6.js → chunk-XKFL2WQO.js} +2 -2
  107. package/dist/{chunk-WF2LYKOB.js → chunk-Y2LZW3EQ.js} +2 -2
  108. package/dist/{chunk-WECKZ3KT.js → chunk-Y6FJDJUK.js} +4 -4
  109. package/dist/{chunk-W2UV6VE3.js → chunk-ZKXNSPGQ.js} +2 -2
  110. package/dist/cli.js +71 -70
  111. package/dist/coding/export-okf-codegraph.js +8 -8
  112. package/dist/compounding/engine.js +8 -8
  113. package/dist/compounding/preference-consolidator.js +7 -571
  114. package/dist/compounding/preference-consolidator.js.map +1 -1
  115. package/dist/config.js +7 -7
  116. package/dist/connectors/codex-materialize-runner.js +6 -6
  117. package/dist/connectors/index.js +7 -7
  118. package/dist/contradiction/index.js +3 -3
  119. package/dist/{contradiction-scan-DTQFAW22.js → contradiction-scan-QSGW4CMA.js} +3 -3
  120. package/dist/convergence-refresh.js +8 -8
  121. package/dist/corpus-watermark.js +8 -8
  122. package/dist/day-summary.js +2 -2
  123. package/dist/embedding-fallback.js +2 -2
  124. package/dist/entity-recall-reads.js +2 -2
  125. package/dist/entity-retrieval.js +7 -7
  126. package/dist/explicit-capture.js +71 -70
  127. package/dist/extraction-judge.js +3 -3
  128. package/dist/extraction-normalization.js +3 -3
  129. package/dist/extraction-prompt.js +2 -2
  130. package/dist/extraction.js +16 -16
  131. package/dist/{first-start-migration-PPPP54X6.js → first-start-migration-CCZ5SM3V.js} +2 -2
  132. package/dist/harmonic-retrieval.js +6 -6
  133. package/dist/index.js +71 -70
  134. package/dist/local-llm.js +2 -2
  135. package/dist/location/index.js +7 -7
  136. package/dist/maintenance/memory-governance.js +6 -6
  137. package/dist/maintenance/rebuild-memory-lifecycle-ledger.js +6 -6
  138. package/dist/maintenance/rebuild-memory-projection-runner.js +8 -8
  139. package/dist/maintenance/rebuild-memory-projection.js +7 -7
  140. package/dist/namespaces/migrate.js +7 -7
  141. package/dist/namespaces/principal.js +2 -2
  142. package/dist/namespaces/search.js +4 -4
  143. package/dist/namespaces/storage.js +6 -6
  144. package/dist/offline-sync-impression-drain.js +5 -5
  145. package/dist/operator-doctor-corpus.js +9 -9
  146. package/dist/operator-toolkit.js +17 -17
  147. package/dist/orchestration/backlog-scheduler.js +72 -71
  148. package/dist/orchestration/backlog-scheduler.js.map +1 -1
  149. package/dist/orchestration/buffer-drain-runner.js +72 -71
  150. package/dist/orchestration/compounding-recall-sections.d.ts +17 -0
  151. package/dist/orchestration/compounding-recall-sections.d.ts.map +1 -0
  152. package/dist/orchestration/compression-guideline-coordinator.js +2 -2
  153. package/dist/orchestration/maintenance.js +19 -19
  154. package/dist/orchestration/recall-internal.d.ts.map +1 -1
  155. package/dist/orchestrator.d.ts.map +1 -1
  156. package/dist/orchestrator.js +71 -70
  157. package/dist/recall-attempt-timing.js +3 -3
  158. package/dist/recall-navigation.js +71 -70
  159. package/dist/recall-phase2-timing.d.ts +1 -1
  160. package/dist/recall-phase2-timing.d.ts.map +1 -1
  161. package/dist/recall-phase2-timing.js +1 -1
  162. package/dist/recall-timings.js +2 -2
  163. package/dist/recall-why-service.js +5 -5
  164. package/dist/recall-why.js +3 -3
  165. package/dist/rerank-outcome.js +2 -2
  166. package/dist/{resolution-CV6QEYEZ.js → resolution-RWIGFH2W.js} +4 -4
  167. package/dist/resume-bundles.js +8 -8
  168. package/dist/search/embed-helper.js +2 -2
  169. package/dist/search/factory.js +3 -3
  170. package/dist/search/index.js +3 -3
  171. package/dist/semantic-consolidation.js +7 -7
  172. package/dist/semantic-rule-promotion.js +6 -6
  173. package/dist/semantic-rule-verifier.js +6 -6
  174. package/dist/shared-context/manager.js +2 -2
  175. package/dist/source-agent-qualifier.js +11 -11
  176. package/dist/standup/build.js +6 -6
  177. package/dist/storage.js +5 -5
  178. package/dist/summarizer.js +3 -3
  179. package/dist/support-passport/index.js +3 -3
  180. package/dist/{tier-stats-XWJSVEHC.js → tier-stats-DXIBRUZH.js} +2 -2
  181. package/dist/transfer/export-okf.js +6 -6
  182. package/dist/verified-recall.js +6 -6
  183. package/dist/who-knows-cli.js +7 -7
  184. package/dist/who-knows.js +6 -6
  185. package/package.json +2 -2
  186. package/src/capabilities.test.ts +6 -4
  187. package/src/capabilities.ts +7 -7
  188. package/src/irc-preference-recall.test.ts +85 -0
  189. package/src/orchestration/compounding-recall-sections.ts +134 -0
  190. package/src/orchestration/recall-internal.ts +34 -48
  191. package/src/orchestrator.ts +0 -3
  192. package/src/recall-phase2-timing.ts +2 -0
  193. package/dist/chunk-5JD4DXQX.js.map +0 -1
  194. package/dist/chunk-KSIDZDW3.js.map +0 -1
  195. /package/dist/{auto-sync-ACP5U5A3.js.map → auto-sync-IUKNPMNI.js.map} +0 -0
  196. /package/dist/{chunk-A2XFG462.js.map → chunk-27BH67PT.js.map} +0 -0
  197. /package/dist/{chunk-SA2YALFU.js.map → chunk-2GQVYLQK.js.map} +0 -0
  198. /package/dist/{chunk-YVXM5QFL.js.map → chunk-2LWXBERZ.js.map} +0 -0
  199. /package/dist/{chunk-XJTRIHTH.js.map → chunk-2WITFW6F.js.map} +0 -0
  200. /package/dist/{chunk-YRD525ZO.js.map → chunk-3FEQNKMB.js.map} +0 -0
  201. /package/dist/{chunk-QKBFVLDH.js.map → chunk-4ACKO4U2.js.map} +0 -0
  202. /package/dist/{chunk-PQIFYBUX.js.map → chunk-4PBHMJRC.js.map} +0 -0
  203. /package/dist/{chunk-LH57QATU.js.map → chunk-4WOEEMGK.js.map} +0 -0
  204. /package/dist/{chunk-W35ICLYZ.js.map → chunk-5MTKGNZ5.js.map} +0 -0
  205. /package/dist/{chunk-5PHOU5QI.js.map → chunk-5OBYISRA.js.map} +0 -0
  206. /package/dist/{chunk-NDPS6OU2.js.map → chunk-63FIQIER.js.map} +0 -0
  207. /package/dist/{chunk-7SNEJNA3.js.map → chunk-6OMSYPOL.js.map} +0 -0
  208. /package/dist/{chunk-YSATDEBY.js.map → chunk-A6JDNYXE.js.map} +0 -0
  209. /package/dist/{chunk-ETTV5F53.js.map → chunk-AM6H7BIY.js.map} +0 -0
  210. /package/dist/{chunk-SOQOUZ2Y.js.map → chunk-ASWECJXS.js.map} +0 -0
  211. /package/dist/{chunk-LAOJHOTG.js.map → chunk-BN5SK2RZ.js.map} +0 -0
  212. /package/dist/{chunk-ESG6ITGP.js.map → chunk-CA5MRHBP.js.map} +0 -0
  213. /package/dist/{chunk-JFMMEHVG.js.map → chunk-CWOMCAUE.js.map} +0 -0
  214. /package/dist/{chunk-GUF2JKG5.js.map → chunk-DMPZABKG.js.map} +0 -0
  215. /package/dist/{chunk-JVBAPAWZ.js.map → chunk-DPPIBEGC.js.map} +0 -0
  216. /package/dist/{chunk-QRCE77YX.js.map → chunk-EXGY5TPU.js.map} +0 -0
  217. /package/dist/{chunk-2OAFPBQB.js.map → chunk-FDXLO6CX.js.map} +0 -0
  218. /package/dist/{chunk-YN2DQ2D6.js.map → chunk-FE43YKNJ.js.map} +0 -0
  219. /package/dist/{chunk-ZYP4YEEI.js.map → chunk-G6V32Q4F.js.map} +0 -0
  220. /package/dist/{chunk-LXSDEPEK.js.map → chunk-GFOLOYAR.js.map} +0 -0
  221. /package/dist/{chunk-E53NLIAP.js.map → chunk-H4KIMZJD.js.map} +0 -0
  222. /package/dist/{chunk-C6S353AG.js.map → chunk-HAB7LLE7.js.map} +0 -0
  223. /package/dist/{chunk-RHQL2RIM.js.map → chunk-HB2PRTXX.js.map} +0 -0
  224. /package/dist/{chunk-ZJ3CEAJD.js.map → chunk-IHB3JO4B.js.map} +0 -0
  225. /package/dist/{chunk-QKAFFVSO.js.map → chunk-IO4AAVYZ.js.map} +0 -0
  226. /package/dist/{chunk-EXYT52NR.js.map → chunk-IOBQMVVL.js.map} +0 -0
  227. /package/dist/{chunk-7G5NTS7F.js.map → chunk-J66ZJW5U.js.map} +0 -0
  228. /package/dist/{chunk-SAPC7N43.js.map → chunk-KMOH6W5B.js.map} +0 -0
  229. /package/dist/{chunk-4AKPTHOO.js.map → chunk-KNYUEYB6.js.map} +0 -0
  230. /package/dist/{chunk-KW4XA7GM.js.map → chunk-KPLKABGR.js.map} +0 -0
  231. /package/dist/{chunk-TNRCDMQT.js.map → chunk-KQ473UMU.js.map} +0 -0
  232. /package/dist/{chunk-LMJVP5CM.js.map → chunk-KUCMDUEZ.js.map} +0 -0
  233. /package/dist/{chunk-EBI6FI5U.js.map → chunk-L3DDKXQJ.js.map} +0 -0
  234. /package/dist/{chunk-YY5UXARJ.js.map → chunk-LKXW6W42.js.map} +0 -0
  235. /package/dist/{chunk-PXY2B7BG.js.map → chunk-MEB4NJO7.js.map} +0 -0
  236. /package/dist/{chunk-QCFZDYYG.js.map → chunk-MLNDSATI.js.map} +0 -0
  237. /package/dist/{chunk-SX4BR26Y.js.map → chunk-NT7JD6D6.js.map} +0 -0
  238. /package/dist/{chunk-JNBSTHVT.js.map → chunk-NTR72OL5.js.map} +0 -0
  239. /package/dist/{chunk-RK7SE3BL.js.map → chunk-NWZEDYHT.js.map} +0 -0
  240. /package/dist/{chunk-Q7OKGBZY.js.map → chunk-OK3X3TBR.js.map} +0 -0
  241. /package/dist/{chunk-X5MFCZDL.js.map → chunk-OWBI5477.js.map} +0 -0
  242. /package/dist/{chunk-3MOL7YE7.js.map → chunk-OWD365QW.js.map} +0 -0
  243. /package/dist/{chunk-L5EE2CXU.js.map → chunk-OY3IULYL.js.map} +0 -0
  244. /package/dist/{chunk-5JCYPBY5.js.map → chunk-PDMGJH4K.js.map} +0 -0
  245. /package/dist/{chunk-4LVQSHHN.js.map → chunk-QVXRE66C.js.map} +0 -0
  246. /package/dist/{chunk-H6TCS5XX.js.map → chunk-RASE4TEF.js.map} +0 -0
  247. /package/dist/{chunk-UFX24WNJ.js.map → chunk-RSUNBJ4I.js.map} +0 -0
  248. /package/dist/{chunk-4E2Z44CV.js.map → chunk-SNI526DD.js.map} +0 -0
  249. /package/dist/{chunk-QXTKN25V.js.map → chunk-SVXUH3FP.js.map} +0 -0
  250. /package/dist/{chunk-BJOQQCYC.js.map → chunk-TOQK5A4Y.js.map} +0 -0
  251. /package/dist/{chunk-BFZFNXOC.js.map → chunk-TQXKUQFX.js.map} +0 -0
  252. /package/dist/{chunk-BGSYM3SH.js.map → chunk-U4ECSKQE.js.map} +0 -0
  253. /package/dist/{chunk-Y65XX5PC.js.map → chunk-UBQ2ZOWA.js.map} +0 -0
  254. /package/dist/{chunk-6VFMEBXY.js.map → chunk-V6MN37WG.js.map} +0 -0
  255. /package/dist/{chunk-5MA6ZQ4Z.js.map → chunk-VBQ3FIS2.js.map} +0 -0
  256. /package/dist/{chunk-BVRZSI7Q.js.map → chunk-VN3RYYMS.js.map} +0 -0
  257. /package/dist/{chunk-OGQL7QC7.js.map → chunk-WKNMKV52.js.map} +0 -0
  258. /package/dist/{chunk-YE77U5HZ.js.map → chunk-WTFHZQXM.js.map} +0 -0
  259. /package/dist/{chunk-UBG65KEY.js.map → chunk-WTYVXUKQ.js.map} +0 -0
  260. /package/dist/{chunk-4DLGKTM6.js.map → chunk-XKFL2WQO.js.map} +0 -0
  261. /package/dist/{chunk-WF2LYKOB.js.map → chunk-Y2LZW3EQ.js.map} +0 -0
  262. /package/dist/{chunk-WECKZ3KT.js.map → chunk-Y6FJDJUK.js.map} +0 -0
  263. /package/dist/{chunk-W2UV6VE3.js.map → chunk-ZKXNSPGQ.js.map} +0 -0
  264. /package/dist/{contradiction-scan-DTQFAW22.js.map → contradiction-scan-QSGW4CMA.js.map} +0 -0
  265. /package/dist/{first-start-migration-PPPP54X6.js.map → first-start-migration-CCZ5SM3V.js.map} +0 -0
  266. /package/dist/{resolution-CV6QEYEZ.js.map → resolution-RWIGFH2W.js.map} +0 -0
  267. /package/dist/{tier-stats-XWJSVEHC.js.map → tier-stats-DXIBRUZH.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/orchestration/backlog-scheduler.ts"],"sourcesContent":["/**\n * Daemon-owned extraction backlog scheduler.\n *\n * ONE bounded in-process loop that owns ALL persisted extraction backlog:\n * at startup (existing drain claims + buffered sessions), on every poll tick\n * (new persisted work), and by retrying keys that are still pending — with\n * bounded memory (per-key COUNTS only; candidate scans never retain turn\n * payloads) and bounded outstanding work (the extraction queue's own\n * maxConcurrency gates submissions, so live foreground work keeps its share\n * of the queue).\n *\n * Claim authority: an existing claim — including an EMPTY ack tombstone — is\n * authoritative over the live buffer's in-memory copy. A tombstoned key is\n * never re-claimed or counted as work; new ingress consumes the tombstone\n * through the native save handover, which is what makes the key a candidate\n * again. Claim creation is fenced: the key is reserved synchronously on the\n * extraction queue BEFORE the async claim decision, so a queued live task for\n * the same key cannot start past the claimed-session gate until the decision\n * settles; live capture continues via the native merge-into-claim protocol.\n *\n * Failed, deferred, or policy-denied outcomes keep their turns durable in the\n * claim and re-submit after backoff (exponential from `retryBaseMs` to\n * `retryMaxMs`, reset by progress; denials wait the full max) — never a busy\n * retry. `stop()` aborts in-flight drains at their chunk boundary and leaves\n * every claim retryable; a restarted daemon's scheduler adopts them.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { hostname } from \"node:os\";\nimport { resolveMaxTurnsPerSession } from \"../buffer-session-cap.js\";\nimport { log } from \"../logger.js\";\nimport type { Orchestrator } from \"../orchestrator.js\";\nimport type { BufferDrainClaims, DrainLease } from \"../storage/buffer-drain-claims.js\";\nimport { BufferDrainRunner } from \"./buffer-drain-runner.js\";\nimport type { DrainRunnerEvent, DrainSessionOutcome } from \"./buffer-drain-runner.js\";\nimport type { ExtractionQueueCoordinator } from \"./extraction-queue-coordinator.js\";\nimport type { ProviderBreakerSnapshot } from \"./provider-breaker.js\";\n\n/** What the scheduler needs from its host (structurally satisfied by the\n * orchestrator wiring); injectable so tests drive ticks deterministically. */\nexport interface BacklogSchedulerDeps {\n queue: Pick<ExtractionQueueCoordinator, \"tryReserveKey\" | \"releaseKeyReservation\" | \"maxConcurrency\">;\n claims: Pick<BufferDrainClaims, \"list\" | \"listPage\" | \"claimFromSessionFile\" | \"isClaimed\">;\n /** Live per-key pending counts (counts only — never turn payloads). May be\n * async: hosts with a lazily-loaded buffer load it here (idempotent). */\n liveBufferCounts():\n | Map<string, { turns: number; retainedTurns: number }>\n | Promise<Map<string, { turns: number; retainedTurns: number }>>;\n /** Create a fresh lease for a unique owner token. */\n lease(ownerId: string): DrainLease;\n /** Drain one key to quiescence (BufferDrainRunner.drainSession). */\n drainKey(\n key: string,\n options: { ownerId: string; signal: AbortSignal; onEvent?: (event: DrainRunnerEvent) => void }\n ): Promise<DrainSessionOutcome>;\n /** Shared provider circuit-breaker snapshot (the same instance the run\n * coordinator gates attempts on). While OPEN inside its cooldown window\n * the scheduler skips submission entirely — claims stay durable, and the\n * breaker's single half-open probe (one attempt through once the window\n * lapses) keeps recovery automatic. Optional: hosts without a breaker\n * never skip. */\n breakerSnapshot?(): ProviderBreakerSnapshot;\n /** Test seam: monotonic-ish clock for backoff windows. */\n now?(): number;\n /** The buffer's per-session turn cap. A live key holding this many turns\n * refuses new captures, so discovery lists it before the claim page.\n * Optional: without it, discovery keeps plain claim-page-first order. */\n maxTurnsPerSession?(): number;\n}\n\nexport interface BacklogSchedulerOptions {\n /** Optional label prefix; each scheduler instance adds a unique token. */\n ownerId?: string;\n /** Scan cadence in ms (startup + new-work + retry checks). */\n pollMs?: number;\n retryBaseMs?: number;\n retryMaxMs?: number;\n /** Bound on `stop()`'s wait for aborted drains to settle. */\n stopSettleTimeoutMs?: number;\n now?: () => number;\n}\n\nexport interface BacklogSchedulerCounters {\n /** Keys submitted to the drain (claimed or adopted) this process lifetime. */\n claimed: number;\n /** Outcomes with genuinely empty claims (durable outputs preceded ack). */\n processed: number;\n /** Sum of durable outputs (memories + entities) across processed drains. */\n durableOutputs: number;\n /** Re-submissions after a failed/deferred/denied outcome. */\n retried: number;\n denied: { keys: number; turns: number };\n failed: number;\n}\n\nexport type BacklogKeyState = \"inflight\" | \"backoff\" | \"denied\";\n\nexport interface BacklogKeySnapshot {\n key: string;\n state: BacklogKeyState;\n turnsRemaining?: number;\n reason?: string;\n}\n\nexport interface BacklogSchedulerSnapshot {\n counters: BacklogSchedulerCounters;\n inFlight: string[];\n reservedKeys: string[];\n keys: BacklogKeySnapshot[];\n}\n\ninterface KeyState {\n state: BacklogKeyState;\n nextAttemptMs: number;\n /** Last observed remaining turns; progress resets the backoff exponent. */\n turnsRemaining: number;\n reason?: string;\n backoffExponent: number;\n}\n\nconst DEFAULT_POLL_MS = 15_000;\nconst DEFAULT_RETRY_BASE_MS = 30_000;\nconst DEFAULT_RETRY_MAX_MS = 15 * 60_000;\n// Aborted drains normally settle within seconds (a chunk boundary); this only\n// bounds the pathological case, well inside the daemon's stop budget.\nconst DEFAULT_STOP_SETTLE_TIMEOUT_MS = 30_000;\n\nexport class BacklogScheduler {\n private readonly deps: BacklogSchedulerDeps;\n private readonly options: Required<Omit<BacklogSchedulerOptions, \"now\">> & Pick<BacklogSchedulerOptions, \"now\">;\n private readonly keys = new Map<string, KeyState>();\n private readonly inFlight = new Map<string, { controller: AbortController; settled: Promise<void> }>();\n private readonly reserved = new Set<string>();\n private readonly counters: BacklogSchedulerCounters = {\n claimed: 0,\n processed: 0,\n durableOutputs: 0,\n retried: 0,\n denied: { keys: 0, turns: 0 },\n failed: 0,\n };\n private claimCursor: string | undefined;\n private timer: ReturnType<typeof setInterval> | undefined;\n private ticking = false;\n private stopped = true;\n\n constructor(deps: BacklogSchedulerDeps, options: BacklogSchedulerOptions = {}) {\n this.deps = deps;\n this.options = {\n ownerId: `${options.ownerId ?? \"daemon-drain\"}-${randomUUID()}`,\n pollMs: options.pollMs ?? DEFAULT_POLL_MS,\n retryBaseMs: options.retryBaseMs ?? DEFAULT_RETRY_BASE_MS,\n retryMaxMs: options.retryMaxMs ?? DEFAULT_RETRY_MAX_MS,\n stopSettleTimeoutMs: options.stopSettleTimeoutMs ?? DEFAULT_STOP_SETTLE_TIMEOUT_MS,\n now: options.now,\n };\n }\n\n /** Idempotent. Starts the poll timer (unref'd) and runs an initial tick. */\n start(): void {\n if (!this.stopped) return;\n this.stopped = false;\n this.timer = setInterval(() => void this.tick(), this.options.pollMs);\n this.timer.unref?.();\n void this.tick();\n }\n\n /** Idempotent. Stops the timer, aborts in-flight drains (their claims stay\n * retryable) and waits up to `stopSettleTimeoutMs` for them to settle. A\n * drain that ignores abort is named in a warning and left behind: the\n * caller's later shutdown phases (orchestrator flush and dispose) must\n * still run before the service manager's kill. */\n async stop(): Promise<void> {\n if (this.stopped) return;\n this.stopped = true;\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = undefined;\n }\n const aborts: Promise<void>[] = [];\n for (const entry of this.inFlight.values()) {\n entry.controller.abort(new Error(\"backlog scheduler stopping\"));\n aborts.push(entry.settled);\n }\n const bound = Promise.withResolvers<\"timeout\">();\n const boundTimer = setTimeout(() => bound.resolve(\"timeout\"), this.options.stopSettleTimeoutMs);\n try {\n const result = await Promise.race([Promise.allSettled(aborts), bound.promise]);\n if (result === \"timeout\") {\n log.warn(\n `backlog scheduler stop: ${this.inFlight.size} drain(s) ignored abort for ${this.options.stopSettleTimeoutMs}ms; ` +\n `continuing shutdown (stuck keys: ${[...this.inFlight.keys()].join(\", \")})`,\n );\n }\n } finally {\n clearTimeout(boundTimer);\n }\n }\n\n /** Bounded snapshot for ops/watchers: counters + per-key states + live sets. */\n snapshot(): BacklogSchedulerSnapshot {\n return {\n counters: {\n claimed: this.counters.claimed,\n processed: this.counters.processed,\n durableOutputs: this.counters.durableOutputs,\n retried: this.counters.retried,\n denied: { ...this.counters.denied },\n failed: this.counters.failed,\n },\n inFlight: [...this.inFlight.keys()],\n reservedKeys: [...this.reserved],\n keys: [...this.keys.entries()].map(([key, state]) => ({\n key,\n state: state.state,\n turnsRemaining: state.turnsRemaining,\n reason: state.reason,\n })),\n };\n }\n\n /** One scan+submit pass (tests drive this instead of the timer). Waits out\n * any in-progress tick first so the pass always actually scans. */\n async tickForTest(): Promise<void> {\n // setImmediate: yields to the event loop so pending I/O (a slow first\n // scan) can finish; a microtask spin would starve it.\n while (this.ticking) await new Promise((resolve) => setImmediate(resolve));\n await this.tick();\n }\n\n /** Await the settle (slot release) of everything currently in flight,\n * optionally excluding one still-gated key (tests). */\n async settleForTest(exclude?: string): Promise<void> {\n for (;;) {\n const pending = [...this.inFlight.entries()].filter(([key]) => key !== exclude).map(([, entry]) => entry.settled);\n if (pending.length === 0) return;\n await Promise.allSettled(pending);\n }\n }\n\n private now(): number {\n return this.options.now?.() ?? Date.now();\n }\n\n private async tick(): Promise<void> {\n if (this.ticking || this.stopped) return;\n this.ticking = true;\n const cursorBeforeTick = this.claimCursor;\n try {\n // Fast bail: a breaker already open must not pay discovery I/O\n // (listPage reads and parses claim bodies on every poll). The\n // submitCandidates guard below still catches a breaker that opens\n // while discovery awaits.\n const breakerBeforeDiscovery = this.deps.breakerSnapshot?.();\n if (\n breakerBeforeDiscovery &&\n breakerBeforeDiscovery.state === \"open\" &&\n this.now() < breakerBeforeDiscovery.openUntilMs\n ) {\n return;\n }\n // stop() may land while discovery's I/O is pending: re-check before\n // submitting anything, and again per candidate.\n // A discovery failure (EACCES/EIO on the claims dir) must not reject\n // into a detached timer callback: it would be an unhandled rejection\n // that terminates the server. Log, skip this pass, retry next poll.\n let candidates: { key: string; needsClaim: boolean }[];\n try {\n candidates = await this.discoverCandidates();\n } catch (err) {\n // Discovery may have listed a page before it failed: the page cursor\n // already moved, so restore it — otherwise those claims wait for the\n // cursor to wrap instead of the next poll.\n this.claimCursor = cursorBeforeTick;\n log.warn(\n `backlog drain: discovery failed; retrying next poll: ${err instanceof Error ? err.message : String(err)}`\n );\n return;\n }\n if (this.stopped) return;\n const dropped = this.submitCandidates(candidates);\n // The concurrency bound stopped submission mid-page: rewind the page\n // cursor so the unsubmitted claims are re-listed on the next tick\n // (already-submitted ones are gated by inFlight and key backoff).\n if (dropped) this.claimCursor = cursorBeforeTick;\n } finally {\n this.ticking = false;\n }\n }\n\n /** Bounded discovery: ONE page of existing claims with pending turns */\n private async discoverCandidates(): Promise<{ key: string; needsClaim: boolean }[]> {\n const capped: { key: string; needsClaim: boolean }[] = [];\n const out: { key: string; needsClaim: boolean }[] = [];\n const seen = new Set<string>();\n const pageLimit = Math.max(this.submissionLimit() * 4, 16);\n const page = await this.deps.claims.listPage(this.claimCursor, pageLimit);\n for (const listed of page.entries) {\n seen.add(listed.key);\n out.push({ key: listed.key, needsClaim: false });\n }\n this.claimCursor = page.nextCursor;\n const turnCap = this.deps.maxTurnsPerSession?.() ?? Number.POSITIVE_INFINITY;\n for (const [key, counts] of await this.deps.liveBufferCounts()) {\n const held = counts.turns + counts.retainedTurns;\n if (held <= 0) continue;\n if (seen.has(key) || this.deps.claims.isClaimed(key)) continue;\n seen.add(key);\n (held >= turnCap ? capped : out).push({ key, needsClaim: true });\n }\n return [...capped, ...out];\n }\n\n /** Submission bound: the queue's own concurrency limit, read with the\n * documented \"0 disables\" contract — a zero limit submits nothing. */\n private submissionLimit(): number {\n if (this.deps.queue.maxConcurrency <= 0) return 0;\n return this.deps.queue.maxConcurrency;\n }\n\n /** Submit discovery candidates within the queue's concurrency bound. */\n private submitCandidates(candidates: { key: string; needsClaim: boolean }[]): boolean {\n // Breaker-open churn guard: a full attempt reads the claim, rebuilds the\n // buffer/coordinator and re-renders chunks before the breaker fails it\n // fast — pure heap pressure per poll during a provider stall. Skip while\n // the window is open; once it lapses, submissions resume and the\n // breaker's half-open probe runs as usual.\n const breaker = this.deps.breakerSnapshot?.();\n if (breaker && breaker.state === \"open\" && this.now() < breaker.openUntilMs) {\n return true;\n }\n let dropped = false;\n for (const candidate of candidates) {\n if (this.stopped || this.inFlight.size >= this.submissionLimit()) {\n dropped = true;\n break;\n }\n if (!this.candidateEligible(candidate)) continue;\n // Fence the claim decision: reserve the key synchronously BEFORE the\n // async rename so no queued task for it can pass the claimed gate in\n // the meantime. Release happens when the decision settles.\n if (candidate.needsClaim) {\n if (!this.deps.queue.tryReserveKey(candidate.key)) continue;\n this.reserved.add(candidate.key);\n }\n void this.submit(candidate.key, candidate.needsClaim);\n }\n return dropped;\n }\n\n /** inFlight is the authority for \"already submitted\" — key state only\n * exists once an outcome landed (backoff/denied gating below). */\n private candidateEligible(candidate: { key: string; needsClaim: boolean }): boolean {\n if (this.stopped || this.inFlight.size >= this.submissionLimit()) return false;\n if (this.inFlight.has(candidate.key)) return false;\n const state = this.keys.get(candidate.key);\n return !(state && this.now() < state.nextAttemptMs);\n }\n\n /** Claim (when needed), then drain one key; the reservation spans the async\n * claim decision, the queue entry carries the key afterwards. */\n private async submit(key: string, needsClaim: boolean): Promise<void> {\n const controller = new AbortController();\n const { promise: settled, resolve: settle } = Promise.withResolvers<void>();\n this.inFlight.set(key, { controller, settled });\n try {\n if (!(await this.claimForSubmit(key, needsClaim, this.options.ownerId))) return;\n // Stopped between the claim decision and the task: leave the claim\n // with its lease (it expires; the next start adopts) — never drain.\n if (this.stopped) return;\n await this.drainClaimedKey(key, controller.signal, this.options.ownerId);\n } catch (err) {\n // Claim/drain failures are scheduler-level: the claim content is\n // untouched — count failed and back off (never an unhandled rejection\n // in the detached submission).\n this.counters.failed += 1;\n const message = err instanceof Error ? err.message : String(err);\n // SAFETY: a thrown non-Error (incl. null) carries no retry hint; the\n // optional chain reads the hint off Error throws only.\n this.setBackoff(key, (err as { turnsRemaining?: number } | null | undefined)?.turnsRemaining ?? 0, message);\n log.warn(`backlog drain: ${key} submission failed: ${message}`);\n } finally {\n this.inFlight.delete(key);\n this.reserved.delete(key);\n this.deps.queue.releaseKeyReservation(key);\n settle();\n }\n }\n\n /** after all — the key goes quiet without a task. \"claimed\": ours. */\n private async claimForSubmit(key: string, needsClaim: boolean, ownerId: string): Promise<boolean> {\n if (!needsClaim) return true;\n try {\n const outcome = await this.deps.claims.claimFromSessionFile(key, this.deps.lease(ownerId));\n if (outcome === \"empty\") {\n this.keys.delete(key);\n return false;\n }\n return true;\n } finally {\n this.reserved.delete(key);\n this.deps.queue.releaseKeyReservation(key);\n }\n }\n\n /** Drain one claimed key. drainKey reports failures as outcomes; a thrown\n * error still means the claim content is intact — count it failed and\n * back off. */\n private async drainClaimedKey(key: string, signal: AbortSignal, ownerId: string): Promise<void> {\n this.counters.claimed += 1;\n try {\n const outcome = await this.deps.drainKey(key, {\n ownerId,\n signal,\n });\n this.applyOutcome(key, outcome);\n } catch (err) {\n this.counters.failed += 1;\n const message = err instanceof Error ? err.message : String(err);\n // SAFETY: a thrown non-Error (incl. null) carries no retry hint; the\n // optional chain reads the hint off Error throws only.\n this.setBackoff(key, (err as { turnsRemaining?: number } | null | undefined)?.turnsRemaining ?? 0, message);\n log.warn(`backlog drain: ${key} threw: ${message}`);\n }\n }\n\n private applyOutcome(key: string, outcome: DrainSessionOutcome): void {\n const deniedTurns = outcome.denied?.reduce((sum, entry) => sum + entry.turns, 0) ?? 0;\n const previous = this.keys.get(key);\n const progressed = outcome.turnsRemaining < (previous?.turnsRemaining ?? Number.POSITIVE_INFINITY);\n if (outcome.status === \"drained\") {\n // The claim is now an empty tombstone: authoritative, nothing pending.\n // New ingress consumes it via the native save path and re-candidates.\n this.keys.delete(key);\n this.counters.processed += 1;\n this.counters.durableOutputs += outcome.durableOutputCount;\n log.info(\n `backlog drain: ${key} drained (${outcome.turnsAtStart} turn(s), ${outcome.durableOutputCount} durable output(s))`\n );\n return;\n }\n this.recordNonDrainedCounters(previous, outcome, deniedTurns);\n const denied = deniedTurns > 0 && outcome.turnsRemaining > 0;\n this.keys.set(key, this.nextKeyState(previous, outcome, denied, progressed));\n log.info(\n `backlog drain: ${key} ${outcome.status} (${outcome.turnsRemaining} turn(s) remaining` +\n `${denied ? `, denied: ${deniedTurns}` : \"\"}${outcome.reason ? `, ${outcome.reason}` : \"\"})`\n );\n }\n\n /** Denied backlog counters for a non-drained outcome. */\n private recordNonDrainedCounters(\n previous: KeyState | undefined,\n outcome: DrainSessionOutcome,\n deniedTurns: number\n ): void {\n if (deniedTurns > 0) {\n this.counters.denied.keys += 1;\n this.counters.denied.turns += deniedTurns;\n }\n if (outcome.status === \"failed\") this.counters.failed += 1;\n else if (previous !== undefined && (previous.state === \"backoff\" || previous.state === \"denied\"))\n this.counters.retried += 1;\n }\n\n /** The post-drain key state: denial waits the full max window (its content\n * is valid but currently unauthorized); progress resets the exponent. */\n private nextKeyState(\n previous: KeyState | undefined,\n outcome: DrainSessionOutcome,\n denied: boolean,\n progressed: boolean\n ): KeyState {\n return {\n state: denied ? \"denied\" : \"backoff\",\n nextAttemptMs: this.now() + this.backoffMs(previous, progressed && !denied),\n turnsRemaining: outcome.turnsRemaining,\n reason: outcome.reason,\n backoffExponent: this.nextBackoffExponent(denied, progressed, previous),\n };\n }\n\n private nextBackoffExponent(denied: boolean, progressed: boolean, previous: KeyState | undefined): number {\n return denied || !progressed ? (previous?.backoffExponent ?? 0) + 1 : 0;\n }\n\n private backoffMs(previous: KeyState | undefined, progressed: boolean): number {\n if (previous?.state === \"denied\") return this.options.retryMaxMs;\n const exponent = progressed ? 0 : (previous?.backoffExponent ?? 0) + 1;\n return Math.min(this.options.retryBaseMs * 2 ** exponent, this.options.retryMaxMs);\n }\n\n private setBackoff(key: string, turnsRemaining: number, reason: string): void {\n const previous = this.keys.get(key);\n this.keys.set(key, {\n state: \"backoff\",\n nextAttemptMs: this.now() + this.backoffMs(previous, false),\n turnsRemaining,\n reason,\n backoffExponent: (previous?.backoffExponent ?? 0) + 1,\n });\n }\n}\n\n/** Lease lifetime for claims the scheduler takes (matches the runner default). */\nconst SCHEDULER_LEASE_MS = 120_000;\n\n/** Wire the scheduler to an orchestrator's own queue, claim store, live buffer\n * counts and drain runner — the daemon's single ownership point. */\nexport function wireBacklogScheduler(\n orchestrator: Orchestrator,\n options: BacklogSchedulerOptions = {}\n): BacklogScheduler {\n const runner = new BufferDrainRunner(orchestrator);\n return new BacklogScheduler(\n {\n queue: orchestrator.extractionQueueCoordinator,\n claims: orchestrator.storage.bufferDrainClaims(),\n liveBufferCounts: async () => {\n // The daemon's buffer may be lazy: ensure the persisted state is in\n // memory before counting (load is guarded/idempotent).\n await orchestrator.buffer.load();\n return orchestrator.buffer.entryCounts();\n },\n lease: (ownerId) => {\n const now = new Date().toISOString();\n return {\n ownerId,\n pid: process.pid,\n host: hostname(),\n acquiredAt: now,\n heartbeatAt: now,\n leaseMs: SCHEDULER_LEASE_MS,\n };\n },\n drainKey: (key, drainOptions) => runner.drainSession(key, drainOptions),\n // The orchestrator's one shared provider breaker (foreground and every\n // claim-backed drain accumulate toward the same threshold).\n breakerSnapshot: () => orchestrator.getExtractionResilienceStatus().breaker,\n maxTurnsPerSession: () => resolveMaxTurnsPerSession(orchestrator.config.bufferMaxTurnsPerSession),\n },\n options\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AA4FzB,IAAM,kBAAkB;AACxB,IAAM,wBAAwB;AAC9B,IAAM,uBAAuB,KAAK;AAGlC,IAAM,iCAAiC;AAEhC,IAAM,mBAAN,MAAuB;AAAA,EACX;AAAA,EACA;AAAA,EACA,OAAO,oBAAI,IAAsB;AAAA,EACjC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AK;AAAA,IACtD,CAAC;AAAA,EACH;AACF;AAGA,IAAM,qBAAqB;AAIpB,SAAS,qBACd,cACA,UAAmC,CAAC,GAClB;AAClB,QAAM,SAAS,IAAI,kBAAkB,YAAY;AACjD,SAAO,IAAI;AAAA,IACT;AAAA,MACE,OAAO,aAAa;AAAA,MACpB,QAAQ,aAAa,QAAQ,kBAAkB;AAAA,MAC/C,kBAAkB,YAAY;AAG5B,cAAM,aAAa,OAAO,KAAK;AAC/B,eAAO,aAAa,OAAO,YAAY;AAAA,MACzC;AAAA,MACA,OAAO,CAAC,YAAY;AAClB,cAAM,OAAM,oBAAI,KAAK,GAAE,YAAY;AACnC,eAAO;AAAA,UACL;AAAA,UACA,KAAK,QAAQ;AAAA,UACb,MAAM,SAAS;AAAA,UACf,YAAY;AAAA,UACZ,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,KAAK,iBAAiB,OAAO,aAAa,KAAK,YAAY;AAAA;AAAA;AAAA,MAGtE,iBAAiB,MAAM,aAAa,8BAA8B,EAAE;AAAA,MACpE,oBAAoB,MAAM,0BAA0B,aAAa,OAAO,wBAAwB;AAAA,IAClG;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/orchestration/backlog-scheduler.ts"],"sourcesContent":["/**\n * Daemon-owned extraction backlog scheduler.\n *\n * ONE bounded in-process loop that owns ALL persisted extraction backlog:\n * at startup (existing drain claims + buffered sessions), on every poll tick\n * (new persisted work), and by retrying keys that are still pending — with\n * bounded memory (per-key COUNTS only; candidate scans never retain turn\n * payloads) and bounded outstanding work (the extraction queue's own\n * maxConcurrency gates submissions, so live foreground work keeps its share\n * of the queue).\n *\n * Claim authority: an existing claim — including an EMPTY ack tombstone — is\n * authoritative over the live buffer's in-memory copy. A tombstoned key is\n * never re-claimed or counted as work; new ingress consumes the tombstone\n * through the native save handover, which is what makes the key a candidate\n * again. Claim creation is fenced: the key is reserved synchronously on the\n * extraction queue BEFORE the async claim decision, so a queued live task for\n * the same key cannot start past the claimed-session gate until the decision\n * settles; live capture continues via the native merge-into-claim protocol.\n *\n * Failed, deferred, or policy-denied outcomes keep their turns durable in the\n * claim and re-submit after backoff (exponential from `retryBaseMs` to\n * `retryMaxMs`, reset by progress; denials wait the full max) — never a busy\n * retry. `stop()` aborts in-flight drains at their chunk boundary and leaves\n * every claim retryable; a restarted daemon's scheduler adopts them.\n */\n\nimport { randomUUID } from \"node:crypto\";\nimport { hostname } from \"node:os\";\nimport { resolveMaxTurnsPerSession } from \"../buffer-session-cap.js\";\nimport { log } from \"../logger.js\";\nimport type { Orchestrator } from \"../orchestrator.js\";\nimport type { BufferDrainClaims, DrainLease } from \"../storage/buffer-drain-claims.js\";\nimport { BufferDrainRunner } from \"./buffer-drain-runner.js\";\nimport type { DrainRunnerEvent, DrainSessionOutcome } from \"./buffer-drain-runner.js\";\nimport type { ExtractionQueueCoordinator } from \"./extraction-queue-coordinator.js\";\nimport type { ProviderBreakerSnapshot } from \"./provider-breaker.js\";\n\n/** What the scheduler needs from its host (structurally satisfied by the\n * orchestrator wiring); injectable so tests drive ticks deterministically. */\nexport interface BacklogSchedulerDeps {\n queue: Pick<ExtractionQueueCoordinator, \"tryReserveKey\" | \"releaseKeyReservation\" | \"maxConcurrency\">;\n claims: Pick<BufferDrainClaims, \"list\" | \"listPage\" | \"claimFromSessionFile\" | \"isClaimed\">;\n /** Live per-key pending counts (counts only — never turn payloads). May be\n * async: hosts with a lazily-loaded buffer load it here (idempotent). */\n liveBufferCounts():\n | Map<string, { turns: number; retainedTurns: number }>\n | Promise<Map<string, { turns: number; retainedTurns: number }>>;\n /** Create a fresh lease for a unique owner token. */\n lease(ownerId: string): DrainLease;\n /** Drain one key to quiescence (BufferDrainRunner.drainSession). */\n drainKey(\n key: string,\n options: { ownerId: string; signal: AbortSignal; onEvent?: (event: DrainRunnerEvent) => void }\n ): Promise<DrainSessionOutcome>;\n /** Shared provider circuit-breaker snapshot (the same instance the run\n * coordinator gates attempts on). While OPEN inside its cooldown window\n * the scheduler skips submission entirely — claims stay durable, and the\n * breaker's single half-open probe (one attempt through once the window\n * lapses) keeps recovery automatic. Optional: hosts without a breaker\n * never skip. */\n breakerSnapshot?(): ProviderBreakerSnapshot;\n /** Test seam: monotonic-ish clock for backoff windows. */\n now?(): number;\n /** The buffer's per-session turn cap. A live key holding this many turns\n * refuses new captures, so discovery lists it before the claim page.\n * Optional: without it, discovery keeps plain claim-page-first order. */\n maxTurnsPerSession?(): number;\n}\n\nexport interface BacklogSchedulerOptions {\n /** Optional label prefix; each scheduler instance adds a unique token. */\n ownerId?: string;\n /** Scan cadence in ms (startup + new-work + retry checks). */\n pollMs?: number;\n retryBaseMs?: number;\n retryMaxMs?: number;\n /** Bound on `stop()`'s wait for aborted drains to settle. */\n stopSettleTimeoutMs?: number;\n now?: () => number;\n}\n\nexport interface BacklogSchedulerCounters {\n /** Keys submitted to the drain (claimed or adopted) this process lifetime. */\n claimed: number;\n /** Outcomes with genuinely empty claims (durable outputs preceded ack). */\n processed: number;\n /** Sum of durable outputs (memories + entities) across processed drains. */\n durableOutputs: number;\n /** Re-submissions after a failed/deferred/denied outcome. */\n retried: number;\n denied: { keys: number; turns: number };\n failed: number;\n}\n\nexport type BacklogKeyState = \"inflight\" | \"backoff\" | \"denied\";\n\nexport interface BacklogKeySnapshot {\n key: string;\n state: BacklogKeyState;\n turnsRemaining?: number;\n reason?: string;\n}\n\nexport interface BacklogSchedulerSnapshot {\n counters: BacklogSchedulerCounters;\n inFlight: string[];\n reservedKeys: string[];\n keys: BacklogKeySnapshot[];\n}\n\ninterface KeyState {\n state: BacklogKeyState;\n nextAttemptMs: number;\n /** Last observed remaining turns; progress resets the backoff exponent. */\n turnsRemaining: number;\n reason?: string;\n backoffExponent: number;\n}\n\nconst DEFAULT_POLL_MS = 15_000;\nconst DEFAULT_RETRY_BASE_MS = 30_000;\nconst DEFAULT_RETRY_MAX_MS = 15 * 60_000;\n// Aborted drains normally settle within seconds (a chunk boundary); this only\n// bounds the pathological case, well inside the daemon's stop budget.\nconst DEFAULT_STOP_SETTLE_TIMEOUT_MS = 30_000;\n\nexport class BacklogScheduler {\n private readonly deps: BacklogSchedulerDeps;\n private readonly options: Required<Omit<BacklogSchedulerOptions, \"now\">> & Pick<BacklogSchedulerOptions, \"now\">;\n private readonly keys = new Map<string, KeyState>();\n private readonly inFlight = new Map<string, { controller: AbortController; settled: Promise<void> }>();\n private readonly reserved = new Set<string>();\n private readonly counters: BacklogSchedulerCounters = {\n claimed: 0,\n processed: 0,\n durableOutputs: 0,\n retried: 0,\n denied: { keys: 0, turns: 0 },\n failed: 0,\n };\n private claimCursor: string | undefined;\n private timer: ReturnType<typeof setInterval> | undefined;\n private ticking = false;\n private stopped = true;\n\n constructor(deps: BacklogSchedulerDeps, options: BacklogSchedulerOptions = {}) {\n this.deps = deps;\n this.options = {\n ownerId: `${options.ownerId ?? \"daemon-drain\"}-${randomUUID()}`,\n pollMs: options.pollMs ?? DEFAULT_POLL_MS,\n retryBaseMs: options.retryBaseMs ?? DEFAULT_RETRY_BASE_MS,\n retryMaxMs: options.retryMaxMs ?? DEFAULT_RETRY_MAX_MS,\n stopSettleTimeoutMs: options.stopSettleTimeoutMs ?? DEFAULT_STOP_SETTLE_TIMEOUT_MS,\n now: options.now,\n };\n }\n\n /** Idempotent. Starts the poll timer (unref'd) and runs an initial tick. */\n start(): void {\n if (!this.stopped) return;\n this.stopped = false;\n this.timer = setInterval(() => void this.tick(), this.options.pollMs);\n this.timer.unref?.();\n void this.tick();\n }\n\n /** Idempotent. Stops the timer, aborts in-flight drains (their claims stay\n * retryable) and waits up to `stopSettleTimeoutMs` for them to settle. A\n * drain that ignores abort is named in a warning and left behind: the\n * caller's later shutdown phases (orchestrator flush and dispose) must\n * still run before the service manager's kill. */\n async stop(): Promise<void> {\n if (this.stopped) return;\n this.stopped = true;\n if (this.timer) {\n clearInterval(this.timer);\n this.timer = undefined;\n }\n const aborts: Promise<void>[] = [];\n for (const entry of this.inFlight.values()) {\n entry.controller.abort(new Error(\"backlog scheduler stopping\"));\n aborts.push(entry.settled);\n }\n const bound = Promise.withResolvers<\"timeout\">();\n const boundTimer = setTimeout(() => bound.resolve(\"timeout\"), this.options.stopSettleTimeoutMs);\n try {\n const result = await Promise.race([Promise.allSettled(aborts), bound.promise]);\n if (result === \"timeout\") {\n log.warn(\n `backlog scheduler stop: ${this.inFlight.size} drain(s) ignored abort for ${this.options.stopSettleTimeoutMs}ms; ` +\n `continuing shutdown (stuck keys: ${[...this.inFlight.keys()].join(\", \")})`,\n );\n }\n } finally {\n clearTimeout(boundTimer);\n }\n }\n\n /** Bounded snapshot for ops/watchers: counters + per-key states + live sets. */\n snapshot(): BacklogSchedulerSnapshot {\n return {\n counters: {\n claimed: this.counters.claimed,\n processed: this.counters.processed,\n durableOutputs: this.counters.durableOutputs,\n retried: this.counters.retried,\n denied: { ...this.counters.denied },\n failed: this.counters.failed,\n },\n inFlight: [...this.inFlight.keys()],\n reservedKeys: [...this.reserved],\n keys: [...this.keys.entries()].map(([key, state]) => ({\n key,\n state: state.state,\n turnsRemaining: state.turnsRemaining,\n reason: state.reason,\n })),\n };\n }\n\n /** One scan+submit pass (tests drive this instead of the timer). Waits out\n * any in-progress tick first so the pass always actually scans. */\n async tickForTest(): Promise<void> {\n // setImmediate: yields to the event loop so pending I/O (a slow first\n // scan) can finish; a microtask spin would starve it.\n while (this.ticking) await new Promise((resolve) => setImmediate(resolve));\n await this.tick();\n }\n\n /** Await the settle (slot release) of everything currently in flight,\n * optionally excluding one still-gated key (tests). */\n async settleForTest(exclude?: string): Promise<void> {\n for (;;) {\n const pending = [...this.inFlight.entries()].filter(([key]) => key !== exclude).map(([, entry]) => entry.settled);\n if (pending.length === 0) return;\n await Promise.allSettled(pending);\n }\n }\n\n private now(): number {\n return this.options.now?.() ?? Date.now();\n }\n\n private async tick(): Promise<void> {\n if (this.ticking || this.stopped) return;\n this.ticking = true;\n const cursorBeforeTick = this.claimCursor;\n try {\n // Fast bail: a breaker already open must not pay discovery I/O\n // (listPage reads and parses claim bodies on every poll). The\n // submitCandidates guard below still catches a breaker that opens\n // while discovery awaits.\n const breakerBeforeDiscovery = this.deps.breakerSnapshot?.();\n if (\n breakerBeforeDiscovery &&\n breakerBeforeDiscovery.state === \"open\" &&\n this.now() < breakerBeforeDiscovery.openUntilMs\n ) {\n return;\n }\n // stop() may land while discovery's I/O is pending: re-check before\n // submitting anything, and again per candidate.\n // A discovery failure (EACCES/EIO on the claims dir) must not reject\n // into a detached timer callback: it would be an unhandled rejection\n // that terminates the server. Log, skip this pass, retry next poll.\n let candidates: { key: string; needsClaim: boolean }[];\n try {\n candidates = await this.discoverCandidates();\n } catch (err) {\n // Discovery may have listed a page before it failed: the page cursor\n // already moved, so restore it — otherwise those claims wait for the\n // cursor to wrap instead of the next poll.\n this.claimCursor = cursorBeforeTick;\n log.warn(\n `backlog drain: discovery failed; retrying next poll: ${err instanceof Error ? err.message : String(err)}`\n );\n return;\n }\n if (this.stopped) return;\n const dropped = this.submitCandidates(candidates);\n // The concurrency bound stopped submission mid-page: rewind the page\n // cursor so the unsubmitted claims are re-listed on the next tick\n // (already-submitted ones are gated by inFlight and key backoff).\n if (dropped) this.claimCursor = cursorBeforeTick;\n } finally {\n this.ticking = false;\n }\n }\n\n /** Bounded discovery: ONE page of existing claims with pending turns */\n private async discoverCandidates(): Promise<{ key: string; needsClaim: boolean }[]> {\n const capped: { key: string; needsClaim: boolean }[] = [];\n const out: { key: string; needsClaim: boolean }[] = [];\n const seen = new Set<string>();\n const pageLimit = Math.max(this.submissionLimit() * 4, 16);\n const page = await this.deps.claims.listPage(this.claimCursor, pageLimit);\n for (const listed of page.entries) {\n seen.add(listed.key);\n out.push({ key: listed.key, needsClaim: false });\n }\n this.claimCursor = page.nextCursor;\n const turnCap = this.deps.maxTurnsPerSession?.() ?? Number.POSITIVE_INFINITY;\n for (const [key, counts] of await this.deps.liveBufferCounts()) {\n const held = counts.turns + counts.retainedTurns;\n if (held <= 0) continue;\n if (seen.has(key) || this.deps.claims.isClaimed(key)) continue;\n seen.add(key);\n (held >= turnCap ? capped : out).push({ key, needsClaim: true });\n }\n return [...capped, ...out];\n }\n\n /** Submission bound: the queue's own concurrency limit, read with the\n * documented \"0 disables\" contract — a zero limit submits nothing. */\n private submissionLimit(): number {\n if (this.deps.queue.maxConcurrency <= 0) return 0;\n return this.deps.queue.maxConcurrency;\n }\n\n /** Submit discovery candidates within the queue's concurrency bound. */\n private submitCandidates(candidates: { key: string; needsClaim: boolean }[]): boolean {\n // Breaker-open churn guard: a full attempt reads the claim, rebuilds the\n // buffer/coordinator and re-renders chunks before the breaker fails it\n // fast — pure heap pressure per poll during a provider stall. Skip while\n // the window is open; once it lapses, submissions resume and the\n // breaker's half-open probe runs as usual.\n const breaker = this.deps.breakerSnapshot?.();\n if (breaker && breaker.state === \"open\" && this.now() < breaker.openUntilMs) {\n return true;\n }\n let dropped = false;\n for (const candidate of candidates) {\n if (this.stopped || this.inFlight.size >= this.submissionLimit()) {\n dropped = true;\n break;\n }\n if (!this.candidateEligible(candidate)) continue;\n // Fence the claim decision: reserve the key synchronously BEFORE the\n // async rename so no queued task for it can pass the claimed gate in\n // the meantime. Release happens when the decision settles.\n if (candidate.needsClaim) {\n if (!this.deps.queue.tryReserveKey(candidate.key)) continue;\n this.reserved.add(candidate.key);\n }\n void this.submit(candidate.key, candidate.needsClaim);\n }\n return dropped;\n }\n\n /** inFlight is the authority for \"already submitted\" — key state only\n * exists once an outcome landed (backoff/denied gating below). */\n private candidateEligible(candidate: { key: string; needsClaim: boolean }): boolean {\n if (this.stopped || this.inFlight.size >= this.submissionLimit()) return false;\n if (this.inFlight.has(candidate.key)) return false;\n const state = this.keys.get(candidate.key);\n return !(state && this.now() < state.nextAttemptMs);\n }\n\n /** Claim (when needed), then drain one key; the reservation spans the async\n * claim decision, the queue entry carries the key afterwards. */\n private async submit(key: string, needsClaim: boolean): Promise<void> {\n const controller = new AbortController();\n const { promise: settled, resolve: settle } = Promise.withResolvers<void>();\n this.inFlight.set(key, { controller, settled });\n try {\n if (!(await this.claimForSubmit(key, needsClaim, this.options.ownerId))) return;\n // Stopped between the claim decision and the task: leave the claim\n // with its lease (it expires; the next start adopts) — never drain.\n if (this.stopped) return;\n await this.drainClaimedKey(key, controller.signal, this.options.ownerId);\n } catch (err) {\n // Claim/drain failures are scheduler-level: the claim content is\n // untouched — count failed and back off (never an unhandled rejection\n // in the detached submission).\n this.counters.failed += 1;\n const message = err instanceof Error ? err.message : String(err);\n // SAFETY: a thrown non-Error (incl. null) carries no retry hint; the\n // optional chain reads the hint off Error throws only.\n this.setBackoff(key, (err as { turnsRemaining?: number } | null | undefined)?.turnsRemaining ?? 0, message);\n log.warn(`backlog drain: ${key} submission failed: ${message}`);\n } finally {\n this.inFlight.delete(key);\n this.reserved.delete(key);\n this.deps.queue.releaseKeyReservation(key);\n settle();\n }\n }\n\n /** after all — the key goes quiet without a task. \"claimed\": ours. */\n private async claimForSubmit(key: string, needsClaim: boolean, ownerId: string): Promise<boolean> {\n if (!needsClaim) return true;\n try {\n const outcome = await this.deps.claims.claimFromSessionFile(key, this.deps.lease(ownerId));\n if (outcome === \"empty\") {\n this.keys.delete(key);\n return false;\n }\n return true;\n } finally {\n this.reserved.delete(key);\n this.deps.queue.releaseKeyReservation(key);\n }\n }\n\n /** Drain one claimed key. drainKey reports failures as outcomes; a thrown\n * error still means the claim content is intact — count it failed and\n * back off. */\n private async drainClaimedKey(key: string, signal: AbortSignal, ownerId: string): Promise<void> {\n this.counters.claimed += 1;\n try {\n const outcome = await this.deps.drainKey(key, {\n ownerId,\n signal,\n });\n this.applyOutcome(key, outcome);\n } catch (err) {\n this.counters.failed += 1;\n const message = err instanceof Error ? err.message : String(err);\n // SAFETY: a thrown non-Error (incl. null) carries no retry hint; the\n // optional chain reads the hint off Error throws only.\n this.setBackoff(key, (err as { turnsRemaining?: number } | null | undefined)?.turnsRemaining ?? 0, message);\n log.warn(`backlog drain: ${key} threw: ${message}`);\n }\n }\n\n private applyOutcome(key: string, outcome: DrainSessionOutcome): void {\n const deniedTurns = outcome.denied?.reduce((sum, entry) => sum + entry.turns, 0) ?? 0;\n const previous = this.keys.get(key);\n const progressed = outcome.turnsRemaining < (previous?.turnsRemaining ?? Number.POSITIVE_INFINITY);\n if (outcome.status === \"drained\") {\n // The claim is now an empty tombstone: authoritative, nothing pending.\n // New ingress consumes it via the native save path and re-candidates.\n this.keys.delete(key);\n this.counters.processed += 1;\n this.counters.durableOutputs += outcome.durableOutputCount;\n log.info(\n `backlog drain: ${key} drained (${outcome.turnsAtStart} turn(s), ${outcome.durableOutputCount} durable output(s))`\n );\n return;\n }\n this.recordNonDrainedCounters(previous, outcome, deniedTurns);\n const denied = deniedTurns > 0 && outcome.turnsRemaining > 0;\n this.keys.set(key, this.nextKeyState(previous, outcome, denied, progressed));\n log.info(\n `backlog drain: ${key} ${outcome.status} (${outcome.turnsRemaining} turn(s) remaining` +\n `${denied ? `, denied: ${deniedTurns}` : \"\"}${outcome.reason ? `, ${outcome.reason}` : \"\"})`\n );\n }\n\n /** Denied backlog counters for a non-drained outcome. */\n private recordNonDrainedCounters(\n previous: KeyState | undefined,\n outcome: DrainSessionOutcome,\n deniedTurns: number\n ): void {\n if (deniedTurns > 0) {\n this.counters.denied.keys += 1;\n this.counters.denied.turns += deniedTurns;\n }\n if (outcome.status === \"failed\") this.counters.failed += 1;\n else if (previous !== undefined && (previous.state === \"backoff\" || previous.state === \"denied\"))\n this.counters.retried += 1;\n }\n\n /** The post-drain key state: denial waits the full max window (its content\n * is valid but currently unauthorized); progress resets the exponent. */\n private nextKeyState(\n previous: KeyState | undefined,\n outcome: DrainSessionOutcome,\n denied: boolean,\n progressed: boolean\n ): KeyState {\n return {\n state: denied ? \"denied\" : \"backoff\",\n nextAttemptMs: this.now() + this.backoffMs(previous, progressed && !denied),\n turnsRemaining: outcome.turnsRemaining,\n reason: outcome.reason,\n backoffExponent: this.nextBackoffExponent(denied, progressed, previous),\n };\n }\n\n private nextBackoffExponent(denied: boolean, progressed: boolean, previous: KeyState | undefined): number {\n return denied || !progressed ? (previous?.backoffExponent ?? 0) + 1 : 0;\n }\n\n private backoffMs(previous: KeyState | undefined, progressed: boolean): number {\n if (previous?.state === \"denied\") return this.options.retryMaxMs;\n const exponent = progressed ? 0 : (previous?.backoffExponent ?? 0) + 1;\n return Math.min(this.options.retryBaseMs * 2 ** exponent, this.options.retryMaxMs);\n }\n\n private setBackoff(key: string, turnsRemaining: number, reason: string): void {\n const previous = this.keys.get(key);\n this.keys.set(key, {\n state: \"backoff\",\n nextAttemptMs: this.now() + this.backoffMs(previous, false),\n turnsRemaining,\n reason,\n backoffExponent: (previous?.backoffExponent ?? 0) + 1,\n });\n }\n}\n\n/** Lease lifetime for claims the scheduler takes (matches the runner default). */\nconst SCHEDULER_LEASE_MS = 120_000;\n\n/** Wire the scheduler to an orchestrator's own queue, claim store, live buffer\n * counts and drain runner — the daemon's single ownership point. */\nexport function wireBacklogScheduler(\n orchestrator: Orchestrator,\n options: BacklogSchedulerOptions = {}\n): BacklogScheduler {\n const runner = new BufferDrainRunner(orchestrator);\n return new BacklogScheduler(\n {\n queue: orchestrator.extractionQueueCoordinator,\n claims: orchestrator.storage.bufferDrainClaims(),\n liveBufferCounts: async () => {\n // The daemon's buffer may be lazy: ensure the persisted state is in\n // memory before counting (load is guarded/idempotent).\n await orchestrator.buffer.load();\n return orchestrator.buffer.entryCounts();\n },\n lease: (ownerId) => {\n const now = new Date().toISOString();\n return {\n ownerId,\n pid: process.pid,\n host: hostname(),\n acquiredAt: now,\n heartbeatAt: now,\n leaseMs: SCHEDULER_LEASE_MS,\n };\n },\n drainKey: (key, drainOptions) => runner.drainSession(key, drainOptions),\n // The orchestrator's one shared provider breaker (foreground and every\n // claim-backed drain accumulate toward the same threshold).\n breakerSnapshot: () => orchestrator.getExtractionResilienceStatus().breaker,\n maxTurnsPerSession: () => resolveMaxTurnsPerSession(orchestrator.config.b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B,YAAY;AAG5B,cAAM,aAAa,OAAO,KAAK;AAC/B,eAAO,aAAa,OAAO,YAAY;AAAA,MACzC;AAAA,MACA,OAAO,CAAC,YAAY;AAClB,cAAM,OAAM,oBAAI,KAAK,GAAE,YAAY;AACnC,eAAO;AAAA,UACL;AAAA,UACA,KAAK,QAAQ;AAAA,UACb,MAAM,SAAS;AAAA,UACf,YAAY;AAAA,UACZ,aAAa;AAAA,UACb,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA,UAAU,CAAC,KAAK,iBAAiB,OAAO,aAAa,KAAK,YAAY;AAAA;AAAA;AAAA,MAGtE,iBAAiB,MAAM,aAAa,8BAA8B,EAAE;AAAA,MACpE,oBAAoB,MAAM,0BAA0B,aAAa,OAAO,wBAAwB;AAAA,IAClG;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  BufferDrainRunner,
3
3
  ClaimBufferStorage
4
- } from "../chunk-3MOL7YE7.js";
5
- import "../chunk-KSIDZDW3.js";
6
- import "../chunk-RK7SE3BL.js";
4
+ } from "../chunk-OWD365QW.js";
5
+ import "../chunk-V6UFCV6T.js";
6
+ import "../chunk-NWZEDYHT.js";
7
7
  import "../chunk-GOZXQNIM.js";
8
8
  import "../chunk-PQM3B54K.js";
9
9
  import "../chunk-W4F3C7N7.js";
@@ -24,10 +24,10 @@ import "../chunk-V5W67PQV.js";
24
24
  import "../chunk-QV2VZKD5.js";
25
25
  import "../chunk-UP6MOYCB.js";
26
26
  import "../chunk-765K3SAT.js";
27
- import "../chunk-W2UV6VE3.js";
27
+ import "../chunk-ZKXNSPGQ.js";
28
28
  import "../chunk-IFBSZGW3.js";
29
- import "../chunk-SA2YALFU.js";
30
- import "../chunk-XJTRIHTH.js";
29
+ import "../chunk-2GQVYLQK.js";
30
+ import "../chunk-2WITFW6F.js";
31
31
  import "../chunk-5ACIRCBO.js";
32
32
  import "../chunk-IMA4DJ7K.js";
33
33
  import "../chunk-FGDKJJZS.js";
@@ -35,13 +35,13 @@ import "../chunk-AJVLDJU6.js";
35
35
  import "../chunk-TBUEE7XF.js";
36
36
  import "../chunk-SZDLX763.js";
37
37
  import "../chunk-PYIFUBRK.js";
38
- import "../chunk-5PHOU5QI.js";
39
- import "../chunk-4LVQSHHN.js";
40
- import "../chunk-PQIFYBUX.js";
41
- import "../chunk-QKBFVLDH.js";
38
+ import "../chunk-5OBYISRA.js";
39
+ import "../chunk-QVXRE66C.js";
40
+ import "../chunk-4PBHMJRC.js";
41
+ import "../chunk-4ACKO4U2.js";
42
42
  import "../chunk-2X4WP4GD.js";
43
43
  import "../chunk-VZAKYDMJ.js";
44
- import "../chunk-7SNEJNA3.js";
44
+ import "../chunk-6OMSYPOL.js";
45
45
  import "../chunk-SBQOBY3S.js";
46
46
  import "../chunk-666A3MOW.js";
47
47
  import "../chunk-6PEEZSGL.js";
@@ -58,12 +58,13 @@ import "../chunk-C5JF6EZ7.js";
58
58
  import "../chunk-KBL3JJR6.js";
59
59
  import "../chunk-RZN4LQ5Y.js";
60
60
  import "../chunk-SDL22RRW.js";
61
- import "../chunk-SAPC7N43.js";
62
- import "../chunk-JVBAPAWZ.js";
61
+ import "../chunk-KMOH6W5B.js";
62
+ import "../chunk-DPPIBEGC.js";
63
+ import "../chunk-VOVSZYCP.js";
63
64
  import "../chunk-V5OCT34X.js";
64
- import "../chunk-4AKPTHOO.js";
65
+ import "../chunk-KNYUEYB6.js";
65
66
  import "../chunk-TECVW3JP.js";
66
- import "../chunk-NDPS6OU2.js";
67
+ import "../chunk-63FIQIER.js";
67
68
  import "../chunk-SQXCUH4L.js";
68
69
  import "../chunk-VQ7B2Q6M.js";
69
70
  import "../chunk-2524MOWK.js";
@@ -82,10 +83,10 @@ import "../chunk-NJAIR57U.js";
82
83
  import "../chunk-W2E2WFXL.js";
83
84
  import "../chunk-PRRWKTK6.js";
84
85
  import "../chunk-EOU6V4IN.js";
85
- import "../chunk-A2XFG462.js";
86
+ import "../chunk-27BH67PT.js";
86
87
  import "../chunk-HL4DB7TO.js";
87
- import "../chunk-LAOJHOTG.js";
88
- import "../chunk-4DLGKTM6.js";
88
+ import "../chunk-BN5SK2RZ.js";
89
+ import "../chunk-XKFL2WQO.js";
89
90
  import "../chunk-GNVZQ5JN.js";
90
91
  import "../chunk-YN2UN7N3.js";
91
92
  import "../chunk-JWX2Q6HS.js";
@@ -97,16 +98,16 @@ import "../chunk-4EX5WZ4M.js";
97
98
  import "../chunk-VHSQU3RO.js";
98
99
  import "../chunk-YRFAYOFQ.js";
99
100
  import "../chunk-KBHUGMUW.js";
100
- import "../chunk-YRD525ZO.js";
101
+ import "../chunk-3FEQNKMB.js";
101
102
  import "../chunk-HNOSWPKG.js";
102
103
  import "../chunk-77NTFICT.js";
103
104
  import "../chunk-LJLGH2DE.js";
104
105
  import "../chunk-ODZKV2F7.js";
105
106
  import "../chunk-WWDO7ZWM.js";
106
- import "../chunk-ETTV5F53.js";
107
- import "../chunk-Q7OKGBZY.js";
107
+ import "../chunk-AM6H7BIY.js";
108
+ import "../chunk-OK3X3TBR.js";
108
109
  import "../chunk-ZKE4CO6B.js";
109
- import "../chunk-WF2LYKOB.js";
110
+ import "../chunk-Y2LZW3EQ.js";
110
111
  import "../chunk-B2NXOVZN.js";
111
112
  import "../chunk-5RONA5FF.js";
112
113
  import "../chunk-ADJXJKU6.js";
@@ -120,7 +121,7 @@ import "../chunk-5CO5G4MN.js";
120
121
  import "../chunk-FEYPXEKE.js";
121
122
  import "../chunk-WBOJMAAV.js";
122
123
  import "../chunk-2KHIBLO5.js";
123
- import "../chunk-SOQOUZ2Y.js";
124
+ import "../chunk-ASWECJXS.js";
124
125
  import "../chunk-5HFVWYHL.js";
125
126
  import "../chunk-FSORYJRP.js";
126
127
  import "../chunk-X7XN6YU4.js";
@@ -147,18 +148,18 @@ import "../chunk-SOBJ6NEY.js";
147
148
  import "../chunk-T2JZF45K.js";
148
149
  import "../chunk-KAGLV5KH.js";
149
150
  import "../chunk-EVWDNKQA.js";
150
- import "../chunk-PXY2B7BG.js";
151
- import "../chunk-C6S353AG.js";
152
- import "../chunk-5JD4DXQX.js";
151
+ import "../chunk-MEB4NJO7.js";
152
+ import "../chunk-HAB7LLE7.js";
153
+ import "../chunk-MNDIM6JB.js";
153
154
  import "../chunk-ROI7BK7H.js";
154
155
  import "../chunk-3T74IZB3.js";
155
156
  import "../chunk-E5IZTY4W.js";
156
157
  import "../chunk-IJKO5RVJ.js";
157
- import "../chunk-UFX24WNJ.js";
158
- import "../chunk-JNBSTHVT.js";
158
+ import "../chunk-RSUNBJ4I.js";
159
+ import "../chunk-NTR72OL5.js";
159
160
  import "../chunk-KFY3SGN7.js";
160
161
  import "../chunk-CMTINOFS.js";
161
- import "../chunk-QKAFFVSO.js";
162
+ import "../chunk-IO4AAVYZ.js";
162
163
  import "../chunk-AQZL7JBZ.js";
163
164
  import "../chunk-2TJSGIKT.js";
164
165
  import "../chunk-UD7UNYRD.js";
@@ -184,7 +185,7 @@ import "../chunk-UOBPK2OS.js";
184
185
  import "../chunk-2YA5N2BY.js";
185
186
  import "../chunk-YLTU2DC4.js";
186
187
  import "../chunk-H7USCTPQ.js";
187
- import "../chunk-L5EE2CXU.js";
188
+ import "../chunk-OY3IULYL.js";
188
189
  import "../chunk-GXL52YZA.js";
189
190
  import "../chunk-AZEZSQ5R.js";
190
191
  import "../chunk-JA2GJCOS.js";
@@ -195,10 +196,10 @@ import "../chunk-PHRLJFWZ.js";
195
196
  import "../chunk-64NJRYU2.js";
196
197
  import "../chunk-BPPUH5JM.js";
197
198
  import "../chunk-LEO4MQ3S.js";
198
- import "../chunk-6VFMEBXY.js";
199
+ import "../chunk-V6MN37WG.js";
199
200
  import "../chunk-EI6V5UXY.js";
200
- import "../chunk-OGQL7QC7.js";
201
- import "../chunk-LXSDEPEK.js";
201
+ import "../chunk-WKNMKV52.js";
202
+ import "../chunk-GFOLOYAR.js";
202
203
  import "../chunk-SMDZTJ2D.js";
203
204
  import "../chunk-54V4BZWP.js";
204
205
  import "../chunk-2CGLBUW3.js";
@@ -213,8 +214,8 @@ import "../chunk-A6CXG5WI.js";
213
214
  import "../chunk-QJ2AX6DU.js";
214
215
  import "../chunk-ULLGI6XR.js";
215
216
  import "../chunk-PT4DZDJA.js";
216
- import "../chunk-LMJVP5CM.js";
217
- import "../chunk-BVRZSI7Q.js";
217
+ import "../chunk-KUCMDUEZ.js";
218
+ import "../chunk-VN3RYYMS.js";
218
219
  import "../chunk-MLAMXQAW.js";
219
220
  import "../chunk-AIYXVWUH.js";
220
221
  import "../chunk-LTHVM4XN.js";
@@ -239,10 +240,10 @@ import "../chunk-C37ZRXX7.js";
239
240
  import "../chunk-BUYVPUEM.js";
240
241
  import "../chunk-IAIPNEHD.js";
241
242
  import "../chunk-DGFU5MSX.js";
242
- import "../chunk-EBI6FI5U.js";
243
+ import "../chunk-L3DDKXQJ.js";
243
244
  import "../chunk-NVKO5YKP.js";
244
245
  import "../chunk-GKUA4MGB.js";
245
- import "../chunk-JFMMEHVG.js";
246
+ import "../chunk-CWOMCAUE.js";
246
247
  import "../chunk-VOLTQNAP.js";
247
248
  import "../chunk-MKYRCCSN.js";
248
249
  import "../chunk-T3GIETKV.js";
@@ -255,8 +256,8 @@ import "../chunk-VEWZZM3H.js";
255
256
  import "../chunk-OB72KNMF.js";
256
257
  import "../chunk-CIO7GCWE.js";
257
258
  import "../chunk-PYIR4SSB.js";
258
- import "../chunk-YSATDEBY.js";
259
- import "../chunk-7G5NTS7F.js";
259
+ import "../chunk-A6JDNYXE.js";
260
+ import "../chunk-J66ZJW5U.js";
260
261
  import "../chunk-VAQIBC2L.js";
261
262
  import "../chunk-HUSTM6PU.js";
262
263
  import "../chunk-SPAKBUJY.js";
@@ -266,9 +267,9 @@ import "../chunk-BFPF5N3H.js";
266
267
  import "../chunk-HRATODNO.js";
267
268
  import "../chunk-WTWQA7BB.js";
268
269
  import "../chunk-VZIAVM72.js";
269
- import "../chunk-ZJ3CEAJD.js";
270
- import "../chunk-YE77U5HZ.js";
271
- import "../chunk-LH57QATU.js";
270
+ import "../chunk-IHB3JO4B.js";
271
+ import "../chunk-WTFHZQXM.js";
272
+ import "../chunk-4WOEEMGK.js";
272
273
  import "../chunk-UFGFMWAD.js";
273
274
  import "../chunk-3DADRUGW.js";
274
275
  import "../chunk-YNDLCWXS.js";
@@ -276,18 +277,18 @@ import "../chunk-AUDJPF4N.js";
276
277
  import "../chunk-44442YCH.js";
277
278
  import "../chunk-Y4Z4I6WK.js";
278
279
  import "../chunk-TLRIRISJ.js";
279
- import "../chunk-4E2Z44CV.js";
280
- import "../chunk-E53NLIAP.js";
280
+ import "../chunk-SNI526DD.js";
281
+ import "../chunk-H4KIMZJD.js";
281
282
  import "../chunk-KJTKLXTH.js";
282
- import "../chunk-KW4XA7GM.js";
283
+ import "../chunk-KPLKABGR.js";
283
284
  import "../chunk-2DQ2XREU.js";
284
285
  import "../chunk-4NZQ7IID.js";
285
286
  import "../chunk-3I4FUAVJ.js";
286
287
  import "../chunk-OKTXM5H4.js";
287
288
  import "../chunk-D24OXEPB.js";
288
289
  import "../chunk-ZAJLJ35W.js";
289
- import "../chunk-YY5UXARJ.js";
290
- import "../chunk-RHQL2RIM.js";
290
+ import "../chunk-LKXW6W42.js";
291
+ import "../chunk-HB2PRTXX.js";
291
292
  import "../chunk-3UXOZBHV.js";
292
293
  import "../chunk-H3MLOQ7F.js";
293
294
  import "../chunk-5JMAGU26.js";
@@ -297,19 +298,19 @@ import "../chunk-2LSZVONP.js";
297
298
  import "../chunk-DEUNUKTD.js";
298
299
  import "../chunk-LXY5VVGM.js";
299
300
  import "../chunk-GKCXTSFF.js";
300
- import "../chunk-QRCE77YX.js";
301
- import "../chunk-Y65XX5PC.js";
301
+ import "../chunk-EXGY5TPU.js";
302
+ import "../chunk-UBQ2ZOWA.js";
302
303
  import "../chunk-CY2C5LM4.js";
303
304
  import "../chunk-CSAKJVXW.js";
304
305
  import "../chunk-K2XUWZBM.js";
305
306
  import "../chunk-OD4FM2U7.js";
306
- import "../chunk-BFZFNXOC.js";
307
+ import "../chunk-TQXKUQFX.js";
307
308
  import "../chunk-KYZMCH4I.js";
308
309
  import "../chunk-MJFL75J6.js";
309
310
  import "../chunk-GT2HWRST.js";
310
311
  import "../chunk-U4LUIE6Y.js";
311
312
  import "../chunk-5YQXWVCP.js";
312
- import "../chunk-YN2DQ2D6.js";
313
+ import "../chunk-FE43YKNJ.js";
313
314
  import "../chunk-WWUQ6CP3.js";
314
315
  import "../chunk-ZY2MNJR6.js";
315
316
  import "../chunk-XAIRTELU.js";
@@ -320,7 +321,7 @@ import "../chunk-HK6KYIF6.js";
320
321
  import "../chunk-2GBFKHBZ.js";
321
322
  import "../chunk-6TBIWIAG.js";
322
323
  import "../chunk-B7RWBZXW.js";
323
- import "../chunk-GUF2JKG5.js";
324
+ import "../chunk-DMPZABKG.js";
324
325
  import "../chunk-FNFURZBZ.js";
325
326
  import "../chunk-GZFKCLRC.js";
326
327
  import "../chunk-EKUI7I2X.js";
@@ -343,8 +344,8 @@ import "../chunk-MI2OTWV5.js";
343
344
  import "../chunk-43HUVDTD.js";
344
345
  import "../chunk-4RA3C3EV.js";
345
346
  import "../chunk-TOTT6S2V.js";
346
- import "../chunk-BGSYM3SH.js";
347
- import "../chunk-H6TCS5XX.js";
347
+ import "../chunk-U4ECSKQE.js";
348
+ import "../chunk-RASE4TEF.js";
348
349
  import "../chunk-ZKOPY4WW.js";
349
350
  import "../chunk-62OKGIJA.js";
350
351
  import "../chunk-J5WI4QRP.js";
@@ -355,7 +356,7 @@ import "../chunk-P32IDSHD.js";
355
356
  import "../chunk-3AUDELZL.js";
356
357
  import "../chunk-LI4APB6M.js";
357
358
  import "../chunk-Z5LAYHGJ.js";
358
- import "../chunk-TNRCDMQT.js";
359
+ import "../chunk-KQ473UMU.js";
359
360
  import "../chunk-4KQIWY4A.js";
360
361
  import "../chunk-EH3HNCAM.js";
361
362
  import "../chunk-LVTT5AUG.js";
@@ -387,21 +388,21 @@ import "../chunk-QDW3E4RD.js";
387
388
  import "../chunk-ZOJUWVAU.js";
388
389
  import "../chunk-ZJP66Q4I.js";
389
390
  import "../chunk-KFZY2OFH.js";
390
- import "../chunk-X5MFCZDL.js";
391
+ import "../chunk-OWBI5477.js";
391
392
  import "../chunk-QGVCFVX6.js";
392
393
  import "../chunk-UHVXE24Y.js";
393
394
  import "../chunk-BL7WULM5.js";
394
395
  import "../chunk-7F7HRJI2.js";
395
396
  import "../chunk-G6OFEGUR.js";
396
- import "../chunk-W35ICLYZ.js";
397
- import "../chunk-BJOQQCYC.js";
397
+ import "../chunk-5MTKGNZ5.js";
398
+ import "../chunk-TOQK5A4Y.js";
398
399
  import "../chunk-3DJ6R4CC.js";
399
400
  import "../chunk-66DUCUOC.js";
400
401
  import "../chunk-CYEPCZN5.js";
401
402
  import "../chunk-DLR3SBOM.js";
402
403
  import "../chunk-YCK26VSL.js";
403
404
  import "../chunk-WNEVEMJ3.js";
404
- import "../chunk-EXYT52NR.js";
405
+ import "../chunk-IOBQMVVL.js";
405
406
  import "../chunk-Y5NLBXPV.js";
406
407
  import "../chunk-TFA6HPOA.js";
407
408
  import "../chunk-F4TWWUMP.js";
@@ -455,9 +456,9 @@ import "../chunk-YCVB7X56.js";
455
456
  import "../chunk-B32WYRXX.js";
456
457
  import "../chunk-PQVCH2AE.js";
457
458
  import "../chunk-EMMUQUHF.js";
458
- import "../chunk-5JCYPBY5.js";
459
- import "../chunk-YVXM5QFL.js";
460
- import "../chunk-SX4BR26Y.js";
459
+ import "../chunk-PDMGJH4K.js";
460
+ import "../chunk-2LWXBERZ.js";
461
+ import "../chunk-NT7JD6D6.js";
461
462
  import "../chunk-CTVWELNK.js";
462
463
  import "../chunk-NJG63FY2.js";
463
464
  import "../chunk-YBA52OKG.js";
@@ -471,12 +472,12 @@ import "../chunk-353C5UNV.js";
471
472
  import "../chunk-X26YOFGS.js";
472
473
  import "../chunk-BT7NVCML.js";
473
474
  import "../chunk-TOSPNM4T.js";
474
- import "../chunk-ZYP4YEEI.js";
475
+ import "../chunk-G6V32Q4F.js";
475
476
  import "../chunk-HHPY5SSE.js";
476
477
  import "../chunk-QUMKDRCF.js";
477
- import "../chunk-QXTKN25V.js";
478
- import "../chunk-WECKZ3KT.js";
479
- import "../chunk-UBG65KEY.js";
478
+ import "../chunk-SVXUH3FP.js";
479
+ import "../chunk-Y6FJDJUK.js";
480
+ import "../chunk-WTYVXUKQ.js";
480
481
  import "../chunk-EHHQJTAU.js";
481
482
  import "../chunk-YYDUBGUF.js";
482
483
  import "../chunk-BNZAR6PO.js";
@@ -496,11 +497,11 @@ import "../chunk-JAKIDQB2.js";
496
497
  import "../chunk-GYOKVJPB.js";
497
498
  import "../chunk-IDYYGOOQ.js";
498
499
  import "../chunk-ZQUVBZI4.js";
499
- import "../chunk-5MA6ZQ4Z.js";
500
+ import "../chunk-VBQ3FIS2.js";
500
501
  import "../chunk-QKDXO4FD.js";
501
502
  import "../chunk-CYTTY4M2.js";
502
503
  import "../chunk-L3E7MLMK.js";
503
- import "../chunk-QCFZDYYG.js";
504
+ import "../chunk-MLNDSATI.js";
504
505
  import "../chunk-Z64TS5V4.js";
505
506
  import "../chunk-AQEJKOKI.js";
506
507
  import "../chunk-4RNBLLZR.js";
@@ -515,7 +516,7 @@ import "../chunk-2BPPGNAQ.js";
515
516
  import "../chunk-DJSJ4ULL.js";
516
517
  import "../chunk-5R627MYY.js";
517
518
  import "../chunk-F5GVIPC7.js";
518
- import "../chunk-2OAFPBQB.js";
519
+ import "../chunk-FDXLO6CX.js";
519
520
  import "../chunk-QJBULLKG.js";
520
521
  import "../chunk-NKAGGDSL.js";
521
522
  import "../chunk-AIF6V2OX.js";
@@ -545,10 +546,10 @@ import "../chunk-XZ66U5M3.js";
545
546
  import "../chunk-LQWOFU6L.js";
546
547
  import "../chunk-EBV6VXKF.js";
547
548
  import "../chunk-P7FMDTKL.js";
548
- import "../chunk-ESG6ITGP.js";
549
+ import "../chunk-CA5MRHBP.js";
549
550
  import "../chunk-PCXDUHQH.js";
550
551
  import "../chunk-VUFL7X3H.js";
551
- import "../chunk-C5LWPYS3.js";
552
+ import "../chunk-MOWZCAKS.js";
552
553
  import "../chunk-X4OZMANG.js";
553
554
  import "../chunk-YRHBSYQR.js";
554
555
  import "../chunk-SRDWJPET.js";
@@ -0,0 +1,17 @@
1
+ import { createRecallSectionMetricRecorder } from "../recall-qos.js";
2
+ import type { StorageManager } from "../storage.js";
3
+ import type { RecallInternalDeps } from "./recall-internal-deps.js";
4
+ type RecordRecallSectionMetric = ReturnType<typeof createRecallSectionMetricRecorder>;
5
+ interface SectionBuildOptions {
6
+ deps: RecallInternalDeps;
7
+ record: RecordRecallSectionMetric;
8
+ retrievalQuery: string;
9
+ deadlineMs: number;
10
+ }
11
+ export declare function buildCompoundingRecallSection(options: SectionBuildOptions): Promise<string | null>;
12
+ interface PreferenceSectionBuildOptions extends SectionBuildOptions {
13
+ profileStorages: StorageManager[];
14
+ }
15
+ export declare function buildIrcPreferencesRecallSection(options: PreferenceSectionBuildOptions): Promise<string | null>;
16
+ export {};
17
+ //# sourceMappingURL=compounding-recall-sections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compounding-recall-sections.d.ts","sourceRoot":"","sources":["../../src/orchestration/compounding-recall-sections.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,iCAAiC,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAEpE,KAAK,yBAAyB,GAAG,UAAU,CACzC,OAAO,iCAAiC,CACzC,CAAC;AAEF,UAAU,mBAAmB;IAC3B,IAAI,EAAE,kBAAkB,CAAC;IACzB,MAAM,EAAE,yBAAyB,CAAC;IAClC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,6BAA6B,CACjD,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgDxB;AAED,UAAU,6BAA8B,SAAQ,mBAAmB;IACjE,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC;AAED,wBAAsB,gCAAgC,CACpD,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkDxB"}
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  CompressionGuidelineCoordinator,
3
3
  formatCompressionGuidelinesForRecall
4
- } from "../chunk-5PHOU5QI.js";
4
+ } from "../chunk-5OBYISRA.js";
5
5
  import "../chunk-OD4FM2U7.js";
6
- import "../chunk-C5LWPYS3.js";
6
+ import "../chunk-MOWZCAKS.js";
7
7
  import "../chunk-3WCASNQZ.js";
8
8
  import "../chunk-PZ5AY32C.js";
9
9
  export {
@@ -1,20 +1,20 @@
1
1
  import {
2
2
  MaintenanceScheduler
3
- } from "../chunk-4LVQSHHN.js";
4
- import "../chunk-PQIFYBUX.js";
5
- import "../chunk-QKBFVLDH.js";
6
- import "../chunk-7SNEJNA3.js";
3
+ } from "../chunk-QVXRE66C.js";
4
+ import "../chunk-4PBHMJRC.js";
5
+ import "../chunk-4ACKO4U2.js";
6
+ import "../chunk-6OMSYPOL.js";
7
7
  import "../chunk-666A3MOW.js";
8
- import "../chunk-SAPC7N43.js";
9
- import "../chunk-JVBAPAWZ.js";
8
+ import "../chunk-KMOH6W5B.js";
9
+ import "../chunk-DPPIBEGC.js";
10
10
  import "../chunk-5CO5G4MN.js";
11
- import "../chunk-JNBSTHVT.js";
12
- import "../chunk-LH57QATU.js";
13
- import "../chunk-E53NLIAP.js";
11
+ import "../chunk-NTR72OL5.js";
12
+ import "../chunk-4WOEEMGK.js";
13
+ import "../chunk-H4KIMZJD.js";
14
14
  import "../chunk-KJTKLXTH.js";
15
- import "../chunk-KW4XA7GM.js";
15
+ import "../chunk-KPLKABGR.js";
16
16
  import "../chunk-2DQ2XREU.js";
17
- import "../chunk-BFZFNXOC.js";
17
+ import "../chunk-TQXKUQFX.js";
18
18
  import "../chunk-KYZMCH4I.js";
19
19
  import "../chunk-MJFL75J6.js";
20
20
  import "../chunk-GT2HWRST.js";
@@ -24,21 +24,21 @@ import "../chunk-YVUNHNB6.js";
24
24
  import "../chunk-TOTT6S2V.js";
25
25
  import "../chunk-J5WI4QRP.js";
26
26
  import "../chunk-EWMRFW3F.js";
27
- import "../chunk-X5MFCZDL.js";
27
+ import "../chunk-OWBI5477.js";
28
28
  import "../chunk-QGVCFVX6.js";
29
29
  import "../chunk-UHVXE24Y.js";
30
30
  import "../chunk-BL7WULM5.js";
31
31
  import "../chunk-7F7HRJI2.js";
32
32
  import "../chunk-G6OFEGUR.js";
33
- import "../chunk-W35ICLYZ.js";
34
- import "../chunk-BJOQQCYC.js";
33
+ import "../chunk-5MTKGNZ5.js";
34
+ import "../chunk-TOQK5A4Y.js";
35
35
  import "../chunk-3DJ6R4CC.js";
36
36
  import "../chunk-66DUCUOC.js";
37
37
  import "../chunk-CYEPCZN5.js";
38
38
  import "../chunk-DLR3SBOM.js";
39
39
  import "../chunk-YCK26VSL.js";
40
40
  import "../chunk-WNEVEMJ3.js";
41
- import "../chunk-EXYT52NR.js";
41
+ import "../chunk-IOBQMVVL.js";
42
42
  import "../chunk-Y5NLBXPV.js";
43
43
  import "../chunk-TFA6HPOA.js";
44
44
  import "../chunk-F4TWWUMP.js";
@@ -97,8 +97,8 @@ import "../chunk-353C5UNV.js";
97
97
  import "../chunk-X26YOFGS.js";
98
98
  import "../chunk-BT7NVCML.js";
99
99
  import "../chunk-TOSPNM4T.js";
100
- import "../chunk-WECKZ3KT.js";
101
- import "../chunk-UBG65KEY.js";
100
+ import "../chunk-Y6FJDJUK.js";
101
+ import "../chunk-WTYVXUKQ.js";
102
102
  import "../chunk-YYDUBGUF.js";
103
103
  import "../chunk-BNZAR6PO.js";
104
104
  import "../chunk-ZA53AZND.js";
@@ -123,10 +123,10 @@ import "../chunk-4D77BI3J.js";
123
123
  import "../chunk-ZEFVK7XC.js";
124
124
  import "../chunk-EBV6VXKF.js";
125
125
  import "../chunk-P7FMDTKL.js";
126
- import "../chunk-ESG6ITGP.js";
126
+ import "../chunk-CA5MRHBP.js";
127
127
  import "../chunk-PCXDUHQH.js";
128
128
  import "../chunk-VUFL7X3H.js";
129
- import "../chunk-C5LWPYS3.js";
129
+ import "../chunk-MOWZCAKS.js";
130
130
  import "../chunk-X4OZMANG.js";
131
131
  import "../chunk-R2MBW2S4.js";
132
132
  import "../chunk-NTS2RCQK.js";