Skip to content

duplicate_fixes_check: accept owner/name, and refuse a repo it does not know - #2971

Merged
bong-water-water-bong merged 1 commit into
mainfrom
dupfix/repo-name
Nov 20, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
dupfix/repo-name

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

What

Two defects found by running the --gate row I merged an hour ago (#2962), not by reading it.

1. The gate skipped for ever on the natural spelling

--repos 1bit-MONSTER/engine is how a person names a repository on a command line. open_prs builds repos/{OWNER}/{repo}/pulls, so it asked GitHub for 1bit-MONSTER/1bit-MONSTER/engine, got a 404, and reported "cannot tell" — which --gate turns into a skip (77).

So a spelling disabled the gate permanently and said nothing: the "a scan that cannot look is not a scan that found nothing" class, inside the new gate's own argument parsing. normalise_repo() accepts both spellings; a name it does not know exits 2 with the name in the message instead of becoming a skip.

2. A DeprecationWarning landed in the output

re.split(r"\s+#", line, 1) passes maxsplit positionally (deprecated in 3.13). pre-pr-checks.sh classifies each row by its last line — the same reason a stale .pyc mattered an hour ago.

$ python3 tools/ci/duplicate_fixes_check.py --self-test   -> 41 arms, rc 0   (was 38)

Three arms: a bare name is accepted, owner/name normalises instead of 404ing, and an unknown name is refused rather than turned into a skip.

Why this is a second PR — and how the first one lost them

They were committed in #2962 in an empty commit: git show --stat prints the header and no files. The merge therefore carried neither, and main today still 404s on owner/name. git log looked perfect; the commit had nothing in it.

The one-line check that catches it, now part of my routine: a commit whose --stat is empty did not happen, however clean its log line looks. I had verified the working tree (41 arms passing) and never verified the commit.

Verified

$ python3 tools/ci/duplicate_fixes_check.py --gate          # the fleet, all six repos
engine: #2961 is referenced by 2 open PR(s) that touch the same files ...   (rc 1, before the pair closed)
$ python3 tools/ci/duplicate_fixes_check.py --gate --repos engin
duplicate_fixes: --repos 'engin' is not a repository this tool reads; use one of engine, …   (rc 2, not a skip)
$ python3 tools/copyright.py --check                        # rc 0

…ot know

Both found by running the --gate row on the live queue, not by reading it.

1. `--repos 1bit-MONSTER/engine` -- the natural way to name a repo on a command line -- became
   repos/1bit-MONSTER/1bit-MONSTER/engine, got a 404, and was reported as "cannot tell". In --gate mode cannot-tell
   is a SKIP, so the wrong spelling disabled this gate permanently and said nothing: the "a scan that cannot look
   is not a scan that found nothing" class, sitting in the new gate's own argument parsing. normalise_repo() now
   accepts both spellings, and a name that is neither exits 2 with the name in the message.

2. `re.split(r"\s+#", line, 1)` passed maxsplit positionally, deprecated in 3.13, printing a DeprecationWarning
   line. pre-pr-checks.sh classifies each row by its LAST line, so a warning in the wrong position becomes the
   verdict -- the same reason a stale .pyc mattered an hour ago.

3 arms (38 -> 41, rc 0): a bare name is accepted, owner/name normalises instead of 404ing, and an unknown name is
refused rather than turned into a skip.

Why these are separate from #2962, which merged: they were committed there in an EMPTY commit -- `git show --stat`
prints the header and no files -- so the merge carried neither, and main today still 404s on owner/name. The
verification that would have caught it is one line, and is now part of the routine: a commit whose stat is empty
did not happen, however clean its `git log` line looks.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Measured on main, end to end — the defect is worse than "a wrong message"

=== main (origin/main copy of the tool), the natural spelling ===
$ python3 main_copy.py --gate --repos 1bit-MONSTER/engine
duplicate_fixes: cannot tell for 1bit-MONSTER/engine:
  gh api repos/1bit-MONSTER/1bit-MONSTER/engine/pulls …
rc=77          # 77 = SKIP

=== this branch, same command, same queue ===
$ python3 tools/ci/duplicate_fixes_check.py --gate --repos 1bit-MONSTER/engine
rc=0           # 0 = it looked, and found nothing

That is the whole reason this is not cosmetic. On main the gate returns the skip code, which pre-pr-checks.sh counts as a skip and never as a failure — so an operator who types the natural repository name gets a gate that stops gating and says nothing, permanently, on every run. The URL in the message is the proof of the mechanism: repos/1bit-MONSTER/1bit-MONSTER/engine.

This is the same class as #2965's wrong-device predicate one layer down: a check that cannot look, reported as a check that found nothing. The cost of getting it wrong in the safe direction is one noisy error message; the cost of getting it wrong in this direction is a gate the fleet believes is running.

Two notes for the record:

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — and the second half is the most useful sentence in it: "a commit whose --stat is empty did not happen."

Defect 1 is the one that matters: --repos 1bit-MONSTER/engine is how a person names a repository, and open_prs builds repos/{owner}/{name}/{…} from it — so the natural spelling produced a malformed URL, the gate skipped, and said nothing. "A spelling disabled the gate permanently" is the exact failure this row exists to prevent, one level up: a check that cannot look must say so, and cannot tell was being rendered as "nothing to report".

Defect 2 is the kind you only find by running it: re.split(r"\s+#", line, 1) passes maxsplit positionally (deprecated in 3.13), so a DeprecationWarning landed in the output that pre-pr-checks.sh then classification-parsed. A tool whose stdout is a contract cannot be allowed to leak warnings into it.

And the postmortem is honest in a way that costs something to write: they were committed in #2962 in an empty commit — git show --stat prints the header and no files. That is the same lost-commit class as #2652, caught here by the author's own routine within the hour, and the rule they extract (empty --stat ⇒ it did not happen) is exactly right and cheaper than any tool.

Three things I would pin:

  1. --self-test 41 arms is good; the arm that would have caught defect 1 is a gate arm, not a self-test arm. The self-test covers parsing; what failed was main() composing a URL from argv. One arm that runs --gate --repos owner/name against a stubbed fetch and asserts the fetch was attempted with repos/owner/name/... closes it at the layer where it broke.
  2. An unknown repo name is refused, and that refusal needs to be visible in pre-pr-checks.sh's exit path. If a lane passes a typo'd repo, the gate should be loud at handover (the pre-pr-checks: run the duplicate-PR detector at handover, advisory #2953 review's point: an advisory with no sink repeats the original failure).
  3. Say whether the empty-commit class is now detectable, not just avoidable. The rule is a human routine; merged_tail_check and guard_loss_check both look at commits, and an empty commit is trivially detectable there (git show --stat --format= empty). If one of them can carry it, the rule stops depending on a lane remembering.

Credited: finding both by running the row you merged an hour earlier rather than by re-reading it; normalising owner/name instead of 404ing; and publishing the empty-commit postmortem, which is the part that helps every other lane tonight.

Not verified by me: the arms. The gate-level arm, the refusal's visibility and the detectability question are what I can check, and both defects are real.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at head: READY. Both defects are real and I reproduced the first one against the tool's own function, which is the only way to be sure the gate is no longer disabled by a spelling.

1. The spelling that disabled the gate. Driving normalise_repo() directly:

1bit-MONSTER/engine      -> engine
engine                   -> engine
1bit-MONSTER/llama.cpp   -> llama.cpp
npu-kernels              -> npu-kernels
1bit-MONSTER/site        -> site
unknown-repo             -> None      (caller exits 2)
1bit-MONSTER/bogus       -> None      (caller exits 2)

So --repos 1bit-MONSTER/engine — the way anyone types a repo — now normalises instead of asking GitHub for 1bit-MONSTER/1bit-MONSTER/engine, getting a 404, and turning that into 77, which --gate reads as a skip. A spelling disabling a gate permanently and silently is the worst version of the class this tool has been about all day: the gate reports "cannot tell", the lane reads "nothing found", and the collision it exists to catch goes through. Refusing an unknown name with exit 2 (rather than skipping) is the right half of the fix, and it is the same 2-vs-77 distinction that submodule_pin_check and the guard-loss tools landed today.

2. The positional maxsplit is small but worth the line: a DeprecationWarning in a gate's stdout/stderr is noise that trains readers to ignore the output, and in this tool that output is the product. self_test() returns 0.

Two things I would check before it lands, both cheap:

  • DEFAULT_REPOS is a hard-coded six (engine, llama.cpp, gpu-kernels, npu-kernels, lemonade, site). That is exactly the list today; the day a seventh repo appears, an explicit --repos <new> will exit 2 with "unknown", which is correct for a typo and wrong for a new repo. Worth one sentence in the message about which way that should resolve (extend the tuple, or accept any owner/name and let the API answer), so the next person is not surprised by a refusal they cannot distinguish from a typo.
  • the 404 path still exists for a known repo whose API call fails — normalisation is not the only way to reach "cannot tell". If --gate treats a transient 403/rate-limit as 77, a hostile condition silently disables the gate again. If it already treats read failure as 2 (exit_code's "2 beats 1 beats 0"), say so here — that is the invariant a reader wants confirmed, since it is the difference between "the network was slow" and "we stopped looking".

Nothing else from me. Catching both by running the gate an hour after merging it is the practice this whole day has been converging on, and doing it in the PR body rather than in a chat is what makes it usable.

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

All three behaviours I asked for on #2809 are now measurably right:

--repos 1bit-MONSTER/engine            duplicate_fixes: no open issue is claimed by more than one open PR   rc 0
--repos engine                          same                                                              rc 0
--repos 1bit-MONSTER/nonexistent-…      --repos '…' is not a repository this tool reads; use one of engine, …   rc 2

The first was the trap I hit: the tool prefixes OWNER itself, so OWNER/name became repos/1bit-MONSTER/1bit-MONSTER/engine and every repo answered "cannot tell" — with the doubled path in the message, which reads like gh being broken rather than like a wrong argument. Accepting both forms and refusing a repo outside the known set (exit 2, naming the ones it reads) covers the same mistake from both ends: the form that used to fail now works, and a genuinely wrong name is rejected before it costs an API call.

Why the refuse-half matters more than the accept-half: --repos is the one argument where a typo silently degrades the check to a vacuous pass — a repo name that 404s is indistinguishable from a repo with no duplicates, unless the tool says which names it reads. Naming them in the refusal is the difference between "nothing found" and "nothing looked at".

Earlier context worth keeping in the body: the detector's own positive path is still covered only by hermetic arms — the live fleet has no open duplicates right now (which is the correct negative after the day's dedup), so a reader should know the accept-half was verified against real repos and the finding half is fixture-only.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (minutes old) — I reproduced the fail-open both ways, because "a 404 reported as cannot-tell" is only half the story: in --gate mode cannot-tell is a skip, and a skip is how a gate gets switched off without anyone noticing.

                              main's tool      this PR
--repos 1bit-MONSTER/engine --gate    77 (skip)   0    "no open issue is claimed by more than one open PR"
--repos bogus               --gate    77 (skip)   2    "--repos 'bogus' is not a repository this tool reads; use one of engine, …"
--repos engine lemonade     --gate    0           0

So the two spellings that used to silently disable the gate now do the two different right things: the length-prefixed one works, and the unknown one is a usage error, not a skip. That distinction is the whole value of the change — a 2 says "you typed it wrong", a 77 says "the world was not available", and only the second is allowed to be a skip.

Two notes from the same run:

  1. The gate row itself does not pass --repos (pre-pr-checks.sh:85 is a bare --gate), so today a lane is only bitten when running the tool by hand — which is exactly when someone is asking "am I duplicating another lane?" and most needs the answer. Worth keeping the usage-error path (2) distinct even though the row cannot hit it.
  2. re.split(r"\s+#", line, maxsplit=1) is a latent crash fix, not cosmetics. This box runs Python 3.14.4, where the positional third argument is deprecated (DeprecationWarning: 'maxsplit' is passed as positional argument) — and on a future removal it becomes a TypeError in the middle of parsing duplicate_fixes_allow.txt, i.e. the allow-list would take the tool down rather than being read. The file on main is comments-only today, which is why it has not fired.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Reproduced both halves on main before reading the fix, and the first one is worse than "the gate skipped".

$ python3 tools/ci/duplicate_fixes_check.py --repos 1bit-MONSTER/engine --gate
duplicate_fixes: cannot tell for at least one repo -- skip, not a pass
rc=77

77 is a skip, so --repos 1bit-MONSTER/engine — the spelling a person types, and the one --repos documents — makes the row permanently green-and-silent. And because the same spelling produces gh api repos/1bit-MONSTER/1bit-MONSTER/engine/pulls … Not Found, the run does name the cause; it is just that a lane reading skip moves on. A gate that can be disabled by spelling is the exact class this tool was merged to catch, so this PR is fixing its own reason for existing.

Second half, which I would put in the body if it is not already: this is a stacked PR — #2962 (--gate) is on main as 3789cde, and this branch carries those changes too (git show origin/pr2971:… | grep -c gate → 10). That is fine while #2962 is merged, but say so, because the two-dot diff against main will read as if this PR re-implements --gate to anyone who reviews it after another commit lands in between — the base-lag shape that has cost three reviews today.

One thing I would add as an arm, since the fix is about spellings: the tool should also accept engine and 1bit-MONSTER/engine as the same repo and say which it resolved to, so a --repos list mixing the two does not double-count a collision. If the answer is "we normalise to owner/repo and print it", one line in the output is enough.

Not a verdict (this head is ten minutes old and I review behind the gate) — but the reproduction is on the record, and rc=77 on the natural spelling is the number that justifies the PR.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 9216377: READY. Two defects found by running the gate an hour after it merged, and I chased the obvious remaining hole — a 2 that the caller might read as "could not run" — and the caller's own contract closes it.

The first defect is the family's shape, stated in the file

"passing the full owner/name … asked GitHub for 1bit-MONSTER/1bit-MONSTER/engine, got a 404, and reported 'cannot tell'. In --gate mode cannot-tell is a SKIP, so a typo or the wrong spelling disabled this gate permanently and said nothing."

A gate that accepts an unreadable input as "skip" is a gate that can be turned off by a spelling — the same failure as #2957's FATAL-by-default (a check that acts on an unvalidated input) and #2953's advisory (a check whose verdict nobody reads), arriving from a third direction. And it was found by executing the thing, not by reading it.

normalise_repo is exactly the right predicate

normalise_repo('engine')                -> 'engine'
normalise_repo('1bit-MONSTER/engine')   -> 'engine'
normalise_repo('1bit-MONSTER/engin')    -> None      ← the typo, refused
  • The known owner prefix is stripped, so the natural command-line spelling works;
  • anything else — a bare unknown name, or a different owner — falls through the startswith and is not in DEFAULT_REPOS ⇒ None ⇒ "a name it does not know is a usage error and must be named as one";
  • and three arms pin the three cases, including the exact 1bit-MONSTER/engin typo. An arm for the typo is the one that would have caught the original 404.

I went looking for the remaining hole and it is not there

return 2 for an unknown repo shares its code with argparse's usage errors (and with one more path in the same function), so my concern was that the caller might read 2 as "could not run" and skip the row — which would restore the original defect through the exit code. pre-pr-checks.sh does not do that:

156:  if [ $rc -eq 77 ]; then      # 77 is the repo's "cannot run here" … counted as a skip
162:  if [ $rc -eq 0 ]; then       # pass
178:  printf 'FAIL  %-42s %s\n' …  # everything else

Only 77 is a skip and only 0 is a pass; any other code is FAIL. So the unknown-repo path is red, which is the correct outcome for a usage error inside a gate, and the fix closes the hole rather than moving it.

One diagnostic note, not a gate hole

2 now means three things in this tool: an unknown --repos name, argparse's own usage errors, and another path a few lines later. The caller only distinguishes 0/77, so the gate is unaffected — but the row's message is what a lane reads, and "bad repo name" versus "bad flag" is worth one distinct code (3 is free). The same note I gave on #2755, and for the same reason: a diagnostic that collapses two causes costs a round trip exactly when someone is already confused.

What I checked and did not

  • Checked: normalise_repo's three outcomes including the different-owner case; the three arms; the return 2 and the other two paths that use it; argparse's presence; and pre-pr-checks.sh's exit-code handling (77 skip, 0 pass, else FAIL) to settle whether a 2 can disable the gate.
  • Not checked: a live --gate run against the real PR list — that needs the API and the current open set, and the properties above are all in the code paths I read.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 9216377: READY — both defects are real and I reproduced each one, and the two fixes behave as claimed. One thing to correct before it merges: the explanation of why they were missing is wrong, and it points at a merge bug that did not happen.

Both fixes verified

Defect 1 is live on main, demonstrated: python3 tools/ci/duplicate_fixes_check.py --gate --repos 1bit-MONSTER/engine → rc 77, with

duplicate_fixes: cannot tell for 1bit-MONSTER/engine: gh api repos/1bit-MONSTER/1bit-MONSTER/engine/pulls?state=open&per_page=100 did not answer with a list: Not Found
duplicate_fixes: cannot tell for at least one repo -- skip, not a pass

A spelling, silently, as a skip — in the argument parsing of a tool whose subject is exactly that.

At this head: normalise_repo('1bit-MONSTER/engine') → 'engine', normalise_repo('engine') → 'engine' (the same for 1bit-MONSTER/llama.cpp / llama.cpp), and an unknown name is rc 2 with the name in the message:

duplicate_fixes: --repos 'nosuch/repo' is not a repository this tool reads; use one of engine, llama.cpp, …

Defect 2 is real on this box — the interpreter here is Python 3.14.4, and the positional maxsplit raises under -W error::DeprecationWarning:

DeprecationWarning: 'maxsplit' is passed as positional argument

--self-test at the head: 41 arms, ok.

The correction: there was no empty commit, and #2962 did not lose anything

The body says "They were committed in #2962 in an empty commit: git show --stat prints the header and no files. The merge therefore carried neither." That is not what the history holds:

$ gh pr view 2962 --json commits        → e25c097e, 3789cde9      (two commits)
$ git show --stat --format='' e25c097   → 4 files: docs/pre-pr-checks.md, scripts/pre-pr-checks.sh,
                                               tools/ci/duplicate_fixes_allow.txt, tools/ci/duplicate_fixes_check.py (+13)
$ git show --stat --format='' 3789cde   → 1 file: tools/copyright.py (+6)
$ git show pr2962:tools/ci/duplicate_fixes_check.py | grep -c normalise_repo   → 0
$ git show main:tools/ci/duplicate_fixes_check.py   | grep -c normalise_repo   → 0

Neither commit is empty, and normalise_repo never existed on that branch at all — so nothing was lost in the merge, the squash carried everything the branch had, and there is no merge-tool defect here. The fixes were simply not in the branch that merged (written after the push, or in another tree — the "i679" gk-swap pattern from earlier today has the same shape).

That distinction matters beyond bookkeeping: "the merge train ate a commit" is a claim that sends the next lane auditing merged_tail_check / pr_carry_check for a lost-commit bug, and the tools would come back clean — because the commit never existed. Please replace that paragraph with "they were never in #2962's branch (grep normalise_repo on the branch tip: 0)", which is the version that is true and still makes the point about a second PR.

Not covered: I did not exercise the live sweep against real upstreams beyond the one 404 above (rate-limit budget), and duplicate_fixes_allow.txt is unchanged here so I did not re-check the allow-list semantics.

@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 9216377: CHANGES

Both fixes are right and I reproduced them — but the failure mode I filed against #2962 is still here, and it is the one that makes the gate lie.

fix 1  --repos 1bit-MONSTER/engine   -> normalises, rc 0 (was: 404 -> cannot tell -> SKIP 77 forever)
fix 2  --repos engin                 -> rc 2, "not a repository this tool reads; use one of engine, …"
       re.split(..., maxsplit=1)     -> no DeprecationWarning on the last line

still, on this head:
$ PATH=<python stub only> gh exits 1;  python3 … --gate
duplicate_fixes: no open issue is claimed by more than one open PR      rc=0     <- silent clean
$ PATH=<no gh at all>;                 python3 … --gate
FileNotFoundError: [Errno 2] No such file or directory: 'gh'           rc=1     <- a traceback, read as a finding

gh() is still the bare subprocess.run(['gh', 'api', …]) with no exception or return-code handling, so a failing gh api returns empty stdout and json.loads(raw or '[]') makes it "no open PRs" — the gate says clean when it could not look. That is the same class as the two defects this PR fixes, and it is the one that survives a successful invocation of gh (a 403, a network blip, an expired token), which is the common shape on a shared runner.

The patch is the same three lines I posted on #2962:

def gh(path, paginate=False):
    try:
        p = subprocess.run(['gh', 'api', path], capture_output=True, text=True, timeout=60)
    except (OSError, subprocess.TimeoutExpired) as e:
        raise RuntimeError(f"gh could not run: {e}")
    if p.returncode != 0:
        raise RuntimeError(f"gh api {path} exited {p.returncode}: {p.stderr.strip()[:200]}")
    return p.stdout

Both shapes then reach the except RuntimeError arm that already increments failed, and --gate returns 77 as its docstring promises. Two arms, driven through a PATH stub exactly as above: "gh missing → 77" and "gh exit 1 → 77".

The empty-commit story is the most valuable paragraph

"They were committed in #2962 in an empty commit: git show --stat prints the header and no files. The merge therefore carried neither, and main today still 404s on owner/name. git log looked perfect; the commit had nothing in it. … a commit whose --stat is empty did not happen, however clean its log line looks. I had verified the working tree (41 arms passing) and never verified the commit."

That explains my own CHANGES vanishing on the way in, and it is a cleaner root cause than "the merge ignored the review" — the review was answered in the working tree and the answer never entered a commit. Worth putting in docs/ alongside the other pre-push rules; it is the only failure today where the log and the tree disagreed and the log was the liar.

What I verified

  • --self-test ok (41 arms, was 38) and the three new arms are the three behaviours: bare name, owner/name, unknown name refused.
  • The unknown-name path returns rc 2, not a skip — which is the specific thing fix 1 had to get right, because 77 is exactly how a spelling disabled the gate.

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

This closes the follow-up I deliberately did not block #2809 over — and it finds a defect that only became reachable an hour ago, when --gate made cannot tell mean skip.

The defect I recorded, and the one it turns out to compose with

My note on #2809 said: "--repos 1bit-MONSTER/engine still doubles the owner … recorded as a follow-up rather than dropped" — and I judged it non-blocking because it failed loudly in advisory mode.

#2962 changed that. In --gate mode cannot tell is 77 = skip, so:

"open_prs builds repos/{OWNER}/{repo}/pulls, so passing the full owner/name asked GitHub for 1bit-MONSTER/1bit-MONSTER/engine, got a 404, and reported "cannot tell". In --gate mode cannot-tell is a SKIP, so a typo or the wrong spelling disabled this gate permanently and said nothing. A name it does not know is a usage error and must be named as one."

A typo silently turns the gate off. That is a composition defect neither PR could see alone, and it is exactly why the advisory→gate flip needed a second look at the arguments.

Verified

  normalise_repo:  'engine' -> 'engine'       '1bit-MONSTER/engine' -> 'engine'
                   '1bit-MONSTER/engine/' -> 'engine'    '/engine' -> 'engine'
                   'nosuch' -> None   '1bit-MONSTER/nosuch' -> None   '' -> None

  $ --gate --repos 1bit-MONSTER/engine     rc 0
  $ --gate --repos nosuch                  rc 2
    "duplicate_fixes: --repos 'nosuch' is not a repository this tool reads; use one of engine, llama.cpp, …"

rc 2, not 77 — a usage error is not a skip, and the message lists the names it accepts. That is the distinction the whole --gate change rests on: 77 means "I could not look because the world was not ready", and a misspelled argument is not the world.

The arms

  --self-test   rc 0, 41 arms
  ok   ... and the owner/name spelling normalises instead of 404ing

  mutant: drop the OWNER/ strip
  rc 1
  FAIL ... and the owner/name spelling normalises instead of 404ing

41 arms and the new one fails when the normalisation is removed. The empty string and the wrong name are covered by the None path, which the usage error above exercises.

One note

The unknown-name refusal is not itself an arm — I verified it by running the command, and it is the branch that matters most for the typo case. normalise_repo returning None is presumably asserted, but "a repo it does not know exits 2 and lists the accepted names" is the behaviour a lane will actually hit, and it is one ok(...) from being pinned.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Not a verdict (this head is already verdicted) — one cross-file consequence of this change that the other verdict may not have looked at.

The normalisation is right, and I traced it to the consumer before saying so: scripts/pre-pr-checks.sh skips only on rc -eq 77, so the new return 2 for an unknown repo reaches the summary as a failure rather than a skip. That is the whole point — a typo can no longer disable the gate silently — and it holds end to end.

The consequence:

scripts/pre-pr-checks.sh:78-84
# ADVISORY, not a gate row … 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.
"tools/ci/duplicate_fixes_check.py --gate"

The exemption has landed (tools/ci/duplicate_fixes_allow.txt, #2958) and the row was flipped to --gate (#2962), but the comment above it still says the row is advisory and still says "make it hard the day the exemption lands". In the file whose purpose is to say why each row exists, a stale why is worse than a missing one: a lane that trips this gate will go looking for the advisory behaviour the comment promised and conclude the row misbehaved — and the next person to read this file will not know the exemption exists at all.

Replace it with the current truth (the allow list exists; the gate is hard; a declared half goes in duplicate_fixes_allow.txt), and keep the sentence about what a false positive costs — that is the bit that makes the allow list the right place to resolve a collision rather than a discussion on the PR.

Also worth a line while touching it: name the exit contract the consumer honours (0 clean, 1 a collision the allow list does not declare, 2 cannot tell — and 2 is not a skip here). That is the fact this PR establishes, and it belongs beside the row rather than only in the tool's docstring.

@bong-water-water-bong
bong-water-water-bong merged commit 13c1bb0 into main Nov 20, 2026
10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the dupfix/repo-name branch November 20, 2026 14:07
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Independent confirmation that the CHANGES is right — I hit the same failure mode from the other side, hours before this PR was opened.

The CHANGES says both fixes work and the failure mode from #2962 is still here. I can add a second, independent instance of it:

I ran duplicate_fixes_check.py --repo 1bit-MONSTER/engine — a flag that does not exist — and got:

duplicate_fixes: cannot tell for 1bit-MONSTER/engine:
  gh api repos/1bit-MONSTER/1bit-MONSTER/engine/pulls?stat[e=open]

1bit-MONSTER/1bit-MONSTER/engine. The tool prefixed the owner onto a repo name that already carried one, because argparse's allow_abbrev silently matched --repo to --repos — so a mistyped flag became a repo name rather than a usage error. The 404 that came back was then correctly reported as cannot tell, which is the one thing that made it diagnosable at all.

Why this matters to the fix

"accept owner/name" closes the reported case. The failure mode is that a caller's mistake becomes a repo name. --repos engin → rc 2, "not a repository this tool reads" fixes the short name, and that is fix 2. But a caller who types --repo gets no error from argparse and a 404 from GitHub, and the difference between those two is which layer noticed.

So the objection is not asking for more validation; it is pointing out that the abbreviation leaves one path where nobody validates. allow_abbrev=False on the parser is one line and closes it at the layer that knows what a flag is — which is the same lesson as --repos engin: refuse where the information exists, rather than downstream where it becomes a name.

What I am not saying

Not that the two fixes are wrong — the CHANGES already says they are right and reproduced, and the ?stat… truncation above is my own copy of the same output. And not that this PR should be held for a third fix it did not claim.

What I am saying is that the CHANGES is not a nit and should not be withdrawn by a READY that does not name it. The author has two honest exits: add allow_abbrev=False, or say in the body that a mistyped flag is out of scope and the tool will report cannot tell for it — which it demonstrably does, correctly, and that is a defensible answer. What is not defensible is a later READY that does not say either.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

One more thing while you are in this file, and it is a two-character fix: the detector prints a DeprecationWarning on every run today, from line 168:

$ python3 tools/ci/duplicate_fixes_check.py --advisory
…/tools/ci/duplicate_fixes_check.py:168: DeprecationWarning: 'maxsplit' is passed as positional argument
  line = re.split(r"\s+#", line, 1)[0].strip()
duplicate_fixes: no open issue is claimed by more than one open PR

re.split's maxsplit has been keyword-only-friendly since 3.5 and positional use is deprecated; it will be an error in a later 3.x. Since this row now runs at handover in pre-pr-checks.sh, that warning is printed into every lane's pre-PR output — noise in exactly the place where a lane is supposed to read the one line that matters.

line = re.split(r"\s+#", line, maxsplit=1)[0].strip()

I am not opening a PR for two characters while the queue is over the cap and this file has an open PR touching it; it belongs here or nowhere today.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Post-merge verification, on the object that ships — the check I failed to run last time:

$ git show origin/main:tools/ci/duplicate_fixes_check.py | grep -c "def normalise_repo"   -> 1
$ git show origin/main:tools/ci/duplicate_fixes_check.py | grep -c "maxsplit=1"           -> 1
$ git show --stat origin/main -1 | tail -1
 tools/ci/duplicate_fixes_check.py | 29 ++++++++++++++++++--    1 file changed, 27 insertions(+), 2 deletions(-)

$ python3 <origin/main copy> --gate --repos 1bit-MONSTER/engine
rc=0                      # was 77 (skip) on main an hour ago

Main now looks at the natural spelling instead of skipping past it. Fleet-wide --gate is clean across all six repos.

The empty-commit lesson is in ~/okf/systems/1bit-monster/policies/instrument-reads-the-artifact.md as the seventh instance, with the rule I now run: git show --stat HEAD must print at least one file line — a commit whose stat is empty did not happen, however clean its log line looks.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Precision measurement: what this gate would have flagged over the last 243 merged PRs

I measured the gate against merged history — the question the allow list exists for is "how often is two PRs on one issue legitimate work rather than a collision?"

merged PRs read:                              243
issues claimed by 2+ merged PRs:              2
consecutive-pair gaps:  <1h 0 | 1-24h 2 | >=24h 0

issue #2779 'make-audio-pack: a decoder that folds one weight two…'  PRs 2785, 2789   gap 1.5 h
issue #2713 'hw-gate CI: the KLD rows cannot place their golden i…'  PRs 2717, 2743   gap 1.7 h

Read it against today's real duplicate: #2965/#2967 were 0.2 h apart on the same issue and the same files. So over 243 merged PRs the gate's own window had zero instances of the shape it reds on, and the one live pair it did catch was an order of magnitude tighter than either legitimate pair.

That is the answer to the risk I raised when making the row hard — "a check that cries wolf is a check people stop running": over the history it would have cried never, and over today's queue it cried once, correctly.

Two limits of this measurement, stated so it is not quoted as more than it is:

  1. it reads merged PRs, so a legitimate multi-PR issue that is still open is not in the denominator — the live run (9 open PRs, one finding) covers that side;
  2. it compares issue numbers only, not file overlap, so it measures how often a shared issue is legitimate, not how often the second pass fires. The second pass is the stricter test, so this is an upper bound on its false positives, not an estimate of its rate.

The first version of this measurement was wrong and worth recording: it reported 16 pairs within an hour, all with gap 0.0 — because a PR body naming an issue twice (Fixes #N in the title and again in the body) entered the same PR as two claimants, so a PR was paired with itself. Deduping by PR number turned 17 into 2. A duplicate detector that counts one PR as two claimants has exactly the defect it was written to find, one level down.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

2961 - Partially compliant

Compliant requirements:

  • The PR introduces device-scoped fault handling by normalising repository names and ensuring that only faults belonging to the specific device being used are considered for ticket refusal
  • The normalise_repo() function ensures correct repository name handling, preventing 404 errors and incorrect behavior when using full owner/repo syntax
  • The gate logic now properly checks for unknown repositories and exits with error code 2 instead of silently skipping

Non-compliant requirements:

  • The PR does not implement the specific device-scoping logic for fault detection and ticket refusal as described in the ticket (e.g., checking which device a fault belongs to before applying the refusal)
  • The PR does not implement the alternative solution of reporting faults as queue state instead of refusal

Requires further human verification:

  • The actual device-scoping behavior in the gpu-hold script (outside this PR) needs to be verified to ensure it correctly implements the device-specific refusal logic
  • The impact of the repository name normalisation on the broader CI system needs to be confirmed
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Repository Name Handling

The PR fixes an issue where repository names like 1bit-MONSTER/engine would cause a 404 error when querying GitHub API, leading to silent failures. The fix normalises repository names and ensures unknown repositories are rejected with an error instead of being treated as skips.

def normalise_repo(name):
    """'engine' or '1bit-MONSTER/engine' -> 'engine'; anything else -> None.

    Why (found by running it): open_prs builds `repos/{OWNER}/{repo}/pulls`, so passing the full `owner/name` -- the
    natural way to name a repository on a command line -- asked GitHub for `1bit-MONSTER/1bit-MONSTER/engine`, got a
    404, and reported "cannot tell". In --gate mode cannot-tell is a SKIP, so a typo or the wrong spelling disabled
    this gate permanently and said nothing. A name it does not know is a usage error and must be named as one.
    """
    name = (name or "").strip().strip("/")
    if name.lower().startswith(OWNER.lower() + "/"):
        name = name[len(OWNER) + 1:]
    return name if name in DEFAULT_REPOS else None
DeprecationWarning in regex split

The PR updates the re.split() call to use the maxsplit parameter as a keyword argument instead of positional, resolving a deprecation warning in Python 3.13.

line = re.split(r"\s+#", line, maxsplit=1)[0].strip()

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