mirror of
https://github.com/Comfy-Org/github-workflows.git
synced 2026-11-05 00:17:37 +00:00
[PR #196] [MERGED] fix(pr-size): require a rename's SOURCE to be linguist-generated too (BE-8137) #205
Labels
No labels
cursor-review-catalog-drift
groom
groom
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/github-workflows#205
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/github-workflows/pull/196
Author: @mattmillerai
Created: 8/20/2026
Status: ✅ Merged
Merged: 8/20/2026
Merged by: @mattmillerai
Base:
main← Head:matt/be-8137-rename-source-linguist-generated📝 Commits (2)
2b2d253fix(pr-size): require a rename's SOURCE to be linguist-generated too (BE-8137)76bf67afix(pr-size): pair renames in annotateDiscounts so the guard isn't cancelled (BE-8137)📊 Changes
2 files changed (+211 additions, -4 deletions)
View changed files
📝
scripts/check-pr-size/main.go(+54 -4)📝
scripts/check-pr-size/main_test.go(+157 -0)📄 Description
ELI-5
The PR-size checker decides which files are "generated" so they skip both the line count and the review panel's patch. For a renamed file it asked "is the file's NEW path marked
linguist-generated?" and nothing else. So you couldgit mva hand-written file into a generated tree, edit it in the same commit, and the edit became invisible — it counted zero lines and never reached the reviewers. The three exclusion buckets sitting on the lines right next to it already asked about the OLD path too; this one just didn't. Now it does.What changed
classify()inscripts/check-pr-size/main.go, two edits:git check-attrlookup now resolves a rename'sOldPathas well as itsPath, so the source path's attribute is actually available.attrGen[f.Path] && (f.OldPath == "" || attrGen[f.OldPath]), mirroring theIsTestPath/IsLockfile/extras.Generatedconjuncts immediately above it.The
classify()header comment's "a RENAME is classified on BOTH its old and new path for every exclusion bucket" list now names the attribute bucket, and spells out that this bucket's hole costs the reviewed diff as well as the count.Chesterton's Fence
The destination-only form was an omission, not a design choice.
git log -Lon those lines lands onab2066a(fix(pr-size): close the rename bypass on lockfiles too), which introduced thelockfileandextraGenboth-paths conjuncts in exactly thisifand leftattrGen[f.Path]bare on the line between them. The change is also strictly narrowing — every case it newly declines to exclude gets counted and reviewed, never the reverse — so the failure direction stays the safe one. The base-ref invariant is untouched:attrGeneratedBatchstill resolves viagit check-attr -z --stdin --source <base>, which works for arbitrary path strings whether or not they exist at that ref, and a rename's source path does exist there.Test
TestClassifyRenameIntoAttrGeneratedTreeStillCounts(new,main_test.go) builds a throwaway repo whose base carriesgen/** linguist-generated=true, then in one head commit renames a hand-written file intogen/with an injected edit and renames a genuinely generated file withingen/. It asserts, in that order: rename detection actually fired (OldPathis the source), the moved hand-written file is NOTGenerated, the intra-gen/rename still IS,Evaluatecounts the injected line, the injected marker appears in the--reviewed-diff-outpatch, and the generated rename does not.I falsified the test three ways against the unfixed code before trusting it — reverting the
attrGenOKconjunct alone, reverting theOldPathbatch-lookup alone, and reverting both. Each revert fails the assertion it is supposed to guard, and reverting both reproduces the ticket's reported numbers exactly:Counted = 0, everything excluded, zero occurrences of the injected marker in the reviewed diff (0 file section(s) kept, 2 generated section(s) excluded). TheOldPathbatch-lookup edit is load-bearing on its own: without itattrGen[f.OldPath]is always false and legitimate moves inside a generated tree would start counting.Sweep of the buckets this PR does NOT change
classify()makes five rename-sensitive decisions. Four were already sound and I left them alone:f.Test,lockfileandextraGencarry the explicit both-paths conjunct, and the content-marker bucket fails closed on renames by construction. I probed that last one rather than reasoning about it, since it was the only non-obvious case — withmarkerFromBaseset it readsbase:<destination>, which for a true rename does not exist, so it returns false and the file is counted. Review sharpened this: the fail-closed behavior holds only under--marker-from-base, which the sole--reviewed-diff-outcall site (cursor-review.yml:672) does pass. Without the flag the head read can be self-marked — but that reduces to pasting the marker in place, needs no rename, and is the already-documented count-only tradeoff, so the bucket stays destination-only with the reasoning now written down. The adjacent worry (moving a hand-written.goon top of a file that was generated at base) is not a rename at all: git reports it as a separate modify plus delete with an emptyOldPath, so the hand-written deletions stay booked against their own non-generated path and still count. One hole out of five, and it is the one fixed here.Propagation
None by hand.
main.gois inside thescripts/check-pr-size/**path filter of bothbump-cursor-review-callers.ymlandbump-pr-size-callers.yml, so merging fans SHA-bump PRs to the pinned callers automatically. Themain_test.gohalf is stripped by the:(exclude)scripts/check-pr-size/*_test.gonegation, which only strips the paths it matches — the non-test change still triggers the bump. No consumer'sci-cursor-review.ymlpin is touched in this PR.Judgment calls and unexercised artifacts
initTestRepo(main_test.go) does not pin the throwaway repo's initial branch, so it inherits the host'sinit.defaultBranch. On any machine where that ismain,TestResolveMergeBaseWithAdvancedBaseBranchfails withfatal: a branch named 'main' already exists— pre-existing on the base commit, unrelated to this change, and invisible in CI because the runner's git still defaults tomaster. I did not fix it: it means touching an unrelated test, and this diff is scoped to the reported defect. Because it is an unfixed defect on a file the ticket names, the reference below isRefs, notCloses.couldn't find remote ref), so I confirmed the bareattrGen[f.Path] ||form on the currentorigin/maintip instead, where it was still present. The private consumer-repo PR the original reproduction ran against is in another repository and out of bounds for this change; nothing here relies on it, since the repro is reproduced in-repo by the new test. The tracking ticket's own thread and any linked material were not readable from this environment.full-autonomyis deliberately absent: the source ticket does not carry it, and the label does not exist on this repo.Review round
The panel raised 5 findings; 3 were fixed and 2 documented as residuals (
76bf67a).The one that mattered — the fix was being cancelled downstream.
annotateDiscountsbuilt its patch with a pathspec naming only the DESTINATION, so git could not pair a rename and re-emitted it as a whole-file addition. Every blank/comment line then became a discount and thed > Changed()clamp droveCounted()to 0. I reproduced it end to end before touching anything: withPR_SIZE_IGNORE_COMMENTS=1(whichcursor-review'signore_commentsinput feeds),git mv handwritten/big.go gen/big.goplus a one-line edit reportedCounted = 0— i.e. the count half of this PR's guard was fully nullified for that caller. It now passesOldPathas an extra pathspec, mirroring the check-attr change, and the same run reportsCounted = 1. Discounts stay keyed by destination, so an unpaired old-path section finds no entry and the file counts raw.Test hardening. The two base files in the new attribute test were byte-identical, leaving
gen/keep2.json's exact-rename pairing to git's hashmap tie-break — it could have paired with the hand-written source and inverted bothOldPathassertions. They now carry distinct bodies. Separately thecheck-attr --sourceprobe ran beforet.Chdir, wherebaseis not a valid object; the helper reports that class of failure as supported, so the skip could never fire and an old-git runner would have died onkept.Generatedwith a misleading message. Probe moved after the chdir.Documented, not changed. The content-marker bucket is destination-only by design (fails closed under
--marker-from-base; without it a rename grants nothing an in-place marker paste does not). And the both-paths rule inherits whatever pairing git chooses, which a same-content generated file planted at base can bias — aKNOWN LIMITparagraph onclassifynow records it. Neither is reachable as a new defect under any current caller, so neither got a follow-up ticket.Refs BE-8137
Provenance
gofmt -l .clean;go vet ./...clean;cd scripts/check-pr-size && go test ./...— ok, 0 failures (run with a neutralGIT_CONFIG_GLOBAL, see the out-of-scope note above). Falsification: the original fix reverted three ways (each partial revert fails the assertion it guards), and the newTestAnnotateDiscountsPairsRenamesSoTheEditStillCountsre-run against the revertedannotateDiscountschange, which fails withDiscounted = 1, want 0andCounted = 0, want 1. Both the original defect and the discount cancellation were also reproduced end to end through the built binary against a throwaway repo, before and after each fix.classify()edits, the header-comment update, and the test are implemented. The review round then added one behavior fix outside the original plan (annotateDiscountsrename pairing), taken on because it silently cancelled this PR's own fix rather than being adjacent cleanup. Two review findings were answered with documentation rather than code, each with the reasoning on its thread. The unrelatedinitTestRepobranch-name fragility described above remains a deliberate omission.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.