Skip to content

feat(issue-pr-loop): finish open PRs before starting new issues - #4084

Merged
thomhurst merged 1 commit into
mainfrom
loop-wip-limit
Nov 2, 2026
Merged

thomhurst merged 1 commit into
mainfrom
loop-wip-limit

Conversation

@thomhurst

Copy link
Copy Markdown
Owner

Problem

Loop workers skipped every PR whose checks were still running and started new issues instead, so open PRs piled up and the chance of conflicts grew.

Change

Ported from thomhurst/TUnit#7423.

  • scripts/Start-IssuePrLoop.ps1: new -MaxOpenPrs (default 8, 0 = no limit). While that many of the loop's open PRs lack needs-human/on-hold, no fresh issue is queued; stranded branches, stale in-progress claims and closed-children parents still are. The held count appears in the idle survey stats.
  • A PR with unresolved review threads, or an outside CHANGES_REQUESTED review newer than both the head commit and the loop's last reply, is no longer skipped for pending checks: it ranks with failed-CI PRs, is not a light unit, and gets a hint to handle the feedback now. Conversation comments do not count (a review with no findings is also a comment).
  • Get-PrActivity reads head commit time and review-thread resolution for all open PRs in one paginated GraphQL query (adding commits to gh pr list --json exceeds GitHub's node limit).
  • scripts/Test-IssuePrLoop.ps1: tests for the feedback detection and the open-PR limit.

The matching SKILL.md priority-list text was pushed to main in 09bf00c.

Validation: pwsh -NoProfile -File scripts/Test-IssuePrLoop.ps1 passes; Get-PrActivity checked against this repository's live open PRs. Script-only change, no hot-path cost.

Add -MaxOpenPrs (default 8): while that many unparked loop PRs are open,
no fresh issue is queued. PRs with unresolved review threads or a
changes-requested review newer than the last push are no longer skipped
for pending checks.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 9 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3acb078e-7ef2-4560-963b-7841ac9657ec
Commits

Reviewing files that changed from the base of the PR and between 09bf00c and 53970c5.

Files selected for processing: 2
  • scripts/Start-IssuePrLoop.ps1
  • scripts/Test-IssuePrLoop.ps1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

@thomhurst
thomhurst marked this pull request as ready for review November 2, 2026 23:31
@thomhurst
thomhurst merged commit 760e8b4 into main Nov 2, 2026
33 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T23:33:15.150689Z 53970c5 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review: no blocking issues.

I read the diff against the surrounding script. This is a script-only change, so none of the AGENTS.md hot-path or benchmark rules apply.

  • Get-PrActivity takes only the head commit and reviewThreads, so it avoids the GraphQL node limit that gh pr list --json commits hits. It paginates correctly. Invoke-GraphQl is defined before it is called, and it returns .data.repository as the query expects.
  • Test-HasNewFeedback uses fields that $prFields already requests: author, reviews and comments. The since-cursor moves forward on a push, on the loop's own review replies and on loop-marker comments. A stale CHANGES_REQUESTED review therefore stops waking the PR after it has been answered or the head has been pushed.
  • $inFlight is incremented after the parked-label filter and before the pending-checks skip. Pending PRs and drafts therefore count toward the limit, and parked PRs do not.
  • atPrLimit skips only fresh issues. Stranded branches, claims and parents whose children are closed still run, as the PR description says.
  • The new tests cover feedback detection, the answered and stale cases, comment-only reviews, the Light flag with open threads, parked PRs not counting, and -MaxOpenPrs 0.

One minor thing, not blocking. reviewThreads(first: 100) ignores any threads past 100 on a single PR. It only matters if all of the first 100 are resolved and a later one is not, which is very unlikely.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 53970c51f5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

function Get-PrActivity {
$query = 'query($owner: String!, $name: String!, $cursor: String) { repository(owner: $owner, name: $name) { ' +
'pullRequests(states: OPEN, first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } ' +
'nodes { number commits(last: 1) { nodes { commit { committedDate } } } reviewThreads(first: 100) { nodes { isResolved } } } } } }'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Paginate review threads before counting unresolved feedback

For a PR with more than 100 review threads, this query ignores every thread after the first page; the surrounding cursor loop paginates only pullRequests. If the first 100 threads are resolved and a later thread is unresolved, Test-HasNewFeedback returns false unless a separate changes-requested review qualifies. Consequently, a pending PR is still skipped despite actionable feedback, and a clean PR can incorrectly receive light effort. Fetch the remaining thread pages before computing UnresolvedThreads, as the existing review gate in scripts/Assert-PrGreen.ps1 does.

AGENTS.md reference: AGENTS.md:L54-L55

Useful? React with 👍 / 👎.

@greptile-apps

greptile-apps Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect work selection in the issue/PR loop.

Fix the deferral check before merging so reopened feedback can actually reach a worker.

Findings

  1. P1 Reopened feedback stays deferred ▶
  2. P2 Later threads go unseen ▶

Summary

This PR makes review feedback actionable while checks run and adds MaxOpenPrs to pause fresh issue work.

  • Unanswered review feedback makes pending-check PRs actionable.
  • New issues wait when too many loop PRs are open.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Survey open PRs] --> B{Checks still running?}
    B -->|No| D[Rank PR]
    B -->|Yes| C{Conflict or review feedback?}
    C -->|Yes| D
    C -->|No| E[Skip PR for now]
    D --> F{Existing deferral still matches?}
    F -->|Yes| G[Keep waiting]
    F -->|No| H[Try to claim PR]
    A --> I[Count unparked PRs]
    I --> J{At MaxOpenPrs?}
    J -->|Yes| K[Hold fresh issues]
    J -->|No| L[Allow fresh issues]
Loading

Reviews (1) · Last reviewed commit: "feat(issue-pr-loop): finish open PRs bef..." · Reviewed by Greptile

else { '' }
# A green, clean PR usually needs only the merge gate or a disposition reply.
New-Candidate 'pr' ([int]$pr.number) $rank (Get-PrFingerprint $pr) ($rank -eq 0)
New-Candidate 'pr' ([int]$pr.number) $rank (Get-PrFingerprint $pr) ($rank -eq 0) $hint

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Reopened feedback stays deferred

When a reviewer reopens a resolved thread on a deferred PR, Test-HasNewFeedback makes it actionable. But Get-PrFingerprint leaves out thread state. If the head, checks, and other comments are unchanged, Test-Deferred still skips the PR until CI changes or the deferral expires. Include thread state in both survey and post-unit fingerprints so this feedback can reach a worker immediately.

function Get-PrActivity {
$query = 'query($owner: String!, $name: String!, $cursor: String) { repository(owner: $owner, name: $name) { ' +
'pullRequests(states: OPEN, first: 100, after: $cursor) { pageInfo { hasNextPage endCursor } ' +
'nodes { number commits(last: 1) { nodes { commit { committedDate } } } reviewThreads(first: 100) { nodes { isResolved } } } } } }'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Later threads go unseen

reviewThreads(first: 100) reads only one page. If a PR has more than 100 threads, the first page can be fully resolved while a later thread remains open. UnresolvedThreads then becomes zero, so a comment-only review on that later thread does not wake the PR while checks run. Read the remaining thread pages before deciding that no unresolved feedback exists.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant