Skip to content

refactor(ci): move four repeated pre-model leg steps into scripts - #16002

Merged
kyle-sexton merged 2 commits into
mainfrom
refactor/15964-pre-model-leg-scripts
Nov 13, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
refactor/15964-pre-model-leg-scripts

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Closes #15964

session: Simplify E2 B

Summary

Four repeated pre-model leg steps now each live in one script under .github/scripts/, and the three dead credit-marker rm -rf lines are gone. This is part of restructuring pass #15695. Behavior is unchanged.

Fix

  • "Assert the gate and the resolver agree" had 7 copies, in pr-verify.yml, pr-verify-capture.yml and pr-rate-merge-risk.yml. It now lives in .github/scripts/pr-verify/assert-gate-agrees.sh.
  • "Read the checker's model" had 3 copies, in the merge-risk legs. It now lives in .github/scripts/pr-merge-risk/read-checker-model.sh.
  • "Prepare the working tree" had 3 copies in the tidy legs and 3 in the changelog legs. Each lane's copy now lives in its own prepare-working-tree.sh under .github/scripts/maintenance-tidy-code-upkeep/ and .github/scripts/upstream-apply-changelog/.
  • The 16 steps: each keeps its name, id, if: and env:, and its run: is now one bash line.
    • Ten steps call bash .base/.github/scripts/<dir>/<script>.sh: the 7 gate assertions and the 3 checker-model reads.
    • The six tidy and changelog "Prepare the working tree" steps call bash .github/scripts/<lane>/prepare-working-tree.sh instead. The issue's .base/ form fails there, because "Check out main with history" replaces .base with a root checkout just before the step. That checkout is the same needs.gate.outputs.base-sha main commit, and it still comes before the model step.
    • The gate assertion is still its own step, so a mismatch still fails that step and the steps after it skip.
  • The rm -rf lines: dropped rm -rf "${RUNNER_TEMP:?}/key-credit-stop" from the key legs of merge-risk, tidy and changelog. No earlier step writes that directory, and runner.temp starts empty in each job.
  • The four scripts: each is mode 100755 with a #!/usr/bin/env bash line and holds its step body verbatim.
    • Each sets set -eo pipefail, without -u. All five workflows set defaults.run.shell: bash, which runs steps as bash -eo pipefail, and a script called with bash inherits neither flag.
    • Each has a file-level # shellcheck disable=SC2154 with its reason, as pr-verify/chunk-diff.sh does.
    • [ ] tests became [[ ]] (SC2292). Every operand is quoted, so the comparisons stay literal.
    • shfmt split the one-line { …; exit 1; } groups.
    • The changelog prompt heredoc is unchanged.

Verification

  • Structural check: I parsed each workflow at HEAD and on the branch and compared them as JSON with the 16 targeted run: values and the 3 rm lines taken out. All five are equal. Every targeted step's run: is its one-line script call.
  • Old against new, in scratch repos (a throwaway harness, not committed): each old step body under bash -eo pipefail -c and each new script ran against an identical scratch repo with a tracked CLAUDE.md, AGENTS.md, .mcp.json, .claude/**, nested copies and a staged plugin. The harness compared stdout, stderr, exit code, GITHUB_OUTPUT, the commit identity, the exclude file, git ls-files -v (skip-worktree flags), the file list, .lane modes and the changelog prompt. All 12 cases were identical:
    • gate check: agree (rc 0), PR mismatch (rc 1), head mismatch (rc 1);
    • checker: no subagent model, alias (rc 0); non-alias subagent, default model (rc 1); unparsable settings (rc 5);
    • tidy and changelog: model set (rc 0), default model (rc 1);
    • the changelog prompt file is byte-identical, and none is written when the model is unset.
    • After review, the harness reran with the tidy and changelog scripts tracked at the scratch repo's root and called from there. All 12 cases matched again. With .base absent, the .base/ path exits 127 and the root path exits 0.
  • Lint: shellcheck --rcfile .shellcheckrc and shfmt -d (the repo's .editorconfig) are clean on all four scripts. scripts/check-affected.sh passed 11 and skipped 5 over the 9 changed files.
  • Tests: all 39 local test files that name these workflows pass under scripts/run-test-file.sh. Among them, the leg-equality and step-order tests in pr-verify/workflow.test.mjs, pr-merge-risk/workflow.test.mjs, the credential-legs tests and callers.test.mjs.
  • actionlint: reports nothing on any of the five workflows apart from the cache-mode and concurrency.queue keys it does not know.
  • Artifact retention: check-artifact-retention.mjs matches 152 upload steps.
  • Left to CI: the full .github suite, under the one-suite-per-machine rule.

Related

Follow-ups

🤖 Generated with Claude Code

Each of these step bodies repeated across legs now lives once:

- "Assert the gate and the resolver agree" (7 copies in pr-verify.yml,
  pr-verify-capture.yml and pr-rate-merge-risk.yml):
  .github/scripts/pr-verify/assert-gate-agrees.sh
- "Read the checker's model" (3 merge-risk legs):
  .github/scripts/pr-merge-risk/read-checker-model.sh
- "Prepare the working tree" (3 tidy legs, 3 changelog legs):
  .github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh and
  .github/scripts/upstream-apply-changelog/prepare-working-tree.sh

Each of the 16 steps keeps its name, id, if: and env: and calls its
script from main's checkout. The scripts set -eo pipefail, as the
workflows' `shell: bash` step shell did, and hold their bodies
verbatim but for shellcheck's [ ] to [[ ]] and shfmt's layout.

Drop the three dead `rm -rf` lines before the key's credit-stop
marker in the merge-risk, tidy and changelog key legs: no earlier step
writes the directory, and each job starts with an empty runner.temp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T18:52:59.473279Z 050a111 PR opened
ℹ️ About Codex in GitHub

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

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

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

@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: 050a1110ec

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Security review (incremental): no findings

I reviewed only what changed since 050a1110. That is the two files in the incremental diff, .github/workflows/maintenance-tidy-code-upkeep.yml and .github/workflows/upstream-apply-changelog.yml. Both are on the trusted-path list, and I read every hunk of each. This lane has reviewed an earlier head of this pull request, so this review reports blocking findings only.

What changed. Six "Prepare the working tree" steps used to run bash .base/.github/scripts/<lane>/prepare-working-tree.sh. They now run bash .github/scripts/<lane>/prepare-working-tree.sh, the same script from the root checkout.

What I checked.

  • Which commit the script comes from. Right before each changed step, the "Check out main with history" step checks out the root at ref: ${{ needs.gate.outputs.base-sha }} with persist-credentials: false (for example maintenance-tidy-code-upkeep.yml#L312-L318 and upstream-apply-changelog.yml#L330-L337). Each job's earlier .base checkout uses that same base-sha. The gate job sets it from github.sha, and these workflows run only on push, schedule and workflow_dispatch, so no pull request head is ever checked out. The script therefore comes from the same trusted commit as before. The comment "Nothing after this step runs from .base" explains why the path moved: the root checkout replaces the working directory, so the .base path is gone by this step.
  • When the script runs. Each prepare step runs before the model step ("Sweep the areas" / "Run the changelog apply"). Nothing the model writes can change the script before it runs.
  • Trust controls. Each step keeps its id, if: and env:. The kill switch, trusted-trigger check, token requests, runner isolation and merge holds are untouched, so no control is widened.

No manifest or userConfig changes. The pull request context contains no embedded instructions to the lane. The prior summary comment from this lane reported no findings, so nothing carries over.

critical-findings: 0

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude-review: 2 inline finding(s) on 050a1110ec7369f76b532185a27233c8dd33ac10; the summary is in this lane's pull request comment.

claude-lane: claude-review

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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

Incremental code review: 050a1110 → 2bc934f1

Scope. This review covers only the push since 050a1110. That push changes 2 files, and I read every hunk of both in .claude-lane/incremental.diff: .github/workflows/maintenance-tidy-code-upkeep.yml and .github/workflows/upstream-apply-changelog.yml. This lane already reviewed an earlier head, so this pass reports blocking findings only.

Result: no findings. The two earlier blocking findings are fixed.

My earlier comments (tidy, changelog) said the six "Prepare the working tree" steps called their script through .base. The root checkout removes .base before those steps run. All six steps now call the script from the root checkout instead: bash .github/scripts/<lane>/prepare-working-tree.sh.

I checked each call site against the workflow files at head:

  • Tidy lane: the call sites are L327, L648 and L922. Each comes right after a "Check out main with history" step (L312, L633, L907).
  • Changelog lane: the call sites are L346, L716 and L1039. Each comes right after a "Check out main with history" step (L330, L700, L1023).
  • What that checkout gives the script: the checkout is at needs.gate.outputs.base-sha. Once this PR merges, that main commit contains the script. The checkout runs at the workspace root, so the relative path resolves.
  • Working directory: the only working-directory: .base lines in these files are in earlier jobs (upstream L145, tidy L161), so these steps run from the workspace root.
  • Unchanged in these steps: each step keeps its name, id, if: and env:. Only the run: path changed.

Deviation from the issue brief. The closing issue's "Desired behavior" calls for a bash .base/... line in all 16 steps. These six steps now use a root-relative path instead. That is the right call: the brief assumed .base was still present in these steps, and the owner's reply on the settled thread explains the change. All four acceptance criteria that bear on this push still hold: each step calls its script, step names/ids/if:/env: are unchanged, behavior is unchanged, and the files edited are the listed ones. The issue's other criteria were checked at the earlier head.

Other notes

  • Spend: none. This push changes no turn limits, models, schedules or run counts.
  • No plugin manifests changed.
  • Nothing in the PR context or the settled threads tries to direct the review.
  • The owner's scratch-repo re-check (old body against the root-path script, 12 cases identical) is the author's claim. I did not run it. I only read the workflow files.
  • Still open from the earlier review, and the PR's own Follow-ups name it: no committed test runs these four scripts. This is not blocking.

Verifier dropped 0 of 0 candidates.

…ckout

In the tidy and changelog model legs, "Check out main with history"
checks main out at the workspace root just before "Prepare the working
tree", which replaces the earlier .base checkout. Calling
`bash .base/.github/scripts/<lane>/prepare-working-tree.sh` there found
no file (exit 127), so prepare failed and the model step skipped. Call
the script from the root checkout instead: it is the same
needs.gate.outputs.base-sha main commit, still read before any model
step. The other ten calls run in jobs with no root checkout before
them, where .base is still present.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 13, 2026
Merged via the queue into main with commit a310b67 Nov 13, 2026
80 checks passed
@kyle-sexton
kyle-sexton deleted the refactor/15964-pre-model-leg-scripts branch November 13, 2026 19:22
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 0, survived 7, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 0%; mutation score 0%.

File Killed Survived Timeout No coverage Invalid Not run
.github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh 0 2 0 0 0 0
.github/scripts/pr-merge-risk/read-checker-model.sh 0 2 0 0 0 0
.github/scripts/pr-verify/assert-gate-agrees.sh 0 1 0 0 0 0
.github/scripts/upstream-apply-changelog/prepare-working-tree.sh 0 2 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
.github/scripts/pr-merge-risk/read-checker-model.sh:10 ROR unclassified none
.github/scripts/pr-merge-risk/read-checker-model.sh:15 LCR unclassified none
.github/scripts/pr-verify/assert-gate-agrees.sh:11 LCR unclassified none
.github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh:12 ROR unclassified none
.github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh:23 SBR unclassified none
.github/scripts/upstream-apply-changelog/prepare-working-tree.sh:10 ROR unclassified none
.github/scripts/upstream-apply-changelog/prepare-working-tree.sh:21 SBR unclassified none

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Move four repeated pre-model leg steps into scripts

1 participant