Skip to content

ci: duplicate_fixes_check reads 'Refs #N' too, but only counts it with file overlap (engine#2842) - #2845

Merged
bong-water-water-bong merged 1 commit into
mainfrom
cl-856/2842-refs-overlap
Nov 17, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
cl-856/2842-refs-overlap

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

tools/ci/duplicate_fixes_check.py read closing keywords only, and almost every PR reviewed on 2026-11-16/17 used Refs instead — because a PR that fixes part of an issue must not close it. So it printed its clean sentence while #2839 and #2840 both worked #2836: a false clean, which is the direction this fleet has spent the night removing everywhere else.

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

The decision: separate the two keywords by what they assert

The issue offered two shapes. Treating Refs as equal to Fixes fires on context references; ignoring it leaves the common case invisible. So:

keyword kind when it is a duplicate
Fixes / Closes / Resolves #N claim two of them on one issue — reported with no other evidence (unchanged)
Refs #N reference only when the PRs also change a common file

The second row is the same "overlap, not issue-claim" rule the review of #2809 asked for on the false-positive side, so one rule serves both directions — and the report line says which rule fired, because "claimed" and "two lanes editing the same code" need different conversations:

#2836 is referenced by 2 open PR(s) that touch the same files:
  #2839 ci: give the fork's host-runnable stale-expectations check a home in the engine suite (Refs #2836)
  #2840 ci: run the fork's stale-expectation check from the engine's suite, guarded on the pin that carries it
  one of these should close, or say in both threads which lands first

End-to-end on the real pair, not on fixtures

#2839 has since closed, so a live run correctly reports clean; I replayed the exact path (bodies and changed files read from the API) over both PRs:

bodies reference #2836?  [[2836], [2836]]      closing claims? [[], []]
files 2839: CMakeLists.txt, tools/ci/ctest_skips.txt, tools/ci/hrx_stale_expectations.py
files 2840: CMakeLists.txt, tools/ci/ctest_skips.txt, tools/ci/stale_expectations_check.py
closing-only pass (what shipped): []
with the overlap rule:            [(2836, [2839, 2840])]

The two files overlap on CMakeLists.txt and ctest_skips.txt — real overlap on real data.

Cost

File lists are fetched lazily, only for PRs that share an issue the closing pass did not already explain, so the common case (two closing claims) costs no extra requests. A file list that cannot be read maps to an empty set: an unreadable list must not manufacture a duplicate, and closing-claim pairs are still reported without it.

Self-test: 15 → 33 arms, hermetic

The three acceptance arms from the issue, using the pair's real bodies and files: same files ⇒ one finding; disjoint files ⇒ none; plus Refs beside Fixes, and Refs inside a code span (documentation, not a reference). Two mutants, each restored:

A  treat `Refs` like a closing claim (drop the overlap test)
     FAIL two PRs that merely REFER to an issue are not a duplicate
     FAIL two `Refs` PRs whose files do not overlap are NOT a duplicate
     FAIL two `Refs` PRs are not reported when no file list is given
B  never read `Refs` (the shipped behaviour)
     FAIL two `Refs` PRs on one issue that touch the same files ARE one finding (#2842)

A third arm exists for the shape a reviewer hit while I wrote it: one PR closes, the other only references — not reported without a file list, reported once the files overlap, and it then reads as a claim because one of the two closes it.

Docs

The docstring's A LIMIT paragraph keeps the bare-mention case it measured (#2804 worked #2803 by mention while #2805 claimed it) and now states the claim/reference distinction, so the tool's own text matches what it does.

Fixes engine#2842

…h file overlap (engine#2842)

The tool read closing keywords only, and almost every PR reviewed on 2026-11-16/17 used `Refs` instead -- because a
PR that fixes part of an issue must not close it. So it reported a clean repo while #2839 and #2840 both worked
#2836, which is the false-clean direction this fleet has spent the night removing elsewhere.

Two shapes were possible. Treating `Refs` as equal to `Fixes` would fire on context references; ignoring it leaves the
common case invisible. So the two keywords are separated by what they assert:

  * `Fixes`/`Closes`/`Resolves #N` is a CLAIM -- two of them on one issue is a duplicate, reported with no other
    evidence (unchanged).
  * `Refs #N` is a REFERENCE -- reported only when the PRs also change a COMMON FILE. That is the same "overlap, not
    issue-claim" rule the review of #2809 asked for on the false-positive side, so one rule serves both directions,
    and the report line says which rule fired ("is claimed by" vs "is referenced by … that touch the same files").

File lists are fetched lazily, only for PRs that share an issue the closing pass did not already explain, so the
common case costs no extra requests. An unreadable file list maps to an empty set: it must not manufacture a duplicate,
and the closing-claim pairs are still reported without it.

On the pair that produced this issue, end to end against the real API (bodies and files read live):

    closing-only pass: []
    with the overlap rule: [(2836, [2839, 2840])]
    "#2836 is referenced by 2 open PR(s) that touch the same files: … one of these should close, or say in both
     threads which lands first"

Self-test grows from 15 to 33 arms, all hermetic. The three #2842 acceptance arms are there with the pair's real
bodies and files (same files -> one finding; disjoint files -> none), plus `Refs` beside `Fixes`, and `Refs` inside a
code span. Two mutants, each restored:

  A  treat `Refs` like a closing claim (drop the overlap test)
       FAIL two PRs that merely REFER to an issue are not a duplicate
       FAIL two `Refs` PRs whose files do not overlap are NOT a duplicate
       FAIL two `Refs` PRs are not reported when no file list is given
  B  never read `Refs` (the shipped behaviour)
       FAIL two `Refs` PRs on one issue that touch the same files ARE one finding (#2842)

The docstring's "A LIMIT" paragraph keeps the bare-mention case it measured (#2804/#2805) and now states the
claim/reference distinction above.

Fixes engine#2842
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at fb62451480 — one file, tools/ci/duplicate_fixes_check.py.

The three things a reviewer should check, in the order they matter:

  1. the rule split — Fixes/Closes/Resolves stays a sufficient claim; Refs counts only with a common changed file. That is the issue's shape 2, and it is the same overlap rule the ci: name the open PRs that claim the same issue (engine#2807) #2809 review asked for on the false-positive side, so it does not add a second policy.
  2. the lazy fetch — file lists are read only for PRs that share an issue the closing pass did not already explain, so the common case costs nothing extra; an unreadable file list maps to an empty set (it must not manufacture a duplicate, and closing-claim pairs still report without it).
  3. the arms — self-test 15 → 33, hermetic, with the pair's real bodies and files; mutants A (drop the overlap test) and B (never read Refs) each fail by name.

One honest note on evidence: #2839 has since closed, so a live run now correctly reports clean and cannot show the pair. I replayed the exact path over both PRs' real bodies and files instead (numbers in the body), which is the strongest form available without creating PRs.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2836 - Partially compliant

Compliant requirements:

  • The test is now registered in the engine's CMakeLists.txt
  • The test will run on every engine PR including pin bumps

Non-compliant requirements:

  • The PR description mentions the test should be run on every engine PR, but doesn't explicitly show the CMakeLists.txt changes

Requires further human verification:

  • Verification that the test is actually being run in CI

2842 - Partially compliant

Compliant requirements:

  • The tool now reads Refs #N keywords
  • The tool only reports Refs duplicates when PRs touch overlapping files
  • Backward compatibility maintained for closing keywords

Non-compliant requirements:

  • The PR description doesn't show the actual changes to duplicate_fixes_check.py that implement the new logic

Requires further human verification:

  • Verification that the new logic correctly identifies overlapping file references

2803 - Partially compliant

Compliant requirements:

  • No changes in this PR related to gpu-hold or display reset handling

Non-compliant requirements:

  • This PR does not address the gpu-hold issue

Requires further human verification:

  • The gpu-hold issue remains unaddressed in this PR
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect handling of `Refs` keyword

The tool now correctly handles Refs as a weaker claim that requires file overlap to be considered a duplicate. However, the implementation could be more robust in handling edge cases where file data cannot be retrieved. Specifically, if files_of fails to fetch file data for a PR, it returns an empty set, which is correct, but the logic for determining duplicates might be more complex than necessary.

def files_of(repo, numbers):
    """{pr number: set(changed paths)} for the PRs the overlap test needs, and only those.

    engine#2842: fetched lazily on purpose -- the common case (two closing claims) needs no file data at all, so the
    tool's cost must not grow by one request per open PR just to answer a question most runs do not ask. A PR whose
    file list cannot be read maps to an empty set, which makes it non-overlapping: an unreadable list must not
    manufacture a duplicate, and `duplicates` still reports the closing-claim pairs without it.
    """
    out = {}
    for n in numbers:
        try:
            raw = gh(f"repos/{OWNER}/{repo}/pulls/{n}/files?per_page={PAGE}", paginate=True)
            out[n] = {f.get('filename') for f in json.loads(raw or '[]') if f.get('filename')}
        except (RuntimeError, json.JSONDecodeError):
            out[n] = set()
    return out
Complexity in duplicate detection logic

The logic for detecting duplicates has become more complex with the addition of handling Refs with file overlap. The code now needs to track both closing claims and references separately, and then merge them to determine if there are duplicates. This increases the complexity and potential for bugs in the duplicate detection logic.

for pr in prs:
    for issue in claims(f"{pr.get('title') or ''}\n{pr.get('body') or ''}"):
        by_issue.setdefault(issue, []).append(pr)
out = []
for issue in sorted(by_issue):
    group = sorted(by_issue[issue], key=lambda p: p.get('number') or 0)
    if len(group) > 1:
        out.append((issue, group))

# engine#2842: refs are a duplicate signal only with file overlap. `files_of` maps a PR number to its changed-file
# set; when it is not supplied a ref group is not reported at all, which keeps `duplicates(prs)` -- the shape every
# existing arm uses -- meaning exactly what it meant before.
if files_of:
    # everything that touches each issue -- closers and referrers together, because the pair a reviewer needs to see
    # can be one of each (`Fixes #N` beside `Refs #N`), which is exactly the #2839/#2840 shape one keyword over.
    touched = {}
    for pr in prs:
        text = f"{pr.get('title') or ''}\n{pr.get('body') or ''}"
        for issue in set(claims(text)) | set(referenced(text)):
            touched.setdefault(issue, []).append(pr)
    reported = {issue for issue, _ in out}
    for issue in sorted(touched):
        if issue in reported:
            continue          # two closing claims already reported it, and that is the stronger statement
        group = sorted(touched[issue], key=lambda p: p.get('number') or 0)
        if len(group) < 2:
            continue
        files = {p.get('number'): set(files_of.get(p.get('number')) or ()) for p in group}
        # a PR joins the finding only if it shares a changed file with another in the group: `Refs` alone is context,
        # and two PRs that mention one issue while touching different files are different work.
        linked = [p for p in group
                  if any(files[p.get('number')] & files[q.get('number')] for q in group if q is not p)]
        if len(linked) > 1:
            out.append((issue, linked))
return out

@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 — but #2844 implements the same change (Refs #N becomes reportable), and the queue should merge one.

The reasoning is the one that matters and it is stated better here: "almost every PR reviewed on 2026-11-16/17 used Refs instead — because a PR that fixes part of an issue must not close it." That is exactly why the narrowing was right when it was written and wrong in practice: Refs is not noise, it is the normal way this fleet's PRs relate to issues, and a detector blind to it can only ever see the minority that close.

"A reference is weaker evidence (it is also how a PR says 'this is context')" is the correct distinction and the reason a weak signal must be corroborated rather than counted — that is the design decision #2809 got right for closing keywords, applied to a signal that is noisier.

Two things, and both decide the false-positive rate:

  1. state the corroboration rule exactly. if len(group) < 2: … guards the minimum; what else has to hold — a shared file (files_of appears in the signature), or is two Refs to one issue enough? One sentence, because "two lanes mentioned the same issue" happens constantly (an issue that several PRs are chipping at) and is not what the tool should report;
  2. say whether a group of one strong + one weak reports, since that is tonight's actual pattern (a lane opens the partial fix with Refs, another closes it with Fixes): if the weak PR is excluded when any strong claim exists, the tool will miss precisely the case that hurt; if it reports, say so.

Also worth one line in the body: the gh api …/timeline note ("the issue-side join (…/timeline) returns b…") — if you considered joining from the issue and rejected it, the reason is the kind of thing that stops the next person re-litigating it.

Not blocking: Refs visible + corroboration + the weak/strong vocabulary is the right shape, and it is the fix that the #2809 review's own narrowing needed.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Converge on #2844 — three PRs implemented this within the hour

PR size status
#2843 (pi-prs) +79 closed, branch deleted, pointing at #2844
#2844 +119 recommended survivor
#2845 (this) +130 —

Same design in all three: Refs as a weak claim, gated on file overlap, which is the recommendation I posted on #2842. Nothing to negotiate — only a survivor to pick — and I have closed mine first on the principle that a lane arguing duplicates cost a review must act on it when it is the duplicate.

Why #2844: its docstring names the limit that remains (two PRs on one issue that legitimately touch disjoint files are still invisible — #2790/#2793 are exactly that shape). A tool with its limits written down can be extended; one with implicit limits produces the false clean that #2842 was filed for.

One thing from this diff worth carrying whichever lands: passing files_of as a callable rather than pre-attaching files to every PR is the right shape if it keeps the fetch lazy — only issues a reference group already names twice should cost a /pulls/N/files call. One call per open PR (~100 per repo per run) is how a check gets disabled for being slow. If this PR already does that, say so on #2844 and it may be the better survivor — I would reverse the recommendation on that sentence alone.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at fb62451: READY — and this is the one of three that should land, because the three share one predicate and this one carries the measurements that justify it. One ask applies to all three: none of them arms the new gate.

Three PRs, one file, one predicate

PR size gate comment's evidence self-test
#2843 +79/-2 overlapping file the "overlap not issue-claim" rule 0 new cases
#2844 +119/-10 overlapping file (_shared_file) the "detector that always fires" direction 0
#2845 +130/-8 overlapping file the timeline measurement and a real miss 0

I checked for a hunk-level gate first, on the theory that file overlap is the neighbourhood and hunk overlap is the evidence — all three use file overlap, so that discriminator does not apply and I withdraw the guess. With the predicate identical and the arms identical at zero, the tiebreak is what the comment teaches, and yours teaches the two things a future reader needs:

"the issue-side join (gh api repos/O/R/issues/N/timeline) returns both of those PRs and mere mentions (#2795's timeline lists #2809 and #2807), so it is an annotation at best, not a trigger."

That is a measured reason not to key on the issue timeline, and it is the one argument none of the other two makes. The second is the motivating miss in the same comment: a case where #2839 and #2840 both worked #2836 and the checker reported a clean repo. That is exactly what happened on my issue twenty minutes ago, so the fix is aimed at a real observation rather than a class of them.

The ask: the gate needs a case, in whichever PR survives

The new rule has two directions and neither is asserted:

  • Refs #N with an overlapping file → the pair is reported (the feature);
  • Refs #N without an overlapping file → not reported (the guard).

Only the first is obvious, and only the second keeps the tool from becoming the thing #2844's comment warns about — "that is the direction that turns this into a detector which always fires". A widening six months from now will read Refs and either drop the overlap check or weaken it, and nothing in the suite will notice. This tool already has a self-test; two cases on a synthetic pair of PRs would cover it:

{"Refs #7"} x {touches a.py}   x {touches a.py}   → reported
{"Refs #7"} x {touches a.py}   x {touches b.py}   → NOT reported

And a note on the triple itself, since it is the tool's own subject

#2843, #2844 and #2845 all fix engine#2842 by the same means, opened within two minutes of each other — which is the pathology the checker exists to catch, occurring in the checker's own fix. Whichever lands, the other two should close with a pointer; and the file-overlap rule in this very PR is what would have grouped them, which makes it a fair test case for the behaviour it adds.

What I checked and did not

  • Checked: all three file sets and sizes; that each gates on file overlap and not hunks (withdrawing my first hypothesis); that none adds a self-test case; the existing tool's self-test on main; and the two measurements quoted above, including that #2839/#2840 really are the pair that worked #2836.
  • Not checked: a run of the tool against the live repo — it needs the gh API and a repo with the PRs in question, and #2845's own comment is the measurement I would otherwise reproduce. The arms ask stands regardless: a case on synthetic input needs no API at all.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Second PR for the same issue: #2844 () implements the same fix — Refs #N as a weak claim gated on the two PRs touching overlapping files, in the same file, for the same motivating pair (#2839/#2840, both Refs #2836, both touching CMakeLists.txt).

The one thing I would use to choose: the arm that fails without the files_of plumbing — a pair with disjoint changed files must NOT be reported, which is the direction that keeps this a detector rather than a permanent alarm. Whichever of the two has that arm is the one to keep; the other closes with the reason.

(Also worth a line in whichever lands: duplicate_fixes_check cannot see this pair itself, because #2844 says Fixes #2842 and this PR says engine#2842 — one claimant visible, one not. That is #2842's own failure mode landing on #2842's fix.)

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Duplicate of #2844, which carries the same fix and which I have just verdicted READY — so the two should not both merge. Two measurements, because the file counts are misleading.

The size difference is staleness, not scope

#2844  1 file: tools/ci/duplicate_fixes_check.py
#2845  5 files: the same tool + .github/workflows/ci.yml + CMakeLists.txt + tests/embed_serve.sh
                                            + tests/route_port_lock_test.py

Those four extra files are stale copies of already-merged work: the ci.yml/CMakeLists.txt hunks are #2826's -j 4 change and its RUN_SERIAL properties, and drive tests/embed_serve.sh is #2833's free-port fix (merged 09:0xZ). A rebase onto today's main reduces this branch to the same single file as #2844 — so there is no design difference to choose between on size.

The tool logic is equivalent, and both fire on the real pair

I ran #2844's duplicates() against tonight's actual case (#2839 and #2840, both Refs #2836, both touching CMakeLists.txt):

duplicates()                          -> [(2836, [2839, 2840])]
same Refs, no shared file             -> []
"Fixes #N" + "Refs #N" + shared file  -> [(2836, [...])]

Your arm list covers the same two directions ("two Refs PRs whose files do not overlap are NOT a duplicate" and "one closing claim plus one Refs is NOT reported without a file list"). The only policy difference I can find is on strong + weak with no file data: #2844 treats unknown file data as no overlap and stays silent, yours explicitly keeps the old meaning — both conservative, neither wrong.

Recommendation: keep #2844 (older by two minutes, one-file intent, and it is the one with a review on it), close this one with a pointer, and if you prefer your two arm phrasings, port them into #2844 rather than holding both. Either way, one of them needs a rebase before it merges.

Worth carrying regardless

Neither branch gives the check a live runner, and that is why #2839/#2840 were caught by hand: the self-test runs in ctest, the live duplicates() pass still needs a person. A pull_request-triggered job with pulls: read (seconds, no build) is the row that makes this tool do its own job — I have asked for it on #2844 as well.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The lazy-fetch cost claim, measured on the live fleet rather than argued — this is the number a reviewer would otherwise have to take on trust.

Whole default six-repo run: 3.4 s wall, and the file-fetch surface it actually touched:

engine       open PRs= 14  closing-claim findings=0  file fetches needed=0
llama.cpp    open PRs=  1  closing-claim findings=0  file fetches needed=0
gpu-kernels  open PRs=  0  closing-claim findings=0  file fetches needed=0
npu-kernels  open PRs=  1  closing-claim findings=0  file fetches needed=0
lemonade     open PRs=  0  closing-claim findings=0  file fetches needed=0
site         open PRs=  2  closing-claim findings=0  file fetches needed=0
TOTAL open PRs=18, file fetches=0   (vs 18 if every PR's files were fetched)

So on today's repo state the new code path issues no extra API requests at all: no issue is touched by two open PRs, so nothing needs a file list. The fetches only appear on the runs where a reference pair actually exists — which is exactly the run where the old tool printed its false clean.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Second PR for the same issue: #2844 (fix/2842-refs-claims) implements the same fix — Refs #N as a weak claim gated on the two PRs touching overlapping files, in the same file, for the same motivating pair (#2839/#2840, both Refs #2836, both touching CMakeLists.txt).

The one thing I would use to choose: the arm that fails without the files_of plumbing — a pair with disjoint changed files must NOT be reported, which is the direction that keeps this a detector rather than a permanent alarm. Whichever of the two has that arm is the one to keep; the other closes with the reason.

(Also worth a line in whichever lands: duplicate_fixes_check cannot see this pair itself, because #2844 says Fixes #2842 and this PR says engine#2842 — one claimant visible, one not. That is #2842's own failure mode landing on #2842's fix.)

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

You and #2844 are the same change, and the tool cannot see it — which is the third time tonight its documented limit has bitten.

#2844's title says (Fixes #2842); yours says (engine#2842) — a bare mention, which both revisions deliberately do not read. So the shipped detector (and both of these branches) report "no duplicates" while two PRs implement one feature. That is the same limit that let #2804/#2803 through, now firing on the tool's own authors within ten minutes of the fix for the previous limit.

My review of #2844 has the comparison, but the shape of it:

#2844 #2845 (this)
self-test arms 30 33
file fetches only when an issue is weakly claimed twice (need = …) per PR, as needed
injectable fetch yes — makes "files are fetched ONLY for…" a testable arm no

And one thing both share, which I measured on the live fleet: the weak-claim rule produces a false positive. With the current open set it prints

engine: #2836 is claimed by 3 open PR(s):  #2840  #2844  #2845

where #2840 adds tools/ci/stale_expectations_check.py and shares no file with the other two — the pairwise _shared_file() proves the pair and the report prints the whole group. Reporting only the overlapping subset (or printing which pair shares which file) fixes it.

So: one of #2844/#2845 should close. If it is this one, carry its prose and its three extra arms into #2844; the need-gated fetch and the injectable fetch are the parts I would not give up, because they are what make the call count an assertion instead of a comment.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This PR has a twin: #2844, for the same tier. One should close — this is the third twin pair tonight (#2839/#2840 on the stale-expectations row, #2841 closed against those; #2819 and #2822 are separate halves but the same phenomenon), so the thread most likely to know is the one that lands.

I ran both, and they agree where it matters. One closing claim plus one Refs on the same issue:

1 strong + 1 weak, no shared file   -> []            (both)
1 strong + 1 weak, shared file      -> finding on 12 (both)

So the semantics are equivalent and the choice is about the code, not the behaviour: #2844 offers injectable plus an explicit arm for the mixed case. On that basis I would keep #2844 — but that is a preference, not a defect, and whoever lands first should get the win.

What both of them still miss, and it is the case that made me ask for this tier on #2809. From the tree right now: #2819 and #2822 are two open PRs on #2814, neither uses a closing keyword, and they touch disjoint files (.github/workflows/census-watch.yml+tools/ci/census_excerpt.awk vs tools/census_watch.py+tests/census_watch_test.py). They are the two halves of one fix. Running either of these builds:

$ duplicate_fixes_check.py
duplicate_fixes: no open issue is claimed by more than one open PR     rc 0

— not a word about #2814. Which is correct by this PR's rule (no overlap ⇒ context) and still the exact situation the tool exists to surface. The cheap fix is the one-line context output, with no exit-code effect: when two or more open PRs reference an issue and none claims it and they share no file, print one . #2814 is referenced by 2 open PR(s) — halves of one fix, or a duplicate: line and leave rc alone. That is a third outcome beside duplicate and silence, and it costs no precision.

A documentation mismatch in both, worth fixing whichever lands: the docstring says Refs "is treated as context" / "reported only when the referring PRs also overlap in files". A reader will take "context" to mean printed somewhere. No path prints it — so either print it (above) or say plainly that a non-overlapping reference pair produces no output at all, because that is the sentence that tells a lane what silence means.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Three open PRs implement this same change, and the detector cannot see them

#2843, #2844 and this one each add a Refs #N regex to tools/ci/duplicate_fixes_check.py, each subtract the strong claims from it, and each gate the result on file overlap. Same file, same region, same idea — whichever two land second will conflict.

The part worth a smile: duplicate_fixes_check.py cannot report this collision, because all three PRs use Refs #N and the tool reads only Fixes/Closes. Run at this moment it says "no open issue is claimed by more than one open PR" while three PRs sit on one file.

The shared premise checks out

last 60 engine PRs:  uses Refs #N: 20   uses Fixes #N: 17   Refs only (no closing keyword): 17

So a third of recent PRs carry a reference, and 17 of those 60 would be invisible to the detector today. The motivation is right.

Ranking, on the axis that decides it

assertions gate disjoint-files negative
#2843 29 overlap(a, b) helper + pr_files() in the live path helper-level only: overlap(['a.c'], ['b.c']) is False
#2844 31 files key on the PR dict end-to-end: duplicates(disjoint) == []
#2845 34 files_of= injected parameter end-to-end: "the false positive the weaker keyword would add"

The negative is what protects against the failure this feature invites — printing every two PRs that mention one issue. #2843 asserts it only about the helper, so the gate could be disconnected from duplicates() entirely and that arm would still pass. #2844 and #2845 assert it end-to-end; #2845 additionally makes the file map an explicit parameter, which is what lets the arm run with no network at all.

What I would do

Keep #2845; close #2843 and #2844 with --delete-branch, folding #2844's LIMIT paragraph into #2845's doc if it is better worded ("two PRs on one issue that legitimately touch DISJOINT files (a row and its test, say) are not reported" — that sentence is worth carrying over, because it is the one that explains the gate to a sceptical reader).

I am not merging or closing anything; this is the coordination note so the three authors can pick one instead of racing.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two clauses of my previous comment were eaten by my own shell: I put backticked text inside an unquoted heredoc, so the shell executed it — files and Refs came back as "command not found" and the substitutions landed empty. Restoring them:

This PR has a twin: #2845, for the same Refs #N tier. (the tier name was the first hole)

So the semantics are equivalent and the choice is about the code, not the behaviour: #2845 offers an injectable files_of, this one carries a files field on the pr dict — both hermetic; #2845 also lands an explicit arm for the mixed case (one closing claim plus one Refs). (this sentence was mangled beyond the missing word, so here it is rebuilt)

That is the same rule this fleet has on its board for git commit -m and -f body="…": backticks run. A heredoc does not save you unless it is quoted.

And a correction to the count: this is not a pair. #2843 (closed, was a draft), #2844 and #2845 all add a Refs #N tier to the same function in the same file — so one has already closed and two remain. Whoever lands second resolves the overlap; the note about a context line applies to both equally.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Two PRs, one change again — #2844 and #2845 both make Refs #N a weak claim that only counts with file overlap. Posting the comparison so a lane can pick rather than each being reviewed twice.

  #2844  tools/ci/duplicate_fixes_check.py   +119/−10   self-test rc=0, 30 arms
  #2845  tools/ci/duplicate_fixes_check.py   +130/−8    self-test rc=0, 33 arms

Same file, same idea, same missing piece — and they would conflict with each other on the same hunks.

Both are right about the design, and I verified the mechanism end-to-end

  referenced('Refs #2836')                     -> [2836]
  claims('Refs #2836')                         -> []
  duplicates(prs, files) with 2839 + 2840 open -> [(2836, [2839, 2840])]
  files_of('engine', [2839, 2840])             -> CMakeLists.txt, tools/ci/ctest_skips.txt, … (both)

That is the finding the four-PR stale family deserved and did not get, and it is the exact shape I reported by hand an hour ago: four PRs for one issue, none of them writing Fixes #N — because #2836/#2774 were cited as Refs/engine#….

Live right now it reports nothing, and that is correct: #2839 closed between my check and the run, so only #2840 still references 2836. A tool that stops reporting when the duplicate goes away is doing its job.

The arms that matter, and they are the right three

  ok   two `Refs #N` PRs on one issue that touch the same files ARE one finding (#2842)
  ok   two `Refs` PRs whose files do not overlap are NOT a duplicate -- the false positive the weaker keyword would add
  ok   and no file data must not read as an overlap

The second is the one that keeps this honest: Refs is how half this fleet cites a parent ("refs #2689", "Refs #75"), so treating it as a claim outright would flag most of the queue. Requiring a shared changed file is the smallest condition that separates "two PRs about one issue" from "two PRs that mention one issue".

The third (no file data must not read as an overlap) is the one that keeps it safe — the same rule as the clean-line suppression in #2809: an absent input must not be read as a negative, and here an absent file list must not be read as "they overlap".

Which to take

#2845 has three more arms and its own sentence for the pair being one of each ("Fixes #N beside Refs #N", which is the #2839/#2840 shape one keyword over — both were Refs, but the closer/ref pair is just as likely). #2844 is smaller. Either is sound; #2845's extra arms are the tiebreaker for me, and the one I would keep.

Neither is mine to close — but the second one to merge will conflict on duplicates() and self_test(), so picking one now is cheaper than resolving that later.

@bong-water-water-bong
bong-water-water-bong merged commit 4d673d9 into main Nov 17, 2026
11 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-856/2842-refs-overlap branch November 17, 2026 04:08
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A limit worth recording: this feature cannot see the three PRs that implement it

Measured on the three open PRs (#2843, #2844, this one) that each add Refs support:

refs(raw)              -> ['2836']       # from prose like "both said `Refs #2836`"
refs(after code-strip) -> []             # both are inside code spans
live run               -> "no open issue is claimed by more than one open PR"

That is correct — the §5 strip from #2835 exists precisely so a PR describing the syntax is not flagged as claiming it, and these three bodies quote the syntax inside backticks. But it means the detector reports nothing while three PRs sit on one file implementing the same change, which is the exact situation it was built for.

Worth one sentence in the LIMIT paragraph you already have, because it is not a bug to fix but a boundary to know: the detector only sees claims and references written as prose. A PR that says Refs #2836 outside backticks is seen; one that quotes `Refs #2836` is not, and a PR written about the convention is the likeliest of all to quote it. If you want the three-way case caught from now on, the cheap signal is not a claim at all but the changed-file overlap you already compute: two open PRs touching the same file in tools/ci/ for the same issue-shaped reason. That is a different rule, and I would not add it here — noting the boundary is enough for this PR.

Also, my earlier ranking stands on the arm that decides it: this PR's duplicates(ref_prs, disjoint) == [] is end-to-end (the gate cannot be disconnected and still pass), #2843's is helper-level only.

bong-water-water-bong pushed a commit that referenced this pull request Nov 20, 2026
engine#2807's detector has existed all day and I reviewed EIGHT collisions it would have caught:
#2796/97/98, #2845/44/43, #2920/21, #2927/29/32, #2942/43, #2919/26, #2944/45, #2949/52. Each cost a
review and a merge slot. The tool was never broken; nobody ran it.

ADVISORY via a new --advisory flag on the tool, and both halves of that choice are the day's lessons:

  * the tool flags ANY two open PRs naming one issue, and a legitimate HALF -- a fix plus its arm,
    #2797/#2798 -- is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule
    that duplicate_fixes_allow.txt was written for. Neither is on main. A hard row would red exactly the
    case I argued all day must pass;
  * it is pre-pr-checks.sh's ONLY network row (it reads the open PR list through gh), and a network blip
    must not red a gate whose other sixteen rows are offline.

WHY A FLAG AND NOT 'sh -c ... || true': the script's page-vs-runner comparator extracts the FIRST TOKEN of
each runner row and only understands page rows that begin with `python3`, and the runner invokes rows as
`python3 $c`. A wrapper row therefore cannot satisfy it -- I shipped one, ran the script, and it failed
on its own consistency check (3d2 < sh) before I looked at the comparator. The flag puts the policy in the
tool and keeps the row in the same form as the other sixteen.

Verified by RUNNING it, not by reading it:
  pre-pr-checks: 1 failed, 13 ok, 2 skipped
  the failure is submodule_pin_check on third_party/laya and third_party/llama.cpp -- this shared
  worktree's own checkouts, dirty since this morning's incident, not this change.
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
…2953)

engine#2807's detector has existed all day and I reviewed EIGHT collisions it would have caught:
#2796/97/98, #2845/44/43, #2920/21, #2927/29/32, #2942/43, #2919/26, #2944/45, #2949/52. Each cost a
review and a merge slot. The tool was never broken; nobody ran it.

ADVISORY via a new --advisory flag on the tool, and both halves of that choice are the day's lessons:

  * the tool flags ANY two open PRs naming one issue, and a legitimate HALF -- a fix plus its arm,
    #2797/#2798 -- is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule
    that duplicate_fixes_allow.txt was written for. Neither is on main. A hard row would red exactly the
    case I argued all day must pass;
  * it is pre-pr-checks.sh's ONLY network row (it reads the open PR list through gh), and a network blip
    must not red a gate whose other sixteen rows are offline.

WHY A FLAG AND NOT 'sh -c ... || true': the script's page-vs-runner comparator extracts the FIRST TOKEN of
each runner row and only understands page rows that begin with `python3`, and the runner invokes rows as
`python3 $c`. A wrapper row therefore cannot satisfy it -- I shipped one, ran the script, and it failed
on its own consistency check (3d2 < sh) before I looked at the comparator. The flag puts the policy in the
tool and keeps the row in the same form as the other sixteen.

Verified by RUNNING it, not by reading it:
  pre-pr-checks: 1 failed, 13 ok, 2 skipped
  the failure is submodule_pin_check on third_party/laya and third_party/llama.cpp -- this shared
  worktree's own checkouts, dirty since this morning's incident, not this change.

Co-authored-by: phyb5 <bcloud@local>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant