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

A check handed to a runner runs the base commit's gate first, the same as a local check #15294

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Checks that run on a runner now run the base commit's scripts/gate.ts before the pull's own command, the same as local checks (#15255, #15284). Before this, a pull checked on a runner was judged only by its own gate.

Notes

shipped production is serving it deploy b03b44b

opened this

Checks that run on a runner now run the base commit's scripts/gate.ts before the pull's own command, the same as local checks (#15255, #15284). Before this, a pull checked on a runner was judged only by its own gate.

What changed

  • src/checks/base_gate.ts gets withBaseGateFrom(command, source, base, blob), a pure function that uses the existing withBaseGate. When runsAsBaseGate holds, the runner job's check step:
    1. writes scripts/.gate-base.ts from the base commit with git show <base>:scripts/gate.ts (the runner already fetches the base for giveHistory);
    2. stops with "base gate: … is not <base>'s scripts/gate.ts" if git hash-object on that file does not match the blob id the forge read from its own bare repository;
    3. runs bun scripts/.gate-base.ts --base-only && <command>.
  • Why it is built this way:
    • The file is written in the check step, after install, and checked against the forge's blob id. So neither the pull's install scripts nor a changed object in the runner's .git can replace it.
    • The job carries only the commit id and the blob id, never the 68 KB gate source, so the job stays small even when split into shards.
    • Ids that are not plain hex leave the command as it was.
  • src/checks/tier_runner.ts, in tryRunner, reads the base gate and its blob id once. If the base's gate should run but its blob id cannot be read, the check is not sent to a runner and runs locally with the base gate instead. tryRunner takes an optional send argument (default runRunnerStep) so a test can pass in a fake runner.
  • Unchanged: when the base's gate does not have --base-only (other repositories, older gates), the command is unchanged.
  • docs/features/gate-bypass.md: one line saying runners are covered, and the runner case is gone from "Not done".

Test: test/check-runner-base-gate.test.ts. It needs no gate-list change, because every test/*.test.ts is gated. It calls tryRunner with a fake runner and runs the job's check step with /bin/sh in a tree checked out the way the runner checks out a job. It checks that:

  • the written file is the base's, not the pull's;
  • the base's gate is what runs;
  • a blob that does not match is refused before the check runs;
  • an older base gate leaves the command unchanged.

With the tier_runner.ts change reverted, 2 of its 4 tests fail.

Run here: bun scripts/gate.ts --fix (nothing to rewrap) and bun x tsc --noEmit both pass. bun scripts/fast.ts picked 3,301 files (an estimated 278 minutes), so I did not run its list. I ran the four test files that cover this code instead, all passing (31 tests): the new one, check-base-gate-step, gate-base-list and checks-runner-placement.

Left out:

  • The cell images and the runner program are unchanged. The step needs git inside the cell, and the cell tools already include it.
  • The shard runner, the release workflow and the chart are untouched.

To try it: bun test test/check-runner-base-gate.test.ts

🤖 Generated with Claude Code

Closes #15291

1 earlier comment · 1 event
commented

Checks that run on a runner now run the base commit's scripts/gate.ts before the pull's own command, the same as local checks (#15255, #15284). Before this, a pull checked on a runner was judged only by its own gate.

What changed

  • src/checks/base_gate.ts gets withBaseGateFrom(command, source, base, blob), a pure function that uses the existing withBaseGate. When runsAsBaseGate holds, the runner job's check step:
    1. writes scripts/.gate-base.ts from the base commit with git show <base>:scripts/gate.ts (the runner already fetches the base for giveHistory);
    2. stops with "base gate: … is not <base>'s scripts/gate.ts" if git hash-object on that file does not match the blob id the forge read from its own bare repository;
    3. runs bun scripts/.gate-base.ts --base-only && <command>.
  • Why it is built this way:
    • The file is written in the check step, after install, and checked against the forge's blob id. So neither the pull's install scripts nor a changed object in the runner's .git can replace it.
    • The job carries only the commit id and the blob id, never the 68 KB gate source, so the job stays small even when split into shards.
    • Ids that are not plain hex leave the command as it was.
  • src/checks/tier_runner.ts, in tryRunner, reads the base gate and its blob id once. If the base's gate should run but its blob id cannot be read, the check is not sent to a runner and runs locally with the base gate instead. tryRunner takes an optional send argument (default runRunnerStep) so a test can pass in a fake runner.
  • Unchanged: when the base's gate does not have --base-only (other repositories, older gates), the command is unchanged.
  • docs/features/gate-bypass.md: one line saying runners are covered, and the runner case is gone from "Not done".

Test: test/check-runner-base-gate.test.ts. It needs no gate-list change, because every test/*.test.ts is gated. It calls tryRunner with a fake runner and runs the job's check step with /bin/sh in a tree checked out the way the runner checks out a job. It checks that:

  • the written file is the base's, not the pull's;
  • the base's gate is what runs;
  • a blob that does not match is refused before the check runs;
  • an older base gate leaves the command unchanged.

With the tier_runner.ts change reverted, 2 of its 4 tests fail.

Run here: bun scripts/gate.ts --fix (nothing to rewrap) and bun x tsc --noEmit both pass. bun scripts/fast.ts picked 3,301 files (an estimated 278 minutes), so I did not run its list. I ran the four test files that cover this code instead, all passing (31 tests): the new one, check-base-gate-step, gate-base-list and checks-runner-placement.

Left out:

  • The cell images and the runner program are unchanged. The step needs git inside the cell, and the cell tools already include it.
  • The shard runner, the release workflow and the chart are untouched.

To try it: bun test test/check-runner-base-gate.test.ts

🤖 Generated with Claude Code

Approved

I opened the preview: / answers 200 with the home page (15 KB HTML, viewport meta set). This change touches no page, so there are no pictures to compare. I read the diff against issue #15291 and the pipeline direction, but did not run the tests myself. It is a small, single-purpose change. The job carries only the base commit and the blob id, both validated as hex before they reach a shell string. The file is written after install and verified with git hash-object. If the base gate cannot be named, the check stays off the runner. The tests drive tryRunner with a fake runner and run the step in a real tree. Two things I would do next: (1) drop the base! assertion and the step !== command comparison in tier_runner.ts by having withBaseGateFrom return a tagged result, so the fallback is explicit; (2) add a test that the runner path returns undefined with its log line when the blob id cannot be read.

commented

Left #15291 open: 1 unticked item remain (When runsAsBaseGate holds for the base's scripts/gate.ts, the runner job's check step starts with bun scripts/.gate-base.ts --base-only, and that file holds the base commit's content. The job either carries the base gate's source in a step that writes the file before the check, or carries the base commit so the runner writes it from git show <base>:scripts/gate.ts. The forge cannot write into the runner's tree the way runTier does.).

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs