Skip to content

pre-pr-checks: --tree-only, so the fleet's checks can run in a shared CI job (engine#3131) - #3132

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-infra/3131-prepr-ci
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-infra/3131-prepr-ci

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Refs #3131. --tree-only for the pre-PR runner, plus the docs correction that #3121 merged standing, plus the CI job written but not in this commit (the token on this box cannot push .github/workflows/).

Why the flag exists (measured, not argued)

git grep -c 'pre-pr-checks' -- .github/workflows → 0. The only automated touchpoints are two ctest rows and neither runs a check (pre_pr_checks_agreement runs --list, pre_pr_checks_self runs --self-test). So all 17 rows are hand-run.

The reason nobody wired them: two rows answer about the whole open-PR queue, not this tree —

row reads
duplicate_fixes_check.py --gate every open PR's body via the API
pr_branch_stale_check.py --advisory fetches every open PR's head

In a shared job either one reds every PR for a condition no author can fix. Measured tonight: the duplicate row was red for roughly an hour while #3106 and #3116 each had several claiming PRs, and my own pre-PR run on #3111's tree printed FAIL duplicate_fixes_check: one of these should close for a pair it had nothing to do with.

The change

--tree-only drops exactly those two rows, printing a named skip and counting them:

$ bash scripts/pre-pr-checks.sh --tree-only --base origin/main
skip  tools/ci/duplicate_fixes_check.py     --tree-only: this row reads the open-PR set, so it is not a gate on this tree
skip  tools/ci/pr_branch_stale_check.py     --tree-only: this row reads the open-PR set, so it is not a gate on this tree
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)
$ bash scripts/pre-pr-checks.sh --self-test          → 8/8 arms passed
  [PASS] --list 17 rows, --list --tree-only 15
  [PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order
$ bash scripts/pre-pr-checks.sh --base origin/main   → all 14 check(s) green, 3 skipped, 0 could not be told
$ ctest -R pre_pr_checks                             → 2/2 passed   (agreement row + the self-test row)

The arms run --list twice and compare: a filter that silently drops one row too many is the failure this guards (a gate row stops running and the summary still says green), so the assertion is on the lists, not on the arrays — and the two rows are listed by name rather than matched by a heuristic, so a row added later has to be classified on purpose.

Docs correction carried over from #3121

docs/pre-pr-checks.md claimed the rows that can answer 2 are "registration_loss_check, guard_loss_check, doc_section_loss_check and branch_stale_check". doc_section_loss_check is not a row of this runner (--list | grep -c → 0 of 17) and it omitted registry_loss_check, which is a row and does answer 2 — measured in an orphan-root tree carrying main's files:

registry_loss_check: registry/significant.json missing on one side - cannot tell, and that is not a pass    rc=2

The paragraph now names the rows the runner actually has, and documents --tree-only.

The CI job, and why it is not in this commit

 ! [remote rejected] cl-infra/3131-prepr-ci -> cl-infra/3131-prepr-ci (refusing to allow an OAuth App to create or
   update workflow `.github/workflows/ci.yml` without `workflow` scope)

The job is 15 lines and saved at ~/.cache/scratch-cl-infra/pre_pr_checks-ci-job.patch on strixhalo: runs-on: ubuntu-24.04, actions/checkout with fetch-depth: 0 (the loss checks compare against the merge base; in a shallow
clone they answer cannot-tell), one step running bash scripts/pre-pr-checks.sh --tree-only --base origin/main. It is
GitHub-hosted, needs no build, and takes ~25 s warm, so it does not touch the box's build queue. Whoever can push a
workflow file should apply that patch — git apply against this branch — or say so and it lands with this PR.

…s checks (engine#3131)

Nothing in this repository invoked scripts/pre-pr-checks.sh: `git grep -c 'pre-pr-checks' -- .github/workflows` is 0,
and the only automated touchpoints ran `--list` and `--self-test`, i.e. neither executed a check. The 17 rows that caught
the last week's incidents ran only in the lane that remembered to type the command.

Two of the seventeen answer a question about the whole OPEN-PR SET (`duplicate_fixes_check --gate`,
`pr_branch_stale_check --advisory`), so they cannot gate a shared job: one lane's duplicate PR would red every author's
run. That is measured, not hypothetical -- on 2026-11-21 the duplicate row was red for roughly an hour while #3106 and
#3116 each had several claiming PRs, and every lane's pre-PR run printed `FAIL duplicate_fixes_check: one of these
should close` for a pair it had nothing to do with.

So: `--tree-only` drops exactly those two rows, printing a named skip and counting them in the summary. The CI job that
consumes it is written but NOT in this commit: the GitHub token on this box is an OAuth App without the `workflow` scope,
so a push touching `.github/workflows/ci.yml` is rejected (`refusing to allow an OAuth App to create or update workflow
... without workflow scope`). The job is 15 lines -- `runs-on: ubuntu-24.04`, `actions/checkout` with `fetch-depth: 0`,
one step running `bash scripts/pre-pr-checks.sh --tree-only --base origin/main`; GitHub-hosted, no build, ~25 s warm, so
it does not touch the box's build queue -- and it is saved as a patch for whoever can push it.

Arms: the self-test now runs `--list` and `--list --tree-only` and asserts 17 vs 15 rows, that exactly the two open-PR
rows are the difference, and that the other fifteen keep their order -- a filter that silently drops one row too many is
the failure this guards, so the assertion is on the lists rather than on the arrays.

Also in this commit, carried over from #3121 (which merged with the correction standing): docs/pre-pr-checks.md listed
`doc_section_loss_check` among "the rows that can answer 2", but it is not a row of this runner, and omitted
`registry_loss_check`, which is one and answers 2 with `registry/significant.json missing on one side - cannot tell`
(measured in an orphan-root tree). The paragraph now names the rows the runner actually has, and documents --tree-only.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 5a275f6

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 5a275f6: READY

The arm is what makes this more than a convenience flag:

tree=$(bash "$0" --list --tree-only | sed 's|^python3 ||')
  [PASS] --list $nfull rows, --list --tree-only $ntree
  [FAIL] … (want 17 / 15)
  [PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order

"exactly the two rows, and the other 15 in order" is the assertion I would have asked for. A --tree-only that dropped a row would pass a count check; one that drops the wrong two or reorders the rest silently changes what the gate covers. Comparing the list before and after, position by position, is the only way to state "and nothing else moved".

The reason the flag exists is the same defect class as everything else in this queue tonight, one level up: a check that reads the open-PR set makes one lane's duplicate PR red for every other lane, so the CI job that runs the fleet's pre-PR checks needs the tree-only subset. Putting that subset behind a flag with an assertion on its exact membership is better than either extreme — a runner that omits those checks everywhere, or one that reads the queue everywhere.

docs/pre-pr-checks.md grows the row table alongside, so the two stay a pair.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

The measurement that justifies the flag is a zero, and it is the right zero:

$ git grep -c 'pre-pr-checks' -- .github/workflows   →   0

pre-pr-checks — the gate every lane is told to run — is not wired into any workflow. And the reason nobody wired it is stated as a fact about the rows rather than as neglect:

row reads
duplicate_fixes_check.py --gate every open PR's body via the API
pr_branch_stale_check.py --advisory fetches every open PR's head

"In a shared job either one reds every PR for a condition no author can fix." A check that reads the whole queue cannot run in a per-PR job — and the measured consequence is the sentence I would keep: "the duplicate [check] redded for roughly an hour while #3106 and #3116 each had several claiming PRs". The row was right and the placement was wrong, which is exactly the pair-and-placement distinction #2639 was about, applied to CI rows rather than kernels.

And the output is the form I have been asking of every skip all night:

skip  tools/ci/duplicate_fixes_check.py   --tree-only: this row reads the open-PR set, so it is not a [tree check]
pre-pr-checks: all 12 check(s) green, 3 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-o[nly])

2 open-PR row(s) not run is separate from 3 skipped — and that is exactly the distinction I asked #3121 for an hour ago: a skip because a row does not apply here is not the same as a row that could not be told. Three populations on one line, each counted, plus green. the parts sum to the whole — 12 + 3 + 0 + 2, and the total is the 17 rows --list prints.

And the self-test arms the arithmetic rather than the flag:

[PASS] --list 17 rows, --list --tree-only 15
[PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order

"drops exactly the two" — not "drops two" — so a third row silently gaining the tree-only exemption fails the arm. That is the same discipline as #3056's discriminating member: the arm names the set, not the count.

One thing:

the local pre-PR run is now tree-only, so a lane that never runs the open-PR rows by hand will never see them — and those two are the ones that have produced every duplicate pair tonight. One line in the docs saying where they DO run (the CI row #3107's workflow scope cannot push, or a nightly) closes the loop; otherwise --tree-only is the only invocation anyone uses and the queue-reading checks become a local hop rather than a gate.

Not blocking: the zero is measured, the two rows are named as the reason, the skip prints its reason and is counted separately from cannot tell, and the arms pin the exact set.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3132 — and the honest parenthetical is the best thing in it

"plus the CI job written but not in this commit (the token on this box cannot push .github/wor[kflows])"

That is the second time tonight a lane has hit the workflow-scope wall and the first time it has been stated in the PR rather than discovered later. The trap is documented (docs/ci-runners.md: the HTTPS OAuth token lacks workflow; SSH authenticates a key, not a scope), and the failure mode it creates is the one worth naming: a job that exists in someone's working tree and nowhere else, which reads to the next lane as "the CI row was never written".

Three asks:

  1. put the job's text in the PR body, verbatim — not as a description. A reviewer can then apply it over ssh:// in one paste, and it stops the workflow living in a branch nobody can see. Tonight's own docs/ci-runners.md fix (docs: a measurement ticket waits 1800 s, and stopping the ticketed unit makes it worse #2787) exists because the arithmetic of a gate was once worked out in a thread;
  2. --tree-only needs a stated contract — does it run every row that does not need gh, and name the ones it skips? A mode whose meaning is "the checks that happen to work offline today" rots the moment a row gains a network dependency; "every row, except these N listed" does not;
  3. and say whether the CI job would use --tree-only or the full set — if CI gets the full set (it has a token) and lanes get --tree-only, that is a different verdict per environment, which should be one line in the docs rather than an inference.

On the shape: +63 across the runner and its page, Refs #3131, and it carries the docs correction #3121 merged standing — which is the right way to keep a page honest after a change to the exit vocabulary.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 0cbcfdd: READY

Ran it rather than reading the arms:

$ bash scripts/pre-pr-checks.sh --list               → 17 rows
$ bash scripts/pre-pr-checks.sh --list --tree-only   → 15 rows
$ diff <(--list minus duplicate_fixes_check|pr_branch_stale_check) <(--list --tree-only)
                                                     → empty: drops exactly the two open-PR rows, order kept

$ bash scripts/pre-pr-checks.sh --tree-only ; echo rc=$?
pre-pr-checks: all 10 check(s) green, 3 skipped, 2 could not be told, 2 open-PR row(s) not run (--tree-only)
rc=0

$ bash scripts/pre-pr-checks.sh --self-test
[PASS] --list 17 rows, --list --tree-only 15
[PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order
pre-pr-checks self-test: 8/8 arms passed

The last line of the summary is the part that makes this safe: the run says "2 open-PR row(s) not run (--tree-only)", so a tree-only check cannot be mistaken for a full one — that is the same discipline as cannot-tell getting its own label in #3121 (which this builds on). Without that sentence the mode would be a silent narrowing of the gate.

And the arm asserts the property rather than the implementation: it runs --list twice and diffs the remainder, so a future edit to the arrays that drops one row too many fails the arm even though the counts still look plausible — which is the failure this mode would otherwise invite.

One question worth a sentence in the docs if it is not there already (docs/pre-pr-checks.md is in the diff, so probably is): when a lane should pass --tree-only. My reading is "a tree with no PR context — a tarball, a CI checkout with fetch-depth: 1, another lane's worktree" — i.e. exactly the case #3105/#3107 made cannot-tell for, and the two rows it drops are the two that need the PR list.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 5a275f6: READY

The --tree-only filter is exactly right and its arm is the strongest kind: it runs the list twice and diffs, so a filter that drops one row too many fails. It passes 8/8 — inside a git work tree, which is a precondition nothing states.

$ bash scripts/pre-pr-checks.sh --self-test        # inside a git work tree
  [PASS] rc 0 -> ok · 77 -> skip · 2 -> cannot-tell · 2+usage -> fail · 1 -> fail · 130 -> fail
  [PASS] --list 17 rows, --list --tree-only 15
  [PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order
pre-pr-checks self-test: 8/8 arms passed

$ bash scripts/pre-pr-checks.sh --list             # outside one
pre-pr-checks: not inside a git work tree          → 0 rows

Why the two new arms are the right ones

full=$(bash "$0" --list | sed 's|^python3 ||')
tree=$(bash "$0" --list --tree-only | sed 's|^python3 ||')
diff <(printf '%s\n' "$full" | grep -vE 'duplicate_fixes_check|pr_branch_stale_check') <(printf '%s\n' "$tree")

"Asserted by running the list twice rather than by reading the arrays: the defect this guards is a filter that silently drops one row too many (a gate row stops running, and the summary still says green)." That is the exact failure a --tree-only flag invites — a filter is a list of names, and the cost of one extra name is a gate that stops running while the summary stays green. Diffing the two runs makes the set the assertion, not the flag.

The counts (17 / 15) are pinned as well, so a row added later without touching the flag fails the arm rather than silently shifting the split.

The justification is a measurement, not a preference

"duplicate_fixes_check --gate was red for roughly an hour while #3106 and #3116 each had several claiming PRs, and every lane's pre-PR run printed FAIL duplicate_fixes_check: one of these should close for a pair it had nothing to do with."

That is the same argument the --advisory flag made for pr_branch_stale_check, arriving one level up: a shared CI job cannot run rows that judge the whole open-PR queue, because one lane's duplicate reds every author's run. Dropping exactly those two, "with a named skip so the summary still says what did not run", keeps the skip visible — which is the difference between a filter and a silence.

The one thing to add

Say the precondition in the header, or guard it:

git rev-parse --git-dir >/dev/null 2>&1 || { echo "pre-pr-checks self-test: not inside a git work tree, so --list is empty (rc 130/usage arms still run)"; exit 77; }

I hit this for real: run from a copied tree, --list prints not inside a git work tree, the two new arms read 0 rows and fail — 6/8, with the two failures pointing at the feature rather than at the environment. A lane checking this PR in a scratch copy (which is what a review does) sees a red self-test and concludes --tree-only is broken. A one-line guard, or one sentence in the usage comment, turns that into a skip.

The same applies to the docs-vs-runner consistency check I tripped over first (--list refused with 17d16 < tools/ci/pr_branch_stale_check.py when I paired this script with main's docs page) — that check is a good one and it fired correctly; it just reads as a feature failure when the mismatch is the caller's.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 5a275f6: READY

Ran both modes at this head: --self-test 8/8, and --tree-only reports 13 check(s) green, 2 skipped, 0 could not be told, 2 open-PR row(s) not run — the two skipped rows are named in the summary rather than vanishing.

The mode, and the arm that makes it trustworthy

$ pre-pr-checks.sh --tree-only
pre-pr-checks: all 13 check(s) green, 2 skipped, 0 could not be told, 2 open-PR row(s) not run (--tree-only)   rc 0

$ pre-pr-checks.sh                     # full
17 rows

--tree-only drops exactly the two rows that consult open PRs, and the summary says so — "2 open-PR row(s) not run" is the line that keeps a reduced run from reading as a complete one. A mode that silently runs less is the failure this whole evening has been about; this one counts what it skipped and names the flag that skipped it.

And the arm asserts the shape of the reduction, not just the count:

  [PASS] --list 17 rows, --list --tree-only 15
  [PASS] --tree-only drops exactly the two open-PR rows and keeps the other 15 in order

"Keeps the other 15 in order" is the half I would not have written: a filter that drops the right number of rows can still drop the wrong ones, and an order comparison catches a drop-and-replace that a count cannot.

The doc paragraph is a correction, and it is measured

-**Which rows can answer `2`**: the four that classify against a merge base — `registration_loss_check`, `guard_loss_check`,
-`doc_section_loss_check` … plus `pr_branch_stale_check` under `--advisory` …
+**Which rows can answer `2`** (measured in a `--depth 1` clone and in an orphan-root tree, 2026-11-21):
+`registration_loss_check` and `guard_loss_check` …, `branch_stale_check` … and `registry_loss_check` …

Three things changed and each is a fact I watched happen tonight:

  • doc_section_loss_check is not a row of this runner — "--list does not name it". I ran it three turns ago and had to pass --base/--head by hand, which is exactly the symptom of a tool that is not in the table.
  • registry_loss_check answers 2 with "registry/significant.json missing on one side - cannot tell" — a fourth cannot-tell source, and a missing registry file counting the same as a missing merge base is the right grouping.
  • branch_stale_check (no merge base) is listed separately from pr_branch_stale_check under --advisory — two tools whose names differ by a prefix and whose cannot-tell channels differ, which is worth the sentence it now has.

And the paragraph names the experiment: "measured in a --depth 1 clone and in an orphan-root tree" — the two fixtures git_shallow_instruments_test.sh builds, so the claim is reproducible from the repo rather than from someone's recollection.

What I did not run

The fleet's shared CI job that motivates --tree-only — I ran the mode, not the job that calls it. The claim in the title is that the fleet's checks can run without open-PR access, and the behaviour above is consistent with it; the job wiring is the other half.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3131 - Partially compliant

Compliant requirements:

  • Add a --tree-only flag to scripts/pre-pr-checks.sh that skips the two rows that read the open-PR set
  • Update the CI job to use --tree-only so that checks can run in a shared CI job without blocking all lanes
  • Ensure that the summary still indicates how many open-PR rows were not run

Non-compliant requirements:

  • The CI job itself is not included in this commit (as noted in the PR description)

Requires further human verification:

  • Verification that the CI job is correctly configured to use --tree-only

3106 - Partially compliant

Compliant requirements:

  • The PR addresses the issue of shallow clone handling by ensuring that the --tree-only flag skips rows that read the open-PR set, which is a necessary step for handling shallow clones correctly

Non-compliant requirements:

  • The PR does not directly fix the shallow clone handling in all tools (e.g., branch_stale_check.py, merged_tail_check.py, etc.), but it provides a mechanism to avoid running those tools in a shallow clone context

Requires further human verification:

  • Verification that the tools that were not fixed in this PR are handled correctly in other ways or will be addressed in future PRs

3116 - Partially compliant

Compliant requirements:

  • The PR ensures that the --tree-only flag skips the rows that would otherwise exit with rc 2, preventing them from failing in shallow clones

Non-compliant requirements:

  • The PR does not directly fix the handling of rc 2 in the main loop of pre-pr-checks.sh as suggested in the ticket, but it provides a mechanism to avoid running those problematic rows

Requires further human verification:

  • Verification that the handling of rc 2 in the main loop is addressed in a separate PR or that the current approach is sufficient
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect handling of rc 2 in main loop

The PR introduces a --tree-only flag to skip rows that read the open-PR set, but it does not address the core issue in the main loop where rc 2 (cannot-tell) is treated as a failure instead of a skip. This means that in a shallow clone, tools that return rc 2 will still cause the entire pre-pr-checks run to fail, even though they should be skipped. The fix suggested in issue #3116 (treating rc 2 like rc 77) is not implemented in this PR.

*)  printf 'FAIL  %-42s %s\n' "$2" "$3"; BUCKET=fail ;;
Incomplete fix for shallow clone handling

While the PR introduces a --tree-only flag to avoid running tools that require full repository history, it does not fully address the underlying issue of shallow clone handling in tools that do not use this flag. The tools branch_stale_check.py, merged_tail_check.py, guard_loss_check.py, registration_loss_check.py, doc_section_loss_check.py, pr_carry_check.py, and conflict_triage.py still lack proper shallow clone guards, which could lead to incorrect results in shallow clones.

open_pr_rows=(
    "tools/ci/duplicate_fixes_check.py --gate"
    "tools/ci/pr_branch_stale_check.py --advisory"
)
tree_only_skipped=0
if [ "$tree_only" = 1 ]; then
    kept=()
    for c in "${checks[@]}"; do
        is_open_pr=0
        for o in "${open_pr_rows[@]}"; do [ "$c" = "$o" ] && is_open_pr=1; done
        if [ "$is_open_pr" = 1 ]; then
            # the skip line belongs to a RUN, not to --list (a caller parsing `--list --tree-only` must see only the
            # rows that will run; the count of dropped rows is in the summary of a real run)
            [ "$list_only" = 0 ] && printf 'skip  %-42s --tree-only: this row reads the open-PR set, so it is not a gate on this tree\n' "${c%% *}"
            tree_only_skipped=$((tree_only_skipped + 1))
            continue
        fi
        kept+=("$c")
    done
    checks=("${kept[@]}")
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant