@cnc-tools/storm 0.6.0 → 0.8.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 (174) hide show
  1. package/dist/build-info.js +1 -1
  2. package/dist/commands/exec/cleanup.d.ts +3 -3
  3. package/dist/commands/exec/cleanup.js +1 -1
  4. package/dist/commands/exec/command.d.ts +797 -1
  5. package/dist/commands/exec/command.js +1 -1
  6. package/dist/commands/exec/live-view.js +32 -15
  7. package/dist/commands/exec/metadata.d.ts +5 -2
  8. package/dist/commands/exec/metadata.js +4 -0
  9. package/dist/commands/exec/mint-failed.d.ts +28 -0
  10. package/dist/commands/exec/outcomes.d.ts +526 -0
  11. package/dist/commands/exec/outcomes.js +9 -0
  12. package/dist/commands/exec/progress.d.ts +14 -2
  13. package/dist/commands/exec/progress.js +57 -14
  14. package/dist/commands/exec/run-command.d.ts +10 -4
  15. package/dist/commands/exec/run-command.js +41 -8
  16. package/dist/commands/exec/run-metadata.d.ts +6 -3
  17. package/dist/commands/exec/run-metadata.js +6 -3
  18. package/dist/commands/exec/run-record.d.ts +83 -4
  19. package/dist/commands/exec/run-record.js +49 -1
  20. package/dist/commands/exec/tests-summary.d.ts +1 -1
  21. package/dist/commands/exec/tests-summary.js +1 -1
  22. package/dist/commands/exec/view.js +36 -4
  23. package/dist/commands/runs/facts.d.ts +25 -0
  24. package/dist/commands/runs/facts.js +36 -3
  25. package/dist/commands/runs/list/command.d.ts +154 -1
  26. package/dist/commands/runs/list/command.js +1 -1
  27. package/dist/commands/runs/list/outcomes.d.ts +41 -0
  28. package/dist/commands/runs/logs/command.d.ts +263 -1
  29. package/dist/commands/runs/logs/command.js +1 -1
  30. package/dist/commands/runs/logs/outcomes.d.ts +105 -0
  31. package/dist/commands/runs/show/command.d.ts +354 -1
  32. package/dist/commands/runs/show/command.js +1 -1
  33. package/dist/commands/runs/show/metadata.js +1 -1
  34. package/dist/commands/runs/show/outcomes.d.ts +96 -0
  35. package/dist/commands/runs/show/outcomes.js +30 -1
  36. package/dist/commands/vitest/command.d.ts +912 -1
  37. package/dist/commands/vitest/command.js +1 -1
  38. package/dist/commands/vitest/metadata.d.ts +5 -2
  39. package/dist/commands/vitest/metadata.js +4 -0
  40. package/dist/commands/vitest/outcomes.d.ts +320 -0
  41. package/dist/config/errors.d.ts +73 -0
  42. package/dist/config/schema.d.ts +1 -1
  43. package/dist/config-file/define.d.ts +4 -3
  44. package/dist/config-file/define.js +1 -1
  45. package/dist/config-file/toolchain.js +1 -1
  46. package/dist/core/command-slots.d.ts +8 -2
  47. package/dist/core/command-slots.js +6 -2
  48. package/dist/core/events.d.ts +9 -7
  49. package/dist/core/index.d.ts +1 -1
  50. package/dist/core/run-state.d.ts +30 -6
  51. package/dist/core/run-state.js +19 -4
  52. package/dist/core/run.d.ts +17 -4
  53. package/dist/core/run.js +61 -25
  54. package/dist/credential/index.d.ts +1 -0
  55. package/dist/credential/index.js +1 -0
  56. package/dist/credential/settle.d.ts +20 -0
  57. package/dist/credential/target.d.ts +6 -0
  58. package/dist/credential/target.js +7 -0
  59. package/dist/resources/github/command.d.ts +54 -2
  60. package/dist/resources/github/config.js +1 -1
  61. package/dist/resources/github/index.js +1 -1
  62. package/dist/resources/github/resource.js +2 -2
  63. package/dist/resources/testserver/command.d.ts +208 -10
  64. package/dist/resources/testserver/command.js +7 -0
  65. package/dist/resources/testserver/commands/create/command.d.ts +808 -1
  66. package/dist/resources/testserver/commands/create/command.js +64 -23
  67. package/dist/resources/testserver/commands/create/metadata.js +6 -2
  68. package/dist/resources/testserver/commands/create/outcomes.d.ts +347 -0
  69. package/dist/resources/testserver/commands/create/outcomes.js +14 -1
  70. package/dist/resources/testserver/commands/list/command.d.ts +84 -1
  71. package/dist/resources/testserver/commands/list/command.js +1 -1
  72. package/dist/resources/testserver/commands/list/outcomes.d.ts +16 -0
  73. package/dist/resources/testserver/config.js +14 -4
  74. package/dist/resources/testserver/events.d.ts +9 -0
  75. package/dist/resources/testserver/index.js +8 -7
  76. package/dist/resources/testserver/lane.js +1 -0
  77. package/dist/resources/testserver/live/gateways.d.ts +2 -0
  78. package/dist/resources/testserver/live/gateways.js +16 -3
  79. package/dist/resources/testserver/pool/channels.d.ts +5 -2
  80. package/dist/resources/testserver/pool/channels.js +1 -1
  81. package/dist/resources/testserver/pool/create.d.ts +6 -2
  82. package/dist/resources/testserver/pool/create.js +6 -5
  83. package/dist/resources/testserver/pool/index.d.ts +1 -0
  84. package/dist/resources/testserver/pool/index.js +1 -0
  85. package/dist/resources/testserver/pool/pull-request.d.ts +89 -0
  86. package/dist/resources/testserver/pool/pull-request.js +85 -0
  87. package/dist/resources/testserver/pr-build-facts.d.ts +130 -0
  88. package/dist/resources/testserver/pr-build-facts.js +261 -0
  89. package/dist/resources/testserver/presentation.d.ts +2 -2
  90. package/dist/resources/testserver/presentation.js +12 -3
  91. package/dist/resources/testserver/provider.d.ts +16 -6
  92. package/dist/resources/testserver/provider.js +46 -15
  93. package/dist/resources/testserver/pull-request/gateways.d.ts +117 -0
  94. package/dist/resources/testserver/pull-request/gateways.js +5 -0
  95. package/dist/resources/testserver/pull-request/index.d.ts +5 -0
  96. package/dist/resources/testserver/pull-request/index.js +6 -0
  97. package/dist/resources/testserver/pull-request/live/github-rest.d.ts +28 -0
  98. package/dist/resources/testserver/pull-request/live/github-rest.js +114 -0
  99. package/dist/resources/testserver/pull-request/live/github-token-gateway.d.ts +12 -0
  100. package/dist/resources/testserver/pull-request/live/github-token-gateway.js +39 -0
  101. package/dist/resources/testserver/pull-request/live/pull-request-gateway.d.ts +10 -0
  102. package/dist/resources/testserver/pull-request/live/pull-request-gateway.js +27 -0
  103. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.d.ts +21 -0
  104. package/dist/resources/testserver/pull-request/live/testserver-workflow-gateway.js +64 -0
  105. package/dist/resources/testserver/ran.d.ts +5 -0
  106. package/dist/resources/testserver/ran.js +19 -3
  107. package/dist/resources/testserver/resource.d.ts +5 -1
  108. package/dist/resources/testserver/resource.js +2 -2
  109. package/dist/resources/testserver/sandbox/build-reference.d.ts +38 -0
  110. package/dist/resources/testserver/sandbox/build-reference.js +79 -0
  111. package/dist/resources/testserver/sandbox/index.d.ts +1 -0
  112. package/dist/resources/testserver/sandbox/index.js +1 -0
  113. package/dist/resources.d.ts +265 -15
  114. package/dist/runner/events.d.ts +64 -1
  115. package/dist/runner/gateways.d.ts +17 -6
  116. package/dist/runner/index.d.ts +5 -4
  117. package/dist/runner/index.js +4 -3
  118. package/dist/runner/live/snapshot-records.js +18 -4
  119. package/dist/runner/prepare.d.ts +23 -4
  120. package/dist/runner/prepare.js +13 -3
  121. package/dist/runner/ready.d.ts +7 -3
  122. package/dist/runner/ready.js +11 -5
  123. package/dist/runner/scope.d.ts +17 -1
  124. package/dist/runner/scope.js +4 -0
  125. package/dist/runner/snapshot-build.d.ts +3 -1
  126. package/dist/runner/snapshot-build.js +12 -2
  127. package/dist/runner/snapshot-cache.d.ts +46 -8
  128. package/dist/runner/snapshot-cache.js +60 -11
  129. package/dist/runner/snapshot-key.d.ts +12 -1
  130. package/dist/runner/snapshot-key.js +17 -1
  131. package/dist/runner/snapshot-save.d.ts +53 -0
  132. package/dist/runner/snapshot-save.js +148 -0
  133. package/dist/sdk/index.js +2 -2
  134. package/dist/story/align.d.ts +1 -1
  135. package/dist/story/align.js +1 -1
  136. package/dist/story/command-line.d.ts +34 -0
  137. package/dist/story/command-line.js +100 -0
  138. package/dist/story/definition.d.ts +22 -15
  139. package/dist/story/definition.js +2 -2
  140. package/dist/story/errors.js +1 -1
  141. package/dist/story/gateways.d.ts +45 -25
  142. package/dist/story/gateways.js +2 -2
  143. package/dist/story/host.d.ts +11 -8
  144. package/dist/story/host.js +37 -37
  145. package/dist/story/index.d.ts +2 -1
  146. package/dist/story/index.js +6 -5
  147. package/dist/story/json.d.ts +1 -1
  148. package/dist/story/json.js +2 -2
  149. package/dist/story/live/recording-gateway.d.ts +2 -0
  150. package/dist/story/live/{artifact-gateway.js → recording-gateway.js} +33 -12
  151. package/dist/story/mode.d.ts +2 -2
  152. package/dist/story/mode.js +1 -1
  153. package/dist/story/orphans.d.ts +23 -5
  154. package/dist/story/orphans.js +44 -8
  155. package/dist/story/recording.d.ts +62 -0
  156. package/dist/story/{artifact.js → recording.js} +31 -27
  157. package/dist/story/report.d.ts +21 -9
  158. package/dist/story/report.js +37 -25
  159. package/dist/story/settle.d.ts +23 -21
  160. package/dist/story/settle.js +17 -16
  161. package/dist/story/{run.d.ts → start.d.ts} +18 -17
  162. package/dist/story/{run.js → start.js} +66 -43
  163. package/dist/vercel-cli/context.js +1 -1
  164. package/dist/vercel-cli/index.js +1 -1
  165. package/dist/vitest/config.js +2 -2
  166. package/dist/vitest/fixtures.d.ts +1 -1
  167. package/dist/vitest/fixtures.js +1 -1
  168. package/dist/vitest/index.js +3 -3
  169. package/dist/vitest/plan.js +1 -1
  170. package/package.json +3 -3
  171. package/skills/overview.md +2 -0
  172. package/skills/testserver-builds.md +80 -0
  173. package/dist/story/artifact.d.ts +0 -60
  174. package/dist/story/live/artifact-gateway.d.ts +0 -2
@@ -1,3 +1,4 @@
1
+ import { mintTargetText } from "../../credential/index.js";
1
2
  import { megabytesText, secondsOf, secondsText } from "../../core/index.js";
2
3
  import { RESOURCE_PRESENTATIONS, RESOURCE_REPORTS, } from "../../resources.js";
3
4
  import { versionText } from "../../version.js";
@@ -76,10 +77,10 @@ function eventLines(event, now, state, line, options) {
76
77
  ];
77
78
  case "minting":
78
79
  state.mintStartedAt = now;
79
- return [line("mint", `credential for ${targetText(event.target)}…`)];
80
+ return [line("mint", `credential for ${mintTargetText(event.target)}…`)];
80
81
  case "minted":
81
82
  return [
82
- line("mint", `${event.ok ? "credential" : "no credential"} for ${targetText(event.target)} (${since(state.mintStartedAt)})`),
83
+ line("mint", `${event.ok ? "credential" : "no credential"} for ${mintTargetText(event.target)} (${since(state.mintStartedAt)})`),
83
84
  ];
84
85
  case "requesting-token":
85
86
  return [line("mint", "requesting a GitHub Actions OIDC token…")];
@@ -119,7 +120,7 @@ function eventLines(event, now, state, line, options) {
119
120
  case "cleanup-started":
120
121
  state.cleanupStartedAt = now;
121
122
  return [
122
- line("cleanup", cleanupText(event.runner, event.keepSandboxMs, RESOURCE_PRESENTATIONS.releaseTexts(event.holdings, "doing"))),
123
+ line("cleanup", cleanupText(event.runnerSandbox, RESOURCE_PRESENTATIONS.releaseTexts(event.holdings, "doing"))),
123
124
  ];
124
125
  case "cleanup-finished": {
125
126
  const problems = [
@@ -150,7 +151,7 @@ function eventLines(event, now, state, line, options) {
150
151
  function runnerLines(event, state, line, options) {
151
152
  switch (event.kind) {
152
153
  case "snapshot-reused":
153
- return [line("runner", `reusing runner snapshot ${event.snapshotId} of base ${short(event.base)}`)];
154
+ return [line("runner", snapshotReusedText(event))];
154
155
  case "snapshot-build-started":
155
156
  return [
156
157
  line("runner", `building a runner snapshot of base ${short(event.base)} (${event.reason === "rebuild" ? "--rebuild-snapshot" : "no cached runner snapshot fits"}); this takes a few minutes: ${event.summary}`),
@@ -204,8 +205,46 @@ function runnerLines(event, state, line, options) {
204
205
  ];
205
206
  case "sandbox-kept":
206
207
  return [line("cleanup", `kept the runner sandbox ${event.name} running until ${isoSecondsText(event.stopsAt)}`)];
208
+ // The cleanup line says the run saves a branch snapshot.
209
+ case "branch-snapshot-saving":
210
+ return [];
211
+ case "branch-snapshot-saved":
212
+ case "branch-snapshot-not-saved":
213
+ return [line("cleanup", branchSnapshotSaveText(event))];
214
+ case "branch-snapshots-dropped":
215
+ case "branch-snapshots-not-dropped":
216
+ return [line("runner", branchSnapshotsDropText(event))];
217
+ }
218
+ }
219
+ /** The line that says which runner snapshot the run starts from, and for a branch snapshot, which run saved it. */
220
+ function snapshotReusedText(event) {
221
+ const reused = `reusing runner snapshot ${event.snapshotId} of base ${short(event.base)}`;
222
+ return event.branch === null || event.head === null
223
+ ? reused
224
+ : `${reused} (branch ${event.branch} at ${short(event.head)})`;
225
+ }
226
+ /** How saving a branch snapshot ended, as its line says. */
227
+ export function branchSnapshotSaveText(event) {
228
+ if (event.kind === "branch-snapshot-saved") {
229
+ return `saved branch snapshot ${event.snapshotId} for ${event.branch} at ${short(event.head)} in ${seconds(event.ms)} (${megabytesText(event.sizeBytes)})`;
230
+ }
231
+ return `not saving a branch snapshot: ${notSavedReason(event.save)}`;
232
+ }
233
+ function notSavedReason(save) {
234
+ switch (save.kind) {
235
+ case "failed":
236
+ return `the ${save.step === "scrub" ? "scrub" : "save"} failed: ${save.message}`;
237
+ case "stopped":
238
+ return "the run is stopping";
207
239
  }
208
240
  }
241
+ /** What `--rebuild-snapshot` did to the branch's branch snapshot entries, as its line says. */
242
+ export function branchSnapshotsDropText(event) {
243
+ if (event.kind === "branch-snapshots-not-dropped")
244
+ return `couldn't drop a branch snapshot of ${event.branch} from the cache at ${event.failure.path}: ${event.failure.message}; a later run on the branch may start from it`;
245
+ const count = event.snapshotIds.length;
246
+ return `dropped ${count} branch ${count === 1 ? "snapshot" : "snapshots"} of ${event.branch} from the cache: ${event.snapshotIds.join(", ")}`;
247
+ }
209
248
  /** What a stopping run says it releases of the resources it holds, such as ` and releasing the leases`. */
210
249
  function releasingText(held) {
211
250
  return RESOURCE_PRESENTATIONS.stoppingTexts(held)
@@ -220,15 +259,18 @@ function closeFold(state) {
220
259
  return ["::endgroup::"];
221
260
  }
222
261
  /**
223
- * What cleaning up does, as its first line says: in a runner run, keeping the runner sandbox running `keepMs` when that
224
- * is above 0, else stopping and deleting the runner's sandboxes; then what releasing each resource does (`releases`).
262
+ * What cleaning up does, as its first line says: in a runner run (`sandbox`, null in a local run), saving the runner
263
+ * sandbox as a branch snapshot while the resources are released, or keeping it running when its keep time is above 0,
264
+ * else stopping and deleting the runner's sandboxes; then what releasing each resource does (`releases`).
225
265
  */
226
- function cleanupText(runner, keepMs, releases) {
266
+ function cleanupText(sandbox, releases) {
227
267
  const release = releases.length === 0 ? undefined : releases.join(", ");
228
- if (!runner)
268
+ if (sandbox === null)
229
269
  return release === undefined ? "nothing to release" : `${release}…`;
230
- const sandboxes = keepMs > 0
231
- ? `keeping the runner sandbox running ${keepTimeText(keepMs)}`
270
+ if (sandbox.kind === "save")
271
+ return `saving a branch snapshot of ${sandbox.branch}${release === undefined ? "" : ` while ${release}`}…`;
272
+ const sandboxes = sandbox.ms > 0
273
+ ? `keeping the runner sandbox running ${keepTimeText(sandbox.ms)}`
232
274
  : "stopping and deleting the runner's sandboxes";
233
275
  return `${sandboxes}${release === undefined ? "" : `, then ${release}`}…`;
234
276
  }
@@ -256,19 +298,20 @@ function noteText(note) {
256
298
  return `not reusing cached runner snapshots of base ${short(note.base)}: ${note.failure.message.replace(/\.$/, "")}`;
257
299
  }
258
300
  }
259
- function targetText(target) {
260
- return `${target.team}/${target.project}`;
261
- }
262
301
  // The notices: what a run reports that the live view's phases can't hold, so it prints them above the live region
263
302
  // as plain lines, and plain progress prints among its other lines. Each builder answers the lines' text, which the
264
303
  // caller prefixes with the time and the lane (`progressLine`). A resource's own notices are its presentation's.
265
- /** In a runner run, what the local checks noticed: nested Git repositories left out, and the cache read's notes. */
304
+ /**
305
+ * In a runner run, what the local checks noticed: nested Git repositories left out, the cache read's notes, and that
306
+ * `--save-snapshot` saves nothing on a detached HEAD.
307
+ */
266
308
  export function preparedNoteTexts(prepared) {
267
309
  return [
268
310
  ...(prepared.nestedRepositories.length === 0
269
311
  ? []
270
312
  : [`leaving out untracked nested Git repositories: ${prepared.nestedRepositories.join(", ")}`]),
271
313
  ...prepared.notes.map(noteText),
314
+ ...(prepared.saveSkipped ? ["not saving a branch snapshot: HEAD is detached"] : []),
272
315
  ];
273
316
  }
274
317
  /** The runner snapshot cache couldn't record a runner snapshot the run built. */
@@ -22,6 +22,7 @@ export declare const RUN_REQUEST_FIELDS: {
22
22
  }>>;
23
23
  local: z.ZodDefault<z.ZodBoolean>;
24
24
  rebuildSnapshot: z.ZodDefault<z.ZodBoolean>;
25
+ saveSnapshot: z.ZodDefault<z.ZodBoolean>;
25
26
  showOutput: z.ZodDefault<z.ZodBoolean>;
26
27
  keepSandbox: z.ZodOptional<z.ZodString>;
27
28
  verbose: z.ZodDefault<z.ZodBoolean>;
@@ -47,6 +48,7 @@ declare const runRequestSchema: z.ZodObject<{
47
48
  }>>;
48
49
  local: z.ZodDefault<z.ZodBoolean>;
49
50
  rebuildSnapshot: z.ZodDefault<z.ZodBoolean>;
51
+ saveSnapshot: z.ZodDefault<z.ZodBoolean>;
50
52
  showOutput: z.ZodDefault<z.ZodBoolean>;
51
53
  keepSandbox: z.ZodOptional<z.ZodString>;
52
54
  verbose: z.ZodDefault<z.ZodBoolean>;
@@ -123,7 +125,11 @@ export interface RunCommandSpec<TPlan, TRan, TRefusal> {
123
125
  * for the runner sandbox, so it needs `scope` and `project` whatever resources it holds. In a runner run, the first
124
126
  * SIGINT, SIGTERM or SIGHUP stops the run in any phase: the remote command is killed, every sandbox the run started is
125
127
  * stopped and deleted, the leases are released, and the run cancels. `--rebuild-snapshot` (no config key, not with
126
- * `--local`) builds a runner snapshot whatever the cache holds.
128
+ * `--local`) builds a runner snapshot whatever the cache holds, and drops HEAD's branch's branch snapshots from it.
129
+ * `--save-snapshot` (no config key, not with `--local` or a `--keep-sandbox` above 0) saves the runner sandbox as a
130
+ * branch snapshot once the command ended on its own, while the leases are released, so the next run on the branch
131
+ * starts from it; a run with it on a branch keeps no runner sandbox, however it ends, and one on a detached HEAD says
132
+ * so as it starts and keeps its runner sandbox as without the flag.
127
133
  *
128
134
  * `--credential` (no config key) picks the credential source: `mint`, the default, or `github-actions`, which requests
129
135
  * a GitHub Actions OIDC token instead and so needs no `--scope` or `--project`; any given are unused. A runner run
@@ -147,9 +153,9 @@ export interface RunCommandSpec<TPlan, TRan, TRefusal> {
147
153
  * are hidden as `<token>` in the run's progress, its run directory, its job summary, its outcome, `spec.prepare`'s
148
154
  * refusal, and its command's output, in either kind of run.
149
155
  */
150
- export declare function runCommand<TPlan extends RunRecordPlan | undefined, TRan extends CommandResult, TRefusal extends CommandError = never>({ app, ui, signal }: ExecutionContext<StormApp>, request: RunCommandRequest, spec: RunCommandSpec<TPlan, TRan, TRefusal>): Promise<TRan | TRefusal | import("@vercel/clinkr").ClinkrError<"canceled"> | CommandError<"credential_unused"> | CommandError<"invalid_config"> | CommandError<"invalid_resource_options"> | CommandError<"mint_failed"> | CommandError<"missing_runner"> | CommandError<"missing_target"> | CommandError<"no_base_ref"> | CommandError<"runner_failed"> | CommandError<"snapshot_gone"> | CommandError<"spawn_failed"> | CommandError<"submodules_refused"> | CommandError<"credential_rejected" | "github_fixture_repo_unavailable" | "github_token_missing" | "no_sandboxes" | "no_usable_sandboxes" | "pool_unavailable" | "pool_unreadable" | "token_request_failed">>;
156
+ export declare function runCommand<TPlan extends RunRecordPlan | undefined, TRan extends CommandResult, TRefusal extends CommandError = never>({ app, ui, signal }: ExecutionContext<StormApp>, request: RunCommandRequest, spec: RunCommandSpec<TPlan, TRan, TRefusal>): Promise<TRan | TRefusal | import("@vercel/clinkr").ClinkrError<"canceled"> | CommandError<"credential_rejected"> | CommandError<"credential_unused"> | CommandError<"github_fixture_repo_unavailable"> | CommandError<"github_token_missing"> | CommandError<"invalid_config"> | CommandError<"invalid_resource_options"> | CommandError<"mint_failed"> | CommandError<"missing_runner"> | CommandError<"missing_target"> | CommandError<"no_base_ref"> | CommandError<"no_sandboxes"> | CommandError<"no_usable_sandboxes"> | CommandError<"pool_unavailable"> | CommandError<"pool_unreadable"> | CommandError<"pr_build_expired"> | CommandError<"pr_build_not_ready"> | CommandError<"pr_builds_unlisted"> | CommandError<"pull_request_unreadable"> | CommandError<"runner_failed"> | CommandError<"snapshot_gone"> | CommandError<"spawn_failed"> | CommandError<"submodules_refused"> | CommandError<"token_request_failed">>;
151
157
  /** What is wrong with a run's request that its schema can't say, as `validate` reports it. */
152
- export declare function runProblems({ set, credential, local, rebuildSnapshot, showOutput, keepSandbox, ...rest }: RunCommandRequest): readonly ArgumentIssue[];
158
+ export declare function runProblems({ set, credential, local, rebuildSnapshot, saveSnapshot, showOutput, keepSandbox, ...rest }: RunCommandRequest): readonly ArgumentIssue[];
153
159
  /**
154
160
  * A run canceled before it started, while it was settled or prepared: nothing was minted, leased or started, and the
155
161
  * command didn't run.
@@ -199,7 +205,7 @@ declare function settleRun(app: StormApp, request: {
199
205
  readonly refusal: CommandError<"missing_target">;
200
206
  } | {
201
207
  readonly ok: false;
202
- readonly refusal: CommandError<"credential_rejected" | "github_fixture_repo_unavailable" | "github_token_missing" | "no_sandboxes" | "no_usable_sandboxes" | "pool_unavailable" | "pool_unreadable" | "token_request_failed">;
208
+ readonly refusal: CommandError<"credential_rejected"> | CommandError<"github_fixture_repo_unavailable"> | CommandError<"github_token_missing"> | CommandError<"no_sandboxes"> | CommandError<"no_usable_sandboxes"> | CommandError<"pool_unavailable"> | CommandError<"pool_unreadable"> | CommandError<"pr_build_expired"> | CommandError<"pr_build_not_ready"> | CommandError<"pr_builds_unlisted"> | CommandError<"pull_request_unreadable"> | CommandError<"token_request_failed">;
203
209
  } | {
204
210
  readonly ok: false;
205
211
  readonly refusal: CommandError<"credential_unused">;
@@ -35,6 +35,7 @@ export const RUN_REQUEST_FIELDS = {
35
35
  credential: z.enum(["mint", "github-actions"]).optional(),
36
36
  local: z.boolean().default(false),
37
37
  rebuildSnapshot: z.boolean().default(false),
38
+ saveSnapshot: z.boolean().default(false),
38
39
  showOutput: z.boolean().default(false),
39
40
  keepSandbox: z.string().optional(),
40
41
  verbose: z.boolean().default(false),
@@ -79,7 +80,11 @@ const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
79
80
  * for the runner sandbox, so it needs `scope` and `project` whatever resources it holds. In a runner run, the first
80
81
  * SIGINT, SIGTERM or SIGHUP stops the run in any phase: the remote command is killed, every sandbox the run started is
81
82
  * stopped and deleted, the leases are released, and the run cancels. `--rebuild-snapshot` (no config key, not with
82
- * `--local`) builds a runner snapshot whatever the cache holds.
83
+ * `--local`) builds a runner snapshot whatever the cache holds, and drops HEAD's branch's branch snapshots from it.
84
+ * `--save-snapshot` (no config key, not with `--local` or a `--keep-sandbox` above 0) saves the runner sandbox as a
85
+ * branch snapshot once the command ended on its own, while the leases are released, so the next run on the branch
86
+ * starts from it; a run with it on a branch keeps no runner sandbox, however it ends, and one on a detached HEAD says
87
+ * so as it starts and keeps its runner sandbox as without the flag.
83
88
  *
84
89
  * `--credential` (no config key) picks the credential source: `mint`, the default, or `github-actions`, which requests
85
90
  * a GitHub Actions OIDC token instead and so needs no `--scope` or `--project`; any given are unused. A runner run
@@ -150,9 +155,11 @@ export async function runCommand({ app, ui, signal }, request, spec) {
150
155
  recipe: where.recipe,
151
156
  resources: RESOURCE_REPORTS.runnerResources(options),
152
157
  rebuild: request.rebuildSnapshot,
158
+ saveSnapshot: request.saveSnapshot,
153
159
  });
154
160
  if (prepared.kind !== "ok")
155
161
  return prepareRefusal(prepared, configFile);
162
+ const { save } = prepared.prepared;
156
163
  run = {
157
164
  ...base,
158
165
  resources: settlement.requests,
@@ -160,7 +167,9 @@ export async function runCommand({ app, ui, signal }, request, spec) {
160
167
  prepared: prepared.prepared,
161
168
  target: where.target,
162
169
  user: app.user,
163
- keepSandboxMs: keepSandboxMinutes(request.keepSandbox, where.recipe, app.env) * 60_000,
170
+ sandbox: save?.kind === "branch"
171
+ ? { kind: "save", branch: save.branch }
172
+ : { kind: "keep", ms: keepSandboxMinutes(request.keepSandbox, where.recipe, app.env) * 60_000 },
164
173
  },
165
174
  };
166
175
  }
@@ -256,10 +265,14 @@ export async function runCommand({ app, ui, signal }, request, spec) {
256
265
  : {
257
266
  snapshotId: outcome.runner.snapshotId,
258
267
  base: outcome.runner.base,
268
+ snapshotBranch: outcome.runner.snapshotBranch,
269
+ snapshotHead: outcome.runner.snapshotHead,
259
270
  built: outcome.runner.built,
260
271
  vcpus: outcome.runner.vcpus,
261
272
  region: outcome.runner.region,
262
273
  runtime: outcome.runner.runtime,
274
+ buildMs: outcome.runner.buildMs,
275
+ save: outcome.runner.save,
263
276
  },
264
277
  timeline: timelineFacts(ran),
265
278
  runId: directory?.id ?? null,
@@ -301,7 +314,7 @@ export async function runCommand({ app, ui, signal }, request, spec) {
301
314
  }
302
315
  }
303
316
  /** What is wrong with a run's request that its schema can't say, as `validate` reports it. */
304
- export function runProblems({ set, credential, local, rebuildSnapshot, showOutput, keepSandbox, ...rest }) {
317
+ export function runProblems({ set, credential, local, rebuildSnapshot, saveSnapshot, showOutput, keepSandbox, ...rest }) {
305
318
  return [
306
319
  ...setProblems(set).map((problem) => ({ field: "set", message: `${problem}.` })),
307
320
  ...testserverFlagProblems(rest),
@@ -330,6 +343,17 @@ export function runProblems({ set, credential, local, rebuildSnapshot, showOutpu
330
343
  ...(keepSandbox !== undefined && local
331
344
  ? [{ field: "keepSandbox", message: "--keep-sandbox keeps a runner run's runner sandbox; drop it or --local." }]
332
345
  : []),
346
+ ...(saveSnapshot && local
347
+ ? [{ field: "saveSnapshot", message: "--save-snapshot saves a runner run's runner sandbox; drop it or --local." }]
348
+ : []),
349
+ ...(saveSnapshot && keepSandbox !== undefined && (parseKeepTime(keepSandbox) ?? 0) > 0
350
+ ? [
351
+ {
352
+ field: "saveSnapshot",
353
+ message: "--save-snapshot saves the runner sandbox instead of keeping it; drop --keep-sandbox or set it to 0.",
354
+ },
355
+ ]
356
+ : []),
333
357
  ];
334
358
  }
335
359
  /**
@@ -389,7 +413,7 @@ async function summarize(app, run) {
389
413
  directory?.writeTimeline(JSON.stringify(ran, null, 2));
390
414
  directory?.writeRun(runRecordText({
391
415
  ...run.record,
392
- where: endedWhere(run.record.where, state.runner),
416
+ where: endedWhere(run.record.where, state.runner, run.outcome.kind === "ran" ? (run.outcome.runner?.save ?? null) : null),
393
417
  ended: runEnd(run.outcome, state.command, tests, run.requests),
394
418
  }));
395
419
  const writeFailure = await directory?.close();
@@ -527,14 +551,16 @@ function startedWhere(runner) {
527
551
  sandbox: null,
528
552
  snapshot: null,
529
553
  keptUntil: null,
554
+ save: null,
530
555
  };
531
556
  }
532
557
  /**
533
558
  * `where` once the run is over, from the runner's final state: for a runner run, the runner sandbox the run started,
534
- * the runner snapshot it started from, which the run reused or built, and when its timeout stops the runner sandbox it
535
- * kept running. Each is null when the run stopped before it, or kept no runner sandbox.
559
+ * the runner snapshot it started from, which the run reused or built, when its timeout stops the runner sandbox it
560
+ * kept running, and how saving it as a branch snapshot ended (`save`). Each is null when the run stopped before it,
561
+ * kept no runner sandbox, or saved none.
536
562
  */
537
- function endedWhere(where, runner) {
563
+ function endedWhere(where, runner, save) {
538
564
  if (where.kind === "local")
539
565
  return where;
540
566
  const snapshot = runner?.snapshot;
@@ -543,8 +569,15 @@ function endedWhere(where, runner) {
543
569
  sandbox: runner?.sandbox?.name ?? null,
544
570
  snapshot: snapshot === undefined || snapshot.kind === "building"
545
571
  ? null
546
- : { id: snapshot.id, base: snapshot.base, built: snapshot.kind === "built" },
572
+ : {
573
+ id: snapshot.id,
574
+ base: snapshot.base,
575
+ built: snapshot.kind === "built",
576
+ branch: snapshot.branch,
577
+ head: snapshot.head,
578
+ },
547
579
  keptUntil: runner?.kept?.stopsAt ?? null,
580
+ save,
548
581
  };
549
582
  }
550
583
  /** For each runner step that failed, where its whole output is: the summary's lines after the critical path. */
@@ -1,5 +1,5 @@
1
1
  /** The flags every run takes, as a usage line names them, before the command's own arguments. */
2
- export declare const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
2
+ export declare const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--save-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
3
3
  /** The field descriptions of the flags every run takes. */
4
4
  export declare const RUN_FIELDS: {
5
5
  readonly testserverSandboxes: {
@@ -8,7 +8,7 @@ export declare const RUN_FIELDS: {
8
8
  };
9
9
  readonly testserverBuild: {
10
10
  readonly valueLabel: "BUILD";
11
- readonly description: "The build the Testserver sandboxes run: a build name or the build channel stable or latest_main, overriding resources.testserverPool.build in storm.config.ts; default stable. Gives the run a Testserver side.";
11
+ readonly description: "The build the Testserver sandboxes run: a build name, the build channel stable or latest_main, or a vercel/api pull request as pr:<N> or its URL, overriding resources.testserverPool.build in storm.config.ts; default stable. A pull request runs on the newest build made from its head commit, which storm reads from GitHub with GITHUB_TOKEN, GH_TOKEN or gh auth token, or refuses. Gives the run a Testserver side.";
12
12
  };
13
13
  readonly testserverMinTimeLeft: {
14
14
  readonly valueLabel: "DURATION";
@@ -33,7 +33,10 @@ export declare const RUN_FIELDS: {
33
33
  readonly description: "Run the command on this machine instead of in a runner sandbox. Without it, the command runs in a Vercel Sandbox started from a runner snapshot of the base, with this checkout's changes applied, installed and built, from the runner key of storm.config.ts, and its output streams back with paths rewritten to this checkout's. No config key.";
34
34
  };
35
35
  readonly rebuildSnapshot: {
36
- readonly description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base. Not with --local. No config key.";
36
+ 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 --local. No config key.";
37
+ };
38
+ readonly saveSnapshot: {
39
+ 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 --local, or with --keep-sandbox above 0. No config key.";
37
40
  };
38
41
  readonly keepSandbox: {
39
42
  readonly valueLabel: "DURATION";
@@ -1,7 +1,7 @@
1
1
  // The help every run's command shares, `exec`'s and `vitest`'s: the usage of the flags every run takes, and their field
2
2
  // descriptions. Clinkr loads each command's metadata eagerly for navigation, so this module imports nothing.
3
3
  /** The flags every run takes, as a usage line names them, before the command's own arguments. */
4
- export const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
4
+ export const RUN_USAGE_FLAGS = "[--testserver-sandboxes <N>] [--testserver-build <BUILD>] [--testserver-min-time-left <DURATION>] [--testserver-ttl <DURATION> | --testserver-no-create] [--set <KEY=VALUE>]... [--credential <SOURCE>] [--scope <TEAM> --project <PROJECT>] [--local | [--rebuild-snapshot] [--save-snapshot] [--show-output] [--keep-sandbox <DURATION>]] [--verbose]";
5
5
  /** The field descriptions of the flags every run takes. */
6
6
  export const RUN_FIELDS = {
7
7
  testserverSandboxes: {
@@ -10,7 +10,7 @@ export const RUN_FIELDS = {
10
10
  },
11
11
  testserverBuild: {
12
12
  valueLabel: "BUILD",
13
- description: "The build the Testserver sandboxes run: a build name or the build channel stable or latest_main, overriding resources.testserverPool.build in storm.config.ts; default stable. Gives the run a Testserver side.",
13
+ description: "The build the Testserver sandboxes run: a build name, the build channel stable or latest_main, or a vercel/api pull request as pr:<N> or its URL, overriding resources.testserverPool.build in storm.config.ts; default stable. A pull request runs on the newest build made from its head commit, which storm reads from GitHub with GITHUB_TOKEN, GH_TOKEN or gh auth token, or refuses. Gives the run a Testserver side.",
14
14
  },
15
15
  testserverMinTimeLeft: {
16
16
  valueLabel: "DURATION",
@@ -35,7 +35,10 @@ export const RUN_FIELDS = {
35
35
  description: "Run the command on this machine instead of in a runner sandbox. Without it, the command runs in a Vercel Sandbox started from a runner snapshot of the base, with this checkout's changes applied, installed and built, from the runner key of storm.config.ts, and its output streams back with paths rewritten to this checkout's. No config key.",
36
36
  },
37
37
  rebuildSnapshot: {
38
- description: "Build a runner snapshot of the base whatever the runner snapshot cache holds, replacing an entry for the same base. Not with --local. No config key.",
38
+ 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 --local. No config key.",
39
+ },
40
+ saveSnapshot: {
41
+ 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 --local, or with --keep-sandbox above 0. No config key.",
39
42
  },
40
43
  keepSandbox: {
41
44
  valueLabel: "DURATION",
@@ -36,12 +36,43 @@ declare const snapshotSchema: z.ZodObject<{
36
36
  id: z.ZodString;
37
37
  base: z.ZodString;
38
38
  built: z.ZodBoolean;
39
+ branch: z.ZodDefault<z.ZodNullable<z.ZodString>>;
40
+ head: z.ZodDefault<z.ZodNullable<z.ZodString>>;
39
41
  }, z.core.$strip>;
40
42
  /**
41
43
  * The runner snapshot a runner sandbox started from: its id, the base it is of, which the run's changes were uploaded
42
- * on top of, and whether the run built it or reused a cached one.
44
+ * on top of, whether the run built it or reused a cached one, and for a branch snapshot the branch and HEAD commit of
45
+ * the run that saved it (each null for a base snapshot).
43
46
  */
44
47
  export type RunRecordSnapshot = Readonly<z.output<typeof snapshotSchema>>;
48
+ /**
49
+ * How saving the runner sandbox as a branch snapshot ended (`--save-snapshot`), as a `ran` outcome and `run.json`
50
+ * report it.
51
+ */
52
+ export declare const saveSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
+ kind: z.ZodLiteral<"saved">;
54
+ snapshotId: z.ZodString;
55
+ base: z.ZodString;
56
+ branch: z.ZodString;
57
+ head: z.ZodString;
58
+ ms: z.ZodNumber;
59
+ sizeBytes: z.ZodNumber;
60
+ entryWritten: z.ZodBoolean;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ kind: z.ZodLiteral<"skipped">;
63
+ reason: z.ZodLiteral<"detached-head">;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ kind: z.ZodLiteral<"failed">;
66
+ step: z.ZodEnum<{
67
+ "save-snapshot": "save-snapshot";
68
+ scrub: "scrub";
69
+ }>;
70
+ message: z.ZodString;
71
+ }, z.core.$strip>, z.ZodObject<{
72
+ kind: z.ZodLiteral<"stopped">;
73
+ }, z.core.$strip>], "kind">;
74
+ /** How saving the runner sandbox as a branch snapshot ended. */
75
+ export type RunRecordSave = z.output<typeof saveSchema>;
45
76
  declare const whereSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
46
77
  kind: z.ZodLiteral<"local">;
47
78
  }, z.core.$strip>, z.ZodObject<{
@@ -58,16 +89,40 @@ declare const whereSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
58
89
  id: z.ZodString;
59
90
  base: z.ZodString;
60
91
  built: z.ZodBoolean;
92
+ branch: z.ZodDefault<z.ZodNullable<z.ZodString>>;
93
+ head: z.ZodDefault<z.ZodNullable<z.ZodString>>;
61
94
  }, z.core.$strip>>;
62
95
  keptUntil: z.ZodDefault<z.ZodNullable<z.ZodString>>;
96
+ save: z.ZodDefault<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
97
+ kind: z.ZodLiteral<"saved">;
98
+ snapshotId: z.ZodString;
99
+ base: z.ZodString;
100
+ branch: z.ZodString;
101
+ head: z.ZodString;
102
+ ms: z.ZodNumber;
103
+ sizeBytes: z.ZodNumber;
104
+ entryWritten: z.ZodBoolean;
105
+ }, z.core.$strip>, z.ZodObject<{
106
+ kind: z.ZodLiteral<"skipped">;
107
+ reason: z.ZodLiteral<"detached-head">;
108
+ }, z.core.$strip>, z.ZodObject<{
109
+ kind: z.ZodLiteral<"failed">;
110
+ step: z.ZodEnum<{
111
+ "save-snapshot": "save-snapshot";
112
+ scrub: "scrub";
113
+ }>;
114
+ message: z.ZodString;
115
+ }, z.core.$strip>, z.ZodObject<{
116
+ kind: z.ZodLiteral<"stopped">;
117
+ }, z.core.$strip>], "kind">>>;
63
118
  }, z.core.$strip>], "kind">;
64
119
  /**
65
120
  * Where a run's command ran: on this machine (`local`, with `--local`), or in a runner sandbox (`runner`): the control
66
121
  * plane team and project it runs in, its region, runtime and vCPUs, and the run's base, HEAD's merge-base with
67
122
  * `baseRef`, all known as the run starts; then, once the run is over, the runner sandbox's name and the runner snapshot
68
- * it started from, each null when the run stopped before it, and when the runner sandbox's timeout stops it, as an ISO
69
- * time, when the run kept it running (null when it stopped and deleted it). A reused runner snapshot can be of an
70
- * older base.
123
+ * it started from, each null when the run stopped before it, when the runner sandbox's timeout stops it, as an ISO
124
+ * time, when the run kept it running (null when it stopped and deleted it), and how saving it as a branch snapshot
125
+ * ended (null without `--save-snapshot`). A reused runner snapshot can be of an older base.
71
126
  */
72
127
  export type RunRecordWhere = Readonly<z.output<typeof whereSchema>>;
73
128
  declare const gitSchema: z.ZodObject<{
@@ -128,8 +183,32 @@ declare const runRecordSchema: z.ZodObject<{
128
183
  id: z.ZodString;
129
184
  base: z.ZodString;
130
185
  built: z.ZodBoolean;
186
+ branch: z.ZodDefault<z.ZodNullable<z.ZodString>>;
187
+ head: z.ZodDefault<z.ZodNullable<z.ZodString>>;
131
188
  }, z.core.$strip>>;
132
189
  keptUntil: z.ZodDefault<z.ZodNullable<z.ZodString>>;
190
+ save: z.ZodDefault<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
191
+ kind: z.ZodLiteral<"saved">;
192
+ snapshotId: z.ZodString;
193
+ base: z.ZodString;
194
+ branch: z.ZodString;
195
+ head: z.ZodString;
196
+ ms: z.ZodNumber;
197
+ sizeBytes: z.ZodNumber;
198
+ entryWritten: z.ZodBoolean;
199
+ }, z.core.$strip>, z.ZodObject<{
200
+ kind: z.ZodLiteral<"skipped">;
201
+ reason: z.ZodLiteral<"detached-head">;
202
+ }, z.core.$strip>, z.ZodObject<{
203
+ kind: z.ZodLiteral<"failed">;
204
+ step: z.ZodEnum<{
205
+ "save-snapshot": "save-snapshot";
206
+ scrub: "scrub";
207
+ }>;
208
+ message: z.ZodString;
209
+ }, z.core.$strip>, z.ZodObject<{
210
+ kind: z.ZodLiteral<"stopped">;
211
+ }, z.core.$strip>], "kind">>>;
133
212
  }, z.core.$strip>], "kind">;
134
213
  git: z.ZodNullable<z.ZodObject<{
135
214
  branch: z.ZodNullable<z.ZodString>;
@@ -19,7 +19,53 @@ const endedSchema = z.object({
19
19
  // Read on its own in `parseRunRecord`, so a resource's facts another storm wrote cost only themselves.
20
20
  resources: z.unknown(),
21
21
  });
22
- const snapshotSchema = z.object({ id: z.string(), base: z.string(), built: z.boolean() });
22
+ const snapshotSchema = z.object({
23
+ id: z.string(),
24
+ base: z.string(),
25
+ built: z.boolean(),
26
+ // Absent from a run.json an earlier storm wrote, which started from no branch snapshot.
27
+ branch: z.string().nullable().default(null),
28
+ head: z.string().nullable().default(null),
29
+ });
30
+ /**
31
+ * How saving the runner sandbox as a branch snapshot ended (`--save-snapshot`), as a `ran` outcome and `run.json`
32
+ * report it.
33
+ */
34
+ export const saveSchema = z.discriminatedUnion("kind", [
35
+ z.object({
36
+ /** It saved the runner sandbox as a branch snapshot. */
37
+ kind: z.literal("saved"),
38
+ /** The runner snapshot it saved. */
39
+ snapshotId: z.string(),
40
+ /** The base it is of: the base of the runner snapshot the run started from, a full SHA. */
41
+ base: z.string(),
42
+ /** The local branch it is for. */
43
+ branch: z.string(),
44
+ /** HEAD's commit as the run started, a full SHA. */
45
+ head: z.string(),
46
+ /** How long the save took, in milliseconds, from the scrub's start until the snapshot was saved. */
47
+ ms: z.number(),
48
+ /** The snapshot's size in bytes. */
49
+ sizeBytes: z.number(),
50
+ /** Whether the runner snapshot cache recorded it; a later run on the branch starts from it only when it did. */
51
+ entryWritten: z.boolean(),
52
+ }),
53
+ z.object({
54
+ /** It didn't save: HEAD was detached, so there is no branch to save for. */
55
+ kind: z.literal("skipped"),
56
+ reason: z.literal("detached-head"),
57
+ }),
58
+ z.object({
59
+ /** It didn't save: the scrub or the save failed. */
60
+ kind: z.literal("failed"),
61
+ step: z.enum(["scrub", "save-snapshot"]),
62
+ message: z.string(),
63
+ }),
64
+ z.object({
65
+ /** It didn't save, or recorded nothing: a signal stopped it. */
66
+ kind: z.literal("stopped"),
67
+ }),
68
+ ]);
23
69
  const whereSchema = z.discriminatedUnion("kind", [
24
70
  z.object({ kind: z.literal("local") }),
25
71
  z.object({
@@ -35,6 +81,8 @@ const whereSchema = z.discriminatedUnion("kind", [
35
81
  snapshot: snapshotSchema.nullable(),
36
82
  // Absent from a run.json an earlier storm wrote, which kept no runner sandbox.
37
83
  keptUntil: z.string().nullable().default(null),
84
+ // Absent from a run.json an earlier storm wrote, which saved no branch snapshot.
85
+ save: saveSchema.nullable().default(null),
38
86
  }),
39
87
  ]);
40
88
  const gitSchema = z.object({ branch: z.string().nullable(), commit: z.string(), dirty: z.boolean() });
@@ -26,7 +26,7 @@ export declare function incompleteText(message: string): string;
26
26
  * What the tests line says in place of totals when the command's test runner reported attempts but no final results:
27
27
  * the Vitest config lacks `stormReporter`, or a `--reporter` on vitest's command line replaced it.
28
28
  */
29
- export declare const NO_FINAL_RESULTS = "no final test results: add stormReporter() to vitest.config's reporters (@cnc-tools/storm/vitest/config)";
29
+ export declare const NO_FINAL_RESULTS = "no final test results: add stormReporter() to vitest.config's reporters (@vercel/storm/vitest/config)";
30
30
  /**
31
31
  * What the summary says about the tests, from `events`, of which `unreadable` lines held none, and `incomplete`, why the
32
32
  * final read of the test events file failed.
@@ -28,7 +28,7 @@ export function incompleteText(message) {
28
28
  * What the tests line says in place of totals when the command's test runner reported attempts but no final results:
29
29
  * the Vitest config lacks `stormReporter`, or a `--reporter` on vitest's command line replaced it.
30
30
  */
31
- export const NO_FINAL_RESULTS = "no final test results: add stormReporter() to vitest.config's reporters (@cnc-tools/storm/vitest/config)";
31
+ export const NO_FINAL_RESULTS = "no final test results: add stormReporter() to vitest.config's reporters (@vercel/storm/vitest/config)";
32
32
  /**
33
33
  * What the summary says about the tests, from `events`, of which `unreadable` lines held none, and `incomplete`, why the
34
34
  * final read of the test events file failed.
@@ -4,7 +4,7 @@
4
4
  import { EMPTY_RUN_STATE } from "../../core/index.js";
5
5
  import { applyStormRunEvent, RESOURCE_PRESENTATIONS, } from "../../resources.js";
6
6
  import { activePhase, headerLine, phaseFrame, phaseRecord } from "./live-view.js";
7
- import { cacheWriteFailureText, lineProgress, preparedNoteTexts, progressLine } from "./progress.js";
7
+ import { branchSnapshotSaveText, branchSnapshotsDropText, cacheWriteFailureText, lineProgress, preparedNoteTexts, progressLine, } from "./progress.js";
8
8
  import { paint } from "./text.js";
9
9
  /** The plain summary's width when stderr reports none: 80 columns. */
10
10
  const PLAIN_WIDTH = 80;
@@ -139,9 +139,7 @@ function noticeLines(timed, origin, verbose) {
139
139
  case "runner-prepared":
140
140
  return preparedNoteTexts(event).map((text) => line("runner", text));
141
141
  case "runner":
142
- return event.event.kind === "snapshot-entry-not-written"
143
- ? [line("runner", cacheWriteFailureText(event.event.failure))]
144
- : [];
142
+ return runnerNoticeLines(event.event, line);
145
143
  case "resource":
146
144
  return RESOURCE_PRESENTATIONS.notices(event, { verbose }).map(({ lane, text }) => line(lane, text));
147
145
  case "started":
@@ -161,3 +159,37 @@ function noticeLines(timed, origin, verbose) {
161
159
  return [];
162
160
  }
163
161
  }
162
+ /** The runner's notices: a cache entry not written, what `--rebuild-snapshot` dropped, and how a save ended. */
163
+ function runnerNoticeLines(event, line) {
164
+ switch (event.kind) {
165
+ case "snapshot-entry-not-written":
166
+ return [line("runner", cacheWriteFailureText(event.failure))];
167
+ case "branch-snapshots-dropped":
168
+ case "branch-snapshots-not-dropped":
169
+ return [line("runner", branchSnapshotsDropText(event))];
170
+ case "branch-snapshot-saved":
171
+ case "branch-snapshot-not-saved":
172
+ return [line("cleanup", branchSnapshotSaveText(event))];
173
+ // The live view's phases show the rest.
174
+ case "snapshot-reused":
175
+ case "snapshot-build-started":
176
+ case "runner-sandbox-starting":
177
+ case "sandbox-started":
178
+ case "output-started":
179
+ case "output-ended":
180
+ case "step-started":
181
+ case "step-output":
182
+ case "step-finished":
183
+ case "snapshot-saving":
184
+ case "snapshot-built":
185
+ case "uploading":
186
+ case "uploaded":
187
+ case "command-output-started":
188
+ case "command-stopped":
189
+ case "stopping":
190
+ case "waiting-for-snapshot":
191
+ case "sandbox-kept":
192
+ case "branch-snapshot-saving":
193
+ return [];
194
+ }
195
+ }