Skip to content

fix(pr-review-main): skip a re-review only on a verdict after the newest retarget - #17717

Merged
kyle-sexton merged 1 commit into
mainfrom
fix-15410-pr-review-main-retarget-cutoff
Nov 21, 2026
Merged

kyle-sexton merged 1 commit into
mainfrom
fix-15410-pr-review-main-retarget-cutoff

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

Refs: #15410

Summary

pr-review-main.yml's check-trigger step "Find a head both lanes already reviewed" called ev._main_bound(lane, head, records, context) with no cutoff. Since #17703 the merge gate binds a lane-source pull request's main-run verdict only from a run created after the newest base_ref_changed event. So after a retarget with no push, this step reported judged=true on the pre-retarget verdict and skipped the review, while the gate refused that same verdict: the pull request stayed held as lane-source-changed. This closes the gap #17703 listed under Known limits and Remaining.

Fix

Design: the owner's Q116 A (decision row). Owner, verbatim: "go w/ recommendations and then /session-flow:handoff".

  • Once both lanes have a counted verdict record, the step reads the pull request's issue events (repos/{repo}/issues/{n}/events?per_page=100), takes the newest retarget with babysit_merge._retargeted_at (the gate's own function, imported as is), parses it with babysit_review_evidence._time, and passes it to _main_bound as after.
  • As in bind(): no retarget means no cutoff; a retarget with no readable time binds nothing, and the review runs.
  • The step's contract holds: a failed read, a full page of events (100 or more, so maybe not the last page) or events that are not a list leave no output, and the review runs. The no-verdict paths make no new read.
  • The issue events endpoint, not the gate's timeline: the docs mark base_ref_changed supported on issue events (issue event types: base_ref_changed), and it returns fewer items (9 against 21 on test(pr-merge): add stack run layer 3 line to case-c pr-pipeline-sandbox#400, with the same created_at from both). The job's pull-requests: read covers it (permissions for Pull requests).
  • The pr-pipeline convention's list of what reviews again names the cutoff; a .changes/pr-pipeline/ fragment records the fix.

Verification

  • node --test --test-concurrency=4 .github/scripts/pr-review-main/workflow.test.mjs: 54 of 54 pass. The judged-head test adds cases: a retarget before the run (judged), after it, at the run's creation time, the newest of two after it (not judged), a retarget with no time or no zone, a full page of events, events that are no list (not judged, a warning), and a failed events read (sent again; three failures leave no output and the review runs). Call counts move from 8 to 9 (one events read); the no-verdict and uncounted-verdict paths keep their counts (1 and 6).
  • scripts/check-affected.sh passes.

Related

Remaining

🤖 Generated with Claude Code

…est retarget

The check-trigger job's already-reviewed step called _main_bound with no
cutoff, so a lane-source pull request retargeted without a push was
judged on its pre-retarget verdict and skipped review, while the merge
gate refused that verdict and held it as lane-source-changed.

The step now reads the pull request's issue events once both lanes have
a counted verdict, takes the newest base_ref_changed time through
babysit_merge._retargeted_at, and passes it to _main_bound as `after`.
An unreadable time, a full page of events or a failed read runs the
review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 21, 2026 00:17
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T00:23:18.438791Z f40a1e9 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

Copy link
Copy Markdown
Contributor

claude-review reviewed f40a1e9fd952453fa4619aa17e7a2b8999a9de5b: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: no findings

This PR changes the step "Find a head both lanes already reviewed" in pr-review-main.yml. Before it skips a review, the step now reads the pull request's issue events and passes the newest base_ref_changed time to _main_bound as after. A pull request retargeted without a push now gets reviewed again instead of staying held as lane-source-changed.

Checked against the merge gate

  • The step gets the cutoff the same way bind() does (babysit_review_evidence.py#L483-L485):
    • It calls the gate's own _retargeted_at (babysit_merge.py#L3313).
    • With no retarget there is no cutoff.
    • When the retarget time can't be read (missing, no time zone, or mixed naive and zoned times), _time returns None. The script then exits non-zero, which lands in unread "a verdict", so no output is written and the review runs.
  • The cutoff is strict: _created_after uses >. The new test case "retargeted as the run was created" checks the boundary.
  • The step still leaves no output on any failure:
    • a failed events read (retried through try_read)
    • a body that is not a list
    • a full page of 100 events (maybe not the last page)
    • an event that is not an object (an AttributeError in Python, which also lands in unread)
  • The events read happens only after both lanes have a non-empty record file. Before, the no-verdict path got the same "no output" result through _main_bound. It now exits early with a message and makes no new read.

Tests. The new cases (before, after and at the run's creation time; the newest of two retargets; no time; no zone; a full page; not a list; a failed events read) cover each branch the step adds. The call counts (9, then 10 with one retry) match the one added read. I did not run the tests. The author reports 54 of 54 passing; that is unverified.

Docs and changelog. The README line and the bump: patch fragment describe the change accurately.

Closing issue. The PR text says Refs: #15410 and closes no issue, so I had no acceptance criteria to check against. The PR's "Remaining" section lists what stays open on #15410.

Loosened checks. The prompt gave no loosened_check_verdict:, loosened_check_patterns: or loosened_check_decision_record: lines, so I used fail with no consumer entries and did not check the citation requirement. The diff weakens no check: it adds a condition before a review is skipped, so more reviews run, not fewer.

Spend. Runs that reach the verdict check make one more GitHub API read. Retargeted pull requests get extra review-lane runs, paid from prepaid credit. Neither is a billing change.

Verifier dropped 0 of 0 candidates.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed f40a1e9fd952453fa4619aa17e7a2b8999a9de5b: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #17717 (f40a1e9f)

I read every hunk of all 4 changed files. I found no security issues.

What changed. The "Find a head both lanes already reviewed" step in .github/workflows/pr-review-main.yml now reads the PR's issue events. It uses them to stop a review verdict from counting when it was made before the PR's newest base_ref_changed. With that cutoff in place, the step sets judged=true in fewer cases. judged=true is what skips the review and the "Check the trigger" step, so the change only narrows when they are skipped. It doesn't widen anything.

Trusted-path checks (.github/workflows/pr-review-main.yml, .github/scripts/pr-review-main/**):

  • Who is trusted. Unchanged. The trusted-actor check still runs whenever judged is not true. With this change, judged stays unset in more cases, so the check runs more often (pr-review-main.yml#L373).

  • Fails closed. Each new failure path calls unread/try_read, exits 0 and sets no judged output, so the review runs:

    • a failed events read;
    • a page that isn't a list, or has 100 or more entries;
    • a retarget time that can't be parsed, or has no time zone (Python's sys.exit makes the $(...) fail, which reaches unread).

    Lines: L348-L363. babysit_merge._retargeted_at returns "" for an unreadable time, and ev._time("") gives None, so that case also exits (babysit_merge.py#L3313-L3325).

  • Injection. None found. PR_NUMBER must already match ^[1-9][0-9]{0,9}$ before it goes into the events URL (L261). The event JSON is parsed only as data by json.load and jq -e. The Python modules come from the trusted .base main checkout, not from the PR's code.

  • Token scope. Unchanged. The step still uses github.token with the job's existing permissions, and no permissions: block changed.

The test file and docs/changelog changes have no security surface.

Spend. One more GitHub REST read per judged-head check, plus extra review runs after a retarget with no push. Both are covered by existing subscription or API usage and are not a billing change.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit ac4f209 Nov 21, 2026
81 checks passed
@kyle-sexton
kyle-sexton deleted the fix-15410-pr-review-main-retarget-cutoff branch November 21, 2026 00:39
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant