Repository navigation
refactor: extract shared find-tracking-issue core into one generated source - #181
Conversation
|
Claude finished @kyle-sexton's task in 2m 23s —— View job Security Review
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 surfaceAll three modified workflows retain safe trigger configurations — no changes introduce
The Script injection (
|
|
Claude finished @kyle-sexton's task in 3m 14s —— View job Code Review
This is a clean, correct, behavior-preserving refactor. The architecture decision (inline-generate vs composite action) is well-reasoned and consistent with the established CorrectnessThe core logic in
The Test Coverage
The
CLAUDE.md ComplianceAll repo rules are satisfied:
Minor Observations1.
matches="$(jq -ce --arg marker "$MARKER" '[...]' <<<"$open_issues")"The 2. Render test asserts implementation-detail content
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 3. Comment slightly loses link-check context through canonicalization The pre-extraction Overall: Approach is sound, logic is correct, test coverage is thorough. Good to merge. |
34fedbf to
98f2b11
Compare
|
Claude finished @kyle-sexton's task in 1m 58s —— View job Security Review
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 surfaceNo trigger changes were made to any workflow. All three modified workflows retain safe configurations — no
Script injection —
|
Independent review trailReviewed by two independent critics before merge (producer ≠ critic). Both findings addressed:
Re-verified green: 205/205 node tests, scoped |
…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]>
98f2b11 to
55f97df
Compare
|
Claude finished @kyle-sexton's task in 2m 50s —— View job Security Review
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 surfaceNo trigger configurations changed. All three modified workflows retain safe trigger patterns — no
Script injection —
|
|
Claude finished @kyle-sexton's task in 2m 27s —— View job Code Review
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
Test Coverage
The
CI Wiring
CLAUDE.md ComplianceAll rules satisfied:
Minor Observations (carry-forward, non-blocking)1.
2. Render test assertion is redundant given
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 Verdict: correct and safe to merge. |
## 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)
…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]>

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, andlink-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_issuesJSON +MARKER+ISSUE_TITLE→issue-number) into.github/scripts/find-tracking-issue.sh, inline-generated into all three workflows viarender-find-tracking-issue.cjsusing the repo's existingBEGIN/END GENERATEDmarker +--checkdrift-test pattern (mirrorsosv-scan-guard.sh/render-osv-scan-guard.cjs).Why inline-generate, not a composite action
A composite action is not viable here:
link-check.ymlis a cross-repo reusable workflow (workflow_call), where a./-relativeuses: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-checkkeeps its mandatory label filter, sha256-scoped dynamic marker, and retry wrapper;After normalizing
link-check's lookup shell var (marker→MARKER, feeding the shared block; its step output staysmarker), 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 postureset -ugave the pre-extraction inline blocks (an emptyMARKERwould 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.ymlselector-contractjob.Verification
node --test .github/scripts/*.test.cjs→ 205/205shfmt -d,shellcheck,actionlint -shellcheck=(per actionlint hangs locally on Windows for large embedded run: blocks (upstream stdin-pipe deadlock, unfixed in v1.7.12) #173) — all clean--checkclean; unit test greenIndependently reviewed (fresh-context + different-vendor) before merge.
Closes #178
Related
osv-scan-guard.sh/render-osv-scan-guard.cjs