deepline 0.3.570 → 0.3.572
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.
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/app-runtime-api.ts +25 -0
- package/dist/bundling-sources/shared_libs/play-runtime/context.ts +1 -0
- package/dist/bundling-sources/shared_libs/play-runtime/experiment-switches.ts +11 -0
- package/dist/bundling-sources/shared_libs/play-runtime/resource-governor.ts +17 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-app/index.ts +2 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/daytona-payload-transport.ts +28 -17
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/backends/modal.ts +360 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runner-backends/early-sandbox.ts +274 -3
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-api-connection-probe.ts +199 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-scheduler-topology.ts +35 -0
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-speed-profile.ts +28 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-pool.ts +2 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts +11 -1
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-claim-affinity.ts +67 -43
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-lane.ts +23 -6
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/early-sandbox-listener-hint.ts +62 -0
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/postgres.ts +54 -2
- package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/runtime-worker-wake.ts +54 -5
- package/dist/cli/auth-PXIVGUVZ.js +44 -0
- package/dist/cli/{auth-KHJKNEYN.mjs → auth-YUDM3YOC.mjs} +5 -5
- package/dist/cli/{billing-Q4BRUODF.js → billing-F3ZGOWKL.js} +99 -99
- package/dist/cli/{billing-R5AO4M3S.mjs → billing-O7WUC4TU.mjs} +8 -8
- package/dist/cli/{chunk-FDSQSUZF.js → chunk-3SFLY3T3.js} +5 -5
- package/dist/cli/{chunk-GPXLMRCB.js → chunk-43GCEVHO.js} +3 -3
- package/dist/cli/{chunk-YQP4ZUOJ.js → chunk-4W5EFHHY.js} +7 -7
- package/dist/cli/{chunk-2GTLZNSK.js → chunk-5EMYPLTW.js} +53 -53
- package/dist/cli/{chunk-NR7QW2E7.js → chunk-5VUD7HGD.js} +2 -2
- package/dist/cli/{chunk-ZZ4D74UL.mjs → chunk-6R57HEPF.mjs} +1 -1
- package/dist/cli/{chunk-GFGXDDJH.mjs → chunk-72WI67H4.mjs} +2 -2
- package/dist/cli/{chunk-J6PTH725.js → chunk-AHNJGA6Z.js} +6 -6
- package/dist/cli/{chunk-77HEH4RY.mjs → chunk-AJO3I3LL.mjs} +1 -1
- package/dist/cli/{chunk-NVYQ6WCW.mjs → chunk-BWWDU6FN.mjs} +5 -5
- package/dist/cli/{chunk-UWQLRBXY.mjs → chunk-CYW6PE3G.mjs} +5 -5
- package/dist/cli/{chunk-5OOGWYSR.mjs → chunk-EDAG7ZU4.mjs} +1 -1
- package/dist/cli/{chunk-WINZRS3A.mjs → chunk-EKIWY5DD.mjs} +1 -1
- package/dist/cli/{chunk-3YHMHV6U.mjs → chunk-EKWDSE6H.mjs} +4 -4
- package/dist/cli/{chunk-OWEUQCBZ.js → chunk-EL4LME5Y.js} +48 -48
- package/dist/cli/{chunk-UDN6EYBJ.js → chunk-FGBX2WVJ.js} +4 -4
- package/dist/cli/{chunk-XHFSNMEU.mjs → chunk-GX4VZL4Z.mjs} +3 -3
- package/dist/cli/{chunk-NWAFCOUF.js → chunk-HYCJNHZ4.js} +15 -15
- package/dist/cli/{chunk-I4N62RWB.mjs → chunk-I4WKB3HO.mjs} +2 -2
- package/dist/cli/{chunk-FABLUH75.js → chunk-ITQPBWDS.js} +3 -3
- package/dist/cli/{chunk-HPWP2B3D.mjs → chunk-JEI7PHET.mjs} +1 -1
- package/dist/cli/{chunk-2GBOHROU.mjs → chunk-JJEN7TRR.mjs} +1 -1
- package/dist/cli/{chunk-W26YT37U.js → chunk-K4LAEKHS.js} +41 -41
- package/dist/cli/{chunk-ZZ7ZH27W.js → chunk-LBNP52C4.js} +5 -5
- package/dist/cli/{chunk-73RTZMDV.mjs → chunk-MVQ5XGRO.mjs} +3 -3
- package/dist/cli/{chunk-PERYT4ZA.js → chunk-NOKSEYMS.js} +1 -1
- package/dist/cli/{chunk-EEUBKKJE.mjs → chunk-OUVQKSVC.mjs} +1 -1
- package/dist/cli/{chunk-OV6EKORX.js → chunk-PI4TKE2B.js} +26 -26
- package/dist/cli/{chunk-OOTXBEHG.mjs → chunk-PQ6PM4V6.mjs} +1 -1
- package/dist/cli/{chunk-2MXS53XJ.js → chunk-PRDCU7BY.js} +20 -20
- package/dist/cli/{chunk-CHHXUEVC.js → chunk-PZGK6EEB.js} +100 -100
- package/dist/cli/{chunk-O3ET4XR3.mjs → chunk-Q6H5RRTG.mjs} +4 -4
- package/dist/cli/{chunk-MVHKTZCX.mjs → chunk-QA733N7N.mjs} +1 -1
- package/dist/cli/{chunk-SOZ2SB43.js → chunk-QMIMGKR2.js} +9 -9
- package/dist/cli/{chunk-TMT3S2JR.mjs → chunk-RIA73OAZ.mjs} +2 -2
- package/dist/cli/{chunk-BEE5VGCL.mjs → chunk-SJI56XPM.mjs} +11 -11
- package/dist/cli/{chunk-TWHTVGGW.mjs → chunk-UFUXGMHL.mjs} +2 -2
- package/dist/cli/{chunk-JSHE4W6W.js → chunk-UKD5ZBQD.js} +5 -5
- package/dist/cli/{chunk-I5EZZFQL.mjs → chunk-UMP76GYQ.mjs} +3 -3
- package/dist/cli/{chunk-RS6KPFQX.mjs → chunk-UQWYDNGB.mjs} +5 -5
- package/dist/cli/{chunk-PSMYOQFI.js → chunk-UUYB6IXC.js} +13 -13
- package/dist/cli/{chunk-EYEPXZNS.mjs → chunk-UY6Z3XWW.mjs} +2 -2
- package/dist/cli/{chunk-MH3WE5O6.mjs → chunk-V2W7GX2I.mjs} +2 -2
- package/dist/cli/{chunk-WNUFRUNS.js → chunk-VGPHXXPI.js} +15 -15
- package/dist/cli/{chunk-Q4P6STRD.js → chunk-VZ4S5JRC.js} +23 -23
- package/dist/cli/{chunk-OPZHUL6T.js → chunk-W3HLZ24Q.js} +10 -10
- package/dist/cli/{chunk-J6M2AX3P.js → chunk-W3RHISD6.js} +8 -8
- package/dist/cli/{chunk-EJB4V77N.mjs → chunk-W742U53L.mjs} +5 -5
- package/dist/cli/{chunk-YXJVYY5V.mjs → chunk-X6F4XOT2.mjs} +2 -2
- package/dist/cli/{chunk-ZGOCDLJQ.js → chunk-XNJXRS3B.js} +2 -2
- package/dist/cli/{chunk-NIO2T6OC.js → chunk-XVQE6IBS.js} +2 -2
- package/dist/cli/{chunk-DPZAEVPO.js → chunk-YOST7EJF.js} +20 -20
- package/dist/cli/{concurrent-runs-help-Q26CEJ7I.mjs → concurrent-runs-help-5BKCGFGL.mjs} +6 -6
- package/dist/cli/concurrent-runs-help-KGELXJIQ.js +22 -0
- package/dist/cli/{csv-Z34I5QIU.js → csv-7ZAWND7L.js} +13 -13
- package/dist/cli/{csv-6LI6HLKG.mjs → csv-MO5WZZDN.mjs} +4 -4
- package/dist/cli/{db-NUDEYQCF.js → db-36LX7JBQ.js} +27 -27
- package/dist/cli/{db-K5GKIKQU.mjs → db-OYMULINA.mjs} +6 -6
- package/dist/cli/describe-AVGE4MH6.js +50 -0
- package/dist/cli/{describe-EB4KTEPT.mjs → describe-JLAERB6X.mjs} +18 -18
- package/dist/cli/{executions-KHOUABZ3.js → executions-AQ32J4BZ.js} +8 -8
- package/dist/cli/{executions-DAGHJZEI.mjs → executions-IZAB2XNC.mjs} +6 -6
- package/dist/cli/{feedback-XLAWTPK2.js → feedback-3IV54HOH.js} +14 -14
- package/dist/cli/{feedback-A57YETEA.mjs → feedback-WA6EBE5H.mjs} +6 -6
- package/dist/cli/{git-U3FNR34D.mjs → git-OSLU6HIK.mjs} +5 -5
- package/dist/cli/git-VOFO6V5W.js +26 -0
- package/dist/cli/index.js +143 -143
- package/dist/cli/index.mjs +45 -45
- package/dist/cli/{integrations-YVOJ5D6W.js → integrations-65SYNL53.js} +29 -29
- package/dist/cli/{integrations-LXUMB4RY.mjs → integrations-WOXFOC4M.mjs} +7 -7
- package/dist/cli/{legacy-noops-IZVLGQZJ.js → legacy-noops-3SGXDAV6.js} +9 -9
- package/dist/cli/{legacy-noops-4Z2RBTHW.mjs → legacy-noops-4FNG2JY3.mjs} +6 -6
- package/dist/cli/{mcp-GRGI3KYH.js → mcp-PX27RHCY.js} +24 -24
- package/dist/cli/{mcp-ZHXRVV7D.mjs → mcp-RZLWMZHH.mjs} +4 -4
- package/dist/cli/{monitors-XFN5D6EW.js → monitors-F5BLGS4R.js} +100 -100
- package/dist/cli/{monitors-7ZVYJ3CX.mjs → monitors-VK2LW7VU.mjs} +7 -7
- package/dist/cli/{org-YY5JTKNV.mjs → org-7AEBTN6Y.mjs} +6 -6
- package/dist/cli/{org-RWWXN5TK.js → org-UU3V7U4K.js} +121 -121
- package/dist/cli/{outcomes-MGWUZNQ6.mjs → outcomes-BWERSUJL.mjs} +6 -6
- package/dist/cli/{outcomes-AOZVYNJT.js → outcomes-GCTBGPMK.js} +14 -14
- package/dist/cli/{play-S34KIOWS.js → play-7NBCCL26.js} +324 -324
- package/dist/cli/{play-AJR7BT3R.mjs → play-TX3RAAYS.mjs} +19 -19
- package/dist/cli/{providers-S4WMWHBW.js → providers-IL2IVKHB.js} +9 -9
- package/dist/cli/{providers-QRWQGVIC.mjs → providers-KFWZXDCV.mjs} +6 -6
- package/dist/cli/{quickstart-GET2M3BQ.js → quickstart-MPA6TUK5.js} +6 -6
- package/dist/cli/{quickstart-NLAIOXVY.mjs → quickstart-RAMDGRRI.mjs} +4 -4
- package/dist/cli/{run-R2RYHNVS.mjs → run-QNJSKPBN.mjs} +23 -23
- package/dist/cli/{run-BOHHBZSI.js → run-WBUSXBUS.js} +44 -44
- package/dist/cli/{search-VBIVRRRO.mjs → search-2X4P2FXR.mjs} +7 -7
- package/dist/cli/search-CJHG3VA4.js +32 -0
- package/dist/cli/{search-output-OCYIQFV6.mjs → search-output-MNJ4AQLV.mjs} +4 -4
- package/dist/cli/{search-output-EVNRKEGZ.js → search-output-P2WNCHA3.js} +6 -6
- package/dist/cli/{secrets-52T2SCZ5.js → secrets-K5CNDUVR.js} +15 -15
- package/dist/cli/{secrets-TNCO45WJ.mjs → secrets-XX54OU22.mjs} +6 -6
- package/dist/cli/sessions-3RMRBBJZ.js +23 -0
- package/dist/cli/{sessions-4XE7AR3A.mjs → sessions-C4GQ6ZVO.mjs} +6 -6
- package/dist/cli/{settings-ZFCHR7MW.mjs → settings-7HBTADGW.mjs} +12 -12
- package/dist/cli/{settings-TKRF2B3K.js → settings-QP3DVFPS.js} +85 -85
- package/dist/cli/{setup-QY3ZML4C.mjs → setup-VPDAKY2G.mjs} +9 -9
- package/dist/cli/{setup-AWNE4VNL.js → setup-X6J7U6B4.js} +49 -49
- package/dist/cli/skills-JUGXGSX2.js +37 -0
- package/dist/cli/{skills-GUGJDCFY.mjs → skills-UGY6W4AC.mjs} +7 -7
- package/dist/cli/{tools-NBKPWOWD.mjs → tools-SVBUAHDD.mjs} +17 -17
- package/dist/cli/tools-ZEI42NSP.js +57 -0
- package/dist/cli/{update-KLGVIBRY.mjs → update-SDNKNDNW.mjs} +9 -9
- package/dist/cli/update-VC4UEGMR.js +37 -0
- package/dist/cli/{views-MDXEIVQ7.js → views-JBFSHQBU.js} +21 -21
- package/dist/cli/{views-OEOW2EZO.mjs → views-M6RBPC65.mjs} +6 -6
- package/dist/cli/{workflow-LK4SIUOM.mjs → workflow-RYVRAIHV.mjs} +7 -7
- package/dist/cli/{workflow-PUSTWPW4.js → workflow-UAMTGHQC.js} +17 -17
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +113 -112
- package/dist/release.d.mts +1 -1
- package/dist/release.d.ts +1 -1
- package/dist/release.js +2 -2
- package/dist/release.mjs +1 -1
- package/dist/server.js +5 -5
- package/dist/server.mjs +3 -3
- package/package.json +1 -1
- package/dist/cli/auth-X2LWGPF4.js +0 -44
- package/dist/cli/concurrent-runs-help-QDURIV4N.js +0 -22
- package/dist/cli/describe-BY7LKP53.js +0 -50
- package/dist/cli/git-CR6PBWBH.js +0 -26
- package/dist/cli/search-CZVM2OX5.js +0 -32
- package/dist/cli/sessions-GOHYDYMH.js +0 -23
- package/dist/cli/skills-54CGCMPF.js +0 -37
- package/dist/cli/tools-A7FEGDPX.js +0 -57
- package/dist/cli/update-3J52CJHB.js +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
1
|
+
import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
2
|
import type { PlaySandboxRuntimeLimits } from '../../plays/sandbox-runtime-limits';
|
|
3
3
|
import {
|
|
4
4
|
resolveExperimentSwitch,
|
|
@@ -117,6 +117,179 @@ export const EARLY_PREBOOT_TAG = 'earlyPreboot';
|
|
|
117
117
|
* runs from pre-boot, and the runner's config wait has a 120 s deadline.
|
|
118
118
|
*/
|
|
119
119
|
export const EARLY_PREBOOT_MAX_ADOPTION_AGE_MS = 30_000;
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Preview experiment PX: a pre-booted early sandbox may be adopted by ANY
|
|
123
|
+
* worker, not only the one that started its runner. The pre-booted runner
|
|
124
|
+
* already waits for its config on files inside the sandbox (the launch
|
|
125
|
+
* delivers them with its own exec by sandbox id), so the only process-local
|
|
126
|
+
* state is the runner's paths and limits. With PX the starting worker
|
|
127
|
+
* publishes them as tags once the pre-boot verified (`publishEarlyPrebootPlan`):
|
|
128
|
+
* one path nonce, the start time, and an HMAC under the workers' internal
|
|
129
|
+
* token over the early key, sandbox id, nonce, start, limits, memory and baked
|
|
130
|
+
* runner hash. A launch on another worker verifies that MAC with its own
|
|
131
|
+
* inputs (`verifyEarlyPrebootPlan`), so a forged or mismatched plan is never
|
|
132
|
+
* delivered to; nothing customer-related is in the tags. Exclusivity is the
|
|
133
|
+
* run attempt's own claim: only the worker running this attempt's launch
|
|
134
|
+
* adopts, and adoption re-tags the sandbox, which the reaper then skips.
|
|
135
|
+
* Liveness without the starting worker's exec handle is the launch's
|
|
136
|
+
* readiness deadline. Off: a foreign pre-boot is refused as today.
|
|
137
|
+
*/
|
|
138
|
+
export const ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES = false;
|
|
139
|
+
/**
|
|
140
|
+
* PX: the published plan rides in the existing `earlyPreboot` tag's value
|
|
141
|
+
* (see the format below), because a Modal sandbox holds at most
|
|
142
|
+
* 10 tags and an early sandbox already carries 9 (lane runtime-1eb0a98f1f44,
|
|
143
|
+
* 2026-11-30: three separate plan tags failed every write with "Sandboxes
|
|
144
|
+
* have a limit of 10 tags."). Readers that only test the tag's presence are
|
|
145
|
+
* unchanged.
|
|
146
|
+
*
|
|
147
|
+
* `plan2:<nonce>.<startedAtMs>.<mac>`: a 96-bit random path nonce and a 96-bit
|
|
148
|
+
* MAC in base64url, the start in base 36 (~49 bytes). A Modal sandbox's tags
|
|
149
|
+
* are also capped at 512 bytes in total, and plan1 (~121 bytes, hex and
|
|
150
|
+
* decimal) pushed every caller-owned run (its ~140-byte workflowId tag) to
|
|
151
|
+
* 535-545 bytes, so its plan was never published (lanes runtime-b026b69af07b,
|
|
152
|
+
* runtime-d65976cf8f14, runtime-0aa51deff3d9, 2026-11-30).
|
|
153
|
+
*/
|
|
154
|
+
const EARLY_PREBOOT_PLAN_PREFIX = 'plan2:';
|
|
155
|
+
const EARLY_PREBOOT_PLAN_VALUE =
|
|
156
|
+
/^plan2:([A-Za-z0-9_-]{16})\.([1-9a-z][0-9a-z]{0,10})\.([A-Za-z0-9_-]{16})$/;
|
|
157
|
+
/** Modal's cap on a sandbox's cumulative tag size, in bytes. */
|
|
158
|
+
export const MODAL_SANDBOX_TAGS_MAX_BYTES = 512;
|
|
159
|
+
|
|
160
|
+
/** Bytes Modal counts toward that cap: every tag name and value (UTF-8). */
|
|
161
|
+
export function modalSandboxTagsBytes(tags: Record<string, string>): number {
|
|
162
|
+
return Object.entries(tags).reduce(
|
|
163
|
+
(sum, [name, value]) => sum + Buffer.byteLength(name) + Buffer.byteLength(value),
|
|
164
|
+
0,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
const MAC_BYTES = 12;
|
|
168
|
+
|
|
169
|
+
/** PX: a fresh 96-bit path nonce (base64url, safe in file names). */
|
|
170
|
+
export function newEarlyPrebootPathNonce(): string {
|
|
171
|
+
return randomBytes(12).toString('base64url');
|
|
172
|
+
}
|
|
173
|
+
/** A plan from a worker whose clock runs ahead by more than this is refused. */
|
|
174
|
+
export const EARLY_PREBOOT_PLAN_FUTURE_SKEW_MS = 5_000;
|
|
175
|
+
/**
|
|
176
|
+
* PX: when the creator re-reads a published sandbox's tags to settle it once
|
|
177
|
+
* another worker adopted it (past the 30 s pre-boot adoption age), instead of
|
|
178
|
+
* counting it against its caps until the 90 s reaper.
|
|
179
|
+
*/
|
|
180
|
+
export const EARLY_PREBOOT_ADOPTION_PROBE_AFTER_MS = 35_000;
|
|
181
|
+
|
|
182
|
+
/** The fields a published pre-boot plan binds. */
|
|
183
|
+
export type EarlyPrebootPlan = {
|
|
184
|
+
key: string;
|
|
185
|
+
sandboxId: string;
|
|
186
|
+
nonce: string;
|
|
187
|
+
startedAtMs: number;
|
|
188
|
+
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
189
|
+
memoryLimitMiB?: number;
|
|
190
|
+
bakedRunnerHash: string;
|
|
191
|
+
/**
|
|
192
|
+
* sha256 of the pre-booted runner's command, as each side builds it, so a
|
|
193
|
+
* launch on a different build (another command for the same nonce) refuses
|
|
194
|
+
* instead of delivering to paths the runner is not watching.
|
|
195
|
+
*/
|
|
196
|
+
runnerCommandSha256: string;
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** sha256 hex of a pre-booted runner's command. */
|
|
200
|
+
export function earlyPrebootRunnerCommandSha256(command: string): string {
|
|
201
|
+
return createHash('sha256').update(command).digest('hex');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function earlyPrebootPlanMac(secret: string, plan: EarlyPrebootPlan): Buffer {
|
|
205
|
+
return createHmac('sha256', `early-preboot-plan2:${secret}`)
|
|
206
|
+
.update(
|
|
207
|
+
JSON.stringify([
|
|
208
|
+
plan.key,
|
|
209
|
+
plan.sandboxId,
|
|
210
|
+
plan.nonce,
|
|
211
|
+
plan.startedAtMs,
|
|
212
|
+
plan.sandboxRuntimeLimits,
|
|
213
|
+
plan.memoryLimitMiB ?? null,
|
|
214
|
+
plan.bakedRunnerHash,
|
|
215
|
+
plan.runnerCommandSha256,
|
|
216
|
+
]),
|
|
217
|
+
)
|
|
218
|
+
.digest()
|
|
219
|
+
.subarray(0, MAC_BYTES);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** PX: the tag that publishes a verified pre-boot's plan (one tag). */
|
|
223
|
+
export function publishEarlyPrebootPlan(
|
|
224
|
+
secret: string,
|
|
225
|
+
plan: EarlyPrebootPlan,
|
|
226
|
+
): Record<string, string> {
|
|
227
|
+
return {
|
|
228
|
+
[EARLY_PREBOOT_TAG]: `${EARLY_PREBOOT_PLAN_PREFIX}${plan.nonce}.${plan.startedAtMs.toString(36)}.${earlyPrebootPlanMac(secret, plan).toString('base64url')}`,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* PX: the published plan another worker may deliver to, or why not. The MAC
|
|
234
|
+
* is recomputed from this launch's own limits, memory and baked runner, so a
|
|
235
|
+
* plan made for anything else (or forged by a tag writer without the token)
|
|
236
|
+
* is refused; so is a pre-boot past the in-process adoption age.
|
|
237
|
+
*/
|
|
238
|
+
export function verifyEarlyPrebootPlan(input: {
|
|
239
|
+
secret: string;
|
|
240
|
+
tags: Record<string, string>;
|
|
241
|
+
key: string;
|
|
242
|
+
sandboxId: string;
|
|
243
|
+
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
244
|
+
memoryLimitMiB?: number;
|
|
245
|
+
bakedRunnerHash: string;
|
|
246
|
+
/** This launch's own runner command for the plan's nonce, hashed. */
|
|
247
|
+
runnerCommandSha256: (nonce: string) => string;
|
|
248
|
+
nowMs: number;
|
|
249
|
+
}):
|
|
250
|
+
| { plan: EarlyPrebootPlan }
|
|
251
|
+
| { refused: 'preboot_plan_missing' | 'preboot_plan_invalid' | 'preboot_stale' } {
|
|
252
|
+
const value = input.tags[EARLY_PREBOOT_TAG];
|
|
253
|
+
// `1` (the create-time claim) or absent: not published (yet). Any other
|
|
254
|
+
// plan form (an older or newer build's) is refused, never guessed at.
|
|
255
|
+
if (!value?.startsWith('plan')) return { refused: 'preboot_plan_missing' };
|
|
256
|
+
const match = EARLY_PREBOOT_PLAN_VALUE.exec(value);
|
|
257
|
+
if (!match) return { refused: 'preboot_plan_invalid' };
|
|
258
|
+
const [, nonce, startedAtText, mac] = match as unknown as [
|
|
259
|
+
string,
|
|
260
|
+
string,
|
|
261
|
+
string,
|
|
262
|
+
string,
|
|
263
|
+
];
|
|
264
|
+
const startedAtMs = parseInt(startedAtText, 36);
|
|
265
|
+
// One canonical form: the MAC covers the number, so refuse other spellings.
|
|
266
|
+
if (
|
|
267
|
+
!Number.isSafeInteger(startedAtMs) ||
|
|
268
|
+
startedAtMs.toString(36) !== startedAtText
|
|
269
|
+
)
|
|
270
|
+
return { refused: 'preboot_plan_invalid' };
|
|
271
|
+
const plan: EarlyPrebootPlan = {
|
|
272
|
+
key: input.key,
|
|
273
|
+
sandboxId: input.sandboxId,
|
|
274
|
+
nonce,
|
|
275
|
+
startedAtMs,
|
|
276
|
+
sandboxRuntimeLimits: input.sandboxRuntimeLimits,
|
|
277
|
+
...(input.memoryLimitMiB === undefined
|
|
278
|
+
? {}
|
|
279
|
+
: { memoryLimitMiB: input.memoryLimitMiB }),
|
|
280
|
+
bakedRunnerHash: input.bakedRunnerHash,
|
|
281
|
+
runnerCommandSha256: input.runnerCommandSha256(nonce),
|
|
282
|
+
};
|
|
283
|
+
const expected = earlyPrebootPlanMac(input.secret, plan);
|
|
284
|
+
const actual = Buffer.from(mac, 'base64url');
|
|
285
|
+
if (expected.length !== actual.length || !timingSafeEqual(expected, actual))
|
|
286
|
+
return { refused: 'preboot_plan_invalid' };
|
|
287
|
+
if (startedAtMs > input.nowMs + EARLY_PREBOOT_PLAN_FUTURE_SKEW_MS)
|
|
288
|
+
return { refused: 'preboot_plan_invalid' };
|
|
289
|
+
if (input.nowMs - startedAtMs > EARLY_PREBOOT_MAX_ADOPTION_AGE_MS)
|
|
290
|
+
return { refused: 'preboot_stale' };
|
|
291
|
+
return { plan };
|
|
292
|
+
}
|
|
120
293
|
/** Bound on the pre-boot's verdict line, and on its exit after a refusal. */
|
|
121
294
|
export const EARLY_PREBOOT_VERDICT_TIMEOUT_MS = 15_000;
|
|
122
295
|
|
|
@@ -636,7 +809,26 @@ export function scheduleEarlySandboxReap(input: {
|
|
|
636
809
|
* until its entry's TTL (the sandbox may still be alive).
|
|
637
810
|
*/
|
|
638
811
|
registry?: Pick<EarlySandboxRegistry, 'settle'>;
|
|
812
|
+
/**
|
|
813
|
+
* PX: also re-read the tags once at this age and settle the sandbox if
|
|
814
|
+
* another worker adopted it (it no longer carries early tags); never
|
|
815
|
+
* terminates. Absent: only the 90 s reap, as before.
|
|
816
|
+
*/
|
|
817
|
+
adoptionProbeAfterMs?: number;
|
|
639
818
|
}): void {
|
|
819
|
+
if (input.adoptionProbeAfterMs !== undefined && input.registry) {
|
|
820
|
+
const registry = input.registry;
|
|
821
|
+
const probe = setTimeout(() => {
|
|
822
|
+
void input.calls
|
|
823
|
+
.fromId(input.sandboxId)
|
|
824
|
+
.then((sandbox) => sandbox.getTags())
|
|
825
|
+
.then((tags) => {
|
|
826
|
+
if (!isUnadoptedEarlySandbox(tags)) registry.settle(input.sandboxId);
|
|
827
|
+
})
|
|
828
|
+
.catch(() => undefined);
|
|
829
|
+
}, input.adoptionProbeAfterMs);
|
|
830
|
+
probe.unref?.();
|
|
831
|
+
}
|
|
640
832
|
const reap = setTimeout(() => {
|
|
641
833
|
void reapEarlySandboxById(input)
|
|
642
834
|
.then(() => input.registry?.settle(input.sandboxId))
|
|
@@ -876,6 +1068,29 @@ export async function adoptEarlySandbox<
|
|
|
876
1068
|
foreignClaimTags?: readonly { tag: string; reason: string }[];
|
|
877
1069
|
/** PB hook: this process's pre-boot on an in-process sandbox, if any. */
|
|
878
1070
|
inProcessPreboot(sandbox: TSandbox): Promise<EarlySandboxPreboot> | undefined;
|
|
1071
|
+
/**
|
|
1072
|
+
* PX hook: whether this launch may deliver to a pre-boot another process
|
|
1073
|
+
* started (a verified published plan); null when it may, else the refusal
|
|
1074
|
+
* reason. Absent: every foreign pre-boot is refused.
|
|
1075
|
+
*/
|
|
1076
|
+
foreignPrebootAdoption?: (
|
|
1077
|
+
sandbox: TSandbox,
|
|
1078
|
+
tags: Record<string, string>,
|
|
1079
|
+
) => Promise<string | null>;
|
|
1080
|
+
/**
|
|
1081
|
+
* Called instead of re-tagging, on every adoption path: the launch re-tags
|
|
1082
|
+
* (with `tags`) only after its own resource record wins the durable sandbox
|
|
1083
|
+
* fence, so a launch that loses a same-run race never re-tags (or
|
|
1084
|
+
* terminates) a sandbox the winner owns; until then the sandbox keeps its
|
|
1085
|
+
* early tags and stays with its reaper. `createdAtMs` lets the launch refuse
|
|
1086
|
+
* a re-tag too close to the 90 s reap. Required for a foreign pre-boot
|
|
1087
|
+
* adoption; absent, other paths re-tag at adoption as before.
|
|
1088
|
+
*/
|
|
1089
|
+
deferRetag?: (
|
|
1090
|
+
sandbox: TSandbox,
|
|
1091
|
+
tags: Record<string, string>,
|
|
1092
|
+
createdAtMs: number,
|
|
1093
|
+
) => void;
|
|
879
1094
|
/**
|
|
880
1095
|
* A1 hook: settles once a tag that makes every other process refuse to
|
|
881
1096
|
* adopt the sandbox is on it at the provider.
|
|
@@ -948,12 +1163,19 @@ export async function adoptEarlySandbox<
|
|
|
948
1163
|
input.experimentSwitchOverrides,
|
|
949
1164
|
ADOPT_IN_PROCESS_EARLY_SANDBOX_WITHOUT_TAG_READ,
|
|
950
1165
|
) &&
|
|
1166
|
+
// PX invites other workers to adopt this sandbox, so its tags may have
|
|
1167
|
+
// changed since this process wrote them: always read them back.
|
|
1168
|
+
!resolveExperimentSwitch(
|
|
1169
|
+
'PX',
|
|
1170
|
+
input.experimentSwitchOverrides,
|
|
1171
|
+
ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES,
|
|
1172
|
+
) &&
|
|
951
1173
|
foreignClaim !== undefined &&
|
|
952
1174
|
(await foreignClaim.then(
|
|
953
1175
|
() => true,
|
|
954
1176
|
() => false,
|
|
955
1177
|
));
|
|
956
|
-
|
|
1178
|
+
let tags =
|
|
957
1179
|
trustLocalTags && localEntry ? localEntry.tags : await sandbox.getTags();
|
|
958
1180
|
const identityRefusal = earlySandboxIdentityRefusal(tags, {
|
|
959
1181
|
key,
|
|
@@ -1006,9 +1228,39 @@ export async function adoptEarlySandbox<
|
|
|
1006
1228
|
{ tag: EARLY_PREBOOT_TAG, reason: 'early_preboot_foreign' },
|
|
1007
1229
|
]) {
|
|
1008
1230
|
if (how !== 'in_process' && tags[claim.tag]) {
|
|
1231
|
+
// PX: a verified published plan lets this launch deliver instead.
|
|
1232
|
+
const foreignRefusal =
|
|
1233
|
+
claim.tag === EARLY_PREBOOT_TAG && input.foreignPrebootAdoption
|
|
1234
|
+
? await input.foreignPrebootAdoption(sandbox, tags)
|
|
1235
|
+
: claim.reason;
|
|
1236
|
+
if (foreignRefusal === null) {
|
|
1237
|
+
how = 'by_tag_preboot';
|
|
1238
|
+
// The hook may have waited for the plan: decide on the sandbox's
|
|
1239
|
+
// latest tags (another launch may have taken it meanwhile).
|
|
1240
|
+
tags = await sandbox.getTags();
|
|
1241
|
+
const latestRefusal = earlySandboxIdentityRefusal(tags, {
|
|
1242
|
+
key,
|
|
1243
|
+
orgId,
|
|
1244
|
+
workflowId: input.workflowId,
|
|
1245
|
+
...input.scope,
|
|
1246
|
+
});
|
|
1247
|
+
if (latestRefusal) {
|
|
1248
|
+
input.emitStage('early:adopt_miss', {
|
|
1249
|
+
key,
|
|
1250
|
+
reason: latestRefusal,
|
|
1251
|
+
sandboxId: sandbox.sandboxId,
|
|
1252
|
+
elapsedMs: nowMs() - startedAt,
|
|
1253
|
+
});
|
|
1254
|
+
return null;
|
|
1255
|
+
}
|
|
1256
|
+
continue;
|
|
1257
|
+
}
|
|
1009
1258
|
input.emitStage('early:adopt_miss', {
|
|
1010
1259
|
key,
|
|
1011
|
-
reason:
|
|
1260
|
+
reason:
|
|
1261
|
+
foreignRefusal === claim.reason
|
|
1262
|
+
? claim.reason
|
|
1263
|
+
: `${claim.reason}:${foreignRefusal}`,
|
|
1012
1264
|
sandboxId: sandbox.sandboxId,
|
|
1013
1265
|
elapsedMs: nowMs() - startedAt,
|
|
1014
1266
|
});
|
|
@@ -1047,6 +1299,25 @@ export async function adoptEarlySandbox<
|
|
|
1047
1299
|
});
|
|
1048
1300
|
return null;
|
|
1049
1301
|
}
|
|
1302
|
+
if (input.deferRetag) {
|
|
1303
|
+
// Re-tagged by the launch once its resource record wins the fence.
|
|
1304
|
+
input.deferRetag(
|
|
1305
|
+
sandbox,
|
|
1306
|
+
{ ...input.createTags, earlyKey: key },
|
|
1307
|
+
nowMs() - ageMs,
|
|
1308
|
+
);
|
|
1309
|
+
// Adopted: it is the launch's sandbox now, no longer early capacity.
|
|
1310
|
+
registry.settle(sandbox.sandboxId);
|
|
1311
|
+
input.emitStage('early:adopted', {
|
|
1312
|
+
key,
|
|
1313
|
+
how,
|
|
1314
|
+
sandboxId: sandbox.sandboxId,
|
|
1315
|
+
elapsedMs: nowMs() - startedAt,
|
|
1316
|
+
});
|
|
1317
|
+
return sandbox;
|
|
1318
|
+
}
|
|
1319
|
+
if (how === 'by_tag_preboot')
|
|
1320
|
+
throw new Error('A foreign pre-boot adoption needs a deferred re-tag.');
|
|
1050
1321
|
// Re-tag first: from here the sandbox is an ordinary launch sandbox for
|
|
1051
1322
|
// every cleanup and reconciliation path, and the reaper skips it.
|
|
1052
1323
|
await sandbox.setTags({ ...input.createTags, earlyKey: key });
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { lookup } from 'node:dns/promises';
|
|
2
|
+
import { connect as tlsConnect, type TLSSocket } from 'node:tls';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One fresh connection's setup cost to the runtime API origin, measured once
|
|
6
|
+
* per runner process and origin, off the request path.
|
|
7
|
+
*
|
|
8
|
+
* Why: a receipt gateway round trip from a Modal sandbox is ~83 ms at p50
|
|
9
|
+
* while the gateway's own work is ~9 ms (Production, 2026-11-30). This probe
|
|
10
|
+
* separates path latency from per-request connection setup: compare
|
|
11
|
+
* `connectMs` (one TCP round trip) with the run's `gatewayRoundTrip`. A round
|
|
12
|
+
* trip near `connectMs` means requests reuse a connection; near
|
|
13
|
+
* `connectMs + tlsMs + connectMs` means each request pays a new connection.
|
|
14
|
+
*
|
|
15
|
+
* Bounded and allowlisted: numbers, the negotiated TLS protocol and ALPN, and a
|
|
16
|
+
* short error code. Never the URL, host, address, or any header.
|
|
17
|
+
*/
|
|
18
|
+
export type RuntimeApiConnectionProbe = {
|
|
19
|
+
outcome: 'ok' | 'error' | 'timeout';
|
|
20
|
+
/** DNS resolution of the origin host. */
|
|
21
|
+
dnsMs: number | null;
|
|
22
|
+
/** TCP connect: about one network round trip. */
|
|
23
|
+
connectMs: number | null;
|
|
24
|
+
/** TLS handshake after TCP connect. */
|
|
25
|
+
tlsMs: number | null;
|
|
26
|
+
totalMs: number;
|
|
27
|
+
tlsProtocol: string | null;
|
|
28
|
+
alpn: string | null;
|
|
29
|
+
errorCode: string | null;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const RUNTIME_API_CONNECTION_PROBE_TIMEOUT_MS = 2_000;
|
|
33
|
+
const ERROR_CODE_PATTERN = /^[A-Z0-9_]{1,40}$/;
|
|
34
|
+
const TLS_PROTOCOL_PATTERN = /^TLSv1(\.[0-3])?$/;
|
|
35
|
+
const ALPN_PATTERN = /^(h2|http\/1\.1)$/;
|
|
36
|
+
|
|
37
|
+
const probes = new Map<string, Promise<RuntimeApiConnectionProbe | null>>();
|
|
38
|
+
const settled = new Map<string, RuntimeApiConnectionProbe | null>();
|
|
39
|
+
|
|
40
|
+
type ProbeDeps = {
|
|
41
|
+
lookup: (host: string) => Promise<{ address: string; family: number }>;
|
|
42
|
+
connect: typeof tlsConnect;
|
|
43
|
+
now: () => number;
|
|
44
|
+
timeoutMs: number;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const DEFAULT_DEPS: ProbeDeps = {
|
|
48
|
+
lookup: (host) => lookup(host),
|
|
49
|
+
connect: tlsConnect,
|
|
50
|
+
now: () => performance.now(),
|
|
51
|
+
timeoutMs: RUNTIME_API_CONNECTION_PROBE_TIMEOUT_MS,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
function round(ms: number): number {
|
|
55
|
+
return Math.max(0, Math.round(ms));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function errorCodeOf(error: unknown): string | null {
|
|
59
|
+
const code = (error as { code?: unknown } | null)?.code;
|
|
60
|
+
return typeof code === 'string' && ERROR_CODE_PATTERN.test(code)
|
|
61
|
+
? code
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Measure one fresh connection to `baseUrl`'s origin. Never throws. */
|
|
66
|
+
export async function measureRuntimeApiConnection(
|
|
67
|
+
baseUrl: string,
|
|
68
|
+
deps: ProbeDeps = DEFAULT_DEPS,
|
|
69
|
+
): Promise<RuntimeApiConnectionProbe | null> {
|
|
70
|
+
let url: URL;
|
|
71
|
+
try {
|
|
72
|
+
url = new URL(baseUrl);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
if (url.protocol !== 'https:') return null;
|
|
77
|
+
const port = url.port ? Number(url.port) : 443;
|
|
78
|
+
const startedAt = deps.now();
|
|
79
|
+
let dnsMs: number | null = null;
|
|
80
|
+
let connectMs: number | null = null;
|
|
81
|
+
let tlsMs: number | null = null;
|
|
82
|
+
let socket: TLSSocket | null = null;
|
|
83
|
+
const result = (
|
|
84
|
+
outcome: RuntimeApiConnectionProbe['outcome'],
|
|
85
|
+
extra: Partial<RuntimeApiConnectionProbe> = {},
|
|
86
|
+
): RuntimeApiConnectionProbe => ({
|
|
87
|
+
outcome,
|
|
88
|
+
dnsMs,
|
|
89
|
+
connectMs,
|
|
90
|
+
tlsMs,
|
|
91
|
+
totalMs: round(deps.now() - startedAt),
|
|
92
|
+
tlsProtocol: null,
|
|
93
|
+
alpn: null,
|
|
94
|
+
errorCode: null,
|
|
95
|
+
...extra,
|
|
96
|
+
});
|
|
97
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
98
|
+
const timeout = new Promise<RuntimeApiConnectionProbe>((resolve) => {
|
|
99
|
+
timer = setTimeout(() => resolve(result('timeout')), deps.timeoutMs);
|
|
100
|
+
(timer as { unref?: () => void }).unref?.();
|
|
101
|
+
});
|
|
102
|
+
const measured = (async (): Promise<RuntimeApiConnectionProbe> => {
|
|
103
|
+
try {
|
|
104
|
+
const dnsStartedAt = deps.now();
|
|
105
|
+
const { address } = await deps.lookup(url.hostname);
|
|
106
|
+
dnsMs = round(deps.now() - dnsStartedAt);
|
|
107
|
+
const connectStartedAt = deps.now();
|
|
108
|
+
return await new Promise<RuntimeApiConnectionProbe>((resolve) => {
|
|
109
|
+
let tcpAt: number | null = null;
|
|
110
|
+
socket = deps.connect({
|
|
111
|
+
host: address,
|
|
112
|
+
port,
|
|
113
|
+
servername: url.hostname,
|
|
114
|
+
ALPNProtocols: ['h2', 'http/1.1'],
|
|
115
|
+
});
|
|
116
|
+
socket.once('connect', () => {
|
|
117
|
+
tcpAt = deps.now();
|
|
118
|
+
connectMs = round(tcpAt - connectStartedAt);
|
|
119
|
+
});
|
|
120
|
+
socket.once('secureConnect', () => {
|
|
121
|
+
const secureAt = deps.now();
|
|
122
|
+
tlsMs = round(secureAt - (tcpAt ?? connectStartedAt));
|
|
123
|
+
const protocol = socket?.getProtocol?.() ?? null;
|
|
124
|
+
const alpn = socket?.alpnProtocol;
|
|
125
|
+
resolve(
|
|
126
|
+
result('ok', {
|
|
127
|
+
tlsProtocol:
|
|
128
|
+
typeof protocol === 'string' &&
|
|
129
|
+
TLS_PROTOCOL_PATTERN.test(protocol)
|
|
130
|
+
? protocol
|
|
131
|
+
: null,
|
|
132
|
+
alpn:
|
|
133
|
+
typeof alpn === 'string' && ALPN_PATTERN.test(alpn)
|
|
134
|
+
? alpn
|
|
135
|
+
: null,
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
// Persistent: a socket that errors again after the first error (or
|
|
140
|
+
// after destroy) must never surface an unhandled 'error' event in
|
|
141
|
+
// the runner process. Resolving twice is a no-op.
|
|
142
|
+
socket.on('error', (error) =>
|
|
143
|
+
resolve(result('error', { errorCode: errorCodeOf(error) })),
|
|
144
|
+
);
|
|
145
|
+
});
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return result('error', { errorCode: errorCodeOf(error) });
|
|
148
|
+
}
|
|
149
|
+
})();
|
|
150
|
+
try {
|
|
151
|
+
return await Promise.race([measured, timeout]);
|
|
152
|
+
} finally {
|
|
153
|
+
clearTimeout(timer);
|
|
154
|
+
(socket as TLSSocket | null)?.destroy();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Start the probe for `baseUrl`'s origin once per process; later calls share
|
|
160
|
+
* the first. The returned promise never rejects.
|
|
161
|
+
*/
|
|
162
|
+
export function runtimeApiConnectionProbe(
|
|
163
|
+
baseUrl: string,
|
|
164
|
+
): Promise<RuntimeApiConnectionProbe | null> {
|
|
165
|
+
let origin: string;
|
|
166
|
+
try {
|
|
167
|
+
origin = new URL(baseUrl).origin;
|
|
168
|
+
} catch {
|
|
169
|
+
return Promise.resolve(null);
|
|
170
|
+
}
|
|
171
|
+
let probe = probes.get(origin);
|
|
172
|
+
if (!probe) {
|
|
173
|
+
probe = measureRuntimeApiConnection(origin)
|
|
174
|
+
.catch(() => null)
|
|
175
|
+
.then((value) => {
|
|
176
|
+
settled.set(origin, value);
|
|
177
|
+
return value;
|
|
178
|
+
});
|
|
179
|
+
probes.set(origin, probe);
|
|
180
|
+
}
|
|
181
|
+
return probe;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** The probe for `baseUrl`'s origin once it has settled; null until then. */
|
|
185
|
+
export function settledRuntimeApiConnectionProbe(
|
|
186
|
+
baseUrl: string,
|
|
187
|
+
): RuntimeApiConnectionProbe | null {
|
|
188
|
+
try {
|
|
189
|
+
return settled.get(new URL(baseUrl).origin) ?? null;
|
|
190
|
+
} catch {
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/** Test seam: forget probes so each test starts fresh. */
|
|
196
|
+
export function resetRuntimeApiConnectionProbesForTests(): void {
|
|
197
|
+
probes.clear();
|
|
198
|
+
settled.clear();
|
|
199
|
+
}
|
|
@@ -96,3 +96,38 @@ export function resolvePreviewWorkerListenerElection(
|
|
|
96
96
|
}
|
|
97
97
|
return 'direct_listen';
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Env turning on the CA claim gate (CAR) on an isolated Preview lane's
|
|
102
|
+
* workers, written only by the release gate from a typed target config
|
|
103
|
+
* (`runtime.claimAffinityReader`). CAR is a worker-process switch whose
|
|
104
|
+
* constant stays off everywhere else, so Production workers never read it.
|
|
105
|
+
*/
|
|
106
|
+
export const PREVIEW_WORKER_CLAIM_AFFINITY_READER_ENV =
|
|
107
|
+
'DEEPLINE_PREVIEW_WORKER_CLAIM_AFFINITY_READER';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Whether this worker runs the CA claim gate because its isolated Preview
|
|
111
|
+
* lane was configured for it. Unset or `off` (every Production worker and
|
|
112
|
+
* every other Preview lane) is off: unchanged. `on` on a non-isolated
|
|
113
|
+
* (Production-shaped) schema, or any other value, fails boot loudly instead
|
|
114
|
+
* of being ignored.
|
|
115
|
+
*/
|
|
116
|
+
export function resolvePreviewWorkerClaimAffinityReader(
|
|
117
|
+
env: Readonly<Record<string, string | undefined>>,
|
|
118
|
+
schedulerSchema: string | null | undefined,
|
|
119
|
+
): boolean {
|
|
120
|
+
const raw = env[PREVIEW_WORKER_CLAIM_AFFINITY_READER_ENV]?.trim();
|
|
121
|
+
if (!raw || raw === 'off') return false;
|
|
122
|
+
if (raw !== 'on') {
|
|
123
|
+
throw new Error(
|
|
124
|
+
`${PREVIEW_WORKER_CLAIM_AFFINITY_READER_ENV} must be off or on; got "${raw}".`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
if (!isIsolatedRuntimeSchedulerSchema(schedulerSchema)) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`${PREVIEW_WORKER_CLAIM_AFFINITY_READER_ENV}=on is valid only on an isolated Preview scheduler schema.`,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
@@ -254,6 +254,34 @@ export const RUNTIME_SPEED_PROFILES = {
|
|
|
254
254
|
PWV: false,
|
|
255
255
|
},
|
|
256
256
|
},
|
|
257
|
+
'fast_launch@8': {
|
|
258
|
+
summary:
|
|
259
|
+
"fast_launch@7 plus PX and CA: a pre-booted early sandbox carries a MAC-signed runner plan, so a launch on any worker can adopt it instead of refusing it as early_preboot_foreign, and the gateway hints the queue worker with the most free slots (CA; the claim gate stays compiled off in Production, so claims are unchanged). Preview, 2 base workers + autoscaling, @7 map + CA + PX: 11 of 12 created early sandboxes adopted at 10/32/64 concurrent runs (4 by a worker other than the hinted one), heartbeat p50 below the E2-off control at every tier, 0 provider-verified leaks; @7 routing adopted 3/6, 0/1, 2/5. Registered before any grant.",
|
|
260
|
+
switches: {
|
|
261
|
+
B: true,
|
|
262
|
+
H1: true,
|
|
263
|
+
P1: true,
|
|
264
|
+
P2: true,
|
|
265
|
+
V3: true,
|
|
266
|
+
C3: true,
|
|
267
|
+
C4: true,
|
|
268
|
+
C5: true,
|
|
269
|
+
PI: true,
|
|
270
|
+
E2: true,
|
|
271
|
+
PB: true,
|
|
272
|
+
LH: true,
|
|
273
|
+
EN: true,
|
|
274
|
+
CA: true,
|
|
275
|
+
PX: true,
|
|
276
|
+
A1: false,
|
|
277
|
+
N1: false,
|
|
278
|
+
F3: false,
|
|
279
|
+
S1: false,
|
|
280
|
+
PWM: false,
|
|
281
|
+
PWT: false,
|
|
282
|
+
PWV: false,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
257
285
|
} as const satisfies Record<string, RuntimeSpeedProfileDefinition>;
|
|
258
286
|
|
|
259
287
|
export type RuntimeSpeedProfileId = keyof typeof RUNTIME_SPEED_PROFILES;
|
|
@@ -130,10 +130,10 @@ export function absurdQueryableForRuntimeScheduler(
|
|
|
130
130
|
params,
|
|
131
131
|
client,
|
|
132
132
|
gate: claimGate,
|
|
133
|
-
run: async () => {
|
|
133
|
+
run: async (gatedParams) => {
|
|
134
134
|
const queried = await client.query<Row & Record<string, unknown>>(
|
|
135
135
|
sql,
|
|
136
|
-
|
|
136
|
+
gatedParams ? [...gatedParams] : gatedParams,
|
|
137
137
|
);
|
|
138
138
|
return { rows: queried.rows as Row[] };
|
|
139
139
|
},
|
package/dist/bundling-sources/shared_libs/play-runtime/scheduler-backends/absurd-runtime-worker.ts
CHANGED
|
@@ -133,6 +133,7 @@ import {
|
|
|
133
133
|
selectRuntimeSandboxCanary,
|
|
134
134
|
} from '../runtime-sandbox-placement-policy';
|
|
135
135
|
import {
|
|
136
|
+
resolvePreviewWorkerClaimAffinityReader,
|
|
136
137
|
resolvePreviewWorkerListenerElection,
|
|
137
138
|
shouldUseRuntimeSchedulerDirectNotify,
|
|
138
139
|
} from '../runtime-scheduler-topology';
|
|
@@ -11987,6 +11988,14 @@ export async function startRuntimeWorkerHost(
|
|
|
11987
11988
|
schema: options.schedulerSchema ?? null,
|
|
11988
11989
|
}).schema,
|
|
11989
11990
|
);
|
|
11991
|
+
// Same rule for the CA claim gate (CAR): only a typed isolated lane turns
|
|
11992
|
+
// it on; Production reads the compiled constant alone.
|
|
11993
|
+
const previewClaimAffinityReader = resolvePreviewWorkerClaimAffinityReader(
|
|
11994
|
+
process.env,
|
|
11995
|
+
normalizeAbsurdSchedulerOptions({
|
|
11996
|
+
schema: options.schedulerSchema ?? null,
|
|
11997
|
+
}).schema,
|
|
11998
|
+
);
|
|
11990
11999
|
const poolOptions = resolveAbsurdPoolOptions();
|
|
11991
12000
|
// Wait for the scheduler database beside the gateway check, before the pool
|
|
11992
12001
|
// makes its first connections: their 5 s timeouts and breaker are for a
|
|
@@ -12049,7 +12058,8 @@ export async function startRuntimeWorkerHost(
|
|
|
12049
12058
|
// CA: the claim gate needs the wake hook, which is created after the
|
|
12050
12059
|
// client; it reads it late. Off unless the reader switch is on.
|
|
12051
12060
|
let claimAffinityWake: (() => boolean) | null = null;
|
|
12052
|
-
const claimAffinityGate =
|
|
12061
|
+
const claimAffinityGate =
|
|
12062
|
+
EARLY_SANDBOX_CLAIM_AFFINITY_READER || previewClaimAffinityReader
|
|
12053
12063
|
? createEarlySandboxClaimGate({
|
|
12054
12064
|
self: workerBase,
|
|
12055
12065
|
queue,
|