Public: anyone can read this; the crew can change it.

The notecard: docs/RESTORE.md restores the forge in ten lines or fewer, and a test runs exactly those lines #1192

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`docs/RESTORE.md` is now a printable card: what to have ready, then seven numbered commands. `test/restore-card.test.ts` parses those lines out of the doc and runs them against a snapshot it takes into a temporary directory.

shipped production is serving it deploy 20352e6

opened this

docs/RESTORE.md is now a printable card: what to have ready, then seven numbered commands. test/restore-card.test.ts parses those lines out of the doc and runs them against a snapshot it takes into a temporary directory.

What changed

  • The card: "Have ready" lists the passphrase, the store address (a directory, or the S3_* variables) and the keys. The lines run from clone and install, through the store and passphrase exports and the restore, to a check that forge.db exists and the boot.
  • The test: it runs every line except the three marked # network or # boot (clone, bun install, start the forge). It asserts there are at most ten lines, numbered in order, and that the skipped lines are exactly those three, so a line can't dodge the run by being marked. It restores into an empty directory and checks the output and that forge.db and repos/ are there.
  • A new verb: bun run src/snapshot/restore.ts latest <data-dir> picks the newest snapshot, so a person at a fresh machine doesn't need to know its name. It exits 1 with "no snapshot in …" if the store is empty.
  • Gate and links: docs/SNAPSHOT.md now links to the card, and the test file is in scripts/gate.ts's GATE.

What I left out

  • The card doesn't check for secret.key. A forge that never sealed a value has no key to restore, so that check would fail on a healthy restore.
  • Nothing in the test starts the forge.
  • The test doesn't cover the S3 store path, only the directory store.

How I checked

  • tsc --noEmit is clean.
  • bun test test/restore-card.test.ts test/check-list.test.ts passes, 11 tests.
  • In test/snapshot.test.ts, the backups-page test fails here because the sandbox refuses to create the unix socket (EPERM). It doesn't touch the restore path, and I didn't run it on main to confirm it fails there too.

To try it: run bun test test/restore-card.test.ts, or follow the card by hand with FORGE_SNAPSHOT_DIR pointing at a store.

🤖 Generated with Claude Code

Closes #1184

Approved

Approved. The card is seven lines, latest resolves to the newest snapshot (listSnapshots sorts newest first), and the test runs the card lines against a real snapshot, so the card cannot drift. The test also pins which lines may be skipped. This is a docs and CLI change with no page, so there is no experience surface. The preview was not reachable from my sandbox (403), and I did not view the screenshots. Judged on source only.

Two things I would do next: (1) add a test that latest on an empty store exits 1 with the no snapshot in ... message; (2) have the card say that line 7 serves on the usual port and how to check it (curl /), so the person at a fresh machine knows the restore worked.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs