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
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.
stopped closed without shipping deploy 433aef6
3 earlier comments · 1 event
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) anddrill_notice(pushes already sent). - Logic:
src/snapshot/drill_log.tsholdsrecordDrill,drillNeedandclaimNotice. - 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 vitalsdegradedcause, so the board's forge strip, the asksforgelines andhealthall show it. It links to/settings/backups. The MCP tool files are unchanged. - Push:
src/crew/notify.tstells admins on a newdrill.checkedevent. Each person and cause is claimed once with a single INSERT intodrill_notice, so two processes send one push. A green drill clears the claims, so a later red tells again. - Scheduling: nothing called
runDrillbefore. The nightly snapshot now runs one when the last is more than 6 days old, records it, and emitsdrill.checked.
Tests
- New file:
test/drill-notice.test.tscovers 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 andhealth, 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 toGATE. Its first version depended on test order, so I made each test set up its own state. The admission run ofbun scripts/flake-hunt.ts admit test/drill-notice.test.tsthen passed 10 of 10 in random order under load. - Existing test changed: in
test/vitals.test.tsI 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 --noEmitis clean, andtest/check-list.test.tsandtest/drill-notice.test.tspass. - 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.
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 emitsdrill.checkedso the notifier looks. A manual "Run a drill" from the Backups page does the same.
Tests
bun x tsc --noEmitis 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.tsand the schema tests. The newtest/drill-notice.test.tsis still listed inGATE. - In
test/vitals.test.tsI 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.
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.
- 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.
- 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.
- 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.
- 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.
- 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.
Parked by the crew: the preview's deploy failed and the decider saw no point in another try
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.
- Service behaviour is tested through the real path. I removed the wrapper that copied the service.
test/drill-notice.test.tsnow runs a realstartSnapshotshandle with the drill seam and callssvc.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.erroron red, so it has no test.
- Green drill: it forgets the notices and emits
- A failed push no longer burns its claim. In
src/crew/notify.tsa 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. - Both doors. There is no
src/tty.tschange, because the terminal dashboard readsforgeNeeds→readHealth→ vitals, the same source as the board, asks andhealth. A test asserts the dashboard'sforgeNeedscarries the line, and the README now says where the line shows. - No store means no late drill.
drillNeedtakes a store flag, and vitals takesdrillsOn, which comes fromsnapshotsOf(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. - Cost of the drill read.
drillNeedis one query of four small subselects: the newestdrillrow by id, plus the minimum event time. I noted this in the doc comment ondrillNeed; I did not measure it.
Tests
bun x tsc --noEmitis 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 oftest/tui*.test.ts, so I took it for a load flake. I did not investigate further.
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
drill_result(each drill's verdict) anddrill_notice(pushes already sent).src/snapshot/drill_log.tsreads and writes them.drillNeedreturns 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.health: the need is a vitalsdegradedcause, so the board's forge strip, the asksforgelines andhealthall show it. It links to/settings/backups.src/crew/notify.tstells admins on a newdrill.checkedevent. Each person and cause is claimed once indrill_notice(a single INSERT), so two processes send one push. A green drill clears the claims, so a later red tells again.runDrillbefore. The nightly snapshot now runs a drill when the last is more than 6 days old, records it, and emitsdrill.checked.Tests
test/drill-notice.test.tscovers 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.healthanswers, and the claim being once per person and cause.test/vitals.test.tsfrom 5 to 6, because the drill read is one more query. That test was a tally, not a behaviour.drill-notice,notify,vitals,vitals-degraded,health,mcp,asks*,schema*,snapshot*), 149 tests pass.bun x tsc --noEmitis clean. Two tests in the snapshot destination suite fail with and without my change; the sandbox denies the loopback connection they need.Left out
To try it Insert a red row with
recordDrill, then open/and/asksas the admin, or call the MCPhealthorasks.Closes #1183