Skip to content

fix(ci): skip the backend gate on a zero-file PR, and fail it instead - #793

Merged
athvin merged 2 commits into
mainfrom
ci/empty-pr-skip
Nov 7, 2026
Merged

athvin merged 2 commits into
mainfrom
ci/empty-pr-skip

Conversation

@athvin

@athvin athvin commented Nov 7, 2026

Copy link
Copy Markdown
Owner

What

A pull request that changes no files ran the entire Rust gate — lint, entities, every test shard, cargo-deny and both DuckLake e2e matrices — to prove a tree byte-identical to main. ~10m of wall clock across the compile matrix and ~0.6 GB of sccache S3 egress per run, for nothing.

claim-ticket opens exactly that shape on purpose: a draft PR pushed from an empty commit, so a ticket claim is visible on GitHub before any code exists. Every claim paid that bill.

Why it happened

rust.yml's is the only detect in the repo built as a denylist, and an empty path list inverts through it. The counting pipelines re-expand the changed list with printf '%s\n' "$changed", which for an empty string emits one blank line; a blank line matches no exemption, so grep -cv reported one non-exempt path:

$ git show a241585b:scripts/ci/detect-paths.sh > old.sh
$ . old.sh && printf '%s\n' "" | detect_classify
code=true
erd=true
drift=true

The four allowlist detects — frontend, infra, images, devcontainer — never had the bug, because zero paths is zero matches there. Measured: those four already skipped a zero-file PR correctly, so rust.yml was the whole cost.

The change

  1. detect_classify guards the empty case ahead of the counting. The test is a plain -z because changed="$(cat)" has already dropped the trailing newline — an empty stdin and a single-newline stdin both arrive as the empty string. The compile jobs then report skipped, which branch protection accepts, same as a skills-only PR.

    Safe in the direction that matters: an empty base...head means head's tree equals the merge base, so there is provably nothing to compile.

  2. A new empty pull request job fails on it. The skip alone would leave such a PR green, with every required context satisfied having proved nothing. detect publishes empty as its own output because the two answers go to opposite places: the compile tier skips, this job fails.

    Deliberately not a required status check. A draft is already unmergeable so there is nothing for it to block; adding a required context is only safe after the job has reported on main; and non-required is what lets the red clear itself — the first real commit flips empty to false, the job skips, and the gate takes over.

Verification

  • detect-paths-test.sh: 36/36, with the new a pull request that changes nothing case.
  • Mutation-tested. Neutering the guard to [ -z "$changed" ] && false fails exactly one case (pass=35 fail=1), so the guard is load-bearing rather than decoration.
  • rust-detect.sh driven end-to-end on all three events: empty PR → code=false empty=true; this branch vs main → code=true empty=false; push → code=true empty=false.
  • workflow-shell-check (the 2-line run: is inside the 3-line budget, no control flow), actionlint + S9 pins (438 uses:, all pinned — the new job adds none, it needs no checkout), scripts-home-check, skills-check.

One unrelated commit, and why it is here

4699821c regenerates two skill-inventory blocks that are already stale on main: a241585b ("enable skill") set disable-model-invocation: false on claim-ticket without re-running the generator. Verified against an untouched git archive of origin/main — regen there changes exactly those two lines, so lint's drift step is red on main and every branch cut from it inherits that. It cannot be separated out without leaving this PR red.

The third file in that commit, required-checks.md, is this branch's: its generated table enumerates every job in every hand-written workflow, so the new job has to appear there.

bmoore813 and others added 2 commits November 7, 2026 14:47
A pull request that changes no files ran the whole Rust gate — lint,
entities, every test shard, cargo-deny and both DuckLake e2e matrices —
to prove a tree identical to `main`. ~10m of wall clock across the
compile matrix and ~0.6 GB of sccache S3 egress per run, for nothing.

`claim-ticket` opens exactly that shape on purpose: a draft PR pushed
from an empty commit, so a ticket claim is visible on GitHub before any
code exists. Every claim paid the bill.

The cause is that `rust.yml`'s is the only `detect` in the repo built as
a DENYLIST, and an empty path list inverts through it. The counting
pipelines re-expand the changed list with `printf '%s\n' "$changed"`,
which for an empty string emits ONE BLANK LINE; a blank line matches no
exemption, so `grep -cv` reported one non-exempt path and `detect`
classified `code=true erd=true drift=true`. The four allowlist detects —
frontend, infra, images, devcontainer — never had the bug, because zero
paths is zero matches there; measured, those four already skipped.

`detect_classify` now guards the case ahead of the counting, and the
test is a plain `-z` because `changed="$(cat)"` has already dropped the
trailing newline. An empty `base...head` means head's tree equals the
merge base, so the skip is safe in the direction that matters: there is
provably nothing to compile.

A skip alone would leave such a PR GREEN, with every required context
satisfied having proved nothing, so `detect` also publishes `empty` and
a new `empty pull request` job fails on it. It is deliberately NOT a
required status check: a draft is already unmergeable, adding a required
context is only safe after the job has reported on `main`, and
non-required is what lets the red clear itself — the first real commit
flips `empty` to false and the gate takes over.

Mutation-tested: neutering the guard fails exactly the new case
(pass=35 fail=1), and HEAD's classifier really does answer `code=true`
on an empty diff.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two of these three are PRE-EXISTING DRIFT ON `main`, not a consequence
of this branch. `a241585b` ("enable skill") set
`disable-model-invocation: false` on `claim-ticket` without re-running
the generator, so the skill-inventory rows in `CLAUDE.md` and the
agent-skills standard still carry the `(user-invoked only)` tail the
generator now drops. Verified against an untouched `git archive` of
`origin/main`: regen there changes exactly those two lines, so the
required `lint` job's drift step is red on `main` and every branch cut
from it inherits that.

The third, `required-checks.md`, IS this branch's: its generated table
enumerates every job in every hand-written workflow, so the new
`empty pull request` job has to appear in it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@athvin
athvin merged commit 6d04e4b into main Nov 7, 2026
42 checks passed
@athvin
athvin deleted the ci/empty-pr-skip branch November 7, 2026 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants