fix(gate): combined refire-token + direct-trigger event fix + auto-fire regression test (gate-fix follow-up) #2157
Reference in New Issue
Block a user
Delete Branch "fix/gate-followup-refire-token-direct-trigger-regression"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem (#2020 blocker evidence)
#2020 (clean-gate-proof) has APPROVED reviews from
core-qa(00:22Z) andcore-security(21:10Z), butqa-review / approvedandsecurity-review / approvedcontexts remainfailurewith stale timestamps (last ran before the APPROVED reviews landed).Live evidence:
core-securityAPPROVED at2026-06-02T21:10:08Zcore-qaAPPROVED at2026-06-03T00:22:20Zqa-reviewlast status:failureat2026-06-02T20:57:31Zsecurity-reviewlast status:failureat2026-06-02T20:57:21Zsop-tier-checkdoes trigger on review events and producedsop-tier-check / tier-check (pull_request_review): successat2026-06-02T21:10:21Z— 13 seconds aftercore-security's APPROVED.This shows
pull_request_reviewevents do fire on this Gitea instance, butpull_request_review_approveddoes not appear to trigger our workflows.(A) Direct-trigger structural fix
Files:
qa-review.yml+security-review.ymlpull_request_review_approvedtrigger withpull_request_reviewtypes: [submitted](proven to fire via sop-tier-check.yml live status contexts).if:guard requiringgithub.event.review.state == 'APPROVED' || 'approved'so only APPROVE reviews run the evaluator; COMMENT / REQUEST_CHANGES are skipped at job level.pull_request_review.SOP_TIER_CHECK_TOKEN, POST viaSTATUS_POST_TOKEN.(B) Refire-path token fix
Files:
sop-checklist.yml+review-refire-status.sh/statuses/{sha}to useSTATUS_POST_TOKEN(narrow-scoped write:repository token, CTO-granted).review-check.sh+ GET/pulls) onSOP_TIER_CHECK_TOKEN || GITHUB_TOKEN(read-only).review-refire-status.shnow creates a separatepost_authfilewithSTATUS_POST_TOKEN; falls back toGITEA_TOKENfor backward compatibility.(#765) Regression test
File:
test_gate_review_auto_fire.pypull_request_review submitted, guard on APPROVED state, POST withSTATUS_POST_TOKEN, and emit exact BP-required context name (qa-review / approved (pull_request_target)andsecurity-review / approved (pull_request_target)).STATUS_POST_TOKENenv var while keeping evaluator on read token.Trust & Security
SOP_TIER_CHECK_TOKEN(read-only); POST usesSTATUS_POST_TOKEN(write-only).Test Plan
pull_request_reviewand flips contexts GREEN./qa-recheckand/security-recheckslash commands continue to work as backstop.Refs: internal#760, internal#765
REQUEST_CHANGES on head
c83e6044.Blocking finding: the refire path still posts the wrong context names for the #2020 clean-gate proof.
review-refire-status.shstill sets:CONTEXT="${TEAM}-review / approved (pull_request)"This PR fixes the refire POST credential by adding
STATUS_POST_TOKEN, but the status it posts is still the(pull_request)variant. The stale blockers on #2020, and the BP-required contexts verified during #2135/#2145, are the(pull_request_target)variants:qa-review / approved (pull_request_target)security-review / approved (pull_request_target)We already proved on #2020 that
/qa-recheckand/security-recheckcorrectly find the real team approvals, then fail at status POST. After this patch, those rechecks would be able to POST, but they would update... (pull_request), not the stale red... (pull_request_target)contexts that need to flip green. That does not satisfy the clean-gate proof path as described.Required fix: make the refire path post the same BP-required context names as the direct review-event path, or otherwise parameterize/assert the exact target context names for qa/security refires. Add regression coverage for that exact byte-match in
test_gate_review_auto_fire.py.Secondary test gap: the APPROVED-state tests use
A or B, so they pass if only uppercase or only lowercase is present. The spec asks for bothAPPROVEDandapproved; please assert both substrings independently.The direct-trigger side otherwise looks directionally correct:
pull_request_reviewsubmitted, APPROVED guard, BASE checkout, read-token evaluator, STATUS_POST_TOKEN status POST, and exact(pull_request_target)direct contexts are present.(a) review-refire-status.sh: CONTEXT now posts exact BP-required "(pull_request_target)" instead of bare "(pull_request)". (b) Tests: job_guard_requires_approved_state now asserts BOTH 'APPROVED' and 'approved' case variants are present (not OR). (c) Tests: new test_refire_script_context_is_pull_request_target asserts refire script emits exact (pull_request_target) context. Test count: 10 → 11. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>APPROVED on head
1b8b7a70, superseding RC 8337.Re-review result: the round-2 fix closes the blocker.
Verified:
review-refire-status.shnow postsCONTEXT="${TEAM}-review / approved (pull_request_target)", which resolves byte-for-byte to the BP-requiredqa-review / approved (pull_request_target)andsecurity-review / approved (pull_request_target)contexts.GITEA_TOKEN(SOP_TIER_CHECK_TOKEN || GITHUB_TOKENfrom the workflow), while POST usesSTATUS_POST_TOKENvia a separate authfile.(pull_request_target)context and rejects the bareapproved (pull_request)"variant that caused RC 8337.APPROVEDandapprovedliterals independently for qa and security.pull_request_reviewsubmitted, APPROVED guard, BASE/default-branch checkout, read-token evaluator,STATUS_POST_TOKENPOST, and exact BP-required context names.CI/all-required is green. The remaining red qa/security/SOP contexts are expected for this gate-repair PR and do not change this CR2 verdict.