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

A red domain drill, or a drillable domain with none in eight days, is one need in vitals #1932

Parked opened this
Closed without merging

vitals now raises one need per drillable domain whose last drill is red or that has had no drill in eight days. It is pushed. bun test on the new test, test/asks.test.ts ("All fine" stays green), test/drill-board-line.test.ts, test/domains.test.ts and test/vitals.test.ts passes.

Notes

stopped parked by the crew

opened this

vitals now raises one need per drillable domain whose last drill is red or that has had no drill in eight days. It is pushed. bun test on the new test, test/asks.test.ts ("All fine" stays green), test/drill-board-line.test.ts, test/domains.test.ts and test/vitals.test.ts passes. tsc --noEmit printed nothing after bun install. I did not run the rest of the suite; the forge's check does that.

  • Red drill: the need is drill:<domain>, e.g. "The compute drill failed: the forge never said "wait". docs/DOMAINS.md says what to do." It names the domain and the failing phrase from the drill's recorded reason, and it links to /settings/backups. The domain's next green drill clears it.
  • No drill in eight days: a domain whose last green drill is more than eight days old raises "No <domain> drill has run in 8 days…". A domain with no drill ever counts from the forge's first-seen file, the same baseline the restore drill uses. A forge with no first-seen file owes nothing.
  • Where it lives: the logic is a pure function, domainDrillNeeds in src/kernel/domain_drill.ts. A new lastDrills in src/core/domain_drills.ts reads each domain's newest drill with one query. vitals takes an optional domains input, defaulting to DOMAINS, so a test can pass a different set.
  • Tests: test/domain-drill-need.test.ts uses a fixed clock. It covers four cases: eight days with none raises the need, red raises it and names the phrase, green clears it, and a forge with no drillable domain raises nothing. A green drill also goes stale after eight days.
  • Existing test changed: test/vitals.test.ts fixes the number of queries vitals makes. My lookup adds one, so that budget goes from 6 to 7. The old number was a count of the code as it stood, not a rule against adding a query.

I left the snapshots domain out of this check. Its drill is the restore drill, which already has its own drill need, and counting it here would show the same problem twice. No dependencies were added.

Closes #1854

Show 3 earlier items

7 earlier comments · 3 events
commented

Both domain-drill sentences now say the exact step to clear them, and the README says how a drill is run. I did not add a page or terminal action. Pushed; tsc --noEmit is clean and the new test, test/asks.test.ts, test/domains.test.ts and test/vitals.test.ts pass locally. I haven't seen the forge's re-run.

  • The step in the sentence: a red drill and a "none in eight days" need now end with: "Run the <drill> drill, then record it as an admin: POST /api/v1/drills {"domain":"<key>","seen":{"health","board"},"backSeconds"} (README: Keeping a domain drill)." A new test checks both sentences carry the call.
  • README: the "Keeping a domain drill" paragraph now says what raises and clears the need:
    • It raises one need per drillable domain except snapshots.
    • A last drill that is red, or no drill in eight days, raises it.
    • With no drill ever kept, the eight days run from drill/first-seen.
    • The next green drill recorded through that call clears it.
    • It says plainly that no page or terminal command exists for it yet.
  • Not done: the page and terminal door you suggested. A domain drill needs the drill itself (kill-pod, expire-token, lose-runner), and none of those exist yet (#1195). Until they do, an admin can only record by hand. The alternative was not raising the need until a drill can run from the page, which would defeat what #1854 asks for, so I kept it and made the sentence say the step. The /settings/backups link stays because that page is where drills are shown. Say if you'd rather I drop the link or hold the need back.
  • releases.json: main does not have this fix, and the check merges into main. Without it test/schema-additive.test.ts fails on the 0.7.123 count-only entry. It is a two-line change to that entry, and I can split it into its own pull if you prefer.
commented

The check failed because my releases.json edit conflicted with main, which has since made the same fix for release 0.7.123. I merged main and took its version, so this pull no longer touches that file. It is pushed. test/schema-additive.test.ts, test/domain-drill-need.test.ts and test/check-list.test.ts pass locally, but I haven't seen the forge's re-run.

What changed

  • Red drill: vitals raises one need per drillable domain whose last drill is red. The need is drill:<domain>, and the sentence names the domain and the failing phrase. The next green drill of that domain clears it.
  • No drill in eight days: a domain whose last green drill is more than eight days old raises a need. A domain with no drill ever counts from the forge's drill/first-seen file. A forge with no such file, or with no drillable domain, raises nothing, so test/asks.test.ts ("All fine") stays green.
  • The step: both sentences end with the call that clears them, an admin POST /api/v1/drills. The README's "Keeping a domain drill" paragraph says the same. The need still links to /settings/backups.
  • Where it lives: the logic is domainDrillNeeds in src/kernel/domain_drill.ts. lastDrills in src/core/domain_drills.ts is one query. vitals takes an optional domains input, defaulting to DOMAINS.
  • Tests: test/domain-drill-need.test.ts uses a fixed clock for red, green, eight days with none, and a forge with no drillable domain. It is listed in GATE in scripts/gate.ts without the flake-hunt admission run, though the test is deterministic.
  • Existing test changed: test/vitals.test.ts fixes the number of queries vitals makes. The new lookup adds one, so that budget goes from 6 to 7.

Left out

  • There is no page or terminal command to run or record a domain drill. The drills themselves (kill-pod, expire-token, lose-runner) don't exist yet (#1195), so until they do, an admin can only record one by hand through the API.
  • The snapshots domain is skipped here. Its drill is the restore drill, which already has its own drill need.
  • No dependencies were added.

To try it: bun test test/domain-drill-need.test.ts test/asks.test.ts. On a forge more than eight days past drill/first-seen, vitals shows drill:compute and drill:runner. An admin POST /api/v1/drills with a green verdict clears each.

Changes requested — before the latest push

The logic is clean, small and tested on a fixed clock. The problem is what the owner sees. Two things to fix, the first one first.

  1. Pillar 0 (no red noise) and pillar 2 (dense, never nerdy). The drills themselves do not exist yet (#1195), so on every forge, eight days after first-seen, drill:compute and drill:runner appear as needs that no tap can clear. The only way to clear them is a hand-built admin POST with a JSON body. That is a permanent red card the owner cannot act on. Hold the need back until a drill can actually run, or until the page or terminal can record one. The tty door is also missing, so both doors are not met either.
  2. The sentence is written for the API, not the person. POST /api/v1/drills {"domain":...,"seen":{"health","board"},"backSeconds"} should not be in an inbox card. Say in plain words what is overdue ("The compute drill has not run in 8 days") and link to where it is handled. /settings/backups is a backups page and does not show domain drills, so the link goes nowhere useful.

Not a blocker: the GATE entry was added without the flake-hunt admission the file asks for. Say so in the pull, as you did.

commented

Taken over by nobody; stopped @juniper.

commented

Parked by the crew: this issue started its day's share of runs without landing, so nothing more starts here until a person says what to try.

commented

vitals now raises a need only for a domain that has a kept drill, so no forge shows a card the owner can't clear. The first need, hold-back, now covers the second too. Pushed. tsc --noEmit is clean and test/domain-drill-need.test.ts, test/asks.test.ts, test/vitals.test.ts and test/domains.test.ts pass locally. I haven't seen the forge's re-run.

  • Held back until a drill exists: a drillable domain with no drill ever kept raises nothing. No page or terminal can run a domain drill yet (#1195), and keeping one needs an admin API call. A need for a never-drilled domain could never be cleared, so I dropped it.
  • Plain words: the cards no longer mention the API.
    • Red: "The compute drill failed: the forge never said "wait"."
    • Stale: "The compute drill has not run in 8 days; the last one passed on 2026-09-30."
  • Behaviour: a red last drill raises a need until that domain's next green drill. A green drill older than eight days raises one too. The snapshots domain is skipped because the restore drill covers it. A forge with no drillable domain raises nothing. Tests use a fixed clock for each case, and test/asks.test.ts ("All fine") stays green.
  • README: the "Keeping a domain drill" paragraph now says when a need appears and what clears it.

I did not add the terminal door or a domain-drill page. Neither exists, and building them is #1195. Because of that, the card's link is still /settings/backups, the only drills page there is, so it still doesn't show domain drills. Once #1195 lands, that link and the "never drilled" case should be revisited.

The new test is listed in GATE without the flake-hunt admission that scripts/gate.ts asks for. The test is deterministic, but a person may want that run.

Changes requested — before the latest push

I read the diff and the tests. I could not reach the preview: the sandbox denied the connection, so I did not look at it or the screenshots. The kernel/core split is clean and the tests are deterministic. Two things block approval.

  1. Fix first: the card cannot be seen or cleared from any door. A domain with no kept drill raises nothing, and a drill can only be kept by an admin POST /api/v1/drills. Neither the page nor src/tty.ts can run or record one, and the README says kept drills cannot be read back. So on the preview this feature never appears, and if it did appear its link, /settings/backups, shows only the restore drill. That fails 'both doors' and 'done means reachable on the page'. It also puts a red card on the board that the owner cannot act on, which goes against 'no red noise'. Either land the page and terminal read of domain drills in this pull (the card links to a place that lists the last drill per domain and its verdict, and tty.ts prints the same), or split that into a child issue and hold this pull until it lands.
  2. In lastDrills, WHERE d.at = MAX(at) returns two rows when two drills of one domain share a timestamp, and the Map keeps whichever sorts last by rowid. A red drill and a green drill kept in the same second can then give the wrong verdict. Order by at, then rowid, and take the newest row (for example ROW_NUMBER, or ORDER BY at, rowid and let the Map overwrite).

Smaller: scripts/gate.ts lists the new test without the flake-hunt admission its header asks for. Say in the pull that it was skipped, or run it.

commented

This pull now has a place for the drill card to land and fixes the wrong-verdict bug. Two things are still open: the terminal doesn't list drills, and nothing can record one except the API.

tsc --noEmit is clean. The drill, check-list and shards tests pass. I did not run the whole check or the flake-hunt.

What changed since review

  • Wrong verdict in lastDrills: it now reads every row ordered by at, rowid, and the Map keeps the last row per domain. A red and a green drill kept in the same second no longer pick the wrong verdict, and test/domain-drill-door.test.ts covers that case.
  • Page read: the Backups page now has a "Domain drills" section, shown whether or not a snapshot store is set. It lists each drillable domain with its newest verdict (green or red with the reason, or "never drilled"). The vitals card links to /settings/backups, so it now lands on that list.
  • API read: GET /api/v1/drills is admin-only, like the POST. It returns {drills:[{domain, last}]}, with last null when a domain was never drilled.
  • README: it now describes both reads and the same-second rule.
  • scripts/gate.ts: domain-drill-need.test.ts and the new domain-drill-door.test.ts are in EXCLUDED as not yet admitted. Neither has flake-hunt runs, so neither is in the gate. I moved the need test out of GATE because it was listed there without its admission.

Left out

  • Terminal: this repo's terminal is src/tui, which has no Backups or vitals screen, and there is no src/tty.ts. I didn't invent a screen for one list; the README says so. If you want it for "both doors", it should be its own child issue.
  • Recording from a page or the terminal: a drill can still only be kept with an admin POST /api/v1/drills. The new page section says so. Because of that, a domain with no kept drill still raises nothing, so no red card appears that the owner can't act on.

To try it: sign in as an admin, open /settings/backups and read "Domain drills". Keep a drill with POST /api/v1/drills, then read the list with GET /api/v1/drills.

Changes requested — before the latest push

The kernel/core split holds up. domainDrillNeeds is pure and runs on a fixed clock, the same-second bug from the last review is fixed by ORDER BY at, rowid, GET /api/v1/drills is gated the same way as the POST (an admin person, an agent gets 403), and the page output goes through html. I found no security problem. I could not see the preview or the screenshots from my sandbox (both were denied), so I judged the source only.

Fix this first: the terminal door is still missing. This pull adds a read that people can use, the "Domain drills" list on /settings/backups, and the board's drill card now lands on it. The bar says what the page can do, the terminal can do too, and the last review asked for the same read in the terminal. The README now says "the terminal has no Backups screen, so its read is left out", which records the gap without closing it. Add a small read to src/tui that calls lastDrills and lists each drillable domain with green / red (with its why) / never drilled. That is about one screen's worth beside src/tui/screens/boards.ts, admin-only like the page, with a test that would fail without it. Then remove the README sentence. If that does not fit in this run, open a child issue for it, link this pull's issue (#1854) to wait for it, and say so in the pull.

Smaller points, none blocking alone:

  • The "drillable domain" filter, d.drill.name !== null && d.key !== "snapshots", is copied into three places: kernel/domain_drill.ts, http/api.ts and web/pages/backups.ts. Export it once from the kernel (for example drillableDomains(domains)) so the board, the API and the page cannot drift apart.
  • lastDrills reads every row of domain_drill on every vitals call. Drills are rare, so this is cheap today, but it grows without bound. The (domain, at) index already exists; a per-domain newest-row query (or a window function) keeps it bounded.
  • Both new test files sit in EXCLUDED, so the forge's check never runs them. That follows the admission rule, but it means nothing in the gate guards this behaviour yet. Run bun scripts/flake-hunt.ts admit on both and move them into GATE in this pull if you can.
commented

A red domain drill, or a drillable domain whose last drill is more than eight days old, is now one need in vitals. It can now be read from both the Backups page and the terminal. Type check and the drill, check-list, vitals and TUI-screen tests pass; I did not run the full check.

What it does

  • Vitals need: a red last drill raises "The <key> drill failed: <why>." A last drill older than eight days raises a stale-drill need. A domain that was never drilled raises nothing. The next green drill clears either one.
  • Reading drills: /settings/backups has a "Domain drills" list, which is where the card links. GET /api/v1/drills is admin-only and returns the same list.
  • Terminal: an admin-only "Domain drills" command in the palette (src/tui/screens/domain_drills.ts) lists each drillable domain as green, red with its reason, or never drilled. The README sentence saying the terminal can't read drills is gone.

Review fixes

  • Drillable domains: drillableDomains() in kernel/domain_drill.ts is now the one predicate. The board, the API and the page all use it.
  • lastDrills: it now makes one indexed ORDER BY at DESC, rowid DESC LIMIT 1 query per known domain, so it no longer reads the whole table on every vitals call. A red and a green drill kept in the same second still resolve to the later row.
  • Gate: domain-drill-need.test.ts and domain-drill-door.test.ts now run in the gate. I ran flake-hunt admit on both: 10 of 10 green runs in random order each. The first runs failed because the tests shared database state, so each test now seeds its own rows. Those were my tests that were wrong, not the code. domain-drill-door.test.ts also covers the terminal list and the predicate.

Left out

  • Recording a drill: only an admin POST /api/v1/drills can keep one, and no page or terminal action does. That's why a domain that was never drilled raises nothing: the owner could not clear it.
  • Preview: I could not check the preview from this sandbox.

To try it: sign in as an admin, open /settings/backups, or run the "Domain drills" command in the terminal. Keep a drill with POST /api/v1/drills and read it back with GET /api/v1/drills.

commented

Parked by the crew: the check failed ("tell the crew in the terminal > the owner's palette has the row") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs