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

The backup holds uploaded plugin jars, and a restore names each one that did not come back (#17284) #17716

opened this

Merged 19h 14m ago, live in production

sold/jars-backup → main 0 commits 2 threads · 2 unresolved

  • Merged. sold/jars-backup was merged into main as 27f9d0a.

Review

Sign in to review this change.
14 files changed +203 −13
docs/SNAPSHOT.md +7 −2
@@ -91,6 +91,10 @@ and `sentMb` put, `heldBefore` already there.
9191 A restore returns each file byte for byte (`test/drop-backup.test.ts`). A
9292 large Drop makes the night longer by the time it takes to read and hash it;
9393 only chunks the store lacks are sent.
94 - The plugin jars people uploaded for their game servers (`games/jars/<id>.jar`),
95 kept nowhere else. A restore names each jar the database lists whose file did
96 not come back, or is of another size (`test/jar-backup.test.ts`). A snapshot
97 from before 2026-12-02 holds none of them.
9498 - The crew's run logs, a day's worth to a few bundles
9599 (`runs/<day>[-n].ndjson`, cut at 4 MB of logs), in the order the logs were
96100 last written: a bundle once full is the same bytes in every later
@@ -99,8 +103,9 @@ and `sentMb` put, `heldBefore` already there.
99103 with its size, hash and chunks, `sent` (what this snapshot itself put),
100104 and `key`: `wrapped` or `none` (older snapshots: `raw`).
101105
102 What stays out is what a boot or a deploy rebuilds: clones, checks,
103 pictures, previews.
106 Everything else under the data directory stays out. Most of it is what a boot
107 or a deploy rebuilds: clones, checks, pictures of pages, previews. Some is not:
108 [backup-left-out.md](features/backup-left-out.md) lists it.
104109
105110 ## Is a snapshot encrypted before it leaves?
106111
docs/features/backup-left-out.md added +52
@@ -0,0 +1,52 @@
1 ---
2 topic: Backups and moving
3 row: What is in no backup
4 ---
5 # What is in no backup
6
7 The nightly snapshot takes a fixed list from the data directory (`src/snapshot/snapshot.ts`,
8 [SNAPSHOT.md](../SNAPSHOT.md), "What a snapshot holds"). A folder that is not on the list is in no
9 snapshot. This page lists those that hold something a boot or a deploy does not make again, as the
10 code writes them.
11
12 ## Kept nowhere else
13
14 | Under the data directory | What it is | Written by |
15 | --- | --- | --- |
16 | `conversation-files/` | Files and images people attached to a Talk message | `src/core/conversation_files.ts` |
17 | `note-pictures/` | The picture sent with a note from the forge button | `src/core/note_pictures.ts` |
18 | `changes/` | Each app's ordered change stream, one SQLite file an app | `src/apps/changes.ts` |
19 | `machines/` | Each person's own directory on a repository's machines | `src/machines/shell.ts` |
20 | `recipes/` | Forge configurations a person saved by name | `src/spawn/recipes.ts` |
21 | `claude-config/` | The agent's own session files for conversations, unless the operator named another directory | `src/crew/conversation.ts` |
22 | `secret.key.old` | The key before the last change of key, while there is one | `src/kernel/secret.ts` |
23 | `edge/signing.pem` | The key that signs the files the edge serves. A boot without it makes a new one, with a new public key | `src/cloud/edge.ts` |
24 | `dataset/salt` | The secret that names people in the dataset. An export without it makes a new one, so the names change | `src/actions/dataset.ts` |
25 | `archive/` | The record of each archived hosted forge: which store holds its copy, and the copy's hash | `src/spawn/archive.ts` |
26 | `routes.json` | Which machine holds a hosted forge that is not on this one | `src/spawn/routes.ts` |
27 | `access/`, `perf/`, `nightly/` | The access log (14 days), the performance log, each nightly job's last output | `src/http/access_log.ts`, `src/perf/kept_log.ts`, `src/nightly/output.ts` |
28
29 ## In the bucket, or only here
30
31 With `S3_*` set these are written to the bucket, beside the snapshots and not inside them. Without
32 it they are folders under the data directory, and in no backup.
33
34 | Without a bucket | What it is | Written by |
35 | --- | --- | --- |
36 | `look-blobs/` | Pictures a person attached as looks | `src/looks/archive.ts` |
37 | `run-archive/` | Finished run logs. The snapshot takes `runs/`, and a log the store holds leaves `runs/` about a day after it was last written | `src/runs/archive.ts` |
38 | `large-blobs/` | Copies of big git blobs; git keeps its own, and the bundles hold it | `src/blob/large.ts` |
39
40 ## Covered another way
41
42 - `ledger/`, this forge's cost ledger: its lines are committed to the `ledger` branch of the forge's
43 own repository, at most once an hour, and that repository is in the snapshot. With no such
44 repository (`FORGE_LEDGER_REPO`, or the forge's own), the ledger is in no backup. A hosted forge's
45 `ledger/` is in the snapshot itself.
46 - `carts/`: a page saved from a build at a fixed commit. Capture makes it again while the build
47 still runs.
48 - `app-backups/`: sealed copies of an app's production data. The data is in the snapshot; the sealed
49 copies are not.
50
51 This list was read from the code on 2026-12-02 and is not checked by a test. It names what was found
52 to matter; folders that hold clones, caches, checks and last-seen states are not listed.
docs/features/hosted-backup.md +2 −2
@@ -14,10 +14,10 @@ Each forge this one hosts goes into the nightly snapshot (#13819), under `childr
1414 | Its key, wrapped under `FORGE_SNAPSHOT_PASSPHRASE` | `secret.key.wrapped` (without a passphrase the key stays home) |
1515 | Every app's production data | alongside |
1616 | This forge's own record of it | `ledger.json` |
17 | Its history: run logs, drop, cost ledger, `parent.json`, `plan.json` | `runs/`, `drop/`, `ledger/`, alongside |
17 | Its history: run logs, drop, cost ledger, uploaded plugin jars, `parent.json`, `plan.json` | `runs/`, `drop/`, `ledger/`, `games/jars/`, alongside |
1818 | What the host holds of it: credit and spend, the own-code switch | `parent/credit.json`, `parent/own-code.json`; `--forge` puts them back under `<data>/credit` and `<data>/own-code` |
1919
20 `parent/credit.json` holds the forge's `tokenHash`; it is backed up like everything else and is covered by the same encryption: a snapshot kept on a sealed lane is sealed chunk by chunk, this file with the rest. Files are opened without following a link and only if regular; a link, a pipe, a file that changed while it was copied, or history past the 512 MiB cap on `runs/`, `drop/` and `ledger/` together is left out and named in the manifest's `omitted` list (first 100, `omittedTotal` counts all). A restore refuses a `parent/` entry it has no place for.
20 `parent/credit.json` holds the forge's `tokenHash`; it is backed up like everything else and is covered by the same encryption: a snapshot kept on a sealed lane is sealed chunk by chunk, this file with the rest. Files are opened without following a link and only if regular; a link, a pipe, a file that changed while it was copied, or history past the 512 MiB cap on `runs/`, `drop/`, `ledger/` and `games/jars/` together is left out and named in the manifest's `omitted` list (first 100, `omittedTotal` counts all). A restore refuses a `parent/` entry it has no place for.
2121
2222 Chunks are shared with the rest of the snapshot, so a forge unchanged since last night sends nothing. A forge that cannot be read is named in the manifest's `hosted` list and the log; the snapshot goes on without it.
2323
scripts/restore-drill.ts +2 −1
@@ -22,7 +22,7 @@ import { bootRestored } from "../src/snapshot/boot.ts";
2222 import { resolveSnapshots } from "../src/snapshot/destination.ts";
2323 import { offsiteFromEnv } from "../src/snapshot/mirror.ts";
2424 import { publicCounts, type PublicCounts } from "../src/snapshot/public_counts.ts";
25 import { restoreSnapshot } from "../src/snapshot/restore.ts";
25 import { jarLines, restoreSnapshot } from "../src/snapshot/restore.ts";
2626 import { listSnapshots } from "../src/snapshot/snapshot.ts";
2727 import { PREVIEW_ADMIN } from "../src/spawn/preview-looks.ts";
2828
@@ -98,6 +98,7 @@ async function main(): Promise<number> {
9898 });
9999 console.log(`restored ${done.files} files and ${done.repos} repositories, key ${done.key}, ${seconds()}s`);
100100 if (done.sealedMissing.length > 0) console.log(`sealed values to set again: ${done.sealedMissing.length}`);
101 for (const line of jarLines(done.jarsMissing)) console.log(line);
101102
102103 let restored: PublicCounts | undefined;
103104 const booted = await bootRestored(args.dataDir, BOOT_MS, undefined, async (base) => {
scripts/standby-restore.ts +2
@@ -16,6 +16,7 @@
1616 */
1717 import { resolve } from "node:path";
1818 import { resolveSnapshots } from "../src/snapshot/destination.ts";
19 import { jarLines } from "../src/snapshot/restore.ts";
1920 import { restoreStandby } from "../src/snapshot/standby.ts";
2021
2122 async function main(args: readonly string[]): Promise<number> {
@@ -38,6 +39,7 @@ async function main(args: readonly string[]): Promise<number> {
3839 try {
3940 const done = await restoreStandby(store, snapshot, dataDir, process.env["FORGE_SNAPSHOT_PASSPHRASE"] || undefined);
4041 console.log(`restored ${done.name}: ${done.restored.files} files, ${done.repos} repositories, key ${done.restored.key}`);
42 for (const line of jarLines(done.restored.jarsMissing)) console.log(line);
4143 if (done.problems.length > 0) {
4244 for (const p of done.problems) console.error(`standby-restore: ${p}`);
4345 return 1;
src/games/jars.ts added +37
@@ -0,0 +1,37 @@
1 /**
2 * Where plugin jars people uploaded are kept, and which of them a data directory lacks. A jar is
3 * a row in `game_jar` and a file under `<data>/games/jars`; the snapshot carries both, and a
4 * restore says which rows came back without their file.
5 */
6 import { Database } from "bun:sqlite";
7 import { existsSync, statSync } from "node:fs";
8 import { join } from "node:path";
9
10 /** Under the data directory, and under the same name in a snapshot. */
11 export const JARS_DIR = "games/jars";
12
13 /** The jars the database at `dataDir` names whose file is missing or of another size, in words. */
14 export function jarsMissing(dataDir: string): string[] {
15 let db: Database | undefined;
16 try {
17 db = new Database(join(dataDir, "forge.db"), { readonly: true });
18 // A database from before jars names none.
19 if (db.query("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'game_jar'").get() === null) return [];
20 return db
21 .query<{ id: string; name: string; bytes: number; box: string | null }, []>(
22 "SELECT j.id AS id, j.name AS name, j.bytes AS bytes, b.name AS box FROM game_jar j LEFT JOIN game_box b ON b.id = j.box_id ORDER BY b.name, j.name, j.id",
23 )
24 .all()
25 .flatMap((j) => {
26 const file = join(dataDir, JARS_DIR, `${j.id}.jar`);
27 const of = `${j.name} (${j.box === null ? "a box that is gone" : `box ${j.box}`})`;
28 if (!existsSync(file)) return [`${of}: no file`];

The size-mismatch message is never exercised by a test. Add a case where the file is truncated after the upload.

29 const size = statSync(file).size;
30 return size === j.bytes ? [] : [`${of}: ${size} bytes, not ${j.bytes}`];
31 });
32 } catch (error) {
33 return [`the jars could not be checked: ${error instanceof Error ? error.message : String(error)}`];
34 } finally {
35 db?.close();
36 }
37 }
src/games/store.ts +2 −1
@@ -8,6 +8,7 @@
88 */
99
1010 import type { Database } from "bun:sqlite";
11 import { JARS_DIR } from "./jars.ts";
1112 import { COMPOSE_AT, sameFile, type ComposeFile } from "./compose_file.ts";
1213 import { keptDiag, readDiag, type Diag } from "./diag.ts";
1314 import { outcomeOf } from "./outcome.ts";
@@ -475,7 +476,7 @@ export function envFiles(app: App, box: GameBox, compose: string, services: read
475476 export const JAR_URL_MS = 6 * 3_600_000;
476477
477478 export function jarPath(app: App, jarId: string): string {
478 return `${app.config.dataDir}/games/jars/${jarId}.jar`;
479 return `${app.config.dataDir}/${JARS_DIR}/${jarId}.jar`;
479480 }
480481
481482 /** What one box keeps: jars, and their bytes together; one jar is at most `JAR_MAX_BYTES`. */
src/snapshot/hosted.ts +10 −3
@@ -21,6 +21,7 @@
2121 import { closeSync, constants, fstatSync, lstatSync, openSync, readdirSync, readFileSync, readlinkSync, readSync, realpathSync, rmSync } from "node:fs";
2222 import { lstat, readdir } from "node:fs/promises";
2323 import { dirname, join, resolve, sep } from "node:path";
24 import { JARS_DIR } from "../games/jars.ts";
2425 import { runGit } from "../git/env.ts";
2526 import { findingWords, scanRepos } from "../spawn/move_scan.ts";
2627 import { CHILD_NAME } from "../spawn/placement.ts";
@@ -75,7 +76,7 @@ export interface HostedSource {
7576 export const PARENT_SIDE = "parent/";
7677 export const PARENT_FILES: readonly string[] = [`${PARENT_SIDE}credit.json`, `${PARENT_SIDE}own-code.json`];
7778 /** What a forge keeps in its own directory beside its database: history and records, whole. */
78 export const HISTORY_DIRS = ["runs", "drop", "ledger"] as const;
79 export const HISTORY_DIRS = ["runs", "drop", "ledger", JARS_DIR] as const;
7980 export const HISTORY_FILES = ["parent.json", "plan.json"] as const;
8081
8182 // A letter or digit first, as `spawn/archive.ts` holds: an id never reads as an option (#14783).
@@ -209,7 +210,7 @@ export type HostedCopy = Pick<HostedEntry, "repos" | "key" | "absent" | "omitted
209210
210211 /** Names of left-out files a manifest lists; the rest are counted. */
211212 export const OMITTED_LISTED = 100;
212 /** Bytes of runs/, drop/ and ledger/ together a snapshot of one forge carries. */
213 /** Bytes of runs/, drop/, ledger/ and games/jars/ together a snapshot of one forge carries. */
213214 export const HISTORY_BYTES_MAX = 512 * 1_048_576;
214215
215216 type Cut = "content" | "fixed" | "bundle";
@@ -232,7 +233,7 @@ export interface HostedTools {
232233 /** The most files read from the forge's directory; `HOSTED_FILES_MAX` unless a test lowers it. */
233234 readonly filesMax?: number | undefined;
234235 /**
235 * The most bytes of history (runs, drop, ledger); `HISTORY_BYTES_MAX` unless a test lowers it.
236 * The most bytes of history (`HISTORY_DIRS`); `HISTORY_BYTES_MAX` unless a test lowers it.
236237 */
237238 readonly historyMax?: number | undefined;
238239 }
@@ -574,6 +575,12 @@ export async function copyHosted(child: HostedSource, tools: HostedTools): Promi
574575 };
575576 let room = tools.historyMax ?? HISTORY_BYTES_MAX;
576577 for (const d of HISTORY_DIRS) {
578 // A directory inside another is listed only when the outer one is the forge's own, not a link.
579 const outer = d.split("/").slice(0, -1);
580 if (outer.length > 0 && notOwnDir(root, outer) !== undefined) {
581 if (lstatSync(join(root, ...outer), { throwIfNoEntry: false }) !== undefined) omitted.push({ path: d, why: "it is not in a directory of the forge's own" });
582 continue;
583 }
577584 const found = await historyIn(join(root, d), d, left);
578585 omitted.push(...found.omitted);
579586 for (const f of found.files) {
src/snapshot/restore.ts +13 −2
@@ -45,6 +45,7 @@ import { chmodSync, existsSync, mkdirSync, readdirSync, rmSync } from "node:fs";
4545 import { open as openFile, type FileHandle } from "node:fs/promises";
4646 import { availableParallelism } from "node:os";
4747 import { dirname, join } from "node:path";
48 import { jarsMissing } from "../games/jars.ts";
4849 import { runGit } from "../git/env.ts";
4950 import { installHooks } from "../git/hooks.ts";
5051 import { repoDir } from "../git/repos.ts";
@@ -76,8 +77,14 @@ export interface Restored {
7677 readonly key: "restored" | "raw" | "missing";
7778 /** Sealed values that will not open without the key, by name. */
7879 readonly sealedMissing: readonly string[];
80 /** Uploaded plugin jars the database names that did not come back, in words. */
81 readonly jarsMissing: readonly string[];
7982 }
8083
84 /** What a restore says of jars that did not come back; nothing when all did. */
85 export const jarLines = (missing: readonly string[]): string[] =>
86 missing.length === 0 ? [] : [`${missing.length} uploaded plugin jar(s) did not come back and must be uploaded again:`, ...missing.map((m) => ` ${m}`)];
87
8188 /** Where a restore is, as plain data: `done` of `total` in `phase`, `bytes` so far in it. */
8289 export interface Progress {
8390 readonly phase: "manifest" | "files" | "unpack" | "bundles" | "key";
@@ -596,7 +603,7 @@ export async function restoreSnapshot(
596603 key !== undefined ? "restored" : kind === "raw" ? "raw" : "missing";
597604 const sealedMissing =
598605 have === "missing" ? await sealedNames(join(dataDir, "forge.db")) : [];
599 return { manifest, files, repos, key: have, sealedMissing };
606 return { manifest, files, repos, key: have, sealedMissing, jarsMissing: jarsMissing(dataDir) };
600607 }
601608
602609 /** What one hosted forge's restore brought back. */
@@ -613,6 +620,8 @@ export interface RestoredHosted {
613620 readonly files: number;
614621 readonly repos: number;
615622 readonly key: "restored" | "missing";
623 /** As `Restored.jarsMissing`. */
624 readonly jarsMissing: readonly string[];
616625 }
617626
618627 /**
@@ -676,7 +685,7 @@ export async function restoreHosted(
676685 }
677686 // What its parent wrote of it was private to it, and is again.
678687 if (existsSync(join(dir, "parent.json"))) chmodSync(join(dir, "parent.json"), 0o600);
679 return { name: forge, dir, ledger: ledgerText, parentFiles, files: got.files, repos: got.bundles.length, key: key === undefined ? "missing" : "restored" };
688 return { name: forge, dir, ledger: ledgerText, parentFiles, files: got.files, repos: got.bundles.length, key: key === undefined ? "missing" : "restored", jarsMissing: jarsMissing(dir) };

Nothing tests that a hosted restore reports jarsMissing. Add one case beside the history test.

680689 }
681690
682691 /**
@@ -791,6 +800,7 @@ if (import.meta.main)
791800 try {
792801 const one = await restoreHostedInto(store, snap, forgeName, dataDir, { passphrase: process.env["FORGE_SNAPSHOT_PASSPHRASE"] || undefined });
793802 console.log(`restored ${forgeName} from ${snap}: ${one.files} files, ${one.repos} repositories into ${one.dir}${one.key === "missing" ? "; its key was not restored" : ""}`);
803 for (const line of jarLines(one.jarsMissing)) console.log(line);
794804 process.exit(0);
795805 } catch (e) {
796806 // CLI message on stderr for the person at the terminal.
@@ -819,4 +829,5 @@ if (import.meta.main)
819829 );
820830 for (const n of done.sealedMissing) console.log(` ${n}`);
821831 }
832 for (const line of jarLines(done.jarsMissing)) console.log(line);
822833 })();
src/snapshot/snapshot.ts +5
@@ -40,6 +40,7 @@ import { vacuumFile, vacuumInto } from "./vacuum.ts";
4040 import { closeSync, createReadStream, fstatSync, lstatSync, mkdtempSync, openSync, readdirSync, readSync, rmSync, statSync } from "node:fs";
4141 import { tmpdir } from "node:os";
4242 import { join, relative } from "node:path";
43 import { JARS_DIR } from "../games/jars.ts";
4344 import { envDataDir } from "../apps/data.ts";
4445 import { listApps } from "../core/apps.ts";
4546 import { listEveryRepo } from "../core/repos.ts";
@@ -787,6 +788,10 @@ export async function takeSnapshot(
787788 for (const f of streaming ? [] : filesUnder(dropped))
788789 if (!f.split("/").some((part) => part.startsWith("."))) await putFile(`drop/${f}`, join(dropped, f));
789790
791 // Plugin jars people uploaded for their game servers (`games/store.ts`): kept nowhere else.
792 const jars = join(forge.dataDir, JARS_DIR);
793 for (const f of streaming ? [] : filesUnder(jars)) await putFile(`${JARS_DIR}/${f}`, join(jars, f));
794
790795 // The crew's run logs: history a person may want back. A day's worth to
791796 // a few bundles, in the order the logs were last written: a log still
792797 // growing is in the day's last bundle, and the bundles before it are the
test/drill-hosted-red.test.ts +1 −1
@@ -57,7 +57,7 @@ const restore: NonNullable<DrillDeps["restore"]> = async (_store, _name, target)
5757 db.run("CREATE TABLE secret (name TEXT, scope TEXT, value_enc TEXT)");
5858 db.run("CREATE TABLE app_env (app_id TEXT, name TEXT, value_enc TEXT)");
5959 db.close();
60 return { manifest, files: 1, repos: 0, key: "missing", sealedMissing: [] };
60 return { manifest, files: 1, repos: 0, key: "missing", sealedMissing: [], jarsMissing: [] };
6161 };
6262
6363 let root: string;
test/jar-backup.test.ts added +66
@@ -0,0 +1,66 @@
1 /**
2 * The backup holds the plugin jars people uploaded for their game servers (`games/jars/<id>.jar`),
3 * and a restore says, by name, each one whose row came back without its file.
4 */
5 import { afterAll, beforeAll, expect, test } from "bun:test";
6 import { mkdtempSync, readFileSync, rmSync } from "node:fs";
7 import { tmpdir } from "node:os";
8 import { join } from "node:path";
9 import { createApp, type App } from "../src/app.ts";
10 import { dirStore } from "../src/blob/store.ts";
11 import { createGameBox, jarPath, storeJar } from "../src/games/store.ts";
12 import { sha256 } from "../src/kernel/hash.ts";
13 import { restoreSnapshot } from "../src/snapshot/restore.ts";
14 import { takeSnapshot } from "../src/snapshot/snapshot.ts";
15
16 let root: string;
17 let app: App;
18 let jar: string;
19 const stored = (): string => join(root, "store");
20 const snap = (at: string) =>
21 takeSnapshot({ db: app.db, dataDir: app.config.dataDir, reposRoot: app.reposRoot, version: "t" }, dirStore(stored()), new Date(at));
22
23 /** The restore command as a person runs it: what it printed. */
24 async function restoreCommand(name: string, into: string): Promise<string> {
25 const p = Bun.spawn([process.execPath, "run", join(import.meta.dir, "../src/snapshot/restore.ts"), name, into], {
26 env: { PATH: process.env["PATH"] ?? "", HOME: root, FORGE_SNAPSHOT_DIR: stored() },
27 stdout: "pipe",
28 stderr: "pipe",
29 });
30 const [out, err, code] = await Promise.all([new Response(p.stdout).text(), new Response(p.stderr).text(), p.exited]);
31 expect(`${code} ${err}`.trim()).toBe("0");
32 return out;
33 }
34
35 beforeAll(async () => {
36 root = mkdtempSync(join(tmpdir(), "forge-jar-backup-"));
37 app = createApp({ dataDir: join(root, "live"), port: 0 });
38 const box = createGameBox(app.db, { name: "mc" });
39 // A zip's first bytes, then every byte value, past one chunk's smallest size.
40 const body = Uint8Array.from({ length: 70_001 }, (_, i) => [0x50, 0x4b, 0x03, 0x04][i] ?? (i * 7) % 256);
41 const made = await storeJar(app, box.id, new Blob([body]), "Hello.jar");
42 if (!made.ok) throw new Error(made.error);
43 jar = made.id;
44 });
45 afterAll(() => {
46 app.close();
47 rmSync(root, { recursive: true, force: true });
48 });
49
50 test("an uploaded jar comes back from a restore with its row's sha256", async () => {
51 const m = await snap("2026-12-02T08:00:00Z");
52 const back = join(root, "back");
53 const done = await restoreSnapshot(dirStore(stored()), m.name, back);
54 const row = app.db.query<{ sha256: string }, [string]>("SELECT sha256 FROM game_jar WHERE id = ?1").get(jar)!;
55 expect(sha256(readFileSync(join(back, "games", "jars", `${jar}.jar`)))).toBe(row.sha256);
56 expect(done.jarsMissing).toEqual([]);
57 expect(await restoreCommand(m.name, join(root, "said-nothing"))).not.toContain("did not come back");
58 }, 30_000);
59
60 test("a jar whose file is in no backup is named by the restore, never passed over", async () => {
61 rmSync(jarPath(app, jar));
62 const m = await snap("2026-12-02T09:00:00Z");
63 const said = await restoreCommand(m.name, join(root, "without"));
64 expect(said).toContain("1 uploaded plugin jar(s) did not come back and must be uploaded again:");
65 expect(said).toContain("Hello.jar (box mc): no file");
66 }, 30_000);
test/snapshot-hosted-history.test.ts +3 −1
@@ -22,9 +22,10 @@ beforeAll(() => {
2222 parent = createApp({ dataDir: join(root, "parent"), port: 0 });
2323 const dir = join(root, "parent", "children", "b1");
2424 child = createApp({ dataDir: dir, port: 0 });
25 for (const d of ["runs/r1", "drop", "ledger"]) mkdirSync(join(dir, d), { recursive: true });
25 for (const d of ["runs/r1", "drop", "ledger", "games/jars"]) mkdirSync(join(dir, d), { recursive: true });
2626 writeFileSync(join(dir, "runs", "r1", "log.txt"), "ran the thing\n");
2727 writeFileSync(join(dir, "drop", "note.txt"), "dropped\n");
28 writeFileSync(join(dir, "games", "jars", "j1.jar"), "a jar\n");
2829 writeFileSync(join(dir, "ledger", "2026-11.jsonl"), '{"usd":1.25}\n');
2930 writeFileSync(join(dir, "parent.json"), '{"name":"kid"}', { mode: 0o600 });
3031 writeFileSync(join(dir, "plan.json"), '{"plan":"free"}');
@@ -51,6 +52,7 @@ test("a restored hosted forge has its runs, drop, ledger, records, spend and swi
5152 const at = join(back, "children", "b1");
5253 expect(readFileSync(join(at, "runs", "r1", "log.txt"), "utf8")).toBe("ran the thing\n");
5354 expect(readFileSync(join(at, "drop", "note.txt"), "utf8")).toBe("dropped\n");
55 expect(readFileSync(join(at, "games", "jars", "j1.jar"), "utf8")).toBe("a jar\n");
5456 expect(readFileSync(join(at, "ledger", "2026-11.jsonl"), "utf8")).toContain("1.25");
5557 expect(readFileSync(join(at, "plan.json"), "utf8")).toContain("free");
5658 expect(statSync(join(at, "parent.json")).mode & 0o077).toBe(0);
test/worker-database-opens.test.ts +1
@@ -59,6 +59,7 @@ const REACHED: Record<string, { opens: number; why: string }> = {
5959 "src/apps/data.ts": { opens: 1, why: "quiesceSqlite folds each app database's log before a copy: called by the serving thread's clone and backup paths, in reach of Workers only through the page layer's imports" },
6060 "src/apps/dump_import.ts": { opens: 3, why: "a person's import of a dump, on the serving thread behind a request; no Worker calls it" },
6161 "src/crew/sentinel.ts": { opens: 1, why: "one scratch database in memory, made once for the process and remembered; the sentinel is a duty of the serving thread" },
62 "src/games/jars.ts": { opens: 1, why: "a restore reads the jar rows of the restored copy once, in the restore tool or a drill, beside the sealed names in snapshot/restore.ts; no Worker calls it" },
6263 "src/kernel/db.ts": { opens: 2, why: "the forge's own database, opened once by createApp on the thread that boots; the Workers that read it open their own handle and keep it (KEEPS)" },
6364 "src/release/rollback.ts": { opens: 1, why: "liveSchema reads the schema count once for a rollback or a swap, on the serving thread or in the release tool" },
6465 "src/snapshot/drill.ts": { opens: 1, why: "a restore drill opens the restored copy once, as a duty of the serving thread" },

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs