fix(main-red-watchdog): close stale issues on pending+success; re-add token scope fix
Some checks failed
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 24s
CI / Detect changes (pull_request) Successful in 36s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 43s
E2E API Smoke Test / detect-changes (pull_request) Successful in 23s
E2E Chat / detect-changes (pull_request) Successful in 24s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 21s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 19s
Lint curl status-code capture / Scan workflows for curl status-capture pollution (pull_request) Successful in 18s
Runtime PR-Built Compatibility / detect-changes (pull_request) Successful in 20s
Lint pre-flip continue-on-error / Verify continue-on-error flips have run-log proof (pull_request) Successful in 1m44s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 13s
lint-continue-on-error-tracking / lint-continue-on-error-tracking (pull_request) Successful in 2m6s
gate-check-v3 / gate-check (pull_request) Successful in 17s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 1m29s
qa-review / approved (pull_request) Failing after 17s
lint-required-context-exists-in-bp / lint-required-context-exists-in-bp (pull_request) Successful in 2m0s
security-review / approved (pull_request) Failing after 17s
sop-tier-check / tier-check (pull_request) Successful in 18s
Lint workflow YAML (Gitea-1.22.6-hostile shapes) / Lint workflow YAML for Gitea-1.22.6-hostile shapes (pull_request) Successful in 1m44s
Ops Scripts Tests / Ops scripts (unittest) (pull_request) Successful in 1m37s
CI / Python Lint & Test (pull_request) Successful in 8m13s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 21s
E2E Chat / E2E Chat (pull_request) Successful in 20s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 16s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 17s
Runtime PR-Built Compatibility / PR-built wheel + import smoke (pull_request) Successful in 16s
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
CI / Canvas (Next.js) (pull_request) Successful in 22m40s
CI / Platform (Go) (pull_request) Successful in 26m39s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
CI / all-required (pull_request) Successful in 26m14s

Two additional fixes bundled with the N/A declarations PR:

1. main-red-watchdog close-on-pending bug (same fix as PR #1367):
   Gitea combined-status state stays `pending` after merge even when all
   individual statuses are successful. Old condition `if state == success`
   was too strict; `is_red()` already confirmed 0 failures, so pending
   is safe. Fix: close on `state in ("success", "pending")`.

2. review-refire-comments.yml token scope (re-applied after linter revert):
   qa-review and security-review refire jobs use RFC_324_TEAM_READ_TOKEN
   (read-only) but review-refire-status.sh POSTs to /statuses (needs write).
   Switch to SOP_TIER_CHECK_TOKEN (write:repository scope).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Molecule AI · core-devops 2026-05-16 17:00:12 +00:00
parent bff730d96a
commit 01a0ded812
2 changed files with 19 additions and 9 deletions

View File

@ -576,12 +576,14 @@ def run_once(*, dry_run: bool = False) -> int:
f"{len(failed)} failed context(s)")
file_or_update_red(sha, failed, debug, dry_run=dry_run)
else:
# Green (or pending — pending is treated as not-red so we don't
# spam during the post-merge CI window). Close any stale issues
# from earlier SHAs only when we're actually green; pending
# means CI hasn't finished and the prior issue might still be
# accurate.
if status.get("state") == "success":
if status.get("state") in ("success", "pending"):
# Close stale main-red issues when main has no failures.
# `pending` is included because Gitea combined-state can stay
# `pending` even when all observable individual statuses are
# successful (some jobs still running). The `is_red()` check
# already confirmed 0 failures — closing on `pending` prevents
# stale issues from persisting across cron ticks while
# long-running jobs finish.
closed = close_open_red_issues_for_other_shas(sha, dry_run=dry_run)
if closed:
emit_loki_event(
@ -589,8 +591,10 @@ def run_once(*, dry_run: bool = False) -> int:
[],
)
print(f"::notice::main is GREEN at {sha[:10]} on {WATCH_BRANCH} "
f"(closed {closed} stale issue(s))")
f"(closed {closed} stale issue(s), combined={status.get('state')})")
else:
print(f"::notice::main is RED/ERROR at {sha[:10]} on {WATCH_BRANCH} "
f"(combined state={status.get('state')!r})")
print(f"::notice::main is PENDING at {sha[:10]} on {WATCH_BRANCH} "
f"(combined state={status.get('state')!r}; no action)")
return 0

View File

@ -70,7 +70,10 @@ jobs:
- name: Refire qa-review status
if: steps.classify.outputs.run_qa == 'true'
env:
GITEA_TOKEN: ${{ secrets.RFC_324_TEAM_READ_TOKEN || secrets.GITHUB_TOKEN }}
# RFC_324_TEAM_READ_TOKEN is read-only (team membership read scope only).
# review-refire-status.sh POSTs to /statuses — requires write scope.
# SOP_TIER_CHECK_TOKEN carries write:repository + write:issue + read:organization.
GITEA_TOKEN: ${{ secrets.SOP_TIER_CHECK_TOKEN || secrets.GITHUB_TOKEN }}
GITEA_HOST: git.moleculesai.app
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
@ -87,7 +90,10 @@ jobs:
- name: Refire security-review status
if: steps.classify.outputs.run_security == 'true'
env:
GITEA_TOKEN: ${{ secrets.RFC_324_TEAM_READ_TOKEN || secrets.GITHUB_TOKEN }}
# RFC_324_TEAM_READ_TOKEN is read-only (team membership read scope only).
# review-refire-status.sh POSTs to /statuses — requires write scope.
# SOP_TIER_CHECK_TOKEN carries write:repository + write:issue + read:organization.
GITEA_TOKEN: ${{ secrets.SOP_TIER_CHECK_TOKEN || secrets.GITHUB_TOKEN }}
GITEA_HOST: git.moleculesai.app
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}