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

scripts/drills/run.ts <domain> walks the operator through a standby drill, posts its result, and says so when the forge never comes back #2179

opened this

Merged 50d 9h ago, live in production

bun scripts/drills/run.ts --forge now exists and walks an operator through a standby drill. The four new tests, the domains and check-list tests, and tsc --noEmit pass; the full gate has not run. What it does Before the drill: it refuses an unknown domain or one whose drill is null (printing the reason) and exits 1.

Notes

opened this

bun scripts/drills/run.ts <domain> --forge <url> now exists and walks an operator through a standby drill. The four new tests, the domains and check-list tests, and tsc --noEmit pass; the full gate has not run.

What it does

  • Before the drill: it refuses an unknown domain or one whose drill is null (printing the reason) and exits 1. Otherwise it prints the fault to cause and waits for Enter.
  • While down: it polls /api/v1/health and / once a second, sending FORGE_TOKEN, so the site-admin view of health is the one it reads. It says each distinct line the first time it appears.
  • Healthy again: the forge counts as down when either request fails or the health body says ok: false. Once it is healthy after having been down, the script posts {domain, seen:{health, board}, backSeconds} to POST /api/v1/drills and prints GREEN or RED with the reason, then a JSON line.
  • Still down at the ceiling (default one hour): it posts nothing and exits 0. It prints one sentence saying the forge did not come back, then the JSON line {"domain":…,"backSeconds":null,"posted":false,"ceilingSeconds":…}.
  • Refused or failed post: it prints the status and the forge's message and exits 1.
  • Constraints kept: no shelling out, no dependencies, no server change, no migration.

Tests (test/drill-run.test.ts): they run against a stub server on a loopback port. The clock, sleep, poll interval, ceiling and the Enter wait are all injected, so nothing waits in real time. They cover down-and-back (asserting the posted body), stays down (status 0, no post, the message, the JSON line), a refused post, and an unknown domain or one with no drill.

docs/DOMAINS.md gained a "Running a drill" section with one full example command.

Left out

  • scripts/gate.ts is unchanged. Since #2037 the gate is every test/*.test.ts minus EXCLUDED, and there is no GATE list to edit, so the new test file is gated automatically.
  • If the forge is already healthy and never goes down, the script keeps polling until the ceiling and then reports it did not come back. A fault shorter than one poll interval is missed.

🤖 Generated with Claude Code

Closes #2174

commented

I've pushed fixes for all four points juniper raised on #2179. The drill-run tests (5) and tsc --noEmit pass; the full gate hasn't run.

  • README: the "Keeping a domain drill" paragraph now ends with a sentence on running FORGE_TOKEN=… bun scripts/drills/run.ts <domain> --forge <url>, pointing at docs/DOMAINS.md.
  • Unused option: I removed polls from the test harness.
  • Redirects: scripts/drills/run.ts now treats any status below 400 as up, so a sign-in redirect from / no longer reads as down for the full hour.
  • Dedupe: lines are compared with their digit runs blanked, so a timestamp or counter doesn't count as a new line. The first form seen is the one printed and posted.

I added a test for the redirect and counter cases. It fails without the fix.

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs