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

The forge's admin hears once of a domain drill that is red, stale or never run, with the exact command to run it #5369

Merged opened this

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

Merged

The forge's admin now gets a notification for each domain drill need that is red, stale or never run, and the line carries the exact `bun scripts/drills/run.ts … --forge …` command. `bun test test/notify-causes.test.ts` and `bun x tsc --noEmit` both pass. I did not run the whole suite.

shipped production is serving it deploy ad44386

opened this

The forge's admin now gets a notification for each domain drill need that is red, stale or never run, and the line carries the exact bun scripts/drills/run.ts … --forge … command. bun test test/notify-causes.test.ts and bun x tsc --noEmit both pass. I did not run the whole suite.

  • domainDrillLines sits beside drillLines in src/crew/notify.ts. It reads the needs from domainDrillNeeds, fed the same way vitals.ts does (newestDrills, firstSeen, DOMAINS), so there is no second computation. It is added to the same set of notifications as drillLines, and it takes the forge URL from the notifier's own forgeUrl option.
  • Who hears it: only an admin who is a person, the same guard as drillLines.
  • Repeats: each line's id is the need's cause plus its since. A repeat tick sends nothing, and a later red gets a new id and is sent.
  • Tests: three cases in test/notify-causes.test.ts.

- An admin gets the drill:never line naming every drillable domain's command. - A second tick returns the same id, so nothing new is sent. - A non-admin gets nothing.

  • Extra test: one more case checks that a later red for a domain changes the id. These tests call domainDrillLines directly rather than going through a notifier tick, so the wiring into tell is not exercised by a test.
  • Not done: the line carries no link of its own, so it opens the forge's asks screen like the restore-drill line does. Vitals links /.

Closes #5368

commented

The forge's admin now gets a notification for each domain drill need that is red, stale or never run, and the line carries the exact bun scripts/drills/run.ts … --forge … command. bun test test/notify-causes.test.ts and bun x tsc --noEmit both pass. I did not run the whole suite.

  • domainDrillLines sits beside drillLines in src/crew/notify.ts. It reads the needs from domainDrillNeeds, fed the same way vitals.ts does (newestDrills, firstSeen, DOMAINS), so there is no second computation. It is added to the same set of notifications as drillLines, and it takes the forge URL from the notifier's own forgeUrl option.
  • Who hears it: only an admin who is a person, the same guard as drillLines.
  • Repeats: each line's id is the need's cause plus its since. A repeat tick sends nothing, and a later red gets a new id and is sent.
  • Tests: three cases in test/notify-causes.test.ts.

- An admin gets the drill:never line naming every drillable domain's command. - A second tick returns the same id, so nothing new is sent. - A non-admin gets nothing.

  • Extra test: one more case checks that a later red for a domain changes the id. These tests call domainDrillLines directly rather than going through a notifier tick, so the wiring into tell is not exercised by a test.
  • Not done: the line carries no link of its own, so it opens the forge's asks screen like the restore-drill line does. Vitals links /.
Changes requested — before the latest push

The change is small and it reads right. domainDrillLines feeds domainDrillNeeds the same inputs vitals.ts does (newestDrills, firstSeen, forgeUrl, DOMAINS), so the needs are not computed a second way. The guard is the same as drillLines, and a cause@since id works with tell's seen-by-items dedupe. There is no new input, nothing to escape and no new dependency. bun test test/notify-causes.test.ts passes at the head (7/7), and the preview answers /.

One miss against the bar: the behaviour this pull adds, "the admin hears it once", has no test that would fail without it. All three tests call domainDrillLines directly. Delete the ...domainDrillLines(app, user, now(), options.forgeUrl), line from tell and every test still passes. The issue's second case, "a second tick with the same need sends nothing", is shown only as two calls returning the same id. Nothing proves no second post goes out.

Fix first: add one test that goes through the notifier, using the same setup as the cause pager describe:

  • seedFirstSeen(dataDir, t0), an admin with setNotifyUrl, and startNotifier with a fake now and a send that records each post. Boot it at t0 + 7 * DAY so the first tell's baseline holds no drill need.
  • Move the clock to t0 + 9 * DAY and call notifier.tick(). Expect exactly one post, and expect it to contain drillCommand(d.key, URL_) for every drillable domain.
  • tick() again a minute later and expect the post count to stay at 1.
  • Optionally, recordDrill a red for compute, tick, and expect a second post naming the compute command.

That test fails if the wiring is removed or the id stops being stable. Nothing else needs to change.

commented

I added the notifier-level test and pushed. Writing it also turned up a second bug in the original change. bun test test/notify-causes.test.ts passes 8/8 and tsc is clean.

  • New test: the admin gets exactly one drill post naming every drillable domain's command. A repeat wake sends nothing. A later red for compute sends a second post naming the compute command.
  • Check that it bites: with the ...domainDrillLines(...) line deleted from tell, the new test fails (7 pass, 1 fail). With the line restored, all 8 pass.
  • Bug found: oneLine cut every pushed line to 160 characters, so the drill:never post lost all but the first command. I raised the cap to 600 (LINE_MAX in src/crew/notify.ts), which fits the four-command line. It applies to every notification line.
  • Differs from your suggestion: I woke the notifier with a drill.finished event, then waited briefly and called settled(). tick() only runs the pager, not tell, so ticking would never have reached the drill lines.
  • Extra filter: the test counts only posts containing scripts/drills/run.ts, because the unrelated restore-drill line also fires in that setup.
Approved

Approved. domainDrillLines reuses the vitals inputs, so the needs are not computed twice. It has the same admin-person guard as drillLines, and the cause@since id makes a repeat tick quiet and a later red new. The notifier-level test now exists. It goes through tell with a fake clock and send, so it fails if the wiring is removed. The preview answers / with 200. Two things I would do next: (1) The LINE_MAX bump from 160 to 600 applies to every notification line, not only drill lines, so add a test that pins that, or scope it to the drill lines. (2) Give the line a link, so it opens the relevant screen rather than only naming a command.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs