Skip to content

fix(comment-hygiene): stop flagging bare domains as owner/repo#N - #74

Merged
kyle-sexton merged 3 commits into
mainfrom
fix/comment-hygiene-owner-regex
Jul 8, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
fix/comment-hygiene-owner-regex

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

Problem

The owner/repo#N tracker-reference rule let the owner segment contain ., so a bare domain with a numeric fragment in a comment — e.g. // see foo.com/bar#3 or # example.com/page#2 at a space/start boundary — was misread as a cross-repo issue reference and flagged. The existing leading-boundary ./- exclusion only caught hosts embedded in a longer URL (preceded by / or ., e.g. https://example.com/page#2), not hosts at a word boundary — so the adjacent comment's claim that dotted hosts were handled was only half true.

Fix

A GitHub owner login (user or org) may contain only alphanumerics and hyphens — never a . or _ (GitHub username rules; ≤39 chars, no leading/trailing/double hyphen). So the owner character class is restricted from [A-Za-z0-9._-] to [A-Za-z0-9-]. The repo segment keeps ./_ because repository names legitimately allow them. A dotted host can no longer be read as an owner.

Verified against the module test suite (comment-hygiene.test.sh), which I extended: the regression guard now covers bare domains (foo.com/bar#3, example.com/page#2, sub.example.com/path#9) alongside the existing scheme'd-URL cases. Genuine refs — including hyphenated owners (melodic-software/app#123, owner-name/repo#7) — still match.

Propagation

This library is vendored downstream:

  • ci-workflows carries a byte-identical copy (its comment-hygiene action self-test sources it) — a sync PR follows.
  • Consuming repos (e.g. kyle-sexton/github-iac) re-copy on their next standards sync.

Separate follow-up (not fixed here)

While committing I found the local lefthook shellcheck hook diverges from CI: CI passes --rcfile modules/shellcheck/.shellcheckrc (which sets external-sources=true), but the local hook relies on root .shellcheckrc auto-discovery, and standards has no root copy — so the hook emits SC1091 for any script that sources another (e.g. comment-hygiene.test.sh) and can't be committed without SHELLCHECK_OPTS=--external-sources. That's a pre-existing dogfooding gap in standards' own tooling, orthogonal to this fix, and touches the root-stub/sync-manifest model — flagging for a maintainer decision rather than fixing inline.

🤖 Generated with Claude Code


Note

Low Risk
Changes are limited to comment-scan regex behavior and ShellCheck config; no runtime auth, data, or production paths.

Overview
Comment-hygiene tightens the owner/repo#N tracker rule so dotted hosts in comments (e.g. foo.com/bar#3, example.com/page#2) are no longer treated as cross-repo issue refs. The owner segment no longer allows . (GitHub logins cannot contain dots); the repo segment still allows . and _, and _ remains in the owner class for GitHub Enterprise Managed User logins (e.g. mona-cat_octo/repo#12). Tests add bare-domain regression cases and an EMU owner positive case.

A root .shellcheckrc is added as the repo’s ShellCheck ruleset (aligned with modules/shellcheck/), so local hooks that auto-discover config from the repo root can resolve sourced scripts with external-sources=true and the same optional checks as CI’s --rcfile path.

Reviewed by Cursor Bugbot for commit 76df493. Bugbot is set up for automated code reviews on this repo. Configure here.

The owner/repo#N rule let the owner segment contain '.', so a bare domain
with a numeric fragment in a comment — e.g. `see foo.com/bar#3` or
`example.com/page#2` at a space/start boundary — was misread as an issue
reference and flagged. The leading-boundary '.'/'-' exclusion only caught
hosts embedded in a longer URL (preceded by '/' or '.'), not ones at a
word boundary, so the adjacent comment's claim that dotted hosts are
handled was only half true.

Fix it at the source: a GitHub owner (user or org) login may contain only
alphanumerics and hyphens — never a dot or underscore (GitHub username
rules; max 39 chars) — so restrict the owner character class to
[A-Za-z0-9-]. The repo segment keeps '.'/'_' because repository names
allow them. Genuine refs including hyphenated owners (melodic-software/
app#123, owner-name/repo#7) still match; the regression test now covers
bare domains alongside the existing scheme'd-URL cases.

Consumers vendor this library, so this needs to propagate: ci-workflows
carries a byte-identical copy (synced separately) and each consuming repo
re-copies on its next standards sync.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FSMCZgc6Dj6MaKLxDBSJFw
@claude

claude Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 1m 55s —— View job


PR Review

  • Gather context (changed files, CLAUDE.md)
  • Review regex change in comment-hygiene-patterns.sh
  • Review test changes in comment-hygiene.test.sh
  • Assess correctness, security, and test coverage
  • Post final review

Summary

The fix is correct and well-targeted. GitHub owner names (user or org logins) genuinely allow only [A-Za-z0-9-] — no . or _ — so restricting the owner character class is the right solution. The repo segment correctly retains . and _. The comment update is accurate. Tests are extended in the right direction.


Findings

No blocking issues. Three minor observations:

1. Positive-case test coverage is thin

The regression guard for bare-domain false positives (test 11) is solid, but the positive-case test (test 12) only checks a single fixture:

# comment-hygiene.test.sh:61
flagged_ref="$(printf '%s\n' '// tracked in owner-name/repo#7')"

The PR body mentions melodic-software/app#123 was also verified, but it isn't in the test. Consider adding a few more genuine-ref shapes to guard regressions in the other direction:

  • simple alphanumeric owner: org/repo#1
  • dotted repo name: owner/some.repo#5
  • underscored repo name: owner/some_repo#5

These are non-blocking nits — the existing test already catches the hyphenated-owner case.

2. Leading-hyphen owner is technically matchable (pre-existing, not introduced here)

The new owner class [A-Za-z0-9-] still allows a string that starts with -. The boundary exclusion [^[:alnum:]_/.-] prevents - itself from being the boundary character, but a line like:

; -owner/repo#1

…would match (; satisfies the boundary, -owner satisfies [A-Za-z0-9-]+). GitHub doesn't permit leading-hyphen logins, so this is a false-positive risk. This pre-dates the PR and is an edge case unlikely to appear in real code comments — just worth flagging for awareness.

3. Owner length limit not enforced (pre-existing, not introduced here)

GitHub caps owner names at 39 characters. A string of 40+ alphanumeric characters followed by /repo#N will still trigger the rule. Pre-existing behaviour, but the new, tighter character class reduces the scope of owner strings that can match, so the risk remains bounded.


Regex correctness trace

For # example.com/page#2 (the core bug):

Candidate start Boundary char Matches [A-Za-z0-9-]+/? Result
example (after space) space ✓ example then ., not / no match
com (after .) . is in excluded set ✗ — no match
page (after /) / is in excluded set ✗ — no match

Correct — the line is clean under the new regex.

For // tracked in owner-name/repo#7 (genuine ref):

Candidate start Boundary char Matches?
owner-name (after space) space ✓ owner-name then /repo#7 ✓ — flagged

Files reviewed

Verdict: ready to merge. The core fix is correct, minimal, and adequately tested. The optional test additions above would make the suite more defensive but are not required to ship this.

cursor[bot]
cursor Bot approved these changes Jul 8, 2026 •

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 25a741d7a4

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

kyle-sexton added a commit to melodic-software/ci-workflows that referenced this pull request Jul 8, 2026
…N fix (#62)

Syncs the vendored `modules/comment-hygiene/comment-hygiene-patterns.sh`
to match the source-of-truth fix in **melodic-software/standards** (PR:
melodic-software/standards#74).

## Why
The `owner/repo#N` tracker-reference rule let the owner segment contain
`.`, so a bare domain with a numeric fragment in a comment
(`foo.com/bar#3`, `example.com/page#2`) was misread as a cross-repo
issue reference. A GitHub owner login allows only alphanumerics and
hyphens (no `.`/`_`), so the owner class is tightened to `[A-Za-z0-9-]`;
the repo segment keeps `.`/`_`.

## Why sync here
This repo carries a **byte-identical** vendored copy of the library that
the comment-hygiene action's `superset-test.sh` sources directly. It
must track standards.

## Verified
- `superset-test.sh`: **pass** — the prefilter remains a superset (the
library now flags a strict subset of before, so no
admitted-but-unflagged gap opens).
- `shellcheck` on the vendored file: clean.

Order-independent with the standards PR (identical content); merge
either first.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Narrow regex change in comment-scan policy only; it reduces false
positives and stays aligned with the vendored standards copy and
superset tests.
> 
> **Overview**
> Syncs the vendored **`comment-hygiene-patterns.sh`** with the
standards library fix for **`owner/repo#N`** tracker detection.
> 
> The **`repo-issue`** regex now restricts the owner segment to
**`[A-Za-z0-9-]+`** (GitHub login rules), instead of allowing **`.`**
and **`_`**. Comments that look like bare URLs with a hash fragment
(e.g. **`foo.com/bar#3`**) are no longer flagged as cross-repo issue
refs; real references like **`org/my.repo#123`** still match via the
repo segment. Inline comments were updated to document that behavior and
to note case-insensitive matching across patterns.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
09e28b2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
kyle-sexton and others added 2 commits July 8, 2026 11:33
The lefthook shellcheck lane runs `shellcheck {staged_files}` with no --rcfile, relying on ShellCheck's upward directory search from each script to find a .shellcheckrc. No such file existed at the repo root, so external-sources never activated and every `source` line tripped SC1091, blocking commits. sync-manifest.yml already declares `shellcheck.root: .shellcheckrc` (a copy of the canonical modules/shellcheck/.shellcheckrc), so this dogfoods what the sync engine ships to consumers. ShellCheck rc files have no include/extend directive, so a copy — not a stub — is the only faithful form.

Co-Authored-By: Claude <[email protected]>
…tection

The owner segment of the owner/repo#N tracker-ref pattern excluded '_', which dropped GitHub Enterprise Managed User owner logins (they carry an '_SHORTCODE' suffix, e.g. mona-cat_octo). Widen the owner class to [A-Za-z0-9_-]+ — still excluding '.' so a bare domain host (foo.com/bar#3) is not misread as owner/repo. Adds a regression test asserting mona-cat_octo/scratch#12 is flagged while bare-domain cases stay unflagged.

Co-Authored-By: Claude <[email protected]>
@claude

claude Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 2m 19s —— View job


PR Review

  • Gather context
  • Read CLAUDE.md (none present)
  • Review regex change (EMU underscore fix)
  • Review .shellcheckrc addition
  • Review test changes

Summary

The EMU underscore regression is correctly fixed, the .shellcheckrc addition resolves the pre-existing dogfooding gap, and the tests are extended in both directions. No blocking issues.


Findings

1. Regex is now correct — . excluded, _ preserved

comment-hygiene-patterns.sh:90

- (^|[^[:alnum:]_/.-])[A-Za-z0-9._-]+/[A-Za-z0-9._-]+#[0-9]+
+ (^|[^[:alnum:]_/.-])[A-Za-z0-9_-]+/[A-Za-z0-9._-]+#[0-9]+

The Codex review was right: the original fix dropped _ unnecessarily. EMU logins take the form IDP-USERNAME_SHORTCODE (e.g. mona-cat_octo) — stripping _ would silently let those refs pass the hygiene gate. Only . needed to be removed to prevent bare-domain false positives. The updated class [A-Za-z0-9_-]+ is the minimal correct change.

Bare-domain trace — foo.com/bar#3 with the new regex:

Start candidate Boundary Owner token hits /? Result
foo (after ^) ^ ✓ foo then ., not / no match
com (after .) . is excluded ✗ — no match
bar (after /) / is excluded ✗ — no match

Clean. ✓

EMU trace — mona-cat_octo/scratch#12:
mona-cat_octo matches [A-Za-z0-9_-]+, /scratch#12 satisfies the rest → flagged. ✓

2. .shellcheckrc is byte-identical to modules/shellcheck/.shellcheckrc

Confirmed with diff. The root copy is purely a discovery stub for lefthook's shellcheck {staged_files} invocation (which has no --rcfile); the sync manifest already declared root: .shellcheckrc at line 40. Standards was missing its own stub — now added.

The source-path=SCRIPTDIR setting means shellcheck resolves sourced files relative to each script's own directory, which is correct regardless of where shellcheck is invoked from.

3. Test suite: 13/13, well-structured

comment-hygiene.test.sh:45-69

  • False-positive guard extended with three bare-domain cases (the regression this PR fixes)
  • New EMU underscore test guards the regression Codex caught
  • Updated assertion label is accurate

4. Pre-existing minor nits (not introduced here)

These existed before this PR and are outside its scope:

  • A leading-underscore "owner" at line start (e.g. _name/repo#1) would technically match, but no valid GitHub username begins with _
  • No owner length cap (GitHub: ≤39 chars) — risk bounded by the tighter character class

Verdict

Ready to merge. The EMU fix is the right call (keep _, drop only .), the .shellcheckrc addition correctly dogs-foods the sync manifest, and both regressions now have dedicated tests.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk: low. Cursor Bugbot completed successfully with no findings. Approved — localized comment-hygiene regex fix with expanded regression tests; no human review required.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@kyle-sexton
kyle-sexton merged commit 579d588 into main Jul 8, 2026
4 checks passed
@kyle-sexton
kyle-sexton deleted the fix/comment-hygiene-owner-regex branch July 8, 2026 15:37
kyle-sexton added a commit to melodic-software/ci-workflows that referenced this pull request Jul 8, 2026
…ary (#66)

Follow-up to #62, syncing the corrected library from
**melodic-software/standards#74**.

#62 tightened the `owner/repo#N` owner class to `[A-Za-z0-9-]`, which
dropped `_`. GitHub Enterprise Managed Users have logins with an
`_SHORTCODE` suffix (e.g. `mona-cat_octo`, `fabrikam_admin`), so `// see
mona-cat_octo/scratch#12` started scanning clean — the hygiene gate
missed deferred-work refs in EMU repos. The corrected owner class
`[A-Za-z0-9_-]` excludes only `.` (keeping the bare-domain fix) while
preserving `_`.

Re-synced byte-identical to standards main. `superset-test.sh` passes;
`shellcheck` clean.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Low Risk**
> Single-regex tweak in a vendored detection policy; improves coverage
for EMU refs without changing auth or runtime behavior.
> 
> **Overview**
> Restores **`_` in the `owner/repo#N` regex owner class**
(`[A-Za-z0-9_-]+` instead of `[A-Za-z0-9-]+`) so comment-hygiene flags
cross-repo refs like `mona-cat_octo/scratch#12` again after a prior
tightening dropped underscores.
> 
> Comments now state that **only `.` is excluded** from owners
(bare-domain false positives) and that **GitHub EMU logins** need `_` in
the owner segment. Repo-name matching and boundary rules are unchanged.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
218bef0. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
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.

1 participant