Skip to content

fix(code-tidying): count "do not edit" as a generated marker only as a whole-file notice - #16338

Merged
kyle-sexton merged 1 commit into
mainfrom
fix/comment-lint-generated-marker
Nov 15, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix/comment-lint-generated-marker

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Refs: #16341

Summary

The comment lint skipped any file whose first 10 lines held the substring do not edit, so a hand-written # do not edit the order below exempted the whole file from the lint. This narrows the marker so only a whole-file notice counts, a condition for moving the lint from report to block.

Fix

  • One shared definition, plugins/code-tidying/scripts/generated-marker.ere (one ERE per line, read with grep -iE -f), used by both the comment lint and the remove-comments audit's upstream note in detect.sh. It ships beside the hook as a new asset in entries.json.
  • sync-managed and @generated match as before. do not edit counts only at the end of the line, before punctuation, before this file, this copy, by hand, manually or directly, or on a line that also has the word generated (Go's Code generated ... DO NOT EDIT., this repo's GENERATED from ... Do not edit this copy: headers).
  • The skip notice, --help text, README and the audit action doc state the new rule. No setting added: the marker list has no existing settings pattern to hang off, so it stays a fixed default.

Verification

  • plugins/code-tidying/git-hooks/comment-lint.test.sh: 55 passed, 0 failed. New cases: 11 real marker forms still skip; # do not edit the order below and Do not edit historical entries; ... are judged (both failed before the fix).
  • plugins/code-tidying/skills/remove-comments/scripts/detect.test.sh: 257 passed. New cases: Go and GENERATED from ... Do not edit this copy: headers get the upstream note; # do not edit the order below does not.
  • lefthook-remote.test.sh (14 passed) and lib/git-hooks/sh-entries.test.sh (181 passed); shellcheck clean on the four changed shell files.
  • Survey of every tracked file's first 10 lines: 942 skipped before, 934 after. The 8 that changed are all hand-written prose (eval prompts and samples saying "Do not edit anything", an append-only history log, a JSON schema description), none generated or synced.
  • Left out: the full .github node suite, which CI runs.

Related

Remaining

🤖 Generated with Claude Code

…a whole-file notice

The comment lint skipped any file whose first 10 lines held the
substring "do not edit", so a hand-written "# do not edit the order
below" exempted the whole file. The marker grammar now lives in one
file, scripts/generated-marker.ere, read by both the comment lint and
the remove-comments audit's upstream note. sync-managed and @generated
match as before; "do not edit" counts only at the end of a line, before
punctuation or "this file", "this copy", "by hand", "manually",
"directly", or on a line that also says "generated".

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kyle-sexton

Copy link
Copy Markdown
Member Author
  • verify skipped by kyle-sexton for this run: suites outside the change fail on main on this host; owner approved 2026-11-15

@kyle-sexton
kyle-sexton marked this pull request as ready for review November 15, 2026 15:07
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T15:10:50.974630Z 1251924 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 1251924ce06c57f44132589974e12220d35a0f7d: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Security review: no security issues found

This is a full review of the first head (not blocking only). I read every hunk of all 9 changed files.

What the change does: the comment lint skipped any file whose first 10 lines contained do not edit anywhere. Now that phrase only counts as a "generated file" marker when it reads as a whole-file notice. The rule lives in one new file, plugins/code-tidying/scripts/generated-marker.ere, which both the commit hook (comment-lint.sh) and the remove-comments audit (detect.sh) read. sync-managed and @generated still match as before.

Why there is nothing to report:

  • The skip only gets narrower. The new patterns let through a subset of what the old substring check did, so fewer files skip the lint. The lint checks comment hygiene, not security, so nothing it skips grants anyone more access.
  • A missing or unreadable marker file can't widen the skip. If generated-marker.ere can't be read, grep exits with status 2 and the file is linted instead of skipped.
  • No injection path. The hook finds the pattern file through its existing asset helper. detect.sh uses a fixed path relative to its own script directory. The file under check only reaches grep as input data, never as a pattern or a command argument. The old loop with shopt nocasematch is replaced by grep -qiE -f "$marker" < <(head -n 10 "$1"), with the filename quoted.
  • entries.json adds one data file to the hook's asset list. It isn't a plugin manifest (plugin.json / marketplace.json) and adds no code that runs.
  • No standing instruction is removed or softened. The README, audit.md and the --help text changes only describe the narrower rule.
  • No trusted-path files are touched. None of the 9 changed files matches a TRUSTED PATHS glob, and none touches a trust control, token scope, kill switch or merge hold.
  • No manifest fields change.

The PR description and the prior-findings file contain no embedded instructions. There are no earlier findings from this lane and no settled threads.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 1251924ce06c57f44132589974e12220d35a0f7d: read 9 of 9 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #16338 (head 1251924)

No findings. I read all 9 changed files in the diff.

What changes. The do not edit check used to match the phrase anywhere in a file's first 10 lines. It now matches only a whole-file notice. The rule lives in one new file, plugins/code-tidying/scripts/generated-marker.ere, and two readers use it through grep -qiE -f:

  • the comment lint, comment-lint.sh
  • the remove-comments audit's upstream note, detect.sh

What I checked:

  • The patterns. I walked each test string through the six patterns by hand:
    • The 11 marker forms in comment-lint.test.sh all match. Examples: bare DO NOT EDIT (end of line), DO NOT EDIT --> (punctuation), Code generated … DO NOT EDIT., GENERATED from … Do not edit this copy: and This file is generated; do not edit it.
    • Neither hand-written negative matches: do not edit the order below and Do not edit historical entries; ….
    • A CRLF line still matches the end-of-line pattern, because [[:space:]]* takes the \r.
  • Finding the file.
    • In comment-lint.sh, the asset helper finds generated-marker.ere both in an installed copy and in the plugin tree.
    • In detect.sh, $SCRIPT_DIR/../../../scripts/generated-marker.ere points to plugins/code-tidying/scripts/.
    • entries.json lists the file as an asset, and install.mjs converts installed text to LF. So a CRLF copy of the pattern file, which would stop every pattern matching, isn't a risk on the install path.
  • Other copies of the old check. I searched the plugin for anything else that tests for the do not edit substring and found none.
  • Path-scoped rules. skill-bodies-state-current-rules.md applies to audit.md. The edited text states the current rule and keeps no history, so it passes.
  • Closing issue. None. The PR only says Refs: #16341, so there are no acceptance criteria to check.
  • Plugin manifests. No plugin.json or marketplace.json changes. The changelog fragment's bump: patch fits a behavior fix.

Not verified. The test counts in the PR body (55 and 257 passed, shellcheck clean) and the before/after count over every tracked file's first 10 lines are the author's claims. I had no shell and couldn't run them.

Possible gap, not a finding. The new patterns no longer skip a few hand-written notices where do not edit is followed by a word, such as Autogenerated - do not edit unless …. That is the trade-off the PR describes. The author says the survey found only 8 files changed, all hand-written.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 2b56d2f Nov 15, 2026
114 of 115 checks passed
@kyle-sexton
kyle-sexton deleted the fix/comment-lint-generated-marker branch November 15, 2026 15:24
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant