Repository navigation
Refuse a Comment Line a Change Adds, Unless the Pull Request Says It Is Wanted - #1662
Conversation
…Is Wanted Two weeks of fleet review rounds put 8% of every bot finding, 117 of 1437, on agent-written comment text, and #1631's decision item 2 is the gate that removes the surface rather than the findings one at a time. `comment-added` joins DEFAULT_RULES. It reports every prose comment line in code or config, and the diff scope main already applies is what turns that into the comments a change adds. Without --diff there is nothing to tell an added comment from one the tree already held, so the rule stands down and says so on stderr rather than reporting the repository's every comment. The override is a deliberate act on one change, and there are two of them because the moments differ. Locally PROSE_ALLOW_COMMENTS reaches the pre-commit hook, and in CI the prose-gate action passes --allow-comments when the pull request carries the `comments` label the fleet label set now declares. Setting the local one by habit therefore fails CI instead of passing quietly. A directive, a bare URI and a key are exempt, by the same filters comment-wrap already applies, since deleting a `# noqa` changes what the file does. A docstring is not a comment line, and Markdown is out of scope, its prose being the document rather than a comment on one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The local review pass found the rule's own contract false. `git diff --unified=0` reports a modified line as an added one, so the added lines alone cannot tell a comment this change wrote from one it merely sat beside. Editing the code on a line carrying a trailing comment, re-indenting a commented block, and moving one each reported the comment as added, and the remedy the finding offered was deleting a comment the change had not written. `held_comment_bodies` reads the file at the diff's base and exempts a comment body it already carried, whitespace collapsed so a re-indent compares equal. A file the base did not hold gets an empty set, since every comment in a new file is one the change brings. Five more from the same pass: - One unbalanced ``` line in a code or config file silenced the rule to end of file, a silent bypass of a refusing gate. A fence is a Markdown construct and Markdown is out of scope, so the fence skip is gone. - A `.py` that does not tokenize fell back to the hash-anchored scan, which has no string model and read a `#` inside a docstring as a comment. It now stands down for that file. - `.md` was matched case-insensitively and `.py` was not, so a `Foo.PY` on a case-insensitive filesystem took that same fallback. - `NOT_PROSE` did not name the parser directives the docstring promised were exempt, so `# syntax=`, `# fmt: off`, `# pragma:`, `# nosec`, `# renovate:` and their kind were reported with deletion as the first remedy. - The escape is read from the environment rather than passed by each caller. The two downstream hook snippets run this file straight from the hub, and one is a single command string with nowhere to put a flag, so a caller-side escape would have refused their commits with no escape at all. The composite action clears the variable, so in CI the label decides and a runner cannot. The docs stated two things the mechanism could not: that CI gates with the whole-tree lists in OPERATIONS.md, which it never has, and that the variable stands the rule down for one commit, which it does for as long as it is set. Both corrected, with the label's own two ordering facts stated beside them: it reaches a repository through the fleet label set rather than through this change, and CI reads it off the event that started the run, so a label added after a failing run applies to the next push rather than to a re-run. Two findings are pre-existing behavior this rule only sharpens, filed as #1657 and #1658 rather than fixed here. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… to Widen a Third The second review pass found the first round's own fixes had defects. The worst was the exemption list. Adding the parser directives to `NOT_PROSE` reached `comment-wrap` and `comment-case` too, since all three rules share that pattern, so both silently stopped reporting any comment that merely named one of the words. Measured: `# hadolint is run by docker_lint.py. It reads the whole tree.` lost two findings it had before. The directives move to `TOOL_DIRECTIVE`, anchored at the body's start and read by the new rule alone. The rule now answers on growth. A file's prose comment lines have to outnumber the ones the base held, and the reported line's own text has to appear more often than the base carried it. Matching on membership alone got two cases wrong in opposite directions: rewording a comment, which every correction of a stale one is, reported it with deletion as the remedy, putting the gate against the rule that a comment states what is true; and any number of copies of a comment the file already held arrived unreported. `held_comment_counts` also separates the two answers its predecessor collapsed. A base that does not hold the file at all is an empty count, so a new file's comments are all reported. A base that holds it and whose comments cannot be read is `None`, and the rule stands down, since a branch repairing a `.py` that did not tokenize otherwise reported every comment it already had. Three test defects, each a case that would have passed with its behavior reverted. The two docstring fixtures were one line short of the shape they named, a single-line string being modeled by both extraction paths, so neither proved the guard it was written for, and a third case asserts that premise directly now. And the no-diff stand-down case failed for any developer who had taken the docs' own advice and exported `PROSE_ALLOW_COMMENTS`, so it clears the variable. The prose: OPERATIONS.md said CI gates with the whole-tree lists in its own block, which it never has, and three unchanged sentences in that section said so too. scripts/README.md carried a causal clause that #1631 disproved, that a review round argues about comments rather than fixing code, where the finding was that most comment findings are real and the surface is what earns removing. The action's log line claimed a label it cannot observe. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…Report Every Line a Surplus Body Sits On The third pass found the rule not firing on this branch's own diff. The head side counted prose comments and the held side counted every comment, so a file's own directives and version pins bought free prose. Measured here: `validate-task.yml` holds 85 comments at base of which 72 are prose, against 74 prose at head, so the two comment lines this change adds to it compared 74 against 85 and reported nothing. Up to 11 more could have arrived the same way. The held side is filtered by the same test now, and those two lines report. `held_comment_counts` reads the base at the path the content had there, from the rename map `git diff --name-status --find-renames -z` gives, so a `git mv` plus an edit on a commented line no longer reports a comment the change did not write. That was the same false positive the base read was added to close, kept alive by keying on the head path. A surplus body is reported at every line holding it, rather than at one line chosen from them. Choosing cannot work: attributing the surplus to a body's last line loses a copy inserted above the held one, and to its first line loses a copy inserted below, because each time the chosen line is the one the diff did not touch and the scope filter drops it. The two cases are both covered now, and each one failed against the other's attribution. An `OSError` from `git show`, which is git not being runnable at all, now answers `None` rather than an empty count. Read as an empty count it meant "the base held no comments", so every comment in every file would have been reported. `TOOL_DIRECTIVE` gains `fmt: skip`, `pyright:`, `isort:`, `nopep8`, `codespell:` and `doctest:`, each a directive whose deletion changes what the file does and each reported with deletion as the first remedy before this. Four prose corrections. Two claims rested on the unfiltered compare and are true now rather than aspirational. `scripts/README.md` said CI's whole-tree run backs the hook's wider scope and that CI gates every default rule except `charset-unknown`, both of which the corrected OPERATIONS.md text contradicts. And OPERATIONS.md named two overrides where there are three, omitting the one a local operator would actually reach for. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…Passes Could Not Settle The rule inferred whether a change had authored a comment, from a diff that cannot say. Four review passes went into that inference and found 64 defects, each round's fixes writing the next round's findings: the base read, then the rename map it needed, then the multiset the duplicate case needed, then the prose filter the count needed, and a documentation that came out false after every one of them because the behavior had become hard to state. The inference is gone. The rule reports every prose comment line in the diff's scope, which is what #1631 decided in the first place. `git diff --unified=0` counts a modified line as an added one, so editing the code on a line carrying a trailing comment, re-indenting a commented block, and rewording a comment each report that comment. That is the cost, it is stated where the rule is stated, and the label is the answer, since a comment worth keeping takes the same label as a comment worth writing. 130 lines of `prose_lint.py` and 161 of its tests go with it: `renamed_from`, `held_comment_counts`, the surplus counting, and every case that drove them. What stays is the whole-file read, the diff scope `main` already applies, the `.py` tokenize guard, the Markdown and directive exemptions, and the three announced stand-downs. Three stale claims the passes found, each on a surface this branch had already corrected elsewhere. `GOVERNANCE.md` was the third surface saying CI re-checks the whole tree, which is what made the hook's wider scope affordable, and CI has no such run. `.husky/pre-commit` kept the same sentence's shape after its premise was deleted. And `OPERATIONS.md` said no invocation below names `comment-added`, which is true of the `--check` block and not of the scoped invocation under it, the one a developer actually meets the rule in. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…top Three Assertions Passing on a Substring
The simplification cut 161 lines of tests with the design they covered, and two
of them covered something it did not delete. Measured by mutation: replacing
`by_env` with `False`, which deletes the whole `PROSE_ALLOW_COMMENTS`
stand-down, passed all 1489 tests, and so did deleting the action's
`unset PROSE_ALLOW_COMMENTS`. The first is the only local escape there is, and
the second is what stops an organization-level environment disarming the gate on
every pull request while the run exits 0. Both cases are back, and each now
fails against its own mutation.
Three assertions passed on a substring of the text they were checking.
`assertIn("comments", message)` matched the closing clause "whose comments are
wanted" rather than the label, and `assertIn("comments", note)` matched
`--allow-comments` on the same line, so a message naming no label at all passed
both. They compare the quoted name the message builds from the constant now, and
a message that drops it fails.
One finding per line rather than one per comment. A line can carry two, and
`extracted_comments` yields one entry per marker, so `/* a */ x = 1; /* b */`
reported the same line twice and counted it as two violations.
`test_the_suffix_tests_agree_on_case` claimed an agreement the file does not
have, since `comment_wrap_findings` still reads the suffix case-sensitively. It
is renamed to what it covers, and the mismatch is filed rather than fixed here.
Two prose corrections. `scripts/README.md` was the fourth surface saying the CI
gate reads the whole tree, which the same file now contradicts 46 lines above.
And the replacement for that claim on the other three surfaces was false in the
other direction: a hook run reads one commit's working tree, while the pull
request gate reads every line the branch changes against its base, so it does
back up a commit no hook ran on. `repo-config/README.md` closed its label
taxonomy with a sentence that covered every label except the new one, which is
also the only label that changes a gate's verdict rather than describing work.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…dge a Directive by Its Argument Three shapes that reach a fleet repository before any feature branch does, each of which the rule refused. A pull request targeting the default branch is a promotion, and it diffs against that branch's tip, so its scope is every line promoted since the last one. Run here against `origin/main`, which is hours behind `develop`, the rule reports 28 comment lines that were already reviewed where they landed; a real promotion carries a release of them. `validate-task.yml` stands the rule down there, which keeps the label meaning what it says on the pull requests where a comment actually arrives. The version-pin exemption was `^v\d+(\.\d+)*$`, and the fleet writes a hub pin bare: `# 2.0.338` was reported and `# v7.0.1` was not, so bumping a pin, a routine resync edit in every fleet repository, failed the gate. A Dependabot pull request cannot label itself, so that blocked the merge-bot path outright. A prerelease suffix failed the same way. `TOOL_DIRECTIVE` matched a prefix and ignored the rest of the body, so `# nosec The value is read once, since the second read can disagree.` exempted the whole sentence. A directive is judged by what follows its name now: an argument does not close as a sentence does, so a body that ends in sentence punctuation is prose whatever word opens it. The message named `PROSE_ALLOW_COMMENTS` as a remedy without saying where it works, and in CI the composite action clears it, so a reader acting on the check log would have set a variable the run ignores. It names the commit as that remedy's place now. `drive-pr` never mentioned the label, so an agent following it met the rule at a failing check rather than when opening the pull request, which is the one moment the label can be applied without costing a push. Two prose corrections. The OPERATIONS.md heading still promised the CI parity its own paragraph exists to deny. And `scripts/README.md` said most of the findings this removes are real, where the measurement it cites puts `correctness` at about half of the comment-text findings. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟡 Changes recommended
The new fleet label description for comments is phrased PR-specifically ("this pull request") and should be made generic for correct reuse across repositories and future PRs.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds a new refusing prose-gate rule (comment-added) that fails PRs which introduce (or touch) prose comment lines in code/config, with explicit opt-outs via a PR label (comments) and local overrides (--allow-comments / PROSE_ALLOW_COMMENTS). This aligns with the goal in #1631 to reduce review churn spent on agent-authored comment prose by mechanically removing that surface unless explicitly requested.
Changes:
- Implement
comment-addedin.github/actions/prose-gate/prose_lint.py, wire it intoDEFAULT_RULES, and add CI/local stand-down paths plus tool/directive/version-pin exemptions. - Add end-to-end and unit tests proving the rule, exemptions, and CI label plumbing (including composite action input behavior).
- Document the new rule and add the
commentslabel to the fleet label payload; wire the workflow to pass the override from PR labels (and stand down on default-branch promotion PRs).
File summaries
| File | Description |
|---|---|
| scripts/tests/test_prose_lint.py | Adds focused unit + integration coverage for comment-added, including action/script plumbing and stand-down behavior. |
| scripts/README.md | Documents comment-added behavior, scope/stand-downs, and how CI vs local runs differ. |
| repo-config/README.md | Updates label taxonomy docs to describe comments as a gate-affecting label. |
| repo-config/labels.json | Declares new comments label in fleet payload. |
| OPERATIONS.md | Updates local verification guidance to reflect comment-added and how CI vs local gating works. |
| GOVERNANCE.md | Clarifies hook vs PR-gate scoping semantics (hook per-commit vs PR per-branch). |
| .husky/pre-commit | Aligns hook comments with updated PR-gate scoping explanation. |
| .github/workflows/validate-task.yml | Wires PR label + promotion condition into prose-gate via allow-comments. |
| .github/actions/prose-gate/prose_lint.py | Implements comment-added, exemptions, message/override plumbing, and adds --allow-comments. |
| .github/actions/prose-gate/action.yml | Adds allow-comments input, passes --allow-comments when true, and clears PROSE_ALLOW_COMMENTS. |
| .github/skills/drive-pr/SKILL.md | Regenerated skill copy reflecting the new comments label guidance. |
| .github/skills/comment-and-doc-style/SKILL.md | Regenerated skill copy documenting comment-added and the comments label/override mechanics. |
| .claude-plugin/fleet-skills/skills/drive-pr/SKILL.md | Regenerated plugin skill copy reflecting the new comments label guidance. |
| .claude-plugin/fleet-skills/skills/comment-and-doc-style/SKILL.md | Regenerated plugin skill copy documenting comment-added and overrides. |
| .claude-plugin/fleet-skills/.source-digests/drive-pr | Updates digest for regenerated drive-pr skill content. |
| .claude-plugin/fleet-skills/.source-digests/comment-and-doc-style | Updates digest for regenerated comment-and-doc-style skill content. |
| .agents/skills/drive-pr/SKILL.md | Source-of-truth skill update: instructs authors to apply comments label up front when a change adds comments. |
| .agents/skills/comment-and-doc-style/SKILL.md | Source-of-truth skill update: documents comment-added behavior and its opt-outs. |
Review details
- Files reviewed: 18/18 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…as Well as the Base Two shapes the last pass reached, plus the surfaces the rename and the stand-down left behind. A checkov skip and a bandit nosec carry a written reason after the rule id, so the sentence test that tells `# nosec The value is read once.` from a directive reported exactly the directives it exists to exempt. Deleting one, which the finding's first remedy says to do, re-enables the rule it suppresses. Both families match on their rule id now, which is what still tells them from a sentence opening on the same word. The promotion stand-down tested only the base branch, and a feature branch may target the default branch directly, which `GOVERNANCE.md` "Branching Model" sanctions. Such a pull request carries new lines and was skipping the rule. The head branch is tested too now. That an operational repository's promotion is its only pull request, and so loses the rule entirely, is filed as #1663 rather than decided here. The stand-down note named the label as CI's reason where CI now has two. The label description read as though it described one pull request, where a label is fleet-wide metadata that every repository carries, which Copilot raised on the pull request and the file's own other descriptions already showed. Four surfaces the earlier commits missed. `docs/fleet-map.md` twice names the OPERATIONS.md section by the title this branch renamed. `catalog/snippets/husky/pre-commit` and `catalog/snippets/pre-commit/README.md` still say CI re-checks the whole tree, which is the claim this branch deleted as false from three other surfaces, and they are the two snippets a downstream repository copies. And three enumerations of the rule's overrides stopped at two. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…p Standing the Rule Down The last commit tried to recognize the two directive families that carry a written reason, and got four of them wrong in one pattern: a checkov id that is not `CKV`-prefixed, which its own regex allows as any `[A-Za-z_\d-]+`; a space after `skip=`, which its regex also allows; bandit's `nosec:` spelling; and bandit's test-name form. It also named `checkov:` while `bridgecrew:skip=` and `cortex:skip=` are equal-status prefixes in the same regex. That is the enumeration growing rather than the rule improving, and encoding two tools' grammars here is what the maintainer's simplify decision already removed once. So it is reverted. A directive carrying a written reason closes as a sentence, is reported, and the label is its remedy, which is the cost this rule was decided to carry rather than a case to chase. The promotion stand-down tested the head branch name and not the head repository, so a fork pull request from a branch named `develop`, targeting the default branch, stood the rule down on lines reviewed nowhere. This repository is public and accepts fork pull requests. The head repository is tested now. `test_the_workflow_reads_the_label_the_fleet_declares` asserted one fragment of that expression, so flipping its `||` to `&&`, which refuses every labeled pull request, left the suite green. It asserts the whole expression now. The rest is prose the narrowing left false. Four surfaces still said CI stands the rule down for a pull request targeting the default branch, which stopped being true when the head branch joined the condition, and one of those sentences asserted that such a pull request is a promotion where the workflow's own comment beside it says otherwise. The rule list and the module docstring said the rule fires on an addition where its finding says "adds or edits". And the two hook comments read as claiming the pull request gate is the wider scope per commit, which is the inverse of what `GOVERNANCE.md` and `scripts/README.md` state. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
The implementation and wiring appear consistent and well-tested, with only a minor remediation-message completeness nit outstanding.
Review details
- Files reviewed: 21/21 changed files
- Comments generated: 1
- Review effort level: Lite
…dy Once The revert's own justification overstated the cost it accepted. `SENT_END` anchors at the body's end, so a reason written as an argument is exempt and only the punctuated spelling of the same reason is reported: `# nosec B608 - the query is parameterized` passes and the period-terminated form does not. Two paragraphs of one docstring disagreed about that input, and the reported set is the terminated subset rather than every reason-carrying directive. Both paragraphs say so now, and four cases cover the pair for `nosec` and `checkov`. `checkov:` had no coverage at all, since the revert deleted its case rather than flipping the expectation. Removing `checkov:` from `TOOL_DIRECTIVE` entirely left the suite green while two docstrings named it as the canonical example. It fails that mutation now. The finding message named the label and the variable and not the flag, which Copilot raised on the pull request. The message prints on a run by hand as well as in CI and at a commit, and there no pull request carries a label. It now names one remedy per context in one clause rather than a fourth clause appended to the sentence. `drive-pr` told an agent to label a change that "adds a comment line", which is the wording this branch corrected everywhere else, so a pull request that only rewords a comment was opened unlabeled and took the round trip that sentence exists to avoid. `GOVERNANCE.md` generalized over both hook shapes one clause after distinguishing them: the `pre-commit` framework's staged state is the commit's own diff and so never wider than the pull request gate, and an amended commit makes that gate strictly wider. The bullet states each shape now. And the "adds or edits" correction had no test on any surface, so reverting the rule list to "adds" left the suite green. `action.yml`'s own clearing comment still said the label decides, 88 lines below the description in the same file that names both terms. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…unds Could Not State A PowerShell comment-based help block reported four comment lines, and `.SYNOPSIS` is a keyword no author may delete, so the label was the only remedy for a change that authored no prose. C# `///` and a Python docstring are both already out of scope, and this is the same case. The fix is this rule's own rather than the syntax table's. Declaring `<#` as PowerShell's doc marker, which is what the table does for C#, was tried first and two `comment-wrap` cases failed against it: the fleet reads a PowerShell block comment with that rule today. Narrowing two gated rules to widen a third is the mistake this branch already made once with `NOT_PROSE`, so the skip is scoped to `comment-added` and the case asserts `comment-wrap` still reads the same block. The scan matches the markers anywhere on a line rather than parsing. A `<#` inside a string costs an exemption instead of a false finding, which is the safe direction for a rule that refuses, and the alternative is a second PowerShell parser beside the one `extracted_comments` already carries. The hook-versus-gate scope comparison is deleted from all four surfaces rather than corrected a fifth time. Its history: the original claim said CI re-checks the whole tree, which was false; the first correction said the pull request gate is narrower, which was false; the second said the hook reads at least as much, which is false when the index is ahead of the working tree and false for an amended commit. Each surface now states its own scope and claims nothing about the other, which is the only version that has not been wrong. The `comment-and-doc-style` skill said the rule reports every comment line where it reports every prose one, and named two escapes where the finding message names three, the flag having been added to the message in the commit before this one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…enced the Rest of the File The previous commit's help-block skip counted `<#` and `#>` as a depth, so one opener that never closed stood the rule down for every line after it, in that file, with nothing on stderr. Three ways to reach it, each measured: a `<#` inside a single-quoted string, the same inside a here-string, and a second `<#` written in the body of a block that does close, which left the depth at one past its own terminator. Its docstring said the cost was an exemption rather than a false finding, and the cost was the file. A block comment does not nest in PowerShell, so the scan reads a second opener as text and exempts a range only once its closer arrives. An opener with no closer now exempts nothing, which is the direction a refusing gate has to fail in: `GOVERNANCE.md` "Verification Discipline" says a gate that quietly stops gating reports success while doing nothing, and that was this shape exactly. Seven cases cover it, one per way an opener can fail to close, and the two mutations they exist for now fail: restoring the exempt-to-end-of-file behavior, and deleting the skip outright. Two false claims the earlier deletions left. `GOVERNANCE.md` said a whole-repo check belongs "there", whose only place-noun after the deletion was the pull request gate, where the bullet's own subject and conclusion are the hook. And `scripts/README.md` said twice that `charset-unknown` reports instead of blocking, which is true of the warn-only whole-tree step and false of the pull request gate, where it blocks like every other default rule, as the same file's own corrected sentence and `OPERATIONS.md` both now say. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Two hand-written scans of `<#` and `#>`, two ways of mistaking a marker inside a string for a real one. The first stood the rule down to end of file. The second bounded that to the next `#>` in the file, which meant an opener in a string borrowed the next genuine help block's terminator and silently dropped every prose comment between them. A gate that stops gating and says nothing is the one failure `GOVERNANCE.md` "Verification Discipline" names, and the scan reached it twice. `extracted_comments` already parses PowerShell with its quoted spans blanked, its here-strings carried, and its documentation blocks skipped. It took a spec from the path alone, so it now takes an override, and `comment-added` passes `POWERSHELL_DOC`, which is `POWERSHELL` with the block opener declared as the documentation marker the way `C_LIKE` declares `///`. The scan is deleted. The other two comment rules keep the plain spelling and go on reading a block comment as a comment, which their own cases assert. Seven inputs the scans got wrong are now right, each one a case: an opener in a single-quoted string, in a here-string, in a remark that a later block follows, a line naming both markers in prose, a block that closes and reopens on one line, a stray closer, and a second opener written inside a block's body. An opener that never closes puts the rest of the file inside a comment, which is what PowerShell reads there, so the rule follows the parser rather than the guess a scan made. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…Not Exempt The comment justifying the exemption said PowerShell writes comment-based help as its one block form. `about_Comment_Based_Help` documents two, the `<# ... #>` block and a run of `#` lines carrying the same `.SYNOPSIS` keywords, so the sentence asserting the case cannot arise sat above a rule that reports it. The behavior stands and the claim is corrected. The `#` form is a run of ordinary comment lines, and reading it as documentation would need the `.`-keyword shape, which is a second grammar in a rule that deliberately holds none. So a change writing one carries the label, exactly as a change writing a directive with a punctuated reason does. A case pins that, so it is a decision rather than an oversight, and the block form stays exempt because it is the form the fleet's own scripts use. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e Does Not Support The exemption's stated reason ended "the block form is the one the fleet's own scripts use". Measured: nine tracked `.ps1` files, none holding a `<#` block, and `.SYNOPSIS` appears nowhere in the repository outside the gate and its own cases. No fleet script uses comment-based help in either form, so the sentence asserted a usage the tree does not contain, and it was the whole stated reason for exempting one form while reporting the other. The reason that holds is the one above it: a block is a documentation comment, which CODESTYLE owns, the way a C# `///` comment is. The clause is deleted rather than restated, since it was a justification beside a correct instruction, which is the shape that has drawn nearly every prose finding on this branch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ng the Tree Does Not Have Two claims beside correct code, both false, both the justifying-clause shape this branch keeps producing. The PowerShell exemption cited CODESTYLE as owning the prose it skips. CODESTYLE.md carries General, .NET, Python and Shell sections and names PowerShell nowhere, so for C# the citation resolves and for the one language the sentence is about it resolves to nothing. The reason that survives is what the two forms have in common: each is its language's documentation form rather than a remark on code. `COMMENT_LABEL_NAME` claimed the message and the action's input could not drift from the declared label because the name is written once. The literal is written three times, in `labels.json`, in the workflow's `contains` expression, and here, and the action's input is a boolean carrying no name at all. Renaming the label would move the constant and the message together while the workflow went on testing the old spelling, and every labeled pull request would silently run the gate. What catches that is the case asserting all three surfaces, which the comment now names instead of claiming a coupling that does not exist. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…as Prose
`extracted_comments` took any `#` as a line-comment opener, and shell and YAML
both require one to open the line or follow whitespace. Every `$#`,
`${#arr[@]}`, `${file##*/}`, `C#` and URL fragment in the tree was therefore a
comment to this rule, reported with a fragment of code as its body and "delete
it" as its remedy, on a line carrying no comment at all. Measured on three
tracked files: `host-setup/bootstrap.sh`, `.github/workflows/validate-task.yml`
and `.github/actions/prose-gate/action.yml` report 43, 79 and 33 findings, and
109 tracked lines tree-wide match the shape.
The three rules that read these comments before this one never surfaced it.
`comment-wrap` and `comment-case` need a leading marker, which a marker inside a
token never is, and `spelling` and `dupword` need a misspelling or a repeated
word inside the body. `comment-added` is the first that reports every body it is
given, so it is the first to read what those bodies actually were.
`line_marker_at` requires whitespace before a `#` and leaves every other marker
alone, since a C-like `//` legally follows a token. Python permits a `#` against
one and reaches this only through the spelling and duplicate-word rules,
`python_comments` answering for it everywhere else, so a line written that way
loses those two and that is the price of three languages not reporting their own
operators.
Two more from the same pass. `PROSE_ALLOW_COMMENTS=false` stood the rule down,
because the variable read as non-empty while the composite action's own input
spells its off value `false`, so a developer mirroring that spelling turned the
gate off at every commit. And the per-line de-duplication ran before the prose
test under one ordering, letting a directive sharing a line claim it and silence
the prose comment beside it, which no case pinned.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…le Files Through Steering the scan past an in-token `#` handed the rest of that line to the string reader, so `echo C# won't build` opened a quote carry that ran to end of file. Measured on a three-line shell file: every comment rule reported nothing, `comment-wrap` included, where before the change two of the three lines reported. That is a silent under-scan in machinery three other rules share, and a worse fault than the operators it was fixing, which reported a finding an author could at least see. The test reads the source line instead, in this rule alone. A line holding no `#` where one opens a comment cannot hold a comment, so dropping it removes a finding rather than inventing one, and a line that holds one keeps whatever the scan made of it. The scan itself is back to what it was, and the shared rules were compared against the merge base over all 357 tracked paths with no file differing. A `#` after a shell metacharacter is a comment too, so `run_gate;# note` now reports where the earlier attempt missed it. TOML and HCL also take one against a bare value, `key = 1# note`, which this misses; no tracked file carries that shape and the miss loses a finding rather than inventing one. Three of the environment override's off spellings were pinned by nothing, so dropping `no` from the set, or either normalizer, left the suite green while ` false ` or `False` stood the gate down at every commit. All five spellings and both normalizers are asserted now, `true` among them, that being the word the composite action's own input uses for on. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…e Afterwards
The filter asked whether any `#` on the line sat where a comment opens, and the
parser had already chosen one. So an unrelated marker answered for the marker
actually taken: `test $# -eq 1 && echo ' #'` reported a finding, the quoted ` #`
vouching for the `#` of `$#`, which is the shape the sibling case pins as fixed.
`sed 's/ #.*//' ${f##*/}` and `echo 'a # b' ${x##*/}` did the same.
`extracted_comments` and `python_comments` return a `Comment` now, carrying the
marker the parser took and the character before it. The test reads those two
rather than the line, so it answers about the marker that produced the body in
front of it. Nothing about the scan changed, which is what the earlier attempt
got wrong: steering the scan past a marker handed the rest of the line to the
string reader and silenced every comment rule to end of file.
Two more the same guess produced. A `;` comment in an INI-family file was never
reported, since the test judged `#` markers only while the guard let the file in,
so whether a `;` comment reported depended on the author's sentence happening to
contain a space-preceded `#`. Every fleet repository carries a `.editorconfig`.
And Python was re-judged by shell and YAML anchoring that Python does not have,
dropping `x = 1# note` and `v = "s"# note`, which `tokenize` had identified
exactly. Python skips the test outright now, since `tokenize` cannot be wrong
about which `#` opens a comment.
Every pre-existing rule was compared against the merge base over all 357 tracked
paths, with no file differing.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ng for Most of Them `HASH_OPENS_AFTER` was shell's rule applied to every language that spells a comment with a hash, and shell is the widest of them. YAML opens one only after whitespace, so `note: See (#1234) for the discussion.` in a plain scalar reported a comment the file does not hold, body `1234) for the discussion.`, remedy "delete it" with nothing to delete. An issue reference in parentheses is a shape this fleet writes constantly, and `©` reported the same way. The set moves onto `Syntax`, which is already where a language's own comment facts live. Whitespace is the default and YAML's rule, shell adds the metacharacters it word-splits on, PowerShell adds the delimiters it also ends a token on, and TOML and HCL say `None`, meaning a `#` opens a comment anywhere, which is what `key = 1# note` is in both and what the old single set could not express at all. PowerShell was losing `{# note` for the same reason. The escape for a marker that is not a `#` was pinned by nothing: forcing every marker to `#` passed all 327 cases while an INI `;`, a CSS `/*`, a JSONC `//` and an XML `<!--` against a non-metacharacter each stopped reporting. Four cases cover it now, and each of the six values this commit adds fails a named case when mutated. Every pre-existing rule was compared against the merge base over all 357 tracked paths, with no file differing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…ttempts Could Not Settle Deciding which mid-line marker opens a comment is a parser fact, and it differs by language in ways no character set can carry. The last attempt proved that by regressing three at once: an extensionless shell script took YAML's rule, so `.husky/pre-push` and `.husky/pre-commit` disagreed about the same language; TOML reported the body of a `"""` string, since `hash_after: None` met a syntax with no string carry; and an HCL heredoc did the same. Beneath those sat three the mechanism could not reach at all. A git pattern file holds no trailing comment, so `build/ # note` is part of the pattern and deleting it changes what the file ignores. PowerShell opens a comment after almost anything in expression mode. And `.psd1` resolves to no syntax at all. So the layer is gone, not extended. `hash_after`, the `HCL` syntax, the `Comment` fields carrying the marker and its neighbour, and the predicate reading them are all deleted, and the rule reports a comment whose marker opens its line. That is unambiguous in every language the gate reads, and it is what #1631 asked for in the first place: a comment line. The evidence was there the whole time. `comment-wrap` and `comment-case` have judged only leading comments for years, beside this same parser, and met none of the six defects the last four rounds found. They were immune for the reason this rule now is. The cost is a trailing comment going ungated, which is stated where the rule is stated and pinned by cases in both directions, so the narrowing cannot pass by reporting nothing. All ten pre-existing rules were compared against the merge base over 357 tracked paths, with no file differing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… Cases For It The bait these cases feed put its `#` mid-line, so the `leading` filter dropped it whatever the guard under test did. Measured: removing the tokenize-failure guard, so a `.py` that does not parse falls back to the hash-anchored scan, left the whole suite green, and so did making the `.py` suffix match case-sensitive. The marker opens its line now, and each of those two mutations fails a case. Filed rather than fixed here, as #1664: a line of multi-line string or heredoc content that opens with the comment marker is read as a comment, in TOML, in HCL, in a workflow `run:` block, and in an extensionless shell script that resolves to `HASH` rather than `SHELL`. The cause is `Syntax["carry"]` modelling no string state for those, which `comment-wrap` shares and rarely reaches. The same issue carries the block-comment continuation, which appends a carried line with `leading` hard-coded true, so a line that only closes a block and then carries code reports. That is parser work of the kind that regressed a language on each of six attempts, so it wants its own change with differential tests against each language's real parser rather than a seventh round here. The exposure is bounded meanwhile: the finding is visible, the label clears it, and no tracked file carries any of those shapes. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
… the Directive Anchor The widening of `NOT_PROSE`'s version-pin alternative was added so a bare hub pin like `# 2.0.338` would not report. Every pin in the tree is a trailing comment, and the leading filter now drops those before the prose test is ever reached, so the widening's only remaining effect was on `comment-wrap` and `comment-case`, two rules it was never meant for and which no case covered. Reverting it leaves the suite green, which is what a change with no live effect should do. The case that stood behind it asserted `[]` on three trailing comments, so it held whatever `NOT_PROSE` contained. Two cases pin the directive exemption's anchoring, which nothing did. Both write a directive name mid-sentence with no terminal punctuation, so neither the sentence half nor the opening half alone can report them. One finding from that pass is not acted on because it is wrong. `TOOL_DIRECTIVE` carries `^` inside the pattern and is read with `.match`, so it is anchored twice, and replacing `.match` with `.search` is an equivalent mutant rather than a coverage gap. Dropping the `^` alone is equivalent for the same reason. The two cases above fail only when both anchors go, which is the honest thing they pin. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
…In For
Every `allow-comments` case drives the composite action's script body and hands
`ALLOW_COMMENTS` to it through the environment, so nothing read the action's
`inputs:` block or its `env:` mapping at all. Two mutations survived the whole
suite because of it, and neither is equivalent.
Deleting `ALLOW_COMMENTS: ${{ inputs.allow-comments }}` leaves the script reading
its own `${ALLOW_COMMENTS:-false}` fallback forever, so in CI neither the
`comments` label nor the promotion stand-down reaches the gate and a correctly
labeled pull request is still refused. And flipping the input's default from
`'false'` to `'true'` stands the rule down on every run for any caller that omits
the input, which is any downstream repository wiring this action from a workflow
of its own, silently.
Both fail a case now.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The new comment-added refusal can be trivially bypassed via NOT_PROSE substring matches, which undermines the rule’s core purpose unless the exemption logic is tightened.
Get a fresh assessment by requesting another Copilot review.
Review details
- Files reviewed: 21/21 changed files
- Comments generated: 1
- Review effort level: Lite
Promotes `develop` to `main`. Two commits: 498f4a6, the `comment-added` prose gate from #1662, and c14323a, the codecov action bump from #1660 whose content `main` already holds from #1661. ## What promotes `comment-added` joins `prose_lint.py`'s `DEFAULT_RULES`. It reports a prose comment line a change adds, scoped by the diff that every other rule is already scoped by, and stands down with a note on stderr when run without `--diff`. Its overrides are the `comments` pull request label in CI, a non-empty `PROSE_ALLOW_COMMENTS` at a commit, and `--allow-comments` by hand. #1662 carries the rule's full description, its exemptions, the 317-case suite and the mutation checks behind it. ## What this promotion changes for the fleet `GOVERNANCE.md` has a downstream pre-commit hook fetch `prose_lint.py` fresh from this repository's `main` rather than from a pin, so this merge, not #1662's, is what starts refusing a downstream commit that adds a comment line. The refusal is legible and names `PROSE_ALLOW_COMMENTS` as the remedy at a commit, which is the leg that reaches a hook. The CI leg's remedy, the `comments` label, exists on this repository alone so far, because `repo-config/labels.json` declaring a label does not create it and `repo-config/configure.sh apply` has not been run across the fleet. #1662 parked that sequencing for this promotion rather than deciding it there. ## Review coverage Every line promoted here was reviewed where it landed. #1662 took three Copilot rounds at full file coverage with all three threads answered and resolved, and #1660 is a Dependabot group bump whose identical content is already on `main` as 664ff95. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Implements #1631 decision item 2: a
prose_lintcheck that fails a diff adding a comment line in code or config, overridable by a pull request label. The measurement behind it put 117 of 1437 bot findings (8%), including every #1630-class loop, on agent-written comment text, and the two weeks it covered showed the rules were broken with the rule already in context, so only removing the surface or gating it mechanically changes anything.What the rule is
comment-addedjoinsDEFAULT_RULES. It reports every prose comment line a file holds, one finding per line, and the diff scopemainalready applies to every rule is what narrows that to the comment lines in a change. That is deliberate reuse rather than a second scoping path, and the rule infers nothing beyond it.git diff --unified=0counts a modified line as an added one, so editing the code on a line carrying a trailing comment, re-indenting a commented block, and rewording a comment each report that comment. That is the rule's cost rather than a defect in it, it is asserted in a test rather than left to be discovered, and it is stated wherever the rule is stated. The history matters before anyone proposes fixing it: an earlier shape on this branch read the file at the diff's base to tell an authored comment from a touched one, and the rename, duplicate-body and prose-filter cases that opened took four adversarial review passes and ~64 findings to close, each round's fixes writing the next round's. The precision was not worth it, because a comment worth keeping takes the same label as a comment worth writing.Without
--diffevery comment in the tree is in scope, so the rule stands down and says so on stderr, next to thedead-pathshallow-clone stand-down that already works this way. A whole-tree run therefore still reports zero.Out of scope, each for a reason the code states: a docstring, since it is not a comment line; a
.pythat does not tokenize, since the hash-anchored fallback would read a#inside a docstring as a comment; Markdown, whose prose is the document rather than a comment on one; a version pin, including the bare form the fleet writes its hub pins in; and a tool directive, judged by its argument rather than its name alone, so# nosec B404is exempt while# nosec The value is read once.is not.The overrides, and the promotion
In CI the composite action takes an
allow-commentsinput and passes--allow-commentsonly when it is exactlytrue, so a misspelled input, an empty one, and a label expression that matched nothing all fail closed.validate-task.ymlsets it from two things: thecommentslabel, now declared inrepo-config/labels.jsonand created on this repository, and the pull request targeting the default branch. The second is the promotion case: adevelop -> mainpull request diffs against main's tip, so its scope is every line promoted since the last one, all of it reviewed where it landed. Measured againstorigin/mainwhile it was hours behinddevelop, the rule reported 28 such lines; a real promotion carries a release of them.Locally a non-empty
PROSE_ALLOW_COMMENTSstands the rule down. The gate reads it directly rather than taking a flag from each caller, which is what reaches the two downstream hook snippets that run this file straight from the hub, one of them a single command string with nowhere to put a flag. The composite actionunsets it, so a runner's environment cannot decide a pull request, and the finding message names the commit rather than CI as that remedy's place.Verification
scripts/tests/test_prose_lint.py, 21 of them new: the rule, its exemptions, all three stand-downs and their notes, the accepted false positive, the bare version pin, the directive-opening-a-sentence case, and the label path driven end to end through the action's own script body against a real repository, labeled and unlabeled.PROSE_ALLOW_COMMENTSstand-down, deleting the action'sunset, dropping the label from the finding message, removing the per-line de-duplication, and reverting the suffix-case match each fail a named case.OPERATIONS.md"Local Verification" block, green: ruff, mypy, 1494 tests,build_dist.py --check,repo_gate.py, both prose invocations,spec/validate.py, all seven Docker linters.PROSE_ALLOW_COMMENTSwas set, and it carries thecommentslabel for the same reason.Stale claims fixed along the way
Four surfaces said CI re-checks the whole tree, which is what made the hook's wider scope affordable. CI has no such run: its only whole-tree
prose_lint.pyinvocation is--check charset-unknown --summaryundercontinue-on-error.GOVERNANCE.md,.husky/pre-commitandscripts/README.mdin two places are corrected, along with anOPERATIONS.mdheading that promised CI parity its own paragraph exists to deny, and arepo-config/README.mdlabel taxonomy whose closing sentence covered every label but the new one.Before this promotes to main
GOVERNANCE.mdsays downstream hooks fetchprose_lint.pyfresh from the hub'smain, never pinned. So the promotion, not this merge, is what makes every downstream repository's pre-commit hook start refusing a commit that adds a comment line, beforeconfigure.sh applyhas put thecommentslabel on those repositories. The finding namesPROSE_ALLOW_COMMENTSso the refusal is legible and has an escape, but it fires per commit rather than per pull request. That sequencing is a decision for the promotion rather than for this pull request.Three findings from the review passes are pre-existing behavior this rule sharpens rather than introduces, filed as #1657, #1658 and #1659. The last is worth reading:
NOT_PROSEis searched unanchored, so a comment that merely namesprettier,Copyrightoreslintis exempt from every prose rule, which in a refusing rule is a bypass the comment's own author controls.🤖 Generated with Claude Code