fix(code-comments): track block-comment state instead of guessing on a leading star #963

Merged
coilysiren merged 1 commit from aos/claude/issue-961-block-comment-state into main 2026-08-06 20:31:54 +00:00
Member

Closes #961.

Problem

is_comment_line classified any line whose stripped text started with * as a block-comment continuation. A leading * is also the dereference operator, so every pointer-bearing language in BLOCK_COMMENT_EXTS (.rs, .c, .go, .cs, .java, and the rest) hit false positives. A long deref tripped the 90-char cap and three consecutive derefs tripped the contiguous-block cap.

Fix

scan_lines now threads real open/close state through the file rather than guessing per line. A new block_state_after walks each line and skips double-quoted strings and line comments, so /* only opens a block where it actually opens one. A leading * counts as a comment only while that state is open. This is the state-tracking fix the issue names as correct, not the interim * -narrowing.

Verification

  • The issue evidence table inverts: *self.stock.entry(item).or_default() += n; (.rs), *ptr = 5; (.c), and *count += 1; (.go) are no longer comments, for both caps.
  • Genuine /* ... */ continuation lines are still counted, and still obey the char cap.
  • 11 regression tests added in tests/test_check_code_comments.py. Seven of them fail against the old checker and pass against the new one. The continuation tests pass against both, guarding the other direction.
  • ward test - 532 passed.
  • ward pre-commit-all - clean, exit 0.

No docs/FEATURES.md entry: this is validation hardening, not a capability change.

Closes #961. ## Problem `is_comment_line` classified any line whose stripped text started with `*` as a block-comment continuation. A leading `*` is also the dereference operator, so every pointer-bearing language in `BLOCK_COMMENT_EXTS` (`.rs`, `.c`, `.go`, `.cs`, `.java`, and the rest) hit false positives. A long deref tripped the 90-char cap and three consecutive derefs tripped the contiguous-block cap. ## Fix `scan_lines` now threads real open/close state through the file rather than guessing per line. A new `block_state_after` walks each line and skips double-quoted strings and line comments, so `/*` only opens a block where it actually opens one. A leading `*` counts as a comment only while that state is open. This is the state-tracking fix the issue names as correct, not the interim `* `-narrowing. ## Verification * The issue evidence table inverts: `*self.stock.entry(item).or_default() += n;` (.rs), `*ptr = 5;` (.c), and `*count += 1;` (.go) are no longer comments, for both caps. * Genuine `/* ... */` continuation lines are still counted, and still obey the char cap. * 11 regression tests added in `tests/test_check_code_comments.py`. Seven of them fail against the old checker and pass against the new one. The continuation tests pass against both, guarding the other direction. * `ward test` - 532 passed. * `ward pre-commit-all` - clean, exit 0. No `docs/FEATURES.md` entry: this is validation hardening, not a capability change.
fix(code-comments): track block-comment state instead of guessing on a leading star
All checks were successful
ci / ward-doctor (pull_request) Successful in 11s
ci / aos-cli-tests (pull_request) Successful in 28s
ci / gate (pull_request) Successful in 52s
bb4743a500
is_comment_line classified any line whose stripped text started with `*`
as a block-comment continuation. A leading `*` is also the dereference
operator, so every pointer-bearing language in BLOCK_COMMENT_EXTS (.rs,
.c, .go, .cs, .java, and the rest) hit false positives: a long deref
tripped the 90-char cap and three consecutive derefs tripped the
contiguous-block cap.

scan_lines now threads real open/close state through the file. A new
block_state_after walks each line, skipping double-quoted strings and
line comments, so `/*` only opens a block where it actually opens one.
A leading `*` counts as a comment only while that state is open.

Closes coilyco-flight-deck/agentic-os#961

Co-authored-by: Kai Siren <coilysiren@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
coilysiren deleted branch aos/claude/issue-961-block-comment-state 2026-08-06 20:31:54 +00:00
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!963
No description provided.