From f1c5f35df38867d1f7f139be0c9549bfa573cbaa Mon Sep 17 00:00:00 2001 From: inviscid Date: Sun, 8 Nov 2026 20:13:32 -0600 Subject: [PATCH 1/2] ci: clean-room-review gate counts only current-head, latest, write-access verdicts (sc-36322) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The SOC 2 CC8.1 merge gate (byte-identical in 85 repos, the only review control there) passed on stale, overridden and outsider reviews: 1. A clean-room APPROVE comment on an older commit still passed after new pushes (commit_id was never read). 2. Any APPROVED outweighed every CHANGES_REQUESTED, including a later one from the same reviewer. 3. The body regex matched "cannot APPROVE" and sub-reviewer APPROVEs inside a REQUEST_CHANGES body, and missed the real "Clean-room re-review" header. 4. Any account's review counted (39 of the repos are public). Now: each write/admin reviewer's latest verdict counts (permission read via the collaborators API, since author_association hides private members); a clean-room comment is judged by its first line only and blocks unless it reads "— **APPROVE**"; any block fails; a pass needs an approval on the head SHA. Non-default bases (beta-*, release) stay exempt. clean-room-review/test_gate.sh runs the workflow's own run: script against 27 fixture cases through a gh shim (old gate: 14 fail; new: 27/27), and is added to test.yaml's gate job. clean-room-review/rollout.sh copies the merged canonical file to the other 84 repos, one draft PR each. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/clean-room-review.yaml | 56 +- .github/workflows/test.yaml | 3 +- clean-room-review/fixtures/cases.json | 645 +++++++++++++++++++++++ clean-room-review/rollout.sh | 45 ++ clean-room-review/test_gate.sh | 32 ++ 5 files changed, 766 insertions(+), 15 deletions(-) create mode 100644 clean-room-review/fixtures/cases.json create mode 100755 clean-room-review/rollout.sh create mode 100755 clean-room-review/test_gate.sh diff --git a/.github/workflows/clean-room-review.yaml b/.github/workflows/clean-room-review.yaml index c4b002e..c59fcf5 100644 --- a/.github/workflows/clean-room-review.yaml +++ b/.github/workflows/clean-room-review.yaml @@ -1,8 +1,12 @@ name: Clean-room review recorded -# Merge gate for the default branch (SOC 2 CC8.1): a pull request may merge only -# when it carries an approving review, or an independent clean-room review whose -# verdict is APPROVE recorded as a review comment (the author cannot approve their -# own PR). Re-evaluated whenever a review is submitted or the PR is updated. +# Merge gate for the default branch (SOC 2 CC8.1). A pull request may merge only +# when, taking each reviewer's latest verdict, nobody is requesting changes and +# someone approved the PR's current head commit, either with a GitHub approval +# or with a clean-room review comment whose first line reads "— **APPROVE**" +# (what /self-approve posts; the PR author may post it). Only reviewers with +# write access count. A verdict covers only the commit it was given on, so +# every push needs a fresh review. +# Canonical copy and regression tests: PlaidCloud/plaidcloud-github-actions. on: pull_request: types: [opened, synchronize, reopened, ready_for_review] @@ -19,11 +23,12 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 3 steps: - - name: Check for an approving or clean-room review + - name: Check for an approving or clean-room review of the head commit env: GH_TOKEN: ${{ github.token }} REPO: ${{ github.repository }} PR: ${{ github.event.pull_request.number }} + HEAD_SHA: ${{ github.event.pull_request.head.sha }} BASE: ${{ github.event.pull_request.base.ref }} DEFAULT: ${{ github.event.repository.default_branch }} run: | @@ -32,15 +37,38 @@ jobs: echo "Target $BASE is not the default branch ($DEFAULT); gate not required."; exit 0 fi gh api --paginate "repos/$REPO/pulls/$PR/reviews" | jq -s 'add // []' > reviews.json - approved=$(jq '[.[] | select(.state=="APPROVED")] | length' reviews.json) - cleanroom=$(jq '[.[] | select((.body // "") | test("Clean-room review[\\s\\S]{0,200}APPROVE"))] | length' reviews.json) - blocking=$(jq '[.[] | select(.state=="CHANGES_REQUESTED")] | length' reviews.json) - echo "approved=$approved clean-room=$cleanroom changes-requested=$blocking" - if [ "$blocking" -gt 0 ] && [ "$approved" -eq 0 ]; then - echo "::error::A reviewer requested changes; resolve and re-review."; exit 1 + # author_association hides private org members, so ask for repo permission. + writers=$(jq -r '[.[].user.login // empty] | unique[]' reviews.json | while read -r login; do + gh api "repos/$REPO/collaborators/$login/permission" --jq 'select(.permission | IN("admin", "write")) | .user.login' || true + done | jq -R . | jq -sc .) + # Latest verdict per reviewer, as GitHub counts them: plain comments + # change nothing, a dismissal clears. A clean-room comment is read + # from its first line only, so prose such as "cannot APPROVE" or a + # sub-reviewer's APPROVE inside a REQUEST_CHANGES body never counts, and + # a clean-room header without a clear APPROVE blocks. + jq --arg head "$HEAD_SHA" --argjson writers "$writers" ' + def header: (.body // "") | [splits("\n")] | map(select(test("\\S"))) | (.[0] // ""); + def verdict: + if .state == "APPROVED" then "approve" + elif .state == "CHANGES_REQUESTED" then "block" + elif .state == "DISMISSED" then "none" + elif .state == "COMMENTED" and (header | test("^\\W*Clean-room (re-)?review")) then + if (header | test("—\\s*\\*\\*APPROVE\\*\\*")) and (header | test("REQUEST_CHANGES") | not) + then "approve" else "block" end + else empty end; + [ .[] | select(.submitted_at != null and (.user.login | IN($writers[]))) + | {who: (.user.login // "ghost"), at: .submitted_at, commit: .commit_id, v: verdict} ] + | sort_by(.at) | group_by(.who) | map(last) + | {blocking: [.[] | select(.v == "block") | .who], + approved: [.[] | select(.v == "approve" and .commit == $head) | .who], + stale: [.[] | select(.v == "approve" and .commit != $head) | "\(.who)@\(.commit[0:7])"]} + ' reviews.json > verdict.json + echo "head=${HEAD_SHA:0:7} $(jq -c . verdict.json)" + if [ "$(jq '.blocking | length' verdict.json)" -gt 0 ]; then + echo "::error::Changes requested by $(jq -r '.blocking | join(", ")' verdict.json); resolve and re-review."; exit 1 fi - if [ "$approved" -gt 0 ] || [ "$cleanroom" -gt 0 ]; then - echo "Review requirement satisfied."; exit 0 + if [ "$(jq '.approved | length' verdict.json)" -gt 0 ]; then + echo "Review requirement satisfied for ${HEAD_SHA:0:7}."; exit 0 fi - echo "::error::No approving review and no clean-room review (\"Clean-room review ... APPROVE\") recorded on PR #$PR." + echo "::error::No approval or clean-room APPROVE recorded on head ${HEAD_SHA:0:7} of PR #$PR (stale: $(jq -r '.stale | join(", ")' verdict.json)). Re-review the current head." exit 1 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index c5bf726..17cd7da 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -8,7 +8,7 @@ on: jobs: gate: if: ${{ !github.event.pull_request.draft }} - name: License gate regression tests + name: Gate regression tests runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -17,6 +17,7 @@ jobs: with: python-version: '3.12' - run: python license-check/test_check_licenses.py + - run: clean-room-review/test_gate.sh # The tests above use synthetic Trivy JSON, which cannot catch a change in # what Trivy actually emits. This runs the whole action against this repo's diff --git a/clean-room-review/fixtures/cases.json b/clean-room-review/fixtures/cases.json new file mode 100644 index 0000000..3ba0208 --- /dev/null +++ b/clean-room-review/fixtures/cases.json @@ -0,0 +1,645 @@ +[ + { + "name": "no reviews", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [] + ] + }, + { + "name": "clean-room APPROVE comment on head", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:00:00Z" + } + ] + ] + }, + { + "name": "clean-room APPROVE only on an older commit (defect 1)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "submitted_at": "2026-11-08T10:01:00Z" + } + ] + ] + }, + { + "name": "old then fresh clean-room APPROVE", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "submitted_at": "2026-11-08T10:02:00Z" + }, + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:03:00Z" + } + ] + ] + }, + { + "name": "native APPROVED on head", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "mirza" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:04:00Z" + } + ] + ] + }, + { + "name": "native APPROVED on older commit, not dismissed", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "mirza" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "submitted_at": "2026-11-08T10:05:00Z" + } + ] + ] + }, + { + "name": "X approves, Y requests changes (defect 2)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:06:00Z" + }, + { + "user": { + "login": "y" + }, + "author_association": "MEMBER", + "state": "CHANGES_REQUESTED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:07:00Z" + } + ] + ] + }, + { + "name": "X approves then X requests changes", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:08:00Z" + }, + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "CHANGES_REQUESTED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:09:00Z" + } + ] + ] + }, + { + "name": "X requests changes then X approves head", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "CHANGES_REQUESTED", + "body": "", + "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "submitted_at": "2026-11-08T10:10:00Z" + }, + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:11:00Z" + } + ] + ] + }, + { + "name": "dismissed change request + clean-room APPROVE", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "y" + }, + "author_association": "MEMBER", + "state": "DISMISSED", + "body": "", + "commit_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "submitted_at": "2026-11-08T10:12:00Z" + }, + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:13:00Z" + } + ] + ] + }, + { + "name": "plain comment after approval keeps it", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:14:00Z" + }, + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "nit: rename", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:15:00Z" + } + ] + ] + }, + { + "name": "'cannot APPROVE' prose (defect 3)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "Clean-room review: I cannot APPROVE this yet.", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:16:00Z" + } + ] + ] + }, + { + "name": "REQUEST_CHANGES body quoting a sub-reviewer APPROVE", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room review (tier L, 3 reviewers) — **REQUEST_CHANGES**\n\nX is sound (tests reviewer APPROVE).", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:17:00Z" + } + ] + ] + }, + { + "name": "clean-room REQUEST_CHANGES after APPROVE on head", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:18:00Z" + }, + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room review (tier L, 3 reviewers) — **REQUEST_CHANGES**\n\nX is sound (tests reviewer APPROVE).", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:19:00Z" + } + ] + ] + }, + { + "name": "re-review header with suffix", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room re-review (tier L) — **APPROVE** after fixes in 2d8c40d", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:20:00Z" + } + ] + ] + }, + { + "name": "self-approve APPROVE event on someone else's PR", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "paul" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:21:00Z" + } + ] + ] + }, + { + "name": "clean-room comment from a non-member (public repo)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "rando" + }, + "author_association": "NONE", + "state": "COMMENTED", + "body": "✅ Clean-room review (tier S, 1 reviewer) — **APPROVE**\n\nsummary\n\n", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:22:00Z" + } + ] + ], + "perm": { + "rando": "none" + } + }, + { + "name": "approval from a read-only account (public repo)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "rando" + }, + "author_association": "CONTRIBUTOR", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:23:00Z" + } + ] + ], + "perm": { + "rando": "read" + } + }, + { + "name": "approval on second page of --paginate", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "bot" + }, + "author_association": "NONE", + "state": "COMMENTED", + "body": "lgtm", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:24:00Z" + } + ], + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:25:00Z" + } + ] + ], + "perm": { + "bot": "none" + } + }, + { + "name": "non-default base skips the gate", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [] + ], + "base": "beta-202610" + }, + { + "name": "infra#1386 at 19:33Z (only REQUEST_CHANGES verdicts) — old gate passed", + "expect": "fail", + "head": "b9652b2000000000000000000000000000000000", + "pages": [ + [ + { + "user": { + "login": "inviscid" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room review (tier L, 3 reviewers + 1 verifier) — **REQUEST_CHANGES**\n\nCP wiring, Grafana-admin move and oauth2-proxy `allowed_roles` are sound (tests+lean reviewer APPROVE). Blocking (found independently by 2 reviewers, CONFIRMED by verifier):\n\n1. **[blocking]** `tenants/templates/configmap-credentials.yaml` (deleted) — the tenant ConfigMap `plaid-rpc-credentials` becomes an ESO Secret of the same name, but plaid master `plaid/core/utility/kubernetes.py:4348-4351` `_get_rpc_volumes()` hard-codes a non-optional `V1ConfigMapVolumeSource(name=\"plaid-rpc-credentials\")` for rpc-spawned export (:688), workflow (:970/:981), lakehouse-transfer (:2200) Jobs and user CronJobs (:4159); `test_credentials_volume_always_configmap` pins it and `reconcile_user_cronjob_volumes` only repairs `config`. After a tenant syncs this chart and Argo prunes the ConfigMap, every new such pod sticks in ContainerCreating (FailedMount) and persisted user CronJobs fail fleet-wide. Fix: plaid PR first — detect the credentials volume kind from the rpc Deployment (as for `config`) and extend the CronJob reconciler; pin that image before/with this chart.\n\nNon-blocking (being fixed in the same batch):\n- `eso.tenantConfig.enabled` gates a Secret that every pod mounts non-optionally — drop the gate (no default-off flags).\n- oauth2-proxy: template should own `provider = \"keycloak-oidc\"` like `scope`, so a content override cannot silently disable `allowed_roles`; C10 scope regex misses single-quoted TOML.\n- \"C8\" vs C10 naming in VENDORED-PATCHES.md / lint.yml.\n- No render assertion for the new ExternalSecrets / absence of D1-A keys in the CP Secret.\n- Grafana admin rotation must reset each tenant DB admin password (sidecars auth with the Secret → 401 otherwise).\n- Not fixed here (filed sc-36237 scope): `profit_store.encrypt_phrase` / `braintree.merchant_id` literals in the credentials template.\n- Merge == ci deploy: Vault seeding must precede merge (PR body says so; nothing enforces it).\n\n", + "commit_id": "172ba87aabeb64a045ad6874db96b31410e09276", + "submitted_at": "2026-11-08T03:25:16Z" + }, + { + "user": { + "login": "inviscid" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room re-review (tier L, opus, focused on eff76055f→f11b67b9d + rebase) — **REQUEST_CHANGES** (ordering precondition only, no code defect)\n\nBlocking: the beta path. Infra RCs keep beta's image pins, and plaid `beta-202610` does not yet contain ebbce9cc78 (#8879). The 7 beta-ref tenants would get the Secret-backed `credentials` volume while old rpc images hard-code the ConfigMap source, so spawned Jobs and user CronJobs would hang in ContainerCreating. Resolution: a plaid beta train to get ebbce9cc78 into beta and its pin bumped on infra beta BEFORE any infra RC that carries this chart. Master alone is safe (rpc:ebbce9c-4967-1 is pinned alongside).\n\nNon-blocking:\n- Transient: the tenant ConfigMap is pruned in wave 0 while rpc/keda-workers roll; old pods cache the \"configMap\" kind, so Jobs spawned in that minutes-long window need a rerun.\n- `tenants/templates/grafana/external-secret-grafana-admin.yaml:30` lacked `| default \"tenant-clusters\"` (fixed in the next commit).\n- The Grafana admin password moved unrotated (E9 rotation planned); dead `apps.cp_rest.credentials.*` literals remain in plaid-tenant-applications overlays (remove + rotate after the prod tag).\n\nVerified: rebase range-diff all `=`; master pins intact; every remoteRef key/property matches Vault; ESO policies read all paths; prod-blue overlay renders C12; 38/38 tenants get one keycloak-oidc provider.\n\n", + "commit_id": "f11b67b9d7f7399078dc1d0ffb37c9289a23d545", + "submitted_at": "2026-11-08T19:25:20Z" + } + ] + ] + }, + { + "name": "infra#1386 at 19:35Z (APPROVE re-review on head; old gate passed only via the stale REQUEST_CHANGES)", + "expect": "pass", + "head": "b9652b2000000000000000000000000000000000", + "pages": [ + [ + { + "user": { + "login": "inviscid" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room review (tier L, 3 reviewers + 1 verifier) — **REQUEST_CHANGES**\n\nCP wiring, Grafana-admin move and oauth2-proxy `allowed_roles` are sound (tests+lean reviewer APPROVE). Blocking (found independently by 2 reviewers, CONFIRMED by verifier):\n\n1. **[blocking]** `tenants/templates/configmap-credentials.yaml` (deleted) — the tenant ConfigMap `plaid-rpc-credentials` becomes an ESO Secret of the same name, but plaid master `plaid/core/utility/kubernetes.py:4348-4351` `_get_rpc_volumes()` hard-codes a non-optional `V1ConfigMapVolumeSource(name=\"plaid-rpc-credentials\")` for rpc-spawned export (:688), workflow (:970/:981), lakehouse-transfer (:2200) Jobs and user CronJobs (:4159); `test_credentials_volume_always_configmap` pins it and `reconcile_user_cronjob_volumes` only repairs `config`. After a tenant syncs this chart and Argo prunes the ConfigMap, every new such pod sticks in ContainerCreating (FailedMount) and persisted user CronJobs fail fleet-wide. Fix: plaid PR first — detect the credentials volume kind from the rpc Deployment (as for `config`) and extend the CronJob reconciler; pin that image before/with this chart.\n\nNon-blocking (being fixed in the same batch):\n- `eso.tenantConfig.enabled` gates a Secret that every pod mounts non-optionally — drop the gate (no default-off flags).\n- oauth2-proxy: template should own `provider = \"keycloak-oidc\"` like `scope`, so a content override cannot silently disable `allowed_roles`; C10 scope regex misses single-quoted TOML.\n- \"C8\" vs C10 naming in VENDORED-PATCHES.md / lint.yml.\n- No render assertion for the new ExternalSecrets / absence of D1-A keys in the CP Secret.\n- Grafana admin rotation must reset each tenant DB admin password (sidecars auth with the Secret → 401 otherwise).\n- Not fixed here (filed sc-36237 scope): `profit_store.encrypt_phrase` / `braintree.merchant_id` literals in the credentials template.\n- Merge == ci deploy: Vault seeding must precede merge (PR body says so; nothing enforces it).\n\n", + "commit_id": "172ba87aabeb64a045ad6874db96b31410e09276", + "submitted_at": "2026-11-08T03:25:16Z" + }, + { + "user": { + "login": "inviscid" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "⛔ Clean-room re-review (tier L, opus, focused on eff76055f→f11b67b9d + rebase) — **REQUEST_CHANGES** (ordering precondition only, no code defect)\n\nBlocking: the beta path. Infra RCs keep beta's image pins, and plaid `beta-202610` does not yet contain ebbce9cc78 (#8879). The 7 beta-ref tenants would get the Secret-backed `credentials` volume while old rpc images hard-code the ConfigMap source, so spawned Jobs and user CronJobs would hang in ContainerCreating. Resolution: a plaid beta train to get ebbce9cc78 into beta and its pin bumped on infra beta BEFORE any infra RC that carries this chart. Master alone is safe (rpc:ebbce9c-4967-1 is pinned alongside).\n\nNon-blocking:\n- Transient: the tenant ConfigMap is pruned in wave 0 while rpc/keda-workers roll; old pods cache the \"configMap\" kind, so Jobs spawned in that minutes-long window need a rerun.\n- `tenants/templates/grafana/external-secret-grafana-admin.yaml:30` lacked `| default \"tenant-clusters\"` (fixed in the next commit).\n- The Grafana admin password moved unrotated (E9 rotation planned); dead `apps.cp_rest.credentials.*` literals remain in plaid-tenant-applications overlays (remove + rotate after the prod tag).\n\nVerified: rebase range-diff all `=`; master pins intact; every remoteRef key/property matches Vault; ESO policies read all paths; prod-blue overlay renders C12; 38/38 tenants get one keycloak-oidc provider.\n\n", + "commit_id": "f11b67b9d7f7399078dc1d0ffb37c9289a23d545", + "submitted_at": "2026-11-08T19:25:20Z" + }, + { + "user": { + "login": "inviscid" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "body": "✅ Clean-room re-review (tier L) — **APPROVE**\n\nThe single blocker (ordering) is resolved: plaid RC #8880 put ebbce9cc78 into beta-202610, and infra `beta` now pins rpc and dimension to `beta-202610-880-1` in tenants/values.yaml and rpc in controlplane/values.yaml (23aec88bfd). Any infra RC carrying this chart now ships with an image that mirrors the volume kind. The Grafana ExternalSecret prefix default is fixed in b9652b247 (gate PASS).\n\nNon-blocking findings, still recorded:\n- A minutes-long Job-spawn window during the ConfigMap→Secret prune while rpc/keda-workers roll (old pods cache the kind); affected Jobs need a rerun.\n- The Grafana admin password moved without rotation (E9); dead `apps.cp_rest.credentials.*` literals remain in plaid-tenant-applications overlays (remove + rotate after the prod tag).\n\n", + "commit_id": "b9652b2000000000000000000000000000000000", + "submitted_at": "2026-11-08T19:35:02Z" + } + ] + ] + }, + { + "name": "approve head then NON-BOLD clean-room REQUEST_CHANGES on head", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T01:00:00Z", + "body": "✅ Clean-room review (tier S) — **APPROVE**" + }, + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T02:00:00Z", + "body": "⛔ Clean-room re-review — REQUEST_CHANGES" + } + ] + ] + }, + { + "name": "private org member with write access (author_association CONTRIBUTOR)", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "kkapper" + }, + "author_association": "CONTRIBUTOR", + "state": "APPROVED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T01:00:00Z", + "body": "" + } + ] + ] + }, + { + "name": "approve head then clean-room line w/o verdict (e.g. 'Clean-room review: blocked, see below')", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T01:00:00Z", + "body": "✅ Clean-room review (tier S) — **APPROVE**" + }, + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T02:00:00Z", + "body": "## Clean-room review — blocked\n**REQUEST_CHANGES**" + } + ] + ] + }, + { + "name": "header 'not **APPROVE**'", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T01:00:00Z", + "body": "Clean-room review: did not **APPROVE**" + } + ] + ] + }, + { + "name": "review with null submitted_at (pending) from another user", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "a" + }, + "author_association": "MEMBER", + "state": "COMMENTED", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T01:00:00Z", + "body": "✅ Clean-room review — **APPROVE**" + }, + { + "user": { + "login": "b" + }, + "author_association": "MEMBER", + "state": "PENDING", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": null, + "body": "" + } + ] + ] + } +] \ No newline at end of file diff --git a/clean-room-review/rollout.sh b/clean-room-review/rollout.sh new file mode 100755 index 0000000..56322c9 --- /dev/null +++ b/clean-room-review/rollout.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# Copies the canonical clean-room-review workflow (this repo's main) to every +# PlaidCloud repo whose default branch still holds the previous gate, one draft +# PR each. Repos with any other copy are listed, not touched. Marking ready, +# recording the review and merging stay separate commands (printed at the end). +# Usage: clean-room-review/rollout.sh [repo ...] DRY_RUN=1 to only survey. +set -euo pipefail +ORG=PlaidCloud +F=.github/workflows/clean-room-review.yaml +OLD=c4b002e0c6a3260fd4d67be821691cbd2b967323 +BR=sc-36322-clean-room-gate-stale-reviews +read -r NEW B64 < <(gh api "repos/$ORG/plaidcloud-github-actions/contents/$F?ref=main" --jq '"\(.sha) \(.content | gsub("\n"; ""))"') +[ "$NEW" != "$OLD" ] || { echo "Canonical copy on main is still the old gate; merge the fix first."; exit 1; } +TITLE="ci: clean-room-review counts only current-head, latest, write-access verdicts (sc-36322)" +MSG="$TITLE + +Byte-identical copy of $ORG/plaidcloud-github-actions:$F (blob $OLD -> $NEW). + +Co-Authored-By: Claude Opus 5.5 " +BODY="Rolls out the fixed clean-room-review merge gate (sc-36322): blob \`${OLD:0:8}\` → \`${NEW:0:8}\`, byte-identical to $ORG/plaidcloud-github-actions main, where its regression tests live. Workflow file only. + +🤖 Generated with [Claude Code](https://claude.com/claude-code)" + +if [ $# -gt 0 ]; then repos=$(printf '%s\n' "$@") +else repos=$(gh api --paginate "orgs/$ORG/repos" --jq '.[] | select(.archived | not) | .name' | grep -vx plaidcloud-github-actions); fi + +prs=() +for r in $repos; do + def=$(gh api "repos/$ORG/$r" --jq .default_branch) || { echo "ERROR $r (rerun with: rollout.sh $r)"; continue; } + cur=$(gh api "repos/$ORG/$r/contents/$F?ref=$def" --jq .sha 2>/dev/null) || cur=none + case $cur in + "$NEW") echo "done $r"; continue ;; + "$OLD") ;; + *) echo "SKIP $r ($def holds $cur, not the old gate)"; continue ;; + esac + if [ -n "${DRY_RUN:-}" ]; then echo "would-PR $r ($def)"; continue; fi + base=$(gh api "repos/$ORG/$r/git/ref/heads/$def" --jq .object.sha) + gh api "repos/$ORG/$r/git/refs" -f ref="refs/heads/$BR" -f sha="$base" > /dev/null + gh api -X PUT "repos/$ORG/$r/contents/$F" -f branch="$BR" -f sha="$OLD" -f message="$MSG" -f content="$B64" > /dev/null + url=$(gh pr create --draft -R "$ORG/$r" --base "$def" --head "$BR" --title "$TITLE" --body "$BODY") + echo "PR $url"; prs+=("$url") +done + +[ ${#prs[@]} -eq 0 ] || { echo; echo "Next, per PR once its required checks are green (run each as its own command):" + for u in "${prs[@]}"; do echo " gh pr ready $u"; done; } diff --git a/clean-room-review/test_gate.sh b/clean-room-review/test_gate.sh new file mode 100755 index 0000000..ff2b3fb --- /dev/null +++ b/clean-room-review/test_gate.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Runs the clean-room-review gate's own `run:` script against fixture review +# lists, with `gh` replaced by a shim that prints the fixture pages. +# Usage: clean-room-review/test_gate.sh [path/to/clean-room-review.yaml] +set -euo pipefail +here=$(cd "$(dirname "$0")" && pwd) +wf=${1:-$here/../.github/workflows/clean-room-review.yaml} +work=$(mktemp -d); trap 'rm -rf "$work"' EXIT +yq '.jobs."clean-room-review".steps[0].run' "$wf" > "$work/gate.sh" +mkdir "$work/bin" +cat > "$work/bin/gh" <<'SHIM' +#!/usr/bin/env bash +case "$*" in + "api --paginate repos/o/r/pulls/7/reviews") jq -c '.pages[]' "$CASE" ;; + "api repos/o/r/collaborators/"*"/permission --jq "*) + login=${2#repos/o/r/collaborators/}; login=${login%/permission} + jq --arg u "$login" '{permission: (.perm[$u] // "write"), user: {login: $u}}' "$CASE" | jq -r "$4" ;; + *) echo "unexpected gh call: $*" >&2; exit 2 ;; +esac +SHIM +chmod +x "$work/bin/gh" +fail=0; n=$(jq length "$here/fixtures/cases.json") +for i in $(seq 0 $((n - 1))); do + jq ".[$i]" "$here/fixtures/cases.json" > "$work/case.json" + name=$(jq -r .name "$work/case.json"); expect=$(jq -r .expect "$work/case.json") + got=pass + (cd "$work" && CASE="$work/case.json" PATH="$work/bin:$PATH" REPO=o/r PR=7 DEFAULT=master \ + BASE=$(jq -r '.base // "master"' case.json) HEAD_SHA=$(jq -r .head case.json) \ + bash gate.sh > out.txt 2>&1) || got=fail + if [ "$got" = "$expect" ]; then echo "ok $name"; else echo "FAIL $name (expected $expect, got $got)"; sed 's/^/ /' "$work/out.txt"; fail=1; fi +done +exit $fail From d8397d1c4de60cb3056284c238d8da316af866c6 Mon Sep 17 00:00:00 2001 From: inviscid Date: Sun, 8 Nov 2026 20:23:14 -0600 Subject: [PATCH 2/2] ci: clean-room-review fails closed on permission-lookup errors; re-run on base retarget (sc-36322) - A reviewer's permission lookup now tolerates only HTTP 404 (deleted or unknown account -> not a writer). Any other failure (5xx, rate limit) fails the gate instead of silently dropping that reviewer, which let a transient error on a blocker's lookup turn another writer's approval into a pass. - pull_request `edited` re-runs the gate when a PR's base is retargeted (e.g. an exempt beta-x PR moved to the default branch). - One concurrent run per PR (cancel-in-progress) so near-simultaneous review events cannot finish out of order. - Harness: the gh shim can fail a login's lookup with a given status; 4 new cases (502 blocker, 502 approver, 404 approval, 404 blocker). 31/31 pass; the previous workflow fails both 502 cases. - rollout.sh: an existing branch (422) skips the repo and is listed for a manual check; next steps spell out the head-pinned clean-room review each rollout PR needs before its gate turns green. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/clean-room-review.yaml | 23 ++++- clean-room-review/fixtures/cases.json | 120 ++++++++++++++++++++++- clean-room-review/rollout.sh | 17 +++- clean-room-review/test_gate.sh | 7 ++ 4 files changed, 158 insertions(+), 9 deletions(-) diff --git a/.github/workflows/clean-room-review.yaml b/.github/workflows/clean-room-review.yaml index c59fcf5..27c70cf 100644 --- a/.github/workflows/clean-room-review.yaml +++ b/.github/workflows/clean-room-review.yaml @@ -9,7 +9,8 @@ name: Clean-room review recorded # Canonical copy and regression tests: PlaidCloud/plaidcloud-github-actions. on: pull_request: - types: [opened, synchronize, reopened, ready_for_review] + # edited: retargeting the base (e.g. beta-x -> master) must re-run the gate. + types: [opened, synchronize, reopened, ready_for_review, edited] pull_request_review: types: [submitted, edited, dismissed] @@ -17,6 +18,10 @@ permissions: pull-requests: read contents: read +concurrency: + group: clean-room-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + jobs: clean-room-review: name: clean-room-review @@ -38,9 +43,19 @@ jobs: fi gh api --paginate "repos/$REPO/pulls/$PR/reviews" | jq -s 'add // []' > reviews.json # author_association hides private org members, so ask for repo permission. - writers=$(jq -r '[.[].user.login // empty] | unique[]' reviews.json | while read -r login; do - gh api "repos/$REPO/collaborators/$login/permission" --jq 'select(.permission | IN("admin", "write")) | .user.login' || true - done | jq -R . | jq -sc .) + # Only a 404 (deleted/unknown account) means "not a writer"; any other + # lookup failure fails closed rather than dropping a blocker's verdict. + : > writers.txt + while read -r login; do + if perm=$(gh api "repos/$REPO/collaborators/$login/permission" --jq .permission 2> err.txt); then + case $perm in admin|write) echo "$login" >> writers.txt ;; esac + elif grep -q '(HTTP 404)' err.txt; then + echo "$login: no such account; their reviews do not count." + else + echo "::error::Could not read $login's permission on $REPO ($(cat err.txt)); failing closed. Re-run this check."; exit 1 + fi + done < <(jq -r '[.[].user.login // empty] | unique[]' reviews.json) + writers=$(jq -R . writers.txt | jq -sc .) # Latest verdict per reviewer, as GitHub counts them: plain comments # change nothing, a dismissal clears. A clean-room comment is read # from its first line only, so prose such as "cannot APPROVE" or a diff --git a/clean-room-review/fixtures/cases.json b/clean-room-review/fixtures/cases.json index 3ba0208..d814f4f 100644 --- a/clean-room-review/fixtures/cases.json +++ b/clean-room-review/fixtures/cases.json @@ -641,5 +641,123 @@ } ] ] + }, + { + "name": "blocker's permission lookup returns 502 (fail closed, not dropped)", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:40:00Z" + }, + { + "user": { + "login": "y" + }, + "author_association": "MEMBER", + "state": "CHANGES_REQUESTED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:41:00Z" + } + ] + ], + "lookup_error": { + "y": 502 + } + }, + { + "name": "approval from a deleted account (permission 404) is ignored", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "gone" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:42:00Z" + } + ] + ], + "lookup_error": { + "gone": 404 + } + }, + { + "name": "deleted account's change request (404) is ignored; writer approved head", + "expect": "pass", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "gone" + }, + "author_association": "MEMBER", + "state": "CHANGES_REQUESTED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:43:00Z" + }, + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:44:00Z" + } + ] + ], + "lookup_error": { + "gone": 404 + } + }, + { + "name": "approver's permission lookup returns 502 while another writer approved", + "expect": "fail", + "head": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "pages": [ + [ + { + "user": { + "login": "x" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:45:00Z" + }, + { + "user": { + "login": "y" + }, + "author_association": "MEMBER", + "state": "APPROVED", + "body": "", + "commit_id": "hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh", + "submitted_at": "2026-11-08T10:46:00Z" + } + ] + ], + "lookup_error": { + "x": 502 + } } -] \ No newline at end of file +] diff --git a/clean-room-review/rollout.sh b/clean-room-review/rollout.sh index 56322c9..e1685ee 100755 --- a/clean-room-review/rollout.sh +++ b/clean-room-review/rollout.sh @@ -24,7 +24,8 @@ BODY="Rolls out the fixed clean-room-review merge gate (sc-36322): blob \`${OLD: if [ $# -gt 0 ]; then repos=$(printf '%s\n' "$@") else repos=$(gh api --paginate "orgs/$ORG/repos" --jq '.[] | select(.archived | not) | .name' | grep -vx plaidcloud-github-actions); fi -prs=() +prs=(); exists=() +trap 'rm -f ref-err.txt' EXIT for r in $repos; do def=$(gh api "repos/$ORG/$r" --jq .default_branch) || { echo "ERROR $r (rerun with: rollout.sh $r)"; continue; } cur=$(gh api "repos/$ORG/$r/contents/$F?ref=$def" --jq .sha 2>/dev/null) || cur=none @@ -35,11 +36,19 @@ for r in $repos; do esac if [ -n "${DRY_RUN:-}" ]; then echo "would-PR $r ($def)"; continue; fi base=$(gh api "repos/$ORG/$r/git/ref/heads/$def" --jq .object.sha) - gh api "repos/$ORG/$r/git/refs" -f ref="refs/heads/$BR" -f sha="$base" > /dev/null + if ! gh api "repos/$ORG/$r/git/refs" -f ref="refs/heads/$BR" -f sha="$base" > /dev/null 2> ref-err.txt; then + if grep -q '(HTTP 422)' ref-err.txt; then echo "EXISTS $r (branch $BR already there)"; exists+=("$r"); continue; fi + echo "ERROR $r: $(cat ref-err.txt)"; continue + fi gh api -X PUT "repos/$ORG/$r/contents/$F" -f branch="$BR" -f sha="$OLD" -f message="$MSG" -f content="$B64" > /dev/null url=$(gh pr create --draft -R "$ORG/$r" --base "$def" --head "$BR" --title "$TITLE" --body "$BODY") echo "PR $url"; prs+=("$url") done -[ ${#prs[@]} -eq 0 ] || { echo; echo "Next, per PR once its required checks are green (run each as its own command):" - for u in "${prs[@]}"; do echo " gh pr ready $u"; done; } +[ ${#exists[@]} -eq 0 ] || { echo; echo "Branch exists, check manually: ${exists[*]}"; } +[ ${#prs[@]} -eq 0 ] || { echo; echo "Next, per PR (run each as its own command, never batched):" + echo " 1. mark it ready (gh pr ready ) so its required checks run;" + echo " 2. once they are SUCCESS, record a clean-room review pinned to the head commit; the gate stays red until one exists:" + echo " gh api repos/$ORG//pulls//reviews -f event=COMMENT -f commit_id= -f body='✅ Clean-room review (canonical) — **APPROVE** ...'" + echo " 3. clean-room-review green -> gh pr merge --squash" + printf ' %s\n' "${prs[@]}"; } diff --git a/clean-room-review/test_gate.sh b/clean-room-review/test_gate.sh index ff2b3fb..56b90ff 100755 --- a/clean-room-review/test_gate.sh +++ b/clean-room-review/test_gate.sh @@ -14,6 +14,13 @@ case "$*" in "api --paginate repos/o/r/pulls/7/reviews") jq -c '.pages[]' "$CASE" ;; "api repos/o/r/collaborators/"*"/permission --jq "*) login=${2#repos/o/r/collaborators/}; login=${login%/permission} + # .lookup_error[login] = HTTP status: fail the lookup the way gh does. + code=$(jq -r --arg u "$login" '.lookup_error[$u] // empty' "$CASE") + case $code in + "") ;; + 404) echo "gh: $login is not a user (HTTP 404)" >&2; exit 1 ;; + *) echo "gh: Bad Gateway (HTTP $code)" >&2; exit 1 ;; + esac jq --arg u "$login" '{permission: (.perm[$u] // "write"), user: {login: $u}}' "$CASE" | jq -r "$4" ;; *) echo "unexpected gh call: $*" >&2; exit 2 ;; esac