@cnc-tools/storm 0.10.0 → 0.11.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 (198) hide show
  1. package/dist/bin/storm.js +17 -9
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-YF3ICDBY.js → chunk-3ZZVZPMG.js} +1 -1
  4. package/dist/chunks/{chunk-JQ2HK4RN.js → chunk-4EU4AH7E.js} +141 -6
  5. package/dist/chunks/{chunk-ZJ2USLAT.js → chunk-4PRAB24Y.js} +2 -22
  6. package/dist/chunks/chunk-AMTYHUYB.js +257 -0
  7. package/dist/chunks/{chunk-WF4KJ7YG.js → chunk-ETCZ6WP7.js} +1 -1
  8. package/dist/chunks/chunk-FVMQKYTT.js +10 -0
  9. package/dist/chunks/{chunk-XHJGHJBW.js → chunk-GRMD7G4J.js} +33 -275
  10. package/dist/chunks/chunk-ICB4BZJX.js +22 -0
  11. package/dist/chunks/{chunk-AGWW3HDT.js → chunk-KR7WIYLG.js} +1826 -2201
  12. package/dist/chunks/{chunk-OVXD7GES.js → chunk-L4ZPMSKQ.js} +4 -37
  13. package/dist/chunks/chunk-NPPJ57W7.js +569 -0
  14. package/dist/chunks/{chunk-VJQLMGOH.js → chunk-O4BUT7BE.js} +361 -1716
  15. package/dist/chunks/chunk-OJOKQRM6.js +1457 -0
  16. package/dist/chunks/chunk-SLNKW4ZM.js +40 -0
  17. package/dist/chunks/{chunk-AKKNF3WZ.js → chunk-TRFEAYNC.js} +277 -348
  18. package/dist/chunks/chunk-VZZTHCBW.js +93 -0
  19. package/dist/chunks/chunk-WNIQA5J6.js +19 -0
  20. package/dist/chunks/chunk-WSIF7SR6.js +10 -0
  21. package/dist/chunks/{live-app-RIJM3QFD.js → live-app-LOGYUBKB.js} +52 -7
  22. package/dist/commands/exec/cleanup.d.ts +3 -3
  23. package/dist/commands/exec/cleanup.js +6 -2
  24. package/dist/commands/exec/command.d.ts +3 -3
  25. package/dist/commands/exec/command.js +17 -10
  26. package/dist/commands/exec/job-summary.d.ts +1 -1
  27. package/dist/commands/exec/job-summary.js +1 -1
  28. package/dist/commands/exec/live-view.js +5 -5
  29. package/dist/commands/exec/mint-failed.js +1 -1
  30. package/dist/commands/exec/outcomes.d.ts +2 -2
  31. package/dist/commands/exec/outcomes.js +7 -8
  32. package/dist/commands/exec/plan-run.d.ts +3 -5
  33. package/dist/commands/exec/progress.d.ts +3 -3
  34. package/dist/commands/exec/progress.js +6 -6
  35. package/dist/commands/exec/resource-refusals.d.ts +1 -1
  36. package/dist/commands/exec/resource-refusals.js +1 -1
  37. package/dist/commands/exec/run-command.d.ts +14 -9
  38. package/dist/commands/exec/run-command.js +91 -202
  39. package/dist/commands/exec/run-metadata.d.ts +2 -2
  40. package/dist/commands/exec/run-metadata.js +3 -3
  41. package/dist/commands/exec/test-plan.d.ts +1 -35
  42. package/dist/commands/exec/test-plan.js +4 -24
  43. package/dist/commands/exec/view.js +3 -3
  44. package/dist/commands/exec/waterfall.d.ts +3 -1
  45. package/dist/commands/exec/waterfall.js +18 -1
  46. package/dist/commands/runs/facts.d.ts +2 -1
  47. package/dist/commands/runs/facts.js +1 -1
  48. package/dist/commands/runs/list/command.js +10 -9
  49. package/dist/commands/runs/logs/command.js +14 -12
  50. package/dist/commands/runs/past-run.d.ts +3 -27
  51. package/dist/commands/runs/past-run.js +3 -37
  52. package/dist/commands/runs/show/command.js +24 -21
  53. package/dist/commands/runs/show/outcomes.js +2 -2
  54. package/dist/commands/vitest/command.d.ts +3 -3
  55. package/dist/commands/vitest/command.js +24 -17
  56. package/dist/commands/vitest/outcomes.d.ts +1 -1
  57. package/dist/commands/vitest/outcomes.js +1 -1
  58. package/dist/config/credential-resolver.d.ts +6 -3
  59. package/dist/config/credential-resolver.js +6 -5
  60. package/dist/context.d.ts +27 -9
  61. package/dist/context.js +19 -8
  62. package/dist/core/before-run.d.ts +5 -4
  63. package/dist/core/before-run.js +6 -6
  64. package/dist/core/definition-lookup.d.ts +22 -0
  65. package/dist/core/definition-lookup.js +34 -0
  66. package/dist/core/events.d.ts +5 -19
  67. package/dist/core/gateways.d.ts +22 -162
  68. package/dist/core/index.d.ts +10 -11
  69. package/dist/core/index.js +9 -11
  70. package/dist/core/launcher-supplies.js +2 -2
  71. package/dist/core/live/terminal-command-gateway.d.ts +8 -0
  72. package/dist/core/live/terminal-command-gateway.js +49 -0
  73. package/dist/core/presentations.d.ts +4 -3
  74. package/dist/core/presentations.js +4 -5
  75. package/dist/core/resource-registry.d.ts +35 -51
  76. package/dist/core/resource-registry.js +27 -54
  77. package/dist/core/resource-reports.d.ts +37 -4
  78. package/dist/core/resource-reports.js +34 -5
  79. package/dist/core/resources.d.ts +4 -3
  80. package/dist/core/resources.js +2 -4
  81. package/dist/core/run-state.d.ts +1 -1
  82. package/dist/core/run-state.js +1 -1
  83. package/dist/core/run.d.ts +19 -37
  84. package/dist/core/run.js +59 -114
  85. package/dist/core/timeline.js +2 -1
  86. package/dist/credential/events.d.ts +20 -0
  87. package/dist/credential/events.js +4 -0
  88. package/dist/credential/index.d.ts +2 -1
  89. package/dist/credential/index.js +6 -5
  90. package/dist/credential/source.d.ts +38 -26
  91. package/dist/credential/source.js +25 -34
  92. package/dist/extension-commands.d.ts +12 -6
  93. package/dist/extension-commands.js +18 -11
  94. package/dist/extensions/story/command-tree.d.ts +6 -0
  95. package/dist/extensions/story/command-tree.js +21 -0
  96. package/dist/extensions/story/commands/app.d.ts +23 -0
  97. package/dist/extensions/story/commands/app.js +5 -0
  98. package/dist/extensions/story/commands/run/command.d.ts +211 -0
  99. package/dist/extensions/story/commands/run/command.js +259 -0
  100. package/dist/extensions/story/commands/run/metadata.d.ts +4 -0
  101. package/dist/extensions/story/commands/run/metadata.js +8 -0
  102. package/dist/extensions/story/commands/run/outcomes.d.ts +101 -0
  103. package/dist/extensions/story/commands/run/outcomes.js +73 -0
  104. package/dist/extensions/story/commands/tree.d.ts +2 -0
  105. package/dist/extensions/story/commands/tree.js +6 -0
  106. package/dist/extensions/story/extension.d.ts +2 -0
  107. package/dist/extensions/story/extension.js +8 -0
  108. package/dist/extensions/testserver/command-tree.d.ts +1 -1
  109. package/dist/extensions/testserver/command-tree.js +0 -1
  110. package/dist/extensions/testserver/commands/pool/create/command.js +14 -8
  111. package/dist/extensions/testserver/commands/pool/list/command.js +8 -4
  112. package/dist/extensions/testserver/vitest/config.d.ts +7 -5
  113. package/dist/extensions/testserver/vitest/config.js +7 -5
  114. package/dist/extensions/testserver/vitest/fixtures.d.ts +2 -0
  115. package/dist/extensions/testserver/vitest/fixtures.js +36 -5
  116. package/dist/extensions.d.ts +12 -21
  117. package/dist/extensions.js +22 -34
  118. package/dist/forward-sigterm.d.ts +8 -0
  119. package/dist/forward-sigterm.js +18 -0
  120. package/dist/launcher-resolvers/index.d.ts +1 -0
  121. package/dist/launcher-resolvers/index.js +2 -1
  122. package/dist/launcher-resolvers/local-services.d.ts +57 -0
  123. package/dist/launcher-resolvers/local-services.js +7 -0
  124. package/dist/live-app.js +2 -1
  125. package/dist/local-services.d.ts +19 -0
  126. package/dist/local-services.js +37 -0
  127. package/dist/run-directory/gateways.d.ts +167 -0
  128. package/dist/run-directory/gateways.js +2 -0
  129. package/dist/run-directory/index.d.ts +8 -0
  130. package/dist/run-directory/index.js +13 -0
  131. package/dist/run-directory/plan.d.ts +35 -0
  132. package/dist/run-directory/plan.js +24 -0
  133. package/dist/run-directory/reader.d.ts +70 -0
  134. package/dist/run-directory/reader.js +51 -0
  135. package/dist/run-directory/recording.d.ts +92 -0
  136. package/dist/run-directory/recording.js +85 -0
  137. package/dist/{commands/exec → run-directory}/run-collector.d.ts +9 -8
  138. package/dist/{commands/exec → run-directory}/run-collector.js +8 -10
  139. package/dist/{core → run-directory}/run-directory.d.ts +3 -3
  140. package/dist/{core → run-directory}/run-directory.js +2 -2
  141. package/dist/{commands/exec → run-directory}/run-record.d.ts +29 -7
  142. package/dist/{commands/exec → run-directory}/run-record.js +79 -5
  143. package/dist/{commands/exec → run-directory}/timeline-facts.d.ts +4 -8
  144. package/dist/{commands/exec → run-directory}/timeline-facts.js +8 -24
  145. package/dist/runner/events.d.ts +6 -5
  146. package/dist/runner/index.d.ts +13 -17
  147. package/dist/runner/index.js +10 -14
  148. package/dist/runner/prepare.d.ts +28 -6
  149. package/dist/runner/prepare.js +15 -9
  150. package/dist/runner/recipe.d.ts +14 -0
  151. package/dist/runner/recipe.js +12 -0
  152. package/dist/runner/scope.d.ts +18 -11
  153. package/dist/runner/scope.js +12 -10
  154. package/dist/runner/session.d.ts +100 -0
  155. package/dist/runner/session.js +109 -0
  156. package/dist/runner/snapshot-save.d.ts +3 -2
  157. package/dist/runner/snapshot-save.js +6 -5
  158. package/dist/sdk/extension/ci.d.ts +2 -0
  159. package/dist/sdk/extension/ci.js +6 -0
  160. package/dist/sdk/extension/commands.d.ts +11 -13
  161. package/dist/sdk/extension/commands.js +5 -5
  162. package/dist/sdk/extension/index.d.ts +1 -0
  163. package/dist/sdk/extension/index.js +1 -0
  164. package/dist/sdk/extension/lifecycle.d.ts +4 -3
  165. package/dist/sdk/extension/progress.js +2 -2
  166. package/dist/sdk/extension/resource.js +1 -1
  167. package/dist/story/align.d.ts +1 -1
  168. package/dist/story/align.js +1 -1
  169. package/dist/story/command-line.d.ts +6 -16
  170. package/dist/story/command-line.js +11 -23
  171. package/dist/story/errors.d.ts +1 -1
  172. package/dist/story/errors.js +1 -1
  173. package/dist/story/host.d.ts +1 -1
  174. package/dist/story/host.js +2 -2
  175. package/dist/story/index.d.ts +2 -2
  176. package/dist/story/index.js +4 -3
  177. package/dist/story/launch.d.ts +70 -0
  178. package/dist/story/launch.js +77 -0
  179. package/dist/story/report.d.ts +2 -2
  180. package/dist/story/report.js +3 -4
  181. package/dist/story/settle.d.ts +7 -7
  182. package/dist/story/settle.js +5 -5
  183. package/dist/story/start.d.ts +2 -2
  184. package/dist/vendor/testserver-sdk/container/container.d.ts +11 -6
  185. package/dist/vendor/testserver-sdk/container/container.js +38 -16
  186. package/dist/vendor/testserver-sdk/testserver/failure.d.ts +4 -3
  187. package/dist/vendor/testserver-sdk/testserver/failure.js +4 -3
  188. package/package.json +1 -1
  189. package/skills/overview.md +3 -0
  190. package/skills/read-run-output.md +2 -2
  191. package/dist/chunks/chunk-H2VCSNVU.js +0 -351
  192. package/dist/chunks/chunk-J6ZNYUDV.js +0 -21
  193. package/dist/core/mint.d.ts +0 -10
  194. package/dist/core/mint.js +0 -14
  195. package/dist/story/mode.d.ts +0 -17
  196. package/dist/story/mode.js +0 -21
  197. /package/dist/{core → run-directory}/live/run-directory-gateway.d.ts +0 -0
  198. /package/dist/{core → run-directory}/live/run-directory-gateway.js +0 -0
@@ -2,9 +2,9 @@ import type { ArgumentIssue, CommandError, CommandResult, ExecutionContext } fro
2
2
  import { z } from "zod";
3
3
  import type { StormApp } from "../../context.ts";
4
4
  import { type CheckoutFailure } from "../../runner/index.ts";
5
- import type { RunTestPlan } from "../../sdk/extension/index.ts";
5
+ import { type RunTestPlan } from "../../sdk/extension/index.ts";
6
+ import { type PlanOption } from "../../run-directory/index.ts";
6
7
  import { type ranSchema } from "./outcomes.ts";
7
- import { type PlanOption } from "./test-plan.ts";
8
8
  import { type PlanCommand } from "./plan-run.ts";
9
9
  /**
10
10
  * The request fields every run takes, `exec`'s and `vitest`'s: the run's own, and each resource option's flag
@@ -19,7 +19,7 @@ export declare const RUN_REQUEST_FIELDS: {
19
19
  }>>;
20
20
  unsandboxed: z.ZodDefault<z.ZodBoolean>;
21
21
  rebuildSnapshot: z.ZodDefault<z.ZodBoolean>;
22
- saveSnapshot: z.ZodDefault<z.ZodBoolean>;
22
+ saveSnapshot: z.ZodOptional<z.ZodBoolean>;
23
23
  showOutput: z.ZodDefault<z.ZodBoolean>;
24
24
  keepSandbox: z.ZodOptional<z.ZodString>;
25
25
  verbose: z.ZodDefault<z.ZodBoolean>;
@@ -39,7 +39,7 @@ declare const runRequestSchema: z.ZodObject<{
39
39
  }>>;
40
40
  unsandboxed: z.ZodDefault<z.ZodBoolean>;
41
41
  rebuildSnapshot: z.ZodDefault<z.ZodBoolean>;
42
- saveSnapshot: z.ZodDefault<z.ZodBoolean>;
42
+ saveSnapshot: z.ZodOptional<z.ZodBoolean>;
43
43
  showOutput: z.ZodDefault<z.ZodBoolean>;
44
44
  keepSandbox: z.ZodOptional<z.ZodString>;
45
45
  verbose: z.ZodDefault<z.ZodBoolean>;
@@ -99,10 +99,15 @@ export interface RunCommandSpec<TTestPlan extends RunTestPlan, TRan, TRefusal> {
99
99
  * run, the first SIGINT, SIGTERM or SIGHUP stops the run in any phase: the sandboxed command is killed, every sandbox
100
100
  * the run started is stopped and deleted, the resources are released, and the run cancels. `--rebuild-snapshot` (no
101
101
  * config key, not with `--unsandboxed`) builds a runner snapshot whatever the cache holds, and drops HEAD's branch's
102
- * branch snapshots from it. `--save-snapshot` (no config key, not with `--unsandboxed` or a `--keep-sandbox` above 0)
103
- * saves the runner sandbox as a branch snapshot once the command ended on its own, while the resources are released, so
104
- * the next run on the branch starts from it; a run with it on a branch keeps no runner sandbox, however it ends, and
105
- * one on a detached HEAD says so as it starts and keeps its runner sandbox as without the flag.
102
+ * branch snapshots from it. A sandboxed run on a branch saves the runner sandbox as a branch snapshot once the command
103
+ * exited 0, while the resources are released, so the next run on the branch starts from it, unless it started from a
104
+ * branch snapshot HEAD's commit saved: one save per commit (`saveMode`). It saves none when `CI` is set,
105
+ * `--keep-sandbox` is above 0, or the recipe's install or build step names a runner secret. `--save-snapshot` (not with `--unsandboxed` or a `--keep-sandbox` above 0) saves once
106
+ * the command ended on its own, whatever its exit code and whatever the run started from, under `CI` too, and on a
107
+ * detached HEAD says as the run starts that it saves nothing; `--save-snapshot=false` saves none. The recipe's
108
+ * `saveSnapshot` says the same for every run that gives neither that flag nor a `--keep-sandbox` above 0. A run
109
+ * whose save starts keeps no runner sandbox, however the save ends; one whose save never starts, such as one whose
110
+ * command failed without the flag, keeps it for the keep time.
106
111
  *
107
112
  * `--credential` (no config key) picks the credential source: `mint`, the default, or `github-actions`, which requests
108
113
  * a GitHub Actions OIDC token instead and so needs no `--scope` or `--project`; any given are unused. A sandboxed run
@@ -114,7 +119,7 @@ export interface RunCommandSpec<TTestPlan extends RunTestPlan, TRan, TRefusal> {
114
119
  * elsewhere, folded for GitHub Actions, nothing under `--json`. `--show-output` (no config key, not with
115
120
  * `--unsandboxed`) prints the runner's step output above the live view. `--verbose` (no config key) prints each
116
121
  * resource's detailed progress and the runner's step output, and sets `verbose` in the run payload. Every run, `--json`
117
- * included, writes a run directory (`core/run-directory.ts`), and a run that can't make one goes on without it; the
122
+ * included, writes a run directory (`recordRun`, `run-directory/`), and a run that can't make one goes on without it; the
118
123
  * waterfall names it and the `storm runs show` command that reads the run back by its run id, which a ran outcome
119
124
  * carries as `runId`, and in a GitHub Actions step with a job summary the run appends a Markdown summary there.
120
125
  *
@@ -1,30 +1,29 @@
1
1
  // What `exec` and `vitest` share: the request fields and checks every run takes, and running it once it is planned
2
2
  // and its resources' `beforeRun` let it go on (`plan-run.ts`). The two commands differ only in their part of planning
3
3
  // the run: the command's argv, and for `vitest` the tests it counts (`RunCommandSpec.planCommand`).
4
- import { NodeSignalCancellation } from "@vercel/clinkr/node";
5
4
  import { z } from "zod";
5
+ import { forwardSigterm } from "../../forward-sigterm.js";
6
6
  import { describeMintFailure } from "../../credential/index.js";
7
- import { prepareRunner, } from "../../runner/index.js";
7
+ import { prepareRunner, runStepTakesSecret, } from "../../runner/index.js";
8
8
  import { invalidConfig, recipeRun } from "../../config/index.js";
9
- import { commandExitStatus, executeRun, observeAll, RUN_DIRECTORIES_KEPT, runDirectoryObserver, stepLog, testEventsPath, timedProgress, } from "../../core/index.js";
10
- import { RESOURCE_REPORTS, RESOURCES, resourceLifecycles, RUN_CLEANUP, stormTimeline } from "../../extensions.js";
9
+ import { isCi } from "../../sdk/extension/index.js";
10
+ import { commandExitStatus, executeRun, timedProgress, } from "../../core/index.js";
11
+ import { REGISTRY } from "../../extensions.js";
12
+ import { recordRun, } from "../../run-directory/index.js";
11
13
  import { parseKeepTime } from "../../time/index.js";
12
14
  import { jobSummaryMarkdown } from "./job-summary.js";
13
15
  import { testsSummaryLines } from "./tests-summary.js";
14
16
  import { resourceFlagFields, resourceFlagProblems, resourceFlagValues } from "./resource-flags.js";
15
17
  import { runView } from "./view.js";
16
- import { timelineFacts } from "./timeline-facts.js";
17
18
  import { waterfallLines } from "./waterfall.js";
18
19
  import { testsChart } from "./worker-chart.js";
19
- import { runCollector } from "./run-collector.js";
20
20
  import { mintFailedErrors } from "./mint-failed.js";
21
21
  import { resourceRefused } from "./resource-refusals.js";
22
22
  import { outcomes, runErrors } from "./outcomes.js";
23
- import { keptText, notDeletedText, notKeptText, notStoppedText, } from "./cleanup.js";
23
+ import { keptText, RUN_CLEANUP, notDeletedText, notKeptText, notStoppedText, } from "./cleanup.js";
24
24
  import { redactingObserver, redactingTerminal, redactor, redactStrings } from "./redaction.js";
25
25
  import { recordedPlan, testPlanLine } from "./test-plan.js";
26
26
  import { canceledBeforeStart, planRun, resourcesBeforeRun, } from "./plan-run.js";
27
- import { runRecordText, testTotals, } from "./run-record.js";
28
27
  /** The run's own request fields, which every run takes beside the resources' flags. */
29
28
  const OWN_RUN_FIELDS = {
30
29
  scope: z.string().min(1).optional(),
@@ -32,7 +31,7 @@ const OWN_RUN_FIELDS = {
32
31
  credential: z.enum(["mint", "github-actions"]).optional(),
33
32
  unsandboxed: z.boolean().default(false),
34
33
  rebuildSnapshot: z.boolean().default(false),
35
- saveSnapshot: z.boolean().default(false),
34
+ saveSnapshot: z.boolean().optional(),
36
35
  showOutput: z.boolean().default(false),
37
36
  keepSandbox: z.string().optional(),
38
37
  verbose: z.boolean().default(false),
@@ -79,10 +78,15 @@ const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
79
78
  * run, the first SIGINT, SIGTERM or SIGHUP stops the run in any phase: the sandboxed command is killed, every sandbox
80
79
  * the run started is stopped and deleted, the resources are released, and the run cancels. `--rebuild-snapshot` (no
81
80
  * config key, not with `--unsandboxed`) builds a runner snapshot whatever the cache holds, and drops HEAD's branch's
82
- * branch snapshots from it. `--save-snapshot` (no config key, not with `--unsandboxed` or a `--keep-sandbox` above 0)
83
- * saves the runner sandbox as a branch snapshot once the command ended on its own, while the resources are released, so
84
- * the next run on the branch starts from it; a run with it on a branch keeps no runner sandbox, however it ends, and
85
- * one on a detached HEAD says so as it starts and keeps its runner sandbox as without the flag.
81
+ * branch snapshots from it. A sandboxed run on a branch saves the runner sandbox as a branch snapshot once the command
82
+ * exited 0, while the resources are released, so the next run on the branch starts from it, unless it started from a
83
+ * branch snapshot HEAD's commit saved: one save per commit (`saveMode`). It saves none when `CI` is set,
84
+ * `--keep-sandbox` is above 0, or the recipe's install or build step names a runner secret. `--save-snapshot` (not with `--unsandboxed` or a `--keep-sandbox` above 0) saves once
85
+ * the command ended on its own, whatever its exit code and whatever the run started from, under `CI` too, and on a
86
+ * detached HEAD says as the run starts that it saves nothing; `--save-snapshot=false` saves none. The recipe's
87
+ * `saveSnapshot` says the same for every run that gives neither that flag nor a `--keep-sandbox` above 0. A run
88
+ * whose save starts keeps no runner sandbox, however the save ends; one whose save never starts, such as one whose
89
+ * command failed without the flag, keeps it for the keep time.
86
90
  *
87
91
  * `--credential` (no config key) picks the credential source: `mint`, the default, or `github-actions`, which requests
88
92
  * a GitHub Actions OIDC token instead and so needs no `--scope` or `--project`; any given are unused. A sandboxed run
@@ -94,7 +98,7 @@ const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
94
98
  * elsewhere, folded for GitHub Actions, nothing under `--json`. `--show-output` (no config key, not with
95
99
  * `--unsandboxed`) prints the runner's step output above the live view. `--verbose` (no config key) prints each
96
100
  * resource's detailed progress and the runner's step output, and sets `verbose` in the run payload. Every run, `--json`
97
- * included, writes a run directory (`core/run-directory.ts`), and a run that can't make one goes on without it; the
101
+ * included, writes a run directory (`recordRun`, `run-directory/`), and a run that can't make one goes on without it; the
98
102
  * waterfall names it and the `storm runs show` command that reads the run back by its run id, which a ran outcome
99
103
  * carries as `runId`, and in a GitHub Actions step with a job summary the run appends a Markdown summary there.
100
104
  *
@@ -117,7 +121,7 @@ const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
117
121
  */
118
122
  export async function runCommand({ app, ui, signal }, request, spec) {
119
123
  // The resources' lifecycles, bound once over the run's worlds, which planning and `beforeRun` share.
120
- const lifecycles = resourceLifecycles(app.worlds);
124
+ const lifecycles = REGISTRY.lifecycles(app.worlds);
121
125
  const planned = await planRun(app, lifecycles, { ...request, given: resourceFlagValues(request) }, spec.planCommand, signal);
122
126
  if (!planned.ok)
123
127
  return planned.refusal;
@@ -149,18 +153,9 @@ export async function runCommand({ app, ui, signal }, request, spec) {
149
153
  // before any view, the run directory or the summary sees them.
150
154
  const secrets = [...used.secrets, ...Object.values(run.runner?.secrets ?? {})];
151
155
  const redact = redactor(secrets);
152
- // Only SIGTERM is passed on to the command, which Ctrl+C and a closed terminal reach directly; a run in a runner
153
- // sandbox stops on any signal itself (`RunControl`).
154
- const terminate = new AbortController();
155
- const forward = () => {
156
- const reason = signal.reason;
157
- if (reason instanceof NodeSignalCancellation && reason.signal === "SIGTERM")
158
- terminate.abort(reason);
159
- };
160
- if (signal.aborted)
161
- forward();
162
- else
163
- signal.addEventListener("abort", forward, { once: true });
156
+ // Only SIGTERM is passed on to the command (`forwardSigterm`); a run in a runner sandbox stops on any signal itself
157
+ // (`RunControl`).
158
+ const sigterm = forwardSigterm(signal);
164
159
  const view = runView({
165
160
  presentation: app.presentation,
166
161
  progress: ui.progress,
@@ -169,54 +164,39 @@ export async function runCommand({ app, ui, signal }, request, spec) {
169
164
  verbose: request.verbose,
170
165
  });
171
166
  const git = await checkoutGit(app.context.checkout, app.cwd);
172
- const startedAt = app.context.clock.now();
173
- const record = redactStrings({
174
- version: 3,
175
- startedAt: startedAt.toISOString(),
167
+ const recording = await recordRun(app.context.runDirectories, {
168
+ registry: REGISTRY,
169
+ startedAt: app.context.clock.now(),
176
170
  cwd: app.cwd,
177
171
  configFile,
178
172
  argv,
179
- ...(plan === undefined ? {} : { plan }),
180
- where: startedWhere(run),
173
+ plan,
174
+ run,
181
175
  git,
182
- }, redact);
183
- const opened = await app.context.runDirectories.open({
184
- startedAt,
185
- keep: RUN_DIRECTORIES_KEPT,
186
- run: runRecordText(record),
176
+ redact: (value) => redactStrings(value, redact),
187
177
  });
188
- const directory = opened.ok ? opened.directory : undefined;
189
- const collector = runCollector(directory);
190
- const observers = [collector.observer, view.observer];
191
- if (directory !== undefined)
192
- observers.push(runDirectoryObserver(directory));
193
- const observer = observeAll(...observers);
194
- const terminal = teeTerminal(view.runnerTerminal, directory);
178
+ // The recording folds each event, hands it to the view, then writes it; its terminal writes `command.log`, then the
179
+ // view's.
180
+ const observer = recording.observer(view.observer);
181
+ const terminal = recording.terminal(view.runnerTerminal);
195
182
  let outcome;
196
183
  try {
197
- const ended = await executeRun(RESOURCES, { ...app.context, runnerTerminal: secrets.length === 0 ? terminal : redactingTerminal(terminal, redact) }, app.worlds, run.runner === undefined && directory !== undefined
198
- ? { ...run, testEvents: testEventsPath(directory.path) }
199
- : run, { signal, terminate: terminate.signal }, timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact)));
184
+ const ended = await executeRun(REGISTRY, { ...app.context, runnerTerminal: secrets.length === 0 ? terminal : redactingTerminal(terminal, redact) }, app.worlds, run.runner === undefined && recording.testEvents !== undefined
185
+ ? { ...run, testEvents: recording.testEvents }
186
+ : run, { signal, terminate: sigterm.terminate }, timedProgress(app.context.clock, secrets.length === 0 ? observer : redactingObserver(observer, redact)));
200
187
  // An outcome's facts, such as a failed Sandbox call's message, can quote what the run handed its command.
201
188
  outcome = secrets.length === 0 ? ended : redactStrings(ended, redact);
202
189
  }
203
190
  catch (error) {
204
- // A live region must not outlive the run, however it ends, and closing the run directory completes it and removes
205
- // the test events an unsandboxed command staged there, unredacted. They are never saved: the run didn't end.
191
+ // A live region must not outlive the run, however it ends, and abandoning the recording completes the run
192
+ // directory and removes the test events an unsandboxed command staged there, unredacted. They are never saved: the
193
+ // run didn't end.
206
194
  await view.finish([]);
207
- await directory?.close();
195
+ await recording.abandon();
208
196
  throw error;
209
197
  }
210
- signal.removeEventListener("abort", forward);
211
- const ran = await summarize(app, {
212
- command: spec.name,
213
- view,
214
- collector,
215
- opened,
216
- redact,
217
- record,
218
- outcome,
219
- });
198
+ sigterm.release();
199
+ const ran = await summarize(app, { command: spec.name, view, recording, outcome });
220
200
  switch (outcome.kind) {
221
201
  case "ran": {
222
202
  app.exit.status = commandExitStatus(outcome.command);
@@ -225,7 +205,7 @@ export async function runCommand({ app, ui, signal }, request, spec) {
225
205
  version: app.version,
226
206
  commit: app.commit,
227
207
  configFile,
228
- resources: RESOURCE_REPORTS.ranFacts(outcome.resources),
208
+ resources: REGISTRY.reports.ranFacts(outcome.resources),
229
209
  cleanup: RUN_CLEANUP.facts(outcome),
230
210
  command: command.kind === "exited"
231
211
  ? { exitCode: command.code, signal: null }
@@ -247,7 +227,7 @@ export async function runCommand({ app, ui, signal }, request, spec) {
247
227
  save: outcome.runner.save,
248
228
  },
249
229
  timeline: ran,
250
- runId: directory?.id ?? null,
230
+ runId: recording.opened.ok ? recording.opened.id : null,
251
231
  }, { testPlan, options: planOptions });
252
232
  }
253
233
  case "resource-refused":
@@ -329,7 +309,7 @@ export function runProblems(request) {
329
309
  },
330
310
  ]
331
311
  : []),
332
- ...(saveSnapshot && unsandboxed
312
+ ...(saveSnapshot === true && unsandboxed
333
313
  ? [
334
314
  {
335
315
  field: "saveSnapshot",
@@ -337,7 +317,7 @@ export function runProblems(request) {
337
317
  },
338
318
  ]
339
319
  : []),
340
- ...(saveSnapshot && keepSandbox !== undefined && (parseKeepTime(keepSandbox) ?? 0) > 0
320
+ ...(saveSnapshot === true && keepsSandbox(keepSandbox)
341
321
  ? [
342
322
  {
343
323
  field: "saveSnapshot",
@@ -372,7 +352,8 @@ async function runRequestFor(app, options) {
372
352
  // The recipe's `vcpus` reads each of the run's resources by its definition: one its `beforeRun` skipped isn't.
373
353
  vcpusRun: recipeRun(recipeResources(used.requests)),
374
354
  rebuild: request.rebuildSnapshot,
375
- saveSnapshot: request.saveSnapshot,
355
+ save: saveMode(request, where.recipe, app.env),
356
+ trustBranchSnapshots: request.saveSnapshot ?? where.recipe.saveSnapshot === true,
376
357
  });
377
358
  if (prepared.kind !== "ok") {
378
359
  const refusal = prepareRefusal(prepared, configFile);
@@ -383,6 +364,7 @@ async function runRequestFor(app, options) {
383
364
  };
384
365
  }
385
366
  const { save } = prepared.prepared;
367
+ const keepMs = keepSandboxMinutes(request.keepSandbox, where.recipe, app.env) * 60_000;
386
368
  const run = {
387
369
  ...base,
388
370
  resources: used.requests,
@@ -393,8 +375,8 @@ async function runRequestFor(app, options) {
393
375
  user: app.user,
394
376
  secrets: where.secrets,
395
377
  sandbox: save?.kind === "branch"
396
- ? { kind: "save", branch: save.branch }
397
- : { kind: "keep", ms: keepSandboxMinutes(request.keepSandbox, where.recipe, app.env) * 60_000 },
378
+ ? { kind: "save", branch: save.branch, always: save.always, otherwiseKeepMs: keepMs }
379
+ : { kind: "keep", ms: keepMs },
398
380
  },
399
381
  };
400
382
  return { ok: true, run };
@@ -428,46 +410,30 @@ export function checkoutFailedRefusal(failure) {
428
410
  });
429
411
  }
430
412
  /**
431
- * Once the run is done: reads the test events the command staged in the run directory, if it staged any, through
432
- * `collector`, which redacts and streams each one to the private test events file, then publishes the redacted test
433
- * events as `tests.jsonl`, writes the timeline, each row with its label, and how the run ended (`record` with `ended`,
434
- * its runner sandbox and runner snapshot from the final state, and a ran outcome's acquired resources' result facts and
435
- * their rows) to the run directory, in that order, and closes it, which removes the staged test events and an
436
- * unpublished partial file. Then it appends the job summary, and has the view print the waterfall, with the worker
437
- * chart under its tests lane, the tests' summary, the logs of failed steps, and what went wrong with either file. The
413
+ * Once the run is done: ends its recording, which writes how the run ended to the run directory and closes it
414
+ * (`RunRecording.end`). Then it appends the job summary, and has the view print the waterfall, with the worker chart
415
+ * under its tests lane, the tests' summary, the logs of failed steps, and what went wrong with the run directory. The
438
416
  * job summary leaves the worker chart out. It answers the timeline, which a ran outcome carries.
439
417
  */
440
418
  async function summarize(app, run) {
441
- const { view, opened } = run;
442
- const directory = opened.ok ? opened.directory : undefined;
443
- if (directory !== undefined)
444
- await run.collector.readStaged(directory, run.redact);
445
- const collected = run.collector.finish();
446
- const { state, tests } = collected;
447
- const ran = stormTimeline(state);
448
- const timeline = timelineFacts(ran);
449
- directory?.publishTestEvents();
450
- directory?.writeTimeline(JSON.stringify(timeline, null, 2));
451
- directory?.writeRun(runRecordText({
452
- ...run.record,
453
- where: endedWhere(run.record.where, state.runner, run.outcome.kind === "ran" ? (run.outcome.runner?.save ?? null) : null),
454
- ended: runEnd(run.outcome, state.command, tests),
455
- }));
456
- const writeFailure = await directory?.close();
419
+ const { view, recording } = run;
420
+ const recorded = await recording.end(run.outcome);
421
+ const { timeline, tests } = recorded;
422
+ const logs = recording.opened.ok ? recording.opened.path : undefined;
457
423
  const failed = tests.events.some((event) => event.kind === "test-result" && event.state === "fail");
458
424
  const testsLines = testsSummaryLines(tests.events, tests.unreadable, tests.incomplete);
459
- const stepLogs = failedStepLogs(ran, directory?.path, app.env);
460
- const clock = workerClock(ran, collected);
425
+ const stepLogs = failedStepLogs(timeline, recording, app.env);
426
+ const clock = workerClock(recorded);
461
427
  const charted = clock === undefined ? undefined : testsChart(tests.events, tests.unreadable, clock, tests.incomplete);
462
428
  const summarized = await app.context.jobSummary.appendJobSummary(jobSummaryMarkdown(timeline, {
463
429
  command: run.command,
464
- logs: directory?.path,
430
+ logs,
465
431
  details: [...testsLines, ...stepLogs],
466
432
  }));
467
433
  await view.finish(waterfallLines(timeline, {
468
434
  width: view.width,
469
435
  paint: view.paint,
470
- logs: logsText(opened, writeFailure, app.env, failed),
436
+ logs: logsText(recording, recorded.writeFailure, app.env, failed),
471
437
  ...(charted === undefined ? {} : { workers: charted.lanes }),
472
438
  details: [
473
439
  ...(charted?.notes ?? testsLines),
@@ -484,27 +450,11 @@ async function summarize(app, run) {
484
450
  * offset comes from when the run heard each worker test event it followed, and is 0 when it followed none: workers
485
451
  * whose test events the command staged in the run directory share the run's clock.
486
452
  */
487
- function workerClock(ran, collected) {
488
- const tests = ran.rows.find((row) => row.name === "tests");
453
+ function workerClock({ timeline, workerOffsetMs }) {
454
+ const tests = timeline.rows.find((row) => row.name === "tests");
489
455
  if (tests === undefined)
490
456
  return undefined;
491
- return { runStartedAt: Date.parse(ran.startedAt), offsetMs: collected.workerOffsetMs, tests };
492
- }
493
- /** The command's output, in either kind of run, to `terminal` and to the run directory's `command.log`. */
494
- function teeTerminal(terminal, directory) {
495
- if (directory === undefined)
496
- return terminal;
497
- return {
498
- color: terminal.color,
499
- writeStdout: (text) => {
500
- directory.appendCommandOutput(text);
501
- terminal.writeStdout(text);
502
- },
503
- writeStderr: (text) => {
504
- directory.appendCommandOutput(text);
505
- terminal.writeStderr(text);
506
- },
507
- };
457
+ return { runStartedAt: Date.parse(timeline.startedAt), offsetMs: workerOffsetMs, tests };
508
458
  }
509
459
  /** A path as a person reads it: under `HOME`, starting `~/`. */
510
460
  function displayPath(path, env) {
@@ -518,41 +468,17 @@ function displayPath(path, env) {
518
468
  * failed, or pruning couldn't remove an older one or the staged test events left in one. The run goes on whichever it
519
469
  * was. Then the command that reads the run back by its run id, with `--failed` when a test `failed`.
520
470
  */
521
- function logsText(opened, writeFailure, env, failed) {
471
+ function logsText({ opened }, writeFailure, env, failed) {
522
472
  if (!opened.ok)
523
473
  return `none: couldn't make ${opened.failure.path}: ${opened.failure.message}`;
524
- const path = `${displayPath(opened.directory.path, env)}/`;
474
+ const path = `${displayPath(opened.path, env)}/`;
525
475
  const problems = [
526
476
  ...(writeFailure === undefined ? [] : [`couldn't write ${writeFailure.path}: ${writeFailure.message}`]),
527
477
  ...opened.pruneFailures.slice(0, 1).map((failure) => `couldn't remove ${failure.path}: ${failure.message}`),
528
478
  ];
529
- const show = `storm runs show ${opened.directory.id}${failed ? " --failed" : ""}`;
479
+ const show = `storm runs show ${opened.id}${failed ? " --failed" : ""}`;
530
480
  return `${problems.length === 0 ? path : `${path} (${problems.join("; ")})`} · ${show}`;
531
481
  }
532
- /**
533
- * How the run ended, for `run.json`: its outcome's kind; for a run whose command ran, the status storm exits with
534
- * and the signal that ended the command; how long the command took, from the command's state once it ended on its own
535
- * (a command the run stopped has none); the totals of its tests' final results, and why they may be incomplete; and a
536
- * ran outcome's acquired resources' result facts, with the rows `storm runs show` lists for them, each rendered when
537
- * the resource's acquire answered, so a past run shows them without the definitions that made them.
538
- */
539
- function runEnd(outcome, ran, tests) {
540
- const command = outcome.kind === "ran" ? outcome.command : undefined;
541
- const ranRecords = outcome.kind === "ran" ? outcome.resources : undefined;
542
- const ms = ran?.outcome === undefined || ran.outcome === "stopped" || ran.endedAt === undefined
543
- ? null
544
- : ran.endedAt - ran.startedAt;
545
- return {
546
- outcome: outcome.kind,
547
- exitCode: command === undefined ? null : commandExitStatus(command),
548
- signal: command?.kind === "signaled" ? command.signal : null,
549
- ms,
550
- tests: testTotals(tests.events),
551
- testsIncomplete: tests.incomplete ?? null,
552
- resources: ranRecords === undefined ? null : RESOURCE_REPORTS.ranFacts(ranRecords),
553
- resourceRows: ranRecords === undefined ? [] : RESOURCE_REPORTS.ranRows(ranRecords),
554
- };
555
- }
556
482
  /**
557
483
  * Where the checkout `cwd` is in was as the run starts, for `run.json`; null outside a Git checkout, or when git
558
484
  * can't say. The run goes on either way.
@@ -576,6 +502,25 @@ function recipeResources(requests) {
576
502
  return [key, { definition, options }];
577
503
  }));
578
504
  }
505
+ /** Whether `--keep-sandbox` asks for a keep time above 0. `validate` refused a flag this can't read. */
506
+ function keepsSandbox(flag) {
507
+ return flag !== undefined && (parseKeepTime(flag) ?? 0) > 0;
508
+ }
509
+ /**
510
+ * Whether a sandboxed run saves its runner sandbox as a branch snapshot (`RunnerSaveMode`): `--save-snapshot` as
511
+ * given, `always` or `never`; else never when `--keep-sandbox` asks to keep the runner sandbox, since a save deletes
512
+ * it and the flag is this run's own; else the recipe's `saveSnapshot` as given, with `CI` set too, as its
513
+ * `keepSandbox` applies there. With none of them it saves once per commit, once a command exits 0 (`new-head`), so a
514
+ * failed command's runner sandbox is kept for a person to connect to, but never when `CI` is set, since the runner
515
+ * snapshot cache is this machine's and a CI machine's next run rarely finds it, and never when the recipe's install
516
+ * or build step names a runner secret (`runStepTakesSecret`).
517
+ */
518
+ function saveMode(request, recipe, env) {
519
+ const choice = request.saveSnapshot ?? (keepsSandbox(request.keepSandbox) ? false : recipe.saveSnapshot);
520
+ if (choice !== undefined)
521
+ return choice ? "always" : "never";
522
+ return isCi(env) || runStepTakesSecret(recipe) ? "never" : "new-head";
523
+ }
579
524
  /** How long a runner sandbox keeps running once its run ends, when neither the flag nor the recipe says. */
580
525
  export const DEFAULT_KEEP_SANDBOX_MINUTES = 30;
581
526
  /**
@@ -587,69 +532,13 @@ function keepSandboxMinutes(flag, recipe, env) {
587
532
  const fromFlag = flag === undefined ? undefined : parseKeepTime(flag);
588
533
  return fromFlag ?? recipe.keepSandboxMinutes ?? (isCi(env) ? 0 : DEFAULT_KEEP_SANDBOX_MINUTES);
589
534
  }
590
- /** Whether `CI` is set, as CI services set it: to anything but empty, `0` or `false`. */
591
- function isCi(env) {
592
- const ci = env["CI"];
593
- return ci !== undefined && ci !== "" && ci !== "0" && ci.toLowerCase() !== "false";
594
- }
595
- /**
596
- * Where the run's command runs, as `run.json` records it as the run starts: unsandboxed, or in a runner sandbox, with
597
- * no sandbox or snapshot yet.
598
- */
599
- function startedWhere(run) {
600
- if (run.runner === undefined)
601
- return { kind: "unsandboxed" };
602
- const { prepared, target } = run.runner;
603
- return {
604
- kind: "runner",
605
- team: target.team,
606
- project: target.project,
607
- region: prepared.recipe.region,
608
- runtime: prepared.recipe.runtime,
609
- vcpus: prepared.vcpus,
610
- base: prepared.base,
611
- baseRef: prepared.baseRef,
612
- sandbox: null,
613
- snapshot: null,
614
- keptUntil: null,
615
- save: null,
616
- };
617
- }
618
- /**
619
- * `where` once the run is over, from the runner's final state: for a sandboxed run, the runner sandbox the run started,
620
- * the runner snapshot it started from, which the run reused or built, when its timeout stops the runner sandbox it
621
- * kept running, and how saving it as a branch snapshot ended (`save`). Each is null when the run stopped before it,
622
- * kept no runner sandbox, or saved none.
623
- */
624
- function endedWhere(where, runner, save) {
625
- if (where.kind === "unsandboxed")
626
- return where;
627
- const snapshot = runner?.snapshot;
628
- return {
629
- ...where,
630
- sandbox: runner?.sandbox?.name ?? null,
631
- snapshot: snapshot === undefined || snapshot.kind === "building"
632
- ? null
633
- : {
634
- id: snapshot.id,
635
- base: snapshot.base,
636
- built: snapshot.kind === "built",
637
- branch: snapshot.branch,
638
- head: snapshot.head,
639
- },
640
- keptUntil: runner?.kept?.stopsAt ?? null,
641
- save,
642
- };
643
- }
644
535
  /** For each runner step that failed, where its whole output is: the summary's lines after the critical path. */
645
- function failedStepLogs(ran, directory, env) {
646
- if (directory === undefined)
647
- return [];
648
- const runner = ran.rows.find((row) => row.name === "runner");
536
+ function failedStepLogs(timeline, recording, env) {
537
+ const runner = timeline.rows.find((row) => row.name === "runner");
649
538
  return (runner?.steps ?? [])
650
539
  .filter((step) => step.outcome === "failed")
651
540
  .flatMap((step) => {
652
- const log = stepLog(directory, step.name);
541
+ const log = recording.stepLog(step.name);
653
542
  return log === undefined ? [] : [` failed ${step.name}, whole output: ${displayPath(log, env)}`];
654
543
  });
655
544
  }
@@ -673,7 +562,7 @@ function runnerFailureFacts(failure) {
673
562
  const NOTHING_RELEASED = { runnerCleanup: null, resourceCleanup: {} };
674
563
  /**
675
564
  * What a canceled run changed, for a person: whether its command ran, what happened to a sandboxed run's sandboxes, and
676
- * what each of its resource instances says of what it changed (`RESOURCE_REPORTS.canceledLines`).
565
+ * what each of its resource instances says of what it changed (`REGISTRY.reports.canceledLines`).
677
566
  */
678
567
  function canceledChanges(outcome) {
679
568
  const { commandStopped } = outcome;
@@ -683,7 +572,7 @@ function canceledChanges(outcome) {
683
572
  const cleanup = RUN_CLEANUP.facts(outcome).runner;
684
573
  if (cleanup !== null)
685
574
  lines.push(...runnerCleanupLines(cleanup));
686
- lines.push(...RESOURCE_REPORTS.canceledLines(outcome.resourceCleanup));
575
+ lines.push(...REGISTRY.reports.canceledLines(outcome.resourceCleanup));
687
576
  return lines.join("\n");
688
577
  }
689
578
  /** What happened to a canceled sandboxed run's sandboxes, for a person: the one it kept running, and the rest. */
@@ -13,11 +13,11 @@ export declare const RUN_FIELDS: {
13
13
  readonly description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base, and drop this branch's saved branch snapshots from the cache. Not with --unsandboxed. No config key.";
14
14
  };
15
15
  saveSnapshot: {
16
- readonly description: "Once the command ends on its own after a successful install and build, save the runner sandbox as this branch's runner snapshot, so the next run on the branch starts from this run's install and build outputs. The run resets the working tree to the snapshot's base, keeps .git and ignored files such as node_modules and build outputs, and empties /tmp; the snapshot keeps whatever the command wrote there and to $HOME, a resource's token included. A run with it on a branch keeps no runner sandbox, even when it fails or stops before the save. With a detached HEAD it says so as it starts and keeps the runner sandbox as without the flag. Not with --unsandboxed, or with --keep-sandbox above 0. No config key.";
16
+ readonly description: "Whether the run saves the runner sandbox as this branch's runner snapshot once the command ends on its own, after a successful install and build, so the next run on the branch starts from this run's install and build outputs. Without the flag, a sandboxed run on a branch saves one when the command exits 0, unless it started from a branch snapshot that HEAD's commit saved, so each commit saves once; it saves none when the command fails, when CI is set, with --keep-sandbox above 0, with a detached HEAD, or when the runner recipe's install or build step names a runner secret, since those steps would run in a later run on top of what this run's command wrote; such a recipe also reuses no branch snapshot unless --save-snapshot or saveSnapshot: true trusts it. --save-snapshot saves whatever the command's exit code and whatever the run started from, under CI too, and with a detached HEAD says as the run starts that it saves nothing; not with --unsandboxed, or with --keep-sandbox above 0. --save-snapshot=false saves none. The save resets the working tree to the snapshot's base, keeps .git and ignored files such as node_modules and build outputs, and empties /tmp; the snapshot keeps whatever the command wrote there and to $HOME, a resource's token included. A run that starts a save keeps no runner sandbox, however the save ends; a run that starts none, such as one a signal stops, one whose install or build fails, or, without the flag, one whose command fails, keeps it for the keep time. Without the flag and without --keep-sandbox above 0, saveSnapshot in the runner recipe says the same as the flag for every run: false saves none, true saves as --save-snapshot does.";
17
17
  };
18
18
  keepSandbox: {
19
19
  readonly valueLabel: "DURATION";
20
- readonly description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --unsandboxed.";
20
+ readonly description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). A run that starts saving a branch snapshot keeps no runner sandbox (see --save-snapshot); given above 0, this flag has the run save none. The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --unsandboxed.";
21
21
  };
22
22
  showOutput: {
23
23
  readonly description: "In a sandboxed run on a terminal, print the runner's step output (a snapshot build, the install, the build) above the live view instead of keeping only each step's last line there. Plain output always prints it. Either way, the run directory keeps it whole. Not with --unsandboxed. No config key.";
@@ -3,7 +3,7 @@
3
3
  // (`resource-flags.ts`). `exec`'s and `vitest`'s `command.ts` read it for their leaf help.
4
4
  import { RESOURCE_FLAG_HELP, RESOURCE_USAGE_FLAGS } from "./resource-flags.js";
5
5
  /** The flags every run takes, as a usage line names them, before the command's own arguments. */
6
- export const RUN_USAGE_FLAGS = `${RESOURCE_USAGE_FLAGS} [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--unsandboxed | [--rebuild-snapshot] [--save-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]`;
6
+ export const RUN_USAGE_FLAGS = `${RESOURCE_USAGE_FLAGS} [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--unsandboxed | [--rebuild-snapshot] [--save-snapshot[=false]] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]`;
7
7
  /** The field descriptions of the run's own flags. */
8
8
  const OWN_RUN_FIELDS = {
9
9
  credential: {
@@ -17,11 +17,11 @@ const OWN_RUN_FIELDS = {
17
17
  description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base, and drop this branch's saved branch snapshots from the cache. Not with --unsandboxed. No config key.",
18
18
  },
19
19
  saveSnapshot: {
20
- description: "Once the command ends on its own after a successful install and build, save the runner sandbox as this branch's runner snapshot, so the next run on the branch starts from this run's install and build outputs. The run resets the working tree to the snapshot's base, keeps .git and ignored files such as node_modules and build outputs, and empties /tmp; the snapshot keeps whatever the command wrote there and to $HOME, a resource's token included. A run with it on a branch keeps no runner sandbox, even when it fails or stops before the save. With a detached HEAD it says so as it starts and keeps the runner sandbox as without the flag. Not with --unsandboxed, or with --keep-sandbox above 0. No config key.",
20
+ description: "Whether the run saves the runner sandbox as this branch's runner snapshot once the command ends on its own, after a successful install and build, so the next run on the branch starts from this run's install and build outputs. Without the flag, a sandboxed run on a branch saves one when the command exits 0, unless it started from a branch snapshot that HEAD's commit saved, so each commit saves once; it saves none when the command fails, when CI is set, with --keep-sandbox above 0, with a detached HEAD, or when the runner recipe's install or build step names a runner secret, since those steps would run in a later run on top of what this run's command wrote; such a recipe also reuses no branch snapshot unless --save-snapshot or saveSnapshot: true trusts it. --save-snapshot saves whatever the command's exit code and whatever the run started from, under CI too, and with a detached HEAD says as the run starts that it saves nothing; not with --unsandboxed, or with --keep-sandbox above 0. --save-snapshot=false saves none. The save resets the working tree to the snapshot's base, keeps .git and ignored files such as node_modules and build outputs, and empties /tmp; the snapshot keeps whatever the command wrote there and to $HOME, a resource's token included. A run that starts a save keeps no runner sandbox, however the save ends; a run that starts none, such as one a signal stops, one whose install or build fails, or, without the flag, one whose command fails, keeps it for the keep time. Without the flag and without --keep-sandbox above 0, saveSnapshot in the runner recipe says the same as the flag for every run: false saves none, true saves as --save-snapshot does.",
21
21
  },
22
22
  keepSandbox: {
23
23
  valueLabel: "DURATION",
24
- description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --unsandboxed.",
24
+ description: "How long the runner sandbox keeps running once the run ends, however it ends, so you can connect to it from its page in the Vercel dashboard: 0, which stops and deletes it with the run's other sandboxes, or a whole number of minutes or hours up to 5h (30m, 2h). A run that starts saving a branch snapshot keeps no runner sandbox (see --save-snapshot); given above 0, this flag has the run save none. The run asks Vercel Sandbox to extend the runner sandbox's timeout when it would stop sooner; it never shortens it, so the sandbox may run past the keep time until its own timeout. The run says until when it runs, and storm runs show and runs list say so too. Default: keepSandbox in the runner recipe, else 30m, or 0 when CI is set. Not with --unsandboxed.",
25
25
  },
26
26
  showOutput: {
27
27
  description: "In a sandboxed run on a terminal, print the runner's step output (a snapshot build, the install, the build) above the live view instead of keeping only each step's last line there. Plain output always prints it. Either way, the run directory keeps it whole. Not with --unsandboxed. No config key.",