Idea: a CI check for comment slop (a "handicap" that lets any contributor ship a clean diff) #2685
Replies: 3 comments 3 replies
|
How about a pre-commit rule and then flagging pre-commit in CI? Would that work? |
|
Put it up as #2689. Two things came out of building it that are worth flagging here rather than on the PR:
|
|
Splitting this into two pieces, with an off-ramp for the second. Phase 1 — the flagger (#2689). The deterministic slop check + pre-commit hook + CI job, the shape you proposed, @superm1. It fires on every commit and every PR. A wrong flag costs a contributor a few minutes; nothing merges on its say-so. Worth landing now. Phase 2 — The gap it closes is already open here. There's a PR on this repo right now whose description says it removes a WHAT-comment, while its diff is +6/−0: it removes no comment and adds an executable guard. Honest branch drift, caught because someone read the diff. But "the description and the diff disagree" is exactly what nobody re-reads a diff to check, and it's one command to verify mechanically. Why they're separate: adversarial review has found fifteen distinct ways a code change could slip past the assertion as "comments only" — an indentation shift; a shebang flipped to The off-ramp. A checker that can be fooled may be worse than none, because it manufactures false confidence. That isn't hypothetical: the first version of this proof stripped It's up now, while still being hardened, and rounds are still running. I'm not asking anyone to merge it until an independent round comes back empty. The upside is the handicap framing I opened with. The label is for contributors who haven't earned your trust yet — a newcomer, or an AI-assisted one — whose "just a comment cleanup" claim you'd otherwise verify by reading the whole diff. Apply the label and CI verifies it in one pass: O(1) instead of O(diff). And they graduate out of it: a contributor whose cleanups you merge on sight, you just merge. Phase 1 stands on its own if you'd rather stop there. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Following on from a Discord thread with @superm1 and @fl0rianr, who both independently
flagged the same thing on my recent PRs: too many comments, too extensive, the same idea
re-explained several times over.
They're right, and I don't think it's a me problem — I think it's a structural one that's
going to get more common, so it may be worth a mechanical answer rather than repeated
reviewer patience.
The problem
AGENTS.md already states the rule plainly: default to no comments; only explain a
non-obvious WHY; never write WHAT-comments. The rule isn't missing. It's just not
enforced, and in practice it gets read and then ignored — especially by AI-assisted
contributors, where verbosity is the default failure mode.
The cost lands on maintainers, who end up either reading past it or fixing it at merge.
What I found when I actually measured it
I cleaned up my three open PRs as a sample set. In every single case the problem was not
one over-written comment — it was one concept explained four or five times in different
places:
In #2588, the rationale for one flag (
--enforce-eager) was restated in five separateplaces. In #1536, a 25-line block comment in the source turned out to be the PR description
pasted into the code.
The bit that makes this safe to automate
A comment cleanup changes no code, and that is mechanically provable, not a promise:
I ran exactly that check on all three PRs before pushing. It's what let @fl0rianr say
"if you only changed comments you can merge" without re-reviewing the diff. Cheap,
deterministic, no judgement involved.
Proposal: a check, not a rewriter
I'd start with something non-destructive and deterministic — it never edits anyone's code:
threshold.
actual root cause in all three of my PRs, and it's the one a human reviewer notices
and resents).
(the check above). Makes those trivially re-approvable.
Deliberately not proposing that CI rewrite anyone's diff. That would mean a
nondeterministic rewriter touching contributor code, and the commit would no longer be what
the author signed. The rewriting belongs author-side — a local hook the human reviews and
accepts, the same way I did this by hand.
The stripped prose isn't worthless, it's just misplaced: it belongs in the PR description or
a discussion thread, where depth is welcome and readers opt in.
Honest problems
whole-diff context ("this is already explained at a better seam"). A check can flag;
it shouldn't decide.
the slop it removed. Which is another argument for warn-not-mutate.
they've been calibrated against real PRs.
Questions
never reaches a reviewer at all?
more than that?
to what actually annoyed people, but it's also the hardest to compute well.
Happy to build the MVP if there's appetite — @superm1 said to go ahead if it's feasible, and
I think the warn-only version clearly is.
All reactions