Enforce size-dependent review approvals in `PR Review Gates`
This pull request was posted by codex-tui using gpt-6.1-sol on behalf of David.
Why we make these changes
The size-dependent merge bar currently depends on policy. This adds CI statuses for clean douwebot approval and size-dependent human approval, ready to become required after deployment checks. Maintainer-requested follow-up to #10968 and #11500; no issue.
New public surface
None in library APIs. Two maintained CI contexts: Gate: clean douwebot approval and Gate: human approval.
User-visible behavior
After the admin rollout below, M/L/XL PRs wait for a clean douwebot approval on their current head; L/XL also wait for another write/admin human's non-dismissed approval. Both statuses fail until exactly one size label matches the shared PR Bots calculation. S triviality stays a manual judgment.
Verification
Targeted pytest, touched-file Pyright and commit hooks pass. The proving tests are gate and workflow execution, review authorization, and size calculation. CI and coverage pass on b506f5be1 (run); douwebot approved that head without findings. The new privileged jobs deliberately run main's code, so deployed Actions behavior still needs the post-merge smoke checks below.
What changes for existing users
Nothing in the library. Once the new statuses are required, PRs must meet the size-dependent review bar before entering the merge queue.
Implementation boundaries and admin rollout
Trusted publication and event binding. Douwebot returns structured findings with a read-only token. A default-branch publisher attaches its run/head receipt and findings to one formal review. If GitHub rejects inline positions with HTTP 422, it rechecks the live head and retries once with findings in the review body, preserving the verdict. Body findings still make an approval unclean. Closed/moved PRs are successful publication no-ops; cancellation retains ordinary-label cleanup without a failure notice. The gate verifies the receipt against the REST run head and successful review/publisher jobs, ignores display titles, and associates inline comments through their parent review, so a relocated comment's mutable commit_id cannot dirty a newly reviewed head. A later clean approval may supersede an empty incomplete review; all earlier findings on the same head still make it unclean. Optional/resolved findings still make a head unclean; CI Review and UI Security receipts identify separate reviewers.
PR Review Gates executes default-branch scripts only. The read-only PR Gates compatibility workflow keeps its own script, triggers and distinct job names, so privileged events cannot publish a skipped compatibility check. The read-only PR Review Gates Events observer supports forks. For completion events, the resolver fetches the source run from GitHub, ignores titles/artifacts, and requires a unique open PR matching its server-reported head SHA, repository and branch. Fork runs can have an empty pull_requests list; the server PR lookup supplies the association. The writer rechecks the exact identity inside its per-PR lock before pending statuses or setup, and evaluation keeps that head pinned. Ambiguous, foreign, closed or moved associations cannot direct writes to another head. PR Bots completion covers its GITHUB_TOKEN label/review writes.
Size and approval semantics. PR Bots relabels on open, push and PR edits, so base changes recover without a dummy push or manual relabel. The shared calculator requires the base commit and preserves the existing thresholds, category rounding and generated-file exclusions, regardless of checkout attributes. Human approvals may predate the head; later change requests supersede approvals, while comments do not. Native stale-approval dismissal supplies freshness when the diff changes. The compatibility gate is preserved. Review enforcement skips S and merge groups; the queue behavior is admission-only.
Failure recovery. Publication is serialized per PR. Verified targets are marked pending before setup; evaluation errors or incomplete data cannot publish success. Latest-per-context statuses replace earlier failures. Rerun a current-head, post-deployment default-branch PR Review Gates run after an API failure or delayed observer. Existing unmarked douwebot reviews do not satisfy the new gate; request fresh marked reviews.
After merge — repo admin steps:
- Complete #10968's code-owner rollout: validate
CODEOWNERS, enable Require a pull request before merging, keep 0 unconditional required approvals, enable Require review from Code Owners, and enable Dismiss stale pull request approvals when new commits are pushed. Check bypass actors. The live ruleset still required onlycheckwhen this description was updated. - Deploy this PR before requiring either new status. On a test PR, request a fresh
douwebotreview. For protected agent/CI configuration, a maintainer removes and reappliesdouwebot:review-agent-configfor that head. Verify its run/head receipt and both review statuses on the PR head. - Verify M fails without a fresh clean bot approval, including after an optional/resolved current-head finding. Verify L/XL additionally fail without another write/admin human approval. Check dismissal, a later change request, wrong/missing/multiple size labels, a new push and automatic relabeling after a base edit. Verify an older relocated comment does not block a clean new head.
- Verify fork observer completion, PR Bots completion and rerunning a current-head default-branch PR Review Gates run recover failing statuses after requirements are met. Fork observer runs may need contributor approval. Verify merge groups receive both success statuses without inspecting queue members.
- In the main ruleset, open Require status checks to pass. Keep
checkand the compatibility-waiver check from #10968. Add Gate: clean douwebot approval and Gate: human approval, each with GitHub Actions as the expected source. Save after the successful smoke checks make these contexts selectable. - Confirm a test PR cannot enter the merge queue while either review status fails. Keep the unconditional approval count at 0; the human status supplies the size-dependent requirement.
PR decisions
2026-10-27 · Size-dependent review enforcement
- Require clean current-head douwebot approval for M/L/XL, with another human approval for L/XL. Keep S triviality manual.
- Count the latest non-dismissed decision from another
Userwith current write/admin permission. The approval may precede the head; native stale-approval dismissal supplies freshness. - Share PR Bots scoring unchanged and require exactly one matching live size label.
- Bind bot publication to a host-owned run/head marker and associate inline comments through their parent review.
- Publish latest-per-context commit statuses from serialized default-branch evaluations. Keep merge-group evaluation admission-only.
- Recover through trusted run reruns; omit branch-selectable privileged dispatch.
- Session:
01a17eb9-0eb3-76d3-ab2d-0172fa7ec8ff.
2026-10-28 · Observer association and publication lifecycle
- Bind each observer to the unique open PR GitHub reports for its exact head identity. Ignore titles and artifacts; recheck the SHA/repository inside the write lock and during evaluation.
- Keep host-verified closed/moved publication a successful no-op.
- Preserve review findings through a bounded HTTP 422 body fallback, rechecking the head before retry. Report actual failures; keep cancellation cleanup without a failure notice.
- Recalculate labels on PR edits to recover after base changes. Explain trust boundaries and recovery in workflow docs; keep one-time rollout steps here. Batch workflow JavaScript scenarios in one Node process.
- Verify run heads through REST metadata while preserving PR-title run names. Assert Actions conditions directly; execute only actual workflow JavaScript in Node.
- Separate privileged review jobs and script from the read-only compatibility workflow. Require the base SHA for attribute scoring. Keep pending publication in setup, and allow a clean retry after an empty incomplete review without erasing findings.
- Share file pagination while retaining the compatibility gate's minimum-count contract; review size requires exact snapshot equality.
- Session:
01a18313-5154-7b41-9e40-4c51c87baf88.
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.