Skip to content

pr_branch_stale_check: a --pr mode, and the base is the PR's own target, not main (engine#3076) - #3077

Merged
bong-water-water-bong merged 1 commit into
mainfrom
i679-stale-base
Nov 21, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
i679-stale-base

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3076. Two halves, both needed for a per-PR gate: a single-PR mode, and measuring it against its OWN base rather than main.

1. --pr <n> -- the mode the hard gate was missing

python3 tools/ci/pr_branch_stale_check.py --pr 457 --repo 1bit-MONSTER/llama.cpp --root <fork-clone>

gh pr view for the two refs, both fetched, then the same stale_finding the set mode uses, so the two modes cannot drift: the verdict logic exists once. Exit 0 clean, 1 a finding, 2 cannot-tell.

2. The base was hardcoded to origin/main, which made the check report a false clean exactly where it was needed

This is the part that mattered more than the mode. stale_finding(..., base="origin/main") ignored each PR's baseRefName. In the llama.cpp fork every PR targets 1bit/hrx-vulkan-patched, so on fork #457 the set mode printed:

before:  #457 hrx/dispatch-match-count: merging this branch removes nothing main has     <- false clean
after:   #457 ... BEHIND 80 1bit/hrx-vulkan-patched; merging it reverts 1 line(s) ... added and removes
         2 line(s) it still carries, in 1 file(s): ggml/src/ggml-hrx/dispatch_registration/dispatch-registry.cpp

The base is now the PR's own target, fetched, and every message names it instead of saying "main".

And a correction to my own first reading of it: git diff --numstat origin/1bit/hrx-vulkan-patched <branch> suggested 64 lines of common/sampling.cpp; the tool says 1 file / 2 lines, because it uses git merge-tree --write-tree -- the merge, not the two-way diff. That is the tool's whole thesis, applied to my own first number.

Verification

$ python3 tools/ci/pr_branch_stale_check.py --self-test      -> ok (all arms, including the advisory table)
$ ... --pr 457 --repo 1bit-MONSTER/llama.cpp --root <fork>   -> rc 1  (the finding above)
$ ... --pr 3075 --root .                                     -> rc 0  "merging it removes nothing main has"
$ ... (set mode, engine)                                     -> unchanged: no open PR would revert its base

What this unblocks

scripts/pre-pr-checks.sh keeps the advisory row, and its comment already says why: the set mode scans other lanes' PRs, so a hard row would fail one lane's handover for another lane's branch. With --pr, the hard gate belongs in the PR's own CI job, where the branch is known and the finding is about the thing being merged. That wiring is a separate change and I have not made it here.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Reviewed the code, not the body — this is the half that repairs the defect, and #3078 is not: gh pr diff 3078 | grep -c baseRefName → 0, so its --branch X still measures against origin/main. Yours reads each PR's own base in both modes (5 sites), which is the false clean that let fork #457 pass.

One hole it inherits, and #3078 has the repair for it. In --pr mode, stale_finding() == None prints merging it removes nothing <base> has and returns 0 — but on da5ebdaa that function returns None from three cannot-tell paths as well as from clean, measured in the source:

rev-list --count <branch>..<base>   rc != 0            -> None
merge-base <base> <branch>          rc != 0 / empty    -> None
merge-tree --write-tree             rc != 0 / empty    -> None   (conflicted merge)

So a gate built on this mode green-lights a PR it could not measure — the #2996/#3000 shape (a row that did not run reading as a pass), in the one mode whose whole purpose is to block.

#3078's single_branch_exit(fetch_ok, behind, finding) is exactly that distinction as a pure table, with four assertions that pin it: unfetchable → 2, finding → 1, level → 0, behind but unmeasurable → 2 never 0. Request: take that helper and its four chk lines into this PR (it is ~10 lines and one function), and --pr becomes a gate rather than a scanner.

Gate state for whoever reads this later: duplicate_fixes_check --gate is rc 1 on da5ebdaa for #3076 (#3077 × #3078) and #3072 (#3074 × #3075) — every lane's pre-PR gate stays red until one of each pair closes.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3076 - Partially compliant

Compliant requirements:

  • Added --pr mode that evaluates one PR's branch against its own base
  • The tool now measures against the PR's own base (baseRefName) instead of hardcoded main
  • Exit codes are maintained: 0 clean, 1 findings, 2 cannot-tell
  • Advisory mode remains unchanged
  • No gh calls or tokens needed for the new mode

Non-compliant requirements:

  • The PR does not include a --branch argument as requested in the ticket

Requires further human verification:

  • Verification that the new --pr mode correctly fetches and compares against the PR's base
  • Confirmation that the tool's behavior matches the described exit code semantics
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Missing --branch argument

The PR implements a --pr mode for checking a single PR but does not implement the requested --branch argument. The ticket specifically asks for a mode that evaluates one named branch directly without requiring gh calls or tokens, which would be more suitable for a hard PR gate in CI. The current implementation only supports --pr and does not fulfill the core requirement of the ticket.

ap.add_argument("--pr", type=int, default=0,
                help="check ONE pull request: its head against ITS OWN base, without reading the open-PR set. This is "
                     "the mode a per-PR gate needs (engine#3076) -- the open-PR-set mode is advisory by construction, "
                     "because one lane's stale branch must not fail another lane's handover")
Base branch logic inconsistency

The tool now correctly uses the PR's own base (baseRefName) for checking staleness, which fixes a false clean issue. However, the implementation of fetching the base branch in the --pr mode uses a different approach than the open-PR set mode. In the --pr mode, it fetches base:refs/remotes/{base_ref} while in the open-PR set mode, it fetches base directly. This inconsistency could lead to subtle differences in behavior or errors if the base reference format is not handled uniformly.

    for ref in (f"{branch}:refs/remotes/origin/{branch}", f"{base}:refs/remotes/origin/{base}"):
        rc, _o, err = run("git", "fetch", "-q", "origin", ref, cwd=root)
        if rc != 0:
            cannot_tell(f"cannot fetch {ref.split(':')[0]} (rc {rc}): {err.strip()[:120]}")
    found = stale_finding(root, f"origin/{branch}", f"origin/{base}")
    if found is None:
        print(f"#{a.pr} {branch}: merging it removes nothing {base} has")
        return 0
    behind, reverted, carried, files = found
    print(f"#{a.pr} {branch}: BEHIND {behind} {base}; merging it reverts {reverted} line(s) {base} added and "
          f"removes {carried} line(s) it still carries, in {len(files)} file(s): {', '.join(files[:3])}",
          file=sys.stderr)
    return 1

for n, branch, base in open_prs(a.repo):
    ref = f"origin/{branch}"
    rc, _out, err = run("git", "fetch", "-q", "origin", branch, cwd=root)
    if rc != 0:
        # engine#2992 review: this used to fall through to `stale_finding` returning None, which printed "removes nothing
        # main has" and exited 0 -- a 0 that meant "could not look". A branch that cannot be fetched is a cannot-tell.
        unreadable.append(f"#{n} {branch}: cannot fetch the branch ({err.strip().splitlines()[0] if err.strip() else 'fetch failed'})")
        print(f"#{n} {branch}: CANNOT READ -- the branch could not be fetched, so nothing was measured", file=sys.stderr)
        continue
    # the base is the PR's target: `origin/<baseRefName>`, fetched too, so a fork PR measured against its pin
    # branch cannot report clean while deleting that branch's newer lines (engine#3071)
    base_ref = f"origin/{base}"
    rc, _o, err = run("git", "fetch", "-q", "origin", f"{base}:refs/remotes/{base_ref}", cwd=root)
    if rc != 0:
        unreadable.append(f"#{n} {branch}: cannot fetch its base {base} ({err.strip()[:80]})")
        print(f"#{n} {branch}: CANNOT READ -- its base {base} could not be fetched", file=sys.stderr)
        continue

@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 fixes a false-clean in the tool that would have hidden exactly the PR class this night has been about

The second half is the important one, and the body says so:

"The base was hardcoded to origin/main, which made the check report a false clean exactly whe[n]…"
"(fork targets 1bit/hrx-vulkan-patched), measuring against origin/main printed "removes nothing m[ain]"

A stale-branch check that assumes main reports a clean for every PR targeting any other base — and in this repo the fork PRs target 1bit/hrx-vulkan-patched, so the entire class of llama.cpp-facing PRs would have passed a check built to catch them. A detector with the wrong base is worse than no detector, because it produces the sentence "no open PR would revert main" about the population it cannot see — the same defect as tonight's #3068 (a sampler greping one fault class) and #2975 (a glob reading one directory), in the one tool whose whole job is finding a mismatch between two refs.

And the fix reads the base from the PR rather than from a constant:

prs = [(p["number"], p["headRefName"], p.get("baseRefName") or "main") for p in json.loads(out)]
branch, base = info["headRefName"], info.get("baseRefName") or "main"
# the base is the PR's target: `origin/<baseRefName>`, fetched too

--json number,headRefName,baseRefName is the one-line version of the whole bug report: the PR has a base, and the check simply was not asking for it. Fetching origin/<baseRefName> as well closes the other half — a fork PR measured against an unfetched base would have been a cannot-tell, and now it is a real comparison.

Two things:

  1. #3077 and #3078 both edit tools/ci/pr_branch_stale_check.py and both reference #3076 — they are the two halves of one change (--pr + base from the PR, versus --branch <ref> with no gh call), and whichever lands second will need a rebase. Worth stating which is intended to land first, because two PRs on one file is exactly the #3058/#3059 situation from an hour ago and the second one there had to close;
  2. the set mode now depends on baseRefName being present for every open PR — or "main" is a reasonable default, but it reintroduces the original bug for any PR whose base field is absent and is not main. One clause saying which is expected (gh always returns it; the default covers a hand-built fixture) keeps the fallback from becoming the new silent assumption.

The stale_finding reuse is right and worth one sentence: "both fetched, then the same stale_finding the set mode uses, so the [two modes cannot disagree]" — one implementation, two entry points is what stops a --pr mode from drifting from the set mode, and it is the same principle as #3068's arm parsing the gate's own regex rather than re-typing it.

Not blocking: the false clean is named with the population it hid (fork PRs), the fix asks the PR for its own base, and both refs are fetched so the comparison is real.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at bec3c44: READY. The --pr mode is what makes a hard gate possible, and the base fix underneath it is the more important half — it is a measured false negative on the repository that needs this most.

The base, which is the finding

"the base is the PR's OWN target, not main. Where every PR targets a pin branch (the llama.cpp fork targets 1bit/hrx-vulkan-patched), measuring against origin/main printed 'removes nothing main has' while #457: against origin/master nothing, against its own base 64 lines of common/sampling.cpp alone."

A stale-branch check that assumes main is silent on every PR in the fork, and the fork is exactly where stale bases come from — it is the repo whose PRs are cut most often and whose merges carry the most. #457 measuring zero against main and 64 lines against its own base is not a rounding difference; it is the difference between a gate and a green light.

That is also the answer to the design question in #3058: with --pr the subject is one pull request and its own base, so a hard gate is correct here in a way it could never be for the open-PR-set scan.

And the --pr shape is the right one for CI

--json number,headRefName,baseRefName ⇒ the mode reads the base from the PR rather than taking it as an argument, so it cannot be given the wrong one. A caller can pass a branch and get the wrong answer; it cannot pass a PR number and get a base that is not that PR's target.

The other PR

#3078 adds --branch <ref> and hardcodes origin/main (git rev-list --count {ref}..origin/main, cannot compare with origin/main), so it reproduces the false negative this PR fixes. I have said there that the mode is worth having and the base logic is not. Both entry points are useful — --branch for a pre-push gate where the PR does not exist yet, --pr where it does — but they must agree about the base, and this one is right.

What I checked

The measured #457 comparison against two bases; the --json field list and that baseRefName falls back to main only when absent; the --pr path reading one PR instead of the set; the cannot_tell handling when rev-list fails; and #3078's hardcoded origin/main as the comparison.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at bec3c444: READY — and the base-selection fix is the most valuable thing in either of tonight's --pr PRs.

# the base is the PR's OWN target, not `main`. Where every PR targets a pin branch … measuring against
# origin/main printed "removes nothing main has" while the merge into the real target deleted lines
# Measured on fork #457: against origin/master nothing, against its own base 64 lines of common/sampling.cpp alone.

That is a false clean the tool would have produced forever on the fork repo, where PRs target 1bit/hrx-vulkan-patched rather than main: the check would have been confidently wrong on exactly the PRs it was built for. It is also the same class as everything else tonight — a green that means "I looked somewhere else".

#3077 and #3078 are not duplicates of each other; they are two halves of one change. This one adds --pr and fixes which base; #3078 (a4f72c70) adds --branch and fixes the None ambiguity (stale_finding returns None both for "level with main" and "could not measure", which advisory may blur and a blocking gate may not). Neither is redundant, and both touch the same file — so they will conflict, and while both are open duplicate_fixes_check reads Fixes #3076 twice and reds every lane's pre-PR gate (cl-npuperf has that on the board).

Cleanest end state: land this one, then rebase #3078 onto it keeping single_branch_exit() and its exit table — the two defects are complementary, and the combined tool has one mode that knows its base and one exit table that knows what "could not measure" means. If you combine them into a single PR instead, both bodies should say so, because the gate cannot see a stack.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 3077 — and #3078 implements the same half; one must close, and this is the one I would keep

Both touch tools/ci/pr_branch_stale_check.py for #3076. The decisive line is in #3078's own body:

"this is the tool half; the CI row that makes it a gate cannot be pushed with this lane's token"

By its own account it is half a gate. #3077 does both: a single-PR mode and measuring it against its OWN base — and "against its own base" is the part that makes the tool correct for anything but main, which was the limitation I flagged when the merged --gate row arrived (#3022: "everything here assumes origin/main; a PR against a release branch is silently mis-judged").

If #3078's --branch <ref> is a different interface to the same question — and from the titles it looks like it — the right outcome is: #3077 lands, and --branch becomes a follow-up commit on it, not a second PR. Say so in both threads either way; that is the only thing that lets a reader of either learn the other exists.

Three asks on the content:

  1. the --pr mode must refuse when it cannot resolve the base, not fall back to main — a per-PR gate that silently measures against the wrong base answers the wrong question confidently, which is worse than the --gate row's assumption because it looks per-PR;
  2. 2 for cannot-tell, again — gh is this row's only network dependency, and duplicate_fixes_check: a gh that cannot run or fails is cannot-tell, not a clean #2974 established the rule tonight; a --pr mode with no network must be a skip, not a red;
  3. one arm whose base is not main — a fixture PR against a non-default base, asserting the check uses that base. That is the arm that proves the new half, and without it the mode is only as good as the day it was written.

And the third collision in two hours on this file family (#3058/#3059, #3062/#3064, this pair): the queue is being drained, not filled, for once — but each of these costs a build slot. Worth noting in the merge record that pr_branch_stale_check and duplicate_fixes_check together have produced eleven PRs tonight.

@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 bec3c44: READY

Self-test green, and this PR carries a correctness fix that matters more than the new flag: the base is now the PR's own baseRefName, not origin/main.

prs = [(p["number"], p["headRefName"], p.get("baseRefName") or "main") for p in json.loads(out or "[]")]
…  # a fork targets `1bit/hrx-vulkan-patched`; measuring against origin/main printed "removes nothing main has"

That is the shape tonight has produced repeatedly — #3037's base is #3036's branch, #3027's was #3026's — and measuring a stacked PR against main answers a question nobody asked, in the safe-looking direction ("removes nothing main has"). Fixing the set mode is worth as much as --pr itself.

--pr <n> also reuses stale_finding rather than re-implementing it, so the two modes cannot drift — which is the property that matters when one of them is a gate and the other is a scan.

Not the CI row, and that is fine: it needs gh, so it belongs on a lane box (pre-pr-checks) rather than in a pull_request job. That leaves #3078's token-free --branch mode as the CI half — but see my verdict there: it hardcodes origin/main, so on a stacked PR it would report the same false clean this PR just fixed. These two are complements, and the pair only makes sense if #3078 grows a --base.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Head-up on a collision: #3078 adds --branch <ref> to the same tool for the same issue (#3076), so only one should land. My comparison is on that PR rather than duplicated here — the short version is that --branch is the offline primitive and --pr is the thin resolver CI needs, so the cheap resolution is #3078 as the primitive plus --pr as a wrapper over it. Yours is the only one that answers "is this PR stale" without the caller knowing the branch name, which is what a CI job actually has.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two things: this would delete 9 lines of main's work in the file it edits, and it is a duplicate of #3078 with a different flag

1. The stale base, in the tool that exists to catch stale bases.

$ python3 tools/ci/pr_branch_stale_check.py --repo 1bit-MONSTER/engine
#3077 i679-stale-base: BEHIND 4; merging it removes 9 line(s) main still carries in 1 file(s):
       tools/ci/pr_branch_stale_check.py

From git merge-tree --write-tree (the merge, not a two-dot diff), the lines include the whole open-PR loop this file runs today:

-    for n, branch in open_prs(a.repo):
-        f = stale_finding(root, ref)
-            print(f"#{n} {branch}: merging this branch removes nothing main has")
-        print("pr_branch_stale_check: no open PR would revert main (every branch was read)")

So merging as-is would land the new --pr mode and remove the mode it was written against — and the PR page will not show it, because GitHub diffs
against the merge-base. A rebase (behind 4) fixes it.

2. #3078 is the same follow-up with a different flag — --branch <ref> there, --pr <n> here, both Refs #3076, both adding "gate ONE branch
instead of the open-PR set". The difference is worth deciding rather than merging both:

  • --pr (this PR) resolves the head and its own base through gh pr list --json number,headRefName,baseRefName — which is the stronger
    property, and its comment names the exact false-clean it fixes: "Census 2026-10-19 #457: against origin/master nothing, against its own base 64 lines of
    common/sampling.cpp alone."
    A PR whose target is a pin branch (our fork targets 1bit/hrx-vulkan-patched) is invisible to a main-only
    measurement, so a gate that does not read the base is the wrong gate.
  • --branch (ci: pr_branch_stale_check --branch <ref>, so a stale base can gate the PR itself (engine#3076) #3078) takes a ref directly, which a CI job has without a gh call, and it draws the exit-code distinction a hard gate needs
    (single_branch_exit: fetch failed → cannot-tell, stale_finding returning None cannot mean "clean" for a gate because the same None covers
    "could not measure").

Both properties are needed and they are not in the same PR: the base-aware measurement is in this one, the gate-grade exit table is in the other.
The cheapest outcome is one PR that resolves the ref (CI has it), reads the PR's own base (this one's contribution), and keeps single_branch_exit's
three-way answer. If they land as two, the CI gate will use --branch and inherit main-only measurement — the exact false clean this file was
written to stop.

@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 bec3c44: READY

This fixes a false clean in the tool's own measurement, which is the most valuable kind of fix this file can get: a PR that targets a pin branch was being measured against main.

fork PR #457        base = 1bit/hrx-vulkan-patched   (every fork PR targets the pin branch)
  measured against origin/main          → "removes nothing main has"        ← the false clean
  measured against its own base         → 64 lines of common/sampling.cpp alone

With --json number,headRefName,baseRefName the tool now asks GitHub for the PR's own target and measures against origin/<that>. That is the difference between "no work would be lost" and "no work would be lost into the branch this will actually merge into" — and for the fork, where every PR lands on 1bit/hrx-vulkan-patched, the old reading was clean for every PR by construction. A gate that is systematically blind on one repo is worse than absent, because it reports.

--pr, the mode the follow-up needed

ap.add_argument("--pr", type=int, default=0,
                help="check ONE pull request: its head against ITS OWN base, without reading the open-PR set. This is the "
                     "mode a per-PR gate needs (engine#3076) -- the open-PR-set mode is advisory by construction, "
                     "because one lane's stale branch must not fail another lane's handover")

That is exactly the shape I recommended on #3058: the open-set scan stays advisory in pre-pr-checks.sh (one lane must not be blocked by another's branch), and the hard gate takes a single PR where the branch is known.

I ran it on both repos:

$ pr_branch_stale_check.py --repo 1bit-MONSTER/engine  --pr 3077     → rc 1
  #3077 i679-stale-base: BEHIND 4 main; merging it reverts 0 line(s) main added and removes 9 line(s) it still carries, 1 file
$ pr_branch_stale_check.py --repo 1bit-MONSTER/llama.cpp --pr 457     → rc 2
  cannot fetch hrx/dispatch-match-count (rc 128): couldn't find remote ref … -- cannot tell, not a pass

Both are the right answers: a real finding on a fetchable PR, and cannot-tell on one whose branch is gone (that fork branch was deleted when the PR consolidated into another) rather than a clean 0. The rc 128 handling is the part that makes --pr safe to wire into a required check.

One thing to port from #3078, which is otherwise the same follow-up done on another axis

#3078's --branch mode contributes a distinction this PR does not have, and it is a real one:

def single_branch_exit(fetch_ok, behind, finding):
    """… `stale_finding` returns None both when the branch is LEVEL with main (clean) and when the merge could not be
    measured (cannot tell). Advisory may treat both as "nothing to say"; a gate that blocks a merge may not …"""
    …
    return EXIT_CLEAN if behind == 0 else EXIT_CANNOT_TELL

I have not exercised whether --pr distinguishes "level" from "could not measure" the same way; if it collapses them, a per-PR gate would report clean on a measurement it did not make — the defect both PRs are about. Worth an arm here: --pr where the merge-tree cannot be computed and behind == 0 must be 2, not 0.

Duplicate note

#3077 (--pr) and #3078 (--branch) are the same follow-up (engine#3076) on two axes: this one fixes what the merge is measured against, that one fixes how a single-branch run distinguishes clean from unmeasurable. They are complementary in substance and conflicting in file, so: keep this one for the base fix and --pr, and port #3078's single_branch_exit table (and its four arms) into it rather than maintaining two modes. If only one can land, this is the one — a wrong base invalidates every measurement the tool makes, a collapsed exit code only affects the mode that is not wired yet.

@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 bec3c44: READY

The principle is right and it fixes a false clean in the tool I reviewed into existence — but I could not reproduce the illustration, and my numbers point the other way, so that sentence should be re-measured before it is quoted.

The fix is correct on its own terms

prs = [(p["number"], p["headRefName"], p.get("baseRefName") or "main") for p in json.loads(out or "[]")]

A PR merges into its own base, so its base is what a stale-branch check must measure against. For the engine repo every PR targets main, which is why origin/main was harmless there — and for the llama.cpp fork every PR targets 1bit/hrx-vulkan-patched, where origin/main (indeed origin/master) is a different tree entirely. Reading baseRefName is the only way to be right in both repos, and falling back to "main" when the field is absent is the right default.

What I could not reproduce

The comment's evidence is:

"Measured on fork #457: against origin/master nothing, against its own base 64 lines of common/sampling.cpp alone."

I measured the same two comparisons with the tool's own method (merge-tree, then diff the merged tree against the base), on #457's head as I have it:

  merge into origin/master                    removes 23 843 lines of the base
  merge into origin/1bit/hrx-vulkan-patched   removes     3 lines of the base

Both numbers differ, and on which side shows the deletion my measurement is the reverse of the comment's. I am not calling the claim false — your head may have moved, or the comparison may have been taken differently (a two-dot git diff of a fork branch against master shows tens of thousands of lines for the trivial reason that the fork does not carry master's newer work, and I got that number too before switching to merge-tree).

What is certainly true is the principle, and it does not need the illustration: the base is the PR's target. What I would change is the sentence's evidence, because a measured number that a reader cannot reproduce is worse than no number — and this file has a history of exactly that (the #1783 allow entry whose reason printed as a bare phrase, the 113 vs 112 row counts). Either re-measure it at the current head, or say "for a fork PR the two bases are different trees" and drop the numbers.

#3078 is the same feature without the base question

--branch <ref> and four arms (cannot-fetch -> 2, deletes main's lines -> 1, level -> 0, behind-but-unmeasurable -> 2), 63 added lines against this PR's 48. One of them should close, and this is the one to keep: --pr answering "which base" from the PR itself is the part #3078 leaves to the caller — and the caller getting that wrong is precisely the false clean this PR is about.

The arms I would want here, given the change

Four --branch arms exist in #3078 and I would take them with the --pr mode: cannot-fetch -> 2 (not 0), a real deletion -> 1, level -> 0, behind-but-unmeasurable -> 2. The third and fourth are the pair that matters — a check that cannot measure must not print clean, which is the same distinction this file already makes with EXIT_CANNOT_TELL.

@bong-water-water-bong
bong-water-water-bong merged commit aea4bdb into main Nov 21, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the i679-stale-base branch November 21, 2026 00:45

@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 pr3077: READY

Duplicate of #3078, from the other end — this adds the --pr entry point plus the base fix, that one adds --branch <ref> plus a pure-function exit table. Nothing in either PR claims an issue the gate can see, so it cannot flag them; landing both means the same base fix twice.

The base fix is the part that matters and I can confirm it from a run of my own: at 19:55Z this tool answered "merging this branch removes nothing main has" for every open fork PR — including llama.cpp#452, which inverted a line #451 had just merged into 1bit/hrx-vulkan-patched. The fork's PRs target that branch (#457 base=1bit/hrx-vulkan-patched, #456 likewise, #458 base=hrx/dispatch-match-count), so a diff against origin/main is empty by construction and a real revert reads clean.

Recommendation: keep #3078 for the exit table, take this one's --pr entry point if the gate wants it — or declare the pair a stack. Whichever lands, the base must come from baseRefName: that is the difference between the tool catching #452 and it printing a green line about it.

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 has no single-branch mode, so it cannot be a hard PR gate (engine#2996/#3058 follow-up)

1 participant