@cnc-tools/storm 0.15.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 (305) 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-SZEURWRS.js → chunk-4O5C2XGJ.js} +18 -15
  10. package/dist/chunks/{chunk-VL7WFTVQ.js → chunk-4WAMTUWZ.js} +419 -340
  11. package/dist/chunks/{chunk-QVS7HRU7.js → chunk-6UHIJXZG.js} +3 -3
  12. package/dist/chunks/{chunk-CN4EFA5J.js → chunk-72ZFEMAW.js} +1 -1
  13. package/dist/chunks/{chunk-4U4DZ7VG.js → chunk-7DZE67QM.js} +2 -2
  14. package/dist/chunks/{chunk-VUPZH7J2.js → chunk-BCBKYOHW.js} +1 -1
  15. package/dist/chunks/{chunk-QUHY6FGN.js → chunk-CKGZA25H.js} +1 -18
  16. package/dist/chunks/{chunk-ZG3WQ4UF.js → chunk-D27KILIA.js} +1 -1
  17. package/dist/chunks/{chunk-KC4KDJ5K.js → chunk-DADEYJDW.js} +174 -153
  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-CXAT7ZKP.js → chunk-FNBB6V4R.js} +1 -1
  21. package/dist/chunks/{chunk-OX7X4B2L.js → chunk-GRT3UIBV.js} +18 -1
  22. package/dist/chunks/chunk-HP3CURSZ.js +88 -0
  23. package/dist/chunks/{chunk-PN5ULTTH.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-XEVHP5ZW.js → chunk-M7EKRGVD.js} +8 -8
  27. package/dist/chunks/chunk-MR77L2GK.js +340 -0
  28. package/dist/chunks/{chunk-L36GBUBB.js → chunk-RNAS7JHE.js} +1755 -522
  29. package/dist/chunks/{chunk-5GBMR4HM.js → chunk-RWIXDDCK.js} +4 -192
  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-YV7GE6EV.js → chunk-YEPFSLQR.js} +480 -375
  33. package/dist/chunks/{live-app-PI3BAN6Y.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 +4 -3
  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 +39 -4
  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 +38 -9
  51. package/dist/commands/exec/outcomes.js +32 -25
  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/planned-outcome.js +8 -1
  55. package/dist/commands/exec/progress.d.ts +10 -6
  56. package/dist/commands/exec/progress.js +38 -25
  57. package/dist/commands/exec/run-bin.d.ts +11 -11
  58. package/dist/commands/exec/run-bin.js +9 -9
  59. package/dist/commands/exec/run-flags.d.ts +69 -0
  60. package/dist/commands/exec/run-flags.js +58 -0
  61. package/dist/commands/exec/run-metadata.js +5 -5
  62. package/dist/commands/exec/run-summary.d.ts +58 -0
  63. package/dist/commands/exec/run-summary.js +205 -0
  64. package/dist/commands/exec/runner-refusals.d.ts +82 -0
  65. package/dist/commands/exec/runner-refusals.js +71 -0
  66. package/dist/commands/exec/sandbox-progress.js +3 -0
  67. package/dist/commands/exec/stopped-outcome.d.ts +12 -0
  68. package/dist/commands/exec/stopped-outcome.js +77 -0
  69. package/dist/commands/exec/view.d.ts +20 -11
  70. package/dist/commands/exec/view.js +103 -47
  71. package/dist/commands/runs/facts.d.ts +9 -4
  72. package/dist/commands/runs/facts.js +28 -11
  73. package/dist/commands/runs/list/command.d.ts +16 -6
  74. package/dist/commands/runs/list/command.js +10 -10
  75. package/dist/commands/runs/list/outcomes.d.ts +8 -3
  76. package/dist/commands/runs/logs/command.d.ts +6 -2
  77. package/dist/commands/runs/logs/command.js +10 -10
  78. package/dist/commands/runs/logs/outcomes.d.ts +3 -1
  79. package/dist/commands/runs/past-run.d.ts +14 -5
  80. package/dist/commands/runs/past-run.js +16 -5
  81. package/dist/commands/runs/show/command.d.ts +20 -8
  82. package/dist/commands/runs/show/command.js +30 -28
  83. package/dist/commands/runs/show/outcomes.d.ts +10 -4
  84. package/dist/commands/runs/show/outcomes.js +7 -5
  85. package/dist/commands/snapshots/access.d.ts +111 -0
  86. package/dist/commands/snapshots/access.js +96 -0
  87. package/dist/commands/snapshots/build/command.d.ts +360 -93
  88. package/dist/commands/snapshots/build/command.js +446 -150
  89. package/dist/commands/snapshots/build/metadata.d.ts +10 -0
  90. package/dist/commands/snapshots/build/metadata.js +31 -11
  91. package/dist/commands/snapshots/build/outcomes.d.ts +234 -43
  92. package/dist/commands/snapshots/build/outcomes.js +200 -36
  93. package/dist/commands/snapshots/list/command.d.ts +368 -27
  94. package/dist/commands/snapshots/list/command.js +296 -66
  95. package/dist/commands/snapshots/list/metadata.d.ts +16 -0
  96. package/dist/commands/snapshots/list/metadata.js +29 -6
  97. package/dist/commands/snapshots/list/outcomes.d.ts +245 -13
  98. package/dist/commands/snapshots/list/outcomes.js +221 -50
  99. package/dist/commands/snapshots/metadata.js +1 -1
  100. package/dist/commands/snapshots/prune/command.d.ts +430 -0
  101. package/dist/commands/snapshots/prune/command.js +161 -0
  102. package/dist/commands/snapshots/prune/metadata.d.ts +28 -0
  103. package/dist/commands/snapshots/prune/metadata.js +39 -0
  104. package/dist/commands/snapshots/prune/outcomes.d.ts +208 -0
  105. package/dist/commands/snapshots/prune/outcomes.js +78 -0
  106. package/dist/commands/suites/list/command.js +19 -18
  107. package/dist/commands/suites/list/outcomes.js +4 -4
  108. package/dist/commands/test/command.d.ts +39 -4
  109. package/dist/commands/test/command.js +50 -255
  110. package/dist/commands/test/metadata.js +1 -1
  111. package/dist/commands/test/outcomes.d.ts +19 -2
  112. package/dist/commands/test/outcomes.js +2 -2
  113. package/dist/config/check-runner.d.ts +5 -3
  114. package/dist/config/check-runner.js +33 -7
  115. package/dist/config/check-suites.js +1 -0
  116. package/dist/config/credential-resolver.d.ts +50 -5
  117. package/dist/config/credential-resolver.js +51 -19
  118. package/dist/config/credential-settle.d.ts +6 -2
  119. package/dist/config/credential-settle.js +11 -5
  120. package/dist/config/gateways.d.ts +7 -3
  121. package/dist/config/index.d.ts +4 -5
  122. package/dist/config/index.js +3 -4
  123. package/dist/config/live/config-gateway.js +5 -2
  124. package/dist/config/load.d.ts +21 -4
  125. package/dist/config/load.js +129 -15
  126. package/dist/config/runner.d.ts +7 -8
  127. package/dist/config/runner.js +1 -1
  128. package/dist/config/schema.d.ts +17 -5
  129. package/dist/config/schema.js +11 -3
  130. package/dist/config/typed-options.d.ts +1 -6
  131. package/dist/config/typed-options.js +2 -10
  132. package/dist/config-file/define.d.ts +1 -11
  133. package/dist/config-file/define.js +3 -3
  134. package/dist/config-file/runner.d.ts +5 -6
  135. package/dist/config-file/toolchain.d.ts +13 -7
  136. package/dist/config-file/toolchain.js +53 -37
  137. package/dist/context.d.ts +8 -6
  138. package/dist/context.js +7 -6
  139. package/dist/core/across-sandboxes.d.ts +7 -6
  140. package/dist/core/across-sandboxes.js +123 -152
  141. package/dist/core/coordinator.d.ts +166 -0
  142. package/dist/core/coordinator.js +233 -0
  143. package/dist/core/events.d.ts +2 -2
  144. package/dist/core/index.d.ts +4 -2
  145. package/dist/core/index.js +1 -1
  146. package/dist/core/outcomes.d.ts +148 -0
  147. package/dist/core/{sandbox-end.js → outcomes.js} +28 -4
  148. package/dist/core/resources.d.ts +31 -53
  149. package/dist/core/resources.js +32 -70
  150. package/dist/core/run-state.d.ts +7 -1
  151. package/dist/core/run-state.js +2 -0
  152. package/dist/core/run.d.ts +32 -236
  153. package/dist/core/run.js +106 -266
  154. package/dist/core/state-directory.d.ts +1 -1
  155. package/dist/core/state-directory.js +2 -2
  156. package/dist/credential/gateways.d.ts +15 -1
  157. package/dist/credential/index.d.ts +4 -3
  158. package/dist/credential/index.js +3 -2
  159. package/dist/credential/live/vercel-cli-gateway.d.ts +1 -1
  160. package/dist/credential/live/vercel-cli-gateway.js +1 -1
  161. package/dist/credential/live/vercel-oidc-token-gateway.d.ts +11 -0
  162. package/dist/credential/live/vercel-oidc-token-gateway.js +16 -0
  163. package/dist/credential/source.d.ts +73 -6
  164. package/dist/credential/source.js +55 -2
  165. package/dist/extension-commands.d.ts +6 -1
  166. package/dist/extension-commands.js +15 -1
  167. package/dist/extensions/github/resource.d.ts +1 -1
  168. package/dist/extensions/github/resource.js +1 -1
  169. package/dist/extensions/testserver/commands/pool/create/command.d.ts +35 -2
  170. package/dist/extensions/testserver/commands/pool/create/command.js +7 -7
  171. package/dist/extensions/testserver/commands/pool/create/metadata.js +5 -5
  172. package/dist/extensions/testserver/commands/pool/create/outcomes.d.ts +17 -1
  173. package/dist/extensions/testserver/commands/pool/list/command.js +4 -4
  174. package/dist/extensions/testserver/credential-facts.d.ts +6 -2
  175. package/dist/extensions/testserver/credential-facts.js +29 -11
  176. package/dist/extensions/testserver/lifecycle.js +7 -1
  177. package/dist/extensions/testserver/limit.d.ts +3 -0
  178. package/dist/extensions/testserver/limit.js +3 -0
  179. package/dist/extensions/testserver/provision.d.ts +8 -1
  180. package/dist/extensions/testserver/provision.js +8 -3
  181. package/dist/extensions/testserver/refusals.d.ts +6 -1
  182. package/dist/extensions/testserver/refusals.js +16 -1
  183. package/dist/extensions/testserver/resource.d.ts +2 -2
  184. package/dist/extensions/testserver/resource.js +2 -2
  185. package/dist/extensions/testserver/result.d.ts +1 -1
  186. package/dist/extensions/testserver/result.js +9 -4
  187. package/dist/planning/driver-file-lists.d.ts +0 -15
  188. package/dist/planning/driver-file-lists.js +2 -21
  189. package/dist/planning/plan-only.d.ts +7 -15
  190. package/dist/planning/plan-only.js +16 -22
  191. package/dist/planning/run-kind-flags.js +2 -2
  192. package/dist/planning/run-plan.d.ts +45 -13
  193. package/dist/planning/run-plan.js +4 -3
  194. package/dist/planning/suites.d.ts +1 -1
  195. package/dist/planning/suites.js +2 -2
  196. package/dist/planning/test-plan.d.ts +9 -0
  197. package/dist/planning/test-plan.js +10 -2
  198. package/dist/run-directory/recording.js +2 -2
  199. package/dist/run-directory/run-record.d.ts +21 -6
  200. package/dist/run-directory/run-record.js +12 -9
  201. package/dist/runner/base.d.ts +0 -6
  202. package/dist/runner/base.js +1 -16
  203. package/dist/runner/build-snapshots.d.ts +55 -29
  204. package/dist/runner/build-snapshots.js +135 -35
  205. package/dist/runner/context.d.ts +15 -7
  206. package/dist/runner/context.js +19 -6
  207. package/dist/runner/events.d.ts +16 -10
  208. package/dist/runner/gateways.d.ts +92 -21
  209. package/dist/runner/gateways.js +1 -1
  210. package/dist/runner/index.d.ts +11 -7
  211. package/dist/runner/index.js +9 -4
  212. package/dist/runner/live/sandbox-errors.d.ts +2 -0
  213. package/dist/runner/live/sandbox-errors.js +4 -0
  214. package/dist/runner/live/sandbox-gateway.js +141 -3
  215. package/dist/runner/live/snapshot-index-gateway.d.ts +12 -0
  216. package/dist/runner/live/{snapshot-cache-gateway.js → snapshot-index-gateway.js} +11 -11
  217. package/dist/runner/live/snapshot-records.js +6 -7
  218. package/dist/runner/local-snapshot-index.d.ts +199 -0
  219. package/dist/runner/local-snapshot-index.js +211 -0
  220. package/dist/runner/network-policy.d.ts +6 -6
  221. package/dist/runner/network-policy.js +7 -7
  222. package/dist/runner/policy-writes.d.ts +1 -1
  223. package/dist/runner/policy-writes.js +1 -1
  224. package/dist/runner/prepare.d.ts +25 -24
  225. package/dist/runner/prepare.js +28 -20
  226. package/dist/runner/ready.d.ts +18 -10
  227. package/dist/runner/ready.js +104 -33
  228. package/dist/runner/sandboxed-command.d.ts +3 -3
  229. package/dist/runner/sandboxed-command.js +3 -3
  230. package/dist/runner/scope.d.ts +10 -6
  231. package/dist/runner/scope.js +10 -3
  232. package/dist/runner/secrets.d.ts +13 -13
  233. package/dist/runner/secrets.js +18 -15
  234. package/dist/runner/session.d.ts +8 -8
  235. package/dist/runner/session.js +3 -3
  236. package/dist/runner/shared-snapshot-entry.d.ts +92 -0
  237. package/dist/runner/shared-snapshot-entry.js +168 -0
  238. package/dist/runner/shared-snapshot-list.d.ts +81 -0
  239. package/dist/runner/shared-snapshot-list.js +155 -0
  240. package/dist/runner/shared-snapshot-lookup.d.ts +51 -0
  241. package/dist/runner/shared-snapshot-lookup.js +118 -0
  242. package/dist/runner/shared-snapshot-prune.d.ts +58 -0
  243. package/dist/runner/shared-snapshot-prune.js +133 -0
  244. package/dist/runner/snapshot-build.d.ts +42 -14
  245. package/dist/runner/snapshot-build.js +38 -28
  246. package/dist/runner/snapshot-choice.js +1 -1
  247. package/dist/runner/snapshot-inspect.d.ts +39 -40
  248. package/dist/runner/snapshot-inspect.js +58 -38
  249. package/dist/runner/snapshot-key.d.ts +30 -21
  250. package/dist/runner/snapshot-key.js +49 -29
  251. package/dist/runner/steps.d.ts +1 -1
  252. package/dist/runner/steps.js +1 -1
  253. package/dist/runner/{recipe-check.d.ts → vercel-sandbox-check.d.ts} +2 -2
  254. package/dist/runner/{recipe-check.js → vercel-sandbox-check.js} +3 -2
  255. package/dist/runner/{recipe.d.ts → vercel-sandbox-options.d.ts} +82 -82
  256. package/dist/runner/vercel-sandbox-options.js +510 -0
  257. package/dist/runner/{recipe-secrets.d.ts → vercel-sandbox-secrets.d.ts} +6 -6
  258. package/dist/runner/{recipe-secrets.js → vercel-sandbox-secrets.js} +20 -20
  259. package/dist/sdk/extension/commands.d.ts +8 -3
  260. package/dist/sdk/extension/commands.js +3 -1
  261. package/dist/sdk/extension/credential-diagnosis.d.ts +3 -1
  262. package/dist/sdk/extension/credential-diagnosis.js +25 -5
  263. package/dist/sdk/extension/credential-source.d.ts +20 -3
  264. package/dist/sdk/extension/credential-source.js +4 -4
  265. package/dist/sdk/extension/index.d.ts +3 -2
  266. package/dist/sdk/extension/index.js +2 -1
  267. package/dist/sdk/extension/resource-definition.d.ts +4 -3
  268. package/dist/sdk/extension/resource-definition.js +3 -2
  269. package/dist/sdk/extension/resource-factory.js +3 -4
  270. package/dist/sdk/extension/secret-source.d.ts +1 -1
  271. package/dist/sdk/extension/secret-source.js +1 -1
  272. package/dist/sdk/extension/vercel-oidc-facts.d.ts +20 -0
  273. package/dist/sdk/extension/vercel-oidc-facts.js +20 -0
  274. package/dist/sdk/run/present.d.ts +3 -3
  275. package/dist/sdk/run/present.js +1 -3
  276. package/dist/shared/cleanup.d.ts +3 -3
  277. package/dist/shared/cleanup.js +15 -5
  278. package/dist/shared/snapshot-text.d.ts +4 -4
  279. package/dist/shared/snapshot-text.js +11 -11
  280. package/dist/time/duration.js +1 -1
  281. package/package.json +3 -2
  282. package/skills/overview.md +6 -4
  283. package/skills/plan-runs.md +2 -2
  284. package/skills/read-run-output.md +6 -6
  285. package/dist/chunks/chunk-E4PJNZVG.js +0 -783
  286. package/dist/chunks/chunk-RAQEXKL6.js +0 -2591
  287. package/dist/commands/exec/across-sandboxes-run.d.ts +0 -180
  288. package/dist/commands/exec/across-sandboxes-run.js +0 -339
  289. package/dist/commands/exec/plan-only.d.ts +0 -10
  290. package/dist/commands/exec/plan-only.js +0 -46
  291. package/dist/commands/exec/run-command.d.ts +0 -476
  292. package/dist/commands/exec/run-command.js +0 -604
  293. package/dist/commands/exec/run-planned.d.ts +0 -20
  294. package/dist/commands/exec/run-planned.js +0 -22
  295. package/dist/commands/exec/sandbox-view.d.ts +0 -19
  296. package/dist/commands/exec/sandbox-view.js +0 -72
  297. package/dist/commands/test/plan.d.ts +0 -92
  298. package/dist/commands/test/plan.js +0 -128
  299. package/dist/config/recipe-run.d.ts +0 -33
  300. package/dist/config/recipe-run.js +0 -28
  301. package/dist/core/sandbox-end.d.ts +0 -64
  302. package/dist/runner/live/snapshot-cache-gateway.d.ts +0 -12
  303. package/dist/runner/recipe.js +0 -425
  304. package/dist/runner/snapshot-cache.d.ts +0 -148
  305. package/dist/runner/snapshot-cache.js +0 -126
@@ -1,85 +1,84 @@
1
1
  import type { CheckoutFailure, CheckoutHead, RunnerSnapshotEntry, UnreadableSnapshotEntry } from "./gateways.ts";
2
- import type { CheckedRecipe } from "./recipe.ts";
3
- import { type SnapshotCacheContext, type SnapshotRejectionReason } from "./snapshot-cache.ts";
2
+ import type { CheckedVercelSandboxOptions } from "./vercel-sandbox-options.ts";
3
+ import { type LocalSnapshotIndexContext, type SnapshotRejectionReason } from "./local-snapshot-index.ts";
4
4
  /**
5
- * One cached runner snapshot, as a checkout sees it: from the checkout's Git history, whether HEAD is its base or
6
- * holds it (`inHistory`), which an amend or a rebase can change, and how many commits HEAD has that its base lacks
7
- * (`builtBehind`). `inHistory` is null when storm didn't check it: outside a Git checkout, or without a recipe or a
8
- * base; `builtBehind` is null then too, and when the base isn't in HEAD's history. `picked` says a run here starts
9
- * from it, for its team and project.
10
- * `reason` says why a run here doesn't (`SnapshotRejectionReason`), `other-recipe` for another recipe's, or null for
5
+ * One runner snapshot in the local snapshot index, as a checkout sees it: from the checkout's Git history, whether HEAD
6
+ * is its base or holds it (`inHistory`), which an amend or a rebase can change, and how many commits HEAD has that its
7
+ * base lacks (`builtBehind`). `inHistory` is null when storm didn't check it: outside a Git checkout, or without a
8
+ * runner or a base; `builtBehind` is null then too, and when the base isn't in HEAD's history. `picked` says a run
9
+ * here starts from it, for its team and project.
10
+ * `reason` says why a run here doesn't (`SnapshotRejectionReason`), `other-runner` for another runner's, or null for
11
11
  * a picked one and when storm checked nothing.
12
12
  */
13
13
  export interface InspectedSnapshot {
14
14
  readonly entry: RunnerSnapshotEntry;
15
15
  readonly inHistory: boolean | null;
16
16
  readonly builtBehind: number | null;
17
+ readonly commitsBehindMergeBase: number | null;
17
18
  readonly expired: boolean;
18
19
  readonly picked: boolean;
19
- readonly reason: SnapshotRejectionReason | "other-recipe" | null;
20
+ readonly reason: SnapshotRejectionReason | "other-runner" | null;
20
21
  }
21
22
  /**
22
- * Why the inspection picked for no recipe: the directory is in no Git checkout (`no-checkout`), no runner recipe
23
- * applies there (`no-recipe`), or no base ref of the recipe exists locally and shares history with HEAD (`no-base`).
23
+ * Why the inspection picked for no runner: the directory is in no Git checkout (`no-checkout`), no Vercel Sandbox
24
+ * runner applies there (`no-runner`), or no base ref of the runner exists locally and shares history with HEAD
25
+ * (`no-base`).
24
26
  */
25
- export type UnpickedReason = "no-checkout" | "no-recipe" | "no-base";
26
- /** What `inspectSnapshotCache` found. */
27
- export interface SnapshotCacheInspection {
28
- /** Where the cache lives. */
27
+ export type UnpickedReason = "no-checkout" | "no-runner" | "no-base";
28
+ /** What `inspectLocalSnapshotIndex` found. */
29
+ export interface LocalSnapshotIndexInspection {
30
+ /** Where the local snapshot index lives. */
29
31
  readonly directory: string;
30
- /** The checkout the directory is in: its root, HEAD, and HEAD's merge-base with a base ref; null without one. */
32
+ /**
33
+ * The checkout the directory is in: its root, HEAD, and HEAD's merge-base with a base ref, with how many commits HEAD
34
+ * has that the merge-base lacks; null without one.
35
+ */
31
36
  readonly checkout: {
32
37
  readonly repoRoot: string;
33
38
  readonly head: CheckoutHead;
34
39
  readonly mergeBase: {
35
40
  readonly commit: string;
36
41
  readonly ref: string;
42
+ readonly commitsAfterBase: number;
37
43
  } | null;
38
44
  } | null;
39
- /** The recipe a run here uses, by name, when storm picked for it; else why it picked for none. */
45
+ /** The runner a run here uses, by name, when storm picked for it; else why it picked for none. */
40
46
  readonly picking: {
41
- readonly kind: "recipe";
42
- readonly recipe: string;
47
+ readonly kind: "runner";
48
+ readonly runner: string;
43
49
  } | {
44
50
  readonly kind: "none";
45
51
  readonly why: UnpickedReason;
46
52
  };
47
- /** The recipe's snapshots, and with `all` every other recipe's too. */
53
+ /** The run's snapshot key at the merge-base, when storm picked for a runner; else null. */
54
+ readonly snapshotKey: string | null;
55
+ /** The runner's snapshots, and with `all` every other runner's too. */
48
56
  readonly snapshots: readonly InspectedSnapshot[];
49
57
  readonly unreadable: readonly UnreadableSnapshotEntry[];
50
58
  }
51
59
  /**
52
- * How an inspection ended: what it found; the cache it couldn't list; git failing while it checked the checkout or a
53
- * snapshot (`checkout-failed`); or a step function of the recipe that failed or returned something storm can't use at
54
- * the merge-base (`invalid-recipe`), as a run's local checks refuse it, with `path` the key inside the recipe.
60
+ * How an inspection ended: what it found; the local snapshot index it couldn't list (`local-index-unreadable`); git
61
+ * failing while it checked the checkout or a snapshot (`checkout-failed`); or a declared base file of the runner that
62
+ * couldn't be read at the merge-base (`invalid-runner`), as a run's local checks refuse it, with `path` the key inside
63
+ * the runner options.
55
64
  */
56
- export type SnapshotCacheInspectionOutcome = {
65
+ export type LocalSnapshotIndexInspectionOutcome = {
57
66
  readonly kind: "ok";
58
- readonly inspection: SnapshotCacheInspection;
67
+ readonly inspection: LocalSnapshotIndexInspection;
59
68
  } | {
60
- readonly kind: "cache-unreadable";
69
+ readonly kind: "local-index-unreadable";
61
70
  readonly path: string;
62
71
  readonly message: string;
63
72
  } | {
64
73
  readonly kind: "checkout-failed";
65
74
  readonly failure: CheckoutFailure;
66
75
  } | {
67
- readonly kind: "invalid-recipe";
76
+ readonly kind: "invalid-runner";
68
77
  readonly path: readonly string[];
69
78
  readonly problem: string;
70
79
  };
71
- /**
72
- * Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
73
- * checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
74
- * here starts from, by a run's own rule (`classifySnapshotEntries`, `pickSnapshot`), and gives each other
75
- * snapshot of the recipe the reason it isn't picked. It runs the recipe's snapshot steps at the merge-base for the
76
- * run's snapshot key, as a run does. Otherwise it picks none and
77
- * says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
78
- * `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
79
- * the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
80
- */
81
- export declare function inspectSnapshotCache(context: SnapshotCacheContext, request: {
80
+ export declare function inspectLocalSnapshotIndex(context: LocalSnapshotIndexContext, request: {
82
81
  readonly cwd: string;
83
- readonly recipe: CheckedRecipe | undefined;
82
+ readonly options: CheckedVercelSandboxOptions | undefined;
84
83
  readonly all: boolean;
85
- }): Promise<SnapshotCacheInspectionOutcome>;
84
+ }): Promise<LocalSnapshotIndexInspectionOutcome>;
@@ -1,32 +1,22 @@
1
- // What the runner snapshot cache holds, as a checkout sees it: every cached snapshot with where it was built, in
2
- // commits, and for the checkout's recipe which one a run here starts from and why not from each other one. It reads
3
- // the cache and Git, and changes nothing: no file is removed, nothing is minted, and no sandbox starts.
1
+ // What the local snapshot index holds, as a checkout sees it: every indexed snapshot with where it was built, in
2
+ // commits, and for the checkout's runner which one a run here starts from and why not from each other one. It reads
3
+ // the local snapshot index and Git, and changes nothing: no file is removed, nothing is minted, and no sandbox starts.
4
4
  import { resolveBase } from "./base.js";
5
- import { classifySnapshotEntries, isExpiredEntry, pickSnapshot, } from "./snapshot-cache.js";
6
- import { snapshotStepsAt } from "./snapshot-key.js";
7
- /**
8
- * Inspects the cache from `cwd` for `recipe`, the runner recipe that applies there, if any. With a recipe, in a Git
9
- * checkout whose HEAD shares history with one of its base refs, it marks for each team and project the snapshot a run
10
- * here starts from, by a run's own rule (`classifySnapshotEntries`, `pickSnapshot`), and gives each other
11
- * snapshot of the recipe the reason it isn't picked. It runs the recipe's snapshot steps at the merge-base for the
12
- * run's snapshot key, as a run does. Otherwise it picks none and
13
- * says why. `all` adds the snapshots of other recipes, and of the recipe's other regions and runtimes, as
14
- * `other-recipe`. It lists the cache once and classifies that listing, which removes no file, so an expired entry of
15
- * the recipe stays and is `expired`. A git failure ends it with `checkout-failed`, as it ends a run.
16
- */
17
- export async function inspectSnapshotCache(context, request) {
5
+ import { classifySnapshotEntries, isExpiredEntry, pickSnapshot, resolveAncestorDistances, } from "./local-snapshot-index.js";
6
+ import { snapshotInputsAt } from "./snapshot-key.js";
7
+ export async function inspectLocalSnapshotIndex(context, request) {
18
8
  const { checkout, runnerSnapshots } = context;
19
- const { recipe } = request;
9
+ const { options } = request;
20
10
  const listed = await runnerSnapshots.listEntries();
21
11
  if (!listed.ok)
22
- return { kind: "cache-unreadable", ...listed.failure };
12
+ return { kind: "local-index-unreadable", ...listed.failure };
23
13
  const { directory, entries, unreadable } = listed.value;
24
14
  const now = context.clock.now();
25
- const ofRecipe = (entry) => recipe !== undefined &&
26
- entry.recipeName === recipe.name &&
27
- entry.region === recipe.region &&
28
- entry.runtime === recipe.runtime;
29
- const shows = (entry) => request.all || recipe === undefined || ofRecipe(entry);
15
+ const ofRunner = (entry) => options !== undefined &&
16
+ entry.runnerName === options.name &&
17
+ entry.region === options.region &&
18
+ entry.runtime === options.runtime;
19
+ const shows = (entry) => request.all || options === undefined || ofRunner(entry);
30
20
  const shown = entries.filter(shows);
31
21
  const root = await checkout.repositoryRoot({ cwd: request.cwd });
32
22
  const head = root.ok ? await checkout.head({ repoRoot: root.value }) : undefined;
@@ -37,41 +27,53 @@ export async function inspectSnapshotCache(context, request) {
37
27
  directory,
38
28
  checkout: null,
39
29
  picking: { kind: "none", why: "no-checkout" },
30
+ snapshotKey: null,
40
31
  snapshots: shown.map((entry) => unchecked(entry, now)),
41
32
  unreadable,
42
33
  },
43
34
  };
44
35
  }
45
36
  const repoRoot = root.value;
46
- const resolved = recipe === undefined ? undefined : await resolveBase(checkout, { repoRoot, baseRefs: recipe.baseRefs });
37
+ const resolved = options === undefined ? undefined : await resolveBase(checkout, { repoRoot, baseRefs: options.baseRefs });
47
38
  if (resolved?.kind === "failed")
48
39
  return { kind: "checkout-failed", failure: resolved.failure };
49
- if (recipe === undefined || resolved === undefined || resolved.kind !== "resolved") {
40
+ if (options === undefined || resolved === undefined || resolved.kind !== "resolved") {
50
41
  return {
51
42
  kind: "ok",
52
43
  inspection: {
53
44
  directory,
54
45
  checkout: { repoRoot, head: head.value, mergeBase: null },
55
- picking: { kind: "none", why: recipe === undefined ? "no-recipe" : "no-base" },
46
+ picking: { kind: "none", why: options === undefined ? "no-runner" : "no-base" },
47
+ snapshotKey: null,
56
48
  snapshots: shown.map((entry) => unchecked(entry, now)),
57
49
  unreadable,
58
50
  },
59
51
  };
60
52
  }
61
53
  const mergeBase = resolved.base;
62
- const steps = await snapshotStepsAt(checkout, { repoRoot, base: mergeBase, recipe });
63
- if (!steps.ok)
64
- return { kind: "invalid-recipe", path: steps.path, problem: steps.problem };
54
+ const inputs = await snapshotInputsAt(checkout, { repoRoot, base: mergeBase, options });
55
+ if (!inputs.ok)
56
+ return { kind: "invalid-runner", path: inputs.path, problem: inputs.problem };
65
57
  const afterBase = await checkout.commitCount({ repoRoot, from: mergeBase, to: "HEAD" });
66
58
  if (!afterBase.ok)
67
59
  return { kind: "checkout-failed", failure: afterBase.failure };
68
- // The one listing above is classified as a run would, but nothing is removed: an expired entry is `expired`.
60
+ // The one listing above is classified as a run would, with ancestors of the merge-base allowed, and nothing is
61
+ // removed: an expired entry is `expired`.
62
+ const ancestorDistances = await resolveAncestorDistances(context, {
63
+ repoRoot,
64
+ entries,
65
+ options,
66
+ mergeBase,
67
+ });
68
+ if (!ancestorDistances.ok)
69
+ return { kind: "checkout-failed", failure: ancestorDistances.failure };
69
70
  const read = classifySnapshotEntries(context, {
70
71
  entries,
71
- recipe,
72
+ options,
72
73
  base: mergeBase,
73
- snapshotKey: steps.key,
74
+ snapshotKey: inputs.key,
74
75
  commitsAfterBase: afterBase.value,
76
+ ancestorDistances: ancestorDistances.value,
75
77
  });
76
78
  // The choice is per team and project, since the credential that names them isn't minted here. Every entry that isn't
77
79
  // a candidate keeps the classification's reason, since it is ruled out whoever the run's credential names.
@@ -82,7 +84,12 @@ export async function inspectSnapshotCache(context, request) {
82
84
  if (pick !== undefined)
83
85
  picked.add(pick);
84
86
  }
85
- const place = historyPlacer(context, { repoRoot, mergeBase, commitsAfterBase: afterBase.value });
87
+ const place = historyPlacer(context, {
88
+ repoRoot,
89
+ mergeBase,
90
+ commitsAfterBase: afterBase.value,
91
+ ancestorDistances: ancestorDistances.value,
92
+ });
86
93
  const snapshots = [];
87
94
  for (const verdict of read.verdicts) {
88
95
  const { entry } = verdict;
@@ -95,6 +102,7 @@ export async function inspectSnapshotCache(context, request) {
95
102
  entry,
96
103
  inHistory: true,
97
104
  builtBehind: candidate.builtBehind,
105
+ commitsBehindMergeBase: candidate.commitsBehindMergeBase,
98
106
  expired,
99
107
  picked: picked.has(candidate),
100
108
  reason: null,
@@ -108,28 +116,35 @@ export async function inspectSnapshotCache(context, request) {
108
116
  snapshots.push({
109
117
  entry,
110
118
  ...placed.value,
119
+ commitsBehindMergeBase: null,
111
120
  expired,
112
121
  picked: false,
113
- reason: verdict.kind === "rejected" ? verdict.rejection.reason : "other-recipe",
122
+ reason: verdict.kind === "rejected" ? verdict.rejection.reason : "other-runner",
114
123
  });
115
124
  }
116
125
  return {
117
126
  kind: "ok",
118
127
  inspection: {
119
128
  directory,
120
- checkout: { repoRoot, head: head.value, mergeBase: { commit: mergeBase, ref: resolved.ref } },
121
- picking: { kind: "recipe", recipe: recipe.name },
129
+ checkout: {
130
+ repoRoot,
131
+ head: head.value,
132
+ mergeBase: { commit: mergeBase, ref: resolved.ref, commitsAfterBase: afterBase.value },
133
+ },
134
+ picking: { kind: "runner", runner: options.name },
135
+ snapshotKey: inputs.key,
122
136
  snapshots,
123
137
  unreadable,
124
138
  },
125
139
  };
126
140
  }
127
- /** An entry storm checked nothing of: outside a Git checkout, or with no recipe or no base to pick for. */
141
+ /** An entry storm checked nothing of: outside a Git checkout, or with no runner or no base to pick for. */
128
142
  function unchecked(entry, now) {
129
143
  return {
130
144
  entry,
131
145
  inHistory: null,
132
146
  builtBehind: null,
147
+ commitsBehindMergeBase: null,
133
148
  expired: isExpiredEntry(entry, now),
134
149
  picked: false,
135
150
  reason: null,
@@ -137,12 +152,17 @@ function unchecked(entry, now) {
137
152
  }
138
153
  /**
139
154
  * Where a base sits in HEAD's history, for the list: whether HEAD is it or holds it, and if so how many commits HEAD
140
- * has that it lacks. Git is asked at most once per base, and nothing for the merge-base, whose count the caller has.
155
+ * has that it lacks. Git is asked at most once per base, and nothing for the merge-base or an ancestor of it, whose
156
+ * counts the caller has.
141
157
  */
142
158
  function historyPlacer(context, request) {
143
159
  const { repoRoot } = request;
144
160
  const known = new Map([
145
161
  [request.mergeBase, { inHistory: true, builtBehind: request.commitsAfterBase }],
162
+ ...Object.entries(request.ancestorDistances).map(([base, commitsBehindMergeBase]) => [
163
+ base,
164
+ { inHistory: true, builtBehind: request.commitsAfterBase + commitsBehindMergeBase },
165
+ ]),
146
166
  ]);
147
167
  return async (base) => {
148
168
  const answer = known.get(base);
@@ -1,12 +1,17 @@
1
1
  import type { CheckoutGateway } from "./gateways.ts";
2
- import { type CheckedRecipe, type RunnerStep } from "./recipe.ts";
2
+ import { type CheckedVercelSandboxOptions, type RunnerStep } from "./vercel-sandbox-options.ts";
3
3
  /**
4
4
  * Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
5
5
  * uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
6
- * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the recipe's credential
7
- * source identities (`credentials=`).
6
+ * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the runner's credential
7
+ * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`).
8
8
  */
9
- export declare const SNAPSHOT_FORMAT = 4;
9
+ export declare const SNAPSHOT_FORMAT = 5;
10
+ /** One declared base file read from the base commit, to stage into `/vercel/sandbox/<path>` before toolchain steps. */
11
+ export interface DeclaredBaseFile {
12
+ readonly path: string;
13
+ readonly text: string;
14
+ }
10
15
  /** Where the repository lives in every runner and build sandbox. */
11
16
  export declare const SANDBOX_ROOT = "/vercel/sandbox";
12
17
  /** The names of the files uploaded to a sandbox's staging directory. */
@@ -33,23 +38,26 @@ export declare function baseIndexScript(base: string, staging: string): string;
33
38
  */
34
39
  export declare function applyScript(staging: string, root?: string): string;
35
40
  /**
36
- * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the recipe's
37
- * credentials read, sorted, once each, joined with ",">`, each toolchain step's label and script, the base-index script
38
- * with the placeholders `<base>` and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe
39
- * without credentials gives `credentials=`. Every snapshot step gets every credential, so the source identities are in
40
- * the key once, never the values, domains, or headers: a recipe that reads another source builds another snapshot, and
41
- * every machine with the same recipe shares one. The base isn't in the key: a cache entry records it beside the key.
41
+ * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the runner's
42
+ * credentials read, sorted, once each, joined with ",">`, `baseFiles=<count>` followed by each sorted declared base
43
+ * file's path and text, each toolchain step's label and script, the base-index script with the placeholders `<base>`
44
+ * and `<staging>`, and each prebuild step's label and script, joined with NUL. A runner without credentials gives
45
+ * `credentials=`, and one without declared base files gives `baseFiles=0`. Every snapshot step gets every credential,
46
+ * so the source identities are in the key once, never the values, domains, or headers: a runner that reads another
47
+ * source builds another snapshot, and every machine with the same runner options shares one. The base isn't in the
48
+ * key: a
49
+ * cache entry records it beside the key.
42
50
  */
43
51
  export declare function snapshotKey(steps: {
44
52
  readonly credentials: readonly string[];
53
+ readonly baseFiles: readonly DeclaredBaseFile[];
45
54
  readonly toolchains: readonly RunnerStep[];
46
55
  readonly prebuild: readonly RunnerStep[];
47
56
  }): string;
48
- /** A recipe's snapshot steps at one base and their key, or the step key whose function failed there and why. */
49
- export type SnapshotStepsAt = {
57
+ /** A runner's snapshot inputs at one base and their key, or why a declared base file couldn't be read there. */
58
+ export type SnapshotInputsAt = {
50
59
  readonly ok: true;
51
- readonly toolchains: readonly RunnerStep[];
52
- readonly prebuild: readonly RunnerStep[];
60
+ readonly baseFiles: readonly DeclaredBaseFile[];
53
61
  readonly key: string;
54
62
  } | {
55
63
  readonly ok: false;
@@ -57,14 +65,15 @@ export type SnapshotStepsAt = {
57
65
  readonly problem: string;
58
66
  };
59
67
  /**
60
- * Evaluates `recipe`'s toolchain and prebuild steps at `base`, and computes their snapshot key with the secret source
61
- * identities the recipe's credentials read.
68
+ * Reads `options`'s declared base files at `base` and computes its snapshot key with the secret source identities the
69
+ * runner's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
70
+ * unreadable at `base`.
62
71
  */
63
- export declare function snapshotStepsAt(checkout: CheckoutGateway, request: {
72
+ export declare function snapshotInputsAt(checkout: CheckoutGateway, request: {
64
73
  readonly repoRoot: string;
65
74
  readonly base: string;
66
- readonly recipe: {
67
- readonly snapshot: Pick<CheckedRecipe["snapshot"], "toolchains" | "prebuild">;
68
- readonly credentials: CheckedRecipe["credentials"];
75
+ readonly options: {
76
+ readonly snapshot: Pick<CheckedVercelSandboxOptions["snapshot"], "toolchains" | "prebuild">;
77
+ readonly credentials: CheckedVercelSandboxOptions["credentials"];
69
78
  };
70
- }): Promise<SnapshotStepsAt>;
79
+ }): Promise<SnapshotInputsAt>;
@@ -1,16 +1,16 @@
1
1
  // What a runner snapshot is built from, and the scripts that commit a base in a build sandbox and a run's changes in
2
- // a runner sandbox. The snapshot key hashes the steps' text and the secret source identities the recipe's credentials
3
- // read, so editing a step means a new snapshot.
2
+ // a runner sandbox. The snapshot key hashes the declared base files' paths and contents, the steps' text, and the
3
+ // secret source identities the runner's credentials read, so editing a step or a declared base file means a new
4
+ // snapshot.
4
5
  import { createHash } from "node:crypto";
5
- import { baseStepContext } from "./base.js";
6
- import { credentialSourceIds, resolveSteps } from "./recipe.js";
6
+ import { credentialSourceIds, declaredBaseFilePaths, } from "./vercel-sandbox-options.js";
7
7
  /**
8
8
  * Bump when a runner snapshot changes in a way its steps' text doesn't show (the scripts between the steps, what is
9
9
  * uploaded, the build sandbox), or the key's encoding changes, so earlier snapshots stop matching. 2 added each step's
10
- * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the recipe's credential
11
- * source identities (`credentials=`).
10
+ * runner secret names. 3 dropped dev snapshots. 4 replaced per-step runner secret names with the runner's credential
11
+ * source identities (`credentials=`). 5 added declared base files' paths and contents (`baseFiles=`).
12
12
  */
13
- export const SNAPSHOT_FORMAT = 4;
13
+ export const SNAPSHOT_FORMAT = 5;
14
14
  /** Where the repository lives in every runner and build sandbox. */
15
15
  export const SANDBOX_ROOT = "/vercel/sandbox";
16
16
  /** The names of the files uploaded to a sandbox's staging directory. */
@@ -70,19 +70,25 @@ export function applyScript(staging, root = SANDBOX_ROOT) {
70
70
  ], root);
71
71
  }
72
72
  /**
73
- * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the recipe's
74
- * credentials read, sorted, once each, joined with ",">`, each toolchain step's label and script, the base-index script
75
- * with the placeholders `<base>` and `<staging>`, and each prebuild step's label and script, joined with NUL. A recipe
76
- * without credentials gives `credentials=`. Every snapshot step gets every credential, so the source identities are in
77
- * the key once, never the values, domains, or headers: a recipe that reads another source builds another snapshot, and
78
- * every machine with the same recipe shares one. The base isn't in the key: a cache entry records it beside the key.
73
+ * The snapshot key: sha256 hex over `format=<SNAPSHOT_FORMAT>`, `credentials=<the secret source identities the runner's
74
+ * credentials read, sorted, once each, joined with ",">`, `baseFiles=<count>` followed by each sorted declared base
75
+ * file's path and text, each toolchain step's label and script, the base-index script with the placeholders `<base>`
76
+ * and `<staging>`, and each prebuild step's label and script, joined with NUL. A runner without credentials gives
77
+ * `credentials=`, and one without declared base files gives `baseFiles=0`. Every snapshot step gets every credential,
78
+ * so the source identities are in the key once, never the values, domains, or headers: a runner that reads another
79
+ * source builds another snapshot, and every machine with the same runner options shares one. The base isn't in the
80
+ * key: a
81
+ * cache entry records it beside the key.
79
82
  */
80
83
  export function snapshotKey(steps) {
81
84
  const text = (list) => list.flatMap(({ label, script }) => [label, script]);
85
+ const baseFiles = [...steps.baseFiles].toSorted((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
82
86
  return createHash("sha256")
83
87
  .update([
84
88
  `format=${SNAPSHOT_FORMAT}`,
85
89
  `credentials=${[...new Set(steps.credentials)].toSorted().join(",")}`,
90
+ `baseFiles=${baseFiles.length}`,
91
+ ...baseFiles.flatMap(({ path, text: content }) => [path, content]),
86
92
  ...text(steps.toolchains),
87
93
  baseIndexScript("<base>", "<staging>"),
88
94
  ...text(steps.prebuild),
@@ -90,26 +96,40 @@ export function snapshotKey(steps) {
90
96
  .digest("hex");
91
97
  }
92
98
  /**
93
- * Evaluates `recipe`'s toolchain and prebuild steps at `base`, and computes their snapshot key with the secret source
94
- * identities the recipe's credentials read.
99
+ * Reads `options`'s declared base files at `base` and computes its snapshot key with the secret source identities the
100
+ * runner's credentials read. Fails with `path: ["snapshot", "toolchains"]` if any declared base file is missing or
101
+ * unreadable at `base`.
95
102
  */
96
- export async function snapshotStepsAt(checkout, request) {
97
- const context = baseStepContext(checkout, request);
98
- const { snapshot } = request.recipe;
99
- const toolchains = await resolveSteps(snapshot.toolchains, context);
100
- if (!toolchains.ok)
101
- return { ok: false, path: ["snapshot", "toolchains"], problem: toolchains.problem };
102
- const prebuild = await resolveSteps(snapshot.prebuild, context);
103
- if (!prebuild.ok)
104
- return { ok: false, path: ["snapshot", "prebuild"], problem: prebuild.problem };
103
+ export async function snapshotInputsAt(checkout, request) {
104
+ const { repoRoot, base, options } = request;
105
+ const { snapshot } = options;
106
+ const baseFiles = [];
107
+ for (const path of declaredBaseFilePaths(snapshot.toolchains)) {
108
+ const file = await checkout.readFileAt({ repoRoot, commit: base, path });
109
+ if (file.kind === "missing") {
110
+ return {
111
+ ok: false,
112
+ path: ["snapshot", "toolchains"],
113
+ problem: `declared base file "${path}" doesn't exist at base ${base.slice(0, 12)}`,
114
+ };
115
+ }
116
+ if (file.kind === "failed") {
117
+ return {
118
+ ok: false,
119
+ path: ["snapshot", "toolchains"],
120
+ problem: `can't read declared base file "${path}" at base ${base.slice(0, 12)}: ${file.failure.message}`,
121
+ };
122
+ }
123
+ baseFiles.push({ path, text: file.text });
124
+ }
105
125
  return {
106
126
  ok: true,
107
- toolchains: toolchains.steps,
108
- prebuild: prebuild.steps,
127
+ baseFiles,
109
128
  key: snapshotKey({
110
- credentials: credentialSourceIds(request.recipe),
111
- toolchains: toolchains.steps,
112
- prebuild: prebuild.steps,
129
+ credentials: credentialSourceIds(options),
130
+ baseFiles,
131
+ toolchains: snapshot.toolchains,
132
+ prebuild: snapshot.prebuild,
113
133
  }),
114
134
  };
115
135
  }
@@ -37,7 +37,7 @@ export declare function runStep(context: {
37
37
  readonly script: string;
38
38
  }, progress: RunnerProgress, signal: AbortSignal): Promise<StepOutcome>;
39
39
  /**
40
- * How a stage ends on a failed network policy write at `around`: granting credentials before the recipe's snapshot
40
+ * How a stage ends on a failed network policy write at `around`: granting credentials before the runner's snapshot
41
41
  * steps, its run steps, or the command, or revoking them before a snapshot save. A stop when the run was canceled, or
42
42
  * closing the scope began, a failure otherwise.
43
43
  */
@@ -40,7 +40,7 @@ export async function runStep(context, request, progress, signal) {
40
40
  return { kind: "succeeded", ms };
41
41
  }
42
42
  /**
43
- * How a stage ends on a failed network policy write at `around`: granting credentials before the recipe's snapshot
43
+ * How a stage ends on a failed network policy write at `around`: granting credentials before the runner's snapshot
44
44
  * steps, its run steps, or the command, or revoking them before a snapshot save. A stop when the run was canceled, or
45
45
  * closing the scope began, a failure otherwise.
46
46
  */
@@ -1,6 +1,6 @@
1
- /** Records one static problem at `path` inside a runner recipe, worded to follow the key. */
1
+ /** Records one static problem at `path` inside Vercel Sandbox runner options, worded to follow the key. */
2
2
  export type Report = (path: readonly string[], problem: string) => void;
3
3
  /** Reports each key of `value` not in `known`; whether there were none. */
4
4
  export declare function reportUnknownKeys(value: Readonly<Record<string, unknown>>, known: ReadonlySet<string>, path: readonly string[], what: string, report: Report): boolean;
5
5
  /** A value as a problem names it: a string or number as written, otherwise its kind. */
6
- export declare function describeRecipeValue(value: unknown): string;
6
+ export declare function describeOptionValue(value: unknown): string;
@@ -1,4 +1,5 @@
1
- // Pure problem-reporting helpers shared by `recipe.ts` and `recipe-secrets.ts` during `checkRecipe`.
1
+ // Pure problem-reporting helpers shared by `vercel-sandbox-options.ts` and `vercel-sandbox-secrets.ts` during
2
+ // `checkVercelSandboxOptions`.
2
3
  /** Reports each key of `value` not in `known`; whether there were none. */
3
4
  export function reportUnknownKeys(value, known, path, what, report) {
4
5
  let ok = true;
@@ -10,7 +11,7 @@ export function reportUnknownKeys(value, known, path, what, report) {
10
11
  return ok;
11
12
  }
12
13
  /** A value as a problem names it: a string or number as written, otherwise its kind. */
13
- export function describeRecipeValue(value) {
14
+ export function describeOptionValue(value) {
14
15
  if (typeof value === "string")
15
16
  return JSON.stringify(value);
16
17
  if (typeof value === "number" || typeof value === "boolean")