@cnc-tools/storm 0.8.1 → 0.9.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.
@@ -1,3 +1,3 @@
1
1
  // Written by scripts/write-build-info.js when the package was built.
2
- export const sha = "f13413f37cb7";
2
+ export const sha = "ac0aeb588460";
3
3
  export const dirty = false;
@@ -301,6 +301,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
301
301
  };
302
302
  cleanup: import("./cleanup.ts").StormCleanupFacts;
303
303
  }]>;
304
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
305
+ variables: {
306
+ name: string;
307
+ problem: "missing" | "multiline" | "short";
308
+ }[];
309
+ minLength: number;
310
+ configFile: string | null;
311
+ }]>;
304
312
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
305
313
  snapshotId: string;
306
314
  base: string;
@@ -512,6 +520,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
512
520
  };
513
521
  cleanup: import("./cleanup.ts").StormCleanupFacts;
514
522
  }]>;
523
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
524
+ variables: {
525
+ name: string;
526
+ problem: "missing" | "multiline" | "short";
527
+ }[];
528
+ minLength: number;
529
+ configFile: string | null;
530
+ }]>;
515
531
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
516
532
  snapshotId: string;
517
533
  base: string;
@@ -821,6 +837,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
821
837
  };
822
838
  cleanup: import("./cleanup.ts").StormCleanupFacts;
823
839
  }]>;
840
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
841
+ variables: {
842
+ name: string;
843
+ problem: "missing" | "multiline" | "short";
844
+ }[];
845
+ minLength: number;
846
+ configFile: string | null;
847
+ }]>;
824
848
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
825
849
  snapshotId: string;
826
850
  base: string;
@@ -1032,6 +1056,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
1032
1056
  };
1033
1057
  cleanup: import("./cleanup.ts").StormCleanupFacts;
1034
1058
  }]>;
1059
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
1060
+ variables: {
1061
+ name: string;
1062
+ problem: "missing" | "multiline" | "short";
1063
+ }[];
1064
+ minLength: number;
1065
+ configFile: string | null;
1066
+ }]>;
1035
1067
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
1036
1068
  snapshotId: string;
1037
1069
  base: string;
@@ -1,6 +1,6 @@
1
1
  import { RUN_FIELDS, RUN_USAGE_FLAGS } from "./run-metadata.js";
2
2
  export const metadata = {
3
- description: "Run any command, the argument list after --, as it is, with the run payload in STORM_RUN. For vitest, use storm vitest, which counts the tests and sizes the run first; exec counts nothing and sizes nothing. In a local run (--local), the command runs on this machine in the working directory, with this machine's environment less the host variables a resource names (TESTSERVER_BASES and TESTSERVER_BASE), plus STORM_RUN, and FORCE_COLOR or NO_COLOR when neither is set. In a runner run, the default, it runs in a runner sandbox, a Vercel Sandbox readied from the runner recipe in storm.config.ts, in the recipe's cwd, with the runner sandbox's own environment, a PATH that starts with node_modules/.bin of that cwd and of the repository's root, the recipe's env and STORM_RUN, and nothing from this machine's environment; each path under the repository's root in its arguments points at the runner sandbox's copy, and each in its output back at this checkout. With a Testserver side (resources.testserverPool in storm.config.ts, or any --testserver-* flag), first lease usable Testserver sandboxes from the pool and create the rest, while a runner run readies its runner sandbox, and release the leases once the command ends; without one, the run payload names no Testserver sandbox. Shows on stderr what runs when and what runs at once, live on a terminal and one line at a time elsewhere, then a waterfall of the run's lanes naming its critical path, and exits with the command's code. Each run writes what it was and how it ended, its events, its steps' output, its command's output, its test events and its timeline to a run directory under ${XDG_STATE_HOME:-~/.local/state}/storm/runs/, named for its run id, keeping the newest 1000 completed ones and every one whose run is still going; the summary names the run id, storm runs show reads the run back, and storm runs logs prints its command's output and its steps' logs. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default. With resources.githubFixtureRepo, in storm.config.ts or by a --set of its options, the run reads a token for that GitHub repository from the host variable its tokenEnv names (refusing without it, unless optional), checks the token can read the repository, hands the command the repository, the token and a run prefix (run/<UTC timestamp>-<suffix>) in the run payload, shows the token as <token> in what it prints and writes, and deletes every branch under the run prefix once the command has stopped.",
3
+ description: "Run any command, the argument list after --, as it is, with the run payload in STORM_RUN. For vitest, use storm vitest, which counts the tests and sizes the run first; exec counts nothing and sizes nothing. In a local run (--local), the command runs on this machine in the working directory, with this machine's environment less the host variables a resource names (TESTSERVER_BASES and TESTSERVER_BASE), plus STORM_RUN, and FORCE_COLOR or NO_COLOR when neither is set. In a runner run, the default, it runs in a runner sandbox, a Vercel Sandbox readied from the runner recipe in storm.config.ts, in the recipe's cwd, with the runner sandbox's own environment, a PATH that starts with node_modules/.bin of that cwd and of the repository's root, the recipe's env and STORM_RUN, and nothing from this machine's environment; each recipe step that names a runner secret, never the command, also gets that host variable, one its secrets key declares, shown as <token> in what storm prints and writes, and a runner run refuses before it starts when one of them is unset, holds a line break or is shorter than 8 characters; each path under the repository's root in its arguments points at the runner sandbox's copy, and each in its output back at this checkout. With a Testserver side (resources.testserverPool in storm.config.ts, or any --testserver-* flag), first lease usable Testserver sandboxes from the pool and create the rest, while a runner run readies its runner sandbox, and release the leases once the command ends; without one, the run payload names no Testserver sandbox. Shows on stderr what runs when and what runs at once, live on a terminal and one line at a time elsewhere, then a waterfall of the run's lanes naming its critical path, and exits with the command's code. Each run writes what it was and how it ended, its events, its steps' output, its command's output, its test events and its timeline to a run directory under ${XDG_STATE_HOME:-~/.local/state}/storm/runs/, named for its run id, keeping the newest 1000 completed ones and every one whose run is still going; the summary names the run id, storm runs show reads the run back, and storm runs logs prints its command's output and its steps' logs. A flag overrides storm.config.ts, found in the working directory or a parent up to the git worktree's root and checked whole, which overrides the built-in default. With resources.githubFixtureRepo, in storm.config.ts or by a --set of its options, the run reads a token for that GitHub repository from the host variable its tokenEnv names (refusing without it, unless optional), checks the token can read the repository, hands the command the repository, the token and a run prefix (run/<UTC timestamp>-<suffix>) in the run payload, shows the token as <token> in what it prints and writes, and deletes every branch under the run prefix once the command has stopped.",
4
4
  summary: "Run any command, in a runner sandbox or locally.",
5
5
  usages: [`${RUN_USAGE_FLAGS} -- <command...>`],
6
6
  fields: {
@@ -162,6 +162,18 @@ export declare const runErrors: import("@vercel/clinkr").SharedErrors<{
162
162
  missingRunner: z.ZodObject<{
163
163
  configFile: z.ZodNullable<z.ZodString>;
164
164
  }, z.core.$strip>;
165
+ runnerSecretsInvalid: z.ZodObject<{
166
+ variables: z.ZodArray<z.ZodObject<{
167
+ name: z.ZodString;
168
+ problem: z.ZodEnum<{
169
+ missing: "missing";
170
+ multiline: "multiline";
171
+ short: "short";
172
+ }>;
173
+ }, z.core.$strip>>;
174
+ minLength: z.ZodNumber;
175
+ configFile: z.ZodNullable<z.ZodString>;
176
+ }, z.core.$strip>;
165
177
  noBaseRef: z.ZodObject<{
166
178
  refs: z.ZodArray<z.ZodObject<{
167
179
  ref: z.ZodString;
@@ -250,6 +262,37 @@ export declare const runErrors: import("@vercel/clinkr").SharedErrors<{
250
262
  }[];
251
263
  };
252
264
  };
265
+ readonly runnerSecretsInvalid: {
266
+ readonly exitCode: 2;
267
+ readonly description: "In a runner run, host environment variables the runner recipe's secrets key names can't be used, so the run didn't start: it minted, leased and created nothing. Each variable has one problem, the first of: missing, unset or empty; multiline, its value holds a carriage return or a line feed, which line-by-line output would split past storm's redaction; short, its value holds fewer than 8 characters, and storm shows each value as <token> wherever it appears in what it prints and writes, so a value that short would hide ordinary output.";
268
+ readonly schema: z.ZodObject<{
269
+ variables: z.ZodArray<z.ZodObject<{
270
+ name: z.ZodString;
271
+ problem: z.ZodEnum<{
272
+ missing: "missing";
273
+ multiline: "multiline";
274
+ short: "short";
275
+ }>;
276
+ }, z.core.$strip>>;
277
+ minLength: z.ZodNumber;
278
+ configFile: z.ZodNullable<z.ZodString>;
279
+ }, z.core.$strip>;
280
+ readonly render: ({ variables, minLength, configFile }: {
281
+ variables: {
282
+ name: string;
283
+ problem: "missing" | "multiline" | "short";
284
+ }[];
285
+ minLength: number;
286
+ configFile: string | null;
287
+ }) => {
288
+ message: string;
289
+ rows: [string, string[]][];
290
+ next: {
291
+ type: "text";
292
+ text: string;
293
+ }[];
294
+ };
295
+ };
253
296
  readonly noBaseRef: {
254
297
  readonly exitCode: 1;
255
298
  readonly description: "In a runner run, none of the runner recipe's baseRefs exists locally and shares history with HEAD, so there is no base. storm never fetches.";
@@ -582,6 +625,14 @@ export declare const RUN_ERRORS: {
582
625
  };
583
626
  cleanup: import("./cleanup.ts").StormCleanupFacts;
584
627
  }]>;
628
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
629
+ variables: {
630
+ name: string;
631
+ problem: "missing" | "multiline" | "short";
632
+ }[];
633
+ minLength: number;
634
+ configFile: string | null;
635
+ }]>;
585
636
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
586
637
  snapshotId: string;
587
638
  base: string;
@@ -893,6 +944,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
893
944
  };
894
945
  cleanup: import("./cleanup.ts").StormCleanupFacts;
895
946
  }]>;
947
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
948
+ variables: {
949
+ name: string;
950
+ problem: "missing" | "multiline" | "short";
951
+ }[];
952
+ minLength: number;
953
+ configFile: string | null;
954
+ }]>;
896
955
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
897
956
  snapshotId: string;
898
957
  base: string;
@@ -1104,6 +1163,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
1104
1163
  };
1105
1164
  cleanup: import("./cleanup.ts").StormCleanupFacts;
1106
1165
  }]>;
1166
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
1167
+ variables: {
1168
+ name: string;
1169
+ problem: "missing" | "multiline" | "short";
1170
+ }[];
1171
+ minLength: number;
1172
+ configFile: string | null;
1173
+ }]>;
1107
1174
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
1108
1175
  snapshotId: string;
1109
1176
  base: string;
@@ -35,6 +35,12 @@ const runnerFailureSchema = z.union([
35
35
  }),
36
36
  z.object({ kind: z.literal("credential-claims-missing"), team: z.string(), project: z.string() }),
37
37
  ]);
38
+ /** Names as a sentence lists them: `A`, `A and B`, `A, B and C`. */
39
+ function listed(names) {
40
+ if (names.length <= 1)
41
+ return names.join("");
42
+ return `${names.slice(0, -1).join(", ")} and ${names.at(-1) ?? ""}`;
43
+ }
38
44
  /** How a step ended, as a message says it. */
39
45
  function stepEnded(exitCode) {
40
46
  return exitCode === null ? "ended without an exit code" : `exited ${exitCode}`;
@@ -226,6 +232,50 @@ export const runErrors = defineErrors({
226
232
  ],
227
233
  }),
228
234
  },
235
+ runnerSecretsInvalid: {
236
+ exitCode: 2,
237
+ description: "In a runner run, host environment variables the runner recipe's secrets key names can't be used, so the run didn't start: it minted, leased and created nothing. Each variable has one problem, the first of: missing, unset or empty; multiline, its value holds a carriage return or a line feed, which line-by-line output would split past storm's redaction; short, its value holds fewer than 8 characters, and storm shows each value as <token> wherever it appears in what it prints and writes, so a value that short would hide ordinary output.",
238
+ schema: z.object({
239
+ /** Each variable storm can't use and why, in the recipe's order. */
240
+ variables: z.array(z.object({ name: z.string(), problem: z.enum(["missing", "multiline", "short"]) })),
241
+ /** The fewest characters a runner secret's value may have. */
242
+ minLength: z.number(),
243
+ /** The config file that gave the runner recipe. */
244
+ configFile: z.string().nullable(),
245
+ }),
246
+ render: ({ variables, minLength, configFile }) => {
247
+ const named = (problem) => variables.filter((variable) => variable.problem === problem).map(({ name }) => name);
248
+ const [missing, multiline, short] = [named("missing"), named("multiline"), named("short")];
249
+ return {
250
+ message: `runner.secrets${configFile === null ? "" : ` in ${configFile}`} names ${variables.length === 1 ? "a variable" : "variables"} storm can't use. The run didn't start.`,
251
+ rows: [
252
+ [
253
+ "Runner secrets",
254
+ variables.map(({ name, problem }) => problem === "missing"
255
+ ? `${name} is not set`
256
+ : problem === "multiline"
257
+ ? `${name} holds a carriage return or a line feed`
258
+ : `${name} holds fewer than ${minLength} characters`),
259
+ ],
260
+ ],
261
+ next: [
262
+ {
263
+ type: "text",
264
+ text: [
265
+ ...(missing.length === 0 ? [] : [`Set ${listed(missing)} in this machine's environment.`]),
266
+ ...(multiline.length === 0
267
+ ? []
268
+ : [
269
+ `Set ${listed(multiline)} to a value on one line: storm hides each value in output a line at a time, and doesn't trim one.`,
270
+ ]),
271
+ ...(short.length === 0 ? [] : [`Set ${listed(short)} to the whole secret.`]),
272
+ ].join(" "),
273
+ },
274
+ { type: "text", text: "Or run on this machine with --local, which reads no runner secret." },
275
+ ],
276
+ };
277
+ },
278
+ },
229
279
  noBaseRef: {
230
280
  exitCode: 1,
231
281
  description: "In a runner run, none of the runner recipe's baseRefs exists locally and shares history with HEAD, so there is no base. storm never fetches.",
@@ -2,7 +2,7 @@ import { type ArgumentIssue, type CommandError, type CommandResult, type Executi
2
2
  import { z } from "zod";
3
3
  import type { StormApp } from "../../context.ts";
4
4
  import { type CredentialSourceChoice, type MintTarget } from "../../credential/index.ts";
5
- import { type CheckedRecipe, type CheckoutFailure } from "../../runner/index.ts";
5
+ import { type CheckedRecipe, type CheckoutFailure, type RunnerSecrets } from "../../runner/index.ts";
6
6
  import { type StormSetValues } from "../../resources.ts";
7
7
  import { type ranSchema } from "./outcomes.ts";
8
8
  import { type RunRecordPlan } from "./run-record.ts";
@@ -148,12 +148,13 @@ export interface RunCommandSpec<TPlan, TRan, TRefusal> {
148
148
  * Each resource is a provider (the registry, `src/resources.ts`, lists them), whose folder under `src/resources/` says
149
149
  * what the run does with it, and whose command half settles it (`RESOURCE_COMMANDS.settle`). The run refuses in this
150
150
  * order: `invalid_config`, `invalid_resource_options`, `credential_unused`; in a runner run `missing_runner`, then
151
- * `missing_target`; in a local run where a resource takes the credential, `missing_target` for the mint; then each
152
- * resource's settle, in provider order; then `spec.prepare`'s refusal, if any. A resource's secrets, such as a token,
153
- * are hidden as `<token>` in the run's progress, its run directory, its job summary, its outcome, `spec.prepare`'s
154
- * refusal, and its command's output, in either kind of run.
151
+ * `missing_target`, then `runner_secrets_invalid`; in a local run where a resource takes
152
+ * the credential, `missing_target` for the mint; then each resource's settle, in provider order; then `spec.prepare`'s
153
+ * refusal, if any. A resource's secrets, such as a token, and in a runner run the runner secrets' values, are hidden as
154
+ * `<token>` in the run's progress, its run directory, its job summary, its outcome, `spec.prepare`'s refusal, a runner
155
+ * run's preparation refusal (`prepareRunner`'s), and its command's output and step output.
155
156
  */
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">>;
157
+ 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<"runner_secrets_invalid"> | CommandError<"snapshot_gone"> | CommandError<"spawn_failed"> | CommandError<"submodules_refused"> | CommandError<"token_request_failed">>;
157
158
  /** What is wrong with a run's request that its schema can't say, as `validate` reports it. */
158
159
  export declare function runProblems({ set, credential, local, rebuildSnapshot, saveSnapshot, showOutput, keepSandbox, ...rest }: RunCommandRequest): readonly ArgumentIssue[];
159
160
  /**
@@ -170,8 +171,8 @@ export declare function checkoutFailedRefusal(failure: CheckoutFailure): Command
170
171
  export declare const DEFAULT_KEEP_SANDBOX_MINUTES = 30;
171
172
  /**
172
173
  * Where a settled run runs: with `--local` on this machine, with the credential source it settled when a held
173
- * resource takes one; or by default in a runner sandbox, with the runner recipe and the team and project the runner
174
- * sandbox's credential is minted for, whose one mint the resources share.
174
+ * resource takes one; or by default in a runner sandbox, with the runner recipe, the team and project the runner
175
+ * sandbox's credential is minted for, whose one mint the resources share, and the runner secrets' values.
175
176
  */
176
177
  type RunWhere = {
177
178
  readonly kind: "local";
@@ -180,13 +181,15 @@ type RunWhere = {
180
181
  readonly kind: "runner";
181
182
  readonly recipe: CheckedRecipe;
182
183
  readonly target: MintTarget;
184
+ readonly secrets: RunnerSecrets;
183
185
  };
184
186
  /**
185
187
  * Settles a run before it starts, refusing in this order: the config file (`invalid_config`); each held resource's
186
188
  * merged options (`invalid_resource_options`); a `--credential` no held resource takes (`credential_unused`); in a
187
- * runner run, the runner recipe (`missing_runner`) and the team and project its mint needs (`missing_target`); in a
188
- * local run where a held resource takes the credential, the credential source (`missing_target` for the mint); then
189
- * each held resource's own settle, in provider order.
189
+ * runner run, the runner recipe (`missing_runner`), the team and project its mint needs (`missing_target`) and the
190
+ * runner secrets from the host's environment (`runner_secrets_invalid`); in a local run
191
+ * where a held resource takes the credential, the credential source (`missing_target` for the mint); then each held
192
+ * resource's own settle, in provider order.
190
193
  */
191
194
  declare function settleRun(app: StormApp, request: {
192
195
  readonly given: StormSetValues;
@@ -212,6 +215,9 @@ declare function settleRun(app: StormApp, request: {
212
215
  } | {
213
216
  readonly ok: false;
214
217
  readonly refusal: CommandError<"missing_runner">;
218
+ } | {
219
+ readonly ok: false;
220
+ readonly refusal: CommandError<"runner_secrets_invalid">;
215
221
  } | {
216
222
  readonly ok: true;
217
223
  readonly configFile: string | null;
@@ -5,7 +5,7 @@ import { refused, } from "@vercel/clinkr";
5
5
  import { NodeSignalCancellation } from "@vercel/clinkr/node";
6
6
  import { z } from "zod";
7
7
  import { describeMintFailure, requireTarget, settleCredential, } from "../../credential/index.js";
8
- import { prepareRunner, } from "../../runner/index.js";
8
+ import { prepareRunner, readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, } from "../../runner/index.js";
9
9
  import { fileSettings, invalidConfig, loadSettingsFile, parseSetFlags, settleResourceOptions, } from "../../config/index.js";
10
10
  import { commandExitStatus, executeRun, observeAll, RUN_DIRECTORIES_KEPT, runDirectoryObserver, stepLog, testEventsPath, timedProgress, } from "../../core/index.js";
11
11
  import { RESOURCE_COMMANDS, RESOURCE_CONFIGS, RESOURCE_REPORTS, RESOURCES, RUN_CLEANUP, stormTimeline, } from "../../resources.js";
@@ -103,10 +103,11 @@ const runRequestSchema = z.object(RUN_REQUEST_FIELDS);
103
103
  * Each resource is a provider (the registry, `src/resources.ts`, lists them), whose folder under `src/resources/` says
104
104
  * what the run does with it, and whose command half settles it (`RESOURCE_COMMANDS.settle`). The run refuses in this
105
105
  * order: `invalid_config`, `invalid_resource_options`, `credential_unused`; in a runner run `missing_runner`, then
106
- * `missing_target`; in a local run where a resource takes the credential, `missing_target` for the mint; then each
107
- * resource's settle, in provider order; then `spec.prepare`'s refusal, if any. A resource's secrets, such as a token,
108
- * are hidden as `<token>` in the run's progress, its run directory, its job summary, its outcome, `spec.prepare`'s
109
- * refusal, and its command's output, in either kind of run.
106
+ * `missing_target`, then `runner_secrets_invalid`; in a local run where a resource takes
107
+ * the credential, `missing_target` for the mint; then each resource's settle, in provider order; then `spec.prepare`'s
108
+ * refusal, if any. A resource's secrets, such as a token, and in a runner run the runner secrets' values, are hidden as
109
+ * `<token>` in the run's progress, its run directory, its job summary, its outcome, `spec.prepare`'s refusal, a runner
110
+ * run's preparation refusal (`prepareRunner`'s), and its command's output and step output.
110
111
  */
111
112
  export async function runCommand({ app, ui, signal }, request, spec) {
112
113
  const sets = parseSetFlags(request.set, RESOURCE_CONFIGS, TESTSERVER_OWN_FLAGS);
@@ -116,10 +117,14 @@ export async function runCommand({ app, ui, signal }, request, spec) {
116
117
  const settled = await settleRun(app, { ...request, given: withTestserverFlags(sets.values, request) });
117
118
  if (!settled.ok)
118
119
  return settled.refusal;
119
- // The resources' secrets: every event, the command's output and a preparation's refusal pass through `redact`
120
- // before any view, the run directory or the summary sees them. A refusal can quote what preparation ran with this
121
- // machine's environment, such as the last line of `vitest list`'s stderr.
122
- const { secrets } = settled.settlement;
120
+ // The resources' secrets and the runner secrets' values: every event, the command's output, `spec.prepare`'s refusal
121
+ // and `prepareRunner`'s pass through `redact` before any view, the run directory or the summary sees them. A refusal
122
+ // can quote what preparation ran with this machine's environment, such as the last line of `vitest list`'s stderr,
123
+ // or what a recipe's step function or `vcpus` function threw.
124
+ const secrets = [
125
+ ...settled.settlement.secrets,
126
+ ...(settled.where.kind === "runner" ? Object.values(settled.where.secrets) : []),
127
+ ];
123
128
  const redact = redactor(secrets);
124
129
  const ready = await spec.prepare(settled, signal);
125
130
  if (signal.aborted)
@@ -128,7 +133,7 @@ export async function runCommand({ app, ui, signal }, request, spec) {
128
133
  return secrets.length === 0 ? ready.refusal : redactStrings(ready.refusal, redact);
129
134
  const { argv, plan } = ready;
130
135
  const { configFile, options, where, settlement } = ready.settled;
131
- if (settlement.secrets !== secrets)
136
+ if (settlement.secrets !== settled.settlement.secrets || where !== settled.where)
132
137
  throw new Error("spec.prepare changed the run's secrets");
133
138
  const base = {
134
139
  argv,
@@ -157,8 +162,10 @@ export async function runCommand({ app, ui, signal }, request, spec) {
157
162
  rebuild: request.rebuildSnapshot,
158
163
  saveSnapshot: request.saveSnapshot,
159
164
  });
160
- if (prepared.kind !== "ok")
161
- return prepareRefusal(prepared, configFile);
165
+ if (prepared.kind !== "ok") {
166
+ const refusal = prepareRefusal(prepared, configFile);
167
+ return secrets.length === 0 ? refusal : redactStrings(refusal, redact);
168
+ }
162
169
  const { save } = prepared.prepared;
163
170
  run = {
164
171
  ...base,
@@ -167,6 +174,7 @@ export async function runCommand({ app, ui, signal }, request, spec) {
167
174
  prepared: prepared.prepared,
168
175
  target: where.target,
169
176
  user: app.user,
177
+ secrets: where.secrets,
170
178
  sandbox: save?.kind === "branch"
171
179
  ? { kind: "save", branch: save.branch }
172
180
  : { kind: "keep", ms: keepSandboxMinutes(request.keepSandbox, where.recipe, app.env) * 60_000 },
@@ -626,9 +634,10 @@ function setProblems(texts) {
626
634
  /**
627
635
  * Settles a run before it starts, refusing in this order: the config file (`invalid_config`); each held resource's
628
636
  * merged options (`invalid_resource_options`); a `--credential` no held resource takes (`credential_unused`); in a
629
- * runner run, the runner recipe (`missing_runner`) and the team and project its mint needs (`missing_target`); in a
630
- * local run where a held resource takes the credential, the credential source (`missing_target` for the mint); then
631
- * each held resource's own settle, in provider order.
637
+ * runner run, the runner recipe (`missing_runner`), the team and project its mint needs (`missing_target`) and the
638
+ * runner secrets from the host's environment (`runner_secrets_invalid`); in a local run
639
+ * where a held resource takes the credential, the credential source (`missing_target` for the mint); then each held
640
+ * resource's own settle, in provider order.
632
641
  */
633
642
  async function settleRun(app, request) {
634
643
  const file = await loadSettingsFile(app.context.config, app.cwd, RESOURCE_CONFIGS);
@@ -650,7 +659,15 @@ async function settleRun(app, request) {
650
659
  const required = requireTarget(settings.scope, settings.project);
651
660
  if (!required.ok)
652
661
  return required;
653
- where = { kind: "runner", recipe: settings.runner.value, target: required.target };
662
+ const recipe = settings.runner.value;
663
+ const secrets = readRunnerSecrets(recipe, app.env);
664
+ if (!secrets.ok)
665
+ return refused(runErrors.runnerSecretsInvalid({
666
+ variables: secrets.variables.map(({ name, problem }) => ({ name, problem })),
667
+ minLength: RUNNER_SECRET_MIN_LENGTH,
668
+ configFile,
669
+ }));
670
+ where = { kind: "runner", recipe, target: required.target, secrets: secrets.values };
654
671
  }
655
672
  else if (takesCredential) {
656
673
  const chosen = settleCredential(request.credential ?? "mint", settings.scope, settings.project);
@@ -328,6 +328,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
328
328
  };
329
329
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
330
330
  }]>;
331
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
332
+ variables: {
333
+ name: string;
334
+ problem: "missing" | "multiline" | "short";
335
+ }[];
336
+ minLength: number;
337
+ configFile: string | null;
338
+ }]>;
331
339
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
332
340
  snapshotId: string;
333
341
  base: string;
@@ -584,6 +592,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
584
592
  };
585
593
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
586
594
  }]>;
595
+ readonly runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
596
+ variables: {
597
+ name: string;
598
+ problem: "missing" | "multiline" | "short";
599
+ }[];
600
+ minLength: number;
601
+ configFile: string | null;
602
+ }]>;
587
603
  readonly snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
588
604
  snapshotId: string;
589
605
  base: string;
@@ -918,6 +934,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
918
934
  };
919
935
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
920
936
  }]>;
937
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
938
+ variables: {
939
+ name: string;
940
+ problem: "missing" | "multiline" | "short";
941
+ }[];
942
+ minLength: number;
943
+ configFile: string | null;
944
+ }]>;
921
945
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
922
946
  snapshotId: string;
923
947
  base: string;
@@ -1174,6 +1198,14 @@ export declare function command(cmd: CommandBuilder<StormApp>): import("@vercel/
1174
1198
  };
1175
1199
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
1176
1200
  }]>;
1201
+ readonly runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
1202
+ variables: {
1203
+ name: string;
1204
+ problem: "missing" | "multiline" | "short";
1205
+ }[];
1206
+ minLength: number;
1207
+ configFile: string | null;
1208
+ }]>;
1177
1209
  readonly snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
1178
1210
  snapshotId: string;
1179
1211
  base: string;
@@ -301,6 +301,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
301
301
  };
302
302
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
303
303
  }]>;
304
+ runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
305
+ variables: {
306
+ name: string;
307
+ problem: "missing" | "multiline" | "short";
308
+ }[];
309
+ minLength: number;
310
+ configFile: string | null;
311
+ }]>;
304
312
  snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
305
313
  snapshotId: string;
306
314
  base: string;
@@ -557,6 +565,14 @@ export declare const outcomes: import("@vercel/clinkr").Outcomes<{
557
565
  };
558
566
  cleanup: import("../exec/cleanup.ts").StormCleanupFacts;
559
567
  }]>;
568
+ readonly runnerSecretsInvalid: import("@vercel/clinkr").SharedError<"runner_secrets_invalid", [data: {
569
+ variables: {
570
+ name: string;
571
+ problem: "missing" | "multiline" | "short";
572
+ }[];
573
+ minLength: number;
574
+ configFile: string | null;
575
+ }]>;
560
576
  readonly snapshotGone: import("@vercel/clinkr").SharedError<"snapshot_gone", [data: {
561
577
  snapshotId: string;
562
578
  base: string;
@@ -1,5 +1,5 @@
1
1
  import { type CredentialGateway, type CredentialSourceChoice, type GitHubActionsTokenGateway, type MintFailure, type MintTarget } from "../credential/index.ts";
2
- import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerSandboxPlan, type RunnerSave, type RunnerScopeReport, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
2
+ import { type PreparedRunner, type RunnerContext, type RunnerFailure, type RunnerSandboxPlan, type RunnerSave, type RunnerScopeReport, type RunnerSecrets, type RunnerSnapshotCacheFailure, type RunnerSnapshotEntry } from "../runner/index.ts";
3
3
  import type { RunProgress } from "./events.ts";
4
4
  import type { CommandGateway } from "./gateways.ts";
5
5
  import type { CoreContext, RunProviders, ResourceCanceledFacts, ResourceCleanup, ResourceFacts, ResourceRefusal, ResourceRequests, ResourceUnprepared } from "./resource.ts";
@@ -23,6 +23,11 @@ export interface RunRunnerRequest {
23
23
  readonly target: MintTarget;
24
24
  /** The local user name, for each sandbox's `user` tag. */
25
25
  readonly user: string;
26
+ /**
27
+ * The runner secrets' values, read from this machine's environment as the run started: each recipe step gets the
28
+ * ones it names, the command gets none, and storm writes none to the run directory, the snapshot cache or `run.json`.
29
+ */
30
+ readonly secrets: RunnerSecrets;
26
31
  /**
27
32
  * What the run does with the runner sandbox once it ends, decided before it starts: keep it running for the keep time
28
33
  * (0 stops and deletes it), or, under `--save-snapshot` on a branch, save it as a branch snapshot once the command
package/dist/core/run.js CHANGED
@@ -349,7 +349,7 @@ async function readyBoth(context, request, control, progress, runnerProgress) {
349
349
  progress,
350
350
  beside: {
351
351
  lane: "runner",
352
- start: (signal) => readyRunner(context, { prepared: runner.prepared, access: request.access, user: runner.user }, { scope: control.scope, signal }, runnerProgress),
352
+ start: (signal) => readyRunner(context, { prepared: runner.prepared, access: request.access, user: runner.user, secrets: runner.secrets }, { scope: control.scope, signal }, runnerProgress),
353
353
  outcomeOf: runnerLaneOutcome,
354
354
  stopped: runnerStopped,
355
355
  },
@@ -10,8 +10,9 @@ export { liveRunnerSnapshotCacheGateway, type LiveRunnerSnapshotCacheOptions, un
10
10
  export { lineSplitter, type LineSplitter, OUTPUT_TAIL_LINES, outputRule, outputTail, type OutputTail, rewritePaths, splitLines, } from "./output.ts";
11
11
  export { type PreparedRunner, prepareRunner, type PrepareRunnerOutcome, type PrepareRunnerRequest, type RunnerPrepareContext, } from "./prepare.ts";
12
12
  export { APPLY_LABEL, type ReadyRunner, readyRunner, type ReadyRunnerOutcome, type ReadyRunnerRequest, } from "./ready.ts";
13
- export { type CheckedRecipe, checkRecipe, type RecipeCheck, type RecipeProblem, resolveSteps, resolveVcpus, type RunnerRecipe, type RunnerResources, type RunnerStep, type RunnerStepContext, type RunnerSteps, } from "./recipe.ts";
13
+ export { type CheckedRecipe, checkRecipe, type RecipeCheck, type RecipeProblem, resolveSteps, resolveVcpus, type RunnerRecipe, type RunnerResources, type ResolvedRunnerStep, type RunnerStep, type RunnerStepContext, type RunnerSteps, } from "./recipe.ts";
14
14
  export { REMOTE_TEST_EVENTS_PATH, type RemoteCommandOutcome, remoteCommand, remoteEnvironment, type RemoteTestEvents, runRemote, } from "./remote-command.ts";
15
+ export { readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, stepSecrets, type RunnerSecretProblem, type RunnerSecrets, type RunnerSecretsRead, } from "./secrets.ts";
15
16
  export { CREATE_SETTLE_MS, keptMs, type RunnerSandboxPlan, type RunnerSandboxScope, runnerSandboxScope, type RunnerScopeReport, SNAPSHOT_SETTLE_MS, } from "./scope.ts";
16
17
  export { BASE_INDEX_LABEL, buildSnapshot, type BuildSnapshotRequest, type BuiltSnapshot } from "./snapshot-build.ts";
17
18
  export { dropBranchSnapshots, type DroppedBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type RunnerSnapshotCandidate, SNAPSHOT_EXPIRATION_MS, type SnapshotCacheContext, type SnapshotCacheNote, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.ts";
@@ -11,6 +11,7 @@ export { prepareRunner, } from "./prepare.js";
11
11
  export { APPLY_LABEL, readyRunner, } from "./ready.js";
12
12
  export { checkRecipe, resolveSteps, resolveVcpus, } from "./recipe.js";
13
13
  export { REMOTE_TEST_EVENTS_PATH, remoteCommand, remoteEnvironment, runRemote, } from "./remote-command.js";
14
+ export { readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, stepSecrets, } from "./secrets.js";
14
15
  export { CREATE_SETTLE_MS, keptMs, runnerSandboxScope, SNAPSHOT_SETTLE_MS, } from "./scope.js";
15
16
  export { BASE_INDEX_LABEL, buildSnapshot } from "./snapshot-build.js";
16
17
  export { dropBranchSnapshots, findSnapshotCandidates, isBranchEntry, pickSnapshot, RUNNER_SNAPSHOTS_SUBPATH, SNAPSHOT_EXPIRATION_MS, snapshotEntryFileName, snapshotEntryIdentity, } from "./snapshot-cache.js";
@@ -1,6 +1,6 @@
1
1
  import { type RefusedBaseRef } from "./base.ts";
2
2
  import type { CheckoutFailure, CheckoutHead, CheckoutUpload } from "./gateways.ts";
3
- import { type CheckedRecipe, type RunnerResources, type RunnerStep } from "./recipe.ts";
3
+ import { type CheckedRecipe, type ResolvedRunnerStep, type RunnerResources } from "./recipe.ts";
4
4
  import { type RunnerSnapshotCandidate, type SnapshotCacheContext, type SnapshotCacheNote } from "./snapshot-cache.ts";
5
5
  /** What `prepareRunner` needs: the checkout, the runner snapshot cache and the clock. */
6
6
  export type RunnerPrepareContext = SnapshotCacheContext;
@@ -24,9 +24,9 @@ export interface PreparedRunner {
24
24
  /** The run's base, a full SHA, and the ref it is HEAD's merge-base with. */
25
25
  readonly base: string;
26
26
  readonly baseRef: string;
27
- /** The recipe's snapshot steps at the base, and their snapshot key. */
28
- readonly toolchains: readonly RunnerStep[];
29
- readonly warm: readonly RunnerStep[];
27
+ /** The recipe's snapshot steps at the base, each with the runner secret names it gets, and their snapshot key. */
28
+ readonly toolchains: readonly ResolvedRunnerStep[];
29
+ readonly prebuild: readonly ResolvedRunnerStep[];
30
30
  readonly snapshotKey: string;
31
31
  /** The runner sandbox's vCPUs for the run's resources. */
32
32
  readonly vcpus: number;
@@ -57,8 +57,9 @@ export interface PreparedRunner {
57
57
  * - `ok`: the run is ready for the remote side.
58
58
  * - `no-base-ref`: no ref in `baseRefs` exists locally and shares history with HEAD; `refs` says why for each.
59
59
  * - `submodules`: the checkout has Git submodules, at `paths`.
60
- * - `invalid-recipe`: a step function or `vcpus` failed or returned something storm can't use, at the run's
61
- * base or for its resources; `path` is the key inside the recipe.
60
+ * - `invalid-recipe`: a step function or `vcpus` failed or returned something storm can't use, such as a step naming
61
+ * a runner secret the recipe's `secrets` doesn't declare, at the run's base or for its resources; `path` is the key
62
+ * inside the recipe.
62
63
  * - `checkout-failed`: git or tar failed, such as outside a Git checkout.
63
64
  */
64
65
  export type PrepareRunnerOutcome = {
@@ -52,7 +52,7 @@ export async function prepareRunner(context, request) {
52
52
  base,
53
53
  baseRef: resolved.ref,
54
54
  toolchains: steps.toolchains,
55
- warm: steps.warm,
55
+ prebuild: steps.prebuild,
56
56
  snapshotKey: steps.key,
57
57
  vcpus: vcpus.vcpus,
58
58
  upload: upload.value,