Skip to content

fix(ci): exempt draft PRs from the opencode-review required-check poll - #1560

Closed
seonghobae wants to merge 1 commit into
mainfrom
fix/opencode-review-draft-poll-exemption
Closed

seonghobae wants to merge 1 commit into
mainfrom
fix/opencode-review-draft-poll-exemption

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

#1443 fixed the required opencode-review-target check hanging forever on a draft PR. It was closed unmerged after #1546's receipt-gate redesign landed, on the premise that the redesign already handles drafts via pr_review_merge_scheduler.py's draft path and opencode_review_receipt_gate.py's is_draft parameter.

That premise is only half right. Reproduced against current main (5686de41):

  • evaluate_receipts's is_draft only narrows what counts as a valid receipt (if is_draft and state == "APPROVED": return False, "draft must never receive bot APPROVE") — it never exempts a draft PR from needing a receipt at all.
  • pr_review_merge_scheduler.py's own draft path (inspect_pr's if pr.get("isDraft")) skips dispatching a review entirely for an ordinary draft with no @opencode-agent mention (active_draft_review_request is documented as "the sole automatic gate for draft review dispatch").
  • Net effect: for an ordinary draft PR, nothing ever posts a verdict, and the Fail closed without a current-head OpenCode verdict step's while :; do ... sleep 30; done loop has no draft check at all — it polls until the job's own ~360-minute runtime ceiling kills it.

#1443's underlying bug still reproduces on current main.

Fix

Per that closure's own guidance ("any residual draft-queue issue must be reproduced against current main and fixed in the current receipt/scheduler boundary rather than reviving this stale branch"), this is a fresh, minimal fix on a new branch off current main — not a revival of #1443's branch:

  • The Fail closed step now also reads PR_DRAFT: ${{ github.event.pull_request.draft }}, matching the sibling dispatch step's existing sourcing convention exactly (deliberately not the live gh api refetch #1443's branch had introduced).
  • It exits early on a draft PR, mirroring its pre-existing closed exit.

The receipt-gate/scheduler architecture itself is otherwise untouched — this is scoped to the one missing exemption.

Test plan

  • Added test_fail_closed_step_exempts_a_draft_pr_before_polling, test_fail_closed_step_closed_still_takes_precedence_over_draft, test_fail_closed_step_still_polls_for_a_non_draft_pr — each executes the actual production step body via a fake gh that fails loudly if invoked, proving the draft/closed exits short-circuit before any Reviews API call (and that a non-draft PR still reaches it).
  • tests/test_opencode_required_verdict_regression.py — 25/25 passed.
  • Full suite (coverage run -m pytest tests) — 2249 passed, 1 skipped, 21 subtests, matching vanilla main's 2246 passed + 3 new tests.
  • Confirmed via git stash that the suite's one pre-existing coverage shortfall (99% vs 100%, in pr_review_fix_scheduler.py/pr_review_merge_scheduler.py — files this PR does not touch) is present on vanilla main too, unrelated to this change.
  • ruff check on the modified test file — clean. interrogate on the modified test file — 100%.
  • YAML parses; both run: script bodies pass bash -n.

Generated by Claude Code

Reproduced against current main (5686de4) after PR #1443 was closed as
superseded by #1546's receipt-gate redesign: the redesign's PR_DRAFT plumbing
only narrows which reviews opencode_review_receipt_gate.py's
evaluate_receipts() accepts (rejecting a bot APPROVE on a draft) -- it never
exempts a draft PR from needing a receipt at all. pr_review_merge_scheduler.py
skips dispatching a review for an ordinary draft with no @opencode-agent
mention, so nothing ever posts a verdict, and the "Fail closed without a
current-head OpenCode verdict" step's while/sleep poll had no draft check at
all -- it loops until the job's own ~360-minute runtime ceiling kills it.

Add the same PR_DRAFT sourcing the sibling dispatch step already uses and an
early exit mirroring the existing closed-PR exit. Minimal and scoped to the
one missing exemption; the receipt-gate/scheduler architecture is otherwise
untouched, per the #1443 closure's own guidance to fix this fresh against
current main rather than revive that branch.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

The code fix remains valid and current-main-based, but this PR is Draft and the connected markPullRequestReadyForReview mutation is still broken by the connector requesting nonexistent GraphQL field Repository.fullDatabaseId. To avoid leaving a queue-amplification fix permanently unreviewable, I am replacing only the PR conversation with a ready successor from the identical unchanged branch/head. No code/history changes and no #1560 checks/reviews will transfer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants