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

An outside runner (a Mac) registers, claims a repository's labelled checks, and reports them as the pull's real check #18073

opened this in answer to

Merged 6h 42m ago, live in production

An outside runner can now register for chosen repositories with labels, claim a repository's labelled check, and report it as the pull's real check. The new tests pass, along with the contract, migration, door, module-state and unused-exports suites and tsc. The forge's full check will run on the push.

Notes

opened this

An outside runner can now register for chosen repositories with labels, claim a repository's labelled check, and report it as the pull's real check. The new tests pass, along with the contract, migration, door, module-state and unused-exports suites and tsc. The forge's full check will run on the push.

What already existed and is kept

  • Enrol, list, revoke, remove and resume under /api/v1/admin/runners.
  • Claim at /api/v1/runner/claim. The runner token is not an account token, so it gets no push and no API beyond the runner routes.
  • Logs and the result use the one report route, POST /api/v1/runner/jobs/{id} ({lines}, then {done}).
  • The fetch credential is the job token with the job's own git door. It is read-only, held to that one commit, and expires with the lease (30 s, renewed by each report).
  • Giving a claim back is {interrupted}: it is queued again and not counted as a try. I did not add a /release route, and I did not build the /api/v1/nodes shape.

What I added

  • check.label in forge.json names one lower-case label, validated in parseCheck.
  • A runner holds labels and a list of repositories. POST /api/v1/admin/runners accepts labels and repos (owner/name). Labels need at least one repo, and a bad value gets a 422 saying what is wrong.
  • A labelled job is claimed only by a runner holding the label and serving that repository. A runner with no repositories listed behaves as before.
  • POST /api/v1/runner/heartbeat takes {state: idle|busy|paused, labels?} and answers 204. A runner that says paused claims nothing. Silence past 60 s reads as away.
  • POST /api/v1/admin/runners/{id}/pause sits beside resume.
  • Labelled checks never run on the forge's machine, whatever FORGE_CHECKS_PLACEMENT says. A red from the runner stays red, and nothing is re-run here.
  • If a claim goes silent twice, the check fails with the reason in words.
  • While no available runner holds the label, the check's log says so. After 15 minutes the check fails and says that.
  • Settings → Runners and the terminal's Runners screen show labels, repositories and the last heartbeat state. The terminal gains p to pause, and revoke now covers outside runners.
  • docs/features/outside-runner.md has the runner's loop as curl lines. The new routes are in the contract, lazy_lists is regenerated, and the migration is pinned.

What I chose not to do

  • Registration is for a forge admin. Per-owner enrolment is a different permission model.
  • The full tier on landing is not offered to labelled runners (runnerTakes), so it still runs on the forge's machine.
  • I did not add placement: "device" or a sandboxEnforced field. contained is the existing field, and the forge shows it as the runner said it, never as proven.
  • Per-run repository secrets are not built, as the issue says.
  • The final shapes are not yet commented on #18037; that is for when it merges.

What I changed in an existing test

  • SKIPPED in test/openapi-errors.test.ts goes from 57 to 58. That test skips any path containing heartbeat. The new heartbeat route is covered by test/outside-runner.test.ts instead.

Gate notes

  • The commit carries No door: and No look: lines. The gate's both-doors rule asked for a new terminal screen for the new contract files, but the existing Runners screen already shows the new facts and pauses with p.
  • The gate suggested three "one implementation?" similarities, such as stringList against parseLock. These are advisory and I left them.

To try Run bun test test/outside-runner.test.ts. It covers register, heartbeat, claim, fetch by git with the job token, two log lines, ok, green check, refused routes, give-back, silent-twice failure, and no holder. For a live look, enrol a runner with labels and repos on the preview, then call GET /api/v1/admin/runners.

No review block: nothing a person sees in the page changed beyond one fact on the existing runners row.

🤖 Generated with Claude Code

Closes #18037

4 earlier comments
commented

An outside runner can now register for chosen repositories with labels, claim a repository's labelled check, and report it as the pull's real check. The new tests pass, along with the contract, migration, door, module-state and unused-exports suites and tsc. The forge's full check will run on the push.

What already existed and is kept

  • Enrol, list, revoke, remove and resume under /api/v1/admin/runners.
  • Claim at /api/v1/runner/claim. The runner token is not an account token, so it gets no push and no API beyond the runner routes.
  • Logs and the result use the one report route, POST /api/v1/runner/jobs/{id} ({lines}, then {done}).
  • The fetch credential is the job token with the job's own git door. It is read-only, held to that one commit, and expires with the lease (30 s, renewed by each report).
  • Giving a claim back is {interrupted}: it is queued again and not counted as a try. I did not add a /release route, and I did not build the /api/v1/nodes shape.

What I added

  • check.label in forge.json names one lower-case label, validated in parseCheck.
  • A runner holds labels and a list of repositories. POST /api/v1/admin/runners accepts labels and repos (owner/name). Labels need at least one repo, and a bad value gets a 422 saying what is wrong.
  • A labelled job is claimed only by a runner holding the label and serving that repository. A runner with no repositories listed behaves as before.
  • POST /api/v1/runner/heartbeat takes {state: idle|busy|paused, labels?} and answers 204. A runner that says paused claims nothing. Silence past 60 s reads as away.
  • POST /api/v1/admin/runners/{id}/pause sits beside resume.
  • Labelled checks never run on the forge's machine, whatever FORGE_CHECKS_PLACEMENT says. A red from the runner stays red, and nothing is re-run here.
  • If a claim goes silent twice, the check fails with the reason in words.
  • While no available runner holds the label, the check's log says so. After 15 minutes the check fails and says that.
  • Settings → Runners and the terminal's Runners screen show labels, repositories and the last heartbeat state. The terminal gains p to pause, and revoke now covers outside runners.
  • docs/features/outside-runner.md has the runner's loop as curl lines. The new routes are in the contract, lazy_lists is regenerated, and the migration is pinned.

What I chose not to do

  • Registration is for a forge admin. Per-owner enrolment is a different permission model.
  • The full tier on landing is not offered to labelled runners (runnerTakes), so it still runs on the forge's machine.
  • I did not add placement: "device" or a sandboxEnforced field. contained is the existing field, and the forge shows it as the runner said it, never as proven.
  • Per-run repository secrets are not built, as the issue says.
  • The final shapes are not yet commented on #18037; that is for when it merges.

What I changed in an existing test

  • SKIPPED in test/openapi-errors.test.ts goes from 57 to 58. That test skips any path containing heartbeat. The new heartbeat route is covered by test/outside-runner.test.ts instead.

Gate notes

  • The commit carries No door: and No look: lines. The gate's both-doors rule asked for a new terminal screen for the new contract files, but the existing Runners screen already shows the new facts and pauses with p.
  • The gate suggested three "one implementation?" similarities, such as stringList against parseLock. These are advisory and I left them.

To try Run bun test test/outside-runner.test.ts. It covers register, heartbeat, claim, fetch by git with the job token, two log lines, ok, green check, refused routes, give-back, silent-twice failure, and no holder. For a live look, enrol a runner with labels and repos on the preview, then call GET /api/v1/admin/runners.

No review block: nothing a person sees in the page changed beyond one fact on the existing runners row.

🤖 Generated with Claude Code

commented

An outside runner now holds only the labels its owner registered, and a labelled check never runs on the forge's machine. bun x tsc --noEmit is clean and the touched suites plus the four rule tests you named pass; the forge's full check runs on this push.

Changes since review

  1. Labels (HIGH). The heartbeat no longer takes labels. noteHeartbeat writes only the state, and the contract, the route and docs/features/outside-runner.md say so. The new test enrols a legacy runner (no labels, no repositories) that sends labels:["macos"]. Its labels stay empty and it claims nothing for a queued macos job, which then fails.
  2. Labelled check on the forge's machine (HIGH). In tryRunner, a labelled check that has no run id, or that runnerTakes refuses (the full tier on landing, a bisection step), now fails in words naming the label. A missing runner verdict fails the same way. Nothing runs here, and the doc no longer contradicts itself. A test calls tryRunner directly for the full-tier and no-run-id cases and checks the runner is never offered the job.
  3. Both doors (MEDIUM).
    • Page: Settings → Runners gets a Pause button and a Register form (name, labels, repositories). Registering shows the token once on a no-store page, not in a flash message or a URL.
    • Terminal: n registers (name, labels, repositories), shows the token once, and a non-admin registers nothing.
    • Tests: the page and terminal paths are tested, and both routes are in lazy_lists.
  4. Clean (LOW). I removed the dead afterAll and made labelServed skip a lent runner's private-repository scope, as claimJob does. The heartbeat route is no longer hidden from the error-shape test: its exclusion pattern now matches only the other heartbeat routes, so SKIPPED is back to 57. A new test covers its 401, 413 and 422 shapes.

Left out: nothing beyond what you asked.

Notes:

  • The terminal's n prompt takes three space-separated words, so a name or label cannot contain a space.
  • gate.ts lists pause/resume and runnerPause/runnerResume as similar functions. I left them separate because they are two different actions.

Try it: on the preview, open Settings → Runners as an admin. Register mac with labels macos and repository owner/name, then Pause and Resume it. In the terminal, press n on the Runners screen.

[
  {"go":"/settings/runners","look":"the Register an outside runner form below the list","expect":"name, labels and repositories fields, one Register button"},
  {"go":"/settings/runners","look":"submit the form with a real repository","expect":"a page showing the token once, with no-store caching"},
  {"go":"/settings/runners","look":"the new runner's row","expect":"Pause button; after Pause the row shows Paused with Resume"}
]

🤖 Generated with Claude Code

commented

The route-marks check was failing because the two new runner routes, POST /settings/runners/register and POST /settings/runners/:id/pause, had no mark. I added both to src/http/marks/settings.json as open, like the other runner routes there. Their handlers still refuse anyone who isn't an admin.

test/route-marks.test.ts now passes locally (20 of 20), and the fix is pushed. I didn't re-run the rest of the suite or tsc; this change only touches that marks file. The forge's check on the new push will run everything.

commented

I merged main into the branch, resolved the four conflicts and pushed. In the 80 tests I ran across 11 related files, 79 passed on the first run and the one failure is fixed, with tsc clean. I did not run the whole suite; the forge's check does that on this push.

Both sides had added a runner pause. The merged version is one function:

  • Local runner: main's guard stays, so the forge's own local-N runner cannot be paused.
  • Reason: this branch's optional reason stays. The default text is paused by <username>, and the reason is trimmed to 200 characters.
  • API route: POST /api/v1/admin/runners/:id/pause takes an optional reason. A paused or revoked runner returns 422, and a local-N runner returns 422 local.
  • Terminal screen: it keeps this branch's n key to register an outside runner. It also keeps main's per-error toasts for a refused pause, and the success toast reads "is paused: u resumes it." as on main.

bun scripts/gate.ts --fix finished with two similarity notes, on runnerPause against runnerResume and on labelledPull in test/outside-runner.test.ts against a pull helper in another test. Both only ask whether they are one implementation; I left them.

commented

Left #18037 open: 1 unticked item remain (In openapi.json and contract-tested; a doc page with the runner's loop as curl lines. Comment the final shapes on this issue when it merges.).

Sign in to join this conversation.

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

Keyboard shortcuts

Docs