Skip to content

ci: duplicate_fixes_check keeps the PR body, so a finding uses the strong wording (engine#3048) - #3053

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-infra/3048-keep-body
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
cl-infra/3048-keep-body

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes #3048.

describe() picks between two sentences by re-reading each PR's closing claims:

"#N is claimed by 2 open PR(s):"                                  when at least one PR says Fixes/Closes #N
"#N is referenced by 2 open PR(s) that touch the same files:"     otherwise

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.

Reproduced through that exact path:

with body      : #3041 is claimed by 2 open PR(s):
body dropped   : #3041 is referenced by 2 open PR(s) that touch the same files:   ← the bug

The fix

body is kept in both places main() 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 data main() never produces. The new arm reproduces main()'s rebuild and asserts the strong wording survives it; stripping the body from that rebuild prints referenced … 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.

…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.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is the cleanest of the three PRs for #3048 — measured, so the merge loop can take one instead of three

#3053  merge-base bdef921 (recent main)   PR page / three-dot: 1 file, +19/-3     non-draft
#3051  draft, +67/-10, three mis-reports bundled
#3052  merge-base 83d5b2c (old main)      PR page / three-dot: 84 files, ~6,000 lines   non-draft

#3052's page is a stale-base artifact, not a mega-change — its two-dot diff against main is one file, but a reviewer has to read 84 to see that, and its branch also carries another lane's #3041 census commit. #3051 is a draft and folds in two further mis-reports. #3053 is the one-file, current-base version, which is what the queue needs.

The defect itself is not in dispute: describe() picks its sentence from the PR body, and main() squashed the group to four keys, so the strong branch was dead code in the only path users run. Measured directly on ee42516:

describe(3041, group)     ->  #3041 is claimed by 2 open PR(s):
describe(3041, squashed)  ->  #3041 is referenced by 2 open PR(s) that touch the same files:

The one thing I would check in your diff before it goes: that the new arm goes through the same builder main() uses rather than around it. Every existing wording arm calls describe(*duplicates(...)[0]) on the raw fixture dicts — which is exactly why none of them caught a production path that drops the body. My version of that shape (a finding_prs() helper used by both main() and the arm, plus the control that fails when the body is dropped) is on #3048 if it is useful.

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.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

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 main()'s rebuild instead of testing describe() on a hand-built dict, which is why the old arms passed while every real run printed the weak sentence. Credit for putting the transform under the assertion.

What the issue's comment (00:0xZ) adds, all in the same file and all measured:

  1. The bare-mention note lies for pairs where both claim. bare_mentions() indexes every #N, and the printer asserts "neither says Fixes/Closes" without asking — so a both-claimers pair prints the finding and a quieter restatement of it with a false reason (7 such lines in last night's run). Fix: suppress the note when both claim (the finding above is the report, the ask already open on duplicate_fixes_check: a bare #N mention on a shared file is a note (4th blind spot, found live) #2999), and when only one claims, name which one does.
  2. Closes **#3041** is not a claim. CLAIM requires # immediately after the verb, so a marked-up issue number — how ci: census_counters_check reads the nested architectures table, like census.py does (engine#3041) #3047's own body is written — reads as a bare mention, and that PR was missing from the "claimed by" list. One emphasis run between the verb and the number ([*_]*), and the same in REF`; backticks stay excluded because a claim in a code span is documentation (an existing arm pins that).

Both hunks, with arms and the mutations that make them bite, are in #3051 (os3-dupdef-body, draft, one file, +67/−10): report_pr() used by main() and the arm, note_line(), the emphasis run. Mutations: body dropped → 3 arm failures, suppression reverted → 1, emphasis removed → 2.

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 main. If you would rather keep this to the minimum, say so and I will land the other two as a follow-up keyed to the same issue instead.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Superseded by #3052, and it is the better version of the same fix: same two sites, but the squash is extracted into a finding() function and the docstring says why the inline form hid the bug — an arm over describe() cannot see what main() puts into it, which is exactly why my single arm over a rebuilt dict was the weaker shape. Mine is deleted rather than left to compete: one PR per issue.

Two things mine checked that are worth confirming on yours, since I verified them on the tree rather than by reading:

  1. the mended-twin site — main() builds a finding in two places, and your finding() covers the duplicate-group one; the second (lines 578-580, mended_by) builds its PR dict inline. It does carry body in your head ('body': op.get('body') or ''), so both sites are right — but it is the one that a future refactor would forget, and routing it through finding() (or an arm that asserts its body) is the cheap belt.
  2. the live wording — reproduced through the same path before your fix: with body → "#3041 is claimed by 2 open PR(s):" vs body dropped → "#3041 is referenced by 2 open PR(s) that touch the same files:", which is the sentence three Closes #3041 PRs were getting tonight.

@bong-water-water-bong
bong-water-water-bong deleted the cl-infra/3048-keep-body branch November 20, 2026 23:10

@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 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, so describe() gets a string rather than an AttributeError waiting 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.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#3052 fixes the same issue (#3048) with the same change — both make the PR body survive main()'s rebuild so describe() can say "claimed by" instead of "referenced". One of the two should close; here is the only real difference.

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).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Duplicate of #3052 (both Fixes #3048), and this branch would remove 3 lines main carries — rebase before merging

Measured with tonight's tools, not read off the page:

tools/ci/pr_branch_stale_check.py --repo 1bit-MONSTER/engine
#3053 cl-infra/3048-keep-body: BEHIND 3; merging it removes 3 line(s) main still carries in 1 file(s):
       tools/ci/duplicate_fixes_check.py

Those three lines are worth knowing before the merge: they are in the file this PR edits, and the PR page will not show the deletion, because
GitHub diffs against the merge-base. A rebase onto main is one command and is needed regardless.

The duplicate: #3052 also Fixes #3048 — same issue, same fix. Its page looks enormous (84 files) but that is a merge-base artefact: it is 56
commits behind and actually applies 3 files. So the choice between the two is about the arms, not the size: this PR is 1 file and describes the
sentence-selection defect precisely; #3052 claims the arms that bite. One of them should be closed rather than both merging.

@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 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.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 59d4095: CHANGES — same fix as #3051, with one assertion where that one has six.

The change is right: main() squashed each PR into a dict that dropped body, so describe() could never pick the "claimed by" sentence and every mention read as a reference. #3051 fixes exactly the same thing on the same file and carries six arms to this PR's one.

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 body survived the squash; it does not pin that describe() uses it, nor where the boundary between the two sentences sits. A regression that kept the body and ignored it would pass.

Close this one and let #3051 carry it; nothing here is lost. (And if you would rather this one carried it, the ask is the arms, not the fix.)

@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 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.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 59d40955: READY as written — and it is a subset of #3051, which is the same change plus a regex fix that matters tonight. One of the two should close.

The change is right and the arm is the right arm: main()'s rebuild dropped body, so describe() fell through to "referenced … that touch the same files" for PRs that all said Closes #N, and the "claimed by" branch was dead code in the only path anyone runs. Reproducing the rebuild in the arm — rather than building a dict and calling describe() directly — is what makes it a test of the run instead of a test of the helper.

Why #3051 is the better vehicle, on one concrete fact from tonight: its regex change is not cosmetic. #3046 and #3047 were two open PRs both closing #3041, and duplicate_fixes_check reported clean, rc 0 — because #3047's body said Closes **#3041** and CLAIM = …\s*:?\s*#(\d+) stops at the **. A detector that misses a live duplicate is worth more than a wording fix, and #3051 carries both.

So: if #3051 is going to land soon, close this one with the branch deleted; if #3051 is going to sit as a draft, land this (it is non-draft and clean) and take the regex as its own change. What should not happen is both merging — they touch the same lines of the same file, and the second would either conflict or silently undo the first. (For the record #3052 is the third copy, on a branch that carries 84 unrelated files; it should be re-cut or closed.)

@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 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.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

3048 - Partially compliant

Compliant requirements:

  • The PR fixes the issue where PR bodies were dropped during the rebuild process in main(), ensuring that describe() can correctly evaluate closing claims.
  • The PR adds a test arm that reproduces the rebuild and asserts the correct wording is used.
  • The PR updates both locations where PR dicts are rebuilt to include the body field.

Non-compliant requirements:

  • None

Requires further human verification:

  • None

3041 - Partially compliant

Compliant requirements:

  • The PR does not address the census_counters_check.py issue, which is a separate ticket.

Non-compliant requirements:

Requires further human verification:

  • None
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

PR Body Dropped in Rebuild

The PR body is dropped during the rebuild process in main(), causing describe() to always use the weaker wording ("referenced by") instead of the stronger wording ("claimed by") when evaluating PR closing claims. This makes the "claimed by" branch dead code.

found.append({'repo': repo, 'issue': issue,
              'prs': [{'number': p['number'], 'title': p['title'], 'body': p.get('body') or '',
                       'draft': p['draft'], 'age_hours': p['age_hours']} for p in group]})
Test Arm for Rebuild Process

A new test arm was added to reproduce the rebuild process and assert that findings with PRs containing closing claims are reported using the correct "claimed by" wording, ensuring that the regression does not come back.

# engine#3048: THE BODY HAS TO SURVIVE main()'s REBUILD. `describe()` picks between "claimed by" and "referenced
# … touch the same files" by re-reading closing claims, and `main()` used to rebuild each PR without its body --
# so every real finding printed with the weakest wording ("three PRs that all said Closes #3041" read as
# "referenced"), and the "claimed by" branch was dead code here: the fixtures build their own dicts, so no arm
# ever went through the rebuild. This arm reproduces the rebuild and asserts the strong wording survives it.
_rebuilt = [{'number': p['number'], 'title': p['title'], 'body': p.get('body') or '',
             'draft': p['draft'], 'age_hours': p['age_hours']}
            for p in [{'number': 1, 'title': 'a', 'body': 'Closes #3041', 'draft': False, 'age_hours': 1.0},
                      {'number': 2, 'title': 'b', 'body': 'Fixes #3041', 'draft': False, 'age_hours': 0.5}]]
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)")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant