Skip to content

fix(org-ci): never abort the candy-gate retirement wave on one repo - #142

Merged
aitrawog merged 1 commit into
mainfrom
feat/retire-candy-gates-per-repo-resilience
Sep 28, 2026
Merged

aitrawog merged 1 commit into
mainfrom
feat/retire-candy-gates-per-repo-resilience

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

The org-wide candy-gate retirement (scripts/retire-per-repo-candy-gates.sh) aborted the entire ~300-repo wave on one repo. Run 36455597712 died at:

FATAL: layer-camsnap deploy.yml metadata fetch failed — refusing to read it as 'not the candy stub'

RCA (executed). stub_meta() returned non-zero on any fetch/decode failure and the caller turned that into exit 1. layer-camsnap's deploy.yml was already deleted by commit 3257d87 (2026-09-28T17:05:37Z), authored by the concurrent run 36455573679 (dispatched 17:04:40, i.e. 13s before the failing run 36455597712 at 17:04:53). The failing run's api_status probe of layer-camsnap returned 200; its stub_meta fetch one second later returned 404:

$ gh api repos/opencharly/layer-camsnap/contents/.github/workflows/deploy.yml
{"message":"Not Found","documentation_url":"…","status":"404"}   # exit 1
$ git -C layer-camsnap show -s --format='%ci' 3257d87
2026-09-28 17:05:37 +0000

So the trigger is a probe→fetch 404 race between two concurrent runs of this same wave — a case the pre-fix script could not tell apart from a real failure. (Two runs in flight, 36455573679 in_progress + 36455597712 failure; a third earlier one 36454414844 also failed the same way.)

Fix

stub_meta() now always returns 0 and prints a leading status; the caller branches:

status meaning action
ok blob metadata + text read and classified unchanged name: candy AND charly box validate safety gate; eligible for delete
vanished (HTTP 404) deleted between the probe and this fetch by a concurrent run of this wave counted absent, never failed, never deleted — idempotent
failed transient/technical fetch or decode error recorded in a distinct failed counter + FAILED repos list, logged loudly, never deleted, loop continues; the run exits non-zero so it is never silent
  1. Fail loud, per-repo — never abort the wave. A technical failure increments failed and the loop proceeds; MAX_FAILURES still guards a genuinely broken token/endpoint (failed > MAX_FAILURES aborts).
  2. Large-file case. When the Contents API omits inline .content (blobs > 1 MB, .encoding: "none"), the script falls back to the git blob API (repos/$ORG/$repo/git/blobs/$sha) to read the text — so a big deploy.yml is classified, not failed.
  3. The fail-closed SAFETY gate is unchanged. Deletion still requires both name: candy and the charly box validate signature; a mismatch is skipped, never touched.
  4. Probe failures still abort. A non-404 api_status failure remains FATAL (a probe transport failure must never read as "absent" org-wide).

How tested

$ bash -n scripts/retire-per-repo-candy-gates.sh
(no output; rc=0)

$ bash scripts/retire-per-repo-candy-gates_test.sh
retire-per-repo-candy-gates_test: all assertions passed

New assertions in retire-per-repo-candy-gates_test.sh:

  • per-repo resilience (the 36455597712 regression): a repo whose metadata fetch fails is counted failed, is logged SKIPPED (technical), never deleted, the summary lists it, the loop CONTINUES past it (the later repos are still classified), and the run exits non-zero.
  • vanished-race (the exact trigger): probe sees 200, the metadata fetch 404s → counted absent (retired=0 absent=2 skipped=2 failed=0), the run SUCCEEDS.
  • large-file blob fallback: a Contents response with a sha but no inline content is read via the blob API and the stub is retired, not failed.
  • plus the existing safety cases (real gate never touched; candy-named gate without the signature never touched; idempotent re-run; delete-failure counting; 403 abort).

Adjacent offline gates still green:

$ bash scripts/retire-per-repo-dispatchers_test.sh
retire-per-repo-dispatchers_test: all assertions passed
$ bash scripts/org-ruleset_test.sh
org-ruleset_test: all assertions passed (apply/verify/abort)
$ bash scripts/governance-reconcile.sh --self-test
governance-reconcile --self-test: all assertions passed

Rulebook compliance

  • R0 — /charly-internals:git-workflow (plus /charly-internals:repo-setup for the org-CI surface) loaded before any edit.
  • R1 — the layer-camsnap failure was root-caused (the concurrent-run 404 race) before the fix, with the commit timestamp and the two run IDs as evidence.
  • R4 — no workaround: the race is handled at its source (the status split), not by serializing runs or a sleep/retry.
  • R6 — feat/retire-candy-gates-per-repo-resilience off fresh origin/main; no direct push; no force-push.
  • Safety unchanged — the fail-closed delete gate (name + signature) is untouched.

Change classification

  • Change class: org-CI maintenance script (workflow logic only; no org ruleset / required-check change).
  • Verification gate: the offline mock-gh test suite (validator-harness.yml) — hermetic, runs in CI; no live service is faked (the mock is the boundary itself).
  • Attribution tier: fully tested and validated — the changed paths were executed live against the test harness on the final committed tree.

Agent: gh-retire-resilience · session ses_f172dce50ffeT3KbvpfC89PD1c
Assisted-by: OpenCode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)

stub_meta() returned non-zero on ANY fetch/decode failure and the caller
turned that into a FATAL exit(1), so a single repo aborted the whole
~300-repo wave. Run 36455597712 died on layer-camsnap: its deploy.yml was
deleted at 17:05:37Z by the CONCURRENT run 36455573679 (one second ahead),
so the probe saw 200 and the metadata fetch one second later returned 404.

Now stub_meta() always returns 0 and reports one of three statuses:
  - ok       (sha\tname\tis_stub) — classified, eligible for the unchanged
             name=candy + 'charly box validate' SAFETY gate;
  - vanished (HTTP 404)           — deleted between probe and fetch by a
             concurrent run; counted absent, never failed (idempotent);
  - failed                        — transient/technical error; recorded in a
             distinct counter + FAILED-repos list, never deleted, loop
             CONTINUES, run exits non-zero so it is never silent.

Also falls back to the git blob API (git/blobs/<sha>) when the Contents API
omits inline content (blobs > 1 MB, encoding 'none'), so a large deploy.yml
is classified, not failed.

Test: adds the per-repo-resilience assertion (a metadata failure is counted
failed, loop continues past it, summary lists it) + the vanished-race case
(the exact 36455597712 trigger; counted absent, run SUCCEEDS) + the
large-file blob fallback.

Assisted-by: OpenCode ollama-cloud/deepseek-v4.1-flash (fully tested and validated)
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: e3a2992c64e4de9b04cef882187c7252c7dd8353 (branch: feat/retire-candy-gates-per-repo-resilience)

Security screen: PASS — no secrets/exfiltration, no supply-chain change, no weakened guardrail (the fail-closed delete gate — name: candy AND the charly box validate signature — is unchanged; a failed/vanished fetch is never deleted, and the run still exits non-zero). Not touching the validator spec / branch protection / rulebook.
Checklist: All applicable rules PASS or NA.

  • Change class: org-CI shell script (.github repo) — gate is the hermetic mock-gh suite; no bed/rebuild applies. Tests provably exercise the changed paths (vanished → absent, failed → per-repo skip + loop-continue + non-zero exit, bigfile → blob fallback + delete), each of which fails on the pre-fix script.
  • Body accounts for both files, pastes real output, ends with the Assisted-by: footer; tier not inflated; the concurrency "race" is RCA'd and fixed idempotently (not dismissed as flake/idle-green); R5 sweep is clean (old comments/behavior removed in the same commit); R8/R9 N/A.

Verdict: PASS


ollama-cloud/deepseek-v4.1-flash — action-review.

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 28, 2026 17:21
@aitrawog
aitrawog merged commit 283bf85 into main Sep 28, 2026
2 checks passed
@aitrawog
aitrawog deleted the feat/retire-candy-gates-per-repo-resilience branch September 28, 2026 17:22
charly-auto-merge Bot added a commit that referenced this pull request Sep 28, 2026
github-actions Bot pushed a commit that referenced this pull request Sep 28, 2026
* feat(org-ci): ONE-shot minimal-diff config version: strip cutover

Add scripts/strip-config-version.sh + its one-shot App-token workflow, mirroring
the retire-per-repo-candy-gates precedent (branch-protection bypass commit by the
charly-auto-merge App). The schema-versioning-removal cutover deletes the authored
config version: field; 393 repos still carry it on main. The host leg
(opencharly/charly#716) is not landed, so no released charly accepts/needs the
strip and `charly migrate` reformats the whole file (~100 cosmetic lines of churn,
incl. trailing-whitespace changes inside description: block scalars) — unacceptable
across 393 repos.

The strip is a minimal-diff, parser-safe line filter (scripts/_strip-filter.py):
delete a line ONLY when it matches ^ {0,8}version: (the indent-0 document stamp, or
an entity-body stamp at indent 8 / indent 4 in the two 2-space manifests). A
version: line at indent 16+ is a fenced YAML example inside a description: | block
scalar and is PRESERVED (9 repos; layer-charly-hermes's code-block stamp MUST
survive). The filter refuses loudly if a matched line ever sits inside a block
scalar. Everything else is byte-identical. DRY_RUN=1 reports without committing;
per-repo failures never abort the wave (#142 lesson).

Also fix scripts/lib-org.sh api_status: `awk 'NR==1{print $2; exit}'` SIGPIPEs
under pipefail when the response body exceeds 64 KiB (every charly.yml > ~64 KB,
measured 100 KB on distro-arch), which killed the probe; drop the `exit`.

Coverage: scripts/strip-config-version_test.sh (offline, mock gh) locks all four
required cases incl. the REAL layer-charly-hermes charly.yml as a committed fixture
(scripts/fixtures/), wired into validator-harness.yml.

Assisted-by: opencode Ollama Cloud deepseek-v4.1-flash (analysed on a live system)

* fix(org-ci): address validator round — consistent counts, injection-safe dispatch, pasted sweep

Round-1 validator BLOCK fixes:

1. Documentation divergence (A1/B5): every surface (script header, workflow header,
   filter docstring, README) now states the SAME measured metrics over the org
   TARGET set (the 423 active, non-fork, main-default repos discover_repos
   enumerates, measured 2026-09-28): 402 carry a charly.yml; 394 would be STRIPPED;
   2 carry ONLY a preserved code-block example; 21 have no charly.yml; equivalently
   396 carry at least one version: line on main, 6 carry a charly.yml with none.

2. R5 (B14d): removed the described-but-unpasted sweep claim; the pasted
   `git grep -n 'strip-config-version' HEAD` output + exit status now live in the PR
   body.

3. T3 shell injection: the dispatch workflow no longer interpolates
   `${{ inputs.repos }}` into `run:`. It is passed via `env: REPOS` and expanded as a
   quoted array (`read -ra repo_args <<<"$REPOS"`), so a metacharacter in the input is
   one literal argv element, never shell code.

Assisted-by: opencode Ollama Cloud deepseek-v4.1-flash (analysed on a live system)

* docs: re-freeze the PR body against the final head (validator round 3)

* docs: re-freeze the PR body against the final head (validator round 3, SHA-generic evidence)

---------

Co-authored-by: Andreas Trawoeger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant