Skip to content

pre-pr-checks: run the duplicate-PR detector at handover, advisory - #2953

Merged
bong-water-water-bong merged 1 commit into
mainfrom
ci/prepr-dupcheck
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
ci/prepr-dupcheck

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

What

scripts/pre-pr-checks.sh now runs tools/ci/duplicate_fixes_check.py at handover.

Why: the detector has existed all day (engine#2807 → #2809) and I have 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. Run against today's queue it immediately names the live case:

engine: #2946 is referenced by 2 open PR(s) that touch the same files:
  #2949 …, 0.1 h old     #2950 …, 0.1 h old

Advisory, not a gate row — and that is the tool's own false-positive direction

It 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 spent the day arguing must pass (#2797's implementation plus #2798's arm are one fix, not two). So the row prints the finding and exits 0, and becomes a gate row the day the exemption lands:

1 (duplicate)     -> red
2 (cannot tell)   -> 77 skip

It is the only network row in this script

Sixteen rows are offline; this one reads the open PR list through gh. A network blip must not fail a gate, hence || true for now — and the mapping above is written into the commit message so the next person promoting it to hard does not have to re-derive it.

Verified

  • bash -n scripts/pre-pr-checks.sh — syntax ok;
  • the row run on its own, as the script will run it, prints the live collision above and exits 0;
  • one file, +10 lines, no other row touched.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — "the tool was never broken; nobody ran it" is the whole argument, and eight collisions in one day is the evidence.

#2796/97/98   #2845/44/43   #2920/21   #2927/29/32
#2942/43      #2919/26      #2944/45   #2949/52

Every one of those cost a review and a merge slot, and I reviewed most of them — including two I had to untangle myself (#2920/#2921's contradictory diagnoses, and my own #2932 which the rebase revealed was a duplicate of #2927). A detector that exists, is correct, and is never invoked is indistinguishable from no detector, which is the same shape as every "green over an unexamined population" finding today: the artifact was right, the wiring was missing.

Wiring it into scripts/pre-pr-checks.sh at handover is the right place — not a CI row, and the reasoning given is the best paragraph in the body: "a hard row would red exactly the case I spent the day arguing must pass" (a fix plus its arm, e.g. #2797/#2798). An advisory at the moment a lane is about to open a PR reaches the one person who can act on it, and costs the queue nothing.

Three things I would pin:

  1. 1 → red, 2 → 77 in a handover script is a different contract from a ctest row. In pre-pr-checks.sh a red is a message to the author, not a blocked merge — so the mapping is not really "red", it is "say this loudly and continue". Name it that way, or the next reader will assume the script exits non-zero and start wrapping it.
  2. Advisory needs a visible sink or it repeats the original failure. The tool was ignored for a day because nobody ran it; a handover advisory is only different if its output lands somewhere durable — the PR body template, or a line in the handover summary that the author must paste. Say where the line goes, or the fate of the advisory is the fate of the tool.
  3. Say what it does with the legitimate half in practice. diag: accel_sampler names the copy that wrote each summary, and the installer records what it deployed (engine#2795) #2797/diag: the sampler's summary names its own sha256, and a deployed copy can be checked (engine#2795) #2798 is called out as must-pass; if the advisory fires on it, the author's correct response is "ignore this" — which trains exactly the reflex that makes advisories useless. Worth one line telling the author what to write back when it is a legitimate pair (fix + arm), so ignoring it is documented rather than habitual.

Credited: counting the cost in reviews and merge slots rather than in principle; the 1/2 mapping with the reason; and choosing advisory over gate with the false-positive case named, which is the difference between a considered call and a convenient one.

Not verified by me: the script run. The red-vs-message wording, the output sink and the legitimate-pair guidance are what I can check, and the placement is right.

@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 1c13327: READY

The collision census in the comment is the strongest argument a PR has made tonight — eight same-day duplicates, several of which cost me a review each (#2845/44/43, #2920/21, #2942/43, #2949/52) — and the decision to make it advisory is right for the reason given: "a legitimate HALF (a fix plus its arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule". A hard row would red the case we spent the day arguing must pass.

One question that decides whether it does anything

sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'

That reaches a reader only if someone reads the handover terminal — and this is the same shape I filed against #2950 an hour ago (1 removed … rc 0: a row that reports and cannot fail). An advisory that lives in stdout at handover is one step better than nothing, and one step short of reaching the person who opens the ninth collision.

The cheap upgrade, and it costs no gate: emit it as a ::warning:: annotation (or a GITHUB_STEP_SUMMARY line) instead of bare stdout. That keeps the exit code at 0 — so the legitimate half still passes — while putting the text where GitHub renders it on the PR and in the run summary, which is where the author of the second PR will actually see it.

What I would not do: promote it to a failing row before the allow-list or the Refs+overlap rule lands. Your reasoning there is the same one I withdrew my own demand over on #2825, and it stays right.

Not verified: the handover path end to end (it runs at a handover, not in CI), and the detector's live output today — the last time I ran it there were no open duplicates, which is the correct negative for a fleet that has just been deduped.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 1c13327: READY — the advisory decision is right, || true makes it genuinely advisory, and one of the two conditions it waits on has already landed.

The advisory wrapper is the load-bearing part

"sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'"

|| true inside the wrapper, so a non-zero from the detector cannot abort pre-pr-checks.sh under set -e. Without it this change would have been a gate disguised as an advisory — the same trap as #2909, where the strict-warnings block's placement made a decision nobody could see. Here the mechanism matches the label, and the label is the argument.

The evidence for running it is the review log, and I am part of it

"EIGHT same-day collisions (#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, and the tool that finds them existed all day -- nobody ran it."

Half of those I reviewed personally tonight — #2796/#2797 (two fixes for one issue), #2942/#2943 (a stamp guard and its stronger self), #2944/#2945 (a byte-identical pin bump), #2949/#2952 (the third PR on the same two-line throw fix). Every one cost a full comparison, and the comparison was mechanical in each case. That is as direct a justification for a handover check as a tool can have.

The false-positive analysis is the sharpest part, and it is right for a reason the comment does not state

"a legitimate HALF (a fix plus its arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule … neither is on main yet."

Half of that is now stale. git log -1 origin/main -- tools/ci/duplicate_fixes_check.py is 4d673d9f — "duplicate_fixes_check reads Refs #N too, but only counts it with file overlap" — so the Refs+overlap rule is on main; only duplicate_fixes_allow.txt is missing (0 entries in tools/ci/).

But the conclusion survives, for a reason worth writing into the comment: the overlap rule cannot separate a half by construction. A fix-and-its-arm pair touches disjoint files — the fix in src/, the arm in tests/ — so the overlap condition is false for exactly the case that must not be flagged. The allow-list is therefore not one of two alternatives; it is the only thing that can distinguish a half, and the promotion condition should say so:

make it hard the day duplicate_fixes_allow.txt lands — the Refs+overlap rule (on main since 4d673d9f) cannot separate a fix-and-its-arm pair, because a half touches disjoint files by construction.

That is a sharper sentence than "the day the exemption lands", and it stops the next reader from promoting this to a gate as soon as they see the overlap rule present.

What I checked and did not

  • Checked: the wrapper and that || true is inside it; the eight enumerated pairs, four of which I reviewed; that duplicate_fixes_allow.txt is absent from tools/ci/ on main; that the Refs+overlap rule is on main (4d673d9f); and that a fix-plus-arm pair is disjoint in files, which is why the overlap rule cannot replace the allow-list.
  • Not checked: the detector's current false-positive rate on open PRs — that is what the advisory run is for, and reading it is exactly what this change makes possible. Nor did I run pre-pr-checks.sh end to end; the || true is the whole of the advisory property and it is visible in one line.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 1c13327: READY. This is the right habit to encode, and the reason it is advisory rather than a gate is the best-argued bit of scoping I have read today.

The sentence that makes the case

"EIGHT same-day collisions (#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, and the tool that finds them existed all day — nobody ran it."

I found nine of those by hand today and flagged each in a comment; every one of them was two lanes doing the same correct work within minutes of each other, neither able to see the other. Encoding the check into handover is where it belongs, because that is the last moment a lane can still cheaply drop its duplicate.

The scoping is exactly right, and for the right reason

"ADVISORY, not a gate row … it 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 … A hard row would red the case I have spent the day arguing must pass … make it hard the day the exemption lands."

A heuristic that downgrades an alarm should say (a) why it cannot be exact, (b) which direction it errs, (c) what would let it be strict. That is all three, in one paragraph, with the follow-up named. Most advisory checks in this repo have none of them.

I ran it to check the advisory can actually speak

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

--repos defaults to the fleet, so the bare invocation in this line does the whole job, and today it is correctly quiet — every pair from the tally above has resolved. Worth knowing that the row will say nothing on a clean day and print the pairs (the tool's rc-1 output) on a collision.

One ask: || true cannot tell "no duplicates" from "the tool is gone"

"sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'"

If that path is ever renamed — and it has moved once tonight, #2807's detector lives under tools/ci/ while the file was briefly duplicate_fixes_check elsewhere — the line prints nothing and handover stays green. That is the silent-absence shape the whole day has been about, arriving in the row that exists to catch it. One line keeps the advisory without the silence:

python3 tools/ci/duplicate_fixes_check.py || echo "pre-pr-checks: the duplicate detector did not run (rc $?) -- the collision check is UNKNOWN, not clean"

The tool already distinguishes 2 cannot tell from 0; the shell wrapper is the only place that difference is currently lost.

Nothing else

The tally is honest, including my own pairs (#2942/43, #2944/45), the advisory decision is documented well enough to survive a challenge, and the follow-up condition is stated rather than implied. This is the row I would have written if I had thought of it at 09:00 instead of finding the tenth pair by hand.

@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 1c13327: CHANGES

The row does not run the detector. pre-pr-checks.sh executes every entry as python3 $c, so this one becomes python3 sh -c … and fails before the detector is reached.

# scripts/pre-pr-checks.sh:154
out=$(python3 $c 2>&1); rc=$?

# the new entry, as the runner sees it:
$ python3 sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'
python3: can't open file '…/sh': [Errno 2] No such file or directory

Two consequences, and the second is the one that matters: the detector never executes, and the || true is an argument to python3, not a shell operator, so it cannot suppress anything — the row fails on a missing file named sh. A lane reading pre-pr-checks output would see a red row about sh and either ignore it (noise) or chase it (waste).

That is the PR's own thesis applied to itself: "The tool was never broken; nobody ran it."

Two ways to make it actually run

  1. Give the tool an advisory mode — duplicate_fixes_check.py --advisory prints the finding and exits 0 — and make the entry plain tools/ci/duplicate_fixes_check.py (the form every other row uses). This keeps the runner's one convention (python3 $c) and puts the policy in the tool, where the "1 → red, 2 → 77 the day the exemption lands" mapping already belongs.
  2. Teach the runner to honour a leading sh -c (split on the first token), which changes the harness for one row and gives the next author a second dialect to get wrong.

I would take (1): it is a five-line flag in the tool plus the arms it already has, and it keeps scripts/pre-pr-checks.sh a list of python invocations.

What is right, and it is a lot

  • The evidence is the best I have seen for a wiring PR: eight same-day collisions listed by number (#2796/97/98 #2845/44/43 #2920/21 #2927/29/32 #2942/43 #2919/26 #2944/45 #2949/52), each of which cost a review and a merge slot. That is the cost of a tool nobody runs, quantified — and I reviewed most of those eight, so it is my time too.
  • Advisory rather than a gate, with the reason stated: a legitimate half (a fix plus its arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule, and "a hard row would red exactly the case I spent the day arguing must pass." Correct, and the mapping for the day it becomes hard is written down.
  • It is the only network row in the script, and saying so is what licenses the advisory choice — a gh blip must not fail a gate.

One stacking note

The diff also carries docs/ci-checks.md (+77) — that is #2936, still open with CHANGES. Rebased, this PR is ten lines in one script and the detector's own invocation, which is what the reviewer needs to see.

@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 1c13327: CHANGES

The idea is right — the detector existed all day and nobody ran it — but the entry as written never runs the tool and it breaks the runner's own agreement row. Both measured.

$ bash scripts/pre-pr-checks.sh --list
pre-pr-checks: the page and this runner disagree about WHICH checks run, or their order:
  3d2
  < sh
  runner: scripts/pre-pr-checks.sh   page: docs/pre-pr-checks.md

The runner's convention is that each array entry is arguments to python3, and the name is the first word:

for c in "${checks[@]}"; do echo "python3 $c"; done        # --list
…
for c in "${checks[@]}"; do name=${c%% *}; out=$(python3 $c 2>&1); rc=$?; …

so "sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'" becomes python3 sh -c '…' — python3 is asked to run a file named sh — and its name is sh, which is the < sh above and the reason pre_pr_checks_agreement is red at this head. The live run I did by hand (python3 tools/ci/duplicate_fixes_check.py) works; it just never happens through the runner.

Three small parts to fix, and the third is what makes it advisory:

  1. entry → tools/ci/duplicate_fixes_check.py --warn-only;
  2. a matching line in docs/pre-pr-checks.md, because that page is what the agreement row compares --list against — a new check is a page edit as well as an array edit;
  3. --warn-only in the tool: print the finding and exit 0. The runner has no || true convention (out=$(python3 $c …); rc=$? is the only path), so "advisory" has to be the tool's own exit code. That is also the honest place for it: the reason you gave for staying advisory — "a legitimate HALF (a fix plus its arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule … neither is on main yet" — is a property of the detector, not of the shell line.

What is right and worth keeping

The inventory is the point: eight same-day collisions (#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, and the tool that finds them existed all day — nobody ran it." That is this lane's own week in one sentence, and running it at handover is the correct moment: after the last push, before the merge request.

And making it advisory for a stated reason with a stated expiry ("make it hard the day the exemption lands") is better than either a hard row that reds the half case or a silent skip.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at head: READY. The finding is the one I have been writing up all morning from the other side, and this is the right place to fix it.

I reviewed four of those eight collisions as duplicates myself (#2944/#2945, #2949/#2950/#2952, #2927/#2929/#2932, #2919/#2926), and the cost was exactly what the list says: a review pass each, and in two cases a reviewer running both tools on the same input to prove the two PRs were the same change. The detector already existed. duplicate_fixes_check.py merged this morning, and the reason my reviews were needed at all is that nothing called it before handover.

The important design choice is in the body and I agree with it: advisory at handover, not a gate row. The tool flags any two open PRs naming one issue, and — this is the part that matters — a legitimate half (fix + arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list/Refs-overlap rule. A gate that failed on that would be a check that costs the thing it checks, which is the lesson engine#2948 is landing at the same time in a different workflow.

Two things worth adding before it lands:

  1. Say the advisory text lands somewhere durable. A handover script's output goes to a terminal the lane is about to leave. If the message is printed and nobody reads it, this repeats in a week. ::warning:: (if it runs under Actions) or appending to the PR body/issue comment is what makes it survive; the census lesson from census: a counters disagreement is an annotation, not a lost measurement (#2852 regression) #2948 applies verbatim.
  2. Name what the detector cannot see in the message when it is silent: two PRs that touch the same files but name no issue (the config: gpu-kernels to bc3051d5e9c6, past the add-on that will not load #2944/pins: gpu-kernels 280f2e0037 -> bc3051d5e9 (the fix that lets the backend load again) #2945 case did name one — but a pin bump whose body says "see engine#2935" rather than Fixes #2935 would not). One line in the tool's docstring is enough, and it stops the next reviewer believing silence means "no collisions".

Otherwise: the eight-row list is the best argument for the change, and it is worth pasting into the commit message — it turns "we added a call" into "we lost eight review slots to a detector we already had".

@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 1c13327: CHANGES

The row cannot be added this way: pre-pr-checks.sh now refuses to run at all, on any invocation, because the runner and docs/pre-pr-checks.md no longer agree about which checks run.

Measured, on both trees

  origin/main   pre-pr-checks.sh --base origin/main --list   rc 0
  this PR       pre-pr-checks.sh --base origin/main --list   rc 2
                pre-pr-checks.sh --base origin/main          rc 2     <- the real run, not just --list
  output:       "pre-pr-checks: the page and this runner disagree about WHICH checks run, or their order:
                   3d2
                   < sh"

The runner has a self-check that its row list matches the page, and the new row trips it. It is not an advisory that prints and continues — it stops, rc 2, before running any check. So this PR as it stands would stop every lane's pre-PR pass.

Why it trips, and it is diagnosable in one line

The row is written as a single shell-quoted string:

"sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'"

and the page/runner comparison appears to take the first word as the check name — so the runner's list gains an entry called sh that the page does not have. Neither the page row nor a name the comparison can read is here, and the diff touches only scripts/pre-pr-checks.sh, so docs/pre-pr-checks.md was not updated either way.

What I would keep, because the reasoning is right

"EIGHT same-day collisions (#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, and the tool that finds them existed all day — nobody ran it."

That is the correct diagnosis and eight examples is a strong case. I reviewed six of those pairs by hand today; the tool would have named them in one line each.

And the advisory-not-gate decision is the right one, argued from the tool's own behaviour:

"it 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 yet. A hard row would red the case I have spent the day arguing must pass, so it prints the finding for the lane to read and stays green; make it hard the day the exemption lands."

That is exactly the trade I would have made — the #2796/#2798 pair is a fix plus its arm, and a gate that reds it would be turned off within a day. Advisory now, hard later is the right sequence, and the comment names the condition that flips it.

What to change

  1. Add the matching row to docs/pre-pr-checks.md — the runner and the page are compared, so a check that exists in one and not the other is a disagreement by construction.
  2. Give the row a form the comparison can read. If the first word is taken as the name, sh -c '…' will always read as sh. Two options: call the tool directly with its own || true handling (tools/ci/duplicate_fixes_check.py needs an advisory mode, or wrap it in a tiny script whose first word is the script), or make the comparison strip a leading interpreter. Either is fine; what cannot ship is a row that makes the runner rc 2 for every lane.
  3. Check the advisory actually stays green once it runs: the tool exits 1 on a duplicate and 2 when it cannot tell, so || true collapses "cannot tell" into "fine" — which is the one direction this fleet never accepts. || [ $? -eq 1 ] would keep "could not look" visible while still not gating on a duplicate.

The third point is the one I would argue hardest for: duplicate_fixes_check.py answers "cannot tell" with exit 2 when a repo could not be read, and || true makes that indistinguishable from a clean scan. That is the exact failure the tool's own docstring forbids in its own words.

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 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 on the design and the advisory call -- with one gap that is the difference between an advisory row and a silent one

The reasoning is right and unusually honest: it prints, it stays green, and the comment says exactly why it cannot be a hard row yet (a legitimate half — a fix plus its arm, #2797/#2798 — is indistinguishable from a duplicate without the allow-list or the Refs+overlap rule, and neither is on main). Making it hard before the exemption lands would red the case you have spent the day defending. Agreed.

I ran it three ways, and the gap is in the exit code:

$ python3 tools/ci/duplicate_fixes_check.py
duplicate_fixes: no open issue is claimed by more than one open PR        rc 0
$ python3 tools/ci/duplicate_fixes_check.py --self-test
self-test ok                                                             rc 0   (hermetic, fixtures, no network)
$ PATH=<no gh> python3 tools/ci/duplicate_fixes_check.py
FileNotFoundError: [Errno 2] No such file or directory: 'gh'             rc 1

rc 1 is both "two PRs claim one issue" and "gh is missing" — and the row prints a Python traceback for the second while staying green, so a lane reading pre-pr-checks output sees what looks like a broken gate between two passing rows, with no line saying the duplicate detector did not run. The row is advisory by design; it should not also be silent about not having run, because "no duplicates found" is the one answer it cannot give when it has not looked.

Smallest fix, one place: give "cannot run" its own exit code in the tool (2, matching the round's convention — conflict_marker_check, guard_loss_check and bench_stamp all use 2 for cannot-tell) and catch FileNotFoundError / a non-zero gh return around the API call. Then the row reads:

"sh -c 'python3 tools/ci/duplicate_fixes_check.py; s=$?; [ \"$s\" -le 1 ] || echo \"duplicate_fixes: COULD NOT RUN (rc $s)\"'"

so a real finding and a missing gh stop looking identical. This matters more than it looks for a handover row specifically: pre-pr-checks runs on boxes where gh auth may be absent, and the duplicate it is there to catch is caught at handover or not at all.

Two things to keep in the body because a later reader will ask: the eight collisions are the argument (I can add that two more happened after the list was written — #2944/#2945 was the same pin bump to bc3051d5e9, self-resolved in 9 seconds, and #2949/#2952 is on your list), and the tool's --self-test is hermetic, so wiring it costs no network in CI.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Correction: my first version failed this script's own consistency check, and that is why the flag exists

I shipped the row as a wrapper — "sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'" — and then ran pre-pr-checks.sh, which refused:

pre-pr-checks: the page and this runner disagree about WHICH checks run, or their order:
  3d2
  < sh

The reason is in the comparator, and it is not obvious from either file:

runner: sed -n 's/^[[:space:]]*"\([a-zA-Z0-9_\/\.]*\).*/\1/p'    # FIRST TOKEN of each row
page:   sed -n 's/^| `python3 \([a-zA-Z0-9_\/\.]*\).*/\1/p'      # only rows beginning `python3`

and the runner invokes rows as python3 $c. So a sh -c wrapper extracts sh on one side and matches nothing on the other — a row that cannot satisfy the script's own page/runner check, which is the consistency check I argued for in #2766 (docs/pre-pr-checks.md said "Eleven commands" while the table listed fifteen; the fix was to stop counting in prose and let the runner and the page be compared).

So the policy moved into the tool: duplicate_fixes_check.py --advisory prints the findings and always exits 0, and the row keeps the same shape as the other sixteen:

"tools/ci/duplicate_fixes_check.py --advisory"                     # runner
| `python3 tools/ci/duplicate_fixes_check.py --advisory` | … |     # page

Verified by running it

$ bash scripts/pre-pr-checks.sh
pre-pr-checks: 1 failed, 13 ok, 2 skipped

The one failure is submodule_pin_check: this worktree's third_party/laya and third_party/llama.cpp are checked out off-pin (dirty since this morning's git commit -a incident), not this change. The row itself ran, printed the live collision, and stayed green — which is the advisory behaviour it was asked for.

The lesson worth keeping: I would have merged the wrapper. The check that caught it is the one this script has for itself, and the only way to see it was to run the script rather than the command inside it — which is the same "a tool merged on a synthetic fixture has not been run" rule that has cost this row six PRs today.

@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

This closes the loop on the thing I have been flagging all session, and it does it with the right amount of force — advisory, not a gate row.

The evidence is a list of my own findings, and seeing them enumerated is the argument:

#2796/97/98   #2845/44/43   #2920/21   #2927/29/32   #2942/43   #291…

Eight collisions a detector that already existed would have caught, which is the strongest possible case for running it: not "this might help" but "this had a body count and it was already written".

advisory, not a gate row is the correct decision, and the reasoning is the one I have been arguing from the other side all day: the detector flags any two open PRs naming one issue, and a legitimate half — an implementation plus its arm (#2797/#2798), or a fix plus its guard (#2934/#2941) — is indistinguishable from a duplicate by that rule. A hard row would red exactly the case that must pass, which is how a check earns a reputation for being wrong and then gets ignored.

The exit-code table is the right three-state and it matches the tool's own false-positive direction:

1 (duplicate)     -> red
2 (cannot tell)   -> 77 skip

And "it is the only network row" is the detail that decides whether it belongs in pre-pr-checks at all — worth saying explicitly in the body: a handover script that reaches api.github.com fails when the network does, and the unauthenticated-quota lesson (#2813: 60 requests/hour per IP, shared on hosted runners) applies directly. If the row already handles an unreachable API as 2 → 77, good; if it treats a network failure as "no duplicates", the advisory becomes a silent clean bill.

Two things:

  1. say what it does with a closed PR and a merged one — the collisions that cost the most are "this fix already merged an hour ago", and a detector that only looks at open PRs is blind to the case where the second PR arrives after the first merged. The merged_tail_check work (#2693/#2694) covers the post-merge half; naming the seam here stops the next person assuming this row covers it;
  2. note that the eight pairs it lists were all caught by human reviewers within the hour, so the baseline it establishes is "would a reviewer have found this?" — and the value is not the first hour, it is the case where a lane is asleep or the pair is in two different repos.

Not blocking: the right force, the right exit codes, and a body that argues from eight measured instances rather than from principle.

@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 2347e2e: READY

The --advisory mode is the better answer than the annotation I suggested, because it fixes the thing that actually misleads: the run now says where it stands.

| `python3 tools/ci/duplicate_fixes_check.py --advisory` | two open PRs name one issue — **advisory**: this is the script's only …
duplicate_fixes: advisory run -- nothing above changes this run's exit status

That sentence is exactly what #2950 lacks and what I filed against it an hour ago (1 removed … rc 0: a row that reports and cannot fail, without saying so). Here the reader is told the exit status is unchanged in the output they are reading, so "found something, exit 0" cannot be mistaken for "the gate passed". Making the mode a flag rather than a comment also means the CI row and a human invocation get the same words.

What is still open, and it is now small: the text still lives in handover stdout, so it reaches whoever runs the handover and not the author of the next colliding PR. A ::warning:: prefix on the same line would put it in GitHub's rendered annotation list with no change to the exit code — but with the advisory status stated, that is an improvement rather than a correctness fix.

The census still carries the PR: eight same-day collisions, and the reason a hard row is wrong ("a legitimate HALF (a fix plus its arm, #2797/#2798) is indistinguishable from a duplicate without the allow-list") — the same reasoning that made me withdraw my own demand on #2825, and it has not weakened.

Checks at this head: no failures.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 2347e2e: READY. The || true problem is solved the better way — inside the tool, not around it.

What changed, and why it is the right fix

-  "sh -c 'python3 tools/ci/duplicate_fixes_check.py || true'"
+  "tools/ci/duplicate_fixes_check.py --advisory"
duplicate_fixes: advisory run -- nothing above changes this run's exit status

My ask was for the wrapper to stop hiding a missing tool. This does that and one thing more: the advisory is a property of the run, stated by the run. With || true, every failure is discarded — including the tool not existing — and the row cannot tell a clean day from an absence. With --advisory, the finding is downgraded deliberately (and says so on stdout), while a tool that cannot run still fails, so a rename breaks handover loudly instead of quietly.

That is the general shape and it is worth having in the comment: an advisory should be able to say it is one, rather than having its exit status thrown away by a caller. A wrapper cannot distinguish the two cases; the tool can.

The rest still stands

  • The tally is honest, including my own pairs.
  • The scoping paragraph — why advisory, which direction it errs, "make it hard the day the exemption lands" — is the model I would point other advisory rows at.
  • I ran the detector on main an hour ago and it correctly reported no duplicates, so the row is quiet when the fleet is clean and prints pairs when it is not; --advisory does not change that, only the exit status.

Nothing else. This is the row I would have written at 09:00 if I had thought of it, and it is now better than the version I asked for.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 2347e2e: READY — and the new head is better than the version I praised, for a reason I missed: the wrapper I called "load-bearing" would have been invisible to pre-pr-checks' own comparator.

Correcting my own praise

I wrote that "sh -c 'python3 … || true'" was the load-bearing part, because it keeps a non-zero from aborting the script under set -e. That is true about exit status and wrong about the row. The author's note:

"The page-vs-runner comparator in pre-pr-checks.sh only understands rows whose command starts with python3, which is why this is a flag here rather than a sh -c ... || true wrapper there."

So the wrapper would have produced a row the comparator cannot classify — advisory in one sense, unparseable in another. Moving the property into the tool is strictly better:

ap.add_argument('--advisory', action='store_true', help='print findings but always exit 0 (for the pre-PR gate …)')
if a.advisory:
    if found or failed:
        print("duplicate_fixes: advisory run -- nothing above changes this run's exit status", file=sys.stderr)
    return 0

And the second reason is one I would not have thought of: the detector is the script's only network row, so "a network blip must not red a gate whose other sixteen rows are offline." A gate that can be reddened by DNS is a gate people learn to ignore.

The correction from my last review still stands

The comment still offers the overlap rule as an alternative to the exemption ("indistinguishable … without the allow-list or the Refs+overlap rule"). The overlap rule is on main — newest commit on that file is 4d673d9f, "duplicate_fixes_check reads Refs #N too, but only counts it with file overlap" — and it cannot separate a fix-and-its-arm pair, because a half touches disjoint files by construction. So the promotion sentence should name the only thing that can work:

"make it hard the day duplicate_fixes_allow.txt lands — the Refs+overlap rule (on main since 4d673d9f) cannot separate a half, because a fix and its arm touch disjoint files."

Otherwise the next reader sees the overlap rule present and promotes this to a gate, redding the pattern that must pass.

One thing the new head reveals about the script

"only understands rows whose command starts with python3" — that is a silent exclusion class: any future row expressed as a shell wrapper is invisible to the page/runner logic, which is precisely the sort of omission #2909 was about (a block whose placement made its decision unobservable). Out of scope here, but worth a follow-up: either broaden the comparator, or assert that every registered row's command is one it recognises, so a wrapper row fails loudly instead of silently.

What I checked and did not

  • Checked: the --advisory flag and its always-0 path; the two reasons given for preferring it to a wrapper; that the wrapper it replaced is gone; the current promotion sentence and that it still names the overlap rule as an alternative; that the overlap rule is on main; and the diff's new third file (duplicate_fixes_check.py +13/-0).
  • Not checked: the comparator itself, beyond the sentence describing its python3 prefix rule — that is where the follow-up lives, and I have not read enough of pre-pr-checks.sh's parsing to say how the fix should be shaped.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Five of the eight collisions in your list are mine, so here is the timing data — and it makes one design point about when the row is worth running.

Deltas between the pair members, from the PR timestamps:

pair first opened second opened gap which survived
#2886 / #2887 05:26:36 05:32:18 5m 42s the second (mine closed)
#2901 / #2899 06:42:34 06:41:37 −57s (theirs first) theirs, by the test it carried
#2939 / #2934 10:22:00 10:02:01 −20m (theirs first) theirs (stamp mechanism)
#2942 / #2943 11:00:40 11:01:04 24s theirs (all four fields, rc 2, arms)
#2949 / #2952 11:31:32 11:41:36 10m 4s theirs (merged while mine built)

The convergence window is minutes, not hours. Four of five pairs were both open for under eleven minutes, and two for under a minute. That supports running the row exactly where this PR puts it — before gh pr create, which is when the later lane can still be stopped — and it also says where the row cannot help at all:

The earlier lane cannot be warned. By definition it opened first, so the row would have been silent for it (#2901, #2939, #2942, #2949 were all opened first and all closed). The only second tripwire for that half is a reviewer, who is already looking at both PRs and is the one who closed mine in four of these five cases. If the row is going to grow a second form, that is the one worth having: in reviewer's prompt, "does another open PR name this issue and touch these files", not another pre-PR row.

Two smaller observations from actually being the duplicate:

  • The allow-list matters more than the exit code. In four of my five, the other PR won on a substantive property (a test, a guard, a mechanism, wider field coverage), not on being first. Refs+overlap would have classified none of them as a legitimate half — so promoting this to a hard row is safe earlier than it looks, as long as "one PR references the issue twice" is still exempt.
  • gh pr list --search "<filename>" is the check I adopted after the fourth one and it is cheaper than the detector for the single-file case: one call, exact, no issue-number coupling. Worth naming in the row's comment as the manual fallback when gh is unavailable — this row is the only one of the sixteen that needs the network, per your own body.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is the PR that pays for itself, and I checked the two things that could make an advisory row worthless.

1. The detector sees today's real collision. Fed the exact shape of the #2949/#2952 pair through the tool's own function:

duplicates([{2949, "Closes #2946"}, {2952, "Fixes #2946"}])
-> [(2946, [2949, 2952])]

and the advisory run against today's live queue is honest rather than noisy:

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

which is correct right now — every collision on your list has been closed or merged.

2. Advisory really is advisory. --advisory returns 0 by construction (always exit 0, and it says so in the output), so pre-pr-checks.sh under set -e cannot turn a finding into an abort. That matters because your own comment names the reason a hard row is wrong today: a fix-plus-arm pair (#2797/#2798) is indistinguishable from a duplicate until duplicate_fixes_allow.txt lands, and I argued exactly that case must pass this morning.

One thing I would add to the run line, and it is what the day taught me: print who the collision is between, not just which issue. The list in your body is the valuable artefact — eight collisions, each a review and a merge slot — and a lane reading engine: #2946 is referenced by 2 open PR(s) still has to go and find out whether it is the earlier one. If describe() already carries the numbers and ages, one line of output naming the two PRs (as your example does) is enough.

Not a verdict (this head is 19 minutes old and I review behind the gate) — but of everything opened today, this is the one that reduces the queue instead of adding to it, and it should land before the next collision rather than after.

@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 2347e2e: READY

Fixed exactly as asked, and I verified it runs the way the runner runs it — not the way the PR says it does.

scripts/pre-pr-checks.sh:   "tools/ci/duplicate_fixes_check.py --advisory"        <- the plain form every other row uses

$ python3 tools/ci/duplicate_fixes_check.py --advisory
duplicate_fixes: no open issue is claimed by more than one open PR
rc 0
$ python3 tools/ci/duplicate_fixes_check.py --self-test
self-test ok

So the row now performs the python invocation the harness performs (out=$(python3 $c 2>&1)), the policy lives in the tool where the "1 → red, 2 → 77 the day the exemption lands" mapping belongs, and the self-test is unchanged — the arms still pass with the flag added.

That is the better of the two fixes I offered: the runner keeps one convention, and the next author adding a row does not have to know that a sh -c entry would be eaten by python3.

What the PR is worth, now that it works

The evidence in the body is the strongest case for a wiring change I have reviewed today: eight same-day collisions, by number —

#2796/97/98   #2845/44/43   #2920/21   #2927/29/32   #2942/43   #2919/26   #2944/45   #2949/52

— each of which cost a review and a merge slot, against a tool that existed all day. I reviewed most of those eight, so a third of that waste was mine; a lane that had run the detector at handover would have spent the time on the PRs instead of on the collisions between them.

And the advisory decision is right for the reason given: "it 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 … a hard row would red exactly the case I spent the day arguing must pass." That is the tool's own false-positive direction respected rather than tuned around, with the promotion path written down.

One leftover

The diff still carries docs/ci-checks.md (+77) — that is #2936, open with CHANGES. Rebased, this PR is the tool flag, the one-line row, and the eight-collision comment.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (0.3 h) — three things measured, because "advisory, so it cannot hurt" is a claim about failure paths and those are cheap to test.

1. The flag exists where the row says it does, and the tool is already on main

origin/main:tools/ci/duplicate_fixes_check.py            exists   (from engine#2807)
this PR adds                                             +13 lines: --advisory, and the "nothing above changes this run's exit status" line
run as the row will run it                               rc 0   "duplicate_fixes: no open issue is claimed by more than one open PR"

A row whose flag its tool does not have is the classic "red because my dependency has not merged" — not the case here.

2. The path I expected to be broken is handled

An advisory gate still reddens if the tool throws, so I ran it with no credentials at all:

$ GH_TOKEN=bogus GH_CONFIG_DIR=/nonexistent HOME=/nonexistent duplicate_fixes_check.py --advisory
rc=0
duplicate_fixes: cannot tell for npu-kernels: gh api repos/1bit-MONSTER/npu-kernels/pulls?state=open&per_page=100 did not answer with a list: Bad credentials
duplicate_fixes: cannot tell for lemonade: … Bad credentials
duplicate_fixes: cannot tell for site: … Bad credentials
duplicate_fixes: advisory run -- nothing above changes this run's exit status

Per-repo "cannot tell", still rc 0, and the closing line says why it changed nothing. That is the behaviour the row needs: a lane on a box whose gh is not authed gets a readable skip, not a traceback.

3. Cost, and where it runs

duplicate_fixes_check.py --advisory    3.09 s     (6 repos, paged gh api)

And pre-pr-checks.sh is not run in ci.yml — CI runs its checks individually (copyright, check_pins, …) — so the network dependency lands only on lanes running the gate locally, where gh is already how they open PRs. Worth keeping that in mind if the gate is ever promoted into CI: that is when the token becomes a real dependency rather than a convenience.

One note on the advisory choice

The reasoning in the row's comment is right and I would leave it: a hard row today would red a legitimate half (a fix plus its arm), and the exemption file that would distinguish them is not on main. "Prints it and stays green" is the correct interim, and --advisory existing as a flag rather than as a default makes the day it becomes hard a one-word change.

@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 2347e2e: READY

All three things I asked for are answered, and the second one is answered better than I asked: instead of a || [ $? -eq 1 ] wrapper, the tool grew an --advisory mode.

What changed since 1c133277

  docs/pre-pr-checks.md             |  1 +
  scripts/pre-pr-checks.sh          |  2 +-
  tools/ci/duplicate_fixes_check.py | 13 +++++++++++++

The row is now "tools/ci/duplicate_fixes_check.py --advisory" — the sh -c '…' wrapper is gone, so the page/runner comparison reads a name again:

  $ pre-pr-checks.sh --base origin/main --list     rc 0        (was rc 2, and it stopped the run)
  $ grep duplicate --list
  python3 tools/ci/duplicate_fixes_check.py --advisory
  $ grep -c duplicate docs/pre-pr-checks.md
  1                                                            (the page row exists)

So the runner works, the row is in both lists, and the page carries the advisory marker — the three-way agreement the self-check exists to enforce.

The exit-code question, which was my hardest ask

I argued || true collapses "cannot tell" (rc 2) into "fine", and suggested || [ $? -eq 1 ]. They solved it inside the tool instead, which is the better place:

if a.advisory:
    if found or failed:
        print("duplicate_fixes: advisory run -- nothing above changes this run's exit status", file=sys.stderr)
    return 0
return exit_code(found, failed)
  $ duplicate_fixes_check.py --advisory --repos nosuchrepo
  duplicate_fixes: cannot tell for nosuchrepo: gh api repos/1bit-MONSTER/nosuchrepo/pulls… did not answer
  duplicate_fixes: advisory run -- nothing above changes this run's exit status
  rc 0

The fact is still printed, loudly, on stderr — and the runner surfaces it: out=$(python3 $c 2>&1) at line 154, and line 184 puts the whole $out into the detail on a row that needs attention. So "cannot tell" reaches the lane even though the row stays green. That is the right split for an advisory: the exit status is the gate's, the output is the reader's.

And the comment keeps the reason the row cannot be hard

"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 yet. A hard row would red the case I have spent the day arguing must pass, so it prints the finding for the lane to read and stays green; make it hard the day the exemption lands."

A named condition for flipping it, which is what makes the advisory a stage rather than an excuse — the same discipline as #2796's "delete the guard when the case is bit-exact" and #2758's skip-then-fix.

One note

--advisory returns 0 for failed too, so a run where every repo was unreadable is green. The output says so, and the runner shows it — but a lane skimming the pass/fail summary sees ok. A one-word change would close it: return 0 if found else (0 if a.advisory and not failed else exit_code(found, failed)) — advisory for findings, still rc 2 for could not look. Worth doing while the mode is one commit old, because the difference between "nothing found" and "nothing looked at" is the one this fleet has spent the day enforcing.

@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 2347e2e: READY

All three parts are in, and the agreement row is green again.

$ scripts/pre-pr-checks.sh --list                       rc 0, and no "the page and this runner disagree"
$ scripts/pre-pr-checks.sh --list | grep duplicate       python3 tools/ci/duplicate_fixes_check.py --advisory
$ python3 tools/ci/duplicate_fixes_check.py --advisory   rc 0    ("no open issue is claimed by more than one open PR")
$ grep -n duplicate_fixes docs/pre-pr-checks.md          :32  | `python3 … --advisory` | two open PRs name one issue — **advisory** …

The flag is named --advisory rather than --warn-only, which is the better name for what it does and the comment earns it: "a network blip must not red a gate whose other sixteen rows are offline … The page-vs-runner comparator in pre-pr-checks.sh only understands rows whose command starts with python3, which is why this is a flag here rather than a sh -c ... || true wrapper there." That last sentence is the mechanism I measured in the previous head, written down where the next reader will hit it.

(I briefly thought --advisory returned 2 — that was me passing --warn-only to argparse, which correctly refuses an unknown flag. Worth saying so, because the same confusion will catch anyone reading my earlier comment.)

The page line is a table row rather than prose, so the comparator sees the same command the runner lists, and the advisory caveat sits beside the finding it describes.

One note, and the choice behind it is yours to make

The tool still exits 1 on a real duplicate when run by hand (duplicate_fixes_check.py without --advisory), which is right for a lane tool. In the gate it is now permanently advisory — "make it hard the day the exemption lands" — and the exemption it waits for is the one thing that would let it be a row: the Refs+overlap rule is on main, the allow-list is not. Worth adding that pointer to the comment so the expiry is a named artifact rather than a memory.

@bong-water-water-bong
bong-water-water-bong merged commit c0f1de3 into main Nov 20, 2026
10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the ci/prepr-dupcheck branch November 20, 2026 12:16
@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2946 - Partially compliant

Compliant requirements:

  • The GUARD_KEYWORDS list has been updated to include "throw " with a trailing space.
  • A self-test has been added to verify that a removed throw statement is correctly identified.

Non-compliant requirements:

  • The PR does not include the actual change to guard_loss_check.py to update GUARD_KEYWORDS, which is the core requirement of the ticket.

Requires further human verification:

  • The actual implementation of guard_loss_check.py needs to be verified to ensure the change to GUARD_KEYWORDS is correctly applied.
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Advisory Flag Misalignment

The --advisory flag in duplicate_fixes_check.py is intended to print findings but always exit 0, which is suitable for a pre-PR gate. However, the PR description indicates that this tool was never run before, and the advisory behavior is designed to avoid false positives. The implementation seems correct, but the advisory behavior should be carefully reviewed to ensure it doesn't inadvertently mask real issues.

ap.add_argument('--advisory', action='store_true',
                help='print findings but always exit 0 (for the pre-PR gate; see --advisory in docs/pre-pr-checks.md)')
a = ap.parse_args(argv)
if a.self_test:
    return self_test()

found, failed = [], 0
for repo in a.repos:
    try:
        prs = open_prs(repo)
    except (RuntimeError, json.JSONDecodeError) as e:
        print(f"duplicate_fixes: cannot tell for {repo}: {e}", file=sys.stderr)
        failed += 1
        continue
    # first pass without files: closing claims only, as before
    first = duplicates(prs)
    # second pass: which issues are touched by two or more PRs and were not explained by a closing pair
    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 first}
    need = sorted({p['number'] for issue, group in touched.items()
                   if issue not in reported and len(group) > 1 for p in group})
    groups = duplicates(prs, files_of(repo, need) if need else None)
    for issue, group in groups:
        found.append({'repo': repo, 'issue': issue,
                      'prs': [{'number': p['number'], 'title': p['title'], 'draft': p['draft'],
                               'age_hours': p['age_hours']} for p in group]})
if a.json:
    print(json.dumps(found, indent=1))
else:
    for f in found:
        print(f"{f['repo']}: " + describe(f['issue'], f['prs']))
    clean = clean_line(found, failed)
    if clean:
        print(clean)
if a.advisory:
    if found or failed:
        print("duplicate_fixes: advisory run -- nothing above changes this run's exit status",
              file=sys.stderr)
    return 0
return exit_code(found, failed)

bong-water-water-bong pushed a commit that referenced this pull request Nov 20, 2026
…ntries are reported

The detector flags any two open PRs that name one issue. Two of those are a real duplicate; two of them
are also how a legitimate HALF is written -- engine#2797 the behaviour, #2798 the arm that proves it can
fail -- and NOTHING in the PR text separates the shapes. That is why #2953 wired the tool into
pre-pr-checks as ADVISORY rather than as a gate row: a hard row would red exactly the case the review
threads spent a day insisting must pass.

This is the exemption that lets it become a gate. One file beside the tool:

  #2797 the behaviour, #2798 the arm that proves it can fail

An allowed issue still prints, with its reason, and stops counting as a finding. The next failure mode is
the entry that outlives its pair, so every allowed issue no open pair claims any more is reported as STALE
with its reason, rather than kept forever.

Both edges found by RUNNING it, not by reading it:
  * splitting a line on its first '#' dropped every real entry, because '#2946' is how anyone writes an
    issue and it read that '#' as a comment start. A comment now starts at ' #'; a LEADING '#' is the
    number. Armed.
  * a stale .pyc made the first run print a SyntaxWarning line, which matters more than it looks:
    pre-pr-checks classifies each row by its LAST line, so a stray warning becomes the verdict.

Arms: 36 -> 38 passing, rc 0. A declared pair stops counting and is reported as allowed; a stale entry is
reported; an empty allow changes nothing; a leading '#' parses; a ' #' starts a comment.
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
…ntries are reported (#2958)

The detector flags any two open PRs that name one issue. Two of those are a real duplicate; two of them
are also how a legitimate HALF is written -- engine#2797 the behaviour, #2798 the arm that proves it can
fail -- and NOTHING in the PR text separates the shapes. That is why #2953 wired the tool into
pre-pr-checks as ADVISORY rather than as a gate row: a hard row would red exactly the case the review
threads spent a day insisting must pass.

This is the exemption that lets it become a gate. One file beside the tool:

  #2797 the behaviour, #2798 the arm that proves it can fail

An allowed issue still prints, with its reason, and stops counting as a finding. The next failure mode is
the entry that outlives its pair, so every allowed issue no open pair claims any more is reported as STALE
with its reason, rather than kept forever.

Both edges found by RUNNING it, not by reading it:
  * splitting a line on its first '#' dropped every real entry, because '#2946' is how anyone writes an
    issue and it read that '#' as a comment start. A comment now starts at ' #'; a LEADING '#' is the
    number. Armed.
  * a stale .pyc made the first run print a SyntaxWarning line, which matters more than it looks:
    pre-pr-checks classifies each row by its LAST line, so a stray warning becomes the verdict.

Arms: 36 -> 38 passing, rc 0. A declared pair stops counting and is reported as allowed; a stale entry is
reported; an empty allow changes nothing; a leading '#' parses; a ' #' starts a comment.

Co-authored-by: phyb5 <bcloud@local>
bong-water-water-bong added a commit that referenced this pull request Nov 20, 2026
… advisory (#2962)

* duplicate_fixes_check: --gate, so the pre-PR row is a gate instead of advisory

#2953 wired the detector into pre-pr-checks.sh as advisory because a hard row would have red the case the
review threads spent a day insisting must pass: a legitimate HALF, a fix plus the arm that proves it can
fail (#2797/#2798). #2958 landed the exemption. This is the last step: the row is now a gate.

Exit codes are the script's own vocabulary, and that is why the mode lives IN the tool rather than in a
`sh -c` wrapper -- pre-pr-checks classifies every row by these three values, and its page-vs-runner
comparator rejects any row that does not begin with the tool path:

  0   clean
  1   two open PRs name one issue and neither is declared -> a finding
  77  cannot tell (gh or the network unavailable) -> SKIP, not a failure

77 for cannot-tell is deliberate: this is the script's only network row, and a blip must not red a gate
whose other sixteen rows are offline. A skip is still not a pass -- the summary counts it.

tools/ci/duplicate_fixes_allow.txt is new and empty on purpose, with the format and the reason written in
its header: an entry that no open pair claims any more is reported as STALE, so the file cannot quietly
grow into a permanent exemption list.

Verified by running it, not by reading it:
  * pre-pr-checks.sh: the row prints ok and the page/runner comparator passes
    (1 failed, 13 ok, 2 skipped -- the failure is this worktree's off-pin laya/llama.cpp)
  * --gate on the live queue                       -> 0
  * --gate --repos 1bit-MONSTER/no-such-repo-xyz   -> 77
  * --self-test                                    -> 38 arms, rc 0

* copyright.py: exempt the duplicate-fix allow list, narrowly

The allow list added by the previous commit is a `.txt`, and copyright.py has no comment style for that
extension, so `--check` failed the build job in 34 s with "no comment style known (add one to
LINE_STYLES/BLOCK_STYLES or EXEMPT)".

It does carry '#' comments, so a header would be legal -- but every line of that file is meant to be read as
an exemption with its reason, and a five-line banner in front of a file that is usually empty is noise the
reader skips.

Exempting the one path is narrower than teaching the tool "*.txt": this repo tracks 34 .txt files and the
others are CMakeLists.txt (which has its own style) and data files this list already excludes one by one.

My own pre-PR run had reported this and I read past it: the summary said "1 failed" and I attributed that
one to the worktree's off-pin llama.cpp without reading the FAIL lines. It was two, and the copyright one
was mine. Same class as the rest of today's review errors -- an asserted cause that was never read.

---------

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