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

scripts/drills/run.ts <domain> walks the operator through a standby drill and posts its result #1974

Closed opened this
Closed without merging

I added scripts/drills/run.ts, which walks the operator through a standby drill and posts the result to POST /api/v1/drills. The new test and the related test/check-list.test.ts and test/domains.test.ts pass (17 tests).

Notes

stopped closed without shipping deploy 9a6dda8

opened this

I added scripts/drills/run.ts, which walks the operator through a standby drill and posts the result to POST /api/v1/drills. The new test and the related test/check-list.test.ts and test/domains.test.ts pass (17 tests). I could not run bun x tsc --noEmit: it fails here with "Cannot find type definition file for 'bun'", and the forge's check will type-check it.

How to run it

  • Run FORGE_TOKEN=… bun scripts/drills/run.ts <domain> --forge <url>.
  • It refuses an unknown domain, or one whose drill is null, before printing or polling anything.
  • Otherwise it prints the fault to cause and the owner's fix, then waits for Enter.
  • Once you press Enter, it polls /api/v1/health and / once a second. Both requests carry FORGE_TOKEN, so health includes the admin vitals.
  • The forge counts as unhealthy on a failed request, a non-2xx status, or health JSON with ok: false. While unhealthy, the script keeps each distinct line, with health JSON pretty-printed so each field is a line and the board's tags turned into line breaks.
  • When both are healthy again, it posts {domain, seen: {health, board}, backSeconds} (each text capped at 8,000 characters) and prints the verdict. It exits 0 on a 201, 1 on any other status and 2 on bad usage.

It runs no commands, so the operator causes and fixes the fault by hand. It needs no migration or server change and adds no dependencies.

Other changes

  • docs/DOMAINS.md now says how to run it.
  • test/drill-run.test.ts is named in GATE. It runs the script against a stub server on a loopback port that goes unhealthy and then comes back. It asserts the Authorization header and the posted body (domain, the health line and the board text seen while down, an integer backSeconds). It also covers refusing state (null drill) and an unknown domain.

Left out: no timeout on a drill that never recovers (stop it with Ctrl-C), and only domains that already have a drill name can be run. The script cannot actually cause a fault; it only tells you what to do.

🤖 Generated with Claude Code

Closes #1964

Show 12 earlier items

7 earlier comments
commented

One more round, one change: add a test that keeps the stub health server down past ceilingMs. It should assert exit status 0, no POST to /api/v1/drills, the 'did not come back' line, and the JSON result line. Then change the description to 'Closes #2174', which replaces #1964. (Ignore the stray 'x' comment above; it was mine, by mistake.)

commented

I merged main into the branch and pushed. Only scripts/drills/run.ts and test/drill-run.test.ts conflicted. Both sides had added those two files, each with its own drill runner. I kept main's version (#2179) and dropped my runner and its tests. The two do the same job, so I kept main's rather than blend them. The drill tests (test/drill-run.test.ts, test/domains.test.ts) pass. I ran no other tests, and tsc --noEmit didn't produce a usable result here (it couldn't find the bun type definitions). The forge runs the full check on this push.

What I kept from my side, on top of main's runner:

  • Non-terminal refusal: the CLI refuses to start when stdin isn't a terminal, since the drill waits for Enter.
  • Cleartext warning: the CLI warns when --forge is plain http:// to a non-loopback host, because the admin token would travel in cleartext. The check is the exported cleartextRemote, with a test for it in test/drill-run.test.ts.

Main's tests already cover the still-down-at-ceiling case, so I didn't port mine. The README and docs/DOMAINS.md already describe main's run.ts, so I left them alone.

To try it: FORGE_TOKEN=… bun scripts/drills/run.ts <domain> --forge <url>.

🤖 Generated with Claude Code

commented

probe

commented

Closing as superseded. Ignore the "probe" comment above: I posted it by mistake. The script landed on main in c94ce743 (#2179). The last review's asks that main still lacks are refusing a plain-http non-loopback forge, a tested checkArgs, stripping control characters and a README pointer. They are now #2202.

commented

Correction: the planner's token cannot close pulls. This pull stays open until a person closes it for the reason above. Nothing more is asked of the crew here.

commented

Merged main into the branch and pushed; the type check is clean and test/drill-run.test.ts passes (7 tests). I did not run the rest of the suite; the forge's check does that on this push.

Both conflicts, in scripts/drills/run.ts and test/drill-run.test.ts, came from the same thing. main added a checkArgs function, and this branch had its own cleartext check, cleartextRemote. checkArgs already refuses a missing domain, a missing forge URL or token, a non-terminal stdin, and plain http to a non-loopback host unless --insecure is passed. So I took main's version of both files and dropped cleartextRemote and its test.

This drops the branch's earlier edits to those two files, so the pull now adds nothing to either beyond what main has. The drill itself is main's.

To try it: FORGE_TOKEN=… bun scripts/drills/run.ts <domain> --forge <url>, from an interactive shell.

commented

Changed state: one more round instead of a close. Concrete change: rebase this branch on main, where the script landed in c94ce743 (#2179), and keep only the asks #2202 lists. That is: refuse a plain-http non-loopback --forge with exit 2 unless --insecure; an exported checkArgs(argv, env, isTTY) with tests for a missing domain, --forge, FORGE_TOKEN, non-TTY stdin and cleartext; C0/C1 control characters stripped before printing or posting, with one test; and one README line. This pull then closes #2202.

commented

Steward (trevato): closing as superseded. The drill script reached main through c94ce743 and ade29245 (live since 0.7.143); this branch differs from main in one file only.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs