Skip to content

Read a Key and Its Value in a Comment as Configuration - #1702

Merged
ptr727 merged 8 commits into
developfrom
feature/comment-case-snippet
Sep 19, 2026
Merged

ptr727 merged 8 commits into
developfrom
feature/comment-case-snippet

Conversation

@ptr727

@ptr727 ptr727 commented Sep 19, 2026 •

Copy link
Copy Markdown
Owner

comment-case reports a comment line whose sentence opens in lowercase, and a configuration snippet pasted into a comment opens on a lowercase key, so no form of one could pass. The rule and a copy-pasteable snippet were mutually exclusive.

The change

A comment body of one key, a colon and one value is configuration rather than a sentence, and neither comment-case nor comment-wrap applies to it. It sits beside the lone-key exemption, which already exempts the # packages: line above the one that failed.

Clearing comment-wrap with it is what a multi-line snippet needs: each snippet line stops being read as a continuation of the one above it.

The guard reads its own terminator set rather than SENT_END, whose set carries the colon. A colon ends configuration rather than a sentence here, which is precisely why the lone-key exemption exists two lines above. Read with the colon in, address: fd00::, image: ghcr.io/o/n: and root: C: were each refused and told to capitalize their key, which is the unfixable finding this exemption exists to remove.

What it costs, stated rather than left to be found

Two detections, and one shape the guard refuses:

  • A marker comment. # todo: refactor and # note: obsolete are the same shape as a config line and are now exempt. This is the common one.
  • A sentence wrapping through such a body. It loses its wrap, and the line under it is reported for case instead, or loses the wrap silently where the body ends it.
  • The refusal, which loses no detection: a value ending in a full stop is judged exactly as before, an FQDN such as origin: example.com. being the case. The terminator cannot drop the full stop without dropping the guard.

is_comment_prose deliberately does not carry this exemption, unlike its three siblings. comment-added reads a body of any case, so exempting the shape there would free # Owner: alice and # Timeout: 30 from the comments label as well, and pricing an added comment is what that rule is for. An earlier round added it for symmetry and this reverts that.

Measurement

Over all tracked files the exemption changes zero findings. Twenty-four bodies match the shape, twenty-three already exempt as tool directives, and the one newly reached is scripts/skills_install.ps1:4, Run: scripts\skills_install.ps1, a command to paste. No body in the tree carries any of the three costs, so that measurement bounds none of them.

Review record

Six local adversarial passes, finding 9, 7, 7, 3, 2 and 2. Nearly every finding was in the prose describing the change rather than in the change: the code has been settled since the colon fix. Two remain open, both about which noun a word binds to, neither affecting behavior:

  • scripts/README.md: "bounds none of the three" now follows "unlike its three siblings", so the nearest three-noun is the wrong one.
  • prose_lint.py: "The terminator" is definite, and that block names SNIPPET_END without ever calling it a terminator, where the README's parallel sentence introduces the phrase first.

A candidate follow-up rather than part of this: each exemption is described twice, once beside the pattern and once in scripts/README.md, and that duplication generated most of the findings above. Collapsing it would remove the defect generator rather than the defects.

Note on the reported case

This unblocks ptr727/ESPHome-Config#153 when that repository's pin moves to a hub commit carrying this, not when this merges.

Closes on promotion: #1700

A config key is lowercase by definition, so `comment-case` rejected every
spelling of a snippet pasted into a comment and the rule and a
copy-pasteable snippet were mutually exclusive. A lone key was already
exempt, and the line under it was not, so the header a fleet of ESPHome
templates carries failed on its second line.

Only two shapes passed and each damaged the snippet. A capitalized key
changes what a reader pastes, and a leading dash is a different YAML
construct from the mapping the line belongs to. The same snippet passes
inside a Markdown fence already, which is what makes this a gap rather than
a constraint.

A body of one key, a colon and one value now reads as configuration, beside
the lone-key exemption it sits under. That clears `comment-wrap` with it,
since a snippet line is no longer read as continuing the snippet line above
it, which is what a multi-line snippet needs.

The shape is deliberately one value with no spaces. Measured over this tree
before adopting it, the exemption newly admits a single comment body, a
command to paste, and every other comment stays inside the rule. A value
carrying a space is still judged, so prose opening on a colon is unaffected.

The rule is diff scoped, so this blocked new content while grandfathering
identical old content, and the failure was invisible until someone added a
file.
The exemption admitted any two-word sentence, so `# one: two.` passed and a
real wrapped sentence whose continuation happened to be two tokens lost its
finding. `is_tool_directive` pairs its own anchor with the same guard for the
same failure, an anchor alone having let a body ending as a sentence exempt
itself. Guarded, three of the four silenced shapes come back and both
snippet shapes stay clean, including the punctuated Markdown HTML comment
that branch keeps deliberately.

The guard was left out on the strength of a measurement over this tree, which
showed it changing nothing here. That reasoning was wrong: the tree shows
what exists rather than what an exemption admits, and this gate runs in every
repository the fleet has.

Three claims were false. A config key is not lowercase by definition, since
an environment key is not. A quoted key is a third spelling that passed, and
it damages nothing, so the exemption rests on the readable spelling being
unavailable rather than on nothing undamaging passing. And the block said
every spelling was rejected two lines above saying which ones were not.

The cases the change was missing: the guard in both directions, the Markdown
branch it must not override, the space the shape requires, and the exemption
holding across seven comment syntaxes, which is this file's convention for a
comment rule. The one remaining cost, a sentence wrapping through a
two-token body with no terminator, is pinned as the cost rather than fixed.

`scripts/README.md` gains the entry its two sibling exemptions already have,
each stating the detections it costs.
The sentence guard added last round used `SENT_END`, whose set carries the
colon, so `address: fd00::`, `image: ghcr.io/o/n:` and `root: C:` were
refused and each told to capitalize its key. That is the finding this
exemption exists to remove, and it landed two lines under the lone-key
exemption, which exists because a trailing colon marks configuration. One
filter read the same character both ways. The guard now reads its own
terminator set without the colon.

Four claims were false and each was mine. A key is not lowercase in the
formats the fleet writes, since this repository's own workflows carry
`DOCKER_HUB_USERNAME:`. The spellings that passed are not three, the test
being the first character, so any key opening on something other than a
lowercase letter passed, an underscored one and a YAML merge key among them.
The guard does not cost nothing, per the colon above. And the exemption
costs two detections rather than one, the common one being a marker comment,
since `todo: refactor` is the same shape as a config line.

The syntax case named seven files covering six specs, all using the same
marker, so it proved nothing about the parsers it never reached. It now
covers eleven names across the distinct ones, which is the convention this
file's own run-on case sets.

`is_comment_prose` gains the exemption its three siblings already have.
Without it, adding the two-line header tripped `comment-added` on the value
line while exempting the key line above it.
Carrying the exemption into `is_comment_prose` widened a gate that nobody
asked to widen. `comment-added` reads a body of any case, where
`comment-case` reads only one opening lowercase, so the exemption freed
`Owner: alice` and `Timeout: 30` from the label as well and a change could
add unbounded key-value comment lines without one. Pricing an added comment
is what that rule is for, so the asymmetry stands and its reason is written
where the exemption is.

The claim that the guard costs nothing survived in a test docstring, having
been corrected in the block and the script reference and missed here. It is
false in the class the colon fix addressed: a value ending in a full stop is
refused, an FQDN being the case, and the terminator cannot drop the full stop
without dropping the guard. That is the third cost, and the count now reads
three in both places that state it.

Two more claims of mine were wrong. One docstring said the exemption costs
one detection while the case below it said the cost it names is the common
one. And the syntax case cited the run-on case beside it as covering a marker
per parser, where that case names five extensions resolving to one syntax.
The claim is now what the eleven names actually reach, which is ten of the
eleven the table declares.
The block announced two costs and listed three, and its "The other" called
the second item the last. The count moved in the script reference last round
and not here, though the message said both. Both now read two costs and one
refusal.

The refusal is not a cost in the sense the neighbouring paragraphs use. A
value ending in a full stop is judged exactly as it was, so the exemption
loses no detection there and simply fails to remove a finding. Counting it
beside the two lost detections read as three of a kind, where the tree's own
idiom reserves that phrasing for a detection that goes away.

The block also described only the loud half of the second cost. A sentence
wrapping through a snippet body reports the line under it for case, and a
sentence ending on one loses its wrap with nothing reported at all. The
script reference named both already and a case asserts both.
The tally noun moved in the comment block and not in the script reference,
so that paragraph announced two costs and one refusal and then closed on
"none of the three costs", counting three again three sentences later. The
same slip as the round before it, on the other surface, and the message
claimed both were aligned both times.

The rewritten sentence also lost its subject. "It cannot drop the full stop"
binds to the guard, which makes the sentence say the guard cannot drop the
full stop without dropping itself. The terminator is what cannot, which is
what the script reference kept saying while this said otherwise.
Copilot AI lite review requested due to automatic review settings September 19, 2026 20:50
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Sep 19, 2026
@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 50dc3736-45c4-481b-b6b1-4d580f097e6f


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The behavioral change is narrowly scoped and well-covered by new tests, with only minor naming and documentation clarity nits remaining.

Review effort: Lite
Findings: 3 Low severity

Open (3)
What changed in this PR

This pull request updates the prose-gate comment heuristics so that single-line key: value snippets inside comments are treated as configuration (not prose), preventing comment-case and comment-wrap from rejecting copy-pasteable config examples (notably YAML snippets).

Changes:

  • Add a SNIPPET exemption (key: value with a single-token value) to the comment-wrap / comment-case logic, guarded so sentence-like endings remain judged.
  • Add targeted tests covering YAML and other comment syntaxes, plus the intended guard behavior and known tradeoffs.
  • Document the new exemption and its costs in scripts/README.md.
File Description
.github/​actions/​prose-gate/​prose_lint.py Adds SNIPPET and SNIPPET_END patterns and exempts qualifying key: value comment bodies from wrap/case findings.
scripts/​tests/​test_prose_lint.py Expands test coverage to pin the new exemption, guard behavior, and cross-syntax extraction expectations.
scripts/​README.md Documents the new exemption rationale, shape, guard, and expected tradeoffs.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/README.md Resolved
Comment thread scripts/tests/test_prose_lint.py Resolved
Three review findings, two of which a local pass had raised on the same
sentences.

The block said "The terminator" without ever introducing one, since it names
`SNIPPET_END` a few lines up without calling it that. It now names the
pattern, which is the thing that cannot drop the full stop.

The script reference closed on "none of the three" one sentence after "unlike
its three siblings", so the nearest three-noun was the wrong one. It names
the two costs and the refusal instead of counting them.

And a test name carried an `_s` token from a possessive, which reads as a
typo in a list scanned by eye.
Three surfaces carry that sentence and the round before this fixed one. The
script reference is the worse of the two left, since it uses the word twice
before the sentence and the nearer use is the colon, which makes the claim
say a colon cannot drop a full stop. The test docstring had no antecedent at
all.

Both now name what cannot drop it, which is the guard's own terminator set
on the reference and `SNIPPET_END` in the docstring, matching the code.

A grep for the sentence across the tree is what found the other two, and it
reports none now. That check is the one the round before this owed and did
not run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped, is guarded against false positives via SNIPPET_END, and is backed by targeted unit tests and updated documentation.

Review effort: Lite
Findings: None

Resolved since last review (3)

@ptr727
ptr727 merged commit 1fa927a into develop Sep 19, 2026
9 checks passed
@ptr727
ptr727 deleted the feature/comment-case-snippet branch September 19, 2026 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants