Skip to content

Decide the exit code from the payload the digest printed - #529

Merged
ptr727 merged 2 commits into
developfrom
feature/exit-code-agrees-with-digest
Aug 3, 2026
Merged

Decide the exit code from the payload the digest printed#529
ptr727 merged 2 commits into
developfrom
feature/exit-code-agrees-with-digest

Conversation

@ptr727

@ptr727 ptr727 commented Aug 3, 2026

Copy link
Copy Markdown
Owner

Fixes a race the review on the promotion pull request #528 found. That pull request cannot carry the fix, since its head is develop and develop takes changes only through a feature branch, so this is the fix and #528 picks it up when this merges.

The race

wait decided its exit code from the last Q_LIVE poll and printed a digest built from a later Q_FULL fetch. A review landing between the two makes the digest print review_on_head=yes while the code returns 40 or 50, and the same gap at the other exit prints coverage and returns 30.

The disagreement is not cosmetic. A reader that has both resolves it by believing the exit code, so the review it was just shown is the thing that gets dropped, and a covered pull request reads as stalled. On this repository's own loops the window is small and the traffic is exactly what fills it: a re-request lands a review within a few minutes of the poll that missed it.

The fix

Both exits leave the loop by breaking, and one payload then decides the digest and the code together. Coverage wins over a stalled request and over the timeout, because a landed review is the outcome the whole wait exists for, however the loop happened to end.

Verification

Two cases, one per exit, each watched failing against a build that decides from the stale poll: they print review_on_head=yes and return 50 and 30 respectively.

scripts/test_pr_review.py 61 pass, prose_lint.py clean over the diff, repo_gate.py clean.

🤖 Generated with Claude Code

The code came from the last liveness poll and the digest from a later
fetch, so a review landing between the two printed `review_on_head=yes`
and returned 40 or 50. A reader resolves that disagreement by believing
the code, which drops the review it was just shown, and the same gap at
the other exit printed coverage and returned PENDING.

Both exits now leave the loop by breaking, and one payload decides the
digest and the code together. Coverage wins over a stalled request and
over the timeout, because a landed review is the outcome the whole wait
is for, however the loop happened to end.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:01

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.

Pull request overview

This PR fixes a race in scripts/pr_review.py wait where the exit code could be decided from an older poll while the printed digest reflected a newer fetch, leading to contradictory “covered vs stalled/pending” signals for the same run.

Changes:

  • Updates digest() to optionally render from a caller-provided PR payload so output can be tied to a specific read.
  • Refactors wait to break out of the loop and then use a single final fetch for digest rendering and exit-code decisions.
  • Adds regression tests covering reviews landing during the final read near both the stalled and timeout exits.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
scripts/pr_review.py Refactors digest() and wait to reduce/avoid inconsistencies between printed digest and exit codes.
scripts/test_pr_review.py Adds tests to reproduce and lock down the race outcomes described in the PR.

Comment thread scripts/pr_review.py Outdated
The exit code was taken off one payload while the stall behind it came
from a reading made earlier in the loop, so a request picked up since
still reported as picked up by nothing. That is the disagreement this
branch exists to close, one layer further in, and the digest re-read the
timeline on its own besides, spending two REST calls to reach two
possibly different answers.

`stall_of` derives the stall from the payload it is reported beside, the
exit path passes both to the digest, and a covered head or an absent
request settles it with no call at all. An answer now outranks a stall,
since the reviewer saying something is worth more to the reader than the
reviewer saying nothing, and a wait that broke on a stall the re-read
clears reports as pending, which is what it is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 3, 2026 14:09

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.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@ptr727
ptr727 merged commit 484edab into develop Aug 3, 2026
7 checks passed
@ptr727
ptr727 deleted the feature/exit-code-agrees-with-digest branch August 3, 2026 14:17
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