Repository navigation
chore(ci): dedupe repeated workflow shell into scripts/ci, and gate it - #740
Merged
Merged
Conversation
`scripts-home-check.sh` asks whether every shell FILE is under `scripts/`,
and the answer has been yes for a while. A workflow's `run:` block is shell
with no file, so it was invisible to that gate — and that is where it
accumulated.
Deduped (the same shell, more than once):
- `build-cost.sh` replaces 7 copies in rust.yml, in two variants: five
printed `df` and two did not, and `df` is the line that tells a slow build
from a full disk. Now one copy that always prints all three.
- `reclaim-disk.sh` replaces 4 copies (rust.yml x3, kind.yml), each of which
had re-derived the errno-28 safety argument in its own words.
- `install-helm.sh` replaces 3 copies, each pinning `HELM_VERSION: v3.19.0`
separately. One pin now; the chart tier and the deploy can no longer
render with different helms.
- `pass-key.sh` / `pass-decide.sh` replace the content-addressed pass gate in
both rust.yml and frontend.yml, together with ~30 duplicated lines arguing
why it is safe to trust. Verified byte-identical: both gates compute the
same key as before, so no open PR loses its marker. Dropped a dead second
`awk` in the frontend copy that filtered on an always-empty regex.
- `tf-step-summary.sh` replaces infra.yml's plan and apply summaries.
- `install-rust.sh` replaces 7 toolchain installs, and names
`--toolchain stable` so the call sites no longer depend on their cwd.
Extracted (single site, real logic): `rust-detect.sh` — the last of the four
detect steps still inline, and the only one whose event branching no test
could reach — plus `duckdb-cache-repair.sh`, `api-breaking-gate.sh`,
`helm-lint.sh`, `tf-validate-all.sh`, `tf-apply-plan.sh`, `tf-drift-plan.sh`,
four `deploy-*.sh` and three `agent-task-*.sh`. Each carries the reasoning
that was above it; `${{ }}` interpolation into shell became `env:`.
Left inline deliberately: five blocks of at most two commands with no control
flow, and folded `run: >` scalars, which are one command however they wrap.
New gate, `workflow-shell-check.sh` — a budget, not a ban: more than 3 lines
of shell, or any control flow at any length, must move to `scripts/ci/`. In
`make check` and in the ungated S9 job. Its self-test runs first, and earned
it: the first parser missed the bare `- run: |` step form entirely (a form
this repo uses), and mis-measured folded scalars.
Two bugs found and fixed on the way:
- `gen_infra_coverage` in skills-check.sh grepped infra.yml for the validate
loop. Extracting the loop made it render every stack as unvalidated and
report `bootstrap/organization` as covered by no tier — a silently WRONG
generated reference, which goes green the moment it is committed. It now
searches both homes and fails loudly on zero, via `err_quiet`.
- `set -u` in `duckdb-cache-repair.sh` made the empty-array path (the normal
one on a cold cache) exit 1. The inline original ran under GitHub's
`bash -eo pipefail`; that is restored, with the reason recorded.
`pass-key.sh` grew a positive control: zero keyed paths emits NO key, so the
gate runs. A key over an empty tree is the one outcome that must never
happen — every PR colliding on one hash and skipping on another's green.
`pass-gate-test.sh` (16 assertions) drives the real script against throwaway
commits rather than re-deriving its filter, and was mutation-tested against
four breakages.
Verified: actionlint, scripts-home-check, detect-paths-test, pass-gate-test,
skills-check-test, workflow-shell-check(-test) all green; both pass keys
byte-identical to the old inline logic. The cargo tiers are untouched by this
diff and left to CI, which runs them in full (scripts/ci is not exempt).
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Extracting infra.yml's helm install and `helm lint` into scripts removed them from the chart tier's own path filter. Inline, they lived in `.github/workflows/infra.yml`, which the pattern matches — so the tier re-ran on any edit to them. As files they matched nothing, so a PR editing only `helm-lint.sh` would no longer render or schema-check a chart. That is the `paths:`-filter trap in CLAUDE.md — a change to a gate not triggering the gate it defines — arriving through a refactor rather than through a filter, which is the direction nothing was watching for. `install-helm.sh` is in the pattern too: it owns the helm pin for three workflows, so a bump must render the charts with the helm that will deploy them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
terraform plan
|
`pass-gate-test.sh` built its probe trees with `git commit-tree`, which needs a
committer identity. `actions/checkout` configures none and the runner's passwd
entry has an empty name, so CI died on
fatal: empty ident name (for <runner@...>) not allowed
while a laptop passed, because git there auto-detects a name from the OS. That
asymmetry is the whole reason the first run was red: the test was green
locally and could not have been green on any runner.
`pass-key.sh` only ever runs `git ls-tree -r "$REF"`, and that accepts a
tree-ish — so `git write-tree` is enough and no commit object is needed. The
test now depends on no ambient git config at all. Verified by running it with
`GIT_*_NAME` forced empty and the global/system config nulled, which
reproduces the runner exactly.
Also guarded the helper. When `probe` failed it returned empty, `keyat` fell
through to its `HEAD` default, and the assertions degraded to comparing HEAD
with HEAD — caught, but reported as "two equal keys" rather than "the probe is
broken". `probed` now exits 2 on an empty OID.
Re-mutation-tested after the change: dropping the HIT check, dropping the
COUPLED re-admit, and ignoring PASS_KEY_REF are each still caught.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 6, 2026
…#741) Two of the three open items from #740. The third — promoting `workflow pins (S9)` to a required check — is branch-protection configuration rather than a file in this tree, and is applied separately. COVERAGE FOR THE AGENT-TASK SCRIPTS (`scripts/ci/agent-task-test.sh`, 25 assertions, in the ungated S9 job). `agent-task.yml` is `workflow_dispatch` only and needs `CLAUDE_CODE_OAUTH_TOKEN` and `AGENT_APP_KEY`, neither of which this repo has — so dispatching it to exercise the extraction would die at the agent step having proved nothing about the three scripts that run before and around it, and would leave an `agent-wip/<run-id>` branch on the remote for the trouble. All three are pure logic over environment variables, so a test covers them completely and covers them on every PR rather than once. The load-bearing half is input validation. `resume` is a dispatch input that reaches `refs/heads/agent-wip/$RESUME` and the agent's prompt, so it is attacker-shaped text until proven numeric: the suite rejects command substitution, backticks, path traversal, leading and trailing whitespace, negatives, decimals and over-length digits, and accepts the documented 20-digit bound so the rule cannot degrade to "reject everything long". It also pins that `agent-task-summary.sh` renders absent, empty, status-less and malformed structured output as three distinct cells without failing a step that runs on `always()`, and that `agent-task-checkpoint.sh` refuses an empty WIP rather than pushing to `refs/heads/`. Mutation-tested: unanchoring the regex, dropping the length bound, removing the validation entirely, and removing the jq fallback are each caught, on the assertions that should catch them. The other two extractions #740 left unexercised are now verified by real runs instead, both dispatched against `main`: - `drift.yml` (read-only by construction — the role holds no S3 write): `tf-drift-plan.sh` succeeded on all four stacks, and `classify the refresh` consumed its output, so the script really did write both the redacted text and the JSON. - `kind.yml`: `reclaim-disk.sh` and `install-kind-tools.sh` both succeeded. The probe job itself is a ~2h executor e2e that fails for reasons predating this work; the two steps this change owns are early and are proven. DESCRIPTION BUDGET. All four skills in the warning band are trimmed under it, so the generated budget table now reads "none; every skill can take another clause" — which was the point of the warning: headroom to absorb a routing tail without an unrelated PR discovering the cap as a failed gate. Only redundancy and prose were cut, never a routing clause or a `Use when` trigger — CLAUDE.md's generated routing table is byte-identical after regen, which is the check that the triggers survived. Headroom now: land-pr 891 (+133), project-board 913 (+111), skill-audit 956 (+68), security 957 (+67). Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
scripts-home-check.shasks whether every shell file is underscripts/, and the answer has been yes for a while. A workflow'srun:block is shell with no file, so it was invisible to that gate — and that is where it accumulated.Deduped — the same shell, more than once
build-cost.shdf, two did not — anddfis the line that distinguishes a slow build from a full disk (which surfaces aslinking with cc failed, not ENOSPC)reclaim-disk.shinstall-helm.shHELM_VERSION: v3.19.0separately — three places to bump, two to forget, and the chart tier could lint against one helm while the deploy rendered with anotherpass-key.sh+pass-decide.shtf-step-summary.shinstall-rust.sh--toolchain stableso the call sites no longer depend on their cwdNo open PR loses its pass marker. Both keys were verified byte-identical to the old inline logic against the same tree. A dead second
awkin the frontend copy — filtering on an always-empty regex, so matching everything — is dropped rather than carried.Extracted — single site, real logic
rust-detect.shis the headline: the last of the four detect steps still inline (frontend/infra/images already had one), and the only one whose event branching no test could reach. Plusduckdb-cache-repair.sh,api-breaking-gate.sh,helm-lint.sh,tf-validate-all.sh,tf-apply-plan.sh,tf-drift-plan.sh, fourdeploy-*.shand threeagent-task-*.sh. Each carries the reasoning that sat above it;${{ }}interpolated into shell becameenv:.Left inline deliberately: five blocks of at most two commands with no control flow, and folded
run: >scalars (one command however they wrap). The threshold is a stated rule, not a judgement call per site.The new gate
workflow-shell-check.sh— a budget, not a ban: more than 3 lines of shell, or any control flow at any length, must move toscripts/ci/. The second clause is load-bearing; a three-lineifis under any budget and is still a decision nothing can test in place. Comments are free, folded scalars are one command, generated workflows are skipped using the same marker testactionlint.shuses. Runs inmake checkand in the ungated S9 job.Its self-test runs first, and earned its place: the first parser missed the bare
- run: |step form entirely — a form this repo uses — and mis-measured folded scalars. Both were caught by fixtures, not by reading.Two bugs found on the way
gen_infra_coveragewas silently wrong. It greppedinfra.ymlfor the validate loop. Extracting the loop made it render every stack as unvalidated and reportbootstrap/organizationas covered by no tier. A silently wrong generated reference is worse than a stale one — it goes green the moment it is committed. It now searches both homes and fails loudly on zero viaerr_quiet, and the positive control was mutation-tested.set -ubroke the cold-cache path. Induckdb-cache-repair.sh, expanding an empty array under-umade the absent-tree path — the normal one — exit 1. The inline original ran under GitHub'sbash -eo pipefail; that is restored, with the reason recorded so it is not re-added.pass-key.shalso grew a positive control: zero keyed paths emits no key, so the gate runs. A key computed over an empty tree is the one outcome that must never happen — every PR colliding on one hash and skipping the gate on another's green.Verification
actionlint,scripts-home-check,detect-paths-test,pass-gate-test(16 assertions),skills-check-test,workflow-shell-checkand its self-test (16 assertions), andmake skills-checkare all green locally.pass-gate-test.shdrives the realpass-key.shagainst throwaway commits via aPASS_KEY_REFseam rather than re-deriving its filter, and was mutation-tested against four distinct breakages.The cargo tiers are untouched by this diff and left to CI, which runs them in full —
scripts/ci/is not exempt indetect-paths.sh, so this PR pays the whole backend gate.Worth a close look at review:
deploy.yml,drift.yml,kind.ymlandagent-task.ymlare not exercised by a pull request, so their extractions were verified by local smoke tests (including input-validation and injection cases foragent-task-ids.sh) rather than by this PR going green.🤖 Generated with Claude Code