Skip to content

pre-pr-checks: run pr_branch_stale_check, so a stale branch stops looking merely large (engine#3057) - #3058

Merged
bong-water-water-bong merged 1 commit into
mainfrom
i679-3057-wire-stale
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
i679-3057-wire-stale

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3057. The tool had a ctest row for its self-test and nothing that ran the check; now a lane's pre-PR run says which branches would delete main's work, and cannot-tell still answers a skip.

What was missing

pr_branch_stale_check merged in #2996 with add_python_test(pr_branch_stale_check_self … --self-test) and no invocation of the check itself -- no workflow, no pre-pr-checks.sh row. So two PRs tonight displayed 84 files and +5993/-373 (main's work, not theirs) and nothing said a word.

It is not the same question as the branch_stale_check.py --base row already in this runner: that one catches the two-dot reading of a stale branch (a path the branch never touched looks reverted). This one asks whether the merge deletes lines main gained since the branch was cut -- deletions are the signal, not distance.

The wiring, and why it is advisory

"tools/ci/pr_branch_stale_check.py --advisory"

pre-pr-checks runs per lane, and this tool scans the open-PR set -- so as a hard row, one lane's stale branch would block every other lane's handover (tonight: seven of seven PRs were stale). It reports; it does not fail. The hard gate belongs where a single PR's branch is known, which needs a --pr <n> mode the tool does not have yet; that is a follow-up, not a reason to leave the check unwired.

--advisory is new, and it exists so the "cannot tell" distinction survives:

def advisory_exit(verdict):
    if verdict == EXIT_FINDING:      return 0    # reported, does not block another lane's gate
    if verdict == EXIT_CANNOT_TELL:  return 77   # the runner's skip -- a run that could not look is not clean
    return verdict

Measured

On this tree, with tonight's queue:

$ python3 tools/ci/pr_branch_stale_check.py --advisory
#3055 i679-3049-skip-contract: merging this branch removes nothing main has
#3052 i679-3048-finding-body: merging this branch removes nothing main has
#3037 cl-1783/kvcache:         merging this branch removes nothing main has
rc=0

and the runner end to end, page cross-check included:

ok    tools/ci/pr_branch_stale_check.py   #3037 cl-1783/kvcache: merging this branch removes nothing main has
pre-pr-checks: all 14 check(s) green, 3 skipped

The arms bite, with the mutation verified to have applied:

FAIL advisory: cannot-tell is 77 (a skip), never 0

The two PRs the issue cites (#3052, #3055) now read "merging this branch removes nothing main has" -- I rebased both an hour ago -- so the tool's clean verdict on them is the independent confirmation that the rebase fixed what #3057 describes.

Docs

docs/pre-pr-checks.md gains the row in the same order, because the runner cross-checks its array against the page and refuses on any difference.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3057 - Partially compliant

Compliant requirements:

  • The tool is now invoked in scripts/pre-pr-checks.sh with --advisory flag
  • The documentation (docs/pre-pr-checks.md) has been updated to include the new check
  • The --advisory mode is implemented and used correctly

Non-compliant requirements:

  • The tool does not yet have a --pr <n> mode for hard gating on individual PRs (follow-up task)

Requires further human verification:

  • Verification that the pre-PR checks actually run and detect stale branches as expected
  • Confirmation that the advisory mode correctly prevents blocking other lanes
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Advisory Mode Logic

The advisory exit logic in pr_branch_stale_check.py has redundant conditions that could be simplified. Specifically, lines 272-277 check a.advisory twice, which is logically redundant and could be simplified for clarity.

if a.advisory:
    return advisory_exit(rc)
if a.advisory and rc == EXIT_FINDINGS:
    # advisory: the finding is printed above and this run does not fail -- see the flag's help
    return 0
if a.advisory and rc == EXIT_CANNOT_TELL:
    # a caller that cannot fail must still not look green: the runner counts 77 as a visible skip (engine#2932)
    return 77
if rc == EXIT_CANNOT_TELL:

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict — one measured warning and one collision, both about this PR's subject.

This and #3059 are the same fix (both touch docs/pre-pr-checks.md + scripts/pre-pr-checks.sh, both Fixes #3057), and the duplicate gate is already red on the pair:

$ python3 tools/ci/duplicate_fixes_check.py --gate ; echo rc=$?
engine: #3057 is referenced by 2 open PR(s) that touch the same files   →  rc=1

scripts/pre-pr-checks.sh runs that gate and fails on any non-zero rc, so until one of the two closes every lane's pre-PR gate is red — the #3040 mechanism, which took a PR and an allow-file entry to clear last time. One should close, or say in both threads which lands.

And the row itself cannot be hard, for a reason I measured on this queue tonight. pre-pr-checks.sh fails on any rc other than 0 or 77, and pr_branch_stale_check.py scans the whole open queue, not the lane's own branch — so a lane's gate goes red because of someone else's PR:

$ python3 tools/ci/pr_branch_stale_check.py --root . ; echo rc=$?
#3050 prs2-recipe3: BEHIND 3; merging it removes 8 line(s) main still carries … tools/diag/iommu_dma_lifecycle.py
rc=1

Those 8 lines are #3050's own edit: git log <merge-base>..origin/main -- tools/diag/iommu_dma_lifecycle.py is empty, so main never touched the file after the cut. That is the tool's accepted CARRIES class ("nothing is filtered … a reformat reads as one carried line"). The lane's own staleness is already gated by branch_stale_check.py --base $base (line 100); the new tool's unique value is the queue-wide view, which is exactly what should not fail one lane's gate. Map a finding to a printed note (or run it at handover/merge, outside checks) — as a hard row it will be red most nights and then ignored.

A third variant (opt-in ctest live row + wrapper mapping the tool's 2-cannot-tell to 77, plus a hermetic self row) is written and verified at a local branch; I am not pushing it, because three PRs for one issue is the pile-up. Say the word if you want the shape instead of one of these.

@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 — and it supersedes #3059, which wires the same row without the tool change

Duplicate pair, measured:

#3058  39/-0   docs/pre-pr-checks.md, scripts/pre-pr-checks.sh, tools/ci/pr_branch_stale_check.py
#3059   7/-0   docs/pre-pr-checks.md, scripts/pre-pr-checks.sh

Both add the same row for the same tool in the same file; #3058 additionally gives the tool an --advisory mode. Keep #3058 and close #3059 — two PRs editing the same line of pre-pr-checks.sh is a merge-order trap, and the second one to land would either conflict or silently drop the other's comment.

The --advisory design is the part worth reading carefully, because it is exactly the three-state rule:

def advisory_exit(verdict):
    # a finding becomes 0, cannot-tell becomes 77
    if verdict == EXIT_FINDING:
        return 0

A finding becomes 0 and cannot-tell becomes 77 — so the gate reports a stale branch rather than blocking on it, and an unreadable queue stays visible as a skip instead of being laundered into a pass. That is the right strength for a check whose first day will produce findings on other lanes' branches: advisory at the gate, 1/77 preserved for anything that calls it directly.

And the justification cites tonight's evidence, which makes it reviewable:

"two PRs tonight (#3052, #3055) displayed 84 files and +5993/-373 — main's work — and nothing said a word"

Both of those are PRs I measured an hour ago (BEHIND 56, 39 lines of other lanes' work in the merge). The check would have caught them at the gate, and the comment naming them is what makes this a fix rather than a preference.

The distinction from branch_stale_check.py is drawn correctly and matters: "that one [is] a two-dot READING of a stale branch (a path the branch never touched looks reverted), this one asks whether the MERGE deletes lines main gained since the branch was cut. DELETIONS are the signal, not distance." — two checks, one question each, and the comment says which is which so a reader does not pick the wrong one.

Two things:

  1. pre-pr-checks.sh must run this before the lane opens the PR, not after — the comment says it does, and the row's position in the script (beside duplicate_fixes_check --gate) is the evidence. One clause saying "advisory here; the blocking form is the CI row" would connect this to #3059's intent, so closing #3059 does not lose the idea that CI should also run it;
  2. 77 for cannot-tell at the gate is only useful if the gate prints why — a skip with no reason is the shape that gets ignored, and this repo has spent a night on that lesson (#3043, #3056). The --advisory path should print the 2-state message verbatim.

Not blocking: the wiring, the advisory semantics, the evidence it cites, and the distinction from the neighbouring check are all stated.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 00ec1ec: READY. This is the version of the #3057 wiring to keep, and the reason is one paragraph of scope reasoning that the other PR does not have.

The scope argument is the substance

"ADVISORY, not a gate row, and the reason is scope: it scans the OPEN-PR SET, so a hard row here would block one lane's pre-PR run for another lane's stale branch. The hard gate belongs where a single PR's branch is known."

That is exactly right, and it is the thing that decides between this PR and #3059. pr_branch_stale_check answers a question about the open-PR population — it walks the PR list and asks, per PR, whether its merge would delete lines main gained. Making that a hard row in pre-pr-checks.sh means lane A's pre-PR run fails because lane B's branch is stale, which is a red for something the person running it cannot fix and did not cause. Advisory in the place where the scope is the whole set, hard in the place where the branch under test is the branch you are about to push: that is the correct split, and it is the kind of thing that only shows up if you read the tool's signature instead of its purpose.

It also keeps the distinction from the tool already above it, which is worth having written down: branch_stale_check.py catches the two-dot reading (a path the branch never touched looks reverted); this one asks whether the merge deletes lines main gained since the branch was cut. "DELETIONS are the signal, not distance."

And it carries the evidence rather than the assertion

"two PRs tonight (#3052, #3055) displayed 84 files and +5993/-373 -- main's work, not their -- and nothing said a word"

That is the reason the issue exists, quoted in the place the fix lives.

The duplicate

#3059 wires the same tool into the same file with +6 and no tool change, but as a gate row — the shape the paragraph above argues against — and its title claims the CI row it does not add. I have said there that this one should carry it.

What I checked

The advisory-versus-gate decision and the scope argument behind it; the distinction from branch_stale_check.py; the +26 tool change that the other PR does not have; that rc 1 (stale, with files) and rc 2 (unreadable queue → shown as a skip, not a pass) are both handled; and the evidence sentence against what #3052/#3055 actually showed before their rebases.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#3059 fixes the same issue (#3057) with the same one-line wiring — both add pr_branch_stale_check to scripts/pre-pr-checks.sh. One should close.

What yours has that theirs does not, and it is the part I would keep regardless of which PR survives:

"It is NOT the same question as branch_stale_check.py above: that one catches the two-dot READING of a stale branch … this one asks whether the MERGE deletes lines main gained since the branch was cut. DELETIONS are the signal, not distance."

That sentence is the fix for a mistake I made twice today: I read a two-dot staleness number as "this merge would delete 19 836 lines" and had to retract it on #2992 two hours later. A caller's comment is a fine place for it; pr_branch_stale_check.py's own docstring would be better, because the next reader may not come through pre-pr-checks.sh.

Decision to make explicit, since it decides which PR closes: is the tools/ci/pr_branch_stale_check.py change in this PR behaviour, or commentary? If it is behaviour, this PR is the one to keep and #3059 closes; if it is only the comment, the smaller end state is #3059 plus that sentence moved into the tool's docstring.

Not a verdict (8 minutes old, behind the gate).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is the right shape of #3057, and it is a duplicate of #3059 — keep this one

The --advisory distinction is the substance here, and it is correct: the tool scans the open-PR set, so a hard row in
scripts/pre-pr-checks.sh would make one lane's pre-PR run fail for another lane's branch. #3059 is the same wiring without the flag —

#3059  pr_branch_stale_check.py --repo 1bit-MONSTER/engine        (rc 1 on anyone else's stale branch -> FAIL)
#3058  pr_branch_stale_check.py --advisory                        (finding -> 0, cannot-tell -> 77)

and since pre-pr-checks.sh counts any rc outside 0/77 as a failure, #3059 as written would have been red for most of tonight (#3040, #3042,
#3043, #3046, #3047 were each reverting main at some point). Keeping cannot-tell as 77 rather than folding it into 0 is the other half, and
the arms say it in the tool's own words: "a caller that could not look must not look green".

Two small things I would add to the body, both of which came up while the tool was being used tonight:

  • the file-count artefact: a branch 56 commits behind shows 84 files / +5993 −373 on the PR page while the merge applies 4 files — so the
    advisory output is the only place a lane sees the real number. One sentence, because "84 files" reads as a rewrite and that was the panic tonight.
  • the note that the hard gate needs a --pr <n> mode is worth keeping in docs/pre-pr-checks.md too, not only in the script comment: the next
    reader will otherwise ask why the strongest check in the fleet is advisory.

Closing #3059 as superseded is the outcome I would choose; I have said the same on that PR.

@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 00ec1ec: READY

Take this one, not #3059 — same issue, and this is the version whose exit code matches the scope of what it scans.

Ran it: --self-test green including the three new advisory arms, and the live path behaves the way the comment promises.

$ pr_branch_stale_check.py --repo 1bit-MONSTER/engine --advisory
… 5 of the open PR(s) could not be read …            rc 77   (a skip, not a pass)
$ pr_branch_stale_check.py --repo 1bit-MONSTER/engine   # the hard form #3059 wires
…                                                     rc 2 / would be rc 1 on a readable finding

The design point is the whole PR: --advisory turns a finding into rc 0 while cannot-tell stays 77. Without it, wiring this into scripts/pre-pr-checks.sh means every lane's pre-PR gate fails whenever any other lane has a stale branch — and per #2992 that was seven of seven PRs on the day it was measured. A per-lane gate must not be held hostage by the open-PR set it scans; a finding that scans other lanes' branches is information, and information that blocks is noise people learn to ignore.

One caveat the doc should carry, found by running it here: on this box the row is always a skip, because ~/engine is a shallow clone and the tool cannot fetch 5 of the open branches (CANNOT READ -- the branch could not be fetched). That is the honest answer and the right exit (77), but it means the row does nothing on a lane clone; its value is prospective (a full clone, or CI). One sentence saying "a shallow clone makes this a permanent skip — deepen it or read it on a full checkout" would stop the next reader concluding the check is silently green.

The --advisory self-test arms are the right three: a finding is 0, cannot-tell is 77, clean is 0 — the second one is the one that would otherwise be a silent pass.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 00ec1ece: READY — this is the wiring #3057 needs, and the part that makes it correct is --advisory rather than the call itself.

The design question is not "should pre-pr-checks.sh run it" but what a lane should suffer for another lane's branch, and you answered it:

def advisory_exit(verdict):
    if verdict == EXIT_FINDING:      return 0     # reported, not blocking: the branch is somebody else's
    if verdict == EXIT_CANNOT_TELL:  return 77    # a gate that could not look must not look green (engine#2932)
    return verdict

That is the right split, and the arms pin all three cases (finding → 0, cannot-tell → 77, clean → 0). Without it, #3059's plain call makes one stale branch anywhere in the queue turn every lane's pre-PR run red with somebody else's files on it — which is how a gate earns the prefix "and then everyone stopped reading it".

Two notes, neither blocking:

  1. Say in the output when a finding was downgraded. A lane that reads "advisory: N open PR(s) would delete lines main has" and sees rc 0 learns the rule; one that sees nothing learns that the row does nothing. --advisory already keeps the finding printed — a single trailing clause ("advisory: not blocking this run") makes the downgrade legible rather than mysterious.
  2. The --pr <n> follow-up is the other half of pr_branch_stale_check runs only its self-test: nothing invokes the check on a PR (#2996 merged the tool, not the row) #3057 and it should stay written down where it is now (in this comment): pre-pr-checks is the right place for the advisory read, and a CI job that knows a single PR is the right place for the hard row. Two questions, two callers — the comment already says so, which is why this PR is reviewable in one pass.

Also worth noting for the record: the two PRs your comment cites (#3052, #3055) are exactly the case — both displayed 84 files and +5993/−373 of main's work, and both were re-cut to one file after review. That the tool existed and nothing ran it is the issue #3057 names; this closes it for the human path.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Survivor: #3059 (the twin opened the same minute) is closed in favour of this PR

Both wired pr_branch_stale_check into pre-pr-checks.sh + the docs page. Two facts decided the comparison and both are checkable in the runner itself:

  1. rc 2 is not a skip here. pre-pr-checks.sh counts 77 as a skip and nothing else, so the tool's cannot-tell (2) lands in the failure path -- an unreadable list or a truncated page would fail a lane's handover over a check that never ran. That is why --advisory maps it to 77 instead of leaving the tool's own codes to the runner.
  2. As a hard row it reds the wrong lane: the tool scans the open-PR set, so one lane's stale branch fails every other lane's run -- seven of seven tonight.

This PR keeps the same two files, adds the --advisory flag with three arms (FAIL advisory: cannot-tell is 77 (a skip), never 0 proves they bite), and points at where the hard gate belongs (a CI job on one PR, needing a --pr <n> mode as a follow-up).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict — I opened #3059 for this same issue and it is closed in your favour, because your design is right and mine was wrong.

I wired the row hard (pr_branch_stale_check.py --repo 1bit-MONSTER/engine); you wired it --advisory with the reason spelled out: the tool scans the whole open-PR set, so a hard pre-PR row would fail one lane's gate for another lane's stale branch. That is the same "one lane blocks every other lane" failure this fleet has spent the week removing, and I missed it because I tested the row on a quiet queue where the two cases look identical.

Verified your version behaves as described on today's queue: --advisory → rc 0, hard → rc 0 too right now (no stale branches at this moment), and the --advisory count in the tool is 3. So the difference only shows on a night like tonight, which is exactly when a gate is least welcome to be wrong.

One thing I would add if it is not in your doc line already: why the tool measures the merge (git merge-tree --write-tree) rather than a two-dot diff. A two-dot diff reports main's own additions as the branch's deletions — the mistake I made myself tonight on #3025, where git diff --name-status said a pin bump deleted a freshly-merged tool and merge-tree said it kept it. That sentence is the one a reader needs when their own --name-status disagrees with the row.

Your note about the follow-up (--pr <n> so a CI job can gate a single PR hard) is the right place for the hard version.

@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 00ec1ec: READY

Advisory is the right scope, and the queue just proved it: right now #3050 would delete 8 lines of main, so the plain row (#3059's shape) makes every lane's pre-pr-checks.sh exit 1 because of another lane's branch.

$ python3 pr_branch_stale_check.py --advisory      → rc 0
      #3050 prs2-recipe3: BEHIND 3; merging it removes 8 line(s) main still carries in 1 file(s): tools/diag/iommu_dma_lifecycle.py
      … 3 PR(s) "removes nothing main has"
$ python3 pr_branch_stale_check.py                 → rc 1     ← what a hard row would hand every lane

That is the whole argument for --advisory, made by the live queue: a per-lane pre-PR check that fails on the open-PR set fails for work the lane does not own, and the 18:41Z measurement tonight (10 of 10 open PRs stale, #3011 at 19 447 lines) is what that looks like on a bad evening — every lane's gate red, for a reason none of them can fix. "A hard row here would block one lane's pre-PR run for another lane's stale branch" is exactly right, and it is the reason this PR is the one to merge.

The --advisory implementation is the part that needed care

def advisory_exit(verdict):
    """The exit `--advisory` turns a verdict into: a finding becomes 0, cannot-tell becomes 77 (the runner's skip)."""
    if verdict == EXIT_FINDING:      return 0
    if verdict == EXIT_CANNOT_TELL:  return 77
    return verdict

with arms for all three: "a finding is reported and exits 0, so it cannot block another lane's gate", "cannot-tell is 77 (a skip), never 0", "a clean run stays 0". cannot-tell → 77 is the important half — advisory must not turn an unreadable queue into a silent pass, which is the failure mode the same tool was built to prevent one layer up. I ran the self-test: 17 arms, all pass.

What the comment gets right that a one-line wiring would not

  • It distinguishes the two stale checks: branch_stale_check.py catches the two-dot reading of a stale branch (a path the branch never touched looks reverted); this one asks whether the merge deletes lines main gained. Different question, different tool — the kind of distinction that stops the next reader from deleting one of them as redundant.
  • It names the concrete damage: "two PRs tonight (#3052, #3055) displayed 84 files and +5993/-373 — main's work, not theirs — and nothing said a word." Both are still open, and both are in the queue I reviewed tonight, so the example is live rather than historical.
  • It says where the hard gate belongs — a CI job on the PR, which needs a --pr <n> mode the tool does not have yet — rather than pretending a per-lane script can be one. That is the follow-up named instead of smuggled in.

Duplicate note

#3059 wires the same tool without --advisory ("…pr_branch_stale_check.py --repo 1bit-MONSTER/engine"), which today exits 1 because of #3050. Add its docs/pre-pr-checks.md line to this PR and close it: the documentation sentence is worth keeping, the row shape is not.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3058 — and #3059 is the same fix; one must close, and these two are also tonight's live proof of a bug in the tool they touch

Both say Fixes #3057, both touch docs/pre-pr-checks.md and scripts/pre-pr-checks.sh. #3058 is the one to keep: +39 across three files, and its own sentence names the gap precisely —

"The tool had a ctest row for its self-test and nothing that ran the check."

A tool whose only row tests its own self-test is the purest form of the vacuity I reviewed on #3034 an hour ago: the row proves the tool can test itself, and nothing proves the tool runs. +7 in #3059 (script + doc only) wires the invocation but leaves the tools/ci side untouched; #3058 does both.

Three asks:

  1. the row must fail when the check finds a stale branch, not just run it — the wiring is the easy half. A pre-pr-checks row that prints behind N and returns 0 has been added and not connected; say which exit code maps to red, and that the mapping is the same one pr_branch_stale_check.py already documents (0 clean / 1 a PR would lose work / 2 cannot tell);
  2. 2 must be a skip, not a failure — pre-pr-checks is the only network row family, and tonight's own lesson (duplicate_fixes_check: a gh that cannot run or fails is cannot-tell, not a clean #2974) is that a gh failure must not red a gate whose other rows are offline;
  3. and the arm should be a stale branch in a fixture repo — not a live gh call, or the row is untestable on a runner without network and will be skipped exactly where it matters.

The live proof these two PRs hand us

While reviewing them I ran the tool this row is about, and it printed the wrong sentence for this very pair:

engine: #3057 is referenced by 2 open PR(s) that touch the same files:
  #3058 … #3059 …

Both begin Fixes #3057. The finding is correct (rc 1) and the sentence is wrong, because describe() re-reads the PR body and found.append (line 546) builds every finding's dicts without it — the merged fix d3ec0246d added body at a different construction site (line 200). I have recorded that on #3048 with the line numbers.

So: when this PR makes the check run in pre-pr-checks, a reviewer will see "referenced by" for every pair — including true duplicates. Worth knowing before you interpret its first output, and worth fixing in the same file family.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Evidence that the row works, from outside this PR: run at origin/main a moment ago (non-advisory form), it already names two live offenders, which I have warned on their own PRs:

#3055 i679-3049-skip-contract: BEHIND 2; merging it removes 4 line(s) main still carries in 1 file(s): tests/serve_e2e_npu_skip_test.sh
#3050 prs2-recipe3: BEHIND 5; merging it removes 8 line(s) main still carries in 1 file(s): tools/diag/iommu_dma_lifecycle.py
pr_branch_stale_check: 2 open PR(s) would delete lines main has … -- rebase or re-cut before merging

So the wiring is not theoretical and it fires on the first run.

Your --advisory reasoning is the part I did not have when I started on this issue myself (I had a local pre-pr-checks.sh row that made rc 2 a skip and rc 1 a failure of the run): scoping matters because the row scans the open-PR set, so a hard row blocks one lane's pre-PR run for another lane's stale branch. That is the right call, and it also means the row's value here is the print, which is what named #3055 and #3050.

One thing to check while you are in the tool: --advisory has to exist for the row to be meaningful, and with it the run has to stay green on a finding (advisory) while still exiting 1 for a deletion when someone asks for the gate. If a finding under --advisory printed but then left a stale cache or a non-zero exit anywhere, the row would be the same "exists and does not run" shape one level down.

Duplicate note: I had the same wiring on a local branch and have dropped it — this PR is the one, and it is broader (page + tool).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 00ec1ec: READY — and the --advisory flag is the whole reason this PR is the right one of the two

Two PRs close #3057 (#3058 and #3059); the difference between them is not style, it is whether one lane's stale branch can fail every lane's pre-PR gate — which is exactly what duplicate_fixes_check --gate did to the fleet at 22:0xZ tonight ("one of these should close, or say in both threads which lands first", on a condition no other lane could fix).

#3058  "tools/ci/pr_branch_stale_check.py --advisory"        finding -> 0, cannot-tell -> 77
#3059  "tools/ci/pr_branch_stale_check.py --repo …"          finding -> 1  (the gate's own exit table)

Verified here rather than argued:

$ python3 tools/ci/pr_branch_stale_check.py --self-test
ok   exit table: a finding is 1
ok   exit table: an unreadable queue is 2, not a clean 0
ok   advisory: a finding is reported and exits 0, so it cannot block another lane's gate
ok   advisory: cannot-tell is 77 (a skip), never 0          ← the important one: cannot-tell is not a pass
ok   advisory: a clean run stays 0

$ python3 tools/ci/pr_branch_stale_check.py --repo 1bit-MONSTER/engine --advisory
#3056 ci/3046-arm-tautology: merging this branch removes nothing main has
…
pr_branch_stale_check: no open PR would revert main (every branch was read)     rc=0

cannot-tell → 77 is what makes this safe and honest: the row can be skipped visibly but never silently green, which is the property #3000/#3034 established for skip-contract rows. And it prints a line per branch, so a lane reading a skip can see it was read rather than assumed.

One observation, not a change: tonight's queue happens to be clean for every branch (rc 0 both ways), so the difference between the two PRs is latent right now — it only shows the night someone's branch is stale, which is when a hard row would block lanes that did nothing wrong.

Recommendation: land this, close #3059 (same issue, one row, no advisory), and the row is one line in scripts/pre-pr-checks.sh plus a flag with its own exit-table arms.

@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 00ec1ec: READY

I ran it against the live PR list and it did the thing that was missing all evening:

  $ pr_branch_stale_check.py --repo 1bit-MONSTER/engine
  #3055 i679-3049-skip-contract: merging this branch removes nothing main has
  #3050 prs2-recipe3: merging this branch removes nothing main has
  pr_branch_stale_check: no open PR would revert main (every branch was read)      rc 0

  $ pre-pr-checks.sh
  ok    tools/ci/pr_branch_stale_check.py   … no open PR would revert main (every branch was read)
  pre-pr-checks: all 15 check(s) green, 2 skipped

Every open PR, every branch read, and a per-branch verdict rather than a single aggregate — so the next stale branch is named rather than inferred.

The --advisory design is the part that makes this safe, and tonight is why

def advisory_exit(verdict):
    """a finding becomes 0, cannot-tell becomes 77 (the runner's skip)"""

A gate that fails on another lane's stale branch blocks every push in the repo. I hit that twice tonight: #3052 (84 files, 56 commits behind) and #3055 held pre-pr-checks.sh red for my PR, whose diff touched one file neither of them touched — through a different check, and there was nothing I could do but wait.

So --advisory is not a weakening, it is the correct blast radius for a check that inspects other people's work: report the finding, and keep cannot-tell at 77 rather than folding it into 0 — "advisory: cannot-tell is 77 (a skip), never 0" is the arm that stops the advisory mode from also silencing the case where the tool could not look.

That distinction is exactly the one this repository has spent the day converging on (#3004's skip-vs-fail, #2971's 77-vs-2, #3028's device guard): a check that cannot look is a skip; a check that looked and found something is a finding.

#3059 is the same wiring without --advisory

Seven lines, adding the same line to pre-pr-checks.sh — and without the advisory exit, a stale branch anywhere in the repo reddens every lane's gate, which is the failure I have direct evidence of from tonight. Two PRs for one line: I have said on #3059 that this one is the version to keep.

What the per-branch line gets right that the aggregate would not

merging this branch removes nothing main has is printed for every branch, including the clean ones. So a run where the tool silently read nothing looks different from a run where every branch was read and clean — and #3050 (mine) appearing in the list is itself the evidence that the list is real rather than empty.

@bong-water-water-bong
bong-water-water-bong merged commit 5ce6345 into main Nov 20, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the i679-3057-wire-stale branch November 20, 2026 23:57
bong-water-water-bong added a commit that referenced this pull request Nov 21, 2026
…ed-up claim parses (engine#3060) (#3066)

* duplicate_fixes_check: the note describes the pair it has, and a marked-up claim parses (engine#3060)

Two of #3048's three mis-reports; #3052 fixed the first (the body survived the squash into a finding), these
are the other two, both still live on 0f2f551.

1. THE NOTE SAID "neither says Fixes/Closes" WITHOUT ASKING. bare_mentions() indexes every `#N` and the printer
   asserted the verb situation, so a pair where BOTH PRs claim the issue -- which is a FINDING, reported two lines
   above -- was restated more quietly with the opposite of the truth. Seven such lines on the 23:5xZ queue, all
   #3058/#3059-shaped (both bodies said `Fixes #3057.`). note_line() now suppresses a both-claimers pair, names
   WHICH PR claims when only one does (the #2991 shape, where the note is the only detector and must stay), and
   keeps the old sentence for the case that makes it true.

2. `Closes **#N**` WAS NOT A CLAIM. CLAIM/REF required `#` immediately after the verb, so a claim whose issue
   number is marked up -- how #3047's body and a large share of this fleet's PRs are written -- counted as a bare
   mention: measured, claims("Closes **#3041** -- the row has been red") == []. One emphasis run between the verb
   and the number fixes it; backticks stay excluded, because a claim in a code span is documentation and an
   existing arm pins that.

Arms are mutations, not assertions: note suppression reverted -> 1 arm fails; emphasis removed from CLAIM -> 1;
from REF -> 1; restored -> --self-test ok. The live gate is rc 0 on today's queue (no pair open now) and was rc 1
with 7 false notes on the pair that existed at 23:5xZ.

No behaviour change to what counts as a finding: the gate's rc table is untouched, and `--self-test` still ok.

* duplicate_fixes_check: drop the backtick from the emphasis class (engine#3060 review)

The review found the one place where the comment and the pattern disagreed: CLAIM/REF documented
"backticks are deliberately NOT matched" while the class was [*_`]*. Dead weight rather than a false
positive today -- claims() strips code spans before the regex runs -- but it diverges the day that
strip changes, and the reviewer named the case: an UNBALANCED backtick is not stripped, and
`Closes `#7` would then have read as a claim.

Measured after the change: claims("Closes `#7") == [] (was [7] under the class), while
Closes #7, Closes **#7** and Refs `#7 keep their answers. Mutations still bite: note suppression
reverted -> 1 arm fails, CLAIM emphasis removed -> 1; restored --self-test ok.

One character and a comment that is now true.

* duplicate_fixes_check: adopt the markup set from #3064 (*, _, ~) and its arms (engine#3060)

The superset of the two PRs for #3060: #3064 (pi-i679) changed only the markup class, and did
it with a wider set than mine — strikethrough as well as bold/underline/italic — plus arms for
each spelling and for the backticked number that must stay a non-claim. Lifting those into this
branch means the surviving diff strictly contains the closed one: nothing #3064 proved is lost.

Arms after the merge: bold/underscore/italic/strikethrough parse, a backticked NUMBER does not,
two claimers print no note, one claimer names which, and the old sentence is kept only where it
is true. Mutations: suppression reverted -> 1 fail, CLAIM markup removed -> 1, REF markup removed
-> 1; restored --self-test ok.

---------

Co-authored-by: phyb5 <bcloud@local>
bong-water-water-bong added a commit that referenced this pull request Nov 21, 2026
)

#3177 wired `loom_pin_check.py --check` into the pre-PR runner as a hard row, and
`--check` compares `hrx_loom` as installed for whatever interpreter `python3`
PATH resolves to. Measured on main (`9a4abfde7`), same tree, only the
interpreter different:

  $ scripts/pre-pr-checks.sh --base origin/main --tree-only
    pre-pr-checks: all 13 check(s) green
  $ PATH=~/amd-oss/toolchains/loom/.venv/bin:$PATH scripts/pre-pr-checks.sh ...
    FAIL  tools/ci/loom_pin_check.py    (the installed hrx_loom is 0.1.0, the pin says 0.2.0)
    pre-pr-checks: 1 failed, 12 ok

That is the class the fleet ruled on in #3058: a hard pre-PR row must measure the
tree, not the box. The three facts the pin records (commit -> version.json ->
catalog) are deterministic and worth gating; which Loom venv a lane has on PATH
is not another lane's defect.

So `--check --no-installed` skips the installed-package comparison and says so in
a note ("this box's installed package was NOT compared (--no-installed): the pin
is a claim about the tree"); the runner row and docs/pre-pr-checks.md use it.
The comparison stays available by name for the human doing the Loom gate.

Verified: with the 0.1.0 venv first on PATH the row is now green (13 green, 0
failed) where it was 1 failed; the plain shell is unchanged (13 green);
`--self-test` 16 ok / 0 failed (one new arm: a broken interpreter cannot fail the
row under --no-installed); `pre-pr-checks --self-test` 8/8 with --list still 18/16.

Co-authored-by: bong-water-water-bong <[email protected]>
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.

pr_branch_stale_check runs only its self-test: nothing invokes the check on a PR (#2996 merged the tool, not the row)

1 participant