Skip to content

Commit 1d5dfd6

Browse files
luisleo526claude
andcommitted
ci(release): the ruleset probe gets the canon authz job; stop claiming which App permission exposes bypass_actors (CR-245 F1, round 2)
Fresh sol + argon reads of the probe commit 6adae66: - P1 (both): test_gcp_sites_reject_cross_class_routes asserted 29 routed GCP sites; the probe workflow adds one, and the authz job it now carries adds another, so the derived count is 31 (ci 5, ci-post 8, native 3, corpus 3, subset 2, docs 2, docs-post 2, release 3 + prebuilt matrix site, promotion 1, probe 2). The PF_CI_LABELS subset stays 15. - P2 (sol): release-ruleset-probe.yml had no authz job. It now has the canonical authz job, the probe job needs it and carries the canonical step guards; the preflight pin and its mutation controls refuse a probe workflow without authz or without the dependency. The App-token mint step is unchanged and still byte-identical to release.yml's (the probe must use the same token path as the bump). - P2 (sol): docs/ci.md, the release.yml comment (comment lines only) and the binding release-gate test stated as fact that the App permission administration: read exposes bypass_actors. That is not verified: GitHub's documentation says bypass_actors is returned only to a caller with write access to the ruleset, and what an installation token sees on an inherited organization ruleset is exactly what the probe measures. All three now say what is true (the gate needs bypass_actors visible on every branch ruleset in the inventory; if the release App token cannot see them the bump is refused; the probe reports whether it can), and the test pins that wording, so it fails if the unsupported claim comes back. - P3 (sol): docs/ci.md said every probe refusal names an endpoint; only API/response failures do. Narrowed. Names the docs/ci.md sentences this commit removes or rewrites, all introduced by a8b1276 ("ci(release): the bump exemption also requires that only the release App can push to main"), as a deliberate revert of their unverified claim: "The gate relies on the release App permission `administration: read` to read `bypass_actors`." "The App installation has that permission and `contents: write`; the workflow-level `contents: write` setting scopes GITHUB_TOKEN and does not grant App permissions." "Tokens without administration access may receive a ruleset response with `bypass_actors` omitted; a missing field refuses, and the guard never assumes an unreadable list is empty or App-only." "Removing this App permission makes every release-bump exemption refuse." They are replaced by the verified wording above; the guard behaviour (a missing bypass_actors field refuses) is unchanged. Open decision, not changed here: the probe and release.yml use the tag references actions/create-github-app-token@v1 and actions/checkout@v4 where the CI canon wants full-SHA pins; the probe keeps the same mint as the bump on purpose. Lane: ci-fu-cr486q (Codex gpt-6.1-sol). Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 6adae66 commit 1d5dfd6

7 files changed

Lines changed: 369 additions & 43 deletions

File tree

‎.github/workflows/release-ruleset-probe.yml‎

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,70 @@ permissions:
99
contents: read
1010

1111
jobs:
12+
authz:
13+
name: authz
14+
# GCP fleet (owner #1050): non-release jobs on pf-gcp-pr; release-class jobs only on pf-gcp-main.
15+
runs-on: ["self-hosted", "pf-gcp-pr"]
16+
permissions: {}
17+
# No timeout-minutes: the owner's no-time-limits rule (check-no-time-limits refuses new ones).
18+
steps:
19+
- name: Only our own pull requests and our own events run CI
20+
env:
21+
EVENT: ${{ github.event_name }}
22+
REPO: ${{ github.repository }}
23+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
24+
HEAD_IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
25+
ASSOCIATION: ${{ github.event.pull_request.author_association }}
26+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
27+
WR_HEAD_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
28+
WR_ACTOR: ${{ github.event.workflow_run.triggering_actor.login }}
29+
GH_TOKEN: ${{ github.token }} # read-only use: one permission lookup for workflow_run
30+
# Bot logins whose same-repository pull requests count as ours: dependabot[bot] (CI-DEPBOT A)
31+
# and the org's own GitHub App bot logins by name (space-separated), nothing else.
32+
ALLOWED_BOTS: "dependabot[bot] pineforge-app[bot]"
33+
run: |
34+
set -eu
35+
fail() { echo "::error title=authz::$1"; echo "authz: REFUSED: $1" >> "$GITHUB_STEP_SUMMARY"; exit 1; }
36+
case "$EVENT" in
37+
push|workflow_dispatch|schedule|merge_group|release|workflow_call|repository_dispatch)
38+
# Only someone with write access to this repository (or our App's token) can cause these
39+
# events; none of them runs pull-request code.
40+
;;
41+
workflow_run)
42+
# LB-437: bind identity to the triggering run and its re-runner.
43+
# These two App bots are fixed canon policy; ALLOWED_BOTS is PR-only.
44+
[ -n "${WR_HEAD_REPO:-}" ] || fail "workflow_run head repository is missing"
45+
[ -n "${WR_ACTOR:-}" ] || fail "workflow_run triggering actor is missing"
46+
[ "$WR_HEAD_REPO" = "$REPO" ] || fail "workflow_run head repository does not match this repository"
47+
case "$WR_ACTOR" in
48+
"pineforge-app[bot]"|"pineforge-ci-dispatcher[bot]") ;;
49+
*"[bot]") fail "workflow_run bot is not on the canon allowlist" ;;
50+
*)
51+
perm=$(gh api "repos/$REPO/collaborators/$WR_ACTOR/permission" --jq .permission 2>/dev/null) || fail "workflow_run permission lookup failed"
52+
case "$perm" in admin|maintain|write) ;; *) fail "workflow_run triggering actor does not have write permission" ;; esac ;;
53+
esac ;;
54+
pull_request)
55+
[ "$HEAD_REPO" = "$REPO" ] || fail "pull request from another repository (${HEAD_REPO:-unknown})"
56+
[ "$HEAD_IS_FORK" = "false" ] || fail "pull request from a fork"
57+
case "$ASSOCIATION" in
58+
OWNER|MEMBER|COLLABORATOR) ;;
59+
*)
60+
case " $ALLOWED_BOTS " in
61+
*" $PR_AUTHOR "*) ;;
62+
*)
63+
# A member whose org membership is private shows as CONTRIBUTOR: ask GitHub for the
64+
# author's permission on this repository; anything but admin/maintain/write (or a
65+
# failed call) refuses.
66+
perm=$(gh api "repos/$REPO/collaborators/$PR_AUTHOR/permission" --jq .permission 2>/dev/null || echo none)
67+
case "$perm" in admin|maintain|write) ;; *) fail "author ${PR_AUTHOR:-unknown} (${ASSOCIATION:-NONE}) has permission '$perm', not write, and is not an allowlisted bot" ;; esac ;;
68+
esac ;;
69+
esac ;;
70+
*) fail "event $EVENT does not run CI (pull_request_target and other events are not allowed)" ;;
71+
esac
72+
echo "authz: allowed ($EVENT${PR_AUTHOR:+ by $PR_AUTHOR})" >> "$GITHUB_STEP_SUMMARY"
73+
1274
probe:
75+
needs: [authz]
1376
runs-on: ["self-hosted","pf-gcp-main"]
1477
steps:
1578
- name: Mint org App token
@@ -22,11 +85,13 @@ jobs:
2285
repositories: pineforge-engine
2386

2487
- name: Checkout
88+
if: ${{ needs.authz.result == 'success' }}
2589
uses: actions/checkout@v4
2690
with:
2791
persist-credentials: false
2892

2993
- name: Probe release ruleset barrier
94+
if: ${{ needs.authz.result == 'success' }}
3095
env:
3196
GH_TOKEN: ${{ steps.app.outputs.token }}
3297
run: python3 scripts/ci_release_gate.py rulesets-probe --repo "${GITHUB_REPOSITORY}"

‎.github/workflows/release.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ jobs:
118118
# The gate requires one active main pull_request ruleset whose own
119119
# bypass_actors is exactly Integration 4105147 with bypass_mode always.
120120
# Other rulesets' bypass lists do not supply or invalidate that barrier.
121-
# Its App permission administration: read exposes bypass_actors; removing
122-
# that permission makes the release-bump exemption refuse every release.
123-
# The workflow-level contents: write scope belongs to GITHUB_TOKEN.
121+
# The gate needs bypass_actors visible on every branch ruleset in the inventory.
122+
# If the release App token cannot see them, the bump is refused.
123+
# release-ruleset-probe.yml reports whether it can. contents: write scopes GITHUB_TOKEN.
124124
- name: Refuse unless pineforge/verify and pineforge/parity are green
125125
id: gate
126126
env:

‎docs/ci.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,23 +1359,23 @@ changes to the two files whose values the release workflow computes: the next
13591359
version and the reset catalog diff. Preflight pins the exact writer, staging,
13601360
commit and atomic-push step and the App-token checkout wiring.
13611361

1362-
The gate relies on the release App permission `administration: read` to read
1363-
`bypass_actors`. The App installation has that permission and `contents: write`;
1364-
the workflow-level `contents: write` setting scopes GITHUB_TOKEN and does not
1365-
grant App permissions. Tokens without administration access may receive a
1366-
ruleset response with `bypass_actors` omitted; a missing field refuses, and
1362+
The gate needs `bypass_actors` visible on every branch ruleset in the inventory.
1363+
If the release App token cannot see them, the bump is refused.
1364+
`release-ruleset-probe.yml` reports whether that token can see them.
1365+
Visibility with the installation token, including inherited organization
1366+
rulesets, is unverified until the probe runs. A missing field refuses;
13671367
the guard never assumes an unreadable list is empty or App-only.
1368-
Removing this App permission makes every release-bump exemption refuse.
1368+
The workflow-level `contents: write` setting scopes GITHUB_TOKEN.
13691369
Preflight pins the unconditional gate invocation and its App token, and its
1370-
binding release-gate tests pin this permission dependency in code and docs.
1370+
binding release-gate tests pin this visibility requirement in code and docs.
13711371

13721372
Dispatch **Release ruleset probe** (`release-ruleset-probe.yml`) once to check
13731373
actual ruleset visibility with the same App token mint as `release.yml`.
13741374
It runs `python3 scripts/ci_release_gate.py rulesets-probe --repo OWNER/REPO`,
13751375
reading only repository metadata, the parent-inclusive ruleset inventory and
13761376
branch details. Success prints the barrier id/name and one compact inventory
13771377
line with enforcement, source and bypass visibility. Refusal exits 1 with empty
1378-
stdout and the reader's `::error::` diagnostic naming the failing endpoint.
1378+
stdout and the reader's `::error::` diagnostic; API/response failures name the endpoint.
13791379
The probe changes no release evidence or gate verdicts. A release `dry_run`
13801380
on a merged PR does not exercise the bump-only ruleset reader.
13811381

‎scripts/ci_preflight.py‎

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@
142142
}
143143
# LB-435 plus addendum 2: isolate releases and the named promotion exception.
144144
# The strategy pin keeps the existing macOS and Linux ARM hosted legs.
145+
# The probe's credential-free authz retains the canon non-release fleet.
145146
RELEASE_JOB_RUNNERS = {
146147
'release.yml': {'release': RELEASE_RUNNER, 'prebuilt': HOSTED_MATRIX_RUNNER,
147148
'notify-hub': RELEASE_RUNNER},
148-
'release-ruleset-probe.yml': {'probe': RELEASE_RUNNER},
149+
'release-ruleset-probe.yml': {'authz': PR_RUNNER, 'probe': RELEASE_RUNNER},
149150
'promote-baseline.yml': {'promote': RELEASE_RUNNER},
150151
}
151152
# Credential-bearing jobs outside the release pins and gated docs build retain
@@ -989,9 +990,16 @@ def runner_findings(workflows: dict[str, str]) -> list[str]:
989990
bool(re.fullmatch(r'ubuntu-(?:\d{2}\.\d{2}|latest)-arm', runs_on[0]))))
990991
if job in fixed_release:
991992
# A quoted JSON scalar does not select a YAML label array.
992-
if _job_values(body, 'runs-on', unquote=False) != [fixed_release[job]]:
993-
findings.append(f'{name} job {job} must run on {fixed_release[job]} '
994-
'(isolated release)')
993+
actual = _job_values(body, 'runs-on', unquote=False)
994+
expected = [fixed_release[job]]
995+
if fixed_release[job] == PR_RUNNER:
996+
# Canon authz keeps its space after the comma; the complete
997+
# probe workflow pin below binds that exact header.
998+
actual = [_runner_value(value) for value in actual]
999+
expected = [_runner_value(value) for value in expected]
1000+
if actual != expected:
1001+
suffix = '' if fixed_release[job] == PR_RUNNER else ' (isolated release)'
1002+
findings.append(f'{name} job {job} must run on {fixed_release[job]}{suffix}')
9951003
environments = _job_values(workflow, 'env') + _job_values(body, 'env')
9961004
if any(re.search(r'\bPF_CI_LABELS["\']?\s*:', value) for value in environments):
9971005
findings.append(f'{name} job {job} must not set PF_CI_LABELS '
@@ -1136,7 +1144,8 @@ def _step_block(step: str, key: str) -> list[str]:
11361144
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
11371145
'''
11381146

1139-
# This App installation has administration: read, which exposes bypass_actors.
1147+
# The release App token must see bypass_actors on every branch ruleset.
1148+
# release-ruleset-probe.yml reports that visibility with the same token mint.
11401149
# The gate requires one active main pull_request ruleset whose own bypass list
11411150
# is exactly Integration 4105147 with bypass_mode always.
11421151
# The workflow's contents: write GITHUB_TOKEN cannot replace that credential.
@@ -1164,7 +1173,70 @@ def _step_block(step: str, key: str) -> list[str]:
11641173
contents: read
11651174
11661175
jobs:
1176+
authz:
1177+
name: authz
1178+
# GCP fleet (owner #1050): non-release jobs on pf-gcp-pr; release-class jobs only on pf-gcp-main.
1179+
runs-on: ["self-hosted", "pf-gcp-pr"]
1180+
permissions: {}
1181+
# No timeout-minutes: the owner's no-time-limits rule (check-no-time-limits refuses new ones).
1182+
steps:
1183+
- name: Only our own pull requests and our own events run CI
1184+
env:
1185+
EVENT: ${{ github.event_name }}
1186+
REPO: ${{ github.repository }}
1187+
HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
1188+
HEAD_IS_FORK: ${{ github.event.pull_request.head.repo.fork }}
1189+
ASSOCIATION: ${{ github.event.pull_request.author_association }}
1190+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
1191+
WR_HEAD_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
1192+
WR_ACTOR: ${{ github.event.workflow_run.triggering_actor.login }}
1193+
GH_TOKEN: ${{ github.token }} # read-only use: one permission lookup for workflow_run
1194+
# Bot logins whose same-repository pull requests count as ours: dependabot[bot] (CI-DEPBOT A)
1195+
# and the org's own GitHub App bot logins by name (space-separated), nothing else.
1196+
ALLOWED_BOTS: "dependabot[bot] pineforge-app[bot]"
1197+
run: |
1198+
set -eu
1199+
fail() { echo "::error title=authz::$1"; echo "authz: REFUSED: $1" >> "$GITHUB_STEP_SUMMARY"; exit 1; }
1200+
case "$EVENT" in
1201+
push|workflow_dispatch|schedule|merge_group|release|workflow_call|repository_dispatch)
1202+
# Only someone with write access to this repository (or our App's token) can cause these
1203+
# events; none of them runs pull-request code.
1204+
;;
1205+
workflow_run)
1206+
# LB-437: bind identity to the triggering run and its re-runner.
1207+
# These two App bots are fixed canon policy; ALLOWED_BOTS is PR-only.
1208+
[ -n "${WR_HEAD_REPO:-}" ] || fail "workflow_run head repository is missing"
1209+
[ -n "${WR_ACTOR:-}" ] || fail "workflow_run triggering actor is missing"
1210+
[ "$WR_HEAD_REPO" = "$REPO" ] || fail "workflow_run head repository does not match this repository"
1211+
case "$WR_ACTOR" in
1212+
"pineforge-app[bot]"|"pineforge-ci-dispatcher[bot]") ;;
1213+
*"[bot]") fail "workflow_run bot is not on the canon allowlist" ;;
1214+
*)
1215+
perm=$(gh api "repos/$REPO/collaborators/$WR_ACTOR/permission" --jq .permission 2>/dev/null) || fail "workflow_run permission lookup failed"
1216+
case "$perm" in admin|maintain|write) ;; *) fail "workflow_run triggering actor does not have write permission" ;; esac ;;
1217+
esac ;;
1218+
pull_request)
1219+
[ "$HEAD_REPO" = "$REPO" ] || fail "pull request from another repository (${HEAD_REPO:-unknown})"
1220+
[ "$HEAD_IS_FORK" = "false" ] || fail "pull request from a fork"
1221+
case "$ASSOCIATION" in
1222+
OWNER|MEMBER|COLLABORATOR) ;;
1223+
*)
1224+
case " $ALLOWED_BOTS " in
1225+
*" $PR_AUTHOR "*) ;;
1226+
*)
1227+
# A member whose org membership is private shows as CONTRIBUTOR: ask GitHub for the
1228+
# author's permission on this repository; anything but admin/maintain/write (or a
1229+
# failed call) refuses.
1230+
perm=$(gh api "repos/$REPO/collaborators/$PR_AUTHOR/permission" --jq .permission 2>/dev/null || echo none)
1231+
case "$perm" in admin|maintain|write) ;; *) fail "author ${PR_AUTHOR:-unknown} (${ASSOCIATION:-NONE}) has permission '$perm', not write, and is not an allowlisted bot" ;; esac ;;
1232+
esac ;;
1233+
esac ;;
1234+
*) fail "event $EVENT does not run CI (pull_request_target and other events are not allowed)" ;;
1235+
esac
1236+
echo "authz: allowed ($EVENT${PR_AUTHOR:+ by $PR_AUTHOR})" >> "$GITHUB_STEP_SUMMARY"
1237+
11671238
probe:
1239+
needs: [authz]
11681240
runs-on: ["self-hosted","pf-gcp-main"]
11691241
steps:
11701242
- name: Mint org App token
@@ -1177,11 +1249,13 @@ def _step_block(step: str, key: str) -> list[str]:
11771249
repositories: pineforge-engine
11781250
11791251
- name: Checkout
1252+
if: ${{ needs.authz.result == 'success' }}
11801253
uses: actions/checkout@v4
11811254
with:
11821255
persist-credentials: false
11831256
11841257
- name: Probe release ruleset barrier
1258+
if: ${{ needs.authz.result == 'success' }}
11851259
env:
11861260
GH_TOKEN: ${{ steps.app.outputs.token }}
11871261
run: python3 scripts/ci_release_gate.py rulesets-probe --repo "${GITHUB_REPOSITORY}"
@@ -1210,7 +1284,7 @@ def release_bump_workflow_findings(workflow: str) -> list[str]:
12101284
gate = _step_named(steps, ' - name: Refuse unless pineforge/verify and pineforge/parity are green')
12111285
if _code(gate) != _code(RELEASE_GATE_STEP):
12121286
findings.append('release.yml must keep the unconditional release gate '
1213-
'with its administration-readable App token '
1287+
'with its release App token '
12141288
'for the App-only main pull_request barrier')
12151289
app = _step_named(steps, ' - name: Mint org App token')
12161290
checkout = _step_named(steps, ' - name: Checkout (full history)')

‎scripts/ci_release_gate.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@
3030
# This is GitHub's authenticated push actor, never the commit's author/committer.
3131
RELEASE_PUSH_ACTOR = "pineforge-app[bot]"
3232
# Integration for release.yml's PINEFORGE_APP_ID installation token.
33-
# The gate relies on App permission administration: read to see bypass_actors;
34-
# removing it makes every release-bump exemption refuse, even with contents: write.
33+
# The gate needs bypass_actors visible on every branch ruleset in the inventory.
34+
# If the release App token cannot see them, the bump is refused;
35+
# release-ruleset-probe.yml reports whether it can.
3536
RELEASE_APP_ID = 4105147
3637
RELEASE_BUMP_PATHS = frozenset(("VERSION", "docker/run_failure_codes_diff.json"))
3738
MAIN_PROOF_WATCHER_FIRST_SHA: str | None = None

0 commit comments

Comments
 (0)