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

Recovery, part 3: the restore drill runs every week on its own and its result is kept #2164

Merged opened this

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

Merged

The weekly drill now runs on its own once per Sunday 09:00 UTC slot, and a restore whose counts differ from the snapshot's goes red. `bun x tsc --noEmit` is clean and the new tests pass, as do the existing drill, snapshot, backups and `check-list` tests, apart from two failures noted below. I did not run the full suite.

shipped production is serving it deploy 78f82e5

opened this

The weekly drill now runs on its own once per Sunday 09:00 UTC slot, and a restore whose counts differ from the snapshot's goes red. bun x tsc --noEmit is clean and the new tests pass, as do the existing drill, snapshot, backups and check-list tests, apart from two failures noted below. I did not run the full suite.

What was already on main: the Sunday timer, the drill table, the board line and push for a red drill, and a scratch directory under FORGE_APP_DATA/drill that the drill removes afterwards.

What changed

  • Catch-up and no double run: the old timer ran on every Sunday boot and did nothing for a forge that was down at 09:00. Now a drill is owed when none has been kept since the latest Sunday 09:00 UTC. The timer runs it then, and so does a check five minutes after boot. A restart after the drill has been kept runs nothing (src/snapshot/due.ts, drillIfDue in src/snapshot/service.ts).
  • "Counts matched" now means something: a snapshot's manifest keeps the five counts of its database copy: repositories, issues, users, pulls and apps (src/snapshot/counts.ts, src/snapshot/snapshot.ts). The drill compares its restore against them. A difference is red at count, with a reason like users 7 became 1, and it reuses the existing board line and push.
  • Backups page: the green line reads "Last drill: <date>, <ms> ms, all counts matched — snapshot …, key opened — counts".
  • Docs and tests: one README paragraph. test/drill-weekly.test.ts covers three things:

- the slot is owed once and not twice; - the service runs a due drill once; - a mismatched count is red, raises the line, and the scratch directory is gone afterwards.

Left out

  • Snapshots taken before this change have no kept counts, so they are not compared.
  • A green drill's page line says "all counts matched" without checking whether the snapshot carried counts. The older snapshots above are the case.
  • There is no new migration: the drill table already holds everything.

Red tests unrelated to this change: snapshot-destination > a failed test-connection is one sentence and leaks no key and … the page says a snapshot is being taken, even before there is a first one fail in this sandbox. I ran them with my changes stashed and they fail the same way.

Closes #1988

Approved

Approved. The weekly slot logic is small and pure (due.ts), the drill runs once per Sunday slot and catches up 5 minutes after waking, the manifest keeps counts, a mismatch is red at count with a sentence naming the count, and the tests would fail without each piece. No new input, route or dependency, so the security floor is untouched. I could not fetch the preview from my sandbox (network denied), so I judged the Backups line from source only: it is one plain sentence and escaped.

Two things I would do next:

  1. The catch-up and weekly runs are invisible while running; the Backups page only shows the result afterwards. A one-line "drill running" state would stop a person pressing the button a second time.
  2. Add the same one-line last-drill result to the terminal/TUI backups view if it does not already show it, so both doors read the same sentence.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs