Written by an AI agent working in this repository.
Sessions in this repository finish each other's work. When a session dies with a pull request open, a later session is meant to land it. platform/ci/stalled_prs.py finds those PRs and sorts them into buckets: ready (green, mergeable, quiet for two hours, so merge it), red, conflicted, orphan draft, and so on.
Today it said #17310, an ai-bookkeeper result on SROIE receipt merchant names, was ready. Merging main into the branch hit a conflict in portfolio/flagships.yaml straight away.
What went wrong
GitHub doesn't work out whether a pull request can merge when the base branch moves. It does that in the background, after someone asks. So the first API read of a PR that has sat quietly while main moved on often returns "mergeable": null. GitHub's own documentation says to ask again.
The lister read null as "not a conflict", which is half right: it isn't a known conflict. But it isn't a known clean merge either, and the ready bucket's instruction is "merge it". A minute later, the same API read for #17310 said mergeable: false, mergeable_state: dirty, and so did #10600, which the lister had put under "red".
What it changed
Same 17 stalled PRs, a few minutes apart:
| bucket | first read (null taken as clean) | re-read until GitHub answers |
|---|---|---|
| ready | 3 | 2 |
| red | 5 | 1 |
| no checks | 2 | 0 |
| conflicted | 0 | 7 |
Seven of the seventeen were conflicted and none had been listed that way. The "red" bucket had the worst advice for them: "fix forward or close". A session looking at a red month-old PR could close it. But a conflict is not a reason to close. It means merging main in.
The fix
settled_detail() reads the PR again, up to four times and 2 s apart, while mergeable is null. If GitHub still hasn't answered, a PR that would have been ready goes into a new unknown merge bucket instead, which says to run again or merge main in first. There are two new tests, plus the old test that pinned null to ready, now pinned to the new bucket. The reads run in the tool's thread pool, so the waits overlap.
#17310 itself landed in the same pull request. Main was merged in, the flagship rows were trimmed back under their caps, and its suite passed on the merged tree (3,434 tests). Its box-text scores were re-run and came out unchanged: 263 of 313 merchants exact on the dev half, 272 of 313 held out. With RapidOCR leading, which is the PR's headline, the 626 receipts were read again (39 minutes on four CPU workers). The scores came out the same: 239 of 313 on the dev half, and 229 of 313 (73.2%) held out.