fix(code-comments): a glob inside a Go raw string opened a phantom block comment #1335

Merged
coilyco-ops merged 2 commits from ops/raw-string-block-comments into main 2026-08-28 03:43:33 +00:00
Owner

One glob, 313 false violations

block_state_after skips double-quoted strings before looking for /*, and never knew about backtick raw strings. Those run across lines and hold arbitrary text, so a /* inside one opened a block comment that stayed open until an unrelated */, and every line after it was scanned as a comment.

umbra's examples/treebuilders/treebuilders.go reported 313 violations against 12 actual comment lines. The opener was a help string documenting where audit rows land:

~/.ward/audit/*.jsonl

The /* in that glob is the whole bug.

The fix

The scanner tracks raw-string state alongside block state, for the languages whose backtick strings span lines (.go, .js, .jsx, .mjs, .ts, .tsx). Raw state is checked first, so:

  • a // or /* inside a raw string opens nothing,
  • a line inside a raw string is never a comment,
  • a genuine /* ... */ after a closed raw string still counts.

All three are tests, including the 313-violation shape itself. The existing 50 comment tests are unchanged and still pass.

Why it mattered here

umbra goes from 331 code-comment violations to 18 with no edit to that repo. Before this, its count read as unmigratable comment debt and was the main reason inbox#457 called it "the largest of the five". Almost all of it was one parsing defect.

753 tests pass and pre-commit run --all-files exits 0.

## One glob, 313 false violations `block_state_after` skips double-quoted strings before looking for `/*`, and never knew about backtick raw strings. Those run across lines and hold arbitrary text, so a `/*` inside one opened a block comment that stayed open until an unrelated `*/`, and every line after it was scanned as a comment. umbra's `examples/treebuilders/treebuilders.go` reported **313 violations against 12 actual comment lines**. The opener was a help string documenting where audit rows land: ``` ~/.ward/audit/*.jsonl ``` The `/*` in that glob is the whole bug. ## The fix The scanner tracks raw-string state alongside block state, for the languages whose backtick strings span lines (`.go`, `.js`, `.jsx`, `.mjs`, `.ts`, `.tsx`). Raw state is checked first, so: * a `//` or `/*` inside a raw string opens nothing, * a line inside a raw string is never a comment, * a genuine `/* ... */` after a **closed** raw string still counts. All three are tests, including the 313-violation shape itself. The existing 50 comment tests are unchanged and still pass. ## Why it mattered here umbra goes from **331 code-comment violations to 18** with no edit to that repo. Before this, its count read as unmigratable comment debt and was the main reason inbox#457 called it "the largest of the five". Almost all of it was one parsing defect. 753 tests pass and `pre-commit run --all-files` exits 0.
fix(code-comments): a glob inside a Go raw string opened a phantom block comment
All checks were successful
ci / aos-eval-tests (pull_request) Successful in 7s
ci / ward-doctor (pull_request) Successful in 7s
ci / aos-cli-tests (pull_request) Successful in 25s
ci / gate (pull_request) Successful in 49s
fdb8ac1ff7
`block_state_after` skips double-quoted strings before looking for `/*`, and
never knew about backtick raw strings. Those run across lines and hold
arbitrary text, so any `/*` inside one opened a block comment that stayed open
until an unrelated `*/`, and every line after it was scanned as comment.

umbra's examples/treebuilders/treebuilders.go reported **313 violations against
12 actual comment lines**. The opener was a help string documenting where audit
rows land: `~/.ward/audit/*.jsonl`. The `/*` in that glob is what did it.

The scanner now tracks raw-string state alongside block state for the languages
whose backtick strings span lines, and a line inside one is never a comment.
The two states are checked in that order, so a `//` or `/*` inside a raw string
opens nothing and a genuine block comment after a closed raw string still
counts. Both directions are tests, alongside the 313-violation case itself.

Effect on umbra: 331 code-comment violations to 18, with no edit to that repo.

Found while advancing umbra's hook pin for coilysiren/inbox#457, where the
count read as unmigratable comment debt rather than as one parsing defect.

Refs coilysiren/inbox#457

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-authored-by: Kai Siren <coilysiren@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Agent-Role: platform
Merge branch 'main' into ops/raw-string-block-comments
All checks were successful
ci / aos-eval-tests (pull_request) Successful in 8s
ci / ward-doctor (pull_request) Successful in 11s
ci / aos-cli-tests (pull_request) Successful in 33s
ci / gate (pull_request) Successful in 1m9s
2af1b40d67
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coilyco-flight-deck/agentic-os!1335
No description provided.