deepline 0.3.579 → 0.3.581

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 (179) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +13 -2
  2. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  3. package/dist/bundling-sources/shared_libs/monitors/billing/public-pricing.ts +470 -15
  4. package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +12 -0
  5. package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +59 -0
  6. package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +5 -3
  7. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +42 -2
  8. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +49 -11
  9. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +13 -4
  10. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +139 -16
  11. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/run-ledger-outbox-recovery.ts +39 -2
  12. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +12 -0
  13. package/dist/bundling-sources/shared_libs/plays/sandbox-runtime-limits.ts +20 -0
  14. package/dist/cli/{agents-D5RZEVXQ.js → agents-UDTRMWPA.js} +81 -39
  15. package/dist/cli/{agents-FJTRTYCL.mjs → agents-VDQSVDSM.mjs} +51 -9
  16. package/dist/cli/{auth-OMYIDVXZ.mjs → auth-SRN5FXUQ.mjs} +5 -5
  17. package/dist/cli/auth-UYQHRHYR.js +44 -0
  18. package/dist/cli/{billing-EWFUDLQ7.js → billing-HGHIOFSA.js} +162 -159
  19. package/dist/cli/{billing-XK3LBNYS.mjs → billing-PR2SIEJM.mjs} +69 -66
  20. package/dist/cli/{chunk-I2TSRLOI.mjs → chunk-2MIJMDGF.mjs} +1 -1
  21. package/dist/cli/{chunk-TVAFWAOQ.js → chunk-2RLMHWXW.js} +3 -3
  22. package/dist/cli/{chunk-OSRATALX.mjs → chunk-3FMGBMT3.mjs} +1 -1
  23. package/dist/cli/{chunk-KIIOKQFY.mjs → chunk-3I6GA5QW.mjs} +7 -3
  24. package/dist/cli/{chunk-UYCBG75H.js → chunk-3LP7J63L.js} +5 -5
  25. package/dist/cli/{chunk-QA55PGJH.js → chunk-3S5KFHQH.js} +7 -7
  26. package/dist/cli/{chunk-SZIWFQI2.mjs → chunk-46EBSUZF.mjs} +3 -3
  27. package/dist/cli/{chunk-7HOYKXVY.js → chunk-5XVDZVCR.js} +217 -213
  28. package/dist/cli/{chunk-PLWZ3NB7.js → chunk-6U3THMRI.js} +5 -5
  29. package/dist/cli/{chunk-LRZGS6RZ.mjs → chunk-7MMEW2WU.mjs} +1 -1
  30. package/dist/cli/{chunk-KWQHQG53.js → chunk-7VOSQARZ.js} +6 -6
  31. package/dist/cli/{chunk-72TWLORR.js → chunk-A4IOPFEJ.js} +3 -3
  32. package/dist/cli/{chunk-S2OXA7QS.mjs → chunk-ALXIC5U5.mjs} +7 -7
  33. package/dist/cli/{chunk-6EVVUVU3.mjs → chunk-BDNQDWGI.mjs} +2 -2
  34. package/dist/cli/{chunk-HEZW2IDK.js → chunk-BQL34VOQ.js} +279 -276
  35. package/dist/cli/{chunk-FKXSIIR4.js → chunk-BULUFFST.js} +15 -15
  36. package/dist/cli/{chunk-NONMY5CY.mjs → chunk-CDIMI54H.mjs} +2 -2
  37. package/dist/cli/{chunk-NWZU6HL4.js → chunk-CN4MXBZ3.js} +13 -13
  38. package/dist/cli/{chunk-XTM6NOJ6.js → chunk-CNRPE3AE.js} +53 -53
  39. package/dist/cli/{chunk-LYBZLA6F.mjs → chunk-DZMQV5FL.mjs} +2 -2
  40. package/dist/cli/{chunk-NKUXW4WB.js → chunk-E2EGQNOS.js} +2 -2
  41. package/dist/cli/{chunk-BLEYV4BJ.js → chunk-E5ITZIWK.js} +21 -21
  42. package/dist/cli/{chunk-N6X2UKYQ.mjs → chunk-E5O4CMHZ.mjs} +2 -2
  43. package/dist/cli/{chunk-X6LPC3SU.mjs → chunk-EHTD65FE.mjs} +1 -1
  44. package/dist/cli/{chunk-E2G2DNAB.js → chunk-EP3GZAHK.js} +7 -7
  45. package/dist/cli/{chunk-NOMO5GPI.js → chunk-FXSDDEAR.js} +1 -1
  46. package/dist/cli/{chunk-AP7PIGL5.js → chunk-INRXX4SX.js} +41 -41
  47. package/dist/cli/{chunk-XQYBBCFI.mjs → chunk-INXRW5AF.mjs} +2 -2
  48. package/dist/cli/{chunk-7JMCRYXU.js → chunk-IT3F7P6O.js} +10 -10
  49. package/dist/cli/{chunk-LYJ2NSHD.js → chunk-J6ITN2X6.js} +13 -13
  50. package/dist/cli/{chunk-LCPJR3IY.js → chunk-JQK42HZQ.js} +2 -2
  51. package/dist/cli/{chunk-HGUFTSB5.mjs → chunk-KDITCSPN.mjs} +27 -1
  52. package/dist/cli/{chunk-VFIIRK7S.mjs → chunk-KLBIHDZB.mjs} +2 -2
  53. package/dist/cli/{chunk-Y2ND6PPW.js → chunk-KO6OLYSD.js} +48 -48
  54. package/dist/cli/{chunk-K2BU67UC.js → chunk-LJZESBNY.js} +2 -2
  55. package/dist/cli/{chunk-PGRRMVQ5.js → chunk-MOZDEYQC.js} +2 -1
  56. package/dist/cli/{chunk-DH736ASH.js → chunk-MSCYYFLY.js} +20 -20
  57. package/dist/cli/{chunk-JFS4KHA3.mjs → chunk-N5VJVVVV.mjs} +5 -5
  58. package/dist/cli/{chunk-G5CZDRY3.js → chunk-O5FIWG2O.js} +26 -26
  59. package/dist/cli/{chunk-YCWRKSLB.mjs → chunk-OVJWDFIL.mjs} +2 -2
  60. package/dist/cli/{chunk-WQQQP3FH.mjs → chunk-P5ZZY4RM.mjs} +4 -4
  61. package/dist/cli/{chunk-WWSGXX6U.js → chunk-PLGJG5FX.js} +5 -5
  62. package/dist/cli/{chunk-BZ4M7OFO.mjs → chunk-QXQBTTRD.mjs} +1 -1
  63. package/dist/cli/{chunk-F57NDSKT.mjs → chunk-RA3BWUTD.mjs} +5 -5
  64. package/dist/cli/{chunk-Q4VKMF3B.js → chunk-S2YKIWCD.js} +17 -17
  65. package/dist/cli/{chunk-DTQBQSUU.mjs → chunk-SECFDB27.mjs} +1 -0
  66. package/dist/cli/{chunk-6MIEJJSO.js → chunk-SNYH4QY2.js} +4 -4
  67. package/dist/cli/{chunk-6GON36H3.mjs → chunk-SZ76UE7C.mjs} +17 -14
  68. package/dist/cli/{chunk-6DMGKAWO.mjs → chunk-ULU4MEXN.mjs} +2 -2
  69. package/dist/cli/{chunk-ABH6PUDZ.js → chunk-VJR4CKYJ.js} +23 -23
  70. package/dist/cli/{chunk-TFNDOH4W.mjs → chunk-VNW454PP.mjs} +1 -1
  71. package/dist/cli/{chunk-7SZCJC4R.mjs → chunk-VTPMBOHZ.mjs} +2 -2
  72. package/dist/cli/{chunk-6NYHMXC7.mjs → chunk-VVENTTSA.mjs} +1 -1
  73. package/dist/cli/{chunk-OOGP737I.js → chunk-VWPM4OIC.js} +20 -20
  74. package/dist/cli/{chunk-27ZYRIQC.mjs → chunk-WCNJSZHC.mjs} +5 -5
  75. package/dist/cli/{chunk-KQAEXBVQ.mjs → chunk-WS5ZX4RB.mjs} +3 -3
  76. package/dist/cli/{chunk-SUHCW7U5.mjs → chunk-WVFDPC4K.mjs} +3 -3
  77. package/dist/cli/{chunk-44NTNNKC.js → chunk-Y36SQMSN.js} +28 -2
  78. package/dist/cli/{chunk-LV2LGW2Q.mjs → chunk-YTPXKG4C.mjs} +1 -1
  79. package/dist/cli/{chunk-3Z4TVZE7.mjs → chunk-Z3MJX3PP.mjs} +1 -1
  80. package/dist/cli/{chunk-LQ45LCH7.js → chunk-ZAKNDIK7.js} +9 -9
  81. package/dist/cli/{chunk-M4YWN5BT.mjs → chunk-ZTKLJADJ.mjs} +4 -4
  82. package/dist/cli/command-docs.js +4 -4
  83. package/dist/cli/command-docs.mjs +3 -3
  84. package/dist/cli/concurrent-runs-help-QWDTLZUX.js +22 -0
  85. package/dist/cli/{concurrent-runs-help-IQBZBTD5.mjs → concurrent-runs-help-Z27MIIH3.mjs} +6 -6
  86. package/dist/cli/{csv-T7TWLIGD.js → csv-4TP36F5O.js} +13 -13
  87. package/dist/cli/{csv-6BEOWTGM.mjs → csv-4YFTMVWQ.mjs} +4 -4
  88. package/dist/cli/{db-MFTUN3DF.js → db-L5EGGO72.js} +27 -27
  89. package/dist/cli/{db-FA5QGXZ7.mjs → db-U5KR6SYI.mjs} +6 -6
  90. package/dist/cli/describe-G3SUS76P.js +50 -0
  91. package/dist/cli/{describe-TITEQNVE.mjs → describe-LZXXSQ26.mjs} +21 -21
  92. package/dist/cli/describe-core.d.mts +2 -2
  93. package/dist/cli/describe-core.d.ts +2 -2
  94. package/dist/cli/describe-core.js +4 -4
  95. package/dist/cli/describe-core.mjs +3 -3
  96. package/dist/cli/{executions-QW3L7G7J.js → executions-VZKRFDGM.js} +8 -8
  97. package/dist/cli/{executions-DMYJJIRB.mjs → executions-ZWEC5DDR.mjs} +6 -6
  98. package/dist/cli/{feedback-6JZGE7OQ.js → feedback-BTJIJCQF.js} +14 -14
  99. package/dist/cli/{feedback-WPSNSFRC.mjs → feedback-HXQTHXEZ.mjs} +6 -6
  100. package/dist/cli/{git-GO65XRM3.mjs → git-P6A45MMT.mjs} +5 -5
  101. package/dist/cli/git-QU673DBV.js +26 -0
  102. package/dist/cli/index.js +150 -150
  103. package/dist/cli/index.mjs +49 -49
  104. package/dist/cli/{integrations-EEBPETH2.mjs → integrations-4POM2CJ3.mjs} +7 -7
  105. package/dist/cli/{integrations-T5JPSZXN.js → integrations-VSJQBRFS.js} +29 -29
  106. package/dist/cli/{legacy-noops-XDNZ46IR.mjs → legacy-noops-I65MIKH2.mjs} +6 -6
  107. package/dist/cli/{legacy-noops-B55OMNH7.js → legacy-noops-QOJGSGVO.js} +9 -9
  108. package/dist/cli/{mcp-4QIUAAWS.mjs → mcp-TGY6SRAC.mjs} +4 -4
  109. package/dist/cli/{mcp-3YA333TQ.js → mcp-WTKBSLSD.js} +24 -24
  110. package/dist/cli/{monitors-BVUPS4CE.mjs → monitors-E2ENT4RY.mjs} +16 -11
  111. package/dist/cli/{monitors-FOS7MWZO.js → monitors-TLWVEXW6.js} +109 -104
  112. package/dist/cli/{org-TCMRRVFC.mjs → org-J2LGW5ZR.mjs} +6 -6
  113. package/dist/cli/{org-CYM7HFLN.js → org-PZPJJU7K.js} +121 -121
  114. package/dist/cli/{outcomes-2JSWXWQ3.mjs → outcomes-TMJDASU5.mjs} +6 -6
  115. package/dist/cli/{outcomes-VDJVP5YC.js → outcomes-Z6ZNBJ3U.js} +14 -14
  116. package/dist/cli/{play-CPP4EBYF.mjs → play-S3Z24HUS.mjs} +22 -22
  117. package/dist/cli/{play-U3G73VIR.js → play-ZOOC57X4.js} +355 -355
  118. package/dist/cli/{providers-RVMIX5ED.mjs → providers-ETD6YLFL.mjs} +6 -6
  119. package/dist/cli/{providers-2ZB67TK7.js → providers-O4Y2YBS7.js} +9 -9
  120. package/dist/cli/{quickstart-V3Y7XZ47.js → quickstart-NZALIRBP.js} +6 -6
  121. package/dist/cli/{quickstart-L3YO3OWZ.mjs → quickstart-QZX32Y5T.mjs} +4 -4
  122. package/dist/cli/{run-M2CADJ6E.js → run-5UXSWJ7N.js} +48 -48
  123. package/dist/cli/{run-PQ3Z2GOF.mjs → run-HCVBRE2P.mjs} +26 -26
  124. package/dist/cli/search-T3SLR55O.js +32 -0
  125. package/dist/cli/{search-QVLGI7SZ.mjs → search-Z247K76U.mjs} +7 -7
  126. package/dist/cli/{search-output-PN3V7MSO.mjs → search-output-XCJI3XRA.mjs} +5 -5
  127. package/dist/cli/{search-output-IUANVHWU.js → search-output-XFKEGUJA.js} +8 -8
  128. package/dist/cli/{secrets-HK25G4K2.mjs → secrets-7JZXHLRU.mjs} +6 -6
  129. package/dist/cli/{secrets-AOW6F67J.js → secrets-VUQLTUTM.js} +15 -15
  130. package/dist/cli/sessions-GHW2H7N2.js +23 -0
  131. package/dist/cli/{sessions-YN2OIAGR.mjs → sessions-UNGJ342N.mjs} +6 -6
  132. package/dist/cli/{settings-7UW5TWSM.mjs → settings-67TIT4MZ.mjs} +12 -12
  133. package/dist/cli/{settings-6EV2FPGF.js → settings-WG5YNHC5.js} +85 -85
  134. package/dist/cli/{setup-ZQPD2R5K.js → setup-IYUNW5ZP.js} +49 -49
  135. package/dist/cli/{setup-BG56SHKH.mjs → setup-KMAAJOZM.mjs} +9 -9
  136. package/dist/cli/skills-JVLCEUBF.js +37 -0
  137. package/dist/cli/{skills-MQV2TNUZ.mjs → skills-UVS4DODN.mjs} +7 -7
  138. package/dist/cli/{tools-RGI4OE5T.mjs → tools-B42JY4BX.mjs} +19 -19
  139. package/dist/cli/tools-ETA3BJNM.js +57 -0
  140. package/dist/cli/{update-SQKGHQKF.mjs → update-EBYZZ7BW.mjs} +9 -9
  141. package/dist/cli/update-XZEBQCEY.js +37 -0
  142. package/dist/cli/{views-BUKVHCRD.js → views-DOUEKLEV.js} +37 -24
  143. package/dist/cli/{views-734T2CXF.mjs → views-QK3AFD2D.mjs} +21 -8
  144. package/dist/cli/{workflow-LPJC6RHP.js → workflow-TAKT2T7A.js} +17 -17
  145. package/dist/cli/{workflow-JNRRBMEK.mjs → workflow-UBJPGRKF.mjs} +7 -7
  146. package/dist/{client-CNYctEBh.d.mts → client-CmG8MT0x.d.mts} +1 -1
  147. package/dist/{client-C1AubrWJ.d.ts → client-QznpkWrk.d.ts} +1 -1
  148. package/dist/{client-core-D6zAE46g.d.ts → client-core-CXDqfeiB.d.ts} +5 -1
  149. package/dist/{client-core-Bb06TCx5.d.mts → client-core-CY0jNW0e.d.mts} +5 -1
  150. package/dist/index.d.mts +3 -3
  151. package/dist/index.d.ts +3 -3
  152. package/dist/index.js +9 -9
  153. package/dist/index.mjs +6 -6
  154. package/dist/install-integrity.json +130 -130
  155. package/dist/plays/bundle-play-file.mjs +1 -1
  156. package/dist/plays/play-description.d.mts +1 -1
  157. package/dist/plays/play-description.d.ts +1 -1
  158. package/dist/plays/run-request.d.mts +1 -1
  159. package/dist/plays/run-request.d.ts +1 -1
  160. package/dist/release.d.mts +1 -1
  161. package/dist/release.d.ts +1 -1
  162. package/dist/release.js +2 -2
  163. package/dist/release.mjs +1 -1
  164. package/dist/server.d.mts +2 -2
  165. package/dist/server.d.ts +2 -2
  166. package/dist/server.js +5 -5
  167. package/dist/server.mjs +3 -3
  168. package/package.json +1 -1
  169. package/dist/cli/auth-Q4O7MJU4.js +0 -44
  170. package/dist/cli/concurrent-runs-help-D6XH3FY5.js +0 -22
  171. package/dist/cli/describe-TYZ5YH3V.js +0 -50
  172. package/dist/cli/git-UGGRLGTQ.js +0 -26
  173. package/dist/cli/search-RHPPZZFG.js +0 -32
  174. package/dist/cli/sessions-AEGGTZ3K.js +0 -23
  175. package/dist/cli/skills-C6ZEZWBE.js +0 -37
  176. package/dist/cli/tools-PM3MC3RR.js +0 -57
  177. package/dist/cli/update-ZHUPF2HT.js +0 -37
  178. /package/dist/cli/{chunk-YGCKMI5P.js → chunk-2M3VVGMZ.js} +0 -0
  179. /package/dist/cli/{chunk-7I4B6V2S.mjs → chunk-VMGJIFSB.mjs} +0 -0
@@ -69,6 +69,7 @@ import {
69
69
  LEGACY_RUNTIME_RECEIPT_WIRE_HEADER,
70
70
  } from './/runtime-contract';
71
71
  import { PLAY_RUNTIME_API_COMPAT_PATH } from './/runtime-api-paths';
72
+ import { RUNTIME_RATE_STATE_UNAVAILABLE_RESPONSE_CODE } from './/transient-service-error';
72
73
  import {
73
74
  buildRunLedgerEventsIdempotencyKey,
74
75
  isRunLedgerProjectionMismatchDiagnostic,
@@ -877,6 +878,32 @@ function isRetryableAppRuntimeResponse(input: {
877
878
  return isRetryableAppRuntimeResponseStatus(input.status);
878
879
  }
879
880
 
881
+ /**
882
+ * The rate-state store's tables are not migrated yet. A server that names this
883
+ * code calls the response retryable, but the rate-state backend owns that retry
884
+ * (governor/app-runtime-rate-state-backend.ts): an acquire fails closed after
885
+ * 3 attempts, 100 and 250 ms apart, and a release holds its leases until their
886
+ * TTL. Retrying here too would multiply those bounds by this ladder's 5
887
+ * attempts, so each action sends as many requests as it does for today's
888
+ * non-retryable 500 `runtime_durability_internal`.
889
+ *
890
+ * This reader ships before any server sends the code (reader first): until
891
+ * then nothing matches it. Recorded responses:
892
+ * tests/fixtures/play-runtime/rate-state-unavailable-response/.
893
+ */
894
+ function isRateStateBackendOwnedRetry(
895
+ action: RuntimeApiRequest['action'],
896
+ responseCode: string | null,
897
+ ): boolean {
898
+ return (
899
+ responseCode === RUNTIME_RATE_STATE_UNAVAILABLE_RESPONSE_CODE &&
900
+ (action === 'rate_state_acquire' ||
901
+ action === 'rate_state_release' ||
902
+ action === 'rate_state_penalize' ||
903
+ action === 'rate_state_validate')
904
+ );
905
+ }
906
+
880
907
  /**
881
908
  * The pre-reader app returns this one precise response for an action it does
882
909
  * not yet know. Do not use a substring match here: an authorization failure
@@ -2075,9 +2102,21 @@ async function postAppRuntimeApiAttempts<TResponse>(
2075
2102
  try {
2076
2103
  responseText = await response.text();
2077
2104
  } catch (error) {
2105
+ // A typed rate-state answer whose body timed out still belongs to the
2106
+ // rate-state backend's ladder: its header names the code.
2107
+ const rateStateBackendOwnedCode =
2108
+ isRequestTimeoutAbort(error) &&
2109
+ isRetryableAppRuntimeResponseStatus(response.status) &&
2110
+ isRateStateBackendOwnedRetry(
2111
+ body.action,
2112
+ appRuntimeErrorCode(response, ''),
2113
+ )
2114
+ ? RUNTIME_RATE_STATE_UNAVAILABLE_RESPONSE_CODE
2115
+ : null;
2078
2116
  if (
2079
2117
  isRequestTimeoutAbort(error) &&
2080
- !isRetryableAppRuntimeResponseStatus(response.status)
2118
+ (!isRetryableAppRuntimeResponseStatus(response.status) ||
2119
+ rateStateBackendOwnedCode)
2081
2120
  ) {
2082
2121
  recordAppRuntimeRetryFailure({
2083
2122
  telemetry: retryTelemetry,
@@ -2097,7 +2136,7 @@ async function postAppRuntimeApiAttempts<TResponse>(
2097
2136
  finalAttemptStartedAt: attemptStartedAt,
2098
2137
  });
2099
2138
  throw new Error(
2100
- `${boundaryLabel} ${body.action} failed with status ${response.status}: response body timed out`,
2139
+ `${boundaryLabel} ${body.action} failed with status ${response.status}${rateStateBackendOwnedCode ? ` code=${rateStateBackendOwnedCode}` : ''}: response body timed out`,
2101
2140
  { cause: error },
2102
2141
  );
2103
2142
  }
@@ -2153,6 +2192,7 @@ async function postAppRuntimeApiAttempts<TResponse>(
2153
2192
  }
2154
2193
  if (
2155
2194
  ladderAttempt < maxAttempts &&
2195
+ !isRateStateBackendOwnedRetry(body.action, responseCode) &&
2156
2196
  isRetryableAppRuntimeResponse({
2157
2197
  action: body.action,
2158
2198
  status: response.status,
@@ -1,5 +1,8 @@
1
1
  import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
2
- import type { PlaySandboxRuntimeLimits } from '../../plays/sandbox-runtime-limits';
2
+ import {
3
+ earlySandboxCapUnits,
4
+ type PlaySandboxRuntimeLimits,
5
+ } from '../../plays/sandbox-runtime-limits';
3
6
  import {
4
7
  resolveExperimentSwitch,
5
8
  type ExperimentSwitchOverrides,
@@ -65,8 +68,9 @@ export const ADOPT_IN_PROCESS_EARLY_SANDBOX_WITHOUT_TAG_READ = false;
65
68
  * credentials or customer data: no envelope, config or token exists in the
66
69
  * sandbox until the run is adopted. The watchdog's runtime/memory limits and
67
70
  * the runner's V8 flags are fixed at pre-boot from the early sandbox's own
68
- * (standard) profile, the same one its `limitsKey` encodes; adoption refuses a
69
- * run whose limits differ, and staging asserts it again.
71
+ * limits: the hinted run's validated limits when the hint carried them, else
72
+ * the standard profile. Its `limitsKey` encodes the same limits; adoption
73
+ * refuses a run whose limits differ, and staging asserts it again.
70
74
  *
71
75
  * Adoption (in this process only) delivers the envelope in one exec: stdin to
72
76
  * a file (same guard as the inline launch), then the run's files, config LAST
@@ -369,19 +373,30 @@ export class EarlySandboxRegistry<
369
373
 
370
374
  readonly #taken = new Set<string>();
371
375
 
372
- /** This process's early sandboxes not yet adopted, reaped or expired. */
376
+ /**
377
+ * This process's early sandboxes not yet adopted, reaped or expired, in cap
378
+ * units (`earlySandboxCapUnits`: a standard sandbox is 1, so standard-only
379
+ * traffic counts exactly as before).
380
+ */
373
381
  outstanding(): number {
374
- return this.#outstanding.size;
382
+ let units = 0;
383
+ for (const entry of this.#outstanding) units += this.#units.get(entry) ?? 1;
384
+ return units;
375
385
  }
376
386
 
377
- /** The same count for one org's hints (entries put with that `orgId`). */
387
+ /** The same units for one org's hints (entries put with that `orgId`). */
378
388
  outstandingForOrg(orgId: string): number {
379
- let count = 0;
380
- for (const owner of this.#outstandingOrg.values())
381
- if (owner === orgId) count += 1;
382
- return count;
389
+ let units = 0;
390
+ for (const [entry, owner] of this.#outstandingOrg)
391
+ if (owner === orgId) units += this.#units.get(entry) ?? 1;
392
+ return units;
383
393
  }
384
394
 
395
+ readonly #units = new Map<
396
+ Promise<EarlySandboxEntry<TSandbox> | null>,
397
+ number
398
+ >();
399
+
385
400
  readonly #outstandingOrg = new Map<
386
401
  Promise<EarlySandboxEntry<TSandbox> | null>,
387
402
  string
@@ -392,9 +407,11 @@ export class EarlySandboxRegistry<
392
407
  entry: Promise<EarlySandboxEntry<TSandbox> | null>,
393
408
  ttlMs: number = EARLY_SANDBOX_REAP_AFTER_MS * 2,
394
409
  orgId?: string,
410
+ units: number = 1,
395
411
  ): void {
396
412
  this.#entries.set(key, entry);
397
413
  this.#outstanding.add(entry);
414
+ this.#units.set(entry, units);
398
415
  if (orgId) this.#outstandingOrg.set(entry, orgId);
399
416
  void entry.then(
400
417
  (resolved) => {
@@ -449,6 +466,7 @@ export class EarlySandboxRegistry<
449
466
  #release(entry: Promise<EarlySandboxEntry<TSandbox> | null>): void {
450
467
  if (!this.#outstanding.delete(entry)) return;
451
468
  this.#outstandingOrg.delete(entry);
469
+ this.#units.delete(entry);
452
470
  for (const [sandboxId, held] of this.#outstandingBySandboxId) {
453
471
  if (held === entry) this.#outstandingBySandboxId.delete(sandboxId);
454
472
  }
@@ -697,7 +715,13 @@ export function startEarlySandbox<TSandbox extends EarlySandboxHandle>(
697
715
  });
698
716
  return null;
699
717
  });
700
- adapter.registry.put(key, started, undefined, orgId);
718
+ adapter.registry.put(
719
+ key,
720
+ started,
721
+ undefined,
722
+ orgId,
723
+ earlySandboxCapUnits(input.sandboxRuntimeLimits),
724
+ );
701
725
  logEarlySandbox(adapter.logScope, 'hint_accepted', {
702
726
  key,
703
727
  orgId,
@@ -1236,6 +1260,20 @@ export async function adoptEarlySandbox<
1236
1260
  sandboxId: sandbox.sandboxId,
1237
1261
  elapsedMs: nowMs() - startedAt,
1238
1262
  });
1263
+ // A genuine mismatch comes from the creating worker's own limits; a
1264
+ // published pre-boot plan on a sandbox whose limitsKey disagrees with
1265
+ // this launch's means a tag was written outside that path. Loud, so
1266
+ // it is never folded into the ordinary miss.
1267
+ if (tags[EARLY_PREBOOT_TAG]?.startsWith('plan')) {
1268
+ console.error(
1269
+ JSON.stringify({
1270
+ event: 'play-runner.early.limits_mismatch_with_plan',
1271
+ key,
1272
+ sandboxId: sandbox.sandboxId,
1273
+ how,
1274
+ }),
1275
+ );
1276
+ }
1239
1277
  return null;
1240
1278
  }
1241
1279
  // PB: another process started a runner here and holds its delivery
@@ -2,6 +2,7 @@ import {
2
2
  normalizePlayRuntimeBackend,
3
3
  type PlayRuntimeBackendId,
4
4
  } from '../backend';
5
+ import { earlySandboxCapUnits } from '../../plays/sandbox-runtime-limits';
5
6
  import { modalEarlySandboxAdapter } from '../runner-backends/backends/modal';
6
7
  import {
7
8
  EARLY_SANDBOX_START,
@@ -63,8 +64,9 @@ export const EARLY_SANDBOX_POLICY_LEAD_PROVIDER: RuntimeSandboxProviderId =
63
64
 
64
65
  /**
65
66
  * Early sandboxes one worker process may hold unadopted at once, summed over
66
- * its Adapters' registries. A hint past it is refused; its run creates its
67
- * own sandbox at launch.
67
+ * its Adapters' registries, in size units (`earlySandboxCapUnits`: standard 1,
68
+ * large 2, xlarge 4). A hint past it is refused; its run creates its own
69
+ * sandbox at launch.
68
70
  */
69
71
  export const EARLY_SANDBOX_MAX_OUTSTANDING_PER_WORKER = 16;
70
72
 
@@ -372,10 +374,14 @@ export function startWorkerLaneEarlySandbox(
372
374
  );
373
375
  return false;
374
376
  }
377
+ // Caps are in size units (`earlySandboxCapUnits`): a hint is admitted only
378
+ // if its own units still fit, so a standard (1-unit) hint is refused at
379
+ // exactly the counts it was before.
380
+ const units = earlySandboxCapUnits(input.sandboxRuntimeLimits);
375
381
  const outstanding = outstandingEarlySandboxes(
376
382
  input.adapters ?? EARLY_SANDBOX_ADAPTERS,
377
383
  );
378
- if (outstanding >= EARLY_SANDBOX_MAX_OUTSTANDING_PER_WORKER) {
384
+ if (outstanding + units > EARLY_SANDBOX_MAX_OUTSTANDING_PER_WORKER) {
379
385
  return refuseEarlySandboxHint({
380
386
  ...hint,
381
387
  reason: 'outstanding_cap',
@@ -388,7 +394,10 @@ export function startWorkerLaneEarlySandbox(
388
394
  hintOrgId,
389
395
  input.adapters ?? EARLY_SANDBOX_ADAPTERS,
390
396
  );
391
- if (orgOutstanding >= EARLY_SANDBOX_MAX_OUTSTANDING_PER_ORG_PER_WORKER) {
397
+ if (
398
+ orgOutstanding + units >
399
+ EARLY_SANDBOX_MAX_OUTSTANDING_PER_ORG_PER_WORKER
400
+ ) {
392
401
  return refuseEarlySandboxHint({
393
402
  ...hint,
394
403
  reason: 'org_outstanding_cap',
@@ -23953,15 +23953,15 @@ function runLedgerDiscoveryHeadsSql(
23953
23953
  )`;
23954
23954
  }
23955
23955
 
23956
- function runLedgerReadyHeadSql(
23956
+ /** Whether another delivery currently leases this run's lane. */
23957
+ function runLedgerRunLeasedSql(
23958
+ runIdSql: string,
23957
23959
  options: Pick<PostgresSchedulerOptions, 'schema'> | undefined,
23958
23960
  searchOnly: boolean,
23959
23961
  ): string {
23960
- return `head.failed_at IS NULL
23961
- AND coalesce(head.next_attempt_at, head.created_at) <= now()
23962
- AND NOT EXISTS (
23962
+ return `EXISTS (
23963
23963
  SELECT 1 FROM ${tableName('outbox', options)} AS active
23964
- WHERE active.run_id = runs.run_id
23964
+ WHERE active.run_id = ${runIdSql}
23965
23965
  AND ${searchLaneSql('active')} = ${String(searchOnly)}
23966
23966
  AND active.delivered_at IS NULL
23967
23967
  AND active.lease_owner IS NOT NULL
@@ -23969,7 +23969,52 @@ function runLedgerReadyHeadSql(
23969
23969
  )`;
23970
23970
  }
23971
23971
 
23972
- function runLedgerAdmissionOrderSql(
23972
+ function runLedgerReadyHeadSql(
23973
+ options: Pick<PostgresSchedulerOptions, 'schema'> | undefined,
23974
+ searchOnly: boolean,
23975
+ /** A lease already computed for this head (`head_workspace_share.leased`). */
23976
+ leasedSql?: string,
23977
+ ): string {
23978
+ return `head.failed_at IS NULL
23979
+ AND coalesce(head.next_attempt_at, head.created_at) <= now()
23980
+ AND NOT ${leasedSql ?? runLedgerRunLeasedSql('runs.run_id', options, searchOnly)}`;
23981
+ }
23982
+
23983
+ /**
23984
+ * Workspace fair share for global claims and admission hints. Each discovered
23985
+ * head belongs to a run; a run leased by an in-flight delivery still has its
23986
+ * head pending. The count of such leased heads per workspace is that
23987
+ * workspace's current share of the drain. Ordering ready heads by it gives
23988
+ * the next free slot to the workspace with the fewest deliveries in flight,
23989
+ * so one workspace's backlog cannot delay every other workspace's projection
23990
+ * (Production 2026-12-01 06:09-06:51Z). It is work-conserving: a lone
23991
+ * backlogged workspace still receives every free slot. Admission class still
23992
+ * comes first and age orders heads within an equal share. Each head's lease
23993
+ * is read once here and reused by the ready filter. Window functions cannot
23994
+ * share a query level with FOR UPDATE, so the share is materialized beside
23995
+ * the heads.
23996
+ */
23997
+ function runLedgerWorkspaceShareSql(
23998
+ options: Pick<PostgresSchedulerOptions, 'schema'> | undefined,
23999
+ searchOnly: boolean,
24000
+ ): string {
24001
+ return `head_workspace_share AS MATERIALIZED (
24002
+ SELECT leased_head.run_id,
24003
+ leased_head.leased,
24004
+ count(*) FILTER (WHERE leased_head.leased)
24005
+ OVER (PARTITION BY leased_head.org_id) AS workspace_in_flight
24006
+ FROM (
24007
+ SELECT head.run_id,
24008
+ share_run.org_id,
24009
+ ${runLedgerRunLeasedSql('head.run_id', options, searchOnly)} AS leased
24010
+ FROM heads AS head
24011
+ JOIN ${tableName('runs', options)} AS share_run
24012
+ ON share_run.run_id = head.run_id
24013
+ ) AS leased_head
24014
+ )`;
24015
+ }
24016
+
24017
+ function runLedgerAdmissionClassSql(
23973
24018
  options: Pick<PostgresSchedulerOptions, 'schema'> | undefined,
23974
24019
  searchOnly: boolean,
23975
24020
  ): string {
@@ -23978,7 +24023,14 @@ function runLedgerAdmissionOrderSql(
23978
24023
  WHEN ${runLedgerTerminalPendingSql('head', options)} THEN 1
23979
24024
  ${searchOnly ? '' : `WHEN ${runLedgerWaitingPendingSql('head', options)} THEN 2`}
23980
24025
  ELSE 3
23981
- END,`;
24026
+ END`;
24027
+ }
24028
+
24029
+ function runLedgerAdmissionOrderSql(
24030
+ options: Pick<PostgresSchedulerOptions, 'schema'> | undefined,
24031
+ searchOnly: boolean,
24032
+ ): string {
24033
+ return `${runLedgerAdmissionClassSql(options, searchOnly)},`;
23982
24034
  }
23983
24035
 
23984
24036
  export type RunLedgerOutboxAdmissionHint = {
@@ -24009,13 +24061,23 @@ export async function readPostgresSchedulerOutboxAdmissionHints(
24009
24061
  );
24010
24062
  const result = await client.query<{ run_id: string }>(
24011
24063
  `
24012
- ${runLedgerDiscoveryHeadsSql(options, false)}
24064
+ ${runLedgerDiscoveryHeadsSql(options, false)},
24065
+ ${runLedgerWorkspaceShareSql(options, false)}
24013
24066
  SELECT runs.run_id
24014
24067
  FROM heads AS head
24068
+ JOIN head_workspace_share AS share ON share.run_id = head.run_id
24015
24069
  JOIN ${tableName('runs', options)} AS runs ON runs.run_id = head.run_id
24016
- WHERE ${runLedgerReadyHeadSql(options, false)}
24070
+ WHERE ${runLedgerReadyHeadSql(options, false, 'share.leased')}
24017
24071
  AND NOT (runs.run_id = ANY($2::text[]))
24018
- ORDER BY ${runLedgerAdmissionOrderSql(options, false)} head.created_at, runs.run_id
24072
+ -- These hints fill up to three slots before any is claimed. A head's
24073
+ -- rank within its workspace and class counts as in flight, so one batch
24074
+ -- interleaves workspaces instead of taking one workspace's oldest heads.
24075
+ ORDER BY ${runLedgerAdmissionOrderSql(options, false)}
24076
+ share.workspace_in_flight + row_number() OVER (
24077
+ PARTITION BY runs.org_id, ${runLedgerAdmissionClassSql(options, false)}
24078
+ ORDER BY head.created_at, runs.run_id
24079
+ ),
24080
+ head.created_at, runs.run_id
24019
24081
  LIMIT $1
24020
24082
  `,
24021
24083
  [input.limit, input.excludeRunIds],
@@ -25573,6 +25635,63 @@ export async function readPostgresSchedulerOutboxOldestPendingSeconds(
25573
25635
  return Number.isFinite(value) ? Math.max(0, Math.floor(value)) : 0;
25574
25636
  }
25575
25637
 
25638
+ export type PostgresSchedulerOutboxBacklogOwner = {
25639
+ orgId: string;
25640
+ /** Runs with an undelivered lifecycle head. */
25641
+ pendingRuns: number;
25642
+ /** Of those, runs a delivery currently leases: the workspace's drain share. */
25643
+ inFlightRuns: number;
25644
+ oldestHeadSeconds: number;
25645
+ };
25646
+
25647
+ /**
25648
+ * Name the workspaces holding a lifecycle backlog, largest first. This reuses
25649
+ * the global claim's own head discovery (one indexed seek per pending run), so
25650
+ * it costs one claim's discovery. The projector reads it only from its periodic
25651
+ * drain probe while the oldest pending fact is already old, never per scrape.
25652
+ */
25653
+ export async function readPostgresSchedulerOutboxBacklogOwners(
25654
+ client: PostgresSchedulerQueryClient,
25655
+ input: { limit: number },
25656
+ options?: Pick<PostgresSchedulerOptions, 'schema'>,
25657
+ ): Promise<PostgresSchedulerOutboxBacklogOwner[]> {
25658
+ const limit = Math.max(1, Math.min(10, Math.floor(input.limit)));
25659
+ if (!(await runLedgerOutboxLaneHasPending(client, options, false))) return [];
25660
+ const result = await client.query<{
25661
+ org_id: string;
25662
+ pending_runs: number | string;
25663
+ in_flight_runs: number | string;
25664
+ oldest_head_seconds: number | string | null;
25665
+ }>(
25666
+ `
25667
+ ${runLedgerDiscoveryHeadsSql(options, false)}
25668
+ SELECT owner_run.org_id,
25669
+ count(*) AS pending_runs,
25670
+ count(*) FILTER (
25671
+ WHERE ${runLedgerRunLeasedSql('head.run_id', options, false)}
25672
+ ) AS in_flight_runs,
25673
+ extract(epoch FROM greatest(now() - min(head.created_at), interval '0 seconds')) AS oldest_head_seconds
25674
+ FROM heads AS head
25675
+ JOIN ${tableName('runs', options)} AS owner_run
25676
+ ON owner_run.run_id = head.run_id
25677
+ WHERE head.failed_at IS NULL
25678
+ GROUP BY owner_run.org_id
25679
+ ORDER BY count(*) DESC, min(head.created_at), owner_run.org_id
25680
+ LIMIT $1
25681
+ `,
25682
+ [limit],
25683
+ );
25684
+ return result.rows.map((row) => ({
25685
+ orgId: row.org_id,
25686
+ pendingRuns: Number(row.pending_runs),
25687
+ inFlightRuns: Number(row.in_flight_runs),
25688
+ oldestHeadSeconds: Math.max(
25689
+ 0,
25690
+ Math.floor(Number(row.oldest_head_seconds ?? 0)),
25691
+ ),
25692
+ }));
25693
+ }
25694
+
25576
25695
  /**
25577
25696
  * Read failed projection work separately from the retryable pending head.
25578
25697
  * This is intentionally a bounded operator signal: failed facts require an
@@ -27562,21 +27681,25 @@ async function dispatchRunLedgerOutboxBatchWithScope(
27562
27681
  dispatch_launch_json: unknown;
27563
27682
  transport_head?: RunLedgerTransportCandidate | null;
27564
27683
  }>(`
27565
- ${runLedgerDiscoveryHeadsSql(options, input.searchOnly === true, needsLaunch)}
27684
+ ${runLedgerDiscoveryHeadsSql(options, input.searchOnly === true, needsLaunch)},
27685
+ ${runLedgerWorkspaceShareSql(options, input.searchOnly === true)}
27566
27686
  SELECT runs.run_id, ${launchSelection} AS dispatch_launch_json, ${transportHeadSelection} AS transport_head
27567
27687
  FROM heads AS head
27688
+ JOIN head_workspace_share AS share ON share.run_id = head.run_id
27568
27689
  JOIN ${tableName('runs', options)} AS runs ON runs.run_id = head.run_id
27569
- WHERE ${runLedgerReadyHeadSql(options, input.searchOnly === true)}
27690
+ WHERE ${runLedgerReadyHeadSql(options, input.searchOnly === true, 'share.leased')}
27570
27691
  -- admission_first: admission, then the causal head of a run with
27571
- -- a pending terminal or public wait, then FIFO progress. oldest_ready keeps its
27572
- -- pure age order so continuous admissions/terminals cannot starve
27573
- -- ordinary progress.
27692
+ -- a pending terminal or public wait, then FIFO progress.
27693
+ -- oldest_ready ignores admission class so continuous
27694
+ -- admissions/terminals cannot starve ordinary progress. Within
27695
+ -- either order, the workspace with the fewest in-flight
27696
+ -- deliveries claims first, then the oldest head.
27574
27697
  ORDER BY ${
27575
27698
  input.headPriority === 'oldest_ready'
27576
27699
  ? ''
27577
27700
  : runLedgerAdmissionOrderSql(options, input.searchOnly === true)
27578
27701
  }
27579
- head.created_at, runs.run_id
27702
+ share.workspace_in_flight, head.created_at, runs.run_id
27580
27703
  FOR UPDATE OF runs SKIP LOCKED LIMIT 1
27581
27704
  `)));
27582
27705
  };
@@ -90,8 +90,9 @@ const RUN_LEDGER_OUTBOX_RECOVERY_PREVIEW_IN_FLIGHT = 16;
90
90
  // it the same total bounded search-index capacity.
91
91
  const RUN_LEDGER_OUTBOX_RECOVERY_PRODUCTION_INDEX_IN_FLIGHT = 4;
92
92
  const RUN_LEDGER_OUTBOX_RECOVERY_PREVIEW_INDEX_IN_FLIGHT = 8;
93
- // Admissions retain three of four claim opportunities. The fourth selects
94
- // the oldest eligible causal head across all runs, preventing terminal work
93
+ // Admissions retain three of four claim opportunities. The fourth ignores
94
+ // admission class and selects the oldest eligible causal head of the
95
+ // workspace with the fewest in-flight deliveries, preventing terminal work
95
96
  // from starving behind continuous new admissions. An empty class never costs
96
97
  // another query: either order can select any eligible run.
97
98
  const ADMISSION_TURNS_PER_OLDEST_READY_TURN = 3;
@@ -181,11 +182,23 @@ export type RunLedgerOutboxRecoveryController = {
181
182
  close: () => Promise<void>;
182
183
  };
183
184
 
185
+ export type RunLedgerOutboxDrainSlots = {
186
+ inFlight: number;
187
+ /** This replica's fixed delivery budget for the lane. */
188
+ parallelism: number;
189
+ };
190
+
184
191
  export type RunLedgerOutboxDrainHealth = {
185
192
  inFlightDispatches: number;
186
193
  /** Start of the oldest dispatch still in flight, or null when idle. */
187
194
  oldestInFlightStartedAt: number | null;
188
195
  lastDispatchSettledAt: number | null;
196
+ /** In-flight deliveries against each lane's budget: a full lane is a
197
+ * saturated drain, distinguishing a capacity backlog from slow delivery. */
198
+ slots: {
199
+ lifecycle: RunLedgerOutboxDrainSlots;
200
+ observability: RunLedgerOutboxDrainSlots;
201
+ };
189
202
  };
190
203
 
191
204
  function boundedFailureDelayMs(failures: number): number {
@@ -309,6 +322,7 @@ export function startRunLedgerOutboxRecovery(
309
322
  return runId;
310
323
  };
311
324
  const inFlightStartedAt = new Map<number, number>();
325
+ const inFlightByLane = { lifecycle: 0, observability: 0 };
312
326
  let nextDispatchId = 0;
313
327
  let lastDispatchSettledAt: number | null = null;
314
328
  let admissionTurns = 0;
@@ -329,7 +343,9 @@ export function startRunLedgerOutboxRecovery(
329
343
  if (!observability && origin !== 'producer_hint')
330
344
  admissionTurns = oldestReady ? 0 : admissionTurns + 1;
331
345
  const id = nextDispatchId++;
346
+ const lane = observability ? 'observability' : 'lifecycle';
332
347
  inFlightStartedAt.set(id, now());
348
+ inFlightByLane[lane] += 1;
333
349
  try {
334
350
  if (observability)
335
351
  return await (runId === undefined
@@ -341,6 +357,7 @@ export function startRunLedgerOutboxRecovery(
341
357
  : deps.dispatchOnce(headPriority, runId));
342
358
  } finally {
343
359
  inFlightStartedAt.delete(id);
360
+ inFlightByLane[lane] -= 1;
344
361
  lastDispatchSettledAt = now();
345
362
  }
346
363
  };
@@ -935,6 +952,16 @@ export function startRunLedgerOutboxRecovery(
935
952
  inFlightDispatches: inFlightStartedAt.size,
936
953
  oldestInFlightStartedAt: oldest,
937
954
  lastDispatchSettledAt,
955
+ slots: {
956
+ lifecycle: {
957
+ inFlight: inFlightByLane.lifecycle,
958
+ parallelism: lifecycleParallelism,
959
+ },
960
+ observability: {
961
+ inFlight: inFlightByLane.observability,
962
+ parallelism: observabilityParallelism,
963
+ },
964
+ },
938
965
  };
939
966
  },
940
967
  close: async () => {
@@ -1388,6 +1415,16 @@ export function startBoundedRunLedgerOutboxRecovery(
1388
1415
  inFlightDispatches: inFlightStartedAt.size,
1389
1416
  oldestInFlightStartedAt: oldest,
1390
1417
  lastDispatchSettledAt,
1418
+ slots: {
1419
+ lifecycle: {
1420
+ inFlight: inFlight.lifecycle,
1421
+ parallelism: lifecycleParallelism,
1422
+ },
1423
+ observability: {
1424
+ inFlight: inFlight.observability,
1425
+ parallelism: observabilityParallelism,
1426
+ },
1427
+ },
1391
1428
  };
1392
1429
  },
1393
1430
  close: async () => {
@@ -57,6 +57,18 @@ export function isConvexEdgeUnavailableError(
57
57
  );
58
58
  }
59
59
 
60
+ /**
61
+ * The runtime API's response code for `RuntimeRateStateUnavailableError`
62
+ * (scheduler-backends/postgres-rate-state.ts): the provider-rate tables,
63
+ * columns or schema are missing until a deploy finishes migrating them.
64
+ *
65
+ * Readers ship before any writer emits it. Until the writer lands, the
66
+ * gateway and app route still answer that error as a non-retryable 500
67
+ * `runtime_durability_internal`, so this code changes nothing on its own.
68
+ */
69
+ export const RUNTIME_RATE_STATE_UNAVAILABLE_RESPONSE_CODE =
70
+ 'runtime_rate_state_unavailable';
71
+
60
72
  export function transientServiceUnavailableDetail(
61
73
  error: unknown,
62
74
  ): string | null {
@@ -94,6 +94,26 @@ export function playSandboxSizeForLimits(
94
94
  );
95
95
  }
96
96
 
97
+ /**
98
+ * Early-start cap units for a sandbox of these limits: its CPU over the
99
+ * standard size's, from the size table (standard 1, large 2, xlarge 4).
100
+ * Early sandboxes are unbilled until adopted, so the outstanding caps weigh
101
+ * them by size. Absent or unrecognised limits count as standard: a hint only
102
+ * carries limits that already passed `readCarriedPlaySandboxRuntimeLimits`.
103
+ */
104
+ export function earlySandboxCapUnits(
105
+ limits:
106
+ | Pick<PlaySandboxRuntimeLimits, 'memoryGiB' | 'cpu' | 'diskGiB'>
107
+ | null
108
+ | undefined,
109
+ ): number {
110
+ if (!limits) return 1;
111
+ const size = playSandboxSizeForLimits(limits);
112
+ return size
113
+ ? PLAY_SANDBOX_SIZE_LIMITS[size].cpu / PLAY_SANDBOX_SIZE_LIMITS.standard.cpu
114
+ : 1;
115
+ }
116
+
97
117
  export const SUPPORTED_PLAY_SANDBOX_SIZES = PLAY_SANDBOX_SIZE_INPUTS.join(', ');
98
118
 
99
119
  export type PlaySandboxRuntimeDeclaration = {