Repository navigation
fix(source-control): stop pr-merge demoting on a listing that dropped its dispatch runs - #9167
Conversation
… its dispatch runs Before a missing dispatch run becomes a deadline failure, read the branch's dispatch runs at the merge commit by head SHA; a run there the listing lacked makes the verdict unreadable. Object listings read through _paginated raise when total_count exceeds the items returned. The demotion filer re-reads the record listing before filing a new record. Refs: #9145 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed No security issues found in the incremental change (3f7a062..3824978). It touches only |
|
claude-review reviewed Incremental review of 3824978 against 3f7a062, which changes only The one change collapses the multi-line I did not run the tests or the formatter. The earlier test and ruff results are the PR author's claims, which I have not verified. No findings. Files unchanged since 3f7a062 were reviewed then. |
…mits and drop the same-pass record re-read The by-SHA confirmation now reads the merge commit and every descendant on the branch committed by the deadline (from compare to the branch tip, which raises when it lists fewer commits than total_commits), and counts only a missing run by the lane or the identity created in time. Run rows of another event or head repository are dropped. A listing past the 1,000-result search cap reads with a listing-capped warning instead of raising. The same-pass record re-read is removed: it cannot catch a lagging index. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The compare from the merge commit to the branch tip lists at most 250 commits, so a merge judged after 250 later commits would hold on every sweep. The candidates now come from the branch's commits between the merge and the deadline, kept when they descend from the merge commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he cap A degraded answer can carry a total_count past the search cap with few items; only a listing that returned at least RUN_SEARCH_CAP items is short by design. Document that the window commit listing has no total, so a silent drop falls back to the read at the merge commit. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…9186) Closes #9168 ## Summary When GitHub answers the `pr-merge-dispatched-<id>` artifact listing with HTTP 200 and no artifacts, pr-merge's post-merge check read a run the lane did dispatch as not the lane's. Past the 6 h deadline that became a dispatch failure, which files a demotion record. This implements the owner's option (a) ([decision](#9168 (comment))): read the listing once more, and when it is still empty, hold with an unreadable verdict instead of failing. ## Fix All code changes are in `plugins/source-control/skills/babysit-prs/scripts/babysit_postmerge.py`: - `_Context._lane_record` reads the dispatch record's listing a second time when the first read names no artifact. A second empty read is noted in `_Context.lane_empty`, and the record still reads absent, so an empty listing never makes a run count as the lane's. - In `_judge`'s deadline block, beside the existing by-SHA hold, a github-actions[bot] dispatch run at or after the merge commit, created by the deadline, whose record listing read empty twice raises `PostMergeReadError`. The verdict is unreadable (exit 3), so pr-merge files nothing and starts no run. The next sweep builds a fresh `_Context`, reads the listing again, and clears once it reads the record. - The raise sits at the deadline, not in `_lane_record`, so nothing changes before the deadline: an unrecorded bot run still reads as pending and `needsDispatch`, and the lane dispatches a recorded run. - A listing that names a sender other than the lane's pr-merge.yml run is not empty. It reads as not the lane's run and still fails at the deadline. The re-run record (`pr-merge-rerun-<id>-attempt-2`) is still read once. ## Verification - `uv run --with pytest python -m pytest plugins/source-control/skills/babysit-prs/scripts/tests/ -q`: 2523 passed, 1954 subtests passed. - 4 new tests in `EmptyLaneRecordListing`. The first two failed before the fix: - both reads empty, past the deadline: verdict unreadable, no failure, 2 listing reads; - the second read returns the record: the run counts as the lane's and the merge verifies; - stay-loud: a dispatch by another actor still fails at the deadline; - stay-loud: a record uploaded by another workflow (a non-empty listing) still fails at the deadline, with one listing read. - `scripts/run-ruff.sh check` and `format` on the scripts directory: clean. `scripts/check-changelog-fragments.sh --check`: valid. - Left out: no live probe against a degraded artifacts API, which cannot be reproduced on demand. ## Related - #9167: the by-SHA dispatch hold this follows. - #9145: the degraded-API incident. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Refs: #9145
Summary
During GitHub's degraded-API window on 2026-10-22 (about 14:18-17:41Z), pr-merge's post-merge check read a dispatched-run listing that answered HTTP 200 without the runs it holds. It took that as "no dispatch run by the agent identity within 6 h" and filed demotion records #9081, #9088 and #9114, which set unattended merging to rung off. Both merges had passing lane-dispatched full runs at their merge commits. A lagging record listing also filed #9088 as a second record for #9081's failure. Root cause and evidence: #9145 (comment)
Fix
All changes are in
plugins/source-control/skills/babysit-prs/scripts/babysit_postmerge.py:_judgereads the branch's dispatch runs at the merge commit byhead_sha, with nocreatedfilter (_Context.dispatch_runs_at, cached per commit). A run there that the listing lacked raisesPostMergeReadError, so the verdict is unreadable (pr-merge holds and files nothing) instead of a failure. When the by-SHA read also shows nothing, the failure stands._paginated, an object listing whosetotal_countexceeds the items returned raises instead of reading as complete. This covers_runs, the new by-SHA read and the failed-jobs read.babysit_gh.flatten_paginated_itemsis unchanged for its other callers._baselineandaffectedread a cappedper_page=20page on purpose and are left out._record_of).An empty artifact listing in
_lane_recordcan still read as "not the lane's run". Telling that apart from a run that really is not the lane's needs a design choice, so it is left to a follow-up.Verification
uv run --with pytest python -m pytest plugins/source-control/skills/babysit-prs/scripts/tests/ -q: 2508 passed, 1952 subtests passed.--remediatemakes no issue POST;total_countraises;scripts/run-ruff.sh checkon the scripts directory: clean.scripts/check-changelog-fragments.sh --check: valid.total_count(62 of 62 dispatch, 88 of 88 canary).Related
🤖 Generated with Claude Code