Skip to content

Move four repeated pre-model leg steps into scripts #15964

Description

@kyle-sexton

Agent Brief

Type: Task
Summary: Move four repeated pre-model leg steps into scripts under .github/scripts/, and drop three dead credit-marker rm -rf lines (part of restructuring pass #15695). The steps are "Assert the gate and the resolver agree" (pr-verify, pr-verify capture, merge-risk), "Read the checker's model" (merge-risk), and "Prepare the working tree" (the tidy and changelog lanes).

Current behavior:
Line numbers are at ba7bb0da37.

  • "Assert the gate and the resolver agree" has the same 4-line run: body 7 times, failing with ::error::the trigger gate and the resolver name different pull requests or heads. Every copy has the same id: agree, if: steps.gate.outputs.proceed == 'true' and env: (GATE_PR, GATE_HEAD, PR_NUMBER, HEAD_SHA). The copies are at pr-rate-merge-risk.yml:212-224, :639-651, :994-1006; pr-verify-capture.yml:235-247; pr-verify.yml:247-259, :2315-2327, :4165-4177.

    • Tests read only its if: and its place in the step order (.github/scripts/pr-merge-risk/workflow.test.mjs:200, .github/scripts/pr-verify/workflow.test.mjs:262,265,382,754).
    • The step before it already runs node .base/.github/scripts/pr-verify/resolve-pr.mjs.
  • "Read the checker's model" has the same 11-line body in the three merge-risk legs: pr-rate-merge-risk.yml:277-295, :697-715, :1052-1070. It refuses a default model and a non-alias subagent model, then writes model and force.

  • "Prepare the working tree" has one body per lane, the same in that lane's three legs:

    • tidy, 15 lines: maintenance-tidy-code-upkeep.yml:321-342, :657-678, :945-966;
    • changelog, 22 lines: upstream-apply-changelog.yml:339-368, :731-760, :1075-1104.

    It sets the commit identity, adds the exclusions, takes the head instruction and settings files out of the session (skip-worktree), and stages the read-only plugin copy.

  • None of these bodies holds a ${{ }} expression. Each runs before its job's model step, from a job that checked main out in full to .base.

    • All four workflows run main's file: workflow_run, push, schedule and workflow_dispatch.
    • No test names "Read the checker's model" or "Prepare the working tree" (git grep over *.test.mjs and *.test.sh: 0 hits).
    • The leg-equality checks compare the legs with each other, so equal edits keep them equal.
  • "Write the key's credit-stop marker" opens with a dead rm -rf "${RUNNER_TEMP:?}/key-credit-stop" at pr-rate-merge-risk.yml:454, maintenance-tidy-code-upkeep.yml:431 and upstream-apply-changelog.yml:457:

Desired behavior:

  • Four new scripts, each mode 100755 with a #!/usr/bin/env bash line (as .github/scripts/lib/handoff-evidence.sh has), called with bash from the workspace root and holding its step's body verbatim, reading the same environment names:
    • .github/scripts/pr-verify/assert-gate-agrees.sh;
    • .github/scripts/pr-merge-risk/read-checker-model.sh;
    • .github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh;
    • .github/scripts/upstream-apply-changelog/prepare-working-tree.sh.
  • Each of the 16 steps keeps its name, id, if: and env:, and its run: becomes one bash .base/.github/scripts/<dir>/<script>.sh line.
  • The three rm -rf lines are gone; each marker step keeps its mkdir -p and echo lines.

Files:

  • .github/scripts/pr-verify/assert-gate-agrees.sh (new)
  • .github/scripts/pr-merge-risk/read-checker-model.sh (new)
  • .github/scripts/maintenance-tidy-code-upkeep/prepare-working-tree.sh (new)
  • .github/scripts/upstream-apply-changelog/prepare-working-tree.sh (new)
  • the steps at pr-rate-merge-risk.yml:212, :277, :454, :639, :697, :994, :1052
  • the steps at pr-verify.yml:247, :2315, :4165 and pr-verify-capture.yml:235
  • the steps at maintenance-tidy-code-upkeep.yml:321, :431, :657, :945
  • the steps at upstream-apply-changelog.yml:339, :457, :731, :1075

Key interfaces:

  • Each step's outputs, error lines, exit codes and working-tree effects: byte-identical for the same inputs.
  • The gate assertion stays its own step with its own id and if:, so a mismatch still fails that step, and the steps after it skip as they do now.
  • Token scope and log shape: each step stays one run step reading main's checkout, before any model step, with no new token, permission or composite action.

Acceptance criteria:

  • The gate-agreement check, the checker-model read and each lane's working-tree preparation each exist once, in their new scripts, and every copy calls its script.
  • No credit-marker step in the three listed lanes removes the marker directory before writing it.
  • Every step name, id, if:, env: key, job id, trigger, permission and workflow file name is unchanged.
  • Behavior is unchanged: the same outputs, exit codes and working-tree state for the same inputs.
  • The diff edits only the listed files and the lines of a test that assert on them when the change breaks that assertion.
  • The pull request stays within 400 changed lines and 15 hand-edited files.
  • The four scripts pass the repository's shellcheck and shfmt checks.
  • ci-status is green.

Out of scope:

  • Steps that run after a model step, the three-leg structure, the plan hash and plan check pair the tidy and changelog lanes share, other duplication, eval cases, fixtures, and skill and agent text.

Activity

  1. added
    status: ready
    host-run
    on Nov 13, 2026
  2. added theissue type on Nov 13, 2026
  3. removed
    status: ready
    on Nov 13, 2026
  4. removed
    host-run
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Work status

    ready

    Priority

    low

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions