Hosted forges in the nightly backup
Each forge this one hosts goes into the nightly snapshot (#13819), under children/<name>/.
| What | Where in the snapshot |
|---|---|
| Database (a consistent copy, taken while it runs) | forge.db |
Repositories, every ref but refs/upstream/* (what a forge only mirrors from its parent, fetched again every hour it is awake: with those in, an awake fork went up whole every night) | repos/<owner>/<name>.bundle |
| SSH host keys | ssh/ |
Its key, wrapped under FORGE_SNAPSHOT_PASSPHRASE | secret.key.wrapped (without a passphrase the key stays home) |
| Every app's production data | alongside |
| This forge's own record of it | ledger.json |
Its history: run logs, drop, cost ledger, parent.json, plan.json | runs/, drop/, ledger/, alongside |
| 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 |
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.
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.
Read from inside the forge's directory only
A hosted forge's directory is the forge's own to write, and its host reads it for the snapshot from outside the forge's cell (copyHosted, src/snapshot/hosted.ts). So the copy stays inside it:
- No link is followed. A file is kept only if the file that was opened is inside the forge's own directory; anything else at the name is passed over.
- The database is copied in a process of its own (
src/snapshot/hosted_copy.ts), which proves the same of the files SQLite opened and refuses the copy otherwise: the forge is then left out, by name, with "its database is not a file of its own". That process, not the serving thread, reads what the copy lists. - Git runs on a repository only after it was read for what git would run on the host or follow out of the forge: a hook or configuration key that names a command, a link, objects borrowed from outside the forge. One that is refused is left out, and the forge's entry in
hostednames it with why (absent). The rest of the forge is kept.
Where it shows
- Backups page: how many forges the newest backup kept, and how many were left out.
- Resilience screen (terminal): the same line, then one line per forge: kept H h ago, or left out and why.
/forges: each row, "kept <age> ago" (under an hour, hours, then days) or "never kept" when no backup holds it, or why the newest left it out.forgesMCP tool andGET /api/v1/forges: the same words askepton each made forge.- MCP
backups:hosted, the same sentence and each forge's line. - The backup verdict (home, vitals, MCP
backups, the Resilience screen): a lane whose newest snapshot left a hosted forge out is red and names it with why. A repository a forge's copy lacks is said there too, as an unknown and not an alarm.
The drill restores one
Each restore drill, after the host itself, restores one hosted forge alone from the same snapshot (the next one each day and each week, src/snapshot/drill_hosted.ts) and proves it opens: its ledger reads and names it, its database passes SQLite's integrity check, and every repository its copy holds comes back and passes git fsck. The verdict says which forge ("…passed, with hosted forge glint (1 of 17)"). One that does not come back fails the drill at the step forge, by name (RECOVERY.md).
- Web:
/settings/backups, press Run a drill; when it ends, the last-drill line says "Restored NAME (1 of N hosted forges): SIZE, K repositories, S seconds, checks passed." in whole seconds. Terminal: the Resilience screen's "Last drill:" line under the verdict says the same, and so does the recovery issue's comment (- hosted:). - A forge that hosts none, or whose snapshot left every hosted forge out, says "No hosted forges to drill." in one line; the drill stays green.
- Red at
forge: the reason names the forge and what did not hold (a missing chunk, the integrity check, a repository'sgit fsck, its ledger); it is paged once like every red drill.
Restore one forge
Into an empty data directory; children/<bodyId>/ and spawn/<name>.json are written there:
bun run src/snapshot/restore.ts latest <data-dir> --forge <name>
A whole restore of the parent leaves children/ out; restore each forge this way.