@cnc-tools/storm 0.16.0 → 0.18.0
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/bin/storm.js +54 -40
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
- package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
- package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
- package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
- package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
- package/dist/chunks/chunk-AS37D43E.js +2173 -0
- package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
- package/dist/chunks/chunk-DZLU7BYK.js +340 -0
- package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
- package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
- package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
- package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
- package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
- package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
- package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
- package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
- package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
- package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
- package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
- package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
- package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
- package/dist/chunks/chunk-SZMYIIG2.js +88 -0
- package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
- package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
- package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
- package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
- package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
- package/dist/cli.d.ts +28 -0
- package/dist/cli.js +64 -0
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
- package/dist/commands/exec/before-run.d.ts +123 -0
- package/dist/commands/exec/before-run.js +105 -0
- package/dist/commands/exec/command.d.ts +67 -14
- package/dist/commands/exec/command.js +31 -95
- package/dist/commands/exec/driver-plan.d.ts +9 -4
- package/dist/commands/exec/driver-plan.js +8 -8
- package/dist/commands/exec/exec-words.js +1 -1
- package/dist/commands/exec/execute-run.d.ts +39 -0
- package/dist/commands/exec/execute-run.js +325 -0
- package/dist/commands/exec/live-view.d.ts +3 -3
- package/dist/commands/exec/live-view.js +16 -15
- package/dist/commands/exec/metadata.js +1 -1
- package/dist/commands/exec/mint-failed.d.ts +38 -0
- package/dist/commands/exec/mint-failed.js +27 -4
- package/dist/commands/exec/outcomes.d.ts +104 -22
- package/dist/commands/exec/outcomes.js +73 -26
- package/dist/commands/exec/plan-run.d.ts +58 -150
- package/dist/commands/exec/plan-run.js +239 -90
- package/dist/commands/exec/progress.d.ts +10 -6
- package/dist/commands/exec/progress.js +38 -25
- package/dist/commands/exec/run-bin.d.ts +11 -11
- package/dist/commands/exec/run-bin.js +9 -9
- package/dist/commands/exec/run-flags.d.ts +69 -0
- package/dist/commands/exec/run-flags.js +58 -0
- package/dist/commands/exec/run-metadata.js +4 -4
- package/dist/commands/exec/run-summary.d.ts +58 -0
- package/dist/commands/exec/run-summary.js +205 -0
- package/dist/commands/exec/runner-refusals.d.ts +82 -0
- package/dist/commands/exec/runner-refusals.js +71 -0
- package/dist/commands/exec/sandbox-progress.js +3 -0
- package/dist/commands/exec/stopped-outcome.d.ts +12 -0
- package/dist/commands/exec/stopped-outcome.js +77 -0
- package/dist/commands/exec/view.d.ts +20 -11
- package/dist/commands/exec/view.js +103 -47
- package/dist/commands/runs/facts.d.ts +8 -4
- package/dist/commands/runs/facts.js +19 -10
- package/dist/commands/runs/list/command.d.ts +16 -8
- package/dist/commands/runs/list/command.js +10 -10
- package/dist/commands/runs/list/outcomes.d.ts +8 -4
- package/dist/commands/runs/logs/command.js +10 -10
- package/dist/commands/runs/show/command.d.ts +16 -8
- package/dist/commands/runs/show/command.js +31 -29
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +8 -4
- package/dist/commands/runs/show/outcomes.js +8 -6
- package/dist/commands/snapshots/access.d.ts +111 -0
- package/dist/commands/snapshots/access.js +96 -0
- package/dist/commands/snapshots/build/command.d.ts +376 -101
- package/dist/commands/snapshots/build/command.js +447 -149
- package/dist/commands/snapshots/build/metadata.d.ts +10 -0
- package/dist/commands/snapshots/build/metadata.js +31 -11
- package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
- package/dist/commands/snapshots/build/outcomes.js +200 -36
- package/dist/commands/snapshots/list/command.d.ts +368 -27
- package/dist/commands/snapshots/list/command.js +298 -68
- package/dist/commands/snapshots/list/metadata.d.ts +16 -0
- package/dist/commands/snapshots/list/metadata.js +29 -6
- package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
- package/dist/commands/snapshots/list/outcomes.js +223 -52
- package/dist/commands/snapshots/metadata.js +1 -1
- package/dist/commands/snapshots/prune/command.d.ts +430 -0
- package/dist/commands/snapshots/prune/command.js +161 -0
- package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
- package/dist/commands/snapshots/prune/metadata.js +39 -0
- package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
- package/dist/commands/snapshots/prune/outcomes.js +78 -0
- package/dist/commands/suites/list/command.js +17 -17
- package/dist/commands/suites/list/outcomes.js +2 -2
- package/dist/commands/test/command.d.ts +67 -14
- package/dist/commands/test/command.js +49 -252
- package/dist/commands/test/outcomes.d.ts +33 -7
- package/dist/config/check-runner.d.ts +3 -3
- package/dist/config/check-runner.js +8 -7
- package/dist/config/credential-resolver.d.ts +50 -5
- package/dist/config/credential-resolver.js +51 -19
- package/dist/config/credential-settle.d.ts +6 -2
- package/dist/config/credential-settle.js +11 -5
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -1
- package/dist/config/runner.d.ts +5 -5
- package/dist/config/runner.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +1 -1
- package/dist/config-file/define.d.ts +1 -1
- package/dist/config-file/define.js +1 -1
- package/dist/config-file/runner.d.ts +5 -5
- package/dist/config-file/toolchain.d.ts +14 -4
- package/dist/config-file/toolchain.js +43 -7
- package/dist/context.d.ts +10 -6
- package/dist/context.js +8 -6
- package/dist/core/across-sandboxes.d.ts +7 -6
- package/dist/core/across-sandboxes.js +123 -152
- package/dist/core/coordinator.d.ts +166 -0
- package/dist/core/coordinator.js +233 -0
- package/dist/core/events.d.ts +2 -2
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +1 -1
- package/dist/core/outcomes.d.ts +148 -0
- package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
- package/dist/core/resources.d.ts +31 -53
- package/dist/core/resources.js +32 -70
- package/dist/core/run-state.d.ts +7 -1
- package/dist/core/run-state.js +2 -0
- package/dist/core/run.d.ts +32 -236
- package/dist/core/run.js +107 -267
- package/dist/core/state-directory.d.ts +1 -1
- package/dist/core/state-directory.js +2 -2
- package/dist/credential/gateways.d.ts +15 -1
- package/dist/credential/index.d.ts +4 -3
- package/dist/credential/index.js +3 -2
- package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
- package/dist/credential/live/vercel-cli-gateway.js +1 -1
- package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
- package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
- package/dist/credential/source.d.ts +73 -6
- package/dist/credential/source.js +55 -2
- package/dist/extension-commands.d.ts +1 -1
- package/dist/extension-commands.js +2 -2
- package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
- package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
- package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
- package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/credential-facts.d.ts +6 -2
- package/dist/extensions/testserver/credential-facts.js +29 -11
- package/dist/extensions/testserver/lifecycle.js +7 -1
- package/dist/extensions/testserver/limit.d.ts +3 -0
- package/dist/extensions/testserver/limit.js +3 -0
- package/dist/extensions/testserver/provision.d.ts +8 -1
- package/dist/extensions/testserver/provision.js +8 -3
- package/dist/extensions/testserver/refusals.d.ts +6 -1
- package/dist/extensions/testserver/refusals.js +16 -1
- package/dist/extensions/testserver/resource.d.ts +1 -1
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/result.d.ts +1 -1
- package/dist/extensions/testserver/result.js +9 -4
- package/dist/planning/driver-file-lists.d.ts +0 -15
- package/dist/planning/driver-file-lists.js +2 -21
- package/dist/planning/plan-only.d.ts +3 -14
- package/dist/planning/plan-only.js +11 -20
- package/dist/planning/run-kind-flags.js +2 -2
- package/dist/planning/run-plan.d.ts +45 -12
- package/dist/planning/run-plan.js +4 -3
- package/dist/planning/suites.d.ts +1 -1
- package/dist/planning/suites.js +2 -2
- package/dist/planning/test-plan.d.ts +9 -0
- package/dist/planning/test-plan.js +9 -0
- package/dist/run-directory/recording.js +3 -3
- package/dist/run-directory/run-record.d.ts +26 -11
- package/dist/run-directory/run-record.js +16 -13
- package/dist/runner/base.js +1 -1
- package/dist/runner/build-snapshots.d.ts +60 -29
- package/dist/runner/build-snapshots.js +136 -29
- package/dist/runner/context.d.ts +15 -7
- package/dist/runner/context.js +19 -6
- package/dist/runner/events.d.ts +16 -10
- package/dist/runner/gateways.d.ts +122 -23
- package/dist/runner/gateways.js +1 -1
- package/dist/runner/gh.d.ts +42 -0
- package/dist/runner/gh.js +58 -0
- package/dist/runner/index.d.ts +13 -8
- package/dist/runner/index.js +12 -6
- package/dist/runner/live/checkout-gateway.js +7 -0
- package/dist/runner/live/gh-output.d.ts +17 -0
- package/dist/runner/live/gh-output.js +37 -0
- package/dist/runner/live/gh-token-gateway.d.ts +13 -0
- package/dist/runner/live/gh-token-gateway.js +51 -0
- package/dist/runner/live/sandbox-errors.d.ts +2 -0
- package/dist/runner/live/sandbox-errors.js +4 -0
- package/dist/runner/live/sandbox-gateway.js +140 -4
- package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
- package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
- package/dist/runner/live/snapshot-records.js +12 -12
- package/dist/runner/local-snapshot-index.d.ts +205 -0
- package/dist/runner/local-snapshot-index.js +210 -0
- package/dist/runner/network-policy.d.ts +6 -6
- package/dist/runner/network-policy.js +7 -7
- package/dist/runner/policy-writes.d.ts +1 -1
- package/dist/runner/policy-writes.js +1 -1
- package/dist/runner/prepare.d.ts +14 -14
- package/dist/runner/prepare.js +20 -11
- package/dist/runner/ready.d.ts +19 -11
- package/dist/runner/ready.js +104 -33
- package/dist/runner/sandboxed-command.d.ts +3 -3
- package/dist/runner/sandboxed-command.js +3 -3
- package/dist/runner/scope.d.ts +15 -8
- package/dist/runner/scope.js +16 -5
- package/dist/runner/secrets.d.ts +41 -18
- package/dist/runner/secrets.js +226 -30
- package/dist/runner/session.d.ts +8 -8
- package/dist/runner/session.js +6 -3
- package/dist/runner/shared-snapshot-entry.d.ts +92 -0
- package/dist/runner/shared-snapshot-entry.js +168 -0
- package/dist/runner/shared-snapshot-list.d.ts +81 -0
- package/dist/runner/shared-snapshot-list.js +155 -0
- package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
- package/dist/runner/shared-snapshot-lookup.js +118 -0
- package/dist/runner/shared-snapshot-prune.d.ts +58 -0
- package/dist/runner/shared-snapshot-prune.js +133 -0
- package/dist/runner/snapshot-build.d.ts +42 -14
- package/dist/runner/snapshot-build.js +79 -47
- package/dist/runner/snapshot-choice.js +2 -1
- package/dist/runner/snapshot-inspect.d.ts +39 -40
- package/dist/runner/snapshot-inspect.js +52 -35
- package/dist/runner/snapshot-key.d.ts +32 -17
- package/dist/runner/snapshot-key.js +43 -18
- package/dist/runner/snapshot-source.d.ts +31 -0
- package/dist/runner/snapshot-source.js +122 -0
- package/dist/runner/steps.d.ts +1 -1
- package/dist/runner/steps.js +1 -1
- package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
- package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
- package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
- package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
- package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
- package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
- package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
- package/dist/sdk/extension/credential-diagnosis.js +25 -5
- package/dist/sdk/extension/credential-source.d.ts +20 -3
- package/dist/sdk/extension/credential-source.js +4 -4
- package/dist/sdk/extension/index.d.ts +3 -2
- package/dist/sdk/extension/index.js +2 -1
- package/dist/sdk/extension/resource-definition.d.ts +1 -1
- package/dist/sdk/extension/secret-source.d.ts +1 -1
- package/dist/sdk/extension/secret-source.js +1 -1
- package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
- package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
- package/dist/shared/cleanup.d.ts +3 -3
- package/dist/shared/cleanup.js +15 -5
- package/dist/shared/snapshot-text.d.ts +4 -4
- package/dist/shared/snapshot-text.js +11 -11
- package/dist/time/duration.js +1 -1
- package/package.json +5 -3
- package/skills/overview.md +4 -4
- package/skills/plan-runs.md +1 -1
- package/skills/read-run-output.md +6 -6
- package/dist/application.d.ts +0 -21
- package/dist/application.js +0 -30
- package/dist/chunks/chunk-7EENF73W.js +0 -782
- package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
- package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
- package/dist/commands/exec/across-sandboxes-run.js +0 -339
- package/dist/commands/exec/plan-only.d.ts +0 -10
- package/dist/commands/exec/plan-only.js +0 -45
- package/dist/commands/exec/run-command.d.ts +0 -475
- package/dist/commands/exec/run-command.js +0 -603
- package/dist/commands/exec/run-planned.d.ts +0 -20
- package/dist/commands/exec/run-planned.js +0 -22
- package/dist/commands/exec/sandbox-view.d.ts +0 -19
- package/dist/commands/exec/sandbox-view.js +0 -72
- package/dist/commands/test/plan.d.ts +0 -92
- package/dist/commands/test/plan.js +0 -125
- package/dist/core/sandbox-end.d.ts +0 -64
- package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
- package/dist/runner/recipe-secrets.d.ts +0 -67
- package/dist/runner/snapshot-cache.d.ts +0 -148
- package/dist/runner/snapshot-cache.js +0 -126
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
// A run across runner sandboxes,
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// failure ahead of resource refusal, matching `core/run.ts`).
|
|
1
|
+
// A run across runner sandboxes (`executeAcrossSandboxes`), delegating run opening, credential obtainment, concurrent
|
|
2
|
+
// setup & deterministic failure ranking, sandbox command execution, fail-closed fence tracking, and resource cleanup
|
|
3
|
+
// framing to `core/coordinator.ts`.
|
|
5
4
|
import { chooseSnapshotForRun, openRunnerSession, SANDBOX_TEST_EVENTS_PATH, } from "../runner/index.js";
|
|
5
|
+
import { coordinateSetup, emitLanesStarted, emitRunOpening, mergedRunnerCleanup, obtainRunnerCredential, runCommandInSandbox, sandboxFenceTracker, withResourceCleanup, } from "./coordinator.js";
|
|
6
|
+
import { canceledStop, runnerLaneOutcome, sandboxEndFacts, } from "./outcomes.js";
|
|
6
7
|
import { runPayload } from "./payload.js";
|
|
7
8
|
import { LOOKUP } from "./resource-definition-set.js";
|
|
8
|
-
import { acquireResources, announceAcquired,
|
|
9
|
-
import { emitRunOpening, mintCredential, runCommandInSandbox, withResourceCleanup, } from "./run.js";
|
|
10
|
-
import { sandboxEndFacts } from "./sandbox-end.js";
|
|
9
|
+
import { acquireResources, announceAcquired, resourceInstances, resourcesCredentials, resourcesRan, resourceWarnings, splitAcquired, } from "./resources.js";
|
|
11
10
|
/**
|
|
12
11
|
* Runs a run across runner sandboxes (`request.sandboxes`) with the resources it asks for (`request.resources`).
|
|
13
12
|
*
|
|
14
|
-
* -
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* runner snapshot failure, then resource refusal.
|
|
13
|
+
* - Opening, credential obtainment, snapshot choice, resource acquire/split, and final release run once for the run.
|
|
14
|
+
* - Snapshot choice and resource acquire/split run concurrently under `coordinateSetup`; sandboxes start readying from
|
|
15
|
+
* the chosen snapshot while resources finish acquiring and splitting.
|
|
18
16
|
* - One runner sandbox's failure or throw never stops the others.
|
|
19
17
|
* - `snapshot_gone` ends the run with `snapshot_gone` only when every runner sandbox reports it; partial
|
|
20
18
|
* `snapshot_gone` ends as `sandboxes_ran` with affected runner sandboxes `not-started`.
|
|
@@ -27,12 +25,10 @@ export async function executeAcrossSandboxes(definitionSet, context, resourceCon
|
|
|
27
25
|
await emitRunOpening(progress, request, instances);
|
|
28
26
|
const { value: ended, resourceCleanup } = await withResourceCleanup(instances, runner.keepMs, progress, async (cleanup) => {
|
|
29
27
|
const all = await runAll(context, request, instances, control.signal, progress);
|
|
30
|
-
// Every runner sandbox's session has fenced and closed its scope by now: the release hears whether each one
|
|
31
|
-
// fenced its runner sandbox, since a runner sandbox still running could still reach what the resources took.
|
|
32
28
|
await cleanup.release({ runnerSandboxFenced: all.runnerSandboxesFenced });
|
|
33
29
|
return all;
|
|
34
30
|
});
|
|
35
|
-
const runnerCleanup =
|
|
31
|
+
const runnerCleanup = mergedRunnerCleanup(runner.target, ended.runnerCleanups);
|
|
36
32
|
await progress.emit({
|
|
37
33
|
kind: "cleanup-finished",
|
|
38
34
|
resourceWarnings: resourceWarnings(resourceCleanup),
|
|
@@ -58,145 +54,148 @@ export async function executeAcrossSandboxes(definitionSet, context, resourceCon
|
|
|
58
54
|
return { kind: "snapshot_gone", entry: first.end.entry, removal: first.end.removal, ...cleanup };
|
|
59
55
|
return { kind: "sandboxes_ran", sandboxes, snapshot: ended.snapshot, resources: resourcesRan(instances), ...cleanup };
|
|
60
56
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Ranks why the run's shared setup stopped, matching `core/run.ts`: user cancellation first, then runner snapshot
|
|
63
|
-
* failure, then resource refusal or throw. A synthetic `canceled` from an internal abort is not a resource failure.
|
|
64
|
-
*/
|
|
65
|
-
function rankSetupEnd(canceled, snapshotFailure, resources) {
|
|
66
|
-
if (canceled)
|
|
67
|
-
return canceledStop();
|
|
68
|
-
if (snapshotFailure !== undefined)
|
|
69
|
-
return snapshotFailure;
|
|
70
|
-
if (resources.kind === "stopped" && resources.stop.kind !== "canceled")
|
|
71
|
-
return resources.stop;
|
|
72
|
-
if (resources.kind === "threw")
|
|
73
|
-
return { kind: "threw", message: errorMessage(resources.error) };
|
|
74
|
-
return canceledStop();
|
|
75
|
-
}
|
|
76
57
|
function errorMessage(error) {
|
|
77
58
|
return error instanceof Error ? error.message : String(error);
|
|
78
59
|
}
|
|
60
|
+
function gateEndFromResources(cancelSignal, settled) {
|
|
61
|
+
if (cancelSignal.aborted)
|
|
62
|
+
return canceledStop();
|
|
63
|
+
if (settled.kind === "stopped")
|
|
64
|
+
return settled.outcome;
|
|
65
|
+
if (settled.kind === "threw")
|
|
66
|
+
return { kind: "threw", message: errorMessage(settled.error) };
|
|
67
|
+
return canceledStop();
|
|
68
|
+
}
|
|
79
69
|
async function runAll(context, request, instances, cancelSignal, progress) {
|
|
80
70
|
const count = request.sandboxes.length;
|
|
81
|
-
const credential = await
|
|
71
|
+
const credential = await obtainRunnerCredential(context, request.credential, cancelSignal, progress);
|
|
82
72
|
if (!credential.ok)
|
|
83
73
|
return stoppedBeforeSandboxes(count, credential.outcome, [], undefined, progress);
|
|
84
74
|
const { access, mint } = credential;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
sandboxes: count,
|
|
94
|
-
runnerCredentials: request.runner.credentials,
|
|
95
|
-
}).then((answered) => {
|
|
96
|
-
if (answered.kind === "split")
|
|
97
|
-
return answered;
|
|
98
|
-
if (answered.stop.kind !== "canceled")
|
|
99
|
-
stop.abort();
|
|
100
|
-
return answered;
|
|
101
|
-
}, (error) => {
|
|
102
|
-
stop.abort();
|
|
103
|
-
return { kind: "threw", error };
|
|
104
|
-
});
|
|
105
|
-
const gateOf = (index) => parts.then((settled) => {
|
|
106
|
-
if (settled.kind === "split") {
|
|
107
|
-
const resources = settled.parts[index];
|
|
108
|
-
if (resources !== undefined)
|
|
109
|
-
return { kind: "ready", resources, credentials: settled.credentials };
|
|
110
|
-
}
|
|
111
|
-
return { kind: "stopped", end: rankSetupEnd(cancelSignal.aborted, undefined, settled) };
|
|
112
|
-
});
|
|
113
|
-
try {
|
|
114
|
-
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
115
|
-
const chosen = await chooseSnapshotForRun(context, {
|
|
116
|
-
prepared: request.runner.prepared,
|
|
117
|
-
access,
|
|
118
|
-
user: request.runner.user,
|
|
119
|
-
credentials: request.runner.credentials,
|
|
120
|
-
}, { signal: cancelSignal, stop: stop.signal }, runnerProgress);
|
|
121
|
-
const choiceCleanup = { ...chosen.cleanup, target: request.runner.target };
|
|
122
|
-
if (chosen.kind !== "chosen") {
|
|
123
|
-
const snapshotFailure = chosen.kind === "failed" ? { kind: "runner_failed", failure: chosen.failure } : undefined;
|
|
124
|
-
if (snapshotFailure !== undefined)
|
|
125
|
-
stop.abort();
|
|
126
|
-
await progress.emit({
|
|
127
|
-
kind: "lane-ended",
|
|
128
|
-
lane: "runner",
|
|
129
|
-
resource: null,
|
|
130
|
-
outcome: chosen.kind === "aborted" ? "stopped" : "failed",
|
|
131
|
-
});
|
|
132
|
-
const settled = await parts;
|
|
133
|
-
const ending = rankSetupEnd(cancelSignal.aborted, snapshotFailure, settled);
|
|
134
|
-
const thrown = settled.kind === "threw" ? { error: settled.error } : undefined;
|
|
135
|
-
return stoppedBeforeSandboxes(count, ending, [choiceCleanup], thrown, progress);
|
|
136
|
-
}
|
|
137
|
-
await progress.emit({ kind: "sandboxes-started", sandboxes: count });
|
|
138
|
-
const ran = await Promise.all(request.sandboxes.map((sandboxSpec, index) => runOneSandbox(context, {
|
|
139
|
-
sandbox: index,
|
|
140
|
-
count,
|
|
141
|
-
sandboxSpec,
|
|
142
|
-
access,
|
|
143
|
-
snapshot: chosen.snapshot,
|
|
144
|
-
request,
|
|
145
|
-
gate: gateOf(index),
|
|
75
|
+
let choiceCleanup;
|
|
76
|
+
let snapshotFailure;
|
|
77
|
+
let sandboxesResult;
|
|
78
|
+
await emitLanesStarted(instances, progress);
|
|
79
|
+
const setup = await coordinateSetup({
|
|
80
|
+
cancelSignal,
|
|
81
|
+
runResources: (stopSignal) => acquireAndSplit(instances, {
|
|
82
|
+
credential: mint,
|
|
146
83
|
cancelSignal,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
84
|
+
stopSignal,
|
|
85
|
+
progress,
|
|
86
|
+
sandboxes: count,
|
|
87
|
+
runnerCredentials: request.runner.credentials,
|
|
88
|
+
}),
|
|
89
|
+
runRunner: async (stopSignal, settledResources, stopResources) => {
|
|
90
|
+
const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
|
|
91
|
+
const chosen = await chooseSnapshotForRun(context, {
|
|
92
|
+
prepared: request.runner.prepared,
|
|
93
|
+
access,
|
|
94
|
+
user: request.runner.user,
|
|
95
|
+
credentials: request.runner.credentials,
|
|
96
|
+
}, { signal: cancelSignal, stop: stopSignal }, runnerProgress);
|
|
97
|
+
choiceCleanup = { ...chosen.cleanup, target: request.runner.target };
|
|
98
|
+
if (chosen.kind !== "chosen") {
|
|
99
|
+
snapshotFailure = chosen.kind === "failed" ? { kind: "runner_failed", failure: chosen.failure } : undefined;
|
|
100
|
+
await progress.emit({
|
|
101
|
+
kind: "lane-ended",
|
|
102
|
+
lane: "runner",
|
|
103
|
+
resource: null,
|
|
104
|
+
outcome: chosen.kind === "aborted" ? "stopped" : "failed",
|
|
105
|
+
});
|
|
106
|
+
if (snapshotFailure !== undefined)
|
|
107
|
+
return { kind: "stopped", outcome: snapshotFailure };
|
|
108
|
+
return cancelSignal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
|
|
109
|
+
}
|
|
110
|
+
const stageSignal = AbortSignal.any([cancelSignal, stopSignal]);
|
|
111
|
+
const gateOf = (index) => settledResources.then((settled) => {
|
|
112
|
+
if (settled.kind === "ready") {
|
|
113
|
+
const resources = settled.value.parts[index];
|
|
114
|
+
if (resources !== undefined)
|
|
115
|
+
return { kind: "ready", resources, credentials: settled.value.credentials };
|
|
116
|
+
}
|
|
117
|
+
return { kind: "stopped", end: gateEndFromResources(cancelSignal, settled) };
|
|
118
|
+
});
|
|
119
|
+
const tracker = sandboxFenceTracker();
|
|
120
|
+
await progress.emit({ kind: "sandboxes-started", sandboxes: count });
|
|
121
|
+
const ran = await Promise.all(request.sandboxes.map((sandboxSpec, index) => runOneSandbox(context, {
|
|
122
|
+
sandbox: index,
|
|
123
|
+
count,
|
|
124
|
+
sandboxSpec,
|
|
125
|
+
access,
|
|
126
|
+
snapshot: chosen.snapshot,
|
|
127
|
+
request,
|
|
128
|
+
gate: gateOf(index),
|
|
129
|
+
cancelSignal,
|
|
130
|
+
stageSignal,
|
|
131
|
+
tracker,
|
|
132
|
+
}, progress)));
|
|
133
|
+
// Every runner sandbox has ended; stop any still-pending resource acquire (for example when every runner sandbox
|
|
134
|
+
// failed to start before reaching the resource gate).
|
|
135
|
+
stopResources();
|
|
136
|
+
sandboxesResult = { snapshot: chosen.snapshot, ran, allFenced: tracker.allFenced() };
|
|
137
|
+
return { kind: "ready", value: sandboxesResult };
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
// An unexpected throw in the runner lane leaves `runAll` directly so `withResourceCleanup`'s `finally` fails closed
|
|
141
|
+
// with `runnerSandboxFenced: false`.
|
|
142
|
+
if (setup.kind === "threw" && setup.lane === "runner")
|
|
143
|
+
throw setup.error;
|
|
144
|
+
const finishSandboxes = (finished) => {
|
|
145
|
+
const { snapshot, ran, allFenced } = finished;
|
|
146
|
+
const sandboxes = ran.map(({ ended }) => ended);
|
|
154
147
|
const runnerCleanups = [
|
|
155
|
-
choiceCleanup,
|
|
148
|
+
...(choiceCleanup === undefined ? [] : [choiceCleanup]),
|
|
156
149
|
...sandboxes.flatMap(({ runnerCleanup }) => (runnerCleanup === null ? [] : [runnerCleanup])),
|
|
157
150
|
];
|
|
158
|
-
if (
|
|
159
|
-
return { kind: "threw", error:
|
|
151
|
+
if (setup.kind === "threw")
|
|
152
|
+
return { kind: "threw", error: setup.error, runnerSandboxesFenced: allFenced, runnerCleanups };
|
|
153
|
+
const progressFailure = ran.find((sandbox) => sandbox.progressFailure !== undefined)?.progressFailure;
|
|
160
154
|
if (progressFailure !== undefined)
|
|
161
|
-
return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced, runnerCleanups };
|
|
155
|
+
return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced: allFenced, runnerCleanups };
|
|
162
156
|
return {
|
|
163
157
|
kind: "sandboxes",
|
|
164
158
|
sandboxes,
|
|
165
|
-
snapshot
|
|
166
|
-
failed:
|
|
167
|
-
canceled: ran.some(({ canceled }) => canceled),
|
|
168
|
-
runnerSandboxesFenced,
|
|
159
|
+
snapshot,
|
|
160
|
+
failed: setup.kind === "stopped" && setup.outcome.kind !== "canceled" ? setup.outcome : undefined,
|
|
161
|
+
canceled: (setup.kind === "stopped" && setup.outcome.kind === "canceled") || ran.some(({ canceled }) => canceled),
|
|
162
|
+
runnerSandboxesFenced: allFenced,
|
|
169
163
|
runnerCleanups,
|
|
170
164
|
};
|
|
165
|
+
};
|
|
166
|
+
if (setup.kind === "ready")
|
|
167
|
+
return finishSandboxes(setup.runner);
|
|
168
|
+
if (sandboxesResult !== undefined)
|
|
169
|
+
return finishSandboxes(sandboxesResult);
|
|
170
|
+
const runnerCleanups = choiceCleanup === undefined ? [] : [choiceCleanup];
|
|
171
|
+
if (setup.kind === "threw") {
|
|
172
|
+
const ending = cancelSignal.aborted
|
|
173
|
+
? canceledStop()
|
|
174
|
+
: (snapshotFailure ?? { kind: "threw", message: errorMessage(setup.error) });
|
|
175
|
+
return stoppedBeforeSandboxes(count, ending, runnerCleanups, { error: setup.error }, progress);
|
|
171
176
|
}
|
|
172
|
-
|
|
173
|
-
stop.abort();
|
|
174
|
-
await parts;
|
|
175
|
-
throw error;
|
|
176
|
-
}
|
|
177
|
+
return stoppedBeforeSandboxes(count, setup.outcome, runnerCleanups, undefined, progress);
|
|
177
178
|
}
|
|
178
179
|
async function acquireAndSplit(instances, input) {
|
|
179
180
|
const acquisition = await acquireResources(instances, {
|
|
180
181
|
credential: input.credential,
|
|
181
|
-
|
|
182
|
+
cancelSignal: input.cancelSignal,
|
|
183
|
+
stopSignal: input.stopSignal,
|
|
182
184
|
progress: input.progress,
|
|
183
185
|
});
|
|
184
|
-
if (acquisition.kind
|
|
185
|
-
return
|
|
186
|
+
if (acquisition.kind !== "acquired")
|
|
187
|
+
return acquisition;
|
|
186
188
|
const split = splitAcquired(instances, input.sandboxes);
|
|
187
189
|
if (split.kind === "refused")
|
|
188
|
-
return { kind: "stopped",
|
|
189
|
-
// Each sandbox credential a resource gives the command, beside the run's own; a clash throws here, before any
|
|
190
|
-
// runner sandbox's command starts, and the run's release still runs.
|
|
190
|
+
return { kind: "stopped", outcome: split.outcome };
|
|
191
191
|
const credentials = resourcesCredentials(instances, input.runnerCredentials).map(({ credential }) => credential);
|
|
192
192
|
await announceAcquired(instances, input.progress);
|
|
193
|
-
return {
|
|
193
|
+
return { kind: "ready", value: { parts: split.parts, credentials } };
|
|
194
194
|
}
|
|
195
195
|
async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progress) {
|
|
196
196
|
const facts = sandboxEndFacts(end, false);
|
|
197
197
|
for (let sandbox = 0; sandbox < count; sandbox += 1)
|
|
198
198
|
await progress.emit({ kind: "sandbox-ended", sandbox, ...facts });
|
|
199
|
-
// No runner sandbox started, so none can reach what the resources took.
|
|
200
199
|
if (thrown !== undefined)
|
|
201
200
|
return { kind: "threw", error: thrown.error, runnerCleanups, runnerSandboxesFenced: true };
|
|
202
201
|
if (end.kind === "ran" || end.kind === "threw")
|
|
@@ -204,31 +203,18 @@ async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progre
|
|
|
204
203
|
return { kind: "stopped", stop: end, runnerCleanups, runnerSandboxesFenced: true };
|
|
205
204
|
}
|
|
206
205
|
async function runOneSandbox(context, input, progress) {
|
|
207
|
-
const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal } = input;
|
|
206
|
+
const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal, tracker } = input;
|
|
208
207
|
const { argv } = sandboxSpec;
|
|
209
208
|
const emitSandbox = async (event) => await progress.emit({ kind: "sandbox", sandbox, event });
|
|
210
209
|
const ownProgress = { emit: emitSandbox };
|
|
211
210
|
const runnerProgress = { emit: (event) => emitSandbox({ kind: "runner", event }) };
|
|
212
|
-
let cleanupStarted = false;
|
|
213
|
-
let fenced = false;
|
|
214
|
-
const startCleanup = async () => {
|
|
215
|
-
if (cleanupStarted)
|
|
216
|
-
return;
|
|
217
|
-
cleanupStarted = true;
|
|
218
|
-
await emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] });
|
|
219
|
-
};
|
|
220
211
|
const session = openRunnerSession({ ...context, runnerTerminal: context.sandboxTerminal(sandbox) }, { ...request.runner, snapshot: input.snapshot },
|
|
221
212
|
// The run releases the resources once, after every runner sandbox's session: each session only says whether it
|
|
222
213
|
// fenced its runner sandbox. A session that never released hasn't confirmed its fence. The scope hears only the
|
|
223
214
|
// command's cancel signal, never storm's internal sibling-stop signal.
|
|
224
215
|
{
|
|
225
216
|
signal: cancelSignal,
|
|
226
|
-
cleanup: {
|
|
227
|
-
startCleanup,
|
|
228
|
-
release: async (fence) => {
|
|
229
|
-
fenced = fence.runnerSandboxFenced;
|
|
230
|
-
},
|
|
231
|
-
},
|
|
217
|
+
cleanup: tracker.sessionCleanup(() => emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] })),
|
|
232
218
|
}, runnerProgress);
|
|
233
219
|
let commandStarted = false;
|
|
234
220
|
let end;
|
|
@@ -248,7 +234,6 @@ async function runOneSandbox(context, input, progress) {
|
|
|
248
234
|
}, ownProgress, () => {
|
|
249
235
|
commandStarted = true;
|
|
250
236
|
});
|
|
251
|
-
// Capture cancellation at the execution boundary so a signal during cleanup never rewrites a completed run.
|
|
252
237
|
canceled = cancelSignal.aborted && end.kind !== "ran";
|
|
253
238
|
runnerCleanup = await session.cleanUp();
|
|
254
239
|
await emitSandbox({
|
|
@@ -259,7 +244,7 @@ async function runOneSandbox(context, input, progress) {
|
|
|
259
244
|
});
|
|
260
245
|
}
|
|
261
246
|
catch (error) {
|
|
262
|
-
end = { kind: "threw", message:
|
|
247
|
+
end = { kind: "threw", message: errorMessage(error) };
|
|
263
248
|
canceled = cancelSignal.aborted;
|
|
264
249
|
runnerCleanup = await session.cleanUp().catch(() => runnerCleanup);
|
|
265
250
|
}
|
|
@@ -267,10 +252,10 @@ async function runOneSandbox(context, input, progress) {
|
|
|
267
252
|
const ended = { sandbox, argv, end, ...facts, runnerCleanup };
|
|
268
253
|
try {
|
|
269
254
|
await progress.emit({ kind: "sandbox-ended", sandbox, ...facts });
|
|
270
|
-
return { ended, progressFailure: undefined,
|
|
255
|
+
return { ended, progressFailure: undefined, canceled };
|
|
271
256
|
}
|
|
272
257
|
catch (error) {
|
|
273
|
-
return { ended, progressFailure: { error },
|
|
258
|
+
return { ended, progressFailure: { error }, canceled };
|
|
274
259
|
}
|
|
275
260
|
}
|
|
276
261
|
async function sandboxBody(input, progress, started) {
|
|
@@ -303,17 +288,3 @@ async function sandboxBody(input, progress, started) {
|
|
|
303
288
|
return ran.outcome;
|
|
304
289
|
return { kind: "ran", command: ran.command };
|
|
305
290
|
}
|
|
306
|
-
function runnerLaneOutcome(outcome) {
|
|
307
|
-
if (outcome.kind === "ready")
|
|
308
|
-
return "ready";
|
|
309
|
-
return outcome.kind === "aborted" ? "stopped" : "failed";
|
|
310
|
-
}
|
|
311
|
-
function mergedCleanup(target, cleanups) {
|
|
312
|
-
return {
|
|
313
|
-
kept: null,
|
|
314
|
-
notKept: null,
|
|
315
|
-
notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
|
|
316
|
-
notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted),
|
|
317
|
-
target,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { type CredentialGateway, type CredentialSource, type CredentialSourceChoice, type GitHubActionsTokenGateway, type VercelOidcTokenGateway } from "../credential/index.ts";
|
|
2
|
+
import type { RunnerCleanupFacts, RunnerContext, RunnerSession, RunnerSessionCleanup, RunnerSessionRequest, SandboxAccess } from "../runner/index.ts";
|
|
3
|
+
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
4
|
+
import type { Clock } from "../time/index.ts";
|
|
5
|
+
import type { BaseRunEvent, RunProgress } from "./events.ts";
|
|
6
|
+
import type { CommandGateway } from "./gateways.ts";
|
|
7
|
+
import { type RunStopped } from "./outcomes.ts";
|
|
8
|
+
import type { ResourceCleanupRecords, ResourceSkip } from "./resource.ts";
|
|
9
|
+
import { type ResourceInstance } from "./resources.ts";
|
|
10
|
+
import type { RanCommand } from "./timing.ts";
|
|
11
|
+
/**
|
|
12
|
+
* The gateways and seams the core reaches the outside through: the credential gateways, command execution, the
|
|
13
|
+
* runner's gateways (checkout, local snapshot index, Vercel Sandbox, terminal, and timer), and the clock. Each
|
|
14
|
+
* resource reaches the outside through its own Context instead (`ResourceContextMap`).
|
|
15
|
+
*/
|
|
16
|
+
export interface RunContext extends RunnerContext {
|
|
17
|
+
readonly clock: Clock;
|
|
18
|
+
readonly credentials: CredentialGateway;
|
|
19
|
+
readonly githubActionsTokens: GitHubActionsTokenGateway;
|
|
20
|
+
readonly vercelOidcTokens: VercelOidcTokenGateway;
|
|
21
|
+
readonly commands: CommandGateway;
|
|
22
|
+
}
|
|
23
|
+
/** Which credential source a Vercel Sandbox runner run uses: `mint` or `vercel-oidc`. */
|
|
24
|
+
export type RunnerCredentialChoice = Extract<CredentialSourceChoice, {
|
|
25
|
+
readonly source: "mint" | "vercel-oidc";
|
|
26
|
+
}>;
|
|
27
|
+
/** What a run using the Vercel Sandbox runner hands to its runner session (`RunnerSessionRequest`). */
|
|
28
|
+
export type RunRunnerRequest = RunnerSessionRequest;
|
|
29
|
+
/**
|
|
30
|
+
* How a run is stopped. `signal` aborting cancels a run before the command starts (or in any phase in a runner
|
|
31
|
+
* sandbox); `terminate` aborting sends SIGTERM to a launch-machine command.
|
|
32
|
+
*/
|
|
33
|
+
export interface RunControl {
|
|
34
|
+
readonly signal: AbortSignal;
|
|
35
|
+
readonly terminate: AbortSignal;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Shared opening events emitted at the start of every run (1 or N runner sandboxes): `started`, skips, and
|
|
39
|
+
* `runner-prepared`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function emitRunOpening(progress: RunProgress, request: {
|
|
42
|
+
readonly version: string;
|
|
43
|
+
readonly commit: string | null;
|
|
44
|
+
readonly configFile: string | null;
|
|
45
|
+
readonly skipped?: readonly ResourceSkip[];
|
|
46
|
+
readonly runner?: RunRunnerRequest | undefined;
|
|
47
|
+
}, instances: readonly ResourceInstance[]): Promise<void>;
|
|
48
|
+
/** Result of obtaining a runner credential and checking its project claims. */
|
|
49
|
+
export type MintedCredential = {
|
|
50
|
+
readonly ok: true;
|
|
51
|
+
readonly mint: CredentialSource;
|
|
52
|
+
readonly access: SandboxAccess;
|
|
53
|
+
} | {
|
|
54
|
+
readonly ok: false;
|
|
55
|
+
readonly outcome: RunStopped;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Obtains a Vercel OIDC credential for `choice` (`mint` or `vercel-oidc`) with the team and project it names
|
|
59
|
+
* (`vercelProjectSource`), and honors `signal`. Shared by 1 and N runner-sandbox runs.
|
|
60
|
+
*/
|
|
61
|
+
export declare function obtainRunnerCredential(context: RunContext, choice: RunnerCredentialChoice, signal: AbortSignal, progress: RunProgress): Promise<MintedCredential>;
|
|
62
|
+
/** Emits `lanes-started` followed by `lane-started` for every resource instance that has a lane, in order. */
|
|
63
|
+
export declare function emitLanesStarted(instances: readonly ResourceInstance[], progress: RunProgress): Promise<void>;
|
|
64
|
+
/** Outcome of the resource lane inside `coordinateSetup`. */
|
|
65
|
+
export type ResourceStageOutcome<TResources = undefined> = {
|
|
66
|
+
readonly kind: "ready";
|
|
67
|
+
readonly value: TResources;
|
|
68
|
+
} | {
|
|
69
|
+
readonly kind: "stopped";
|
|
70
|
+
readonly outcome: RunStopped;
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "canceled";
|
|
73
|
+
} | {
|
|
74
|
+
readonly kind: "internal-stopped";
|
|
75
|
+
};
|
|
76
|
+
/** Settled view of the resource lane passed to streaming runner lanes (such as multi-sandbox gates). */
|
|
77
|
+
export type SettledResourceStage<TResources = undefined> = ResourceStageOutcome<TResources> | {
|
|
78
|
+
readonly kind: "threw";
|
|
79
|
+
readonly error: unknown;
|
|
80
|
+
};
|
|
81
|
+
/** Outcome of the runner lane inside `coordinateSetup`. */
|
|
82
|
+
export type RunnerStageOutcome<TRunner> = {
|
|
83
|
+
readonly kind: "ready";
|
|
84
|
+
readonly value: TRunner;
|
|
85
|
+
} | {
|
|
86
|
+
readonly kind: "stopped";
|
|
87
|
+
readonly outcome: RunStopped;
|
|
88
|
+
} | {
|
|
89
|
+
readonly kind: "canceled";
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "internal-stopped";
|
|
92
|
+
};
|
|
93
|
+
/** Ranked outcome of concurrent resource and runner setup (`coordinateSetup`). */
|
|
94
|
+
export type SetupCoordinationOutcome<TRunner, TResources = undefined> = {
|
|
95
|
+
readonly kind: "ready";
|
|
96
|
+
readonly runner: TRunner;
|
|
97
|
+
readonly resources: TResources | undefined;
|
|
98
|
+
} | {
|
|
99
|
+
readonly kind: "stopped";
|
|
100
|
+
readonly outcome: RunStopped;
|
|
101
|
+
} | {
|
|
102
|
+
readonly kind: "threw";
|
|
103
|
+
readonly error: unknown;
|
|
104
|
+
readonly lane: "runner" | "resources";
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Runs resource setup and runner setup concurrently under a shared internal sibling-stop controller, waits for both
|
|
108
|
+
* lanes to settle, and ranks failures deterministically:
|
|
109
|
+
*
|
|
110
|
+
* 1. Throws (runner lane throw first, then resource lane throw).
|
|
111
|
+
* 2. User cancellation (`cancelSignal.aborted`).
|
|
112
|
+
* 3. Runner or snapshot failure (`runner_failed`, `snapshot_gone`).
|
|
113
|
+
* 4. Resource refusal, `mint_failed`, or split refusal.
|
|
114
|
+
* 5. Explicit cancellation (`canceled`).
|
|
115
|
+
*
|
|
116
|
+
* Passes the settled resource promise and a `stopResources` callback to `runRunner` so multi-sandbox runs can stream
|
|
117
|
+
* sandboxes from a chosen snapshot while resources acquire and split, and stop any still-pending resource acquire once
|
|
118
|
+
* all runner sandboxes have ended (an `internal-stopped` resource lane then resolves as `ready` with `resources:
|
|
119
|
+
* undefined`, not `canceled`).
|
|
120
|
+
*/
|
|
121
|
+
export declare function coordinateSetup<TRunner, TResources = undefined>(input: {
|
|
122
|
+
readonly cancelSignal: AbortSignal;
|
|
123
|
+
readonly runResources: (stopSignal: AbortSignal) => Promise<ResourceStageOutcome<TResources>>;
|
|
124
|
+
readonly runRunner: (stopSignal: AbortSignal, resources: Promise<SettledResourceStage<TResources>>, stopResources: () => void) => Promise<RunnerStageOutcome<TRunner>>;
|
|
125
|
+
}): Promise<SetupCoordinationOutcome<TRunner, TResources>>;
|
|
126
|
+
/** Result of running a command inside a ready runner sandbox, including test-event pumping. */
|
|
127
|
+
export type SandboxCommandExecution = {
|
|
128
|
+
readonly ok: true;
|
|
129
|
+
readonly command: RanCommand;
|
|
130
|
+
} | {
|
|
131
|
+
readonly ok: false;
|
|
132
|
+
readonly outcome: RunStopped;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Runs `request.argv` in `session` with `request.runPayload`, pumping test events in arrival order and mapping sandbox
|
|
136
|
+
* exit, kill, and failure outcomes into `RanCommand` or `RunStopped`. Shared by 1 and N runner-sandbox runs.
|
|
137
|
+
*/
|
|
138
|
+
export declare function runCommandInSandbox(session: RunnerSession, request: {
|
|
139
|
+
readonly argv: readonly string[];
|
|
140
|
+
readonly runPayload: string;
|
|
141
|
+
/** The sandbox credentials the run's resources give the command (`RunnerSession.runCommand`). */
|
|
142
|
+
readonly credentials?: readonly Required<SandboxCredential>[];
|
|
143
|
+
}, signal: AbortSignal, progress: {
|
|
144
|
+
emit(event: BaseRunEvent): Promise<void>;
|
|
145
|
+
}, onStarted?: () => void): Promise<SandboxCommandExecution>;
|
|
146
|
+
/**
|
|
147
|
+
* Runs `body` with idempotent `startCleanup` and `release` hooks, guarantees every acquired resource instance is
|
|
148
|
+
* released in `finally`, and returns both `body`'s result and the collected `resourceCleanup`.
|
|
149
|
+
*/
|
|
150
|
+
export declare function withResourceCleanup<T>(instances: readonly ResourceInstance[], keepMs: number | null, progress: RunProgress, body: (cleanup: RunnerSessionCleanup) => Promise<T>): Promise<{
|
|
151
|
+
readonly value: T;
|
|
152
|
+
readonly resourceCleanup: ResourceCleanupRecords;
|
|
153
|
+
}>;
|
|
154
|
+
/** Fail-closed tracker for runner-sandbox fences across N concurrent runner sessions. */
|
|
155
|
+
export interface SandboxFenceTracker {
|
|
156
|
+
sessionCleanup(onStart: () => Promise<void>): RunnerSessionCleanup;
|
|
157
|
+
allFenced(): boolean;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Creates a fail-closed multi-session fence tracker. Each call to `sessionCleanup` registers a session as unfenced
|
|
161
|
+
* (`false`) until its `release` hook confirms `fence.runnerSandboxFenced === true`, and makes `startCleanup`
|
|
162
|
+
* idempotent per session. When no session registered, `allFenced()` returns `true`.
|
|
163
|
+
*/
|
|
164
|
+
export declare function sandboxFenceTracker(): SandboxFenceTracker;
|
|
165
|
+
/** Merges per-sandbox `RunnerCleanupFacts` into one run-level cleanup summary. */
|
|
166
|
+
export declare function mergedRunnerCleanup(target: RunRunnerRequest["target"], cleanups: readonly RunnerCleanupFacts[]): RunnerCleanupFacts;
|