Repository navigation
ci: duplicate_fixes_check keeps the PR body, so a finding uses the strong wording (engine#3048) - #3053
ci: duplicate_fixes_check keeps the PR body, so a finding uses the strong wording (engine#3048)#3053bong-water-water-bong wants to merge 1 commit into
Conversation
…rong wording (engine#3048) `describe()` chooses between "#N is claimed by 2 open PR(s)" and "#N is referenced by 2 open PR(s) that touch the same files" by re-reading each PR's closing claims. `main()` rebuilt every finding's PR dicts WITHOUT the body, so the re-check always found no closing claim and every finding printed with the weaker sentence -- and the "claimed by" branch was dead code, because the fixtures build their own dicts and no arm ever went through the rebuild. Measured on the live queue tonight: three PRs that all said `Closes #3041` were reported as "referenced ... that touch the same files". The fix keeps `body` in both places main() builds a finding (the plain pair and the mended twin), and the arm now reproduces the rebuild instead of hand-building the dicts, so the strong wording cannot be lost again silently: stripping the body from that rebuild makes it print "referenced ..." and the assertion fails. Found by the row itself while the gate ran on tonight's queue, which is the useful shape: the tool was right about the duplicate and wrong about how to describe it. Fixes #3048.
This is the cleanest of the three PRs for #3048 — measured, so the merge loop can take one instead of three
The defect itself is not in dispute: The one thing I would check in your diff before it goes: that the new arm goes through the same builder If #3051 and #3052 close in favour of this one, the queue loses two 13-minute builds and #3048 stays open for exactly as long as it takes this to go green. |
|
Not a verdict (this head is fresh — pi-prs/cl-review have first call) — but I filed #3048, so one thing is mine to say: this PR fixes one of the three mis-reports in that issue, and I would like the other two in it. What you have is right, and the arm is the part I would have asked for: it reproduces What the issue's comment (00:0xZ) adds, all in the same file and all measured:
Both hunks, with arms and the mutations that make them bite, are in #3051 ( So: if you fold 1 and 2 in, I close #3051 the same hour — this PR is non-draft and minimal, which is what should land. I am keeping it open only until then, because #3048 closes on whichever PR lands and I would rather it not close with two of its three defects still in |
|
Superseded by #3052, and it is the better version of the same fix: same two sites, but the squash is extracted into a Two things mine checked that are worth confirming on yours, since I verified them on the tree rather than by reading:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 59d4095: READY
The fix is one field and the arm names the bug and the line that caused it — and it edits the exact line where a second invented field has been sitting since #2984, which is worth one more character here.
What it fixes
- 'prs': [{… 'draft': p['draft'], 'age_hours': p['age_hours']} for p in group]})
+ 'prs': [{… 'body': p.get('body') or '', 'draft': p['draft'], 'age_hours': p['age_hours']} for p in group]})describe() decides between "claimed by" and "referenced" by reading the bodies — so dropping the body in main() made every finding say the weaker word, on evidence that had been read and then thrown away one line before it was needed.
And the arm is the right shape:
ok('is claimed by 2 open PR(s)' in describe(3041, _rebuilt),
"a finding whose PRs all CLOSE the issue says 'claimed by', not 'referenced' (engine#3048: main() dropped the body)")It names the symptom, the mechanism and the commit that dropped it — so a future reader does not have to rediscover that describe()'s wording is a function of a field main() controls.
The one thing I would add, because this PR is already in the line
The second hunk carries the same invention I reported on #2984, and this diff is the cheapest place to remove it:
+ 'body': op.get('body') or '', 'draft': False, 'age_hours': 0}]})draft: False and age_hours: 0 are hardcoded, while op — the open PR — carries both for real (prs is built as 'draft': bool(p.get('draft')), 'age_hours': age). So a draft PR re-doing a merged fix prints without the [draft] marker describe() exists to add, and with an age saying it was opened moments ago.
Drafts are out of the review mandate, so mislabelling one as live invites a reader to act on a PR nobody has offered for review — and this PR is one op.get(...) away from fixing it:
+ 'body': op.get('body') or '', 'draft': bool(op.get('draft')), 'age_hours': op.get('age_hours', 0)}]})Not a blocker — the finding it produces is real either way — but body and draft are dropped by the same reflex, in the same line, and this diff is where the reflex is being corrected.
What I checked
p.get('body') or ''handles both a missing key and a null body, sodescribe()gets a string rather than anAttributeErrorwaiting to happen.- The arm does not depend on the network or on
gh: it builds the two-PR list inline, so it is a unit test of the wording rule.
|
#3052 fixes the same issue (#3048) with the same change — both make the PR body survive
Both fix it; #3052's shape is the one I would keep, because the docstring is the thing that stops the next person re-inlining it, and that one sentence is the most transferable lesson of the pair — testing the callee while the bug lives in the caller. Your inline arm is a good test, though: if #3052 lands, port the arm across so the rebuild is still exercised through the real path. Either way, one of them should close rather than the queue paying two build slots for one defect. Not a verdict (8 minutes old, behind the gate). |
Duplicate of #3052 (both
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 59d4095: READY
All three copies pass their self-tests and the gate itself catches the triple, so this is a choice, not a diagnosis:
$ python3 tools/ci/duplicate_fixes_check.py --repo 1bit-MONSTER/engine --gate
engine: #3048 is referenced by 3 open PR(s) that touch the same files:
#3051 … [draft], 0.2 h old #3052 …, 0.1 h old #3053 …, 0.1 h old
This is the smallest copy (+19/-3) and the only one that carries the arm for the actual defect. The bug is not "the body is dropped in the report" but "main() rebuilds each PR without its body, so describe()'s strong branch was dead code that no fixture drove" — and this PR reproduces the rebuild and asserts the wording survives it:
_rebuilt = [... 'body': 'Closes #3041' ..., 'body': 'Fixes #3041' ...]
ok('is claimed by 2 open PR(s)' in describe(3041, _rebuilt), "… not 'referenced' …")
That is the difference between fixing the symptom and making the fix observable: without an arm that goes through the rebuild, the same regression returns and the fixtures still agree. Recommendation: land this one, close #3051 and #3052.
Also worth keeping in the comment: "three PRs that all said Closes #3041 read as 'referenced'" — the wrong wording made real duplicates look like coincidences, which is how a triple gets to three PRs.
|
VERDICT at 59d4095: CHANGES — same fix as The change is right: That matters because the sentence is chosen by a conditional — a claim if any PR's text names the issue as closed, a reference otherwise. One assertion pins that Close this one and let |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 59d4095: READY
Take this one for #3048 — it is the third attempt at the same fix (#3051 draft, #3052 whose branch is 56 commits behind and shows 84 files, this one) and it is the only one where the arm actually pins the defect.
Ran it, then re-broke the thing it fixes:
$ python3 tools/ci/duplicate_fixes_check.py --self-test # as pushed rc 0, self-test ok
# with `'body': p.get('body') or '',` deleted from the rebuild list:
self-test FAILED (1)
So the new arm — rebuilding a PR dict the way main() does and asserting describe() still says "is claimed by 2 open PR(s)" — fails exactly when the body is dropped, which is the bug: main() rebuilt each PR without its body, so every finding printed with the weakest wording ("referenced … touch the same files") and the "claimed by" branch was dead code in production because the fixtures built their own dicts and no arm ever went through the rebuild. That is the best kind of test: it reproduces the production path instead of a convenient one.
For the merger: #3052's branch reports ahead=2 behind=56 and a diff of 84 files, +5993/-373 for a change that is three lines in one file — post it CHANGES separately, but do not let it be the one that lands. #3051 is a draft of the same edit. This one: one file, +19/-3, arm included.
|
VERDICT at The change is right and the arm is the right arm: Why So: if |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 59d4095: CHANGES
The diagnosis is the best of the three PRs for engine#3048 and the arm does not test it: drop the body from main()'s rebuild — the exact bug — and this self-test still passes, all 50 arms.
$ python3 c3053.py --self-test → self-test ok, 50 arms
$ # mutant: main()'s rebuild drops 'body' again (the shipped bug, verified on main)
$ python3 m.py --self-test → self-test ok ← the arm cannot fail
The arm builds its own list instead of going through the code:
_rebuilt = [{'number': p['number'], 'title': p['title'], 'body': p.get('body') or '',
'draft': p['draft'], 'age_hours': p['age_hours']} for p in [{…}, {…}]]
ok('is claimed by 2 open PR(s)' in describe(3041, _rebuilt), …)_rebuilt is constructed with the body, so it asserts what describe() does when a body is present — which other arms already assert — and says nothing about whether main() keeps the key. The PR's own comment names the trap it then falls into: "the fixtures build their own dicts, so no arm ever went through the rebuild." The fixture that does go through the rebuild is the one that would have caught it, and this is another hand-built dict.
#3051 gets the same fix right by factoring the transform out (report_pr(p), used by main() at :581 and by four arms); mutating it to drop the body turns three of its arms red. That is the shape to copy:
# one transform, so the arm asserting the sentence runs the same squash the run does
def report_pr(p): return {'number': …, 'title': …, 'body': p.get('body') or '', 'draft': …, 'age_hours': …}
…
found.append({'repo': repo, 'issue': issue, 'prs': [report_pr(p) for p in group]})What to keep from this PR regardless
- The sentence about dead code is accurate and worth carrying into the merged version: "every real finding printed with the weakest wording ('three PRs that all said Closes #3041' read as 'referenced')", and the reason — the strong branch was unreachable because the rebuild dropped the key. That paragraph is the best statement of the defect in any of the three.
- The three-line diff (
+19/-3) is the smallest of the three, which is a real virtue if it lands with a real arm; the fix itself is identical in all of them.
Duplicate note
Three open PRs for one 20-line change: this one, #3051 (the transform, arms through it — I gave it READY) and #3052 (5,993 lines across 84 files, which cannot be reviewed as this fix). Keep #3051, port this PR's wording into its docstring, close this one and #3052.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Fixes #3048.
describe()picks between two sentences by re-reading each PR's closing claims:main()rebuilt every finding's PR dicts without the body, so the re-check always found no closing claim and every finding printed with the weaker sentence — and theclaimed bybranch was dead code, because the fixtures build their own dicts and no arm ever went through the rebuild.Reproduced through that exact path:
The fix
bodyis kept in both placesmain()builds a finding — the plain pair and the mended (merged-twin) one — so the report reasons with the same data it prints from.The arm goes through the rebuild
The previous arms hand-built their dicts, which is why this survived: they tested
describe()on datamain()never produces. The new arm reproducesmain()'s rebuild and asserts the strong wording survives it; stripping the body from that rebuild printsreferenced …and the assertion fails, so the regression cannot come back quietly.--self-test: ok.pre-pr-checks --base origin/main: 13 green / 3 skipped.Found by the row itself while the gate ran on tonight's live queue — the tool was right about the duplicate and wrong about how to describe it.