Public: anyone can read this; the crew can change it.

One BlobStore: promote src/snapshot/store.ts to a shared module with streaming, range reads and presigned URLs #16638

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/forge:mason/4489-one-blobstore-promote-src-snapshot-store → main 0 commits fork

  • Merged. mason/4489-one-blobstore-promote-src-snapshot-store was merged into main as 0cd2497.

Review

Sign in to review this change.
120 files changed +892 −152
CLAUDE.md +3
@@ -237,6 +237,9 @@ src/
237237 actions/); actions/fleet.ts plans, applies, keeps the receipt
238238 (core/fleet_ops.ts) and undoes
239239 runs/ log (one file per run, appended live, tailed by listeners)
240 blob/ store (the one BlobStore, docs/BLOBS.md: a bucket over S3 or a
241 directory; streamed puts, ranges, presigned URLs, a class
242 hint; snapshots use its small `Store` shape)
240243 crew/ agents as child processes: brief (the system + task prompts:
241244 the golden path, written down), claude (the headless adapter:
242245 argv, stream-json, outcome), sandbox (what the agent's shell
docs/BLOBS.md added +49
@@ -0,0 +1,49 @@
1 # Blobs
2
3 Big, immutable things go to one store, `src/blob/store.ts` (step 2 of
4 #4481). Its keys are paths and its contents are bytes; it has no other
5 idea of structure. The refs and metadata that name those bytes stay in
6 the database.
7
8 ## Two shapes, one store
9
10 - **`Store`** is the small shape snapshots were written against: put, get,
11 list, names, delete. Snapshots, the mirror and the drill still take
12 exactly this, unchanged (`docs/SNAPSHOT.md`).
13 - **`BlobStore`** is the same store, with what a large file needs:
14 - `put(key, Blob)`: a `Bun.file` is streamed from disk, never read whole
15 into memory. It can be retried, because it is read anew each time.
16 - `putStream(key, stream)`: a body of unknown length. A bucket takes it
17 multipart. A directory writes it under a temporary name and renames it
18 into place, so a reader never sees half of it. It is tried only once,
19 because a stream cannot be replayed.
20 - `size(key)`, `getRange(key, { start, end })` and `getStream(key, range?)`.
21 `end` is exclusive. A range past the end of the object is empty, and an
22 absent key is `undefined`, the same answer on a bucket as on a
23 directory.
24 - `presign(key, { method: "GET" | "PUT", expiresInS })`: a URL straight to
25 the bucket, signed locally with no request. A directory has none, so its
26 caller serves the bytes itself.
27 - A **storage-class hint** on every put: `hot` (the default, which sends
28 nothing), `infrequent` (`STANDARD_IA`, which R2 and S3 accept) or
29 `archive` (`DEEP_ARCHIVE`, S3 only).
30 It is the fourth argument of `put(key, body, signal?, options?)`: the third
31 is the abort signal snapshots already pass, so their calls are unchanged.
32
33 `s3Store` (any S3-compatible endpoint: R2, S3, B2) and `dirStore` are both
34 `BlobStore`s. `withRetries` keeps one a `BlobStore`: sizes, ranges and
35 opening a stream are retried the way a get is, and a `Blob` put gets a
36 deadline that follows its size.
37
38 ## At the boundary
39
40 A key with `..` or `.` segments, a leading `/` or a control byte is
41 refused. So is a range that is not whole, non-negative bytes in order, and
42 a presign that is not a GET or PUT valid for 1 s to 7 days. The bucket's
43 secret never appears in a presigned URL; only its signature does.
44
45 ## Not here yet
46
47 Archiving finished run logs and attachments onto the store, big git blobs
48 by OID and the cold-tier lifecycle are later steps of #4481, each with
49 its own issue.
docs/REFERENCE.md +1
@@ -523,6 +523,7 @@ Once a minute the forge measures its landing rate, names the one cause binding i
523523 - [`docs/web.md`](web.md) — the rules for assets and HTML: what is cached where, how a page streams, and the byte budgets a test enforces.
524524 - [`docs/PRINCIPLES.md`](PRINCIPLES.md) — what the forge holds to, each with what enforces it; capped, and read by the crew and the in-forge conversation.
525525 - [`docs/AI_AGNOSTIC.md`](AI_AGNOSTIC.md) — every place the forge still names or assumes one AI vendor, and the issue that removes each.
526 - [`docs/BLOBS.md`](BLOBS.md) — the one store for big, immutable bytes: its two shapes and who uses them.
526527 This page is the front door. Everything else is a file of its own under
527528 `docs/`, each about one thing:
528529
scripts/backup-probe.ts +1 −1
@@ -7,7 +7,7 @@
77 */
88
99 import { parseProbeArgs, probe } from "../src/snapshot/probe.ts";
10 import { dirStore, s3FromEnv, s3Store, withRetries, type Store } from "../src/snapshot/store.ts";
10 import { dirStore, s3FromEnv, s3Store, withRetries, type Store } from "../src/blob/store.ts";
1111
1212 const parsed = parseProbeArgs(process.argv.slice(2), process.env);
1313 if ("error" in parsed) {
src/actions/destination.ts +1 −1
@@ -17,7 +17,7 @@ import {
1717 SEALED_READ,
1818 } from "../snapshot/destination.ts";
1919 import { kitIdentity, kitText, makeKit, recordDownload } from "../snapshot/kit.ts";
20 import { s3FromEnv, type S3Target } from "../snapshot/store.ts";
20 import { s3FromEnv, type S3Target } from "../blob/store.ts";
2121 import { snapshotsOf } from "../snapshot/service.ts";
2222 import type { User } from "../core/users.ts";
2323 import { err, ok, type Result } from "../kernel/result.ts";
src/snapshot/store.ts → src/blob/store.ts renamed +319 −39
@@ -1,15 +1,51 @@
11 /**
2 * Where snapshots go. Two places, one shape: a bucket over S3 (the platform
3 * gives every app one, mirrored off the machine by lanes the forge never
4 * sees) or a directory (a forge on a desk, a test). Keys are paths; the
2 * Where the forge's big, immutable things go (docs/BLOBS.md). Two places,
3 * one shape: a bucket over S3 (the platform gives every app one, mirrored
4 * off the machine by lanes the forge never sees; R2, S3 and B2 all speak
5 * it) or a directory (a forge on a desk, a test). Keys are paths; the
56 * store keeps no other idea of structure, so a snapshot is exactly the
67 * files it lists and a restore is exactly reading them back.
8 *
9 * `Store` is the small shape snapshots were written against; `BlobStore`
10 * is the same store with what a large file needs: a body streamed in from
11 * disk or a pipe, a byte range read back, a URL a client fetches from the
12 * bucket itself, and a hint of how cold the object may be kept.
713 */
814
9 import { mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
15 import { mkdirSync, readdirSync, renameSync, rmSync, statSync } from "node:fs";
1016 import { dirname, join, relative } from "node:path";
1117 import { durationWords } from "../system/format.ts";
12 import { lineMeter, measuredDeadlineMs, type LineMeter } from "./line.ts";
18 import { lineMeter, measuredDeadlineMs, type LineMeter } from "../snapshot/line.ts";
19
20 /**
21 * How often an object is expected to be read back, as a hint the bucket
22 * may honour: `hot` (the default, sends nothing), `infrequent` (R2 and S3
23 * Infrequent Access; a 30-day minimum), `archive` (S3 Glacier Deep
24 * Archive; S3 only, 180-day minimum, hours to read back). A directory has
25 * no classes and ignores it.
26 */
27 export type StorageClass = "hot" | "infrequent" | "archive";
28
29 export interface PutOptions {
30 readonly storageClass?: StorageClass;
31 /** The object's media type; `application/octet-stream` when left out. */
32 readonly type?: string;
33 }
34
35 /** Bytes `start` up to, not including, `end` (the object's end when left out). */
36 export interface ByteRange {
37 readonly start: number;
38 readonly end?: number;
39 }
40
41 /** A URL that lets its holder GET or PUT one key, until it expires. */
42 export interface PresignRequest {
43 readonly method: "GET" | "PUT";
44 /** Seconds the URL stays good: 1 to 604800 (seven days, S3's limit). */
45 readonly expiresInS: number;
46 /** For a PUT, the class the object is written in. */
47 readonly storageClass?: StorageClass;
48 }
1349
1450 export interface Store {
1551 /** What this store is, for a page and a log; never a secret. */
@@ -21,7 +57,12 @@ export interface Store {
2157 * keep the line busy under the attempt that replaces it (#13733). A store that cannot abort
2258 * ignores it.
2359 */
24 put(key: string, body: Uint8Array | string, signal?: AbortSignal): Promise<void>;
60 put(
61 key: string,
62 body: Uint8Array | string,
63 signal?: AbortSignal,
64 options?: PutOptions,
65 ): Promise<void>;
2566 get(key: string): Promise<Uint8Array | undefined>;
2667 /** Every key under `prefix`, in no particular order. */
2768 list(prefix: string): Promise<string[]>;
@@ -80,6 +121,95 @@ export function remakes<S extends Store>(store: S, spec: StoreSpec): S {
80121 return store;
81122 }
82123
124 export interface BlobStore extends Store {
125 /**
126 * A `Blob` (a `Bun.file` most of all) is streamed from where it lies,
127 * never read whole into memory, and can be tried again: it is read anew.
128 */
129 put(
130 key: string,
131 body: Uint8Array | string | Blob,
132 signal?: AbortSignal,
133 options?: PutOptions,
134 ): Promise<void>;
135 /**
136 * A body of unknown length, streamed in (multipart on a bucket). Tried
137 * once: a stream cannot be read twice, so its caller holds the source.
138 */
139 putStream(
140 key: string,
141 body: ReadableStream<Uint8Array>,
142 options?: PutOptions,
143 ): Promise<void>;
144 /** The object's size in bytes; undefined when there is no such key. */
145 size(key: string): Promise<number | undefined>;
146 /** Some of the object's bytes; empty past its end, undefined when absent. */
147 getRange(key: string, range: ByteRange): Promise<Uint8Array | undefined>;
148 /** The object, or a range of it, as a stream; undefined when absent. */
149 getStream(
150 key: string,
151 range?: ByteRange,
152 ): Promise<ReadableStream<Uint8Array> | undefined>;
153 /**
154 * A URL straight to the object, signed here with no request made. A
155 * directory has none and leaves this out: its caller serves the bytes.
156 */
157 presign?(key: string, request: PresignRequest): string;
158 bounded?(leftMs: () => number): BlobStore;
159 }
160
161 /** Whether `store` is a whole `BlobStore`, not only the snapshot shape. */
162 export const isBlobStore = (store: Store): store is BlobStore =>
163 "getRange" in store && "putStream" in store && "size" in store;
164
165 /** The longest a presigned URL may live: S3's own limit. */
166 export const PRESIGN_MAX_S = 7 * 24 * 60 * 60;
167
168 /** Refuse a range that is not whole, non-negative bytes in order. */
169 export function checkRange(range: ByteRange): void {
170 const { start, end } = range;
171 if (!Number.isSafeInteger(start) || start < 0)
172 throw new Error(`refusing range start ${start}`);
173 if (end !== undefined && (!Number.isSafeInteger(end) || end < start))
174 throw new Error(`refusing range end ${end}`);
175 }
176
177 /** Refuse a presign that is not a GET or PUT for a whole number of seconds within S3's limit. */
178 export function checkPresign(request: {
179 readonly method: string;
180 readonly expiresInS: number;
181 }): void {
182 if (request.method !== "GET" && request.method !== "PUT")
183 throw new Error(`refusing presign method ${request.method}`);
184 const s = request.expiresInS;
185 if (!Number.isSafeInteger(s) || s < 1 || s > PRESIGN_MAX_S)
186 throw new Error(`refusing presign expiry ${s}`);
187 }
188
189 /**
190 * Refuse a key that is not a plain relative path: empty, absolute, with a
191 * `..` or `.` segment, or a control byte. A directory
192 * would resolve one outside its root; a bucket would sign it as given.
193 */
194 export function checkKey(key: string): void {
195 if (
196 key === "" ||
197 key.startsWith("/") ||
198 key.split("/").some((s) => s === ".." || s === ".") ||
199 /[\u0000-\u001f\u007f]/.test(key)
200 )
201 throw new Error(`refusing key ${JSON.stringify(key)}`);
202 }
203
204 /**
205 * The S3 `x-amz-storage-class` a hint asks for; none for `hot`, so a default put sends exactly what
206 * it always did.
207 */
208 export const s3StorageClass = (
209 hint: StorageClass | undefined,
210 ): "STANDARD_IA" | "DEEP_ARCHIVE" | undefined =>
211 hint === "infrequent" ? "STANDARD_IA" : hint === "archive" ? "DEEP_ARCHIVE" : undefined;
212
83213 /** The S3 credentials as the platform hands them to an app. */
84214 export interface S3Target {
85215 readonly endpoint: string;
@@ -128,8 +258,12 @@ export const deadlineFor = (
128258 slackMs = SLACK_MS,
129259 ): number => slackMs + Math.ceil((bytes / floorBytesPerS) * 1000);
130260
131 const sizeOf = (body: Uint8Array | string): number =>
132 typeof body === "string" ? Buffer.byteLength(body) : body.byteLength;
261 const sizeOf = (body: Uint8Array | string | Blob): number =>
262 typeof body === "string"
263 ? Buffer.byteLength(body)
264 : body instanceof Blob
265 ? body.size
266 : body.byteLength;
133267
134268 /**
135269 * A store that tries again. Object stores answer a burst, a flake or a
@@ -159,19 +293,24 @@ const sizeOf = (body: Uint8Array | string): number =>
159293 * what is left after the waits still to come, and none starts once
160294 * nothing is, so a stalled store fails within the budget instead of
161295 * holding five 180 s attempts past it.
296 *
297 * A `BlobStore` comes back a `BlobStore`: its sizes and ranges are tried
298 * as a get is, opening a stream is tried but not the reading of it, and a
299 * `putStream` is passed through once with its key named when it fails (a
300 * stream cannot be replayed). Presigning makes no request, so is not tried.
162301 */
163 export function withRetries(
164 inner: Store,
165 options: {
166 attempts?: number;
167 baseMs?: number;
168 deadlineMs?: number;
169 floorBytesPerS?: number;
170 slackMs?: number;
171 sleep?: (ms: number) => Promise<void>;
172 line?: LineMeter;
173 } = {},
174 ): Store {
302 export interface RetryOptions {
303 attempts?: number;
304 baseMs?: number;
305 deadlineMs?: number;
306 floorBytesPerS?: number;
307 slackMs?: number;
308 sleep?: (ms: number) => Promise<void>;
309 line?: LineMeter;
310 }
311 export function withRetries(inner: BlobStore, options?: RetryOptions): BlobStore;
312 export function withRetries(inner: Store, options?: RetryOptions): Store;
313 export function withRetries(inner: Store, options: RetryOptions = {}): Store {
175314 const attempts = Math.max(1, options.attempts ?? 5);
176315 const baseMs = options.baseMs ?? 500;
177316 const fixed = options.deadlineMs;
@@ -179,7 +318,7 @@ export function withRetries(
179318 const line = options.line ?? lineMeter();
180319 const slackMs = options.slackMs ?? SLACK_MS;
181320 // Read at each attempt: the line may have been measured since the last one.
182 const putMs = (body: Uint8Array | string): number => {
321 const putMs = (body: Uint8Array | string | Blob): number => {
183322 if (fixed !== undefined) return fixed;
184323 const bytes = sizeOf(body);
185324 const floor = deadlineFor(bytes, options.floorBytesPerS, slackMs);
@@ -225,7 +364,7 @@ export function withRetries(
225364 const view = (leftMs?: () => number): Store => ({
226365 where: inner.where,
227366 ...(inner.dir === undefined ? {} : { dir: inner.dir }),
228 put: (key, body) =>
367 put: (key, body, _signal, how) =>
229368 tried(
230369 `put ${key}`,
231370 () => putMs(body),
@@ -233,7 +372,7 @@ export function withRetries(
233372 const end = line.begin();
234373 let landed = 0;
235374 try {
236 await inner.put(key, body, signal);
375 await inner.put(key, body, signal, how);
237376 landed = sizeOf(body);
238377 } finally {
239378 end(landed);
@@ -249,7 +388,27 @@ export function withRetries(
249388 bounded: (left) => view(left),
250389 line,
251390 });
252 return view();
391 if (!isBlobStore(inner)) return view();
392 const blobView = (leftMs?: () => number): BlobStore => {
393 const presign = inner.presign?.bind(inner);
394 return {
395 ...view(leftMs),
396 putStream: (key, body, put) =>
397 inner.putStream(key, body, put).catch((error: unknown) => {
398 throw new Error(
399 `put ${key} failed: ${String(error instanceof Error ? error.message : error)}`,
400 );
401 }),
402 size: (key) => tried(`size ${key}`, callMs, () => inner.size(key), leftMs),
403 getRange: (key, range) =>
404 tried(`get ${key}`, callMs, () => inner.getRange(key, range), leftMs),
405 getStream: (key, range) =>
406 tried(`get ${key}`, callMs, () => inner.getStream(key, range), leftMs),
407 ...(presign === undefined ? {} : { presign }),
408 bounded: (left) => blobView(left),
409 };
410 };
411 return blobView();
253412 }
254413
255414 /**
@@ -275,7 +434,7 @@ function answered<T>(start: (signal: AbortSignal) => Promise<T>, ms: number): Pr
275434 return Promise.race([attempt, deadline]).finally(() => clearTimeout(timer));
276435 }
277436
278 export function s3Store(target: S3Target, attempts?: number): Store {
437 export function s3Store(target: S3Target, attempts?: number): BlobStore {
279438 const spec: StoreSpec = attempts === undefined ? { kind: "s3", target } : { kind: "s3", target, attempts };
280439 return remakes(withRetries(rawS3Store(target), attempts === undefined ? {} : { attempts }), spec);
281440 }
@@ -287,8 +446,17 @@ export const s3Where = (target: Pick<S3Target, "endpoint" | "bucket">): string =
287446 /** How long a put's signed URL is good for: longer than any put's deadline. */
288447 const PUT_URL_SECONDS = 6 * 3600;
289448
449 /** The S3 options a put signs: none at all for a default put, as before. */
450 const s3PutOptions = (put: PutOptions | undefined) => {
451 const storageClass = s3StorageClass(put?.storageClass);
452 return {
453 ...(storageClass === undefined ? {} : { storageClass }),
454 ...(put?.type === undefined ? {} : { type: put.type }),
455 };
456 };
457
290458 /** The bucket as a store, each call once: `s3Store` is this with retries. Exported for tests. */
291 export function rawS3Store(target: S3Target): Store {
459 export function rawS3Store(target: S3Target): BlobStore {
292460 const client = new Bun.S3Client({
293461 endpoint: target.endpoint,
294462 bucket: target.bucket,
@@ -296,24 +464,93 @@ export function rawS3Store(target: S3Target): Store {
296464 secretAccessKey: target.secretAccessKey,
297465 ...(target.region === undefined ? {} : { region: target.region }),
298466 });
467 // One HEAD: a missing key is the client's `NoSuchKey`, anything else a failure.
468 const size = async (key: string): Promise<number | undefined> => {
469 try {
470 return (await client.file(key).stat()).size;
471 } catch (error) {
472 if ((error as { code?: unknown }).code === "NoSuchKey") return undefined;
473 throw error;
474 }
475 };
476 // The object's bytes in `range`, clamped to its size: a bucket answers a
477 // range starting past the end with 416, a file with nothing.
478 const ranged = async (key: string, range: ByteRange) => {
479 checkKey(key);
480 checkRange(range);
481 const n = await size(key);
482 if (n === undefined) return undefined;
483 const start = Math.min(range.start, n);
484 const end = Math.min(range.end ?? n, n);
485 return { file: client.file(key).slice(start, end), empty: start >= end };
486 };
487 // A default put is a presigned PUT through fetch, not `client.write`: only fetch takes a signal,
488 // and an upload given up at its deadline must stop (#13733). The URL is signed here, no network.
489 // A put that asks for a class or a type goes through the client, which sends them as headers
490 // the bucket is known to honour; it cannot be aborted, so a deadline abandons it instead.
491 const sendPut = async (
492 key: string,
493 body: Uint8Array | string | Blob,
494 signal: AbortSignal | undefined,
495 how: PutOptions | undefined,
496 ) => {
497 checkKey(key);
498 const asked = s3PutOptions(how);
499 if (Object.keys(asked).length > 0) {
500 await client.write(key, body, asked);
501 return;
502 }
503 const url = client.presign(key, { method: "PUT", expiresIn: PUT_URL_SECONDS });
504 const res = await fetch(url, {
505 method: "PUT",
506 body,
507 ...(signal === undefined ? {} : { signal }),
508 });
509 if (!res.ok) {
510 const said = (await res.text().catch(() => "")).match(/<Code>([^<]{1,80})<\/Code>/)?.[1];
511 throw new Error(`the bucket answered ${res.status}${said === undefined ? "" : ` ${said}`}`);
512 }
513 await res.body?.cancel().catch(() => {});
514 };
299515 return {
300516 where: s3Where(target),
301 // A presigned PUT through fetch, not `client.write`: only fetch takes a signal, and an
302 // upload given up at its deadline must stop (#13733). The URL is signed here, no network.
303 async put(key, body, signal) {
304 const url = client.presign(key, { method: "PUT", expiresIn: PUT_URL_SECONDS });
305 const res = await fetch(url, { method: "PUT", body, ...(signal === undefined ? {} : { signal }) });
306 if (!res.ok) {
307 const said = (await res.text().catch(() => "")).match(/<Code>([^<]{1,80})<\/Code>/)?.[1];
308 throw new Error(`the bucket answered ${res.status}${said === undefined ? "" : ` ${said}`}`);
309 }
310 await res.body?.cancel().catch(() => {});
517 async put(key, body, signal, how) {
518 await sendPut(key, body, signal, how);
519 },
520 async putStream(key, body, how) {
521 checkKey(key);
522 await client.write(key, new Response(body), s3PutOptions(how));
311523 },
312524 async get(key) {
313525 const file = client.file(key);
314526 if (!(await file.exists())) return undefined;
315527 return new Uint8Array(await file.arrayBuffer());
316528 },
529 size(key) {
530 checkKey(key);
531 return size(key);
532 },
533 async getRange(key, range) {
534 const at = await ranged(key, range);
535 if (at === undefined) return undefined;
536 return at.empty ? new Uint8Array(0) : new Uint8Array(await at.file.arrayBuffer());
537 },
538 async getStream(key, range = { start: 0 }) {
539 const at = await ranged(key, range);
540 if (at === undefined) return undefined;
541 return at.empty ? new Blob([]).stream() : at.file.stream();
542 },
543 presign(key, request) {
544 checkKey(key);
545 checkPresign(request);
546 const storageClass =
547 request.method === "PUT" ? s3StorageClass(request.storageClass) : undefined;
548 return client.presign(key, {
549 method: request.method,
550 expiresIn: request.expiresInS,
551 ...(storageClass === undefined ? {} : { storageClass }),
552 });
553 },
317554 async list(prefix) {
318555 const keys: string[] = [];
319556 let token: string | undefined;
@@ -350,8 +587,12 @@ export function rawS3Store(target: S3Target): Store {
350587 };
351588 }
352589
353 /** A directory as a store: `key` is a path under it, nothing else. */
354 export function dirStore(root: string): Store {
590 /**
591 * A directory as a store: `key` is a path under it, nothing else. It has
592 * no URL to presign and no storage classes; a streamed put lands under a
593 * temporary name and is renamed into place, so a reader never sees half.
594 */
595 export function dirStore(root: string): BlobStore {
355596 const at = (key: string): string => {
356597 if (key.startsWith("/") || key.split("/").includes(".."))
357598 throw new Error(`refusing key ${key}`);
@@ -370,7 +611,12 @@ export function dirStore(root: string): Store {
370611 else out.push(relative(root, path));
371612 }
372613 };
373 return remakes<Store>({
614 const file = async (key: string) => {
615 checkKey(key);
616 const f = Bun.file(at(key));
617 return (await f.exists()) ? f : undefined;
618 };
619 return remakes<BlobStore>({
374620 where: root,
375621 dir: root,
376622 async put(key, body) {
@@ -378,11 +624,45 @@ export function dirStore(root: string): Store {
378624 mkdirSync(dirname(path), { recursive: true });
379625 await Bun.write(path, body);
380626 },
627 async putStream(key, body) {
628 checkKey(key);
629 const path = at(key);
630 mkdirSync(dirname(path), { recursive: true });
631 const part = `${path}.part-${process.pid}-${Bun.nanoseconds()}`;
632 // Pumped by hand: `Bun.write(part, new Response(body))` never settles
633 // when the stream errors (Bun 1.3), and a broken pipe must fail the put.
634 const sink = Bun.file(part).writer();
635 try {
636 try {
637 for await (const chunk of body) sink.write(chunk);
638 } finally {
639 await sink.end();
640 }
641 renameSync(part, path);
642 } catch (error) {
643 rmSync(part, { force: true });
644 throw error;
645 }
646 },
381647 async get(key) {
382648 const file = Bun.file(at(key));
383649 if (!(await file.exists())) return undefined;
384650 return new Uint8Array(await file.arrayBuffer());
385651 },
652 async size(key) {
653 return (await file(key))?.size;
654 },
655 async getRange(key, range) {
656 checkRange(range);
657 const f = await file(key);
658 if (f === undefined) return undefined;
659 return new Uint8Array(await f.slice(range.start, range.end).arrayBuffer());
660 },
661 async getStream(key, range = { start: 0 }) {
662 checkRange(range);
663 const f = await file(key);
664 return f?.slice(range.start, range.end).stream();
665 },
386666 async list(prefix) {
387667 const all: string[] = [];
388668 walk(root, all);
src/chaos/faults.ts +1 −1
@@ -10,7 +10,7 @@ import { tmpdir } from "node:os";
1010 import { sweepAbandonedChecks, failAbandonedRuns } from "../core/runs.ts";
1111 import { serve } from "../http/server.ts";
1212 import { takeSnapshot } from "../snapshot/snapshot.ts";
13 import { dirStore } from "../snapshot/store.ts";
13 import { dirStore } from "../blob/store.ts";
1414 import { dbFile, reopen, type World } from "./world.ts";
1515
1616 export interface Fault {
src/chaos/invariants.ts +1 −1
@@ -10,7 +10,7 @@ import { Database } from "bun:sqlite";
1010 import { repoDir } from "../git/repos.ts";
1111 import { restoreSnapshot } from "../snapshot/restore.ts";
1212 import { takeSnapshot } from "../snapshot/snapshot.ts";
13 import { dirStore } from "../snapshot/store.ts";
13 import { dirStore } from "../blob/store.ts";
1414 import { SEALED_VALUE, type World } from "./world.ts";
1515
1616 export interface Invariant {
src/git/bundle_uri.ts +1 −1
@@ -29,7 +29,7 @@ import type { ForgeEvent } from "../core/events.ts";
2929 import { getRepoById, type Repo } from "../core/repos.ts";
3030 import { createLog } from "../kernel/log.ts";
3131 import { repoDir } from "./repos.ts";
32 import { s3FromEnv, s3Store, type Store } from "../snapshot/store.ts";
32 import { s3FromEnv, s3Store, type Store } from "../blob/store.ts";
3333
3434 export interface Published {
3535 readonly oid: string;
src/http/mcp/tools/backups.ts +2 −2
@@ -1,8 +1,8 @@
11 import { snapshotsOf } from "../../../snapshot/service.ts";
22 import { resolveSnapshots, scrubReason, sealedTarget } from "../../../snapshot/destination.ts";
3 import { bodiesOf } from "../../../snapshot/store.ts";
3 import { bodiesOf } from "../../../blob/store.ts";
44 import { mirrorNeed } from "../../../snapshot/mirror.ts";
5 import { s3FromEnv } from "../../../snapshot/store.ts";
5 import { s3FromEnv } from "../../../blob/store.ts";
66 import { listSnapshots } from "../../../snapshot/snapshot.ts";
77 import { hostedWords, keptWords } from "../../../snapshot/hosted.ts";
88 import { backupVerdict } from "../../../snapshot/bucket.ts";
src/http/mcp/tools/backups_destination.ts +1 −1
@@ -1,6 +1,6 @@
11 import { forgetDestination, invalidField, saveDestination, type DestinationInput } from "../../../actions/destination.ts";
22 import { resolveSnapshots } from "../../../snapshot/destination.ts";
3 import { bodiesOf } from "../../../snapshot/store.ts";
3 import { bodiesOf } from "../../../blob/store.ts";
44 import { good, bad, type Tool } from "../shared.ts";
55
66 export const tool: Tool = {
src/snapshot/bucket.ts +1 −1
@@ -22,7 +22,7 @@ import { listSnapshots, notInSnapshot } from "./snapshot.ts";
2222 import type { HostedEntry } from "./hosted.ts";
2323 import { scrubReason } from "./destination.ts";
2424 import { lastOutside, type OutsideDrill } from "./kit.ts";
25 import { bodiesOf, type S3Target, type Store } from "./store.ts";
25 import { bodiesOf, type S3Target, type Store } from "../blob/store.ts";
2626
2727 /** A newest snapshot older than this is red: the nightly is 24 h apart, plus a slow one's slack. */
2828 export const LATE_MS = 26 * 3_600_000;
src/snapshot/destination.ts +1 −1
@@ -22,7 +22,7 @@ import {
2222 s3Store,
2323 type S3Target,
2424 type Store,
25 } from "./store.ts";
25 } from "../blob/store.ts";
2626
2727 export type DestinationSource = "sealed" | "dir" | "env";
2828
src/snapshot/drill.ts +1 −1
@@ -22,7 +22,7 @@ import { restoreSnapshot, type Progress } from "./restore.ts";
2222 import { drillPick, proveHosted, type HostedProof } from "./drill_hosted.ts";
2323 import { isOffBox } from "./off_box.ts";
2424 import { listSnapshots } from "./snapshot.ts";
25 import type { Store } from "./store.ts";
25 import type { Store } from "../blob/store.ts";
2626
2727 /** The floor of every drill's budget, and the whole budget for finding the newest snapshot. */
2828 export const DRILL_TIMEOUT_MS = 10 * 60_000;
src/snapshot/drill_child.ts +1 −1
@@ -15,7 +15,7 @@
1515 import { runDrill, type DrillResult } from "./drill.ts";
1616 import { storeFrom } from "./remake.ts";
1717 import type { Progress } from "./restore.ts";
18 import type { StoreSpec } from "./store.ts";
18 import type { StoreSpec } from "../blob/store.ts";
1919
2020 export interface DrillJob {
2121 readonly dataDir: string;
src/snapshot/drill_hosted.ts +1 −1
@@ -18,7 +18,7 @@ import { join } from "node:path";
1818 import { runGit } from "../git/env.ts";
1919 import type { HostedEntry } from "./hosted.ts";
2020 import { restoreHosted } from "./restore.ts";
21 import type { Store } from "./store.ts";
21 import type { Store } from "../blob/store.ts";
2222
2323 /** What a drill says of the hosted forge it restored. */
2424 export interface HostedProof {
src/snapshot/kit.ts +1 −1
@@ -20,7 +20,7 @@ import { answersRoot, DRILL_TIMEOUT_MS } from "./drill.ts";
2020 import { OUTSIDE_SCRATCH } from "./drill_job.ts";
2121 import { readOnlyTarget, sealsSnapshots, type Sources } from "./destination.ts";
2222 import { sealedStore } from "./sealed_store.ts";
23 import { s3Store, type S3Target, type Store } from "./store.ts";
23 import { s3Store, type S3Target, type Store } from "../blob/store.ts";
2424
2525 export interface Kit {
2626 readonly v: 1;
src/snapshot/lanes.ts +1 −1
@@ -26,7 +26,7 @@
2626
2727 import { LATE_MS, isRetired, printable, scrubError, type LaneRead } from "./bucket.ts";
2828 import { isOffBox } from "./off_box.ts";
29 import { s3Where, type S3Target } from "./store.ts";
29 import { s3Where, type S3Target } from "../blob/store.ts";
3030
3131 /** Pages read at one folder level before the read counts as bounded. */
3232 export const PAGES = 3;
src/snapshot/mirror.ts +1 −1
@@ -26,7 +26,7 @@ import { deleteSecret, resolveSecrets } from "../core/secret_store.ts";
2626 import { chunkKey, CHUNK_PREFIX } from "./chunks.ts";
2727 import { chunksNamed, KEEP, listSnapshots, missingChunks, pruneSnapshots, SNAPSHOT_PREFIX, storedChunk, type Manifest } from "./snapshot.ts";
2828 import { refusingStore, sealedStore } from "./sealed_store.ts";
29 import { remakeOf, s3Store, type S3Target, type Store } from "./store.ts";
29 import { remakeOf, s3Store, type S3Target, type Store } from "../blob/store.ts";
3030 import type { MirrorAnswer, MirrorJob } from "./mirror_worker.ts";
3131 import { verifySnapshot } from "./verify.ts";
3232
src/snapshot/mirror_worker.ts +1 −1
@@ -13,7 +13,7 @@
1313
1414 import { mirrorPass, type MirrorState } from "./mirror.ts";
1515 import { storeFrom } from "./remake.ts";
16 import type { StoreSpec } from "./store.ts";
16 import type { StoreSpec } from "../blob/store.ts";
1717 import { workerMemory } from "../perf/memory_watch.ts";
1818
1919 export interface MirrorJob {
src/snapshot/off_box.ts +1 −1
@@ -12,7 +12,7 @@
1212
1313 import { lastMirror } from "./mirror.ts";
1414 import { lastSnapshotOutcome, offBoxAtOf } from "./outcome.ts";
15 import type { Store } from "./store.ts";
15 import type { Store } from "../blob/store.ts";
1616
1717 /** The host of a bucket's `where` (`host[:port]/bucket`), lower-cased, without its port or brackets. */
1818 function hostOf(where: string): string {
src/snapshot/probe.ts +1 −1
@@ -9,7 +9,7 @@
99 */
1010
1111 import { listSnapshots } from "./snapshot.ts";
12 import type { Store } from "./store.ts";
12 import type { Store } from "../blob/store.ts";
1313 import { boundedSignal } from "../kernel/fetch_timeout.ts";
1414
1515 /** One nightly plus a day-and-a-half's grace: older than this is a missed night. */
src/snapshot/remake.ts +1 −1
@@ -6,7 +6,7 @@
66 */
77
88 import { sealedStore } from "./sealed_store.ts";
9 import { dirStore, s3Store, type Store, type StoreSpec } from "./store.ts";
9 import { dirStore, s3Store, type Store, type StoreSpec } from "../blob/store.ts";
1010
1111 export function storeFrom(spec: StoreSpec): Store {
1212 if (spec.kind === "s3") return s3Store(spec.target, spec.attempts);
src/snapshot/restore.ts +1 −1
@@ -65,7 +65,7 @@ import { isPackedFile, partPaths, safePath, unpacker, type PackedFile, type Unpa
6565 import { resolveSnapshots } from "./destination.ts";
6666 import { offsiteFromEnv } from "./mirror.ts";
6767 import { kitStore, parseKit } from "./kit.ts";
68 import type { Store } from "./store.ts";
68 import type { Store } from "../blob/store.ts";
6969
7070 export interface Restored {
7171 readonly manifest: Manifest;
src/snapshot/sealed_store.ts +1 −1
@@ -28,7 +28,7 @@
2828 */
2929
3030 import { createCipheriv, createDecipheriv, createHmac, randomBytes, scrypt, timingSafeEqual } from "node:crypto";
31 import { remakeOf, remakes, type Store } from "./store.ts";
31 import { remakeOf, remakes, type Store } from "../blob/store.ts";
3232
3333 export const SEALED_PREFIX = "sealed/";
3434 const MAGIC = Buffer.from("FSO1");
src/snapshot/service.ts +1 −1
@@ -37,7 +37,7 @@ import { lastMirror, mirrorOffThread, mirrorTarget, MIRROR_EVERY_MS, recordMirro
3737 import { isOffBox } from "./off_box.ts";
3838 import { failureCause } from "./cause.ts";
3939 import { noteOffBox, recordSnapshotOutcome, SNAPSHOT_RETRY_MS } from "./outcome.ts";
40 import { remakeOf, s3FromEnv, type Store } from "./store.ts";
40 import { remakeOf, s3FromEnv, type Store } from "../blob/store.ts";
4141 import { verifySnapshot } from "./verify.ts";
4242 import { during } from "../perf/jobs.ts";
4343 import { limitValue } from "../settings/limits.ts";
src/snapshot/snapshot.ts +1 −1
@@ -50,7 +50,7 @@ import { copyHosted, unchanged, HostedRefusal, hostedSources, HOSTED_PREFIX, ope
5050 import { countRows, type DrillCounts } from "./counts.ts";
5151 import { CHUNK_PREFIX, chunkId, chunkKey, chunkSeed, contentChunker, fixedChunker, isChunkId, packChunk, type Chunker } from "./chunks.ts";
5252 import type { PackedFile } from "./parts.ts";
53 import { bodiesOf, type Store } from "./store.ts";
53 import { bodiesOf, type Store } from "../blob/store.ts";
5454 import { putsAtOnce } from "./line.ts";
5555 import { unwrapKey, wrapKey, WRAPPED_KEY } from "./wrap.ts";
5656 import { during } from "../perf/jobs.ts";
src/snapshot/standby.ts +1 −1
@@ -10,7 +10,7 @@ import { join } from "node:path";
1010 import { repoDir } from "../git/repos.ts";
1111 import { restoreSnapshot, type Restored } from "./restore.ts";
1212 import { listSnapshots } from "./snapshot.ts";
13 import type { Store } from "./store.ts";
13 import type { Store } from "../blob/store.ts";
1414
1515 export interface Standby {
1616 readonly name: string;
src/snapshot/verify.ts +1 −1
@@ -30,7 +30,7 @@ import {
3030 type BrokenRefs,
3131 type Manifest,
3232 } from "./snapshot.ts";
33 import type { Store } from "./store.ts";
33 import type { Store } from "../blob/store.ts";
3434
3535 export interface Verified {
3636 readonly name: string;
src/tui/screens/resilience.ts +1 −1
@@ -45,7 +45,7 @@ import { backupVerdict } from "../../snapshot/bucket.ts";
4545 import { lastDrill } from "../../snapshot/drills.ts";
4646 import { hostedDrillWords } from "../../snapshot/drill_hosted_words.ts";
4747 import { resolveSnapshots } from "../../snapshot/destination.ts";
48 import { bodiesOf } from "../../snapshot/store.ts";
48 import { bodiesOf } from "../../blob/store.ts";
4949 import { snapshotsOf } from "../../snapshot/service.ts";
5050 import type { Ctx, Screen } from "../app/app.ts";
5151 import { binding } from "../app/keys.ts";
src/view/doc_sections.ts +1
@@ -68,6 +68,7 @@ export const DOC_LINES: Record<string, Line> = {
6868 "ADAPTERS.md": ["reference", "Apps that import from other systems."],
6969 "THREATS.md": ["reference", "Who might attack, and what stops them."],
7070
71 "BLOBS.md": ["internals", "The one store for big, immutable bytes."],
7172 "ARCHITECTURE.md": ["internals", "How the parts fit together."],
7273 "DEVELOP.md": ["internals", "Tests, type check and the push gate."],
7374 "PRINCIPLES.md": ["internals", "Rules learned the hard way."],
src/web/pages/backups.ts +1 −1
@@ -33,7 +33,7 @@ import { drillFailure, drillTiming, spokenSpan } from "../../snapshot/drill_card
3333 import { costFacts } from "../../snapshot/drill_cost.ts";
3434 import { lastDrill } from "../../snapshot/drills.ts";
3535 import { backupVerdict } from "../../snapshot/bucket.ts";
36 import { bodiesOf, type Store } from "../../snapshot/store.ts";
36 import { bodiesOf, type Store } from "../../blob/store.ts";
3737 import { hostedWords } from "../../snapshot/hosted.ts";
3838 import { hostedDrillWords } from "../../snapshot/drill_hosted_words.ts";
3939 import { snapshotsOf, type SnapshotsHandle } from "../../snapshot/service.ts";
test/backup-growth.test.ts +1 −1
@@ -7,7 +7,7 @@ import { tmpdir } from "node:os";
77 import { join } from "node:path";
88 import { createApp } from "../src/app.ts";
99 import { startSnapshots } from "../src/snapshot/service.ts";
10 import { dirStore, type Store } from "../src/snapshot/store.ts";
10 import { dirStore, type Store } from "../src/blob/store.ts";
1111 import { rulesWorld } from "./helpers/rules-app.ts";
1212 import { duty, TITLE } from "../src/maintain/duties/backup_growth.ts";
1313 import { growthOf } from "../src/snapshot/growth.ts";
test/backup-lanes.test.ts +1 −1
@@ -26,7 +26,7 @@ import {
2626 type Lister,
2727 } from "../src/snapshot/lanes.ts";
2828 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
29 import { dirStore } from "../src/snapshot/store.ts";
29 import { dirStore } from "../src/blob/store.ts";
3030 import { verdictLines } from "../src/tui/screens/resilience.ts";
3131
3232 const NOW = Date.parse("2026-11-02T12:00:00Z");
test/backup-probe.test.ts +1 −1
@@ -5,7 +5,7 @@ import { mkdtempSync, rmSync } from "node:fs";
55 import { tmpdir } from "node:os";
66 import { join } from "node:path";
77 import { parseProbeArgs, probe } from "../src/snapshot/probe.ts";
8 import { dirStore } from "../src/snapshot/store.ts";
8 import { dirStore } from "../src/blob/store.ts";
99
1010 const root = mkdtempSync(join(tmpdir(), "probe-"));
1111 afterAll(() => rmSync(root, { recursive: true, force: true }));
test/backup-retry.test.ts +1 −1
@@ -9,7 +9,7 @@ import { createUser, type User } from "../src/core/users.ts";
99 import { alarmBackup } from "../src/flow/alarm_backup.ts";
1010 import { recordSnapshotOutcome } from "../src/snapshot/outcome.ts";
1111 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
12 import { dirStore } from "../src/snapshot/store.ts";
12 import { dirStore } from "../src/blob/store.ts";
1313 import { cachedAlarms } from "../src/web/studio/alarm_lines.ts";
1414 import { createForgeApp } from "../src/tui/forge.ts";
1515 import { headlessTerminal } from "../src/tui/term/terminal.ts";
test/backup-truth.test.ts +1 −1
@@ -18,7 +18,7 @@ import type { DrillResult } from "../src/snapshot/drill.ts";
1818 import { lastNightly, snapshotDue } from "../src/snapshot/due.ts";
1919 import { snapshotsOf, startSnapshots } from "../src/snapshot/service.ts";
2020 import { listSnapshots } from "../src/snapshot/snapshot.ts";
21 import { dirStore } from "../src/snapshot/store.ts";
21 import { dirStore } from "../src/blob/store.ts";
2222 import { verdictLines } from "../src/tui/screens/resilience.ts";
2323 import { readHealth } from "../src/actions/health.ts";
2424 import type { User } from "../src/core/users.ts";
test/backups-drill-cost.test.ts +1 −1
@@ -12,7 +12,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1212 import type { DrillResult } from "../src/snapshot/drill.ts";
1313 import { recordDrill } from "../src/snapshot/drills.ts";
1414 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
1717
1818 quietLogs();
test/backups-drill-words.test.ts +1 −1
@@ -15,7 +15,7 @@ import { costFacts, costLine } from "../src/snapshot/drill_cost.ts";
1515 import { drillFailure, spokenSpan, stepDoing } from "../src/snapshot/drill_card_words.ts";
1616 import { recordDrill } from "../src/snapshot/drills.ts";
1717 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919 import { quietLogs } from "./helpers/globals.ts";
2020
2121 quietLogs();
test/backups-line.test.ts +1 −1
@@ -12,7 +12,7 @@ import { createUser, getUserByName } from "../src/core/users.ts";
1212 import { serve, type Servers } from "../src/http/server.ts";
1313 import { BACKUPS_OFF, backupsLineOf } from "../src/snapshot/backups_line.ts";
1414 import { startSnapshots } from "../src/snapshot/service.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { createForgeApp } from "../src/tui/forge.ts";
1717 import { headlessTerminal } from "../src/tui/term/terminal.ts";
1818 import { quietLogs } from "./helpers/globals.ts";
test/backups-live.test.ts +1 −1
@@ -13,7 +13,7 @@ import { createUser } from "../src/core/users.ts";
1313 import { listEvents } from "../src/core/events.ts";
1414 import { serve, type Servers } from "../src/http/server.ts";
1515 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
16 import { dirStore } from "../src/snapshot/store.ts";
16 import { dirStore } from "../src/blob/store.ts";
1717 import { quietLogs } from "./helpers/globals.ts";
1818
1919 quietLogs();
test/backups-parts.test.ts +1 −1
@@ -14,7 +14,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1414 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
1515 import { recordDrill } from "../src/snapshot/drills.ts";
1616 import { forgetReads, keepReads } from "../src/snapshot/bucket.ts";
17 import { dirStore } from "../src/snapshot/store.ts";
17 import { dirStore } from "../src/blob/store.ts";
1818 import { quietLogs } from "./helpers/globals.ts";
1919
2020 quietLogs();
test/backups-timing.test.ts +1 −1
@@ -7,7 +7,7 @@ import { createApp, type App } from "../src/app.ts";
77 import { createUser } from "../src/core/users.ts";
88 import { serve, type Servers } from "../src/http/server.ts";
99 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
10 import { dirStore } from "../src/snapshot/store.ts";
10 import { dirStore } from "../src/blob/store.ts";
1111 import { quietLogs } from "./helpers/globals.ts";
1212
1313 quietLogs();
test/blob-store-s3.test.ts added +97
@@ -0,0 +1,97 @@
1 /**
2 * The bucket side of the BlobStore, on the wire: what `s3Store` asks the
3 * bucket for when it puts with a storage class, streams a body, reads a
4 * range and presigns a URL. The real Bun.S3Client runs in a child
5 * (test/helpers/s3-wire.ts) against a fake bucket on loopback, from an
6 * environment built here: the client reads a proxy from its environment
7 * once, and a proxy refuses loopback.
8 */
9 import { beforeAll, describe, expect, test } from "bun:test";
10 import { join } from "node:path";
11
12 interface Seen {
13 method: string;
14 path: string;
15 range: string | null;
16 storageClass: string | null;
17 type: string | null;
18 }
19 type Step<T = unknown> = { value?: T; seen: Seen[] };
20 let out: Record<string, Step> & { presignGet: string; presignPut: string };
21
22 beforeAll(async () => {
23 const child = Bun.spawn([process.execPath, join(import.meta.dir, "helpers/s3-wire.ts")], {
24 env: {
25 PATH: process.env["PATH"] ?? "/usr/bin:/bin",
26 HOME: process.env["HOME"] ?? "/tmp",
27 ...(process.env["TMPDIR"] === undefined ? {} : { TMPDIR: process.env["TMPDIR"] }),
28 },
29 stdout: "pipe",
30 stderr: "pipe",
31 });
32 const [stdout, stderr, code] = await Promise.all([
33 new Response(child.stdout).text(),
34 new Response(child.stderr).text(),
35 child.exited,
36 ]);
37 if (code !== 0) throw new Error(`s3-wire exited ${code}: ${stderr}`);
38 out = JSON.parse(stdout);
39 }, 30_000);
40
41 const requests = (step: string) =>
42 out[step]!.seen.map((s) => `${s.method} ${s.path}${s.range === null ? "" : ` ${s.range}`}`);
43
44 describe("s3Store on the wire", () => {
45 test("a default put sends no storage class, exactly as snapshots always have", () => {
46 expect(out["putDefault"]!.seen).toEqual([
47 expect.objectContaining({ method: "PUT", path: "/b/logs/a", range: null, storageClass: null }),
48 ]);
49 });
50
51 test("the storage-class hint becomes the bucket's class, and a type is sent as given", () => {
52 expect(out["putInfrequent"]!.seen[0]!.storageClass).toBe("STANDARD_IA");
53 expect(out["putInfrequent"]!.seen[0]!.type).toStartWith("text/plain");
54 expect(out["putFile"]!.seen[0]!.storageClass).toBe("DEEP_ARCHIVE");
55 expect(out["putStream"]!.seen.some((s) => s.storageClass === "STANDARD_IA")).toBe(true);
56 });
57
58 test("a Blob and a stream both land whole", () => {
59 expect(out["whole"]!.value).toEqual(["from a file", "streamed in"]);
60 });
61
62 test("a size is one HEAD, and a missing key is undefined, not an error", () => {
63 expect(out["size"]!.value).toBe(11);
64 expect(requests("size")).toEqual(["HEAD /b/logs/a"]);
65 expect(out["sizeAbsent"]!.value).toBeUndefined();
66 });
67
68 test("a range is one ranged GET with an inclusive end, after the HEAD that bounds it", () => {
69 expect(out["range"]!.value).toBe("llo");
70 expect(requests("range")).toEqual(["HEAD /b/logs/a", "GET /b/logs/a bytes=2-4"]);
71 expect(out["rangeOpen"]!.value).toBe("world");
72 expect(requests("rangeOpen")).toEqual(["HEAD /b/logs/a", "GET /b/logs/a bytes=6-10"]);
73 });
74
75 test("a range past the end is empty without asking (a bucket would answer 416); an absent key is null", () => {
76 expect(out["rangePast"]!.value).toBe("");
77 expect(requests("rangePast")).toEqual(["HEAD /b/logs/a"]);
78 expect(out["rangeAbsent"]!.value).toBeNull();
79 });
80
81 test("a stream of a range reads only that range", () => {
82 expect(out["stream"]!.value).toBe("in");
83 expect(requests("stream")).toContain("GET /b/logs/d bytes=9-10");
84 });
85
86 test("a presigned URL is signed for its method, expiry and class, and names no secret", () => {
87 const get = new URL(out.presignGet);
88 expect(get.pathname).toBe("/b/logs/a");
89 expect(get.searchParams.get("X-Amz-Expires")).toBe("600");
90 expect(get.searchParams.get("X-Amz-Signature")).toMatch(/^[0-9a-f]{64}$/);
91 expect(get.searchParams.get("x-amz-storage-class")).toBeNull();
92 const put = new URL(out.presignPut);
93 expect(put.searchParams.get("X-Amz-Expires")).toBe("60");
94 expect(put.searchParams.get("x-amz-storage-class")).toBe("STANDARD_IA");
95 expect(out.presignGet + out.presignPut).not.toContain("secret");
96 });
97 });
test/blob-store.test.ts added +187
@@ -0,0 +1,187 @@
1 /**
2 * The BlobStore over a directory, and its retries: streamed puts that
3 * never show half a file, sizes, byte ranges and range streams, keys and
4 * ranges refused at the boundary, and `withRetries` keeping a BlobStore a
5 * BlobStore. The bucket side is test/blob-store-s3.test.ts.
6 */
7 import { afterAll, describe, expect, test } from "bun:test";
8 import { mkdtempSync, readdirSync, rmSync } from "node:fs";
9 import { tmpdir } from "node:os";
10 import { join } from "node:path";
11 import {
12 checkPresign,
13 checkRange,
14 dirStore,
15 isBlobStore,
16 s3StorageClass,
17 withRetries,
18 type BlobStore,
19 type Store,
20 } from "../src/blob/store.ts";
21
22 const root = mkdtempSync(join(tmpdir(), "blob-store-"));
23 afterAll(() => rmSync(root, { recursive: true, force: true }));
24 const text = (b: Uint8Array | undefined) =>
25 b === undefined ? undefined : new TextDecoder().decode(b);
26
27 describe("a directory as a BlobStore", () => {
28 const store = dirStore(join(root, "dir"));
29
30 test("a stream lands whole under its key, and no temporary file is left beside it", async () => {
31 await store.putStream("runs/1/log", new Blob(["one ", "two ", "three"]).stream());
32 expect(text(await store.get("runs/1/log"))).toBe("one two three");
33 expect(readdirSync(join(root, "dir/runs/1"))).toEqual(["log"]);
34 });
35
36 test("a stream that fails leaves nothing under its key", async () => {
37 const broken = new ReadableStream<Uint8Array>({
38 pull(c) {
39 c.error(new Error("the pipe broke"));
40 },
41 });
42 await expect(store.putStream("runs/2/log", broken)).rejects.toThrow("the pipe broke");
43 expect(await store.size("runs/2/log")).toBeUndefined();
44 expect(readdirSync(join(root, "dir/runs/2"))).toEqual([]);
45 });
46
47 test("a Blob put lands as its bytes", async () => {
48 await store.put("a/blob", new Blob(["from a file"]), undefined, { storageClass: "archive" });
49 expect(text(await store.get("a/blob"))).toBe("from a file");
50 });
51
52 test("size, ranges and range streams read what is there; absent is undefined", async () => {
53 await store.put("r", "hello world");
54 expect(await store.size("r")).toBe(11);
55 expect(await store.size("none")).toBeUndefined();
56 expect(text(await store.getRange("r", { start: 2, end: 5 }))).toBe("llo");
57 expect(text(await store.getRange("r", { start: 6 }))).toBe("world");
58 expect(text(await store.getRange("r", { start: 50 }))).toBe("");
59 expect(await store.getRange("none", { start: 0 })).toBeUndefined();
60 expect(await new Response(await store.getStream("r", { start: 0, end: 5 })).text()).toBe("hello");
61 expect(await new Response(await store.getStream("r")).text()).toBe("hello world");
62 expect(await store.getStream("none")).toBeUndefined();
63 });
64
65 test("a directory has no URL to presign", () => {
66 expect(store.presign).toBeUndefined();
67 });
68
69 test("a key that leaves the directory, or carries a control byte, is refused", async () => {
70 for (const key of ["../x", "/etc/passwd", "a/../../x", "", "a/./b", "a\nb"])
71 await expect(store.getRange(key, { start: 0 })).rejects.toThrow("refusing key");
72 await expect(store.putStream("../x", new Blob(["x"]).stream())).rejects.toThrow("refusing key");
73 });
74
75 test("a range that is not whole, non-negative bytes in order is refused", async () => {
76 for (const range of [{ start: -1 }, { start: 1.5 }, { start: 5, end: 4 }, { start: 0, end: Number.NaN }])
77 await expect(store.getRange("r", range)).rejects.toThrow("refusing range");
78 expect(() => checkRange({ start: 0, end: 0 })).not.toThrow();
79 });
80 });
81
82 describe("the boundary rules a bucket shares", () => {
83 test("a presign is a GET or a PUT for 1 s to seven days", () => {
84 expect(() => checkPresign({ method: "GET", expiresInS: 1 })).not.toThrow();
85 expect(() => checkPresign({ method: "PUT", expiresInS: 604_800 })).not.toThrow();
86 for (const bad of [
87 { method: "GET", expiresInS: 0 },
88 { method: "GET", expiresInS: 604_801 },
89 { method: "GET", expiresInS: 1.5 },
90 { method: "DELETE", expiresInS: 60 },
91 ])
92 expect(() => checkPresign(bad)).toThrow("refusing presign");
93 });
94
95 test("the class hint maps to S3's names, and hot sends none", () => {
96 expect(s3StorageClass(undefined)).toBeUndefined();
97 expect(s3StorageClass("hot")).toBeUndefined();
98 expect(s3StorageClass("infrequent")).toBe("STANDARD_IA");
99 expect(s3StorageClass("archive")).toBe("DEEP_ARCHIVE");
100 });
101 });
102
103 describe("withRetries over a BlobStore", () => {
104 /** A directory store whose reads fail the first `failures` times each. */
105 function flaky(failures: number): { store: BlobStore; calls: string[] } {
106 const inner = dirStore(join(root, `flaky-${failures}`));
107 const calls: string[] = [];
108 const left = new Map<string, number>();
109 const gate = (what: string): void => {
110 calls.push(what);
111 const n = left.get(what) ?? failures;
112 if (n > 0) {
113 left.set(what, n - 1);
114 throw new Error("S3Error: an unexpected error has occurred");
115 }
116 };
117 return {
118 calls,
119 store: {
120 ...inner,
121 async size(key) {
122 gate(`size ${key}`);
123 return inner.size(key);
124 },
125 async getRange(key, range) {
126 gate(`getRange ${key}`);
127 return inner.getRange(key, range);
128 },
129 async getStream(key, range) {
130 gate(`getStream ${key}`);
131 return inner.getStream(key, range);
132 },
133 async putStream(key, body) {
134 gate(`putStream ${key}`);
135 return inner.putStream(key, body);
136 },
137 },
138 };
139 }
140 const quick = { sleep: async () => {} };
141
142 test("it stays a BlobStore; the snapshot shape stays a Store", () => {
143 const blob = withRetries(dirStore(join(root, "w")), quick);
144 expect(isBlobStore(blob)).toBe(true);
145 expect(isBlobStore(blob.bounded!(() => 60_000))).toBe(true);
146 const plain: Store = {
147 where: "plain",
148 put: async () => {},
149 get: async () => undefined,
150 list: async () => [],
151 names: async () => [],
152 delete: async () => {},
153 };
154 expect(isBlobStore(withRetries(plain, quick))).toBe(false);
155 });
156
157 test("sizes, ranges and opening a stream are tried again", async () => {
158 const f = flaky(2);
159 await f.store.put("k", "hello world");
160 const store = withRetries(f.store, quick);
161 expect(await store.size("k")).toBe(11);
162 expect(text(await store.getRange("k", { start: 0, end: 5 }))).toBe("hello");
163 expect(await new Response(await store.getStream("k", { start: 6 })).text()).toBe("world");
164 expect(f.calls.filter((c) => c === "getRange k")).toHaveLength(3);
165 });
166
167 test("a stream is put once, and its failure names the key", async () => {
168 const f = flaky(1);
169 const store = withRetries(f.store, quick);
170 await expect(store.putStream("s", new Blob(["x"]).stream())).rejects.toThrow(
171 "put s failed: S3Error",
172 );
173 expect(f.calls).toEqual(["putStream s"]);
174 });
175
176 test("a Blob put's deadline follows its size, as a byte put's does", async () => {
177 const stalled = {
178 ...dirStore(join(root, "stalled")),
179 put: () => new Promise<void>(() => {}),
180 } as BlobStore;
181 // 300 bytes at a floor of 1 kB/s and no slack: a 300 ms deadline, named in the failure.
182 const store = withRetries(stalled, { ...quick, attempts: 1, floorBytesPerS: 1_000, slackMs: 0 });
183 await expect(store.put("b", new Blob([new Uint8Array(300)]))).rejects.toThrow(
184 "put b failed after 1 attempt: no answer in 300 ms",
185 );
186 });
187 });
test/bundle-uri-wired.test.ts +1 −1
@@ -17,7 +17,7 @@ import type { User } from "../src/core/users.ts";
1717 import { onPushEvent, pointerOf, settledOf } from "../src/git/bundle_uri.ts";
1818 import { repoDir } from "../src/git/repos.ts";
1919 import { serve, type Servers } from "../src/http/server.ts";
20 import { dirStore } from "../src/snapshot/store.ts";
20 import { dirStore } from "../src/blob/store.ts";
2121 import { seedAdmin } from "./helpers/admin.ts";
2222 import { quietLogs } from "./helpers/globals.ts";
2323
test/bundle-uri.test.ts +1 −1
@@ -13,7 +13,7 @@ import { MAX_BUILDS, noteBundle, retractBundles, settledOf } from "../src/git/bu
1313 import { bundleBase, bundleConfig, bundleKey, bundleUriFor, pointerOf, publishBundle } from "../src/git/bundle_uri.ts";
1414 import { initBareRepo, repoDir } from "../src/git/repos.ts";
1515 import { advertiseRefs, isGitService, serviceCommand, serviceRpc } from "../src/git/smart-http.ts";
16 import { dirStore } from "../src/snapshot/store.ts";
16 import { dirStore } from "../src/blob/store.ts";
1717 import { unwrap } from "../src/kernel/result.ts";
1818 import { gitClientEnv } from "./helpers/git-client.ts";
1919
test/cost-ledger-snapshot.test.ts +1 −1
@@ -5,7 +5,7 @@ import { join } from "node:path";
55 import { createApp } from "../src/app.ts";
66 import { setLedgerDir, verifyDir } from "../src/core/ledger.ts";
77 import { startSnapshots } from "../src/snapshot/service.ts";
8 import { dirStore, type Store } from "../src/snapshot/store.ts";
8 import { dirStore, type Store } from "../src/blob/store.ts";
99 import { quietLogs } from "./helpers/globals.ts";
1010
1111 quietLogs();
test/drill-budget-size.test.ts +1 −1
@@ -18,7 +18,7 @@ import { DRILL_MS_PER_MB, drillBudgetMs, runDrill } from "../src/snapshot/drill.
1818 import { failedSentence } from "../src/snapshot/verdict.ts";
1919 import { restoreSnapshot } from "../src/snapshot/restore.ts";
2020 import { listSnapshots, takeSnapshot } from "../src/snapshot/snapshot.ts";
21 import { CALL_DEADLINE_MS, dirStore, withRetries, type Store } from "../src/snapshot/store.ts";
21 import { CALL_DEADLINE_MS, dirStore, withRetries, type Store } from "../src/blob/store.ts";
2222 import { quietLogs } from "./helpers/globals.ts";
2323 import { waitFor } from "./helpers/poll.ts";
2424
test/drill-cost-setting.test.ts +1 −1
@@ -12,7 +12,7 @@ import { LIMIT_RULE } from "../src/snapshot/drill_cost.ts";
1212 import { drillMemoryLimit } from "../src/snapshot/drill_job.ts";
1313 import { lastDrill } from "../src/snapshot/drills.ts";
1414 import { startSnapshots } from "../src/snapshot/service.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { drillMemoryDefaultMiB, LIMITS, limitValue, setLimit } from "../src/settings/limits.ts";
1717 import { createUser, getUserByName } from "../src/core/users.ts";
1818
test/drill-hosted-card.test.ts +1 −1
@@ -15,7 +15,7 @@ import type { DrillResult } from "../src/snapshot/drill.ts";
1515 import { hostedDrillWords, seconds } from "../src/snapshot/drill_hosted_words.ts";
1616 import { lastDrill, recordDrill } from "../src/snapshot/drills.ts";
1717 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919 import { drillNeed, lastVerdict, recordVerdict, verdictComment } from "../src/snapshot/verdict.ts";
2020 import { hostedDrillLines } from "../src/tui/screens/resilience.ts";
2121 import { quietLogs } from "./helpers/globals.ts";
test/drill-hosted-proof.test.ts +1 −1
@@ -15,7 +15,7 @@ import { chunkId, chunkKey, packChunk } from "../src/snapshot/chunks.ts";
1515 import { proveHosted } from "../src/snapshot/drill_hosted.ts";
1616 import type { HostedEntry } from "../src/snapshot/hosted.ts";
1717 import { SNAPSHOT_PREFIX, type Manifest, type SnapshotFile } from "../src/snapshot/snapshot.ts";
18 import type { Store } from "../src/snapshot/store.ts";
18 import type { Store } from "../src/blob/store.ts";
1919
2020 const SNAP = "2026-11-16T08-00-00Z";
2121
test/drill-hosted-red.test.ts +1 −1
@@ -16,7 +16,7 @@ import { setNotifyUrl, startNotifier } from "../src/crew/notify.ts";
1616 import { namedForge, runDrill, type DrillDeps } from "../src/snapshot/drill.ts";
1717 import type { HostedEntry } from "../src/snapshot/hosted.ts";
1818 import { SNAPSHOT_PREFIX, type Manifest } from "../src/snapshot/snapshot.ts";
19 import type { Store } from "../src/snapshot/store.ts";
19 import type { Store } from "../src/blob/store.ts";
2020 import { recordVerdict, seedFirstSeen } from "../src/snapshot/verdict.ts";
2121
2222 const SNAP = "2026-11-16T08-00-00Z";
test/drill-job.test.ts +1 −1
@@ -11,7 +11,7 @@ import { cutDrill, drillMemoryLimit, markerLeft, residentBytes, runDrillInChild,
1111 import { costFacts, costLine, LIMIT_RULE } from "../src/snapshot/drill_cost.ts";
1212 import { lastDrill, parseCost, recordDrill } from "../src/snapshot/drills.ts";
1313 import { startSnapshots } from "../src/snapshot/service.ts";
14 import { dirStore } from "../src/snapshot/store.ts";
14 import { dirStore } from "../src/blob/store.ts";
1515
1616 let root = "";
1717 beforeEach(() => {
test/drill-parts.test.ts +1 −1
@@ -10,7 +10,7 @@ import { createApp, type App } from "../src/app.ts";
1010 import { createUser } from "../src/core/users.ts";
1111 import { describeTimes, runDrill, timeByPart } from "../src/snapshot/drill.ts";
1212 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
13 import { dirStore, type Store } from "../src/snapshot/store.ts";
13 import { dirStore, type Store } from "../src/blob/store.ts";
1414 import { failedSentence, slowSentence } from "../src/snapshot/verdict.ts";
1515 import { quietLogs } from "./helpers/globals.ts";
1616
test/drill-verdict.test.ts +1 −1
@@ -15,7 +15,7 @@ import { createUser } from "../src/core/users.ts";
1515 import { vitals } from "../src/kernel/vitals.ts";
1616 import { bootRestored } from "../src/snapshot/boot.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919 import { runDrill } from "../src/snapshot/drill.ts";
2020 import { untilDrill } from "../src/snapshot/service.ts";
2121 import { lastVerdict, postToRecoveryIssue, reportVerdict, verdictComment } from "../src/snapshot/verdict.ts";
test/drill-weekly.test.ts +1 −1
@@ -16,7 +16,7 @@ import { BOOT_RED_FLOOR_MS, drillDue, lastSlot, RED_RETRY_MS } from "../src/snap
1616 import { lastDrill, recordDrill } from "../src/snapshot/drills.ts";
1717 import { startSnapshots } from "../src/snapshot/service.ts";
1818 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
19 import { dirStore } from "../src/snapshot/store.ts";
19 import { dirStore } from "../src/blob/store.ts";
2020 import { recordVerdict } from "../src/snapshot/verdict.ts";
2121
2222 const t = (iso: string): number => Date.parse(iso);
test/drop-backup.test.ts +1 −1
@@ -15,7 +15,7 @@ import { createUser } from "../src/core/users.ts";
1515 import { dropDir } from "../src/drop/store.ts";
1616 import { restoreSnapshot } from "../src/snapshot/restore.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919
2020 let root: string;
2121 let app: App;
test/forge-archive.test.ts +1 −1
@@ -22,7 +22,7 @@ import { clientRows, servedRows, useChildFetch } from "../src/spawn/clients.ts";
2222 import { useProbe } from "../src/spawn/door.ts";
2323 import { firstBoot } from "../src/spawn/first-boot.ts";
2424 import { personReading } from "../src/spawn/person_activity.ts";
25 import { dirStore } from "../src/snapshot/store.ts";
25 import { dirStore } from "../src/blob/store.ts";
2626 import { BODY_ID } from "../src/spawn/archive.ts";
2727 import { isAwakeBody, resolveHostedChild, sleepChild, wakeGate } from "../src/spawn/host.ts";
2828 import { childPublicUrl } from "../src/spawn/placement.ts";
test/forge-needs-defaults.test.ts +1 −1
@@ -22,7 +22,7 @@ import { claimRun, createRun, finishRun } from "../src/core/runs.ts";
2222 import { recordVerdict } from "../src/snapshot/verdict.ts";
2323 import type { DrillResult } from "../src/snapshot/drill.ts";
2424 import { startSnapshots } from "../src/snapshot/service.ts";
25 import { dirStore } from "../src/snapshot/store.ts";
25 import { dirStore } from "../src/blob/store.ts";
2626 import { needsScreen, whyNot } from "../src/tui/screens/needs.ts";
2727 import type { Ctx as TuiCtx } from "../src/tui/app/app.ts";
2828 import type { Session } from "../src/tui/session.ts";
test/format-duration.test.ts +1 −1
@@ -1,5 +1,5 @@
11 import { expect, test } from "bun:test";
2 import { noAnswerIn } from "../src/snapshot/store.ts";
2 import { noAnswerIn } from "../src/blob/store.ts";
33 import { plainDurations } from "../src/snapshot/verdict.ts";
44 import { durationWords, spanWords } from "../src/system/format.ts";
55 import { costFacts, costLine } from "../src/snapshot/drill_cost.ts";
test/helpers/archive-child.ts +1 −1
@@ -7,7 +7,7 @@ import { createApp } from "../../src/app.ts";
77 import { archiveForge } from "../../src/spawn/archive.ts";
88 import { useChildFetch } from "../../src/spawn/clients.ts";
99 import { useProbe } from "../../src/spawn/door.ts";
10 import { dirStore } from "../../src/snapshot/store.ts";
10 import { dirStore } from "../../src/blob/store.ts";
1111
1212 const app = createApp({ dataDir: process.env["DATA_DIR"]!, url: "https://forge.test", port: 0 });
1313 useProbe(app, () => async () => true);
test/helpers/s3-wire.ts added +122
@@ -0,0 +1,122 @@
1 /**
2 * Run as its own process by test/blob-store-s3.test.ts: a fake S3 bucket on
3 * loopback and `s3Store` (the real Bun.S3Client) pointed at it. Every
4 * request the client made and every answer it got is printed as one JSON
5 * line. Its own process, so the environment it starts from is the one the
6 * test built: Bun's S3 client takes its proxy from the environment once,
7 * and a proxy refuses loopback.
8 */
9 import { s3Store } from "../../src/blob/store.ts";
10
11 interface Seen {
12 method: string;
13 path: string;
14 range: string | null;
15 storageClass: string | null;
16 type: string | null;
17 }
18 const seen: Seen[] = [];
19 const kept = new Map<string, Uint8Array>();
20 const parts = new Map<number, Uint8Array>();
21
22 const server = Bun.serve({
23 hostname: "127.0.0.1",
24 port: 0,
25 async fetch(req) {
26 const url = new URL(req.url);
27 const path = decodeURIComponent(url.pathname);
28 seen.push({
29 method: req.method,
30 path,
31 range: req.headers.get("range"),
32 storageClass: req.headers.get("x-amz-storage-class"),
33 type: req.headers.get("content-type"),
34 });
35 const q = url.searchParams;
36 if (req.method === "POST" && q.has("uploads"))
37 return new Response(
38 `<?xml version="1.0"?><InitiateMultipartUploadResult><UploadId>u</UploadId></InitiateMultipartUploadResult>`,
39 );
40 if (req.method === "PUT" && q.has("partNumber")) {
41 parts.set(Number(q.get("partNumber")), new Uint8Array(await req.arrayBuffer()));
42 return new Response(null, { headers: { etag: `"p${q.get("partNumber")}"` } });
43 }
44 if (req.method === "POST" && q.has("uploadId")) {
45 const all = [...parts.entries()].sort(([a], [b]) => a - b).map(([, p]) => p);
46 kept.set(path, new Uint8Array(Buffer.concat(all)));
47 parts.clear();
48 return new Response(
49 `<?xml version="1.0"?><CompleteMultipartUploadResult><ETag>"x"</ETag></CompleteMultipartUploadResult>`,
50 );
51 }
52 if (req.method === "PUT") {
53 kept.set(path, new Uint8Array(await req.arrayBuffer()));
54 return new Response(null, { headers: { etag: '"x"' } });
55 }
56 if (req.method === "DELETE") {
57 kept.delete(path);
58 return new Response(null, { status: 204 });
59 }
60 const body = kept.get(path);
61 if (body === undefined) return new Response(null, { status: 404 });
62 if (req.method === "HEAD")
63 return new Response(null, { headers: { "content-length": String(body.byteLength) } });
64 const m = /^bytes=(\d+)-(\d*)$/.exec(req.headers.get("range") ?? "");
65 if (m === null) return new Response(body);
66 const start = Number(m[1]);
67 const end = m[2] === "" ? body.byteLength : Number(m[2]) + 1;
68 if (start >= body.byteLength) return new Response(null, { status: 416 });
69 return new Response(body.slice(start, end), { status: 206 });
70 },
71 });
72
73 const store = s3Store({
74 endpoint: `http://127.0.0.1:${server.port}`,
75 bucket: "b",
76 accessKeyId: "AKIDEXAMPLE",
77 secretAccessKey: "secret",
78 region: "auto",
79 });
80 const text = (b: Uint8Array | undefined) =>
81 b === undefined ? null : new TextDecoder().decode(b);
82 const step = async <T>(f: () => Promise<T>): Promise<{ value: T; seen: Seen[] }> => {
83 seen.length = 0;
84 const value = await f();
85 return { value, seen: [...seen] };
86 };
87
88 const out = {
89 putDefault: await step(() => store.put("logs/a", "hello world")),
90 putInfrequent: await step(() =>
91 store.put("logs/b", "cold", undefined, { storageClass: "infrequent", type: "text/plain" }),
92 ),
93 putFile: await step(() =>
94 store.put("logs/c", new Blob(["from a file"]), undefined, { storageClass: "archive" }),
95 ),
96 putStream: await step(() =>
97 store.putStream(
98 "logs/d",
99 new Blob(["streamed ", "in"]).stream(),
100 { storageClass: "infrequent" },
101 ),
102 ),
103 size: await step(() => store.size("logs/a")),
104 sizeAbsent: await step(() => store.size("logs/none")),
105 range: await step(async () => text(await store.getRange("logs/a", { start: 2, end: 5 }))),
106 rangeOpen: await step(async () => text(await store.getRange("logs/a", { start: 6 }))),
107 rangePast: await step(async () => text(await store.getRange("logs/a", { start: 50 }))),
108 rangeAbsent: await step(async () => text(await store.getRange("logs/none", { start: 0 }))),
109 stream: await step(async () => {
110 const s = await store.getStream("logs/d", { start: 9 });
111 return s === undefined ? null : await new Response(s).text();
112 }),
113 whole: await step(async () => [text(await store.get("logs/c")), text(await store.get("logs/d"))]),
114 presignGet: store.presign!("logs/a", { method: "GET", expiresInS: 600 }),
115 presignPut: store.presign!("logs/e", {
116 method: "PUT",
117 expiresInS: 60,
118 storageClass: "infrequent",
119 }),
120 };
121 console.log(JSON.stringify(out));
122 server.stop(true);
test/helpers/snapshot-fixtures.ts +1 −1
@@ -8,7 +8,7 @@
88 import { chunkId, chunkKey, fixedChunker, FIXED_BYTES, packChunk } from "../../src/snapshot/chunks.ts";
99 import { safePath, type PackedFile } from "../../src/snapshot/parts.ts";
1010 import type { SnapshotFile } from "../../src/snapshot/snapshot.ts";
11 import type { Store } from "../../src/snapshot/store.ts";
11 import type { Store } from "../../src/blob/store.ts";
1212
1313 /** `body` put in `store` as chunks of `size`, and the entry a manifest lists it by. */
1414 export async function chunked(store: Store, path: string, body: Uint8Array, size = FIXED_BYTES): Promise<SnapshotFile> {
test/helpers/snapshot-seed.ts +1 −1
@@ -4,7 +4,7 @@
44 * name two days back, so a snapshot taken now is always a second one, never the seeded one again.
55 */
66 import { SNAPSHOT_PREFIX, snapshotName, type Manifest } from "../../src/snapshot/snapshot.ts";
7 import type { Store } from "../../src/snapshot/store.ts";
7 import type { Store } from "../../src/blob/store.ts";
88
99 const SEED_AGE_MS = 2 * 86_400_000;
1010
test/helpers/throttled-drill.ts +1 −1
@@ -19,7 +19,7 @@ import { drillBudgetMs, runDrill } from "../../src/snapshot/drill.ts";
1919 import { chunkId, chunkKey, packChunk } from "../../src/snapshot/chunks.ts";
2020 import { readWhole } from "../../src/snapshot/restore.ts";
2121 import { listSnapshots, takeSnapshot, type Manifest } from "../../src/snapshot/snapshot.ts";
22 import { dirStore, type Store } from "../../src/snapshot/store.ts";
22 import { dirStore, type Store } from "../../src/blob/store.ts";
2323
2424 export const MB = 1_000_000;
2525 /** Free bytes the full run wants on the scratch disk: the 400 MB restored, the rest as margin. */
test/hosted-surfaces.test.ts +1 −1
@@ -12,7 +12,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1212 import { noteHosted } from "../src/snapshot/hosted.ts";
1313 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
1414 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { createForgeApp } from "../src/tui/forge.ts";
1717 import { headlessTerminal } from "../src/tui/term/terminal.ts";
1818 import { quietLogs } from "./helpers/globals.ts";
test/keys-backups.test.ts +1 −1
@@ -7,7 +7,7 @@ import { createApp, type App } from "../src/app.ts";
77 import { createUser } from "../src/core/users.ts";
88 import { serve, type Servers } from "../src/http/server.ts";
99 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
10 import { dirStore } from "../src/snapshot/store.ts";
10 import { dirStore } from "../src/blob/store.ts";
1111 import { quietLogs } from "./helpers/globals.ts";
1212
1313 quietLogs();
test/maintenance.test.ts +1 −1
@@ -14,7 +14,7 @@ import { prepare, resume, resumeAtBoot, resumeNow, status } from "../src/mainten
1414 import { inMaintenance, readState, writeState } from "../src/maintenance/state.ts";
1515 import { HOLD_WORDS } from "../src/runs/held.ts";
1616 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
17 import { dirStore } from "../src/snapshot/store.ts";
17 import { dirStore } from "../src/blob/store.ts";
1818 import { runnerCheck, tunnelCheck } from "../src/maintenance/checks.ts";
1919 import { entry, maintenanceLines, maintenanceScreen } from "../src/tui/screens/maintenance.ts";
2020 import { quietLogs } from "./helpers/globals.ts";
test/mcp-backups.test.ts +1 −1
@@ -9,7 +9,7 @@ import { createToken } from "../src/core/tokens.ts";
99 import { createUser } from "../src/core/users.ts";
1010 import { serve, type Servers } from "../src/http/server.ts";
1111 import { scrubReason } from "../src/snapshot/destination.ts";
12 import { dirStore } from "../src/snapshot/store.ts";
12 import { dirStore } from "../src/blob/store.ts";
1313 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
1414 import { quietLogs } from "./helpers/globals.ts";
1515
test/mcp-mirror-now.test.ts +1 −1
@@ -8,7 +8,7 @@ import { createToken } from "../src/core/tokens.ts";
88 import { createUser } from "../src/core/users.ts";
99 import { serve, type Servers } from "../src/http/server.ts";
1010 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
11 import { dirStore, type Store } from "../src/snapshot/store.ts";
11 import { dirStore, type Store } from "../src/blob/store.ts";
1212 import { promote } from "./helpers/members.ts";
1313 import { quietLogs } from "./helpers/globals.ts";
1414
test/mcp-mirror-set.test.ts +1 −1
@@ -9,7 +9,7 @@ import { createUser } from "../src/core/users.ts";
99 import { serve, type Servers } from "../src/http/server.ts";
1010 import { resolveMirror } from "../src/snapshot/mirror.ts";
1111 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
12 import { dirStore } from "../src/snapshot/store.ts";
12 import { dirStore } from "../src/blob/store.ts";
1313 import { promote } from "./helpers/members.ts";
1414 import { quietLogs } from "./helpers/globals.ts";
1515
test/mcp-ops-tool-cards.test.ts +1 −1
@@ -11,7 +11,7 @@ import { createUser, getUserByName } from "../src/core/users.ts";
1111 import { serve, type Servers } from "../src/http/server.ts";
1212 import type { DrillResult } from "../src/snapshot/drill.ts";
1313 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
14 import { dirStore } from "../src/snapshot/store.ts";
14 import { dirStore } from "../src/blob/store.ts";
1515 import { quietLogs } from "./helpers/globals.ts";
1616
1717 quietLogs();
test/mcp-restore-drill.test.ts +1 −1
@@ -12,7 +12,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1212 import type { DrillResult } from "../src/snapshot/drill.ts";
1313 import { lastDrill } from "../src/snapshot/drills.ts";
1414 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
1717
1818 quietLogs();
test/mcp-snapshot-now.test.ts +1 −1
@@ -8,7 +8,7 @@ import { createToken } from "../src/core/tokens.ts";
88 import { createUser } from "../src/core/users.ts";
99 import { serve, type Servers } from "../src/http/server.ts";
1010 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
11 import { dirStore } from "../src/snapshot/store.ts";
11 import { dirStore } from "../src/blob/store.ts";
1212 import { quietLogs } from "./helpers/globals.ts";
1313
1414 quietLogs();
test/mirror-worker.test.ts +1 −1
@@ -12,7 +12,7 @@ import { join } from "node:path";
1212 import { lastMirror, mirrorOffThread } from "../src/snapshot/mirror.ts";
1313 import { storeFrom } from "../src/snapshot/remake.ts";
1414 import { sealedStore } from "../src/snapshot/sealed_store.ts";
15 import { dirStore, remakeOf, s3Store, type Store } from "../src/snapshot/store.ts";
15 import { dirStore, remakeOf, s3Store, type Store } from "../src/blob/store.ts";
1616 import { bypassProxy, stubBucket } from "./helpers/stub-bucket.ts";
1717
1818 const restoreProxy = bypassProxy();
test/offsite-lane.test.ts +1 −1
@@ -20,7 +20,7 @@ import { restoreSnapshot } from "../src/snapshot/restore.ts";
2020 import { hiddenKey, LANE_HEADER, openBody, parseHeader, sealBody, sealedStore, sealKeys, SEALED_PREFIX } from "../src/snapshot/sealed_store.ts";
2121 import { startSnapshots } from "../src/snapshot/service.ts";
2222 import { listSnapshots, SNAPSHOT_PREFIX } from "../src/snapshot/snapshot.ts";
23 import { dirStore, type Store } from "../src/snapshot/store.ts";
23 import { dirStore, type Store } from "../src/blob/store.ts";
2424 import { tool as systemTool } from "../src/http/mcp/tools/system.ts";
2525 import { Session } from "../src/tui/forge.ts";
2626 import { lastSnapshotOutcome, recordSnapshotOutcome } from "../src/snapshot/outcome.ts";
test/one-core-hold.test.ts +1 −1
@@ -10,7 +10,7 @@ import { createIssue } from "../src/core/issues.ts";
1010 import { createRun, getRun } from "../src/core/runs.ts";
1111 import { createUser } from "../src/core/users.ts";
1212 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
13 import { dirStore } from "../src/snapshot/store.ts";
13 import { dirStore } from "../src/blob/store.ts";
1414 import { holdClock } from "../src/core/one_core.ts";
1515 import { quietLogs } from "./helpers/globals.ts";
1616 import { seedSnapshot } from "./helpers/snapshot-seed.ts";
test/outbound-sweep.test.ts +1 −1
@@ -51,7 +51,7 @@ const ALLOWED: Record<string, { count: number; why: string }> = {
5151 "src/release/small_forge.ts": { count: 1, why: "a forge the release check started itself" },
5252 "src/snapshot/verdict.ts": { count: 1, why: "the forge URL from operator configuration" },
5353 "src/snapshot/drill.ts": { count: 1, why: "the restored forge the drill started on loopback" },
54 "src/snapshot/store.ts": { count: 1, why: "a presigned URL to the operator's bucket" },
54 "src/blob/store.ts": { count: 1, why: "a presigned URL to the operator's bucket" },
5555 "src/snapshot/probe.ts": { count: 1, why: "the operator's forge URL" },
5656 "src/maintenance/standby.ts": { count: 1, why: "the operator's standby page URL" },
5757 "src/maintain/keeper/down.ts": { count: 1, why: "services the operator listed in the keeper's environment" },
test/recovery-doc.test.ts +1 −1
@@ -8,7 +8,7 @@ const doc = read("docs/RECOVERY.md");
88
99 test("the doc names every variable the store reads", () => {
1010 const vars = new Set(
11 [...read("src/snapshot/store.ts").matchAll(/env\["(S3_[A-Z_]+)"\]/g)].map(
11 [...read("src/blob/store.ts").matchAll(/env\["(S3_[A-Z_]+)"\]/g)].map(
1212 (m) => m[1]!,
1313 ),
1414 );
test/recovery-kit.test.ts +1 −1
@@ -13,7 +13,7 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1313 import { saveDestination } from "../src/actions/destination.ts";
1414 import { saveReadKey, takeKit } from "../src/actions/destination.ts";
1515 import { createUser, type User } from "../src/core/users.ts";
16 import { dirStore } from "../src/snapshot/store.ts";
16 import { dirStore } from "../src/blob/store.ts";
1717 import { sealedStore } from "../src/snapshot/sealed_store.ts";
1818 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
1919 import { judge, type LaneRead } from "../src/snapshot/bucket.ts";
test/resilience.test.ts +1 −1
@@ -14,7 +14,7 @@ import { createUser, getUserByName } from "../src/core/users.ts";
1414 import type { Ctx, Screen } from "../src/tui/app/app.ts";
1515 import { forgeCommands, Session } from "../src/tui/forge.ts";
1616 import { startSnapshots } from "../src/snapshot/service.ts";
17 import { dirStore, type Store } from "../src/snapshot/store.ts";
17 import { dirStore, type Store } from "../src/blob/store.ts";
1818 import { createForgeApp } from "../src/tui/forge.ts";
1919 import { headlessTerminal } from "../src/tui/term/terminal.ts";
2020 import { settleApp } from "./helpers/tui.ts";
test/restore-card.test.ts +1 −1
@@ -14,7 +14,7 @@ import { join } from "node:path";
1414 import { createApp, type App } from "../src/app.ts";
1515 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1616 import { createUser } from "../src/core/users.ts";
17 import { dirStore } from "../src/snapshot/store.ts";
17 import { dirStore } from "../src/blob/store.ts";
1818 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
1919
2020 const PASS = "correct horse battery staple";
test/restore-drill-script.test.ts +1 −1
@@ -13,7 +13,7 @@ import { join, relative } from "node:path";
1313 import { createApp, type App } from "../src/app.ts";
1414 import { commitToBranch, createRepo } from "../src/actions/repos.ts";
1515 import { createUser } from "../src/core/users.ts";
16 import { dirStore } from "../src/snapshot/store.ts";
16 import { dirStore } from "../src/blob/store.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
1818 import { compareLines, parseArgs, PRODUCTION } from "../scripts/restore-drill.ts";
1919 import { publicCounts } from "../src/snapshot/public_counts.ts";
test/snapshot-destination.test.ts +1 −1
@@ -17,7 +17,7 @@ import {
1717 } from "../src/actions/destination.ts";
1818 import { createUser, type User } from "../src/core/users.ts";
1919 import { resolveDestination } from "../src/snapshot/destination.ts";
20 import { dirStore, type Store } from "../src/snapshot/store.ts";
20 import { dirStore, type Store } from "../src/blob/store.ts";
2121 import { startSnapshots } from "../src/snapshot/service.ts";
2222 import { serve, type Servers } from "../src/http/server.ts";
2323 import { quietLogs } from "./helpers/globals.ts";
test/snapshot-drill-counts.test.ts +1 −1
@@ -15,7 +15,7 @@ import { createUser } from "../src/core/users.ts";
1515 import { runDrill } from "../src/snapshot/drill.ts";
1616 import { lastDrill, recordDrill } from "../src/snapshot/drills.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919
2020 describe("the restore drill's counts", () => {
2121 let root: string;
test/snapshot-drill-page.test.ts +1 −1
@@ -12,7 +12,7 @@ import { createUser } from "../src/core/users.ts";
1212 import { serve, type Servers } from "../src/http/server.ts";
1313 import type { DrillResult } from "../src/snapshot/drill.ts";
1414 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
15 import { dirStore } from "../src/snapshot/store.ts";
15 import { dirStore } from "../src/blob/store.ts";
1616 import { quietLogs } from "./helpers/globals.ts";
1717
1818 quietLogs();
test/snapshot-drill-phases.test.ts +1 −1
@@ -15,7 +15,7 @@ import { lastDrill, parsePhases, recordDrill } from "../src/snapshot/drills.ts";
1515 import { restoreSnapshot } from "../src/snapshot/restore.ts";
1616 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919 import { quietLogs } from "./helpers/globals.ts";
2020
2121 quietLogs();
test/snapshot-drill.test.ts +1 −1
@@ -16,7 +16,7 @@ import { createUser } from "../src/core/users.ts";
1616 import { drillBudgetMs, formatBudget, formatBytes, formatMinutes, runDrill } from "../src/snapshot/drill.ts";
1717 import { chunked } from "./helpers/snapshot-fixtures.ts";
1818 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
19 import { dirStore } from "../src/snapshot/store.ts";
19 import { dirStore } from "../src/blob/store.ts";
2020
2121 const PASS = "correct horse battery staple";
2222
test/snapshot-hosted-chunks.test.ts +1 −1
@@ -34,7 +34,7 @@ import { drillPick, proveHosted } from "../src/snapshot/drill_hosted.ts";
3434 import { hostedDrillWords } from "../src/snapshot/drill_hosted_words.ts";
3535 import { restoreHosted } from "../src/snapshot/restore.ts";
3636 import { chunksNamed, pruneSnapshots, takeSnapshot, type Manifest } from "../src/snapshot/snapshot.ts";
37 import type { Store } from "../src/snapshot/store.ts";
37 import type { Store } from "../src/blob/store.ts";
3838 import { verifySnapshot } from "../src/snapshot/verify.ts";
3939 import { quietLogs } from "./helpers/globals.ts";
4040
test/snapshot-hosted-history.test.ts +1 −1
@@ -11,7 +11,7 @@ import { createApp, type App } from "../src/app.ts";
1111 import { copyHosted, unchanged } from "../src/snapshot/hosted.ts";
1212 import { restoreHostedInto } from "../src/snapshot/restore.ts";
1313 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
14 import { dirStore } from "../src/snapshot/store.ts";
14 import { dirStore } from "../src/blob/store.ts";
1515
1616 let root: string;
1717 let parent: App;
test/snapshot-hosted-inside.test.ts +1 −1
@@ -39,7 +39,7 @@ import { chunkKey, openChunk } from "../src/snapshot/chunks.ts";
3939 import { copyInProcess, hostedSources, notOwnDir, type HostedSource } from "../src/snapshot/hosted.ts";
4040 import { restoreHosted } from "../src/snapshot/restore.ts";
4141 import { takeSnapshot, type Manifest } from "../src/snapshot/snapshot.ts";
42 import type { Store } from "../src/snapshot/store.ts";
42 import type { Store } from "../src/blob/store.ts";
4343 import { verifySnapshot } from "../src/snapshot/verify.ts";
4444 import { quietLogs } from "./helpers/globals.ts";
4545
test/snapshot-hosted.test.ts +1 −1
@@ -15,7 +15,7 @@ import { repoDir } from "../src/git/repos.ts";
1515 import { bodyIdOf, hostedSources, hostedWords, keptWords, noteHosted, readHosted } from "../src/snapshot/hosted.ts";
1616 import { restoreHosted, restoreHostedInto, restoreSnapshot } from "../src/snapshot/restore.ts";
1717 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
18 import { dirStore } from "../src/snapshot/store.ts";
18 import { dirStore } from "../src/blob/store.ts";
1919
2020 const PASS = "correct horse battery staple";
2121
test/snapshot-incremental.test.ts +1 −1
@@ -70,7 +70,7 @@ import {
7070 takeSnapshot,
7171 type Manifest,
7272 } from "../src/snapshot/snapshot.ts";
73 import { dirStore, s3Store, type Store } from "../src/snapshot/store.ts";
73 import { dirStore, s3Store, type Store } from "../src/blob/store.ts";
7474 import { verifySnapshot } from "../src/snapshot/verify.ts";
7575 import { chunked, pack } from "./helpers/snapshot-fixtures.ts";
7676 import { quietLogs } from "./helpers/globals.ts";
test/snapshot-mirror-page.test.ts +1 −1
@@ -14,7 +14,7 @@ import { serve, type Servers } from "../src/http/server.ts";
1414 import { vitals } from "../src/kernel/vitals.ts";
1515 import { lastMirror, mirrorSealedSet, MIRROR_NAMES, recordMirror, resolveMirror } from "../src/snapshot/mirror.ts";
1616 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
17 import { dirStore } from "../src/snapshot/store.ts";
17 import { dirStore } from "../src/blob/store.ts";
1818 import { quietLogs } from "./helpers/globals.ts";
1919
2020 quietLogs();
test/snapshot-mirror.test.ts +1 −1
@@ -24,7 +24,7 @@ import {
2424 resolveMirror,
2525 } from "../src/snapshot/mirror.ts";
2626 import { startSnapshots } from "../src/snapshot/service.ts";
27 import { dirStore, type Store } from "../src/snapshot/store.ts";
27 import { dirStore, type Store } from "../src/blob/store.ts";
2828
2929 /** A directory as a bucket that can be switched off: while `down`, every call fails like an unreachable host. */
3030 function bucket(dir: string): { store: () => Store; down: boolean } {
test/snapshot-off-box.test.ts +1 −1
@@ -17,7 +17,7 @@ import { recordMirror } from "../src/snapshot/mirror.ts";
1717 import { isOffBox, lastOffBox } from "../src/snapshot/off_box.ts";
1818 import { lastSnapshotOutcome, noteOffBox, recordSnapshotOutcome } from "../src/snapshot/outcome.ts";
1919 import { startSnapshots } from "../src/snapshot/service.ts";
20 import { dirStore, type Store } from "../src/snapshot/store.ts";
20 import { dirStore, type Store } from "../src/blob/store.ts";
2121 import { kpiForge } from "../src/tui/screens/dashboard.ts";
2222
2323 describe("isOffBox", () => {
test/snapshot-one-core.test.ts +1 −1
@@ -12,7 +12,7 @@ import { join } from "node:path";
1212 import { createApp, type App } from "../src/app.ts";
1313 import { MAX_DEFER_MS, startSnapshots } from "../src/snapshot/service.ts";
1414 import { listSnapshots } from "../src/snapshot/snapshot.ts";
15 import { dirStore, type Store } from "../src/snapshot/store.ts";
15 import { dirStore, type Store } from "../src/blob/store.ts";
1616 import { seedSnapshot } from "./helpers/snapshot-seed.ts";
1717
1818 let root: string;
test/snapshot-outcome.test.ts +1 −1
@@ -16,7 +16,7 @@ import { createUser, type User } from "../src/core/users.ts";
1616 import { serve, type Servers } from "../src/http/server.ts";
1717 import { lastSnapshotOutcome, recordSnapshotOutcome, snapshotNeed, SNAPSHOT_RETRY_MS } from "../src/snapshot/outcome.ts";
1818 import { startSnapshots } from "../src/snapshot/service.ts";
19 import { dirStore, type Store } from "../src/snapshot/store.ts";
19 import { dirStore, type Store } from "../src/blob/store.ts";
2020
2121 const failed = (app: App) => forgeVitals(app).degraded.find((d) => d.cause === "snapshot-failed");
2222
test/snapshot-put-abort.test.ts +1 −1
@@ -5,7 +5,7 @@
55 * line with the ones before it. The deadline now aborts the attempt's request.
66 */
77 import { describe, expect, test } from "bun:test";
8 import { rawS3Store, s3Store, withRetries, type Store } from "../src/snapshot/store.ts";
8 import { rawS3Store, s3Store, withRetries, type Store } from "../src/blob/store.ts";
99 import { bypassProxy, stubBucket } from "./helpers/stub-bucket.ts";
1010
1111 describe("a put past its deadline", () => {

20 more files not shown.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs