@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.
Files changed (96) hide show
  1. package/dist/bin/storm.js +1 -1
  2. package/dist/build-info.js +1 -1
  3. package/dist/chunks/{chunk-4XT5RC5T.js → chunk-2NZXL6OH.js} +6 -42
  4. package/dist/chunks/{chunk-ISGQJIQM.js → chunk-5UMJNVKT.js} +1 -1
  5. package/dist/chunks/{chunk-FSP3SJ35.js → chunk-6EQKA7LI.js} +16 -46
  6. package/dist/chunks/{chunk-Y3BUNNRG.js → chunk-AX4EQZUS.js} +4 -4
  7. package/dist/chunks/{chunk-RYRJNHL7.js → chunk-DOFB2ACU.js} +3 -9
  8. package/dist/chunks/{chunk-SXW6XN4R.js → chunk-EGNP3S6C.js} +3 -3
  9. package/dist/chunks/{chunk-FK4RLDEK.js → chunk-N7E6DAUE.js} +1 -1
  10. package/dist/chunks/{chunk-U7M3ZB3Z.js → chunk-Q4TKRILH.js} +33 -167
  11. package/dist/chunks/{chunk-TMQQYHUX.js → chunk-RTILVSYQ.js} +1 -1
  12. package/dist/chunks/{chunk-7D6LC5JY.js → chunk-X4WBJIOF.js} +7 -39
  13. package/dist/chunks/{chunk-TEEZL3GA.js → chunk-YGS5VRQT.js} +11 -68
  14. package/dist/chunks/{chunk-ODQHQJLE.js → chunk-ZDJLKF2G.js} +742 -1117
  15. package/dist/chunks/{live-app-AZ5N5HBD.js → live-app-QFHS54SX.js} +4 -4
  16. package/dist/commands/exec/command.d.ts +2 -90
  17. package/dist/commands/exec/command.js +10 -10
  18. package/dist/commands/exec/define-run-command.d.ts +2 -90
  19. package/dist/commands/exec/live-view.js +18 -22
  20. package/dist/commands/exec/outcomes.d.ts +2 -106
  21. package/dist/commands/exec/outcomes.js +4 -35
  22. package/dist/commands/exec/progress.d.ts +3 -19
  23. package/dist/commands/exec/progress.js +16 -60
  24. package/dist/commands/exec/run-command.d.ts +4 -23
  25. package/dist/commands/exec/run-command.js +5 -79
  26. package/dist/commands/exec/run-metadata.d.ts +0 -6
  27. package/dist/commands/exec/run-metadata.js +2 -8
  28. package/dist/commands/exec/snapshot-text.d.ts +7 -16
  29. package/dist/commands/exec/snapshot-text.js +9 -49
  30. package/dist/commands/exec/view.js +2 -12
  31. package/dist/commands/playwright/command.d.ts +2 -90
  32. package/dist/commands/playwright/command.js +11 -11
  33. package/dist/commands/runs/facts.d.ts +1 -37
  34. package/dist/commands/runs/facts.js +4 -36
  35. package/dist/commands/runs/list/command.d.ts +0 -72
  36. package/dist/commands/runs/list/command.js +5 -5
  37. package/dist/commands/runs/list/outcomes.d.ts +0 -36
  38. package/dist/commands/runs/logs/command.js +5 -5
  39. package/dist/commands/runs/show/command.d.ts +0 -72
  40. package/dist/commands/runs/show/command.js +13 -40
  41. package/dist/commands/runs/show/metadata.js +1 -1
  42. package/dist/commands/runs/show/outcomes.d.ts +0 -36
  43. package/dist/commands/runs/show/outcomes.js +8 -42
  44. package/dist/commands/snapshots/build/command.d.ts +14 -411
  45. package/dist/commands/snapshots/build/command.js +56 -231
  46. package/dist/commands/snapshots/build/metadata.js +10 -7
  47. package/dist/commands/snapshots/build/outcomes.d.ts +11 -241
  48. package/dist/commands/snapshots/build/outcomes.js +29 -196
  49. package/dist/commands/snapshots/list/command.d.ts +2 -36
  50. package/dist/commands/snapshots/list/command.js +17 -53
  51. package/dist/commands/snapshots/list/metadata.js +1 -1
  52. package/dist/commands/snapshots/list/outcomes.d.ts +2 -37
  53. package/dist/commands/snapshots/list/outcomes.js +13 -53
  54. package/dist/commands/vitest/command.d.ts +2 -90
  55. package/dist/commands/vitest/command.js +11 -11
  56. package/dist/core/events.d.ts +5 -6
  57. package/dist/core/run-state.d.ts +7 -29
  58. package/dist/core/run-state.js +3 -26
  59. package/dist/core/run.d.ts +6 -14
  60. package/dist/core/run.js +17 -28
  61. package/dist/extensions/testserver/commands/pool/create/command.js +1 -1
  62. package/dist/run-directory/index.d.ts +1 -1
  63. package/dist/run-directory/index.js +0 -1
  64. package/dist/run-directory/recording.js +2 -2
  65. package/dist/run-directory/run-record.d.ts +14 -132
  66. package/dist/run-directory/run-record.js +8 -68
  67. package/dist/runner/build-snapshots.d.ts +50 -114
  68. package/dist/runner/build-snapshots.js +70 -159
  69. package/dist/runner/events.d.ts +4 -88
  70. package/dist/runner/gateways.d.ts +5 -23
  71. package/dist/runner/index.d.ts +5 -6
  72. package/dist/runner/index.js +1 -1
  73. package/dist/runner/live/snapshot-records.js +7 -18
  74. package/dist/runner/prepare.d.ts +11 -22
  75. package/dist/runner/prepare.js +6 -17
  76. package/dist/runner/ready.d.ts +16 -45
  77. package/dist/runner/ready.js +34 -59
  78. package/dist/runner/recipe.d.ts +0 -44
  79. package/dist/runner/recipe.js +0 -41
  80. package/dist/runner/scope.d.ts +8 -25
  81. package/dist/runner/scope.js +4 -8
  82. package/dist/runner/session.d.ts +18 -65
  83. package/dist/runner/session.js +15 -83
  84. package/dist/runner/snapshot-build.d.ts +2 -2
  85. package/dist/runner/snapshot-cache.d.ts +22 -74
  86. package/dist/runner/snapshot-cache.js +15 -107
  87. package/dist/runner/snapshot-inspect.d.ts +9 -13
  88. package/dist/runner/snapshot-inspect.js +48 -57
  89. package/dist/runner/snapshot-key.d.ts +9 -14
  90. package/dist/runner/snapshot-key.js +15 -22
  91. package/package.json +1 -1
  92. package/skills/read-run-output.md +8 -9
  93. package/dist/runner/snapshot-save.d.ts +0 -70
  94. package/dist/runner/snapshot-save.js +0 -160
  95. package/dist/runner/snapshot-start.d.ts +0 -25
  96. package/dist/runner/snapshot-start.js +0 -16
@@ -1,35 +1,21 @@
1
- // `storm snapshots build`: building what the runner snapshot cache lacks for a checkout, with no run. It owns its
2
- // sandbox scope from its first stage to its end, as a run's runner session does, and reuses a run's stages: the choice
3
- // of what to start from, obtaining it, readying the runner sandbox, and the dev snapshot save. It acquires no
4
- // resource, runs no command, and keeps no sandbox.
5
- import { prepareRunner } from "./prepare.js";
6
- import { obtainSnapshot, readyRunner } from "./ready.js";
1
+ // `storm snapshots build`: building one base snapshot that the runner snapshot cache lacks, with no run: at the
2
+ // merge-base by default, or at the commit `--base <ref>` names, which a run starts from only once that commit is its
3
+ // merge-base. It owns its sandbox scope from its first stage to its end, as a run's runner session does. It
4
+ // acquires no resource, runs no command, and keeps no sandbox.
5
+ import { resolveBase } from "./base.js";
7
6
  import { runnerSandboxScope } from "./scope.js";
8
7
  import { buildSnapshot } from "./snapshot-build.js";
9
- import { dropDevSnapshotsOn, hasTimeLeft, isDevEntry } from "./snapshot-cache.js";
8
+ import { hasTimeLeft } from "./snapshot-cache.js";
10
9
  import { snapshotStepsAt } from "./snapshot-key.js";
11
- import { saveDevSnapshot } from "./snapshot-save.js";
12
- import { chooseSnapshotStart } from "./snapshot-start.js";
13
10
  /**
14
- * Runs a build's local checks, before anything is minted or started. For this checkout, they are a run's
15
- * (`prepareRunner`), reading dev snapshot candidates as the recipe allows. For `--base`, they are the repository's
16
- * root, HEAD, the submodule refusal, the commit the ref resolves to locally, its snapshot steps and key, the cache's
17
- * base snapshots of it, and the warnings. It never mints, acquires or creates.
11
+ * Runs a build's local checks, before anything is minted or started: the repository's root, HEAD, the submodule
12
+ * refusal, HEAD's merge-base (`resolveBase`, which refuses with `no-base-ref` only without `--base`), the commit
13
+ * `--base` resolves to locally, the snapshot steps and key at the commit it builds, the cache's base snapshots of it,
14
+ * 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.
18
15
  */
19
16
  export async function prepareSnapshotBuild(context, request) {
20
- const { recipe, mode } = request;
21
- if (mode.kind === "checkout") {
22
- const prepared = await prepareRunner(context, {
23
- cwd: request.cwd,
24
- recipe,
25
- vcpusRun: request.vcpusRun,
26
- reuseDevSnapshots: recipe.reuseDevSnapshot,
27
- });
28
- if (prepared.kind !== "ok")
29
- return prepared;
30
- return { kind: "ok", build: { kind: "checkout", prepared: prepared.prepared, full: mode.full } };
31
- }
32
17
  const { checkout } = context;
18
+ const { recipe, ref } = request;
33
19
  const root = await checkout.repositoryRoot({ cwd: request.cwd });
34
20
  if (!root.ok)
35
21
  return { kind: "checkout-failed", failure: root.failure };
@@ -37,47 +23,53 @@ export async function prepareSnapshotBuild(context, request) {
37
23
  const head = await checkout.head({ repoRoot });
38
24
  if (!head.ok)
39
25
  return { kind: "checkout-failed", failure: head.failure };
26
+ const resolved = await resolveBase(checkout, { repoRoot, baseRefs: recipe.baseRefs });
27
+ if (resolved.kind === "failed")
28
+ return { kind: "checkout-failed", failure: resolved.failure };
29
+ const mergeBase = resolved.kind === "resolved" ? { commit: resolved.base, ref: resolved.ref } : null;
40
30
  const submodules = await checkout.submodules({ repoRoot });
41
31
  if (!submodules.ok)
42
32
  return { kind: "checkout-failed", failure: submodules.failure };
43
33
  if (submodules.value.length > 0)
44
34
  return { kind: "submodules", paths: [...submodules.value] };
45
- const resolved = await checkout.resolveCommit({ repoRoot, ref: mode.ref });
46
- if (!resolved.ok)
47
- return { kind: "checkout-failed", failure: resolved.failure };
48
- if (resolved.value === null)
49
- return { kind: "ref-not-found", ref: mode.ref };
50
- const base = resolved.value;
35
+ let base;
36
+ if (ref === undefined) {
37
+ if (resolved.kind !== "resolved")
38
+ return resolved;
39
+ base = resolved.base;
40
+ }
41
+ else {
42
+ const commit = await checkout.resolveCommit({ repoRoot, ref });
43
+ if (!commit.ok)
44
+ return { kind: "checkout-failed", failure: commit.failure };
45
+ if (commit.value === null)
46
+ return { kind: "ref-not-found", ref };
47
+ base = commit.value;
48
+ }
51
49
  const steps = await snapshotStepsAt(checkout, { repoRoot, base, recipe });
52
50
  if (!steps.ok)
53
51
  return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
54
52
  // An unreadable cache holds nothing to reuse: the build goes on, and builds.
55
53
  const listed = await context.runnerSnapshots.listEntries();
56
54
  const now = context.clock.now();
57
- const cached = (listed.ok ? listed.value.entries : []).filter((entry) => !isDevEntry(entry) &&
58
- entry.base === base &&
55
+ const cached = (listed.ok ? listed.value.entries : []).filter((entry) => entry.base === base &&
59
56
  entry.recipeName === recipe.name &&
60
57
  entry.region === recipe.region &&
61
58
  entry.runtime === recipe.runtime &&
62
59
  entry.snapshotKey === steps.key &&
63
60
  hasTimeLeft(entry, now));
64
- const warnings = [];
65
- if (head.value.dirty)
66
- warnings.push({ kind: "uncommitted" });
67
- let onBaseRef = false;
68
- for (const ref of recipe.baseRefs) {
69
- const contained = await checkout.contains({ repoRoot, ancestor: base, descendant: ref });
70
- if (contained.ok && contained.value)
71
- onBaseRef = true;
61
+ const atMergeBase = base === mergeBase?.commit;
62
+ // The built snapshot's count behind HEAD, for a build at the merge-base, the one snapshot a run here starts from.
63
+ let commitsAfterBase = null;
64
+ if (atMergeBase) {
65
+ const counted = await checkout.commitCount({ repoRoot, from: base, to: "HEAD" });
66
+ if (!counted.ok)
67
+ return { kind: "checkout-failed", failure: counted.failure };
68
+ commitsAfterBase = counted.value;
72
69
  }
73
- if (!onBaseRef)
74
- warnings.push({ kind: "not-on-base-ref", refs: recipe.baseRefs });
75
- const inHistory = await checkout.contains({ repoRoot, ancestor: base, descendant: "HEAD" });
76
- const afterBase = inHistory.ok && inHistory.value ? await checkout.commitCount({ repoRoot, from: base, to: "HEAD" }) : undefined;
77
70
  return {
78
71
  kind: "ok",
79
72
  build: {
80
- kind: "base",
81
73
  plan: {
82
74
  recipe,
83
75
  repoRoot,
@@ -85,37 +77,27 @@ export async function prepareSnapshotBuild(context, request) {
85
77
  toolchains: steps.toolchains,
86
78
  prebuild: steps.prebuild,
87
79
  snapshotKey: steps.key,
88
- commitsAfterBase: afterBase?.ok === true ? afterBase.value : null,
80
+ commitsAfterBase,
89
81
  },
90
- ref: mode.ref,
91
82
  head: head.value,
83
+ ref: ref ?? null,
84
+ mergeBase,
85
+ atMergeBase,
92
86
  cached,
93
- full: mode.full,
94
- warnings,
87
+ full: request.full,
95
88
  },
96
89
  };
97
90
  }
98
- /** A build that stopped on the signal before it saved anything. */
99
- const ABORTED_EARLY = { kind: "aborted", baseSnapshot: null, dropped: null };
100
91
  /**
101
- * Builds what a checked build needs, reporting to `progress`, and closes every sandbox it started however it ends,
102
- * keeping none. `signal` stops it in any stage: it says so, then closes the scope at once.
103
- *
104
- * For this checkout, it chooses what to start from by the one rule a run uses (`chooseSnapshotStart`), or, under
105
- * `full`, builds a base snapshot whatever the cache holds. When it reuses a dev snapshot built at HEAD's commit with a clean working tree, or, for a build that
106
- * saves no dev snapshot, any snapshot, it is up to date. Otherwise it obtains the start (`obtainSnapshot`), building a
107
- * base snapshot at the merge-base when it chose to; under `full`, once the cache holds the new base snapshot's entry,
108
- * it then drops the dev snapshots built on the base snapshot it replaced (`dropDevSnapshotsOn`), before any runner
109
- * sandbox starts. A build that saves no dev snapshot ends there. Otherwise it readies a runner sandbox on the start
110
- * (`readyRunner`) and saves it as a dev snapshot at HEAD's commit (`saveDevSnapshot`). For `--base`: a cached base
111
- * snapshot of the commit for the access's team and project is up to date, unless `full`; otherwise it builds one, and
112
- * under `full`, once its entry is cached, drops the dev snapshots built on the one it replaced. A base snapshot's save
113
- * isn't stopped by the signal, so after it the build checks the signal once, after any drop, and ends `aborted` with
114
- * what it saved.
92
+ * Builds the checked build's base snapshot, reporting to `progress`, and closes every sandbox it started however it
93
+ * ends, keeping none. A cached base snapshot at the commit for the access's team and project is up to date, unless
94
+ * `full`, which builds a new one that replaces its cache entry. `signal` stops it in any stage: it says so, then
95
+ * closes the scope at once. A base snapshot's save isn't stopped by the signal, so after it the build checks the signal
96
+ * once and ends `aborted` with what it saved.
115
97
  */
116
98
  export async function buildSnapshots(context, request, control, progress) {
117
99
  const { signal } = control;
118
- const scope = runnerSandboxScope(context, progress, { keepMs: () => 0 });
100
+ const scope = runnerSandboxScope(context, progress, { keepMs: 0 });
119
101
  const stop = () => {
120
102
  void progress.emit({ kind: "stopping", commandRunning: false, keepMs: 0 }).catch(() => undefined);
121
103
  void scope.close().catch(() => undefined);
@@ -139,97 +121,26 @@ async function buildIn(context, request, control, progress) {
139
121
  const { build, access, user, secrets } = request;
140
122
  const { signal } = control;
141
123
  if (signal.aborted)
142
- return ABORTED_EARLY;
143
- if (build.kind === "base") {
144
- const cached = build.cached.find((entry) => entry.teamId === access.teamId && entry.projectId === access.projectId);
145
- if (!build.full && cached !== undefined)
146
- return { kind: "up-to-date", snapshot: cached };
147
- const built = await buildSnapshot(context, { prepared: build.plan, access, user, secrets, why: { kind: build.full ? "full" : "base" } }, control, progress);
148
- if (built.kind === "aborted")
149
- return ABORTED_EARLY;
150
- if (built.kind !== "ok")
151
- return built;
152
- const { entry, cacheFailure } = built.value;
153
- const dropped = build.full && cacheFailure === null ? await dropOn(context, entry, progress) : null;
154
- if (signal.aborted)
155
- return { kind: "aborted", baseSnapshot: savedBaseOf(built.value), dropped };
156
- return baseOnlyEnd(built.value, dropped);
157
- }
158
- const { prepared } = build;
159
- const start = build.full
160
- ? { kind: "build", why: { kind: "full" } }
161
- : chooseSnapshotStart(prepared, access);
162
- if (start.kind === "reuse") {
163
- const { entry } = start.candidate;
164
- if (isDevEntry(entry) && entry.head === prepared.head.commit && !prepared.head.dirty)
165
- return { kind: "up-to-date", snapshot: entry };
166
- // A build that saves no dev snapshot needs only a snapshot that fits.
167
- if (prepared.devSnapshots !== "reuse")
168
- return { kind: "up-to-date", snapshot: entry };
169
- }
170
- const obtained = await obtainSnapshot(context, { prepared, access, user, secrets, start }, control, progress);
171
- if (obtained.kind === "aborted")
172
- return ABORTED_EARLY;
173
- if (obtained.kind !== "ok")
174
- return obtained;
175
- const { built } = obtained.value;
176
- // The base snapshot this build built, if any. Only a cached one replaces the old one.
177
- const baseSnapshot = built === null ? null : savedBaseOf(built);
178
- const dropped = build.full && baseSnapshot?.cached === true ? await dropOn(context, baseSnapshot.entry, progress) : null;
179
- const aborted = { kind: "aborted", baseSnapshot, dropped };
124
+ return { kind: "aborted", snapshot: null };
125
+ const cached = build.cached.find((entry) => entry.teamId === access.teamId && entry.projectId === access.projectId);
126
+ if (!build.full && cached !== undefined)
127
+ return { kind: "up-to-date", snapshot: cached };
128
+ const why = build.full ? "full" : build.ref === null ? "no-snapshot" : "base";
129
+ const built = await buildSnapshot(context, {
130
+ prepared: build.plan,
131
+ access,
132
+ user,
133
+ secrets,
134
+ why: why === "no-snapshot" ? { kind: why, rejected: [] } : { kind: why },
135
+ }, control, progress);
136
+ if (built.kind === "aborted")
137
+ return { kind: "aborted", snapshot: null };
138
+ if (built.kind !== "ok")
139
+ return built;
140
+ const { entry, cacheFailure, ms, sizeBytes } = built.value;
180
141
  if (signal.aborted)
181
- return aborted;
182
- if (prepared.devSnapshots !== "reuse")
183
- // A build that reuses a snapshot here returned above, but this branch doesn't count on it.
184
- return built === null ? { kind: "up-to-date", snapshot: obtained.value.entry } : baseOnlyEnd(built, dropped);
185
- const ready = await readyRunner(context, { prepared, access, user, secrets, start: obtained.value }, control, progress);
186
- if (ready.kind === "aborted")
187
- return aborted;
188
- if (ready.kind !== "ready")
189
- return ready;
190
- const { runner } = ready;
191
- const saved = await saveDevSnapshot(context, { ready: runner, branch: prepared.head.branch, head: prepared.head.commit }, control, progress);
192
- if (saved.entry === null) {
193
- const { save } = saved;
194
- // Only a signal stops a save: its handler is what closes the scope.
195
- return save.kind === "stopped"
196
- ? aborted
197
- : { kind: "dev-snapshot-not-saved", step: save.step, message: save.message, baseSnapshot };
198
- }
199
- const { entry, cacheFailure, save } = saved;
200
- if (cacheFailure !== null)
201
- return { kind: "not-cached", snapshot: entry, failure: cacheFailure, baseSnapshot, dropped };
202
- return {
203
- kind: "built",
204
- baseSnapshot,
205
- startedFrom: runner.startedFrom,
206
- devSnapshot: { entry, ms: save.ms, sizeBytes: save.sizeBytes },
207
- dropped,
208
- };
209
- }
210
- /** A base snapshot this build built, and whether the cache wrote its entry. */
211
- function savedBaseOf(built) {
212
- return { entry: built.entry, cached: built.cacheFailure === null };
213
- }
214
- /**
215
- * How a build that saves no dev snapshot ends once it built base snapshot `built`: `built` when the cache wrote its
216
- * entry, else `not-cached`, since no run finds it. It takes the base snapshot it built, never one it reused.
217
- */
218
- function baseOnlyEnd(built, dropped) {
219
- const baseSnapshot = savedBaseOf(built);
220
- return built.cacheFailure === null
221
- ? { kind: "built", baseSnapshot, startedFrom: null, devSnapshot: null, dropped }
222
- : { kind: "not-cached", snapshot: built.entry, failure: built.cacheFailure, baseSnapshot, dropped };
223
- }
224
- /**
225
- * Drops the dev snapshots built on the base snapshot `built` replaced, the cache entry of the same identity, and
226
- * reports what it dropped and what it couldn't.
227
- */
228
- async function dropOn(context, built, progress) {
229
- const dropped = await dropDevSnapshotsOn(context, built);
230
- if (dropped.snapshotIds.length > 0)
231
- await progress.emit({ kind: "dev-snapshots-dropped", snapshotIds: dropped.snapshotIds });
232
- for (const { message } of dropped.failures)
233
- await progress.emit({ kind: "dev-snapshots-not-dropped", message });
234
- return dropped;
142
+ return { kind: "aborted", snapshot: { entry, cached: cacheFailure === null } };
143
+ return cacheFailure === null
144
+ ? { kind: "built", snapshot: entry, ms, sizeBytes }
145
+ : { kind: "not-cached", snapshot: entry, failure: cacheFailure };
235
146
  }
@@ -47,9 +47,8 @@ export type SnapshotBuildReason = {
47
47
  /**
48
48
  * What the runner reports, in order.
49
49
  *
50
- * - `snapshot-reused`: the run starts from cached runner snapshot `snapshotId`, of `base`; for a dev snapshot,
51
- * saved at HEAD commit `head` by a run on `branch`, which is null when that run's HEAD was detached. Both are null
52
- * for a base snapshot. `snapshot` says its kind, its built-at commit and how far it is behind the run.
50
+ * - `snapshot-reused`: the run starts from cached runner snapshot `snapshotId`, built at `base`; `builtBehind` is how
51
+ * many commits HEAD has that `base` lacks.
53
52
  * - `snapshot-build-started`: a base snapshot of `base` is being built, and `why` (`SnapshotBuildReason`); `summary`
54
53
  * says what the build does.
55
54
  * - `runner-sandbox-starting`: the runner sandbox is starting from runner snapshot `snapshotId`.
@@ -58,7 +57,7 @@ export type SnapshotBuildReason = {
58
57
  * - `step-started`, `step-output` (one line, without its newline) and `step-finished`: a step's progress.
59
58
  * - `snapshot-saving`: the build sandbox is being saved as a runner snapshot.
60
59
  * - `snapshot-built`: it was, in `ms` from the build's start; `builtBehind` is how many commits HEAD has that `base`
61
- * lacks, null for a `storm snapshots build --base` commit that isn't in HEAD's history.
60
+ * lacks, null for a `storm snapshots build --base` commit that isn't HEAD's merge-base.
62
61
  * - `snapshot-entry-not-written`: the cache couldn't record the new snapshot; the run goes on.
63
62
  * - `uploading`: the run's changes are being uploaded to the runner sandbox.
64
63
  * - `uploaded`: the run's changes, `bytes` in all, reached the runner sandbox.
@@ -70,22 +69,12 @@ export type SnapshotBuildReason = {
70
69
  * and releasing the run's resources.
71
70
  * - `waiting-for-snapshot`: closing waits up to `settleMs` for a runner snapshot still saving.
72
71
  * - `sandbox-kept`: closing kept runner sandbox `name` running until `stopsAt`, an ISO time.
73
- * - `dev-snapshot-saving`: the run saves the runner sandbox as a dev snapshot, once the command ended; `branch` is
74
- * HEAD's branch, null when detached.
75
- * - `dev-snapshot-saved`: it did, as runner snapshot `snapshotId` at HEAD commit `head`, in `ms`.
76
- * - `dev-snapshot-not-saved`: it didn't, and `save` says why.
77
- * - `dev-snapshot-skipped`: the command ended on its own and the run starts no save, for `reason`.
78
- * - `dev-snapshots-dropped`: `storm snapshots build --full` removed the cache entries of the dev snapshots built on
79
- * the base snapshot it replaced, from any checkout.
80
- * - `dev-snapshots-not-dropped`: it couldn't list the cache or remove an entry; `message` says which.
81
72
  */
82
73
  export type RunnerEvent = {
83
74
  readonly kind: "snapshot-reused";
84
75
  readonly snapshotId: string;
85
76
  readonly base: string;
86
- readonly branch: string | null;
87
- readonly head: string | null;
88
- readonly snapshot: StartedFromSnapshot;
77
+ readonly builtBehind: number;
89
78
  } | {
90
79
  readonly kind: "snapshot-build-started";
91
80
  readonly base: string;
@@ -160,30 +149,6 @@ export type RunnerEvent = {
160
149
  readonly kind: "sandbox-kept";
161
150
  readonly name: string;
162
151
  readonly stopsAt: string;
163
- } | {
164
- readonly kind: "dev-snapshot-saving";
165
- readonly branch: string | null;
166
- } | {
167
- readonly kind: "dev-snapshot-saved";
168
- readonly snapshotId: string;
169
- readonly branch: string | null;
170
- readonly head: string;
171
- readonly ms: number;
172
- readonly sizeBytes: number;
173
- } | {
174
- readonly kind: "dev-snapshot-not-saved";
175
- readonly save: Exclude<RunnerSave, {
176
- readonly kind: "saved";
177
- }>;
178
- } | {
179
- readonly kind: "dev-snapshot-skipped";
180
- readonly reason: RunnerNoSaveReason;
181
- } | {
182
- readonly kind: "dev-snapshots-dropped";
183
- readonly snapshotIds: readonly string[];
184
- } | {
185
- readonly kind: "dev-snapshots-not-dropped";
186
- readonly message: string;
187
152
  };
188
153
  /** Hears the runner's events as they happen. */
189
154
  export interface RunnerProgress {
@@ -213,55 +178,6 @@ export type RunnerFailure = {
213
178
  readonly kind: "checkout-failed";
214
179
  readonly failure: CheckoutFailure;
215
180
  };
216
- /**
217
- * The runner snapshot a run starts from, in commits: its kind, the commit it was built at (a base snapshot's base, or
218
- * the commit that saved a dev snapshot), and how many commits HEAD has that its built-at commit lacks
219
- * (`builtBehind`). The count is null when the commit isn't in HEAD's history, as for a `storm snapshots build --base`
220
- * build, or when an older run record holds none.
221
- */
222
- export interface StartedFromSnapshot {
223
- readonly kind: "base" | "dev";
224
- readonly builtAt: string;
225
- readonly builtBehind: number | null;
226
- }
227
- /**
228
- * Why a run saves never, decided before it starts: `--save-dev-snapshot=false` (`no-save-flag`), the recipe's
229
- * `saveDevSnapshot: false` (`recipe`), a `--keep-sandbox` above 0 (`keep-sandbox`), `CI` set (`ci`), or a recipe
230
- * whose install or build step names a runner secret and that doesn't set `trustDevSnapshots` (`not-trusted`).
231
- */
232
- export type NeverSaveReason = "no-save-flag" | "recipe" | "keep-sandbox" | "ci" | "not-trusted";
233
- /**
234
- * Why a run whose command ended on its own started no save: it saves never (`NeverSaveReason`), the command didn't
235
- * exit 0 (`command-failed`), or the run started from a dev snapshot built at HEAD's commit (`already-saved`).
236
- */
237
- export type RunnerNoSaveReason = NeverSaveReason | "command-failed" | "already-saved";
238
- /**
239
- * How saving the runner sandbox as a dev snapshot ended.
240
- *
241
- * - `saved`: it is runner snapshot `snapshotId` of `base`, at HEAD commit `head` on `branch`, null when HEAD was
242
- * detached, saved in `ms` from the save's start; `entryWritten` says whether the cache recorded it.
243
- * - `failed`: the scrub or the save failed with `message`.
244
- * - `stopped`: a signal stopped it before it saved, or before the cache recorded the snapshot.
245
- *
246
- * A run whose save started never keeps its runner sandbox, however the save ended; a run whose save never started
247
- * has none of these, and keeps its runner sandbox for the keep time (`RunnerSandboxPlan`).
248
- */
249
- export type RunnerSave = {
250
- readonly kind: "saved";
251
- readonly snapshotId: string;
252
- readonly base: string;
253
- readonly branch: string | null;
254
- readonly head: string;
255
- readonly ms: number;
256
- readonly sizeBytes: number;
257
- readonly entryWritten: boolean;
258
- } | {
259
- readonly kind: "failed";
260
- readonly step: "scrub" | "save-snapshot";
261
- readonly message: string;
262
- } | {
263
- readonly kind: "stopped";
264
- };
265
181
  /** How one stage of readying the runner ended: its value, a failure, or a stop because the run was aborted. */
266
182
  export type RunnerStage<T> = {
267
183
  readonly kind: "ok";
@@ -134,9 +134,7 @@ export interface CheckoutGateway {
134
134
  }
135
135
  /**
136
136
  * One runner snapshot the cache records: who it belongs to, what it was built from, and when it expires. Times
137
- * are ISO strings. An entry with `head` and `repoRoot` records a dev snapshot, saved from a run's runner sandbox; one
138
- * without them records a base snapshot, built from its base. An entry has both or neither, and `branch` only with
139
- * them.
137
+ * are ISO strings. Every entry records a base snapshot, built at its base, which may be any commit.
140
138
  */
141
139
  export interface RunnerSnapshotEntry {
142
140
  readonly teamId: string;
@@ -146,23 +144,8 @@ export interface RunnerSnapshotEntry {
146
144
  readonly recipeName: string;
147
145
  /** The snapshot key at `base` (`snapshotKey`). */
148
146
  readonly snapshotKey: string;
149
- /** The base commit's full SHA, whose tracked files the snapshot's repository commits first, in either kind. */
147
+ /** The base commit's full SHA: the commit the snapshot was built at, whose tracked files its repository commits. */
150
148
  readonly base: string;
151
- /**
152
- * For a dev snapshot, the local branch of the run that saved it, for display; absent when that run's HEAD was
153
- * detached. No lookup reads it.
154
- */
155
- readonly branch?: string;
156
- /**
157
- * For a dev snapshot, the full SHA of the HEAD commit of the run that saved it, the commit it was built at. A run
158
- * starts from it only while that commit is HEAD or in HEAD's history.
159
- */
160
- readonly head?: string;
161
- /**
162
- * For a dev snapshot, the root of the checkout the run that saved it ran from. Only a run from that checkout
163
- * starts from it, so another checkout never inherits what this run left.
164
- */
165
- readonly repoRoot?: string;
166
149
  readonly snapshotId: string;
167
150
  readonly createdAt: string;
168
151
  readonly expiresAt: string;
@@ -199,8 +182,7 @@ export type RunnerSnapshotCacheOperation = {
199
182
  };
200
183
  /**
201
184
  * The per-machine runner snapshot cache: one record per runner snapshot, keyed by the entry's identity (team,
202
- * project, region, runtime, recipe name, snapshot key, and a base snapshot's base or a dev snapshot's checkout root
203
- * and commit).
185
+ * project, region, runtime, recipe name, snapshot key and base).
204
186
  * Every method returns its expected failures and never rejects. Which entries a run may use, and when one has
205
187
  * expired, is the caller's.
206
188
  */
@@ -291,7 +273,7 @@ export interface StagedFile {
291
273
  readonly name: string;
292
274
  readonly content: Uint8Array;
293
275
  }
294
- /** A runner snapshot a build sandbox or a runner sandbox was saved as. */
276
+ /** A runner snapshot a build sandbox was saved as. */
295
277
  export interface SavedSnapshot {
296
278
  readonly snapshotId: string;
297
279
  /** When the Sandbox API says it expires, as an ISO string, when it says. */
@@ -350,7 +332,7 @@ export interface RunnerSandboxGateway {
350
332
  readonly path: string;
351
333
  readonly fromLine: number;
352
334
  }, onOutput: (chunk: SandboxOutputChunk) => void, signal?: AbortSignal): Promise<RunnerSandboxOperation>;
353
- /** Saves a build or runner sandbox as a runner snapshot that expires after `expirationMs`; that stops the sandbox. */
335
+ /** Saves a build sandbox as a runner snapshot that expires after `expirationMs`; that stops the sandbox. */
354
336
  saveSnapshot(sandbox: RunnerSandbox, request: {
355
337
  readonly expirationMs: number;
356
338
  }): Promise<RunnerSandboxResult<SavedSnapshot>>;
@@ -1,6 +1,6 @@
1
1
  export type { RunnerContext } from "./context.ts";
2
- export { buildSnapshots, prepareSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildMode, type SnapshotBuildOutcome, type SnapshotBuildWarning, } from "./build-snapshots.ts";
3
- export { type KeptSandbox, type NeverSaveReason, type RunnerEvent, type RunnerFailure, type RunnerNoSaveReason, type RunnerProgress, type RunnerSave, type RunnerStepPhase, type SnapshotBuildReason, type StartedFromSnapshot, } from "./events.ts";
2
+ export { buildSnapshots, prepareSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
3
+ export { type KeptSandbox, type RunnerEvent, type RunnerFailure, type RunnerProgress, type RunnerStepPhase, type SnapshotBuildReason, } from "./events.ts";
4
4
  export type { CheckoutFailure, CheckoutGateway, RunnerSandboxGateway, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotEntry, RunnerTerminal, } from "./gateways.ts";
5
5
  export { liveCheckoutGateway } from "./live/checkout-gateway.ts";
6
6
  export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.ts";
@@ -10,10 +10,9 @@ export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway,
10
10
  export { lineSplitter } from "./output.ts";
11
11
  export { prepareRunner, type PrepareRunnerOutcome } from "./prepare.ts";
12
12
  export type { ReadyRunnerOutcome } from "./ready.ts";
13
- export { type CheckedRecipe, checkRecipe, type DevSnapshotReuse, devSnapshotsTrusted, runStepTakesSecret, } from "./recipe.ts";
13
+ export { type CheckedRecipe, checkRecipe } from "./recipe.ts";
14
14
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.ts";
15
15
  export { declaredSecretValues, readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH, type RunnerSecrets } from "./secrets.ts";
16
- export type { RunnerSandboxPlan } from "./scope.ts";
17
- export { type RunnerCleanupFacts, openRunnerSession, type RunnerSaveMode, type RunnerSession, type RunnerSessionRequest, } from "./session.ts";
16
+ export { type RunnerCleanupFacts, openRunnerSession, type RunnerSession, type RunnerSessionCleanup, type RunnerSessionRequest, } from "./session.ts";
18
17
  export { type InspectedSnapshot, inspectSnapshotCache, type SnapshotCacheInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
19
- export { type DevSnapshotDrop, type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotCacheNote, type SnapshotRejectionReason, } from "./snapshot-cache.ts";
18
+ export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotCacheNote, type SnapshotRejectionReason, } from "./snapshot-cache.ts";
@@ -10,7 +10,7 @@ export { localUserName } from "./live/user.js";
10
10
  export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway, } from "./live/snapshot-cache-gateway.js";
11
11
  export { lineSplitter } from "./output.js";
12
12
  export { prepareRunner } from "./prepare.js";
13
- export { checkRecipe, devSnapshotsTrusted, runStepTakesSecret, } from "./recipe.js";
13
+ export { checkRecipe } from "./recipe.js";
14
14
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.js";
15
15
  export { declaredSecretValues, readRunnerSecrets, RUNNER_SECRET_MIN_LENGTH } from "./secrets.js";
16
16
  export { openRunnerSession, } from "./session.js";
@@ -1,15 +1,12 @@
1
1
  // The runner snapshot cache's file format: one JSON object per runner snapshot, carrying `version: 1`. A reader
2
- // rejects a version it doesn't know. A dev snapshot's record adds `head` and `repoRoot`, both or neither, and, when
3
- // the run that saved it was on a branch, `branch`, which only a record with those two has. A file is named for its
4
- // entry's identity (`snapshotEntryIdentity`), and the gateway lists a file whose name isn't as unreadable. So a storm
5
- // that names a dev snapshot's file by another identity, an older one that keyed it by branch and base, or one that
6
- // predates dev snapshots and drops the fields as it reads, never starts from it, and this storm never starts from an
7
- // older storm's dev snapshot file: there is no migration, and each file stays until its snapshot expires.
2
+ // rejects a version it doesn't know, and drops keys it doesn't know. A file is named for its entry's identity
3
+ // (`snapshotEntryIdentity`), and the gateway lists a file whose name isn't as unreadable. So a file an older storm
4
+ // wrote for a dev snapshot, named for an identity that held its checkout's root and commit, is listed as unreadable,
5
+ // and no run starts from it: there is no migration.
8
6
  import { z } from "zod";
9
7
  const isoTime = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
10
8
  const nonEmpty = z.string().min(1);
11
- const entrySchema = z
12
- .object({
9
+ const entrySchema = z.object({
13
10
  version: z.literal(1),
14
11
  teamId: nonEmpty,
15
12
  projectId: nonEmpty,
@@ -18,15 +15,10 @@ const entrySchema = z
18
15
  recipeName: nonEmpty,
19
16
  snapshotKey: nonEmpty,
20
17
  base: nonEmpty,
21
- branch: nonEmpty.exactOptional(),
22
- head: nonEmpty.exactOptional(),
23
- repoRoot: nonEmpty.exactOptional(),
24
18
  snapshotId: nonEmpty,
25
19
  createdAt: isoTime,
26
20
  expiresAt: isoTime,
27
- })
28
- .refine((entry) => (entry.head === undefined) === (entry.repoRoot === undefined) &&
29
- (entry.branch === undefined || entry.head !== undefined), { message: "has some of branch, head and repoRoot without head and repoRoot together" });
21
+ });
30
22
  /** The entry a cache file holds, or why it holds none. */
31
23
  export function parseSnapshotEntry(text) {
32
24
  let json;
@@ -50,7 +42,7 @@ export function parseSnapshotEntry(text) {
50
42
  }
51
43
  /** The text of the file that records `entry`. */
52
44
  export function snapshotEntryText(entry) {
53
- const { teamId, projectId, region, runtime, recipeName, snapshotKey, base, branch, head, repoRoot } = entry;
45
+ const { teamId, projectId, region, runtime, recipeName, snapshotKey, base } = entry;
54
46
  const { snapshotId, createdAt, expiresAt } = entry;
55
47
  const record = {
56
48
  version: 1,
@@ -61,9 +53,6 @@ export function snapshotEntryText(entry) {
61
53
  recipeName,
62
54
  snapshotKey,
63
55
  base,
64
- ...(branch === undefined ? {} : { branch }),
65
- ...(head === undefined ? {} : { head }),
66
- ...(repoRoot === undefined ? {} : { repoRoot }),
67
56
  snapshotId,
68
57
  createdAt,
69
58
  expiresAt,