Skip to content

fix(code-tidying): make audit-comment-residue --added-since cost track added lines - #10879

Merged
melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-8764-40819930818-1
Oct 29, 2026
Merged

melodic-automation-lanes[bot] merged 1 commit into
mainfrom
work-resolve-issue/issue-8764-40819930818-1

Conversation

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor

Closes #8764

Summary

Opened by the work-resolve-issue lane. The run's own summary:

Under --added-since, detect.sh now analyzes a line only when it, the line before it, or the line after it is an added line, so the number of detection calls follows the added lines instead of the length of every file that gained one. The window includes the line before, as well as the one after, so a wrapped pair is still found when only its first line is added. The issue's proposed rule (this line or the next) would have dropped that case. cr_comment_text, cr_detect_shapes and cr_detect_shapes_text now return their result in REPLY instead of on stdout, so neither the per-line loop nor the cr_run_lines_with pre-passes start a command substitution per line.

Not verified

  • detect.test.sh (test-bash) was not run here: this lane runs only its named wrappers. It is left to the PR's CI.
  • The Windows Git Bash timing and the paid acr-* eval run are split to #8848, per the issue.
  • tidy recorded as skipped: pass 4 (/ai-slop:audit fix) could not run its deterministic detector, which is not an allowed wrapper in this lane. It ran as a manual read of the fragment against the catalog and found nothing to fix. Passes 1-3 ran in full.
  • Tidy proposal not applied: compute comment text once per line in audit_file instead of in both cr_detect_shapes and the ct branch. It would leave cr_detect_shapes unused, and removing it needs lines outside the change.
  • The license and workaround pre-passes (cr_run_lines_with) still read each whole file under --added-since. They no longer fork per line, which the issue's step 3 says is probably enough; no Windows measurement was possible here.
  • review-venue.txt was absent, so the review ran locally in one fresh-context subagent.
  • Untracked files at the checkout root (.bash_profile, .bashrc, .gitconfig, .idea, .mcp.json, .profile, .ripgreprc, .vscode, .zprofile, .zshrc) were not created by this run and are not part of the change.

Fix

  • plugins/code-tidying/skills/audit-comment-residue/scripts/detect.sh: audit_file skips analysis of a line under --added-since unless line N-1, N or N+1 is added; it keeps prev_line current so the comment-residue-ignore marker still works and clears prev_ct/prev_shapes. It reads shapes and comment tex
  • plugins/code-tidying/skills/audit-comment-residue/scripts/lib/comment-shapes.sh: cr_comment_text sets REPLY instead of printing. cr_detect_shapes and cr_detect_shapes_text set REPLY to newline-separated shape names through a new cr_add_shape helper and return 0. cr_run_lines_with calls cr_comment_te
  • plugins/code-tidying/skills/audit-comment-residue/scripts/detect.test.sh: new --added-since cases. A wrapped pair with only its second line added and one with only its first line added are each reported at the first line. A comment-residue-ignore marker on an unchanged line suppresses the added line
  • .changes/code-tidying/work-resolve-issue-issue-8764-5b2e7d94.md: new patch changelog fragment (Fixed) for code-tidying, written by hand because new-changelog-fragment.sh refuses a detached HEAD.

Verification

The runner ran each check from the base copy against 18de287:

  • scripts/check-changelog-fragments.sh --check: passed

The run reports:

  • check-changelog-fragments: All 30 changelog fragment(s) under .changes/ are valid (run after the edit, after tidy, and after the review fixes)
  • check-affected: 12 passed, 6 skipped over 4 changed files (run after the edit, after tidy, and after the review fixes)
  • cant-fail-scan --file detect.test.sh --lines 987-1038: No can't-fail tests found, exit 0
  • fresh-context review subagent (opus) over the whole diff: no correctness bugs. Two notes, both fixed: the changelog overstated the cost claim because the pre-passes still read whole files, and the bash -x cost test depended on the default PS4, so both runs now pin PS4='+ '
  • read of audit_file in detect.sh and cr_run_lines_with in lib/comment-shapes.sh: no $(cr_detect_shapes or $(cr_comment_text remains in either
  • The lane run: https://github.com/melodic-software/claude-code-plugins/actions/runs/40819930818

Left out: the items under Not verified.

Related

#8764

Lane-Activity: work-resolve-issue/resolve-issue
@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 18de2877f3a4bfc6a96889988edc6392c7ae474b: 0 finding(s), 0 as inline comments.

No security issues found in this pull request.

The change has no security-relevant surface. It touches only a read-only comment-audit script under plugins/code-tidying/skills/audit-comment-residue/, its test, and a changelog fragment. No changed file matches a trusted path. No plugin.json or marketplace.json is changed, so there are no manifest items to report.

  • Injection: Nothing is passed to eval, source or a command. Comment text is only matched against [[ =~ ]] patterns and string-expanded. done <<<"$joined_shapes" reads shape names that cr_add_shape built from fixed literals, not from file content.
  • Trust boundary: The in_scope gating and the REPLY hand-off change only what the audit analyzes and how a result is returned. They add no new input source, network access, file write or privilege.
  • File mode: lib/comment-shapes.sh goes from 100644 to 100755. It is still only sourced, and the change adds no new caller or execution path.
  • Tests: detect.test.sh creates temporary git repositories under $TEST_TMPDIR only. Its bash -x trace output is written to files in that directory.
  • PR context: The PR description contains no embedded instructions directed at the lane.

Cost: no billed resource or plan change. The change only reduces the audit's runtime.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 18de2877f3a4bfc6a96889988edc6392c7ae474b: 0 finding(s), 0 as inline comments.

No findings. I read the full diff, the PR context and the surrounding audit_file code in detect.sh. I ran no tests, so the PR's own passing claims are author-claimed and unverified.

What I checked by reading the code

  • Scope window. audit_file now analyzes line N only when line N-1, N or N+1 is an added line.
    • A wrapped pair is still found when only its second line is added, because that line is in scope itself and the line before it is in the window.
    • It is also found when only its first line is added, because the second line is in the window through its N-1 neighbour.
    • Skipped lines still update prev_line, so a comment-residue-ignore marker on an unchanged line still suppresses the added line after it. They reset prev_ct and prev_shapes, so nothing stale carries across a skipped gap.
  • REPLY conversion. cr_comment_text, cr_detect_shapes and cr_detect_shapes_text now return through REPLY.
    • No helper they call touches REPLY between the reset and the final cr_add_shape. A grep of comment-shapes.sh shows REPLY used only in the converted functions and in cr_run_lines_with.
    • detect.sh is the only caller outside the library.
    • The old return-code contract (1 when no shape was found) is gone. Every call site that relied on it, || true included, was updated.
  • New tests.
    • The ignore.py fixture puts a newly added line right after an unchanged marker, so the suppression case is real.
    • The cost test counts cr_detect_shapes_text calls in a bash -x trace. I expect about 2 for the added-since run against at least 601 for the whole-file run, so the 10-call bound has wide headroom.
  • Closing issue fix(code-tidying): make audit-comment-residue --added-since cost track added lines, not file length #8764. The acceptance criteria are met or covered by tests. The two criteria that need Windows timing or the paid acr-* eval run are split to test(code-tidying): measure audit-comment-residue --added-since on Windows Git Bash and run the acr evals after #8764 #8848. No existing detect.test.sh assertion changed, since the diff only adds cases.
  • Manifest. The diff changes no plugin manifest. The changelog fragment has bump: patch under Fixed, which fits a performance fix with no behavior change.

Notes, not findings

  • lib/comment-shapes.sh changed mode from 100644 to 100755. It is a sourced library, so this does no harm, but it looks unintended.
  • The two pre-passes (cr_license_block_lines, cr_justified_run_lines) still read each whole file. They no longer fork per line. The changelog says this accurately.

@melodic-automation-lanes

Copy link
Copy Markdown
Contributor Author

The unattended merge path armed native auto-merge at head 18de2877f3a4bfc6a96889988edc6392c7ae474b.

@melodic-automation-lanes
melodic-automation-lanes Bot added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit 82432cf Oct 29, 2026
43 checks passed
@melodic-automation-lanes
melodic-automation-lanes Bot deleted the work-resolve-issue/issue-8764-40819930818-1 branch October 29, 2026 05:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(code-tidying): make audit-comment-residue --added-since cost track added lines, not file length

0 participants