Skip to content

fix(issue-pr-loop): finish open PRs before claiming new issues - #623

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

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.

  • 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 parents with all sub-issues closed still are. Survey stats report the held count.
  • A PR with an unresolved review thread, 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, 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 saying "no blocking issues" is also a comment).
  • Head commit time and review threads come from one paginated GraphQL query; gh pr list --json commits exceeds GitHub's node limit.

The matching SKILL.md priority-list change went to main in 8884eec.

Ported from thomhurst/TUnit#7423.

Validation: pwsh -NoProfile -File scripts/Test-IssuePrLoop.ps1 passes; new tests cover the feedback and open-PR-limit paths (checked that they fail when the logic is removed). -DryRun -MaxUnits 1 surveys the live repo successfully.

Workers skipped every PR whose checks were still running and started new
issues instead, so open PRs piled up and conflicts became likelier.

- Add -MaxOpenPrs (default 8, 0 = no limit): while that many unparked loop
  PRs are open, no fresh issue is queued; stranded branches, stale claims
  and finished parents still are. Survey stats count the held issues.
- A PR with an unresolved review thread, or an outside changes-requested
  review newer than the last push and the loop's last reply, is not skipped
  for pending checks and ranks with failed-CI PRs.
- Read head commit time and review threads with one paginated GraphQL query
  (gh pr list --json commits exceeds GitHub's node limit).

Ported from thomhurst/TUnit#7423.
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Caution

Review failed

The pull request is closed.

  • 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.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Review of #623 (draft, current head)

No blocking issues found. The change does what the description says, and the tests exercise the new paths.

What I checked:

  • Test-HasNewFeedback counts unresolved threads. It counts a CHANGES_REQUESTED review only if it is newer than the head commit and newer than the loop's last reply, whether that reply is a review by the PR author or a comment carrying $loopMarker. Plain conversation comments are ignored, as intended.
  • Get-PrActivity paginates and asks only for the last commit, which avoids the GraphQL node limit. It is skipped when there are no PRs.
  • $inFlight is incremented after the needs-human/on-hold exclusion, so parked PRs don't count toward the limit. Stranded branches, stale claims and finished parents are not gated by it, and 0 disables it. The tests cover each of these.
  • A green PR with open threads is no longer a light unit and no longer ranks 0, so it won't be sent to the merge gate.

Non-blocking suggestions:

  1. reviewThreads(first: 100) is unpaginated. A PR with more than 100 threads where the first 100 are all resolved would read as having no feedback. This is unlikely, but a one-line comment would record the assumption.
  2. The fingerprint (Get-PrFingerprint) doesn't include the unresolved-thread count. If a unit defers a PR because a thread needs a human and then someone resolves it, the PR stays deferred until another field changes. If you want the deferral to lift, add the count to the fingerprint. If not, this is fine as is.
  3. -MaxOpenPrs counts every non-parked PR, including ones waiting only on CI. That fits the stated goal, but the survey line could also report the $inFlight count, so it's clear why issues were held.

Performance validation doesn't apply here, because this is tooling script code and not the library.

@thomhurst
thomhurst marked this pull request as ready for review November 2, 2026 23:33
@thomhurst
thomhurst merged commit a8718c5 into main Nov 2, 2026
6 checks passed
@thomhurst
thomhurst deployed to Pull Requests November 2, 2026 23:33 — with GitHub Actions Active
@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:35:08.720692Z b39bef6 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.

@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: b39bef6f14

ℹ️ 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 as well as pull requests

For a PR with more than 100 review threads, this query examines only the first 100, including resolved threads; the pagination loop advances only the outer pullRequests connection. If those first threads are resolved but a later thread is unresolved, UnresolvedThreads incorrectly becomes zero. While checks are pending, Get-Candidates then skips that PR despite its actionable feedback; once checks finish, it can incorrectly classify the PR as a light merge candidate. Fetch subsequent thread pages before deciding whether feedback remains. This also preserves the repository requirement to check and disposition review-thread findings.

AGENTS.md reference: AGENTS.md:L39-L40

Useful? React with 👍 / 👎.

This branch was successfully deployed

1 active deployment
Pull Requests — b39bef6f Deployed Nov 2, 2026 by thomhurst via modularpipeline #1737
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.

1 participant