@cnc-tools/storm 0.16.0 → 0.17.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 (281) hide show
  1. package/dist/application.d.ts +22 -13
  2. package/dist/application.js +21 -10
  3. package/dist/bin/run.d.ts +18 -0
  4. package/dist/bin/run.js +31 -0
  5. package/dist/bin/storm.js +42 -26
  6. package/dist/build-info.js +1 -1
  7. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
  8. package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
  9. package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
  18. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  19. package/dist/chunks/chunk-F4MOYHRY.js +198 -0
  20. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
  24. package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
  25. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
  26. package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
  29. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
  30. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
  31. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  32. package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
  34. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  35. package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
  36. package/dist/commands/exec/before-run.d.ts +123 -0
  37. package/dist/commands/exec/before-run.js +105 -0
  38. package/dist/commands/exec/command.d.ts +31 -2
  39. package/dist/commands/exec/command.js +31 -95
  40. package/dist/commands/exec/driver-plan.d.ts +9 -4
  41. package/dist/commands/exec/driver-plan.js +8 -8
  42. package/dist/commands/exec/exec-words.js +1 -1
  43. package/dist/commands/exec/execute-run.d.ts +39 -0
  44. package/dist/commands/exec/execute-run.js +325 -0
  45. package/dist/commands/exec/live-view.d.ts +3 -3
  46. package/dist/commands/exec/live-view.js +16 -15
  47. package/dist/commands/exec/metadata.js +1 -1
  48. package/dist/commands/exec/mint-failed.d.ts +38 -0
  49. package/dist/commands/exec/mint-failed.js +27 -4
  50. package/dist/commands/exec/outcomes.d.ts +34 -8
  51. package/dist/commands/exec/outcomes.js +30 -23
  52. package/dist/commands/exec/plan-run.d.ts +58 -150
  53. package/dist/commands/exec/plan-run.js +232 -88
  54. package/dist/commands/exec/progress.d.ts +10 -6
  55. package/dist/commands/exec/progress.js +38 -25
  56. package/dist/commands/exec/run-bin.d.ts +11 -11
  57. package/dist/commands/exec/run-bin.js +9 -9
  58. package/dist/commands/exec/run-flags.d.ts +69 -0
  59. package/dist/commands/exec/run-flags.js +58 -0
  60. package/dist/commands/exec/run-metadata.js +4 -4
  61. package/dist/commands/exec/run-summary.d.ts +58 -0
  62. package/dist/commands/exec/run-summary.js +205 -0
  63. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  64. package/dist/commands/exec/runner-refusals.js +71 -0
  65. package/dist/commands/exec/sandbox-progress.js +3 -0
  66. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  67. package/dist/commands/exec/stopped-outcome.js +77 -0
  68. package/dist/commands/exec/view.d.ts +20 -11
  69. package/dist/commands/exec/view.js +103 -47
  70. package/dist/commands/runs/facts.d.ts +7 -3
  71. package/dist/commands/runs/facts.js +17 -8
  72. package/dist/commands/runs/list/command.d.ts +14 -6
  73. package/dist/commands/runs/list/command.js +10 -10
  74. package/dist/commands/runs/list/outcomes.d.ts +7 -3
  75. package/dist/commands/runs/logs/command.js +10 -10
  76. package/dist/commands/runs/show/command.d.ts +14 -6
  77. package/dist/commands/runs/show/command.js +30 -28
  78. package/dist/commands/runs/show/outcomes.d.ts +7 -3
  79. package/dist/commands/runs/show/outcomes.js +7 -5
  80. package/dist/commands/snapshots/access.d.ts +111 -0
  81. package/dist/commands/snapshots/access.js +96 -0
  82. package/dist/commands/snapshots/build/command.d.ts +360 -93
  83. package/dist/commands/snapshots/build/command.js +446 -150
  84. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  85. package/dist/commands/snapshots/build/metadata.js +31 -11
  86. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  87. package/dist/commands/snapshots/build/outcomes.js +200 -36
  88. package/dist/commands/snapshots/list/command.d.ts +366 -25
  89. package/dist/commands/snapshots/list/command.js +296 -66
  90. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  91. package/dist/commands/snapshots/list/metadata.js +29 -6
  92. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  93. package/dist/commands/snapshots/list/outcomes.js +221 -50
  94. package/dist/commands/snapshots/metadata.js +1 -1
  95. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  96. package/dist/commands/snapshots/prune/command.js +161 -0
  97. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  98. package/dist/commands/snapshots/prune/metadata.js +39 -0
  99. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  100. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  101. package/dist/commands/suites/list/command.js +17 -17
  102. package/dist/commands/suites/list/outcomes.js +2 -2
  103. package/dist/commands/test/command.d.ts +31 -2
  104. package/dist/commands/test/command.js +49 -252
  105. package/dist/commands/test/outcomes.d.ts +15 -1
  106. package/dist/config/check-runner.d.ts +3 -3
  107. package/dist/config/check-runner.js +8 -7
  108. package/dist/config/credential-resolver.d.ts +50 -5
  109. package/dist/config/credential-resolver.js +51 -19
  110. package/dist/config/credential-settle.d.ts +6 -2
  111. package/dist/config/credential-settle.js +11 -5
  112. package/dist/config/index.d.ts +2 -2
  113. package/dist/config/index.js +1 -1
  114. package/dist/config/runner.d.ts +5 -5
  115. package/dist/config/runner.js +1 -1
  116. package/dist/config/schema.d.ts +2 -2
  117. package/dist/config/schema.js +1 -1
  118. package/dist/config-file/define.d.ts +1 -1
  119. package/dist/config-file/define.js +1 -1
  120. package/dist/config-file/runner.d.ts +5 -5
  121. package/dist/config-file/toolchain.d.ts +1 -1
  122. package/dist/config-file/toolchain.js +2 -2
  123. package/dist/context.d.ts +8 -6
  124. package/dist/context.js +7 -6
  125. package/dist/core/across-sandboxes.d.ts +7 -6
  126. package/dist/core/across-sandboxes.js +123 -152
  127. package/dist/core/coordinator.d.ts +166 -0
  128. package/dist/core/coordinator.js +233 -0
  129. package/dist/core/events.d.ts +2 -2
  130. package/dist/core/index.d.ts +4 -2
  131. package/dist/core/index.js +1 -1
  132. package/dist/core/outcomes.d.ts +148 -0
  133. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  134. package/dist/core/resources.d.ts +31 -53
  135. package/dist/core/resources.js +32 -70
  136. package/dist/core/run-state.d.ts +7 -1
  137. package/dist/core/run-state.js +2 -0
  138. package/dist/core/run.d.ts +32 -236
  139. package/dist/core/run.js +106 -266
  140. package/dist/core/state-directory.d.ts +1 -1
  141. package/dist/core/state-directory.js +2 -2
  142. package/dist/credential/gateways.d.ts +15 -1
  143. package/dist/credential/index.d.ts +4 -3
  144. package/dist/credential/index.js +3 -2
  145. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  146. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  147. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  148. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  149. package/dist/credential/source.d.ts +73 -6
  150. package/dist/credential/source.js +55 -2
  151. package/dist/extension-commands.d.ts +6 -1
  152. package/dist/extension-commands.js +15 -1
  153. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  154. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  155. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  156. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  157. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  158. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  159. package/dist/extensions/testserver/credential-facts.js +29 -11
  160. package/dist/extensions/testserver/lifecycle.js +7 -1
  161. package/dist/extensions/testserver/limit.d.ts +3 -0
  162. package/dist/extensions/testserver/limit.js +3 -0
  163. package/dist/extensions/testserver/provision.d.ts +8 -1
  164. package/dist/extensions/testserver/provision.js +8 -3
  165. package/dist/extensions/testserver/refusals.d.ts +6 -1
  166. package/dist/extensions/testserver/refusals.js +16 -1
  167. package/dist/extensions/testserver/resource.d.ts +1 -1
  168. package/dist/extensions/testserver/resource.js +1 -1
  169. package/dist/extensions/testserver/result.d.ts +1 -1
  170. package/dist/extensions/testserver/result.js +9 -4
  171. package/dist/planning/driver-file-lists.d.ts +0 -15
  172. package/dist/planning/driver-file-lists.js +2 -21
  173. package/dist/planning/plan-only.d.ts +3 -14
  174. package/dist/planning/plan-only.js +11 -20
  175. package/dist/planning/run-kind-flags.js +2 -2
  176. package/dist/planning/run-plan.d.ts +45 -12
  177. package/dist/planning/run-plan.js +4 -3
  178. package/dist/planning/suites.d.ts +1 -1
  179. package/dist/planning/suites.js +2 -2
  180. package/dist/planning/test-plan.d.ts +9 -0
  181. package/dist/planning/test-plan.js +9 -0
  182. package/dist/run-directory/recording.js +2 -2
  183. package/dist/run-directory/run-record.d.ts +21 -6
  184. package/dist/run-directory/run-record.js +12 -9
  185. package/dist/runner/base.js +1 -1
  186. package/dist/runner/build-snapshots.d.ts +55 -29
  187. package/dist/runner/build-snapshots.js +130 -29
  188. package/dist/runner/context.d.ts +15 -7
  189. package/dist/runner/context.js +19 -6
  190. package/dist/runner/events.d.ts +16 -10
  191. package/dist/runner/gateways.d.ts +87 -21
  192. package/dist/runner/gateways.js +1 -1
  193. package/dist/runner/index.d.ts +11 -7
  194. package/dist/runner/index.js +9 -4
  195. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  196. package/dist/runner/live/sandbox-errors.js +4 -0
  197. package/dist/runner/live/sandbox-gateway.js +129 -3
  198. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  199. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  200. package/dist/runner/live/snapshot-records.js +6 -7
  201. package/dist/runner/local-snapshot-index.d.ts +199 -0
  202. package/dist/runner/local-snapshot-index.js +211 -0
  203. package/dist/runner/network-policy.d.ts +6 -6
  204. package/dist/runner/network-policy.js +7 -7
  205. package/dist/runner/policy-writes.d.ts +1 -1
  206. package/dist/runner/policy-writes.js +1 -1
  207. package/dist/runner/prepare.d.ts +14 -14
  208. package/dist/runner/prepare.js +20 -11
  209. package/dist/runner/ready.d.ts +18 -10
  210. package/dist/runner/ready.js +104 -33
  211. package/dist/runner/sandboxed-command.d.ts +3 -3
  212. package/dist/runner/sandboxed-command.js +3 -3
  213. package/dist/runner/scope.d.ts +10 -6
  214. package/dist/runner/scope.js +10 -3
  215. package/dist/runner/secrets.d.ts +13 -13
  216. package/dist/runner/secrets.js +18 -15
  217. package/dist/runner/session.d.ts +8 -8
  218. package/dist/runner/session.js +3 -3
  219. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  220. package/dist/runner/shared-snapshot-entry.js +168 -0
  221. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  222. package/dist/runner/shared-snapshot-list.js +155 -0
  223. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  224. package/dist/runner/shared-snapshot-lookup.js +118 -0
  225. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  226. package/dist/runner/shared-snapshot-prune.js +133 -0
  227. package/dist/runner/snapshot-build.d.ts +42 -14
  228. package/dist/runner/snapshot-build.js +32 -29
  229. package/dist/runner/snapshot-choice.js +1 -1
  230. package/dist/runner/snapshot-inspect.d.ts +39 -40
  231. package/dist/runner/snapshot-inspect.js +55 -35
  232. package/dist/runner/snapshot-key.d.ts +13 -12
  233. package/dist/runner/snapshot-key.js +13 -12
  234. package/dist/runner/steps.d.ts +1 -1
  235. package/dist/runner/steps.js +1 -1
  236. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  237. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  238. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
  239. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
  240. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  241. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  242. package/dist/sdk/extension/commands.d.ts +8 -3
  243. package/dist/sdk/extension/commands.js +3 -1
  244. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  245. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  246. package/dist/sdk/extension/credential-source.d.ts +20 -3
  247. package/dist/sdk/extension/credential-source.js +4 -4
  248. package/dist/sdk/extension/index.d.ts +3 -2
  249. package/dist/sdk/extension/index.js +2 -1
  250. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  251. package/dist/sdk/extension/secret-source.d.ts +1 -1
  252. package/dist/sdk/extension/secret-source.js +1 -1
  253. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  254. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  255. package/dist/shared/cleanup.d.ts +3 -3
  256. package/dist/shared/cleanup.js +15 -5
  257. package/dist/shared/snapshot-text.d.ts +4 -4
  258. package/dist/shared/snapshot-text.js +11 -11
  259. package/dist/time/duration.js +1 -1
  260. package/package.json +3 -2
  261. package/skills/overview.md +4 -4
  262. package/skills/plan-runs.md +1 -1
  263. package/skills/read-run-output.md +6 -6
  264. package/dist/chunks/chunk-7EENF73W.js +0 -782
  265. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  266. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  267. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  268. package/dist/commands/exec/plan-only.d.ts +0 -10
  269. package/dist/commands/exec/plan-only.js +0 -45
  270. package/dist/commands/exec/run-command.d.ts +0 -475
  271. package/dist/commands/exec/run-command.js +0 -603
  272. package/dist/commands/exec/run-planned.d.ts +0 -20
  273. package/dist/commands/exec/run-planned.js +0 -22
  274. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  275. package/dist/commands/exec/sandbox-view.js +0 -72
  276. package/dist/commands/test/plan.d.ts +0 -92
  277. package/dist/commands/test/plan.js +0 -125
  278. package/dist/core/sandbox-end.d.ts +0 -64
  279. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  280. package/dist/runner/snapshot-cache.d.ts +0 -148
  281. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,20 +1,18 @@
1
- // A run across runner sandboxes, from its start to its outcome: one run that starts its runner sandboxes from one
2
- // runner snapshot, and runs each one's command in it. Reuses the shared opening, minting, sandbox command execution,
3
- // and cleanup stages from `core/run.ts`, and ranks concurrent snapshot vs. resource failures deterministically (runner
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, canceledStop, resourceInstances, resourcesCredentials, resourcesRan, resourceWarnings, splitAcquired, } from "./resources.js";
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
- * - Steps that run once (opening, mint, snapshot choice, resource acquire/split, and final release) run once for the
15
- * run.
16
- * - Failure ranking between snapshot choice and resource acquire/split is deterministic: user cancellation first, then
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 = mergedCleanup(runner.target, ended.runnerCleanups);
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 mintCredential(context, request.runner.target, cancelSignal, progress);
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
- await progress.emit({ kind: "lanes-started" });
86
- const stop = new AbortController();
87
- // Stage preparation stops on either user cancel or a sibling failure; sandbox scopes hear only `cancelSignal`.
88
- const stageSignal = AbortSignal.any([cancelSignal, stop.signal]);
89
- const parts = acquireAndSplit(instances, {
90
- credential: mint,
91
- signal: stageSignal,
92
- progress,
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
- stageSignal,
148
- }, progress)));
149
- stop.abort();
150
- const settled = await parts;
151
- const progressFailure = ran.find((sandbox) => sandbox.progressFailure !== undefined)?.progressFailure;
152
- const sandboxes = ran.map(({ ended: sandbox }) => sandbox);
153
- const runnerSandboxesFenced = ran.every(({ fenced }) => fenced);
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 (settled.kind === "threw")
159
- return { kind: "threw", error: settled.error, runnerSandboxesFenced, runnerCleanups };
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: chosen.snapshot,
166
- failed: settled.kind === "stopped" && settled.stop.kind !== "canceled" ? settled.stop : undefined,
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
- catch (error) {
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
- signal: input.signal,
182
+ cancelSignal: input.cancelSignal,
183
+ stopSignal: input.stopSignal,
182
184
  progress: input.progress,
183
185
  });
184
- if (acquisition.kind === "stopped")
185
- return { kind: "stopped", stop: acquisition.outcome };
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", stop: split.outcome };
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 { ...split, credentials };
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: error instanceof Error ? error.message : String(error) };
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, fenced, canceled };
255
+ return { ended, progressFailure: undefined, canceled };
271
256
  }
272
257
  catch (error) {
273
- return { ended, progressFailure: { error }, fenced, canceled };
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;