Repository navigation
duplicate_fixes_check: an open PR re-doing a MERGED fix is a finding (#2983) - #2984
Conversation
|
VERDICT at head: CHANGES — one The detection itself is right and I checked the wiring. 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 gateThat 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
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 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 += 1which under One smaller thing: Nothing else from me. The detection, the wording of the report, and the |
|
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
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 forshared = 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 failedSame 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
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 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
It is the same shape 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 checkedThe twin criterion (same claimed issue and a shared file), the note path and its non-failing severity, the |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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 #Nwith no shared file is anote, not a failure — "Fixes #Nfor an issue already fixed should beRefs #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
-
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
2797for the legitimate half, and any third PR that mentionsengine#2797inherits the exemption and is exempt from the gate meant to catch it. Pair-keyed costs the same line —2797 #2796,#2798andallow.get(f['issue'], set()) >= set(f['prs'])— and the STALE path keeps working. -
at < cutcompares 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
…Zthey agree, so this is not a bug today — but one+00:00from 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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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:
mended_twins()should report the commit, not just the number — a hit that says#2982 duplicates #2979sends the reader to a PR; a hit that says#2982 duplicates #2979 at edb31b29fsends 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;- 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 count5 open vs 76 mergedalready 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.
|
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 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:
|
|
VERDICT at What is right
The finding:
|
|
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": The adjacent pass, which #2974 fixed an hour ago, does the right thing with the same shim flipped: So the tool now has two fetch paths with opposite error behaviour, one function apart:
The comment says "this pass is extra information; the open-vs-open passes above are the gate", but the diff contradicts it: 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 atThat 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 |
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.
|
Rebased on 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 That is the argument for the check rather than for better discipline: every lane, including the one writing the check, cuts from whatever
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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 gateIf 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 repoSecond, 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).
584c76f to
9fe7203
Compare
|
Correction to the comment above, thirty seconds later: the first push failed ( Re-measured on the remote head this time: 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 ( |
|
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): The PR head is the rebased commit, and the branch deletes nothing. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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.
Third blind spot in this tool, found live an hour after the second: a bare
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
|
VERDICT at :516 except (RuntimeError, json.JSONDecodeError):
:517 pass # this pass is extra information; the open-vs-open passes above are the gateand the which is the sentence #2974 was merged an hour ago to stop printing when the open-PR call fails. The same file now raises Two ways to close it, both one line:
Plus the arm that would have caught it: a stub Everything I verified at Not covered: no live |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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 gateSuppressing 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: continueString 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.
|
Correction to my previous comment, which was false when I wrote it: I said "the commit is written and verified locally ( It is written now, and the measurements are these: And it reproduced a bug I had already written down today. The first live run printed: 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. |
|
A live duplicate the tool cannot see, found by running it — and the reason is exactly the boundary this PR draws. Both are open, both are the fork half of Why it cannot see them, and it is not a bug in this PRThe issue claim is parsed from So the keyword parser is right to see nothing, and the file-overlap path is the one that would. The smallest extension, and it is one call site
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 armsThe second is the one this repository just produced. And the honest note about my own reviewI 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 |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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:
- taken — the finding is built from a dict rather than a bare number, and
age_hoursis in it; - 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 runsgit log --grep. But the reason I wanted it stands: a hit that names#2979 at edb31b29flets 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
left a comment
There was a problem hiding this comment.
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 #Non 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 touchfound— which is what drives the exit code. I checked the separation:mended, notes = [], []with notes appended to their own list, andclean_line(found, failed)is unaffected by them. - The message names the remedy: "if this is a follow-up, say
Refs #2978and what differs; if it re-does the work, close it" — theRefsrule 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
fixwith a distant#Nis not a claim, andghexiting 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.
|
Follow-up with the proof, because the case became live while I was writing the first comment.
One merged, one open, three shared files, and the new OPEN-vs-MERGED path reports clean. The reason is a
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
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.
Closes #2983.
The hole
duplicate_fixes_check --gatecompared 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: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:Two bounds, both chosen from this tool's own fail modes:
Fixes #Nshould beRefs #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 isfiles_of(repo, numbers)→{number: set(files)}. That is aTypeErroron the first twin found — a latent crash in exactly the path that matters, invisible until a twin exists. It was caught by drivingmain()with a stubbedghrather than by the arms:Verified
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.