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

Recovery on one page: docs/RECOVERY.md with the restore command, the boot on a side port, the manual tarball route, and a weekly drill that posts its result #1222

Closed opened this in answer to
Closed without merging

Adds the one-page recovery card (docs/RECOVERY.md), a test that keeps the card matched to the code, and a weekly restore drill that posts its result. The card. It covers: Where snapshots live: the snapshots/ / prefix in the bucket named by S3BUCKET (region S3REGION, Backblaze B2).

Notes

stopped closed without shipping deploy 880c9e0

opened this

Adds the one-page recovery card (docs/RECOVERY.md), a test that keeps the card matched to the code, and a weekly restore drill that posts its result.

The card. It covers:

  • Where snapshots live: the snapshots/<name>/ prefix in the bucket named by S3_BUCKET (region S3_REGION, Backblaze B2).
  • What a restore needs: the five S3_* variables and FORGE_SNAPSHOT_PASSPHRASE.
  • The restore command: bun run src/snapshot/restore.ts <snapshot-name> <data-dir>.
  • The boot on port 18080 with crew and checks off, taken from the boot proof on #1147.
  • What to look at first: /api/v1/health, then the home page as the owner, then one repository's issues.
  • The manual tarball route (manual/<stamp>/, openssl enc -d -aes-256-cbc -pbkdf2 -pass file:… then tar -x), and when to prefer it.
  • What a snapshot does not bring back: the forge's own environment. Sealed values and app variables only open with the passphrase. Crew clones, checks and previews are rebuilt.

The bucket and region names aren't in the repository, so the card points at the variables rather than spelling the values out. The owner may want to write the real names on the printed copy.

test/recovery-doc.test.ts fails if:

  • src/snapshot/store.ts reads a variable the card doesn't name;
  • the restore or drill command differs from the usage line its script prints;
  • a variable in the boot line isn't one src/main.ts reads;
  • the drill workflow is missing;
  • the card grows past 66 lines (one printed side).

src/snapshot/drill.ts restores the newest snapshot into a scratch directory, starts a quiet forge on it on a side port, and reads health, the home page and the counts (repositories, users, issues, pulls, apps).

  • The quiet forge sends no webhooks, syncs no origins, and runs no apps or crew, so it can't act as a second forge.
  • It posts the result as a comment on #1147, the recovery issue.
  • A failed drill also opens an issue assigned to DRILL_OWNER (that is the inbox card), and the script exits 1.
  • .forgejo/workflows/restore-drill.yml runs it every Sunday at 03:00 UTC, or on demand.
  • test/recovery-drill.test.ts covers a passing drill, an empty store, a wrong passphrase and a missing one, the comment and failure-issue calls, and how the environment variables are checked.

Both new test files are added to the gate in scripts/gate.ts.

What to look at:

  • Whether the drill can finish on that runner: the 2026-10-13 restore took 81 minutes, but check.yml says the isolated runner cuts a job at about 30 minutes. The drill will likely be cut off until restore fetches in parallel (the counterpart of #1193 on the download side). That needs settling before the schedule means anything.
  • Missing Actions secrets: the workflow needs the five S3_*, FORGE_SNAPSHOT_PASSPHRASE and DRILL_FORGE_TOKEN, and none of them are set yet.
  • One test fails only in my sandbox: typecheck is clean, the doc test passes, and 3 of the 4 drill tests pass here. The fourth, the full restore-and-boot case, can't pass in this sandbox because it blocks the forge's unix socket. test/reports.test.ts fails here the same way, so the forge's check run is the first real run of that case.

Not done: the Backups-page line and showing drill results in the dataset. Those belong to #1147.

To try it, read docs/RECOVERY.md. Then, with the bucket variables and passphrase exported, run bun run src/snapshot/drill.ts "$(mktemp -d)". It prints its report, and posts it only when DRILL_FORGE_URL and DRILL_FORGE_TOKEN are set.

🤖 Generated with Claude Code

Closes #1219

3 earlier comments · 1 event
commented

mason: #1192 just landed docs/RESTORE.md (the ten-line notecard from the planner's issue). One page, not two: fold your docs/RECOVERY.md into docs/RESTORE.md (keep that name, keep it printable on one side), keep the drill script and the weekly workflow from this pull, and point test/recovery-doc.test.ts at the one file.

commented

Recovery now lives on one card, docs/RESTORE.md, the file from #1192. docs/RECOVERY.md has been folded into it and deleted. The drill (src/snapshot/drill.ts) and the weekly workflow (.forgejo/workflows/restore-drill.yml) stay as they were.

What moved into docs/RESTORE.md. The card from #1192 keeps its seven numbered lines exactly; test/restore-card.test.ts runs them, so I added nothing in that numbered format. Around them it gains:

  • Have ready: a note on what the bucket holds (snapshots/<name>/, newest fourteen kept), and what no snapshot carries (the environment, the passphrase, the crew's clones, checks and previews).
  • Timing: the 81-minute restore time measured on 2026-10-13, under line 5.
  • Before line 7, look on a side port: the quiet boot command (no crew, no checks), the three things to check in order, and only then the switch over.
  • The manual tarball, when restore.ts cannot: the openssl … | tar route.
  • The weekly drill: what runs on Sundays and where the result is posted (#1147).

The card is 66 lines, which still prints on one side.

Tests.

  • test/recovery-doc.test.ts now reads docs/RESTORE.md. It still checks the bucket and passphrase variables, the side-port boot's variables against main.ts, the drill's usage line, the workflow's schedule, and the 66-line limit.
  • I removed its check that the doc quotes restore.ts's usage line word for word. Since #1192 the usage reads <snapshot-name|latest> and the card uses latest, and the restore line is already covered by test/restore-card.test.ts, which runs it.

References. src/snapshot/drill.ts (its comment and the body of the issue a failed drill opens), the workflow comment and the README now point at docs/RESTORE.md.

Merge. origin/main is merged in, not rebased, because force pushes are refused.

Checks. The type check passes, and so do recovery-doc and restore-card. test/recovery-drill.test.ts fails here: my sandbox won't let the drill's booted forge open its socket (EPERM on listen). That code is unchanged, and the test fails the same way without this commit, so the forge's run of the check is the real verdict.

To try it: read docs/RESTORE.md printed, or run bun test test/recovery-doc.test.ts test/restore-card.test.ts.

🤖 Generated with Claude Code

Changes requested — before the latest push

The drill itself is well built: it restores, boots with only createApp/reconcile/serve, reads counts, posts, and is tested. But the side-port boot line on the recovery card does not do what it says. One fix first.

  1. docs/RESTORE.md, the boot line: FORGE_CREW_CONCURRENCY=0 FORGE_CHECKS_CONCURRENCY=0 does not quiet anything. In src/main.ts:308 positive() returns the fallback for any value that is not > 0, so 0 becomes 1 for checks (main.ts:233) and 1 or 2 for the crew (main.ts:267). The card says "no crew, no checks", but the restored copy would start both. That is the second-forge-acting-as-the-first hazard that drill.ts documents and avoids. A person following this card at 3am gets it wrong. Fix: either give main.ts a real quiet switch (for example 0 honoured, with a test) or have the card use a boot that really is quiet, and say so. Then change test/recovery-doc.test.ts to assert the boot line runs quiet, not just that the variable names appear in main.ts.
  2. docs/RESTORE.md, manual tarball section: nothing in src/, scripts/ or docs/ writes manual/<stamp>/ or its README, so the section describes a route this pull cannot show exists. Point at what produces those files, or say plainly that they are placed by hand. The openssl line is also untested.

Smaller: DRILL_ISSUE 1147 is hard-coded in the workflow and the card. That is acceptable, but name what #1147 is.

commented

Recovery on one page: docs/RESTORE.md holds the restore lines, a quiet look on a side port, the manual tarball route, and the weekly drill that posts its result to #1147.

What changed after review

  • Side-port boot (finding 1). The card used to boot with FORGE_CREW_CONCURRENCY=0 FORGE_CHECKS_CONCURRENCY=0. main.ts treats any value that is not above zero as "use the default", so that line started the crew and checks. The card now uses bun run src/snapshot/look.ts <data-dir> 18080. src/snapshot/look.ts is the drill's quiet boot moved into its own module: createApp, reconcile and serve on 127.0.0.1, and nothing else. It does not start the crew, checks, apps, webhook delivery, origin sync or nightly snapshots. drill.ts now calls the same function, so the card and the drill boot the same way.
    • I chose not to make 0 mean "off" in main.ts. That would change what an existing setting means for every forge that has it set. A separate quiet boot means nobody has to remember the right combination of variables at 3am.
  • Tests for the quiet boot. test/restore-card.test.ts has a webhook pointing at a local receiver, with a delivery queued when the snapshot is taken. It restores using the card's own lines, then runs the card's look line as a real process. It checks that health answers 200, that the receiver got nothing, and that the delivery is still pending. main.ts would send that delivery as it boots, so a look that wasn't quiet would fail here.
    • test/recovery-doc.test.ts no longer just checks that variable names appear in main.ts. It checks that the card's look line matches look.ts's usage line, that src/main.ts is booted only by line 7, and that look.ts imports only app.ts, core/reconcile.ts and http/server.ts.
  • Manual tarball (finding 2). The card now says plainly that nothing in the forge writes manual/<stamp>/: an operator puts tarballs there by hand. I removed the claim that a README sits beside them. A new test seals a tarball with the same cipher, key derivation and passphrase file, runs the card's openssl line on it, and checks that the file comes out intact.
  • #1147 is named. The card, the workflow and the default in drill.ts now say what #1147 is: the recovery issue, "Recovery you can print on a notecard".

Testing

  • The typecheck is clean.
  • The doc tests (including the openssl round-trip) and the card's restore-lines test pass.
  • The new look test, and the drill's existing boot test, could not run here. This sandbox refuses to open the forge's local socket (EPERM), and that drill test fails the same way on main here. The forge's check is the first real run of both, so look at those two results first.

How to try it: restore with lines 1–6 of the card, then run bun run src/snapshot/look.ts <data-dir> 18080 and open http://127.0.0.1:18080/api/v1/health. Ctrl-C stops it.

🤖 Generated with Claude Code

commented

Parked by the crew: the check failed ("the gate's list > every test/*.test.ts is in exactly one list, and every entry exists") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs