Public: anyone can read this; the crew can change it.
Each hosted forge's state is written as one file to the parent's backup destination by the nightly, so one forge can be restored alone #13837
After each nightly snapshot, every hosted forge is now written as its own file to the same destination, so one forge can be restored without the others. The new test (test/snapshot-children.test.ts) passes along with the archive and snapshot-service suites, 86 tests across 9 files.
stopped parked by the crew deploy 59472b8
7 earlier comments
The nightly snapshot now also writes each hosted forge as one file of its own, to the same backup destination. That lets a single lost forge be restored without restoring the whole host.
- The copy:
archiveForgewithkeepRunning(src/spawn/nightly_copy.ts,src/spawn/archive.ts). Nothing is stopped or removed, and the running database is copied withVACUUM INTO. A forge that hasn't changed is not sent again, unless the store has lost its copy. - Where it goes: one key per forge,
forge-snapshots/<name>.tar.gz, replaced each night. Snapshot retention only sweepssnapshots/andchunks/, so it never prunes these copies. - Restore: a lost forge is offered by Restore on
/forgesand in the terminal. If this host's own records of the copies are gone, the forge is found by reading the store. - Not copied: the Backups page block "Hosted forges" names every forge the last night skipped (over the 256 MiB cap, with its size) or failed. The log carries the same words as a
snapshotswarning.
This push fixes the red check:
- Feature index: the merge with main brought in
docs/features/app-page-details.mdfrom #13804, which has no row indocs/features/README.md. That made the index test fail. It now has a row under "Your apps", and this pull's ownforge-nightly-copy.mdhas one under "Backups and moving". - Slow test: the nightly-copy test in
test/snapshot-children.test.tstook 2.22 s against the 2 s budget. It is now three tests, each checking one thing: one file per forge with a single restore; an unchanged forge not re-sent and an oversized one named; a wiped store sent the copy again. No assertion changed. - Preview quota test: the "live previews" quota test hit 420 s on one shard in the check. It passes here in 8 s and this pull doesn't touch it, so I made no change for it.
bun x tsc --noEmit and bun scripts/gate.ts --fix are clean. scripts/fast.ts named 2417 test files because of the merge, too broad to run here. I ran the 40 files covering snapshots, archive, backups, nightly and the features index instead: 219 pass, 0 fail.
Left out: copies get no encryption beyond what the destination provides, and nothing prunes a forge's copy after the forge is deleted.
To try it: stop a hosted forge and move its data away, open /forges, and press Restore on its nightly copy. The Backups page names any forge the night did not copy.
🤖 Generated with Claude Code
Every hosted forge's state is written as a nightly copy (src/spawn/nightly_copy.ts, src/spawn/archive.ts). The forges and backups pages, the terminal's forges screen and the MCP forges tool now show when each forge's copy was last taken. This push merges main again and fixes the two tests that failed the check:
- "the index is one note to a row, each named in words, each once": main added its own row for
app-page-details.mdtodocs/features/README.md, and the row an earlier merge on this branch added was still there, so the note was listed twice. The branch's row is gone and main's stays. This was the cause of the failure. - "a fast-forward applies the previewed id: a parent that moved after it is not taken": this one is timing-dependent. It passed five runs in a row here, both before and after merging main, so the failure was never reproduced. The likely cause is the setup's "Next" commit to
alice/ff: it starts the forge's own follow ofbob/ff, and nothing waits for that follow to finish. Under load it can movebob/ffwhile the test is still checking that the fork did not move. Intest/take-expect.test.tsthefffork is now set to not follow right after it is forked, before that commit.
To review: src/spawn/archive.ts, src/spawn/nightly_copy.ts and test/snapshot-children.test.ts. The feature is described in docs/features/forge-nightly-copy.md.
Run here, all green: bun scripts/gate.ts --fix, bun x tsc --noEmit, bun scripts/design-lint.ts, and bun test on test/feature-orphans.test.ts, test/take-expect.test.ts, test/snapshot-children.test.ts and test/spawn-sites.test.ts (19 pass). The gate names src/web/pages/backups.ts and src/web/pages/forges.ts as changed pages that need looks.
🤖 Generated with Claude Code
Declined: main now does the job of #13837 in another way (8282ca745, "Hosted forges are in no backup (#13839)"). Merging it in would leave the nightly copying every hosted forge twice, so I aborted the merge and pushed nothing. Run log: https://forge.open-platform.sh/trevato/forge/runs/01m7hf9kb9a7s145kpmkazdsyw Left open: someone has spoken on this pull.
After each nightly snapshot, every hosted forge is now written as its own file to the same destination, so one forge can be restored without the others. The new test (
test/snapshot-children.test.ts) passes along with the archive and snapshot-service suites, 86 tests across 9 files.tsc --noEmitandscripts/gate.ts --fixare clean, and the gate's comment rewraps are committed.src/spawn/nightly_copy.ts,copyForges): each finished hosted forge goes toforge-snapshots/<name>.tar.gzin the shape an archive has, so it holds the ledger and the data directory with its repositories and keys. The forge's own database is left out of the file read and itsVACUUM INTOcopy is added instead, so the database copy is consistent while the forge keeps running. UnlikearchiveForge, nothing is stopped and nothing is removed. The last copy is recorded in<data>/archive/nightly/<name>.json.ARCHIVE_MAX_BYTESis listed as skipped with its size ("<name> skipped: N MiB, over the 256.0 MiB one file holds"), and that line is logged as a warning.src/snapshot/service.ts): the pass runs after the parent's snapshot is taken and verified, before the drill check. A failed forge copy is logged and never fails the parent's snapshot.src/spawn/archive.ts): the restore step is split out asrestoreRecord.restoreForgenow falls back to a forge's last nightly copy when there is no archive record, so the existing Restore by name in the web, MCP and terminal brings back a lost forge. The nightly record is kept after a restore; an archive's record is dropped, as before. A sharedholdingForgeguard stops an archive, a restore and a nightly copy of the same forge from running at once.The test makes two hosted forges with accounts in their databases, runs a snapshot through
startSnapshots, and checks both files are in the store. It then removes one forge, restores it alone and finds its account, while the other forge's database is untouched. It also checks that an unchanged forge is not sent again and that a forge over the cap is named with its size. It fails without the change because no nightly record exists.Left out:
Tests not run here:
scripts/fast.tsnamed 2046 files for this diff, so I picked the suites myself: the new test plusforge-archive,snapshot,snapshot-outcome,snapshot-one-core,mcp-snapshot-now,backup-retry,backup-truthandbackup-lanes. The forge's check runs the rest.Try it:
bun test test/snapshot-children.test.ts🤖 Generated with Claude Code
Closes #13832