Skip to content

Exit pr_review.py wait When Unresolved Threads Land on an Attested Head - #3680

Merged
ptr727 merged 5 commits into
developfrom
feature/3671-wait-unresolved-threads
Oct 31, 2026
Merged

ptr727 merged 5 commits into
developfrom
feature/3671-wait-unresolved-threads

Conversation

@ptr727

@ptr727 ptr727 commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes #3671. On a pull request into develop whose head carries an attestation, pr_review.py wait polls the checks rather than requesting a Copilot round. That poll never read review threads. So when Qodo or CodeRabbit opened threads while the checks ran, wait kept polling while the merge read BLOCKED, and the driver was never told there was work to dispose of.

  • Q_HELD, the poll's read, now selects each thread's isResolved and opening author, and nothing else, so each poll read stays thin.
  • A new open_on_head helper reads the open threads from that page. Where the page was cut at 100, it walks every page through the existing unresolved_threads() instead.
  • An open thread ends the held poll on any read. On an open pull request wait then exits 46 with status=THREADS_UNRESOLVED, naming the threads' authors. 46 outranks 30, 44, and 45, since no check clears a thread.
  • A merged or closed pull request with a thread left open still exits 0, since no rerun clears it.
  • Documented in the pr_review.py docstring, the scripts/README.md exit-code table and held-poll paragraph, and drive-pr step 3, with the generated skill copies regenerated.
  • Tests cover: an open thread over a running check, a thread landing mid-poll, 46 over 44 and 45, a cut page walked to its end with and without an open thread past it, the unnamed-author fallback, MERGED/CLOSED reaching 0, and resolved threads only reaching 0. The poll-query contract test now pins the thin thread selection in place of "no threads".

Each new poll test fails with the code path it pins removed. The full suite passes, 3140 tests, and so do ruff, mypy, the prose gate, and the eol gate.

Local review

Five local-strict-review passes ran at the frontier tier, over two pushes.

  • Push 1, three passes. Pass 1 raised four introduced findings, fixed in 509e677: two README drifts, 46 firing on a pull request no longer open, and missing precedence tests. It also raised an over-hardening finding, which was taken. A suggestion to reuse the digest's thread count was declined as style. Pass 2 raised one wording finding, fixed in 9a54b23, and pass 3 raised nothing.
  • Push 2, after Copilot's round. Pass 4 found that d7413e6's fail-closed on a cut page looped forever on a pull request with more than 100 resolved threads, and two wording drifts. All three were fixed in 9ed6b04 by walking the cut page instead.
  • Remaining introduced finding, with this push's edit budget spent: on a pull request whose thread read is cut, the full walk runs twice per poll read, since backoff re-runs still_held on the value held_read already judged. It also runs once more at the exit-46 branch. Correctness is unaffected. Its cost is a few GraphQL points per iteration, only past 100 threads. This gets its outcome in this pull request's review loop.

🤖 Generated with Claude Code

ptr727 and others added 3 commits October 30, 2026 16:02
The held poll on an attested head now reads each thread's state and
author, and an open thread ends it at once with exit 46 and a
status=THREADS_UNRESOLVED line naming who opened them, since no check
clears a thread. Closes #3671.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A merged or closed pull request with a thread left open now exits 0
rather than 46, since no rerun clears it. The README's exit-0 row and
held-poll paragraph now name the thread release, and tests pin 46 over
44 and 45, the cut-page mark, and the unnamed-author fallback.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A merged or closed held head with a thread left open exits 0, so the
exit-0 rows now say no thread is open only where the pull request is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 30, 2026 23:15
@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 9a54b230a73668983dc2c79ddaee0ab8b8f4f421, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • 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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The polling logic can miss unresolved threads beyond a truncated page and incorrectly return success, so it must be corrected before approval.

2 open issues
What changed in this PR

This pull request updates pr_review.py wait to detect unresolved review threads during attested-head polling, return exit code 46, identify thread authors, and document the required driver behavior.

Changes:

  • Adds thin thread-state and author reads to held-poll queries.
  • Adds unresolved-thread precedence over check-related outcomes.
  • Adds tests for polling transitions, truncation markers, author fallbacks, closed or merged pull requests, and resolved threads.
  • Updates the README and canonical/generated drive-pr skill documentation.
  • This pull request requires changes.
File Summary Findings
tests/​test_pr_review.py Adds regression coverage for unresolved-thread polling, precedence, truncation, author fallbacks, and terminal states. [P3] nit — 1 vote: Rename the malformed thread_s_state test name.
scripts/​README.md Documents exit code 46 and held-poll behavior. [P2] nit — 2 votes: Qualify the thread condition as wait-only because status can still return 0 with an unresolved thread.
scripts/​pr_review.py Adds thread-aware held polling and exit code 46. [P1] critical — 4 votes: Handle truncated thread pages before continuing the poll; unresolved threads beyond the first 100 entries can currently be missed.
.github/​skills/​drive-pr/​SKILL.md Regenerated GitHub skill documentation. None.
.claude-plugin/​fleet-skills/​skills/​drive-pr/​SKILL.md Regenerated Claude skill documentation. None.
.claude-plugin/​fleet-skills/​.source-digests/​drive-pr Updates the generated skill source digest. None.
.agents/​skills/​drive-pr/​SKILL.md Updates the canonical driver procedure for exit code 46. None.

Review effort: Lite

Comment thread scripts/pr_review.py Resolved
Comment thread scripts/README.md Resolved
@codecov

codecov Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.74%. Comparing base (90813a0) to head (9ed6b04).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3680      +/-   ##
===========================================
+ Coverage    81.72%   81.74%   +0.01%     
===========================================
  Files           27       27              
  Lines         9128     9137       +9     
===========================================
+ Hits          7460     7469       +9     
  Misses        1668     1668              
Flag Coverage Δ
python-3.13 81.74% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

ptr727 and others added 2 commits October 30, 2026 16:27
A thread page cut at 100 with none open in it now ends the held poll
with exit 46, since an open thread may sit past it, rather than
releasing to 0. The README's exit-0 row now says only wait reads
threads, and a malformed test name is fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A held head whose thread read was cut at 100 now has every page read
before the poll decides, so a pull request whose many threads are all
resolved releases normally rather than exiting 46 on every rerun. The
README's exit-0 row now says status exits 0 whatever threads are open.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Answering the review-body finding with no thread on 9a54b23, the [P3] nit in the tests/test_pr_review.py row: the malformed test name test_the_held_poll_reads_no_files_and_only_each_thread_s_state_and_author was renamed to ..._each_threads_state_and_author in d7413e6.

@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 9ed6b0462603a1ce2823659249a16dd993e2acb7, the content this pull request carries at that commit against develop, and it recorded 1 finding.

@ptr727

ptr727 commented Oct 30, 2026

Copy link
Copy Markdown
Owner Author

Outcome for the remaining local-review finding listed in the body, the doubled thread walk on a cut page: declined with evidence. The walk runs only where a pull request's thread read is cut at 100, which the same review pass judged unrealistic for a feature pull request into develop. There it costs about one GraphQL point per page per poll read, against a 5000-point hourly budget, and a 45-minute wait makes about 25 reads. Correctness is unaffected, and caching it per payload would add state to the poll for a path that is rarely reached.

@ptr727
ptr727 merged commit 125d6bf into develop Oct 31, 2026
13 checks passed
@ptr727
ptr727 deleted the feature/3671-wait-unresolved-threads branch October 31, 2026 01:26
ptr727 added a commit that referenced this pull request Oct 31, 2026
## Summary

Answers Copilot's finding on promotion
[#3681](#3681), [Cache
paginated thread results within each
poll](#3681 (comment)).
It follows #3680, for #3671.

The held poll in `pr_review.py wait` judges one read more than once. It
judges it in `held_read`, again in `backoff`'s `keep`, and once more at
the exit-46 branch. On a pull request whose thread read is cut at 100,
each judgment walked every thread page again. `open_on_head` now keeps
its answer on the payload it judged, as `_open`, so each read's walk is
paid for once. Each GitHub read is a fresh dict, so the kept answer
never outlives the read it describes.

- Test: `test_a_cut_thread_page_is_walked_once_per_read` pins one walk
where the poll and the exit judge the same read. It fails with the cache
removed.
- The full suite passes, 3141 tests, and so do ruff, mypy, the prose
gate, and the eol gate.

## Local review

One `local-strict-review` pass at the `frontier` tier raised nothing. It
checked every call site for staleness, `full_read`'s reuse of the polled
object, the test mock's repeated object, and whether the extra key leaks
into anything that iterates or serializes a payload.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
ptr727 added a commit that referenced this pull request Oct 31, 2026
…on an Attested Head (#3681)

Promotes the changes merged into `develop` since promotion #3678 to
`main`.

- [#3680](#3680) Ends
`pr_review.py wait`'s held poll on an attested head when an unresolved
review thread is open, with a new exit `46` and a
`status=THREADS_UNRESOLVED` line naming the threads' authors. The poll's
read now carries each thread's state and author, and a thread read cut
at 100 is walked to its end first.
- [#3682](#3682) Walks a
cut thread page once per poll read, keeping the answer on the payload it
judged, which answers this promotion's first Copilot round.

Closes #3671

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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