@cnc-tools/storm 0.12.0 → 0.14.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 (188) hide show
  1. package/dist/application.js +5 -1
  2. package/dist/bin/storm.js +6 -2
  3. package/dist/build-info.js +1 -1
  4. package/dist/chunks/{chunk-FK4RLDEK.js → chunk-27P2QSIM.js} +1 -1
  5. package/dist/chunks/{chunk-ODQHQJLE.js → chunk-5ED3IDUJ.js} +749 -1121
  6. package/dist/chunks/{chunk-FSP3SJ35.js → chunk-5TMHYH7G.js} +16 -46
  7. package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-BFLYGMG3.js} +12 -7
  8. package/dist/chunks/{chunk-LQKNI3EG.js → chunk-BRUIATTR.js} +6 -6
  9. package/dist/chunks/{chunk-RYRJNHL7.js → chunk-HOKDKP5A.js} +3 -9
  10. package/dist/chunks/{chunk-SXW6XN4R.js → chunk-IVRRGGCD.js} +60 -20
  11. package/dist/chunks/{chunk-TMQQYHUX.js → chunk-QBR5VHJ7.js} +1 -1
  12. package/dist/chunks/{chunk-YT5OROR7.js → chunk-RA4L2ACU.js} +12 -2
  13. package/dist/chunks/{chunk-TEEZL3GA.js → chunk-RKONDLPS.js} +17 -71
  14. package/dist/chunks/{chunk-IYM44FUX.js → chunk-UC6DULWY.js} +2 -2
  15. package/dist/chunks/{chunk-4XT5RC5T.js → chunk-XPCUINWS.js} +6 -42
  16. package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-YBPTMJUM.js} +123 -180
  17. package/dist/chunks/{chunk-ISGQJIQM.js → chunk-Z5OXOZD3.js} +125 -83
  18. package/dist/chunks/{chunk-7D6LC5JY.js → chunk-ZH5R7W4A.js} +7 -39
  19. package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-FBVWUUMT.js} +7 -7
  20. package/dist/commands/exec/command.d.ts +4 -90
  21. package/dist/commands/exec/command.js +15 -41
  22. package/dist/commands/exec/define-run-command.d.ts +19 -100
  23. package/dist/commands/exec/define-run-command.js +48 -15
  24. package/dist/commands/exec/driver-plan.d.ts +24 -16
  25. package/dist/commands/exec/driver-plan.js +34 -15
  26. package/dist/commands/exec/driver-refusals.js +7 -6
  27. package/dist/commands/exec/exec-words.d.ts +1 -1
  28. package/dist/commands/exec/exec-words.js +8 -2
  29. package/dist/commands/exec/final-results.d.ts +39 -0
  30. package/dist/commands/exec/final-results.js +29 -0
  31. package/dist/commands/exec/live-view.js +18 -22
  32. package/dist/commands/exec/metadata.js +1 -1
  33. package/dist/commands/exec/outcomes.d.ts +15 -109
  34. package/dist/commands/exec/outcomes.js +25 -39
  35. package/dist/commands/exec/plan-run.d.ts +11 -3
  36. package/dist/commands/exec/plan-run.js +3 -2
  37. package/dist/commands/exec/progress.d.ts +3 -19
  38. package/dist/commands/exec/progress.js +16 -60
  39. package/dist/commands/exec/run-command.d.ts +5 -24
  40. package/dist/commands/exec/run-command.js +32 -84
  41. package/dist/commands/exec/run-metadata.d.ts +0 -6
  42. package/dist/commands/exec/run-metadata.js +2 -8
  43. package/dist/commands/exec/snapshot-text.d.ts +7 -16
  44. package/dist/commands/exec/snapshot-text.js +9 -49
  45. package/dist/commands/exec/test-plan.d.ts +2 -1
  46. package/dist/commands/exec/test-plan.js +13 -4
  47. package/dist/commands/exec/tests-summary.d.ts +2 -2
  48. package/dist/commands/exec/view.js +2 -12
  49. package/dist/commands/exec/worker-chart.d.ts +1 -1
  50. package/dist/commands/playwright/command.d.ts +12 -97
  51. package/dist/commands/playwright/command.js +14 -14
  52. package/dist/commands/playwright/metadata.js +2 -2
  53. package/dist/commands/runs/facts.d.ts +1 -37
  54. package/dist/commands/runs/facts.js +4 -36
  55. package/dist/commands/runs/list/command.d.ts +0 -72
  56. package/dist/commands/runs/list/command.js +6 -6
  57. package/dist/commands/runs/list/outcomes.d.ts +0 -36
  58. package/dist/commands/runs/logs/command.js +6 -6
  59. package/dist/commands/runs/show/command.d.ts +2 -74
  60. package/dist/commands/runs/show/command.js +16 -43
  61. package/dist/commands/runs/show/metadata.js +1 -1
  62. package/dist/commands/runs/show/outcomes.d.ts +1 -37
  63. package/dist/commands/runs/show/outcomes.js +8 -42
  64. package/dist/commands/snapshots/build/command.d.ts +14 -411
  65. package/dist/commands/snapshots/build/command.js +59 -234
  66. package/dist/commands/snapshots/build/metadata.js +10 -7
  67. package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
  68. package/dist/commands/snapshots/build/outcomes.js +29 -196
  69. package/dist/commands/snapshots/list/command.d.ts +2 -36
  70. package/dist/commands/snapshots/list/command.js +20 -56
  71. package/dist/commands/snapshots/list/metadata.js +1 -1
  72. package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
  73. package/dist/commands/snapshots/list/outcomes.js +13 -53
  74. package/dist/commands/vitest/command.d.ts +14 -98
  75. package/dist/commands/vitest/command.js +14 -14
  76. package/dist/commands/vitest/metadata.js +2 -2
  77. package/dist/config/resolve.d.ts +1 -1
  78. package/dist/config/resolve.js +2 -1
  79. package/dist/config/schema.d.ts +8 -0
  80. package/dist/config/schema.js +5 -4
  81. package/dist/core/events.d.ts +5 -6
  82. package/dist/core/run-state.d.ts +7 -29
  83. package/dist/core/run-state.js +3 -26
  84. package/dist/core/run.d.ts +6 -14
  85. package/dist/core/run.js +17 -28
  86. package/dist/extensions/playwright/driver.js +17 -10
  87. package/dist/extensions/testserver/commands/pool/create/command.js +4 -4
  88. package/dist/extensions/testserver/commands/pool/list/command.js +2 -2
  89. package/dist/extensions/testserver/definition.d.ts +1 -1
  90. package/dist/extensions/testserver/extension.d.ts +1 -1
  91. package/dist/extensions/testserver/options/rules.d.ts +3 -3
  92. package/dist/extensions/testserver/options/rules.js +5 -5
  93. package/dist/extensions/testserver/resource.d.ts +1 -1
  94. package/dist/extensions/testserver/vercel-cli/index.d.ts +1 -0
  95. package/dist/extensions/testserver/vercel-cli/index.js +1 -0
  96. package/dist/extensions/testserver/vercel-cli/report.js +5 -2
  97. package/dist/extensions/testserver/vercel-cli/session-id.d.ts +8 -0
  98. package/dist/extensions/testserver/vercel-cli/session-id.js +16 -0
  99. package/dist/extensions/testserver/vitest/config.d.ts +2 -2
  100. package/dist/extensions/testserver/vitest/config.js +2 -2
  101. package/dist/extensions/testserver/vitest/container-scope.d.ts +25 -16
  102. package/dist/extensions/testserver/vitest/container-scope.js +32 -13
  103. package/dist/extensions/testserver/vitest/diagnostics.d.ts +5 -4
  104. package/dist/extensions/testserver/vitest/diagnostics.js +15 -8
  105. package/dist/extensions/testserver/vitest/fixtures.d.ts +10 -1
  106. package/dist/extensions/testserver/vitest/fixtures.js +36 -10
  107. package/dist/extensions/testserver/vitest/types.d.ts +9 -0
  108. package/dist/extensions/vitest/driver.js +28 -14
  109. package/dist/extensions/vitest/plan/gateways.d.ts +28 -5
  110. package/dist/extensions/vitest/plan/gateways.js +2 -2
  111. package/dist/extensions/vitest/plan/list-output.d.ts +5 -0
  112. package/dist/extensions/vitest/plan/list-output.js +23 -9
  113. package/dist/extensions/vitest/plan/live/list-gateway.d.ts +3 -2
  114. package/dist/extensions/vitest/plan/live/list-gateway.js +77 -64
  115. package/dist/extensions/vitest/plan/plan-over.d.ts +19 -7
  116. package/dist/extensions/vitest/plan/plan-over.js +18 -7
  117. package/dist/extensions/vitest/plan/plan.d.ts +14 -5
  118. package/dist/extensions/vitest/plan/plan.js +23 -9
  119. package/dist/extensions.d.ts +2 -2
  120. package/dist/run-directory/index.d.ts +1 -1
  121. package/dist/run-directory/index.js +0 -1
  122. package/dist/run-directory/plan.d.ts +3 -2
  123. package/dist/run-directory/plan.js +6 -3
  124. package/dist/run-directory/recording.js +2 -2
  125. package/dist/run-directory/run-record.d.ts +18 -135
  126. package/dist/run-directory/run-record.js +8 -68
  127. package/dist/runner/build-snapshots.d.ts +50 -114
  128. package/dist/runner/build-snapshots.js +70 -159
  129. package/dist/runner/events.d.ts +4 -88
  130. package/dist/runner/gateways.d.ts +5 -23
  131. package/dist/runner/index.d.ts +5 -6
  132. package/dist/runner/index.js +1 -1
  133. package/dist/runner/live/snapshot-records.js +7 -18
  134. package/dist/runner/prepare.d.ts +11 -22
  135. package/dist/runner/prepare.js +6 -17
  136. package/dist/runner/ready.d.ts +16 -45
  137. package/dist/runner/ready.js +34 -59
  138. package/dist/runner/recipe.d.ts +5 -45
  139. package/dist/runner/recipe.js +0 -41
  140. package/dist/runner/sandboxed-command.d.ts +5 -3
  141. package/dist/runner/sandboxed-command.js +10 -4
  142. package/dist/runner/scope.d.ts +8 -25
  143. package/dist/runner/scope.js +4 -8
  144. package/dist/runner/session.d.ts +18 -65
  145. package/dist/runner/session.js +15 -83
  146. package/dist/runner/snapshot-build.d.ts +2 -2
  147. package/dist/runner/snapshot-cache.d.ts +22 -74
  148. package/dist/runner/snapshot-cache.js +15 -107
  149. package/dist/runner/snapshot-inspect.d.ts +9 -13
  150. package/dist/runner/snapshot-inspect.js +48 -57
  151. package/dist/runner/snapshot-key.d.ts +9 -14
  152. package/dist/runner/snapshot-key.js +15 -22
  153. package/dist/sdk/extension/driver.d.ts +32 -6
  154. package/dist/sdk/extension/driver.js +12 -2
  155. package/dist/sdk/extension/index.d.ts +1 -1
  156. package/dist/sdk/extension/index.js +2 -1
  157. package/dist/sdk/extension/resource-definition.d.ts +6 -5
  158. package/dist/vendor/testserver-sdk/container/api-request.d.ts +2 -3
  159. package/dist/vendor/testserver-sdk/container/api-request.js +2 -3
  160. package/dist/vendor/testserver-sdk/container/container.d.ts +12 -2
  161. package/dist/vendor/testserver-sdk/container/container.js +10 -7
  162. package/dist/vendor/testserver-sdk/container/recorder.d.ts +29 -7
  163. package/dist/vendor/testserver-sdk/container/recorder.js +26 -14
  164. package/dist/vendor/testserver-sdk/index.d.ts +1 -1
  165. package/dist/vendor/testserver-sdk/index.js +1 -1
  166. package/dist/vendor/testserver-sdk/proxy/exchange.d.ts +24 -5
  167. package/dist/vendor/testserver-sdk/proxy/exchange.js +43 -25
  168. package/dist/vendor/testserver-sdk/proxy/faulted-exchange.js +15 -10
  169. package/dist/vendor/testserver-sdk/proxy/faults.d.ts +6 -5
  170. package/dist/vendor/testserver-sdk/proxy/proxy.d.ts +10 -1
  171. package/dist/vendor/testserver-sdk/proxy/proxy.js +5 -3
  172. package/dist/vendor/testserver-sdk/proxy/records.d.ts +17 -17
  173. package/dist/vendor/testserver-sdk/proxy/records.js +18 -17
  174. package/dist/vendor/testserver-sdk/records/body.d.ts +7 -9
  175. package/dist/vendor/testserver-sdk/records/body.js +10 -15
  176. package/dist/vendor/testserver-sdk/records/headers.d.ts +79 -0
  177. package/dist/vendor/testserver-sdk/records/headers.js +162 -0
  178. package/dist/vendor/testserver-sdk/records/index.d.ts +2 -1
  179. package/dist/vendor/testserver-sdk/records/index.js +4 -2
  180. package/dist/vendor/testserver-sdk/records/records.d.ts +19 -10
  181. package/package.json +5 -4
  182. package/skills/overview.md +5 -5
  183. package/skills/read-run-output.md +8 -9
  184. package/dist/runner/snapshot-save.d.ts +0 -70
  185. package/dist/runner/snapshot-save.js +0 -160
  186. package/dist/runner/snapshot-start.d.ts +0 -25
  187. package/dist/runner/snapshot-start.js +0 -16
  188. package/skills/testserver-builds.md +0 -82
@@ -1,65 +1,48 @@
1
- // Readying the runner sandbox once the run's credential names its team and project: obtain the runner snapshot it
2
- // starts from, reusing the cached one `chooseSnapshotStart` chose or building a base snapshot, then start the runner
3
- // sandbox from it, upload and apply the run's changes, and install and build.
1
+ // Readying the runner sandbox once the run's credential names its team and project: pick the cached runner snapshot it
2
+ // starts from, or build a base snapshot, then start the runner sandbox from it, upload and apply the run's changes,
3
+ // and install and build.
4
4
  import { posix } from "node:path";
5
5
  import { runnerTags } from "./context.js";
6
6
  import { stepSecrets } from "./secrets.js";
7
7
  import { buildSnapshot } from "./snapshot-build.js";
8
- import { isDevEntry } from "./snapshot-cache.js";
8
+ import { pickSnapshot, snapshotRejections } from "./snapshot-cache.js";
9
9
  import { applyScript, SANDBOX_ROOT, STAGED_FILES } from "./snapshot-key.js";
10
10
  import { runStep, sandboxStop } from "./steps.js";
11
11
  /** The label of the step that applies and commits the run's changes in the runner sandbox. */
12
12
  export const APPLY_LABEL = "Applying your changes";
13
13
  /**
14
- * Carries out what `chooseSnapshotStart` chose. To reuse a cached candidate it reports `snapshot-reused`, with where
15
- * that snapshot was built; to build, it builds a base snapshot at the run's base, saying why (`buildSnapshot`).
14
+ * Readies the runner sandbox for a prepared run. It picks, of the prepared candidates, the one for the access's team
15
+ * and project (`pickSnapshot`) and reports `snapshot-reused`; with no pick, it builds a base
16
+ * snapshot at the run's base, saying why each cached snapshot of the recipe doesn't fit (`no-snapshot`,
17
+ * `snapshotRejections`; `buildSnapshot`). Then it starts the runner sandbox from that snapshot, uploads what the
18
+ * checkout changes on top of the run's base, applies it, and runs the install and the build.
16
19
  */
17
- export async function obtainSnapshot(context, request, control, progress) {
18
- const { prepared, start } = request;
19
- if (control.signal.aborted)
20
+ export async function readyRunner(context, request, control, progress) {
21
+ const { prepared, access } = request;
22
+ const { recipe, repoRoot } = prepared;
23
+ const { scope, signal } = control;
24
+ const now = () => context.clock.now().getTime();
25
+ if (signal.aborted)
20
26
  return { kind: "aborted" };
21
- if (start.kind === "reuse") {
22
- const { candidate } = start;
23
- const { entry } = candidate;
24
- const snapshot = {
25
- kind: isDevEntry(entry) ? "dev" : "base",
26
- builtAt: candidate.builtAt,
27
- builtBehind: candidate.builtBehind,
28
- };
27
+ const pick = pickSnapshot(prepared.candidates, access);
28
+ let entry;
29
+ if (pick !== undefined) {
30
+ ({ entry } = pick);
29
31
  await progress.emit({
30
32
  kind: "snapshot-reused",
31
33
  snapshotId: entry.snapshotId,
32
34
  base: entry.base,
33
- branch: entry.branch ?? null,
34
- head: entry.head ?? null,
35
- snapshot,
35
+ builtBehind: pick.builtBehind,
36
36
  });
37
- return { kind: "ok", value: { entry, snapshot, built: null } };
38
37
  }
39
- const building = await buildSnapshot(context, { prepared, access: request.access, user: request.user, secrets: request.secrets, why: start.why }, control, progress);
40
- if (building.kind !== "ok")
41
- return building;
42
- const { entry } = building.value;
43
- // A base snapshot built here is built at the run's base, its merge-base.
44
- const snapshot = {
45
- kind: "base",
46
- builtAt: entry.base,
47
- builtBehind: prepared.commitsAfterBase,
48
- };
49
- return { kind: "ok", value: { entry, snapshot, built: building.value } };
50
- }
51
- /**
52
- * Readies the runner sandbox for a prepared run, from the runner snapshot `start` names: it starts the runner sandbox
53
- * from it, uploads what the checkout changes on top of the snapshot's base, applies it, and runs the install and the
54
- * build. It chooses nothing: `chooseSnapshotStart` chose the snapshot, and `obtainSnapshot` obtained it.
55
- */
56
- export async function readyRunner(context, request, control, progress) {
57
- const { prepared, access } = request;
58
- const { recipe, repoRoot } = prepared;
59
- const { scope, signal } = control;
60
- const now = () => context.clock.now().getTime();
61
- const { entry, snapshot } = request.start;
62
- const built = request.start.built !== null;
38
+ else {
39
+ const why = { kind: "no-snapshot", rejected: snapshotRejections(prepared, access) };
40
+ const building = await buildSnapshot(context, { prepared, access, user: request.user, secrets: request.secrets, why }, control, progress);
41
+ if (building.kind !== "ok")
42
+ return building;
43
+ ({ entry } = building.value);
44
+ }
45
+ const built = pick === undefined;
63
46
  if (signal.aborted)
64
47
  return { kind: "aborted" };
65
48
  await progress.emit({ kind: "runner-sandbox-starting", snapshotId: entry.snapshotId });
@@ -87,7 +70,7 @@ export async function readyRunner(context, request, control, progress) {
87
70
  vcpus: prepared.vcpus,
88
71
  ms: now() - startedAt,
89
72
  });
90
- const changes = await uploadChanges(context, { prepared, sandbox, base: entry.base }, signal, progress);
73
+ const changes = await uploadChanges(context, { prepared, sandbox }, signal, progress);
91
74
  if (changes.kind !== "ok")
92
75
  return changes;
93
76
  const applied = await stage(context, {
@@ -123,9 +106,10 @@ export async function readyRunner(context, request, control, progress) {
123
106
  kind: "ready",
124
107
  runner: {
125
108
  sandbox,
126
- startedFrom: entry,
109
+ snapshotId: entry.snapshotId,
110
+ base: entry.base,
127
111
  built,
128
- snapshot,
112
+ builtBehind: prepared.commitsAfterBase,
129
113
  uploadBytes: changes.value.bytes,
130
114
  buildMs: builtOutputs.value,
131
115
  vcpus: prepared.vcpus,
@@ -139,21 +123,12 @@ export async function readyRunner(context, request, control, progress) {
139
123
  };
140
124
  }
141
125
  /**
142
- * Uploads what the checkout changes on top of `base`: the prepared upload when `base` is the run's base, or one
143
- * assembled against `base`, an older snapshot's.
126
+ * Uploads what the checkout changes on top of the run's base, the prepared upload.
144
127
  */
145
128
  async function uploadChanges(context, request, signal, progress) {
146
- const { prepared } = request;
147
129
  await progress.emit({ kind: "uploading" });
148
130
  const startedAt = context.clock.now().getTime();
149
- let upload = prepared.upload;
150
- if (request.base !== prepared.base) {
151
- const assembled = await context.checkout.assembleUpload({ repoRoot: prepared.repoRoot, base: request.base });
152
- if (!assembled.ok)
153
- return { kind: "failed", failure: { kind: "checkout-failed", failure: assembled.failure } };
154
- upload = assembled.value;
155
- }
156
- const files = stagedChanges(upload);
131
+ const files = stagedChanges(request.prepared.upload);
157
132
  const staged = await context.runnerSandboxes.upload(request.sandbox, files, signal);
158
133
  if (!staged.ok)
159
134
  return sandboxStop("upload", staged.failure);
@@ -12,27 +12,6 @@ export interface RunnerStep {
12
12
  export interface ResolvedRunnerStep extends RunnerStep {
13
13
  readonly secrets: readonly string[];
14
14
  }
15
- /**
16
- * Whether the recipe's install or build step names a runner secret. A dev snapshot holds what an earlier command
17
- * wrote, shell startup files and `node_modules/.bin` included, and those steps run on top of it as the same user.
18
- */
19
- export declare function runStepTakesSecret(recipe: Pick<CheckedRecipe, "run">): boolean;
20
- /**
21
- * Whether a run of the recipe may save and reuse dev snapshots: always when neither its install nor its build step
22
- * names a runner secret, and otherwise only when its `trustDevSnapshots` is true. No run flag grants that trust.
23
- */
24
- export declare function devSnapshotsTrusted(recipe: Pick<CheckedRecipe, "run" | "trustDevSnapshots">): boolean;
25
- /**
26
- * Whether a run uses dev snapshots: `reuse` does; `reuse-off` doesn't, by the run's flag or the recipe's
27
- * `reuseDevSnapshot: false`; `not-trusted` doesn't, since the recipe's install or build step names a runner secret and
28
- * the recipe doesn't set `trustDevSnapshots`. The two that say no are also why the cache read rejects a dev snapshot.
29
- */
30
- export type DevSnapshotReuse = "reuse" | "reuse-off" | "not-trusted";
31
- /**
32
- * Whether a run of `recipe` uses dev snapshots, when the run's own switches say it reuses them (`runReuses`) or not.
33
- * Trust comes first: no switch makes an untrusted recipe use them.
34
- */
35
- export declare function devSnapshotReuse(recipe: Pick<CheckedRecipe, "run" | "trustDevSnapshots">, runReuses: boolean): DevSnapshotReuse;
36
15
  /** What a step function may read about the base it is evaluated at. */
37
16
  export interface RunnerStepContext {
38
17
  /** The base's full SHA. */
@@ -73,7 +52,11 @@ export interface RunnerRecipe<Run = never> {
73
52
  readonly cwd?: string;
74
53
  /** The runner sandbox's vCPUs, or a function of the run that returns them. */
75
54
  readonly vcpus: number | ((run: Run) => number);
76
- /** Extra environment variables for the command. It can't set `STORM_RUN`. */
55
+ /**
56
+ * Extra environment variables for the command. It can't set `STORM_RUN`. When it sets neither `FORCE_COLOR` nor
57
+ * `NO_COLOR`, storm sets `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`; when it sets
58
+ * either, storm sets neither, so `{ FORCE_COLOR: "1" }` gets color and no `NO_COLOR`.
59
+ */
77
60
  readonly env?: Readonly<Record<string, string>>;
78
61
  /**
79
62
  * The runner secrets: names of environment variables storm reads on this machine as the run starts, before it mints,
@@ -91,27 +74,6 @@ export interface RunnerRecipe<Run = never> {
91
74
  * it, or up to `5h`. `run --keep-sandbox` overrides it; without either, `30m`, or `0` when `CI` is set.
92
75
  */
93
76
  readonly keepSandbox?: string;
94
- /**
95
- * The recipe default for `--save-dev-snapshot`: whether a run saves its runner sandbox as a dev snapshot at HEAD's
96
- * commit when it gives neither the flag nor a `--keep-sandbox` above 0. `false` saves none, and `true` saves once
97
- * the command ends on its own, whatever its exit code and whatever runner snapshot the run started from, with `CI`
98
- * set too. It applies to runs only: `storm snapshots build` is not a run. Without it, the built-in default holds: a run saves once per commit, once a command exits 0, and none when `CI` is set or when
99
- * `run.install` or `run.build` names a runner secret and `trustDevSnapshots` isn't `true`. `true` on such a recipe
100
- * needs `trustDevSnapshots: true`.
101
- */
102
- readonly saveDevSnapshot?: boolean;
103
- /**
104
- * Whether a run may start from a dev snapshot; `true` by default. `false` starts every run from a base snapshot,
105
- * as `--no-reuse-dev-snapshot` does for one run.
106
- */
107
- readonly reuseDevSnapshot?: boolean;
108
- /**
109
- * Lets a recipe whose `run.install` or `run.build` names a runner secret save and reuse dev snapshots; `false` by
110
- * default. A dev snapshot holds what a command wrote, shell startup files and `node_modules/.bin` included, and
111
- * those steps run on top of it in later runs as the same user, so `true` trusts every command run from a checkout
112
- * with those secrets. A recipe with no such step saves and reuses dev snapshots without it.
113
- */
114
- readonly trustDevSnapshots?: boolean;
115
77
  /** The refs a base can come from, preferred first; `["main", "origin/main"]` by default. */
116
78
  readonly baseRefs?: readonly string[];
117
79
  /** The Vercel region of the runner sandbox and its snapshots; `iad1` by default. */
@@ -141,8 +103,6 @@ export interface CheckedRecipe<Run = never> extends RunnerRecipe<Run> {
141
103
  readonly timeoutMinutes: number;
142
104
  /** `keepSandbox` in minutes; undefined when the recipe doesn't set it. */
143
105
  readonly keepSandboxMinutes: number | undefined;
144
- readonly reuseDevSnapshot: boolean;
145
- readonly trustDevSnapshots: boolean;
146
106
  readonly baseRefs: readonly string[];
147
107
  readonly region: string;
148
108
  readonly runtime: string;
@@ -5,29 +5,6 @@
5
5
  import { parseKeepTime, parseTtl } from "../time/index.js";
6
6
  import { RUN_PAYLOAD_VARIABLE } from "../sdk/run/launcher.js";
7
7
  import { STEP_ENV } from "./steps.js";
8
- /**
9
- * Whether the recipe's install or build step names a runner secret. A dev snapshot holds what an earlier command
10
- * wrote, shell startup files and `node_modules/.bin` included, and those steps run on top of it as the same user.
11
- */
12
- export function runStepTakesSecret(recipe) {
13
- return recipe.run.install.secrets.length > 0 || recipe.run.build.secrets.length > 0;
14
- }
15
- /**
16
- * Whether a run of the recipe may save and reuse dev snapshots: always when neither its install nor its build step
17
- * names a runner secret, and otherwise only when its `trustDevSnapshots` is true. No run flag grants that trust.
18
- */
19
- export function devSnapshotsTrusted(recipe) {
20
- return recipe.trustDevSnapshots || !runStepTakesSecret(recipe);
21
- }
22
- /**
23
- * Whether a run of `recipe` uses dev snapshots, when the run's own switches say it reuses them (`runReuses`) or not.
24
- * Trust comes first: no switch makes an untrusted recipe use them.
25
- */
26
- export function devSnapshotReuse(recipe, runReuses) {
27
- if (!devSnapshotsTrusted(recipe))
28
- return "not-trusted";
29
- return runReuses ? "reuse" : "reuse-off";
30
- }
31
8
  /** The defaults of a recipe's optional keys. */
32
9
  export const RECIPE_DEFAULTS = {
33
10
  cwd: ".",
@@ -46,9 +23,6 @@ const RECIPE_KEYS = new Set([
46
23
  "secrets",
47
24
  "timeout",
48
25
  "keepSandbox",
49
- "saveDevSnapshot",
50
- "reuseDevSnapshot",
51
- "trustDevSnapshots",
52
26
  "baseRefs",
53
27
  "region",
54
28
  "runtime",
@@ -112,18 +86,6 @@ export function checkRecipe(value) {
112
86
  const keepSandboxMinutes = typeof keepSandbox === "string" ? parseKeepTime(keepSandbox) : undefined;
113
87
  if (keepSandbox !== undefined && keepSandboxMinutes === undefined)
114
88
  report(["keepSandbox"], `must be 0, or a whole number of minutes or hours up to 5h, not ${describeRecipeValue(keepSandbox)}`);
115
- const saveDevSnapshot = value["saveDevSnapshot"];
116
- if (saveDevSnapshot !== undefined && typeof saveDevSnapshot !== "boolean")
117
- report(["saveDevSnapshot"], `must be true or false, not ${describeRecipeValue(saveDevSnapshot)}`);
118
- const reuseDevSnapshot = orDefault(value["reuseDevSnapshot"], true);
119
- if (typeof reuseDevSnapshot !== "boolean")
120
- report(["reuseDevSnapshot"], `must be true or false, not ${describeRecipeValue(reuseDevSnapshot)}`);
121
- const trustDevSnapshots = orDefault(value["trustDevSnapshots"], false);
122
- if (typeof trustDevSnapshots !== "boolean")
123
- report(["trustDevSnapshots"], `must be true or false, not ${describeRecipeValue(trustDevSnapshots)}`);
124
- // No run flag and no other key grants the trust a dev snapshot needs once the install or build takes a secret.
125
- if (saveDevSnapshot === true && trustDevSnapshots === false && run !== undefined && runStepTakesSecret({ run }))
126
- report(["saveDevSnapshot"], "must not be true while run.install or run.build names a runner secret, unless trustDevSnapshots is true");
127
89
  const baseRefs = checkBaseRefs(value["baseRefs"], report);
128
90
  const region = orDefault(value["region"], RECIPE_DEFAULTS.region);
129
91
  if (!isNonEmptyString(region))
@@ -152,9 +114,6 @@ export function checkRecipe(value) {
152
114
  timeout: timeout,
153
115
  timeoutMinutes,
154
116
  keepSandboxMinutes,
155
- ...(typeof saveDevSnapshot === "boolean" ? { saveDevSnapshot } : {}),
156
- reuseDevSnapshot: reuseDevSnapshot,
157
- trustDevSnapshots: trustDevSnapshots,
158
117
  baseRefs,
159
118
  region: region,
160
119
  runtime: runtime,
@@ -16,9 +16,11 @@ export declare function sandboxedCommand(request: {
16
16
  };
17
17
  /**
18
18
  * What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
19
- * repository's `node_modules/.bin` before the login shell's, no update checks, color when the local terminal shows
20
- * it, the recipe's `env`, and `STORM_RUN` last, so nothing overrides it. Nothing comes from the local
21
- * environment.
19
+ * repository's `node_modules/.bin` before the login shell's, no update checks, the recipe's `env`, and `STORM_RUN`
20
+ * last, so nothing overrides it. When the recipe's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets
21
+ * `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`, as a run with no runner does
22
+ * (`colorEnvironment` in `core/payload.ts`); a recipe that sets either gets neither from storm. Nothing comes from
23
+ * the local environment.
22
24
  */
23
25
  export declare function sandboxEnvironment(request: {
24
26
  readonly cwd: string;
@@ -16,9 +16,11 @@ export function sandboxedCommand(request) {
16
16
  }
17
17
  /**
18
18
  * What the command's environment adds to the runner sandbox's own: `PATH` with the sandbox `cwd`'s and the
19
- * repository's `node_modules/.bin` before the login shell's, no update checks, color when the local terminal shows
20
- * it, the recipe's `env`, and `STORM_RUN` last, so nothing overrides it. Nothing comes from the local
21
- * environment.
19
+ * repository's `node_modules/.bin` before the login shell's, no update checks, the recipe's `env`, and `STORM_RUN`
20
+ * last, so nothing overrides it. When the recipe's `env` sets neither `FORCE_COLOR` nor `NO_COLOR`, it also gets
21
+ * `FORCE_COLOR=1` when the local terminal shows color, else `NO_COLOR=1`, as a run with no runner does
22
+ * (`colorEnvironment` in `core/payload.ts`); a recipe that sets either gets neither from storm. Nothing comes from
23
+ * the local environment.
22
24
  */
23
25
  export function sandboxEnvironment(request) {
24
26
  const bins = [
@@ -27,7 +29,11 @@ export function sandboxEnvironment(request) {
27
29
  return {
28
30
  PATH: [...bins, request.loginPath].filter((part) => part !== "").join(":"),
29
31
  NO_UPDATE_NOTIFIER: "1",
30
- ...(request.color ? { FORCE_COLOR: "1" } : { NO_COLOR: "1" }),
32
+ ...(request.env["FORCE_COLOR"] !== undefined || request.env["NO_COLOR"] !== undefined
33
+ ? {}
34
+ : request.color
35
+ ? { FORCE_COLOR: "1" }
36
+ : { NO_COLOR: "1" }),
31
37
  ...request.env,
32
38
  [RUN_PAYLOAD_VARIABLE]: request.runPayload,
33
39
  };
@@ -5,19 +5,6 @@ import type { RunnerSandbox, RunnerSandboxGateway, RunnerSandboxPlacement, Runne
5
5
  export declare const CREATE_SETTLE_MS = 20000;
6
6
  /** How long closing waits for a runner snapshot still saving: 2 minutes. */
7
7
  export declare const SNAPSHOT_SETTLE_MS: number;
8
- /**
9
- * What cleanup does with the runner sandbox, as the run reports it when cleanup starts: keep it running `ms` (`keep`;
10
- * 0 stops and deletes it), or save it as a dev snapshot at HEAD's commit (`save`; `branch` is HEAD's branch, null when
11
- * detached, for what the run says). The runner session chooses it as it finishes (`RunnerSaveMode`): a run whose save
12
- * starts keeps no runner sandbox, however the save ends.
13
- */
14
- export type RunnerSandboxPlan = {
15
- readonly kind: "keep";
16
- readonly ms: number;
17
- } | {
18
- readonly kind: "save";
19
- readonly branch: string | null;
20
- };
21
8
  /**
22
9
  * What closing a scope left: the runner sandbox it kept running (`kept`), or couldn't keep running and so stopped and
23
10
  * deleted (`notKept`), each null otherwise, and the sandboxes it couldn't stop or delete.
@@ -35,8 +22,6 @@ export interface RunnerScopeFacts {
35
22
  * sandbox it returns.
36
23
  */
37
24
  export interface RunnerSandboxScope {
38
- /** Whether closing has begun. */
39
- readonly closed: boolean;
40
25
  startBuildSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
41
26
  readonly runtime: string;
42
27
  }): Promise<RunnerSandboxResult<RunnerSandbox>>;
@@ -44,31 +29,29 @@ export interface RunnerSandboxScope {
44
29
  readonly snapshotId: string;
45
30
  }): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
46
31
  /**
47
- * Saves a build or runner sandbox as a runner snapshot, then deletes it at once; a failed save leaves it to `close`.
32
+ * Saves a build sandbox as a runner snapshot, then deletes it at once; a failed save leaves it to `close`.
48
33
  */
49
34
  saveSnapshot(sandbox: RunnerSandbox, request: {
50
35
  readonly expirationMs: number;
51
36
  }): Promise<RunnerSandboxResult<SavedSnapshot>>;
52
37
  /**
53
38
  * Waits up to `CREATE_SETTLE_MS` for creates in flight and up to `SNAPSHOT_SETTLE_MS` for a snapshot saving, then
54
- * stops and deletes every sandbox the scope holds, but for the runner sandbox when the keep time, read once the
55
- * waits are over, is above 0: that one it keeps running at least the keep time from now, with nothing the run
56
- * started still running in it, reporting `sandbox-kept`, or stops and deletes when it can't. A create that ends
57
- * after closing began is stopped and deleted when it ends. Calling it again answers the first
58
- * call's report.
39
+ * stops and deletes every sandbox the scope holds, but for the runner sandbox when the keep time is above 0: that
40
+ * one it keeps running at least the keep time from now, with nothing the run started still running in it, reporting
41
+ * `sandbox-kept`, or stops and deletes when it can't. A create that ends after closing began is stopped and deleted
42
+ * when it ends. Calling it again answers the first call's report.
59
43
  */
60
44
  close(): Promise<RunnerScopeFacts>;
61
45
  }
62
46
  /**
63
47
  * A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
64
- * runner sandbox running `keepMs()` past closing (`context.clock` says when that is), or stops and deletes it with the
65
- * rest when `keepMs()` is 0. It asks for the keep time as it closes, once its waits are over, since a save that starts
66
- * after the scope opened takes the runner sandbox's keep time away (`session.ts`).
48
+ * runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
49
+ * rest when `keepMs` is 0.
67
50
  */
68
51
  export declare function runnerSandboxScope(context: {
69
52
  readonly runnerSandboxes: RunnerSandboxGateway;
70
53
  readonly timer: Timer;
71
54
  readonly clock: Clock;
72
55
  }, progress: RunnerProgress, keep: {
73
- readonly keepMs: () => number;
56
+ readonly keepMs: number;
74
57
  }): RunnerSandboxScope;
@@ -1,5 +1,5 @@
1
1
  // The sandbox scope: owns every sandbox one run creates, so however the run ends, each one is stopped and deleted, but
2
- // for the runner sandbox, which it keeps running for the keep time its owner gives as it closes, when that is above 0,
2
+ // for the runner sandbox, which it keeps running for the keep time its owner gives, when that is above 0,
3
3
  // so a person can connect to it. Closing waits briefly for work in flight first: a create, so the sandbox it returns
4
4
  // doesn't outlive the run until its timeout, and a snapshot save, so the build isn't thrown away.
5
5
  /** How long closing waits for a create in flight: 20 seconds. */
@@ -8,9 +8,8 @@ export const CREATE_SETTLE_MS = 20_000;
8
8
  export const SNAPSHOT_SETTLE_MS = 2 * 60_000;
9
9
  /**
10
10
  * A scope over `context.runnerSandboxes`, waiting with `context.timer` and reporting to `progress`, which keeps the
11
- * runner sandbox running `keepMs()` past closing (`context.clock` says when that is), or stops and deletes it with the
12
- * rest when `keepMs()` is 0. It asks for the keep time as it closes, once its waits are over, since a save that starts
13
- * after the scope opened takes the runner sandbox's keep time away (`session.ts`).
11
+ * runner sandbox running `keepMs` past closing (`context.clock` says when that is), or stops and deletes it with the
12
+ * rest when `keepMs` is 0.
14
13
  */
15
14
  export function runnerSandboxScope(context, progress, keep) {
16
15
  const { runnerSandboxes: sandboxes, timer, clock } = context;
@@ -51,7 +50,7 @@ export function runnerSandboxScope(context, progress, keep) {
51
50
  * when it can't, such as with a process that won't end, stops and deletes it as without a keep time.
52
51
  */
53
52
  const keepOrRemove = async (sandbox) => {
54
- const keepMs = sandbox.role === "runner" ? keep.keepMs() : 0;
53
+ const keepMs = sandbox.role === "runner" ? keep.keepMs : 0;
55
54
  if (keepMs <= 0)
56
55
  return await stopAndRemove(sandbox);
57
56
  const keeping = await sandboxes.keepRunning(sandbox, { until: new Date(clock.now().getTime() + keepMs) });
@@ -78,9 +77,6 @@ export function runnerSandboxScope(context, progress, keep) {
78
77
  })());
79
78
  };
80
79
  return {
81
- get closed() {
82
- return closing !== undefined;
83
- },
84
80
  startBuildSandbox: (access, request) => owned(() => sandboxes.startBuildSandbox(access, request)),
85
81
  startRunnerSandbox: (access, request) => owned(() => sandboxes.startRunnerSandbox(access, request)),
86
82
  saveSnapshot: (sandbox, request) => track(saving, (async () => {
@@ -1,32 +1,12 @@
1
1
  import type { MintTarget } from "../credential/index.ts";
2
2
  import type { RunnerContext } from "./context.ts";
3
- import type { NeverSaveReason, RunnerNoSaveReason, RunnerProgress, RunnerSave } from "./events.ts";
3
+ import type { RunnerProgress } from "./events.ts";
4
4
  import type { SandboxAccess } from "./gateways.ts";
5
5
  import type { PreparedRunner } from "./prepare.ts";
6
6
  import { type ReadyRunnerOutcome } from "./ready.ts";
7
7
  import { type SandboxedCommandOutcome, type SandboxTestEvents } from "./sandboxed-command.ts";
8
- import { type RunnerSandboxPlan, type RunnerScopeFacts } from "./scope.ts";
8
+ import { type RunnerScopeFacts } from "./scope.ts";
9
9
  import type { RunnerSecrets } from "./secrets.ts";
10
- /**
11
- * Whether a run saves its runner sandbox as a dev snapshot at HEAD's commit once the command ends on its own. A
12
- * detached HEAD saves as any HEAD does.
13
- *
14
- * - `new-head`: when the command exited 0 and the run didn't start from a dev snapshot built at HEAD's commit. What
15
- * a run does when neither `--save-dev-snapshot` nor the recipe's `saveDevSnapshot` is given.
16
- * - `always`: whatever the command's exit code and whatever runner snapshot the run started from
17
- * (`--save-dev-snapshot`, or the recipe's `saveDevSnapshot: true`).
18
- * - `never`: `--save-dev-snapshot=false`, or the recipe's `saveDevSnapshot: false`; with neither given, `CI` set, a
19
- * `--keep-sandbox` above 0, or a recipe whose install or build step names a runner secret and that doesn't set
20
- * `trustDevSnapshots`. `reason` says which, for the line the run prints.
21
- */
22
- export type RunnerSaveMode = {
23
- readonly kind: "new-head";
24
- } | {
25
- readonly kind: "always";
26
- } | {
27
- readonly kind: "never";
28
- readonly reason: NeverSaveReason;
29
- };
30
10
  /** What a run's runner session runs: the runner checked on this machine, where its sandboxes run, and what it keeps. */
31
11
  export interface RunnerSessionRequest {
32
12
  /** The runner checked on this machine (`prepareRunner`). */
@@ -40,42 +20,22 @@ export interface RunnerSessionRequest {
40
20
  * ones it names, the command gets none, and storm writes none to the run directory, the snapshot cache or `run.json`.
41
21
  */
42
22
  readonly secrets: RunnerSecrets;
43
- /** Whether the run saves the runner sandbox as a dev snapshot at HEAD's commit once the command ends on its own. */
44
- readonly save: RunnerSaveMode;
45
- /**
46
- * How long the runner sandbox keeps running once the run ends, in milliseconds, when no save starts; 0 stops and
47
- * deletes it. A run whose save starts keeps no runner sandbox, however the save ends.
48
- */
23
+ /** How long the runner sandbox keeps running once the run ends, in milliseconds; 0 stops and deletes it. */
49
24
  readonly keepMs: number;
50
25
  }
51
26
  /**
52
27
  * What the run hands its runner session for its cleanup. Each is the run's own, and each acts once, however often the
53
- * session calls it: `startCleanup` reports cleanup's start, with what cleanup does with the runner sandbox, and
54
- * `release` releases the run's resources, reporting cleanup's start first.
28
+ * session calls it: `startCleanup` reports cleanup's start, and `release` releases the run's resources, reporting
29
+ * cleanup's start first.
55
30
  */
56
31
  export interface RunnerSessionCleanup {
57
- readonly startCleanup: (runnerSandbox: RunnerSandboxPlan) => Promise<void>;
58
- readonly release: (runnerSandbox: RunnerSandboxPlan) => Promise<void>;
32
+ readonly startCleanup: () => Promise<void>;
33
+ readonly release: () => Promise<void>;
59
34
  }
60
35
  /** What closing a session's sandbox scope left, and the team and project its sandboxes are in: the run's target. */
61
36
  export interface RunnerCleanupFacts extends RunnerScopeFacts {
62
37
  readonly target: MintTarget;
63
38
  }
64
- /** How a session ended: how saving the runner sandbox as a dev snapshot did, and what closing left. */
65
- export interface RunnerSessionEnd {
66
- /**
67
- * How the save ended; null when the run's save mode saves never, or its save never started: the command didn't end
68
- * on its own, or the mode doesn't save always and the command didn't exit 0 or the run started from a dev snapshot
69
- * built at HEAD's commit.
70
- */
71
- readonly save: RunnerSave | null;
72
- /**
73
- * Why no save started, in a run whose command ended on its own and that no signal stopped; null when a save
74
- * started, and when the command never ran or didn't end on its own.
75
- */
76
- readonly noSave: RunnerNoSaveReason | null;
77
- readonly cleanup: RunnerCleanupFacts;
78
- }
79
39
  /**
80
40
  * One run's runner session, open from before the run mints. Its stages run in this order: `ready`, then `runCommand`
81
41
  * in the runner sandbox `ready` readied, then `finish`; `close` ends it however the run went. A signal stops the
@@ -83,9 +43,9 @@ export interface RunnerSessionEnd {
83
43
  */
84
44
  export interface RunnerSession {
85
45
  /**
86
- * Readies the runner sandbox: chooses what it starts from (`chooseSnapshotStart`), reuses that cached
87
- * runner snapshot or builds a base snapshot (`obtainSnapshot`), starts the runner sandbox from it, uploads and
88
- * applies the run's changes, and runs the install and build (`readyRunner`). `signal` stops it. Called once.
46
+ * Readies the runner sandbox (`readyRunner`): reuses the cached runner snapshot it picks or builds a base snapshot,
47
+ * starts the runner sandbox from it, uploads and applies the run's changes, and runs the install and build. `signal`
48
+ * stops it. Called once.
89
49
  */
90
50
  ready(access: SandboxAccess, signal: AbortSignal): Promise<ReadyRunnerOutcome>;
91
51
  /**
@@ -98,29 +58,22 @@ export interface RunnerSession {
98
58
  readonly testEvents?: SandboxTestEvents;
99
59
  }): Promise<SandboxedCommandOutcome>;
100
60
  /**
101
- * Ends the session once the run is done in the runner sandbox. When the command ended on its own and no signal
102
- * arrived, it decides once whether to save (`saveDecision`): a save mode other than `never` saves the runner sandbox
103
- * as a dev snapshot while the run's resources are released, and the save settles before the scope closes, even when
104
- * releasing them throws; a mode that doesn't save always saves nothing when the command didn't exit 0, so a person
105
- * can connect to the runner sandbox a failed command ran in, or when the run started from a dev snapshot HEAD's
106
- * commit saved. Then it reports cleanup's start, with the plan it acted on, closes the scope, and releases the
107
- * resources, which a run without a save does only once the scope is closed. A run whose save never started keeps
108
- * its runner sandbox for the keep time.
61
+ * Ends the session once the run is done in the runner sandbox: it reports cleanup's start, closes the scope, which
62
+ * keeps the runner sandbox for the keep time, and then releases the run's resources. It answers what closing the
63
+ * scope left.
109
64
  */
110
- finish(): Promise<RunnerSessionEnd>;
65
+ finish(): Promise<RunnerCleanupFacts>;
111
66
  /**
112
- * Stops listening for the signal, closes the scope and releases the run's resources, with the keep time of a run
113
- * whose save never started, even when closing throws. Closing is memoized: once `finish` closed the scope, it
67
+ * Stops listening for the signal, closes the scope and releases the run's resources, even when closing throws. Closing is memoized: once `finish` closed the scope, it
114
68
  * answers that close's report, and once the resources are released, releasing them does nothing. For a run that
115
69
  * throws.
116
70
  */
117
71
  close(): Promise<RunnerCleanupFacts>;
118
72
  }
119
73
  /**
120
- * Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which asks the
121
- * session for the keep time as it closes, and listens for `signal`. The keep time is the request's until a save starts,
122
- * and 0 from then on, however the save ends: the save resets the runner sandbox's working tree. On its first abort,
123
- * the session reports `stopping`, with whether the command runs and that keep time, before the scope starts to close.
74
+ * Opens a run's runner session over `context`, reporting to `progress`: it opens the sandbox scope, which keeps the
75
+ * runner sandbox for the request's keep time as it closes, and listens for `signal`. On its first abort, the session
76
+ * reports `stopping`, with whether the command runs and the keep time, before the scope starts to close.
124
77
  */
125
78
  export declare function openRunnerSession(context: RunnerContext, request: RunnerSessionRequest, control: {
126
79
  readonly signal: AbortSignal;