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

Parked opened this
Closed without merging

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.

Notes

stopped parked by the crew deploy c92b44a

opened this

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. It is named there now.

What changed

  • docs/RESTORE.md is the single printable page: five commands, plus where the passphrase and bucket credentials live. test/restore-card.test.ts holds those commands to the ones the drill runs.
  • src/snapshot/drill.ts restores the newest snapshot through restoreLatest, 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.ts builds 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.
  • A timestamp-named migration, src/core/migrations/20261016000000-drill-counts.ts, carries the new drill counts.

Checks: bun x tsc --noEmit printed 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, and check-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.md and run its restore command into an empty directory.

🤖 Generated with Claude Code

Closes #1986

3 earlier comments · 2 events
Changes requested — before the latest push

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.

commented

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_LINE constant, 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 calls restore.ts, that it starts with bun run src/snapshot/restore.ts latest <data-dir>, and that drill.ts restores through restoreLatest. The card's wording is now "its line 3 is the CLI whose latest goes through restoreLatest, the same function the drill restores with."
  • Pre-migration drill rows: the migration now adds the users, pulls, apps and sealed_opens columns without defaults, so an old row holds NULL, meaning "not recorded". lastDrill marks such a row predatesCounts. countsSay then 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 to countsSay(drill), and both Backups doors use it. test/drill-legacy-row.test.ts covers this and is named in GATE.
  • Typed error: restoreLatest now throws NoSnapshotError, and the CLI checks it with instanceof. The same new test file asserts it.
  • Card line 5: I removed the echo line. 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 — before the latest push

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:

  1. In RESTORE.md line 1, command -v git bun || curl ... | bash only 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.
  2. 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 for snapshotId, 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.
commented

The full gate on land was red and named no test; the pull is open again.

commented

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 in test/restore-card.test.ts has the new line.
  • Source-grep test: I removed the toContain("restoreLatest") check from test/restore-card.test.ts. test/snapshot-drill.test.ts already checks that the drill restores through restoreLatest.
  • Snapshot id race: runDrill still lists first, so an empty store or a failed listing is red at fetch as before. After the restore it records restored.manifest.name, not the listed name. A new test has the restore return a different name and checks the recorded id follows it.
commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs