deepline 0.3.537 → 0.3.539

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 (205) hide show
  1. package/dist/bundling-sources/sdk/src/client-core.ts +22 -5
  2. package/dist/bundling-sources/sdk/src/index.ts +2 -0
  3. package/dist/bundling-sources/sdk/src/plays/client-core.ts +18 -1
  4. package/dist/bundling-sources/sdk/src/release.ts +1 -1
  5. package/dist/bundling-sources/sdk/src/runs/watch-polling.ts +33 -4
  6. package/dist/bundling-sources/shared_libs/integration-contracts/billing-entitlements.ts +1 -1
  7. package/dist/bundling-sources/shared_libs/observability/scheduled-jobs.json +18 -0
  8. package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +9 -1
  9. package/dist/bundling-sources/shared_libs/play-runtime/baked-runner-image.ts +392 -0
  10. package/dist/bundling-sources/shared_libs/play-runtime/context.ts +717 -133
  11. package/dist/bundling-sources/shared_libs/play-runtime/coordinator-headers.ts +7 -0
  12. package/dist/bundling-sources/shared_libs/play-runtime/daytona-payload-contract.ts +22 -1
  13. package/dist/bundling-sources/shared_libs/play-runtime/durable-runs-rollout.ts +123 -0
  14. package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +480 -0
  15. package/dist/bundling-sources/shared_libs/play-runtime/fixture-egress-fetch.ts +24 -16
  16. package/dist/bundling-sources/shared_libs/play-runtime/freshness-receipt-execution.ts +293 -53
  17. package/dist/bundling-sources/shared_libs/play-runtime/governor/block-reserving-budget-state-backend.ts +57 -2
  18. package/dist/bundling-sources/shared_libs/play-runtime/governor/budget-state-backend.ts +43 -0
  19. package/dist/bundling-sources/shared_libs/play-runtime/governor/governor.ts +141 -9
  20. package/dist/bundling-sources/shared_libs/play-runtime/launch-identity.ts +4 -0
  21. package/dist/bundling-sources/shared_libs/play-runtime/modal-runtime-config.ts +6 -0
  22. package/dist/bundling-sources/shared_libs/play-runtime/modal-supervisor-sidecar.ts +556 -0
  23. package/dist/bundling-sources/shared_libs/play-runtime/protocol.ts +27 -0
  24. package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +19 -0
  25. package/dist/bundling-sources/shared_libs/play-runtime/run-ledger.ts +54 -0
  26. package/dist/bundling-sources/shared_libs/play-runtime/run-snapshot-stream.ts +5 -0
  27. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +155 -7
  28. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/relay-connection-counter.ts +103 -0
  29. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-heartbeat.ts +75 -6
  30. package/dist/bundling-sources/shared_libs/play-runtime/runner-app/runtime-terminal-push.ts +59 -0
  31. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +544 -73
  32. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-runtime-watchdog.ts +8 -1
  33. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/detached-runner-readiness-pacing.ts +19 -1
  34. package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +2399 -110
  35. package/dist/bundling-sources/shared_libs/play-runtime/runtime-flow.ts +42 -8
  36. package/dist/bundling-sources/shared_libs/play-runtime/runtime-read-through.ts +287 -0
  37. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-finish.ts +606 -0
  38. package/dist/bundling-sources/shared_libs/play-runtime/runtime-receipt-writer.ts +274 -119
  39. package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +136 -0
  40. package/dist/bundling-sources/shared_libs/play-runtime/runtime-traffic-policy.ts +54 -0
  41. package/dist/bundling-sources/shared_libs/play-runtime/runtime-work-counters.ts +10 -1
  42. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backend.ts +22 -0
  43. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-play-run-task.ts +18 -1
  44. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +18 -4
  45. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +219 -7
  46. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-shared.ts +3 -0
  47. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +340 -0
  48. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/play-run-recovery.ts +1 -0
  49. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-progress.ts +10 -1
  50. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres-rate-state.ts +623 -7
  51. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +340 -5
  52. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runner-push.ts +61 -0
  53. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-event-search.ts +2 -1
  54. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-sandbox-ledger-reconciliation.ts +269 -2
  55. package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +238 -5
  56. package/dist/bundling-sources/shared_libs/play-runtime/startup-read-tool-ids.ts +47 -0
  57. package/dist/bundling-sources/shared_libs/play-runtime/tool-call/runtime-step-receipts-adapter.ts +5 -4
  58. package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +6 -0
  59. package/dist/bundling-sources/shared_libs/play-runtime/transient-service-error.ts +11 -0
  60. package/dist/cli/auth-O5Y2VYXK.js +43 -0
  61. package/dist/cli/{auth-4SUPGDIM.mjs → auth-QD7QGD3B.mjs} +5 -5
  62. package/dist/cli/{billing-5JUA3ZM3.mjs → billing-FIZXMHBW.mjs} +31 -7
  63. package/dist/cli/{billing-SQU726P7.js → billing-KOQAF6WS.js} +114 -90
  64. package/dist/cli/{chunk-R7JYG6XO.mjs → chunk-2XMFT44N.mjs} +1 -1
  65. package/dist/cli/{chunk-XDS26J7Z.js → chunk-3YDI2PTN.js} +10 -10
  66. package/dist/cli/{chunk-KH27B2HJ.mjs → chunk-55ITVU2V.mjs} +2 -2
  67. package/dist/cli/{chunk-2Q7VXTMS.js → chunk-5QL4GJB2.js} +2 -2
  68. package/dist/cli/{chunk-D77W6Q67.js → chunk-5RUB53KG.js} +26 -26
  69. package/dist/cli/{chunk-JS2SBCWD.js → chunk-5YF35HAV.js} +6 -6
  70. package/dist/cli/{chunk-C37VELBR.mjs → chunk-6KG4KVTH.mjs} +5 -5
  71. package/dist/cli/{chunk-AX2OAXDL.mjs → chunk-6NZBLFL4.mjs} +1 -1
  72. package/dist/cli/{chunk-C3XD2WHM.mjs → chunk-6V3LNYK5.mjs} +2 -2
  73. package/dist/cli/{chunk-GPMS6OPX.mjs → chunk-ADV2IB2C.mjs} +5 -5
  74. package/dist/cli/{chunk-ZUAMXZXC.mjs → chunk-APKZGUTU.mjs} +4 -4
  75. package/dist/cli/{chunk-IQOIT6E3.js → chunk-CQJCLHBE.js} +41 -41
  76. package/dist/cli/{chunk-W3J3LT22.mjs → chunk-DZFVVP3S.mjs} +5 -5
  77. package/dist/cli/{chunk-V5IIBG2E.mjs → chunk-E4QHTDPF.mjs} +1 -1
  78. package/dist/cli/{chunk-CXTW7SRW.mjs → chunk-E7D37PLM.mjs} +8 -0
  79. package/dist/cli/{chunk-KULT6O5K.js → chunk-EAZS52DL.js} +15 -15
  80. package/dist/cli/{chunk-L3JVGNAT.mjs → chunk-F43MXIN3.mjs} +2 -2
  81. package/dist/cli/{chunk-WBTYWJLN.js → chunk-FH3P3E4S.js} +2 -2
  82. package/dist/cli/{chunk-K4WJ4BYO.mjs → chunk-FIRV7BXJ.mjs} +1 -1
  83. package/dist/cli/{chunk-NXGLJGPB.js → chunk-FSQCB5SJ.js} +2 -2
  84. package/dist/cli/{chunk-AVQET3NR.js → chunk-FTBWFDF3.js} +7 -7
  85. package/dist/cli/{chunk-QDBGPRR2.mjs → chunk-G3UFDUYU.mjs} +3 -1
  86. package/dist/cli/{chunk-ZHPSJ3LJ.mjs → chunk-GEO2EMM7.mjs} +29 -16
  87. package/dist/cli/{chunk-CGDW2CRR.mjs → chunk-GLEGINSP.mjs} +2 -2
  88. package/dist/cli/{chunk-EEFSUCYP.mjs → chunk-GLKUC5PO.mjs} +2 -2
  89. package/dist/cli/{chunk-BFHR7IC2.mjs → chunk-GNCIMHO2.mjs} +10 -10
  90. package/dist/cli/{chunk-PU42VOBI.js → chunk-ISXX5DUD.js} +3 -3
  91. package/dist/cli/{chunk-Y6AMMXWS.mjs → chunk-JBCQFG7G.mjs} +3 -3
  92. package/dist/cli/{chunk-Z2PPB3IO.mjs → chunk-JHEZQMOM.mjs} +1 -1
  93. package/dist/cli/{chunk-WBFOV5HT.js → chunk-K22EKW6L.js} +5 -5
  94. package/dist/cli/{chunk-CHIGEDAE.js → chunk-K5MZHTK7.js} +3 -3
  95. package/dist/cli/{chunk-L6QAIZNZ.js → chunk-KAEVL62Q.js} +44 -44
  96. package/dist/cli/{chunk-PJ4ZGZAN.js → chunk-KQTX545E.js} +13 -13
  97. package/dist/cli/{chunk-VP2K5B3R.mjs → chunk-LE5KN7CZ.mjs} +3 -3
  98. package/dist/cli/{chunk-BGXEMTIG.js → chunk-LEREPTAE.js} +19 -19
  99. package/dist/cli/{chunk-QPDLG7DQ.js → chunk-MI53W4DN.js} +53 -53
  100. package/dist/cli/{chunk-RMVZTBI5.mjs → chunk-MKESK3SW.mjs} +4 -4
  101. package/dist/cli/{chunk-NU7B5X6J.mjs → chunk-N3LPGGWD.mjs} +1 -1
  102. package/dist/cli/{chunk-VRYX2BR4.js → chunk-NR5PLMNG.js} +107 -107
  103. package/dist/cli/{chunk-JMHYDDBQ.js → chunk-Q4HNK7JX.js} +292 -279
  104. package/dist/cli/{chunk-37AZHCTP.mjs → chunk-RULRGMMM.mjs} +5 -5
  105. package/dist/cli/{chunk-GI3V4D7K.mjs → chunk-SDAP5MCO.mjs} +2 -2
  106. package/dist/cli/{chunk-5EOEJKSV.js → chunk-TZBCJHV6.js} +1 -1
  107. package/dist/cli/{chunk-3PMCQ3LK.js → chunk-V7DEGIYO.js} +7 -5
  108. package/dist/cli/{chunk-ALHKB3AE.js → chunk-VK5UTS5B.js} +9 -9
  109. package/dist/cli/{chunk-ZFSB7GXF.js → chunk-W32KT6LM.js} +5 -5
  110. package/dist/cli/{chunk-6BBGUQJJ.js → chunk-XTYHZEJ2.js} +8 -0
  111. package/dist/cli/{chunk-UGA5KI4A.js → chunk-XZBXQCRJ.js} +22 -22
  112. package/dist/cli/{chunk-BRRCWUOW.mjs → chunk-Y66ZMOJI.mjs} +1 -1
  113. package/dist/cli/{chunk-CFND2ACL.js → chunk-YMQFQO3K.js} +16 -16
  114. package/dist/cli/command-docs.js +2 -2
  115. package/dist/cli/command-docs.mjs +1 -1
  116. package/dist/cli/{csv-JITYN27L.js → csv-BWWJYV2C.js} +13 -13
  117. package/dist/cli/{csv-HZP6QMG7.mjs → csv-G5RQQ74W.mjs} +4 -4
  118. package/dist/cli/{db-FYSRB7O4.js → db-5KNDLADE.js} +27 -27
  119. package/dist/cli/{db-QRIRTOMM.mjs → db-AJZHWB3V.mjs} +6 -6
  120. package/dist/cli/describe-B6CN6CFJ.js +49 -0
  121. package/dist/cli/{describe-REXJVJC3.mjs → describe-QY5TKWVD.mjs} +17 -17
  122. package/dist/cli/describe-core.d.mts +3 -3
  123. package/dist/cli/describe-core.d.ts +3 -3
  124. package/dist/cli/{executions-BSTF4DDS.js → executions-BCCW76BI.js} +8 -8
  125. package/dist/cli/{executions-53KJAFOW.mjs → executions-SJPH3MZT.mjs} +6 -6
  126. package/dist/cli/{feedback-6MW3QOXX.js → feedback-GF65JKK6.js} +14 -14
  127. package/dist/cli/{feedback-CWUJJF3J.mjs → feedback-S6SZOFGK.mjs} +6 -6
  128. package/dist/cli/git-DX6NB7VF.js +25 -0
  129. package/dist/cli/{git-CKVZTJFS.mjs → git-F5FT5YVB.mjs} +5 -5
  130. package/dist/cli/index.js +143 -143
  131. package/dist/cli/index.mjs +42 -42
  132. package/dist/cli/{legacy-noops-QBL4PNGB.js → legacy-noops-ECR6FS6U.js} +9 -9
  133. package/dist/cli/{legacy-noops-USTBRFRX.mjs → legacy-noops-NOA4P5NE.mjs} +6 -6
  134. package/dist/cli/{monitors-6UCG5D7W.mjs → monitors-CTYSAGP4.mjs} +7 -7
  135. package/dist/cli/{monitors-VCR6SUZD.js → monitors-DEWBSURN.js} +100 -100
  136. package/dist/cli/{org-GSRBOJVO.mjs → org-EKSKKT7H.mjs} +6 -6
  137. package/dist/cli/{org-HPILTEG4.js → org-ZM2UUMZZ.js} +86 -86
  138. package/dist/cli/{play-TK7WOP5H.js → play-6JQOM6DE.js} +317 -317
  139. package/dist/cli/{play-QRTYQNG4.mjs → play-R2BH374J.mjs} +17 -17
  140. package/dist/cli/{providers-HEXNJ5QC.js → providers-CMIYHEMN.js} +9 -9
  141. package/dist/cli/{providers-OAQJWVBS.mjs → providers-X7WMIWO4.mjs} +6 -6
  142. package/dist/cli/{quickstart-PYZTFXZX.js → quickstart-6HVPAMSW.js} +6 -6
  143. package/dist/cli/{quickstart-FFVHTPSP.mjs → quickstart-ZZ7L6VZJ.mjs} +4 -4
  144. package/dist/cli/{run-HLN6YYZH.mjs → run-FP32RKBU.mjs} +22 -22
  145. package/dist/cli/{run-4DWJXJRO.js → run-OOHYH3GI.js} +42 -42
  146. package/dist/cli/search-34C6LFOJ.js +32 -0
  147. package/dist/cli/{search-ZHRCXGEL.mjs → search-BDDNC23Z.mjs} +7 -7
  148. package/dist/cli/{search-output-2KY6PFDH.js → search-output-5VZIQQAM.js} +6 -6
  149. package/dist/cli/{search-output-N7QXACVK.mjs → search-output-QXJ6CV5G.mjs} +4 -4
  150. package/dist/cli/{secrets-WXQ7XO5C.js → secrets-EN2HQCO3.js} +15 -15
  151. package/dist/cli/{secrets-FKMWBLHU.mjs → secrets-Z7CQSQGC.mjs} +6 -6
  152. package/dist/cli/{sessions-3YDTEDA5.mjs → sessions-I2H37OTJ.mjs} +6 -6
  153. package/dist/cli/sessions-RYQX3NDD.js +22 -0
  154. package/dist/cli/{settings-67TWLQ6E.js → settings-CTRAPFNZ.js} +85 -85
  155. package/dist/cli/{settings-JTPASUZN.mjs → settings-IYSC5PPQ.mjs} +12 -12
  156. package/dist/cli/{setup-VYNGXUJ6.mjs → setup-PU3HOVI3.mjs} +9 -9
  157. package/dist/cli/{setup-KUERQJUX.js → setup-XIN53GEW.js} +49 -49
  158. package/dist/cli/skills-576CX7DK.js +36 -0
  159. package/dist/cli/{skills-KI4KYHH6.mjs → skills-TYBML2ZO.mjs} +7 -7
  160. package/dist/cli/tools-EXMUWA3Z.js +56 -0
  161. package/dist/cli/{tools-UQDJS2RS.mjs → tools-ZVNE6M6J.mjs} +16 -16
  162. package/dist/cli/{update-7FQQUBOD.mjs → update-54WENBNT.mjs} +9 -9
  163. package/dist/cli/update-RAHETNL2.js +34 -0
  164. package/dist/cli/{views-MJK7JGZG.js → views-7L75EZOJ.js} +21 -21
  165. package/dist/cli/{views-JAM4MNNV.mjs → views-EUBB4ONT.mjs} +6 -6
  166. package/dist/cli/{workflow-AQPRIWQX.js → workflow-EZVYCR6Y.js} +17 -17
  167. package/dist/cli/{workflow-TQRV5FGO.mjs → workflow-GUKGFJ72.mjs} +7 -7
  168. package/dist/{client-BlLYQDNo.d.mts → client-D0uDBybG.d.mts} +1 -1
  169. package/dist/{client-DSQlkIDO.d.ts → client-DZTnAv4B.d.ts} +1 -1
  170. package/dist/{client-core-rX7n2H8U.d.mts → client-core-BhWf8Y1b.d.mts} +15 -2
  171. package/dist/{client-core-CDwapXy5.d.ts → client-core-og3AP1LL.d.ts} +15 -2
  172. package/dist/{compiler-manifest-BHNC4RL-.d.ts → compiler-manifest-Bes3OVA3.d.mts} +1 -1
  173. package/dist/{compiler-manifest-BHNC4RL-.d.mts → compiler-manifest-Bes3OVA3.d.ts} +1 -1
  174. package/dist/{errors-lhtIWG5Z.d.ts → errors-BJm4lLWc.d.ts} +1 -1
  175. package/dist/{errors-D7sPXrvB.d.mts → errors-Dc5r42ks.d.mts} +1 -1
  176. package/dist/{index-CQTBHXHr.d.ts → index-BfV7mRPF.d.ts} +1 -1
  177. package/dist/{index-NaDZq2xf.d.mts → index-DTkiz_Ur.d.mts} +1 -1
  178. package/dist/index.d.mts +7 -7
  179. package/dist/index.d.ts +7 -7
  180. package/dist/index.js +9 -9
  181. package/dist/index.mjs +6 -6
  182. package/dist/install-integrity.json +121 -112
  183. package/dist/plays/bundle-play-file.d.mts +3 -3
  184. package/dist/plays/bundle-play-file.d.ts +3 -3
  185. package/dist/plays/play-description.d.mts +2 -2
  186. package/dist/plays/play-description.d.ts +2 -2
  187. package/dist/plays/run-request.d.mts +2 -2
  188. package/dist/plays/run-request.d.ts +2 -2
  189. package/dist/release.d.mts +1 -1
  190. package/dist/release.d.ts +1 -1
  191. package/dist/release.js +2 -2
  192. package/dist/release.mjs +1 -1
  193. package/dist/server.d.mts +4 -4
  194. package/dist/server.d.ts +4 -4
  195. package/dist/server.js +5 -5
  196. package/dist/server.mjs +3 -3
  197. package/package.json +1 -1
  198. package/dist/cli/auth-Y2K2ZYYA.js +0 -43
  199. package/dist/cli/describe-LSOHOLFI.js +0 -49
  200. package/dist/cli/git-S7SWUZ3T.js +0 -25
  201. package/dist/cli/search-WERQBC6V.js +0 -32
  202. package/dist/cli/sessions-LXQ4Q6BS.js +0 -22
  203. package/dist/cli/skills-EFRLHY3F.js +0 -36
  204. package/dist/cli/tools-C3EIGFFP.js +0 -56
  205. package/dist/cli/update-KCY72RXH.js +0 -34
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Runtime speed profiles: a named, frozen set of per-run experiment switch
3
+ * values that admission stamps on a run.
4
+ *
5
+ * A profile is decided once, at admission, from the `runtime-fast-launch`
6
+ * feature rollout (an organization override beats the percentage) or, outside
7
+ * Production, from the `x-deepline-runtime-speed-profile` header authorized by
8
+ * the `play_run.runtime_speed_profile` internal capability. Admission writes
9
+ * the profile's switch map into the launch's existing optional
10
+ * `experimentSwitchOverrides` field, which Production workers, the
11
+ * executor-token route and the Modal backend already read. The profile id is
12
+ * also stamped as `runtimeSpeedProfile`, for attribution only: no reader
13
+ * branches on it.
14
+ *
15
+ * Every claim, resume and recovery re-reads the durable launch, never the
16
+ * rollout, so a run keeps the switch values it was admitted with. A worker
17
+ * that does not know a switch id drops it (`readCarriedExperimentSwitchOverrides`)
18
+ * and keeps that switch's static default.
19
+ *
20
+ * Rules for this registry:
21
+ * - An id's content is frozen once it has shipped. New content gets a new id
22
+ * (`fast_launch@2`), the same way placement policy ids work.
23
+ * - Each map is explicit: `true` turns a switch on, `false` pins it off, so a
24
+ * later change to a static default cannot change an admitted run.
25
+ * - Promoting a switch's static default to `true` while a profile pins it off
26
+ * would leave that profile's cohort slower than everyone else. Do it with a
27
+ * new profile id that turns it on; the registry test fails otherwise.
28
+ * - Only `perRun: true` switches can appear (the type enforces it), so E4/F1
29
+ * and every worker-process switch are impossible here.
30
+ * - S1 (the supervisor sidecar) is pinned off, and no profile may exist while
31
+ * `modalSupervisorSidecar` is on. `tests/lib/plays/runtime-speed-profile.test.ts`
32
+ * enforces both.
33
+ * - Placement and CPU are not part of any profile yet. A profile changes switch
34
+ * values only; the run's sandbox placement policy is chosen exactly as it is
35
+ * without one.
36
+ */
37
+
38
+ import type {
39
+ ExperimentSwitchOverrides,
40
+ PerRunExperimentSwitchId,
41
+ } from './experiment-switches';
42
+
43
+ /** Requests a profile for one run: `fast_launch@1`, or `off` for none. */
44
+ export const RUNTIME_SPEED_PROFILE_HEADER = 'x-deepline-runtime-speed-profile';
45
+
46
+ /** The header value that asks for no profile, even when the rollout grants one. */
47
+ export const RUNTIME_SPEED_PROFILE_OFF = 'off';
48
+
49
+ type RuntimeSpeedProfileDefinition = {
50
+ readonly summary: string;
51
+ readonly switches: Readonly<Partial<Record<PerRunExperimentSwitchId, boolean>>>;
52
+ };
53
+
54
+ export const RUNTIME_SPEED_PROFILES = {
55
+ 'fast_launch@1': {
56
+ summary:
57
+ 'The per-run admission and launch switches certified for fast launch: B, H1, P1, P2 and V3. Early start (E2 and everything built on it) and the sidecar stay off.',
58
+ switches: {
59
+ B: true,
60
+ H1: true,
61
+ P1: true,
62
+ P2: true,
63
+ V3: true,
64
+ // Early start and its dependants: not in @1.
65
+ E2: false,
66
+ PB: false,
67
+ CA: false,
68
+ A1: false,
69
+ // The supervisor sidecar: blocked for security.
70
+ S1: false,
71
+ // Never screened, or Preview-only.
72
+ PWM: false,
73
+ PWT: false,
74
+ PWV: false,
75
+ PI: false,
76
+ F3: false,
77
+ },
78
+ },
79
+ } as const satisfies Record<string, RuntimeSpeedProfileDefinition>;
80
+
81
+ export type RuntimeSpeedProfileId = keyof typeof RUNTIME_SPEED_PROFILES;
82
+
83
+ /** The profile the `runtime-fast-launch` rollout grants. */
84
+ export const RUNTIME_FAST_LAUNCH_PROFILE: RuntimeSpeedProfileId =
85
+ 'fast_launch@1';
86
+
87
+ export function isRuntimeSpeedProfileId(
88
+ value: unknown,
89
+ ): value is RuntimeSpeedProfileId {
90
+ return (
91
+ typeof value === 'string' &&
92
+ Object.prototype.hasOwnProperty.call(RUNTIME_SPEED_PROFILES, value)
93
+ );
94
+ }
95
+
96
+ export class RuntimeSpeedProfileHeaderError extends Error {
97
+ constructor(message: string) {
98
+ super(message);
99
+ this.name = 'RuntimeSpeedProfileHeaderError';
100
+ }
101
+ }
102
+
103
+ /**
104
+ * Strict parser for the request header. Returns the profile id, or null for
105
+ * `off`. Anything else throws, so a request is never silently run without the
106
+ * profile it asked for.
107
+ */
108
+ export function parseRuntimeSpeedProfileHeader(
109
+ value: string,
110
+ ): RuntimeSpeedProfileId | null {
111
+ const trimmed = value.trim();
112
+ if (trimmed === RUNTIME_SPEED_PROFILE_OFF) return null;
113
+ if (isRuntimeSpeedProfileId(trimmed)) return trimmed;
114
+ throw new RuntimeSpeedProfileHeaderError(
115
+ `Unknown runtime speed profile "${trimmed}" in ${RUNTIME_SPEED_PROFILE_HEADER}. Known: ${[
116
+ ...Object.keys(RUNTIME_SPEED_PROFILES),
117
+ RUNTIME_SPEED_PROFILE_OFF,
118
+ ].join(', ')}.`,
119
+ );
120
+ }
121
+
122
+ /**
123
+ * The switch overrides a run is admitted with: the profile's frozen map, with
124
+ * any explicitly requested per-run override winning for its own id. With no
125
+ * profile, the explicit overrides are returned unchanged.
126
+ */
127
+ export function applyRuntimeSpeedProfile(
128
+ profileId: RuntimeSpeedProfileId | null,
129
+ explicitOverrides: ExperimentSwitchOverrides | null,
130
+ ): ExperimentSwitchOverrides | null {
131
+ if (!profileId) return explicitOverrides;
132
+ return {
133
+ ...RUNTIME_SPEED_PROFILES[profileId].switches,
134
+ ...(explicitOverrides ?? {}),
135
+ };
136
+ }
@@ -123,3 +123,57 @@ export function validateRuntimeTrafficOverride(input: {
123
123
  );
124
124
  }
125
125
  }
126
+
127
+ /**
128
+ * Fast mode P1: overlap the worker's pre-create policy read with the executor
129
+ * token mint. Normally the mint acknowledges the policy it read while opening
130
+ * the compute session, and the worker needs no read of its own. When the ack
131
+ * is missing (the route's optional read lost the race on a cold instance) the
132
+ * worker used to start its own read only after the mint returned, so a slow
133
+ * mint and a slow read added up (COLDC7: a 1.9 s read after a 129 ms mint).
134
+ *
135
+ * With this on:
136
+ * - the executor-token route loads the policy reader's modules at request
137
+ * entry and starts the read as soon as the lease and origin checks pass
138
+ * (never for a rejected request), so the ack normally carries the policy;
139
+ * - the worker starts its fallback read during the mint if the mint has not
140
+ * answered within RUNTIME_TRAFFIC_POLICY_HEDGE_AFTER_MS (a delayed hedge:
141
+ * a fast mint costs no extra read).
142
+ * Unchanged: the policy is still enforced before any sandbox create, and the
143
+ * mint/compute-session ordering is untouched (both reads are pure reads).
144
+ * Gives up: one extra policy read per launch whose mint is slower than the
145
+ * hedge delay. Off.
146
+ */
147
+ export const OVERLAP_RUNTIME_TRAFFIC_POLICY_READ = false;
148
+ /** ~p90 of executor_token_mint across the msc cohorts (p50 ~130 ms). */
149
+ export const RUNTIME_TRAFFIC_POLICY_HEDGE_AFTER_MS = 300;
150
+
151
+ export type HedgedRuntimeTrafficPolicyRead = {
152
+ /** The read started during the mint, or null when the mint answered first. */
153
+ started(): Promise<RuntimeTrafficPolicy> | null;
154
+ };
155
+
156
+ /**
157
+ * Start `read` if `mint` has not settled after `delayMs`. The returned read is
158
+ * observed here, so an unused one can never become an unhandled rejection.
159
+ */
160
+ export function hedgeRuntimeTrafficPolicyRead(input: {
161
+ mint: Promise<unknown>;
162
+ read: () => Promise<RuntimeTrafficPolicy>;
163
+ delayMs?: number;
164
+ }): HedgedRuntimeTrafficPolicyRead {
165
+ let started: Promise<RuntimeTrafficPolicy> | null = null;
166
+ let mintSettled = false;
167
+ const timer = setTimeout(() => {
168
+ if (mintSettled) return;
169
+ started = Promise.resolve().then(input.read);
170
+ started.catch(() => undefined);
171
+ }, input.delayMs ?? RUNTIME_TRAFFIC_POLICY_HEDGE_AFTER_MS);
172
+ timer.unref?.();
173
+ const settle = () => {
174
+ mintSettled = true;
175
+ clearTimeout(timer);
176
+ };
177
+ input.mint.then(settle, settle);
178
+ return { started: () => started };
179
+ }
@@ -1,5 +1,7 @@
1
1
  /** Fixed-size terminal accounting retained even when detailed runtime telemetry is too large. */
2
2
  export type RuntimeWorkCounters = {
3
+ /** Absent on historical runners; never imputed as zero. */
4
+ reusableResultCalls?: number;
3
5
  logicalCalls: number;
4
6
  providerRequests: number;
5
7
  /** Older resource snapshots did not retain this scalar. */
@@ -47,7 +49,14 @@ export function runtimeWorkCountersFromStats(
47
49
  providerRequests !== null &&
48
50
  provider429s !== null
49
51
  ) {
50
- return { logicalCalls, providerRequests, provider429s };
52
+ return {
53
+ logicalCalls,
54
+ providerRequests,
55
+ provider429s,
56
+ ...(count(compact.reusableResultCalls) !== null
57
+ ? { reusableResultCalls: count(compact.reusableResultCalls)! }
58
+ : {}),
59
+ };
51
60
  }
52
61
  }
53
62
  return null;
@@ -21,6 +21,7 @@ import type { PreloadedRuntimeDbSession } from './db-session';
21
21
  import type { RuntimeAuthorityDescriptor } from './execution-capabilities';
22
22
  import type { PlayRunnerRuntimeTiming } from './protocol';
23
23
  import type { RuntimeTestPolicyOverrides } from './test-runtime-seams';
24
+ import type { ExperimentSwitchOverrides } from './experiment-switches';
24
25
  import type { PlayRunInputPayload } from './play-input';
25
26
  import type { RuntimeSandboxPlacementPolicyId } from './runtime-sandbox-placement-policy';
26
27
  import type { PlayRuntimeProtocolVersion } from './execution-protocol';
@@ -258,6 +259,27 @@ export type PlaySchedulerSubmitInput = RetainedPipelineCarrier & {
258
259
  runtimeTestFaultHeader?: string | null;
259
260
  /** Request-scoped, dev-only runtime policy overrides for black-box durability tests. */
260
261
  testPolicyOverrides?: RuntimeTestPolicyOverrides | null;
262
+ /**
263
+ * EXPERIMENT: per-run switch overrides validated and authorized at
264
+ * admission (`experiment-switches.ts`). Present only on a run whose request
265
+ * carried `x-deepline-experiment-switches`; absent means every switch keeps
266
+ * its static default, so old launches and old workers are unaffected.
267
+ */
268
+ experimentSwitchOverrides?: ExperimentSwitchOverrides | null;
269
+ /**
270
+ * The runtime speed profile (`runtime-speed-profile.ts`) the run was
271
+ * admitted with, such as `fast_launch@1`. Attribution only: its switch map
272
+ * is already in `experimentSwitchOverrides`, and no reader branches on this
273
+ * id. Absent on every run admitted without a profile.
274
+ */
275
+ runtimeSpeedProfile?: string | null;
276
+ /**
277
+ * EXPERIMENT CA: the worker that started this run's early sandbox, as named
278
+ * in its hint reply. Copied onto the run's task params, where other workers'
279
+ * claim gates read it (see early-sandbox-claim-affinity.ts). Absent on every
280
+ * other run; readers treat absence as "no affinity".
281
+ */
282
+ earlySandboxClaimOwner?: string | null;
261
283
  /**
262
284
  * Digest of the named intent behind this launch. Runtime admission compares
263
285
  * this optional field instead of treating transport and execution details as
@@ -1,6 +1,7 @@
1
1
  import type { RetryStrategy } from '@deepline/absurd/sdk';
2
2
  import type { PlaySchedulerSubmitInput } from '../scheduler-backend';
3
3
  import { RUNTIME_RELIABILITY_POLICY } from '../runtime-reliability-policy';
4
+ import { parseEarlySandboxClaimOwner } from './early-sandbox-claim-affinity';
4
5
 
5
6
  export const ABSURD_PLAY_RUN_TASK = 'play-run';
6
7
 
@@ -23,6 +24,12 @@ export type AbsurdPlayRunTaskParams = {
23
24
  */
24
25
  nestingDepth: number;
25
26
  schedulerSchema?: string | null;
27
+ /**
28
+ * EXPERIMENT CA (optional, reader-first): the worker that started the run's
29
+ * early sandbox. Other workers yield the first claim for a bounded window
30
+ * (`early-sandbox-claim-affinity.ts`). Absent: claimed as before.
31
+ */
32
+ earlySandboxClaimOwner?: string;
26
33
  };
27
34
 
28
35
  /**
@@ -34,7 +41,11 @@ export type AbsurdPlayRunTaskParams = {
34
41
  export function buildAbsurdPlayRunTask(input: {
35
42
  launch: Pick<
36
43
  PlaySchedulerSubmitInput,
37
- 'runId' | 'orgId' | 'queueMaxDelaySeconds' | 'queuePriority'
44
+ | 'runId'
45
+ | 'orgId'
46
+ | 'queueMaxDelaySeconds'
47
+ | 'queuePriority'
48
+ | 'earlySandboxClaimOwner'
38
49
  >;
39
50
  schedulerSchema?: string | null;
40
51
  }) {
@@ -44,6 +55,12 @@ export function buildAbsurdPlayRunTask(input: {
44
55
  nestingDepth: 0,
45
56
  schedulerSchema: input.schedulerSchema ?? null,
46
57
  };
58
+ const earlySandboxClaimOwner = parseEarlySandboxClaimOwner(
59
+ input.launch.earlySandboxClaimOwner,
60
+ );
61
+ if (earlySandboxClaimOwner) {
62
+ params.earlySandboxClaimOwner = earlySandboxClaimOwner;
63
+ }
47
64
  const maxDelaySeconds = input.launch.queueMaxDelaySeconds;
48
65
  const priority = input.launch.queuePriority;
49
66
  return {
@@ -29,6 +29,10 @@ import {
29
29
  withRuntimeSchedulerClient,
30
30
  type RuntimeSchedulerPoolOptions,
31
31
  } from './postgres-pool';
32
+ import {
33
+ runGatedAbsurdClaimQuery,
34
+ type EarlySandboxClaimGate,
35
+ } from './early-sandbox-claim-affinity';
32
36
 
33
37
  export { ABSURD_SCHEMA_VERSION };
34
38
 
@@ -73,6 +77,8 @@ const ABSURD_CLAIM_TASK_SQL = 'absurd.claim_task(';
73
77
  export function absurdQueryableForRuntimeScheduler(
74
78
  poolOptions: RuntimeSchedulerPoolOptions,
75
79
  observer?: AbsurdSchedulerQueryObserver,
80
+ /** CA: may skip a claim on the claim's own client (see early-sandbox-claim-affinity). */
81
+ claimGate?: EarlySandboxClaimGate,
76
82
  ): Queryable {
77
83
  return {
78
84
  query: async <Row = Record<string, unknown>>(
@@ -88,11 +94,18 @@ export function absurdQueryableForRuntimeScheduler(
88
94
  poolOptions,
89
95
  async (client) => {
90
96
  if (timed) clientAt ??= performance.now();
91
- const queried = await client.query<Row & Record<string, unknown>>(
97
+ return runGatedAbsurdClaimQuery<Row>({
92
98
  sql,
93
99
  params,
94
- );
95
- return { rows: queried.rows as Row[] };
100
+ client,
101
+ gate: claimGate,
102
+ run: async () => {
103
+ const queried = await client.query<
104
+ Row & Record<string, unknown>
105
+ >(sql, params);
106
+ return { rows: queried.rows as Row[] };
107
+ },
108
+ });
96
109
  },
97
110
  undefined,
98
111
  { signal },
@@ -123,10 +136,11 @@ export function createAbsurdForRuntimeScheduler(
123
136
  poolOptions: RuntimeSchedulerPoolOptions,
124
137
  options: Omit<AbsurdOptions, 'db'> = {},
125
138
  observer?: AbsurdSchedulerQueryObserver,
139
+ claimGate?: EarlySandboxClaimGate,
126
140
  ): Absurd {
127
141
  return new Absurd({
128
142
  ...options,
129
- db: absurdQueryableForRuntimeScheduler(poolOptions, observer),
143
+ db: absurdQueryableForRuntimeScheduler(poolOptions, observer, claimGate),
130
144
  });
131
145
  }
132
146