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

A Mac can take a repository's checks and report them on the pull #17915

opened this in answer to

Merged 9h 19m ago, live in production

A machine outside the forge can now report a named check on a pull's head, and requirechecks counts it. The label-claiming runner and the per-run repository secrets are not built, so forge-apple's Mac build still can't claim its runs or read the App Store Connect key through the forge.

Notes

opened this

A machine outside the forge can now report a named check on a pull's head, and require_checks counts it. The label-claiming runner and the per-run repository secrets are not built, so forge-apple's Mac build still can't claim its runs or read the App Store Connect key through the forge.

I ran outside-checks.test.ts, the OpenAPI, boot-lazy and doors tests, the dead-code, module-state and route-timing tests, and the migration tests. They pass, and so does tsc --noEmit. The gate has no failing rule. It still asks "one implementation?" about pullHeadOid and the test helper person; I kept both. I did not run the full suite: scripts/fast.ts named 3,727 files, so I stopped that run and left the full check to the forge.

What changed

  • Route: PUT /api/v1/repos/:owner/:name/pulls/:number/checks/:check (e.g. macos) takes { state: pending|ok|failed, summary?, url?, oid? }. Reporting again under the same name replaces the report. The route and its OpenAPI entry are in src/http/api/outside_checks.ts.
  • Storage: a report is a row in a new outside_check table, not a queued run, so no scheduler picks it up. checksForHead and checksForHeads in src/core/runs.ts return it as a check run of the head. The head is green only when the forge's own check and every named report are ok. The pull page, the terminal pull screen and the merge gate read the same verdict, so no second rule was added.
  • Guards:
    • The caller needs an rw token and write access.
    • A crew agent is refused, so the crew cannot turn a check green.
    • The pull must be open.
    • A cross-origin session is refused.
    • If oid is not the current head, the answer is 409 head_moved and nothing is written.
    • Name, summary, link and oid are validated at the boundary.
  • Event: each report appends a check.reported event.
  • Docs and tests: how-to in docs/features/outside-checks.md; tests in test/outside-checks.test.ts.

Left out

  • Label-based claiming of a repository's declared check runs by a registered runner. A Mac can post results today, but it must be told what to build.
  • Repository secrets readable only by such a runner for one run, with secret.read logging.
  • The link is shown after the summary text rather than as a separate field. A posted check has no run log, so a run link to it would 404.
  • A new terminal screen: the existing pull screen already shows the verdict, so the commit says No door:.

Reused: body, requireScope, loadPull, canWrite, checkSummary and newestOfEachKind, and the migration-pin and lazy-list scripts. I also exported pullHeadOid from api.ts.

Try it: run curl -X PUT -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{"state":"ok","summary":"uploaded"}' $FORGE_URL/api/v1/repos/OWNER/NAME/pulls/N/checks/macos, then GET …/pulls/N/checks and look at the state.

🤖 Generated with Claude Code

Closes #17910

9 earlier comments
commented

A machine outside the forge can now report a named check on a pull's head, and require_checks counts it. The label-claiming runner and the per-run repository secrets are not built, so forge-apple's Mac build still can't claim its runs or read the App Store Connect key through the forge.

I ran outside-checks.test.ts, the OpenAPI, boot-lazy and doors tests, the dead-code, module-state and route-timing tests, and the migration tests. They pass, and so does tsc --noEmit. The gate has no failing rule. It still asks "one implementation?" about pullHeadOid and the test helper person; I kept both. I did not run the full suite: scripts/fast.ts named 3,727 files, so I stopped that run and left the full check to the forge.

What changed

  • Route: PUT /api/v1/repos/:owner/:name/pulls/:number/checks/:check (e.g. macos) takes { state: pending|ok|failed, summary?, url?, oid? }. Reporting again under the same name replaces the report. The route and its OpenAPI entry are in src/http/api/outside_checks.ts.
  • Storage: a report is a row in a new outside_check table, not a queued run, so no scheduler picks it up. checksForHead and checksForHeads in src/core/runs.ts return it as a check run of the head. The head is green only when the forge's own check and every named report are ok. The pull page, the terminal pull screen and the merge gate read the same verdict, so no second rule was added.
  • Guards:
    • The caller needs an rw token and write access.
    • A crew agent is refused, so the crew cannot turn a check green.
    • The pull must be open.
    • A cross-origin session is refused.
    • If oid is not the current head, the answer is 409 head_moved and nothing is written.
    • Name, summary, link and oid are validated at the boundary.
  • Event: each report appends a check.reported event.
  • Docs and tests: how-to in docs/features/outside-checks.md; tests in test/outside-checks.test.ts.

Left out

  • Label-based claiming of a repository's declared check runs by a registered runner. A Mac can post results today, but it must be told what to build.
  • Repository secrets readable only by such a runner for one run, with secret.read logging.
  • The link is shown after the summary text rather than as a separate field. A posted check has no run log, so a run link to it would 404.
  • A new terminal screen: the existing pull screen already shows the verdict, so the commit says No door:.

Reused: body, requireScope, loadPull, canWrite, checkSummary and newestOfEachKind, and the migration-pin and lazy-list scripts. I also exported pullHeadOid from api.ts.

Try it: run curl -X PUT -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{"state":"ok","summary":"uploaded"}' $FORGE_URL/api/v1/repos/OWNER/NAME/pulls/N/checks/macos, then GET …/pulls/N/checks and look at the state.

🤖 Generated with Claude Code

commented

A registered machine can now report a named check on a pull's head, which merging counts like any other check. This covers the API option from the issue. It is already on the branch, and the push said everything was up to date.

What changed

  • PUT /api/v1/repos/:owner/:name/pulls/:number/checks/:name takes {state: pending|ok|failed, summary, link} and records it on the pull's current head. GET …/pulls/:number/checks reads the reports back.
  • The head's runs carry the report, so require_checks and the head verdict count it. The terminal's pull screen reads the same verdict (checkSummary), so it shows the report with no separate terminal change. Every input is validated at the boundary, and the migration is pinned.
  • Tests are in test/outside-checks.test.ts, and the how-to is docs/features/outside-checks.md.

Review checks

  • bun x tsc --noEmit is clean.
  • The four tests the check named for this pull pass: unused exports, module-level state, job slices and outside-checks.
  • gate --fix made no changes. It flagged two near-duplicate helpers, pullHeadOid and a test person helper, and one over-long comment in src/core/runs.ts that the nightly rewrap will wrap on main. I left all three.

Left out, on purpose

  • The node register/claim/lease/log/finish protocol from the design comment. It is a larger change and the issue allows the API alone as the minimum.
  • Repository secrets that a runner can read for one run only, with secret.read logging. This is the part the App Store Connect key needs, so it comes next.

Try it PUT /api/v1/repos/trevato/forge-apple/pulls/N/checks/macos with {"state":"ok"}, then read GET …/pulls/N/checks.

commented

Un-parked by the owner (2026-12-04): finish this. A fresh check is asked for; please bring it up to date with main and fix what is red. The claiming runner is filed as the next slice and builds on this.

commented

This pull adds an API for a machine outside the forge to report a named check (pending, ok or failed, with a summary and link) on a pull's head. Nothing new needed committing this turn, so I pushed nothing.

The earlier red check on #17915, the Property 'feed' is missing type error in src/checks/outside_checks.ts, no longer shows up. bun x tsc --noEmit is clean on the current head.

The four checks you listed (dead code, process-wide state, UNTIMED jobs, duplicate imports) pass. I ran test/dup-imports.test.ts, test/unused-exports.test.ts, test/module-state.test.ts and test/job-slices.test.ts, plus test/outside-checks.test.ts: 22 pass, 0 fail.

bun scripts/gate.ts --fix changed nothing. It still prints three notes, none of which I acted on:

  • Long comment line: one is over 100 columns in src/core/runs.ts; the gate says the nightly rewrap handles it on main.
  • Similar functions: pullHeadOid in src/http/api.ts looks like liveHead in src/flow/why.ts, and the person helper in test/outside-checks.test.ts looks like mk in test/app-reads-etag.test.ts. The gate asks "one implementation?".

What I chose not to do: the issue's other asks are not built here. That means device nodes that claim runs, streamed logs from the machine, and run-scoped repository secrets such as the App Store Connect key. This pull covers only the named-check state that require_checks counts.

To try it: the how-to is in docs/features/outside-checks.md, and bun test test/outside-checks.test.ts runs the tests.

commented

A Mac, or any other machine outside the forge, can now report a named check on a pull's head. PUT /api/v1/repos/:owner/:name/pulls/:number/checks/:name takes {state: pending|ok|failed, summary?, url?, oid?}. The report counts in require_checks like any other run.

What I fixed this time: the branch was 67 commits behind main, and main had added a feed field to Run. The outside report's run lacked it, so tsc failed and two outside-check tests failed on the OpenAPI response check. I merged main and added feed: null.

Checks: after the merge, tsc is clean. These pass: test/outside-checks.test.ts, test/unused-exports.test.ts, test/module-state.test.ts and test/job-slices.test.ts. I did not run the rest of the suite; the forge runs it on push.

The three named tests: my files don't trip them. The change adds no module-level Map, Set or array, no job under during, and no export without a caller. The unused-exports test does list five unused exports in other files (src/http/crawl.ts, src/kernel/migrate.ts, src/spawn/watch_probe_default.ts, src/spawn/reach_default.ts). I left those alone.

Both doors: bun scripts/gate.ts --explain passes the both-doors rule. The first commit already says No door: because the terminal's pull screen reads the same head verdict, so it shows the report. The new commit also has a No door: line, since it changes no page, action or route. The how-to is docs/features/outside-checks.md.

Not done:

  • Agents can't report checks; only a person with write access can. That stops a crew member turning a check green.
  • A report for an older head is refused with 409 head_moved, never put on the new head.
  • I did not merge the duplicate test helper person (test/outside-checks.test.ts:30) with mk in test/app-reads-etag.test.ts. The gate only notes it.

Try it: PUT …/pulls/N/checks/macos with {"state":"ok"} using a writer's rw token, then GET …/pulls/N/checks.

🤖 Generated with Claude Code

commented

Still red on current main: event audience coverage > every kind the source emits is classified. Fix it and push.

commented

A machine outside the forge can now report a named check on a pull's head. Those three tests failed on the last push and now pass locally, along with 600 others in the files I re-ran. tsc is clean.

PUT /api/v1/repos/:owner/:name/pulls/:number/checks/:check takes {state: pending|ok|failed, summary?, url?, oid?}. require_checks counts the report like any other run on the head.

What failed and why:

  • Route index: the generated route index was stale. I regenerated it with bun scripts/openapi-routes.ts.
  • Event audience: the new check.reported event was not classified. I added it to the audience list in src/core/event_audience.ts.
  • Pull page SQL budget: the pull page was at 118 SQL statements against a budget of 115. It asks for a head's checks three times, and each ask cost one extra statement for the reports. checksForHead now reads the reports in a column of the same statement that reads the runs, so a head costs no extra statement. The list readers (checksForHeads) cost one batched statement however many pulls.

Not done:

  • Agents cannot report checks. Only a person who can write to the repository can, so a crew member cannot turn a check green.
  • A report for an older head is refused with 409 head_moved, never put on the new head.
  • A request with oid is not matched to a head here. The pull's head is read from git.
  • I did not merge the duplicate test helper person in test/outside-checks.test.ts with mk in test/app-reads-etag.test.ts. The gate only notes it.

Try it: PUT …/pulls/N/checks/macos with {"state":"ok"} using a writer's rw token, then GET …/pulls/N/checks.

🤖 Generated with Claude Code

commented

Still red on current main: fifty open pulls read their steps in the statements five do: one batch, not one per row. Fix it and push.

commented

A repository's checks now include what a machine outside the forge reported on the same head, and the batch read behind the pull lists no longer costs an extra SQL statement. That extra statement is why path-steps-batch and pulls-words went over their budgets (6 statements against a limit of 5).

What changed

  • Cause: the earlier commit in this pull added a second statement to checksForHeads, the function that reads many pulls' checks at once. It ran one query per chunk of pulls plus one for the outside reports.
  • Fix: checksForHeads in src/core/runs.ts now reads the runs and the outside reports in one statement. Each head's reports ride along as a JSON column and are merged newest-first with the runs.
  • Helper: the column builder in src/checks/outside_checks.ts is now outsideAsJson(issue, oid), which both the single-head and batch reads use.
  • Behaviour: unchanged apart from the statement count. A head with only outside reports still shows up.

Tests

  • path-steps-batch, pulls-words and the outside-check suites pass: 113 tests across 10 files. tsc --noEmit is clean.
  • I did not run the full suite; the forge's check does that on this push.

Left out

  • Each run row of a head repeats that head's reports column. That is fine while reports are rare, and I did not de-duplicate it.
  • The gate's remaining notes (comment wrapping, two lookalike functions) were advisory, and I did not act on them.

Try it Run bun test test/path-steps-batch.test.ts test/pulls-words.test.ts test/outside-checks.test.ts.

🤖 Generated with Claude Code

commented

All three review points are addressed and pushed. The outside-checks tests (10) and tsc pass. I did not run the full suite, so the forge's check on this push is its first run.

What changed

  • Reply: PUT …/pulls/:number/checks/:check now returns only { head, check, state }, which is what the OpenAPI reply declares. states is gone from the handler.
  • Row growth: recordReport now deletes the pull's reports for any older head before writing the new one. Rows stay bounded by the number of names on the current head. I added no cap on names per head; the reviewer said pruning was preferable.
  • Tests added in test/outside-checks.test.ts:
    • An agent session is refused with 403 and writes no row.
    • A closed pull answers 409 not_open, then the test reopens it.
    • Reporting twice under the same name leaves one row, each report appends a check.reported event, and the reply keys are exactly check, head and state.
    • A report stored under an older head is deleted when the current head is reported.

Left alone

  • The agent test sets is_agent on a second user. It does not use createAgent.
  • Gate notes, advisory only and not acted on: the person test helper duplicates mk in another test file, and pullHeadOid resembles liveHead. Two over-long comments sit in files I didn't touch, src/core/event_audience.ts and src/core/runs.ts.
  • The commit carries No door:. The only API change is dropping an undeclared field, so the terminal side and docs/features/outside-checks.md are unchanged.

To try

  • bun test test/outside-checks.test.ts.
Sign in to join this conversation.

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

Keyboard shortcuts

Docs