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
Check · Review · Land · Live done — Landed and live in production.
mason/forge:mason/4489-one-blobstore-promote-src-snapshot-store → main 0 commits fork
120 files
changed +892
−152
- CLAUDE.md
- docs/BLOBS.md
- docs/REFERENCE.md
- scripts/backup-probe.ts
- src/actions/destination.ts
- src/blob/store.ts
- src/chaos/faults.ts
- src/chaos/invariants.ts
- src/git/bundle_uri.ts
- src/http/mcp/tools/backups.ts
- src/http/mcp/tools/backups_destination.ts
- src/snapshot/bucket.ts
- src/snapshot/destination.ts
- src/snapshot/drill.ts
- src/snapshot/drill_child.ts
- src/snapshot/drill_hosted.ts
- src/snapshot/kit.ts
- src/snapshot/lanes.ts
- src/snapshot/mirror.ts
- src/snapshot/mirror_worker.ts
- src/snapshot/off_box.ts
- src/snapshot/probe.ts
- src/snapshot/remake.ts
- src/snapshot/restore.ts
- src/snapshot/sealed_store.ts
- src/snapshot/service.ts
- src/snapshot/snapshot.ts
- src/snapshot/standby.ts
- src/snapshot/verify.ts
- src/tui/screens/resilience.ts
- src/view/doc_sections.ts
- src/web/pages/backups.ts
- test/backup-growth.test.ts
- test/backup-lanes.test.ts
- test/backup-probe.test.ts
- test/backup-retry.test.ts
- test/backup-truth.test.ts
- test/backups-drill-cost.test.ts
- test/backups-drill-words.test.ts
- test/backups-line.test.ts
- test/backups-live.test.ts
- test/backups-parts.test.ts
- test/backups-timing.test.ts
- test/blob-store-s3.test.ts
- test/blob-store.test.ts
- test/bundle-uri-wired.test.ts
- test/bundle-uri.test.ts
- test/cost-ledger-snapshot.test.ts
- test/drill-budget-size.test.ts
- test/drill-cost-setting.test.ts
- test/drill-hosted-card.test.ts
- test/drill-hosted-proof.test.ts
- test/drill-hosted-red.test.ts
- test/drill-job.test.ts
- test/drill-parts.test.ts
- test/drill-verdict.test.ts
- test/drill-weekly.test.ts
- test/drop-backup.test.ts
- test/forge-archive.test.ts
- test/forge-needs-defaults.test.ts
- test/format-duration.test.ts
- test/helpers/archive-child.ts
- test/helpers/s3-wire.ts
- test/helpers/snapshot-fixtures.ts
- test/helpers/snapshot-seed.ts
- test/helpers/throttled-drill.ts
- test/hosted-surfaces.test.ts
- test/keys-backups.test.ts
- test/maintenance.test.ts
- test/mcp-backups.test.ts
- test/mcp-mirror-now.test.ts
- test/mcp-mirror-set.test.ts
- test/mcp-ops-tool-cards.test.ts
- test/mcp-restore-drill.test.ts
- test/mcp-snapshot-now.test.ts
- test/mirror-worker.test.ts
- test/offsite-lane.test.ts
- test/one-core-hold.test.ts
- test/outbound-sweep.test.ts
- test/recovery-doc.test.ts
- test/recovery-kit.test.ts
- test/resilience.test.ts
- test/restore-card.test.ts
- test/restore-drill-script.test.ts
- test/snapshot-destination.test.ts
- test/snapshot-drill-counts.test.ts
- test/snapshot-drill-page.test.ts
- test/snapshot-drill-phases.test.ts
- test/snapshot-drill.test.ts
- test/snapshot-hosted-chunks.test.ts
- test/snapshot-hosted-history.test.ts
- test/snapshot-hosted-inside.test.ts
- test/snapshot-hosted.test.ts
- test/snapshot-incremental.test.ts
- test/snapshot-mirror-page.test.ts
- test/snapshot-mirror.test.ts
- test/snapshot-off-box.test.ts
- test/snapshot-one-core.test.ts
- test/snapshot-outcome.test.ts
- test/snapshot-put-abort.test.ts
CLAUDE.md +3
| @@ -237,6 +237,9 @@ src/ | ||
| 237 | 237 | actions/); actions/fleet.ts plans, applies, keeps the receipt |
| 238 | 238 | (core/fleet_ops.ts) and undoes |
| 239 | 239 | 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) | |
| 240 | 243 | crew/ agents as child processes: brief (the system + task prompts: |
| 241 | 244 | the golden path, written down), claude (the headless adapter: |
| 242 | 245 | 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 | ||
| 523 | 523 | - [](web.md) — the rules for assets and HTML: what is cached where, how a page streams, and the byte budgets a test enforces. |
| 524 | 524 | - [](PRINCIPLES.md) — what the forge holds to, each with what enforces it; capped, and read by the crew and the in-forge conversation. |
| 525 | 525 | - [](AI_AGNOSTIC.md) — every place the forge still names or assumes one AI vendor, and the issue that removes each. |
| 526 | - [](BLOBS.md) — the one store for big, immutable bytes: its two shapes and who uses them. | |
| 526 | 527 | This page is the front door. Everything else is a file of its own under |
| 527 | 528 | `docs/`, each about one thing: |
| 528 | 529 |
scripts/backup-probe.ts +1 −1
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | 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"; | |
| 11 | 11 | |
| 12 | 12 | const parsed = parseProbeArgs(process.argv.slice(2), process.env); |
| 13 | 13 | if ("error" in parsed) { |
src/actions/destination.ts +1 −1
| @@ -17,7 +17,7 @@ import { | ||
| 17 | 17 | SEALED_READ, |
| 18 | 18 | } from "../snapshot/destination.ts"; |
| 19 | 19 | 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"; | |
| 21 | 21 | import { snapshotsOf } from "../snapshot/service.ts"; |
| 22 | 22 | import type { User } from "../core/users.ts"; |
| 23 | 23 | import { err, ok, type Result } from "../kernel/result.ts"; |
src/snapshot/store.ts → src/blob/store.ts renamed +319 −39
| @@ -1,15 +1,51 @@ | ||
| 1 | 1 | /** |
| 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 | |
| 5 | 6 | * store keeps no other idea of structure, so a snapshot is exactly the |
| 6 | 7 | * 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. | |
| 7 | 13 | */ |
| 8 | 14 | |
| 9 | import { mkdirSync, readdirSync, rmSync, statSync } from "node:fs"; | |
| 15 | import { mkdirSync, readdirSync, renameSync, rmSync, statSync } from "node:fs"; | |
| 10 | 16 | import { dirname, join, relative } from "node:path"; |
| 11 | 17 | 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 | } | |
| 13 | 49 | |
| 14 | 50 | export interface Store { |
| 15 | 51 | /** What this store is, for a page and a log; never a secret. */ |
| @@ -21,7 +57,12 @@ export interface Store { | ||
| 21 | 57 | * keep the line busy under the attempt that replaces it (#13733). A store that cannot abort |
| 22 | 58 | * ignores it. |
| 23 | 59 | */ |
| 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>; | |
| 25 | 66 | get(key: string): Promise<Uint8Array | undefined>; |
| 26 | 67 | /** Every key under `prefix`, in no particular order. */ |
| 27 | 68 | list(prefix: string): Promise<string[]>; |
| @@ -80,6 +121,95 @@ export function remakes<S extends Store>(store: S, spec: StoreSpec): S { | ||
| 80 | 121 | return store; |
| 81 | 122 | } |
| 82 | 123 | |
| 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 | ||
| 83 | 213 | /** The S3 credentials as the platform hands them to an app. */ |
| 84 | 214 | export interface S3Target { |
| 85 | 215 | readonly endpoint: string; |
| @@ -128,8 +258,12 @@ export const deadlineFor = ( | ||
| 128 | 258 | slackMs = SLACK_MS, |
| 129 | 259 | ): number => slackMs + Math.ceil((bytes / floorBytesPerS) * 1000); |
| 130 | 260 | |
| 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; | |
| 133 | 267 | |
| 134 | 268 | /** |
| 135 | 269 | * A store that tries again. Object stores answer a burst, a flake or a |
| @@ -159,19 +293,24 @@ const sizeOf = (body: Uint8Array | string): number => | ||
| 159 | 293 | * what is left after the waits still to come, and none starts once |
| 160 | 294 | * nothing is, so a stalled store fails within the budget instead of |
| 161 | 295 | * 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. | |
| 162 | 301 | */ |
| 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 { | |
| 175 | 314 | const attempts = Math.max(1, options.attempts ?? 5); |
| 176 | 315 | const baseMs = options.baseMs ?? 500; |
| 177 | 316 | const fixed = options.deadlineMs; |
| @@ -179,7 +318,7 @@ export function withRetries( | ||
| 179 | 318 | const line = options.line ?? lineMeter(); |
| 180 | 319 | const slackMs = options.slackMs ?? SLACK_MS; |
| 181 | 320 | // 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 => { | |
| 183 | 322 | if (fixed !== undefined) return fixed; |
| 184 | 323 | const bytes = sizeOf(body); |
| 185 | 324 | const floor = deadlineFor(bytes, options.floorBytesPerS, slackMs); |
| @@ -225,7 +364,7 @@ export function withRetries( | ||
| 225 | 364 | const view = (leftMs?: () => number): Store => ({ |
| 226 | 365 | where: inner.where, |
| 227 | 366 | ...(inner.dir === undefined ? {} : { dir: inner.dir }), |
| 228 | put: (key, body) => | |
| 367 | put: (key, body, _signal, how) => | |
| 229 | 368 | tried( |
| 230 | 369 | `put ${key}`, |
| 231 | 370 | () => putMs(body), |
| @@ -233,7 +372,7 @@ export function withRetries( | ||
| 233 | 372 | const end = line.begin(); |
| 234 | 373 | let landed = 0; |
| 235 | 374 | try { |
| 236 | await inner.put(key, body, signal); | |
| 375 | await inner.put(key, body, signal, how); | |
| 237 | 376 | landed = sizeOf(body); |
| 238 | 377 | } finally { |
| 239 | 378 | end(landed); |
| @@ -249,7 +388,27 @@ export function withRetries( | ||
| 249 | 388 | bounded: (left) => view(left), |
| 250 | 389 | line, |
| 251 | 390 | }); |
| 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(); | |
| 253 | 412 | } |
| 254 | 413 | |
| 255 | 414 | /** |
| @@ -275,7 +434,7 @@ function answered<T>(start: (signal: AbortSignal) => Promise<T>, ms: number): Pr | ||
| 275 | 434 | return Promise.race([attempt, deadline]).finally(() => clearTimeout(timer)); |
| 276 | 435 | } |
| 277 | 436 | |
| 278 | export function s3Store(target: S3Target, attempts?: number): Store { | |
| 437 | export function s3Store(target: S3Target, attempts?: number): BlobStore { | |
| 279 | 438 | const spec: StoreSpec = attempts === undefined ? { kind: "s3", target } : { kind: "s3", target, attempts }; |
| 280 | 439 | return remakes(withRetries(rawS3Store(target), attempts === undefined ? {} : { attempts }), spec); |
| 281 | 440 | } |
| @@ -287,8 +446,17 @@ export const s3Where = (target: Pick<S3Target, "endpoint" | "bucket">): string = | ||
| 287 | 446 | /** How long a put's signed URL is good for: longer than any put's deadline. */ |
| 288 | 447 | const PUT_URL_SECONDS = 6 * 3600; |
| 289 | 448 | |
| 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 | ||
| 290 | 458 | /** 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 { | |
| 292 | 460 | const client = new Bun.S3Client({ |
| 293 | 461 | endpoint: target.endpoint, |
| 294 | 462 | bucket: target.bucket, |
| @@ -296,24 +464,93 @@ export function rawS3Store(target: S3Target): Store { | ||
| 296 | 464 | secretAccessKey: target.secretAccessKey, |
| 297 | 465 | ...(target.region === undefined ? {} : { region: target.region }), |
| 298 | 466 | }); |
| 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 | }; | |
| 299 | 515 | return { |
| 300 | 516 | 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)); | |
| 311 | 523 | }, |
| 312 | 524 | async get(key) { |
| 313 | 525 | const file = client.file(key); |
| 314 | 526 | if (!(await file.exists())) return undefined; |
| 315 | 527 | return new Uint8Array(await file.arrayBuffer()); |
| 316 | 528 | }, |
| 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 | }, | |
| 317 | 554 | async list(prefix) { |
| 318 | 555 | const keys: string[] = []; |
| 319 | 556 | let token: string | undefined; |
| @@ -350,8 +587,12 @@ export function rawS3Store(target: S3Target): Store { | ||
| 350 | 587 | }; |
| 351 | 588 | } |
| 352 | 589 | |
| 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 { | |
| 355 | 596 | const at = (key: string): string => { |
| 356 | 597 | if (key.startsWith("/") || key.split("/").includes("..")) |
| 357 | 598 | throw new Error(`refusing key ${key}`); |
| @@ -370,7 +611,12 @@ export function dirStore(root: string): Store { | ||
| 370 | 611 | else out.push(relative(root, path)); |
| 371 | 612 | } |
| 372 | 613 | }; |
| 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>({ | |
| 374 | 620 | where: root, |
| 375 | 621 | dir: root, |
| 376 | 622 | async put(key, body) { |
| @@ -378,11 +624,45 @@ export function dirStore(root: string): Store { | ||
| 378 | 624 | mkdirSync(dirname(path), { recursive: true }); |
| 379 | 625 | await Bun.write(path, body); |
| 380 | 626 | }, |
| 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 | }, | |
| 381 | 647 | async get(key) { |
| 382 | 648 | const file = Bun.file(at(key)); |
| 383 | 649 | if (!(await file.exists())) return undefined; |
| 384 | 650 | return new Uint8Array(await file.arrayBuffer()); |
| 385 | 651 | }, |
| 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 | }, | |
| 386 | 666 | async list(prefix) { |
| 387 | 667 | const all: string[] = []; |
| 388 | 668 | walk(root, all); |
src/chaos/faults.ts +1 −1
| @@ -10,7 +10,7 @@ import { tmpdir } from "node:os"; | ||
| 10 | 10 | import { sweepAbandonedChecks, failAbandonedRuns } from "../core/runs.ts"; |
| 11 | 11 | import { serve } from "../http/server.ts"; |
| 12 | 12 | import { takeSnapshot } from "../snapshot/snapshot.ts"; |
| 13 | import { dirStore } from "../snapshot/store.ts"; | |
| 13 | import { dirStore } from "../blob/store.ts"; | |
| 14 | 14 | import { dbFile, reopen, type World } from "./world.ts"; |
| 15 | 15 | |
| 16 | 16 | export interface Fault { |
src/chaos/invariants.ts +1 −1
| @@ -10,7 +10,7 @@ import { Database } from "bun:sqlite"; | ||
| 10 | 10 | import { repoDir } from "../git/repos.ts"; |
| 11 | 11 | import { restoreSnapshot } from "../snapshot/restore.ts"; |
| 12 | 12 | import { takeSnapshot } from "../snapshot/snapshot.ts"; |
| 13 | import { dirStore } from "../snapshot/store.ts"; | |
| 13 | import { dirStore } from "../blob/store.ts"; | |
| 14 | 14 | import { SEALED_VALUE, type World } from "./world.ts"; |
| 15 | 15 | |
| 16 | 16 | export interface Invariant { |
src/git/bundle_uri.ts +1 −1
| @@ -29,7 +29,7 @@ import type { ForgeEvent } from "../core/events.ts"; | ||
| 29 | 29 | import { getRepoById, type Repo } from "../core/repos.ts"; |
| 30 | 30 | import { createLog } from "../kernel/log.ts"; |
| 31 | 31 | 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"; | |
| 33 | 33 | |
| 34 | 34 | export interface Published { |
| 35 | 35 | readonly oid: string; |
src/http/mcp/tools/backups.ts +2 −2
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | import { snapshotsOf } from "../../../snapshot/service.ts"; |
| 2 | 2 | import { resolveSnapshots, scrubReason, sealedTarget } from "../../../snapshot/destination.ts"; |
| 3 | import { bodiesOf } from "../../../snapshot/store.ts"; | |
| 3 | import { bodiesOf } from "../../../blob/store.ts"; | |
| 4 | 4 | import { mirrorNeed } from "../../../snapshot/mirror.ts"; |
| 5 | import { s3FromEnv } from "../../../snapshot/store.ts"; | |
| 5 | import { s3FromEnv } from "../../../blob/store.ts"; | |
| 6 | 6 | import { listSnapshots } from "../../../snapshot/snapshot.ts"; |
| 7 | 7 | import { hostedWords, keptWords } from "../../../snapshot/hosted.ts"; |
| 8 | 8 | import { backupVerdict } from "../../../snapshot/bucket.ts"; |
src/http/mcp/tools/backups_destination.ts +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import { forgetDestination, invalidField, saveDestination, type DestinationInput } from "../../../actions/destination.ts"; |
| 2 | 2 | import { resolveSnapshots } from "../../../snapshot/destination.ts"; |
| 3 | import { bodiesOf } from "../../../snapshot/store.ts"; | |
| 3 | import { bodiesOf } from "../../../blob/store.ts"; | |
| 4 | 4 | import { good, bad, type Tool } from "../shared.ts"; |
| 5 | 5 | |
| 6 | 6 | export const tool: Tool = { |
src/snapshot/bucket.ts +1 −1
| @@ -22,7 +22,7 @@ import { listSnapshots, notInSnapshot } from "./snapshot.ts"; | ||
| 22 | 22 | import type { HostedEntry } from "./hosted.ts"; |
| 23 | 23 | import { scrubReason } from "./destination.ts"; |
| 24 | 24 | 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"; | |
| 26 | 26 | |
| 27 | 27 | /** A newest snapshot older than this is red: the nightly is 24 h apart, plus a slow one's slack. */ |
| 28 | 28 | export const LATE_MS = 26 * 3_600_000; |
src/snapshot/destination.ts +1 −1
src/snapshot/drill.ts +1 −1
| @@ -22,7 +22,7 @@ import { restoreSnapshot, type Progress } from "./restore.ts"; | ||
| 22 | 22 | import { drillPick, proveHosted, type HostedProof } from "./drill_hosted.ts"; |
| 23 | 23 | import { isOffBox } from "./off_box.ts"; |
| 24 | 24 | import { listSnapshots } from "./snapshot.ts"; |
| 25 | import type { Store } from "./store.ts"; | |
| 25 | import type { Store } from "../blob/store.ts"; | |
| 26 | 26 | |
| 27 | 27 | /** The floor of every drill's budget, and the whole budget for finding the newest snapshot. */ |
| 28 | 28 | export const DRILL_TIMEOUT_MS = 10 * 60_000; |
src/snapshot/drill_child.ts +1 −1
| @@ -15,7 +15,7 @@ | ||
| 15 | 15 | import { runDrill, type DrillResult } from "./drill.ts"; |
| 16 | 16 | import { storeFrom } from "./remake.ts"; |
| 17 | 17 | import type { Progress } from "./restore.ts"; |
| 18 | import type { StoreSpec } from "./store.ts"; | |
| 18 | import type { StoreSpec } from "../blob/store.ts"; | |
| 19 | 19 | |
| 20 | 20 | export interface DrillJob { |
| 21 | 21 | readonly dataDir: string; |
src/snapshot/drill_hosted.ts +1 −1
| @@ -18,7 +18,7 @@ import { join } from "node:path"; | ||
| 18 | 18 | import { runGit } from "../git/env.ts"; |
| 19 | 19 | import type { HostedEntry } from "./hosted.ts"; |
| 20 | 20 | import { restoreHosted } from "./restore.ts"; |
| 21 | import type { Store } from "./store.ts"; | |
| 21 | import type { Store } from "../blob/store.ts"; | |
| 22 | 22 | |
| 23 | 23 | /** What a drill says of the hosted forge it restored. */ |
| 24 | 24 | export interface HostedProof { |
src/snapshot/kit.ts +1 −1
| @@ -20,7 +20,7 @@ import { answersRoot, DRILL_TIMEOUT_MS } from "./drill.ts"; | ||
| 20 | 20 | import { OUTSIDE_SCRATCH } from "./drill_job.ts"; |
| 21 | 21 | import { readOnlyTarget, sealsSnapshots, type Sources } from "./destination.ts"; |
| 22 | 22 | 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"; | |
| 24 | 24 | |
| 25 | 25 | export interface Kit { |
| 26 | 26 | readonly v: 1; |
src/snapshot/lanes.ts +1 −1
| @@ -26,7 +26,7 @@ | ||
| 26 | 26 | |
| 27 | 27 | import { LATE_MS, isRetired, printable, scrubError, type LaneRead } from "./bucket.ts"; |
| 28 | 28 | import { isOffBox } from "./off_box.ts"; |
| 29 | import { s3Where, type S3Target } from "./store.ts"; | |
| 29 | import { s3Where, type S3Target } from "../blob/store.ts"; | |
| 30 | 30 | |
| 31 | 31 | /** Pages read at one folder level before the read counts as bounded. */ |
| 32 | 32 | export const PAGES = 3; |
src/snapshot/mirror.ts +1 −1
| @@ -26,7 +26,7 @@ import { deleteSecret, resolveSecrets } from "../core/secret_store.ts"; | ||
| 26 | 26 | import { chunkKey, CHUNK_PREFIX } from "./chunks.ts"; |
| 27 | 27 | import { chunksNamed, KEEP, listSnapshots, missingChunks, pruneSnapshots, SNAPSHOT_PREFIX, storedChunk, type Manifest } from "./snapshot.ts"; |
| 28 | 28 | 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"; | |
| 30 | 30 | import type { MirrorAnswer, MirrorJob } from "./mirror_worker.ts"; |
| 31 | 31 | import { verifySnapshot } from "./verify.ts"; |
| 32 | 32 |
src/snapshot/mirror_worker.ts +1 −1
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | |
| 14 | 14 | import { mirrorPass, type MirrorState } from "./mirror.ts"; |
| 15 | 15 | import { storeFrom } from "./remake.ts"; |
| 16 | import type { StoreSpec } from "./store.ts"; | |
| 16 | import type { StoreSpec } from "../blob/store.ts"; | |
| 17 | 17 | import { workerMemory } from "../perf/memory_watch.ts"; |
| 18 | 18 | |
| 19 | 19 | export interface MirrorJob { |
src/snapshot/off_box.ts +1 −1
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | |
| 13 | 13 | import { lastMirror } from "./mirror.ts"; |
| 14 | 14 | import { lastSnapshotOutcome, offBoxAtOf } from "./outcome.ts"; |
| 15 | import type { Store } from "./store.ts"; | |
| 15 | import type { Store } from "../blob/store.ts"; | |
| 16 | 16 | |
| 17 | 17 | /** The host of a bucket's `where` (`host[:port]/bucket`), lower-cased, without its port or brackets. */ |
| 18 | 18 | function hostOf(where: string): string { |
src/snapshot/probe.ts +1 −1
| @@ -9,7 +9,7 @@ | ||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | import { listSnapshots } from "./snapshot.ts"; |
| 12 | import type { Store } from "./store.ts"; | |
| 12 | import type { Store } from "../blob/store.ts"; | |
| 13 | 13 | import { boundedSignal } from "../kernel/fetch_timeout.ts"; |
| 14 | 14 | |
| 15 | 15 | /** 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 @@ | ||
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | 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"; | |
| 10 | 10 | |
| 11 | 11 | export function storeFrom(spec: StoreSpec): Store { |
| 12 | 12 | 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 | ||
| 65 | 65 | import { resolveSnapshots } from "./destination.ts"; |
| 66 | 66 | import { offsiteFromEnv } from "./mirror.ts"; |
| 67 | 67 | import { kitStore, parseKit } from "./kit.ts"; |
| 68 | import type { Store } from "./store.ts"; | |
| 68 | import type { Store } from "../blob/store.ts"; | |
| 69 | 69 | |
| 70 | 70 | export interface Restored { |
| 71 | 71 | readonly manifest: Manifest; |
src/snapshot/sealed_store.ts +1 −1
| @@ -28,7 +28,7 @@ | ||
| 28 | 28 | */ |
| 29 | 29 | |
| 30 | 30 | 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"; | |
| 32 | 32 | |
| 33 | 33 | export const SEALED_PREFIX = "sealed/"; |
| 34 | 34 | const MAGIC = Buffer.from("FSO1"); |
src/snapshot/service.ts +1 −1
| @@ -37,7 +37,7 @@ import { lastMirror, mirrorOffThread, mirrorTarget, MIRROR_EVERY_MS, recordMirro | ||
| 37 | 37 | import { isOffBox } from "./off_box.ts"; |
| 38 | 38 | import { failureCause } from "./cause.ts"; |
| 39 | 39 | 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"; | |
| 41 | 41 | import { verifySnapshot } from "./verify.ts"; |
| 42 | 42 | import { during } from "../perf/jobs.ts"; |
| 43 | 43 | import { limitValue } from "../settings/limits.ts"; |
src/snapshot/snapshot.ts +1 −1
| @@ -50,7 +50,7 @@ import { copyHosted, unchanged, HostedRefusal, hostedSources, HOSTED_PREFIX, ope | ||
| 50 | 50 | import { countRows, type DrillCounts } from "./counts.ts"; |
| 51 | 51 | import { CHUNK_PREFIX, chunkId, chunkKey, chunkSeed, contentChunker, fixedChunker, isChunkId, packChunk, type Chunker } from "./chunks.ts"; |
| 52 | 52 | import type { PackedFile } from "./parts.ts"; |
| 53 | import { bodiesOf, type Store } from "./store.ts"; | |
| 53 | import { bodiesOf, type Store } from "../blob/store.ts"; | |
| 54 | 54 | import { putsAtOnce } from "./line.ts"; |
| 55 | 55 | import { unwrapKey, wrapKey, WRAPPED_KEY } from "./wrap.ts"; |
| 56 | 56 | import { during } from "../perf/jobs.ts"; |
src/snapshot/standby.ts +1 −1
| @@ -10,7 +10,7 @@ import { join } from "node:path"; | ||
| 10 | 10 | import { repoDir } from "../git/repos.ts"; |
| 11 | 11 | import { restoreSnapshot, type Restored } from "./restore.ts"; |
| 12 | 12 | import { listSnapshots } from "./snapshot.ts"; |
| 13 | import type { Store } from "./store.ts"; | |
| 13 | import type { Store } from "../blob/store.ts"; | |
| 14 | 14 | |
| 15 | 15 | export interface Standby { |
| 16 | 16 | readonly name: string; |
src/snapshot/verify.ts +1 −1
src/tui/screens/resilience.ts +1 −1
| @@ -45,7 +45,7 @@ import { backupVerdict } from "../../snapshot/bucket.ts"; | ||
| 45 | 45 | import { lastDrill } from "../../snapshot/drills.ts"; |
| 46 | 46 | import { hostedDrillWords } from "../../snapshot/drill_hosted_words.ts"; |
| 47 | 47 | import { resolveSnapshots } from "../../snapshot/destination.ts"; |
| 48 | import { bodiesOf } from "../../snapshot/store.ts"; | |
| 48 | import { bodiesOf } from "../../blob/store.ts"; | |
| 49 | 49 | import { snapshotsOf } from "../../snapshot/service.ts"; |
| 50 | 50 | import type { Ctx, Screen } from "../app/app.ts"; |
| 51 | 51 | import { binding } from "../app/keys.ts"; |
src/view/doc_sections.ts +1
| @@ -68,6 +68,7 @@ export const DOC_LINES: Record<string, Line> = { | ||
| 68 | 68 | "ADAPTERS.md": ["reference", "Apps that import from other systems."], |
| 69 | 69 | "THREATS.md": ["reference", "Who might attack, and what stops them."], |
| 70 | 70 | |
| 71 | "BLOBS.md": ["internals", "The one store for big, immutable bytes."], | |
| 71 | 72 | "ARCHITECTURE.md": ["internals", "How the parts fit together."], |
| 72 | 73 | "DEVELOP.md": ["internals", "Tests, type check and the push gate."], |
| 73 | 74 | "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 | ||
| 33 | 33 | import { costFacts } from "../../snapshot/drill_cost.ts"; |
| 34 | 34 | import { lastDrill } from "../../snapshot/drills.ts"; |
| 35 | 35 | import { backupVerdict } from "../../snapshot/bucket.ts"; |
| 36 | import { bodiesOf, type Store } from "../../snapshot/store.ts"; | |
| 36 | import { bodiesOf, type Store } from "../../blob/store.ts"; | |
| 37 | 37 | import { hostedWords } from "../../snapshot/hosted.ts"; |
| 38 | 38 | import { hostedDrillWords } from "../../snapshot/drill_hosted_words.ts"; |
| 39 | 39 | import { snapshotsOf, type SnapshotsHandle } from "../../snapshot/service.ts"; |
test/backup-growth.test.ts +1 −1
| @@ -7,7 +7,7 @@ import { tmpdir } from "node:os"; | ||
| 7 | 7 | import { join } from "node:path"; |
| 8 | 8 | import { createApp } from "../src/app.ts"; |
| 9 | 9 | 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"; | |
| 11 | 11 | import { rulesWorld } from "./helpers/rules-app.ts"; |
| 12 | 12 | import { duty, TITLE } from "../src/maintain/duties/backup_growth.ts"; |
| 13 | 13 | import { growthOf } from "../src/snapshot/growth.ts"; |
test/backup-lanes.test.ts +1 −1
| @@ -26,7 +26,7 @@ import { | ||
| 26 | 26 | type Lister, |
| 27 | 27 | } from "../src/snapshot/lanes.ts"; |
| 28 | 28 | 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"; | |
| 30 | 30 | import { verdictLines } from "../src/tui/screens/resilience.ts"; |
| 31 | 31 | |
| 32 | 32 | 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"; | ||
| 5 | 5 | import { tmpdir } from "node:os"; |
| 6 | 6 | import { join } from "node:path"; |
| 7 | 7 | import { parseProbeArgs, probe } from "../src/snapshot/probe.ts"; |
| 8 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 8 | import { dirStore } from "../src/blob/store.ts"; | |
| 9 | 9 | |
| 10 | 10 | const root = mkdtempSync(join(tmpdir(), "probe-")); |
| 11 | 11 | 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"; | ||
| 9 | 9 | import { alarmBackup } from "../src/flow/alarm_backup.ts"; |
| 10 | 10 | import { recordSnapshotOutcome } from "../src/snapshot/outcome.ts"; |
| 11 | 11 | 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"; | |
| 13 | 13 | import { cachedAlarms } from "../src/web/studio/alarm_lines.ts"; |
| 14 | 14 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 15 | 15 | 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"; | ||
| 18 | 18 | import { lastNightly, snapshotDue } from "../src/snapshot/due.ts"; |
| 19 | 19 | import { snapshotsOf, startSnapshots } from "../src/snapshot/service.ts"; |
| 20 | 20 | import { listSnapshots } from "../src/snapshot/snapshot.ts"; |
| 21 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 21 | import { dirStore } from "../src/blob/store.ts"; | |
| 22 | 22 | import { verdictLines } from "../src/tui/screens/resilience.ts"; |
| 23 | 23 | import { readHealth } from "../src/actions/health.ts"; |
| 24 | 24 | 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"; | ||
| 12 | 12 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 13 | 13 | import { recordDrill } from "../src/snapshot/drills.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 17 | |
| 18 | 18 | quietLogs(); |
test/backups-drill-words.test.ts +1 −1
| @@ -15,7 +15,7 @@ import { costFacts, costLine } from "../src/snapshot/drill_cost.ts"; | ||
| 15 | 15 | import { drillFailure, spokenSpan, stepDoing } from "../src/snapshot/drill_card_words.ts"; |
| 16 | 16 | import { recordDrill } from "../src/snapshot/drills.ts"; |
| 17 | 17 | 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"; | |
| 19 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
| 20 | 20 | |
| 21 | 21 | quietLogs(); |
test/backups-line.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { createUser, getUserByName } from "../src/core/users.ts"; | ||
| 12 | 12 | import { serve, type Servers } from "../src/http/server.ts"; |
| 13 | 13 | import { BACKUPS_OFF, backupsLineOf } from "../src/snapshot/backups_line.ts"; |
| 14 | 14 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 15 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 15 | import { dirStore } from "../src/blob/store.ts"; | |
| 16 | 16 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 17 | 17 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 18 | 18 | import { quietLogs } from "./helpers/globals.ts"; |
test/backups-live.test.ts +1 −1
| @@ -13,7 +13,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 13 | 13 | import { listEvents } from "../src/core/events.ts"; |
| 14 | 14 | import { serve, type Servers } from "../src/http/server.ts"; |
| 15 | 15 | 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"; | |
| 17 | 17 | import { quietLogs } from "./helpers/globals.ts"; |
| 18 | 18 | |
| 19 | 19 | quietLogs(); |
test/backups-parts.test.ts +1 −1
| @@ -14,7 +14,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 14 | 14 | import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts"; |
| 15 | 15 | import { recordDrill } from "../src/snapshot/drills.ts"; |
| 16 | 16 | import { forgetReads, keepReads } from "../src/snapshot/bucket.ts"; |
| 17 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 17 | import { dirStore } from "../src/blob/store.ts"; | |
| 18 | 18 | import { quietLogs } from "./helpers/globals.ts"; |
| 19 | 19 | |
| 20 | 20 | quietLogs(); |
test/backups-timing.test.ts +1 −1
| @@ -7,7 +7,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 7 | 7 | import { createUser } from "../src/core/users.ts"; |
| 8 | 8 | import { serve, type Servers } from "../src/http/server.ts"; |
| 9 | 9 | 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"; | |
| 11 | 11 | import { quietLogs } from "./helpers/globals.ts"; |
| 12 | 12 | |
| 13 | 13 | 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"; | ||
| 17 | 17 | import { onPushEvent, pointerOf, settledOf } from "../src/git/bundle_uri.ts"; |
| 18 | 18 | import { repoDir } from "../src/git/repos.ts"; |
| 19 | 19 | 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"; | |
| 21 | 21 | import { seedAdmin } from "./helpers/admin.ts"; |
| 22 | 22 | import { quietLogs } from "./helpers/globals.ts"; |
| 23 | 23 |
test/bundle-uri.test.ts +1 −1
| @@ -13,7 +13,7 @@ import { MAX_BUILDS, noteBundle, retractBundles, settledOf } from "../src/git/bu | ||
| 13 | 13 | import { bundleBase, bundleConfig, bundleKey, bundleUriFor, pointerOf, publishBundle } from "../src/git/bundle_uri.ts"; |
| 14 | 14 | import { initBareRepo, repoDir } from "../src/git/repos.ts"; |
| 15 | 15 | 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"; | |
| 17 | 17 | import { unwrap } from "../src/kernel/result.ts"; |
| 18 | 18 | import { gitClientEnv } from "./helpers/git-client.ts"; |
| 19 | 19 |
test/cost-ledger-snapshot.test.ts +1 −1
| @@ -5,7 +5,7 @@ import { join } from "node:path"; | ||
| 5 | 5 | import { createApp } from "../src/app.ts"; |
| 6 | 6 | import { setLedgerDir, verifyDir } from "../src/core/ledger.ts"; |
| 7 | 7 | 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"; | |
| 9 | 9 | import { quietLogs } from "./helpers/globals.ts"; |
| 10 | 10 | |
| 11 | 11 | quietLogs(); |
test/drill-budget-size.test.ts +1 −1
| @@ -18,7 +18,7 @@ import { DRILL_MS_PER_MB, drillBudgetMs, runDrill } from "../src/snapshot/drill. | ||
| 18 | 18 | import { failedSentence } from "../src/snapshot/verdict.ts"; |
| 19 | 19 | import { restoreSnapshot } from "../src/snapshot/restore.ts"; |
| 20 | 20 | 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"; | |
| 22 | 22 | import { quietLogs } from "./helpers/globals.ts"; |
| 23 | 23 | import { waitFor } from "./helpers/poll.ts"; |
| 24 | 24 |
test/drill-cost-setting.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { LIMIT_RULE } from "../src/snapshot/drill_cost.ts"; | ||
| 12 | 12 | import { drillMemoryLimit } from "../src/snapshot/drill_job.ts"; |
| 13 | 13 | import { lastDrill } from "../src/snapshot/drills.ts"; |
| 14 | 14 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 15 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 15 | import { dirStore } from "../src/blob/store.ts"; | |
| 16 | 16 | import { drillMemoryDefaultMiB, LIMITS, limitValue, setLimit } from "../src/settings/limits.ts"; |
| 17 | 17 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 18 | 18 |
test/drill-hosted-card.test.ts +1 −1
| @@ -15,7 +15,7 @@ import type { DrillResult } from "../src/snapshot/drill.ts"; | ||
| 15 | 15 | import { hostedDrillWords, seconds } from "../src/snapshot/drill_hosted_words.ts"; |
| 16 | 16 | import { lastDrill, recordDrill } from "../src/snapshot/drills.ts"; |
| 17 | 17 | 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"; | |
| 19 | 19 | import { drillNeed, lastVerdict, recordVerdict, verdictComment } from "../src/snapshot/verdict.ts"; |
| 20 | 20 | import { hostedDrillLines } from "../src/tui/screens/resilience.ts"; |
| 21 | 21 | 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"; | ||
| 15 | 15 | import { proveHosted } from "../src/snapshot/drill_hosted.ts"; |
| 16 | 16 | import type { HostedEntry } from "../src/snapshot/hosted.ts"; |
| 17 | 17 | 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"; | |
| 19 | 19 | |
| 20 | 20 | const SNAP = "2026-11-16T08-00-00Z"; |
| 21 | 21 |
test/drill-hosted-red.test.ts +1 −1
| @@ -16,7 +16,7 @@ import { setNotifyUrl, startNotifier } from "../src/crew/notify.ts"; | ||
| 16 | 16 | import { namedForge, runDrill, type DrillDeps } from "../src/snapshot/drill.ts"; |
| 17 | 17 | import type { HostedEntry } from "../src/snapshot/hosted.ts"; |
| 18 | 18 | 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"; | |
| 20 | 20 | import { recordVerdict, seedFirstSeen } from "../src/snapshot/verdict.ts"; |
| 21 | 21 | |
| 22 | 22 | const SNAP = "2026-11-16T08-00-00Z"; |
test/drill-job.test.ts +1 −1
| @@ -11,7 +11,7 @@ import { cutDrill, drillMemoryLimit, markerLeft, residentBytes, runDrillInChild, | ||
| 11 | 11 | import { costFacts, costLine, LIMIT_RULE } from "../src/snapshot/drill_cost.ts"; |
| 12 | 12 | import { lastDrill, parseCost, recordDrill } from "../src/snapshot/drills.ts"; |
| 13 | 13 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 14 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 14 | import { dirStore } from "../src/blob/store.ts"; | |
| 15 | 15 | |
| 16 | 16 | let root = ""; |
| 17 | 17 | beforeEach(() => { |
test/drill-parts.test.ts +1 −1
| @@ -10,7 +10,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 10 | 10 | import { createUser } from "../src/core/users.ts"; |
| 11 | 11 | import { describeTimes, runDrill, timeByPart } from "../src/snapshot/drill.ts"; |
| 12 | 12 | 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"; | |
| 14 | 14 | import { failedSentence, slowSentence } from "../src/snapshot/verdict.ts"; |
| 15 | 15 | import { quietLogs } from "./helpers/globals.ts"; |
| 16 | 16 |
test/drill-verdict.test.ts +1 −1
| @@ -15,7 +15,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 15 | 15 | import { vitals } from "../src/kernel/vitals.ts"; |
| 16 | 16 | import { bootRestored } from "../src/snapshot/boot.ts"; |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 18 | import { dirStore } from "../src/blob/store.ts"; | |
| 19 | 19 | import { runDrill } from "../src/snapshot/drill.ts"; |
| 20 | 20 | import { untilDrill } from "../src/snapshot/service.ts"; |
| 21 | 21 | 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 | ||
| 16 | 16 | import { lastDrill, recordDrill } from "../src/snapshot/drills.ts"; |
| 17 | 17 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 18 | 18 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 19 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 19 | import { dirStore } from "../src/blob/store.ts"; | |
| 20 | 20 | import { recordVerdict } from "../src/snapshot/verdict.ts"; |
| 21 | 21 | |
| 22 | 22 | 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"; | ||
| 15 | 15 | import { dropDir } from "../src/drop/store.ts"; |
| 16 | 16 | import { restoreSnapshot } from "../src/snapshot/restore.ts"; |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 18 | import { dirStore } from "../src/blob/store.ts"; | |
| 19 | 19 | |
| 20 | 20 | let root: string; |
| 21 | 21 | let app: App; |
test/forge-archive.test.ts +1 −1
| @@ -22,7 +22,7 @@ import { clientRows, servedRows, useChildFetch } from "../src/spawn/clients.ts"; | ||
| 22 | 22 | import { useProbe } from "../src/spawn/door.ts"; |
| 23 | 23 | import { firstBoot } from "../src/spawn/first-boot.ts"; |
| 24 | 24 | import { personReading } from "../src/spawn/person_activity.ts"; |
| 25 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 25 | import { dirStore } from "../src/blob/store.ts"; | |
| 26 | 26 | import { BODY_ID } from "../src/spawn/archive.ts"; |
| 27 | 27 | import { isAwakeBody, resolveHostedChild, sleepChild, wakeGate } from "../src/spawn/host.ts"; |
| 28 | 28 | 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"; | ||
| 22 | 22 | import { recordVerdict } from "../src/snapshot/verdict.ts"; |
| 23 | 23 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 24 | 24 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 25 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 25 | import { dirStore } from "../src/blob/store.ts"; | |
| 26 | 26 | import { needsScreen, whyNot } from "../src/tui/screens/needs.ts"; |
| 27 | 27 | import type { Ctx as TuiCtx } from "../src/tui/app/app.ts"; |
| 28 | 28 | import type { Session } from "../src/tui/session.ts"; |
test/format-duration.test.ts +1 −1
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | import { expect, test } from "bun:test"; |
| 2 | import { noAnswerIn } from "../src/snapshot/store.ts"; | |
| 2 | import { noAnswerIn } from "../src/blob/store.ts"; | |
| 3 | 3 | import { plainDurations } from "../src/snapshot/verdict.ts"; |
| 4 | 4 | import { durationWords, spanWords } from "../src/system/format.ts"; |
| 5 | 5 | 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"; | ||
| 7 | 7 | import { archiveForge } from "../../src/spawn/archive.ts"; |
| 8 | 8 | import { useChildFetch } from "../../src/spawn/clients.ts"; |
| 9 | 9 | import { useProbe } from "../../src/spawn/door.ts"; |
| 10 | import { dirStore } from "../../src/snapshot/store.ts"; | |
| 10 | import { dirStore } from "../../src/blob/store.ts"; | |
| 11 | 11 | |
| 12 | 12 | const app = createApp({ dataDir: process.env["DATA_DIR"]!, url: "https://forge.test", port: 0 }); |
| 13 | 13 | 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 @@ | ||
| 8 | 8 | import { chunkId, chunkKey, fixedChunker, FIXED_BYTES, packChunk } from "../../src/snapshot/chunks.ts"; |
| 9 | 9 | import { safePath, type PackedFile } from "../../src/snapshot/parts.ts"; |
| 10 | 10 | 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"; | |
| 12 | 12 | |
| 13 | 13 | /** `body` put in `store` as chunks of `size`, and the entry a manifest lists it by. */ |
| 14 | 14 | 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 @@ | ||
| 4 | 4 | * name two days back, so a snapshot taken now is always a second one, never the seeded one again. |
| 5 | 5 | */ |
| 6 | 6 | 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"; | |
| 8 | 8 | |
| 9 | 9 | const SEED_AGE_MS = 2 * 86_400_000; |
| 10 | 10 |
test/helpers/throttled-drill.ts +1 −1
| @@ -19,7 +19,7 @@ import { drillBudgetMs, runDrill } from "../../src/snapshot/drill.ts"; | ||
| 19 | 19 | import { chunkId, chunkKey, packChunk } from "../../src/snapshot/chunks.ts"; |
| 20 | 20 | import { readWhole } from "../../src/snapshot/restore.ts"; |
| 21 | 21 | 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"; | |
| 23 | 23 | |
| 24 | 24 | export const MB = 1_000_000; |
| 25 | 25 | /** 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"; | ||
| 12 | 12 | import { noteHosted } from "../src/snapshot/hosted.ts"; |
| 13 | 13 | import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts"; |
| 14 | 14 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 15 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 15 | import { dirStore } from "../src/blob/store.ts"; | |
| 16 | 16 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 17 | 17 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 18 | 18 | 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"; | ||
| 7 | 7 | import { createUser } from "../src/core/users.ts"; |
| 8 | 8 | import { serve, type Servers } from "../src/http/server.ts"; |
| 9 | 9 | 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"; | |
| 11 | 11 | import { quietLogs } from "./helpers/globals.ts"; |
| 12 | 12 | |
| 13 | 13 | quietLogs(); |
test/maintenance.test.ts +1 −1
| @@ -14,7 +14,7 @@ import { prepare, resume, resumeAtBoot, resumeNow, status } from "../src/mainten | ||
| 14 | 14 | import { inMaintenance, readState, writeState } from "../src/maintenance/state.ts"; |
| 15 | 15 | import { HOLD_WORDS } from "../src/runs/held.ts"; |
| 16 | 16 | 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"; | |
| 18 | 18 | import { runnerCheck, tunnelCheck } from "../src/maintenance/checks.ts"; |
| 19 | 19 | import { entry, maintenanceLines, maintenanceScreen } from "../src/tui/screens/maintenance.ts"; |
| 20 | 20 | import { quietLogs } from "./helpers/globals.ts"; |
test/mcp-backups.test.ts +1 −1
| @@ -9,7 +9,7 @@ import { createToken } from "../src/core/tokens.ts"; | ||
| 9 | 9 | import { createUser } from "../src/core/users.ts"; |
| 10 | 10 | import { serve, type Servers } from "../src/http/server.ts"; |
| 11 | 11 | import { scrubReason } from "../src/snapshot/destination.ts"; |
| 12 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 12 | import { dirStore } from "../src/blob/store.ts"; | |
| 13 | 13 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 14 | 14 | import { quietLogs } from "./helpers/globals.ts"; |
| 15 | 15 |
test/mcp-mirror-now.test.ts +1 −1
| @@ -8,7 +8,7 @@ import { createToken } from "../src/core/tokens.ts"; | ||
| 8 | 8 | import { createUser } from "../src/core/users.ts"; |
| 9 | 9 | import { serve, type Servers } from "../src/http/server.ts"; |
| 10 | 10 | 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"; | |
| 12 | 12 | import { promote } from "./helpers/members.ts"; |
| 13 | 13 | import { quietLogs } from "./helpers/globals.ts"; |
| 14 | 14 |
test/mcp-mirror-set.test.ts +1 −1
| @@ -9,7 +9,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 9 | 9 | import { serve, type Servers } from "../src/http/server.ts"; |
| 10 | 10 | import { resolveMirror } from "../src/snapshot/mirror.ts"; |
| 11 | 11 | 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"; | |
| 13 | 13 | import { promote } from "./helpers/members.ts"; |
| 14 | 14 | import { quietLogs } from "./helpers/globals.ts"; |
| 15 | 15 |
test/mcp-ops-tool-cards.test.ts +1 −1
| @@ -11,7 +11,7 @@ import { createUser, getUserByName } from "../src/core/users.ts"; | ||
| 11 | 11 | import { serve, type Servers } from "../src/http/server.ts"; |
| 12 | 12 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 13 | 13 | 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"; | |
| 15 | 15 | import { quietLogs } from "./helpers/globals.ts"; |
| 16 | 16 | |
| 17 | 17 | quietLogs(); |
test/mcp-restore-drill.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { serve, type Servers } from "../src/http/server.ts"; | ||
| 12 | 12 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 13 | 13 | import { lastDrill } from "../src/snapshot/drills.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 17 | |
| 18 | 18 | quietLogs(); |
test/mcp-snapshot-now.test.ts +1 −1
| @@ -8,7 +8,7 @@ import { createToken } from "../src/core/tokens.ts"; | ||
| 8 | 8 | import { createUser } from "../src/core/users.ts"; |
| 9 | 9 | import { serve, type Servers } from "../src/http/server.ts"; |
| 10 | 10 | 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"; | |
| 12 | 12 | import { quietLogs } from "./helpers/globals.ts"; |
| 13 | 13 | |
| 14 | 14 | quietLogs(); |
test/mirror-worker.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { join } from "node:path"; | ||
| 12 | 12 | import { lastMirror, mirrorOffThread } from "../src/snapshot/mirror.ts"; |
| 13 | 13 | import { storeFrom } from "../src/snapshot/remake.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { bypassProxy, stubBucket } from "./helpers/stub-bucket.ts"; |
| 17 | 17 | |
| 18 | 18 | const restoreProxy = bypassProxy(); |
test/offsite-lane.test.ts +1 −1
| @@ -20,7 +20,7 @@ import { restoreSnapshot } from "../src/snapshot/restore.ts"; | ||
| 20 | 20 | import { hiddenKey, LANE_HEADER, openBody, parseHeader, sealBody, sealedStore, sealKeys, SEALED_PREFIX } from "../src/snapshot/sealed_store.ts"; |
| 21 | 21 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 22 | 22 | 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"; | |
| 24 | 24 | import { tool as systemTool } from "../src/http/mcp/tools/system.ts"; |
| 25 | 25 | import { Session } from "../src/tui/forge.ts"; |
| 26 | 26 | 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"; | ||
| 10 | 10 | import { createRun, getRun } from "../src/core/runs.ts"; |
| 11 | 11 | import { createUser } from "../src/core/users.ts"; |
| 12 | 12 | 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"; | |
| 14 | 14 | import { holdClock } from "../src/core/one_core.ts"; |
| 15 | 15 | import { quietLogs } from "./helpers/globals.ts"; |
| 16 | 16 | 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 }> = { | ||
| 51 | 51 | "src/release/small_forge.ts": { count: 1, why: "a forge the release check started itself" }, |
| 52 | 52 | "src/snapshot/verdict.ts": { count: 1, why: "the forge URL from operator configuration" }, |
| 53 | 53 | "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" }, | |
| 55 | 55 | "src/snapshot/probe.ts": { count: 1, why: "the operator's forge URL" }, |
| 56 | 56 | "src/maintenance/standby.ts": { count: 1, why: "the operator's standby page URL" }, |
| 57 | 57 | "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"); | ||
| 8 | 8 | |
| 9 | 9 | test("the doc names every variable the store reads", () => { |
| 10 | 10 | 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( | |
| 12 | 12 | (m) => m[1]!, |
| 13 | 13 | ), |
| 14 | 14 | ); |
test/recovery-kit.test.ts +1 −1
| @@ -13,7 +13,7 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | ||
| 13 | 13 | import { saveDestination } from "../src/actions/destination.ts"; |
| 14 | 14 | import { saveReadKey, takeKit } from "../src/actions/destination.ts"; |
| 15 | 15 | 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"; | |
| 17 | 17 | import { sealedStore } from "../src/snapshot/sealed_store.ts"; |
| 18 | 18 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 19 | 19 | 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"; | ||
| 14 | 14 | import type { Ctx, Screen } from "../src/tui/app/app.ts"; |
| 15 | 15 | import { forgeCommands, Session } from "../src/tui/forge.ts"; |
| 16 | 16 | 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"; | |
| 18 | 18 | import { createForgeApp } from "../src/tui/forge.ts"; |
| 19 | 19 | import { headlessTerminal } from "../src/tui/term/terminal.ts"; |
| 20 | 20 | import { settleApp } from "./helpers/tui.ts"; |
test/restore-card.test.ts +1 −1
| @@ -14,7 +14,7 @@ import { join } from "node:path"; | ||
| 14 | 14 | import { createApp, type App } from "../src/app.ts"; |
| 15 | 15 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 16 | 16 | import { createUser } from "../src/core/users.ts"; |
| 17 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 17 | import { dirStore } from "../src/blob/store.ts"; | |
| 18 | 18 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 19 | 19 | |
| 20 | 20 | const PASS = "correct horse battery staple"; |
test/restore-drill-script.test.ts +1 −1
| @@ -13,7 +13,7 @@ import { join, relative } from "node:path"; | ||
| 13 | 13 | import { createApp, type App } from "../src/app.ts"; |
| 14 | 14 | import { commitToBranch, createRepo } from "../src/actions/repos.ts"; |
| 15 | 15 | import { createUser } from "../src/core/users.ts"; |
| 16 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 16 | import { dirStore } from "../src/blob/store.ts"; | |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | 18 | import { compareLines, parseArgs, PRODUCTION } from "../scripts/restore-drill.ts"; |
| 19 | 19 | import { publicCounts } from "../src/snapshot/public_counts.ts"; |
test/snapshot-destination.test.ts +1 −1
| @@ -17,7 +17,7 @@ import { | ||
| 17 | 17 | } from "../src/actions/destination.ts"; |
| 18 | 18 | import { createUser, type User } from "../src/core/users.ts"; |
| 19 | 19 | 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"; | |
| 21 | 21 | import { startSnapshots } from "../src/snapshot/service.ts"; |
| 22 | 22 | import { serve, type Servers } from "../src/http/server.ts"; |
| 23 | 23 | 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"; | ||
| 15 | 15 | import { runDrill } from "../src/snapshot/drill.ts"; |
| 16 | 16 | import { lastDrill, recordDrill } from "../src/snapshot/drills.ts"; |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 18 | import { dirStore } from "../src/blob/store.ts"; | |
| 19 | 19 | |
| 20 | 20 | describe("the restore drill's counts", () => { |
| 21 | 21 | let root: string; |
test/snapshot-drill-page.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 12 | 12 | import { serve, type Servers } from "../src/http/server.ts"; |
| 13 | 13 | import type { DrillResult } from "../src/snapshot/drill.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { quietLogs } from "./helpers/globals.ts"; |
| 17 | 17 | |
| 18 | 18 | quietLogs(); |
test/snapshot-drill-phases.test.ts +1 −1
| @@ -15,7 +15,7 @@ import { lastDrill, parsePhases, recordDrill } from "../src/snapshot/drills.ts"; | ||
| 15 | 15 | import { restoreSnapshot } from "../src/snapshot/restore.ts"; |
| 16 | 16 | import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts"; |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 18 | import { dirStore } from "../src/blob/store.ts"; | |
| 19 | 19 | import { quietLogs } from "./helpers/globals.ts"; |
| 20 | 20 | |
| 21 | 21 | quietLogs(); |
test/snapshot-drill.test.ts +1 −1
| @@ -16,7 +16,7 @@ import { createUser } from "../src/core/users.ts"; | ||
| 16 | 16 | import { drillBudgetMs, formatBudget, formatBytes, formatMinutes, runDrill } from "../src/snapshot/drill.ts"; |
| 17 | 17 | import { chunked } from "./helpers/snapshot-fixtures.ts"; |
| 18 | 18 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 19 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 19 | import { dirStore } from "../src/blob/store.ts"; | |
| 20 | 20 | |
| 21 | 21 | const PASS = "correct horse battery staple"; |
| 22 | 22 |
test/snapshot-hosted-chunks.test.ts +1 −1
| @@ -34,7 +34,7 @@ import { drillPick, proveHosted } from "../src/snapshot/drill_hosted.ts"; | ||
| 34 | 34 | import { hostedDrillWords } from "../src/snapshot/drill_hosted_words.ts"; |
| 35 | 35 | import { restoreHosted } from "../src/snapshot/restore.ts"; |
| 36 | 36 | 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"; | |
| 38 | 38 | import { verifySnapshot } from "../src/snapshot/verify.ts"; |
| 39 | 39 | import { quietLogs } from "./helpers/globals.ts"; |
| 40 | 40 |
test/snapshot-hosted-history.test.ts +1 −1
| @@ -11,7 +11,7 @@ import { createApp, type App } from "../src/app.ts"; | ||
| 11 | 11 | import { copyHosted, unchanged } from "../src/snapshot/hosted.ts"; |
| 12 | 12 | import { restoreHostedInto } from "../src/snapshot/restore.ts"; |
| 13 | 13 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 14 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 14 | import { dirStore } from "../src/blob/store.ts"; | |
| 15 | 15 | |
| 16 | 16 | let root: string; |
| 17 | 17 | let parent: App; |
test/snapshot-hosted-inside.test.ts +1 −1
| @@ -39,7 +39,7 @@ import { chunkKey, openChunk } from "../src/snapshot/chunks.ts"; | ||
| 39 | 39 | import { copyInProcess, hostedSources, notOwnDir, type HostedSource } from "../src/snapshot/hosted.ts"; |
| 40 | 40 | import { restoreHosted } from "../src/snapshot/restore.ts"; |
| 41 | 41 | 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"; | |
| 43 | 43 | import { verifySnapshot } from "../src/snapshot/verify.ts"; |
| 44 | 44 | import { quietLogs } from "./helpers/globals.ts"; |
| 45 | 45 |
test/snapshot-hosted.test.ts +1 −1
| @@ -15,7 +15,7 @@ import { repoDir } from "../src/git/repos.ts"; | ||
| 15 | 15 | import { bodyIdOf, hostedSources, hostedWords, keptWords, noteHosted, readHosted } from "../src/snapshot/hosted.ts"; |
| 16 | 16 | import { restoreHosted, restoreHostedInto, restoreSnapshot } from "../src/snapshot/restore.ts"; |
| 17 | 17 | import { takeSnapshot } from "../src/snapshot/snapshot.ts"; |
| 18 | import { dirStore } from "../src/snapshot/store.ts"; | |
| 18 | import { dirStore } from "../src/blob/store.ts"; | |
| 19 | 19 | |
| 20 | 20 | const PASS = "correct horse battery staple"; |
| 21 | 21 |
test/snapshot-incremental.test.ts +1 −1
| @@ -70,7 +70,7 @@ import { | ||
| 70 | 70 | takeSnapshot, |
| 71 | 71 | type Manifest, |
| 72 | 72 | } 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"; | |
| 74 | 74 | import { verifySnapshot } from "../src/snapshot/verify.ts"; |
| 75 | 75 | import { chunked, pack } from "./helpers/snapshot-fixtures.ts"; |
| 76 | 76 | 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"; | ||
| 14 | 14 | import { vitals } from "../src/kernel/vitals.ts"; |
| 15 | 15 | import { lastMirror, mirrorSealedSet, MIRROR_NAMES, recordMirror, resolveMirror } from "../src/snapshot/mirror.ts"; |
| 16 | 16 | 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"; | |
| 18 | 18 | import { quietLogs } from "./helpers/globals.ts"; |
| 19 | 19 | |
| 20 | 20 | quietLogs(); |
test/snapshot-mirror.test.ts +1 −1
| @@ -24,7 +24,7 @@ import { | ||
| 24 | 24 | resolveMirror, |
| 25 | 25 | } from "../src/snapshot/mirror.ts"; |
| 26 | 26 | 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"; | |
| 28 | 28 | |
| 29 | 29 | /** A directory as a bucket that can be switched off: while `down`, every call fails like an unreachable host. */ |
| 30 | 30 | 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"; | ||
| 17 | 17 | import { isOffBox, lastOffBox } from "../src/snapshot/off_box.ts"; |
| 18 | 18 | import { lastSnapshotOutcome, noteOffBox, recordSnapshotOutcome } from "../src/snapshot/outcome.ts"; |
| 19 | 19 | 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"; | |
| 21 | 21 | import { kpiForge } from "../src/tui/screens/dashboard.ts"; |
| 22 | 22 | |
| 23 | 23 | describe("isOffBox", () => { |
test/snapshot-one-core.test.ts +1 −1
| @@ -12,7 +12,7 @@ import { join } from "node:path"; | ||
| 12 | 12 | import { createApp, type App } from "../src/app.ts"; |
| 13 | 13 | import { MAX_DEFER_MS, startSnapshots } from "../src/snapshot/service.ts"; |
| 14 | 14 | 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"; | |
| 16 | 16 | import { seedSnapshot } from "./helpers/snapshot-seed.ts"; |
| 17 | 17 | |
| 18 | 18 | let root: string; |
test/snapshot-outcome.test.ts +1 −1
| @@ -16,7 +16,7 @@ import { createUser, type User } from "../src/core/users.ts"; | ||
| 16 | 16 | import { serve, type Servers } from "../src/http/server.ts"; |
| 17 | 17 | import { lastSnapshotOutcome, recordSnapshotOutcome, snapshotNeed, SNAPSHOT_RETRY_MS } from "../src/snapshot/outcome.ts"; |
| 18 | 18 | 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"; | |
| 20 | 20 | |
| 21 | 21 | const failed = (app: App) => forgeVitals(app).degraded.find((d) => d.cause === "snapshot-failed"); |
| 22 | 22 |
test/snapshot-put-abort.test.ts +1 −1
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | * line with the ones before it. The deadline now aborts the attempt's request. |
| 6 | 6 | */ |
| 7 | 7 | 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"; | |
| 9 | 9 | import { bypassProxy, stubBucket } from "./helpers/stub-bucket.ts"; |
| 10 | 10 | |
| 11 | 11 | describe("a put past its deadline", () => { |
20 more files not shown.
new above
offline