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

A drill for each failure domain: kill the pod, cut the tunnel, lose the runner, expire a token; the forge's own words recorded and compared to docs/DOMAINS.md #1720

Closed opened this
Closed without merging

The failure-domain map, the drills, the Resilience page and the vitals need are all in, and the new tests, the vitals tests and the schema tests pass. Nothing in it has been run against a real fault. I haven't run the whole suite, and bun x tsc --noEmit printed nothing.

Notes

stopped closed without shipping deploy 2565b4b

opened this

The failure-domain map, the drills, the Resilience page and the vitals need are all in, and the new tests, the vitals tests and the schema tests pass. Nothing in it has been run against a real fault. I haven't run the whole suite, and bun x tsc --noEmit printed nothing.

My first run declined because docs/DOMAINS.md, src/kernel/domains.ts and a Resilience page didn't exist. I wrote them here. The map's contents are my draft: the phrases the forge must say and the recovery times in it are for a person to review.

What changed

  • The map: src/kernel/domains.ts and docs/DOMAINS.md hold seven domains, each with what breaks, the phrases the forge must say, minutes until back, the owner's action and its drill. test/domains.test.ts fails if the doc and the data disagree.
  • Which domains are drilled: compute (the pod), edge (the tunnel), model credential and runner. State, snapshot store and identity name no drill and say why on the page. State and identity can't be drilled without harm. The snapshot store is already read by the restore drill.
  • Recording and verdict: scripts/drills/run.ts <domain> is the operator's standby script. It prints the fault to cause and waits for Enter. It then polls /api/v1/health and / once a second, keeping what they said while the forge is not healthy. When the forge is back, it posts the result to a new admin-only endpoint, POST /api/v1/drills. The forge judges the result in src/kernel/drills.ts. It is green when the recorded words contain one of the domain's phrases and the forge was back in time. Otherwise it is red, with the reason. Rows go in a new additive table, domain_drill.
  • Settings → Resilience: src/web/pages/resilience.ts shows each domain's map entry, its last drill with the verdict, and the command to run.
  • Vitals: a drilled domain with no drill in eight days becomes a need. That only applies once the forge itself is older than eight days, so a fresh forge isn't red. This adds one query to vitals, so test/vitals.test.ts now expects 6 queries instead of 5. That change is to the test, not a bug.

What I left out

  • The forge doesn't cause any fault itself, and nothing is scheduled. The issue says drills are scheduled like the restore drill, but with all four drills needing the operator, only the eight-day reminder runs on a schedule.
  • The runner and credential drills are also standby scripts the operator runs.
  • src/cloud/edge.ts (the static "restarting" page) isn't touched. The compute drill goes red until the edge serves a page containing "the forge is restarting".
  • No dependencies were added.

To try it

  1. Run FORGE_URL=… FORGE_TOKEN=<admin token> bun scripts/drills/run.ts compute.
  2. Delete the pod, then read the result at Settings → Resilience.
  3. For the tests, run bun test test/domains.test.ts.

Closes #1195

Show 9 earlier items

7 earlier comments · 4 events
commented

Handed to a person: the reviewer asked for changes 3 times without approving, so the crew stops here. Nothing is closed or parked; approve it, push a fix, or say what to do.

  1. sentinel: The drills can't give a true verdict as written, and the change adds red noise to every production forge. Fix the first item first. 1. High: the drill deadlocks on itself. undrilled() adds a vitals need for every drilled domain on any forge older than eight days. Production is older than that,…
  2. sentinel: Security is sound. The write is admin-only through requireScope (same-origin for a cookie, admin scope for a token). The body is capped by the bytes actually read (body() → readBounded). Input is validated in recordDomainDrill, the SQL is parameterised, and the page escapes everything it pri…
  3. sentinel: The security side holds up. POST /api/v1/drills reads its body through the bounded body(), checks the admin scope and that the caller is an admin, and has a test that refuses another origin. GET /api/v1/drills, the page and the MCP tool are all admin-only. Every write is validated at the bound…
commented

I merged main into this branch and pushed it. The only conflict was in src/core/schema.ts, and the type check and the 7 test files that cover the change pass.

  • Conflict: main added a placements migration as number 84, which collided with my domain-drills migration, also 84. I kept both. Placements stays at 84 and domain_drill is now migration 85, appended after it, with its comment renumbered to match.
  • Tests: I ran domains, drill-verdict, mcp, schema-additive, schema-migrations, thoughts and spawn-placement: 75 pass, 0 fail. I did not run the full bun test. It ran past 10 minutes in the sandbox, so I stopped relying on it, and the forge's check will run the whole suite on this push.
  • Unchecked: I did not scan the rest of the test suite for tests that depend on the migration count. The grep I ran turned up nothing that hard-codes 84.

The pull's description is otherwise unchanged from before the merge.

the crew's run was interrupted: restart, resumes on the next pass — cancelled
the crew's run was interrupted: restart, resumes on the next pass — cancelled
Changes requested — before the latest push

The core of this is sound. The map is plain data and a test keeps it in step with the doc. The POST checks scope and admin, its body is capped by the bytes read (body() → readBounded), the same-origin and non-admin refusals are tested, and the page escapes through html. It still misses the bar in three places, and I could not check the preview: from my sandbox the preview host refuses connections and the screenshots under /data/looks are unreadable, so nothing here was confirmed by eye.

Fix first: the README. Add a short section next to the Backups/drill text around README.md:536. It should cover the three drills and the command FORGE_URL=… FORGE_TOKEN=<admin token> bun scripts/drills/run.ts compute|edge|runner, Settings → Resilience, GET/POST /api/v1/drills (admin only), and the MCP drills tool. It should also say whether the terminal has a view, the way the Backups section says "The terminal has no backups view". Right now the README does not mention any of this.

Second: the MCP drills tool has no test. The pull itself says so. Add one in test/mcp.test.ts: an admin's call returns domains with last, and a non-admin's call returns forbidden. Adding the name to the pinned list does not test the gate.

Third: the runner verdict is circular. In isDown, the runner counts as down only while health carries a queue: cause, and words are recorded only while it is down. So the recorded health always contains queue:check (or another queue cause), and the phrase check can never fail. The drill can only be red on time, so it does not test what the forge says. Either judge the runner on the board's words ("behind one lane") or say plainly in DOMAINS.md that the runner verdict measures time only.

Smaller points:

  • resiliencePage rebuilds what drillMap() already returns. Have it call drillMap() so the page, the API and MCP really are one answer, as the drillMap comment says.
  • The page prints both "Older than eight days" on each row and the overdue line in the footer. Keep one of them.
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

Understood. I'm stopping on #1720 and starting nothing more there until someone says what to try.

The last push, e9b1494b, is on the branch with sentinel's three requested fixes and the smaller points. It has not been checked by the forge's full run yet. I never finished a full bun test locally, because it ran past the timeout and I stopped it. The two suites I touched pass, as does the type check.

If the next run should try something different, tell me what. The runner verdict is the likeliest point of disagreement: I judge it on the board's words alone, rather than saying in DOMAINS.md that it measures time only.

Changes requested — before the latest push

Security and tests look right (admin-only reads and write, bounded body, validated input, escaped page, MCP drills test now present). I could not open the preview or the pictures from my sandbox, so I judged from the code. Two misses against the bar.

  1. Fix first: the terminal door. The README says "The terminal has no drills view". The bar is that what a person can do on the page they can do in the terminal, and the Resilience page is admin-only reading. Add a drills read to the terminal (admin sees the map with each last verdict and the overdue line; a guest sees nothing), reading the same drillMap(), with a test for the admin and the guest, and say how in the README.
  2. scripts/drills/run.ts: if the forge never goes down (an idle forge for the runner drill, where a queue cause only appears after a check has waited, or a fault that was not caused), the loop polls for an hour, then posts backMs of about an hour with empty words. That records a red that blames the forge. If wentDown never became true, print that the fault was not seen and exit non-zero without posting. For the runner drill, name in the drill sentence and in DOMAINS.md that a check must be queued (push something), and count backMs from Enter so the detection delay is not free.

Smaller: the 502/503/504 phrases are substring matches over the whole health text, so a number elsewhere in the JSON can satisfy them; match the status line (heard() starts with the status) instead.

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

scout only (reviewers: not for you): the check on this pull is red on "check failed: does not merge into main: src/core/schema.ts"; fix it on this branch and push, or say in one line why the red is not yours.

commented

Each failure domain now has a drill, and the forge's own words are recorded and judged against docs/DOMAINS.md. This push addresses all of @juniper's points and the red merge check. tsc is clean and bun test on test/domains.test.ts and test/mcp.test.ts passes (38 tests). I did not run the whole suite; the forge's check does that.

  • Merge conflict: main took migrations 85–88 in src/core/schema.ts, so the domain_drill table is now migration 89, appended last.
  • Terminal drills view: an admin gets a Drills command in the palette (src/tui/screens/drills.ts). It reads the same drillMap() as the page, API and MCP tool, and shows each domain's last verdict and the overdue line. A non-admin or guest is not offered it. A new test covers the admin, a non-admin and a guest, and the README says so.
  • scripts/drills/run.ts when the fault is never seen: if the forge never went down in an hour, the script prints that the fault was not seen, exits 1 and posts nothing. backMs now counts from Enter, so the delay in noticing the fault is not free. The runner drill's sentence (in domains.ts and docs/DOMAINS.md) now says to push something so a check is queued. The README says the same.
  • 502/503/504 matching: status-code phrases now match only at the start of a status line, not anywhere in the health text. A new test covers a 502 inside a JSON body (red) and a real 502 status line (green).

I left the script's loop and its hour cap as they were. I did not add a test for the script's exit path, since it needs a live forge and Enter on stdin.

To try it, run FORGE_URL=… FORGE_TOKEN=<admin token> bun scripts/drills/run.ts compute|edge|runner. Then look at Settings → Resilience, or open the terminal as an admin and pick Drills.

commented

Parked by the crew: the check failed ("a stalled check queue says what the runner drill listens for") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs