Skip to content

Paginate and Filter the cleanup Head Pull Request Read Before Counting Overflow as Branch Users #3003

Closed

Description

@ptr727

Finding

Raised by Copilot on the develop -> main promotion #3002, against branch_users in scripts/pr_review.py (added in #2988).

The heads query in Q_CLEANUP_USERS reads the first 20 open pull requests whose head ref name is the branch, across every repository, forks included. branch_users then filters those nodes to heads in owner/repo, but adds totalCount - len(nodes) as "N more with the branch as head" without knowing whether any of the unread ones is local. So where more than 20 open fork pull requests share the branch name and none is local, cleanup refuses a delete that is safe, and the message counts fork pull requests as users of this repository's branch.

Why It Is Not Fixed on the Promotion

The failure is fail-closed: cleanup refuses and deletes nothing, and the maintainer is told. It needs over 20 open fork pull requests sharing one feature branch name, which no fleet repository has seen. That makes it an over-refusal with no safety gain, filed rather than chased under the round's review-loop stop rule.

Fix Shape

Paginate the heads connection, filter each page by headRepository, and decide from the filtered set, keeping an unread page as a refusal (exit 2). Add a test for the fork-only overflow case, and one for a local pull request past the first page.

Activity

  1. added
    script
    on Oct 14, 2026
  2. ptr727 commented on Oct 14, 2026

    @ptr727
    OwnerAuthor

    Claim (engineering round 25, grouped with #2985): branch feature/2985-3003-pr-review-readers, files scripts/pr_review.py and tests/test_pr_review.py.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    script

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions