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 #1718

Closed opened this
Closed without merging

A red restore drill, or none in eight days, now shows as one line for the forge admin and sends one push. There is no screenshot, and the issue's by-eye item is not done: I can't take a preview screenshot from this sandbox.

Notes

stopped closed without shipping deploy 433aef6

opened this

A red restore drill, or none in eight days, now shows as one line for the forge admin and sends one push. There is no screenshot, and the issue's by-eye item is not done: I can't take a preview screenshot from this sandbox.

What changed

  • Record: migration 80 adds drill_result (each drill's verdict) and drill_notice (pushes already sent). src/snapshot/drill_log.ts reads and writes them.
  • Need: drillNeed returns one cause at a time. A red newest drill gives "The last restore drill failed at the <step> step." A newest drill older than 8 days gives "No restore drill has run in 8 days." A green drill inside the window clears it.
  • No drill on record: it counts the forge's age from its oldest event, so a fresh forge says nothing.
  • Board, asks, health: the need is a vitals degraded cause, so the board's forge strip, the asks forge lines and health all show it. It links to /settings/backups.
  • Push: src/crew/notify.ts tells admins on a new drill.checked event. Each person and cause is claimed once in drill_notice (a single INSERT), so two processes send one push. A green drill clears the claims, so a later red tells again.
  • Scheduling: nothing called runDrill before. The nightly snapshot now runs a drill when the last is more than 6 days old, records it, and emits drill.checked.

Tests

  • test/drill-notice.test.ts covers the three cases in the issue: a red drill gives one line and one push (two notifiers, three ticks), a green drill clears it, and eight days with none gives the line.
  • It also covers a later red telling again, the line appearing in the asks and health answers, and the claim being once per person and cause.
  • I changed the query tally in test/vitals.test.ts from 5 to 6, because the drill read is one more query. That test was a tally, not a behaviour.
  • In the files I ran (drill-notice, notify, vitals, vitals-degraded, health, mcp, asks*, schema*, snapshot*), 149 tests pass. bun x tsc --noEmit is clean. Two tests in the snapshot destination suite fail with and without my change; the sandbox denies the loopback connection they need.

Left out

  • I did not run the whole suite; the forge runs the check.
  • The MCP tool files are unchanged, because both tools already read vitals.
  • The line goes to admins only, as other forge needs do.

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

3 earlier comments · 1 event
commented

A red restore drill, or none in eight days, now shows as one line for the forge admin and sends one push. There is no screenshot from the preview in this pull. I can't take one from this sandbox, so that item in the issue is not done.

What changed

  • Record: migration 80 adds drill_result (each drill's verdict) and drill_notice (pushes already sent).
  • Logic: src/snapshot/drill_log.ts holds recordDrill, drillNeed and claimNotice.
  • Red drill: the line reads "The last restore drill failed at the <step> step."
  • Stale drill: the line reads "No restore drill has run in 8 days." A forge with no drill on record counts its age from its oldest event, so a fresh forge says nothing.
  • Board, asks, health: the need is a vitals degraded cause, so the board's forge strip, the asks forge lines and health all show it. It links to /settings/backups. The MCP tool files are unchanged.
  • Push: src/crew/notify.ts tells admins on a new drill.checked event. Each person and cause is claimed once with a single INSERT into drill_notice, so two processes send one push. A green drill clears the claims, so a later red tells again.
  • Scheduling: nothing called runDrill before. The nightly snapshot now runs one when the last is more than 6 days old, records it, and emits drill.checked.

Tests

  • New file: test/drill-notice.test.ts covers a red drill giving one line and one push (two notifiers, three ticks), and a green drill clearing it. It also covers eight days with none giving the line, a later red telling again, the line showing in the asks and health, and the one-claim-per-person rule.
  • The check failure: the new test file was in neither list in scripts/gate.ts, so I added it to GATE. Its first version depended on test order, so I made each test set up its own state. The admission run of bun scripts/flake-hunt.ts admit test/drill-notice.test.ts then passed 10 of 10 in random order under load.
  • Existing test changed: in test/vitals.test.ts I changed the query tally from 5 to 6, because the drill read is one more query. That test was a tally, not a behaviour.
  • Local runs: bun x tsc --noEmit is clean, and test/check-list.test.ts and test/drill-notice.test.ts pass.
  • Failures here: two tests in the snapshot destination suite fail with and without my change, because the sandbox denies the loopback connection they need.

Left out: the line and the push go to admins only, as other forge needs do.

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

commented

I merged main into the branch, resolved the conflicts in src/core/schema.ts and src/snapshot/service.ts, and pushed. I haven't seen the forge's check run on the merge yet. There is still no screenshot from the preview, because I can't take one from this sandbox.

Main had meanwhile landed its own drill table and recorder (#1707). I dropped my duplicate drill_result table and recorder and now read main's drill table. Only drill_notice is mine, as migration 81 after main's 80.

What the pull does now

  • Board, asks, health: a red restore drill, or none in eight days, shows as one line for the forge admin. The red line names the step that failed, and a green drill clears it.
  • Push: the owner gets one push per cause. It is claimed with a single INSERT, so a roll with two processes sends it once.
  • Scheduling: the nightly snapshot runs a drill when the last is more than 6 days old, through main's drill(). After each drill, drill() forgets old notices on green and emits drill.checked so the notifier looks. A manual "Run a drill" from the Backups page does the same.

Tests

  • bun x tsc --noEmit is clean.
  • 53 tests pass across test/drill-notice.test.ts, test/snapshot-drill-page.test.ts, test/notify.test.ts, test/vitals.test.ts, test/check-list.test.ts and the schema tests. The new test/drill-notice.test.ts is still listed in GATE.
  • In test/vitals.test.ts I changed the query tally from 5 to 6, since the drill check is one more read. That test was a tally, not a behaviour.

Left out: the line and the push go to admins only, as other forge needs do.

To try it: record a red drill, then open / and /asks as the admin, or call the MCP health or asks.

Changes requested — before the latest push

The need itself is well shaped: one cause key per piece of evidence, one claim INSERT, and it reuses vitals so the board, asks and health share it. One thing blocks it. The behaviour added in src/snapshot/service.ts has no test that would fail without it. Fix that first. I read the diff and the code; I did not curl the preview or read the screenshots.

  1. Untested service behaviour (blocking). test/drill-notice.test.ts defines its own recordDrill wrapper that calls forgetNotices on green. That copies the service, so it passes even if drill() never forgets notices or never emits drill.checked. drillIfDue (the 6-day rule) and the log.error on red are not exercised either. Drive them through startSnapshots, or extract the post-drill step into a function that both the service and the test call. Add a test that drillIfDue skips a drill when the last one is under 6 days old and runs one when it is older.
  2. A claimed push is lost if delivery fails (notify.ts). claimNotice runs before the send. If the send fails or times out, the claim is already stored and that cause never tells again, so the owner may never hear about a red drill. Claim after a delivered send, or delete the claim when the send fails. Add a test with a failing send.
  3. Both doors. I saw no src/tty.ts change. Confirm the terminal health and asks read the same vitals and show the line, add a test for that, and make sure the README says where the line shows up.
  4. A forge with no snapshot store has no drill ever, so it shows the stale line for good after 8 days, and nothing on the page can clear it. Return null from drillNeed when no store is configured.
  5. Minor: test/vitals.test.ts changes the query tally from 5 to 6. That is fine, but the drill read is a four-subselect query on every vitals tick, so say it is cheap.
commented

Parked by the crew: the preview's deploy failed and the decider saw no point in another try

commented

I've addressed all five points from the review and pushed. I haven't seen the forge's check run on this push, and there is still no preview screenshot. I can't take one from this sandbox.

  1. Service behaviour is tested through the real path. I removed the wrapper that copied the service. test/drill-notice.test.ts now runs a real startSnapshots handle with the drill seam and calls svc.drill().
    • Green drill: it forgets the notices and emits drill.checked.
    • drillIfDue (new on the handle): it skips a drill when the last is 2 days old and runs one when it is 7 days old.
    • Check: I temporarily broke each of these behaviours and the matching test failed. I did not break the log.error on red, so it has no test.
  2. A failed push no longer burns its claim. In src/crew/notify.ts a failed send now releases the claim (releaseNotice). It also drops the cause from the notifier's seen set, so the next wake tries again, subject to the endpoint's pause. A test with a failing send covers this; I broke the release and it failed.
  3. Both doors. There is no src/tty.ts change, because the terminal dashboard reads forgeNeeds → readHealth → vitals, the same source as the board, asks and health. A test asserts the dashboard's forgeNeeds carries the line, and the README now says where the line shows.
  4. No store means no late drill. drillNeed takes a store flag, and vitals takes drillsOn, which comes from snapshotsOf(app)?.store. All four vitals callers pass it (health.ts, board.ts, asks.ts, main.ts), and so does the notifier. A red drill still shows without a store; only the "none in eight days" line needs one. A test covers it.
  5. Cost of the drill read. drillNeed is one query of four small subselects: the newest drill row by id, plus the minimum event time. I noted this in the doc comment on drillNeed; I did not measure it.

Tests

  • bun x tsc --noEmit is clean.
  • 441 tests passed across the drill, notify, vitals, health, MCP, board, asks, tui* and check-list files, with one failure.
  • The failure was "the sentinel command > an admin has it" in test/tui-sentinel.test.ts. It passes on its own and in three repeats of test/tui*.test.ts, so I took it for a load flake. I did not investigate further.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs