Skip to content

refactor: extract shared find-tracking-issue core into one generated source - #181

Merged
kyle-sexton merged 1 commit into
mainfrom
refactor/extract-find-tracking-issue
Jul 21, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
refactor/extract-find-tracking-issue

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Summary

Behavior-preserving refactor. The "find the rolling tracking issue this workflow owns" idiom was triplicated across queue-monitor-liveness.yml, tool-version-drift-check.yml, and link-check.yml — the same marker-match, duplicate fail-closed guard, and pre-marker title-fallback logic, drifting independently in three places.

Extracted the pure matching core (open_issues JSON + MARKER + ISSUE_TITLE → issue-number) into .github/scripts/find-tracking-issue.sh, inline-generated into all three workflows via render-find-tracking-issue.cjs using the repo's existing BEGIN/END GENERATED marker + --check drift-test pattern (mirrors osv-scan-guard.sh / render-osv-scan-guard.cjs).

Why inline-generate, not a composite action

A composite action is not viable here: link-check.yml is a cross-repo reusable workflow (workflow_call), where a ./-relative uses: resolves to the caller's checkout, and this repo has no precedent for full-path self-reference of an in-repo action from a reusable workflow (which would force a self-SHA pin and make consumers fetch a second action). Inline-generate-from-canonical is the established pattern for shared logic across workflows that can't use ./.

Seam

The per-site fetch stays where it genuinely differs:

  • link-check keeps its mandatory label filter, sha256-scoped dynamic marker, and retry wrapper;
  • the two scheduled workflows keep their simpler fetch.

After normalizing link-check's lookup shell var (marker → MARKER, feeding the shared block; its step output stays marker), the three cores are byte-identical, so the canonical block takes no config parameters — just the three shell/env inputs already in scope.

All three inputs are asserted required (: "${MARKER:?}" etc.) so an unset input fails closed — preserving the fail-closed posture set -u gave the pre-extraction inline blocks (an empty MARKER would otherwise match every issue and let the caller mutate an unrelated one). Caught by independent review.

New coverage the triplicated logic never had

  • find-tracking-issue.test.sh — marker match, title fallback, no-match, PR exclusion, marker-over-title precedence, both duplicate-fail-closed paths, and unset-required-input fail-closed.
  • find-tracking-issue-render.test.cjs — asserts the generated blocks are in sync (--check).

Both wired into the blocking ci.yml selector-contract job.

Verification

Independently reviewed (fresh-context + different-vendor) before merge.

Closes #178

Related

@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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


Security Review

  • Gather PR diff and changed files
  • Review shell scripts for injection surfaces
  • Review workflow YAML for dangerous patterns
  • Review renderer/test scripts for security issues
  • Post findings

No security issues found.

This PR is a behavior-preserving refactor. I reviewed all nine changed files against the threat model specified in CLAUDE.md and found no exploitable vulnerabilities. Below is the full audit trail.


Trigger surface

All three modified workflows retain safe trigger configurations — no changes introduce pull_request_target or workflow_run with secrets over untrusted code (the "pwn request" class):

Workflow Triggers
link-check.yml workflow_call only
queue-monitor-liveness.yml schedule, push, workflow_dispatch
tool-version-drift-check.yml schedule, push, workflow_dispatch

The ci.yml change adds only two run: test steps to an existing job — no trigger or permission changes.


Script injection (github context in run: blocks)

The generated block and all surrounding changes pass values exclusively through environment variables (env: keys), never via inline ${{ }} expressions inside run: blocks. No GitHub context value is interpolated directly into shell.


MARKER / ISSUE_TITLE injection surfaces

In queue-monitor-liveness.yml and tool-version-drift-check.yml, both MARKER and ISSUE_TITLE are hardcoded YAML literals — no attacker-controlled path to either.

In link-check.yml, ISSUE_TITLE comes from ${{ inputs.issue-title }} (a workflow_call input set by the calling workflow, not by PR content or user comments). The marker is then derived as:

report_key="$(printf '%s' "$ISSUE_TITLE" | sha256sum | cut -c1-12)"
MARKER=""

The sha256 pipeline always produces a 64-character hex string; cut -c1-12 produces 12 hex characters. MARKER is therefore a fixed-format HTML comment regardless of what ISSUE_TITLE contains — no newlines, no special characters.

The echo "marker=${MARKER}" >> "$GITHUB_OUTPUT" write is safe for the same reason.


GITHUB_OUTPUT write — issue-number value

The generated block's only write to GITHUB_OUTPUT is:

jq -r 'if length == 1 then "issue-number=" + (.[0] | tostring) else "issue-number=" end' <<<"$matches" >>"${GITHUB_OUTPUT:?}"

.[0] | tostring converts a JSON integer to its decimal string representation. The value is type-constrained by jq's own parser — no injection possible.


jq --arg usage

All jq filters in the generated block use --arg marker "$MARKER" and --arg title "$ISSUE_TITLE" to pass shell variables as jq string arguments, never interpolated into the filter expression itself. contains($marker) and .title == $title are string operations, not code execution paths.


Fail-closed assertions

The PR adds : "${MARKER:?MARKER is required}" / : "${ISSUE_TITLE:?...}" / : "${open_issues:?...}" guards. These are strictly tighter than the previous set -u posture (an unset MARKER under set -u would abort immediately but only at first use; the explicit : assertions document the intent and fail at the same point). No regression in fail-closed posture.


render-find-tracking-issue.cjs — file paths

All paths are derived from __dirname and a fixed file list — no user input reaches fs.readFileSync or fs.writeFileSync. The render() function uses indexOf on in-memory strings with no external data in the search keys. No path traversal or injection surface.


Permissions

No permissions: blocks were changed. The workflows retain contents: read + issues: write at the job level, matching the documented minimum grant.


Action pins

No new uses: references were introduced. The one existing action added by this PR's consumer context (peter-evans/create-issue-from-file) and all other uses: entries remain SHA-pinned.


Verdict: safe to merge from a security perspective.

@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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


Code Review

  • Read changed files and gather context
  • Review canonical script and renderer
  • Review test coverage
  • Review workflow integrations
  • Check CLAUDE.md compliance

This is a clean, correct, behavior-preserving refactor. The architecture decision (inline-generate vs composite action) is well-reasoned and consistent with the established osv-scan-guard pattern. No blocking issues. Three minor observations below.


Correctness

The core logic in find-tracking-issue.sh is correct:

  • Marker search → count=1 → skips fallback, outputs the match. ✓
  • Marker search → count=0 → title fallback; count=1 → outputs that. ✓
  • Either search → count>1 → fails closed with an actionable error. ✓
  • Final jq at line 36 correctly reuses whatever matches holds at that point (marker result if found; title-fallback result if not). ✓
  • The GITHUB_OUTPUT is :?-asserted in the generated block, which is a strict upgrade over the previous >> "$GITHUB_OUTPUT" in link-check.yml that would silently no-op on an unset variable. ✓

The link-check.yml shell-var rename (marker → MARKER) correctly preserves the step output name — echo "marker=${MARKER}" >> "$GITHUB_OUTPUT" still writes the lowercase marker output that steps.tracking.outputs.marker at line 207 consumes. ✓


Test Coverage

find-tracking-issue.test.sh covers all 9 discriminating cases thoroughly:

Case Covered
Marker match ✓
Title fallback ✓
No match → empty output ✓
PR excluded ✓
Marker wins over title ✓
Duplicate markers → fail closed ✓
Duplicate titles → fail closed ✓
Foreign marker → empty ✓
All three unset-required-input paths ✓

The run() fixture correctly clears $github_output between cases (rm -f -- "$github_output") so tests don't bleed state, and >> "$github_output" (append, no prior create) correctly recreates it. ✓

find-tracking-issue-render.test.cjs runs --check and verifies the source header comment appears exactly once per consumer workflow — catching both drift and duplicate injection. ✓


CLAUDE.md Compliance

All repo rules are satisfied:

  • No new uses: entries; existing pins are untouched.
  • No event-trigger changes.
  • No permission widening.
  • No checkout-before-action reordering.

Minor Observations

1. jq -ce — the -e flag has no effect on array output

find-tracking-issue.sh line 13 and line 27:

matches="$(jq -ce --arg marker "$MARKER" '[...]' <<<"$open_issues")"

The -e flag exits non-zero when the result is false or null. Since the filter always produces an array (never false/null), -e is a no-op — an empty [] is truthy in jq. This is harmless but slightly misleading; -c alone expresses the intent (compact output). Not blocking.

2. Render test asserts implementation-detail content

find-tracking-issue-render.test.cjs lines 34–37:

assert.match(
  workflow,
  /issue-number=" \+ \(\.\[0\] \| tostring\)/u,
  `${name} must resolve issue-number from the generated core`,
);

This regex pins the literal jq expression from the canonical source. Any reformatting of that expression (e.g. spacing) would break the test even though the --check call on line 18-21 already verifies the generated block is byte-identical to the canonical. The assertion adds a "core resolution logic is present" sanity check, but given the --check already guarantees byte identity, the regex is redundant and fragile. Very minor; the --check gate is the load-bearing coverage here.

3. Comment slightly loses link-check context through canonicalization

The pre-extraction link-check.yml fallback comment included the sentence: "Once adopted, its body carries the marker and this fallback no longer applies to it." — and used "update/close steps below" (plural) to reflect that link-check has both an update and a close path. The canonical comment uses "update step below" (singular), which is slightly imprecise for link-check.yml. Harmless (comment-only), but the nuance is lost. Worth knowing if the comment is ever reviewed for accuracy.


Overall: Approach is sound, logic is correct, test coverage is thorough. Good to merge.

@kyle-sexton
kyle-sexton force-pushed the refactor/extract-find-tracking-issue branch from 34fedbf to 98f2b11 Compare July 20, 2026 23:34
@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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


Security Review

  • Gather PR diff and changed files
  • Review shell scripts for injection surfaces
  • Review workflow YAML for dangerous patterns
  • Review renderer/test scripts for security issues
  • Post findings

No security issues found.

This is a behavior-preserving refactor. I audited all nine changed files against the threat model in CLAUDE.md and found no exploitable vulnerabilities. Full trail below.


Trigger surface

No trigger changes were made to any workflow. All three modified workflows retain safe configurations — no pull_request_target or workflow_run with secrets:

Workflow Triggers
link-check.yml workflow_call only
queue-monitor-liveness.yml schedule, push (main only), workflow_dispatch
tool-version-drift-check.yml schedule, push (main only), workflow_dispatch
ci.yml push (main only), pull_request

Script injection — github context in run: blocks

All three generated-block sites pass GitHub context values exclusively through env: keys. No ${{ }} expression is interpolated directly into any shell script body:


MARKER derivation in link-check.yml

link-check.yml L135–L136:

report_key="$(printf '%s' "$ISSUE_TITLE" | sha256sum | cut -c1-12)"
MARKER=""

sha256sum always emits 64 lowercase hex characters; cut -c1-12 takes the first 12. Regardless of what ISSUE_TITLE contains, report_key is always a 12-character [0-9a-f] string, and MARKER is a fixed-format HTML comment with no newlines, special characters, or :: sequences. No injection into the marker value or the echo "marker=${MARKER}" >> "$GITHUB_OUTPUT" write at L137.


GITHUB_OUTPUT write — issue-number value

find-tracking-issue.sh L36 (generated verbatim into all three workflows):

jq -r 'if length == 1 then "issue-number=" + (.[0] | tostring) else "issue-number=" end' <<<"$matches" >>"${GITHUB_OUTPUT:?}"

.[0] is a GitHub API .number field — a JSON integer. tostring in jq on an integer produces its decimal representation. Type-constrained at the jq layer; no string is accepted in place of an integer. No injection possible.


jq --arg usage — no filter-expression injection

All four jq calls in the generated block use --arg marker "$MARKER" and --arg title "$ISSUE_TITLE" to bind shell variables as jq string arguments, never via interpolation into the filter expression itself. contains($marker) and .title == $title are value operations, not code paths.


Fail-closed assertions — strictly tighter than before

find-tracking-issue.sh L10–L12:

: "${MARKER:?MARKER is required}"
: "${ISSUE_TITLE:?ISSUE_TITLE is required}"
: "${open_issues:?open_issues is required}"

These :? assertions fail immediately if any input is unset or empty. An empty MARKER passed to jq contains($marker) would act as an empty-string needle and match every issue body — potentially adopting and mutating an unrelated issue. The assertions prevent that. This is a security improvement over the pre-extraction inline blocks where set -u only caught the unset case on first use. Test case 9 in find-tracking-issue.test.sh covers all three paths.


render-find-tracking-issue.cjs — file path safety

All file paths are derived from __dirname and a hardcoded filename list. No user input reaches fs.readFileSync or fs.writeFileSync. The render() function uses indexOf on in-memory strings with no external data in the search keys. No path traversal or code injection surface.


Permissions

No permissions: blocks were changed. All three workflows retain contents: read + issues: write at the job level, matching the documented minimum grant. ci.yml retains contents: read at the workflow level; the new test steps require no additional permissions.


Action pins

No new uses: references were introduced. All existing uses: entries remain SHA-pinned with version comments.


Verdict: safe to merge from a security perspective.

@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

Code Review

  • Gather PR diff and changed files
  • Review canonical script and renderer
  • Review test coverage
  • Review workflow integrations
  • Post findings

View job run

@kyle-sexton

Copy link
Copy Markdown
Member Author

Independent review trail

Reviewed by two independent critics before merge (producer ≠ critic). Both findings addressed:

  1. Fail-open regression (fresh-context + Codex). The initial extraction used ${MARKER:-} (added to satisfy standalone ShellCheck SC2154), which defeated set -u: an unset MARKER becomes contains(""), matching every issue body — so with one open issue the caller would update/close an unrelated issue, a fail-open on a fail-closed-by-design path. Fixed: all three inputs asserted required (: "${MARKER:?}" …) with bare refs in the body, plus three unset-input fail-closed test cases.

  2. Misplaced ShellCheck directive — SC1126 (Codex, High). # shellcheck shell=bash was inlined mid-run:-block (after the per-site fetch), which ShellCheck rejects (a directive must precede all commands); the blocking actionlint job would have failed. The local actionlint -shellcheck= workaround (per actionlint hangs locally on Windows for large embedded run: blocks (upstream stdin-pipe deadlock, unfixed in v1.7.12) #173) masked it. Fixed: the directive is kept in the source for standalone linting but stripped by the renderer from the inlined copy (actionlint already supplies the bash shell). Verified by reconstructing each of the three run-blocks and running shellcheck --shell=bash (all exit 0).

Re-verified green: 205/205 node tests, scoped shfmt -d, standalone shellcheck, render --check, unit test.

…source

The "find the rolling tracking issue this workflow owns" idiom was
triplicated across queue-monitor-liveness.yml, tool-version-drift-check.yml,
and link-check.yml — the same marker-match, duplicate-guard, and
pre-marker title-fallback logic, drifting independently in three places.

Extract the pure matching core (open_issues JSON + MARKER + ISSUE_TITLE ->
issue-number) into .github/scripts/find-tracking-issue.sh, inline-generated
into all three workflows via render-find-tracking-issue.cjs with the repo's
BEGIN/END GENERATED marker + --check drift-test pattern (mirrors
osv-scan-guard.sh / render-osv-scan-guard.cjs). A composite action is not
viable: link-check.yml is a cross-repo reusable workflow where a ./-relative
uses: resolves to the caller's checkout, and the repo has no precedent for
full-path self-reference of an in-repo action.

The per-site fetch stays where it differs — link-check keeps its mandatory
label filter, sha256-scoped dynamic marker, and retry wrapper; the two
scheduled workflows keep their simpler fetch. link-check's lookup shell var
is renamed marker -> MARKER to feed the shared block; its step output stays
`marker`. Behavior-preserving.

All three inputs are asserted required (`: "${MARKER:?}"` etc.) so an unset
input fails closed, preserving the fail-closed posture set -u gave the
pre-extraction inline blocks: an empty MARKER would otherwise match every
issue and let the caller mutate an unrelated issue. The `# shellcheck
shell=bash` dialect directive is kept in the source for standalone linting
but stripped by the renderer from the inlined copy, where it would land
mid-run:-block after commands (ShellCheck rejects a late directive; actionlint
already supplies the bash shell for embedded scripts).

New coverage the triplicated logic never had: find-tracking-issue.test.sh
(marker match, title fallback, no-match, PR exclusion, marker precedence,
duplicate fail-closed, and unset-input fail-closed) and
find-tracking-issue-render.test.cjs (drift check), both wired into the
blocking ci.yml selector-contract job.

Verified: 205/205 script tests, CI-exact scoped shfmt, shellcheck (standalone
+ reconstructed run: blocks via shellcheck --shell=bash), actionlint.

Closes #178

Co-authored-by: Claude Opus 4.8 <[email protected]>
@kyle-sexton
kyle-sexton force-pushed the refactor/extract-find-tracking-issue branch from 98f2b11 to 55f97df Compare July 20, 2026 23:36
@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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


Security Review

  • Gather PR diff and identify changed files
  • Audit find-tracking-issue.sh — injection surfaces, fail-closed posture, variable handling
  • Audit render-find-tracking-issue.cjs — file path safety, eval surfaces
  • Audit modified workflows — trigger patterns, context injection, permissions
  • Audit test scripts for security relevance
  • Post findings

No security issues found.

This is a behavior-preserving refactor. I audited all nine changed files against the threat model in CLAUDE.md and found no exploitable vulnerabilities. Full trail below.


Trigger surface

No trigger configurations changed. All three modified workflows retain safe trigger patterns — no pull_request_target or workflow_run with secrets over untrusted code:

Workflow Triggers
link-check.yml workflow_call only
queue-monitor-liveness.yml schedule, push (main), workflow_dispatch
tool-version-drift-check.yml schedule, push (main), workflow_dispatch

Script injection — github context in run: blocks

All three generated-block sites pass context values exclusively through env: keys. No ${{ }} expression is interpolated directly into a shell script body.

In queue-monitor-liveness.yml and tool-version-drift-check.yml, MARKER and ISSUE_TITLE are hardcoded YAML string literals — no attacker-controlled path to either.

In link-check.yml, ISSUE_TITLE arrives via ${{ inputs.issue-title }} — a workflow_call input, set only by a trusted org-owned calling workflow, never by PR content or user comments. It is bound through env:, not inlined in the shell body.


MARKER derivation in link-check.yml

Lines 135–136:

report_key="$(printf '%s' "$ISSUE_TITLE" | sha256sum | cut -c1-12)"
MARKER=""

sha256sum always emits 64 lowercase hex characters; cut -c1-12 extracts the first 12. Regardless of ISSUE_TITLE content, report_key is always a 12-character [0-9a-f] string. MARKER is a fixed-format HTML comment — no newlines, no shell metacharacters, no :: sequences that could be misread as workflow commands.

The echo "marker=${MARKER}" >> "$GITHUB_OUTPUT" write at line 137 is safe for the same reason.


jq --arg usage — no filter-expression injection

All four jq calls in the generated block (find-tracking-issue.sh lines 13–14 and 27–28) use --arg marker "$MARKER" and --arg title "$ISSUE_TITLE" to pass shell variables as jq string arguments, never interpolated into the filter expression. contains($marker) and .title == $title are value comparisons, not code execution paths.


GITHUB_OUTPUT write — issue-number value

find-tracking-issue.sh line 36:

jq -r 'if length == 1 then "issue-number=" + (.[0] | tostring) else "issue-number=" end' <<<"$matches" >>"${GITHUB_OUTPUT:?}"

.[0] is a GitHub API .number field — a JSON integer. tostring on a jq integer produces its decimal string representation. Type-constrained at the jq layer; no injection possible. The ${GITHUB_OUTPUT:?} assertion prevents a silent no-op if GITHUB_OUTPUT is somehow unset.


Fail-closed assertions — strictly tighter than before

find-tracking-issue.sh lines 10–12:

: "${MARKER:?MARKER is required}"
: "${ISSUE_TITLE:?ISSUE_TITLE is required}"
: "${open_issues:?open_issues is required}"

An empty MARKER under contains($marker) would act as an empty-string needle and match every issue body — potentially adopting and mutating an unrelated issue. The :? assertions kill the script before that can happen, covering both the unset and empty-string cases. This is a security improvement over the pre-extraction set -u posture, which only caught unset variables at first use.

Test case 9 in find-tracking-issue.test.sh lines 87–92 covers all three paths using env without -i. Because MARKER is never exported in the test script, it does not appear in the child process environment — the unset-MARKER test does correctly invoke the script without that variable.


render-find-tracking-issue.cjs — file path safety

All paths are derived from __dirname and a hardcoded filename list (lines 6–13). No user input reaches fs.readFileSync or fs.writeFileSync. The render() function uses indexOf on in-memory strings with fixed search keys. No path traversal or code injection surface.


Permissions

No permissions: blocks were changed. The workflows retain contents: read + issues: write at the job level. ci.yml's two new run: steps are test-only and require no additional permissions.


Action pins

No new uses: references were introduced. All existing uses: entries remain SHA-pinned with version comments. The peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 pin is unchanged across all three consumers.


Verdict: no security issues. Safe to merge.

@claude

claude Bot commented Jul 20, 2026 •

Copy link
Copy Markdown

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


Code Review

  • Gather PR diff and understand scope
  • Review canonical script (find-tracking-issue.sh)
  • Review renderer (render-find-tracking-issue.cjs)
  • Review test scripts
  • Review workflow integrations
  • Review CI wiring
  • Post findings

This is a correct, well-structured behavior-preserving refactor. The architecture is sound, logic is correct, test coverage is thorough, and CLAUDE.md rules are all satisfied. Three carry-forward minor observations (previously flagged) below — none blocking.


Correctness

find-tracking-issue.sh — logic is sound end-to-end:

  • Marker search → count == 1 → write to GITHUB_OUTPUT, skip fallback. ✓
  • Marker search → count == 0 → title fallback, then same fail-closed check. ✓
  • Either search → count > 1 → fails closed with an actionable ::error::. ✓
  • Final jq -r at line 36 reuses whichever matches array was last written — correct regardless of which path was taken. ✓
  • ((.body // "") | contains($marker)) correctly handles null bodies without error. ✓

render-find-tracking-issue.cjs — substitution is correct:

  • bundledScript() strips the # shellcheck shell=bash directive before inlining (avoids SC1126: directive mid-block), strips leading blank lines, and applies 10-space indent to all non-empty lines, matching the target indentation in all three workflows. ✓
  • render() slices workflow[0, start] + generated block + workflow[end + endMarker.length, ...] — no duplication, no off-by-one. ✓
  • end < start guard correctly catches malformed marker pairs. ✓

link-check.yml shell-var rename (marker → MARKER):

  • Step output is preserved: echo "marker=${MARKER}" >> "$GITHUB_OUTPUT" still writes the lowercase marker key that steps.tracking.outputs.marker at line 205 consumes. ✓

Test Coverage

find-tracking-issue.test.sh — 9 discriminating cases, all verified:

Case Verdict
Marker match → resolves number ✓
Title-only fallback → resolves number ✓
No match → empty output, exit 0 ✓
PR with marker → excluded (empty) ✓
Marker wins over title ✓
Duplicate markers → exit 1, error text ✓
Duplicate titles (no marker) → exit 1, error text ✓
Foreign marker → empty ✓
Unset MARKER / ISSUE_TITLE / open_issues → exit non-zero ✓

The run_unset() helper correctly uses env without -i; since MARKER and TITLE are unexported shell variables (not in the process environment), env won't inherit them for the unset-input tests. The fail-closed assertions therefore trigger as intended. ✓

find-tracking-issue-render.test.cjs — --check is the load-bearing gate; the regex assertion on the jq expression at line 34–38 adds a redundant but harmless sanity check on top of byte-identity verification. ✓


CI Wiring

  • find-tracking-issue.test.sh wired at ci.yml line 372 ✓
  • find-tracking-issue-render.test.cjs picked up by the existing node --test .github/scripts/*.test.cjs glob at ci.yml line 366 ✓

CLAUDE.md Compliance

All rules satisfied:

  • No new uses: references; all existing pins SHA-pinned with version comments. ✓
  • No trigger changes — no pull_request_target or workflow_run with secrets. ✓
  • No permission widening; all three workflows retain contents: read + issues: write. ✓
  • No checkout-before-action reordering. ✓

Minor Observations (carry-forward, non-blocking)

1. jq -ce — -e flag is a no-op on array output

find-tracking-issue.sh lines 13 and 27: the filter always produces an array (never false/null), so -e never changes the exit code. -c alone expresses the intent. Harmless.

2. Render test assertion is redundant given --check

find-tracking-issue-render.test.cjs lines 34–38: the jq expression regex would break on any whitespace reformatting even though the --check call at lines 18–21 already guarantees byte identity. The --check gate is the load-bearing coverage.

3. Comment loses link-check specificity through canonicalization

The generated comment says "update step below" (singular), which is accurate for the two scheduled workflows but imprecise for link-check.yml, which has both an update path and a close path. Comment-only, harmless.


Verdict: correct and safe to merge.

@kyle-sexton
kyle-sexton merged commit 5e6285b into main Jul 21, 2026
1 check passed
@kyle-sexton
kyle-sexton deleted the refactor/extract-find-tracking-issue branch July 21, 2026 00:52
kyle-sexton added a commit that referenced this pull request Jul 21, 2026
## Summary

- extend `selector-conformance.yml` pull-request and main-push path
filters to cover the canonical tracking-issue resolver, renderer,
shell/render tests, and all three generated workflow consumers
- run `bash .github/scripts/find-tracking-issue.test.sh` directly in the
selector unit job

## Why

PR #181 delivered the shared tracking-issue resolver for #178, but it
merged before the selector-conformance trigger and shell-test wiring
corrections could be pushed. Without these paths, changes limited to the
resolver source, renderer, tests, `link-check.yml`, or
`queue-monitor-liveness.yml` could skip this focused conformance
workflow.

GitHub's workflow syntax documents that a workflow with a `paths` filter
runs when at least one changed path matches, so every source and
generated consumer that can invalidate conformance must be listed for
both `pull_request` and `push`:

https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#onpushpull_requestpull_request_targetpathspaths-ignore

GitHub also documents invoking repository scripts directly from a `run`
step:

https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsrun

## Impact

This completes the remaining selector-conformance acceptance criteria
from #178 without changing resolver behavior.

## Verification

- `node --test .github/scripts/*.test.cjs` — 206/206 passed
- `bash .github/scripts/find-tracking-issue.test.sh`
- `bash .github/scripts/osv-scan-guard.test.sh`
- `bash .github/scripts/zizmor-sarif-guard.test.sh`
- `bash .github/scripts/osv-release-digest.test.sh`
- `node .github/scripts/render-find-tracking-issue.cjs --check`
- `shfmt -d` and `shellcheck` on resolver source/test
- repository-wide `actionlint -shellcheck=`
- `git diff --check`

## Related

- Follow-up to #181
- Fixes #178 (follow-up completion after #181)
kyle-sexton added a commit that referenced this pull request Oct 20, 2026
…820)

Refs: #661

## Summary

Part 1 of #661: `pr-require-checks.yml` now runs on `merge_group`
(`checks_requested` only), so `ci-status` reports on the merge-group
commit once a queue is required. This PR does not turn the queue on;
that is part 2, `UsesMergeQueue` for ci-workflows in github-iac.

## Fix

- `pr-require-checks.yml`: adds `merge_group: { types:
[checks_requested] }`. No job gate needed changing. A merge-group
payload has no `github.event.pull_request`, so the contract-only
predicate is false and every lane `ci-status` aggregates runs in full.
The concurrency group falls back to `github.run_id`, so queued runs
never cancel each other. `pr-review`, `pr-review-security` and
`pr-automerge-dependabot` keep their `github.event_name ==
'pull_request'` gate, so they stay off on merge groups and stay
advisory. `check-managed-files` is still pull_request-only; its
merge-group handling is #710.
- `check-contract`: a merge-group path. It reads the queued PR number
from `merge_group.head_ref`
(`[refs/heads/]gh-readonly-queue/<base>/pr-<N>-<40-hex>`) and re-reads
that PR live. It re-runs the Conventional Commits title check and fails
when the PR carries the `do-not-merge` label, so the queue drops it;
either can change after enqueue. It reports `linkage` as `skipped` and
writes no comment or label. The head ref names only the group's last PR,
so the README states the queue must use `grouping_strategy: ALLGREEN`.
It fails closed when the ref cannot be parsed or the PR cannot be read.
`pr-number` is ignored on `merge_group`.
- `aggregate-results`: the `sha` default is now `pull_request.head.sha
|| merge_group.head_sha || github.sha`. On a merge group, `github.sha`
is already the group head, so this only names it explicitly. `ci-lanes`
is recorded on the group commit, where the `ci-status` check run also
reports.
- `gitleaks` git mode: a merge group defaults to
`merge_group.base_sha..HEAD`, the same way a PR uses its base SHA. A
missing base SHA fails closed. This repo's own dogfood scans in `dir`
mode, so this change affects git-mode consumers only.
- `actions-expression.cjs` (test helper): adds `fromJSON`, `cancelled()`
(always false) and element-wise `contains` over arrays. With these, the
test can evaluate the real job gates under a merge-group context.

## Verification

- `node --test .github/scripts/*.test.cjs`: 479 pass, 0 fail. New tests
in `ci-fanout-consolidation.test.cjs`:
  - the trigger is `merge_group` with `checks_requested` only;
- under a merge-group context, every job in `ci-status`'s `needs`, and
`ci-status` itself, evaluates `true`;
- the review lanes, the Dependabot arm and the issue labeler evaluate
`false`;
  - the concurrency group resolves to `pr-require-checks-<run_id>`.
- Mutation check: adding `&& github.event_name == 'pull_request'` to
`ruff`'s gate fails the lanes test, which names `ruff`.
- `node --test .github/actions/*/*.test.cjs`: 88 pass, 0 fail.
- `check-contract/run.test.sh`: all pass. The new cases run `run.sh`
itself:
  - a queued PR with `do-not-merge` fails;
- a queued PR with a good title passes, skips linkage, and makes no POST
or DELETE;
- a queued PR with a non-conventional title fails, with no POST or
DELETE;
- four unparsable refs (empty, `refs/heads/main`, non-numeric PR, short
SHA) fail closed with no API call;
  - a 404 on the PR read fails.
  - Run against the old `run.sh`, every new case fails.
- `aggregate-results/run.test.sh` and `gitleaks/scan.test.sh` (new
`merge_group` range case and missing-base case): pass.
- `actionlint`: clean. `zizmor --offline .`: no findings. `shellcheck`,
`shfmt -d`, `composite-run-shellcheck.sh` and Biome 2.5.11 `ci
.github/scripts`: clean.
- Not yet verified: `ci-status` on a real merge-group commit. That needs
the queue from part 2.

### Live probes on pr-pipeline-sandbox (queue: `merge_method: SQUASH`,
`ALLGREEN`)

- **(a) stale `--match-head-commit`: refused, not enqueued.** In
[#180](melodic-software/pr-pipeline-sandbox#180),
the first head
[`b85280c`](melodic-software/pr-pipeline-sandbox@b85280c)
went green. I then pushed
[`ec7de8d`](melodic-software/pr-pipeline-sandbox@ec7de8d),
waited until every check on it was green, and ran `gh pr merge 180 -R
melodic-software/pr-pipeline-sandbox --match-head-commit
b85280cc18966310e6fcabd0bd4759a5e72e7e43` (gh 2.102.0):
  ```
GraphQL: Failed to add PR #180: expected head oid does not match the
current head oid (enablePullRequestAutoMerge)
  ```
Afterwards GraphQL showed `isInMergeQueue: false` and `autoMergeRequest:
null`, so the queue path enforces `expectedHeadOid`. An earlier try,
while checks on `ec7de8d` were still pending, was stopped by the local
guardrails `block-unresolved-pr-merge` hook before it reached GitHub.
- **(b) non-squash method: inconclusive, not run.** In
[#181](melodic-software/pr-pipeline-sandbox#181),
head
[`0e01991`](melodic-software/pr-pipeline-sandbox@0e01991)
was green. The local Claude Code permission system denied `gh pr merge
181 -R melodic-software/pr-pipeline-sandbox --merge --match-head-commit
0e019915a7a063f3b7fc0e45596e24f599699c62` before it reached GitHub:
`Permission to use Bash with command ... has been denied.` No other
shape was tried. #181 was closed unmerged.

Both probe PRs are closed and their branches deleted.

## Related

- #661: part 2 (github-iac `UsesMergeQueue: true` for ci-workflows)
stays open and follows this PR.
- #710: `check-managed-files` merge-group handling, out of scope here.

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

---------

Co-authored-by: Claude Opus 5.5 <[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.

Extract shared find-tracking-issue core across 3 workflows (inline-generate)

1 participant