@cnc-tools/storm 0.12.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/storm.js +1 -1
- package/dist/build-info.js +1 -1
- package/dist/chunks/{chunk-4XT5RC5T.js → chunk-2NZXL6OH.js} +6 -42
- package/dist/chunks/{chunk-ISGQJIQM.js → chunk-5UMJNVKT.js} +1 -1
- package/dist/chunks/{chunk-FSP3SJ35.js → chunk-6EQKA7LI.js} +16 -46
- package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-AX4EQZUS.js} +4 -4
- package/dist/chunks/{chunk-RYRJNHL7.js → chunk-DOFB2ACU.js} +3 -9
- package/dist/chunks/{chunk-SXW6XN4R.js → chunk-EGNP3S6C.js} +3 -3
- package/dist/chunks/{chunk-FK4RLDEK.js → chunk-N7E6DAUE.js} +1 -1
- package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-Q4TKRILH.js} +33 -167
- package/dist/chunks/{chunk-TMQQYHUX.js → chunk-RTILVSYQ.js} +1 -1
- package/dist/chunks/{chunk-7D6LC5JY.js → chunk-X4WBJIOF.js} +7 -39
- package/dist/chunks/{chunk-TEEZL3GA.js → chunk-YGS5VRQT.js} +11 -68
- package/dist/chunks/{chunk-ODQHQJLE.js → chunk-ZDJLKF2G.js} +742 -1117
- package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-QFHS54SX.js} +4 -4
- package/dist/commands/exec/command.d.ts +2 -90
- package/dist/commands/exec/command.js +10 -10
- package/dist/commands/exec/define-run-command.d.ts +2 -90
- package/dist/commands/exec/live-view.js +18 -22
- package/dist/commands/exec/outcomes.d.ts +2 -106
- package/dist/commands/exec/outcomes.js +4 -35
- package/dist/commands/exec/progress.d.ts +3 -19
- package/dist/commands/exec/progress.js +16 -60
- package/dist/commands/exec/run-command.d.ts +4 -23
- package/dist/commands/exec/run-command.js +5 -79
- package/dist/commands/exec/run-metadata.d.ts +0 -6
- package/dist/commands/exec/run-metadata.js +2 -8
- package/dist/commands/exec/snapshot-text.d.ts +7 -16
- package/dist/commands/exec/snapshot-text.js +9 -49
- package/dist/commands/exec/view.js +2 -12
- package/dist/commands/playwright/command.d.ts +2 -90
- package/dist/commands/playwright/command.js +11 -11
- package/dist/commands/runs/facts.d.ts +1 -37
- package/dist/commands/runs/facts.js +4 -36
- package/dist/commands/runs/list/command.d.ts +0 -72
- package/dist/commands/runs/list/command.js +5 -5
- package/dist/commands/runs/list/outcomes.d.ts +0 -36
- package/dist/commands/runs/logs/command.js +5 -5
- package/dist/commands/runs/show/command.d.ts +0 -72
- package/dist/commands/runs/show/command.js +13 -40
- package/dist/commands/runs/show/metadata.js +1 -1
- package/dist/commands/runs/show/outcomes.d.ts +0 -36
- package/dist/commands/runs/show/outcomes.js +8 -42
- package/dist/commands/snapshots/build/command.d.ts +14 -411
- package/dist/commands/snapshots/build/command.js +56 -231
- package/dist/commands/snapshots/build/metadata.js +10 -7
- package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
- package/dist/commands/snapshots/build/outcomes.js +29 -196
- package/dist/commands/snapshots/list/command.d.ts +2 -36
- package/dist/commands/snapshots/list/command.js +17 -53
- package/dist/commands/snapshots/list/metadata.js +1 -1
- package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
- package/dist/commands/snapshots/list/outcomes.js +13 -53
- package/dist/commands/vitest/command.d.ts +2 -90
- package/dist/commands/vitest/command.js +11 -11
- package/dist/core/events.d.ts +5 -6
- package/dist/core/run-state.d.ts +7 -29
- package/dist/core/run-state.js +3 -26
- package/dist/core/run.d.ts +6 -14
- package/dist/core/run.js +17 -28
- package/dist/extensions/testserver/commands/pool/create/command.js +1 -1
- package/dist/run-directory/index.d.ts +1 -1
- package/dist/run-directory/index.js +0 -1
- package/dist/run-directory/recording.js +2 -2
- package/dist/run-directory/run-record.d.ts +14 -132
- package/dist/run-directory/run-record.js +8 -68
- package/dist/runner/build-snapshots.d.ts +50 -114
- package/dist/runner/build-snapshots.js +70 -159
- package/dist/runner/events.d.ts +4 -88
- package/dist/runner/gateways.d.ts +5 -23
- package/dist/runner/index.d.ts +5 -6
- package/dist/runner/index.js +1 -1
- package/dist/runner/live/snapshot-records.js +7 -18
- package/dist/runner/prepare.d.ts +11 -22
- package/dist/runner/prepare.js +6 -17
- package/dist/runner/ready.d.ts +16 -45
- package/dist/runner/ready.js +34 -59
- package/dist/runner/recipe.d.ts +0 -44
- package/dist/runner/recipe.js +0 -41
- package/dist/runner/scope.d.ts +8 -25
- package/dist/runner/scope.js +4 -8
- package/dist/runner/session.d.ts +18 -65
- package/dist/runner/session.js +15 -83
- package/dist/runner/snapshot-build.d.ts +2 -2
- package/dist/runner/snapshot-cache.d.ts +22 -74
- package/dist/runner/snapshot-cache.js +15 -107
- package/dist/runner/snapshot-inspect.d.ts +9 -13
- package/dist/runner/snapshot-inspect.js +48 -57
- package/dist/runner/snapshot-key.d.ts +9 -14
- package/dist/runner/snapshot-key.js +15 -22
- package/package.json +1 -1
- package/skills/read-run-output.md +8 -9
- package/dist/runner/snapshot-save.d.ts +0 -70
- package/dist/runner/snapshot-save.js +0 -160
- package/dist/runner/snapshot-start.d.ts +0 -25
- package/dist/runner/snapshot-start.js +0 -16
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { type ResourceReports, type RunOutcome, type RunRequest, type RunState } from "../core/index.ts";
|
|
3
|
-
import type { RunnerSave } from "../runner/index.ts";
|
|
4
3
|
import type { Row } from "../sdk/extension/index.ts";
|
|
5
4
|
import type { TestEvent } from "../sdk/run/launcher.ts";
|
|
6
5
|
import { type TestPlanFacts } from "./plan.ts";
|
|
@@ -55,59 +54,15 @@ declare const snapshotSchema: z.ZodObject<{
|
|
|
55
54
|
id: z.ZodString;
|
|
56
55
|
base: z.ZodString;
|
|
57
56
|
built: z.ZodBoolean;
|
|
58
|
-
|
|
59
|
-
head: z.ZodNullable<z.ZodString>;
|
|
60
|
-
kind: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
61
|
-
base: "base";
|
|
62
|
-
dev: "dev";
|
|
63
|
-
}>>>;
|
|
64
|
-
builtAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
65
|
-
builtBehind: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
57
|
+
builtBehind: z.ZodNullable<z.ZodNumber>;
|
|
66
58
|
}, z.core.$strip>;
|
|
67
|
-
/** Why a run whose command ended on its own started no save of a dev snapshot (`RunnerNoSaveReason`). */
|
|
68
|
-
export declare const noSaveReasonSchema: z.ZodEnum<{
|
|
69
|
-
"already-saved": "already-saved";
|
|
70
|
-
ci: "ci";
|
|
71
|
-
"command-failed": "command-failed";
|
|
72
|
-
"keep-sandbox": "keep-sandbox";
|
|
73
|
-
"no-save-flag": "no-save-flag";
|
|
74
|
-
"not-trusted": "not-trusted";
|
|
75
|
-
recipe: "recipe";
|
|
76
|
-
}>;
|
|
77
59
|
/**
|
|
78
60
|
* The runner snapshot a runner sandbox started from: its id, the base it is of, which the run's changes were uploaded
|
|
79
|
-
* on top of, whether the run built it or reused a cached one, and
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* snapshot), and how many commits HEAD has that its built-at commit lacks (`builtBehind`), each null when unknown or in
|
|
83
|
-
* a record written before it existed. A record written before storm required a snapshot's base to be the merge-base
|
|
84
|
-
* may still hold that base's count of commits behind the merge-base, which the schema drops as it reads.
|
|
61
|
+
* on top of and the commit it was built at, whether the run built it or reused a cached one, and how many commits HEAD
|
|
62
|
+
* has that its base lacks (`builtBehind`), null when the run state had no count. Version 5 records only base snapshots; storm does not read a version 4
|
|
63
|
+
* record, whose dev snapshot count may have been measured from another commit than its base.
|
|
85
64
|
*/
|
|
86
65
|
export type RunRecordSnapshot = Readonly<z.output<typeof snapshotSchema>>;
|
|
87
|
-
/**
|
|
88
|
-
* How saving the runner sandbox as a dev snapshot ended, as a `ran` outcome and `run.json` report it.
|
|
89
|
-
*/
|
|
90
|
-
export declare const saveSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
91
|
-
kind: z.ZodLiteral<"saved">;
|
|
92
|
-
snapshotId: z.ZodString;
|
|
93
|
-
base: z.ZodString;
|
|
94
|
-
branch: z.ZodNullable<z.ZodString>;
|
|
95
|
-
head: z.ZodString;
|
|
96
|
-
ms: z.ZodNumber;
|
|
97
|
-
sizeBytes: z.ZodNumber;
|
|
98
|
-
entryWritten: z.ZodBoolean;
|
|
99
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
100
|
-
kind: z.ZodLiteral<"failed">;
|
|
101
|
-
step: z.ZodEnum<{
|
|
102
|
-
"save-snapshot": "save-snapshot";
|
|
103
|
-
scrub: "scrub";
|
|
104
|
-
}>;
|
|
105
|
-
message: z.ZodString;
|
|
106
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
107
|
-
kind: z.ZodLiteral<"stopped">;
|
|
108
|
-
}, z.core.$strip>], "kind">;
|
|
109
|
-
/** How saving the runner sandbox as a dev snapshot ended. */
|
|
110
|
-
export type RunRecordSave = z.output<typeof saveSchema>;
|
|
111
66
|
declare const whereSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
112
67
|
kind: z.ZodLiteral<"unsandboxed">;
|
|
113
68
|
}, z.core.$strip>, z.ZodObject<{
|
|
@@ -124,55 +79,18 @@ declare const whereSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
124
79
|
id: z.ZodString;
|
|
125
80
|
base: z.ZodString;
|
|
126
81
|
built: z.ZodBoolean;
|
|
127
|
-
|
|
128
|
-
head: z.ZodNullable<z.ZodString>;
|
|
129
|
-
kind: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
130
|
-
base: "base";
|
|
131
|
-
dev: "dev";
|
|
132
|
-
}>>>;
|
|
133
|
-
builtAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
134
|
-
builtBehind: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
82
|
+
builtBehind: z.ZodNullable<z.ZodNumber>;
|
|
135
83
|
}, z.core.$strip>>;
|
|
136
84
|
keptUntil: z.ZodNullable<z.ZodString>;
|
|
137
|
-
|
|
138
|
-
kind: z.ZodLiteral<"saved">;
|
|
139
|
-
snapshotId: z.ZodString;
|
|
140
|
-
base: z.ZodString;
|
|
141
|
-
branch: z.ZodNullable<z.ZodString>;
|
|
142
|
-
head: z.ZodString;
|
|
143
|
-
ms: z.ZodNumber;
|
|
144
|
-
sizeBytes: z.ZodNumber;
|
|
145
|
-
entryWritten: z.ZodBoolean;
|
|
146
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
147
|
-
kind: z.ZodLiteral<"failed">;
|
|
148
|
-
step: z.ZodEnum<{
|
|
149
|
-
"save-snapshot": "save-snapshot";
|
|
150
|
-
scrub: "scrub";
|
|
151
|
-
}>;
|
|
152
|
-
message: z.ZodString;
|
|
153
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
154
|
-
kind: z.ZodLiteral<"stopped">;
|
|
155
|
-
}, z.core.$strip>], "kind">>;
|
|
156
|
-
uploadBytes: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
157
|
-
noSaveReason: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
158
|
-
"already-saved": "already-saved";
|
|
159
|
-
ci: "ci";
|
|
160
|
-
"command-failed": "command-failed";
|
|
161
|
-
"keep-sandbox": "keep-sandbox";
|
|
162
|
-
"no-save-flag": "no-save-flag";
|
|
163
|
-
"not-trusted": "not-trusted";
|
|
164
|
-
recipe: "recipe";
|
|
165
|
-
}>>>;
|
|
85
|
+
uploadBytes: z.ZodNullable<z.ZodNumber>;
|
|
166
86
|
}, z.core.$strip>], "kind">;
|
|
167
87
|
/**
|
|
168
88
|
* Where the command ran: on this machine (`unsandboxed`, with `--unsandboxed`), or in a runner sandbox (`runner`):
|
|
169
89
|
* the control plane team and project it runs in, its region, runtime and vCPUs, and the run's base, HEAD's merge-base
|
|
170
90
|
* with `baseRef`, all known as the run starts; then, once the run is over, the runner sandbox's name and the runner
|
|
171
91
|
* snapshot it started from, each null when the run stopped before it, when the runner sandbox's timeout stops it, as an
|
|
172
|
-
* ISO time, when the run kept it running (null when it stopped and deleted it), how
|
|
173
|
-
*
|
|
174
|
-
* ended on its own started no save (each null when unknown). A record written by an older storm can name a reused
|
|
175
|
-
* runner snapshot of an older base.
|
|
92
|
+
* ISO time, when the run kept it running (null when it stopped and deleted it), and how many bytes of changes the run
|
|
93
|
+
* uploaded (null when the run stopped before the upload).
|
|
176
94
|
*/
|
|
177
95
|
export type RunRecordWhere = Readonly<z.output<typeof whereSchema>>;
|
|
178
96
|
declare const gitSchema: z.ZodObject<{
|
|
@@ -191,7 +109,7 @@ export type RunRecordGit = Readonly<z.output<typeof gitSchema>>;
|
|
|
191
109
|
*/
|
|
192
110
|
export type RunRecordPlan = TestPlanFacts;
|
|
193
111
|
declare const runRecordSchema: z.ZodObject<{
|
|
194
|
-
version: z.ZodLiteral<
|
|
112
|
+
version: z.ZodLiteral<5>;
|
|
195
113
|
startedAt: z.ZodString;
|
|
196
114
|
cwd: z.ZodString;
|
|
197
115
|
configFile: z.ZodNullable<z.ZodString>;
|
|
@@ -225,45 +143,10 @@ declare const runRecordSchema: z.ZodObject<{
|
|
|
225
143
|
id: z.ZodString;
|
|
226
144
|
base: z.ZodString;
|
|
227
145
|
built: z.ZodBoolean;
|
|
228
|
-
|
|
229
|
-
head: z.ZodNullable<z.ZodString>;
|
|
230
|
-
kind: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
231
|
-
base: "base";
|
|
232
|
-
dev: "dev";
|
|
233
|
-
}>>>;
|
|
234
|
-
builtAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
235
|
-
builtBehind: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
146
|
+
builtBehind: z.ZodNullable<z.ZodNumber>;
|
|
236
147
|
}, z.core.$strip>>;
|
|
237
148
|
keptUntil: z.ZodNullable<z.ZodString>;
|
|
238
|
-
|
|
239
|
-
kind: z.ZodLiteral<"saved">;
|
|
240
|
-
snapshotId: z.ZodString;
|
|
241
|
-
base: z.ZodString;
|
|
242
|
-
branch: z.ZodNullable<z.ZodString>;
|
|
243
|
-
head: z.ZodString;
|
|
244
|
-
ms: z.ZodNumber;
|
|
245
|
-
sizeBytes: z.ZodNumber;
|
|
246
|
-
entryWritten: z.ZodBoolean;
|
|
247
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
248
|
-
kind: z.ZodLiteral<"failed">;
|
|
249
|
-
step: z.ZodEnum<{
|
|
250
|
-
"save-snapshot": "save-snapshot";
|
|
251
|
-
scrub: "scrub";
|
|
252
|
-
}>;
|
|
253
|
-
message: z.ZodString;
|
|
254
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
255
|
-
kind: z.ZodLiteral<"stopped">;
|
|
256
|
-
}, z.core.$strip>], "kind">>;
|
|
257
|
-
uploadBytes: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
258
|
-
noSaveReason: z.ZodDefault<z.ZodNullable<z.ZodEnum<{
|
|
259
|
-
"already-saved": "already-saved";
|
|
260
|
-
ci: "ci";
|
|
261
|
-
"command-failed": "command-failed";
|
|
262
|
-
"keep-sandbox": "keep-sandbox";
|
|
263
|
-
"no-save-flag": "no-save-flag";
|
|
264
|
-
"not-trusted": "not-trusted";
|
|
265
|
-
recipe: "recipe";
|
|
266
|
-
}>>>;
|
|
149
|
+
uploadBytes: z.ZodNullable<z.ZodNumber>;
|
|
267
150
|
}, z.core.$strip>], "kind">;
|
|
268
151
|
git: z.ZodNullable<z.ZodObject<{
|
|
269
152
|
branch: z.ZodNullable<z.ZodString>;
|
|
@@ -298,7 +181,7 @@ export type RunRecord = Readonly<Omit<z.output<typeof runRecordSchema>, "ended">
|
|
|
298
181
|
}>;
|
|
299
182
|
/** `run.json`'s text for `record`. */
|
|
300
183
|
export declare function runRecordText(record: RunRecord): string;
|
|
301
|
-
/** The run `text` records; undefined when there is no text, or it isn't a version
|
|
184
|
+
/** The run `text` records; undefined when there is no text, or it isn't a version 5 `run.json`. */
|
|
302
185
|
export declare function parseRunRecord(text: string | undefined): RunRecord | undefined;
|
|
303
186
|
/** The totals of `events`' final results; null without one. */
|
|
304
187
|
export declare function testTotals(events: readonly TestEvent[]): RunTestTotals | null;
|
|
@@ -318,8 +201,7 @@ export declare function startedWhere(run: RunRequest): RunRecordWhere;
|
|
|
318
201
|
/**
|
|
319
202
|
* `where` once the run is over, from the runner's final state: for a sandboxed run, the runner sandbox the run started,
|
|
320
203
|
* the runner snapshot it started from, which the run reused or built, when its timeout stops the runner sandbox it
|
|
321
|
-
* kept running
|
|
322
|
-
* kept no runner sandbox, or saved none.
|
|
204
|
+
* kept running. Each is null when the run stopped before it, or kept no runner sandbox.
|
|
323
205
|
*/
|
|
324
|
-
export declare function endedWhere(where: RunRecordWhere, runner: RunState["runner"]
|
|
206
|
+
export declare function endedWhere(where: RunRecordWhere, runner: RunState["runner"]): RunRecordWhere;
|
|
325
207
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// What a run records about itself in its run directory's `run.json`, which `storm runs` reads back: written as
|
|
2
2
|
// the run directory opens, then replaced with how the run ended once it is over. The run directory gateway stores the
|
|
3
|
-
// text; this file owns its shape, version
|
|
3
|
+
// text; this file owns its shape, version 5, and what goes in it: where the command runs, as the run starts and
|
|
4
4
|
// once it is over, and how the run ended. Reading it back asks the resource definition set nothing: each resource
|
|
5
5
|
// instance's facts read as recorded, beside its definition's name, and `runs show` lists the rows storm rendered for
|
|
6
6
|
// them when the run ended, so a past run reads the same after a resource definition is renamed or its extension
|
|
@@ -27,56 +27,8 @@ const snapshotSchema = z.object({
|
|
|
27
27
|
id: z.string(),
|
|
28
28
|
base: z.string(),
|
|
29
29
|
built: z.boolean(),
|
|
30
|
-
|
|
31
|
-
head: z.string().nullable(),
|
|
32
|
-
// A record written before these existed lacks them, and reads each as null.
|
|
33
|
-
kind: z.enum(["base", "dev"]).nullable().default(null),
|
|
34
|
-
builtAt: z.string().nullable().default(null),
|
|
35
|
-
builtBehind: z.number().nullable().default(null),
|
|
30
|
+
builtBehind: z.number().nullable(),
|
|
36
31
|
});
|
|
37
|
-
/** Why a run whose command ended on its own started no save of a dev snapshot (`RunnerNoSaveReason`). */
|
|
38
|
-
export const noSaveReasonSchema = z.enum([
|
|
39
|
-
"no-save-flag",
|
|
40
|
-
"recipe",
|
|
41
|
-
"keep-sandbox",
|
|
42
|
-
"ci",
|
|
43
|
-
"not-trusted",
|
|
44
|
-
"command-failed",
|
|
45
|
-
"already-saved",
|
|
46
|
-
]);
|
|
47
|
-
/**
|
|
48
|
-
* How saving the runner sandbox as a dev snapshot ended, as a `ran` outcome and `run.json` report it.
|
|
49
|
-
*/
|
|
50
|
-
export const saveSchema = z.discriminatedUnion("kind", [
|
|
51
|
-
z.object({
|
|
52
|
-
/** It saved the runner sandbox as a dev snapshot. */
|
|
53
|
-
kind: z.literal("saved"),
|
|
54
|
-
/** The runner snapshot it saved. */
|
|
55
|
-
snapshotId: z.string(),
|
|
56
|
-
/** The base it is of: the base of the runner snapshot the run started from, a full SHA. */
|
|
57
|
-
base: z.string(),
|
|
58
|
-
/** HEAD's local branch as the run started; null when HEAD was detached. */
|
|
59
|
-
branch: z.string().nullable(),
|
|
60
|
-
/** HEAD's commit as the run started, a full SHA, which the dev snapshot was built at. */
|
|
61
|
-
head: z.string(),
|
|
62
|
-
/** How long the save took, in milliseconds, from the scrub's start until the snapshot was saved. */
|
|
63
|
-
ms: z.number(),
|
|
64
|
-
/** The snapshot's size in bytes. */
|
|
65
|
-
sizeBytes: z.number(),
|
|
66
|
-
/** Whether the runner snapshot cache recorded it; a later run starts from it only when it did. */
|
|
67
|
-
entryWritten: z.boolean(),
|
|
68
|
-
}),
|
|
69
|
-
z.object({
|
|
70
|
-
/** It didn't save: the scrub or the save failed. */
|
|
71
|
-
kind: z.literal("failed"),
|
|
72
|
-
step: z.enum(["scrub", "save-snapshot"]),
|
|
73
|
-
message: z.string(),
|
|
74
|
-
}),
|
|
75
|
-
z.object({
|
|
76
|
-
/** It didn't save, or recorded nothing: a signal stopped it. */
|
|
77
|
-
kind: z.literal("stopped"),
|
|
78
|
-
}),
|
|
79
|
-
]);
|
|
80
32
|
const whereSchema = z.discriminatedUnion("kind", [
|
|
81
33
|
z.object({ kind: z.literal("unsandboxed") }),
|
|
82
34
|
z.object({
|
|
@@ -91,15 +43,12 @@ const whereSchema = z.discriminatedUnion("kind", [
|
|
|
91
43
|
sandbox: z.string().nullable(),
|
|
92
44
|
snapshot: snapshotSchema.nullable(),
|
|
93
45
|
keptUntil: z.string().nullable(),
|
|
94
|
-
|
|
95
|
-
// A record written before these existed lacks them, and reads each as null.
|
|
96
|
-
uploadBytes: z.number().nullable().default(null),
|
|
97
|
-
noSaveReason: noSaveReasonSchema.nullable().default(null),
|
|
46
|
+
uploadBytes: z.number().nullable(),
|
|
98
47
|
}),
|
|
99
48
|
]);
|
|
100
49
|
const gitSchema = z.object({ branch: z.string().nullable(), commit: z.string(), dirty: z.boolean() });
|
|
101
50
|
const runRecordSchema = z.object({
|
|
102
|
-
version: z.literal(
|
|
51
|
+
version: z.literal(5),
|
|
103
52
|
startedAt: z.string(),
|
|
104
53
|
cwd: z.string(),
|
|
105
54
|
configFile: z.string().nullable(),
|
|
@@ -114,7 +63,7 @@ const runRecordSchema = z.object({
|
|
|
114
63
|
export function runRecordText(record) {
|
|
115
64
|
return JSON.stringify(record);
|
|
116
65
|
}
|
|
117
|
-
/** The run `text` records; undefined when there is no text, or it isn't a version
|
|
66
|
+
/** The run `text` records; undefined when there is no text, or it isn't a version 5 `run.json`. */
|
|
118
67
|
export function parseRunRecord(text) {
|
|
119
68
|
if (text === undefined)
|
|
120
69
|
return undefined;
|
|
@@ -191,18 +140,15 @@ export function startedWhere(run) {
|
|
|
191
140
|
sandbox: null,
|
|
192
141
|
snapshot: null,
|
|
193
142
|
keptUntil: null,
|
|
194
|
-
save: null,
|
|
195
143
|
uploadBytes: null,
|
|
196
|
-
noSaveReason: null,
|
|
197
144
|
};
|
|
198
145
|
}
|
|
199
146
|
/**
|
|
200
147
|
* `where` once the run is over, from the runner's final state: for a sandboxed run, the runner sandbox the run started,
|
|
201
148
|
* the runner snapshot it started from, which the run reused or built, when its timeout stops the runner sandbox it
|
|
202
|
-
* kept running
|
|
203
|
-
* kept no runner sandbox, or saved none.
|
|
149
|
+
* kept running. Each is null when the run stopped before it, or kept no runner sandbox.
|
|
204
150
|
*/
|
|
205
|
-
export function endedWhere(where, runner
|
|
151
|
+
export function endedWhere(where, runner) {
|
|
206
152
|
if (where.kind === "unsandboxed")
|
|
207
153
|
return where;
|
|
208
154
|
const snapshot = runner?.snapshot;
|
|
@@ -215,15 +161,9 @@ export function endedWhere(where, runner, save) {
|
|
|
215
161
|
id: snapshot.id,
|
|
216
162
|
base: snapshot.base,
|
|
217
163
|
built: snapshot.kind === "built",
|
|
218
|
-
|
|
219
|
-
head: snapshot.head,
|
|
220
|
-
kind: snapshot.snapshot.kind,
|
|
221
|
-
builtAt: snapshot.snapshot.builtAt,
|
|
222
|
-
builtBehind: snapshot.snapshot.builtBehind,
|
|
164
|
+
builtBehind: snapshot.builtBehind,
|
|
223
165
|
},
|
|
224
166
|
keptUntil: runner?.kept?.stopsAt ?? null,
|
|
225
|
-
save,
|
|
226
167
|
uploadBytes: runner?.uploadBytes ?? null,
|
|
227
|
-
noSaveReason: runner?.noSave ?? null,
|
|
228
168
|
};
|
|
229
169
|
}
|
|
@@ -1,66 +1,45 @@
|
|
|
1
1
|
import type { RunnerContext } from "./context.ts";
|
|
2
2
|
import type { RunnerFailure, RunnerProgress } from "./events.ts";
|
|
3
3
|
import type { CheckoutHead, RunnerSnapshotCacheFailure, RunnerSnapshotEntry, SandboxAccess } from "./gateways.ts";
|
|
4
|
-
import
|
|
5
|
-
import type { CheckedRecipe
|
|
4
|
+
import type { PrepareRunnerOutcome, RunnerPrepareContext } from "./prepare.ts";
|
|
5
|
+
import type { CheckedRecipe } from "./recipe.ts";
|
|
6
6
|
import { type RunnerScopeFacts } from "./scope.ts";
|
|
7
7
|
import type { RunnerSecrets } from "./secrets.ts";
|
|
8
8
|
import { type BaseSnapshotPlan } from "./snapshot-build.ts";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* What `storm snapshots build` builds: for this checkout (`checkout`), what the next run starts from, a base snapshot
|
|
12
|
-
* when none fits and then a dev snapshot at HEAD's commit; or only a base snapshot at the commit `ref` names (`base`).
|
|
13
|
-
* `full` uses nothing from the cache.
|
|
14
|
-
*/
|
|
15
|
-
export type SnapshotBuildMode = {
|
|
16
|
-
readonly kind: "checkout";
|
|
17
|
-
readonly full: boolean;
|
|
18
|
-
} | {
|
|
19
|
-
readonly kind: "base";
|
|
20
|
-
readonly ref: string;
|
|
21
|
-
readonly full: boolean;
|
|
22
|
-
};
|
|
23
|
-
/** What `prepareSnapshotBuild` checks: where, which recipe, the run `vcpus` is called with, and what to build. */
|
|
24
|
-
export interface SnapshotBuildRequest<Run> {
|
|
9
|
+
/** What `prepareSnapshotBuild` checks: where, which recipe, and what to build. */
|
|
10
|
+
export interface SnapshotBuildRequest {
|
|
25
11
|
/** The directory the command started in, inside the checkout. */
|
|
26
12
|
readonly cwd: string;
|
|
27
|
-
readonly recipe: CheckedRecipe
|
|
28
|
-
/**
|
|
29
|
-
readonly
|
|
30
|
-
|
|
13
|
+
readonly recipe: CheckedRecipe;
|
|
14
|
+
/** The ref `--base` names; undefined builds at the merge-base. */
|
|
15
|
+
readonly ref: string | undefined;
|
|
16
|
+
/** `--full`: build whatever the cache holds. */
|
|
17
|
+
readonly full: boolean;
|
|
31
18
|
}
|
|
32
19
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
20
|
+
* A build, checked on this machine: the base snapshot it builds (`plan`), HEAD, whose `dirty` says the working tree
|
|
21
|
+
* has uncommitted changes, which a base snapshot doesn't hold, the ref `--base` named (null for the merge-base), HEAD's
|
|
22
|
+
* merge-base and its ref (null for a `--base` build in a checkout where no base ref shares history with HEAD), whether
|
|
23
|
+
* the commit it builds at is that merge-base (`atMergeBase`: a run here starts only from a snapshot at its merge-base,
|
|
24
|
+
* though a run in another checkout, or after a later merge-base, still might), and the base snapshots of `plan`'s base
|
|
25
|
+
* and key the cache holds with more than an hour left (`cached`, before the team and project filter).
|
|
36
26
|
*/
|
|
37
|
-
export
|
|
38
|
-
readonly kind: "uncommitted";
|
|
39
|
-
} | {
|
|
40
|
-
readonly kind: "not-on-base-ref";
|
|
41
|
-
readonly refs: readonly string[];
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* A build, checked on this machine. `checkout`: the run's own local checks (`prepareRunner`); unless its
|
|
45
|
-
* `devSnapshots` is `reuse`, it says why the build saves no dev snapshot (the recipe doesn't trust dev snapshots, or
|
|
46
|
-
* reuses none, so no run would start from one). `base`: the commit `ref` names, its snapshot steps and key, HEAD, the base snapshots of
|
|
47
|
-
* that commit the cache holds with more than an hour left (`cached`, before the team and project filter), and what to
|
|
48
|
-
* warn about.
|
|
49
|
-
*/
|
|
50
|
-
export type PreparedSnapshotBuild = {
|
|
51
|
-
readonly kind: "checkout";
|
|
52
|
-
readonly prepared: PreparedRunner;
|
|
53
|
-
readonly full: boolean;
|
|
54
|
-
} | {
|
|
55
|
-
readonly kind: "base";
|
|
27
|
+
export interface PreparedSnapshotBuild {
|
|
56
28
|
readonly plan: BaseSnapshotPlan;
|
|
57
|
-
readonly ref: string;
|
|
58
29
|
readonly head: CheckoutHead;
|
|
30
|
+
readonly ref: string | null;
|
|
31
|
+
readonly mergeBase: {
|
|
32
|
+
readonly commit: string;
|
|
33
|
+
readonly ref: string;
|
|
34
|
+
} | null;
|
|
35
|
+
readonly atMergeBase: boolean;
|
|
59
36
|
readonly cached: readonly RunnerSnapshotEntry[];
|
|
60
37
|
readonly full: boolean;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* How a build's local checks ended: a run's refusals, but `submodules`'s and `invalid-recipe`'s and `checkout-failed`'s
|
|
41
|
+
* that the build shares, or `ref-not-found` when `--base` names no local commit.
|
|
42
|
+
*/
|
|
64
43
|
export type PrepareSnapshotBuildOutcome = {
|
|
65
44
|
readonly kind: "ok";
|
|
66
45
|
readonly build: PreparedSnapshotBuild;
|
|
@@ -71,12 +50,12 @@ export type PrepareSnapshotBuildOutcome = {
|
|
|
71
50
|
readonly ref: string;
|
|
72
51
|
};
|
|
73
52
|
/**
|
|
74
|
-
* Runs a build's local checks, before anything is minted or started
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* base
|
|
53
|
+
* Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
|
|
54
|
+
* refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
|
|
55
|
+
* `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
|
|
56
|
+
* and, when it builds at the merge-base, HEAD's count of commits after it. It never mints, acquires or creates, and removes no cache file.
|
|
78
57
|
*/
|
|
79
|
-
export declare function prepareSnapshotBuild
|
|
58
|
+
export declare function prepareSnapshotBuild(context: RunnerPrepareContext, request: SnapshotBuildRequest): Promise<PrepareSnapshotBuildOutcome>;
|
|
80
59
|
/** What `buildSnapshots` is handed: the checked build, where its sandboxes run, who starts them, and the secrets. */
|
|
81
60
|
export interface BuildSnapshotsRequest {
|
|
82
61
|
readonly build: PreparedSnapshotBuild;
|
|
@@ -90,89 +69,46 @@ export interface BuildSnapshotsRequest {
|
|
|
90
69
|
/**
|
|
91
70
|
* How a build ended, before its sandbox scope closed.
|
|
92
71
|
*
|
|
93
|
-
* - `up-to-date`:
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* - `
|
|
97
|
-
* `devSnapshot` the dev snapshot it saved and cached, null when it saved none.
|
|
98
|
-
* - `dev-snapshot-not-saved`: the scrub or the save of the dev snapshot failed (`step`), with `message`.
|
|
99
|
-
* - `not-cached`: it saved `snapshot`, the snapshot the build ends with (the dev snapshot, or the base snapshot of a
|
|
100
|
-
* build that saves no dev snapshot), but the cache couldn't write its entry (`failure`), so no run finds it.
|
|
101
|
-
* - `snapshot-gone`: starting from cached runner snapshot `entry` answered that it is gone, so its entry was removed;
|
|
102
|
-
* `removal` is why it couldn't be, if it couldn't.
|
|
72
|
+
* - `up-to-date`: the cache holds `snapshot`, a base snapshot at the commit for the access's team and project, so
|
|
73
|
+
* nothing started.
|
|
74
|
+
* - `built`: it built `snapshot` in `ms` (`sizeBytes`), and the cache recorded it.
|
|
75
|
+
* - `not-cached`: it built `snapshot`, but the cache couldn't write its entry (`failure`), so no run finds it.
|
|
103
76
|
* - `failed`: a step, a Sandbox call or the checkout failed.
|
|
104
|
-
* - `aborted`: the signal aborted
|
|
105
|
-
*
|
|
106
|
-
* replacement still drops the dev snapshots on the base snapshot it replaced before the build stops.
|
|
107
|
-
*
|
|
108
|
-
* In `built`, `dev-snapshot-not-saved`, `not-cached`, and `aborted`, `baseSnapshot` is the base snapshot this build
|
|
109
|
-
* built, with whether the cache wrote its entry (`SavedBaseSnapshot`), null when it built none. In `built`,
|
|
110
|
-
* `not-cached`, and `aborted`, `dropped` is what `--full` dropped, null when it dropped nothing: without `--full`, or
|
|
111
|
-
* when the base snapshot it built isn't cached, so the one it replaces stays usable, and so do the dev snapshots built
|
|
112
|
-
* on it.
|
|
77
|
+
* - `aborted`: the signal aborted. A base snapshot's save runs to its end once started, so a signal during it still
|
|
78
|
+
* leaves a saved snapshot, which `snapshot` names with whether the cache wrote its entry; null when it saved none.
|
|
113
79
|
*/
|
|
114
80
|
export type SnapshotBuildEnd = {
|
|
115
81
|
readonly kind: "up-to-date";
|
|
116
82
|
readonly snapshot: RunnerSnapshotEntry;
|
|
117
83
|
} | {
|
|
118
84
|
readonly kind: "built";
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly dropped: DevSnapshotDrop | null;
|
|
123
|
-
} | {
|
|
124
|
-
readonly kind: "dev-snapshot-not-saved";
|
|
125
|
-
readonly step: "scrub" | "save-snapshot";
|
|
126
|
-
readonly message: string;
|
|
127
|
-
readonly baseSnapshot: SavedBaseSnapshot | null;
|
|
85
|
+
readonly snapshot: RunnerSnapshotEntry;
|
|
86
|
+
readonly ms: number;
|
|
87
|
+
readonly sizeBytes: number;
|
|
128
88
|
} | {
|
|
129
89
|
readonly kind: "not-cached";
|
|
130
90
|
readonly snapshot: RunnerSnapshotEntry;
|
|
131
91
|
readonly failure: RunnerSnapshotCacheFailure;
|
|
132
|
-
readonly baseSnapshot: SavedBaseSnapshot | null;
|
|
133
|
-
readonly dropped: DevSnapshotDrop | null;
|
|
134
|
-
} | {
|
|
135
|
-
readonly kind: "snapshot-gone";
|
|
136
|
-
readonly entry: RunnerSnapshotEntry;
|
|
137
|
-
readonly removal: RunnerSnapshotCacheFailure | undefined;
|
|
138
92
|
} | {
|
|
139
93
|
readonly kind: "failed";
|
|
140
94
|
readonly failure: RunnerFailure;
|
|
141
95
|
} | {
|
|
142
96
|
readonly kind: "aborted";
|
|
143
|
-
readonly
|
|
144
|
-
|
|
97
|
+
readonly snapshot: {
|
|
98
|
+
readonly entry: RunnerSnapshotEntry;
|
|
99
|
+
readonly cached: boolean;
|
|
100
|
+
} | null;
|
|
145
101
|
};
|
|
146
|
-
/** A base snapshot a build built and saved: its entry, and whether the cache wrote it, so a run finds it. */
|
|
147
|
-
export interface SavedBaseSnapshot {
|
|
148
|
-
readonly entry: RunnerSnapshotEntry;
|
|
149
|
-
readonly cached: boolean;
|
|
150
|
-
}
|
|
151
|
-
/** A dev snapshot a build saved: the cache entry it wrote, how long the save took, and the snapshot's size. */
|
|
152
|
-
export interface SavedDevSnapshot {
|
|
153
|
-
readonly entry: RunnerSnapshotEntry;
|
|
154
|
-
readonly ms: number;
|
|
155
|
-
readonly sizeBytes: number;
|
|
156
|
-
}
|
|
157
102
|
/** How a build ended (`SnapshotBuildEnd`), with what closing its sandbox scope left (`cleanup`). */
|
|
158
103
|
export type SnapshotBuildOutcome = SnapshotBuildEnd & {
|
|
159
104
|
readonly cleanup: RunnerScopeFacts;
|
|
160
105
|
};
|
|
161
106
|
/**
|
|
162
|
-
* Builds
|
|
163
|
-
* keeping none.
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* saves no dev snapshot, any snapshot, it is up to date. Otherwise it obtains the start (`obtainSnapshot`), building a
|
|
168
|
-
* base snapshot at the merge-base when it chose to; under `full`, once the cache holds the new base snapshot's entry,
|
|
169
|
-
* it then drops the dev snapshots built on the base snapshot it replaced (`dropDevSnapshotsOn`), before any runner
|
|
170
|
-
* sandbox starts. A build that saves no dev snapshot ends there. Otherwise it readies a runner sandbox on the start
|
|
171
|
-
* (`readyRunner`) and saves it as a dev snapshot at HEAD's commit (`saveDevSnapshot`). For `--base`: a cached base
|
|
172
|
-
* snapshot of the commit for the access's team and project is up to date, unless `full`; otherwise it builds one, and
|
|
173
|
-
* under `full`, once its entry is cached, drops the dev snapshots built on the one it replaced. A base snapshot's save
|
|
174
|
-
* isn't stopped by the signal, so after it the build checks the signal once, after any drop, and ends `aborted` with
|
|
175
|
-
* what it saved.
|
|
107
|
+
* Builds the checked build's base snapshot, reporting to `progress`, and closes every sandbox it started however it
|
|
108
|
+
* ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
|
|
109
|
+
* `full`, which builds a new one that replaces its cache entry. `signal` stops it in any stage: it says so, then
|
|
110
|
+
* closes the scope at once. A base snapshot's save isn't stopped by the signal, so after it the build checks the signal
|
|
111
|
+
* once and ends `aborted` with what it saved.
|
|
176
112
|
*/
|
|
177
113
|
export declare function buildSnapshots(context: RunnerContext, request: BuildSnapshotsRequest, control: {
|
|
178
114
|
readonly signal: AbortSignal;
|