Skip to content

fix(review): defect generator never injects into comments - #543

Merged
dan-petty merged 1 commit into
release/v0.2.23from
fix/537-injections-in-comments
Sep 24, 2026
Merged

dan-petty merged 1 commit into
release/v0.2.23from
fix/537-injections-in-comments

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Closes #537.

Problem

The first sample validation (#505) found 9 of 78 brace-language injections inside multi-line comments. All were drop-await in ky's JSDoc examples, e.g. const text = await ky(...) in types/ky.ts. The finders (#503) blanked string literals and one-line comments, but a /* ... */ block spanning lines was not tracked. Documentation counted as code, and the corpus scored the reviewer on defects that do not exist: 9 of the 20 TypeScript injections.

The substitution templates (TLS, file modes, Terraform) matched raw lines, so a commented-out setting could be changed too.

Changes (defects.py)

  • _mask_lines:

    • tracks a /* left open through the line that closes it;
    • code after the */ is still code;
    • which parts are strings is decided first, so a /* or // inside a string ("src/**/*.ts", a URL) opens no comment.

    Guards, awaits, C string calls and the HCL block tracker all use it.

  • _substitute(..., code_only=<syntax>): a rule applies only where it matches the same text once comments are blanked. Strings are kept, because some rules match inside them (PosixFilePermissions.fromString("rw-------")). It is used for:

    • TLS verification (TS/JS, Go, Rust, C#);
    • brace-language and Java file modes;
    • Terraform public access and encryption.
  • docs/SELF_IMPROVEMENT.md notes that code finders never touch comments.

Verification on the pinned samples

Every site of every template on the brace-language and Terraform samples was checked with an independent block-comment tracker, and none is inside a comment now. The only counts that changed are TypeScript/JavaScript:

Template Before After
drop-await 99 44
drop-bounds-check 15 12 (the three removed were in @example blocks)

Every other language is unchanged.

Test plan

  • tests/test_review_defects_comments.py (13 cases, 10 fail without the fix):
    • excluded: JSDoc example, a guard in a C block comment, TLS and mode settings in one-line and block comments (Go, Rust, C#, Java), strncpy and a Terraform attribute in block comments;
    • kept: code after a comment closes, /* inside a string, a URL.
  • Existing defect template tests pass (103)
  • uv run devops ci --force: all 13 gates pass

The first sample validation (#505) found 9 of 78 brace-language injections inside
multi-line comments, all dropped awaits in ky's JSDoc examples. The finders blanked
one-line comments only, so documentation counted as code and the corpus scored the
reviewer on defects that do not exist.

Block comments spanning lines are now blanked for every brace-language finder and the
Terraform block tracker. A /* or // inside a string opens no comment. TLS, file-mode
and Terraform substitutions apply only where they match outside comments.

On the pinned samples, no site falls inside a comment. TypeScript drop-await sites fell
from 99 to 44 and drop-bounds-check from 15 to 12; other languages are unchanged.

Closes #537
@dan-petty dan-petty added this to the v0.2.23 milestone Sep 24, 2026
@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/review Multi-persona code review engine, verification, and findings priority/p1-high Priority P1: high-impact work for the next planned milestone labels Sep 24, 2026
@dan-petty
dan-petty merged commit f73d843 into release/v0.2.23 Sep 24, 2026
7 checks passed
@dan-petty
dan-petty deleted the fix/537-injections-in-comments branch September 24, 2026 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority/p1-high Priority P1: high-impact work for the next planned milestone scope/review Multi-persona code review engine, verification, and findings type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant