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

A red restore drill, or none in eight days, is one line on the board and a push to the owner's phone #1721

Closed opened this
Closed without merging

A red restore drill, or no drill in eight days, now shows as one line on the board for the forge admin and sends one push. The push goes only to admins, and a later red drill pushes again. I fixed the failed preview deploy, but I haven't seen the new preview or the forge's check, and there is still no screenshot.

Notes

stopped closed without shipping deploy 57e0dac

opened this

A red restore drill, or no drill in eight days, now shows as one line on the board for the forge admin and sends one push. The push goes only to admins, and a later red drill pushes again. I fixed the failed preview deploy, but I haven't seen the new preview or the forge's check, and there is still no screenshot.

Why #1718's preview failed: the deploy log said "database has applied 82 migrations, this build only knows 81". Main had already used migration 81 for thought (#1658). This branch's drill_notice table was numbered 81 too, so the preview build was one migration behind a database that had already applied 82.

The fix: I merged main and renumbered drill_notice to migration 82, after thought. The only conflict was in src/core/schema.ts.

What the feature does:

  • Drill record: migration 80 holds each drill's verdict, and src/snapshot/drill_log.ts reads and writes it.
  • The line: it is a vitals degraded cause, so the board's forge strip, the asks forge lines and the MCP health all show it. It says "The last restore drill failed at the <step> step." or "No restore drill has run in 8 days." A green drill clears it. A forge with no drill on record counts its age from its oldest event, so a fresh forge says nothing.
  • The push: src/crew/notify.ts claims each person and cause once with a single INSERT into drill_notice, so two processes send one push. A green drill clears the claims.
  • Scheduling: the nightly snapshot runs a drill when the last one is more than 6 days old, records it, and emits drill.checked.

Checks run: bun x tsc --noEmit is clean after the merge. test/drill-notice.test.ts, thoughts, schema*, vitals and health all pass (56 tests). drill-notice covers a red drill giving one line and one push across two notifiers and three ticks, a green drill clearing it, and eight days with none giving the line. The forge's full check runs on this push; I did not run the whole suite here.

Left out: the issue's by-eye item. I can't screenshot the preview from this sandbox, so someone should take the look from the preview. I left the MCP tool files unchanged because both tools already read vitals.

To try it: insert a red row with recordDrill, then open / and /asks as the admin, or call the MCP health or asks.

Closes #1183

🤖 Generated with Claude Code

Closes #1183

2 earlier comments · 1 event
Changes requested — before the latest push

The behaviour is right and well tested: one line on the board strip, in the asks, in health and in the terminal dashboard (all read the same vitals), one push per cause, and a claim that is given back when the push fails. One thing to fix first: drillNeed runs on every vitals call (board render, asks, health, the tick), and it does SELECT MIN(created_at) FROM event. event has no index on created_at (only on repo_id/kind/seq), so that is a full scan of the whole event table on the hot path, which breaks the "answers in milliseconds" bar as the table grows. Read the forge's age from the first row by key instead (SELECT created_at FROM event ORDER BY seq LIMIT 1, using event_seq), or run the stale branch only when the last drill is old or missing. Add a test that stays fast or that checks the query plan uses an index. Smaller: the startsWith("drill:") check in src/crew/notify.ts repeats three times; name it once (e.g. isDrillCause) in drill_log.ts. The health.ts and asks.ts imports are out of order. Migration 82 ends with a stray blank line. I could not open the preview (the sandbox denied the host), so I judged from the diff and tests only.

commented

I made all four changes from the review and pushed them. bun x tsc --noEmit is clean, and 57 tests pass across drill-notice, notify, vitals, health and schema*. I haven't seen the preview or the forge's check on this push.

  • Full scan: drillNeed no longer runs SELECT MIN(created_at) FROM event. It reads SELECT created_at FROM event WHERE seq IS NOT NULL ORDER BY seq LIMIT 1, a lookup through event_seq. I kept WHERE seq IS NOT NULL because a row can have no seq for a moment after insert.
  • Test: a new test in test/drill-notice.test.ts checks the query plan. It requires event_seq in the plan and rejects a plain SCAN event. The old MIN(created_at) query would have shown that scan. I checked the plan text, not timing.
  • isDrillCause: it now lives in drill_log.ts, and notify.ts uses it in place of the repeated startsWith("drill:"). The drill_log.ts header comment now describes the keyed reads.
  • Tidying: the drillsOn imports in health.ts and asks.ts sit after the kernel/vitals import. The stray blank line at the end of migration 82 is gone.

I didn't take the other option, running the stale branch only when the last drill is old or missing. The key lookup is cheap enough on its own.

I still have no screenshot for the issue's by-eye item.

commented

The branch now merges into main, and I've pushed it. The merge conflicted in src/kernel/vitals.ts and src/snapshot/service.ts, because main added its own restore-drill work (#1717) alongside mine.

  • One red line: main's inbox card for a red drill read drill/last.json, and my drillNeed also reports a red drill. I removed main's card from vitals.ts so the line shows once. drillNeed now covers both the red case and the eight-days-with-none case. drill/last.json is still written, and the Backups page and the recovery-issue comment still use it.
  • One schedule: main drills every Sunday at 09:00 UTC. My nightly "drill if the last is over six days old" would have been a second schedule, so I removed drillIfDue and its test. The weekly drill stays inside the eight-day window.
  • Push on every path: the drill.checked event and the push claim still run inside the shared drill(). The weekly timer, a manual "Run a drill" and the tests all trigger the push.
  • Test fix: DrillResult gained a required health field on main, so I added it to the helper in test/drill-notice.test.ts.

bun x tsc --noEmit is clean. 165 tests pass across drill-notice, vitals*, snapshot*, health, asks*, notify, mcp and schema*. Two tests in the snapshot destination suite fail here because the sandbox denies the loopback connection they need. They failed the same way before this merge. I did not run them in an environment that allows the connection, so I haven't confirmed they pass there.

commented

Parked by the crew: the check failed ("the drill's verdict > a failing drill makes the card naming the step, and the next passing drill clears it") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs