@cnc-tools/storm 0.14.1 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/application.js +3 -1
- package/dist/bin/storm.js +18 -8
- package/dist/build-info.js +1 -1
- package/dist/chunks/chunk-4U4DZ7VG.js +40 -0
- package/dist/chunks/{chunk-GSC6SRTW.js → chunk-5CCP36QQ.js} +1 -1
- package/dist/chunks/chunk-5GBMR4HM.js +966 -0
- package/dist/chunks/{chunk-43MWZLJR.js → chunk-5VXBKPW6.js} +1 -1
- package/dist/chunks/{chunk-RA4L2ACU.js → chunk-AWBSONHB.js} +88 -34
- package/dist/chunks/{chunk-BRUIATTR.js → chunk-CN4EFA5J.js} +59 -12
- package/dist/chunks/{chunk-27P2QSIM.js → chunk-CXAT7ZKP.js} +2 -2
- package/dist/chunks/chunk-E4PJNZVG.js +783 -0
- package/dist/chunks/{chunk-T6AZIDZD.js → chunk-F6N34UWB.js} +12 -244
- package/dist/chunks/{chunk-ZH5R7W4A.js → chunk-KC4KDJ5K.js} +147 -26
- package/dist/chunks/{chunk-5ED3IDUJ.js → chunk-L36GBUBB.js} +1652 -681
- package/dist/chunks/{chunk-QBR5VHJ7.js → chunk-OX7X4B2L.js} +7 -2
- package/dist/chunks/{chunk-Z5OXOZD3.js → chunk-PN5ULTTH.js} +140 -130
- package/dist/chunks/chunk-QUHY6FGN.js +108 -0
- package/dist/chunks/chunk-QVS7HRU7.js +74 -0
- package/dist/chunks/{chunk-UC6DULWY.js → chunk-R7XVBZOY.js} +130 -39
- package/dist/chunks/{chunk-YBPTMJUM.js → chunk-RAQEXKL6.js} +1120 -465
- package/dist/chunks/{chunk-RKONDLPS.js → chunk-SZEURWRS.js} +446 -52
- package/dist/chunks/chunk-TJNFVNKR.js +246 -0
- package/dist/chunks/{chunk-BW2ADH7U.js → chunk-VUPZH7J2.js} +1 -1
- package/dist/chunks/{chunk-XPCUINWS.js → chunk-XEVHP5ZW.js} +2 -2
- package/dist/chunks/{chunk-5TMHYH7G.js → chunk-YV7GE6EV.js} +638 -80
- package/dist/chunks/{chunk-GQIL3AHY.js → chunk-ZG3WQ4UF.js} +1 -1
- package/dist/chunks/{live-app-FBVWUUMT.js → live-app-PI3BAN6Y.js} +37 -26
- package/dist/command-tree.d.ts +2 -2
- package/dist/command-tree.js +2 -2
- package/dist/commands/exec/across-sandboxes-outcomes.d.ts +364 -0
- package/dist/commands/exec/across-sandboxes-outcomes.js +229 -0
- package/dist/commands/exec/across-sandboxes-run.d.ts +180 -0
- package/dist/commands/exec/across-sandboxes-run.js +339 -0
- package/dist/commands/exec/command.d.ts +577 -75
- package/dist/commands/exec/command.js +165 -32
- package/dist/commands/exec/driver-plan.d.ts +8 -2
- package/dist/commands/exec/driver-plan.js +13 -3
- package/dist/commands/exec/exec-words.d.ts +17 -3
- package/dist/commands/exec/exec-words.js +27 -16
- package/dist/commands/exec/live-view.d.ts +3 -4
- package/dist/commands/exec/live-view.js +37 -28
- package/dist/commands/exec/metadata.js +2 -2
- package/dist/commands/exec/mint-failed.d.ts +4 -4
- package/dist/commands/exec/mint-failed.js +6 -6
- package/dist/commands/exec/outcomes.d.ts +530 -73
- package/dist/commands/exec/outcomes.js +202 -66
- package/dist/commands/exec/plan-only.d.ts +10 -0
- package/dist/commands/exec/plan-only.js +46 -0
- package/dist/commands/exec/plan-run.d.ts +54 -35
- package/dist/commands/exec/plan-run.js +81 -38
- package/dist/commands/exec/planned-outcome.d.ts +15 -0
- package/dist/commands/exec/planned-outcome.js +35 -0
- package/dist/commands/exec/progress.d.ts +2 -2
- package/dist/commands/exec/progress.js +35 -18
- package/dist/commands/exec/resource-refusals.d.ts +2 -2
- package/dist/commands/exec/resource-refusals.js +3 -3
- package/dist/commands/exec/run-bin.d.ts +1 -1
- package/dist/commands/exec/run-bin.js +2 -2
- package/dist/commands/exec/run-command.d.ts +345 -63
- package/dist/commands/exec/run-command.js +308 -258
- package/dist/commands/exec/run-metadata.d.ts +42 -8
- package/dist/commands/exec/run-metadata.js +40 -21
- package/dist/commands/exec/run-planned.d.ts +20 -0
- package/dist/commands/exec/run-planned.js +22 -0
- package/dist/commands/exec/sandbox-lines.d.ts +42 -0
- package/dist/commands/exec/sandbox-lines.js +59 -0
- package/dist/commands/exec/sandbox-progress.d.ts +30 -0
- package/dist/commands/exec/sandbox-progress.js +232 -0
- package/dist/commands/exec/sandbox-view.d.ts +19 -0
- package/dist/commands/exec/sandbox-view.js +72 -0
- package/dist/commands/exec/view.d.ts +3 -2
- package/dist/commands/exec/view.js +10 -6
- package/dist/commands/runs/facts.d.ts +51 -9
- package/dist/commands/runs/facts.js +49 -29
- package/dist/commands/runs/list/command.d.ts +80 -4
- package/dist/commands/runs/list/command.js +11 -10
- package/dist/commands/runs/list/metadata.js +1 -1
- package/dist/commands/runs/list/outcomes.d.ts +40 -2
- package/dist/commands/runs/logs/command.d.ts +103 -8
- package/dist/commands/runs/logs/command.js +139 -24
- package/dist/commands/runs/logs/metadata.d.ts +4 -0
- package/dist/commands/runs/logs/metadata.js +14 -7
- package/dist/commands/runs/logs/outcomes.d.ts +49 -2
- package/dist/commands/runs/logs/outcomes.js +110 -6
- package/dist/commands/runs/past-run.d.ts +77 -6
- package/dist/commands/runs/past-run.js +133 -4
- package/dist/commands/runs/show/command.d.ts +568 -10
- package/dist/commands/runs/show/command.js +634 -119
- package/dist/commands/runs/show/metadata.d.ts +17 -0
- package/dist/commands/runs/show/metadata.js +48 -7
- package/dist/commands/runs/show/outcomes.d.ts +276 -5
- package/dist/commands/runs/show/outcomes.js +484 -96
- package/dist/commands/snapshots/build/command.d.ts +109 -18
- package/dist/commands/snapshots/build/command.js +72 -36
- package/dist/commands/snapshots/build/metadata.d.ts +4 -0
- package/dist/commands/snapshots/build/metadata.js +5 -1
- package/dist/commands/snapshots/build/outcomes.d.ts +53 -8
- package/dist/commands/snapshots/build/outcomes.js +26 -3
- package/dist/commands/snapshots/list/command.d.ts +72 -7
- package/dist/commands/snapshots/list/command.js +57 -24
- package/dist/commands/snapshots/list/metadata.d.ts +4 -0
- package/dist/commands/snapshots/list/metadata.js +4 -0
- package/dist/commands/snapshots/list/outcomes.d.ts +31 -0
- package/dist/commands/snapshots/list/outcomes.js +25 -2
- package/dist/commands/suites/list/command.d.ts +129 -0
- package/dist/commands/suites/list/command.js +162 -0
- package/dist/commands/suites/list/metadata.d.ts +11 -0
- package/dist/commands/suites/list/metadata.js +15 -0
- package/dist/commands/suites/list/outcomes.d.ts +91 -0
- package/dist/commands/suites/list/outcomes.js +122 -0
- package/dist/commands/suites/metadata.js +8 -0
- package/dist/commands/test/command.d.ts +1389 -0
- package/dist/commands/test/command.js +583 -0
- package/dist/commands/test/metadata.js +8 -0
- package/dist/commands/test/outcomes.d.ts +765 -0
- package/dist/commands/test/outcomes.js +140 -0
- package/dist/commands/test/plan.d.ts +92 -0
- package/dist/commands/test/plan.js +128 -0
- package/dist/commands/test/test-words.d.ts +12 -0
- package/dist/commands/test/test-words.js +42 -0
- package/dist/config/check-resources.d.ts +14 -0
- package/dist/config/check-resources.js +98 -0
- package/dist/config/check-runner.d.ts +13 -0
- package/dist/config/check-runner.js +54 -0
- package/dist/config/check-suites.d.ts +14 -0
- package/dist/config/check-suites.js +99 -0
- package/dist/config/gateways.d.ts +24 -0
- package/dist/config/index.d.ts +6 -3
- package/dist/config/index.js +3 -1
- package/dist/config/live/file-lists-file-gateway.d.ts +4 -0
- package/dist/config/live/file-lists-file-gateway.js +27 -0
- package/dist/config/load.d.ts +11 -10
- package/dist/config/load.js +35 -103
- package/dist/config/recipe-run.d.ts +8 -1
- package/dist/config/recipe-run.js +2 -1
- package/dist/config/resolve.d.ts +3 -2
- package/dist/config/resolve.js +6 -3
- package/dist/config/resolver.d.ts +20 -6
- package/dist/config/resolver.js +11 -8
- package/dist/config/runner.d.ts +24 -0
- package/dist/config/runner.js +4 -0
- package/dist/config/schema.d.ts +26 -18
- package/dist/config/schema.js +41 -9
- package/dist/config/settings-file.d.ts +9 -3
- package/dist/config/settings-file.js +41 -4
- package/dist/config/suite.d.ts +39 -0
- package/dist/config/suite.js +5 -0
- package/dist/config-file/define.d.ts +49 -18
- package/dist/config-file/define.js +9 -8
- package/dist/config-file/runner.d.ts +12 -0
- package/dist/config-file/runner.js +9 -0
- package/dist/context.d.ts +13 -8
- package/dist/context.js +13 -4
- package/dist/core/across-sandboxes.d.ts +43 -0
- package/dist/core/across-sandboxes.js +319 -0
- package/dist/core/before-run.d.ts +5 -3
- package/dist/core/before-run.js +12 -1
- package/dist/core/events.d.ts +62 -6
- package/dist/core/events.js +14 -0
- package/dist/core/index.d.ts +4 -2
- package/dist/core/index.js +3 -1
- package/dist/core/payload.d.ts +7 -4
- package/dist/core/payload.js +10 -4
- package/dist/core/presentations.js +1 -1
- package/dist/core/resource.d.ts +1 -1
- package/dist/core/resources.d.ts +56 -6
- package/dist/core/resources.js +81 -5
- package/dist/core/run-state.js +9 -0
- package/dist/core/run.d.ts +77 -15
- package/dist/core/run.js +150 -86
- package/dist/core/sandbox-end.d.ts +64 -0
- package/dist/core/sandbox-end.js +128 -0
- package/dist/core/timeline.d.ts +4 -4
- package/dist/core/timeline.js +3 -3
- package/dist/credential/live/vercel-cli-gateway.d.ts +7 -0
- package/dist/credential/live/vercel-cli-gateway.js +14 -1
- package/dist/extensions/github/context.d.ts +1 -1
- package/dist/extensions/github/definition.d.ts +11 -9
- package/dist/extensions/github/definition.js +8 -6
- package/dist/extensions/github/extension.d.ts +3 -3
- package/dist/extensions/github/fixture-repo.d.ts +21 -2
- package/dist/extensions/github/fixture-repo.js +31 -2
- package/dist/extensions/github/index.d.ts +2 -2
- package/dist/extensions/github/index.js +2 -2
- package/dist/extensions/github/lifecycle.d.ts +16 -6
- package/dist/extensions/github/lifecycle.js +42 -25
- package/dist/extensions/github/options.d.ts +17 -11
- package/dist/extensions/github/options.js +14 -13
- package/dist/extensions/github/refusals.d.ts +23 -6
- package/dist/extensions/github/refusals.js +34 -12
- package/dist/extensions/github/resource.d.ts +21 -12
- package/dist/extensions/github/resource.js +16 -8
- package/dist/extensions/github/run/payload.d.ts +6 -6
- package/dist/extensions/github/run/payload.js +3 -5
- package/dist/extensions/github/split.d.ts +10 -0
- package/dist/extensions/github/split.js +12 -0
- package/dist/extensions/playwright/driver.js +6 -26
- package/dist/extensions/playwright/extension.js +1 -1
- package/dist/extensions/testserver/commands/pool/create/command.js +8 -8
- package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
- package/dist/extensions/testserver/definition.d.ts +4 -4
- package/dist/extensions/testserver/definition.js +41 -31
- package/dist/extensions/testserver/extension.d.ts +4 -5
- package/dist/extensions/testserver/extension.js +14 -41
- package/dist/extensions/testserver/index.d.ts +1 -1
- package/dist/extensions/testserver/index.js +1 -1
- package/dist/extensions/testserver/lifecycle.d.ts +10 -2
- package/dist/extensions/testserver/lifecycle.js +29 -6
- package/dist/extensions/testserver/options/rules.d.ts +5 -5
- package/dist/extensions/testserver/options/rules.js +10 -8
- package/dist/extensions/testserver/options/sandboxes.d.ts +4 -2
- package/dist/extensions/testserver/options/sandboxes.js +8 -3
- package/dist/extensions/testserver/pool/gateways.d.ts +29 -4
- package/dist/extensions/testserver/pool/index.d.ts +2 -2
- package/dist/extensions/testserver/pool/index.js +1 -1
- package/dist/extensions/testserver/pool/lease.d.ts +10 -0
- package/dist/extensions/testserver/pool/lease.js +21 -0
- package/dist/extensions/testserver/pool/live/pool-store-gateway.js +38 -3
- package/dist/extensions/testserver/refusals.d.ts +12 -0
- package/dist/extensions/testserver/refusals.js +18 -0
- package/dist/extensions/testserver/release.d.ts +16 -0
- package/dist/extensions/testserver/release.js +56 -4
- package/dist/extensions/testserver/resource.d.ts +4 -4
- package/dist/extensions/testserver/resource.js +1 -1
- package/dist/extensions/testserver/split.d.ts +9 -0
- package/dist/extensions/testserver/split.js +22 -0
- package/dist/extensions/testserver/vitest/fixtures.d.ts +5 -5
- package/dist/extensions/testserver/vitest/fixtures.js +9 -38
- package/dist/extensions/vitest/driver.d.ts +7 -0
- package/dist/extensions/vitest/driver.js +33 -37
- package/dist/extensions/vitest/extension.js +1 -1
- package/dist/extensions/vitest/plan/plan-over.d.ts +8 -1
- package/dist/extensions/vitest/plan/plan-over.js +16 -2
- package/dist/extensions.d.ts +17 -16
- package/dist/extensions.js +5 -4
- package/dist/forward-sigterm.js +1 -1
- package/dist/launcher-resolvers/local-services.d.ts +1 -1
- package/dist/live-app.d.ts +3 -1
- package/dist/live-app.js +9 -5
- package/dist/local-services.js +1 -1
- package/dist/planning/driver-file-lists.d.ts +61 -0
- package/dist/planning/driver-file-lists.js +66 -0
- package/dist/{commands/exec → planning}/driver-refusals.d.ts +11 -10
- package/dist/{commands/exec → planning}/driver-refusals.js +18 -14
- package/dist/planning/file-lists-file.d.ts +58 -0
- package/dist/planning/file-lists-file.js +105 -0
- package/dist/planning/file-lists.d.ts +28 -0
- package/dist/planning/file-lists.js +52 -0
- package/dist/{commands/exec → planning}/final-results.d.ts +1 -1
- package/dist/{commands/exec → planning}/final-results.js +6 -6
- package/dist/planning/plan-only.d.ts +81 -0
- package/dist/planning/plan-only.js +83 -0
- package/dist/{commands/exec → planning}/redaction.d.ts +2 -2
- package/dist/{commands/exec → planning}/redaction.js +5 -4
- package/dist/{commands/exec → planning}/resource-flags.d.ts +5 -12
- package/dist/{commands/exec → planning}/resource-flags.js +6 -16
- package/dist/planning/run-kind-flags.d.ts +20 -0
- package/dist/planning/run-kind-flags.js +48 -0
- package/dist/planning/run-plan.d.ts +30 -0
- package/dist/planning/run-plan.js +4 -0
- package/dist/planning/sandbox-placeholders.d.ts +22 -0
- package/dist/planning/sandbox-placeholders.js +60 -0
- package/dist/planning/suite-not-found.d.ts +37 -0
- package/dist/planning/suite-not-found.js +36 -0
- package/dist/planning/suites.d.ts +43 -0
- package/dist/planning/suites.js +89 -0
- package/dist/{commands/exec → planning}/test-plan.d.ts +8 -3
- package/dist/{commands/exec → planning}/test-plan.js +32 -4
- package/dist/playwright/reporter.d.ts +20 -8
- package/dist/playwright/reporter.js +195 -15
- package/dist/presentation.d.ts +10 -6
- package/dist/presentation.js +13 -15
- package/dist/run-directory/gateways.d.ts +60 -4
- package/dist/run-directory/index.d.ts +4 -4
- package/dist/run-directory/index.js +2 -1
- package/dist/run-directory/live/run-directory-gateway.js +92 -16
- package/dist/run-directory/plan.d.ts +35 -2
- package/dist/run-directory/plan.js +44 -7
- package/dist/run-directory/reader.d.ts +26 -5
- package/dist/run-directory/reader.js +24 -1
- package/dist/run-directory/recording.d.ts +75 -49
- package/dist/run-directory/recording.js +214 -28
- package/dist/run-directory/run-directory.d.ts +22 -1
- package/dist/run-directory/run-directory.js +24 -0
- package/dist/run-directory/run-record.d.ts +144 -21
- package/dist/run-directory/run-record.js +118 -19
- package/dist/run-directory/timeline-facts.js +4 -4
- package/dist/runner/build-snapshots.d.ts +7 -7
- package/dist/runner/build-snapshots.js +12 -16
- package/dist/runner/events.d.ts +29 -8
- package/dist/runner/gateways.d.ts +59 -8
- package/dist/runner/index.d.ts +6 -4
- package/dist/runner/index.js +3 -2
- package/dist/runner/live/sandbox-gateway.js +177 -33
- package/dist/runner/live/terminal.d.ts +15 -3
- package/dist/runner/live/terminal.js +25 -3
- package/dist/runner/network-policy.d.ts +55 -0
- package/dist/runner/network-policy.js +46 -0
- package/dist/runner/policy-writes.d.ts +40 -0
- package/dist/runner/policy-writes.js +124 -0
- package/dist/runner/prepare.d.ts +6 -7
- package/dist/runner/ready.d.ts +39 -10
- package/dist/runner/ready.js +59 -47
- package/dist/runner/recipe-check.d.ts +6 -0
- package/dist/runner/recipe-check.js +29 -0
- package/dist/runner/recipe-secrets.d.ts +67 -0
- package/dist/runner/recipe-secrets.js +230 -0
- package/dist/runner/recipe.d.ts +118 -28
- package/dist/runner/recipe.js +147 -154
- package/dist/runner/sandboxed-command.d.ts +24 -10
- package/dist/runner/sandboxed-command.js +37 -12
- package/dist/runner/scope.d.ts +107 -21
- package/dist/runner/scope.js +274 -54
- package/dist/runner/secrets.d.ts +42 -31
- package/dist/runner/secrets.js +62 -40
- package/dist/runner/session.d.ts +59 -26
- package/dist/runner/session.js +82 -41
- package/dist/runner/snapshot-build.d.ts +7 -4
- package/dist/runner/snapshot-build.js +48 -28
- package/dist/runner/snapshot-choice.d.ts +37 -0
- package/dist/runner/snapshot-choice.js +38 -0
- package/dist/runner/snapshot-key.d.ts +16 -14
- package/dist/runner/snapshot-key.js +24 -18
- package/dist/runner/steps.d.ts +13 -5
- package/dist/runner/steps.js +34 -4
- package/dist/runner/time-limit.d.ts +10 -0
- package/dist/runner/time-limit.js +43 -0
- package/dist/sdk/extension/commands.d.ts +1 -7
- package/dist/sdk/extension/driver.d.ts +39 -46
- package/dist/sdk/extension/driver.js +6 -6
- package/dist/sdk/extension/index.d.ts +3 -3
- package/dist/sdk/extension/index.js +3 -4
- package/dist/sdk/extension/lifecycle.d.ts +52 -9
- package/dist/sdk/extension/lifecycle.js +1 -1
- package/dist/sdk/extension/resource-definition.d.ts +13 -10
- package/dist/sdk/extension/resource-definition.js +7 -2
- package/dist/sdk/extension/resource.d.ts +2 -2
- package/dist/sdk/extension/secret-source.d.ts +58 -0
- package/dist/sdk/extension/secret-source.js +78 -0
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/run/launcher.d.ts +1 -1
- package/dist/sdk/run/launcher.js +1 -1
- package/dist/sdk/run/payload.d.ts +16 -1
- package/dist/sdk/run/payload.js +17 -2
- package/dist/sdk/run/redact.js +2 -2
- package/dist/sdk/run/test-events.d.ts +23 -6
- package/dist/sdk/run/test-events.js +6 -4
- package/dist/sdk/run/test-result-writer.d.ts +8 -3
- package/dist/sdk/run/test-result-writer.js +22 -2
- package/dist/{commands/exec → shared}/cleanup.d.ts +3 -3
- package/dist/{commands/exec → shared}/cleanup.js +11 -6
- package/dist/shared/job-summary.d.ts +19 -0
- package/dist/{commands/exec → shared}/job-summary.js +17 -0
- package/dist/shared/sandbox-table.d.ts +48 -0
- package/dist/shared/sandbox-table.js +109 -0
- package/dist/{commands/exec → shared}/snapshot-text.d.ts +1 -1
- package/dist/{commands/exec → shared}/tests-summary.d.ts +22 -6
- package/dist/{commands/exec → shared}/tests-summary.js +74 -31
- package/dist/{commands/exec → shared}/text.d.ts +7 -2
- package/dist/{commands/exec → shared}/text.js +9 -1
- package/dist/{commands/exec → shared}/waterfall.d.ts +8 -6
- package/dist/{commands/exec → shared}/waterfall.js +71 -24
- package/dist/shared/worker-chart.d.ts +172 -0
- package/dist/shared/worker-chart.js +623 -0
- package/dist/vitest/config.d.ts +35 -11
- package/dist/vitest/config.js +47 -14
- package/dist/vitest/index.d.ts +1 -1
- package/dist/vitest/index.js +3 -3
- package/dist/vitest/sequencer.d.ts +23 -0
- package/dist/vitest/sequencer.js +73 -0
- package/dist/vitest/setup.d.ts +1 -0
- package/dist/vitest/setup.js +34 -0
- package/dist/vitest/test-events.d.ts +32 -6
- package/dist/vitest/test-events.js +25 -5
- package/dist/vitest/test-results.d.ts +8 -3
- package/dist/vitest/test-results.js +6 -0
- package/package.json +7 -2
- package/skills/overview.md +21 -17
- package/skills/plan-runs.md +67 -0
- package/skills/read-run-output.md +51 -19
- package/dist/chunks/chunk-BFLYGMG3.js +0 -607
- package/dist/chunks/chunk-HOKDKP5A.js +0 -49
- package/dist/chunks/chunk-IVRRGGCD.js +0 -201
- package/dist/chunks/chunk-NMVODY3P.js +0 -19
- package/dist/commands/exec/define-run-command.d.ts +0 -671
- package/dist/commands/exec/define-run-command.js +0 -91
- package/dist/commands/exec/job-summary.d.ts +0 -10
- package/dist/commands/exec/worker-chart.d.ts +0 -87
- package/dist/commands/exec/worker-chart.js +0 -343
- package/dist/commands/playwright/command.d.ts +0 -661
- package/dist/commands/playwright/command.js +0 -31
- package/dist/commands/playwright/metadata.js +0 -8
- package/dist/commands/vitest/command.d.ts +0 -662
- package/dist/commands/vitest/command.js +0 -31
- package/dist/commands/vitest/metadata.js +0 -8
- package/dist/sdk/extension/ci.d.ts +0 -2
- package/dist/sdk/extension/ci.js +0 -6
- package/dist/chunks/{chunk-YM6TZV4L.js → chunk-VL7WFTVQ.js} +52 -52
- package/dist/commands/{playwright → suites}/metadata.d.ts +1 -1
- package/dist/commands/{vitest → test}/metadata.d.ts +1 -1
- /package/dist/{commands → shared}/dashboard.d.ts +0 -0
- /package/dist/{commands → shared}/dashboard.js +0 -0
- /package/dist/{commands/exec → shared}/snapshot-text.js +0 -0
package/dist/runner/scope.d.ts
CHANGED
|
@@ -1,14 +1,31 @@
|
|
|
1
|
+
import type { SandboxCredential } from "../sdk/extension/index.ts";
|
|
1
2
|
import type { Clock, Timer } from "../time/index.ts";
|
|
2
3
|
import type { KeptSandbox, NotDeletedSandbox, NotKeptSandbox, NotStoppedSandbox, RunnerProgress } from "./events.ts";
|
|
3
|
-
import type { RunnerSandbox, RunnerSandboxGateway, RunnerSandboxPlacement, RunnerSandboxResult, RunnerStartFailure, SandboxAccess, SavedSnapshot } from "./gateways.ts";
|
|
4
|
+
import type { RunnerSandbox, RunnerSandboxFailure, RunnerSandboxGateway, RunnerSandboxPlacement, RunnerSandboxResult, RunnerStartFailure, SandboxAccess, SavedSnapshot } from "./gateways.ts";
|
|
5
|
+
import { type NetworkPolicyWriteFailure, type NetworkPolicyWriteResult, type RunnerReachPolicy } from "./network-policy.ts";
|
|
4
6
|
/** How long closing waits for a create in flight: 20 seconds. */
|
|
5
7
|
export declare const CREATE_SETTLE_MS = 20000;
|
|
6
8
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
7
9
|
export declare const SNAPSHOT_SETTLE_MS: number;
|
|
10
|
+
/** How long the scope waits for one sandbox's stop, and then for its delete: 30 seconds each. */
|
|
11
|
+
export declare const SANDBOX_CALL_LIMIT_MS = 30000;
|
|
12
|
+
/**
|
|
13
|
+
* How long closing waits for keeping the runner sandbox running: 1 minute. That ends every process the run started in
|
|
14
|
+
* it first, which in the live gateway takes up to 15 seconds of grace periods, beside its kills and the extend call.
|
|
15
|
+
*/
|
|
16
|
+
export declare const KEEP_RUNNING_LIMIT_MS = 60000;
|
|
8
17
|
/**
|
|
9
18
|
* What closing a scope left: the runner sandbox it kept running (`kept`), or couldn't keep running and so stopped and
|
|
10
|
-
* deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete.
|
|
19
|
+
* deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete. A runner sandbox whose
|
|
20
|
+
* policy may still hold a credential, because removing the credential failed, is `notKept`, saying so.
|
|
11
21
|
*/
|
|
22
|
+
/**
|
|
23
|
+
* Whether fencing the run's sandboxes left the runner sandbox fenced: false when a runner sandbox failed to stop or
|
|
24
|
+
* had no answer in time (so code there may still run and reach what the run's resources took), true otherwise.
|
|
25
|
+
*/
|
|
26
|
+
export interface RunnerFenceOutcome {
|
|
27
|
+
readonly runnerSandboxFenced: boolean;
|
|
28
|
+
}
|
|
12
29
|
export interface RunnerScopeFacts {
|
|
13
30
|
readonly kept: KeptSandbox | null;
|
|
14
31
|
readonly notKept: NotKeptSandbox | null;
|
|
@@ -16,42 +33,111 @@ export interface RunnerScopeFacts {
|
|
|
16
33
|
readonly notDeleted: readonly NotDeletedSandbox[];
|
|
17
34
|
}
|
|
18
35
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
|
|
36
|
+
* Why the scope saved no snapshot of a build sandbox: a Sandbox failure, or `credential-not-revoked` when its policy
|
|
37
|
+
* may hold a credential (the recipe's or a resource's) and writing the policy without it failed (`failure`).
|
|
38
|
+
*/
|
|
39
|
+
export type ScopeSaveFailure = RunnerSandboxFailure | {
|
|
40
|
+
readonly kind: "credential-not-revoked";
|
|
41
|
+
readonly failure: NetworkPolicyWriteFailure;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* What a sandbox the scope starts is created with: its placement, but for the network policy. The scope gives every
|
|
45
|
+
* sandbox it starts its base policy, the one it writes again whenever it revokes a credential.
|
|
46
|
+
*/
|
|
47
|
+
export type ScopedSandboxPlacement = Omit<RunnerSandboxPlacement, "networkPolicy">;
|
|
48
|
+
/**
|
|
49
|
+
* Starts sandboxes, grants and revokes their credentials, and saves runner snapshots on the scope's behalf, so `close`
|
|
50
|
+
* knows about every one. It creates each sandbox with its base policy. A start once closing has begun answers `aborted`
|
|
51
|
+
* and creates nothing. A start in flight is never aborted: an aborted create could still leave a sandbox the scope
|
|
52
|
+
* never hears of, so closing waits for it instead, and stops and deletes the sandbox it returns.
|
|
23
53
|
*/
|
|
24
54
|
export interface RunnerSandboxScope {
|
|
25
|
-
startBuildSandbox(access: SandboxAccess, request:
|
|
55
|
+
startBuildSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
26
56
|
readonly runtime: string;
|
|
27
57
|
}): Promise<RunnerSandboxResult<RunnerSandbox>>;
|
|
28
|
-
startRunnerSandbox(access: SandboxAccess, request:
|
|
58
|
+
startRunnerSandbox(access: SandboxAccess, request: ScopedSandboxPlacement & {
|
|
29
59
|
readonly snapshotId: string;
|
|
30
60
|
}): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
|
|
31
61
|
/**
|
|
32
|
-
*
|
|
62
|
+
* Grants `sandbox` `credentials`: it writes the scope's base policy with them (`withCredentials`), a whole
|
|
63
|
+
* replacement, so the list is every credential that should be in place from now on. The scope's users write no
|
|
64
|
+
* other policy, so every write keeps what the sandbox was created to reach, and no credential stays in place but as
|
|
65
|
+
* the scope's own to revoke. Each write answers within `NETWORK_POLICY_WRITE_LIMIT_MS`. The scope sends one
|
|
66
|
+
* sandbox's writes one at a time: a write waits until the one before it has answered, and `signal` ends only that
|
|
67
|
+
* wait; a write once sent is waited for. From the start of the write, the scope takes the policy to hold a credential
|
|
68
|
+
* until a write without credentials answers ok, since a failed write may have changed the policy or not. A write with
|
|
69
|
+
* no answer within its limit may still take effect at any time, so the scope sends no other write to that sandbox,
|
|
70
|
+
* answering `timed-out`, and stops it at once.
|
|
71
|
+
*
|
|
72
|
+
* When the write fails, or `signal` aborted by the time it answered, it revokes the credentials (as
|
|
73
|
+
* `revokeCredentials`), since the write may have taken, and answers the failure, `aborted` for the signal. Once
|
|
74
|
+
* closing has begun, it writes nothing and answers `aborted`, and closing revokes any credential itself. A grant
|
|
75
|
+
* whose write was sent before then answers `aborted` once that write answers, and closing revokes the credential.
|
|
76
|
+
* Otherwise it answers ok, and the credentials stay in place until the next grant, a revoke, or closing.
|
|
77
|
+
*/
|
|
78
|
+
grantCredentials(sandbox: RunnerSandbox, credentials: readonly Required<SandboxCredential>[], signal: AbortSignal): Promise<NetworkPolicyWriteResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Revokes every credential in `sandbox`'s policy: it writes the base policy alone, which no signal stops, within
|
|
81
|
+
* `NETWORK_POLICY_WRITE_LIMIT_MS`, after any write in flight to it has answered; a removal already in flight is that
|
|
82
|
+
* write. With no credential that may be in place, it writes nothing and answers ok. Once closing has begun, it writes
|
|
83
|
+
* nothing and answers `aborted`, since closing revokes any credential itself. A failed revoke leaves the sandbox's
|
|
84
|
+
* policy taken to hold a credential, so the scope never keeps or saves the sandbox.
|
|
85
|
+
*/
|
|
86
|
+
revokeCredentials(sandbox: RunnerSandbox): Promise<NetworkPolicyWriteResult>;
|
|
87
|
+
/**
|
|
88
|
+
* Saves a build sandbox as a runner snapshot, then deletes it at once; a failed save leaves it to `close`. When the
|
|
89
|
+
* sandbox's policy may hold a credential, it first writes the policy without the injection, and saves nothing
|
|
90
|
+
* when that fails (`credential-not-revoked`).
|
|
33
91
|
*/
|
|
34
92
|
saveSnapshot(sandbox: RunnerSandbox, request: {
|
|
35
93
|
readonly expirationMs: number;
|
|
36
|
-
}): Promise<RunnerSandboxResult<SavedSnapshot>>;
|
|
94
|
+
}): Promise<RunnerSandboxResult<SavedSnapshot, ScopeSaveFailure>>;
|
|
37
95
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
96
|
+
* Fences every sandbox the scope holds, before its owner releases the run's resources. It waits up to
|
|
97
|
+
* `CREATE_SETTLE_MS` for creates in flight and up to `SNAPSHOT_SETTLE_MS` for a snapshot saving, and stops every
|
|
98
|
+
* sandbox the scope doesn't keep; before it stops one whose policy may hold a credential, it writes the policy
|
|
99
|
+
* without it. For the runner sandbox it keeps, it always writes a policy with no network access (`denyAllPolicy`),
|
|
100
|
+
* which removes any injection too. Each write answers within `NETWORK_POLICY_WRITE_LIMIT_MS`, after any write in
|
|
101
|
+
* flight to it has answered. When the write fails, or a write had no answer within its limit, it doesn't keep the
|
|
102
|
+
* sandbox: it stops it within `SANDBOX_CALL_LIMIT_MS`, and `notKept` says why. When the storm command was canceled,
|
|
103
|
+
* it first waits for the removals the cancel began, and then sends no second removal to a sandbox whose injection is
|
|
104
|
+
* gone, and no second stop to one a failed removal stopped; the runner sandbox it keeps still gets the policy with no
|
|
105
|
+
* network access. Once it has answered, the scope stops listening for the signal.
|
|
106
|
+
*
|
|
107
|
+
* It answers whether it fenced the runner sandbox (`runnerSandboxFenced`): false when a sandbox of role `runner` is
|
|
108
|
+
* in `notStopped` as the fence answers, since its stop failed or had no answer within its limit and it runs on until
|
|
109
|
+
* its own timeout, whether the scope would have kept it or not; true otherwise. A build sandbox that didn't stop
|
|
110
|
+
* doesn't count, since it never gets the run payload, and the runner sandbox the scope keeps is fenced, since the
|
|
111
|
+
* fence left it with no network access. Calling it again answers the first call.
|
|
112
|
+
*/
|
|
113
|
+
fence(): Promise<RunnerFenceOutcome>;
|
|
114
|
+
/**
|
|
115
|
+
* Ends closing, once the fence has answered (`fence`, which it calls when its owner hasn't): deletes every sandbox
|
|
116
|
+
* the fence stopped, each within `SANDBOX_CALL_LIMIT_MS`, and keeps the runner sandbox the fence kept running at
|
|
117
|
+
* least the keep time from now, with nothing the run started still running in it, within `KEEP_RUNNING_LIMIT_MS`,
|
|
118
|
+
* reporting `sandbox-kept`, or stops and deletes it when it can't. Calling it again answers the first call's report.
|
|
43
119
|
*/
|
|
44
120
|
close(): Promise<RunnerScopeFacts>;
|
|
45
121
|
}
|
|
122
|
+
/** What a scope is opened with (`runnerSandboxScope`). */
|
|
123
|
+
export interface RunnerScopeSettings {
|
|
124
|
+
/** How long closing keeps the runner sandbox running, in milliseconds; 0 stops and deletes it with the rest. */
|
|
125
|
+
readonly keepMs: number;
|
|
126
|
+
/** The run's policy with no credential (`runnerNetworkPolicy`). */
|
|
127
|
+
readonly basePolicy: RunnerReachPolicy;
|
|
128
|
+
/** The storm command's signal: its abort cancels the command, which stops the scope's sandboxes. */
|
|
129
|
+
readonly signal: AbortSignal;
|
|
130
|
+
/** Whether the command runs now, for the `stopping` event; by default it never does. */
|
|
131
|
+
readonly commandRunning?: () => boolean;
|
|
132
|
+
}
|
|
46
133
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
134
|
+
* Opens a sandbox scope over `context.runnerSandboxes`, bounded on `context.timer` and `context.clock`, reporting to
|
|
135
|
+
* `progress`. Creates every sandbox with `settings.basePolicy`, and listens for `settings.signal` until `fence`
|
|
136
|
+
* answers (reporting `stopping`, revoking in-place credentials immediately, and stopping unkept sandboxes). See
|
|
137
|
+
* `RunnerSandboxScope` and `README.md` for each method's contract.
|
|
50
138
|
*/
|
|
51
139
|
export declare function runnerSandboxScope(context: {
|
|
52
140
|
readonly runnerSandboxes: RunnerSandboxGateway;
|
|
53
141
|
readonly timer: Timer;
|
|
54
142
|
readonly clock: Clock;
|
|
55
|
-
}, progress: RunnerProgress,
|
|
56
|
-
readonly keepMs: number;
|
|
57
|
-
}): RunnerSandboxScope;
|
|
143
|
+
}, progress: RunnerProgress, settings: RunnerScopeSettings): RunnerSandboxScope;
|
package/dist/runner/scope.js
CHANGED
|
@@ -1,104 +1,320 @@
|
|
|
1
|
-
// The sandbox scope: owns every sandbox one
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// The sandbox scope: owns every sandbox one storm command creates, so every one is stopped and deleted (or, for the
|
|
2
|
+
// kept runner sandbox when `keepMs` > 0, fenced with no network access and kept running). Every policy write goes
|
|
3
|
+
// through the scope via `policy-writes.ts`, so the scope knows which sandboxes may hold a credential and revokes every
|
|
4
|
+
// credential before saving a snapshot, keeping, or stopping a sandbox. It listens for the command's abort signal,
|
|
5
|
+
// revoking in-place credentials immediately on cancel. See `README.md` ("Network policy and sandbox scope") for the
|
|
6
|
+
// full lifecycle contract.
|
|
7
|
+
import { denyAllPolicy, withCredentials, } from "./network-policy.js";
|
|
8
|
+
import { notFencedMessage, notRemovedMessage, sandboxPolicyWriter } from "./policy-writes.js";
|
|
9
|
+
import { callWithin } from "./time-limit.js";
|
|
5
10
|
/** How long closing waits for a create in flight: 20 seconds. */
|
|
6
11
|
export const CREATE_SETTLE_MS = 20_000;
|
|
7
12
|
/** How long closing waits for a runner snapshot still saving: 2 minutes. */
|
|
8
13
|
export const SNAPSHOT_SETTLE_MS = 2 * 60_000;
|
|
14
|
+
/** How long the scope waits for one sandbox's stop, and then for its delete: 30 seconds each. */
|
|
15
|
+
export const SANDBOX_CALL_LIMIT_MS = 30_000;
|
|
9
16
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* rest when `keepMs` is 0.
|
|
17
|
+
* How long closing waits for keeping the runner sandbox running: 1 minute. That ends every process the run started in
|
|
18
|
+
* it first, which in the live gateway takes up to 15 seconds of grace periods, beside its kills and the extend call.
|
|
13
19
|
*/
|
|
14
|
-
export
|
|
20
|
+
export const KEEP_RUNNING_LIMIT_MS = 60_000;
|
|
21
|
+
/**
|
|
22
|
+
* Opens a sandbox scope over `context.runnerSandboxes`, bounded on `context.timer` and `context.clock`, reporting to
|
|
23
|
+
* `progress`. Creates every sandbox with `settings.basePolicy`, and listens for `settings.signal` until `fence`
|
|
24
|
+
* answers (reporting `stopping`, revoking in-place credentials immediately, and stopping unkept sandboxes). See
|
|
25
|
+
* `RunnerSandboxScope` and `README.md` for each method's contract.
|
|
26
|
+
*/
|
|
27
|
+
export function runnerSandboxScope(context, progress, settings) {
|
|
15
28
|
const { runnerSandboxes: sandboxes, timer, clock } = context;
|
|
16
|
-
|
|
17
|
-
const creating = new Set();
|
|
29
|
+
let phase = { kind: "open", sandboxes: new Map(), creating: new Set() };
|
|
18
30
|
const saving = new Set();
|
|
19
31
|
const notStopped = [];
|
|
20
32
|
const notDeleted = [];
|
|
21
33
|
let kept = null;
|
|
22
34
|
let notKept = null;
|
|
23
|
-
let
|
|
35
|
+
let settling;
|
|
36
|
+
let stoppingOthers;
|
|
37
|
+
/** What the cancel began, once the storm command was canceled. */
|
|
38
|
+
let stoppingUnkept;
|
|
39
|
+
/** The removal of every injection that the cancel began, which the fence waits for. */
|
|
40
|
+
let removingOnSignal;
|
|
41
|
+
let fencing;
|
|
42
|
+
let closingScope;
|
|
43
|
+
/** Each sandbox's stop, once the scope began one: whether it stopped. A sandbox is stopped once. */
|
|
44
|
+
const stops = new Map();
|
|
45
|
+
/** Whether a stop has already begun for `sandbox`, meaning it is already lost and takes no further policy write. */
|
|
46
|
+
const isStopping = (sandbox) => stops.has(sandbox);
|
|
47
|
+
const currentPhase = () => phase;
|
|
48
|
+
const beginClosing = () => {
|
|
49
|
+
if (phase.kind === "open")
|
|
50
|
+
phase = { kind: "settling", sandboxes: phase.sandboxes, creating: phase.creating };
|
|
51
|
+
};
|
|
24
52
|
const track = (set, task) => {
|
|
25
53
|
set.add(task);
|
|
26
54
|
const forget = () => set.delete(task);
|
|
27
55
|
void task.then(forget, forget);
|
|
28
56
|
return task;
|
|
29
57
|
};
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
notDeleted.push({ name: sandbox.name, role: sandbox.role, message: failureMessage(deleted.failure) });
|
|
58
|
+
/** Records why the runner sandbox the scope would have kept isn't kept: the first reason given. */
|
|
59
|
+
const recordNotKept = (sandbox, message) => {
|
|
60
|
+
notKept ??= { name: sandbox.name, message };
|
|
34
61
|
};
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
38
|
-
|
|
62
|
+
const deleteSandbox = async (sandbox) => {
|
|
63
|
+
const deleted = await callWithin(timer, SANDBOX_CALL_LIMIT_MS, (signal) => sandboxes.delete(sandbox, signal));
|
|
64
|
+
if (deleted === null || !deleted.ok)
|
|
65
|
+
notDeleted.push({
|
|
39
66
|
name: sandbox.name,
|
|
40
67
|
role: sandbox.role,
|
|
41
|
-
|
|
42
|
-
message: failureMessage(stopped.failure),
|
|
68
|
+
message: callFailureMessage(deleted, SANDBOX_CALL_LIMIT_MS),
|
|
43
69
|
});
|
|
44
|
-
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Stops `sandbox` within `SANDBOX_CALL_LIMIT_MS`, once however often it is asked: whether it stopped, reporting it
|
|
73
|
+
* in `notStopped` when it failed or had no answer by then.
|
|
74
|
+
*/
|
|
75
|
+
const stop = (sandbox) => {
|
|
76
|
+
let stopping = stops.get(sandbox);
|
|
77
|
+
if (stopping === undefined) {
|
|
78
|
+
stopping = (async () => {
|
|
79
|
+
const answer = await callWithin(timer, SANDBOX_CALL_LIMIT_MS, (signal) => sandboxes.stop(sandbox, signal));
|
|
80
|
+
if (answer !== null && answer.ok)
|
|
81
|
+
return true;
|
|
82
|
+
notStopped.push({
|
|
83
|
+
name: sandbox.name,
|
|
84
|
+
role: sandbox.role,
|
|
85
|
+
timeoutMinutes: Math.round(sandbox.timeoutMs / 60_000),
|
|
86
|
+
message: callFailureMessage(answer, SANDBOX_CALL_LIMIT_MS),
|
|
87
|
+
});
|
|
88
|
+
return false;
|
|
89
|
+
})();
|
|
90
|
+
stops.set(sandbox, stopping);
|
|
91
|
+
}
|
|
92
|
+
return stopping;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Gives up on keeping `sandbox` and stops it: when the scope would have kept it, records `message` (when given) as
|
|
96
|
+
* the first reason it isn't kept, clears `entry.keep`, and starts (or joins) its memoized stop.
|
|
97
|
+
*/
|
|
98
|
+
const giveUp = (sandbox, message) => {
|
|
99
|
+
const entry = phase.sandboxes.get(sandbox);
|
|
100
|
+
if (entry?.keep === true) {
|
|
101
|
+
if (message !== undefined)
|
|
102
|
+
recordNotKept(sandbox, message);
|
|
103
|
+
entry.keep = false;
|
|
45
104
|
}
|
|
46
|
-
|
|
105
|
+
return stop(sandbox);
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Every policy write, one sandbox at a time, and which sandbox's policy may hold a credential. A sandbox whose write
|
|
109
|
+
* timed out may take that write at any time, so the scope stops it at once, and doesn't keep it, saying why.
|
|
110
|
+
*/
|
|
111
|
+
const policies = sandboxPolicyWriter(context, settings.basePolicy, (sandbox, failure) => {
|
|
112
|
+
void giveUp(sandbox, notFencedMessage(failure, policies.mayInject(sandbox)));
|
|
113
|
+
});
|
|
114
|
+
const stopAndDelete = async (sandbox) => {
|
|
115
|
+
if (await stop(sandbox))
|
|
116
|
+
await deleteSandbox(sandbox);
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Revokes any credential in `sandbox` (stopping it if that fails) and then stops it. Both the removal and the stop
|
|
120
|
+
* are memoized, so overlapping callers send at most one write and one stop.
|
|
121
|
+
*/
|
|
122
|
+
const stopUnkeptSandbox = async (sandbox) => {
|
|
123
|
+
if (policies.mayInject(sandbox))
|
|
124
|
+
await revoke(sandbox);
|
|
125
|
+
await stop(sandbox);
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Fences the runner sandbox the scope keeps: it writes a policy with no network access, which removes any injection
|
|
129
|
+
* too. When the write fails, the scope doesn't keep it, and stops it. It waits first for the removal a signal began:
|
|
130
|
+
* by then the injection is gone, or the sandbox's stop began. One whose stop began, then or while this write was
|
|
131
|
+
* under way, by a signal that couldn't remove its injection and said why it isn't kept, the scope doesn't keep: it
|
|
132
|
+
* takes no other write, and the scope waits for that stop.
|
|
133
|
+
*/
|
|
134
|
+
const fenceKept = async (entry) => {
|
|
135
|
+
const { sandbox } = entry;
|
|
136
|
+
await removingOnSignal;
|
|
137
|
+
let message;
|
|
138
|
+
if (!isStopping(sandbox)) {
|
|
139
|
+
const injecting = policies.mayInject(sandbox);
|
|
140
|
+
const written = await policies.write(sandbox, denyAllPolicy());
|
|
141
|
+
if (!isStopping(sandbox)) {
|
|
142
|
+
if (written.ok)
|
|
143
|
+
return;
|
|
144
|
+
message = notFencedMessage(written.failure, injecting);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
await giveUp(sandbox, message);
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Revokes the injection in one sandbox at once, for a signal or an unkept stop: the removal, or, when that fails,
|
|
151
|
+
* the sandbox's stop (and records why a kept runner sandbox isn't kept). A sandbox whose stop already began needs
|
|
152
|
+
* only that stop's answer.
|
|
153
|
+
*/
|
|
154
|
+
const revoke = async (sandbox) => {
|
|
155
|
+
let message;
|
|
156
|
+
if (!isStopping(sandbox)) {
|
|
157
|
+
const removed = await policies.removeInjections(sandbox);
|
|
158
|
+
if (removed.ok)
|
|
159
|
+
return;
|
|
160
|
+
message = notRemovedMessage(removed.failure);
|
|
161
|
+
}
|
|
162
|
+
await giveUp(sandbox, message);
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* Revokes the injection in each of `injecting` at once (`revoke`). It answers once each holds no injection or its
|
|
166
|
+
* stop has answered, and never throws: each ends on its own, so one that throws, as on a sandbox the gateway no
|
|
167
|
+
* longer knows, doesn't end the others. Calls that overlap send one removal and one stop to a sandbox.
|
|
168
|
+
*/
|
|
169
|
+
const revokeEach = async (injecting) => {
|
|
170
|
+
await Promise.allSettled(injecting.map(revoke));
|
|
47
171
|
};
|
|
48
172
|
/**
|
|
49
173
|
* Keeps the runner sandbox running `keepMs` from now, once the gateway saw every process the run started in it end;
|
|
50
174
|
* when it can't, such as with a process that won't end, stops and deletes it as without a keep time.
|
|
51
175
|
*/
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const keeping = await sandboxes.keepRunning(sandbox, { until
|
|
57
|
-
if (!keeping.ok) {
|
|
58
|
-
|
|
59
|
-
return await
|
|
176
|
+
const keepOrDelete = async (sandbox) => {
|
|
177
|
+
if (isStopping(sandbox))
|
|
178
|
+
return await stopAndDelete(sandbox);
|
|
179
|
+
const until = new Date(clock.now().getTime() + settings.keepMs);
|
|
180
|
+
const keeping = await callWithin(timer, KEEP_RUNNING_LIMIT_MS, (signal) => sandboxes.keepRunning(sandbox, { until }, signal));
|
|
181
|
+
if (keeping === null || !keeping.ok) {
|
|
182
|
+
recordNotKept(sandbox, callFailureMessage(keeping, KEEP_RUNNING_LIMIT_MS));
|
|
183
|
+
return await stopAndDelete(sandbox);
|
|
60
184
|
}
|
|
61
185
|
kept = { name: sandbox.name, stopsAt: keeping.value.stopsAt.toISOString() };
|
|
62
186
|
await progress.emit({ kind: "sandbox-kept", ...kept });
|
|
63
187
|
};
|
|
64
|
-
|
|
65
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Begins closing, once: transitions to `settling`, waits for the work in flight, then freezes the sandbox entries
|
|
190
|
+
* in `closing` for `fence` and `close`.
|
|
191
|
+
*/
|
|
192
|
+
const settle = () => {
|
|
193
|
+
beginClosing();
|
|
194
|
+
return (settling ??= (async () => {
|
|
195
|
+
if (phase.kind === "closing")
|
|
196
|
+
return phase.sandboxes;
|
|
197
|
+
const { creating, sandboxes: entries } = phase;
|
|
198
|
+
if (saving.size > 0)
|
|
199
|
+
await progress.emit({ kind: "waiting-for-snapshot", settleMs: SNAPSHOT_SETTLE_MS });
|
|
200
|
+
await Promise.all([
|
|
201
|
+
settleWithin(timer, creating, CREATE_SETTLE_MS),
|
|
202
|
+
settleWithin(timer, saving, SNAPSHOT_SETTLE_MS),
|
|
203
|
+
]);
|
|
204
|
+
phase = { kind: "closing", sandboxes: entries };
|
|
205
|
+
return entries;
|
|
206
|
+
})());
|
|
207
|
+
};
|
|
208
|
+
/** Stops every sandbox the scope doesn't keep, once the work in flight has settled: the fence's first part. */
|
|
209
|
+
const stopOthers = () => {
|
|
210
|
+
const entries = settle();
|
|
211
|
+
return (stoppingOthers ??= (async () => {
|
|
212
|
+
const unkept = [...(await entries).values()].filter((entry) => !entry.keep);
|
|
213
|
+
await Promise.all(unkept.map(({ sandbox }) => stopUnkeptSandbox(sandbox)));
|
|
214
|
+
})());
|
|
215
|
+
};
|
|
216
|
+
const stopUnkept = () => (stoppingUnkept ??= (async () => {
|
|
217
|
+
beginClosing();
|
|
218
|
+
// Begun before `settle`'s waits, and not held by them: a create in flight or a snapshot saving can take long.
|
|
219
|
+
removingOnSignal = revokeEach(policies.injectingSandboxes());
|
|
220
|
+
await Promise.all([removingOnSignal, stopOthers()]);
|
|
221
|
+
})());
|
|
222
|
+
const fence = () => {
|
|
223
|
+
const settled = settle();
|
|
224
|
+
return (fencing ??= (async () => {
|
|
225
|
+
const entries = await settled;
|
|
226
|
+
const keptEntry = [...entries.values()].find((entry) => entry.keep);
|
|
227
|
+
await Promise.all([stopOthers(), keptEntry === undefined ? undefined : fenceKept(keptEntry)]);
|
|
228
|
+
// A signal's removals, begun before the fence or beside it: each stop they began has answered too.
|
|
229
|
+
await removingOnSignal;
|
|
230
|
+
// Every stop the scope began has answered by now, so `notStopped` holds each one that didn't stop.
|
|
231
|
+
return { runnerSandboxFenced: !notStopped.some(({ role }) => role === "runner") };
|
|
232
|
+
})().finally(() => settings.signal.removeEventListener("abort", onSignal)));
|
|
233
|
+
};
|
|
234
|
+
/** Whether the scope's users may still write a policy: not once closing began. */
|
|
235
|
+
const writable = () => phase.kind === "open";
|
|
236
|
+
const refused = { ok: false, failure: { kind: "aborted" } };
|
|
237
|
+
// Refused once closing began: closing revokes any credential itself.
|
|
238
|
+
const revokeCredentials = async (sandbox) => {
|
|
239
|
+
if (!writable())
|
|
240
|
+
return refused;
|
|
241
|
+
if (!policies.mayInject(sandbox))
|
|
242
|
+
return { ok: true };
|
|
243
|
+
return await policies.removeInjections(sandbox);
|
|
244
|
+
};
|
|
245
|
+
const grantCredentials = async (sandbox, credentials, signal) => {
|
|
246
|
+
if (!writable() || signal.aborted)
|
|
247
|
+
return refused;
|
|
248
|
+
const granted = await policies.write(sandbox, withCredentials(settings.basePolicy, credentials), signal);
|
|
249
|
+
// The signal ends only the wait for a write's turn, so one that came while the write was sent stops it here. So
|
|
250
|
+
// does closing that began meanwhile: then the revoke is refused, and closing revokes.
|
|
251
|
+
if (signal.aborted || !writable()) {
|
|
252
|
+
await revokeCredentials(sandbox);
|
|
253
|
+
return refused;
|
|
254
|
+
}
|
|
255
|
+
// A failed write may have taken, so the credentials are revoked at once.
|
|
256
|
+
if (!granted.ok)
|
|
257
|
+
await revokeCredentials(sandbox);
|
|
258
|
+
return granted;
|
|
259
|
+
};
|
|
260
|
+
const owned = (start, canKeep = false) => {
|
|
261
|
+
if (phase.kind !== "open")
|
|
66
262
|
return Promise.resolve({ ok: false, failure: { kind: "aborted" } });
|
|
67
|
-
return track(creating, (async () => {
|
|
263
|
+
return track(phase.creating, (async () => {
|
|
68
264
|
const started = await start();
|
|
69
265
|
if (!started.ok)
|
|
70
266
|
return started;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
267
|
+
const now = currentPhase();
|
|
268
|
+
switch (now.kind) {
|
|
269
|
+
case "open":
|
|
270
|
+
now.sandboxes.set(started.value, { sandbox: started.value, keep: canKeep && settings.keepMs > 0 });
|
|
271
|
+
return started;
|
|
272
|
+
case "settling":
|
|
273
|
+
now.sandboxes.set(started.value, { sandbox: started.value, keep: false });
|
|
274
|
+
return { ok: false, failure: { kind: "aborted" } };
|
|
275
|
+
case "closing":
|
|
276
|
+
await stopAndDelete(started.value);
|
|
277
|
+
return { ok: false, failure: { kind: "aborted" } };
|
|
74
278
|
}
|
|
75
|
-
live.add(started.value);
|
|
76
|
-
return started;
|
|
77
279
|
})());
|
|
78
280
|
};
|
|
281
|
+
// Said before closing begins, so the stopping line comes before any line closing's waits print.
|
|
282
|
+
function onSignal() {
|
|
283
|
+
const commandRunning = settings.commandRunning?.() ?? false;
|
|
284
|
+
void progress.emit({ kind: "stopping", commandRunning, keepMs: settings.keepMs }).catch(() => undefined);
|
|
285
|
+
void stopUnkept().catch(() => undefined);
|
|
286
|
+
}
|
|
287
|
+
if (settings.signal.aborted)
|
|
288
|
+
onSignal();
|
|
289
|
+
else
|
|
290
|
+
settings.signal.addEventListener("abort", onSignal, { once: true });
|
|
79
291
|
return {
|
|
80
|
-
startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, request)),
|
|
81
|
-
startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, request)),
|
|
292
|
+
startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, { ...request, networkPolicy: settings.basePolicy })),
|
|
293
|
+
startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, { ...request, networkPolicy: settings.basePolicy }), true),
|
|
294
|
+
grantCredentials,
|
|
295
|
+
revokeCredentials,
|
|
82
296
|
saveSnapshot: (sandbox, request) => track(saving, (async () => {
|
|
297
|
+
if (policies.mayInject(sandbox)) {
|
|
298
|
+
const removed = await policies.removeInjections(sandbox);
|
|
299
|
+
if (!removed.ok)
|
|
300
|
+
return { ok: false, failure: { kind: "credential-not-revoked", failure: removed.failure } };
|
|
301
|
+
}
|
|
83
302
|
const saved = await sandboxes.saveSnapshot(sandbox, request);
|
|
84
|
-
|
|
85
|
-
|
|
303
|
+
const now = currentPhase();
|
|
304
|
+
if (saved.ok && now.kind !== "closing" && now.sandboxes.delete(sandbox))
|
|
305
|
+
await deleteSandbox(sandbox);
|
|
86
306
|
return saved;
|
|
87
307
|
})()),
|
|
308
|
+
fence,
|
|
88
309
|
close() {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
await
|
|
93
|
-
|
|
94
|
-
settleWithin(timer, saving, SNAPSHOT_SETTLE_MS),
|
|
95
|
-
]);
|
|
96
|
-
const held = [...live];
|
|
97
|
-
live.clear();
|
|
98
|
-
await Promise.all(held.map(keepOrRemove));
|
|
310
|
+
beginClosing();
|
|
311
|
+
closingScope ??= (async () => {
|
|
312
|
+
await fence();
|
|
313
|
+
const entries = await settle();
|
|
314
|
+
await Promise.all([...entries.values()].map((entry) => entry.keep ? keepOrDelete(entry.sandbox) : stopAndDelete(entry.sandbox)));
|
|
99
315
|
return { kept, notKept, notStopped: [...notStopped], notDeleted: [...notDeleted] };
|
|
100
316
|
})();
|
|
101
|
-
return
|
|
317
|
+
return closingScope;
|
|
102
318
|
},
|
|
103
319
|
};
|
|
104
320
|
}
|
|
@@ -113,3 +329,7 @@ async function settleWithin(timer, tasks, ms) {
|
|
|
113
329
|
function failureMessage(failure) {
|
|
114
330
|
return failure.message ?? failure.kind;
|
|
115
331
|
}
|
|
332
|
+
/** A failed call bounded by `callWithin`, in words: its failure, or that it had no answer within `limitMs`. */
|
|
333
|
+
function callFailureMessage(answer, limitMs) {
|
|
334
|
+
return answer === null ? `no answer within ${limitMs / 1000} seconds` : failureMessage(answer.failure);
|
|
335
|
+
}
|