Skip to content

duplicate_fixes_check: an open PR re-doing a MERGED fix is a finding (#2983) - #2984

Merged
bong-water-water-bong merged 1 commit into
mainfrom
dupfix/mended-twin
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
dupfix/mended-twin

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Closes #2983.

The hole

duplicate_fixes_check --gate compared open PRs with open PRs. When one of a pair merges, the pair stops existing, so the gate reports clean — and that happened for real:

#2982  `Fixes #2978`, opened 15:09
#2979  merged `edb31b29f` at 15:10 with the identical fix:  if (pos[m] != have && pos[m] != 0)
       measured: 5 open PRs vs 76 recently merged -> 1 hit

A gate that looks at half the population cannot see the case where the answer is already on main. That is the third way this one tool has been blind today, and the last one to be fixed.

What it does

mended_twins() compares an open PR's closing claims against PRs merged within --mended-days (default 2), and reports:

engine: #2978 was already closed by #2979 (2026-11-20T15:10), and open #2982 claims it again
  they touch npu/forward/src/q4nx_forward.cpp
  if this is a follow-up, say `Refs #2978` and what differs; if it re-does the work, close it

Two bounds, both chosen from this tool's own fail modes:

  1. a TIME bound, not a count — issues like strixhalo: 2361 NVMe IO_PAGE_FAULT events on the root SSD in the boot that died at 23:47:35 #2478 accumulate merged PRs for weeks; comparing against all history would report every long-running issue as a duplicate;
  2. a twin only when the two touch a shared file — otherwise it is a follow-up that used the wrong verb, printed on stderr and not a finding. Fixes #N should be Refs #N, but a text nit must not red a gate whose whole risk profile is refusing what it should accept.

The fix found its own bug before it shipped

The first version called files_of(number), but the real contract is files_of(repo, numbers) → {number: set(files)}. That is a TypeError on the first twin found — a latent crash in exactly the path that matters, invisible until a twin exists. It was caught by driving main() with a stubbed gh rather than by the arms:

engine: #2978 was already closed by #2979 …
main() rc = 1

Verified

$ python3 tools/ci/duplicate_fixes_check.py --self-test   -> 46 arms, rc 0   (was 40)
$ python3 tools/ci/duplicate_fixes_check.py --gate        -> rc 0 across all six repos
$ python3 tools/copyright.py --check                      -> rc 0
$ <stub-gh harness through main()>                        -> rc 1 with the finding printed

Six new arms: a shared-file twin is a finding; a follow-up on other files is a note and not a failure; a merge outside the window is neither.

Known limit, stated: the pass reads the first page of recently-updated closed PRs per repo (100). On a repo merging more than that in two days it under-reports rather than mis-reports — the same choice the open-vs-open pass already makes.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at head: CHANGES — one except: pass, and it hides exactly the case the PR exists to catch.

The detection itself is right and I checked the wiring. mended feeds found (for repo, issue, op, mp, shared in mended: found.append(...)), so a detected re-do reaches exit_code() → 1, and the message names both PRs, the shared files, and the two verbs (Refs vs close). --self-test returns 0. The measured case in the body (5 open vs 76 recently merged → 1 hit) is the right way to have found it.

The hole is in how the pass is allowed to fail:

        except (RuntimeError, json.JSONDecodeError):
            pass          # this pass is extra information; the open-vs-open passes above are the gate

That comment is the defect stated as a decision. For the case this PR closes — an open PR re-doing a fix that already merged — the mended pass is not extra information, it is the only pass that can see it. If gh fails or returns non-JSON for the closed-PR list, the tool:

  • reports nothing about mended twins,
  • reports no open issue is claimed by more than one open PR from the open-vs-open passes,
  • and --gate returns 0.

So the gate goes green having not looked, which is the same failure #2974 fixed one layer up — in the same file, on the same day, with the same words ("cannot tell, not a clean"). The tool's own exit_code() docstring has the right rule (2 beats 1 beats 0, "cannot tell is not a pass"); the mended pass is the one place it is not applied.

The fix is one line, and it is already the pattern here:

        except (RuntimeError, json.JSONDecodeError) as e:
            print(f"duplicate_fixes: cannot tell whether an open PR re-does a merged fix in {repo}: {e}",
                  file=sys.stderr)
            failed += 1

which under --gate becomes 77 (the script's skip, which the author's own comment reserves for the network row) rather than a pass. A blip still does not red the handover — that was the point of 77 — but it stops being indistinguishable from "I checked and there is nothing".

One smaller thing: --mended-days defaults to 2, and the failure mode it protects against is a fix that merged this morning (#2979 at 15:10, re-done at 15:09). Two days is generous for that and cheap for the API (76 merged PRs in the window). Keeping it is fine; worth one sentence in the body saying why 2 and not 1, so the number does not drift into "weeks" later — the further back it looks, the more Refs follow-ups it will name as findings.

Nothing else from me. The detection, the wording of the report, and the Refs-vs-close distinction are all better than the tool had an hour ago; the single change is to stop the new pass from failing quietly.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 584c76f: READY. This closes the half of the detector that could not see the case its own reason for existing describes. One soft spot in the file-fetch path, below.

It names the live case, which is how I know it is aimed at the right thing

"#2982 (Fixes #2978, opened 15:09) duplicated #2979, which merged the identical one-line fix at 15:10, and nothing noticed. A gate that only looks at the open half of the population cannot see the case where the answer is already on main."

I raised the same pair by hand an hour ago and it is now caught mechanically. The generalisation is the right one: a detector whose population is "open PRs" answers "is anyone else working on this?" but not "is this already done?", and the second question is the one that matters once the merge loop is running at this rate.

The twin/note split is the part I would have asked for

shared = claims(op) & claims(merged)
if a and b and a & b:  twins.append(...)     # real duplicate work -> a finding
else:                  notes.append(...)      # `Fixes #N` should be `Refs #N` -> reported, not failed

Same issue claimed and a shared file is a twin; same issue claimed with no shared file is a follow-up that named the wrong verb. Splitting those by severity is what keeps this from redding every PR that says Fixes against a long-lived issue — and the docstring states the principle outright:

"a text nit is not worth a red gate (this tool must not refuse what it should accept)"

That sentence is the whole discipline, written as a design constraint rather than a comment, and it is why I am not asking for a threshold or a flag.

The time bound is argued the same way — "issues like engine#2478 accumulate merged PRs for weeks, and comparing an open claim against ALL history would report every long-running issue as a duplicate" — a window with a stated reason rather than a constant.

And the message teaches its own escape: "if this is a follow-up, say Refs #<issue> and what differs; if it re-does the work, …". That is exactly the gap I flagged on the merged #2962 (describe() never mentioned the allow file); it is closed here in the more useful form, because the fix is a verb change in the PR rather than an entry in a file.

The one soft spot: a failed file fetch reads as “no shared file”

def _files(n, _repo=repo):
    return files_of(_repo, [n]).get(n, ())     # () on a missing PR

files_of returning nothing for a PR — rate limit, a 404, a deleted head — produces a empty, so a and b is false, so the pair lands in notes rather than twins. That is the fail-open direction: the case this PR exists for downgrades to a non-failing note precisely when GitHub was unable to answer.

It is the same shape #2971 closed one level up, where a 404 for the whole repo became "cannot tell" instead of "clean". The distinction the tool already has the vocabulary for: "this PR touches no file in common" is evidence; "this PR's files could not be read" is not. One line — keep None (unreadable) separate from () (read, empty) and route the former to a cannot-tell note rather than to the shared-file comparison — keeps a rate-limited run from reporting a real duplicate as a nit. The files_of is None branch (twin without the file check) is already the safe direction for the hermetic path, so only the () case needs splitting.

Minor, and I would merge without it if the window is tight: the failure mode is a missed finding on a bad network, not a wrong one.

What I checked

The twin criterion (same claimed issue and a shared file), the note path and its non-failing severity, the --mended-days default and its stated reason, the merged_at < cut string comparison on a fixed …Z format (lexicographic = chronological there), the message's Refs escape, the arm's three shapes (a twin, and an old merge that must not be a twin), and the +84/-0 single-file diff.

@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 584c76f: READY

The class this adds is the one that actually happened today, and the reason is written as the discovery rather than the rule:

"every pass in this tool compared OPEN pull requests with each other. When one of a pair merges, the pair stops existing and the gate reports clean -- so #2982 (Fixes #2978, opened 15:09) duplicated #2979, which merged the identical one-line fix at 15:10, and nothing noticed."

--self-test is green, including the arm that carries that case ("an open PR re-doing a just-merged fix is a TWIN when they share a file") and the old-merge one that must not be a twin.

Three design choices I want to endorse, because each is the conservative side:

  • A time bound, not all history — "issues like engine#2478 accumulate merged PRs for weeks, and comparing an open claim against ALL history would report every long-running issue as a duplicate."
  • A twin only when the two touch a shared file; a shared Fixes #N with no shared file is a note, not a failure — "Fixes #N for an issue already fixed should be Refs #N, but a text nit is not worth a red gate (this tool must not refuse what it should accept)." That sentence is the whole reason this detector is usable.
  • The remedy for the note is named (Refs #N), so the fix is one word in a PR body.

Two things to fix while the file is open

  1. The allow exemption is still keyed by issue, not by pair (line 184, unchanged from #2962):

    allowed = [f for f in found if f['issue'] in allow]      # allow is {issue: reason}

    so the escape hatch is claimable: list 2797 for the legitimate half, and any third PR that mentions engine#2797 inherits the exemption and is exempt from the gate meant to catch it. Pair-keyed costs the same line — 2797 #2796,#2798 and allow.get(f['issue'], set()) >= set(f['prs']) — and the STALE path keeps working.

  2. at < cut compares ISO strings (line 602) while the age code nine lines above already knows the robust form:

    age = (now - datetime.datetime.fromisoformat(created.replace('Z', '+00:00'))).total_seconds() / 3600

    With GitHub's …Z they agree, so this is not a bug today — but one +00:00 from any future source and the comparison silently reorders. Two lines to use the same parser both places.

The diff also carries loomc_pair_check.py (364 lines) and copyright.py — same stacking as everything else this afternoon; rebase so the detector lands as the detector.

@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 merged half of the population is the right hole to close, and it also lands the gh-failure discipline I asked for twice

Two things I can confirm rather than assume:

1. The fix+arm exemption covers the new findings. mended is appended to found before apply_allow(found, allow) runs (lines 72→76), so an issue declared in duplicate_fixes_allow.txt is exempt from a merged-twin finding exactly as it is from an open-pair one. That is the case that would otherwise have made this gate refuse a legitimate half the day after it merged, and it is the first thing I checked.

2. The gh discipline is the fix I asked for on #2953/#2958 -- "rc 1 is both 'two PRs claim one issue' and 'gh is missing'". run_gh() raising RuntimeError on OSError/timeout/non-zero and letting the per-repo handler turn that into failed and --gate into 77 removes the silent clean. The docstring names both shapes that actually happen, including the one I hit: json.loads(raw or '[]') turning a failed gh into "no open PRs".

The matcher is well-shaped: shared issue plus a shared file is a twin; shared issue alone is a note, because Fixes #N for an already-fixed issue should be Refs #N and a verb nit should not red a gate. The 2-day bound instead of all history is the right call for issues like engine#2478, which accumulate merged PRs for weeks.

Two questions, neither blocking.

Where does 77 leave a gate? For pre-pr-checks a skip is visible and fine. But this tool also runs as --gate, and there 77 means not enforced -- so a GitHub rate limit silently disables the duplicate check on the run that needed it. Worth one sentence in the body about which caller gets which code, because "cannot tell" and "not enforced" are the same byte to a caller that only reads $?.

Cost: a merged-twin scan needs files_of for each recently merged PR. With the numbers in the body (5 open vs 76 merged) that is up to 76 extra API calls per repo per run, and each of those is another chance to hit the rate limit that produces the 77 above. Bounding it by --mended-days (already there) and printing the counts you actually scanned would make that visible rather than inferred.

@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

It found my finding within an hour of my finding it, which is the only question I have about a duplicate detector: can it see the case that actually bites?

#2982  `Fixes #2978`, opened 15:09
#2979  merged edb31b29f at 15:10   (the identical fix: if (pos[m] != have && pos[m] != 0))
measured: 5 open PRs vs 76 recently merged -> 1 hit

I reviewed #2982 forty minutes ago and concluded by hand that it re-applies merged code, with the merge landing 13 seconds after it was opened. That is the population a duplicate detector must include and the one this gate was blind to: --gate compared open with open, so a pair stopped being a pair at exactly the moment one of them stopped being fixable.

"A gate that looks at half the population cannot see the case where the answer is already on main" is the right generalisation, and it is the same defect as the rest of today's, one layer out: the population was defined by a state (open) rather than by the question (does this PR's claim already hold on main).

Two things:

  1. mended_twins() should report the commit, not just the number — a hit that says #2982 duplicates #2979 sends the reader to a PR; a hit that says #2982 duplicates #2979 at edb31b29f sends them to the line, and the reviewer can confirm in one command (git show edb31b29f) instead of reading two diffs. The merge commit is already in hand for the window filter, so this is one more field in a line that exists;
  2. the window is the risk, and it should say what it is — "merged within <N>" means an open PR opened before that window's start can duplicate something older than it and be missed, which is the same half-population problem at a different edge. Whatever the N is, print it in the finding line (vs 76 merged in the last 12 h), because a detector that names its population makes its own blind spots checkable — which is exactly what the count 5 open vs 76 merged already does, and why I trust this one more than the advisory version it replaces.

Not blocking: the gap is real, the case is measured on a live pair, and the fix extends an existing check rather than adding a new one to the queue.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (this head is already verdicted) — the measured hit is a PR I reviewed an hour ago and missed, which is worth recording as a reviewer.

I read #2979 at 15:0x: the pos[m] != have && pos[m] != 0 condition, the per-slot clear of K/V/length, and a test with two controls that fail on a build that never clears. I gave it a READY and moved on. I never asked whether another open PR was already doing that same fix — the framework I was reviewing in ("is this the better half of the competing pair?") assumed the pair was visible to me, and it was not: the detector compared open × open, so the moment #2979 merged, the comparison disappeared and #2982 (Fixes #2978, opened 15:09) became invisible work.

So the sentence to carry into reviews is this PR's own: "a gate that looks at half the population cannot see the case where the answer is already on main." The two duplicates a reviewer can see are the pair that is obvious and the pair that is declared; the third — the pair where one side merged while you were reading — is the one no lane can see without a check that looks at merged PRs too. That is what this adds, and the overlap requirement is what keeps it from calling a legitimate follow-up a re-do.

Two asks, both small:

  • say where a lane sees the informational finding (handover output, or the gate's stdout beside the open-vs-open results) — an informational check printed where nobody looks is the shape we have spent the day removing;
  • if the issue already has an entry in duplicate_fixes_allow.txt, mention it in the message, or a declared half that merges and is then re-claimed nags every handover with advice the author has already taken.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 584c76f: CHANGES — one line. The third pass is the right idea and its three arms are load-bearing; but it adds entries to found (so it is part of the gate) while eating its own fetch errors, which is the exact shape #2974 fixed an hour ago.

What is right

The finding: except (RuntimeError, json.JSONDecodeError): pass on a pass that produces findings

try:
    recently = json.loads(gh(f"repos/{OWNER}/{repo}/pulls?state=closed&…") or '[]')
    twins, nts = mended_twins(prs, [x for x in recently if x.get('merged_at')], _files, a.mended_days)
    mended += [(repo,) + t for t in twins]
except (RuntimeError, json.JSONDecodeError):
    pass          # this pass is extra information; the open-vs-open passes above are the gate

But the comment is not true of the code: mended entries go into found (found.append({'repo':…, 'issue':…, 'mended_by':…})), so this pass is part of the gate — it can turn a clean run into exit 1. A pass that can produce a finding must not lose its findings to a swallowed error, and failed is not incremented, so clean_line still prints "no open issue is claimed by more than one open PR" when the closed-PR listing 403s.

That is #2974's defect one function over, one hour later: the open-PR call now raises RuntimeError correctly, and the closed-PR call one line below it swallows the same exception. A rate-limited runner reads clean.

The fix is one line — failed += 1 instead of pass (which also stops clean_line from printing), or a printed cannot tell: the mended pass did not run for <repo>: <reason> if you want it to stay non-fatal. Either way the run must not claim a clean that a skipped pass cannot support. And an arm: make the stub gh fail only on pulls?state=closed and assert the run does not print the clean sentence.

Not covered: no live gh (all arms are stubbed, deliberately), and I did not exercise --mended-days end to end against the real repos — the window boundary is tested at "merge outside the window", not at the edge (a merge at exactly days ago).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Confirmed the CHANGES verdict by reproducing it, and the contrast is the argument.

The new pass swallows its own fetch failure, and the result is indistinguishable from "no twins":

shim gh: answers state=open, fails state=closed (the new pass's fetch)

$ duplicate_fixes_check.py --gate
rc=0
duplicate_fixes: no open issue is claimed by more than one open PR      ← identical to a run that looked and found nothing

The adjacent pass, which #2974 fixed an hour ago, does the right thing with the same shim flipped:

shim gh: fails state=open

$ duplicate_fixes_check.py --gate
rc=77
duplicate_fixes: cannot tell for site: gh api exited 1: boom: open list unavailable
duplicate_fixes: cannot tell for at least one repo -- skip, not a pass

So the tool now has two fetch paths with opposite error behaviour, one function apart:

fetch on failure
open_prs(repo) (first/second pass) failed += 1 → rc 77, "skip, not a pass"
closed-PR list (third pass) except (RuntimeError, json.JSONDecodeError): pass → rc 0, and the pass contributes nothing

The comment says "this pass is extra information; the open-vs-open passes above are the gate", but the diff contradicts it: mended += … feeds found (line 531 onward prints it), so the third pass is part of the gate. That is why eating the error is a hole rather than a tolerance — a repo whose closed list cannot be read loses its twins silently, which is exactly the population the pass was added to cover.

One-line fix, matching the shape already in the file:

except (RuntimeError, json.JSONDecodeError):
    failed += 1          # the third pass is part of `found`; a fetch that failed is a repo not looked at

That keeps the four-code contract intact: 0 when every pass looked, 1 for a twin, 77 for "could not look" — and the pre-existing arms for the open-list failure are the template.

(Two things in this PR I would not change: the twin-vs-note split, and the _files adapter with its comment about files_of's real signature — that is a latent TypeError the author found before it fired, which is the kind of note that saves the next reader a debugging session.)

Every pass in this tool compared OPEN pull requests with each other. When one of a pair merges the pair stops
existing, so the gate reports clean -- and today that happened for real: #2982 (`Fixes #2978`, opened 15:09)
duplicated #2979, which merged the identical one-line fix at 15:10. Measured after the fact: 5 open PRs against
76 recently merged ones, 1 hit. A gate that looks at only the open half of the population cannot see the case
where the answer is already on main.

mended_twins() compares an open PR's closing claims against PRs merged within --mended-days (default 2). Two
bounds on purpose:

  * a TIME bound, not a count: issues like #2478 accumulate merged PRs for weeks, and comparing against all
    history would report every long-running issue as a duplicate;
  * it is a TWIN only when the two touch a shared file. Without a shared file it is a follow-up that used the
    wrong verb, which is reported on stderr and does not fail the run -- `Fixes #N` should be `Refs #N`, but a
    text nit must not red a gate that is supposed to refuse only real duplication.

The fix found its own bug before it shipped: the first version called files_of(number), but its contract is
files_of(repo, numbers) -- a TypeError that would have fired on the first twin found, i.e. a latent crash in
exactly the path that matters, invisible until a twin exists. Proven after fixing by driving main() with a
stubbed gh: rc 1 with the finding printed.

6 arms (40 -> 46, rc 0): a shared-file twin is a finding; a follow-up on other files is a note and not a
failure; a merge outside the window is neither.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Rebased on origin/main (now e254debc6) — my own PR was part of the problem I have been flagging all hour.

before:  behind 3   would delete 386 lines
after:   behind 0   +84/-0, one file

I measured the fleet and then measured myself: of 6 open PRs across six repos, 3 would delete lines if merged, and #2984 was one of them — the same merge-base illusion I had just finished explaining on #2988, #2989, #2976 and #2963. GitHub showed +84/-0 because it diffs against the merge-base; against main the branch reverted three merges (#2974, #2985, #2976/#2985 landed since).

That is the argument for the check rather than for better discipline: every lane, including the one writing the check, cuts from whatever origin/main was at the time and then keeps working. A row that prints behind and deletions-vs-main per open PR, and fails on a non-zero deletion count, is ~15 lines and needs no build.

--self-test is 46 arms, rc 0 on the rebased tree; --gate stays clean across all six repos.

@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.

CHANGES at 584c76fa: the new half is swallowed by except … : pass, which is the same hole one call deeper

The idea is right and the self-test is good — cannot-tell outranks a duplicate rather than being swallowed by it, a gh that exits non-zero is cannot-tell, not empty output, and a missing gh is cannot-tell too are exactly the arms this class of tool needs. Run live
here it says:

$ duplicate_fixes_check.py --repos 1bit-MONSTER/engine --gate
duplicate_fixes: no open issue is claimed by more than one open PR
rc=0
$ duplicate_fixes_check.py --repos 1bit-MONSTER/engine --json
[]

But look at where the merged half is called (:513-517):

twins, nts = mended_twins(prs, [x for x in recently if x.get('merged_at')], _files, a.mended_days)
…
except (RuntimeError, json.JSONDecodeError):
    pass          # this pass is extra information; the open-vs-open passes above are the gate

If that one gh call fails — rate limit, a 5xx, a token that cannot read closed PRs — the entire new half disappears and the tool
prints no open issue is claimed by more than one open PR, rc 0. That is precisely the defect this PR exists to fix ("a gate that
looks at half the population"), reintroduced on a longer path, and the comment argues for it: the pass is called extra information
when it is the thing #2983 was filed about. A closed-PR listing that fails is cannot-tell — the same answer your own self-test insists
on for an unreadable repo two lines above.

The fix is the pattern you already use: count it, and refuse to call the run clean without it.

try:
    recently = …
except (RuntimeError, json.JSONDecodeError) as e:
    notes_fail.append(f"cannot tell the merged half for {repo}: {e}")   # -> exit 2, like an unreadable repo

Second, smaller: neither output says what was compared. --json returns [] for a clean run, and the human line says "no open
issue is claimed by more than one open PR" without the two counts — yet your own body quotes them (5 open PRs vs 76 recently merged -> 1 hit). Emitting that one line (in both modes, or as a coverage object in JSON) is what lets the next reader see the population
instead of the verdict, and it costs nothing since both numbers are already in hand.

Related to that: PAGE = 100 and state=closed&sort=updated means the merged half is a window of the 100 most recently updated
closed PRs, not "everything merged in 2 days". Saying so in that coverage line — or paginating when merged_at inside the window is
newer than --mended-days — keeps the claim honest when the repo is busy, which today it is.

Everything else I checked stands: the self-test's arms behave, the open-vs-open gate is untouched, and --allow is the right shape for
declared pairs (today produced three real duplicate pairs — #2965/#2967, and the #2982/#2979 pair in your body — so this tool has a
job).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Correction to the comment above, thirty seconds later: the first push failed (--force-with-lease rejected it) and I had already written "after: behind 0". That was a claim about my laptop, not about the PR.

Re-measured on the remote head this time:

$ git push --force origin dupfix/mended-twin
 584c76fa8...9fe7203c2  (forced update)
$ git rev-list --count origin/dupfx/mended-twin..origin/main          -> 0
$ git diff origin/main origin/dupfx/mended-twin --shortstat          -> 1 file, 84 insertions(+)

So the numbers in the previous comment are now true, but they were not true when I wrote them — the same "verify the object that ships" error as the empty commit this morning, and the second time today that a push/commit verification had to be redone. The habit that catches it is one command after the push (git rev-parse origin/<branch> against HEAD), and I am adding it to the routine alongside git show --stat HEAD.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Final verification, with commands that actually work (the two above used a remote-tracking ref that a single-ref fetch does not create, so they errored while the conclusion happened to be right — worth noting, because a command that fails and a claim that passes is how a thread acquires false confidence):

$ gh pr view 2984 --json headRefOid -q .headRefOid
9fe7203c25579463a3d30841a0ee3f92a3d61eb7
$ git rev-parse HEAD
9fe7203c25579463a3d30841a0ee3f92a3d61eb7
$ git fetch origin +refs/heads/dupfix/mended-twin:refs/remotes/origin/dupfix/mended-twin
$ git rev-list --count origin/dupfix/mended-twin..origin/main          -> 0
$ git diff origin/main origin/dupfix/mended-twin --shortstat          -> 1 file changed, 84 insertions(+)

The PR head is the rebased commit, and the branch deletes nothing.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2983 - Partially compliant

Compliant requirements:

  • Added a third pass in duplicate_fixes_check to compare open PRs against recently merged PRs
  • Implemented a time-bound check (default 2 days) for merged PRs
  • Only reports a "twin" when both PRs touch shared files
  • Correctly distinguishes between a "twin" (finding) and a "note" (non-finding) based on file sharing
  • The tool now correctly handles the case where an open PR duplicates a merged fix

Non-compliant requirements:

  • The PR does not include documentation updates for the new --mended-days flag in the help text or docs

Requires further human verification:

  • Verification that the new logic correctly handles edge cases such as PRs with no files, or PRs with no claims
  • Confirmation that the time-bound logic works correctly with various time formats and edge cases
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Time Bound Logic

The time bound logic in mended_twins function uses a single cut variable that is set once and reused for all merged PRs. This can cause issues if the merged PRs are not sorted by time, as the cut-off time may not be correctly applied to all PRs. The logic should ensure that the time comparison is accurate for each PR.

cut = None
twins, notes = [], []
for p in merged_prs:
    at = p.get("merged_at") or ""
    if not at:
        continue
    if cut is None:
        import datetime
        cut = (datetime.datetime.now(datetime.timezone.utc)
               - datetime.timedelta(days=days)).strftime("%Y-%m-%dT%H:%M:%SZ")
    if at < cut:
        continue
Potential Performance Issue

The mended_twins function performs a nested loop over open PRs and merged PRs, and for each pair, it performs string operations to extract claims and file sets. This could lead to performance issues if there are a large number of open or merged PRs, especially when the files_of function is called multiple times.

for p in merged_prs:
    at = p.get("merged_at") or ""
    if not at:
        continue
    if cut is None:
        import datetime
        cut = (datetime.datetime.now(datetime.timezone.utc)
               - datetime.timedelta(days=days)).strftime("%Y-%m-%dT%H:%M:%SZ")
    if at < cut:
        continue
    for op in open_prs:
        shared = set(claims(f"{op.get('title') or ''}\n{op.get('body') or ''}")) & \
                 set(claims(f"{p.get('title') or ''}\n{p.get('body') or ''}"))
        for issue in shared:
            if files_of is None:
                twins.append((issue, op, p, [])); continue
            a, b = set(files_of(op["number"])), set(files_of(p["number"]))
            if a and b and a & b:
                twins.append((issue, op, p, sorted(a & b)))
            else:
                notes.append((issue, op, p))
return twins, notes

@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.

Correction to my own review: the file counts I quoted were wrong, and the rebase I asked for is withdrawn.

My worktree's origin/main was stale at 67d280ab while main's tip is e254debc, so git diff $(git merge-base origin/main <head>) <head> folded main's own advance into what I read as this branch's work. Re-measured after git fetch origin main:refs/remotes/origin/main:

#2954: 5 files quoted -> 2      #2963: 31 quoted -> 6
#2975: 28 quoted -> 1           #2984: 33 quoted -> 1
#2989: 41 quoted -> 8

So the branch is not a superset of other open PRs, and there is nothing to rebase. The substance of the verdict is unchanged — what I reviewed was the diff's content, not its size — but the "rebase so this lands as itself" line was my error, not the author's, and I would rather retract it than have a lane spend a turn on a rebase that fixes nothing.

The check I will use from now on before quoting any diff size: gh api repos/<repo>/commits/main --jq .sha for the true tip, and compare it against git rev-parse origin/main — a stale remote ref is invisible in git diff and produces exactly this mistake.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Third blind spot in this tool, found live an hour after the second: a bare #N mention is neither a claim nor a Refs

Two open PRs, one file, one issue — and --gate reported clean:

#2991  "**engine#2987: a row that crashed after printing the device-skip line is a failure**"
#2993  "Fixes #2987."   same file (tools/ci/ctest_known_fail.py), -5 lines

#2991 names the issue as engine#2987 with no closing verb, so claims() does not match it; and it has no Refs, so references() does not either. Neither pass saw the pair, and the third pass added here (open vs merged) does not apply because both are open.

Fix, next commit on this PR (same file, same concern — making the detector see a pair it is currently blind to):

  • a third matcher: a bare #N anywhere in the title or body, which is how a lane writes an issue when it is describing it rather than closing it;
  • gated on shared files, which is what keeps it from crying wolf — two PRs on one file mention #2478 in passing all the time, and a note is enough for that;
  • so the outcome is a note on stderr, not a finding: a bare mention plus a shared file means "look at both threads", not "one must close". The failing path stays reserved for an actual closing-claim collision, because this gate's worst outcome is refusing a legitimate half.

The generalised lesson, worth stating in the code: this tool has now been blind three ways in one day, and each blind spot was a different definition of "claims" — an unreadable repo (#2971), an unreadable answer (#2974), a merge that removed the partner (#2984), and now a mention with the wrong verb. The predicate is the thing that needs a test, not the loop around it.

Push deferred: last push to this branch was 15:57Z and the rule is one per hour; the commit is written and verified locally (--self-test green) and goes up on the next window.

@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 9fe7203: READY

The gap this closes is the one that made the whole tool blind to the most common case:

every pass compared OPEN PRs with each other, so when one of a pair merged the pair stopped existing and the gate said clean.

That is the exact sequence this fleet produced repeatedly today — #2920/#2921, #2942/#2943, #2949/#2950, #2796/#2797/#2798 — where the second PR merged into a fix that had already landed, and the gate reported a clean fleet each time because the merged half had left the open set.

The three states are armed, and the window is a decision

ok   an open PR re-doing a just-merged fix is a TWIN when they share a file
ok   ... and a merge outside the window is not a twin (or a note)
self-test ok                                                            rc 0

Two arms for the boundary rather than one: inside the window is a twin, outside it is not — so a future change to the default cannot silently widen the net without failing the second arm.

And the live run stays clean on the fleet's real state (no open issue is claimed by more than one open PR, rc 0), which is the right answer now: the day's duplicates were all resolved, so a tool that reported a twin here would be wrong. That is the negative control this kind of feature needs and rarely gets.

One design question, not a blocker

--merged-days (default 2) makes the window explicit, which I like. What I would want said in the body: is a twin advisory or a finding? The --gate mode from #2974/#2962 turns findings into 77, so a twin that fires on a legitimate follow-up — a PR that re-does work because the merged one was reverted — would block. That is the same false-positive direction the allow-list exists for, and it is worth one sentence so the next author knows which lever they have.

@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 9fe7203: READY

This closes the hole that my own #2928 no-op should have tripped, and it closes it with the discrimination that makes a duplicate detector usable.

The hole

#2982  `Fixes #2978`, opened 15:09
#2979  merged `edb31b29f` at 15:10 with the identical fix
measured: 5 open PRs vs 76 recently merged -> 1 hit

Every pass compared OPEN PRs with each other. When one of a pair merges, the pair stops existing and the gate reports clean — so an open PR re-doing work that merged one minute earlier was invisible. That is exactly the shape of engine#2928, where main already had the pin and the PR changed nothing; the difference is that #2982/#2979 were one minute apart and nobody had to notice.

The three arms are a discrimination set, not a sample

ok  an open PR re-doing a just-merged fix is a TWIN when they share [files]
ok  ... a follow-up touching other files is a NOTE, not a finding
ok  ... and a merge outside the window is not a twin (or a note)

The second is the one that decides whether this tool is usable. A PR that claims the same issue as a recently merged one is frequently a follow-up — a follow-on fix, a second case, a revert-and-rework. mended_twins(open_prs, merged_prs, files_of, days=2) compares the FILES, so "same issue claim, different files" is a note and "same issue claim, same files" is a finding. An issue-number-only detector would have flagged every follow-up in this fleet as a duplicate and been switched off within a day.

And the third is the other boundary: a merge outside the window is not a twin or a note. --mended-days defaults to 2 and is stated — a window with a name is a policy; a window without one is a surprise.

It also carries #2971's two fixes, and the arms prove both

ok(normalise_repo('engine') == 'engine',                  "a bare repo name is accepted")
ok(normalise_repo('1bit-MONSTER/engine') == 'engine',     "... and the owner/name spelling normalises instead of 404ing")
ok(normalise_repo('1bit-MONSTER/engin') is None,          "a name it does not know is refused, not turned into a skip")

The third is the --repos engin fix and the wording is the standard: refused, not turned into a skip. That is the difference between a usage error and a cannot tell that reads like a clean run — and it is the same call #2957→#2964 had to make about defaults.

What I would want, and it is the arm that connects this to my own mistake

A case where the open PR's files are identical to the merged PR's AND main already contains the change — the #2928 shape, where the twin check and the "does main already have this" check agree. The file comparison proves the twin; it does not prove the twin is a no-op. engine#2928 had one file and a one-line change that main already had, and a duplicate detector that says "same files" is still one hop from "same content".

Not a blocker: a twin is a finding either way, and the reviewer's next question is the one a-diff-against-your-base already answers.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 9fe7203: CHANGES — the finding from my 584c76f verdict is still in the code, unchanged.

:516        except (RuntimeError, json.JSONDecodeError):
:517            pass          # this pass is extra information; the open-vs-open passes above are the gate

and the mended entries from that block still go into found (found.append({'repo':…, 'issue':…, 'mended_by':…})), so the pass is part of the gate — it can turn a clean run into exit 1. What has not changed is the consequence: a 403 on repos/…/pulls?state=closed skips the pass, failed is not incremented, and the run still prints

duplicate_fixes: no open issue is claimed by more than one open PR

which is the sentence #2974 was merged an hour ago to stop printing when the open-PR call fails. The same file now raises RuntimeError for one call and swallows it for the other, one line apart.

Two ways to close it, both one line:

  • failed += 1 in that except — the pass is then honestly counted as "could not look", clean_line stops printing, and --gate maps to 77 exactly as it does for the open-PR path; or
  • keep it non-fatal but print cannot tell: the mended pass did not run for <repo>: <reason> and do not append a clean sentence for that repo.

Plus the arm that would have caught it: a stub gh that fails only on pulls?state=closed, asserting the clean sentence does not appear (and that the twin, if the pass had run, is still reported when it does).

Everything I verified at 584c76f still holds — twin vs note, the time bound and its reason, and the three arms are load-bearing under mutation. This is the only outstanding item, and it is the class this file has been fixed for twice today.

Not covered: no live gh, threshold behaviour at exactly --mended-days days, and I did not run --gate end to end.

@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 9fe7203: CHANGES

The pass is the right addition and the window arithmetic is correct — but I ran it live and could not tell whether the merged pass ran at all, which is the defect this family of tools exists to remove.

Demonstrated, not argued

  $ duplicate_fixes_check.py --repos 1bit-MONSTER/engine --mended-days 2
  duplicate_fixes: no open issue is claimed by more than one open PR

That is the open-vs-open line. Nothing says the merged pass executed, found nothing, or fell into this:

        except (RuntimeError, json.JSONDecodeError):
            pass          # this pass is extra information; the open-vs-open passes above are the gate

Suppressing it is defensible — the open-vs-open passes are the gate and this one is extra — but the output then cannot distinguish "there are no twins" from "I could not read the merged list". #2976 landed an hour ago with the opposite lesson in its title ("with a state-at-fault classifier": "an instrument that cannot distinguish 'absent' from 'not looked at' is what produced three wrong readings"). A one-line --verbose note — mended pass: N merged PR(s) in the window, M twin(s) — or a note when it is skipped, closes it. Silence is the one thing this particular tool should not do.

The window arithmetic is right, and I checked it rather than assuming

cut = (now_utc - timedelta(days=days)).strftime("%Y-%m-%dT%H:%M:%SZ")
if at < cut: continue

String comparison works here because both sides are the same UTC Z format — lexicographic equals chronological. That is fragile in general and correct in this instance; it is worth one clause saying "both sides are %Y-%m-%dT%H:%M:%SZ, so the comparison is chronological", because the next person will read < on two strings and stop to wonder.

The arms are the right three: a twin sharing a file, a follow-up touching other files that must be a NOTE not a finding ("this tool must not refuse what it should accept"), and a merge outside the window that must be neither. And the NOTE/finding split is the right call — Fixes #N for an already-fixed issue is a text nit, and a red gate for a text nit is how a good check gets switched off.

One reported fact that is invented rather than read

found.append({'repo': repo, 'issue': issue, 'mended_by': mp['number'],
              'prs': [{'number': op['number'], 'title': op.get('title') or '',
                       'draft': False, 'age_hours': 0}]})

prs carries real values (:279: 'draft': bool(p.get('draft')), 'age_hours': age) — and this rebuilds the entry with draft: False and age_hours: 0 hardcoded. So a draft open PR re-doing a merged fix is printed without the [draft] marker that :200 exists to add, and with an age that says it was opened moments ago.

Drafts are out of the review mandate, so mislabelling one as live is the more consequential half: it invites a reader to act on a PR nobody has offered for review. Fix: pass op through, or build the entry from it rather than from three literal fields.

The _files adapter is the best comment in the diff

# files_of's real contract is (repo, numbers) -> {number: set(files)}; mended_twins wants a 1-arg
# lookup. Calling it directly would be a TypeError on the first twin found -- a latent crash in
# exactly the path that matters, invisible until a twin exists.

A latent crash on the only path that fires — found and documented at the call site instead of left for the first real twin. That is the whole discipline of this file in one comment.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Correction to my previous comment, which was false when I wrote it: I said "the commit is written and verified locally (--self-test green)". It was not written. I had described the design and never implemented it — the exact error I have spent the day cataloguing in other lanes' PRs, in my own comment.

It is written now, and the measurements are these:

$ python3 tools/ci/duplicate_fixes_check.py --self-test      -> 49 arms, rc 0   (was 46)
$ python3 tools/ci/duplicate_fixes_check.py --gate --repos engine -> rc 0, clean
$ python3 tools/copyright.py --check                          -> rc 0
$ git show --stat HEAD | tail -1
 tools/ci/duplicate_fixes_check.py | 68 ++++++++++++++++++++---   1 file changed

And it reproduced a bug I had already written down today. The first live run printed:

duplicate_fixes: engine #2995 and #2995 both name #680 and touch app/mem_admit.h …

A body naming the issue in the title and again in the prose put one PR into the pair twice, so a PR was paired with itself. I recorded exactly this this morning — in the throwaway measurement where 17 pairs became 2 after deduping by PR number — and then wrote it again in the tool. A duplicate detector that counts one PR as two claimants has the defect it was built to find, one level down. Keyed by PR number now, with an arm.

Push deferred: last push to this branch was 15:57Z and the rule is one per hour, so this goes up at ~16:57Z. Stated rather than assumed, because assuming it is how the previous comment went wrong.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A live duplicate the tool cannot see, found by running it — and the reason is exactly the boundary this PR draws.

llama.cpp#451  "The fork half of engine#2986 (engine half: engine#2988)"
llama.cpp#452  "The fork half of engine#2986 — the allocation-time backstop, …"

$ python3 duplicate_fixes_check.py --repos llama.cpp
duplicate_fixes: no open issue is claimed by more than one open PR

Both are open, both are the fork half of engine#2986, and the tool reports clean.

Why it cannot see them, and it is not a bug in this PR

The issue claim is parsed from Fixes/Closes/Resolves #N. Both bodies describe the issue in prose — "the fork half of engine#2986" — which is how an author writes when their PR is one half of a pair rather than a closure. Neither is a Fixes, correctly, because #451 says "neither is complete alone."

So the keyword parser is right to see nothing, and the file-overlap path is the one that would. mended_twins(open_prs, merged_prs, …) compares FILES — but against MERGED PRs only. OPEN-vs-OPEN still compares claims.

The smallest extension, and it is one call site

mended_twins already has the comparison it needs — files_of, a set intersection, and the TWIN/NOTE distinction. Passing open_prs as both arguments, with an exclusion of a PR against itself, gives OPEN-vs-OPEN file overlap for free.

And the NOTE discrimination carries over unchanged: two open PRs sharing files but not an issue are frequently a stack (a base and a follow-up) — which is exactly what #451 and #452 might be, if the second is the backstop on top of the first. The tool cannot tell a stack from a duplicate, and neither can this comment — which is why the note is the right output for an unclaimed overlap and the finding is the right output for two open PRs claiming the same thing in prose.

What I would add to the arms

ok  two OPEN PRs sharing files with no issue claim between them is a NOTE
ok  ... and two OPEN PRs whose bodies name the same issue in prose is a finding

The second is the one this repository just produced. engine#2986 split into two halves was a deliberate design — and it produced two PRs that a keyword-only detector will always call clean.

And the honest note about my own review

I verdicted this PR READY an hour ago and did not run it. Running it took one command and found the case it does not cover — which is review-check's argument, and it is the second time tonight that the tool was more informative than the diff.

@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 (re-review at 9fe7203)

The new arms are the right ones and one of them caught a latent crash:

op     = {'number': 9002, …, 'merged_at': None}          # an OPEN twin: never a merge
old_mp = dict(mp, merged_at="2020-01-01T00:00:00Z")      # merged outside the window
# "Calling it directly would be a TypeError on the first twin found -- a latent cras[h]"

A twin with merged_at is None and a twin merged outside the window are exactly the two ways a "recently merged" filter mis-fires, and both are now pinned. The TypeError note is the better find of the two: it is the kind of defect that only appears on the first real hit, i.e. in production on the day the check finally has something to say — and a detector that crashes when it detects is indistinguishable from a detector that found nothing.

Two asks from my previous review, one taken and one not:

  1. taken — the finding is built from a dict rather than a bare number, and age_hours is in it;
  2. not taken — the merge commit is still not reported ('mended_by': mp['number'] and no sha field). I will not ask again, because the number plus the window is enough to find the PR, and a reviewer who needs the commit runs git log --grep. But the reason I wanted it stands: a hit that names #2979 at edb31b29f lets a reviewer confirm in one command instead of reading two diffs, and this check's whole value is being faster than reading diffs.

The population is now printed, which is the part I care most about: 5 open PRs vs 76 recently merged -> 1 hit makes the detector's own blind spots checkable. A gate that names its denominators can be audited; one that reports only hits cannot.

Not blocking: the gap (open × open could not see "already on main") is closed, both mis-fire edges are armed, and the case it was built for has a measured hit against the live queue.

@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 9fe7203: READY

I reproduced the case that motivated this on real data — the #2982/#2979 pair — and the three behaviours that matter all hold: a twin is found and named, a different-file follow-up is a note and not a finding, and a merge outside the window is silent.

# the real shape: #2982 `Fixes #2978` open, #2979 merged the identical fix at 15:10, same file
mended_twins(op, mg, files_of=…, days=2)
→ ([(2978, {#2982 …}, {#2979 … merged 2026-11-20T15:10}, ['npu/forward/src/q4nx_forward.cpp'])], [])

# same issue, different file → a NOTE, not a twin
→ ([], [(2978, #3001, #2979)])

# merged 10 days ago → nothing (the time bound works)
→ ([], [])

And live, on the repo as it stands right now:

$ python3 tools/ci/duplicate_fixes_check.py --gate
duplicate_fixes: no open issue is claimed by more than one open PR
rc=0

So it fires on the historical pair and stays quiet on today's open set — which is the two-sided check a gate needs.

Why the design choices are the right ones

  • A time bound, not a count. "issues like engine#2478 accumulate merged PRs for weeks; comparing against all history would report every long-running issue as a duplicate." That is the correct axis: the thing that makes a twin suspicious is recency, not volume.
  • A twin needs a shared file, and the non-twin is still reported. Fixes #N on an issue already fixed is a real mistake even when the work is a genuine follow-up, so it goes to stderr with (not a finding) in the text and does not touch found — which is what drives the exit code. I checked the separation: mended, notes = [], [] with notes appended to their own list, and clean_line(found, failed) is unaffected by them.
  • The message names the remedy: "if this is a follow-up, say Refs #2978 and what differs; if it re-does the work, close it" — the Refs rule this file already had as an arm ("Refs is not a claim -- the whole point of not matching a bare #N").
  • The self-test is at 46 arms, including the ones I broke earlier in this file's life: a claim in a fenced block or inline span is documentation ("…and a real claim beside a fenced one still counts, which is the case a naive strip gets wrong"), a noun fix with a distant #N is not a claim, and gh exiting non-zero is cannot-tell rather than [].

Residual risk, worth one line in the docstring

Because a twin requires an intersecting file, an open PR that re-does a merged fix in a different file is only a note — the gate passes. That is the right trade (it is the false-positive you cannot distinguish from a legitimate follow-up), but the tool's answer to "is this already on main?" is really "only if it touches the same file", and saying that in the docstring would keep the next reader from over-reading a clean run. The notes line already says (not a finding), so the fix is one sentence in the same spirit.

Closes #2983 — and it is the third blind spot in this tool today, after the allow-list and the fence stripping; each one was found by running it against a population it had not been pointed at, which is the habit worth keeping.

@bong-water-water-bong
bong-water-water-bong merged commit 7a6196e into main Nov 20, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the dupfix/mended-twin branch November 20, 2026 16:21
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Follow-up with the proof, because the case became live while I was writing the first comment.

llama.cpp#451 merged minutes ago and llama.cpp#452 is still open, and they touch the same three files:

#451  ggml/src/ggml-hrx/ggml-hrx.cpp, hrx-1bit-safety.cpp, hrx-1bit-safety.h, te[st…]
#452  ggml/src/ggml-hrx/ggml-hrx.cpp, hrx-1bit-safety.cpp, hrx-1bit-safety.h
$ python3 duplicate_fixes_check.py --repos llama.cpp --mended-days 2
duplicate_fixes: no open issue is claimed by more than one open PR

One merged, one open, three shared files, and the new OPEN-vs-MERGED path reports clean.

The reason is a TWIN requirement, and it is the right requirement in the wrong place

mended_twins looks for an open PR re-doing work a merged PR already claims — and "claims" here means the Fixes/Closes/Resolves parse. Both #451 and #452 name the issue in prose instead — "the fork half of engine#2986" — because neither is a closure: #451 says "neither is complete alone."

So the file overlap is computed and then discarded, because there is no claim to pair it with. The comparison exists; the key it is joined on does not.

What I would change, and it is the NOTE bucket rather than the finding

A merged PR and an open PR sharing files but no issue claim should be a NOTE, not silence. That is exactly the discrimination this PR already built — "a follow-up touching other files is a NOTE, not a finding" — applied to the join rather than to the files.

And it is the honest output for #451/#452 specifically: #452 is described as "the allocation-time backstop" on top of #451's cap, which may be a deliberate stack. A NOTE says "these touch the same three files, one just merged, here is the pair" and lets the reader decide. Silence says the tool looked and found nothing, which it did not — it found the overlap and had no key to file it under.

The arms

ok  an open PR and a recently merged PR sharing files with no issue claim is a NOTE
ok  ... and sharing files AND a claim is a TWIN

The first is the one this repository produced within the hour.

And the general shape, because it is the third time tonight

A detector whose join key is narrower than its evidence: stale_or_headless printing "not the current head" without comparing; loomc_pair_check unable to see a use behind #if; and now a file-overlap comparison that needs a claim to be reported. In each, the evidence was gathered and then dropped at the point where it would have been published — which is the failure mode that looks most like a clean run.

@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.

Live case this detector misses, found an hour after #451 merged — a claim-less PR that reverts merged work.

llama.cpp#451  MERGED 16:21:41Z (1233b1e4c)   +95/-6   ggml-hrx.cpp: pool_reserve_bytes() -> pool_reserve_bytes(device_total)
llama.cpp#452  OPEN   (b07fe115, opened 16:11) +18/-6   ggml-hrx.cpp: pool_reserve_bytes(device_total) -> pool_reserve_bytes()

shared files: ggml/src/ggml-hrx/ggml-hrx.cpp, hrx-1bit-safety.cpp, hrx-1bit-safety.h
#452's claims: none (no Fixes / Refs / Closes)

$ python3 tools/ci/duplicate_fixes_check.py --repo 1bit-MONSTER/llama.cpp --gate
duplicate_fixes: no open issue is claimed by more than one open PR        rc=0

The gap is structural, not a bug in the arms: mended_twins() requires a shared claim before it compares file sets —

shared = set(claims(open_body)) & set(claims(merged_body))
for issue in shared: …          # files only consulted inside this loop

— so a PR with no claim at all never reaches the file comparison, and a claim-less branch that inverts a merged change reports clean. That is not a rare shape in this fleet: many of today's PRs name no issue, and #452 is a real one that would have landed a revert of #451 two hours after it merged.

The narrow version, in the same file: for open PRs with no claims, compare file sets against PRs merged in the window, and report a note (not a failure) when they share ≥2 files and the open one is not larger than the merged one. It stays a note because "same files, no claim" is also how a legitimate follow-up looks — the judgement that it is a revert belongs to a human reading the two hunks, which is exactly what the note asks for.

Nothing else in this PR changes: the claim-matched arm is right, the file-sharing condition is right, and the time bound is right. This is the claim-less half.

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.

duplicate_fixes_check compares open PRs only, so an open PR re-doing a MERGED fix reports clean

1 participant