ci / static: cache + retry the pinned shellcheck fetch so a GitHub 5xx no longer reds main (machinery for #332) #333

Closed
opened 2026-11-05 09:32:18 +00:00 by matou-build-agent · 1 comment

Machinery change — .forgejo/workflows/ci.yml (protected path)

Filed by a Sandcastle worker while working #332. The fix for #332 lives
entirely inside .forgejo/workflows/ci.yml, a fingerprinted protected
path
(PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo" in
.sandcastle/protected-paths-lib.sh). A swarm worker cannot land a diff
under .forgejo/workflows/ — the protected-path boundary rolls it back and
reds the run, and heal_rails (rehearsal-heal-lib.sh:175) refuses the same
diff. Per CLAUDE.md rule 9 / the boundary's own PP_ESCAPE_PATH, the change
needs an interactive session's standing. Hence this ticket.

Symptom (from #332)

ci / static has been red on main for three consecutive pushes
(26333 → f95e71f, 26339 → 5b5727c, 26348 → 107020c), tripping the watchdog's
always-red signature 5653c0ad3cd5. ci / test stayed green throughout.

Two different faults wore one red: 26333 was a genuine SC2155 lint (closed
by #326); 26339 and 26348 never reached shellcheck — the download died:

curl: (22) The requested URL returned error: 504

GitHub returned HTTP 504 for the pinned
shellcheck-v0.11.0.linux.x86_64.tar.xz. At 107020c both static steps are
clean when the tarball is reachable (verified on the runner host).

Durable defect

The static job's shellcheck -S warning -x step fetches the pinned
shellcheck from github.com on every run with a single un-retried curl
under set -euo pipefail (.forgejo/workflows/ci.yml, currently around
lines 76–87 — the curl -fsSL ".../shellcheck-${ver}..." line). Any transient
5xx at GitHub reds the gate on main; because the swarm pushes to main
continuously, one GitHub blip reds several consecutive runs and reads as
"always red", masking whether the tree actually lints. The test job has no
such dependency (bash + jq + git only), which is why it stayed green.

Proposed fix (in the static job's shellcheck step)

  • Cache the verified binary on the runner at a stable, version-keyed path
    (e.g. $HOME/.cache/matou-factory/shellcheck-<ver>/), re-verifying the
    pinned sha256
    of the cached artefact on every run and re-downloading
    only on absence or checksum mismatch — a warm runner needs no network and
    the checksum rail is not weakened.
  • Retry the cold fetch with backoff (curl --retry 5 --retry-all-errors --retry-delay 3, or an explicit attempt loop) before failing.
  • Keep the step fail-closed: if shellcheck genuinely cannot be obtained
    after retries, the job must still fail rather than silently skip the lint.

Keep ver=v0.11.0 and
sha=8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198
pinned; the checksum must gate both a fresh download and a cache hit.

Consider logging a line on cache-hit vs cold-fetch so the signal stays
readable.

Why a worker can't do it

.forgejo/workflows/ is a protected path; a worker's edit there is rolled
back and reds the run. Needs a session.

Related: #332 (originating report, now agent-blocked on this ticket),
#211 (originating CI static-checks ticket), #326 (fixed the SC2155 fault).

## Machinery change — `.forgejo/workflows/ci.yml` (protected path) Filed by a Sandcastle worker while working **#332**. The fix for #332 lives entirely inside `.forgejo/workflows/ci.yml`, a fingerprinted **protected path** (`PP_PROTECTED_DIRS_DEFAULT=".sandcastle .forgejo"` in `.sandcastle/protected-paths-lib.sh`). A swarm worker cannot land a diff under `.forgejo/workflows/` — the protected-path boundary rolls it back and reds the run, and `heal_rails` (`rehearsal-heal-lib.sh:175`) refuses the same diff. Per CLAUDE.md rule 9 / the boundary's own `PP_ESCAPE_PATH`, the change needs an **interactive session's** standing. Hence this ticket. ## Symptom (from #332) `ci / static` has been red on `main` for three consecutive pushes (26333 → f95e71f, 26339 → 5b5727c, 26348 → 107020c), tripping the watchdog's `always-red` signature `5653c0ad3cd5`. `ci / test` stayed green throughout. Two different faults wore one red: 26333 was a genuine `SC2155` lint (closed by #326); 26339 and 26348 **never reached shellcheck** — the download died: ``` curl: (22) The requested URL returned error: 504 ``` GitHub returned HTTP 504 for the pinned `shellcheck-v0.11.0.linux.x86_64.tar.xz`. At 107020c both static steps are clean when the tarball is reachable (verified on the runner host). ## Durable defect The `static` job's `shellcheck -S warning -x` step fetches the pinned shellcheck from `github.com` on **every run** with a single un-retried `curl` under `set -euo pipefail` (`.forgejo/workflows/ci.yml`, currently around lines 76–87 — the `curl -fsSL ".../shellcheck-${ver}..."` line). Any transient 5xx at GitHub reds the gate on `main`; because the swarm pushes to `main` continuously, one GitHub blip reds several consecutive runs and reads as "always red", masking whether the tree actually lints. The `test` job has no such dependency (bash + jq + git only), which is why it stayed green. ## Proposed fix (in the `static` job's shellcheck step) - **Cache** the verified binary on the runner at a stable, version-keyed path (e.g. `$HOME/.cache/matou-factory/shellcheck-<ver>/`), **re-verifying the pinned `sha256`** of the cached artefact on every run and re-downloading only on absence or checksum mismatch — a warm runner needs no network and the checksum rail is not weakened. - **Retry** the cold fetch with backoff (`curl --retry 5 --retry-all-errors --retry-delay 3`, or an explicit attempt loop) before failing. - Keep the step **fail-closed**: if shellcheck genuinely cannot be obtained after retries, the job must still fail rather than silently skip the lint. Keep `ver=v0.11.0` and `sha=8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198` pinned; the checksum must gate both a fresh download and a cache hit. Consider logging a line on cache-hit vs cold-fetch so the signal stays readable. ## Why a worker can't do it `.forgejo/workflows/` is a protected path; a worker's edit there is rolled back and reds the run. Needs a session. Related: #332 (originating report, now `agent-blocked` on this ticket), #211 (originating CI static-checks ticket), #326 (fixed the `SC2155` fault).
Author
Member

Close report — landed on main (push mode)

Commit: 13434c0 — ci / static: #333 — cache + retry the pinned shellcheck fetch so a GitHub 5xx no longer reds main (pushed to main).

What landed (in .forgejo/workflows/ci.yml, the static job's shellcheck -S warning -x step; ver=v0.11.0 / sha=8c3be12b… unchanged):

  • Cache the pinned tarball at a version-keyed path on the runner — $HOME/.cache/matou-factory/shellcheck-<ver>/ — re-verifying the pinned sha256 on every run. A warm runner needs no network; a cache hit is trusted only when the cached artefact re-verifies, so a corrupt/truncated cache falls through to a cold fetch and the checksum rail is never weakened.
  • Retry the cold fetch with backoff: curl --retry 5 --retry-all-errors --retry-delay 3 — --retry-all-errors rides out the transient 504s #332 saw.
  • Fail-closed: a fetch that never succeeds, or a download that does not match the pin, is removed and the job dies rather than linting with an unverified (or no) binary.
  • A cache-hit vs cold-fetch line is logged so the signal stays readable.

Proof (no offline test covers ci.yml — self-workflows-drift-test.sh scopes it out — so the step's run-block was extracted and exercised on the matou-workstation runner host itself, where the gate runs):

  1. Cold fetch on an empty cache → downloads, sha256sum … OK, prints shellcheck v0.11.0.
  2. Second run → cache hit — no network.
  3. Corrupted cached tarball → self-heals via a fresh cold fetch.
  4. Deliberately wrong pin → fails closed (FAILED, exit 1) and removes the artefact.
  5. Unreachable mirror → retries (2 attempts, ~3s backoff) then dies non-zero (exit 7).

The full static job was then re-run locally at main's HEAD: bash -n over every script and shellcheck -S warning -x over *.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence are both clean, so the gate is green at HEAD once the tarball is reachable. ci.yml re-parses as valid YAML.

Blast radius: ci.yml here has deliberately diverged from its template (own test loop, pinned runner) and is not vendored to consumers — this is this repo's own CI only. No consumer/host/worker-class surface row changed and no pin moved, so STATUS.md's surface is untouched; the per-change entry is docs/journal/2026-11-05-333.md.

Advances #332 (its originating report, agent-blocked on this). Related: #326 (the SC2155 fault), #211.

Ruled by agent under ADR 0174 — veto anytime (two-way: a revertible ci.yml edit, proven on the runner host).

## Close report — landed on `main` (push mode) **Commit:** `13434c0` — `ci / static: #333 — cache + retry the pinned shellcheck fetch so a GitHub 5xx no longer reds main` (pushed to `main`). **What landed** (in `.forgejo/workflows/ci.yml`, the `static` job's `shellcheck -S warning -x` step; `ver=v0.11.0` / `sha=8c3be12b…` unchanged): - **Cache** the pinned tarball at a version-keyed path on the runner — `$HOME/.cache/matou-factory/shellcheck-<ver>/` — **re-verifying the pinned `sha256` on every run**. A warm runner needs no network; a cache hit is trusted only when the cached artefact re-verifies, so a corrupt/truncated cache falls through to a cold fetch and the checksum rail is never weakened. - **Retry** the cold fetch with backoff: `curl --retry 5 --retry-all-errors --retry-delay 3` — `--retry-all-errors` rides out the transient 504s #332 saw. - **Fail-closed**: a fetch that never succeeds, or a download that does not match the pin, is removed and the job dies rather than linting with an unverified (or no) binary. - A cache-hit vs cold-fetch line is logged so the signal stays readable. **Proof** (no offline test covers `ci.yml` — `self-workflows-drift-test.sh` scopes it out — so the step's run-block was extracted and exercised on the **matou-workstation runner host** itself, where the gate runs): 1. Cold fetch on an empty cache → downloads, `sha256sum … OK`, prints `shellcheck v0.11.0`. 2. Second run → `cache hit — no network`. 3. Corrupted cached tarball → self-heals via a fresh cold fetch. 4. Deliberately wrong pin → fails **closed** (`FAILED`, exit 1) and removes the artefact. 5. Unreachable mirror → retries (2 attempts, ~3s backoff) then dies non-zero (exit 7). The full `static` job was then re-run locally at `main`'s HEAD: `bash -n` over every script and `shellcheck -S warning -x` over `*.sh onboarding/*.sh onboarding/tests/*.sh tests/*.sh git-hooks/* git-fence` are both **clean**, so the gate is green at HEAD once the tarball is reachable. `ci.yml` re-parses as valid YAML. **Blast radius:** `ci.yml` here has deliberately diverged from its template (own test loop, pinned runner) and is **not** vendored to consumers — this is this repo's own CI only. No consumer/host/worker-class surface row changed and no pin moved, so `STATUS.md`'s surface is untouched; the per-change entry is `docs/journal/2026-11-05-333.md`. Advances #332 (its originating report, `agent-blocked` on this). Related: #326 (the `SC2155` fault), #211. Ruled by agent under ADR 0174 — veto anytime (two-way: a revertible `ci.yml` edit, proven on the runner host).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#333
No description provided.