deepline 0.3.534 → 0.3.536

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 (235) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +254 -147
  2. package/dist/bundling-sources/sdk/src/index.ts +4 -0
  3. package/dist/bundling-sources/sdk/src/plays/local-file-discovery.ts +27 -1
  4. package/dist/bundling-sources/sdk/src/plays/run-request.ts +16 -5
  5. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  6. package/dist/bundling-sources/sdk/src/types.ts +2 -23
  7. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-fleet-contract.ts +26 -14
  8. package/dist/bundling-sources/shared_libs/integration-contracts/monitor-input-contract.ts +33 -8
  9. package/dist/bundling-sources/shared_libs/monitors/fleets/count-drift-alert.ts +121 -0
  10. package/dist/bundling-sources/shared_libs/monitors/fleets/limits.ts +8 -0
  11. package/dist/bundling-sources/shared_libs/monitors/fleets/plan.ts +14 -82
  12. package/dist/bundling-sources/shared_libs/monitors/package.json +1 -0
  13. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +4 -4
  14. package/dist/bundling-sources/shared_libs/play-data-plane/r2.ts +0 -26
  15. package/dist/bundling-sources/shared_libs/play-runtime/activity-observation.ts +36 -0
  16. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +21 -31
  17. package/dist/bundling-sources/shared_libs/play-runtime/call-requeue-state-machine.ts +420 -0
  18. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +727 -102
  19. package/dist/bundling-sources/shared_libs/play-runtime/ctx-types.ts +26 -0
  20. package/dist/bundling-sources/shared_libs/play-runtime/durable-retry-policy.ts +624 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +12 -10
  22. package/dist/bundling-sources/shared_libs/play-runtime/durable-summary-events.ts +3 -1
  23. package/dist/bundling-sources/shared_libs/play-runtime/governor/app-runtime-rate-state-backend.ts +71 -2
  24. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +60 -1
  25. package/dist/bundling-sources/shared_libs/play-runtime/governor/rate-state-backend.ts +2 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +1 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/map-memory-limits.ts +372 -10
  28. package/dist/bundling-sources/shared_libs/play-runtime/memory-ledger.ts +15 -2
  29. package/dist/bundling-sources/shared_libs/play-runtime/output-size-limits.ts +21 -0
  30. package/dist/bundling-sources/shared_libs/play-runtime/prebuilt-result-quality.ts +1 -1
  31. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +6 -0
  32. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/fixture-capacity-simulator.ts +1 -0
  33. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/gradient2-concurrency-controller.ts +41 -0
  34. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-capacity-policy.ts +6 -0
  35. package/dist/bundling-sources/shared_libs/play-runtime/provider-capacity/provider-concurrency-policy.ts +9 -0
  36. package/dist/bundling-sources/shared_libs/play-runtime/provider-no-progress.ts +6 -2
  37. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +17 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/run-failure.ts +2 -2
  39. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +5 -2
  40. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-tool-hooks.ts +63 -3
  41. package/dist/bundling-sources/shared_libs/play-runtime/runtime-operation-contract.ts +7 -0
  42. package/dist/bundling-sources/shared_libs/play-runtime/sandbox-compute-usage.ts +31 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +6 -0
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +26 -1
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-scope.ts +11 -4
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +73 -18
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +169 -2
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-capacity.ts +26 -4
  49. package/dist/bundling-sources/shared_libs/play-runtime/tool-execute-retry-policy.ts +90 -49
  50. package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +136 -30
  51. package/dist/bundling-sources/shared_libs/plays/launch/input-contract.ts +13 -1
  52. package/dist/bundling-sources/shared_libs/plays/local-file-discovery.ts +68 -1
  53. package/dist/bundling-sources/shared_libs/plays/share/static-pipeline-summary.ts +63 -13
  54. package/dist/bundling-sources/shared_libs/product-notifications/configuration-draft.ts +57 -1
  55. package/dist/bundling-sources/shared_libs/product-notifications/configuration.ts +22 -9
  56. package/dist/cli/auth-6XQKFOLG.js +43 -0
  57. package/dist/cli/{auth-MHQYIMVX.mjs → auth-KCTCUO7P.mjs} +7 -7
  58. package/dist/cli/{billing-YQLNP4S5.js → billing-4VBGZ3CT.js} +273 -112
  59. package/dist/cli/{billing-LX2PSBJ4.mjs → billing-OOJHKLNS.mjs} +185 -24
  60. package/dist/cli/{chunk-DGKTHWWH.js → chunk-2B4IOGFD.js} +406 -382
  61. package/dist/cli/{chunk-MQORQ7WL.js → chunk-2FCSUOYN.js} +55 -55
  62. package/dist/cli/{chunk-T2N3B7IQ.js → chunk-2GJZLIKW.js} +8 -8
  63. package/dist/cli/{chunk-6IFZPEJE.mjs → chunk-2YWJS76L.mjs} +1 -1
  64. package/dist/cli/{chunk-E7TP25I2.mjs → chunk-3PCYV6ZJ.mjs} +2 -2
  65. package/dist/cli/{chunk-LGRZCHKC.js → chunk-4E5JXZ3W.js} +18 -20
  66. package/dist/cli/{chunk-R4RG4FV5.mjs → chunk-4KWD3MX2.mjs} +13 -10
  67. package/dist/cli/{chunk-SUWTLXCV.js → chunk-6BBGUQJJ.js} +67 -146
  68. package/dist/cli/{chunk-JBBJDFUJ.js → chunk-6VUGBQZQ.js} +5 -5
  69. package/dist/cli/{chunk-2P3NVX65.mjs → chunk-AB2GBOD4.mjs} +40 -27
  70. package/dist/cli/{chunk-62SOZ67Y.mjs → chunk-ANUKBZ6W.mjs} +475 -11
  71. package/dist/cli/{chunk-MG6YL4M7.mjs → chunk-BASLYGXK.mjs} +101 -77
  72. package/dist/cli/{chunk-SQWET4SL.js → chunk-BBTKAASQ.js} +2 -1
  73. package/dist/cli/{chunk-NRO3NTVO.js → chunk-CBV7AKWM.js} +5 -5
  74. package/dist/cli/{chunk-RH3YRMUY.js → chunk-CIDN5K23.js} +1 -1
  75. package/dist/cli/{chunk-QNHHZ63P.mjs → chunk-CQBIO6HW.mjs} +1 -1
  76. package/dist/cli/{chunk-2KHUFWTK.js → chunk-CQDQNZGH.js} +42 -37
  77. package/dist/cli/{chunk-UWNVFAFN.js → chunk-CWSLUNA6.js} +33 -33
  78. package/dist/cli/{chunk-5FXMEEF4.mjs → chunk-CXTW7SRW.mjs} +67 -146
  79. package/dist/cli/{chunk-O53LHONF.mjs → chunk-DA2I2M7D.mjs} +2 -2
  80. package/dist/cli/{chunk-EYXUAJAU.mjs → chunk-DQHUJMCL.mjs} +5 -5
  81. package/dist/cli/{chunk-7GFR5Y4J.mjs → chunk-DUYAMLOC.mjs} +1 -1
  82. package/dist/cli/{chunk-OMVVHX4U.mjs → chunk-E24UGPGG.mjs} +13 -15
  83. package/dist/cli/{chunk-STR5LXK4.mjs → chunk-FSIVF2SI.mjs} +1 -1
  84. package/dist/cli/{chunk-KJVY7V2X.mjs → chunk-GF32SBST.mjs} +1 -1
  85. package/dist/cli/{chunk-AK622KIG.mjs → chunk-GHLDCLSC.mjs} +1 -1
  86. package/dist/cli/{chunk-A6HNT4EE.js → chunk-GTVZKY3F.js} +2 -2
  87. package/dist/cli/{chunk-BXIUZM5N.mjs → chunk-HAJQGP5V.mjs} +2 -2
  88. package/dist/cli/{chunk-6CEUQYMB.js → chunk-HWDKRN7L.js} +3 -3
  89. package/dist/cli/{chunk-5YAJGRWB.js → chunk-IPVRMYWT.js} +7 -7
  90. package/dist/cli/{chunk-ZPGGW27Q.mjs → chunk-JL2OTMSG.mjs} +1 -0
  91. package/dist/cli/{chunk-WR4WETRU.mjs → chunk-JUHDJNSI.mjs} +4 -4
  92. package/dist/cli/{chunk-TQH3533L.mjs → chunk-KPQHUVYW.mjs} +5 -5
  93. package/dist/cli/{chunk-V7SCRUFQ.js → chunk-KWYGWO4Y.js} +9 -6
  94. package/dist/cli/{chunk-DZS4JC7I.js → chunk-LDGZFDUB.js} +2 -2
  95. package/dist/cli/{chunk-EGTUOYYG.js → chunk-LN6RXDTB.js} +523 -59
  96. package/dist/cli/{chunk-DQ5ADV2J.mjs → chunk-LZXZQPA2.mjs} +4 -1
  97. package/dist/cli/{chunk-MYSKWJMA.js → chunk-MSP4DTSD.js} +13 -13
  98. package/dist/cli/{chunk-BNH4Y35W.mjs → chunk-OLH2PHMC.mjs} +2 -2
  99. package/dist/cli/{chunk-NNAE7E23.mjs → chunk-OUDTOMZC.mjs} +7 -9
  100. package/dist/cli/{chunk-GESIFFQX.mjs → chunk-OVX3Q5Q3.mjs} +1 -1
  101. package/dist/cli/{chunk-ENCA6O2D.mjs → chunk-PNY3BWHP.mjs} +2 -2
  102. package/dist/cli/{chunk-KSA2XE4T.js → chunk-Q4MNUOS4.js} +316 -303
  103. package/dist/cli/{chunk-GTXSUPCJ.js → chunk-Q5CXV3E3.js} +2 -2
  104. package/dist/cli/{chunk-VAG5YKP6.mjs → chunk-RVSSQPQO.mjs} +1 -1
  105. package/dist/cli/{chunk-VE7ZPLN2.js → chunk-SLPJ3LXI.js} +22 -22
  106. package/dist/cli/{chunk-IX45S5VC.js → chunk-TX5TUHJN.js} +17 -19
  107. package/dist/cli/{chunk-IF75RD6U.js → chunk-U2LVWCTD.js} +18 -6
  108. package/dist/cli/{chunk-ZS2WHWWL.js → chunk-UNDLNT3V.js} +1 -1
  109. package/dist/cli/{chunk-NDFNBJGL.js → chunk-VBDZIMWD.js} +26 -26
  110. package/dist/cli/{chunk-GVGQ6NZW.js → chunk-W7AEIGZR.js} +41 -41
  111. package/dist/cli/{chunk-WDNRPZED.mjs → chunk-WC5M3JXE.mjs} +2 -2
  112. package/dist/cli/{chunk-C374C22Y.js → chunk-WOQO3GV4.js} +14 -11
  113. package/dist/cli/{chunk-MQX363YF.js → chunk-XBAH3TKU.js} +5 -5
  114. package/dist/cli/{chunk-BDWZBMGV.mjs → chunk-XJD2GYUP.mjs} +5 -5
  115. package/dist/cli/{chunk-XRZJKHUA.mjs → chunk-XVZRJJDS.mjs} +4 -4
  116. package/dist/cli/{chunk-TVINIDHB.js → chunk-Y2NTPYGS.js} +17 -17
  117. package/dist/cli/{chunk-6GTGWZJG.mjs → chunk-YBMHOH6H.mjs} +4 -4
  118. package/dist/cli/{chunk-TG2UB3A5.mjs → chunk-YRLAUGQY.mjs} +3 -3
  119. package/dist/cli/{chunk-FKD3KL5Q.mjs → chunk-Z2XA6YU4.mjs} +10 -5
  120. package/dist/cli/{chunk-KXQCUX3X.mjs → chunk-Z7UIOGW4.mjs} +3 -3
  121. package/dist/cli/{chunk-HCD36BP6.js → chunk-ZEV2Y56V.js} +44 -44
  122. package/dist/cli/{chunk-MI6ZP7XI.mjs → chunk-ZG7BOECV.mjs} +18 -6
  123. package/dist/cli/{chunk-XBK6WCVA.js → chunk-ZILSRDIN.js} +8 -8
  124. package/dist/cli/{chunk-B2AS3R5W.js → chunk-ZISEH7OL.js} +16 -16
  125. package/dist/cli/{chunk-HPJAE6PP.js → chunk-ZZ4MF2GI.js} +6 -6
  126. package/dist/cli/command-docs.js +2 -2
  127. package/dist/cli/command-docs.mjs +1 -1
  128. package/dist/cli/{csv-U3M2G76R.js → csv-2V2DIFNG.js} +15 -15
  129. package/dist/cli/{csv-4ID4E5W3.mjs → csv-P3HLK4GO.mjs} +6 -6
  130. package/dist/cli/{db-IHAQIKEQ.js → db-MREAQVW6.js} +36 -36
  131. package/dist/cli/{db-LHX5BBCZ.mjs → db-ZYOY3QRQ.mjs} +9 -9
  132. package/dist/cli/describe-IKZFOADR.mjs +49 -0
  133. package/dist/cli/describe-WW3OQRLP.js +49 -0
  134. package/dist/cli/describe-core.d.mts +3 -3
  135. package/dist/cli/describe-core.d.ts +3 -3
  136. package/dist/cli/describe-core.js +5 -5
  137. package/dist/cli/describe-core.mjs +4 -4
  138. package/dist/cli/{executions-CJ5LV23G.js → executions-H5IJ7QSQ.js} +11 -11
  139. package/dist/cli/{executions-UJ6JZUL5.mjs → executions-KTSY5M34.mjs} +9 -9
  140. package/dist/cli/{feedback-TGUBVGRP.js → feedback-724QK3Z5.js} +16 -16
  141. package/dist/cli/{feedback-YGTPJBRJ.mjs → feedback-WWJRIXEU.mjs} +8 -8
  142. package/dist/cli/git-PHYRD56H.js +25 -0
  143. package/dist/cli/{git-3DOTQHJO.mjs → git-R5VRG7X6.mjs} +7 -7
  144. package/dist/cli/index.js +151 -157
  145. package/dist/cli/index.mjs +51 -57
  146. package/dist/cli/{legacy-noops-BHEHVFHI.js → legacy-noops-C6GDEGPU.js} +11 -11
  147. package/dist/cli/{legacy-noops-RBBYRVLG.mjs → legacy-noops-PWZ5XLAO.mjs} +8 -8
  148. package/dist/cli/{monitors-XECKLAXA.js → monitors-VAVQ4WCE.js} +125 -122
  149. package/dist/cli/{monitors-5AJCG6IV.mjs → monitors-WQSKMHAP.mjs} +19 -16
  150. package/dist/cli/{org-DOBAIYWG.js → org-CWWRWXZQ.js} +89 -89
  151. package/dist/cli/{org-ZAAIEZKB.mjs → org-MAL4QPVF.mjs} +9 -9
  152. package/dist/cli/{play-KLYRMQPF.mjs → play-ILW6MSNG.mjs} +174 -80
  153. package/dist/cli/{play-E74VN6B7.js → play-WJOWK5PQ.js} +690 -596
  154. package/dist/cli/{providers-XTQXV5LB.mjs → providers-4V2NMLZZ.mjs} +9 -9
  155. package/dist/cli/{providers-APZ6SOSK.js → providers-W662ANCH.js} +12 -12
  156. package/dist/cli/{quickstart-S6WN6NWW.js → quickstart-BW6EBUYX.js} +8 -8
  157. package/dist/cli/{quickstart-X7RHHQCH.mjs → quickstart-C22BR743.mjs} +6 -6
  158. package/dist/cli/{run-3YLIJJ57.js → run-KW7KW4FX.js} +50 -53
  159. package/dist/cli/{run-TZPBBSPX.mjs → run-SPAU5IMW.mjs} +31 -34
  160. package/dist/cli/search-HLE54W5G.js +32 -0
  161. package/dist/cli/{search-VLHE2CMZ.mjs → search-XPC75HLM.mjs} +10 -11
  162. package/dist/cli/{search-output-73BYB7UE.mjs → search-output-JKYJSEPM.mjs} +6 -6
  163. package/dist/cli/{search-output-GCT7PQIT.js → search-output-VJYE7USJ.js} +8 -8
  164. package/dist/cli/{secrets-RLOTGKQZ.mjs → secrets-OJG73GXQ.mjs} +9 -9
  165. package/dist/cli/{secrets-J6CEKXKQ.js → secrets-YB57KGSB.js} +18 -18
  166. package/dist/cli/{sessions-7HZ7OZ62.mjs → sessions-7ZL37BW4.mjs} +8 -8
  167. package/dist/cli/sessions-VEBYZIEU.js +22 -0
  168. package/dist/cli/{settings-WRV5XEZC.js → settings-A7DD2ZYE.js} +88 -89
  169. package/dist/cli/{settings-72K5YCIS.mjs → settings-RKSQB7FA.mjs} +15 -16
  170. package/dist/cli/{setup-KQFY6WT4.mjs → setup-NXDUTITY.mjs} +11 -12
  171. package/dist/cli/{setup-QVXWT2EQ.js → setup-S3K5YU62.js} +51 -52
  172. package/dist/cli/skills-NVQ744CN.js +36 -0
  173. package/dist/cli/{skills-C3K3E473.mjs → skills-VMFAIDO6.mjs} +9 -10
  174. package/dist/cli/{tools-4A2OH6MB.mjs → tools-52NTHBSJ.mjs} +20 -21
  175. package/dist/cli/tools-SBDUL3WB.js +56 -0
  176. package/dist/cli/update-HHVFZPCV.js +34 -0
  177. package/dist/cli/{update-BS6USKPR.mjs → update-SAKBEKMV.mjs} +11 -12
  178. package/dist/cli/{views-WB6GFTRX.mjs → views-ACRV7MD6.mjs} +54 -10
  179. package/dist/cli/{views-4NZGAXHL.js → views-C3GJOBDG.js} +66 -22
  180. package/dist/cli/{workflow-2D4WX55R.mjs → workflow-CS22E7TC.mjs} +10 -10
  181. package/dist/cli/{workflow-L2QTQZYV.js → workflow-ZNWCZEGN.js} +20 -20
  182. package/dist/{client-DoUVSkqC.d.mts → client-BlLYQDNo.d.mts} +1 -1
  183. package/dist/{client-DQm56zMs.d.ts → client-DSQlkIDO.d.ts} +1 -1
  184. package/dist/{client-core-C7KkUIE_.d.ts → client-core-CDwapXy5.d.ts} +167 -108
  185. package/dist/{client-core-CPlwsC1Q.d.mts → client-core-rX7n2H8U.d.mts} +167 -108
  186. package/dist/{compiler-manifest-DsxsQP-T.d.mts → compiler-manifest-BHNC4RL-.d.mts} +58 -21
  187. package/dist/{compiler-manifest-DsxsQP-T.d.ts → compiler-manifest-BHNC4RL-.d.ts} +58 -21
  188. package/dist/{errors-qdJUVQ3g.d.mts → errors-D7sPXrvB.d.mts} +1 -1
  189. package/dist/{errors-Bk5h1D-C.d.ts → errors-lhtIWG5Z.d.ts} +1 -1
  190. package/dist/{index-bL66eHYz.d.ts → index-CQTBHXHr.d.ts} +1 -1
  191. package/dist/{index-PaupwX1B.d.mts → index-NaDZq2xf.d.mts} +1 -1
  192. package/dist/index.d.mts +7 -7
  193. package/dist/index.d.ts +7 -7
  194. package/dist/index.js +15 -15
  195. package/dist/index.mjs +11 -11
  196. package/dist/install-integrity.json +131 -132
  197. package/dist/monitor-fleet-contract.d.mts +17 -11
  198. package/dist/monitor-fleet-contract.d.ts +17 -11
  199. package/dist/monitor-fleet-contract.js +3 -3
  200. package/dist/monitor-fleet-contract.mjs +2 -2
  201. package/dist/monitor-input-contract.js +2 -2
  202. package/dist/monitor-input-contract.mjs +1 -1
  203. package/dist/plays/bundle-play-file.d.mts +3 -3
  204. package/dist/plays/bundle-play-file.d.ts +3 -3
  205. package/dist/plays/bundle-play-file.mjs +67 -3
  206. package/dist/plays/csv-data-input.js +3 -3
  207. package/dist/plays/csv-data-input.mjs +2 -2
  208. package/dist/plays/play-description.d.mts +2 -2
  209. package/dist/plays/play-description.d.ts +2 -2
  210. package/dist/plays/run-request.d.mts +2 -2
  211. package/dist/plays/run-request.d.ts +2 -2
  212. package/dist/plays/run-request.js +3 -3
  213. package/dist/plays/run-request.mjs +2 -2
  214. package/dist/release.d.mts +1 -1
  215. package/dist/release.d.ts +1 -1
  216. package/dist/release.js +2 -2
  217. package/dist/release.mjs +1 -1
  218. package/dist/server.d.mts +4 -4
  219. package/dist/server.d.ts +4 -4
  220. package/dist/server.js +12 -12
  221. package/dist/server.mjs +6 -6
  222. package/package.json +1 -1
  223. package/dist/cli/auth-UP2RGPI6.js +0 -43
  224. package/dist/cli/chunk-5LZ5VSOK.mjs +0 -405
  225. package/dist/cli/chunk-D3J2Y2BP.js +0 -405
  226. package/dist/cli/describe-CI4MREFF.mjs +0 -50
  227. package/dist/cli/describe-IVTSD7ST.js +0 -50
  228. package/dist/cli/git-R3W25XIF.js +0 -25
  229. package/dist/cli/pages-FUOSF6BE.mjs +0 -266
  230. package/dist/cli/pages-TLC2N6L7.js +0 -266
  231. package/dist/cli/search-NB5CBALV.js +0 -33
  232. package/dist/cli/sessions-SFCZSB77.js +0 -22
  233. package/dist/cli/skills-WIJEHVLA.js +0 -37
  234. package/dist/cli/tools-VMMERMLO.js +0 -57
  235. package/dist/cli/update-54WZQDTS.js +0 -35
@@ -9,6 +9,11 @@ export type Gradient2ConcurrencyControllerOptions = Readonly<{
9
9
  startupProbeMultiplier?: number;
10
10
  /** Reprobe undeclared capacity after an entire healthy completion window. */
11
11
  recoveryProbeMultiplier?: number;
12
+ /**
13
+ * Share of the current limit a success must have started with in flight to
14
+ * count toward the next limit change. Absent: every success counts.
15
+ */
16
+ provenOccupancyFraction?: number;
12
17
  }>;
13
18
 
14
19
  export type Gradient2Observation = Readonly<{
@@ -47,6 +52,13 @@ function openFraction(value: number, label: string): number {
47
52
  return value;
48
53
  }
49
54
 
55
+ function provenFraction(value: number): number {
56
+ if (!Number.isFinite(value) || value <= 0 || value > 1) {
57
+ throw new Error('Proven occupancy fraction must be in (0, 1].');
58
+ }
59
+ return value;
60
+ }
61
+
50
62
  function clamp(value: number, minimum: number, maximum: number): number {
51
63
  return Math.min(maximum, Math.max(minimum, value));
52
64
  }
@@ -66,6 +78,7 @@ export class Gradient2ConcurrencyController {
66
78
  readonly #rttTolerance: number;
67
79
  readonly #startupProbeMultiplier: number;
68
80
  readonly #recoveryProbeMultiplier: number;
81
+ readonly #provenOccupancyFraction: number | null;
69
82
  #limit: number;
70
83
  #shortRttMs: number | null = null;
71
84
  #longRttMs: number | null = null;
@@ -105,6 +118,10 @@ export class Gradient2ConcurrencyController {
105
118
  'Recovery probe multiplier',
106
119
  ),
107
120
  );
121
+ this.#provenOccupancyFraction =
122
+ options.provenOccupancyFraction === undefined
123
+ ? null
124
+ : provenFraction(options.provenOccupancyFraction);
108
125
  this.#windowStartedAtLimit = this.#limit;
109
126
  if (checkpoint) {
110
127
  this.#limit = clamp(
@@ -169,6 +186,10 @@ export class Gradient2ConcurrencyController {
169
186
  this.#minimumRttMs === null
170
187
  ? latencyMs
171
188
  : Math.min(this.#minimumRttMs, latencyMs);
189
+ // A call that started far below the limit never tested it. Its latency
190
+ // still informs the RTT baselines, but it cannot close a window, so the
191
+ // limit only grows after calls actually ran near it.
192
+ if (!this.#provesLimit(observation)) return;
172
193
  this.#successfulSamplesInWindow += 1;
173
194
  if (
174
195
  this.#successfulSamplesInWindow < Math.ceil(this.#windowStartedAtLimit)
@@ -204,6 +225,26 @@ export class Gradient2ConcurrencyController {
204
225
  this.#windowStartedAtLimit = this.#limit;
205
226
  }
206
227
 
228
+ #provesLimit(observation: Gradient2Observation): boolean {
229
+ // Older writers send no occupancy. Absence keeps their samples counting.
230
+ if (
231
+ this.#provenOccupancyFraction === null ||
232
+ observation.inFlightAtStart === undefined
233
+ ) {
234
+ return true;
235
+ }
236
+ // Never ask for more than a fractional limit can admit when enforced by
237
+ // rounding down, or a saturated lane could never prove itself again.
238
+ const required = Math.max(
239
+ 1,
240
+ Math.min(
241
+ Math.floor(this.#limit + 1e-9),
242
+ Math.ceil(this.#limit * this.#provenOccupancyFraction - 1e-9),
243
+ ),
244
+ );
245
+ return observation.inFlightAtStart >= required;
246
+ }
247
+
207
248
  snapshot(): Gradient2ConcurrencyControllerSnapshot {
208
249
  return Object.freeze({
209
250
  limit: this.#limit,
@@ -31,6 +31,12 @@ export const PROVIDER_CAPACITY_POLICY = Object.freeze({
31
31
  rttTolerance: 1.25,
32
32
  startupProbeMultiplier: 2,
33
33
  unknownProviderRecoveryProbeMultiplier: 2,
34
+ // On an undeclared scope, a success proves the current limit only when its
35
+ // call started with at least this share of the limit in flight. Calls that
36
+ // never came near the limit say nothing about whether a larger one is
37
+ // safe. A declared limit already caps growth, so its lanes count every
38
+ // success.
39
+ provenOccupancyFraction: 0.8,
34
40
  }),
35
41
  } as const);
36
42
 
@@ -31,5 +31,14 @@ export function providerConcurrencyControllerOptions(input: {
31
31
  ? PROVIDER_CAPACITY_POLICY.concurrency
32
32
  .unknownProviderRecoveryProbeMultiplier
33
33
  : 1,
34
+ // A declared limit already caps growth. Only an undeclared scope, bounded
35
+ // by the safety limit alone, must see calls run near a limit before
36
+ // trusting a larger one.
37
+ ...(input.unknownProvider
38
+ ? {
39
+ provenOccupancyFraction:
40
+ PROVIDER_CAPACITY_POLICY.concurrency.provenOccupancyFraction,
41
+ }
42
+ : {}),
34
43
  });
35
44
  }
@@ -11,6 +11,8 @@ export function observeProviderNoProgress(input: {
11
11
  scope: string;
12
12
  retryAtMs: number;
13
13
  nowMs: number;
14
+ /** The no-progress limit; absent is `PROVIDER_NO_PROGRESS_MAX_MS`. */
15
+ maxMs?: number;
14
16
  }): { exhausted: boolean; startedAtMs: number; deadlineMs: number } {
15
17
  const saved = input.startedAtMsByScope[input.scope];
16
18
  const startedAtMs =
@@ -18,7 +20,7 @@ export function observeProviderNoProgress(input: {
18
20
  ? saved
19
21
  : input.nowMs;
20
22
  input.startedAtMsByScope[input.scope] = startedAtMs;
21
- const deadlineMs = startedAtMs + PROVIDER_NO_PROGRESS_MAX_MS;
23
+ const deadlineMs = startedAtMs + (input.maxMs ?? PROVIDER_NO_PROGRESS_MAX_MS);
22
24
  return {
23
25
  exhausted: input.nowMs >= deadlineMs || input.retryAtMs > deadlineMs,
24
26
  startedAtMs,
@@ -30,11 +32,13 @@ export function providerNoProgressExpired(input: {
30
32
  startedAtMsByScope: Record<string, number> | undefined;
31
33
  scope: string;
32
34
  nowMs: number;
35
+ /** The no-progress limit; absent is `PROVIDER_NO_PROGRESS_MAX_MS`. */
36
+ maxMs?: number;
33
37
  }): boolean {
34
38
  const startedAtMs = input.startedAtMsByScope?.[input.scope];
35
39
  return (
36
40
  typeof startedAtMs === 'number' &&
37
41
  Number.isFinite(startedAtMs) &&
38
- input.nowMs >= startedAtMs + PROVIDER_NO_PROGRESS_MAX_MS
42
+ input.nowMs >= startedAtMs + (input.maxMs ?? PROVIDER_NO_PROGRESS_MAX_MS)
39
43
  );
40
44
  }
@@ -918,6 +918,12 @@ export interface RuntimeResourceGovernor {
918
918
  tryAcquireProviderPermit(input: {
919
919
  toolId: string;
920
920
  }): RuntimeProviderPermit | null;
921
+ /** Calls waiting now for the run's external-call slots, and its slot count. */
922
+ externalExecutionBacklog?(): {
923
+ waiting: number;
924
+ slots: number;
925
+ inFlight: number;
926
+ } | null;
921
927
  /**
922
928
  * Observe one physical provider request's run-local residence. This is not
923
929
  * a permit: it cannot block, queue, or widen capacity. Callers must release
@@ -1872,15 +1878,22 @@ export function createRuntimeResourceGovernor(input: {
1872
1878
  observation.providerSuccess === true &&
1873
1879
  (observation.toolId || observation.providerResourceKey)
1874
1880
  ) {
1881
+ // The permit's occupancy lets the shared learner tell a call that
1882
+ // tested the current limit from one that ran far below it.
1883
+ const inFlightAtStart =
1884
+ observation.providerConcurrencyGrant?.inFlightAtStart;
1885
+ const occupancy = inFlightAtStart != null ? { inFlightAtStart } : {};
1875
1886
  if (observation.toolId) {
1876
1887
  input.executionGovernor.observeToolSuccess({
1877
1888
  toolId: observation.toolId,
1878
1889
  latencyMs: observation.providerLatencyMs,
1890
+ ...occupancy,
1879
1891
  });
1880
1892
  } else {
1881
1893
  input.executionGovernor.observeProviderSuccess({
1882
1894
  provider: observation.providerResourceKey!,
1883
1895
  latencyMs: observation.providerLatencyMs,
1896
+ ...occupancy,
1884
1897
  });
1885
1898
  }
1886
1899
  }
@@ -1961,6 +1974,10 @@ export function createRuntimeResourceGovernor(input: {
1961
1974
  return lease;
1962
1975
  },
1963
1976
 
1977
+ externalExecutionBacklog() {
1978
+ return input.executionGovernor.externalExecutionBacklog?.() ?? null;
1979
+ },
1980
+
1964
1981
  tryAcquireProviderPermit(providerInput) {
1965
1982
  const lease = input.executionGovernor.tryAcquireProviderPermit(
1966
1983
  providerInput.toolId,
@@ -55,7 +55,7 @@ export const RUNTIME_SANDBOX_MEMORY_ABORT_MESSAGE =
55
55
  export const RUNTIME_SANDBOX_KILLED_MESSAGE =
56
56
  'The execution sandbox was killed before it could return a result, and the kill reason is unavailable. Completed work is durably recorded. Retry the same command safely; Deepline reuses completed steps and does not repeat their provider calls.';
57
57
  export const RUNTIME_LIMIT_EXCEEDED_MESSAGE =
58
- 'The play reached its 30 minute runtime limit and was stopped before returning. Saved datasets remain available: inspect and export them before rerunning unfinished work. Use fewer rows or increase runtime.timeout in the Play; remove the override to use the 30-minute default. Compatible completed work can be reused; an in-flight response is not proof of a saved result.';
58
+ 'The Play reached its 30 minute runtime limit and was stopped before returning. Any saved Dataset rows remain available; rows held only in local variables are not published. Inspect saved output, then use runs resume to recover matching completed operations if the run is eligible. Starting a new run may repeat paid calls; staleAfterSeconds: 0 requests fresh data. Use fewer rows or increase runtime.timeout in the Play; remove the override to use the 30-minute default. An in-flight response is not proof of a saved result.';
59
59
  export const SANDBOX_CAPACITY_EXCEEDED_MESSAGE =
60
60
  'Your organization has reached its concurrency limit, so this play did not start. Try again after another play finishes, or contact Deepline to request a higher limit.';
61
61
  export const RUNTIME_CONTROL_PLANE_UNAVAILABLE_MESSAGE =
@@ -417,7 +417,7 @@ export function runtimeLimitExceededMessage(timeoutSeconds: number): string {
417
417
  timeoutSeconds >= 4 * 60 * 60
418
418
  ? 'This Play already uses the maximum 4-hour runtime.timeout; split unfinished work into smaller batches.'
419
419
  : 'Use fewer rows or increase runtime.timeout in the Play; remove the override to use the 30-minute default.';
420
- return `The play reached its configured runtime limit of ${formatRuntimeLimitDuration(timeoutSeconds)} and was stopped before returning. Saved datasets remain available: inspect and export them before rerunning unfinished work. ${guidance} Compatible completed work can be reused; an in-flight response is not proof of a saved result.`;
420
+ return `The Play reached its configured runtime limit of ${formatRuntimeLimitDuration(timeoutSeconds)} and was stopped before returning. Any saved Dataset rows remain available; rows held only in local variables are not published. Inspect saved output, then use runs resume to recover matching completed operations if the run is eligible. Starting a new run may repeat paid calls; staleAfterSeconds: 0 requests fresh data. ${guidance} An in-flight response is not proof of a saved result.`;
421
421
  }
422
422
 
423
423
  export function runtimeLimitExceededFailure(
@@ -23,6 +23,7 @@ import {
23
23
  isPlayActivityObservation,
24
24
  PLATFORM_RECOVERY_ACTIVITY_ID,
25
25
  CANCELLATION_CLEANUP_ACTIVITY_ID,
26
+ SANDBOX_CAPACITY_ACTIVITY_ID,
26
27
  type PlayActivityObservation,
27
28
  } from './activity-observation';
28
29
  import {
@@ -1922,13 +1923,15 @@ export function reducePlayRunLedgerEvent(
1922
1923
  Object.entries(snapshot.activitiesById).filter(
1923
1924
  ([id]) =>
1924
1925
  id !== PLATFORM_RECOVERY_ACTIVITY_ID &&
1925
- id !== CANCELLATION_CLEANUP_ACTIVITY_ID,
1926
+ id !== CANCELLATION_CLEANUP_ACTIVITY_ID &&
1927
+ id !== SANDBOX_CAPACITY_ACTIVITY_ID,
1926
1928
  ),
1927
1929
  ),
1928
1930
  orderedActivityIds: snapshot.orderedActivityIds.filter(
1929
1931
  (id) =>
1930
1932
  id !== PLATFORM_RECOVERY_ACTIVITY_ID &&
1931
- id !== CANCELLATION_CLEANUP_ACTIVITY_ID,
1933
+ id !== CANCELLATION_CLEANUP_ACTIVITY_ID &&
1934
+ id !== SANDBOX_CAPACITY_ACTIVITY_ID,
1932
1935
  ),
1933
1936
  updatedAt: Math.max(snapshot.updatedAt ?? 0, occurredAt),
1934
1937
  };
@@ -3,6 +3,7 @@ import { isIntegrationEventWaitToolId } from '../event-wait-tools';
3
3
  import type { PlayQueueHint } from '../governor/rate-state-backend';
4
4
  import { getPlayRuntimeBatchStrategy } from '../play-runtime-batching-registry';
5
5
  import type { ToolResultMetadataInput } from '../tool-result';
6
+ import { resolveDurableRetryPolicy } from '../durable-retry-policy';
6
7
 
7
8
  /** The app's runtime tool metadata as the runner receives it over HTTP. */
8
9
  export type RuntimeToolMetadata = {
@@ -20,6 +21,28 @@ export type RuntimeToolMetadata = {
20
21
  requiresExecutionFence?: boolean;
21
22
  providerServerErrorReplay?: 'idempotent_key' | 'read_safe' | 'never';
22
23
  };
24
+ /** Optional (reader-first): absent from an older app; treated as a write. */
25
+ effect?: 'read' | 'write' | 'destructive' | null;
26
+ /** Optional (reader-first): absent counts as non-idempotent. */
27
+ writeIdempotency?: 'idempotent_write' | 'non_idempotent_write' | null;
28
+ /**
29
+ * Optional (reader-first): the stored Durable retry policy the app read for
30
+ * this attempt. Absent, null, or with `readError`, the compiled defaults
31
+ * apply and say so.
32
+ */
33
+ durableRetryPolicy?: {
34
+ stored: {
35
+ sequence: number;
36
+ policyJson: string;
37
+ /**
38
+ * Optional (reader-first): set when the policy is the run workspace's
39
+ * override rather than the global policy. Attribution only; the
40
+ * sequence already names exactly one stored version.
41
+ */
42
+ orgId?: string;
43
+ } | null;
44
+ readError?: string;
45
+ } | null;
23
46
  targetGetters?: Record<string, string[]>;
24
47
  listExtractorPaths?: string[];
25
48
  listExtractorAliases?: ToolResultMetadataInput['listExtractorAliases'];
@@ -42,6 +65,7 @@ export type RuntimeToolHooks = Required<
42
65
  | 'getToolIdempotencyScope'
43
66
  | 'getToolReusableResultSupport'
44
67
  | 'getToolRetryPolicy'
68
+ | 'getToolDurableRetryContext'
45
69
  | 'getToolActionCacheVersion'
46
70
  | 'getToolActionCacheReadVersions'
47
71
  | 'getToolTargetGetters'
@@ -104,9 +128,45 @@ export function createRuntimeToolHooks(input: {
104
128
  return {
105
129
  retrySafeTransientHttp: metadata.retry?.retrySafeTransientHttp === true,
106
130
  requiresExecutionFence: metadata.retry?.requiresExecutionFence === true,
107
- // Absent (an older metadata reader or an unclassified action) is `never`.
108
- providerServerErrorReplay:
109
- metadata.retry?.providerServerErrorReplay ?? 'never',
131
+ // Absent is an unclassified action: a provider 5xx retries (owner
132
+ // rule 2026-11-16). Only a declared `never` refuses.
133
+ ...(metadata.retry?.providerServerErrorReplay !== undefined
134
+ ? {
135
+ providerServerErrorReplay:
136
+ metadata.retry.providerServerErrorReplay,
137
+ }
138
+ : {}),
139
+ };
140
+ },
141
+ getToolDurableRetryContext: async (toolId) => {
142
+ const metadata = await getRuntimeToolMetadata(toolId);
143
+ const wire = metadata.durableRetryPolicy;
144
+ // An app that predates the policy sends no field: keep the old
145
+ // behaviour (never park). A sent field with no stored policy, or an
146
+ // unreadable one, resolves to the compiled defaults, loudly.
147
+ if (wire === undefined || wire === null) return null;
148
+ const policy = resolveDurableRetryPolicy(wire.stored ?? null);
149
+ return {
150
+ effect:
151
+ metadata.effect === 'read' ||
152
+ metadata.effect === 'write' ||
153
+ metadata.effect === 'destructive'
154
+ ? metadata.effect
155
+ : null,
156
+ writeIdempotency:
157
+ metadata.writeIdempotency === 'idempotent_write' ||
158
+ metadata.writeIdempotency === 'non_idempotent_write'
159
+ ? metadata.writeIdempotency
160
+ : null,
161
+ policy: wire.readError
162
+ ? {
163
+ ...policy,
164
+ warnings: [
165
+ `The app could not read the Durable retry policy: ${wire.readError}`,
166
+ ...policy.warnings,
167
+ ],
168
+ }
169
+ : policy,
110
170
  };
111
171
  },
112
172
  getToolActionCacheVersion: async (toolId) => {
@@ -100,6 +100,9 @@ export const RUNTIME_OPERATION_CAPABILITIES = {
100
100
  // Provider prices and availability use the existing discovery authority.
101
101
  get_billing_entitlements: 'tool.inspect',
102
102
  write_page: 'page.write',
103
+ // Lists the running Play's own views: a read of that Play's control-plane
104
+ // metadata, the same authority resolve_play uses.
105
+ list_views: 'artifact.read',
103
106
  } as const satisfies Readonly<Record<string, RuntimeExecutionCapability>>;
104
107
 
105
108
  export const RUNTIME_OPERATION_CONTRACT: DeployedOperationContract =
@@ -115,6 +118,10 @@ export const RUNTIME_OPERATION_CONTRACT: DeployedOperationContract =
115
118
  kind: 'feature-unavailable',
116
119
  code: 'PAGES_UNAVAILABLE',
117
120
  },
121
+ list_views: {
122
+ kind: 'feature-unavailable',
123
+ code: 'VIEWS_UNAVAILABLE',
124
+ },
118
125
  // The shared read cache is only an optimization: an older receiver
119
126
  // writes nothing and the runner treats the publish as a no-op.
120
127
  publish_latest_cache_result: {
@@ -105,12 +105,40 @@ export function resolveRuntimeSandboxComputeItems(input: {
105
105
  * A recovered create is recorded from its reservation, without the ceiling a
106
106
  * live create carries, and cleanup may find it weeks later. It still bills no
107
107
  * more than one run could: `maxBillingDurationSeconds` fills any missing one.
108
+ *
109
+ * A sandbox handed to cleanup before it could receive a command
110
+ * (`customerCodeUnreachable`: a create that timed out or stayed in `creating`)
111
+ * never ran customer code. The time spent failing to acquire it is not billed.
108
112
  */
109
113
  export function resolveLateRuntimeSandboxComputeItems(input: {
110
114
  resources: readonly unknown[];
111
115
  endedAt: number;
112
116
  maxBillingDurationSeconds: number;
113
117
  }): ComputeBillingItem[] {
118
+ return resolveLateItems(input, false);
119
+ }
120
+
121
+ /**
122
+ * The same projection for the late sandboxes that are not billed: what the
123
+ * provider time cost Deepline. For diagnostics only; never record these as
124
+ * billing items.
125
+ */
126
+ export function resolveAbsorbedLateRuntimeSandboxComputeItems(input: {
127
+ resources: readonly unknown[];
128
+ endedAt: number;
129
+ maxBillingDurationSeconds: number;
130
+ }): ComputeBillingItem[] {
131
+ return resolveLateItems(input, true);
132
+ }
133
+
134
+ function resolveLateItems(
135
+ input: {
136
+ resources: readonly unknown[];
137
+ endedAt: number;
138
+ maxBillingDurationSeconds: number;
139
+ },
140
+ customerCodeUnreachable: boolean,
141
+ ): ComputeBillingItem[] {
114
142
  const lateResources: Record<string, unknown>[] = [];
115
143
  for (const resource of input.resources) {
116
144
  if (!resource || typeof resource !== 'object' || Array.isArray(resource)) {
@@ -118,6 +146,9 @@ export function resolveLateRuntimeSandboxComputeItems(input: {
118
146
  }
119
147
  const value = resource as Record<string, unknown>;
120
148
  if (value.lateAcquired !== true) continue;
149
+ if ((value.customerCodeUnreachable === true) !== customerCodeUnreachable) {
150
+ continue;
151
+ }
121
152
  lateResources.push({
122
153
  ...value,
123
154
  maxBillingDurationSeconds:
@@ -267,6 +267,12 @@ export type PlaySchedulerSubmitInput = RetainedPipelineCarrier & {
267
267
  launchIdentityDigest?: string | null;
268
268
  /** Millisecond epoch timestamp captured immediately before scheduler submit. */
269
269
  submittedAtMs?: number;
270
+ /**
271
+ * The workspace's `play.concurrent_runs` entitlement, resolved at admission.
272
+ * The worker enforces it as the live-sandbox cap. Optional: launches from
273
+ * older builds omit it and use the mirrored cap or the runtime default.
274
+ */
275
+ concurrentRunsLimit?: number | null;
270
276
  /** Scheduler backend that owns orchestration for this run. */
271
277
  schedulerBackend?: PlaySchedulerBackendId | null;
272
278
  };
@@ -200,6 +200,7 @@ import {
200
200
  listPostgresSchedulerAmbiguousModalCreateIntents,
201
201
  recordPostgresSchedulerDetachedRunnerLivenessVerdict,
202
202
  recordPostgresSchedulerAttemptRuntimeResource,
203
+ clearPostgresSandboxCapacityActivity,
203
204
  recordPostgresSchedulerAmbiguousModalCreateIntent,
204
205
  recordPostgresSchedulerLateManagedSandboxOperationForCleanup,
205
206
  recordPostgresSchedulerLateRuntimeResourceForCleanup,
@@ -4004,6 +4005,14 @@ async function executeAbsurdAttemptAdapter(
4004
4005
  attempt: generation,
4005
4006
  leaseToken,
4006
4007
  reason: error.message,
4008
+ ...(error instanceof RuntimeSandboxCapacityLimitError
4009
+ ? {
4010
+ sandboxCapacity: {
4011
+ limit: error.limit,
4012
+ nowMs: Date.now(),
4013
+ },
4014
+ }
4015
+ : {}),
4007
4016
  },
4008
4017
  options,
4009
4018
  ),
@@ -5418,6 +5427,9 @@ async function executeAssignedAbsurdAttempt(input: {
5418
5427
  : ('production' as const),
5419
5428
  resumePendingDaytonaOperation: provider === 'daytona',
5420
5429
  operationKey: `sandbox-operation:${runId}:${generation}:${provider}:${providerAttempt ?? 1}`,
5430
+ // The workspace's concurrent-run entitlement, resolved
5431
+ // at admission; older launches fall back to the mirror.
5432
+ entitlementLimit: launch.concurrentRunsLimit ?? null,
5421
5433
  };
5422
5434
  // A pooled callback may retry after its INSERT committed.
5423
5435
  // Keep unsent-create authority outside those callback retries;
@@ -5611,7 +5623,9 @@ async function executeAssignedAbsurdAttempt(input: {
5611
5623
  playRunnerRuntimeResourceFromSandboxExecutionResource(
5612
5624
  resource,
5613
5625
  );
5614
- const recorded = await deps.runWithClient(async (client) => {
5626
+ const recordSandboxResource = async (
5627
+ client: PostgresSchedulerQueryClient,
5628
+ ): Promise<boolean> => {
5615
5629
  if (isManagedSandboxCapacityResource(runnerResource)) {
5616
5630
  const promoted =
5617
5631
  await recordPostgresSchedulerManagedSandboxOperationLive(
@@ -5679,6 +5693,17 @@ async function executeAssignedAbsurdAttempt(input: {
5679
5693
  throw new Error(
5680
5694
  `Runtime resource ${runnerResource.kind} carried a capacity lease without a matching managed provider owner.`,
5681
5695
  );
5696
+ };
5697
+ const recorded = await deps.runWithClient(async (client) => {
5698
+ if (!(await recordSandboxResource(client))) return false;
5699
+ // The run has its sandbox (managed or not): retire the
5700
+ // queued headline a sandbox-capacity wait published.
5701
+ await clearPostgresSandboxCapacityActivity(
5702
+ client,
5703
+ { runId, attempt: generation, nowMs: Date.now() },
5704
+ options,
5705
+ );
5706
+ return true;
5682
5707
  });
5683
5708
  return recorded
5684
5709
  ? { kind: 'recorded' as const }
@@ -91,10 +91,13 @@ export function acquireRateScopeSql(
91
91
  // Keep it available for one later ramp rather than requiring another call at
92
92
  // the old pace. The baseline consumes it once. Unknown-provider upward probes
93
93
  // above useful seed capacity retain their separate observation policy.
94
+ // Before any backpressure the same stored successes also count, whichever
95
+ // run wrote them: a single-call run reports its success only in its final
96
+ // flush, after its one acquire, so waiting for successes carried by the
97
+ // request itself would keep such a lane in cold discovery indefinitely.
94
98
  const recoverySuccess = probeBaselineSupported
95
99
  ? `(${successesParameter}::int > 0 OR (
96
- h.seen_backpressure
97
- AND (${!unknownProvider} OR ${fastRecovery})
100
+ (NOT h.seen_backpressure OR ${!unknownProvider} OR ${fastRecovery})
98
101
  AND h.rate_probe_started_at_ms >= h.last_ramp_at_ms
99
102
  AND h.rate_probe_started_at_ms >= h.rate_observation_started_at_ms
100
103
  AND h.rate_successes > h.rate_probe_successes_at_ramp
@@ -174,6 +177,10 @@ export function updateRateScopeSql(
174
177
  AND ph.next_refill_per_sec > ph.refill_per_sec`;
175
178
  const knownRampedObservation = `${!unknownProvider} AND ph.seen_backpressure
176
179
  AND ph.next_refill_per_sec > ph.refill_per_sec`;
180
+ // A ramp before any backpressure consumes the stored successes that proved
181
+ // it, so the next ramp needs a success recorded after this one.
182
+ const coldRampedObservation = `NOT ph.seen_backpressure
183
+ AND ph.next_ramp_at_ms <> ph.last_ramp_at_ms`;
177
184
  const idleFloorObservation = `ph.observation_was_idle AND ph.fast_recovery`;
178
185
  const rebaseProbe =
179
186
  'ph.rate_probe_started_at_ms < ph.last_ramp_at_ms OR ph.rate_probe_started_at_ms < COALESCE(ph.rate_observation_started_at_ms, 0) OR ph.rate_probe_successes_at_ramp > ph.rate_successes';
@@ -202,10 +209,10 @@ export function updateRateScopeSql(
202
209
  WHEN (SELECT granted FROM grant_calc) > 0
203
210
  AND (ph.rate_observation_started_at_ms IS NULL OR ph.observation_was_idle) THEN 0
204
211
  WHEN ${idleFloorObservation} THEN ph.rate_successes
205
- WHEN ${knownRampedObservation} OR ${floorRampedObservation} OR ${probedObservation} OR (${rebaseProbe}) THEN ph.rate_successes
212
+ WHEN ${knownRampedObservation} OR ${coldRampedObservation} OR ${floorRampedObservation} OR ${probedObservation} OR (${rebaseProbe}) THEN ph.rate_successes
206
213
  ELSE ph.rate_probe_successes_at_ramp END,
207
214
  rate_probe_started_at_ms = CASE
208
- WHEN ${knownRampedObservation} OR ${idleFloorObservation} OR ${recoveredObservation} OR ${floorRampedObservation} OR ${probedObservation} OR (${rebaseProbe}) THEN nv.now_ms
215
+ WHEN ${knownRampedObservation} OR ${coldRampedObservation} OR ${idleFloorObservation} OR ${recoveredObservation} OR ${floorRampedObservation} OR ${probedObservation} OR (${rebaseProbe}) THEN nv.now_ms
209
216
  WHEN (SELECT granted FROM grant_calc) > 0
210
217
  AND (ph.rate_observation_started_at_ms IS NULL OR ph.observation_was_idle) THEN nv.now_ms
211
218
  ELSE ph.rate_probe_started_at_ms END,`