@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
@@ -134,15 +134,15 @@ export interface CheckoutGateway {
134
134
  }): Promise<CheckoutResult<BaseArchive>>;
135
135
  }
136
136
  /**
137
- * One runner snapshot the cache records: who it belongs to, what it was built from, and when it expires. Times
138
- * are ISO strings. Every entry records a base snapshot, built at its base, which may be any commit.
137
+ * One runner snapshot the local snapshot index records: who it belongs to, what it was built from, and when it expires.
138
+ * Times are ISO strings. Every entry records a runner snapshot built at its base commit.
139
139
  */
140
140
  export interface RunnerSnapshotEntry {
141
141
  readonly teamId: string;
142
142
  readonly projectId: string;
143
143
  readonly region: string;
144
144
  readonly runtime: string;
145
- readonly recipeName: string;
145
+ readonly runnerName: string;
146
146
  /** The snapshot key at `base` (`snapshotKey`). */
147
147
  readonly snapshotKey: string;
148
148
  /** The base commit's full SHA: the commit the snapshot was built at, whose tracked files its repository commits. */
@@ -151,49 +151,49 @@ export interface RunnerSnapshotEntry {
151
151
  readonly createdAt: string;
152
152
  readonly expiresAt: string;
153
153
  }
154
- /** A cache file storm can't read: not JSON, of an unknown version, invalid, or misnamed. */
154
+ /** A local snapshot index file storm can't read: not JSON, of an unknown version, invalid, or misnamed. */
155
155
  export interface UnreadableSnapshotEntry {
156
156
  readonly file: string;
157
157
  readonly reason: string;
158
158
  }
159
159
  /** What `listEntries` found. */
160
160
  export interface RunnerSnapshotListing {
161
- /** Where the cache lives. */
161
+ /** Where the local snapshot index lives. */
162
162
  readonly directory: string;
163
163
  readonly entries: readonly RunnerSnapshotEntry[];
164
164
  readonly unreadable: readonly UnreadableSnapshotEntry[];
165
165
  }
166
- /** Why a cache operation failed: the path it failed on and what the OS said. */
167
- export interface RunnerSnapshotCacheFailure {
166
+ /** Why a local snapshot index operation failed: the path it failed on and what the OS said. */
167
+ export interface RunnerSnapshotIndexFailure {
168
168
  readonly path: string;
169
169
  readonly message: string;
170
170
  }
171
- export type RunnerSnapshotCacheResult<T> = {
171
+ export type RunnerSnapshotIndexResult<T> = {
172
172
  readonly ok: true;
173
173
  readonly value: T;
174
174
  } | {
175
175
  readonly ok: false;
176
- readonly failure: RunnerSnapshotCacheFailure;
176
+ readonly failure: RunnerSnapshotIndexFailure;
177
177
  };
178
- export type RunnerSnapshotCacheOperation = {
178
+ export type RunnerSnapshotIndexOperation = {
179
179
  readonly ok: true;
180
180
  } | {
181
181
  readonly ok: false;
182
- readonly failure: RunnerSnapshotCacheFailure;
182
+ readonly failure: RunnerSnapshotIndexFailure;
183
183
  };
184
184
  /**
185
- * The per-machine runner snapshot cache: one record per runner snapshot, keyed by the entry's identity (team,
186
- * project, region, runtime, recipe name, snapshot key and base).
185
+ * The per-machine local snapshot index: one record per runner snapshot, keyed by the entry's identity (team, project,
186
+ * region, runtime, runner name, snapshot key, and base).
187
187
  * Every method returns its expected failures and never rejects. Which entries a run may use, and when one has
188
188
  * expired, is the caller's.
189
189
  */
190
- export interface RunnerSnapshotCacheGateway {
191
- /** Every readable entry, and the files it couldn't read. A cache never written is empty. */
192
- listEntries(): Promise<RunnerSnapshotCacheResult<RunnerSnapshotListing>>;
190
+ export interface RunnerSnapshotIndexGateway {
191
+ /** Every readable entry, and the files it couldn't read. An index never written is empty. */
192
+ listEntries(): Promise<RunnerSnapshotIndexResult<RunnerSnapshotListing>>;
193
193
  /** Records `entry`, replacing any entry with the same identity. */
194
- writeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotCacheOperation>;
194
+ writeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotIndexOperation>;
195
195
  /** Removes the entry with `entry`'s identity. Removing one that isn't there succeeds. */
196
- removeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotCacheOperation>;
196
+ removeEntry(entry: RunnerSnapshotEntry): Promise<RunnerSnapshotIndexOperation>;
197
197
  }
198
198
  /** What every Sandbox call runs as: the run's credential, and the team and project its token names. */
199
199
  export interface SandboxAccess {
@@ -226,7 +226,7 @@ export interface RunnerSandbox {
226
226
  * with 403; for `all`, every request. Every other domain stays fully reachable.
227
227
  * - `custom`: only the allowed domains and the domain of each credential in place are reachable, and every other
228
228
  * domain doesn't resolve. An allowed domain is a hostname or a wildcard with one leading `*.`. Each credential's
229
- * domain gets the same rules as under `allow-all`. A recipe's `allowedDomains` gives the list.
229
+ * domain gets the same rules as under `allow-all`. A runner's `allowedDomains` gives the list.
230
230
  * - `deny-all`: no domain is reachable, and no credential is in place. A run writes it to the runner sandbox it keeps
231
231
  * before it releases its resources.
232
232
  *
@@ -278,6 +278,49 @@ export type RunnerStartFailure = RunnerSandboxFailure | {
278
278
  readonly kind: "snapshot-gone";
279
279
  readonly message: string;
280
280
  };
281
+ /** Why starting a build sandbox failed: any Sandbox failure, or `name-taken` when `name` already exists. */
282
+ export type RunnerBuildStartFailure = RunnerSandboxFailure | {
283
+ readonly kind: "name-taken";
284
+ readonly name: string;
285
+ readonly message: string;
286
+ };
287
+ /** Status of a Vercel Sandbox as returned by the Sandbox API. */
288
+ export type NamedSandboxStatus = "pending" | "running" | "stopping" | "stopped" | "failed" | "aborted" | "snapshotting";
289
+ /** Metadata for a named sandbox in a Vercel project. */
290
+ export interface NamedSandboxInfo {
291
+ readonly name: string;
292
+ readonly status: NamedSandboxStatus;
293
+ readonly currentSnapshotId: string | undefined;
294
+ /** When the sandbox was created, as an ISO timestamp string. */
295
+ readonly createdAt: string;
296
+ readonly tags: Readonly<Record<string, string>>;
297
+ }
298
+ /** What `getNamedSandbox` found: the sandbox's metadata, or `not-found` when no sandbox by that name exists. */
299
+ export type NamedSandboxLookup = {
300
+ readonly kind: "found";
301
+ readonly sandbox: NamedSandboxInfo;
302
+ } | {
303
+ readonly kind: "not-found";
304
+ };
305
+ /** Status of a Vercel Sandbox snapshot as returned by the Sandbox API. */
306
+ export type SnapshotStatus = "failed" | "created" | "deleted";
307
+ /** Metadata for a snapshot in a Vercel project. */
308
+ export interface SnapshotInfo {
309
+ readonly snapshotId: string;
310
+ readonly status: SnapshotStatus;
311
+ /** When the snapshot was created, as an ISO timestamp string. */
312
+ readonly createdAt: string;
313
+ /** When the snapshot expires, as an ISO timestamp string, or `undefined` when it doesn't expire. */
314
+ readonly expiresAt: string | undefined;
315
+ readonly sizeBytes: number;
316
+ }
317
+ /** What `getSnapshot` found: the snapshot's metadata, or `not-found` when it is missing or has expired. */
318
+ export type SnapshotLookup = {
319
+ readonly kind: "found";
320
+ readonly snapshot: SnapshotInfo;
321
+ } | {
322
+ readonly kind: "not-found";
323
+ };
281
324
  export type RunnerSandboxResult<T, F = RunnerSandboxFailure> = {
282
325
  readonly ok: true;
283
326
  readonly value: T;
@@ -319,14 +362,37 @@ export interface SavedSnapshot {
319
362
  * outlive the call, and only `keepRunning` and `stop` end every one.
320
363
  */
321
364
  export interface RunnerSandboxGateway {
322
- /** Starts a fresh build sandbox on `runtime`, not persistent. */
365
+ /**
366
+ * Starts a fresh build sandbox on `runtime`, not persistent, optionally with an explicit `name`; answers
367
+ * `name-taken` when a sandbox with that `name` already exists in the project.
368
+ */
323
369
  startBuildSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
324
370
  readonly runtime: string;
325
- }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox>>;
371
+ readonly name?: string;
372
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox, RunnerBuildStartFailure>>;
326
373
  /** Starts a runner sandbox from runner snapshot `snapshotId`, not persistent; `snapshot-gone` when it is gone. */
327
374
  startRunnerSandbox(access: SandboxAccess, request: RunnerSandboxPlacement & {
328
375
  readonly snapshotId: string;
329
376
  }, signal?: AbortSignal): Promise<RunnerSandboxResult<RunnerSandbox, RunnerStartFailure>>;
377
+ /** Reads metadata for the named sandbox `name`, without resuming it; answers `not-found` on 404. */
378
+ getNamedSandbox(access: SandboxAccess, request: {
379
+ readonly name: string;
380
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<NamedSandboxLookup>>;
381
+ /** Lists every sandbox in the project whose name starts with `namePrefix`, across all pages, sorted by name. */
382
+ listNamedSandboxes(access: SandboxAccess, request: {
383
+ readonly namePrefix: string;
384
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<readonly NamedSandboxInfo[]>>;
385
+ /** Reads metadata for snapshot `snapshotId`; answers `not-found` on 404 or 410. */
386
+ getSnapshot(access: SandboxAccess, request: {
387
+ readonly snapshotId: string;
388
+ }, signal?: AbortSignal): Promise<RunnerSandboxResult<SnapshotLookup>>;
389
+ /**
390
+ * Deletes the named sandbox `name`, keeping any snapshots it saved (`deleteOrphanSnapshots: false`). Deleting a
391
+ * sandbox that doesn't exist succeeds.
392
+ */
393
+ deleteNamedSandbox(access: SandboxAccess, request: {
394
+ readonly name: string;
395
+ }, signal?: AbortSignal): Promise<RunnerSandboxOperation>;
330
396
  /** Writes `files` to the sandbox's own staging directory, made once per sandbox, and answers its path. */
331
397
  upload(sandbox: RunnerSandbox, files: readonly StagedFile[], signal?: AbortSignal): Promise<RunnerSandboxResult<{
332
398
  readonly directory: string;
@@ -1,3 +1,3 @@
1
- // The runner's gateways: on this machine, the Git checkout a run uploads from and the runner snapshot cache; remotely,
1
+ // The runner's gateways: on this machine, the Git checkout a run uploads from and the local snapshot index; remotely,
2
2
  // Vercel Sandbox, where runner and build sandboxes run. And the terminal the command's output reaches.
3
3
  export {};
@@ -1,20 +1,24 @@
1
- export type { RunnerContext } from "./context.ts";
2
- export { buildSnapshots, prepareSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
1
+ export { type RunnerContext, snapshotIndexTags } from "./context.ts";
2
+ export { buildSnapshots, prepareSnapshotBuild, type PreparedSnapshotBuild, type PrepareSnapshotBuildOutcome, type SnapshotBuildOutcome, } from "./build-snapshots.ts";
3
3
  export { type KeptSandbox, type RunnerEvent, type RunnerFailure, type RunnerProgress, type RunnerStepPhase, type SnapshotBuildReason, } from "./events.ts";
4
- export type { CheckoutFailure, CheckoutGateway, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotCacheFailure, RunnerSnapshotCacheGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, } from "./gateways.ts";
4
+ export type { CheckoutFailure, CheckoutGateway, NamedSandboxInfo, NamedSandboxLookup, NamedSandboxStatus, RunnerBuildStartFailure, RunnerSandboxGateway, SandboxAccess, RunnerSnapshotIndexFailure, RunnerSnapshotIndexGateway, RunnerSnapshotEntry, RunnerTerminal, RunnerTerminalColor, SnapshotInfo, SnapshotLookup, SnapshotStatus, } from "./gateways.ts";
5
5
  export { liveCheckoutGateway } from "./live/checkout-gateway.ts";
6
6
  export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.ts";
7
7
  export { liveRunnerTerminal } from "./live/terminal.ts";
8
8
  export { localUserName } from "./live/user.ts";
9
- export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway, } from "./live/snapshot-cache-gateway.ts";
9
+ export { liveRunnerSnapshotIndexGateway, unavailableRunnerSnapshotIndexGateway, } from "./live/snapshot-index-gateway.ts";
10
10
  export { lineSplitter } from "./output.ts";
11
11
  export { prepareRunner, type PrepareRunnerOutcome } from "./prepare.ts";
12
12
  export type { ChosenSnapshot, ReadyRunnerOutcome } from "./ready.ts";
13
- export { type CheckedRecipe, checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type RunnerSandboxCount, type ToolchainStep, type VcpuRun, } from "./recipe.ts";
13
+ export { type CheckedVercelSandboxOptions, checkVercelSandboxOptions, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, type RunnerVcpuCount, type RunnerVcpuRule, type SandboxCountDefault, type SandboxCountDefaultRule, type RunnerSandboxCount, type ToolchainStep, type VcpuRun, } from "./vercel-sandbox-options.ts";
14
14
  export { chooseSnapshotForRun, type SnapshotChoice, type SnapshotChoiceEnd } from "./snapshot-choice.ts";
15
15
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.ts";
16
16
  export type { RunnerFenceOutcome } from "./scope.ts";
17
17
  export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, type UnsafeSecretEnvVarMap, } from "./secrets.ts";
18
18
  export { type RunnerCleanupFacts, openRunnerSession, type RunnerSession, type RunnerSessionCleanup, type RunnerSessionRequest, } from "./session.ts";
19
- export { type InspectedSnapshot, inspectSnapshotCache, type SnapshotCacheInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
20
- export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotCacheNote, type SnapshotRejectionReason, } from "./snapshot-cache.ts";
19
+ export { type InspectedSnapshot, inspectLocalSnapshotIndex, type LocalSnapshotIndexInspection, type UnpickedReason, } from "./snapshot-inspect.ts";
20
+ export { type RejectedSnapshot, RUNNER_SNAPSHOTS_SUBPATH, type SnapshotIndexNote, type SnapshotRejectionReason, } from "./local-snapshot-index.ts";
21
+ export { type ParsedSharedSnapshotName, parseSharedSnapshotSandboxName, SHARED_SNAPSHOT_SANDBOX_PREFIX, sharedSnapshotBucket, type SharedSnapshotBucketInput, sharedSnapshotSandboxName, sharedSnapshotSandboxPrefix, type SharedSnapshotStatus, } from "./shared-snapshot-entry.ts";
22
+ export { listSharedSnapshots, pickSnapshotAcrossIndexes, type SharedSnapshotIndexEntry, type SharedSnapshotListRequest, type SharedSnapshotListResult, type SharedSnapshotSelection, type SnapshotAcrossIndexesResult, } from "./shared-snapshot-list.ts";
23
+ export { lookupSharedSnapshot, type SharedSnapshotLookupContext, type SharedSnapshotLookupRequest, type SharedSnapshotLookupResult, } from "./shared-snapshot-lookup.ts";
24
+ export { type PrunedSharedSnapshot, pruneSharedSnapshots, type SharedSnapshotPruneFailure, type SharedSnapshotPruneReason, type SharedSnapshotPruneRequest, type SharedSnapshotPruneResult, type SharedSnapshotPruneSummary, } from "./shared-snapshot-prune.ts";
@@ -1,19 +1,24 @@
1
1
  // The `runner` module's public surface: running a command in a runner sandbox, through a run's runner session. Other
2
2
  // modules import only from here, and it holds only what another module under `src/` imports; the runner's own tests
3
3
  // import the files that declare the rest (`README.md`).
4
+ export { snapshotIndexTags } from "./context.js";
4
5
  export { buildSnapshots, prepareSnapshotBuild, } from "./build-snapshots.js";
5
6
  export {} from "./events.js";
6
7
  export { liveCheckoutGateway } from "./live/checkout-gateway.js";
7
8
  export { liveRunnerSandboxGateway } from "./live/sandbox-gateway.js";
8
9
  export { liveRunnerTerminal } from "./live/terminal.js";
9
10
  export { localUserName } from "./live/user.js";
10
- export { liveRunnerSnapshotCacheGateway, unavailableRunnerSnapshotCacheGateway, } from "./live/snapshot-cache-gateway.js";
11
+ export { liveRunnerSnapshotIndexGateway, unavailableRunnerSnapshotIndexGateway, } from "./live/snapshot-index-gateway.js";
11
12
  export { lineSplitter } from "./output.js";
12
13
  export { prepareRunner } from "./prepare.js";
13
- export { checkRecipe, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, } from "./recipe.js";
14
+ export { checkVercelSandboxOptions, MAX_RUNNER_SANDBOXES, resolveSandboxCountDefault, } from "./vercel-sandbox-options.js";
14
15
  export { chooseSnapshotForRun } from "./snapshot-choice.js";
15
16
  export { SANDBOX_TEST_EVENTS_PATH } from "./sandboxed-command.js";
16
17
  export { declaredSecretValues, readCredentials, readUnsafeSecretEnvVars, SECRET_MIN_LENGTH, } from "./secrets.js";
17
18
  export { openRunnerSession, } from "./session.js";
18
- export { inspectSnapshotCache, } from "./snapshot-inspect.js";
19
- export { RUNNER_SNAPSHOTS_SUBPATH, } from "./snapshot-cache.js";
19
+ export { inspectLocalSnapshotIndex, } from "./snapshot-inspect.js";
20
+ export { RUNNER_SNAPSHOTS_SUBPATH, } from "./local-snapshot-index.js";
21
+ export { parseSharedSnapshotSandboxName, SHARED_SNAPSHOT_SANDBOX_PREFIX, sharedSnapshotBucket, sharedSnapshotSandboxName, sharedSnapshotSandboxPrefix, } from "./shared-snapshot-entry.js";
22
+ export { listSharedSnapshots, pickSnapshotAcrossIndexes, } from "./shared-snapshot-list.js";
23
+ export { lookupSharedSnapshot, } from "./shared-snapshot-lookup.js";
24
+ export { pruneSharedSnapshots, } from "./shared-snapshot-prune.js";
@@ -3,5 +3,7 @@ import type { RunnerSandboxFailure } from "../gateways.ts";
3
3
  export declare function apiStatus(error: unknown): number | undefined;
4
4
  /** Whether `error` is an abort: a DOM `AbortError`, as `fetch` and the SDK throw when a signal aborts. */
5
5
  export declare function isAbortError(error: unknown): boolean;
6
+ /** Whether a Sandbox API error means a sandbox with the requested name already exists (HTTP 400). */
7
+ export declare function isNameTakenError(error: unknown, message: string): boolean;
6
8
  /** What a thrown Sandbox error means: an abort when `signal` aborted or the error is one, otherwise an API failure. */
7
9
  export declare function sandboxFailure(error: unknown, signal: AbortSignal | undefined): RunnerSandboxFailure;
@@ -13,6 +13,10 @@ export function apiStatus(error) {
13
13
  export function isAbortError(error) {
14
14
  return typeof error === "object" && error !== null && error.name === "AbortError";
15
15
  }
16
+ /** Whether a Sandbox API error means a sandbox with the requested name already exists (HTTP 400). */
17
+ export function isNameTakenError(error, message) {
18
+ return apiStatus(error) === 400 && /already exists/i.test(message);
19
+ }
16
20
  /** What a thrown Sandbox error means: an abort when `signal` aborted or the error is one, otherwise an API failure. */
17
21
  export function sandboxFailure(error, signal) {
18
22
  if (signal?.aborted === true || isAbortError(error))
@@ -12,15 +12,19 @@
12
12
  import { policyCredentials } from "../network-policy.js";
13
13
  import { SANDBOX_ROOT } from "../snapshot-key.js";
14
14
  import { ABORTED, untilAborted } from "../time-limit.js";
15
- import { apiStatus, sandboxFailure } from "./sandbox-errors.js";
15
+ import { apiStatus, isNameTakenError, sandboxFailure } from "./sandbox-errors.js";
16
16
  /** How long a process has to end after SIGTERM before it gets SIGKILL: 10 seconds. */
17
17
  export const TERMINATE_GRACE_MS = 10_000;
18
18
  /** How long a process has to end after SIGKILL before keeping its sandbox fails: 5 seconds. */
19
19
  export const KILL_GRACE_MS = 5_000;
20
20
  /** The most stderr characters a failed test events read reports. */
21
21
  const STDERR_MESSAGE_CHARS = 1000;
22
+ /** The Sandbox API's answer when a sandbox or snapshot does not exist. */
23
+ const NOT_FOUND_STATUS = 404;
22
24
  /** The Sandbox API's answer when a snapshot to start from has expired or been deleted. */
23
25
  const SNAPSHOT_GONE_STATUS = 410;
26
+ /** Page size for `Sandbox.list` calls. */
27
+ const LIST_SANDBOXES_PAGE_LIMIT = 50;
24
28
  /**
25
29
  * `setpriv` flags used to drop every Linux capability and block privilege escalation before `execve` of the user
26
30
  * command. Vercel Sandbox's default `vercel-sandbox` user (uid 1000) holds full capabilities (`CAP_DAC_OVERRIDE`,
@@ -57,15 +61,19 @@ export function liveRunnerSandboxGateway() {
57
61
  const { Sandbox } = await sdk();
58
62
  const sandbox = await Sandbox.create({
59
63
  ...credentials(access),
60
- // oxlint-disable-next-line typescript/no-deprecated -- the recipe names a runtime; moving to `image` changes the recipe format.
64
+ // oxlint-disable-next-line typescript/no-deprecated -- the runner options name a runtime; moving to `image` changes the config file's format.
61
65
  runtime: request.runtime,
66
+ ...(request.name === undefined ? {} : { name: request.name }),
62
67
  ...placement(request),
63
68
  ...(signal === undefined ? {} : { signal }),
64
69
  });
65
70
  return { ok: true, value: adopt(sandbox, "snapshot-build", request.timeoutMs) };
66
71
  }
67
72
  catch (error) {
68
- return { ok: false, failure: sandboxFailure(error, signal) };
73
+ const failure = sandboxFailure(error, signal);
74
+ if (request.name !== undefined && failure.kind === "api" && isNameTakenError(error, failure.message))
75
+ return { ok: false, failure: { kind: "name-taken", name: request.name, message: failure.message } };
76
+ return { ok: false, failure };
69
77
  }
70
78
  },
71
79
  async startRunnerSandbox(access, request, signal) {
@@ -86,6 +94,124 @@ export function liveRunnerSandboxGateway() {
86
94
  return { ok: false, failure };
87
95
  }
88
96
  },
97
+ async getNamedSandbox(access, request, signal) {
98
+ if (isAborted(signal))
99
+ return { ok: false, failure: { kind: "aborted" } };
100
+ try {
101
+ const { Sandbox } = await sdk();
102
+ const sandbox = await Sandbox.get({
103
+ ...credentials(access),
104
+ name: request.name,
105
+ ...(signal === undefined ? {} : { signal }),
106
+ });
107
+ return {
108
+ ok: true,
109
+ value: {
110
+ kind: "found",
111
+ sandbox: {
112
+ name: sandbox.name,
113
+ status: sandbox.status,
114
+ currentSnapshotId: sandbox.currentSnapshotId,
115
+ createdAt: sandbox.createdAt.toISOString(),
116
+ tags: { ...sandbox.tags },
117
+ },
118
+ },
119
+ };
120
+ }
121
+ catch (error) {
122
+ const failure = sandboxFailure(error, signal);
123
+ if (failure.kind === "api" && apiStatus(error) === NOT_FOUND_STATUS)
124
+ return { ok: true, value: { kind: "not-found" } };
125
+ return { ok: false, failure };
126
+ }
127
+ },
128
+ async listNamedSandboxes(access, request, signal) {
129
+ if (isAborted(signal))
130
+ return { ok: false, failure: { kind: "aborted" } };
131
+ try {
132
+ const { Sandbox } = await sdk();
133
+ // `namePrefix` requires `sortBy: "name"`; omitting it causes Vercel Sandbox to reject with HTTP 400.
134
+ const paginator = await Sandbox.list({
135
+ ...credentials(access),
136
+ namePrefix: request.namePrefix,
137
+ sortBy: "name",
138
+ limit: LIST_SANDBOXES_PAGE_LIMIT,
139
+ ...(signal === undefined ? {} : { signal }),
140
+ });
141
+ const listed = [];
142
+ for await (const page of paginator.pages()) {
143
+ if (isAborted(signal))
144
+ return { ok: false, failure: { kind: "aborted" } };
145
+ for (const item of page.sandboxes) {
146
+ listed.push({
147
+ name: item.name,
148
+ status: item.status,
149
+ currentSnapshotId: item.currentSnapshotId,
150
+ createdAt: new Date(item.createdAt).toISOString(),
151
+ tags: { ...item.tags },
152
+ });
153
+ }
154
+ }
155
+ return { ok: true, value: listed };
156
+ }
157
+ catch (error) {
158
+ return { ok: false, failure: sandboxFailure(error, signal) };
159
+ }
160
+ },
161
+ async getSnapshot(access, request, signal) {
162
+ if (isAborted(signal))
163
+ return { ok: false, failure: { kind: "aborted" } };
164
+ try {
165
+ const { Snapshot } = await sdk();
166
+ const snapshot = await Snapshot.get({
167
+ ...credentials(access),
168
+ snapshotId: request.snapshotId,
169
+ ...(signal === undefined ? {} : { signal }),
170
+ });
171
+ return {
172
+ ok: true,
173
+ value: {
174
+ kind: "found",
175
+ snapshot: {
176
+ snapshotId: snapshot.snapshotId,
177
+ status: snapshot.status,
178
+ createdAt: snapshot.createdAt.toISOString(),
179
+ expiresAt: snapshot.expiresAt?.toISOString(),
180
+ sizeBytes: snapshot.sizeBytes,
181
+ },
182
+ },
183
+ };
184
+ }
185
+ catch (error) {
186
+ const failure = sandboxFailure(error, signal);
187
+ const status = apiStatus(error);
188
+ if (failure.kind === "api" && (status === NOT_FOUND_STATUS || status === SNAPSHOT_GONE_STATUS))
189
+ return { ok: true, value: { kind: "not-found" } };
190
+ return { ok: false, failure };
191
+ }
192
+ },
193
+ async deleteNamedSandbox(access, request, signal) {
194
+ if (isAborted(signal))
195
+ return { ok: false, failure: { kind: "aborted" } };
196
+ try {
197
+ const { Sandbox } = await sdk();
198
+ const sandbox = await Sandbox.get({
199
+ ...credentials(access),
200
+ name: request.name,
201
+ ...(signal === undefined ? {} : { signal }),
202
+ });
203
+ if (isAborted(signal))
204
+ return { ok: false, failure: { kind: "aborted" } };
205
+ await sandbox.delete({ deleteOrphanSnapshots: false, ...(signal === undefined ? {} : { signal }) });
206
+ return { ok: true };
207
+ }
208
+ catch (error) {
209
+ const failure = sandboxFailure(error, signal);
210
+ if (failure.kind === "api" && apiStatus(error) === NOT_FOUND_STATUS)
211
+ return { ok: true };
212
+ return { ok: false, failure };
213
+ }
214
+ },
89
215
  async upload(sandbox, files, signal) {
90
216
  const holder = holding(sandbox);
91
217
  try {
@@ -0,0 +1,12 @@
1
+ import type { RunnerSnapshotIndexGateway } from "../gateways.ts";
2
+ export interface LiveRunnerSnapshotIndexOptions {
3
+ /** The local snapshot index directory, `$XDG_STATE_HOME/storm/runner/snapshots`. */
4
+ readonly directory: string;
5
+ }
6
+ /** The local snapshot index in `options.directory`. */
7
+ export declare function liveRunnerSnapshotIndexGateway(options: LiveRunnerSnapshotIndexOptions): RunnerSnapshotIndexGateway;
8
+ /**
9
+ * A local snapshot index that can't be found, because neither `XDG_STATE_HOME` nor `HOME` names a place for it. Every
10
+ * operation fails with `reason`, at `location`.
11
+ */
12
+ export declare function unavailableRunnerSnapshotIndexGateway(location: string, reason: string): RunnerSnapshotIndexGateway;
@@ -1,18 +1,18 @@
1
- // The runner snapshot cache on disk: one `<identity>.json` file per runner snapshot in one directory, named after
2
- // the entry's identity (`snapshotEntryIdentity`). An entry is written to a temp file in the same directory and
3
- // renamed into place, so a write with the same identity replaces the file whole and the last write wins. Files are
4
- // mode 0600 and directories 0700.
1
+ // The local snapshot index on disk: one `<identity>.json` file per runner snapshot in one directory, named after the
2
+ // entry's identity (`snapshotEntryIdentity`). An entry is written to a temp file in the same directory and renamed into
3
+ // place, so a write with the same identity replaces the file whole and the last write wins. Files are mode 0600 and
4
+ // directories 0700.
5
5
  import { randomBytes } from "node:crypto";
6
6
  import { mkdir, readdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
7
7
  import { join } from "node:path";
8
- import { snapshotEntryFileName } from "../snapshot-cache.js";
8
+ import { snapshotEntryFileName } from "../local-snapshot-index.js";
9
9
  import { parseSnapshotEntry, snapshotEntryText } from "./snapshot-records.js";
10
10
  const DIRECTORY_MODE = 0o700;
11
11
  const FILE_MODE = 0o600;
12
- /** A cache file's name: 32 hex characters and `.json`. Temp files start with a dot and never match. */
12
+ /** A local snapshot index file's name: 32 hex characters and `.json`. Temp files start with a dot and never match. */
13
13
  const ENTRY_FILE_NAME = /^[0-9a-f]{32}\.json$/;
14
- /** The runner snapshot cache in `options.directory`. */
15
- export function liveRunnerSnapshotCacheGateway(options) {
14
+ /** The local snapshot index in `options.directory`. */
15
+ export function liveRunnerSnapshotIndexGateway(options) {
16
16
  const { directory } = options;
17
17
  return {
18
18
  listEntries: () => listEntries(directory),
@@ -21,10 +21,10 @@ export function liveRunnerSnapshotCacheGateway(options) {
21
21
  };
22
22
  }
23
23
  /**
24
- * A cache that can't be found, because neither `XDG_STATE_HOME` nor `HOME` names a place for it. Every operation
25
- * fails with `reason`, at `location`.
24
+ * A local snapshot index that can't be found, because neither `XDG_STATE_HOME` nor `HOME` names a place for it. Every
25
+ * operation fails with `reason`, at `location`.
26
26
  */
27
- export function unavailableRunnerSnapshotCacheGateway(location, reason) {
27
+ export function unavailableRunnerSnapshotIndexGateway(location, reason) {
28
28
  const failure = { path: location, message: reason };
29
29
  const fail = async () => ({ ok: false, failure });
30
30
  return { listEntries: fail, writeEntry: fail, removeEntry: fail };
@@ -1,8 +1,7 @@
1
- // The runner snapshot cache's file format: one JSON object per runner snapshot, carrying `version: 1`. A reader
1
+ // The local snapshot index's file format: one JSON object per runner snapshot, carrying `version: 1`. A reader
2
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.
3
+ // (`snapshotEntryIdentity`), and the gateway lists a file whose name isn't as unreadable. Older files (such as ones
4
+ // using the retired runner-name field) are listed as unreadable, and no run starts from them: there is no migration.
6
5
  import { z } from "zod";
7
6
  const isoTime = z.string().refine((value) => !Number.isNaN(Date.parse(value)), { message: "not a time" });
8
7
  const nonEmpty = z.string().min(1);
@@ -12,7 +11,7 @@ const entrySchema = z.object({
12
11
  projectId: nonEmpty,
13
12
  region: nonEmpty,
14
13
  runtime: nonEmpty,
15
- recipeName: nonEmpty,
14
+ runnerName: nonEmpty,
16
15
  snapshotKey: nonEmpty,
17
16
  base: nonEmpty,
18
17
  snapshotId: nonEmpty,
@@ -42,7 +41,7 @@ export function parseSnapshotEntry(text) {
42
41
  }
43
42
  /** The text of the file that records `entry`. */
44
43
  export function snapshotEntryText(entry) {
45
- const { teamId, projectId, region, runtime, recipeName, snapshotKey, base } = entry;
44
+ const { teamId, projectId, region, runtime, runnerName, snapshotKey, base } = entry;
46
45
  const { snapshotId, createdAt, expiresAt } = entry;
47
46
  const record = {
48
47
  version: 1,
@@ -50,7 +49,7 @@ export function snapshotEntryText(entry) {
50
49
  projectId,
51
50
  region,
52
51
  runtime,
53
- recipeName,
52
+ runnerName,
54
53
  snapshotKey,
55
54
  base,
56
55
  snapshotId,