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

docs/RECOVERY.md is the one page a person reads at 3 a.m., and a test keeps it true to src/snapshot #1497

opened this

Merged 52d 2h ago, live in production

docs/RECOVERY.md is written, with a test that keeps it true to src/snapshot, and it's pushed. bun test test/recovery-doc.test.ts test/check-list.test.ts passes in the sandbox (12 tests). I did not run the type check or the full gate; the forge runs those on this push.

Notes

opened this

docs/RECOVERY.md is written, with a test that keeps it true to src/snapshot, and it's pushed. bun test test/recovery-doc.test.ts test/check-list.test.ts passes in the sandbox (12 tests). I did not run the type check or the full gate; the forge runs those on this push.

What changed

  • docs/RECOVERY.md (new, about 60 lines, meant to fit one printed side) has these sections:
    • Where snapshots live.
    • The five S3_* variables, plus FORGE_SNAPSHOT_PASSPHRASE from the owner's safe.
    • Route 1, the restore command, with a side-port boot (PORT=3999 FORGE_SSH_PORT=0) and a first-look checklist: /api/v1/health, the home as the owner, one repository's issues.
    • Route 2, the manual tarball under manual/<stamp>/, opened with openssl enc -d -aes-256-cbc -pbkdf2 -pass file:<passphrase> then untarred, with when to prefer it.
    • What a snapshot does not hold: sealed values, app variables, the crew's clones.
  • test/recovery-doc.test.ts (new) has four tests:
    • It fails if the doc misses any S3_* variable that src/snapshot/store.ts reads, or FORGE_SNAPSHOT_PASSPHRASE.
    • It fails if the doc's restore command differs from the usage line restore.ts prints.
    • It checks the doc keeps the manual route, the health path and the "NOT hold" section.
    • It checks the doc stays under 70 lines.
  • scripts/gate.ts lists the new test in GATE.

Choices and gaps

  • The restore command in the doc is bun run src/snapshot/restore.ts <snapshot-name|latest> <data-dir>, because that is what restore.ts prints. The issue's wording was <snapshot-name> <empty data dir>.
  • The doc says "the bucket named by S3_BUCKET" and gives the snapshots/ prefix. It doesn't hard-code a bucket name or region, since I couldn't read those from the repository.
  • The manual/<stamp>/ route comes from the issue. Nothing in src creates or reads it, so the tarball steps (including the file name inside the stamp directory) are untested and unconfirmed against a real tarball.
  • I did not run the boot or health steps here.
  • docs/RESTORE.md (the restore card) is untouched. The two pages overlap on the restore command.

Closes #1480

commented

docs/RECOVERY.md Route 2 now describes only what src/snapshot writes, and the test checks the doc against that code. You were right that the old Route 2 described a tarball nothing creates. bun test test/recovery-doc.test.ts passes (6 tests) and tsc --noEmit is clean. I did not run the whole suite, since the forge runs it on push.

What changed

  • Route 2: it is now "the objects by hand". It lists what lives under snapshots/<name>/:
    • manifest.json
    • forge.db
    • secret.key.wrapped
    • ssh/…
    • repos/<owner>/<repo>.bundle
    • apps/<id>/production/data/…
    • runs/…

    It says to rebuild each repository with git clone --mirror into <data-dir>/repos/<owner>/<repo>.git, the layout restore.ts writes. The manual/<stamp>/ route and the openssl command are gone. The doc also says the wrapped key is scrypt + AES-GCM, so only restore.ts opens it and a hand restore sets the sealed values again.

  • latest: the doc now says it is a name restore.ts accepts for the newest snapshot, not an object in the bucket.
  • "Sealed values / app variables": both are true. app_env.ts seals app variables at rest, and restore.ts lists the sealed names it cannot open.
  • "Crew's clones": true. The snapshot.ts header lists clones among what stays out.
  • Test: it reads SNAPSHOT_PREFIX and WRAPPED_KEY from source and checks the doc uses them. It checks snapshot.ts really writes each path in the layout, that restore.ts accepts latest, and that the clones and sealed-values claims hold in source. It also asserts the doc contains no manual/ or openssl. The usage-line and S3_* checks and the 70-line limit are unchanged.

Left out

  • A hand restore does not reinstall the git hooks. restore.ts does that, and the doc does not claim otherwise.
  • The layout checks are substring checks on snapshot.ts, not a run of takeSnapshot. A fixture-backed test would be stronger but is heavier.

To try it, read docs/RECOVERY.md and run bun test test/recovery-doc.test.ts.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs