From 2580d14d5ef179ed567230891cd05d93473b1574 Mon Sep 17 00:00:00 2001 From: pi-release Date: Sun, 15 Nov 2026 22:36:36 -0400 Subject: [PATCH] ci: pr_verdict can post as a comment, because a peer's pending review blocks every review Measured 2026-11-16: #2612's verdict could not be posted -- 'pending review(s) [5914255057] block it' -- because another lane had a draft review open on that PR, and GitHub allows one PENDING review per user per PR. The only way through was to post it by hand as an issue comment, which pr_review_queue reads (#2495 reads the sha-first verdict from reviews AND issue comments). So the tool now has --as-comment: same body checks (head in the first line, head is current, verdict named), posted with , and read back from BOTH lists so the proof-of-post covers the fallback too. The refusal message names it, so the next lane does not have to rediscover that a comment is a verdict. Deliberately NOT automatic: swapping the post mechanism silently would make a review look like a comment in the PR's history, and that is a reviewer's choice, not the tool's. --- tools/ci/pr_verdict.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/tools/ci/pr_verdict.py b/tools/ci/pr_verdict.py index 6cc32ca40..d1e531335 100755 --- a/tools/ci/pr_verdict.py +++ b/tools/ci/pr_verdict.py @@ -30,7 +30,12 @@ Usage: tools/ci/pr_verdict.py --check REPO PR # pending review? head? verdicted at this head? - tools/ci/pr_verdict.py --post REPO PR BODY_FILE VERDICT [--dry-run] + tools/ci/pr_verdict.py --post REPO PR BODY_FILE VERDICT [--dry-run] [--as-comment] + +`--as-comment` posts the verdict as an issue comment instead of a review. It exists because a PENDING review from +another lane blocks every review post on that PR (failure 1), and pr_review_queue reads the sha-first verdict from +*both* lists -- so a comment is a verdict when a review cannot be posted. Measured 2026-11-16: a peer's draft +blocked #2612's verdict, and the only way through was to post it by hand. `--post` refuses (exit 2) when the body's first line does not carry the current head, or when a pending review exists; it posts and then re-reads to prove the review landed with this head in it. @@ -117,7 +122,7 @@ def do_check(repo, pr): return 0 -def do_post(repo, pr, body_file, verdict, dry_run): +def do_post(repo, pr, body_file, verdict, dry_run, as_comment=False): head = (api_json(f"repos/{repo}/pulls/{pr}") or {}).get("head", {}).get("sha", "") if not head: return 2 @@ -132,18 +137,25 @@ def do_post(repo, pr, body_file, verdict, dry_run): print(f"pr_verdict: refusing to post: {why}", file=sys.stderr) return 2 pend = pending_ids(api_json(f"repos/{repo}/pulls/{pr}/reviews?per_page=100") or []) - if pend: + if pend and not as_comment: print(f"pr_verdict: refusing to post: pending review(s) {pend} block it " - f"(clear: gh api -X DELETE repos/{repo}/pulls/{pr}/reviews/)", file=sys.stderr) + f"(clear: gh api -X DELETE repos/{repo}/pulls/{pr}/reviews/; or pass --as-comment, " + f"which pr_review_queue also reads)", file=sys.stderr) return 2 if dry_run: - print(f"would post {verdict} about {head[:7]} to {repo}#{pr}") + how = "comment" if as_comment else "review" + print(f"would post {verdict} about {head[:7]} to {repo}#{pr} as a {how}") return 0 - rc, out, err = gh("pr", "review", str(pr), "--repo", repo, "--comment", "--body-file", body_file) + if as_comment: + rc, out, err = gh("pr", "comment", str(pr), "--repo", repo, "--body-file", body_file) + else: + rc, out, err = gh("pr", "review", str(pr), "--repo", repo, "--comment", "--body-file", body_file) if rc != 0: print(f"pr_verdict: post failed: {(err or out).strip()[:200]}", file=sys.stderr) return 2 - if not verdicted_at(api_json(f"repos/{repo}/pulls/{pr}/reviews?per_page=100") or [], head): + back = ((api_json(f"repos/{repo}/pulls/{pr}/reviews?per_page=100") or []) + + (api_json(f"repos/{repo}/issues/{pr}/comments?per_page=100") or [])) + if not verdicted_at(back, head): print(f"pr_verdict: posted, but no review at {head[:7]} is readable back: check the PR by hand", file=sys.stderr) return 2 print(f"posted {verdict} about {head[:7]} (read back)") @@ -173,6 +185,8 @@ def self_test(): assert verdicted_at([{"body": "abcdef1 READY — x"}], H) assert not verdicted_at([{"body": "READY — no head here"}], H) assert not verdicted_at([{"body": "abcdef1 looks fine"}], H) + # the --as-comment fallback is read back from the ISSUE-comment list, same shape + assert verdicted_at([{"body": "abcdef1 READY — posted as a comment"}], H) print("pr_verdict self-test: ok (head in line 1, stale head, missing verdict, empty, pending, read-back)") return 0 @@ -182,6 +196,8 @@ def main(): ap.add_argument("--check", nargs=2, metavar=("REPO", "PR")) ap.add_argument("--post", nargs=4, metavar=("REPO", "PR", "BODY_FILE", "VERDICT")) ap.add_argument("--dry-run", action="store_true") + ap.add_argument("--as-comment", action="store_true", + help="post as an issue comment when a peer's pending review blocks a review") ap.add_argument("--self-test", action="store_true") a = ap.parse_args() if a.self_test: @@ -193,7 +209,7 @@ def main(): if verdict not in VERDICTS: print(f"pr_verdict: VERDICT must be one of {VERDICTS}", file=sys.stderr) return 2 - return do_post(repo, pr, body, verdict, a.dry_run) + return do_post(repo, pr, body, verdict, a.dry_run, a.as_comment) ap.print_help() return 2