Skip to content

fix(ci): fail fast on the workflows-permission 403 + document the app requirement - #110

Merged
github-actions[bot] merged 2 commits into
mainfrom
fix/retire-workflows-permission
Sep 22, 2026
Merged

github-actions[bot] merged 2 commits into
mainfrom
fix/retire-workflows-permission

Conversation

@aitrawog

Copy link
Copy Markdown
Contributor

Summary

RCA fix for a defect found while executing the org-wide validator cutover: the retirement workflow's charly-auto-merge App token holds contents: write (which carries the ruleset bypass for a protected-main commit) but not workflows: write — the distinct GitHub Apps permission required by DELETE on .github/workflows/*. Every delete on a repo where the app had not already succeeded returned 403 Resource not accessible by integration; the script counted those as ordinary failures and churned through the whole org before aborting at the failure cap.

Changes:

  • scripts/retire-per-repo-dispatchers.sh — a 403 Resource not accessible by integration is now classified as a PERMISSION error and aborts the run immediately with the exact remediation (the App must hold workflows: write in addition to contents: write), instead of churning through the remaining repos. The offline test gains the 403-abort case and asserts the remediation text.
  • .github/workflows/retire-per-repo-dispatchers.yml — header documents the required App permission (contents: write + workflows: write) and where to grant it.
  • README.md — the bot-token section names the workflows: write requirement; a new section documents the org-wide required workflow (ONE org ruleset, no per-repo copy) and the one-time cutover order.

This is a follow-up to #109 (merged), which introduced the cutover machinery.

How tested

The retirement script's offline mock-gh test, which now covers the 403 path:

$ bash -n scripts/retire-per-repo-dispatchers.sh && bash scripts/retire-per-repo-dispatchers_test.sh
retire-per-repo-dispatchers_test: all assertions passed

The RCA itself is the live cutover evidence (the 403s on the actual run), recorded in the #109 execution.

Rulebook compliance

  • R0 skills: /charly-internals:git-workflow loaded.
  • R1 RCA: root-caused to the missing workflows: write App permission; fixed at the root (fail-fast + documented), not worked around.
  • R2 complete: script + test + workflow + README land together.
  • R3 no duplication: one owner script; no second copy.
  • R4 no workaround: no retry/churn; a permission error aborts.
  • R5: the old claims are swept (the workflow header is the only place that claimed the app was sufficient).
  • R6 git safety: feat/-style branch; no force-push; no direct push to main.
  • R7 gate: the offline test pasted above.
  • Live-or-skip: the script test is pure offline logic with an explicit gh fake; the RCA is the real 403s from the live cutover.
  • R8/R9/R10: N/A — no generated artifact, no binary, no runtime bed (CI-config change).

Change classification

  • Change class: CI configuration (workflow script + header + README).
  • Verification gate: bash -n + the offline mock-gh test, pasted above.
  • Attribution tier: analysed on a live system — the defect was observed live during the cutover; the fix is covered by the offline test.

Assisted-by: opencode ollama-cloud/deepseek-v4.1-flash (analysed on a live system)

… requirement

RCA (live cutover, 2026-09-22): the retirement workflow's charly-auto-merge App
token holds contents:write + the ruleset bypass, but NOT workflows:write — the
GitHub Apps permission required by DELETE on .github/workflows/*. Every delete on
repos where the app had not already succeeded returned 403 'Resource not
accessible by integration'; the script counted them as failures and churned
through the whole org instead of stopping.

- scripts/retire-per-repo-dispatchers.sh: classify a 403 'Resource not accessible
  by integration' as a PERMISSION error and abort immediately with the remediation
  (the app must hold workflows:write in addition to contents:write), never a
  per-repo churn. Test adds the 403 abort case.
- The workflow header + README document the required app permission.
- README also documents the org-wide required workflow (ONE org ruleset) and the
  one-time cutover order.
@github-actions

Copy link
Copy Markdown
Contributor

Review — BLOCK

Head SHA: 71e660c971a82162bcecc4fcb38215f72610ae38 (branch: fix/retire-workflows-permission)

Change class: CI configuration (shell script + workflow header + README).

Security screen: PASS — no secrets/egress/supply-chain change; the change strengthens the cutover gate (fail-fast), it does not weaken any guardrail. No injected instructions in body/diffs.

Blocks

  1. B18 / R1 — scripts/retire-per-repo-dispatchers.sh: the failure path now double-counts deleted. The delete is captured as resp="$(gh api … 2>&1)" || { … }. Because of 2>&1, resp holds the error text on failure (not empty), so the success guard on the next line — [[ -z "${resp:-}" ]] || { echo "$repo: retired $path"; deleted=$((deleted+1)); } (new-file ~line 66) — is false on failure too and increments deleted for a repo that was not retired. On any non-403, under-cap failure the || block runs (failed++) and then execution falls through to that line and also does deleted++. The pre-PR if … then … else … fi cleanly separated the two counters; this PR regresses it.
    • Consequence: the summary retired=$deleted absent=$skipped failed=$failed over-reports retirements (a failed repo is reported as both retired and failed). The exit code stays correct only because [[ "$failed" == 0 ]] still trips.
    • The body's own RCA confirms this path is reachable: the pre-change run "churned through the whole org before aborting at the failure cap", i.e. the analogous non-exit-on-non-403-failure structure does continue (so deleted++ is reached).
    • The added offline test does not catch it: the FORCE_DELETE_FAIL case asserts only a non-zero exit, never the retired=…/failed=… counts — so the regression ships untested.
    • Fix: gate deleted++ on the delete's exit status, not on resp being non-empty, e.g. if resp="$(gh api --method DELETE … 2>&1)"; then echo "$repo: retired $path"; deleted=$((deleted+1)); else …403-check / failed++…; fi, and add a test assertion on the summary counts for the failure case (e.g. retired=0 … failed=1).

Verdict: BLOCK


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

View action run

…t (review round 2)

The round-1 fail-fast used 'resp=$(gh api ... 2>&1) || { ... }' then
'[[ -z "$resp" ]] || deleted++'. Because 2>&1 captures the error text, resp was
non-empty on failure too, so a failed repo was counted as BOTH retired and failed.
Gate on the delete's EXIT STATUS ('if resp=$(... 2>&1); then deleted++ else ...').
The test now asserts the exact counters (retired=0 absent=1 failed=1) for the
failure case, which the previous assertion-only-nonzero-exit did not catch.
@github-actions

Copy link
Copy Markdown
Contributor

Review — PASS

Head SHA: 9eb05abf74b97afa06fceb54d0beb9fc474364e5 (branch: fix/retire-workflows-permission)

Security screen: PASS — the workflow diff is comment-only, the script change strengthens the gate (fail-fast on 403), no secrets/egress/supply-chain/guardrail change, no injected instructions.
Checklist: All applicable rules PASS or NA.
Comment intake: 1 comment — github-actions[bot] BLOCK on prior SHA 71e660c9 — stale-superseded: the current HEAD gates deleted++ on the delete's exit status (if resp="$(gh api … 2>&1)"; then … else … fi), and the test now asserts retired=0 absent=1 failed=1 for the delete-fail case; the prior double-count finding no longer reproduces against the current diff.

Verdict: PASS


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

View action run

@github-actions
github-actions Bot enabled auto-merge (squash) September 22, 2026 17:12
@github-actions
github-actions Bot merged commit eebd754 into main Sep 22, 2026
2 checks passed
charly-auto-merge Bot added a commit that referenced this pull request Sep 22, 2026
@aitrawog
aitrawog deleted the fix/retire-workflows-permission branch September 25, 2026 19:08
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.

2 participants