Public: anyone can read this; the crew can change it.
The restore drill restores one hosted forge from its backup file and proves its database and repositories open #14000
The weekly restore drill now restores one hosted forge from the snapshot it just drilled, and checks that the forge's database and repositories are sound. #13832 (hosted forges written to the backup) is already on main as #13839, so this builds on its restoreHosted.
stopped closed without shipping deploy 572a380
7 earlier comments
<!-- look-pages d47ed17c1c6e --> Look pages for d47ed17, from the gate:
look pages (none): "Looks: /settings/backups" is not a page of app.looks in forge.json; this pull changes src/web/pages/backups.ts but the forge could not trace the route of /settings/security/controls (an inline or wrapped handler), so it could not infer a page; the reviewer decides. A "Looks: <path>" line naming the nearest page, or a "No look: <why>" line (10+ characters), says it
After the restore drill proves the parent's newest snapshot, it now restores one hosted forge on its own from that same snapshot (#13919). That forge's database must pass PRAGMA integrity_check, and each of its repositories must pass git fsck --connectivity-only.
- Which forge: the one whose last green drill is oldest; forges never drilled go first. The dates are kept in
drill/hosted.json. - When it runs: only when every earlier step passed, inside the drill's own time budget.
- When it fails: the drill goes red at step
hosted. The reason names the forge, the step that broke (unpack,integrityorfsck) and the cause. - When there is nothing to restore: one line says the hosted restore was skipped, and the drill stays green.
The result shows in four places, each naming the forge, its size and the restore time in seconds:
- the Backups card at
/settings/backups; - the terminal's Resilience screen, in a "Last drill:" line under the backup verdict (
hostedDrillLines(db)insrc/tui/screens/resilience.ts); - the recovery comment;
docs/features/hosted-backup.md.
Two gate waivers are in the commit messages and are worth a look:
No door:the "both doors" rule only counts a newly added screen or how-to file. This step belongs on the existing Resilience screen and in the existing how-to, so it adds neither.No look:/settings/backupsis not one of thelookspages inforge.json, so no screenshot page is named. The test checks the line's wording instead.
test/drill-hosted.test.ts covers a green restore, a failed unpack, the skip line, which forge is picked, the database and fsck checks, the hosted step kept with the drill, and the terminal line matching the card's words. It passes, as do bun x tsc --noEmit and bun scripts/gate.ts; test/backup-truth.test.ts also passed earlier in this pull.
To try it, open /settings/backups and press Run a drill, or on the Resilience screen press r then y. When the drill ends, the last-drill line names the hosted forge with its size and seconds, or says the hosted restore was skipped.
🤖 Generated with Claude Code
Nothing new to push. That note is about commit d47ed17, which named /settings/backups in a Looks: line, and that page isn't one of the app.looks pages in forge.json. The commit after it, 6b6df0f, already has the answer the gate asks for:
No look: the hosted-drill words land on /settings/backups, which is not among forge.json's looks pages; the test asserts the line.
On the branch head (6b6df0f), bun scripts/gate.ts reports no look-pages finding and no other failure, only the long-comment note.
I didn't add /settings/backups to forge.json looks. That would add a screenshot to every pull's look pages for one line of text, and test/drill-hosted.test.ts already checks that text. The nearest listed page, /resilience, doesn't show the drill, so naming it would be wrong. If you want the Backups card screenshotted, say so and I'll add it to looks and looksAsOwner in a separate change.
What the pull does: after the restore drill proves the parent's newest snapshot, it restores one hosted forge on its own from that same snapshot (#13919). The database has to pass PRAGMA integrity_check, and each repository has to pass git fsck --connectivity-only.
- Which forge: the one whose last green drill is oldest; forges never drilled go first. The dates are kept in
drill/hosted.json. - When it runs: only after every earlier step passed, within the drill's own time budget.
- When it fails: the drill goes red at step
hosted. The reason names the forge, the step that broke (unpack,integrityorfsck) and the cause. - When there's nothing to restore: if no hosted forge is whole in the snapshot, one line says the hosted restore was skipped and the drill stays green.
The forge, its size and the restore time in seconds show in four places:
- the Backups card;
- a "Last drill:" line on the terminal's Resilience screen (
hostedDrillLines(db)insrc/tui/screens/resilience.ts); - the recovery comment;
docs/features/hosted-backup.md.
test/drill-hosted.test.ts covers a green restore, a failed unpack, the skip line, which forge is picked, the database and fsck checks, and the hosted step kept with the drill. It also checks that the terminal line uses the same words as the Backups card.
To try it: open /settings/backups and press Run a drill, or press r then y on the Resilience screen. When the drill ends, the last-drill line names the hosted forge it restored with its size and seconds, or says the hosted restore was skipped.
🤖 Generated with Claude Code
After it proves the parent's newest snapshot, the weekly restore drill now also restores one hosted forge from the same snapshot into its scratch directory (#13919). It picks the forge whose last green drill is oldest, and a forge never drilled goes first; <data>/drill/hosted.json keeps the dates. Then it checks two things:
- Database: opened read-only, it must answer
PRAGMA integrity_checkwithok. - Repositories: each one must pass
git fsck --connectivity-only.
The hosted restore uses the drill's own time budget and runs only when every earlier step passed.
Red drill: the drill fails at a new step, hosted. The reason names the forge and where it stopped: unpack, integrity or fsck. It is paged like any red drill, and the next drill tries the same forge again.
Green drill: the Backups card and the terminal's Resilience screen ("Last drill:") name the forge, its size and the seconds it took. When no hosted forge is whole in the snapshot, one line says the hosted restore was skipped and the drill stays green.
Places to look:
src/snapshot/hosted_drill.ts: picks the forge, restores it and checks it.src/snapshot/drill.ts: where the drill calls it.
Docs:
docs/RECOVERY.mdgets a two-linehostedentry, and its "When the drill is red" paragraph is shorter, so the page still fits the two printed sidestest/recovery-doc.test.tsholds it to.- The details and the fix (restore the forge by hand with
--forge NAME) are indocs/features/hosted-backup.md.
test/worker-database-opens.test.ts now lists hosted_drill.ts's one read-only open. The open runs on the serving thread; a Worker reaches the file only through the page layer's imports and never calls it. That is a new entry for new code; no existing test was changed.
test/recovery-doc.test.ts, test/worker-database-opens.test.ts and test/drill-hosted.test.ts pass, as do bun scripts/gate.ts --fix and bun x tsc --noEmit.
To try it: open /settings/backups and press Run a drill. When it ends, the last-drill line names the hosted forge it restored, its size and the seconds it took, or says the hosted restore was skipped. In the terminal, press r then y on the Resilience screen.
🤖 Generated with Claude Code
Left #13919 open: 5 unticked items remain (The weekly drill (src/snapshot/drill.ts, drill_child.ts) picks the hosted forge with the oldest drilled date, unpacks its file from the backup destination into a scratch directory under FORGE_APP_DATA, runs PRAGMA integrity_check on its database and git fsck --connectivity-only on each of its repositories, then removes the scratch.; The drill's card names the forge, its size and the restore time in seconds, not raw ms.; A restore that fails is a failure named with its cause (which forge, which step), paged once.; …).
The weekly restore drill now restores one hosted forge from the snapshot it just drilled, and checks that the forge's database and repositories are sound. #13832 (hosted forges written to the backup) is already on main as #13839, so this builds on its
restoreHosted.What changed
src/snapshot/hosted_drill.tsruns after the health step passes. It uses the drill's remaining budget (the samewithin/left()clock) and stops at the first failure.<data>/drill/hosted.json. A red forge keeps its old date, so the next drill tries the same forge again.drill/restore-*/hosted. Its database must passPRAGMA integrity_check(5)and each repository must passgit fsck --connectivity-only. The scratch is then removed with the rest of the drill's.hosted. Its reason readshosted forge NAME: unpack|integrity|fsck failed: <cause>. It reaches the page through the existingdrillNeedkeyred:<at>, so each red drill is paged once.restoreHostednow also returns the repository directories it cloned (repoDirs), which the fsck step walks.docs/RECOVERY.mdgets ahostedentry, whichtest/recovery-red-drill.test.tsrequires for every drill step.docs/features/hosted-backup.mdgets a section on the drill.Not done
integrityandfsckfailures are tested throughcheckDatabaseandcheckRepodirectly, not end-to-end. A snapshot whose file passes its hash but holds a broken database can't be made throughtakeSnapshot.Tests:
test/drill-hosted.test.tsbuilds a fixture hosted forge and runsrunDrillagainst a real snapshot:hosted/unpack, namingkid, with no date recorded.Both the green and the corrupted case fail without this change.
bun x tsc --noEmit,bun scripts/gate.ts --fixandbun scripts/design-lint.tsare clean.scripts/fast.tsnamed 2342 files (about 198 min), so I ran the 74 drill, hosted, backups, verdict, restore and recovery test files instead: they pass (one RECOVERY.md doc test failed until I added thehostedentry). The desk hold says production is rolling; this pull doesn't touch production until it is merged.To try it: open
/settings/backupsand press "Run a drill". When it ends, the last-drill line names the hosted forge it restored, its size and seconds, or says the hosted restore was skipped. For a red case, seebun test test/drill-hosted.test.ts.🤖 Generated with Claude Code
Closes #13919