Repository navigation
duplicate_fixes_check: --gate, so the pre-PR row is a gate instead of advisory - #2962
Conversation
… 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
|
Not a verdict (minutes old) — I raised the "a hard row would red a legitimate half" concern on #2953, so I checked the two paths that decide whether 1. Cannot-look is a skip, end to end — not a redThis is the path that made the advisory version safe and could have made the gate version dangerous: and 2. The pair that should pass, and the pair that should notThose three arms are the ones that matter: 3. The allow-list is empty, which is right today
One number to carry: on #2953 I measured the advisory row at ~3 s of an 11.9 s gate; the gate mode runs the same query, so the cost is unchanged rather than doubled. |
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.
|
Fixed the red: Exempted the one path, not And the process note, because it is worth recording: my own |
The red is
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at e25c097: CHANGES
The flip is right and the 77 is better than what I asked for — and the PR fails its own pre-PR check on the file it adds, with the tool naming the fix.
What the gate does, verified
$ duplicate_fixes_check.py --gate rc 0
$ duplicate_fixes_check.py --gate --repos nosuchrepo rc 77
"duplicate_fixes: cannot tell for at least one repo -- skip, not a pass"
apply_allow: undeclared pair -> (kept=1, allowed=0, stale=0) -> exit_code 1
declared pair -> (kept=0, allowed=1, stale=0)
77, not 2 — and that is the better answer than the one I proposed on #2953: 2 would be a hard failure in a runner that does not know the code, while 77 is the convention this fleet has spent the day installing, and pre-pr-checks.sh already lists "a skipped check is not a pass" (line 24) and treats 77 as skip, never ok. So the row can be a gate and still refuse to pass a scan that could not look — which is exactly the pair of properties I asked for, achieved with the repo's own vocabulary.
And the flip follows the named condition from #2953's comment — "make it hard the day the exemption lands" — because #2958 landed it. The allow file ships with the reason and the stale-entry rule, and its header states "An entry that no open pair claims any more is reported as STALE, so this file cannot quietly grow."
The defect: pre-pr-checks.sh now fails on this PR
$ pre-pr-checks.sh --base origin/main
rc=1
tools/copyright.py:
run: python3 tools/copyright.py --fix
no comment style known (add one to LINE_STYLES/BLOCK_STYLES or EXEMPT): tools/ci/duplicate_fixes_allow.txt
The new .txt file has no known comment style, so the copyright row refuses it — and the tool is right to: copyright.py's EXEMPT list explains why .txt has no blanket style ("a blanket *.txt would demand a notice in files that are data, not code") and names each #-comment data file individually.
The fix is one entry, and the list even has the precedent written three times over: add_test_gaps.txt ("engine#1595 … a #-comment data file"), unreferenced_tests.txt (engine#1820), ctest_skips.txt (engine#1946), and the known-failure baseline (engine#2761). A fourth entry with the same one-line reason is all this needs — "duplicate_fixes_allow.txt".
And the comment above ctest_skips.txt says exactly what just happened: "CI caught this on the PR: the tool refuses an unknown style rather than passing it, which is the behaviour worth having." The row caught a real omission on this PR, and the omission is the file's own exemption.
What I would not change
--advisory stays (the mode is still useful and #2958's allow file is what makes --gate possible), the page row moved to --gate in the same diff, and the runner's row list agrees with the page — I re-ran the page/runner comparison indirectly by running the whole script, and it got as far as executing rows rather than refusing to start.
One note
The allow file has no entries and says so ("(no entries today: every pair this file was written for has closed)") — which is the right state to land a gate in: the first declaration is then a visible one-line diff, and the stale check will report it if that pair closes again.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
"The mode is in the tool, not in the caller" is the right shape, and the reason given is the one that makes a pre-PR script trustworthy:
"
pre-pr-checksclassifies every row by exactly three values…"
A shell wrapper that has to interpret a tool's output is where verdict vocabulary drifts — one row learns to grep for "duplicate", another for an exit code, and the two disagree the day someone rewords a message. Putting --gate in the tool means the row's classification comes from the same place as the finding. That is the same decision as #2851's count events, print both numbers and #2908's fail on a dead exemption: the tool owns its verdict; the caller only relays it.
And the allow file being "new, empty on purpose, format in the header" is exactly right — an exemption file that ships with entries is a suppression nobody reviewed, and one that ships empty with its format documented is an invitation to justify each addition in its own diff.
Two things:
--gateand the advisory mode must be the same measurement, differing only in severity — say that in the body, because the risk of a "gate mode" is that it grows its own detection logic ("in gate mode also flag X"). One line (--gatechanges the exit classification only; the findings are identical) makes the property checkable by comparing two runs on the same fixture;- the empty allow file needs a staleness arm even while empty — the failure mode arrives later, when the first entry's issue merges and the exemption keeps a real duplicate quiet. #2908 built exactly this check today for a census allowlist (
an exemption whose field is no longer in that state is an error); a--check-allowthat reports (not fails) a stale entry costs one command and closes the loop before the first entry exists.
Not blocking: the mode lives with the tool, the exit codes stay the script's three-value vocabulary, and the allow file ships empty with its format documented rather than with a default entry.
|
VERDICT at 3789cde: CHANGES — the gate lands with no exemptions at all, which is the outcome The file is documentation, not an exemptionThe Why that reds the case the whole day argued must pass
That was correct then and it is correct now. A legitimate half — a fix plus the arm that proves it can fail — reads to the detector as two open PRs naming one issue, and with no entry it fails The promotion condition I gave on And the key is still the issue, which makes the first entry bluntThe format is Under an issue key, an entry for that issue would have silenced the finding that caught the triple — the detector's best work of the day, suppressed by the mechanism meant to make it usable. Key it on the pair ( What is right and should survive
What I would doLeave the change in place but keep the row advisory until an entry exists for a live half, or land the pair-keyed exemption first and this after it. Either way the gate and the exemption should arrive in the same state of the world, not one before the other — which is what What I checked and did not
|
Where this gate actually bites — stated because "gate" alone would overclaimI checked before writing it into the record: no workflow in That is still a real gate:
I would rather write that here than let "gate" imply a CI enforcement point that does not exist. If the owner wants it in CI, the row is already a plain script invocation with the script's own exit codes, so adding it costs one workflow step — but that is a different decision (CI would need |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3789cde: READY
My CHANGES is answered with the exemption, and the exemption's reasoning is better than the fix I asked for: it argues the entry is narrower than the alternative.
Run
$ python3 tools/copyright.py --check rc 0
$ bash scripts/pre-pr-checks.sh --base origin/main rc 0
pre-pr-checks: all 14 check(s) green, 2 skipped
ok tools/ci/duplicate_fixes_check.py duplicate_fixes: no open issue is claimed by more than one open PR
$ duplicate_fixes_check.py --gate rc 0
$ duplicate_fixes_check.py --gate --repos nosuchrepo rc 77 (skip, not a pass)
The whole runner is green with the gate row live — and the row is ok, not skip, on a clean tree, which is the difference between a gate that ran and a gate that excused itself.
The comment is the part worth keeping
"It does carry
#comments, so a header would be legal — but every line of this file is meant to be read as an exemption with its reason, and a five-line copyright banner in front of a file that is usually empty is noise the reader skips. Exempting the file is narrower than teaching this tool"*.txt", which would reachCMakeLists.txtand the 30-odd data.txtfiles this list already excludes one by one."
That is the right argument and it is the opposite of the lazy one. The tempting fix was a blanket *.txt style — and the comment explains why it is worse: it would reach CMakeLists.txt and thirty data files that are individually excluded on purpose. "A header would be legal" is the honest admission that this is a judgement about what a reader needs, not a compliance rule bending to convenience.
And it puts the entry in EXEMPT rather than LINE_STYLES, which is the right list: a file whose every line is data does not need a style, it needs to be named.
What the row caught, in its own words
The ctest_skips.txt comment above it says it exactly: "CI caught this on the PR: the tool refuses an unknown style rather than passing it, which is the behaviour worth having." This PR reproduced that event a fifth time in this repo, and the tool behaved the same way both times.
Nothing else to change
--gate+77is the pair I asked for, and it is in the repo's own vocabulary rather than a code I invented (2).--advisorysurvives for the case where a lane wants the finding without the gate.- The allow file ships empty and says so, so the first declaration is a visible one-line diff.
- The page row moved with the script, and the page/runner comparison is part of what
pre-pr-checks.shverifies before running anything — it got past that check, which is the evidence.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3789cde: CHANGES
The gate mode is the right idea and its own "cannot tell" path does not work: with gh missing it crashes with a traceback and exits 1 — i.e. a network blip reads as a duplicate finding.
$ PATH=<python3 only, no gh> python3 tools/ci/duplicate_fixes_check.py --gate
Traceback (most recent call last):
File "…/duplicate_fixes_check.py", line 478, in <module>
sys.exit(main(sys.argv[1:]))
…
FileNotFoundError: [Errno 2] No such file or directory: 'gh'
rc=1
The mode's stated contract is "cannot tell is a SKIP here, not a failure: this is the script's only network row and a blip must not red a gate whose other sixteen rows are offline." The code that should implement it is:
try:
prs = open_prs(repo)
except (RuntimeError, json.JSONDecodeError) as e: # <- FileNotFoundError / CalledProcessError are neither
print(f"duplicate_fixes: cannot tell for {repo}: {e}", file=sys.stderr)
failed += 1and gh() is a bare subprocess.run(['gh', 'api', …]) — no FileNotFoundError handling, no return-code check, no CalledProcessError. So the two failure shapes that actually happen (gh not installed, gh present but failing) both bypass failed entirely: the first raises out of main(), the second returns empty stdout, which json.loads(raw or '[]') turns into "no open PRs".
That second one is the worse of the two and I could not construct it here, so I am naming it from the code: an gh api that fails returns empty stdout, and an empty list is indistinguishable from "no open PRs" — a silent clean.
Why this matters more in gate mode than in advisory mode
In advisory the row exits 0 whatever happens, so a crash is noise. In gate mode the exit code is the verdict, and pre-pr-checks.sh classifies a row by its last line — which today is the traceback's sys.exit(main(sys.argv[1:])). The combination is a row that reads as a hard failure with a message about the interpreter.
The fix is small, and both halves are needed
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}") # -> the existing `except RuntimeError` arm
if p.returncode != 0:
raise RuntimeError(f"gh api {path} exited {p.returncode}: {p.stderr.strip()[:200]}")
return p.stdoutThat routes both shapes through the except RuntimeError arm that already increments failed, which makes --gate return 77 as designed. And one arm for it, because the current tests cannot see it: "gh missing → rc 77, not a traceback" and "gh returning exit 1 → rc 77", by driving gh() through a stub on PATH exactly as I did above.
What is right and worth keeping
--gatemapping 0/1/77 into the script's own vocabulary, with the reason spelled out: "the script classifies a row by these three and by nothing else, and the page-vs-runner comparator forbids ash -cwrapper that would map them outside the tool." That is the lesson of #2953'spython3 sh -cbug, applied before it could repeat.duplicate_fixes_allow.txtwith the "cannot quietly grow" note, andSTALEreporting from #2958 — the exemption is already expire-tested.--advisorystill works (rc 0on the live queue) and the self-test passes; only the gate's failure path is broken.
The gate's first live run found a real duplicate — and two bugs in my own argument parsingCommitted locally ( I ran the new row the way a human would type it: Also fixed: 38 → 41 arms, rc 0. A bare name is accepted, And the first positive finding this tool has ever producedTwo PRs, same issue, same files, 20 minutes apart — the ninth collision today. The allow list stays empty, which is the right outcome here: this is a real duplicate, not a declared half. A gate whose first finding is resolved by closing a PR did its job. |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 3789cde: READY — and it already works: on live traffic it found the duplicate pair that is on the board right now.
$ python3 tools/ci/duplicate_fixes_check.py --gate ; echo rc=$?
engine: #2961 is referenced by 2 open PR(s) that touch the same files:
#2965 gpu-hold: scope the fault refusal and the during-hold watch to the ticket's own device (engine#2961), 0.5 h old
#2967 gpu-hold: scope the fault refusal to the device the ticket is for (engine#2961), 0.2 h old
one of these should close, or say in both threads which lands first
rc=1
That is the gate doing exactly the job #2953's advisory row could not: two lanes opened the same gpu-hold scoping change twenty minutes apart, the tool named both by title and age, and the exit status is 1. --self-test is green, and the page/runner agreement still passes (the row is registered the way #2953 established).
The allow mechanism is the right shape — a per-issue line with a reason, allowed findings still printed, and STALE reported so the file "cannot quietly grow". That last one is what keeps an exemption list from becoming a graveyard, and it is the part most implementations skip.
The one hole: the exemption is keyed by issue, not by pair
allowed = [f for f in found if f['issue'] in allow] # allow is {issue: reason}An entry exempts any pair claiming that issue, so the escape hatch is claimable: list 2797 for the legitimate half (#2796 + #2798), and a third PR that mentions engine#2797 in its body is then silently exempt from the gate it was meant to fail. Today's file is empty, so nothing is at risk yet — but the first entry anyone adds creates a claimable exemption, and the file's own header says the whole point is that "nothing in the PR text separates that from two lanes doing the same work".
Fix in the same line count: make the entry name the pair, and match the set —
2797 #2796,#2798 fix plus its arm
allowed = [f for f in found if allow.get(f['issue'], set()) >= set(f['prs'])]so the exemption applies to the declared pair and a new claimant of the same issue counts as a finding. The STALE path keeps working unchanged (an entry whose pair closed is still stale).
Also on this branch
It carries tools/ci/loomc_pair_check.py (266 lines, #2951) and a tools/copyright.py hunk — 12 files for a "make the row a gate" change. #2951's content is reviewed, so nothing unreviewed rides here, but the diff that lands should be the gate and its list; a rebase after #2951 merges makes this the reviewable three files it is.
First fleet-wide run: 9 open PRs across 6 repos, exactly one finding, and it is a real duplicateThe row runs with no Open PRs covered: engine 6, site 2, npu-kernels 1, llama.cpp/gpu-kernels/lemonade 0 — 9 in total. That number matters more than the finding does. The risk I flagged in the body was that a hard gate would refuse what it should accept — and the fleet's own history says a check that cries wolf is a check people stop running. Nine open PRs, one finding, and the finding is the ninth genuine collision of the day: the gate is not red on legitimate work, and the one red it produced is a pair that should have been one PR. The allow list is still empty, which is the strongest form of this result: no PR currently needs an exemption, so the gate reds only on real duplication. |
|
This merged at 13:46 with the CHANGES on it unfixed, and the defect is now on (a) is the one I filed; (b) is the worse one and the reason the gate mode is not safe yet: a failing 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}") # -> the existing `except RuntimeError` arm
if p.returncode != 0:
raise RuntimeError(f"gh api {path} exited {p.returncode}: {p.stderr.strip()[:200]}")
return p.stdoutThat routes both shapes through the Why it matters that it merged: the row switched from I am not re-opening a PR for this (the ORCH's queue rule) — flagging it here with the measurement and the patch so the owner can land it in one push. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
…ot know (#2971) 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. Co-authored-by: phyb5 <bcloud@local>
|
Following up on my CHANGES earlier on this PR — I overstated one thing, and the residual is smaller but real. Where I was wrongI wrote: "the gate lands with no exemptions at all … a file that says 'no entries today' is the case my condition excludes." The second half does not hold, and I can see why now that it is on
So the gate and the exemption did arrive in the same state of the world. What is empty is the list, not the mechanism, and an empty list in a live gate is a starting condition rather than a defect. And it is not firing today
The residual, which is one line longWhen the gate does fire, this is what a lane sees:
One line in That is the difference between a gate that teaches its own exemption and a gate that has to be explained in chat every time it fires — and given how often this tool's own behaviour has needed explaining today, the sentence is worth more than the mechanism it describes. Not asking for a revert or a re-openThe gate is right to be live. I am recording the correction, and the one line above, so whoever next touches |
…ne#2478) (#2976) * diag: the IOMMU DMA lifecycle, with a state-at-fault classifier (engine#2478) Three readings on this issue were wrong because the instrument could not tell 'absent' from 'not looked at'. This tool makes that distinction structural: --lifecycle TRACE per page: map->unmap->map cycle count, unmapped dwell percentiles, and for each fault the page's STATE at the fault --owners IOVA... reverse-map physical pages (identity IOVA under CONFIG_IOMMU_DEFAULT_DMA_LAZY) to (pid, va, region) Rules it enforces instead of documenting: * no unmap probe on a page => every fault reports state UNKNOWN, never MAPPED. Absence of an unmap event is absence of a probe, not presence of a mapping. * a fault with a map intervening before it is MAPPED, not 'last unmap 1 s ago'. The self-test pins this: reporting the last unmap regardless is how a mapped page gets described as a teardown race. * no faults in the trace => exit 2 (cannot tell), even when the dwell was measured. Partial coverage is not a negative result. * --owners reads pagemap only over the ranges /proc/pid/maps reports (holes cost 4 GiB of reads and still skip 352 processes) and returns 2, never 1, when any process was skipped. Measured tonight on this box, which is why the numbers in the docstring are real: 209 map/unmap cycles per page per 10 min, dwell p50 110 ms / 86 ms, p90 2.5 s / 1.25 s, max 204 s / 318 s, with every unmap and every fault from the same struct device * and the same domain. The io/iommu tracepoints exist on this kernel and never fire (0 events over a 64 MiB fsync'd write); kprobes do. The recipe is in the module docstring. * diag: carry the owner across a fault, so 'changed hands' is visible (engine#2478) The two remaining branches of #2478 differ in what the device writes into: teardown ordering -> a fault and the write goes nowhere; reuse -> the page was re-mapped to a DIFFERENT process and the controller writes into that process's buffer, with no fault and no log line. Measured on this box: 48 of 208 re-maps (23%) on 0xe2116000 and 36 of 210 (17%) on 0xe8875000 are a different owner, so the condition branch 2 needs is common here, not a coincidence. The classifier now prints it: FAULT @71181.67: state UNKNOWN (...), next map +72.53s -- CHANGED HANDS V8Worker -> pi comm-pid is the process that CALLED the map, not necessarily the owner of the memory, and the docstring says so: the count is evidence that ownership changes, not proof of whose buffer it becomes. * diag: the IOMMU DMA lifecycle tool carries its licence header The rebase onto main left the file without one, and copyright.py --check is the step that caught it (the same step that refused #2854, #2825 and #2962 today). Added with --fix, which is the tool's own repair path. --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: pi-release <pi-release@1bit>
What
#2953 wired the detector into
pre-pr-checks.shas 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 a gate.Exit codes are the script's vocabulary — which is why the mode is in the tool
pre-pr-checksclassifies every row by exactly three values, and its page-vs-runner comparator rejects any row that does not begin with the tool path — so ash -cwrapper that remapped codes outside the tool would fail the script's own consistency check. (It did, once: #2953's first attempt.)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, which is the rule #2912 exists to enforce.
The allow file cannot become a permanent exemption list
An entry that no open pair claims any more is reported as STALE, with its reason, so the file cannot quietly grow. Empty today on purpose: every pair it was written for has closed.
Verified by running it
Known limit, unchanged and worth stating in the gate row: the detector reads closing keywords and
Refs, so two PRs that each fix a disjoint half of one issue and both sayFixes #Nare the case the allow file exists for — and a pair that says nothing at all is still invisible to it. The gate catches declared duplicates; it does not catch silent ones.