deepline 0.3.571 → 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/experiment-switches.ts +11 -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-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 +11 -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-ARGNQK7A.mjs → auth-YUDM3YOC.mjs} +5 -5
- package/dist/cli/{billing-KAKODYTN.js → billing-F3ZGOWKL.js} +99 -99
- package/dist/cli/{billing-QRZTHCBX.mjs → billing-O7WUC4TU.mjs} +8 -8
- package/dist/cli/{chunk-C27FK36H.js → chunk-3SFLY3T3.js} +5 -5
- package/dist/cli/{chunk-GOUKX6XD.js → chunk-43GCEVHO.js} +3 -3
- package/dist/cli/{chunk-PTM5V5FV.js → chunk-4W5EFHHY.js} +7 -7
- package/dist/cli/{chunk-2IZOCGOA.js → chunk-5EMYPLTW.js} +53 -53
- package/dist/cli/{chunk-IXFFOZZQ.js → chunk-5VUD7HGD.js} +2 -2
- package/dist/cli/{chunk-7HAYEKC4.mjs → chunk-6R57HEPF.mjs} +1 -1
- package/dist/cli/{chunk-H6QMUX7Y.mjs → chunk-72WI67H4.mjs} +2 -2
- package/dist/cli/{chunk-MFBFQUQK.js → chunk-AHNJGA6Z.js} +6 -6
- package/dist/cli/{chunk-CR6IPQBB.mjs → chunk-AJO3I3LL.mjs} +1 -1
- package/dist/cli/{chunk-UBNRPJKO.mjs → chunk-BWWDU6FN.mjs} +5 -5
- package/dist/cli/{chunk-ETGM6PIR.mjs → chunk-CYW6PE3G.mjs} +5 -5
- package/dist/cli/{chunk-Z3DSCE5F.mjs → chunk-EDAG7ZU4.mjs} +1 -1
- package/dist/cli/{chunk-FQP5VSVF.mjs → chunk-EKIWY5DD.mjs} +1 -1
- package/dist/cli/{chunk-336AHC7H.mjs → chunk-EKWDSE6H.mjs} +4 -4
- package/dist/cli/{chunk-6OP5UW7C.js → chunk-EL4LME5Y.js} +48 -48
- package/dist/cli/{chunk-7JGHNZTD.js → chunk-FGBX2WVJ.js} +4 -4
- package/dist/cli/{chunk-TJU2BECV.mjs → chunk-GX4VZL4Z.mjs} +3 -3
- package/dist/cli/{chunk-YGGHPEWP.js → chunk-HYCJNHZ4.js} +15 -15
- package/dist/cli/{chunk-QRMTITKL.mjs → chunk-I4WKB3HO.mjs} +2 -2
- package/dist/cli/{chunk-A5HDA22N.js → chunk-ITQPBWDS.js} +3 -3
- package/dist/cli/{chunk-A3IVPA6Q.mjs → chunk-JEI7PHET.mjs} +1 -1
- package/dist/cli/{chunk-J5KW2ZDB.mjs → chunk-JJEN7TRR.mjs} +1 -1
- package/dist/cli/{chunk-ILKUKEWX.js → chunk-K4LAEKHS.js} +41 -41
- package/dist/cli/{chunk-HGER4CJA.js → chunk-LBNP52C4.js} +5 -5
- package/dist/cli/{chunk-A3B54QEW.mjs → chunk-MVQ5XGRO.mjs} +3 -3
- package/dist/cli/{chunk-IFKZQCPX.js → chunk-NOKSEYMS.js} +1 -1
- package/dist/cli/{chunk-PO3NOBHU.mjs → chunk-OUVQKSVC.mjs} +1 -1
- package/dist/cli/{chunk-CITDBSXI.js → chunk-PI4TKE2B.js} +26 -26
- package/dist/cli/{chunk-WZOUXILM.mjs → chunk-PQ6PM4V6.mjs} +1 -1
- package/dist/cli/{chunk-6N3NTEJ6.js → chunk-PRDCU7BY.js} +20 -20
- package/dist/cli/{chunk-RBPR5ZNN.js → chunk-PZGK6EEB.js} +100 -100
- package/dist/cli/{chunk-CF6CSAMJ.mjs → chunk-Q6H5RRTG.mjs} +4 -4
- package/dist/cli/{chunk-UTGHPC5D.mjs → chunk-QA733N7N.mjs} +1 -1
- package/dist/cli/{chunk-VLQB65HI.js → chunk-QMIMGKR2.js} +9 -9
- package/dist/cli/{chunk-YDULFKDL.mjs → chunk-RIA73OAZ.mjs} +2 -2
- package/dist/cli/{chunk-GCE5KOJJ.mjs → chunk-SJI56XPM.mjs} +11 -11
- package/dist/cli/{chunk-GRD3DLH7.mjs → chunk-UFUXGMHL.mjs} +2 -2
- package/dist/cli/{chunk-NAGGCF6Y.js → chunk-UKD5ZBQD.js} +5 -5
- package/dist/cli/{chunk-C6XV2DPY.mjs → chunk-UMP76GYQ.mjs} +3 -3
- package/dist/cli/{chunk-VULSFPD4.mjs → chunk-UQWYDNGB.mjs} +5 -5
- package/dist/cli/{chunk-SJYLLHHZ.js → chunk-UUYB6IXC.js} +13 -13
- package/dist/cli/{chunk-Z6OUUAIV.mjs → chunk-UY6Z3XWW.mjs} +2 -2
- package/dist/cli/{chunk-CFMIWRGD.mjs → chunk-V2W7GX2I.mjs} +2 -2
- package/dist/cli/{chunk-GACQOGRS.js → chunk-VGPHXXPI.js} +15 -15
- package/dist/cli/{chunk-WOU2WS6S.js → chunk-VZ4S5JRC.js} +23 -23
- package/dist/cli/{chunk-AOMVAXGX.js → chunk-W3HLZ24Q.js} +10 -10
- package/dist/cli/{chunk-XD4MT4BH.js → chunk-W3RHISD6.js} +8 -8
- package/dist/cli/{chunk-YDM5WSXO.mjs → chunk-W742U53L.mjs} +5 -5
- package/dist/cli/{chunk-AD7BGMTL.mjs → chunk-X6F4XOT2.mjs} +2 -2
- package/dist/cli/{chunk-YQ36Z23U.js → chunk-XNJXRS3B.js} +2 -2
- package/dist/cli/{chunk-C3FHMJ4A.js → chunk-XVQE6IBS.js} +2 -2
- package/dist/cli/{chunk-73P76DCN.js → chunk-YOST7EJF.js} +20 -20
- package/dist/cli/{concurrent-runs-help-VPYB4ODC.mjs → concurrent-runs-help-5BKCGFGL.mjs} +6 -6
- package/dist/cli/concurrent-runs-help-KGELXJIQ.js +22 -0
- package/dist/cli/{csv-GHGDSFNV.js → csv-7ZAWND7L.js} +13 -13
- package/dist/cli/{csv-RALLG3MG.mjs → csv-MO5WZZDN.mjs} +4 -4
- package/dist/cli/{db-722SKSIB.js → db-36LX7JBQ.js} +27 -27
- package/dist/cli/{db-HB65VYRR.mjs → db-OYMULINA.mjs} +6 -6
- package/dist/cli/describe-AVGE4MH6.js +50 -0
- package/dist/cli/{describe-Q6M7PUBU.mjs → describe-JLAERB6X.mjs} +18 -18
- package/dist/cli/{executions-GQNV3LNU.js → executions-AQ32J4BZ.js} +8 -8
- package/dist/cli/{executions-G3M75HW2.mjs → executions-IZAB2XNC.mjs} +6 -6
- package/dist/cli/{feedback-B43F2FBL.js → feedback-3IV54HOH.js} +14 -14
- package/dist/cli/{feedback-CSDBYSRS.mjs → feedback-WA6EBE5H.mjs} +6 -6
- package/dist/cli/{git-IZ4Y3RAW.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-OLCUWZ6Z.js → integrations-65SYNL53.js} +29 -29
- package/dist/cli/{integrations-DT7EGM2Y.mjs → integrations-WOXFOC4M.mjs} +7 -7
- package/dist/cli/{legacy-noops-FTGNTO3U.js → legacy-noops-3SGXDAV6.js} +9 -9
- package/dist/cli/{legacy-noops-4TPT534L.mjs → legacy-noops-4FNG2JY3.mjs} +6 -6
- package/dist/cli/{mcp-3IDWLBKK.js → mcp-PX27RHCY.js} +24 -24
- package/dist/cli/{mcp-5KDJJT7M.mjs → mcp-RZLWMZHH.mjs} +4 -4
- package/dist/cli/{monitors-7GOZBKJR.js → monitors-F5BLGS4R.js} +100 -100
- package/dist/cli/{monitors-EOAA5RQO.mjs → monitors-VK2LW7VU.mjs} +7 -7
- package/dist/cli/{org-H5I56A4F.mjs → org-7AEBTN6Y.mjs} +6 -6
- package/dist/cli/{org-UJ5SWQJ5.js → org-UU3V7U4K.js} +121 -121
- package/dist/cli/{outcomes-MG57YXJX.mjs → outcomes-BWERSUJL.mjs} +6 -6
- package/dist/cli/{outcomes-24KFY2X5.js → outcomes-GCTBGPMK.js} +14 -14
- package/dist/cli/{play-PPPACSQE.js → play-7NBCCL26.js} +324 -324
- package/dist/cli/{play-MXPXRAUM.mjs → play-TX3RAAYS.mjs} +19 -19
- package/dist/cli/{providers-LTYNEXLB.js → providers-IL2IVKHB.js} +9 -9
- package/dist/cli/{providers-5ZN3MO6E.mjs → providers-KFWZXDCV.mjs} +6 -6
- package/dist/cli/{quickstart-UBDHX7PT.js → quickstart-MPA6TUK5.js} +6 -6
- package/dist/cli/{quickstart-ENDTTNLE.mjs → quickstart-RAMDGRRI.mjs} +4 -4
- package/dist/cli/{run-QJJSP35C.mjs → run-QNJSKPBN.mjs} +23 -23
- package/dist/cli/{run-6O6LQVWD.js → run-WBUSXBUS.js} +44 -44
- package/dist/cli/{search-PXZPVXDK.mjs → search-2X4P2FXR.mjs} +7 -7
- package/dist/cli/search-CJHG3VA4.js +32 -0
- package/dist/cli/{search-output-KRR4YOJX.mjs → search-output-MNJ4AQLV.mjs} +4 -4
- package/dist/cli/{search-output-H3ZQLJUF.js → search-output-P2WNCHA3.js} +6 -6
- package/dist/cli/{secrets-QZMXBI64.js → secrets-K5CNDUVR.js} +15 -15
- package/dist/cli/{secrets-HIGERL4N.mjs → secrets-XX54OU22.mjs} +6 -6
- package/dist/cli/sessions-3RMRBBJZ.js +23 -0
- package/dist/cli/{sessions-4SGQAX3F.mjs → sessions-C4GQ6ZVO.mjs} +6 -6
- package/dist/cli/{settings-UQLHVBOP.mjs → settings-7HBTADGW.mjs} +12 -12
- package/dist/cli/{settings-FFTTVDRV.js → settings-QP3DVFPS.js} +85 -85
- package/dist/cli/{setup-R5MBUG5M.mjs → setup-VPDAKY2G.mjs} +9 -9
- package/dist/cli/{setup-SS3MABJP.js → setup-X6J7U6B4.js} +49 -49
- package/dist/cli/skills-JUGXGSX2.js +37 -0
- package/dist/cli/{skills-X6PNEVWX.mjs → skills-UGY6W4AC.mjs} +7 -7
- package/dist/cli/{tools-YFW3FXAB.mjs → tools-SVBUAHDD.mjs} +17 -17
- package/dist/cli/tools-ZEI42NSP.js +57 -0
- package/dist/cli/{update-HX5BNFLQ.mjs → update-SDNKNDNW.mjs} +9 -9
- package/dist/cli/update-VC4UEGMR.js +37 -0
- package/dist/cli/{views-BGCRC22G.js → views-JBFSHQBU.js} +21 -21
- package/dist/cli/{views-FH5XL2PU.mjs → views-M6RBPC65.mjs} +6 -6
- package/dist/cli/{workflow-VLNDGNJI.mjs → workflow-RYVRAIHV.mjs} +7 -7
- package/dist/cli/{workflow-UY5PZBIK.js → workflow-UAMTGHQC.js} +17 -17
- package/dist/index.js +9 -9
- package/dist/index.mjs +6 -6
- package/dist/install-integrity.json +112 -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-FKYYYCME.js +0 -44
- package/dist/cli/concurrent-runs-help-VUMIMYO7.js +0 -22
- package/dist/cli/describe-SG2N62VE.js +0 -50
- package/dist/cli/git-IJHKRWTR.js +0 -26
- package/dist/cli/search-TYPJWK4I.js +0 -32
- package/dist/cli/sessions-OS4ZBU4K.js +0 -23
- package/dist/cli/skills-FVDSEEUL.js +0 -37
- package/dist/cli/tools-ORTGWD63.js +0 -57
- package/dist/cli/update-RWVNNNHN.js +0 -37
|
@@ -205,7 +205,7 @@ export const SDK_RELEASE = {
|
|
|
205
205
|
// getters keep their established compatibility behavior.
|
|
206
206
|
// 0.3.1 deprecated the legacy `deepline enrich` command in favor of Plays.
|
|
207
207
|
// 0.3.90 is the first deliberately versioned SDK release for API v3.
|
|
208
|
-
version: '0.3.
|
|
208
|
+
version: '0.3.572',
|
|
209
209
|
updateSummary: {
|
|
210
210
|
introducedIn: '0.3.90',
|
|
211
211
|
summary:
|
|
@@ -137,6 +137,17 @@ export const EXPERIMENT_SWITCHES = {
|
|
|
137
137
|
{ file: EARLY_SANDBOX, name: 'PREBOOT_RUNNER_IN_EARLY_SANDBOX' },
|
|
138
138
|
],
|
|
139
139
|
},
|
|
140
|
+
PX: {
|
|
141
|
+
perRun: true,
|
|
142
|
+
summary:
|
|
143
|
+
'With PB, the worker that pre-boots an early sandbox publishes its runner plan as MAC-signed tags, so a launch on any worker can deliver to it instead of refusing it as early_preboot_foreign (worker).',
|
|
144
|
+
constants: [
|
|
145
|
+
{
|
|
146
|
+
file: EARLY_SANDBOX,
|
|
147
|
+
name: 'ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES',
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
},
|
|
140
151
|
PWM: {
|
|
141
152
|
perRun: true,
|
|
142
153
|
summary:
|
|
@@ -764,31 +764,38 @@ function buildDetachedRunnerCommand(input: {
|
|
|
764
764
|
* `materialize`.
|
|
765
765
|
*/
|
|
766
766
|
oneNodeBakedGuard?: { path: string; hash: string };
|
|
767
|
+
/**
|
|
768
|
+
* PX: one nonce for every path of a pre-booted runner, so a worker other
|
|
769
|
+
* than the one that started it can rebuild the same paths from the nonce
|
|
770
|
+
* the pre-boot published. Absent: a fresh UUID per path, as before.
|
|
771
|
+
*/
|
|
772
|
+
pathNonce?: string;
|
|
767
773
|
}): DetachedRunnerPaths & {
|
|
768
774
|
command: string;
|
|
769
775
|
/** N1 only: the marker the guard writes once the baked runner verified. */
|
|
770
776
|
bakedPassMarkerPath?: string;
|
|
771
777
|
} {
|
|
772
778
|
const { workDir, configPath, crashPusherPath, materialize } = input;
|
|
779
|
+
const pathId = () => input.pathNonce ?? randomUUID();
|
|
773
780
|
const oneNodeBakedGuard =
|
|
774
781
|
materialize !== null ? (input.oneNodeBakedGuard ?? null) : null;
|
|
775
782
|
const bakedPassMarkerPath = oneNodeBakedGuard
|
|
776
|
-
? `${workDir}/deepline-play-baked-verified-${
|
|
783
|
+
? `${workDir}/deepline-play-baked-verified-${pathId()}.txt`
|
|
777
784
|
: null;
|
|
778
785
|
const runtimeLimitSeconds = input.sandboxRuntimeLimits.timeoutSeconds;
|
|
779
|
-
const outputPath = `${workDir}/deepline-play-output-${
|
|
780
|
-
const crashPusherLogPath = `${workDir}/deepline-play-crash-terminal-${
|
|
781
|
-
const exitCodePath = `${workDir}/deepline-play-exit-${
|
|
782
|
-
const oomKillBaselinePath = `${workDir}/deepline-play-oom-kill-${
|
|
783
|
-
const runnerPidPath = `${workDir}/deepline-play-runner-pid-${
|
|
784
|
-
const runtimeStartedPath = `${workDir}/deepline-play-runtime-started-${
|
|
785
|
-
const runtimeCompletedPath = `${workDir}/deepline-play-runtime-completed-${
|
|
786
|
-
const runtimeLimitMarkerPath = `${workDir}/deepline-play-runtime-limit-${
|
|
787
|
-
const terminationDiagnosticPath = `${workDir}/deepline-play-termination-${
|
|
788
|
-
const memoryLedgerPath = `${workDir}/deepline-play-memory-ledger-${
|
|
789
|
-
const memoryPressurePath = `${workDir}/deepline-play-memory-pressure-${
|
|
790
|
-
const progressEventPath = `${workDir}/deepline-play-progress-${
|
|
791
|
-
const startupDiagnosticPath = `${workDir}/deepline-play-startup-${
|
|
786
|
+
const outputPath = `${workDir}/deepline-play-output-${pathId()}.log`;
|
|
787
|
+
const crashPusherLogPath = `${workDir}/deepline-play-crash-terminal-${pathId()}.log`;
|
|
788
|
+
const exitCodePath = `${workDir}/deepline-play-exit-${pathId()}.txt`;
|
|
789
|
+
const oomKillBaselinePath = `${workDir}/deepline-play-oom-kill-${pathId()}.txt`;
|
|
790
|
+
const runnerPidPath = `${workDir}/deepline-play-runner-pid-${pathId()}.txt`;
|
|
791
|
+
const runtimeStartedPath = `${workDir}/deepline-play-runtime-started-${pathId()}.json`;
|
|
792
|
+
const runtimeCompletedPath = `${workDir}/deepline-play-runtime-completed-${pathId()}.json`;
|
|
793
|
+
const runtimeLimitMarkerPath = `${workDir}/deepline-play-runtime-limit-${pathId()}.txt`;
|
|
794
|
+
const terminationDiagnosticPath = `${workDir}/deepline-play-termination-${pathId()}.json`;
|
|
795
|
+
const memoryLedgerPath = `${workDir}/deepline-play-memory-ledger-${pathId()}.json`;
|
|
796
|
+
const memoryPressurePath = `${workDir}/deepline-play-memory-pressure-${pathId()}.json`;
|
|
797
|
+
const progressEventPath = `${workDir}/deepline-play-progress-${pathId()}.jsonl`;
|
|
798
|
+
const startupDiagnosticPath = `${workDir}/deepline-play-startup-${pathId()}.json`;
|
|
792
799
|
const runnerTraceEnv =
|
|
793
800
|
process.env.DEEPLINE_RUNTIME_RECEIPT_TRACE === '1'
|
|
794
801
|
? 'DEEPLINE_RUNTIME_RECEIPT_TRACE=1 '
|
|
@@ -933,14 +940,17 @@ export function buildPrebootedRunnerLaunch(input: {
|
|
|
933
940
|
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
934
941
|
memoryLimitMiB?: number;
|
|
935
942
|
nodeBinaryPath?: string;
|
|
943
|
+
/** PX: rebuild a published pre-boot's exact paths (see buildDetachedRunnerCommand). */
|
|
944
|
+
pathNonce?: string;
|
|
936
945
|
}): PrebootedRunnerLaunch {
|
|
937
946
|
const workDir = input.workDir.replace(/\/$/, '');
|
|
938
947
|
const sandboxRuntimeLimits = validatePlaySandboxRuntimeLimits(
|
|
939
948
|
input.sandboxRuntimeLimits,
|
|
940
949
|
);
|
|
941
|
-
const
|
|
942
|
-
const
|
|
943
|
-
const
|
|
950
|
+
const pathId = () => input.pathNonce ?? randomUUID();
|
|
951
|
+
const configPath = `${workDir}/deepline-play-config-${pathId()}.json`;
|
|
952
|
+
const artifactCodePath = `${workDir}/deepline-play-artifact-${pathId()}.cjs`;
|
|
953
|
+
const crashPusherPath = `${workDir}/deepline-play-crash-terminal-${pathId()}.cjs`;
|
|
944
954
|
const nodeCommand = input.nodeBinaryPath
|
|
945
955
|
? shellQuote(input.nodeBinaryPath)
|
|
946
956
|
: 'node';
|
|
@@ -953,6 +963,7 @@ export function buildPrebootedRunnerLaunch(input: {
|
|
|
953
963
|
configPath,
|
|
954
964
|
crashPusherPath,
|
|
955
965
|
materialize: null,
|
|
966
|
+
...(input.pathNonce === undefined ? {} : { pathNonce: input.pathNonce }),
|
|
956
967
|
});
|
|
957
968
|
return {
|
|
958
969
|
...paths,
|
|
@@ -92,6 +92,14 @@ import {
|
|
|
92
92
|
logEarlySandbox,
|
|
93
93
|
logEarlySandboxReapUnconfirmed,
|
|
94
94
|
PREBOOT_RUNNER_IN_EARLY_SANDBOX,
|
|
95
|
+
ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES,
|
|
96
|
+
EARLY_PREBOOT_ADOPTION_PROBE_AFTER_MS,
|
|
97
|
+
earlyPrebootRunnerCommandSha256,
|
|
98
|
+
MODAL_SANDBOX_TAGS_MAX_BYTES,
|
|
99
|
+
modalSandboxTagsBytes,
|
|
100
|
+
newEarlyPrebootPathNonce,
|
|
101
|
+
publishEarlyPrebootPlan,
|
|
102
|
+
verifyEarlyPrebootPlan,
|
|
95
103
|
readEarlySandboxExitCode,
|
|
96
104
|
reapEarlySandboxById,
|
|
97
105
|
scheduleEarlySandboxReap,
|
|
@@ -1011,6 +1019,34 @@ async function releaseModalSandboxCapacityAfterConfirmedTermination(input: {
|
|
|
1011
1019
|
throw lastError;
|
|
1012
1020
|
}
|
|
1013
1021
|
|
|
1022
|
+
/**
|
|
1023
|
+
* An adopted early sandbox this launch never won is not terminated here, so
|
|
1024
|
+
* its capacity lease is not released by the terminate branch either. The
|
|
1025
|
+
* lease was never bound (its record lost or failed), and only expiry would
|
|
1026
|
+
* release it, so release it now: `releaseCapacity` touches an unbound lease
|
|
1027
|
+
* only. Best effort and loud; the launch is already failing.
|
|
1028
|
+
*/
|
|
1029
|
+
export async function releaseNotWonEarlyAdoptionCapacity(input: {
|
|
1030
|
+
leaseId: string;
|
|
1031
|
+
release: NonNullable<PlayRunnerCallbacks['releaseSandboxCapacity']>;
|
|
1032
|
+
sandboxId: string;
|
|
1033
|
+
runId: string | null;
|
|
1034
|
+
}): Promise<void> {
|
|
1035
|
+
try {
|
|
1036
|
+
await releaseModalSandboxCapacityAfterConfirmedTermination({
|
|
1037
|
+
leaseId: input.leaseId,
|
|
1038
|
+
release: input.release,
|
|
1039
|
+
});
|
|
1040
|
+
} catch (error) {
|
|
1041
|
+
console.error('[play-runner.modal.capacity_release_failed]', {
|
|
1042
|
+
sandboxId: input.sandboxId,
|
|
1043
|
+
runId: input.runId,
|
|
1044
|
+
notWonAdoption: true,
|
|
1045
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1014
1050
|
/**
|
|
1015
1051
|
* A create that settles after its caller timed out is already an external
|
|
1016
1052
|
* fact. Persist it before attempting any further provider operation: the
|
|
@@ -1517,8 +1553,21 @@ export async function startEarlyModalPreboot(input: {
|
|
|
1517
1553
|
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
1518
1554
|
memoryLimitMiB?: number;
|
|
1519
1555
|
verdictTimeoutMs?: number;
|
|
1556
|
+
/**
|
|
1557
|
+
* PX: once the pre-boot verified, publish its plan (MAC-signed tags) so a
|
|
1558
|
+
* launch on another worker can deliver to it. The write finishes before
|
|
1559
|
+
* this resolves, so an in-process adoption (which awaits this) re-tags
|
|
1560
|
+
* after it and never has its tags overwritten.
|
|
1561
|
+
*/
|
|
1562
|
+
publishPlan?: {
|
|
1563
|
+
secret: string;
|
|
1564
|
+
tags: Record<string, string>;
|
|
1565
|
+
setTags: (tags: Record<string, string>) => Promise<void>;
|
|
1566
|
+
} | null;
|
|
1520
1567
|
}): Promise<EarlyModalPreboot> {
|
|
1521
1568
|
const startedAtMs = Date.now();
|
|
1569
|
+
// PX: one nonce for every runner path, so the plan can name them all.
|
|
1570
|
+
const pathNonce = input.publishPlan ? newEarlyPrebootPathNonce() : undefined;
|
|
1522
1571
|
const timeoutMs = input.verdictTimeoutMs ?? EARLY_PREBOOT_VERDICT_TIMEOUT_MS;
|
|
1523
1572
|
const fail = (
|
|
1524
1573
|
status: 'not_started' | 'ambiguous',
|
|
@@ -1551,6 +1600,7 @@ export async function startEarlyModalPreboot(input: {
|
|
|
1551
1600
|
...(input.memoryLimitMiB === undefined
|
|
1552
1601
|
? {}
|
|
1553
1602
|
: { memoryLimitMiB: input.memoryLimitMiB }),
|
|
1603
|
+
...(pathNonce === undefined ? {} : { pathNonce }),
|
|
1554
1604
|
});
|
|
1555
1605
|
// Text-mode exec (the verdict line is read as a string), typed from the call.
|
|
1556
1606
|
const execPreboot = () => input.sandbox.exec(['bash', '-lc', runner.command]);
|
|
@@ -1607,6 +1657,51 @@ export async function startEarlyModalPreboot(input: {
|
|
|
1607
1657
|
sandboxId: input.sandbox.sandboxId,
|
|
1608
1658
|
elapsedMs: Date.now() - startedAtMs,
|
|
1609
1659
|
});
|
|
1660
|
+
if (input.publishPlan && pathNonce) {
|
|
1661
|
+
try {
|
|
1662
|
+
const published = {
|
|
1663
|
+
...input.publishPlan.tags,
|
|
1664
|
+
...publishEarlyPrebootPlan(input.publishPlan.secret, {
|
|
1665
|
+
key: input.key,
|
|
1666
|
+
sandboxId: input.sandbox.sandboxId,
|
|
1667
|
+
nonce: pathNonce,
|
|
1668
|
+
startedAtMs,
|
|
1669
|
+
sandboxRuntimeLimits: runner.sandboxRuntimeLimits,
|
|
1670
|
+
...(runner.memoryLimitMiB === undefined
|
|
1671
|
+
? {}
|
|
1672
|
+
: { memoryLimitMiB: runner.memoryLimitMiB }),
|
|
1673
|
+
bakedRunnerHash: bakedRunner.hash,
|
|
1674
|
+
runnerCommandSha256: earlyPrebootRunnerCommandSha256(runner.command),
|
|
1675
|
+
}),
|
|
1676
|
+
};
|
|
1677
|
+
const bytes = modalSandboxTagsBytes(published);
|
|
1678
|
+
if (bytes > MODAL_SANDBOX_TAGS_MAX_BYTES) {
|
|
1679
|
+
// Modal would refuse the write: a Play whose family key makes the
|
|
1680
|
+
// caller workflowId tag long. Only this worker can deliver, as
|
|
1681
|
+
// without PX; loud so the lost cross-worker adoption is visible.
|
|
1682
|
+
console.error('[play-runner.modal.early] preboot_plan_too_large', {
|
|
1683
|
+
key: input.key,
|
|
1684
|
+
sandboxId: input.sandbox.sandboxId,
|
|
1685
|
+
bytes,
|
|
1686
|
+
maxBytes: MODAL_SANDBOX_TAGS_MAX_BYTES,
|
|
1687
|
+
});
|
|
1688
|
+
return state;
|
|
1689
|
+
}
|
|
1690
|
+
await input.publishPlan.setTags(published);
|
|
1691
|
+
logEarlyModalSandbox('preboot_plan_published', {
|
|
1692
|
+
key: input.key,
|
|
1693
|
+
sandboxId: input.sandbox.sandboxId,
|
|
1694
|
+
elapsedMs: Date.now() - startedAtMs,
|
|
1695
|
+
});
|
|
1696
|
+
} catch (error) {
|
|
1697
|
+
// Unpublished: only this worker can deliver to it, as without PX.
|
|
1698
|
+
logEarlyModalSandbox('preboot_plan_publish_failed', {
|
|
1699
|
+
key: input.key,
|
|
1700
|
+
sandboxId: input.sandbox.sandboxId,
|
|
1701
|
+
error: error instanceof Error ? error.message : String(error),
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1610
1705
|
return state;
|
|
1611
1706
|
}
|
|
1612
1707
|
// A refusal exits 98 before the watchdog or runner start; only that exit
|
|
@@ -1906,12 +2001,45 @@ async function createEarlyModalSandbox(
|
|
|
1906
2001
|
});
|
|
1907
2002
|
// Arm the early sandbox: exact-id reaper, PB pre-boot, S1 supervisor.
|
|
1908
2003
|
const armEarlySandbox = (sandbox: ModalSandbox) => {
|
|
1909
|
-
//
|
|
2004
|
+
// PX: publish the verified plan (its own tag write) unless S1 also tags
|
|
2005
|
+
// this sandbox; the token signs it, so without one nothing is published
|
|
2006
|
+
// and only this worker can deliver, as without PX.
|
|
2007
|
+
const pxWanted =
|
|
2008
|
+
preboot &&
|
|
2009
|
+
resolveExperimentSwitch(
|
|
2010
|
+
'PX',
|
|
2011
|
+
input.experimentSwitchOverrides,
|
|
2012
|
+
ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES,
|
|
2013
|
+
);
|
|
2014
|
+
const planSecret = process.env.DEEPLINE_INTERNAL_TOKEN?.trim();
|
|
2015
|
+
if (pxWanted && !planSecret) warnEarlyPrebootPlanTokenMissingOnce();
|
|
2016
|
+
const publishPlan =
|
|
2017
|
+
pxWanted &&
|
|
2018
|
+
planSecret &&
|
|
2019
|
+
!(
|
|
2020
|
+
supervisorSidecar &&
|
|
2021
|
+
resolveExperimentSwitch(
|
|
2022
|
+
'S1',
|
|
2023
|
+
input.experimentSwitchOverrides,
|
|
2024
|
+
START_SUPERVISOR_WITH_EARLY_SANDBOX,
|
|
2025
|
+
)
|
|
2026
|
+
)
|
|
2027
|
+
? {
|
|
2028
|
+
secret: planSecret,
|
|
2029
|
+
tags: earlyTags,
|
|
2030
|
+
setTags: (tags: Record<string, string>) => sandbox.setTags(tags),
|
|
2031
|
+
}
|
|
2032
|
+
: null;
|
|
2033
|
+
// Exact-id reaper: if no launch adopted it, terminate it by id. With a
|
|
2034
|
+
// published plan, also settle it early once another worker adopted it.
|
|
1910
2035
|
scheduleEarlySandboxReap({
|
|
1911
2036
|
calls: lookups,
|
|
1912
2037
|
key,
|
|
1913
2038
|
sandboxId: sandbox.sandboxId,
|
|
1914
2039
|
registry: earlyModalSandboxes,
|
|
2040
|
+
...(publishPlan
|
|
2041
|
+
? { adoptionProbeAfterMs: EARLY_PREBOOT_ADOPTION_PROBE_AFTER_MS }
|
|
2042
|
+
: {}),
|
|
1915
2043
|
});
|
|
1916
2044
|
if (preboot) {
|
|
1917
2045
|
earlyModalPreboots.set(
|
|
@@ -1929,6 +2057,7 @@ async function createEarlyModalSandbox(
|
|
|
1929
2057
|
...(memoryPolicy.memoryLimitMiB > memoryPolicy.reservationMemoryMiB
|
|
1930
2058
|
? { memoryLimitMiB: memoryPolicy.memoryLimitMiB }
|
|
1931
2059
|
: {}),
|
|
2060
|
+
publishPlan,
|
|
1932
2061
|
}),
|
|
1933
2062
|
);
|
|
1934
2063
|
}
|
|
@@ -1941,7 +2070,9 @@ async function createEarlyModalSandbox(
|
|
|
1941
2070
|
START_SUPERVISOR_WITH_EARLY_SANDBOX,
|
|
1942
2071
|
);
|
|
1943
2072
|
// PB's claim rode on the create tags, so it is already on the sandbox.
|
|
1944
|
-
|
|
2073
|
+
// PX: a published plan invites other workers to adopt it, so the A1
|
|
2074
|
+
// shortcut (trust this process's tags, skip the read) must not apply.
|
|
2075
|
+
if (preboot && !publishPlan)
|
|
1945
2076
|
earlyModalForeignAdoptionClaims.set(sandbox, Promise.resolve());
|
|
1946
2077
|
let tags: Record<string, string> = earlyTags;
|
|
1947
2078
|
if (earlySupervisor) {
|
|
@@ -2339,6 +2470,88 @@ export const modalEarlySandboxAdapter: EarlySandboxAdapter<ModalSandbox> = {
|
|
|
2339
2470
|
sweepOrphansForWorker: sweepOrphanEarlyModalSandboxesForWorker,
|
|
2340
2471
|
};
|
|
2341
2472
|
|
|
2473
|
+
/**
|
|
2474
|
+
* The re-tag a launch owes an early sandbox it adopted (any path), applied
|
|
2475
|
+
* only after its resource record wins the durable sandbox fence (see
|
|
2476
|
+
* `deferRetag`). Present means adopted but not (yet) won.
|
|
2477
|
+
*/
|
|
2478
|
+
const earlyModalDeferredRetags = new WeakMap<
|
|
2479
|
+
Pick<ModalSandbox, 'sandboxId'>,
|
|
2480
|
+
{ tags: Record<string, string>; createdAtMs: number }
|
|
2481
|
+
>();
|
|
2482
|
+
|
|
2483
|
+
/**
|
|
2484
|
+
* Past this age a won early sandbox is not re-tagged: the starting worker's
|
|
2485
|
+
* 90 s reaper could read its still-early tags in between. The launch defers
|
|
2486
|
+
* to a fresh attempt instead (P3-a).
|
|
2487
|
+
*/
|
|
2488
|
+
export const EARLY_DEFERRED_RETAG_MAX_AGE_MS = 75_000;
|
|
2489
|
+
|
|
2490
|
+
/** Test seam: the re-tag an adopted early sandbox still owes, if any. */
|
|
2491
|
+
export function earlyModalDeferredRetagFor(
|
|
2492
|
+
sandbox: Pick<ModalSandbox, 'sandboxId'>,
|
|
2493
|
+
): Record<string, string> | undefined {
|
|
2494
|
+
return earlyModalDeferredRetags.get(sandbox)?.tags;
|
|
2495
|
+
}
|
|
2496
|
+
|
|
2497
|
+
/**
|
|
2498
|
+
* After this launch's resource record won the fence: take the sandbox off
|
|
2499
|
+
* the early tags. The pending entry is removed first, so a failure here is a
|
|
2500
|
+
* won sandbox the launch's own cleanup terminates and releases. A re-tag too
|
|
2501
|
+
* close to the reap, or a failed tag write, defers the run to a fresh attempt
|
|
2502
|
+
* (not-live recovery) instead of failing it.
|
|
2503
|
+
*/
|
|
2504
|
+
export async function applyEarlyModalRetagAfterFence(
|
|
2505
|
+
sandbox: Pick<ModalSandbox, 'sandboxId' | 'setTags'>,
|
|
2506
|
+
nowMs: number = Date.now(),
|
|
2507
|
+
): Promise<void> {
|
|
2508
|
+
const pending = earlyModalDeferredRetags.get(sandbox);
|
|
2509
|
+
if (!pending) return;
|
|
2510
|
+
earlyModalDeferredRetags.delete(sandbox);
|
|
2511
|
+
if (nowMs - pending.createdAtMs > EARLY_DEFERRED_RETAG_MAX_AGE_MS)
|
|
2512
|
+
throw recoveryForRunnerStartupNotLive(
|
|
2513
|
+
new Error(
|
|
2514
|
+
`Early sandbox ${sandbox.sandboxId} is too close to its reap to re-tag; deferring to a fresh attempt.`,
|
|
2515
|
+
),
|
|
2516
|
+
);
|
|
2517
|
+
try {
|
|
2518
|
+
await sandbox.setTags(pending.tags);
|
|
2519
|
+
} catch (error) {
|
|
2520
|
+
throw recoveryForRunnerStartupNotLive(error);
|
|
2521
|
+
}
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
/**
|
|
2525
|
+
* Whether this launch adopted an early sandbox it never won (its resource
|
|
2526
|
+
* record lost the fence or failed): such a sandbox is never terminated here;
|
|
2527
|
+
* the winner's durable cleanup or its reaper owns it. Consumes the entry.
|
|
2528
|
+
*/
|
|
2529
|
+
export function takeEarlyModalAdoptionNotWon(
|
|
2530
|
+
sandbox: Pick<ModalSandbox, 'sandboxId'>,
|
|
2531
|
+
): boolean {
|
|
2532
|
+
if (!earlyModalDeferredRetags.has(sandbox)) return false;
|
|
2533
|
+
earlyModalDeferredRetags.delete(sandbox);
|
|
2534
|
+
return true;
|
|
2535
|
+
}
|
|
2536
|
+
|
|
2537
|
+
let earlyPrebootPlanTokenMissingWarned = false;
|
|
2538
|
+
/** PX without the signing token: nothing is published (logged once). */
|
|
2539
|
+
function warnEarlyPrebootPlanTokenMissingOnce(): void {
|
|
2540
|
+
if (earlyPrebootPlanTokenMissingWarned) return;
|
|
2541
|
+
earlyPrebootPlanTokenMissingWarned = true;
|
|
2542
|
+
console.error(
|
|
2543
|
+
JSON.stringify({
|
|
2544
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.preboot_plan_token_missing`,
|
|
2545
|
+
reason:
|
|
2546
|
+
'PX is on but DEEPLINE_INTERNAL_TOKEN is unset: pre-boot plans are not published, so only the starting worker can adopt.',
|
|
2547
|
+
}),
|
|
2548
|
+
);
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
/** PX: how long a launch waits for another worker's pre-boot plan, and how often it re-reads. */
|
|
2552
|
+
export const EARLY_PREBOOT_PLAN_WAIT_MS = 1_500;
|
|
2553
|
+
export const EARLY_PREBOOT_PLAN_POLL_MS = 100;
|
|
2554
|
+
|
|
2342
2555
|
/**
|
|
2343
2556
|
* Adopt this run's early Modal sandbox by exact id, or return null so the
|
|
2344
2557
|
* launch creates its own (see adoptEarlySandbox). A sandbox whose S1 sidecar
|
|
@@ -2358,11 +2571,120 @@ export async function adoptEarlyModalSandbox(input: {
|
|
|
2358
2571
|
wanted: boolean;
|
|
2359
2572
|
sandboxRuntimeLimits: PlaySandboxRuntimeLimits;
|
|
2360
2573
|
memoryLimitMiB?: number;
|
|
2574
|
+
/** PX: the runner work dir a published plan's paths are rebuilt under. */
|
|
2575
|
+
workDir?: string;
|
|
2361
2576
|
};
|
|
2362
2577
|
/** This process's early sandboxes; the module registry unless injected. */
|
|
2363
2578
|
registry?: EarlyModalSandboxRegistry;
|
|
2364
2579
|
nowMs?: () => number;
|
|
2580
|
+
/** PX test seams: the plan's signing token and this launch's baked runner. */
|
|
2581
|
+
planSecret?: string | null;
|
|
2582
|
+
sleep?: (ms: number) => Promise<void>;
|
|
2583
|
+
bakedRunner?: () => Promise<{ hash: string; path: string } | undefined>;
|
|
2365
2584
|
}): Promise<ModalSandbox | null> {
|
|
2585
|
+
const planSecret =
|
|
2586
|
+
input.planSecret === undefined
|
|
2587
|
+
? process.env.DEEPLINE_INTERNAL_TOKEN?.trim() || null
|
|
2588
|
+
: input.planSecret;
|
|
2589
|
+
const nowMs = input.nowMs ?? Date.now;
|
|
2590
|
+
// PX: deliver to a pre-boot another worker started, when its published
|
|
2591
|
+
// plan verifies against this launch's own limits, memory and baked runner.
|
|
2592
|
+
const foreignPrebootAdoption =
|
|
2593
|
+
planSecret &&
|
|
2594
|
+
input.preboot.wanted &&
|
|
2595
|
+
input.preboot.workDir &&
|
|
2596
|
+
resolveExperimentSwitch(
|
|
2597
|
+
'PX',
|
|
2598
|
+
input.context.experimentSwitchOverrides,
|
|
2599
|
+
ADOPT_PREBOOTED_EARLY_SANDBOX_ACROSS_PROCESSES,
|
|
2600
|
+
)
|
|
2601
|
+
? async (sandbox: ModalSandbox, tags: Record<string, string>) => {
|
|
2602
|
+
const bakedRunner = await (
|
|
2603
|
+
input.bakedRunner ??
|
|
2604
|
+
(() =>
|
|
2605
|
+
modalBakedRunnerExpectation({
|
|
2606
|
+
imageBaked: true,
|
|
2607
|
+
bundlePromise: buildPlayRunnerBundle(),
|
|
2608
|
+
}))
|
|
2609
|
+
)().catch((error: unknown) => {
|
|
2610
|
+
// Loud: without it this launch cannot check the plan.
|
|
2611
|
+
console.error(
|
|
2612
|
+
JSON.stringify({
|
|
2613
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.preboot_baked_runner_failed`,
|
|
2614
|
+
sandboxId: sandbox.sandboxId,
|
|
2615
|
+
error: error instanceof Error ? error.message : String(error),
|
|
2616
|
+
}),
|
|
2617
|
+
);
|
|
2618
|
+
return undefined;
|
|
2619
|
+
});
|
|
2620
|
+
if (!bakedRunner) return 'preboot_no_baked_runner';
|
|
2621
|
+
const runnerFor = (nonce: string) =>
|
|
2622
|
+
buildPrebootedRunnerLaunch({
|
|
2623
|
+
workDir: input.preboot.workDir!,
|
|
2624
|
+
bakedRunner,
|
|
2625
|
+
sandboxRuntimeLimits: input.preboot.sandboxRuntimeLimits,
|
|
2626
|
+
...(input.preboot.memoryLimitMiB === undefined
|
|
2627
|
+
? {}
|
|
2628
|
+
: { memoryLimitMiB: input.preboot.memoryLimitMiB }),
|
|
2629
|
+
pathNonce: nonce,
|
|
2630
|
+
});
|
|
2631
|
+
const verifyWith = (current: Record<string, string>) =>
|
|
2632
|
+
verifyEarlyPrebootPlan({
|
|
2633
|
+
secret: planSecret,
|
|
2634
|
+
tags: current,
|
|
2635
|
+
key: tags.earlyKey ?? '',
|
|
2636
|
+
sandboxId: sandbox.sandboxId,
|
|
2637
|
+
sandboxRuntimeLimits: input.preboot.sandboxRuntimeLimits,
|
|
2638
|
+
...(input.preboot.memoryLimitMiB === undefined
|
|
2639
|
+
? {}
|
|
2640
|
+
: { memoryLimitMiB: input.preboot.memoryLimitMiB }),
|
|
2641
|
+
bakedRunnerHash: bakedRunner.hash,
|
|
2642
|
+
runnerCommandSha256: (nonce) =>
|
|
2643
|
+
earlyPrebootRunnerCommandSha256(runnerFor(nonce).command),
|
|
2644
|
+
nowMs: nowMs(),
|
|
2645
|
+
});
|
|
2646
|
+
// The starting worker publishes once the pre-boot verifies (~1 s
|
|
2647
|
+
// after create); a launch claimed sooner waits for it, bounded,
|
|
2648
|
+
// as an in-process adoption waits for the verdict.
|
|
2649
|
+
let verified = verifyWith(tags);
|
|
2650
|
+
const waitUntil = nowMs() + EARLY_PREBOOT_PLAN_WAIT_MS;
|
|
2651
|
+
while (
|
|
2652
|
+
'refused' in verified &&
|
|
2653
|
+
verified.refused === 'preboot_plan_missing' &&
|
|
2654
|
+
nowMs() < waitUntil
|
|
2655
|
+
) {
|
|
2656
|
+
await (input.sleep ?? sleepMs)(EARLY_PREBOOT_PLAN_POLL_MS);
|
|
2657
|
+
verified = verifyWith(await sandbox.getTags());
|
|
2658
|
+
}
|
|
2659
|
+
if ('refused' in verified) {
|
|
2660
|
+
if (verified.refused === 'preboot_plan_invalid')
|
|
2661
|
+
// Loud: a forged, mismatched or other-build plan.
|
|
2662
|
+
console.error(
|
|
2663
|
+
JSON.stringify({
|
|
2664
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.preboot_plan_invalid`,
|
|
2665
|
+
key: tags.earlyKey ?? null,
|
|
2666
|
+
sandboxId: sandbox.sandboxId,
|
|
2667
|
+
runId: input.context.runId ?? null,
|
|
2668
|
+
}),
|
|
2669
|
+
);
|
|
2670
|
+
return verified.refused;
|
|
2671
|
+
}
|
|
2672
|
+
// The launch reads this like an in-process running pre-boot. The
|
|
2673
|
+
// starting worker holds the exec handle, so liveness here is the
|
|
2674
|
+
// launch's delivery result and readiness deadline only.
|
|
2675
|
+
earlyModalPreboots.set(
|
|
2676
|
+
sandbox,
|
|
2677
|
+
Promise.resolve<EarlyModalPreboot>({
|
|
2678
|
+
status: 'running',
|
|
2679
|
+
runner: runnerFor(verified.plan.nonce),
|
|
2680
|
+
exited: new Promise<number>(() => undefined),
|
|
2681
|
+
exitCode: null,
|
|
2682
|
+
startedAtMs: verified.plan.startedAtMs,
|
|
2683
|
+
}),
|
|
2684
|
+
);
|
|
2685
|
+
return null;
|
|
2686
|
+
}
|
|
2687
|
+
: undefined;
|
|
2366
2688
|
return await adoptEarlySandbox({
|
|
2367
2689
|
calls: earlyModalSandboxCalls(input),
|
|
2368
2690
|
registry: input.registry ?? earlyModalSandboxes,
|
|
@@ -2380,6 +2702,13 @@ export async function adoptEarlyModalSandbox(input: {
|
|
|
2380
2702
|
{ tag: EARLY_SUPERVISOR_TAG, reason: 'early_supervisor_foreign' },
|
|
2381
2703
|
],
|
|
2382
2704
|
inProcessPreboot: (sandbox) => earlyModalPreboots.get(sandbox),
|
|
2705
|
+
...(foreignPrebootAdoption ? { foreignPrebootAdoption } : {}),
|
|
2706
|
+
// Every adoption path re-tags only after the launch wins the fence.
|
|
2707
|
+
deferRetag: (
|
|
2708
|
+
sandbox: ModalSandbox,
|
|
2709
|
+
tags: Record<string, string>,
|
|
2710
|
+
createdAtMs: number,
|
|
2711
|
+
) => earlyModalDeferredRetags.set(sandbox, { tags, createdAtMs }),
|
|
2383
2712
|
inProcessForeignAdoptionClaim: (sandbox) =>
|
|
2384
2713
|
earlyModalForeignAdoptionClaims.get(sandbox),
|
|
2385
2714
|
emitStage: (stage, extra) => emitModalStage(input.context, stage, extra),
|
|
@@ -2698,6 +3027,7 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2698
3027
|
...(runMemoryLimitMiB === undefined
|
|
2699
3028
|
? {}
|
|
2700
3029
|
: { memoryLimitMiB: runMemoryLimitMiB }),
|
|
3030
|
+
workDir: modalConfig.workdir,
|
|
2701
3031
|
},
|
|
2702
3032
|
}).then((adopted) => adopted ?? createSandbox())
|
|
2703
3033
|
: createSandbox(),
|
|
@@ -2985,6 +3315,9 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
2985
3315
|
runtimeResourceRegistrationError = error;
|
|
2986
3316
|
throw error;
|
|
2987
3317
|
}
|
|
3318
|
+
// This launch's record won the durable sandbox fence; only now does
|
|
3319
|
+
// an adopted early sandbox leave the early tags (and its reaper).
|
|
3320
|
+
await applyEarlyModalRetagAfterFence(sandbox);
|
|
2988
3321
|
emitModalStage(config.context, 'resource:recorded', {
|
|
2989
3322
|
sandboxId: sandbox.sandboxId,
|
|
2990
3323
|
elapsedMs: Date.now() - startedAt,
|
|
@@ -3303,7 +3636,31 @@ export const modalPlayRunnerBackend: PlayRunnerBackend = {
|
|
|
3303
3636
|
throw error;
|
|
3304
3637
|
} finally {
|
|
3305
3638
|
callbacks?.cancellationSignal?.removeEventListener('abort', onCancel);
|
|
3306
|
-
|
|
3639
|
+
// An adopted early sandbox still awaiting its re-tag was never won by
|
|
3640
|
+
// this launch (its resource record lost or failed): never terminate
|
|
3641
|
+
// it here; the winner's durable cleanup or its reaper owns it.
|
|
3642
|
+
const unwonForeign = takeEarlyModalAdoptionNotWon(sandbox);
|
|
3643
|
+
if (unwonForeign) {
|
|
3644
|
+
console.error(
|
|
3645
|
+
JSON.stringify({
|
|
3646
|
+
event: `${EARLY_MODAL_LOG_SCOPE}.adoption_not_won`,
|
|
3647
|
+
sandboxId: sandbox.sandboxId,
|
|
3648
|
+
runId: config.context.runId ?? null,
|
|
3649
|
+
}),
|
|
3650
|
+
);
|
|
3651
|
+
if (capacityReservation && callbacks?.releaseSandboxCapacity)
|
|
3652
|
+
await releaseNotWonEarlyAdoptionCapacity({
|
|
3653
|
+
leaseId: capacityReservation.leaseId,
|
|
3654
|
+
release: callbacks.releaseSandboxCapacity,
|
|
3655
|
+
sandboxId: sandbox.sandboxId,
|
|
3656
|
+
runId: config.context.runId ?? null,
|
|
3657
|
+
});
|
|
3658
|
+
}
|
|
3659
|
+
if (
|
|
3660
|
+
!detached &&
|
|
3661
|
+
!unwonForeign &&
|
|
3662
|
+
(await terminateModalSandbox(sandbox))
|
|
3663
|
+
) {
|
|
3307
3664
|
// This branch synchronously confirms that the just-created resource
|
|
3308
3665
|
// is gone. Do not keep its admission lease until the cleanup loop
|
|
3309
3666
|
// sees a resource that no longer exists.
|