fix(gate): combined refire-token + direct-trigger event fix + auto-fire regression test (gate-fix follow-up) #2157

Merged
hongming merged 2 commits from fix/gate-followup-refire-token-direct-trigger-regression into main 2026-06-03 00:55:44 +00:00
Member

Problem (#2020 blocker evidence)

#2020 (clean-gate-proof) has APPROVED reviews from core-qa (00:22Z) and core-security (21:10Z), but qa-review / approved and security-review / approved contexts remain failure with stale timestamps (last ran before the APPROVED reviews landed).

Live evidence:

  • core-security APPROVED at 2026-06-02T21:10:08Z
  • core-qa APPROVED at 2026-06-03T00:22:20Z
  • qa-review last status: failure at 2026-06-02T20:57:31Z
  • security-review last status: failure at 2026-06-02T20:57:21Z
  • Meanwhile, sop-tier-check does trigger on review events and produced sop-tier-check / tier-check (pull_request_review): success at 2026-06-02T21:10:21Z — 13 seconds after core-security's APPROVED.

This shows pull_request_review events do fire on this Gitea instance, but pull_request_review_approved does not appear to trigger our workflows.

(A) Direct-trigger structural fix

Files: qa-review.yml + security-review.yml

  • Replace pull_request_review_approved trigger with pull_request_review types: [submitted] (proven to fire via sop-tier-check.yml live status contexts).
  • Add job-level if: guard requiring github.event.review.state == 'APPROVED' || 'approved' so only APPROVE reviews run the evaluator; COMMENT / REQUEST_CHANGES are skipped at job level.
  • Update explicit POST step event guard to pull_request_review.
  • Keep BASE/default-branch checkout, eval read-only via SOP_TIER_CHECK_TOKEN, POST via STATUS_POST_TOKEN.

(B) Refire-path token fix

Files: sop-checklist.yml + review-refire-status.sh

  • Change explicit POST /statuses/{sha} to use STATUS_POST_TOKEN (narrow-scoped write:repository token, CTO-granted).
  • Leave evaluator (review-check.sh + GET /pulls) on SOP_TIER_CHECK_TOKEN || GITHUB_TOKEN (read-only).
  • review-refire-status.sh now creates a separate post_authfile with STATUS_POST_TOKEN; falls back to GITEA_TOKEN for backward compatibility.

(#765) Regression test

File: test_gate_review_auto_fire.py

  • Structural tests asserting qa-review and security-review workflows trigger on pull_request_review submitted, guard on APPROVED state, POST with STATUS_POST_TOKEN, and emit exact BP-required context name (qa-review / approved (pull_request_target) and security-review / approved (pull_request_target)).
  • Structural tests asserting sop-checklist refire steps pass STATUS_POST_TOKEN env var while keeping evaluator on read token.

Trust & Security

  • BASE ref checkout unchanged (no PR-head code execution).
  • Token separation unchanged: evaluator uses SOP_TIER_CHECK_TOKEN (read-only); POST uses STATUS_POST_TOKEN (write-only).

Test Plan

  • After CTO force-merge, a new APPROVED review on #2020 triggers qa-review + security-review via pull_request_review and flips contexts GREEN.
  • /qa-recheck and /security-recheck slash commands continue to work as backstop.

Refs: internal#760, internal#765

## Problem (#2020 blocker evidence) #2020 (clean-gate-proof) has APPROVED reviews from `core-qa` (00:22Z) and `core-security` (21:10Z), but `qa-review / approved` and `security-review / approved` contexts remain `failure` with stale timestamps (last ran **before** the APPROVED reviews landed). **Live evidence:** - `core-security` APPROVED at `2026-06-02T21:10:08Z` - `core-qa` APPROVED at `2026-06-03T00:22:20Z` - `qa-review` last status: `failure` at `2026-06-02T20:57:31Z` - `security-review` last status: `failure` at `2026-06-02T20:57:21Z` - Meanwhile, `sop-tier-check` **does** trigger on review events and produced `sop-tier-check / tier-check (pull_request_review): success` at `2026-06-02T21:10:21Z` — 13 seconds after `core-security`'s APPROVED. This shows `pull_request_review` events **do fire** on this Gitea instance, but `pull_request_review_approved` does **not** appear to trigger our workflows. ## (A) Direct-trigger structural fix Files: `qa-review.yml` + `security-review.yml` - Replace `pull_request_review_approved` trigger with `pull_request_review` `types: [submitted]` (proven to fire via sop-tier-check.yml live status contexts). - Add job-level `if:` guard requiring `github.event.review.state == 'APPROVED' || 'approved'` so only APPROVE reviews run the evaluator; COMMENT / REQUEST_CHANGES are skipped at job level. - Update explicit POST step event guard to `pull_request_review`. - Keep BASE/default-branch checkout, eval read-only via `SOP_TIER_CHECK_TOKEN`, POST via `STATUS_POST_TOKEN`. ## (B) Refire-path token fix Files: `sop-checklist.yml` + `review-refire-status.sh` - Change explicit POST `/statuses/{sha}` to use `STATUS_POST_TOKEN` (narrow-scoped write:repository token, CTO-granted). - Leave evaluator (`review-check.sh` + GET `/pulls`) on `SOP_TIER_CHECK_TOKEN || GITHUB_TOKEN` (read-only). - `review-refire-status.sh` now creates a separate `post_authfile` with `STATUS_POST_TOKEN`; falls back to `GITEA_TOKEN` for backward compatibility. ## (#765) Regression test File: `test_gate_review_auto_fire.py` - Structural tests asserting qa-review and security-review workflows trigger on `pull_request_review submitted`, guard on APPROVED state, POST with `STATUS_POST_TOKEN`, and emit exact BP-required context name (`qa-review / approved (pull_request_target)` and `security-review / approved (pull_request_target)`). - Structural tests asserting sop-checklist refire steps pass `STATUS_POST_TOKEN` env var while keeping evaluator on read token. ## Trust & Security - BASE ref checkout unchanged (no PR-head code execution). - Token separation unchanged: evaluator uses `SOP_TIER_CHECK_TOKEN` (read-only); POST uses `STATUS_POST_TOKEN` (write-only). ## Test Plan - [ ] After CTO force-merge, a new APPROVED review on #2020 triggers qa-review + security-review via `pull_request_review` and flips contexts GREEN. - [ ] `/qa-recheck` and `/security-recheck` slash commands continue to work as backstop. Refs: internal#760, internal#765
core-be added 1 commit 2026-06-03 00:44:31 +00:00
fix(gate): combined refire-token + direct-trigger event fix + auto-fire regression test (gate-fix follow-up)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Failing after 1s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 4s
CI / Python Lint & Test (pull_request) Successful in 3s
CI / Detect changes (pull_request) Successful in 6s
E2E Chat / detect-changes (pull_request) Successful in 7s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 7s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 3s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 4s
E2E API Smoke Test / detect-changes (pull_request) Successful in 17s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 11s
lint-required-workflows-docker-host-pinned / Lint docker-host pin on docker-touching workflows (pull_request) Successful in 11s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 14s
gate-check-v3 / gate-check (pull_request_target) Successful in 7s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
sop-checklist / all-items-acked (pull_request_target) Successful in 3s
sop-checklist / review-refire (pull_request_target) Has been skipped
qa-review / approved (pull_request_target) Failing after 7s
security-review / approved (pull_request_target) Failing after 6s
sop-tier-check / tier-check (pull_request_target) Successful in 4s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 57s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 54s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m15s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 1m15s
CI / Platform (Go) (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
E2E Chat / E2E Chat (pull_request) Successful in 2s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 1m2s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 2s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 2s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1s
CI / Canvas (Next.js) (pull_request) Successful in 14s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m48s
CI / all-required (pull_request) Successful in 22s
qa-review / approved (pull_request_review) Has been skipped
security-review / approved (pull_request_review) Has been skipped
sop-tier-check / tier-check (pull_request_review) Successful in 5s
c83e6044f0
(A) Direct-trigger structural fix — qa-review.yml + security-review.yml:
- Replace pull_request_review_approved trigger with pull_request_review
  types: [submitted] (proven to fire via sop-tier-check.yml live status
  contexts).
- Add job-level if: guard requiring
  github.event.review.state == 'APPROVED' || 'approved' so only APPROVE
  reviews run the evaluator; COMMENT / REQUEST_CHANGES are skipped at
  job level.
- Update explicit POST step event guard to pull_request_review.

(B) Refire-path token fix — sop-checklist.yml + review-refire-status.sh:
- Change explicit POST /statuses to use STATUS_POST_TOKEN (narrow-scoped
  write:repository token, CTO-granted).
- Leave evaluator (review-check.sh + GET /pulls) on
  SOP_TIER_CHECK_TOKEN || GITHUB_TOKEN (read-only).
- review-refire-status.sh now creates a separate post_authfile with
  STATUS_POST_TOKEN; falls back to GITEA_TOKEN for backward
  compatibility.

(#765 regression test) — test_gate_review_auto_fire.py:
- Structural tests asserting qa-review and security-review workflows
  trigger on pull_request_review submitted, guard on APPROVED state,
  POST with STATUS_POST_TOKEN, and emit exact BP-required context name.
- Structural tests asserting sop-checklist refire steps pass
  STATUS_POST_TOKEN env var while keeping evaluator on read token.

Trust boundary unchanged: BASE ref checkout, no PR-head code execution.

Refs: internal#760, internal#765
molecule-code-reviewer requested changes 2026-06-03 00:48:44 +00:00
Dismissed
molecule-code-reviewer left a comment
Member

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.sh still 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-recheck and /security-recheck correctly 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 both APPROVED and approved; please assert both substrings independently.

The direct-trigger side otherwise looks directionally correct: pull_request_review submitted, APPROVED guard, BASE checkout, read-token evaluator, STATUS_POST_TOKEN status POST, and exact (pull_request_target) direct contexts are present.

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.sh` still 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-recheck` and `/security-recheck` correctly 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 both `APPROVED` and `approved`; please assert both substrings independently. The direct-trigger side otherwise looks directionally correct: `pull_request_review` submitted, APPROVED guard, BASE checkout, read-token evaluator, STATUS_POST_TOKEN status POST, and exact `(pull_request_target)` direct contexts are present.
core-be added 1 commit 2026-06-03 00:52:14 +00:00
fix(gate): CR2 RC 8337 — refire context name + test strengthening (#2157)
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Successful in 3s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 6s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Failing after 2s
CI / Detect changes (pull_request) Successful in 7s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 4s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 3s
lint-required-workflows-docker-host-pinned / Lint docker-host pin on docker-touching workflows (pull_request) Successful in 4s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 16s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 15s
E2E Chat / detect-changes (pull_request) Successful in 16s
gate-check-v3 / gate-check (pull_request_target) Failing after 5s
sop-checklist / review-refire (pull_request_target) Has been skipped
sop-tier-check / tier-check (pull_request_target) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 1s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 1s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 2s
E2E Chat / E2E Chat (pull_request) Successful in 1s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 2s
CI / Platform (Go) (pull_request) Successful in 14s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
qa-review / approved (pull_request_target) Failing after 21s
security-review / approved (pull_request_target) Failing after 21s
sop-checklist / all-items-acked (pull_request_target) Successful in 21s
CI / all-required (pull_request) Successful in 3s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 51s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Failing after 1m1s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 53s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m6s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m12s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 1m22s
qa-review / approved (pull_request_review) Has been skipped
security-review / approved (pull_request_review) Has been skipped
sop-tier-check / tier-check (pull_request_review) Successful in 4s
audit-force-merge / audit (pull_request_target) Successful in 3s
1b8b7a7047
(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>
molecule-code-reviewer approved these changes 2026-06-03 00:54:09 +00:00
molecule-code-reviewer left a comment
Member

APPROVED on head 1b8b7a70, superseding RC 8337.

Re-review result: the round-2 fix closes the blocker.

Verified:

  • review-refire-status.sh now posts CONTEXT="${TEAM}-review / approved (pull_request_target)", which resolves byte-for-byte to the BP-required qa-review / approved (pull_request_target) and security-review / approved (pull_request_target) contexts.
  • Refire read/write separation is preserved: evaluator stays on GITEA_TOKEN (SOP_TIER_CHECK_TOKEN || GITHUB_TOKEN from the workflow), while POST uses STATUS_POST_TOKEN via a separate authfile.
  • Regression test now asserts the refire script contains the exact (pull_request_target) context and rejects the bare approved (pull_request)" variant that caused RC 8337.
  • APPROVED-state guard tests now require both APPROVED and approved literals independently for qa and security.
  • Direct-trigger side remains in the previously acceptable shape: pull_request_review submitted, APPROVED guard, BASE/default-branch checkout, read-token evaluator, STATUS_POST_TOKEN POST, 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.

APPROVED on head 1b8b7a70, superseding RC 8337. Re-review result: the round-2 fix closes the blocker. Verified: - `review-refire-status.sh` now posts `CONTEXT="${TEAM}-review / approved (pull_request_target)"`, which resolves byte-for-byte to the BP-required `qa-review / approved (pull_request_target)` and `security-review / approved (pull_request_target)` contexts. - Refire read/write separation is preserved: evaluator stays on `GITEA_TOKEN` (`SOP_TIER_CHECK_TOKEN || GITHUB_TOKEN` from the workflow), while POST uses `STATUS_POST_TOKEN` via a separate authfile. - Regression test now asserts the refire script contains the exact `(pull_request_target)` context and rejects the bare `approved (pull_request)"` variant that caused RC 8337. - APPROVED-state guard tests now require both `APPROVED` and `approved` literals independently for qa and security. - Direct-trigger side remains in the previously acceptable shape: `pull_request_review` submitted, APPROVED guard, BASE/default-branch checkout, read-token evaluator, `STATUS_POST_TOKEN` POST, 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.
hongming merged commit ef90e5a279 into main 2026-06-03 00:55:44 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2157