@cnc-tools/storm 0.16.0 → 0.17.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 (281) hide show
  1. package/dist/application.d.ts +22 -13
  2. package/dist/application.js +21 -10
  3. package/dist/bin/run.d.ts +18 -0
  4. package/dist/bin/run.js +31 -0
  5. package/dist/bin/storm.js +42 -26
  6. package/dist/build-info.js +1 -1
  7. package/dist/chunks/{chunk-5CCP36QQ.js → chunk-2RNDPDTJ.js} +2 -2
  8. package/dist/chunks/chunk-2VP4GRJM.js +1219 -0
  9. package/dist/chunks/{chunk-P357TZAY.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-OIY3DMF2.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-CK2GZEPK.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-2MAD5NKK.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-V4IKA3WI.js → chunk-DADEYJDW.js} +24 -17
  18. package/dist/chunks/{chunk-R7XVBZOY.js → chunk-EEENLQHE.js} +59 -11
  19. package/dist/chunks/chunk-F4MOYHRY.js +198 -0
  20. package/dist/chunks/{chunk-HVNK3I45.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-G3PHMXH5.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-DWEAHX4T.js → chunk-HWIQ2S7K.js} +5 -5
  24. package/dist/chunks/chunk-JN3YY6ZH.js +2166 -0
  25. package/dist/chunks/{chunk-TJNFVNKR.js → chunk-LKTZ5OXS.js} +1 -1
  26. package/dist/chunks/{chunk-3L52KNQA.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-DC2CDHNK.js → chunk-RNAS7JHE.js} +1438 -445
  29. package/dist/chunks/{chunk-FCQUJDA4.js → chunk-RWIXDDCK.js} +4 -189
  30. package/dist/chunks/{chunk-5VXBKPW6.js → chunk-WV3DP6NR.js} +1 -1
  31. package/dist/chunks/{chunk-AWBSONHB.js → chunk-XBDRVFEV.js} +55 -16
  32. package/dist/chunks/{chunk-FOZWA52V.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-WECQOQ4C.js → live-app-R76JQXZL.js} +15 -13
  34. package/dist/commands/exec/across-sandboxes-outcomes.d.ts +1 -1
  35. package/dist/commands/exec/across-sandboxes-outcomes.js +2 -2
  36. package/dist/commands/exec/before-run.d.ts +123 -0
  37. package/dist/commands/exec/before-run.js +105 -0
  38. package/dist/commands/exec/command.d.ts +31 -2
  39. package/dist/commands/exec/command.js +31 -95
  40. package/dist/commands/exec/driver-plan.d.ts +9 -4
  41. package/dist/commands/exec/driver-plan.js +8 -8
  42. package/dist/commands/exec/exec-words.js +1 -1
  43. package/dist/commands/exec/execute-run.d.ts +39 -0
  44. package/dist/commands/exec/execute-run.js +325 -0
  45. package/dist/commands/exec/live-view.d.ts +3 -3
  46. package/dist/commands/exec/live-view.js +16 -15
  47. package/dist/commands/exec/metadata.js +1 -1
  48. package/dist/commands/exec/mint-failed.d.ts +38 -0
  49. package/dist/commands/exec/mint-failed.js +27 -4
  50. package/dist/commands/exec/outcomes.d.ts +34 -8
  51. package/dist/commands/exec/outcomes.js +30 -23
  52. package/dist/commands/exec/plan-run.d.ts +58 -150
  53. package/dist/commands/exec/plan-run.js +232 -88
  54. package/dist/commands/exec/progress.d.ts +10 -6
  55. package/dist/commands/exec/progress.js +38 -25
  56. package/dist/commands/exec/run-bin.d.ts +11 -11
  57. package/dist/commands/exec/run-bin.js +9 -9
  58. package/dist/commands/exec/run-flags.d.ts +69 -0
  59. package/dist/commands/exec/run-flags.js +58 -0
  60. package/dist/commands/exec/run-metadata.js +4 -4
  61. package/dist/commands/exec/run-summary.d.ts +58 -0
  62. package/dist/commands/exec/run-summary.js +205 -0
  63. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  64. package/dist/commands/exec/runner-refusals.js +71 -0
  65. package/dist/commands/exec/sandbox-progress.js +3 -0
  66. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  67. package/dist/commands/exec/stopped-outcome.js +77 -0
  68. package/dist/commands/exec/view.d.ts +20 -11
  69. package/dist/commands/exec/view.js +103 -47
  70. package/dist/commands/runs/facts.d.ts +7 -3
  71. package/dist/commands/runs/facts.js +17 -8
  72. package/dist/commands/runs/list/command.d.ts +14 -6
  73. package/dist/commands/runs/list/command.js +10 -10
  74. package/dist/commands/runs/list/outcomes.d.ts +7 -3
  75. package/dist/commands/runs/logs/command.js +10 -10
  76. package/dist/commands/runs/show/command.d.ts +14 -6
  77. package/dist/commands/runs/show/command.js +30 -28
  78. package/dist/commands/runs/show/outcomes.d.ts +7 -3
  79. package/dist/commands/runs/show/outcomes.js +7 -5
  80. package/dist/commands/snapshots/access.d.ts +111 -0
  81. package/dist/commands/snapshots/access.js +96 -0
  82. package/dist/commands/snapshots/build/command.d.ts +360 -93
  83. package/dist/commands/snapshots/build/command.js +446 -150
  84. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  85. package/dist/commands/snapshots/build/metadata.js +31 -11
  86. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  87. package/dist/commands/snapshots/build/outcomes.js +200 -36
  88. package/dist/commands/snapshots/list/command.d.ts +366 -25
  89. package/dist/commands/snapshots/list/command.js +296 -66
  90. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  91. package/dist/commands/snapshots/list/metadata.js +29 -6
  92. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  93. package/dist/commands/snapshots/list/outcomes.js +221 -50
  94. package/dist/commands/snapshots/metadata.js +1 -1
  95. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  96. package/dist/commands/snapshots/prune/command.js +161 -0
  97. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  98. package/dist/commands/snapshots/prune/metadata.js +39 -0
  99. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  100. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  101. package/dist/commands/suites/list/command.js +17 -17
  102. package/dist/commands/suites/list/outcomes.js +2 -2
  103. package/dist/commands/test/command.d.ts +31 -2
  104. package/dist/commands/test/command.js +49 -252
  105. package/dist/commands/test/outcomes.d.ts +15 -1
  106. package/dist/config/check-runner.d.ts +3 -3
  107. package/dist/config/check-runner.js +8 -7
  108. package/dist/config/credential-resolver.d.ts +50 -5
  109. package/dist/config/credential-resolver.js +51 -19
  110. package/dist/config/credential-settle.d.ts +6 -2
  111. package/dist/config/credential-settle.js +11 -5
  112. package/dist/config/index.d.ts +2 -2
  113. package/dist/config/index.js +1 -1
  114. package/dist/config/runner.d.ts +5 -5
  115. package/dist/config/runner.js +1 -1
  116. package/dist/config/schema.d.ts +2 -2
  117. package/dist/config/schema.js +1 -1
  118. package/dist/config-file/define.d.ts +1 -1
  119. package/dist/config-file/define.js +1 -1
  120. package/dist/config-file/runner.d.ts +5 -5
  121. package/dist/config-file/toolchain.d.ts +1 -1
  122. package/dist/config-file/toolchain.js +2 -2
  123. package/dist/context.d.ts +8 -6
  124. package/dist/context.js +7 -6
  125. package/dist/core/across-sandboxes.d.ts +7 -6
  126. package/dist/core/across-sandboxes.js +123 -152
  127. package/dist/core/coordinator.d.ts +166 -0
  128. package/dist/core/coordinator.js +233 -0
  129. package/dist/core/events.d.ts +2 -2
  130. package/dist/core/index.d.ts +4 -2
  131. package/dist/core/index.js +1 -1
  132. package/dist/core/outcomes.d.ts +148 -0
  133. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  134. package/dist/core/resources.d.ts +31 -53
  135. package/dist/core/resources.js +32 -70
  136. package/dist/core/run-state.d.ts +7 -1
  137. package/dist/core/run-state.js +2 -0
  138. package/dist/core/run.d.ts +32 -236
  139. package/dist/core/run.js +106 -266
  140. package/dist/core/state-directory.d.ts +1 -1
  141. package/dist/core/state-directory.js +2 -2
  142. package/dist/credential/gateways.d.ts +15 -1
  143. package/dist/credential/index.d.ts +4 -3
  144. package/dist/credential/index.js +3 -2
  145. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  146. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  147. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  148. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  149. package/dist/credential/source.d.ts +73 -6
  150. package/dist/credential/source.js +55 -2
  151. package/dist/extension-commands.d.ts +6 -1
  152. package/dist/extension-commands.js +15 -1
  153. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  154. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  155. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  156. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  157. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  158. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  159. package/dist/extensions/testserver/credential-facts.js +29 -11
  160. package/dist/extensions/testserver/lifecycle.js +7 -1
  161. package/dist/extensions/testserver/limit.d.ts +3 -0
  162. package/dist/extensions/testserver/limit.js +3 -0
  163. package/dist/extensions/testserver/provision.d.ts +8 -1
  164. package/dist/extensions/testserver/provision.js +8 -3
  165. package/dist/extensions/testserver/refusals.d.ts +6 -1
  166. package/dist/extensions/testserver/refusals.js +16 -1
  167. package/dist/extensions/testserver/resource.d.ts +1 -1
  168. package/dist/extensions/testserver/resource.js +1 -1
  169. package/dist/extensions/testserver/result.d.ts +1 -1
  170. package/dist/extensions/testserver/result.js +9 -4
  171. package/dist/planning/driver-file-lists.d.ts +0 -15
  172. package/dist/planning/driver-file-lists.js +2 -21
  173. package/dist/planning/plan-only.d.ts +3 -14
  174. package/dist/planning/plan-only.js +11 -20
  175. package/dist/planning/run-kind-flags.js +2 -2
  176. package/dist/planning/run-plan.d.ts +45 -12
  177. package/dist/planning/run-plan.js +4 -3
  178. package/dist/planning/suites.d.ts +1 -1
  179. package/dist/planning/suites.js +2 -2
  180. package/dist/planning/test-plan.d.ts +9 -0
  181. package/dist/planning/test-plan.js +9 -0
  182. package/dist/run-directory/recording.js +2 -2
  183. package/dist/run-directory/run-record.d.ts +21 -6
  184. package/dist/run-directory/run-record.js +12 -9
  185. package/dist/runner/base.js +1 -1
  186. package/dist/runner/build-snapshots.d.ts +55 -29
  187. package/dist/runner/build-snapshots.js +130 -29
  188. package/dist/runner/context.d.ts +15 -7
  189. package/dist/runner/context.js +19 -6
  190. package/dist/runner/events.d.ts +16 -10
  191. package/dist/runner/gateways.d.ts +87 -21
  192. package/dist/runner/gateways.js +1 -1
  193. package/dist/runner/index.d.ts +11 -7
  194. package/dist/runner/index.js +9 -4
  195. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  196. package/dist/runner/live/sandbox-errors.js +4 -0
  197. package/dist/runner/live/sandbox-gateway.js +129 -3
  198. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  199. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  200. package/dist/runner/live/snapshot-records.js +6 -7
  201. package/dist/runner/local-snapshot-index.d.ts +199 -0
  202. package/dist/runner/local-snapshot-index.js +211 -0
  203. package/dist/runner/network-policy.d.ts +6 -6
  204. package/dist/runner/network-policy.js +7 -7
  205. package/dist/runner/policy-writes.d.ts +1 -1
  206. package/dist/runner/policy-writes.js +1 -1
  207. package/dist/runner/prepare.d.ts +14 -14
  208. package/dist/runner/prepare.js +20 -11
  209. package/dist/runner/ready.d.ts +18 -10
  210. package/dist/runner/ready.js +104 -33
  211. package/dist/runner/sandboxed-command.d.ts +3 -3
  212. package/dist/runner/sandboxed-command.js +3 -3
  213. package/dist/runner/scope.d.ts +10 -6
  214. package/dist/runner/scope.js +10 -3
  215. package/dist/runner/secrets.d.ts +13 -13
  216. package/dist/runner/secrets.js +18 -15
  217. package/dist/runner/session.d.ts +8 -8
  218. package/dist/runner/session.js +3 -3
  219. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  220. package/dist/runner/shared-snapshot-entry.js +168 -0
  221. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  222. package/dist/runner/shared-snapshot-list.js +155 -0
  223. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  224. package/dist/runner/shared-snapshot-lookup.js +118 -0
  225. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  226. package/dist/runner/shared-snapshot-prune.js +133 -0
  227. package/dist/runner/snapshot-build.d.ts +42 -14
  228. package/dist/runner/snapshot-build.js +32 -29
  229. package/dist/runner/snapshot-choice.js +1 -1
  230. package/dist/runner/snapshot-inspect.d.ts +39 -40
  231. package/dist/runner/snapshot-inspect.js +55 -35
  232. package/dist/runner/snapshot-key.d.ts +13 -12
  233. package/dist/runner/snapshot-key.js +13 -12
  234. package/dist/runner/steps.d.ts +1 -1
  235. package/dist/runner/steps.js +1 -1
  236. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  237. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  238. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +24 -23
  239. package/dist/runner/{recipe.js → vercel-sandbox-options.js} +70 -69
  240. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  241. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  242. package/dist/sdk/extension/commands.d.ts +8 -3
  243. package/dist/sdk/extension/commands.js +3 -1
  244. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  245. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  246. package/dist/sdk/extension/credential-source.d.ts +20 -3
  247. package/dist/sdk/extension/credential-source.js +4 -4
  248. package/dist/sdk/extension/index.d.ts +3 -2
  249. package/dist/sdk/extension/index.js +2 -1
  250. package/dist/sdk/extension/resource-definition.d.ts +1 -1
  251. package/dist/sdk/extension/secret-source.d.ts +1 -1
  252. package/dist/sdk/extension/secret-source.js +1 -1
  253. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  254. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  255. package/dist/shared/cleanup.d.ts +3 -3
  256. package/dist/shared/cleanup.js +15 -5
  257. package/dist/shared/snapshot-text.d.ts +4 -4
  258. package/dist/shared/snapshot-text.js +11 -11
  259. package/dist/time/duration.js +1 -1
  260. package/package.json +3 -2
  261. package/skills/overview.md +4 -4
  262. package/skills/plan-runs.md +1 -1
  263. package/skills/read-run-output.md +6 -6
  264. package/dist/chunks/chunk-7EENF73W.js +0 -782
  265. package/dist/chunks/chunk-Z5PBVG3Y.js +0 -2599
  266. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  267. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  268. package/dist/commands/exec/plan-only.d.ts +0 -10
  269. package/dist/commands/exec/plan-only.js +0 -45
  270. package/dist/commands/exec/run-command.d.ts +0 -475
  271. package/dist/commands/exec/run-command.js +0 -603
  272. package/dist/commands/exec/run-planned.d.ts +0 -20
  273. package/dist/commands/exec/run-planned.js +0 -22
  274. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  275. package/dist/commands/exec/sandbox-view.js +0 -72
  276. package/dist/commands/test/plan.d.ts +0 -92
  277. package/dist/commands/test/plan.js +0 -125
  278. package/dist/core/sandbox-end.d.ts +0 -64
  279. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  280. package/dist/runner/snapshot-cache.d.ts +0 -148
  281. package/dist/runner/snapshot-cache.js +0 -126
@@ -7,7 +7,8 @@ import { megabytesText } from "../../../core/index.js";
7
7
  import { RUN_CLEANUP } from "../../../shared/cleanup.js";
8
8
  import { seconds, short } from "../../../shared/text.js";
9
9
  import { runErrors } from "../../exec/outcomes.js";
10
- /** A cached base snapshot, as the result names it. */
10
+ import { PROJECT_FIELDS } from "../access.js";
11
+ /** A runner snapshot, as the result names it. */
11
12
  const snapshotSchema = z.object({
12
13
  snapshotId: z.string(),
13
14
  /** Its base, the commit it was built at, a full SHA. */
@@ -15,65 +16,182 @@ const snapshotSchema = z.object({
15
16
  /** When it expires, as an ISO time. */
16
17
  expiresAt: z.string(),
17
18
  });
18
- /** A cache entry as the result names it. */
19
+ /** A local snapshot index entry as the result names it. */
19
20
  export function snapshotOf(entry) {
20
21
  return { snapshotId: entry.snapshotId, base: entry.base, expiresAt: entry.expiresAt };
21
22
  }
22
23
  /** A snapshot in words: its id and its base. */
23
24
  export function snapshotText({ snapshotId, base }) {
24
- return `base snapshot ${snapshotId} at ${short(base)}`;
25
+ return `runner snapshot ${snapshotId} at ${short(base)}`;
25
26
  }
26
- /** What every result says of where the build ran, and of what it built at. */
27
- const whereFields = {
28
- /** The config file that gave the runner recipe. */
29
- configFile: z.string().nullable(),
30
- recipe: z.string(),
31
- /** The team and project the credential was minted for: the sandboxes ran there, and the snapshots are theirs. */
32
- team: z.string(),
33
- project: z.string(),
34
- /** HEAD's commit, a full SHA. */
35
- head: z.string(),
27
+ /** What every runner's result says of what it built at, and of the commit a --base build checked. */
28
+ const baseFields = {
36
29
  /** What it built at: HEAD's merge-base with `baseRef`, or with --base the commit the ref names, a full SHA. */
37
30
  base: z.string(),
38
31
  baseRef: z.string(),
39
32
  /** With --base, whether the working tree had uncommitted changes, which a base snapshot doesn't hold; else null. */
40
33
  uncommitted: z.boolean().nullable(),
34
+ /** With --base, whether the commit is HEAD's merge-base with a base ref; else null. */
35
+ atMergeBase: z.boolean().nullable(),
41
36
  /**
42
- * With --base, whether the commit is HEAD's merge-base with a base ref; else null. A run here starts only from a
43
- * snapshot at its merge-base.
37
+ * With --base, whether the commit is an ancestor of HEAD's merge-base, a commit behind it on the base ref (false at
38
+ * the merge-base itself); else null. A run here starts only from a snapshot at its merge-base or at such a commit.
44
39
  */
45
- atMergeBase: z.boolean().nullable(),
40
+ ancestorOfMergeBase: z.boolean().nullable(),
41
+ };
42
+ /** What every single runner's result says of where the build ran, and of what it built at. */
43
+ const whereFields = {
44
+ /** The config file that gave the Vercel Sandbox runner. */
45
+ configFile: z.string().nullable(),
46
+ runner: z.string(),
47
+ /** The Vercel project the sandboxes ran in, whose snapshots they are. */
48
+ ...PROJECT_FIELDS,
49
+ /** HEAD's commit, a full SHA. */
50
+ head: z.string(),
51
+ ...baseFields,
46
52
  };
47
53
  const builtSchema = z.object({
48
54
  ...whereFields,
49
- /** The base snapshot it built and cached. */
55
+ /** The runner snapshot it built and indexed. */
50
56
  snapshot: snapshotSchema,
51
57
  /** How long the build took, and the snapshot's size. */
52
58
  ms: z.number(),
53
59
  sizeBytes: z.number(),
60
+ /**
61
+ * With --publish, the stopped sandbox that holds the runner snapshot as the shared snapshot index entry; null without
62
+ * --publish.
63
+ */
64
+ sandboxName: z.string().nullable(),
65
+ /**
66
+ * Whether the local snapshot index on this machine recorded the snapshot. Only --publish ends `built` without it,
67
+ * since a run finds the snapshot in the shared snapshot index.
68
+ */
69
+ localIndexWritten: z.boolean(),
54
70
  /** What the build couldn't clean up. */
55
71
  cleanup: RUN_CLEANUP.schema,
56
72
  });
57
73
  const upToDateSchema = z.object({
58
74
  ...whereFields,
59
- /** The base snapshot the cache holds at that commit for the team and project. */
75
+ /** The runner snapshot the local snapshot index holds, or with --publish the shared snapshot index holds, at that commit. */
60
76
  snapshot: snapshotSchema,
77
+ /** With --publish, the stopped sandbox that holds it as the shared snapshot index entry; null without --publish. */
78
+ sandboxName: z.string().nullable(),
79
+ });
80
+ const alreadyBuildingSchema = z.object({
81
+ ...whereFields,
82
+ /** The shared snapshot index entry's sandbox, which another build owns. */
83
+ sandboxName: z.string(),
84
+ /** Its status, such as `running` or `snapshotting`; null when another build took the name as this one started. */
85
+ status: z.string().nullable(),
86
+ });
87
+ const runnerBuildCommon = {
88
+ runner: z.string(),
89
+ region: z.string(),
90
+ runtime: z.string(),
91
+ /** Whether the top-level runner uses this runner configuration. */
92
+ topLevel: z.boolean(),
93
+ /** The suites whose effective runner uses this runner configuration, in declaration order. */
94
+ suites: z.array(z.string()),
95
+ ...baseFields,
96
+ };
97
+ /** One runner that --all-suites built or checked. */
98
+ const runnerBuildSchema = z.discriminatedUnion("result", [
99
+ z.object({
100
+ ...runnerBuildCommon,
101
+ result: z.literal("built"),
102
+ /** The runner snapshot it built. */
103
+ snapshot: snapshotSchema,
104
+ /** With --publish, the shared snapshot index entry's sandbox; null without --publish. */
105
+ sandboxName: z.string().nullable(),
106
+ /** How long the build took, in milliseconds. */
107
+ ms: z.number(),
108
+ /** The snapshot's size, in bytes. */
109
+ sizeBytes: z.number(),
110
+ /** Whether the local snapshot index on this machine recorded the snapshot. */
111
+ localIndexWritten: z.boolean(),
112
+ }),
113
+ z.object({
114
+ ...runnerBuildCommon,
115
+ result: z.literal("up_to_date"),
116
+ /** The runner snapshot it found. */
117
+ snapshot: snapshotSchema,
118
+ /** With --publish, the shared snapshot index entry's sandbox; null without --publish. */
119
+ sandboxName: z.string().nullable(),
120
+ }),
121
+ z.object({
122
+ ...runnerBuildCommon,
123
+ result: z.literal("already_building"),
124
+ /** The shared snapshot index entry's sandbox, which another build owns. */
125
+ sandboxName: z.string(),
126
+ /** Its status, such as `running` or `snapshotting`; null when another build took the name as this one started. */
127
+ status: z.string().nullable(),
128
+ }),
129
+ ]);
130
+ const allSuitesBuiltSchema = z.object({
131
+ configFile: z.string().nullable(),
132
+ /** The Vercel project the sandboxes ran in, whose snapshots they are. */
133
+ ...PROJECT_FIELDS,
134
+ /** HEAD's commit, a full SHA. */
135
+ head: z.string(),
136
+ /** Each distinct runner, in the order the config file first declares it, and how its build ended. */
137
+ runners: z.array(runnerBuildSchema),
138
+ /** What the builds couldn't clean up. */
139
+ cleanup: RUN_CLEANUP.schema,
61
140
  });
141
+ /** A sandbox status in words, for the already-building line. */
142
+ function statusText(status) {
143
+ return status === null ? "another build took its name first" : `status ${status}`;
144
+ }
145
+ /** What `already_building` says: the sandbox another build owns and its status. */
146
+ function alreadyBuildingText(facts) {
147
+ return `Sandbox ${facts.sandboxName} is already building this runner snapshot (${statusText(facts.status)}), so nothing started.`;
148
+ }
149
+ /** What `up_to_date` says: where the snapshot is. */
150
+ function upToDateText(facts) {
151
+ return facts.sandboxName === null
152
+ ? `The local snapshot index holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.`
153
+ : `The shared snapshot index holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.`;
154
+ }
155
+ /** What `built` says: the snapshot, how long it took, its size, and where it was published. */
156
+ function builtText(facts) {
157
+ const published = facts.sandboxName === null ? "" : ", and published it to the shared snapshot index";
158
+ return `Built ${snapshotText(facts.snapshot)} in ${seconds(facts.ms)} (${megabytesText(facts.sizeBytes)})${published}.`;
159
+ }
160
+ /** Who uses a runner, in words: the top level, then each suite. */
161
+ export function usedByText(facts) {
162
+ return [...(facts.topLevel ? ["the top level"] : []), ...facts.suites.map((suite) => `suite ${suite}`)].join(", ");
163
+ }
164
+ /** One --all-suites runner's result, in words. */
165
+ function runnerBuildText(facts) {
166
+ const where = `${facts.runner} (${usedByText(facts)})`;
167
+ switch (facts.result) {
168
+ case "already_building":
169
+ return `${where}: ${alreadyBuildingText(facts)}`;
170
+ case "up_to_date":
171
+ return `${where}: ${upToDateText(facts)}`;
172
+ case "built":
173
+ return `${where}: ${builtText(facts)}`;
174
+ }
175
+ }
176
+ const LOCAL_INDEX_NOT_WRITTEN = {
177
+ reason: "local_index_not_written",
178
+ message: "The local snapshot index couldn't record the snapshot; a run here finds it in the shared snapshot index instead.",
179
+ };
62
180
  function warningsOf(facts) {
63
181
  return [
64
182
  ...(facts.uncommitted === true
65
183
  ? [
66
184
  {
67
185
  reason: "uncommitted_changes_not_included",
68
- message: "The working tree has uncommitted changes: a base snapshot holds only the commit's tracked files.",
186
+ message: "The working tree has uncommitted changes: a runner snapshot holds only the commit's tracked files.",
69
187
  },
70
188
  ]
71
189
  : []),
72
- ...(facts.atMergeBase === false
190
+ ...(facts.atMergeBase === false && facts.ancestorOfMergeBase === false
73
191
  ? [
74
192
  {
75
- reason: "commit_not_merge_base",
76
- message: `${facts.baseRef}'s commit is not HEAD's merge-base, so a run here doesn't start from the snapshot: a run starts only from a snapshot at its merge-base.`,
193
+ reason: "commit_not_merge_base_or_ancestor",
194
+ message: `${facts.baseRef}'s commit is neither HEAD's merge-base nor an ancestor of it, so a run here doesn't start from the snapshot: a run starts only from a snapshot at its merge-base or at a commit behind it on the base ref.`,
77
195
  },
78
196
  ]
79
197
  : []),
@@ -84,30 +202,77 @@ export const outcomes = defineOutcomes({
84
202
  results: {
85
203
  built: {
86
204
  schema: builtSchema,
87
- description: "It built a base snapshot that the cache lacked, at the merge-base or, with --base, at the commit the ref names, and cached it.",
205
+ description: "It built a runner snapshot that the local snapshot index lacked, at the merge-base or, with --base, at the commit the ref names, and indexed it.",
88
206
  render: (built) => {
89
- const warnings = warningsOf(built);
207
+ const warnings = [...warningsOf(built), ...(built.localIndexWritten ? [] : [LOCAL_INDEX_NOT_WRITTEN])];
90
208
  return renderOutcome({
91
- rows: [["Recipe", built.recipe], ...RUN_CLEANUP.rows(built.cleanup)],
92
- message: `Built ${snapshotText(built.snapshot)} in ${seconds(built.ms)} (${megabytesText(built.sizeBytes)}).`,
209
+ rows: [["Runner", built.runner], ...RUN_CLEANUP.rows(built.cleanup)],
210
+ message: builtText(built),
93
211
  ...(warnings.length === 0 ? {} : { warnings }),
94
212
  });
95
213
  },
96
214
  },
97
215
  upToDate: {
98
216
  schema: upToDateSchema,
99
- description: "Nothing to build, so nothing started: the cache holds a base snapshot at the commit, the merge-base or the one --base names, for the team and project.",
217
+ description: "Nothing to build, so nothing started: the local snapshot index holds a runner snapshot at the commit, the merge-base or the one --base names, for the team and project. With --publish, the shared snapshot index holds it instead, and the local snapshot index now records it too.",
218
+ render: (facts) => {
219
+ const warnings = warningsOf(facts);
220
+ return renderOutcome({
221
+ rows: [["Runner", facts.runner]],
222
+ message: upToDateText(facts),
223
+ ...(warnings.length === 0 ? {} : { warnings }),
224
+ });
225
+ },
226
+ },
227
+ alreadyBuilding: {
228
+ schema: alreadyBuildingSchema,
229
+ description: "With --publish, another build already owns the shared snapshot index entry's sandbox for the commit, so nothing started.",
100
230
  render: (facts) => {
101
231
  const warnings = warningsOf(facts);
102
232
  return renderOutcome({
103
- rows: [["Recipe", facts.recipe]],
104
- message: `The cache holds ${snapshotText(facts.snapshot)} for this team and project. --full builds a new one.`,
233
+ rows: [
234
+ ["Runner", facts.runner],
235
+ ["Sandbox", facts.sandboxName],
236
+ ],
237
+ message: alreadyBuildingText(facts),
238
+ ...(warnings.length === 0 ? {} : { warnings }),
239
+ });
240
+ },
241
+ },
242
+ allSuitesBuilt: {
243
+ schema: allSuitesBuiltSchema,
244
+ description: "With --all-suites, it built or checked the runner snapshot of each distinct vercelSandbox({ … }) runner that the top level and the suites use.",
245
+ render: (facts) => {
246
+ // Each runner's warnings come from the same facts as a single build's; one --base gives every runner the same
247
+ // commit, so a warning they share shows once.
248
+ const warnings = [
249
+ ...new Map(facts.runners.flatMap(warningsOf).map((warning) => [`${warning.reason}\0${warning.message}`, warning])).values(),
250
+ ...(facts.runners.some((runner) => runner.result === "built" && !runner.localIndexWritten)
251
+ ? [LOCAL_INDEX_NOT_WRITTEN]
252
+ : []),
253
+ ];
254
+ return renderOutcome({
255
+ rows: [["Runners", facts.runners.map(runnerBuildText)], ...RUN_CLEANUP.rows(facts.cleanup)],
256
+ message: `Built or checked ${facts.runners.length === 1 ? "1 runner" : `${facts.runners.length} runners`}.`,
105
257
  ...(warnings.length === 0 ? {} : { warnings }),
106
258
  });
107
259
  },
108
260
  },
109
261
  },
110
262
  errors: {
263
+ conflictingOptions: {
264
+ exitCode: 2,
265
+ description: "--suite and --all-suites were both given: --suite builds one runner, and --all-suites builds them all.",
266
+ schema: z.object({
267
+ /** Each conflicting flag, as typed, and why it doesn't fit. */
268
+ conflicts: z.array(z.object({ flag: z.string(), message: z.string() })),
269
+ }),
270
+ render: ({ conflicts, }) => ({
271
+ message: conflicts.map(({ message }) => message).join(" "),
272
+ rows: [["Conflicts", conflicts.map(({ flag }) => flag)]],
273
+ next: [{ type: "text", text: "Pass --suite <name> or --all-suites, not both." }],
274
+ }),
275
+ },
111
276
  invalidConfig: configErrors.invalidConfig,
112
277
  ...suiteNotFoundErrors,
113
278
  missingRunner: runErrors.missingRunner,
@@ -136,8 +301,7 @@ export const outcomes = defineOutcomes({
136
301
  credentialsInvalid: runErrors.credentialsInvalid,
137
302
  noBaseRef: runErrors.noBaseRef,
138
303
  submodulesRefused: runErrors.submodulesRefused,
139
- mintFailed: credentialSourceErrors.mintFailed,
140
- tokenRequestFailed: credentialSourceErrors.tokenRequestFailed,
304
+ ...credentialSourceErrors,
141
305
  runnerFailed: runErrors.runnerFailed,
142
306
  refNotFound: {
143
307
  exitCode: 1,
@@ -151,20 +315,20 @@ export const outcomes = defineOutcomes({
151
315
  next: [{ type: "text", text: `Fetch the ref, such as git fetch origin, then run again.` }],
152
316
  }),
153
317
  },
154
- snapshotNotCached: {
318
+ snapshotNotIndexed: {
155
319
  exitCode: 1,
156
- description: "It built and saved the base snapshot, but couldn't write its cache entry, so no run finds it.",
320
+ description: "It built and saved the runner snapshot, but couldn't write its local snapshot index entry, so no run finds it.",
157
321
  schema: z.object({
158
- /** The snapshot it saved, whose cache entry it couldn't write. */
322
+ /** The snapshot it saved, whose local snapshot index entry it couldn't write. */
159
323
  snapshot: snapshotSchema,
160
- /** The cache file the write failed on. */
324
+ /** The local snapshot index file the write failed on. */
161
325
  path: z.string(),
162
326
  /** What the operating system said. */
163
327
  message: z.string(),
164
328
  cleanup: RUN_CLEANUP.schema,
165
329
  }),
166
330
  render: (facts) => ({
167
- message: `Saved ${snapshotText(facts.snapshot)}, but couldn't write its cache entry: ${facts.message}`,
331
+ message: `Saved ${snapshotText(facts.snapshot)}, but couldn't write its local snapshot index entry: ${facts.message}`,
168
332
  rows: [["Path", facts.path], ...RUN_CLEANUP.rows(facts.cleanup)],
169
333
  next: [
170
334
  {