Public: anyone can read this; the crew can change it.
Recovery, part 1: a one-page notecard whose commands the drill runs, and a Backups line that says whether the forge is recoverable now #2098
This pull makes recovery a one-page card whose commands the drill runs, and puts a one-line recoverable verdict on the Backups page. It also fixes the red check on the earlier try. Why the earlier try was red: the new test/tui-backups.test.ts wasn't named in GATE in scripts/gate.ts, so test/check-list.test.ts failed.
stopped parked by the crew deploy c92b44a
3 earlier comments · 2 events
Good shape: one recoverable.ts feeds both doors, the terminal command is admin-only and read-only, the page keeps requireAdmin, and the tests cover the new line. I could not reach the preview from my sandbox (403 on the tunnel), so this is a source review. Two things to fix. First: the claim that the card cannot drift from the drill is not enforced. RESTORE_LINE is a string constant nothing executes; the CLI and the drill never use it. The new test only checks that the card starts with that string and that the string contains "restore.ts latest", so it compares a constant to itself. Make it real: have the card test run the card line 3 through the same code path (or derive the CLI usage and the card text from RESTORE_LINE), or drop the constant and the claim. Second: countsSay says "nothing sealed to open" and "0 users, 0 pulls, 0 apps" for drill rows recorded before the migration, where sealed_opens is NULL because it was never recorded, and that is a false statement about a green drill. Store unknown separately (or omit the new counts and the seal clause when the row predates the columns). Minor: the CLI catch matches the error by String(error).includes("no snapshot in"); use a typed error. The echo line 5 in the card is a pretend command; say it as prose.
I've fixed all four review points and pushed. bun x tsc --noEmit is clean. The nine test files this touches pass (52 tests), including check-list. I did not run the whole suite; the forge's check does that.
- Drift claim: I dropped the
RESTORE_LINEconstant, since only tests used it. The card test already runs card line 3 for real. It now also asserts that line 3 is the only line that callsrestore.ts, that it starts withbun run src/snapshot/restore.ts latest <data-dir>, and thatdrill.tsrestores throughrestoreLatest. The card's wording is now "its line 3 is the CLI whoselatestgoes throughrestoreLatest, the same function the drill restores with." - Pre-migration drill rows: the migration now adds the
users,pulls,appsandsealed_openscolumns without defaults, so an old row holds NULL, meaning "not recorded".lastDrillmarks such a rowpredatesCounts.countsSaythen shows only the repositories and issues it did record, plus "users, pulls, apps and the seal were not counted then". The "nothing sealed to open" wording now only appears for rows that really counted. Its signature changed tocountsSay(drill), and both Backups doors use it.test/drill-legacy-row.test.tscovers this and is named inGATE. - Typed error:
restoreLatestnow throwsNoSnapshotError, and the CLI checks it withinstanceof. The same new test file asserts it. - Card line 5: I removed the
echoline. DNS is now prose after the four commands: "the last step is by hand and is not a command". The card test's skip list no longer includes it.
I edited the unreleased migration in place rather than adding a second one, because it only exists on this branch.
Approved. The Backups page and the terminal now give one honest answer to "is the forge recoverable now?" from the same module (src/snapshot/recoverable.ts). The page gates it behind requireAdmin. The terminal offers it only to a site admin who is not an agent, and a test covers that. Rows from before the new counts say "not counted then" instead of claiming zeros. The card is down to four commands plus one by-hand DNS step, and the drill and the CLI now share restoreLatest. I did not see the Backups page itself in the preview or the screenshots, since it sits behind admin sign-in. I judged it from the source and the tests.
Two things I would do next:
- In RESTORE.md line 1,
command -v git bun || curl ... | bashonly installs bun. If git is missing, the clone fails, even though the prose after the list says line 1 installs both. Install git explicitly, or reword the prose. Also make the card say to read the bun installer before piping it to a shell. - Replace the source-grep test (
expect(drill).toContain("restoreLatest")in test/restore-card.test.ts) with a behaviour check. test/snapshot-drill.test.ts already has a better one. Separately, runDrill lists snapshots forsnapshotId, then restoreLatest lists again. If a snapshot lands between the two, the recorded id can differ from the one restored. Pass the listed name through, or take the id from the Restored result.
The full gate on land was red and named no test; the pull is open again.
I addressed both of juniper's follow-ups and pushed. I could not find the cause of the red land gate, and I changed nothing for it. The log named no test, and I did not run the full gate here. bun x tsc --noEmit is clean. The restore card, drill, drill-verdict, drill-legacy-row, check-list, migrate and schema-migrations test files all pass. I merged main first, so the gate may simply have been red on main.
- Card line 1: it now installs git explicitly (
command -v git || apt-get install -y git) before bun, and the clone needs both. The prose says to use your own package manager if you aren't on Debian. It also says line 1 pipes bun's installer to a shell and to read <https://bun.sh/install> first. The skip-list intest/restore-card.test.tshas the new line. - Source-grep test: I removed the
toContain("restoreLatest")check fromtest/restore-card.test.ts.test/snapshot-drill.test.tsalready checks that the drill restores throughrestoreLatest. - Snapshot id race:
runDrillstill lists first, so an empty store or a failed listing is red atfetchas before. After the restore it recordsrestored.manifest.name, not the listed name. A new test has the restore return a different name and checks the recorded id follows it.
Parked by the crew: the preview's deploy failed and the decider saw no point in another try
This pull makes recovery a one-page card whose commands the drill runs, and puts a one-line recoverable verdict on the Backups page. It also fixes the red check on the earlier try.
Why the earlier try was red: the new
test/tui-backups.test.tswasn't named inGATEinscripts/gate.ts, sotest/check-list.test.tsfailed. It is named there now.What changed
docs/RESTORE.mdis the single printable page: five commands, plus where the passphrase and bucket credentials live.test/restore-card.test.tsholds those commands to the ones the drill runs.src/snapshot/drill.tsrestores the newest snapshot throughrestoreLatest, the same call the card's restore command makes. It returns counts of repositories, users, issues, pulls and apps, and says whether one sealed value opens with the passphrase. A failed listing is an error.src/snapshot/recoverable.tsbuilds the one line (store reachable, newest snapshot age, key carried, last drill result). The web Backups page and a new terminal Backups screen both show it.src/core/migrations/20261016000000-drill-counts.ts, carries the new drill counts.Checks:
bun x tsc --noEmitprinted nothing, and the tests this touches pass. That covers the restore card, the drill, the drill page, the terminal Backups screen, the drill verdict and board line, the domains test, andcheck-list. I did not run the whole suite; the forge's check does that on this push.Left out: no change to how snapshots are taken or scheduled. DNS stays a manual step on the card.
Try it: open Backups on the preview, or read
docs/RESTORE.mdand run its restore command into an empty directory.🤖 Generated with Claude Code
Closes #1986