Skip to content

feat(pin-comment-convention): add dual-form pin-comment convention lint - #248

Merged
kyle-sexton merged 7 commits into
mainfrom
docs/244-pin-comment-convention
Jul 22, 2026
Merged

kyle-sexton merged 7 commits into
mainfrom
docs/244-pin-comment-convention

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Closes #244

Summary

  • Documents the dual-form pin-comment convention (# vX.Y.Z primary / # <short-sha> <date>[ <note>] fallback) for uses: references to melodic-software/ci-workflows reusable workflows and composite actions pinned by 40-character SHA, in a new pin-comment-convention component README following the comment-hygiene/path-detection shape.
  • pin-comment-patterns.sh scans real YAML nodes via yq (Mike Farah's yq v4, this repo's established YAML tool), not a per-line text regex: explode(.) resolves anchors/aliases first, then extraction is scoped to exactly the two positions GitHub Actions executes a uses: value from — jobs.<id>.uses and jobs.<id>.steps[*].uses — so a plain, quoted, anchored, or aliased pin is scanned the same way, and uses:-shaped text inside a run: block, a YAML comment, a strategy.matrix.include entry, or a step's own with: input is never a false-positive candidate. scan-workflow-files.sh is a minimal driver (file enumeration, exit-code mapping) that this repo's own CI runs as its live consumer.
  • The tag form (# vX.Y.Z) is format-only — GitHub tag data isn't verifiable by a static scan. The fallback form (# <short-sha> <date>[ <note>]) is provenance-checked: <short-sha> must case-insensitively prefix the same line's pinned SHA, verified directly rather than deferred to runner-policy's whole-repository isShaClaim heuristic. Both READMEs cross-point to each other so this boundary — and where it now genuinely overlaps runner-policy's pin-provenance-drift check versus where that check remains the sole authority — is explicit, not silent.
  • The pinned 40-character SHA is matched case-insensitively (same git object regardless of hex letter case, matching runner-policy's own treatment); the fallback comment's own short-SHA and the tag form's leading v stay case-sensitive by deliberate, documented design (an authored documentation string with a fixed canonical spelling, and a tag's case being part of its git-ref identity, respectively).
  • Wires the new check into this repo's own CI (pin-comment-convention job, added to ci-status, with the same checksum-pinned yq install the distribution job uses) as the live consumer: it scans this repo's real .github/workflows/*.yml and *.yaml today and passes cleanly, satisfying the component-lifecycle admission evidence with a real baseline rather than a deferred claim.
  • Adds a distribution/sync-manifest.yml component entry so the policy is distributable to other repositories via the existing materialization mechanism (no targets: adoption yet — that's a separate consumer-side integration).
  • Reaffirms build(dependabot): stop proposing governed reusable-workflow bumps #102 (Renovate rejected for pin tracking) with the updated research rationale as a PR comment, pointed to from the new README rather than duplicated inline.

Review history and defensive pass

This PR went through several rounds of automated review findings, each fixed structurally rather than patched around:

  1. A quoted uses: scalar (uses: 'owner/repo@sha') bypassed the original line-regex scanner entirely.
  2. The live-consumer CI step only globbed .github/workflows/*.yml, missing .yaml.
  3. The line-regex approach itself could both false-flag uses:-shaped text inside a run: block/YAML comment and miss a YAML-anchored/aliased uses: scalar — root-caused by replacing the line regex with yq-based YAML-node extraction (findings 1 and 2 became structurally subsumed by this change).
  4. The rewritten extraction still required a lowercase-hex pinned SHA, silently skipping an uppercase-hex pin.
  5. The rewritten extraction was an untargeted whole-document walk (.. | select(has("uses"))), which could false-positive on an unrelated data field named "uses" (a strategy.matrix.include entry, a step's with: input).
  6. The fallback form's <short-sha> accepted any 7-40 lowercase-hex token by shape, but runner-policy's isShaClaim heuristic wouldn't recognize an all-digit or all-a-f token as a SHA claim, so that narrow shape could pass this component's check while runner-policy never attempted to verify it.

Findings 4 and 5 were fixed together with a deliberate defensive self-review pass hunting the same classes (case sensitivity, quoting, YAML structure position, field conflation) before that push, rather than waiting for another round:

  • Confirmed the org/repo segment (melodic-software/ci-workflows) and the .github/(workflows|actions)/ directory segment are correctly left case-sensitive — the former has no known real-world alternate spelling in this fleet, and case-insensitively matching it would require widening the latter too, which are genuinely case-sensitive git tree paths; documented this reasoning in the README rather than leaving it silently unaddressed.
  • Verified (and added a test for) a document with no jobs: key, jobs: null, jobs: {}, and a malformed jobs: scalar all scanning clean rather than erroring — the driver's file glob can plausibly reach a non-workflow file.
  • Verified the .github/(workflows|actions)/ path segment already handles arbitrarily nested action subdirectories.

Finding 6 was root-caused rather than aligned to runner-policy's subset: since the fallback form's position makes the token an unambiguous SHA claim about the exact pin on the same line, the short-sha is now checked directly against that pin (a real provenance check) instead of widening the accepted character shape to match a heuristic meant for free-form, whole-repository scanning — which would have also rejected a legitimate all-digit abbreviated SHA, a real git prefix shape.

Also found and fixed along the way (not a review finding, surfaced by the yq rewrite): IFS=$'\t' read -r a b c coalesces adjacent tab delimiters because bash treats tab as "IFS whitespace" regardless of what IFS is set to, silently losing a genuinely empty comment field and therefore never reporting missing-comment. Replaced with parameter-expansion field extraction, the pattern already used elsewhere in this file.

Test plan

  • bash harness/shell/run-tests.sh components/pin-comment-convention/pin-comment-convention.test.sh — 34 assertions, all pass
  • bash components/pin-comment-convention/scan-workflow-files.sh .github/workflows/*.yml .github/workflows/*.yaml — clean (this repo's existing pins already conform)
  • bash distribution/sync-manifest.sh validate — 30 components, 8 targets, valid
  • shellcheck --rcfile .shellcheckrc on all scripts — clean
  • markdownlint-cli2, typos, editorconfig-checker on all changed files — clean
  • lefthook pre-commit (typos, shellcheck, editorconfig, gitleaks, markdownlint) — all green on every commit

Related

Known issue: hosted CI may fail 0-step/2s (billing) — environmental, unrelated to this change.

🤖 Generated with Claude Code

Documents and lints the dual-form trailing-comment convention on
`uses:` references to melodic-software/ci-workflows reusable workflows
and composite actions pinned by 40-character SHA (`# vX.Y.Z` primary,
`# <short-sha> <date>[ <note>]` fallback for untagged pins). The check
covers form only and explicitly cedes short-SHA provenance correctness
to runner-policy's existing pin-provenance-drift check, cross-pointered
from both READMEs. Wired into this repo's own CI as the live consumer,
scanning its real .github/workflows/*.yml (currently clean).

Closes #244

## Related

- Refs #102 (reaffirmed with updated rationale, see PR comment)
- Refs #197 (deferred pin-alignment mechanism, unaffected)
- Refs melodic-software/medley#1624 (fleet pin-comment census)

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 4m 42s —— View job


Code Review — PR #248: pin-comment-convention

  • Gather context (CLAUDE.md, REVIEW.md)
  • Review changed files
  • Analyze test coverage and correctness
  • Check shell script safety and correctness
  • Post final review findings

No critical or blocking issues found. The design is coherent: the library/driver split mirrors comment-hygiene, the cross-pointer to runner-policy is precise and bidirectional, the CI wiring is correct, and the test suite covers every documented form and documented drift shape. Four nits below.


🟡 Nit 1 — Single-space strictness is undocumented but enforced

pin-comment-patterns.sh L63–64

local tag_re='^#[[:space:]]v[0-9]+\.[0-9]+\.[0-9]+[[:space:]]*$'
local fallback_re='^#[[:space:]][0-9a-f]{7,40}[[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}([[:space:]]+.+)?[[:space:]]*$'

Both [[:space:]] tokens in the primary position match exactly one space character. That means # v1.0.0 (two spaces after #) or # 90f1c54 2026-07-18 (two spaces between short-SHA and date) would be flagged as invalid-form. The README and library header describe the forms without stating this single-space requirement. If a consumer formats their comment with two spaces (e.g., editor auto-alignment), they'll get a surprising failure. Either document the constraint in both READMEs and the library header, or relax the inner token to [[:space:]]+. Fix this →


🟡 Nit 2 — Uppercase hex in fallback short-SHA is unspecified and untested

pin-comment-convention.test.sh L32–36

fallback_re uses [0-9a-f] (lowercase only), so # 90F1C54 2026-07-18 (uppercase) would be rejected. The policy specifies lowercase, which is correct. But the test suite does not exercise this boundary — there's no case verifying that an uppercase short-SHA comment is flagged as invalid-form. Add a single inline assertion analogous to line 35: Fix this →


🟡 Nit 3 — Pre-release SemVer exclusion is an undocumented policy restriction

pin-comment-patterns.sh L63 / README.md L9

tag_re accepts only vMAJOR.MINOR.PATCH — pre-release identifiers (v1.0.0-rc.1, v1.0.0-alpha.2) are rejected. The README says "full SemVer release tag" but SemVer 2.0 includes pre-release identifiers in its grammar. If ci-workflows ever ships an RC tag and someone pins to it with # v1.0.0-rc.1, they'll get an invalid-form error and be forced to use the fallback. Worth one sentence in the README clarifying that pre-release SemVer identifiers are deliberately not accepted in the primary form (the fallback covers that case). Fix this →


🟡 Nit 4 — scan-workflow-files.sh silently exits 0 when no files match

scan-workflow-files.sh L21

[[ -f "$file" ]] || continue

A non-existent file argument is silently skipped. This is benign for the CI invocation (glob expansion in bash before the script sees argv), but if called with a non-matching glob from a shell with noglob set, the literal *.yml string would be skipped and the script would exit 0 having scanned nothing. A one-line warning to stderr when a file argument is not found would make diagnostic failures explicit without changing exit-code semantics.


Overall

The component is solid: clean library/driver split, correct bash dynamic-scoping idiom (documented as private, called only from pcc::scan_text), no injection surface (file contents are treated as strings), correct exit-code propagation with set -euo pipefail + || rc=$?, complete fixture and inline test coverage for all four documented bad shapes, and an accurate bidirectional cross-reference with runner-policy. The CI wiring is a faithful copy of the comment-hygiene job shape. The sync-manifest entry distributes only the runtime files, not test infrastructure — that's the right split.

@kyle-sexton
kyle-sexton enabled auto-merge (squash) July 22, 2026 17:49

@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: b72ed5d86c

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

Comment thread .github/workflows/ci.yml Resolved
…ensions

Two Codex review findings on standards#248:

- pin-comment-patterns.sh's uses: regex required melodic-software
  immediately after the colon, so a single- or double-quoted YAML
  scalar (`uses: 'owner/repo@sha'`) skipped the check entirely — a
  silent false pass. The regex now accepts an optional matching-not-
  required quote character before and after the ref, covering both
  quote styles without touching the comment-format check itself.
  Adds inline test cases for both quote styles, valid and invalid
  comment.
- ci.yml's live-consumer step only globbed .github/workflows/*.yml,
  so a future .yaml workflow would escape scanning. Globs both
  extensions now; the driver's existing `[[ -f "$file" ]] || continue`
  guard already tolerates the currently-unmatched .yaml glob.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

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


Code Review — PR #248: pin-comment-convention (follow-up on 3cf4f8a)

  • Gather context (CLAUDE.md, REVIEW.md, prior review)
  • Diff the latest commit against the previous reviewed state
  • Verify Codex findings were addressed (quoted refs, .yaml glob)
  • Check for any regressions or new issues introduced
  • Post final review findings

Both Codex findings from the prior review pass are correctly addressed. No regressions introduced. Details below.


Codex findings: verified closed

Quoted refs (pin-comment-patterns.sh L67)

The fix introduces ['"]? before and after the ref path via the shell quoting idiom ['\''"]?. The regex character class is correct — it matches either quote style or no quote, and the group numbering (BASH_REMATCH[2] / BASH_REMATCH[3]) is unchanged since ['"]? adds no capture groups. The four new test cases cover the material matrix: single-quoted clean, single-quoted invalid-form, double-quoted clean, double-quoted missing-comment. The deliberate non-enforcement of matching quotes (open ', close ") is documented in the inline comment and is the right scope choice for a form-only check.

.yaml glob (.github/workflows/ci.yml L755)

The invocation now passes both *.yml and *.yaml to the driver. The existing [[ -f "$file" ]] || continue guard in scan-workflow-files.sh:21 already handles the currently-unmatched .yaml glob without error. ✓


Remaining nits from prior pass

The following three nits raised in the prior review were not addressed in this commit. They are still open but remain non-blocking:

🟡 Nit 1 — Single-space strictness undocumented

pin-comment-patterns.sh L68–69 — tag_re and fallback_re use [[:space:]] (exactly one space) after # and between fallback fields. The README and library header do not state this constraint. A consumer who formats # v1.0.0 (two spaces) gets a surprising invalid-form. Document the single-space requirement or relax to [[:space:]]+. Fix this →

🟡 Nit 2 — Uppercase hex boundary untested

pin-comment-convention.test.sh — fallback_re uses [0-9a-f] (lowercase only); uppercase short-SHA should be rejected. The test suite has no assertion verifying that # 90F1C54 2026-07-18 is flagged as invalid-form. Add one inline case after L56. Fix this →

🟡 Nit 3 — Pre-release SemVer exclusion is an undocumented policy restriction

README.md L9 — tag_re accepts only vMAJOR.MINOR.PATCH; pre-release identifiers (v1.0.0-rc.1) are rejected and the author must use the fallback form. The README describes the primary form as "full-SemVer release tag" but SemVer 2.0 includes pre-release identifiers. Worth one clarifying parenthetical so consumers aren't surprised. Fix this →


Overall

The fix commit is clean and correct. Both Codex P2s are resolved with appropriate test coverage. The three remaining nits are carry-overs from the prior pass — none are blocking. The component is ready to merge once those are triaged (or deferred with a documented rationale).

@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: 3cf4f8a4d4

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

Copy link
Copy Markdown
Member Author

🔒 babysit-prs lane claiming this PR for on-branch fix work this cycle (amendment-round: 16, safe tier). Will fix clear branch-owned findings and push; will not resolve threads or merge (safe tier).

The exec-bit CI gate requires files carrying a shebang to be mode
100755 in the git index. scan-workflow-files.sh and
pin-comment-convention.test.sh both begin with `#!/usr/bin/env bash`
but were committed 100644, failing the gate. pin-comment-patterns.sh
is a sourced library with no shebang and correctly stays 100644.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

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


Code Review — PR #248: pin-comment-convention (follow-up on c64815c)

  • Gather context (CLAUDE.md, REVIEW.md, prior reviews)
  • Diff the latest commit against previously reviewed state
  • Verify remaining nits were addressed
  • Check for regressions or new issues
  • Post final review findings

Latest commit: verified clean

c64815c — fix(pin-comment-convention): set exec bit on scan scripts

The only change is file-mode corrections: pin-comment-convention.test.sh and scan-workflow-files.sh promoted from 100644 → 100755 (both carry #!/usr/bin/env bash). pin-comment-patterns.sh is a sourced library with no shebang and correctly stays 100644. No code changes, no regressions.


Remaining nits from prior passes (carry-over)

None of the three open nits were addressed in this commit. Still non-blocking.

🟡 Nit 1 — Single-space strictness undocumented

pin-comment-patterns.sh L68–69 — both tag_re and fallback_re use [[:space:]] (exactly one space) after # and between fallback fields. The README and library header do not state this constraint. # v1.0.0 (two spaces) would be flagged as invalid-form. Document the single-space requirement or relax to [[:space:]]+. Fix this →

🟡 Nit 2 — Uppercase hex boundary untested

pin-comment-convention.test.sh — fallback_re uses [0-9a-f] (lowercase only); uppercase short-SHA should be rejected. No test asserts that # 90F1C54 2026-07-18 is flagged as invalid-form. Add one inline case after L56. Fix this →

🟡 Nit 3 — Pre-release SemVer exclusion undocumented

README.md L9 — tag_re accepts only vMAJOR.MINOR.PATCH; pre-release identifiers (v1.0.0-rc.1) are rejected silently. The README says "full-SemVer release tag" but SemVer 2.0 includes pre-release identifiers. Worth one clarifying parenthetical so consumers aren't surprised. Fix this →

🟡 Nit 4 — Raw-text scan can false-positive on non-uses: key occurrences

pin-comment-patterns.sh L67 — uses_re matches anywhere on a line, not anchored to a YAML uses: key position. A run: block line containing the literal text uses: melodic-software/ci-workflows/...@<sha> (e.g., a script that prints or echoes a workflow ref) would trigger a false missing-comment violation. The library header documents form-only scope but does not mention the raw-text assumption. This is low probability in practice, but worth a one-line note in the library header so operators know what to expect. Fix this →


Overall

c64815c is a clean exec-bit housekeeping commit with no logic changes and no regressions. All four nits above are carry-overs or newly identified suggestions — none are blocking. The component remains ready to merge once the nits are triaged.

@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: c64815c06a

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

The fallback form's short-SHA is lowercase hex only (`[0-9a-f]`), and an
uppercase short-SHA is already rejected as invalid-form, but no case
exercised that boundary. Adds the assertion so the lowercase-only
constraint is locked by a test.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

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


Code Review — PR #248: pin-comment-convention (follow-up on c05179e)

  • Gather context (CLAUDE.md, REVIEW.md, prior reviews)
  • Diff the latest commit against previously reviewed state
  • Verify Nit 2 (uppercase hex boundary test) was correctly addressed
  • Check remaining open nits
  • Check Codex P2 on uppercase SHA in uses_re
  • Post final review findings

Latest commit: verified clean

c05179e — test(pin-comment-convention): assert uppercase short-SHA is invalid-form

The commit adds a single test case at pin-comment-convention.test.sh L58–61:

# The fallback short-SHA is lowercase hex only; an uppercase short-SHA does
# not read as the documented fallback shape and is flagged as invalid-form.
pcc::scan_text 'uses: melodic-software/ci-workflows/.github/workflows/x.yml@90f1c54935203fa31b5b3d1f41531228be2c2b7f # 90F1C54 2026-07-18' >/dev/null
assert_exit 'uppercase short-sha in fallback is invalid-form' 1 "$?"

The test is mechanically correct:

  • uses_re matches because the 40-char SHA in the uses: field is lowercase ✓
  • BASH_REMATCH[2] is non-empty (# 90F1C54 2026-07-18) → not missing-comment
  • fallback_re uses [0-9a-f]{7,40} (lowercase only), so 90F1C54 (uppercase) does not match → invalid-form violation → exit 1 ✓
  • Assertion is correct; comment is accurate and useful ✓

Nit 2 is now closed.


Codex P2: uses_re uppercase pin SHA — distinct from the test just added

The Codex finding from the prior pass targets a different boundary:
pin-comment-patterns.sh L67 uses [0-9a-f]{40} for the pinned commit SHA in uses_re. An uppercase SHA in the uses: line itself — uses: melodic-software/ci-workflows/...@90F1C54935203FA31B5B3D1F41531228BE2C2B7F — would not be matched by uses_re at all, silently escaping the check regardless of what comment follows.

The test just added exercises the comment field (lowercase pin SHA, uppercase comment SHA); this is the orthogonal case (uppercase pin SHA, any comment). In practice, git rev-parse always emits lowercase hex, so the risk is low. But since runner-policy's provenance scanner accepts uppercase case-insensitively, the asymmetry is worth a one-line note in the library header so operators understand the scan surface. This remains non-blocking.


Remaining nits from prior passes (carry-over, non-blocking)

🟡 Nit 1 — Single-space strictness undocumented

pin-comment-patterns.sh L68–69 — tag_re and fallback_re both use [[:space:]] (exactly one space) after # and between fallback fields. The README and library header describe the forms without stating this single-space constraint. A consumer who writes # v1.0.0 (two spaces after #) or # 90f1c54 2026-07-18 (two spaces between SHA and date) gets a surprising invalid-form. Either document the constraint or relax to [[:space:]]+. Fix this →

🟡 Nit 3 — Pre-release SemVer exclusion undocumented

README.md L9 — tag_re accepts only vMAJOR.MINOR.PATCH; pre-release identifiers (v1.0.0-rc.1) are rejected. The README says "full-SemVer release tag" but SemVer 2.0 includes pre-release identifiers. A consumer pinning an RC tag must use the fallback form; the README doesn't say that. Worth one parenthetical. Fix this →

🟡 Nit 4 — Raw-text scan false-positive surface undocumented

pin-comment-patterns.sh L67 — uses_re matches anywhere on a raw line. A run: block containing uses: melodic-software/ci-workflows/...@<sha> as literal text (e.g., a cat or echo) would trigger a false missing-comment violation. The library header's "form only" paragraph is accurate but doesn't call out the raw-text assumption. A one-line note would set operator expectations. Fix this →


Overall

c05179e is a minimal, correct test addition that closes Nit 2. The three carry-over nits and the Codex P2 on uppercase uses_re pins all remain non-blocking. The component is ready to merge once the nits are triaged.

@kyle-sexton

Copy link
Copy Markdown
Member Author

babysit-prs safe-tier classification — review nits (head c05179e)

Reacted 👍 (at least one finding actioned). Per-finding triage:

# Finding Classification Evidence Action
1 Single-space strictness undocumented (pin-comment-patterns.sh L68–69) VALID tag_re/fallback_re use [[:space:]] (exactly one char) after # and between fallback fields, so #&nbsp;&nbsp;v1.0.0 (two spaces) is flagged invalid-form. Confirmed against the code. Deferred to author — document-as-intentional vs relax to [[:space:]]+ is a policy choice on a normative FORM check; a normative change carries the cross-doc reconciliation step (distribution/governance-process.md). Safe tier does not decide it.
2 Uppercase-hex short-SHA boundary untested (pin-comment-convention.test.sh) VALID — fixed fallback_re is [0-9a-f] (lowercase-only); an uppercase short-SHA was already rejected but never exercised. Added an assertion that # 90F1C54 2026-07-18 is invalid-form; all 17 tests pass, shellcheck -x clean. Fixed in c05179e
3 Pre-release SemVer exclusion undocumented (README.md L9) VALID tag_re v[0-9]+\.[0-9]+\.[0-9]+ rejects v1.0.0-rc.1 → invalid-form (the fallback form covers untagged/pre-tag pins). Confirmed. Deferred to author — a one-line README clarification of the deliberate exclusion is a normative-doc change (author intent + reconciliation).
4 Raw-text scan can false-positive on non-uses:-key occurrences (pin-comment-patterns.sh L67) VALID uses_re is unanchored, so a run:-block line (or a commented-out line) containing literal uses: melodic-software/ci-workflows/...@<40-hex> matches and is flagged missing-comment. Same finding as the Codex inline thread. Confirmed. Deferred to author — anchoring to a real YAML uses: key / node-parsing changes the documented FORM-only design (header L27–37, complementary to runner-policy's parser); architectural, needs reconciliation.

Nits 1, 3, 4 are non-blocking and left for author triage (this review itself frames them as "triage or defer with documented rationale"). This safe-tier lane fixed only the judgment-free, branch-owned item (Nit 2) and did not resolve any threads.

…not text lines

Codex flagged a real structural gap in the line-regex scanner: it could
both false-flag uses:-shaped text inside a run: block body or a YAML
comment, and miss a YAML-anchored/aliased uses: scalar the existing
runner-policy parser already handles. Fixing this as a third
band-aid on top of the earlier quote-handling patch would still leave
the same class of gap open for the next YAML shape; replacing the
line regex with yq-based tree extraction closes it structurally
instead.

pcc::scan_text now pipes <content> through yq (explode(.) to resolve
anchors/aliases first, then `.. | select(has("uses")) | .uses` to walk
every uses: node at any depth) and validates each in-scope pin's
line_comment against the two documented forms. This subsumes the
prior quote-handling fix (yq resolves quoted scalars to their plain
value) and correctly distinguishes a whole aliased step (comment
travels with it) from a bare scalar-value alias (comment does not).

Along the way, found and fixed a real bug the yq output surfaced:
`IFS=$'\t' read -r a b c` coalesces adjacent tabs because bash treats
tab as "IFS whitespace" regardless of what IFS is set to, silently
losing a genuinely empty comment field and therefore never reporting
missing-comment. Replaced with parameter-expansion field extraction,
the pattern this file's own driver and the original version already
used elsewhere.

Adds the checksum-pinned yq 4.53.3 install step (matching the
`distribution` job's exact block) to the pin-comment-convention CI
job, and a yq-availability skip_suite guard to the test file matching
distribution/sync-manifest.test.sh's existing precedent. New test
cases: whole-step anchor/alias (valid + invalid comment), bare
scalar-value alias (valid + invalid — and that the comment does not
propagate), run:-block false-positive, YAML-comment false-positive.
Fixtures updated to match; row-count assertions recomputed against
actual yq output rather than assumed.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 39s —— View job


Code Review — PR #248: pin-comment-convention (follow-up on 1672680)

  • Gather context (CLAUDE.md, REVIEW.md, prior reviews)
  • Diff the latest commit against the previously reviewed state (c05179e)
  • Verify the yq-based YAML scanning approach is correct and complete
  • Check remaining open nits from prior passes
  • Check for regressions or new issues
  • Post final review findings

Latest commit: verified correct

1672680 — refactor(pin-comment-convention): scan real YAML uses: nodes via yq, not text lines

This commit replaces the line-oriented text regex with a yq-powered YAML tree walk. The approach is sound.

Nit 4 and both Codex P2s on raw-text scanning: closed. explode(.) | .. | select(has("uses")) | .uses walks the parsed YAML tree, so uses:-shaped text in run: block bodies or YAML # comments is never a candidate. The --yaml-fix-merge-anchor-to-spec=true flag handles merge-key (<<:) anchors correctly. explode() resolves anchors and aliases before the walk. All prior false-positive surfaces are eliminated.

Nit 1 (single-space strictness): partially resolved. yq strips exactly one leading # from line_comment, so any extra spaces after # appear as leading whitespace in raw. The ^[[:space:]]* prefix in both form patterns now tolerates that. The library header documents the behavior explicitly. The inter-field single-space constraint (short-sha[[:space:]]date) remains and is now intentional — the comment correctly omits it from the policy dimension list.

Tab-field splitting: correct. The IFS= read -r rec + parameter-expansion approach is the right call — IFS=$'\t' read -r a b c would collapse adjacent tabs and silently shift fields when line_comment is empty. The comment explains the reason. Traced through both the populated and empty-comment cases: correct in both.

Anchor/alias semantics: correctly modeled. Whole-step anchor/alias (- &s uses: …, - *s): after explode(), the alias resolves to the full step including the line_comment, so the invalid-comment test correctly flags 2 violations. Bare scalar alias (uses: *v): yq does NOT copy the anchor's line_comment to the alias node, so an alias without its own comment is flagged missing-comment. The test suite validates both shapes.


One new nit

🟡 Nit 5 — Aliased violations may report the anchor's line number for both occurrences

pin-comment-patterns.sh L97

After explode(), yq replaces each alias with a copy of the anchor's node. The line property on that copy likely reflects the anchor's source line, not the alias's position in the file. A whole-step anchor/alias violation would therefore emit two lines with the same lineno, both pointing to the anchor's position. The test asserts that two violations are emitted (assert_row_count … 2) but does not verify they have distinct line numbers. In practice, a user seeing two violations at the same line would know one is from the alias, but the output is ambiguous. Worth a one-line note in the pcc::scan_text header (alongside the existing lineno relative to <content> note) that alias violations may report the anchor's line.


Remaining nits from prior passes (carry-over, non-blocking)

🟡 Nit 3 — Pre-release SemVer exclusion undocumented

README.md L9 — the primary form accepts only vMAJOR.MINOR.PATCH; pre-release identifiers (v1.0.0-rc.1) are rejected and the author must use the fallback form. The README says "full-SemVer release tag" but SemVer 2.0 includes pre-release identifiers. Fix this →

🟡 Codex P2 — Uppercase pin SHA in value_re escapes scanning

pin-comment-patterns.sh L92 — value_re uses [0-9a-f]{40} (lowercase only). An uppercase 40-hex SHA in the uses: value would not match value_re and would escape scanning entirely, regardless of comment. The runner-policy scanner matches case-insensitively. Deferred by prior babysit-prs pass; still non-blocking.


Overall

1672680 is a well-scoped, technically correct refactor. The move from line-regex to YAML tree extraction resolves the remaining structural issues from prior passes cleanly. The implementation handles all documented YAML shapes (plain, quoted, anchored, aliased — both whole-step and scalar-value), correctly models the difference between whole-step and scalar-value alias comment inheritance, and adds test coverage for the two false-positive guard cases (run block, YAML comment). The tab-splitting choice is correct and documented. No regressions from prior functionality. Two carry-over nits and one new minor nit (aliased violation line numbers) remain — none are blocking. The component is ready to merge.

@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: 16726803c2

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

…ept uppercase pinned SHA

Two more Codex findings on the yq rewrite, fixed together with a
defensive self-review pass rather than one commit each:

- The untargeted `.. | select(has("uses"))` walk matched any map
  anywhere in the document with a key literally named "uses" — a
  strategy.matrix.include entry or a step's own with: input could
  false-positive. Extraction is now scoped to exactly the two
  positions GitHub Actions executes a uses: value from:
  jobs.<id>.uses and jobs.<id>.steps[*].uses.
- The pinned 40-character SHA in uses:...@<sha> required lowercase
  hex only, so an uppercase-hex pin silently escaped the check
  entirely (same false-negative class as the earlier quoted-ref bug).
  It is now matched case-insensitively, matching how the
  runner-policy provenance scanner already treats it. The fallback
  comment's own short-SHA stays lowercase-only exactly as the
  concurrently-landed test locked it: that field is an authored
  documentation string with a fixed canonical spelling, not a
  resolved git object.

Defensive pass (same false-negative/false-positive classes Codex
kept finding: case sensitivity, quoting, YAML structure position,
field conflation): confirmed the org/repo segment and the
.github/(workflows|actions)/ directory segment are deliberately left
case-sensitive (the former has no known real-world alternate
spelling in this fleet and would require case-insensitively widening
the latter, which are real case-sensitive git tree paths, to match
it; the latter's case sensitivity is a fact of how GitHub resolves
the path, not a policy choice) and documented that reasoning in the
README rather than silently leaving it unaddressed. Verified a
document with no jobs: key, jobs: null, jobs: {}, and a malformed
jobs: scalar all scan clean rather than erroring (the driver's file
glob can plausibly reach a non-workflow file) and added a test
locking that. Verified the .github/(workflows|actions)/ path segment
already handles arbitrarily nested subdirectories.

New tests: uppercase pinned SHA (valid + invalid comment),
matrix.include decoy, with: input decoy, no-jobs-key document. All
30 assertions pass; shellcheck, markdownlint, typos, editorconfig
clean; driver dogfood against this repo's real workflow files stays
clean.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Claude finished @kyle-sexton's task in 3m 49s —— View job


Code Review — PR #248: pin-comment-convention (follow-up on 3f109bc)

  • Gather context (CLAUDE.md, REVIEW.md, prior reviews)
  • Diff the latest commit against the previously reviewed state (1672680)
  • Verify Codex P2 (executable uses paths restriction) was addressed
  • Verify Codex P2 (uppercase pinned SHA escape) was addressed
  • Check remaining nits from prior passes
  • Check for regressions or new issues
  • Post final review findings

Latest commit: verified correct

3f109bc — fix(pin-comment-convention): scope to executable uses: positions, accept uppercase pinned SHA

Three changes, all correct.

Codex P2 (executable uses positions) — closed. The yq extraction now walks only jobs.<id>.uses and jobs.<id>.steps[*].uses instead of an untargeted .. | select(has("uses")) walk. The strategy.matrix.include decoy and with: input decoy test cases verify both false-positive shapes are eliminated:

explode(.) | .jobs[]
| (
    (select(has("uses")) | .uses),
    (select(has("steps")) | .steps[] | select(has("uses")) | .uses)
  )

Tracing both decoys confirms: the matrix.include entry is nested under strategy, not at jobs.<id> or jobs.<id>.steps[*], so it never reaches either select; the with.uses key is nested one level under the step, not the step's own uses key, so select(has("uses")) | .uses on the step returns the step-level uses: (actions/checkout@...), not the with.uses value, which never matches value_re. Both produce exit 0 correctly.

Codex P2 (uppercase pinned SHA escape) — closed. pin-comment-patterns.sh L109 changes [0-9a-f]{40} → [0-9a-fA-F]{40} in value_re, matching how runner-policy's provenance scanner already treats the pinned object ID. Two new test cases cover the material matrix — uppercase pinned SHA with a valid comment (clean) and with an invalid comment (flagged), not silently escaped.

The deliberate asymmetry between the pinned SHA (case-insensitive, git object ID) and the fallback comment's short-SHA (lowercase-only, authored policy string) is now explicitly documented in both the library header (L50–60) and the README (L72–86), with per-field rationale. That documentation is accurate and sufficient.

No-jobs:-key guard — correct. pin-comment-convention.test.sh L91–93 verifies that a document without a jobs: key produces no candidates and exits clean. In yq v4, .jobs on a document lacking that key returns null, and .jobs[] on null iterates an empty stream — no output, no error, records is empty, loop produces no violations. The test assertion confirms this.

Inline test structure update — correct. All prior inline pcc::scan_text cases now wrap their uses: line in jobs: a: uses: (or jobs: a: steps:) rather than a bare root-level scalar. This is the right fix: the new scoped yq expression never reaches a bare root-level uses: key, so those tests would have started passing trivially (false-positive clean assertions) with the prior yq expression. Wrapping them in the real GitHub Actions structure means they actually exercise the scan path, not a vacuous no-match.


Remaining nits (carry-over, non-blocking)

🟡 Nit 3 — Pre-release SemVer exclusion undocumented

README.md L9 — tag_re accepts only vMAJOR.MINOR.PATCH; pre-release identifiers (v1.0.0-rc.1) are rejected and the author must use the fallback form. The README calls the primary form "full-SemVer release tag" but SemVer 2.0 includes pre-release identifiers in its grammar. A consumer pinning an RC tag gets a surprising invalid-form; the fallback form exists for exactly this case but the README does not say so. Worth one parenthetical. Fix this →

🟡 Nit 5 — Whole-step anchor/alias violations both report the anchor's line number

pin-comment-patterns.sh L112–118 — after explode(.), each alias is replaced with a deep copy of the anchor node; the line property on that copy reflects the anchor's source line, not the alias's position. Two whole-step alias violations therefore emit the same lineno, both pointing to the anchor. The assert_row_count test at L173 verifies that two violation rows are produced but does not assert distinct line numbers. In practice a user seeing two violations at line N would know one is the anchor and one is an alias, but the output is ambiguous. A one-line note in the pcc::scan_text header alongside the existing lineno relative to <content> note would set operator expectations.


Overall

3f109bc closes the two remaining Codex P2s cleanly — the scoped yq walk eliminates both the data-field false-positive and the uppercase-SHA false-negative — and the inline test suite update ensures existing assertions remain meaningful under the new extraction logic. No regressions from any prior commit. The component is ready to merge once Nits 3 and 5 are triaged (or formally deferred with documented rationale).

@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: 3f109bc21e

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

… at source

Codex's sixth finding: the fallback form accepted any 7-40 lowercase
hex token as <short-sha>, but runner-policy's isShaClaim heuristic
(scoped to free-form comments across the whole repository) only
treats a token as a SHA claim when it mixes digits/letters or is
exactly 40 characters, so an all-digit or all-a-through-f short-sha
could pass this component's format check while runner-policy never
attempted to verify it.

Root-caused rather than aligned to the heuristic: at the fallback
form's position, the token is an unambiguous SHA claim about the
exact pin on the same line, so there is no ambiguity to defer a
heuristic classifier to. pcc::_check_comment now takes the pinned SHA
alongside the raw comment and requires the fallback short-sha to
case-insensitively prefix it directly. This closes the gap without
touching runner-policy, and does NOT reject a legitimate all-digit
abbreviated SHA (a real git prefix shape, ~1 in 25 real 7-character
hex prefixes) the way subset-aligning to isShaClaim would have.

The two checks now genuinely overlap for a ci-workflows fallback
comment: this component is authoritative there (verified directly
against the pin it annotates), and pin-provenance-drift remains the
sole check for every other SHA-pin comment shape this convention
does not govern. Updated both READMEs' boundary description
accordingly.

New tests: matching prefix (already covered, reconfirmed), a
non-matching prefix (flagged), an all-digit prefix that genuinely
matches (clean), a short-sha under 7 characters (still invalid-form
on shape, unaffected by the new prefix check). Audited every existing
fallback-form test case before this change confirmed none would
regress (all already used a genuine short+full SHA pair); all 34
assertions pass. shellcheck, markdownlint, typos, editorconfig clean;
driver dogfood against this repo's real workflow files stays clean.

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

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Claude encountered an error after 1s —— View job


I'll analyze this and get back to you.

@github-actions

Copy link
Copy Markdown

Warning

Automated review did not complete — this is an infrastructure failure, not a review verdict.

Treat any Claude comment on this PR (including a placeholder like "I'll analyze this and get back to you") as incomplete, not "no findings."

Re-running the job, or pushing a new commit, will retry the review.

@kyle-sexton
kyle-sexton merged commit 280601e into main Jul 22, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the docs/244-pin-comment-convention branch July 22, 2026 21:00

@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: e8056d7168

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

Comment on lines +106 to +107
[[ "$raw" =~ ^[[:space:]]*v[0-9]+\.[0-9]+\.[0-9]+[[:space:]]*$ ]] && return 0
if [[ "$raw" =~ ^[[:space:]]*([0-9a-f]{7,40})[[:space:]][0-9]{4}-[0-9]{2}-[0-9]{2}([[:space:]]+.+)?[[:space:]]*$ ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Disable nocasematch while enforcing case-sensitive forms

When this library is sourced from a shell that already has shopt -s nocasematch enabled, Bash makes these [[ =~ ]] checks case-insensitive, so comments such as # V0.7.0 or # 90F1C54 2026-07-18 are accepted even though the README and header deliberately make lowercase v and lowercase short-SHAs canonical. The current CI driver starts a fresh shell, but this file is also distributed as a sourceable policy library; save, clear, and restore nocasematch around the scan so caller shell state cannot weaken the convention.

Useful? React with 👍 / 👎.

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.

Reusable-pin management: normalize pin-comment format; evaluate Renovate tag-tracking

1 participant