@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.
Files changed (290) hide show
  1. package/dist/bin/storm.js +54 -40
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-24UYAK4R.js} +465 -365
  4. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-2JMWUKH3.js} +2074 -473
  5. package/dist/chunks/{chunk-FOZWA52V.js → chunk-3VXZONGE.js} +481 -376
  6. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-55O4FCN4.js} +1 -1
  7. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  8. package/dist/chunks/chunk-AS37D43E.js +2173 -0
  9. package/dist/chunks/chunk-CQAY6GLP.js +1260 -0
  10. package/dist/chunks/chunk-DZLU7BYK.js +340 -0
  11. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  12. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-EI3XDCEI.js} +1 -1
  13. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FDUY3BNF.js} +1 -1
  14. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-GUCCYCIO.js} +4 -189
  15. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-HBI4LEMH.js} +3 -3
  16. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-K4MDQPLW.js} +1 -18
  17. package/dist/chunks/chunk-KK7PAWIZ.js +198 -0
  18. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-KQ5FXRUD.js} +18 -1
  19. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-LKXHGGGX.js} +1 -1
  20. package/dist/chunks/{chunk-P357TZAY.js → chunk-LOGHIUUB.js} +21 -18
  21. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-OEPFINFT.js} +2 -2
  22. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-OI4AP6Z7.js} +5 -5
  23. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-PMBQWVTW.js} +26 -19
  24. package/dist/chunks/chunk-SZMYIIG2.js +88 -0
  25. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-TXCOFC7N.js} +1 -1
  26. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-UXD3TVWM.js} +1 -1
  27. package/dist/chunks/{chunk-3L52KNQA.js → chunk-WNW2QXQK.js} +8 -8
  28. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  29. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-UY7BEDUN.js} +17 -13
  30. package/dist/cli.d.ts +28 -0
  31. package/dist/cli.js +64 -0
  32. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +2 -2
  33. package/dist/commands/exec/across-sandboxes-outcomes.js +3 -3
  34. package/dist/commands/exec/before-run.d.ts +123 -0
  35. package/dist/commands/exec/before-run.js +105 -0
  36. package/dist/commands/exec/command.d.ts +67 -14
  37. package/dist/commands/exec/command.js +31 -95
  38. package/dist/commands/exec/driver-plan.d.ts +9 -4
  39. package/dist/commands/exec/driver-plan.js +8 -8
  40. package/dist/commands/exec/exec-words.js +1 -1
  41. package/dist/commands/exec/execute-run.d.ts +39 -0
  42. package/dist/commands/exec/execute-run.js +325 -0
  43. package/dist/commands/exec/live-view.d.ts +3 -3
  44. package/dist/commands/exec/live-view.js +16 -15
  45. package/dist/commands/exec/metadata.js +1 -1
  46. package/dist/commands/exec/mint-failed.d.ts +38 -0
  47. package/dist/commands/exec/mint-failed.js +27 -4
  48. package/dist/commands/exec/outcomes.d.ts +104 -22
  49. package/dist/commands/exec/outcomes.js +73 -26
  50. package/dist/commands/exec/plan-run.d.ts +58 -150
  51. package/dist/commands/exec/plan-run.js +239 -90
  52. package/dist/commands/exec/progress.d.ts +10 -6
  53. package/dist/commands/exec/progress.js +38 -25
  54. package/dist/commands/exec/run-bin.d.ts +11 -11
  55. package/dist/commands/exec/run-bin.js +9 -9
  56. package/dist/commands/exec/run-flags.d.ts +69 -0
  57. package/dist/commands/exec/run-flags.js +58 -0
  58. package/dist/commands/exec/run-metadata.js +4 -4
  59. package/dist/commands/exec/run-summary.d.ts +58 -0
  60. package/dist/commands/exec/run-summary.js +205 -0
  61. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  62. package/dist/commands/exec/runner-refusals.js +71 -0
  63. package/dist/commands/exec/sandbox-progress.js +3 -0
  64. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  65. package/dist/commands/exec/stopped-outcome.js +77 -0
  66. package/dist/commands/exec/view.d.ts +20 -11
  67. package/dist/commands/exec/view.js +103 -47
  68. package/dist/commands/runs/facts.d.ts +8 -4
  69. package/dist/commands/runs/facts.js +19 -10
  70. package/dist/commands/runs/list/command.d.ts +16 -8
  71. package/dist/commands/runs/list/command.js +10 -10
  72. package/dist/commands/runs/list/outcomes.d.ts +8 -4
  73. package/dist/commands/runs/logs/command.js +10 -10
  74. package/dist/commands/runs/show/command.d.ts +16 -8
  75. package/dist/commands/runs/show/command.js +31 -29
  76. package/dist/commands/runs/show/metadata.js +1 -1
  77. package/dist/commands/runs/show/outcomes.d.ts +8 -4
  78. package/dist/commands/runs/show/outcomes.js +8 -6
  79. package/dist/commands/snapshots/access.d.ts +111 -0
  80. package/dist/commands/snapshots/access.js +96 -0
  81. package/dist/commands/snapshots/build/command.d.ts +376 -101
  82. package/dist/commands/snapshots/build/command.js +447 -149
  83. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  84. package/dist/commands/snapshots/build/metadata.js +31 -11
  85. package/dist/commands/snapshots/build/outcomes.d.ts +242 -47
  86. package/dist/commands/snapshots/build/outcomes.js +200 -36
  87. package/dist/commands/snapshots/list/command.d.ts +368 -27
  88. package/dist/commands/snapshots/list/command.js +298 -68
  89. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  90. package/dist/commands/snapshots/list/metadata.js +29 -6
  91. package/dist/commands/snapshots/list/outcomes.d.ts +247 -15
  92. package/dist/commands/snapshots/list/outcomes.js +223 -52
  93. package/dist/commands/snapshots/metadata.js +1 -1
  94. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  95. package/dist/commands/snapshots/prune/command.js +161 -0
  96. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  97. package/dist/commands/snapshots/prune/metadata.js +39 -0
  98. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  99. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  100. package/dist/commands/suites/list/command.js +17 -17
  101. package/dist/commands/suites/list/outcomes.js +2 -2
  102. package/dist/commands/test/command.d.ts +67 -14
  103. package/dist/commands/test/command.js +49 -252
  104. package/dist/commands/test/outcomes.d.ts +33 -7
  105. package/dist/config/check-runner.d.ts +3 -3
  106. package/dist/config/check-runner.js +8 -7
  107. package/dist/config/credential-resolver.d.ts +50 -5
  108. package/dist/config/credential-resolver.js +51 -19
  109. package/dist/config/credential-settle.d.ts +6 -2
  110. package/dist/config/credential-settle.js +11 -5
  111. package/dist/config/index.d.ts +2 -2
  112. package/dist/config/index.js +1 -1
  113. package/dist/config/runner.d.ts +5 -5
  114. package/dist/config/runner.js +1 -1
  115. package/dist/config/schema.d.ts +2 -2
  116. package/dist/config/schema.js +1 -1
  117. package/dist/config-file/define.d.ts +1 -1
  118. package/dist/config-file/define.js +1 -1
  119. package/dist/config-file/runner.d.ts +5 -5
  120. package/dist/config-file/toolchain.d.ts +14 -4
  121. package/dist/config-file/toolchain.js +43 -7
  122. package/dist/context.d.ts +10 -6
  123. package/dist/context.js +8 -6
  124. package/dist/core/across-sandboxes.d.ts +7 -6
  125. package/dist/core/across-sandboxes.js +123 -152
  126. package/dist/core/coordinator.d.ts +166 -0
  127. package/dist/core/coordinator.js +233 -0
  128. package/dist/core/events.d.ts +2 -2
  129. package/dist/core/index.d.ts +4 -2
  130. package/dist/core/index.js +1 -1
  131. package/dist/core/outcomes.d.ts +148 -0
  132. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  133. package/dist/core/resources.d.ts +31 -53
  134. package/dist/core/resources.js +32 -70
  135. package/dist/core/run-state.d.ts +7 -1
  136. package/dist/core/run-state.js +2 -0
  137. package/dist/core/run.d.ts +32 -236
  138. package/dist/core/run.js +107 -267
  139. package/dist/core/state-directory.d.ts +1 -1
  140. package/dist/core/state-directory.js +2 -2
  141. package/dist/credential/gateways.d.ts +15 -1
  142. package/dist/credential/index.d.ts +4 -3
  143. package/dist/credential/index.js +3 -2
  144. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  145. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  146. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  147. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  148. package/dist/credential/source.d.ts +73 -6
  149. package/dist/credential/source.js +55 -2
  150. package/dist/extension-commands.d.ts +1 -1
  151. package/dist/extension-commands.js +2 -2
  152. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  153. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  154. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  155. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  156. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  157. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  158. package/dist/extensions/testserver/credential-facts.js +29 -11
  159. package/dist/extensions/testserver/lifecycle.js +7 -1
  160. package/dist/extensions/testserver/limit.d.ts +3 -0
  161. package/dist/extensions/testserver/limit.js +3 -0
  162. package/dist/extensions/testserver/provision.d.ts +8 -1
  163. package/dist/extensions/testserver/provision.js +8 -3
  164. package/dist/extensions/testserver/refusals.d.ts +6 -1
  165. package/dist/extensions/testserver/refusals.js +16 -1
  166. package/dist/extensions/testserver/resource.d.ts +1 -1
  167. package/dist/extensions/testserver/resource.js +1 -1
  168. package/dist/extensions/testserver/result.d.ts +1 -1
  169. package/dist/extensions/testserver/result.js +9 -4
  170. package/dist/planning/driver-file-lists.d.ts +0 -15
  171. package/dist/planning/driver-file-lists.js +2 -21
  172. package/dist/planning/plan-only.d.ts +3 -14
  173. package/dist/planning/plan-only.js +11 -20
  174. package/dist/planning/run-kind-flags.js +2 -2
  175. package/dist/planning/run-plan.d.ts +45 -12
  176. package/dist/planning/run-plan.js +4 -3
  177. package/dist/planning/suites.d.ts +1 -1
  178. package/dist/planning/suites.js +2 -2
  179. package/dist/planning/test-plan.d.ts +9 -0
  180. package/dist/planning/test-plan.js +9 -0
  181. package/dist/run-directory/recording.js +3 -3
  182. package/dist/run-directory/run-record.d.ts +26 -11
  183. package/dist/run-directory/run-record.js +16 -13
  184. package/dist/runner/base.js +1 -1
  185. package/dist/runner/build-snapshots.d.ts +60 -29
  186. package/dist/runner/build-snapshots.js +136 -29
  187. package/dist/runner/context.d.ts +15 -7
  188. package/dist/runner/context.js +19 -6
  189. package/dist/runner/events.d.ts +16 -10
  190. package/dist/runner/gateways.d.ts +122 -23
  191. package/dist/runner/gateways.js +1 -1
  192. package/dist/runner/gh.d.ts +42 -0
  193. package/dist/runner/gh.js +58 -0
  194. package/dist/runner/index.d.ts +13 -8
  195. package/dist/runner/index.js +12 -6
  196. package/dist/runner/live/checkout-gateway.js +7 -0
  197. package/dist/runner/live/gh-output.d.ts +17 -0
  198. package/dist/runner/live/gh-output.js +37 -0
  199. package/dist/runner/live/gh-token-gateway.d.ts +13 -0
  200. package/dist/runner/live/gh-token-gateway.js +51 -0
  201. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  202. package/dist/runner/live/sandbox-errors.js +4 -0
  203. package/dist/runner/live/sandbox-gateway.js +140 -4
  204. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  205. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  206. package/dist/runner/live/snapshot-records.js +12 -12
  207. package/dist/runner/local-snapshot-index.d.ts +205 -0
  208. package/dist/runner/local-snapshot-index.js +210 -0
  209. package/dist/runner/network-policy.d.ts +6 -6
  210. package/dist/runner/network-policy.js +7 -7
  211. package/dist/runner/policy-writes.d.ts +1 -1
  212. package/dist/runner/policy-writes.js +1 -1
  213. package/dist/runner/prepare.d.ts +14 -14
  214. package/dist/runner/prepare.js +20 -11
  215. package/dist/runner/ready.d.ts +19 -11
  216. package/dist/runner/ready.js +104 -33
  217. package/dist/runner/sandboxed-command.d.ts +3 -3
  218. package/dist/runner/sandboxed-command.js +3 -3
  219. package/dist/runner/scope.d.ts +15 -8
  220. package/dist/runner/scope.js +16 -5
  221. package/dist/runner/secrets.d.ts +41 -18
  222. package/dist/runner/secrets.js +226 -30
  223. package/dist/runner/session.d.ts +8 -8
  224. package/dist/runner/session.js +6 -3
  225. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  226. package/dist/runner/shared-snapshot-entry.js +168 -0
  227. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  228. package/dist/runner/shared-snapshot-list.js +155 -0
  229. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  230. package/dist/runner/shared-snapshot-lookup.js +118 -0
  231. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  232. package/dist/runner/shared-snapshot-prune.js +133 -0
  233. package/dist/runner/snapshot-build.d.ts +42 -14
  234. package/dist/runner/snapshot-build.js +79 -47
  235. package/dist/runner/snapshot-choice.js +2 -1
  236. package/dist/runner/snapshot-inspect.d.ts +39 -40
  237. package/dist/runner/snapshot-inspect.js +52 -35
  238. package/dist/runner/snapshot-key.d.ts +32 -17
  239. package/dist/runner/snapshot-key.js +43 -18
  240. package/dist/runner/snapshot-source.d.ts +31 -0
  241. package/dist/runner/snapshot-source.js +122 -0
  242. package/dist/runner/steps.d.ts +1 -1
  243. package/dist/runner/steps.js +1 -1
  244. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +4 -2
  245. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +7 -2
  246. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +59 -28
  247. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +128 -84
  248. package/dist/runner/vercel-sandbox-secrets.d.ts +116 -0
  249. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +159 -26
  250. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  251. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  252. package/dist/sdk/extension/credential-source.d.ts +20 -3
  253. package/dist/sdk/extension/credential-source.js +4 -4
  254. package/dist/sdk/extension/index.d.ts +3 -2
  255. package/dist/sdk/extension/index.js +2 -1
  256. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  257. package/dist/sdk/extension/secret-source.d.ts +1 -1
  258. package/dist/sdk/extension/secret-source.js +1 -1
  259. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  260. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  261. package/dist/shared/cleanup.d.ts +3 -3
  262. package/dist/shared/cleanup.js +15 -5
  263. package/dist/shared/snapshot-text.d.ts +4 -4
  264. package/dist/shared/snapshot-text.js +11 -11
  265. package/dist/time/duration.js +1 -1
  266. package/package.json +5 -3
  267. package/skills/overview.md +4 -4
  268. package/skills/plan-runs.md +1 -1
  269. package/skills/read-run-output.md +6 -6
  270. package/dist/application.d.ts +0 -21
  271. package/dist/application.js +0 -30
  272. package/dist/chunks/chunk-7EENF73W.js +0 -782
  273. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  274. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  275. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  276. package/dist/commands/exec/plan-only.d.ts +0 -10
  277. package/dist/commands/exec/plan-only.js +0 -45
  278. package/dist/commands/exec/run-command.d.ts +0 -475
  279. package/dist/commands/exec/run-command.js +0 -603
  280. package/dist/commands/exec/run-planned.d.ts +0 -20
  281. package/dist/commands/exec/run-planned.js +0 -22
  282. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  283. package/dist/commands/exec/sandbox-view.js +0 -72
  284. package/dist/commands/test/plan.d.ts +0 -92
  285. package/dist/commands/test/plan.js +0 -125
  286. package/dist/core/sandbox-end.d.ts +0 -64
  287. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  288. package/dist/runner/recipe-secrets.d.ts +0 -67
  289. package/dist/runner/snapshot-cache.d.ts +0 -148
  290. package/dist/runner/snapshot-cache.js +0 -126
@@ -7,11 +7,13 @@ import {
7
7
  openRunnerSession,
8
8
  parseTestEvent,
9
9
  systemClock,
10
- systemTimer
11
- } from "./chunk-DC2CDHNK.js";
10
+ systemTimer,
11
+ vercelProjectSource
12
+ } from "./chunk-2JMWUKH3.js";
12
13
  import {
13
- describeMintFailure
14
- } from "./chunk-AWBSONHB.js";
14
+ describeMintFailure,
15
+ describeVercelOidcTokenFailure
16
+ } from "./chunk-XBDRVFEV.js";
15
17
 
16
18
  // src/core/reports.ts
17
19
  var WARNINGS_HEADING = "Warnings";
@@ -455,7 +457,8 @@ function applyRunnerEvent(state, event, at) {
455
457
  kind: "reused",
456
458
  id: event.snapshotId,
457
459
  base: event.base,
458
- builtBehind: event.builtBehind
460
+ builtBehind: event.builtBehind,
461
+ source: event.source
459
462
  }
460
463
  })
461
464
  );
@@ -519,6 +522,7 @@ function applyRunnerEvent(state, event, at) {
519
522
  case "output-started":
520
523
  case "output-ended":
521
524
  case "snapshot-entry-not-written":
525
+ case "shared-snapshot-lookup-failed":
522
526
  case "command-output-started":
523
527
  return state;
524
528
  }
@@ -993,36 +997,149 @@ var livePackageBinGateway = {
993
997
  }
994
998
  };
995
999
 
996
- // src/core/run.ts
997
- import { posix } from "node:path";
998
-
999
- // src/core/payload.ts
1000
- function runPayload(resources, options = {}) {
1001
- return {
1002
- version: 3,
1003
- resources,
1004
- ...options.testEvents === void 0 ? {} : { testEvents: options.testEvents },
1005
- ...options.verbose === true ? { verbose: true } : {},
1006
- ...options.sandbox === void 0 ? {} : { sandbox: options.sandbox }
1007
- };
1000
+ // src/core/outcomes.ts
1001
+ function canceledStop() {
1002
+ return { kind: "canceled" };
1008
1003
  }
1009
- function commandEnvironment(env, payload) {
1010
- const kept = Object.entries(env).filter((pair) => pair[1] !== void 0);
1011
- return { ...Object.fromEntries(kept), [RUN_PAYLOAD_VARIABLE]: JSON.stringify(payload) };
1004
+ function runnerLaneOutcome(outcome) {
1005
+ if (outcome.kind === "ready") return "ready";
1006
+ return outcome.kind === "aborted" ? "stopped" : "failed";
1012
1007
  }
1013
- function colorEnvironment(env, color) {
1014
- if (env["FORCE_COLOR"] !== void 0 || env["NO_COLOR"] !== void 0) return env;
1015
- if (color === "on") return { ...env, FORCE_COLOR: "1" };
1016
- if (color === "off") return { ...env, NO_COLOR: "1" };
1017
- return env;
1008
+ function runnerStopped(outcome) {
1009
+ if (outcome.kind === "failed") return { kind: "runner_failed", failure: outcome.failure };
1010
+ if (outcome.kind === "snapshot-gone")
1011
+ return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
1012
+ return void 0;
1013
+ }
1014
+ function acrossSandboxesExitStatus(sandboxes) {
1015
+ return sandboxes.every(({ state }) => state === "passed") ? 0 : 1;
1016
+ }
1017
+ function sandboxEndFacts(end, commandStarted) {
1018
+ const short = (cause, failedStage, started = commandStarted) => ({
1019
+ state: started ? "failed" : "not-started",
1020
+ failedStage,
1021
+ exitCode: null,
1022
+ cause: oneLine(cause)
1023
+ });
1024
+ switch (end.kind) {
1025
+ case "ran": {
1026
+ const { command } = end;
1027
+ if (command.kind === "exited")
1028
+ return {
1029
+ state: command.code === 0 ? "passed" : "failed",
1030
+ failedStage: command.code === 0 ? null : "command",
1031
+ exitCode: command.code,
1032
+ cause: null
1033
+ };
1034
+ return {
1035
+ state: "failed",
1036
+ failedStage: "command",
1037
+ exitCode: null,
1038
+ cause: command.kind === "signaled" ? `signaled: ${command.signal}` : "no-exit-code"
1039
+ };
1040
+ }
1041
+ case "canceled":
1042
+ return { state: "canceled", failedStage: null, exitCode: null, cause: "canceled" };
1043
+ case "runner_failed": {
1044
+ const { failure } = end;
1045
+ const ranCommand = failure.kind === "sandbox-api-failed" && failure.operation === "run-command";
1046
+ return short(runnerFailureCause(failure), runnerFailureStage(failure), commandStarted || ranCommand);
1047
+ }
1048
+ case "mint_failed":
1049
+ return short(`mint-failed: ${describeMintFailure(end.failure, end.target).cause}`, "mint");
1050
+ case "vercel_oidc_token_failed":
1051
+ return short(`vercel-oidc-token-failed: ${describeVercelOidcTokenFailure(end.failure).cause}`, "mint");
1052
+ case "snapshot_gone":
1053
+ return short("snapshot-gone", "snapshot");
1054
+ case "spawn_failed":
1055
+ return short(`spawn-failed: ${end.message}`, "command");
1056
+ case "resource_refused":
1057
+ return short(`resource-refused: ${end.resource}: ${end.refusal.message}`, "resource");
1058
+ case "threw":
1059
+ return short(`threw: ${end.message}`, "storm");
1060
+ }
1061
+ }
1062
+ function runnerFailureStage(failure) {
1063
+ switch (failure.kind) {
1064
+ case "snapshot-build-step-failed":
1065
+ return "snapshot";
1066
+ case "apply-failed":
1067
+ return "apply";
1068
+ case "install-failed":
1069
+ return "install";
1070
+ case "build-failed":
1071
+ return "build";
1072
+ case "checkout-failed":
1073
+ return "checkout";
1074
+ case "credential-claims-missing":
1075
+ return "mint";
1076
+ case "sandbox-api-failed":
1077
+ switch (failure.operation) {
1078
+ case "start-build-sandbox":
1079
+ case "save-snapshot":
1080
+ case "get-named-sandbox":
1081
+ case "get-snapshot":
1082
+ case "delete-named-sandbox":
1083
+ return "snapshot";
1084
+ case "start-runner-sandbox":
1085
+ case "login-path":
1086
+ case "run-script":
1087
+ return "start";
1088
+ case "upload":
1089
+ return "upload";
1090
+ case "run-command":
1091
+ return "command";
1092
+ }
1093
+ // A policy write fails at the stage it guards: a snapshot build's steps or save, the install and build steps, or
1094
+ // the command.
1095
+ case "network-policy-failed":
1096
+ switch (failure.around) {
1097
+ case "snapshot-steps":
1098
+ case "snapshot-save":
1099
+ return "snapshot";
1100
+ case "run-steps":
1101
+ return "install";
1102
+ case "command":
1103
+ return "command";
1104
+ }
1105
+ }
1106
+ }
1107
+ function runnerFailureCause(failure) {
1108
+ switch (failure.kind) {
1109
+ case "sandbox-api-failed":
1110
+ return `${failure.operation}: ${failure.message}`;
1111
+ case "checkout-failed":
1112
+ return `checkout-failed: ${failure.failure.message}`;
1113
+ case "credential-claims-missing":
1114
+ return `credential-claims-missing: ${failure.target.team}/${failure.target.project}`;
1115
+ case "snapshot-build-step-failed":
1116
+ case "apply-failed":
1117
+ case "install-failed":
1118
+ case "build-failed":
1119
+ return `${failure.kind}: ${failure.exitCode === null ? "no exit code" : `exited ${failure.exitCode}`}`;
1120
+ case "network-policy-failed":
1121
+ return `network-policy-failed: ${failure.operation} around ${failure.around}: ${failure.status === null ? "" : `HTTP ${failure.status}: `}${failure.message}`;
1122
+ }
1123
+ }
1124
+ function oneLine(text) {
1125
+ return text.trim().replace(/\s*\n\s*/g, " ");
1018
1126
  }
1019
1127
 
1128
+ // src/core/run.ts
1129
+ import { posix as posix2 } from "node:path";
1130
+
1131
+ // src/core/coordinator.ts
1132
+ import { posix } from "node:path";
1133
+
1020
1134
  // src/core/resources.ts
1021
1135
  function resourceInstances({ named }, resourceContexts2, requests) {
1022
1136
  return Object.entries(requests).map(
1023
1137
  ([key, request]) => instanceOf(named(request.definition, key), key, resourceContexts2, request)
1024
1138
  );
1025
1139
  }
1140
+ async function startResourceLanes(instances, progress) {
1141
+ for (const instance of instances) await instance.startLane(progress);
1142
+ }
1026
1143
  function instanceOf(resource, key, resourceContexts2, request) {
1027
1144
  const { name } = resource;
1028
1145
  const lifecycle = resource.lifecycle(resourceContexts2[name]);
@@ -1123,9 +1240,9 @@ function instanceOf(resource, key, resourceContexts2, request) {
1123
1240
  };
1124
1241
  }
1125
1242
  async function acquireResources(instances, input) {
1126
- const { progress, beside } = input;
1243
+ const { progress, cancelSignal, stopSignal } = input;
1127
1244
  const internal = new AbortController();
1128
- const signal = AbortSignal.any([input.signal, internal.signal]);
1245
+ const signal = stopSignal === void 0 ? AbortSignal.any([cancelSignal, internal.signal]) : AbortSignal.any([cancelSignal, stopSignal, internal.signal]);
1129
1246
  const finishLane = async (lane, task, outcomeOf2) => {
1130
1247
  let value;
1131
1248
  let outcome;
@@ -1142,36 +1259,25 @@ async function acquireResources(instances, input) {
1142
1259
  if (outcome !== "ready") internal.abort();
1143
1260
  return value;
1144
1261
  };
1145
- for (const instance of instances) await instance.startLane(progress);
1146
1262
  const instanceTasks = instances.map(
1147
1263
  (instance) => instance.acquire({ signal, credential: input.credential, progress, finishLane })
1148
1264
  );
1149
- const besideTask = beside === void 0 ? Promise.resolve(void 0) : finishLane(beside.lane, beside.start(signal), beside.outcomeOf);
1150
- const [[besideEnded], instancesEnded] = await Promise.all([
1151
- Promise.allSettled([besideTask]),
1152
- Promise.allSettled(instanceTasks)
1153
- ]);
1154
- if (besideEnded.status === "rejected") throw besideEnded.reason;
1265
+ const instancesEnded = await Promise.allSettled(instanceTasks);
1155
1266
  const outcomes = [];
1156
1267
  for (const one of instancesEnded) {
1157
1268
  if (one.status === "rejected") throw one.reason;
1158
1269
  outcomes.push(one.value);
1159
1270
  }
1160
- if (input.signal.aborted) return { kind: "stopped", outcome: canceledStop() };
1161
- const besideValue = besideEnded.value;
1162
- const besideStopped = besideValue === void 0 ? void 0 : beside?.stopped(besideValue);
1163
- if (besideStopped !== void 0) return { kind: "stopped", outcome: besideStopped };
1164
- for (const outcome of outcomes) if (outcome?.kind === "refused") return { kind: "stopped", outcome: outcome.outcome };
1165
- if (outcomes.some((outcome) => outcome?.kind === "canceled")) return { kind: "stopped", outcome: canceledStop() };
1166
- return { kind: "acquired", beside: besideValue };
1271
+ if (cancelSignal.aborted) return { kind: "canceled" };
1272
+ for (const outcome of outcomes) if (outcome.kind === "refused") return { kind: "stopped", outcome: outcome.outcome };
1273
+ if (stopSignal?.aborted) return { kind: "internal-stopped" };
1274
+ if (outcomes.some((outcome) => outcome.kind === "canceled")) return { kind: "canceled" };
1275
+ return { kind: "acquired" };
1167
1276
  }
1168
1277
  function resourceLaneOutcome(result) {
1169
1278
  if ("acquired" in result) return "ready";
1170
1279
  return "canceled" in result ? "stopped" : "failed";
1171
1280
  }
1172
- function canceledStop() {
1173
- return { kind: "canceled" };
1174
- }
1175
1281
  async function announceAcquired(instances, progress) {
1176
1282
  for (const instance of instances) for (const event of instance.acquired()) await progress.emit(event);
1177
1283
  }
@@ -1252,7 +1358,7 @@ function resourceWarnings(cleanup) {
1252
1358
  return Object.values(cleanup).reduce((sum, { warnings }) => sum + warnings.length, 0);
1253
1359
  }
1254
1360
 
1255
- // src/core/run.ts
1361
+ // src/core/coordinator.ts
1256
1362
  async function emitRunOpening(progress, request, instances) {
1257
1363
  await progress.emit({
1258
1364
  kind: "started",
@@ -1273,28 +1379,76 @@ async function emitRunOpening(progress, request, instances) {
1273
1379
  });
1274
1380
  }
1275
1381
  }
1276
- async function mintCredential(context, target, signal, progress) {
1382
+ async function obtainRunnerCredential(context, choice, signal, progress) {
1277
1383
  const canceled = () => ({ ...canceledStop(), commandStopped: false });
1278
1384
  if (signal.aborted) return { ok: false, outcome: canceled() };
1279
- const mint = credentialSourceFor({ source: "mint", target }, context, progress);
1280
- const minted = await mint.obtain();
1281
- if (!minted.ok)
1282
- return { ok: false, outcome: { kind: "mint_failed", failure: minted.failure.failure, target, runner: true } };
1283
- const project = minted.credential.vercelProject();
1284
- if (project === void 0)
1285
- return {
1286
- ok: false,
1287
- outcome: { kind: "runner_failed", failure: { kind: "credential-claims-missing", target } }
1288
- };
1385
+ const { source, obtain } = vercelProjectSource(choice, context, progress);
1386
+ const obtained = await obtain();
1387
+ if (!obtained.ok) {
1388
+ const { failure } = obtained;
1389
+ switch (failure.source) {
1390
+ case "mint":
1391
+ return {
1392
+ ok: false,
1393
+ outcome: { kind: "mint_failed", failure: failure.failure, target: failure.target, runner: true }
1394
+ };
1395
+ case "vercel-oidc":
1396
+ return { ok: false, outcome: { kind: "vercel_oidc_token_failed", failure: failure.failure, runner: true } };
1397
+ case "claims-missing":
1398
+ return {
1399
+ ok: false,
1400
+ outcome: { kind: "runner_failed", failure: { kind: "credential-claims-missing", target: failure.target } }
1401
+ };
1402
+ }
1403
+ }
1289
1404
  if (signal.aborted) return { ok: false, outcome: canceled() };
1290
- return { ok: true, mint, access: { credential: minted.credential, ...project } };
1405
+ return { ok: true, mint: source, access: { credential: obtained.credential, ...obtained.project } };
1406
+ }
1407
+ async function emitLanesStarted(instances, progress) {
1408
+ await progress.emit({ kind: "lanes-started" });
1409
+ await startResourceLanes(instances, progress);
1410
+ }
1411
+ async function coordinateSetup(input) {
1412
+ const stop = new AbortController();
1413
+ const stopResources = () => stop.abort();
1414
+ const settledResources = input.runResources(stop.signal).then(
1415
+ (outcome) => {
1416
+ if (outcome.kind !== "ready" && outcome.kind !== "internal-stopped") stop.abort();
1417
+ return outcome;
1418
+ },
1419
+ (error) => {
1420
+ stop.abort();
1421
+ return { kind: "threw", error };
1422
+ }
1423
+ );
1424
+ const settledRunner = input.runRunner(stop.signal, settledResources, stopResources).then(
1425
+ (outcome) => {
1426
+ if (outcome.kind !== "ready" && outcome.kind !== "internal-stopped") stop.abort();
1427
+ return outcome;
1428
+ },
1429
+ (error) => {
1430
+ stop.abort();
1431
+ return { kind: "threw", error };
1432
+ }
1433
+ );
1434
+ const [runner, resources] = await Promise.all([settledRunner, settledResources]);
1435
+ if (runner.kind === "threw") return { kind: "threw", error: runner.error, lane: "runner" };
1436
+ if (resources.kind === "threw") return { kind: "threw", error: resources.error, lane: "resources" };
1437
+ if (input.cancelSignal.aborted) return { kind: "stopped", outcome: canceledStop() };
1438
+ if (runner.kind === "stopped") return { kind: "stopped", outcome: runner.outcome };
1439
+ if (resources.kind === "stopped") return { kind: "stopped", outcome: resources.outcome };
1440
+ if (runner.kind === "ready" && resources.kind === "ready")
1441
+ return { kind: "ready", runner: runner.value, resources: resources.value };
1442
+ if (runner.kind === "ready" && resources.kind === "internal-stopped")
1443
+ return { kind: "ready", runner: runner.value, resources: void 0 };
1444
+ return { kind: "stopped", outcome: canceledStop() };
1291
1445
  }
1292
1446
  async function runCommandInSandbox(session, request, signal, progress, onStarted) {
1293
1447
  await progress.emit({ kind: "command-started", argv: request.argv });
1294
1448
  if (signal.aborted) return { ok: false, outcome: { ...canceledStop(), commandStopped: false } };
1295
1449
  onStarted?.();
1296
1450
  let testEvents = Promise.resolve();
1297
- const sandboxed = await session.runCommand({
1451
+ const ended = await session.runCommand({
1298
1452
  argv: request.argv,
1299
1453
  runPayload: request.runPayload,
1300
1454
  ...request.credentials === void 0 ? {} : { credentials: request.credentials },
@@ -1311,15 +1465,15 @@ async function runCommandInSandbox(session, request, signal, progress, onStarted
1311
1465
  }
1312
1466
  });
1313
1467
  await testEvents;
1314
- if (sandboxed.kind === "killed" || sandboxed.kind === "failed" && signal.aborted)
1468
+ if (ended.kind === "killed" || ended.kind === "failed" && signal.aborted)
1315
1469
  return { ok: false, outcome: { ...canceledStop(), commandStopped: true } };
1316
- if (sandboxed.kind === "failed") return { ok: false, outcome: { kind: "runner_failed", failure: sandboxed.failure } };
1317
- const command = sandboxed.exitCode === null ? { kind: "no-exit-code" } : { kind: "exited", code: sandboxed.exitCode };
1470
+ if (ended.kind === "failed") return { ok: false, outcome: { kind: "runner_failed", failure: ended.failure } };
1471
+ const command = ended.exitCode === null ? { kind: "no-exit-code" } : { kind: "exited", code: ended.exitCode };
1318
1472
  await progress.emit({
1319
1473
  kind: "command-ended",
1320
1474
  command: posix.basename(request.argv[0] ?? ""),
1321
1475
  outcome: command,
1322
- ms: sandboxed.ms
1476
+ ms: ended.ms
1323
1477
  });
1324
1478
  return { ok: true, command };
1325
1479
  }
@@ -1347,19 +1501,100 @@ async function withResourceCleanup(instances, keepMs, progress, body) {
1347
1501
  }
1348
1502
  return { value, resourceCleanup };
1349
1503
  }
1504
+ function sandboxFenceTracker() {
1505
+ const sessions = [];
1506
+ return {
1507
+ sessionCleanup(onStart) {
1508
+ const entry = { fenced: false };
1509
+ sessions.push(entry);
1510
+ let cleanupStarted = false;
1511
+ return {
1512
+ startCleanup: async () => {
1513
+ if (cleanupStarted) return;
1514
+ cleanupStarted = true;
1515
+ await onStart();
1516
+ },
1517
+ release: async (fence) => {
1518
+ entry.fenced = fence.runnerSandboxFenced;
1519
+ }
1520
+ };
1521
+ },
1522
+ allFenced: () => sessions.every(({ fenced }) => fenced)
1523
+ };
1524
+ }
1525
+ function mergedRunnerCleanup(target, cleanups) {
1526
+ return {
1527
+ kept: null,
1528
+ notKept: null,
1529
+ notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
1530
+ notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted),
1531
+ target
1532
+ };
1533
+ }
1534
+
1535
+ // src/core/payload.ts
1536
+ function runPayload(resources, options = {}) {
1537
+ return {
1538
+ version: 3,
1539
+ resources,
1540
+ ...options.testEvents === void 0 ? {} : { testEvents: options.testEvents },
1541
+ ...options.verbose === true ? { verbose: true } : {},
1542
+ ...options.sandbox === void 0 ? {} : { sandbox: options.sandbox }
1543
+ };
1544
+ }
1545
+ function commandEnvironment(env, payload) {
1546
+ const kept = Object.entries(env).filter((pair) => pair[1] !== void 0);
1547
+ return { ...Object.fromEntries(kept), [RUN_PAYLOAD_VARIABLE]: JSON.stringify(payload) };
1548
+ }
1549
+ function colorEnvironment(env, color) {
1550
+ if (env["FORCE_COLOR"] !== void 0 || env["NO_COLOR"] !== void 0) return env;
1551
+ if (color === "on") return { ...env, FORCE_COLOR: "1" };
1552
+ if (color === "off") return { ...env, NO_COLOR: "1" };
1553
+ return env;
1554
+ }
1555
+
1556
+ // src/core/run.ts
1350
1557
  async function executeRun(definitionSet, context, resourceContexts2, request, control, progress) {
1351
1558
  const instances = resourceInstances(definitionSet[LOOKUP], resourceContexts2, request.resources);
1352
- await emitRunOpening(progress, request, instances);
1353
- const keepMs = request.runner === void 0 ? null : request.runner.keepMs;
1559
+ await emitRunOpening(
1560
+ progress,
1561
+ {
1562
+ version: request.version,
1563
+ commit: request.commit,
1564
+ configFile: request.configFile,
1565
+ ...request.skipped === void 0 ? {} : { skipped: request.skipped },
1566
+ ...request.runner.kind === "vercel-sandbox" ? { runner: request.runner.session } : {}
1567
+ },
1568
+ instances
1569
+ );
1570
+ const keepMs = request.runner.kind === "vercel-sandbox" ? request.runner.session.keepMs : null;
1354
1571
  const {
1355
1572
  value: { ended, runnerCleanup },
1356
1573
  resourceCleanup
1357
- } = await withResourceCleanup(
1358
- instances,
1359
- keepMs,
1360
- progress,
1361
- async (cleanup) => request.runner === void 0 ? { ended: await runUnsandboxed(context, request, instances, control, progress), runnerCleanup: null } : await runSandboxed(context, request, instances, control, progress, cleanup)
1362
- );
1574
+ } = await withResourceCleanup(instances, keepMs, progress, async (cleanup) => {
1575
+ switch (request.runner.kind) {
1576
+ case "launch-machine":
1577
+ return {
1578
+ ended: await runOnLaunchMachine(context, request.runner, {
1579
+ argv: request.argv,
1580
+ verbose: request.verbose,
1581
+ instances,
1582
+ control,
1583
+ progress
1584
+ }),
1585
+ runnerCleanup: null
1586
+ };
1587
+ case "vercel-sandbox":
1588
+ return await runInVercelSandboxSession(context, request.runner, {
1589
+ argv: request.argv,
1590
+ verbose: request.verbose,
1591
+ instances,
1592
+ control,
1593
+ progress,
1594
+ cleanup
1595
+ });
1596
+ }
1597
+ });
1363
1598
  await progress.emit({
1364
1599
  kind: "cleanup-finished",
1365
1600
  resourceWarnings: resourceWarnings(resourceCleanup),
@@ -1375,13 +1610,16 @@ async function executeRun(definitionSet, context, resourceContexts2, request, co
1375
1610
  resourceCleanup
1376
1611
  };
1377
1612
  }
1378
- async function runUnsandboxed(context, request, instances, control, progress) {
1613
+ async function runOnLaunchMachine(context, runner, input) {
1614
+ const { argv, verbose, instances, control, progress } = input;
1615
+ await startResourceLanes(instances, progress);
1379
1616
  const acquisition = await acquireResources(instances, {
1380
- credential: request.credential === void 0 ? void 0 : credentialSourceFor(request.credential, context, progress),
1381
- signal: control.signal,
1617
+ credential: runner.credential === void 0 ? void 0 : credentialSourceFor(runner.credential, context, progress),
1618
+ cancelSignal: control.signal,
1382
1619
  progress
1383
1620
  });
1384
1621
  if (acquisition.kind === "stopped") return acquisition.outcome;
1622
+ if (acquisition.kind !== "acquired") return canceledStop();
1385
1623
  const crediting = resourcesCredentials(instances);
1386
1624
  if (crediting.length > 0)
1387
1625
  throw new Error(
@@ -1390,13 +1628,13 @@ async function runUnsandboxed(context, request, instances, control, progress) {
1390
1628
  await announceAcquired(instances, progress);
1391
1629
  const terminal = context.runnerTerminal;
1392
1630
  const env = commandEnvironment(
1393
- colorEnvironment(request.env, terminal.color),
1631
+ colorEnvironment(runner.env, terminal.color),
1394
1632
  runPayload(resourcesPayload(instances), {
1395
- ...request.testEvents === void 0 ? {} : { testEvents: request.testEvents },
1396
- ...request.verbose === void 0 ? {} : { verbose: request.verbose }
1633
+ ...runner.testEvents === void 0 ? {} : { testEvents: runner.testEvents },
1634
+ ...verbose === void 0 ? {} : { verbose }
1397
1635
  })
1398
1636
  );
1399
- await progress.emit({ kind: "command-started", argv: request.argv });
1637
+ await progress.emit({ kind: "command-started", argv });
1400
1638
  if (control.signal.aborted) return canceledStop();
1401
1639
  const commandStartedAt = context.clock.now();
1402
1640
  const splitters = { stdout: lineSplitter(), stderr: lineSplitter() };
@@ -1406,7 +1644,7 @@ async function runUnsandboxed(context, request, instances, control, progress) {
1406
1644
  else terminal.writeStderr(text);
1407
1645
  };
1408
1646
  const command = await context.commands.run({
1409
- argv: request.argv,
1647
+ argv,
1410
1648
  env,
1411
1649
  terminate: control.terminate,
1412
1650
  onOutput: ({ stream, data }) => write(stream, splitters[stream].push(data))
@@ -1415,66 +1653,77 @@ async function runUnsandboxed(context, request, instances, control, progress) {
1415
1653
  write("stdout", splitters.stdout.flush());
1416
1654
  write("stderr", splitters.stderr.flush());
1417
1655
  if (command.kind === "spawn-failed")
1418
- return { kind: "spawn_failed", executable: request.argv[0] ?? "", message: command.message };
1656
+ return { kind: "spawn_failed", executable: argv[0] ?? "", message: command.message };
1419
1657
  await progress.emit({
1420
1658
  kind: "command-ended",
1421
- command: posix.basename(request.argv[0] ?? ""),
1659
+ command: posix2.basename(argv[0] ?? ""),
1422
1660
  outcome: command,
1423
1661
  ms: commandEndedAt.getTime() - commandStartedAt.getTime()
1424
1662
  });
1425
1663
  return { kind: "command-ended", resources: resourcesRan(instances), command, runner: void 0 };
1426
1664
  }
1427
- function runnerLaneOutcome(outcome) {
1428
- if (outcome.kind === "ready") return "ready";
1429
- return outcome.kind === "aborted" ? "stopped" : "failed";
1430
- }
1431
- function runnerStopped(outcome) {
1432
- if (outcome.kind === "failed") return { kind: "runner_failed", failure: outcome.failure };
1433
- if (outcome.kind === "snapshot-gone")
1434
- return { kind: "snapshot_gone", entry: outcome.entry, removal: outcome.removal };
1435
- return void 0;
1436
- }
1437
- async function runSandboxed(context, request, instances, control, progress, cleanup) {
1665
+ async function runInVercelSandboxSession(context, runner, input) {
1666
+ const { argv, verbose, instances, control, progress, cleanup } = input;
1438
1667
  const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
1439
- const session = openRunnerSession(context, request.runner, { signal: control.signal, cleanup }, runnerProgress);
1668
+ const session = openRunnerSession(context, runner.session, { signal: control.signal, cleanup }, runnerProgress);
1440
1669
  try {
1441
- const ended = await runInSandbox(context, request, instances, session, control, progress);
1670
+ const ended = await runInVercelSandbox(context, runner, { argv, verbose, instances, session, control, progress });
1442
1671
  return { ended, runnerCleanup: await session.cleanUp() };
1443
1672
  } finally {
1444
1673
  await session.cleanUp();
1445
1674
  }
1446
1675
  }
1447
- async function runInSandbox(context, request, instances, session, control, progress) {
1448
- const { runner } = request;
1449
- const canceled = () => ({ ...canceledStop(), commandStopped: false });
1450
- const credential = await mintCredential(context, runner.target, control.signal, progress);
1676
+ async function runInVercelSandbox(context, runner, input) {
1677
+ const { argv, verbose, instances, session, control, progress } = input;
1678
+ const credential = await obtainRunnerCredential(context, runner.credential, control.signal, progress);
1451
1679
  if (!credential.ok) return credential.outcome;
1452
- const acquisition = await readyBoth(
1453
- {
1454
- instances,
1455
- credential: credential.mint,
1456
- ready: (signal) => session.ready(credential.access, signal)
1680
+ await emitLanesStarted(instances, progress);
1681
+ const setup = await coordinateSetup({
1682
+ cancelSignal: control.signal,
1683
+ runResources: async (stopSignal) => {
1684
+ const acquired = await acquireResources(instances, {
1685
+ credential: credential.mint,
1686
+ cancelSignal: control.signal,
1687
+ stopSignal,
1688
+ progress
1689
+ });
1690
+ if (acquired.kind === "acquired") return { kind: "ready", value: void 0 };
1691
+ return acquired;
1457
1692
  },
1458
- control,
1459
- progress
1460
- );
1461
- if (acquisition.kind === "stopped") {
1462
- const { outcome } = acquisition;
1693
+ runRunner: async (stopSignal) => {
1694
+ let readied;
1695
+ let laneOutcome;
1696
+ try {
1697
+ readied = await session.ready(credential.access, AbortSignal.any([control.signal, stopSignal]));
1698
+ laneOutcome = runnerLaneOutcome(readied);
1699
+ await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: laneOutcome });
1700
+ } catch (error) {
1701
+ if (laneOutcome === void 0)
1702
+ await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: "failed" }).catch(() => void 0);
1703
+ throw error;
1704
+ }
1705
+ if (readied.kind === "ready") return { kind: "ready", value: readied.runner };
1706
+ const stopped = runnerStopped(readied);
1707
+ if (stopped !== void 0) return { kind: "stopped", outcome: stopped };
1708
+ return control.signal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
1709
+ }
1710
+ });
1711
+ if (setup.kind === "threw") throw setup.error;
1712
+ if (setup.kind === "stopped") {
1713
+ const { outcome } = setup;
1463
1714
  return outcome.kind === "canceled" ? { ...outcome, commandStopped: false } : outcome;
1464
1715
  }
1465
- const { beside: readied } = acquisition;
1466
- if (readied?.kind !== "ready") return canceled();
1467
- const ready = readied.runner;
1468
- const credentials = resourcesCredentials(instances, runner.credentials).map(({ credential: credential2 }) => credential2);
1716
+ const ready = setup.runner;
1717
+ const credentials = resourcesCredentials(instances, runner.session.credentials).map(({ credential: c }) => c);
1469
1718
  await announceAcquired(instances, progress);
1470
1719
  const ran = await runCommandInSandbox(
1471
1720
  session,
1472
1721
  {
1473
- argv: request.argv,
1722
+ argv,
1474
1723
  runPayload: JSON.stringify(
1475
1724
  runPayload(resourcesPayload(instances), {
1476
1725
  testEvents: SANDBOX_TEST_EVENTS_PATH,
1477
- ...request.verbose === void 0 ? {} : { verbose: request.verbose }
1726
+ ...verbose === void 0 ? {} : { verbose }
1478
1727
  })
1479
1728
  ),
1480
1729
  credentials
@@ -1483,11 +1732,10 @@ async function runInSandbox(context, request, instances, session, control, progr
1483
1732
  progress
1484
1733
  );
1485
1734
  if (!ran.ok) return ran.outcome;
1486
- const { command } = ran;
1487
1735
  return {
1488
1736
  kind: "command-ended",
1489
1737
  resources: resourcesRan(instances),
1490
- command,
1738
+ command: ran.command,
1491
1739
  runner: {
1492
1740
  snapshotId: ready.snapshotId,
1493
1741
  base: ready.base,
@@ -1496,135 +1744,11 @@ async function runInSandbox(context, request, instances, session, control, progr
1496
1744
  uploadBytes: ready.uploadBytes,
1497
1745
  vcpus: ready.vcpus,
1498
1746
  region: ready.region,
1499
- runtime: ready.runtime,
1747
+ image: ready.image,
1500
1748
  buildMs: ready.buildMs
1501
1749
  }
1502
1750
  };
1503
1751
  }
1504
- async function readyBoth(request, control, progress) {
1505
- await progress.emit({ kind: "lanes-started" });
1506
- return await acquireResources(request.instances, {
1507
- credential: request.credential,
1508
- signal: control.signal,
1509
- progress,
1510
- beside: {
1511
- lane: { lane: "runner", resource: null },
1512
- start: request.ready,
1513
- outcomeOf: runnerLaneOutcome,
1514
- stopped: runnerStopped
1515
- }
1516
- });
1517
- }
1518
-
1519
- // src/core/sandbox-end.ts
1520
- function acrossSandboxesExitStatus(sandboxes) {
1521
- return sandboxes.every(({ state }) => state === "passed") ? 0 : 1;
1522
- }
1523
- function sandboxEndFacts(end, commandStarted) {
1524
- const short = (cause, failedStage, started = commandStarted) => ({
1525
- state: started ? "failed" : "not-started",
1526
- failedStage,
1527
- exitCode: null,
1528
- cause: oneLine(cause)
1529
- });
1530
- switch (end.kind) {
1531
- case "ran": {
1532
- const { command } = end;
1533
- if (command.kind === "exited")
1534
- return {
1535
- state: command.code === 0 ? "passed" : "failed",
1536
- failedStage: command.code === 0 ? null : "command",
1537
- exitCode: command.code,
1538
- cause: null
1539
- };
1540
- return {
1541
- state: "failed",
1542
- failedStage: "command",
1543
- exitCode: null,
1544
- cause: command.kind === "signaled" ? `signaled: ${command.signal}` : "no-exit-code"
1545
- };
1546
- }
1547
- case "canceled":
1548
- return { state: "canceled", failedStage: null, exitCode: null, cause: "canceled" };
1549
- case "runner_failed": {
1550
- const { failure } = end;
1551
- const ranCommand = failure.kind === "sandbox-api-failed" && failure.operation === "run-command";
1552
- return short(runnerFailureCause(failure), runnerFailureStage(failure), commandStarted || ranCommand);
1553
- }
1554
- case "mint_failed":
1555
- return short(`mint-failed: ${describeMintFailure(end.failure, end.target).cause}`, "mint");
1556
- case "snapshot_gone":
1557
- return short("snapshot-gone", "snapshot");
1558
- case "spawn_failed":
1559
- return short(`spawn-failed: ${end.message}`, "command");
1560
- case "resource_refused":
1561
- return short(`resource-refused: ${end.resource}: ${end.refusal.message}`, "resource");
1562
- case "threw":
1563
- return short(`threw: ${end.message}`, "storm");
1564
- }
1565
- }
1566
- function runnerFailureStage(failure) {
1567
- switch (failure.kind) {
1568
- case "snapshot-build-step-failed":
1569
- return "snapshot";
1570
- case "apply-failed":
1571
- return "apply";
1572
- case "install-failed":
1573
- return "install";
1574
- case "build-failed":
1575
- return "build";
1576
- case "checkout-failed":
1577
- return "checkout";
1578
- case "credential-claims-missing":
1579
- return "mint";
1580
- case "sandbox-api-failed":
1581
- switch (failure.operation) {
1582
- case "start-build-sandbox":
1583
- case "save-snapshot":
1584
- return "snapshot";
1585
- case "start-runner-sandbox":
1586
- case "login-path":
1587
- case "run-script":
1588
- return "start";
1589
- case "upload":
1590
- return "upload";
1591
- case "run-command":
1592
- return "command";
1593
- }
1594
- // A policy write fails at the stage it guards: a snapshot build's steps or save, the install and build steps, or
1595
- // the command.
1596
- case "network-policy-failed":
1597
- switch (failure.around) {
1598
- case "snapshot-steps":
1599
- case "snapshot-save":
1600
- return "snapshot";
1601
- case "run-steps":
1602
- return "install";
1603
- case "command":
1604
- return "command";
1605
- }
1606
- }
1607
- }
1608
- function runnerFailureCause(failure) {
1609
- switch (failure.kind) {
1610
- case "sandbox-api-failed":
1611
- return `${failure.operation}: ${failure.message}`;
1612
- case "checkout-failed":
1613
- return `checkout-failed: ${failure.failure.message}`;
1614
- case "credential-claims-missing":
1615
- return `credential-claims-missing: ${failure.target.team}/${failure.target.project}`;
1616
- case "snapshot-build-step-failed":
1617
- case "apply-failed":
1618
- case "install-failed":
1619
- case "build-failed":
1620
- return `${failure.kind}: ${failure.exitCode === null ? "no exit code" : `exited ${failure.exitCode}`}`;
1621
- case "network-policy-failed":
1622
- return `network-policy-failed: ${failure.operation} around ${failure.around}: ${failure.status === null ? "" : `HTTP ${failure.status}: `}${failure.message}`;
1623
- }
1624
- }
1625
- function oneLine(text) {
1626
- return text.trim().replace(/\s*\n\s*/g, " ");
1627
- }
1628
1752
 
1629
1753
  // src/core/across-sandboxes.ts
1630
1754
  async function executeAcrossSandboxes(definitionSet, context, resourceContexts2, request, control, progress) {
@@ -1643,7 +1767,7 @@ async function executeAcrossSandboxes(definitionSet, context, resourceContexts2,
1643
1767
  return all;
1644
1768
  }
1645
1769
  );
1646
- const runnerCleanup = mergedCleanup(runner.target, ended.runnerCleanups);
1770
+ const runnerCleanup = mergedRunnerCleanup(runner.target, ended.runnerCleanups);
1647
1771
  await progress.emit({
1648
1772
  kind: "cleanup-finished",
1649
1773
  resourceWarnings: resourceWarnings(resourceCleanup),
@@ -1666,135 +1790,139 @@ async function executeAcrossSandboxes(definitionSet, context, resourceContexts2,
1666
1790
  return { kind: "snapshot_gone", entry: first.end.entry, removal: first.end.removal, ...cleanup };
1667
1791
  return { kind: "sandboxes_ran", sandboxes, snapshot: ended.snapshot, resources: resourcesRan(instances), ...cleanup };
1668
1792
  }
1669
- function rankSetupEnd(canceled, snapshotFailure, resources) {
1670
- if (canceled) return canceledStop();
1671
- if (snapshotFailure !== void 0) return snapshotFailure;
1672
- if (resources.kind === "stopped" && resources.stop.kind !== "canceled") return resources.stop;
1673
- if (resources.kind === "threw") return { kind: "threw", message: errorMessage(resources.error) };
1674
- return canceledStop();
1675
- }
1676
1793
  function errorMessage(error) {
1677
1794
  return error instanceof Error ? error.message : String(error);
1678
1795
  }
1796
+ function gateEndFromResources(cancelSignal, settled) {
1797
+ if (cancelSignal.aborted) return canceledStop();
1798
+ if (settled.kind === "stopped") return settled.outcome;
1799
+ if (settled.kind === "threw") return { kind: "threw", message: errorMessage(settled.error) };
1800
+ return canceledStop();
1801
+ }
1679
1802
  async function runAll(context, request, instances, cancelSignal, progress) {
1680
1803
  const count = request.sandboxes.length;
1681
- const credential = await mintCredential(context, request.runner.target, cancelSignal, progress);
1804
+ const credential = await obtainRunnerCredential(context, request.credential, cancelSignal, progress);
1682
1805
  if (!credential.ok) return stoppedBeforeSandboxes(count, credential.outcome, [], void 0, progress);
1683
1806
  const { access: access2, mint } = credential;
1684
- await progress.emit({ kind: "lanes-started" });
1685
- const stop = new AbortController();
1686
- const stageSignal = AbortSignal.any([cancelSignal, stop.signal]);
1687
- const parts = acquireAndSplit(instances, {
1688
- credential: mint,
1689
- signal: stageSignal,
1690
- progress,
1691
- sandboxes: count,
1692
- runnerCredentials: request.runner.credentials
1693
- }).then(
1694
- (answered) => {
1695
- if (answered.kind === "split") return answered;
1696
- if (answered.stop.kind !== "canceled") stop.abort();
1697
- return answered;
1698
- },
1699
- (error) => {
1700
- stop.abort();
1701
- return { kind: "threw", error };
1702
- }
1703
- );
1704
- const gateOf = (index) => parts.then((settled) => {
1705
- if (settled.kind === "split") {
1706
- const resources = settled.parts[index];
1707
- if (resources !== void 0) return { kind: "ready", resources, credentials: settled.credentials };
1708
- }
1709
- return { kind: "stopped", end: rankSetupEnd(cancelSignal.aborted, void 0, settled) };
1710
- });
1711
- try {
1712
- const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
1713
- const chosen = await chooseSnapshotForRun(
1714
- context,
1715
- {
1716
- prepared: request.runner.prepared,
1717
- access: access2,
1718
- user: request.runner.user,
1719
- credentials: request.runner.credentials
1720
- },
1721
- { signal: cancelSignal, stop: stop.signal },
1722
- runnerProgress
1723
- );
1724
- const choiceCleanup = { ...chosen.cleanup, target: request.runner.target };
1725
- if (chosen.kind !== "chosen") {
1726
- const snapshotFailure = chosen.kind === "failed" ? { kind: "runner_failed", failure: chosen.failure } : void 0;
1727
- if (snapshotFailure !== void 0) stop.abort();
1728
- await progress.emit({
1729
- kind: "lane-ended",
1730
- lane: "runner",
1731
- resource: null,
1732
- outcome: chosen.kind === "aborted" ? "stopped" : "failed"
1807
+ let choiceCleanup;
1808
+ let snapshotFailure;
1809
+ let sandboxesResult;
1810
+ await emitLanesStarted(instances, progress);
1811
+ const setup = await coordinateSetup({
1812
+ cancelSignal,
1813
+ runResources: (stopSignal) => acquireAndSplit(instances, {
1814
+ credential: mint,
1815
+ cancelSignal,
1816
+ stopSignal,
1817
+ progress,
1818
+ sandboxes: count,
1819
+ runnerCredentials: request.runner.credentials
1820
+ }),
1821
+ runRunner: async (stopSignal, settledResources, stopResources) => {
1822
+ const runnerProgress = { emit: (event) => progress.emit({ kind: "runner", event }) };
1823
+ const chosen = await chooseSnapshotForRun(
1824
+ context,
1825
+ {
1826
+ prepared: request.runner.prepared,
1827
+ access: access2,
1828
+ user: request.runner.user,
1829
+ credentials: request.runner.credentials
1830
+ },
1831
+ { signal: cancelSignal, stop: stopSignal },
1832
+ runnerProgress
1833
+ );
1834
+ choiceCleanup = { ...chosen.cleanup, target: request.runner.target };
1835
+ if (chosen.kind !== "chosen") {
1836
+ snapshotFailure = chosen.kind === "failed" ? { kind: "runner_failed", failure: chosen.failure } : void 0;
1837
+ await progress.emit({
1838
+ kind: "lane-ended",
1839
+ lane: "runner",
1840
+ resource: null,
1841
+ outcome: chosen.kind === "aborted" ? "stopped" : "failed"
1842
+ });
1843
+ if (snapshotFailure !== void 0) return { kind: "stopped", outcome: snapshotFailure };
1844
+ return cancelSignal.aborted ? { kind: "canceled" } : { kind: "internal-stopped" };
1845
+ }
1846
+ const stageSignal = AbortSignal.any([cancelSignal, stopSignal]);
1847
+ const gateOf = (index) => settledResources.then((settled) => {
1848
+ if (settled.kind === "ready") {
1849
+ const resources = settled.value.parts[index];
1850
+ if (resources !== void 0) return { kind: "ready", resources, credentials: settled.value.credentials };
1851
+ }
1852
+ return { kind: "stopped", end: gateEndFromResources(cancelSignal, settled) };
1733
1853
  });
1734
- const settled2 = await parts;
1735
- const ending = rankSetupEnd(cancelSignal.aborted, snapshotFailure, settled2);
1736
- const thrown = settled2.kind === "threw" ? { error: settled2.error } : void 0;
1737
- return stoppedBeforeSandboxes(count, ending, [choiceCleanup], thrown, progress);
1738
- }
1739
- await progress.emit({ kind: "sandboxes-started", sandboxes: count });
1740
- const ran = await Promise.all(
1741
- request.sandboxes.map(
1742
- (sandboxSpec, index) => runOneSandbox(
1743
- context,
1744
- {
1745
- sandbox: index,
1746
- count,
1747
- sandboxSpec,
1748
- access: access2,
1749
- snapshot: chosen.snapshot,
1750
- request,
1751
- gate: gateOf(index),
1752
- cancelSignal,
1753
- stageSignal
1754
- },
1755
- progress
1854
+ const tracker = sandboxFenceTracker();
1855
+ await progress.emit({ kind: "sandboxes-started", sandboxes: count });
1856
+ const ran = await Promise.all(
1857
+ request.sandboxes.map(
1858
+ (sandboxSpec, index) => runOneSandbox(
1859
+ context,
1860
+ {
1861
+ sandbox: index,
1862
+ count,
1863
+ sandboxSpec,
1864
+ access: access2,
1865
+ snapshot: chosen.snapshot,
1866
+ request,
1867
+ gate: gateOf(index),
1868
+ cancelSignal,
1869
+ stageSignal,
1870
+ tracker
1871
+ },
1872
+ progress
1873
+ )
1756
1874
  )
1757
- )
1758
- );
1759
- stop.abort();
1760
- const settled = await parts;
1761
- const progressFailure = ran.find((sandbox) => sandbox.progressFailure !== void 0)?.progressFailure;
1762
- const sandboxes = ran.map(({ ended: sandbox }) => sandbox);
1763
- const runnerSandboxesFenced = ran.every(({ fenced }) => fenced);
1764
- const runnerCleanups = [
1765
- choiceCleanup,
1875
+ );
1876
+ stopResources();
1877
+ sandboxesResult = { snapshot: chosen.snapshot, ran, allFenced: tracker.allFenced() };
1878
+ return { kind: "ready", value: sandboxesResult };
1879
+ }
1880
+ });
1881
+ if (setup.kind === "threw" && setup.lane === "runner") throw setup.error;
1882
+ const finishSandboxes = (finished) => {
1883
+ const { snapshot, ran, allFenced } = finished;
1884
+ const sandboxes = ran.map(({ ended }) => ended);
1885
+ const runnerCleanups2 = [
1886
+ ...choiceCleanup === void 0 ? [] : [choiceCleanup],
1766
1887
  ...sandboxes.flatMap(({ runnerCleanup }) => runnerCleanup === null ? [] : [runnerCleanup])
1767
1888
  ];
1768
- if (settled.kind === "threw") return { kind: "threw", error: settled.error, runnerSandboxesFenced, runnerCleanups };
1889
+ if (setup.kind === "threw")
1890
+ return { kind: "threw", error: setup.error, runnerSandboxesFenced: allFenced, runnerCleanups: runnerCleanups2 };
1891
+ const progressFailure = ran.find((sandbox) => sandbox.progressFailure !== void 0)?.progressFailure;
1769
1892
  if (progressFailure !== void 0)
1770
- return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced, runnerCleanups };
1893
+ return { kind: "threw", error: progressFailure.error, runnerSandboxesFenced: allFenced, runnerCleanups: runnerCleanups2 };
1771
1894
  return {
1772
1895
  kind: "sandboxes",
1773
1896
  sandboxes,
1774
- snapshot: chosen.snapshot,
1775
- failed: settled.kind === "stopped" && settled.stop.kind !== "canceled" ? settled.stop : void 0,
1776
- canceled: ran.some(({ canceled }) => canceled),
1777
- runnerSandboxesFenced,
1778
- runnerCleanups
1897
+ snapshot,
1898
+ failed: setup.kind === "stopped" && setup.outcome.kind !== "canceled" ? setup.outcome : void 0,
1899
+ canceled: setup.kind === "stopped" && setup.outcome.kind === "canceled" || ran.some(({ canceled }) => canceled),
1900
+ runnerSandboxesFenced: allFenced,
1901
+ runnerCleanups: runnerCleanups2
1779
1902
  };
1780
- } catch (error) {
1781
- stop.abort();
1782
- await parts;
1783
- throw error;
1903
+ };
1904
+ if (setup.kind === "ready") return finishSandboxes(setup.runner);
1905
+ if (sandboxesResult !== void 0) return finishSandboxes(sandboxesResult);
1906
+ const runnerCleanups = choiceCleanup === void 0 ? [] : [choiceCleanup];
1907
+ if (setup.kind === "threw") {
1908
+ const ending = cancelSignal.aborted ? canceledStop() : snapshotFailure ?? { kind: "threw", message: errorMessage(setup.error) };
1909
+ return stoppedBeforeSandboxes(count, ending, runnerCleanups, { error: setup.error }, progress);
1784
1910
  }
1911
+ return stoppedBeforeSandboxes(count, setup.outcome, runnerCleanups, void 0, progress);
1785
1912
  }
1786
1913
  async function acquireAndSplit(instances, input) {
1787
1914
  const acquisition = await acquireResources(instances, {
1788
1915
  credential: input.credential,
1789
- signal: input.signal,
1916
+ cancelSignal: input.cancelSignal,
1917
+ stopSignal: input.stopSignal,
1790
1918
  progress: input.progress
1791
1919
  });
1792
- if (acquisition.kind === "stopped") return { kind: "stopped", stop: acquisition.outcome };
1920
+ if (acquisition.kind !== "acquired") return acquisition;
1793
1921
  const split = splitAcquired(instances, input.sandboxes);
1794
- if (split.kind === "refused") return { kind: "stopped", stop: split.outcome };
1922
+ if (split.kind === "refused") return { kind: "stopped", outcome: split.outcome };
1795
1923
  const credentials = resourcesCredentials(instances, input.runnerCredentials).map(({ credential }) => credential);
1796
1924
  await announceAcquired(instances, input.progress);
1797
- return { ...split, credentials };
1925
+ return { kind: "ready", value: { parts: split.parts, credentials } };
1798
1926
  }
1799
1927
  async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progress) {
1800
1928
  const facts = sandboxEndFacts(end, false);
@@ -1806,18 +1934,11 @@ async function stoppedBeforeSandboxes(count, end, runnerCleanups, thrown, progre
1806
1934
  return { kind: "stopped", stop: end, runnerCleanups, runnerSandboxesFenced: true };
1807
1935
  }
1808
1936
  async function runOneSandbox(context, input, progress) {
1809
- const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal } = input;
1937
+ const { sandbox, count, sandboxSpec, request, cancelSignal, stageSignal, tracker } = input;
1810
1938
  const { argv } = sandboxSpec;
1811
1939
  const emitSandbox = async (event) => await progress.emit({ kind: "sandbox", sandbox, event });
1812
1940
  const ownProgress = { emit: emitSandbox };
1813
1941
  const runnerProgress = { emit: (event) => emitSandbox({ kind: "runner", event }) };
1814
- let cleanupStarted = false;
1815
- let fenced = false;
1816
- const startCleanup = async () => {
1817
- if (cleanupStarted) return;
1818
- cleanupStarted = true;
1819
- await emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] });
1820
- };
1821
1942
  const session = openRunnerSession(
1822
1943
  { ...context, runnerTerminal: context.sandboxTerminal(sandbox) },
1823
1944
  { ...request.runner, snapshot: input.snapshot },
@@ -1826,12 +1947,9 @@ async function runOneSandbox(context, input, progress) {
1826
1947
  // command's cancel signal, never storm's internal sibling-stop signal.
1827
1948
  {
1828
1949
  signal: cancelSignal,
1829
- cleanup: {
1830
- startCleanup,
1831
- release: async (fence) => {
1832
- fenced = fence.runnerSandboxFenced;
1833
- }
1834
- }
1950
+ cleanup: tracker.sessionCleanup(
1951
+ () => emitSandbox({ kind: "cleanup-started", keepMs: request.runner.keepMs, resources: [] })
1952
+ )
1835
1953
  },
1836
1954
  runnerProgress
1837
1955
  );
@@ -1866,7 +1984,7 @@ async function runOneSandbox(context, input, progress) {
1866
1984
  notDeleted: runnerCleanup.notDeleted.length
1867
1985
  });
1868
1986
  } catch (error) {
1869
- end = { kind: "threw", message: error instanceof Error ? error.message : String(error) };
1987
+ end = { kind: "threw", message: errorMessage(error) };
1870
1988
  canceled = cancelSignal.aborted;
1871
1989
  runnerCleanup = await session.cleanUp().catch(() => runnerCleanup);
1872
1990
  }
@@ -1874,9 +1992,9 @@ async function runOneSandbox(context, input, progress) {
1874
1992
  const ended = { sandbox, argv, end, ...facts, runnerCleanup };
1875
1993
  try {
1876
1994
  await progress.emit({ kind: "sandbox-ended", sandbox, ...facts });
1877
- return { ended, progressFailure: void 0, fenced, canceled };
1995
+ return { ended, progressFailure: void 0, canceled };
1878
1996
  } catch (error) {
1879
- return { ended, progressFailure: { error }, fenced, canceled };
1997
+ return { ended, progressFailure: { error }, canceled };
1880
1998
  }
1881
1999
  }
1882
2000
  async function sandboxBody(input, progress, started) {
@@ -1888,7 +2006,7 @@ async function sandboxBody(input, progress, started) {
1888
2006
  };
1889
2007
  if (stageSignal.aborted) return await stopped();
1890
2008
  const readied = await session.ready(input.access, stageSignal);
1891
- await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: runnerLaneOutcome2(readied) });
2009
+ await progress.emit({ kind: "lane-ended", lane: "runner", resource: null, outcome: runnerLaneOutcome(readied) });
1892
2010
  if (readied.kind === "aborted") return await stopped();
1893
2011
  if (readied.kind === "failed") return { kind: "runner_failed", failure: readied.failure };
1894
2012
  if (readied.kind === "snapshot-gone")
@@ -1912,19 +2030,6 @@ async function sandboxBody(input, progress, started) {
1912
2030
  if (!ran.ok) return ran.outcome;
1913
2031
  return { kind: "ran", command: ran.command };
1914
2032
  }
1915
- function runnerLaneOutcome2(outcome) {
1916
- if (outcome.kind === "ready") return "ready";
1917
- return outcome.kind === "aborted" ? "stopped" : "failed";
1918
- }
1919
- function mergedCleanup(target, cleanups) {
1920
- return {
1921
- kept: null,
1922
- notKept: null,
1923
- notStopped: cleanups.flatMap(({ notStopped }) => notStopped),
1924
- notDeleted: cleanups.flatMap(({ notDeleted }) => notDeleted),
1925
- target
1926
- };
1927
- }
1928
2033
 
1929
2034
  export {
1930
2035
  warningTally,
@@ -1950,8 +2055,8 @@ export {
1950
2055
  liveJobSummaryGateway,
1951
2056
  liveProgressTerminal,
1952
2057
  livePackageBinGateway,
1953
- executeRun,
1954
2058
  acrossSandboxesExitStatus,
1955
2059
  sandboxEndFacts,
2060
+ executeRun,
1956
2061
  executeAcrossSandboxes
1957
2062
  };