pr_conflict_label: read the open pull requests 100 per request (TOOLS-PR-CONFLICT-LABEL-RATE-LIMIT) #3116
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3116"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by lorentsob on 2026-12-02T11:43:09Z.
Claimed in the coordination issue as: TOOLS-PR-CONFLICT-LABEL-RATE-LIMIT (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7344305222)
What and why
tools/pr_conflict_label.pyasks for every open pull request by number, once per attempt. The workflow's token gets1,000 requests an hour for the whole repository, so with many hundreds open a run spends them all, stops before the
last pull requests and leaves none for the other workflows that hour:
That is how
Needs rebase labelfailed onmainfrom 27 November to 1 December: run 45977772822 (about 1,500 open),46273987960, 46274246229 and 46275295800 (about 700 open), 46608955886 and, last, 46666290577 on 1 December at
14:20 UTC (about 700 open). It has been green since the closures of 1 December brought the open count to about 210,
but each run still costs one request per open pull request, and the count only has to climb back for it to fail
again. Labels then go stale: a pull request that conflicts is not labeled and one that was rebased keeps
needs rebase.A run over every open pull request now reads them 100 per request through the GraphQL API (number,
mergeable,labels): 3 requests per attempt for today's 210 open, 7 for 700, instead of one per pull request. What it decides and
writes is unchanged, and
--pr Nstill asks for each number as before. A pull request closed between two attemptsis skipped. Since a listing is cheap, its attempts are 60 seconds apart instead of 10 (
LIST_WAIT): a pass of onerequest per pull request took about 3.5 minutes for 208 open, and that was the time GitHub had to compute the merges
a push to
mainreset; the three waits keep about as much.This complements #3099 (CI-LABEL-HOURLY), which keeps the workflow to its hourly run: that one cuts the number of
runs, this one the cost of each run. They change different files.
Tested
python -I tests/test_pr_conflict_label.pyonmain40ac04183: 17 of 17 pass (the run over 1,500 also checksthe three waits are
LIST_WAIT). The same tests againstmain'stools/pr_conflict_label.py: 4 errors, one of them the HTTP 403 above (a fake API that allows 1,000 requests for1,500 pull requests).
pages, cost 1 point per page; 57
CONFLICTING, 0UNKNOWN, and the same 57 labeledneeds rebase, which is whatthe current run left.
mainafterthe merge is the real check.
GET /pulls/Nisdocumented to. Today's listing found no
UNKNOWNto watch, andmaindid not move while I could look. If it doesnot, a pull request a push left
UNKNOWNkeeps its label as it is until a later run finds it computed (the runnever guesses);
--pr Nstill asks the REST way.github_api): that one retries a failed call, this one makes far fewer calls and does not touchgithub_api.python -I scripts/check_no_game_data.pyon the two changed files: clean.Tested on macOS (Apple M5 Max). GPUs tested: n/a
AI-assisted: yes (Claude Fable 5.2 wrote the first version, Claude Opus 5.5 the rebase and the changes after review;
a separate read-only reviewer agent on Claude Fable 5.2 audited the diff twice. From its first pass: the listing's
wait between attempts, the docstring's account of the 403 and two comments were fixed; it found no blocker.)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T12:43:00Z.
Ran natively on Windows 11, Python 3.13, head
10fcd88fbmerged into currentmain.tests/test_pr_conflict_label.pypasses.I also ran
open_pulls()live against this repository, read-only. It used a personal token with no write scope, and a wrapper refused any method other than GET or the/graphqlPOST, so nothing was labeled. The point was to check that the GraphQL listing getsmergeableresolved: with REST, the per-PRGETis what starts GitHub's background merge check.main: a push landed between my first two listings 60 s apart. The second listing showed 118UNKNOWN, 42MERGEABLEand 1CONFLICTING.So with only GraphQL listings, the
UNKNOWNs cleared within the default 4 attempts ×LIST_WAIT(60 s).Not checked: a real labeling run with the workflow's token.
GPUs tested: n/a (CPU and network only).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T13:31:26Z.
Review: COMMENTED
Independent Linux review on main
01eca4b71+ head10fcd88fb, with Python 3.14.10 and the repository’s offline fake API. All 17 tests passed. The same test suite against main’s implementation reproduced the simulated API-limit failure in the 1,500-PR case. The merge remains clean on128648cfe, which leaves the tool, tests, and workflow identical. The paginated run also passed the closed-between-polls and single-PR REST cases. No Actions token or live writes were used in the test. CPU only. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by aegish-zagi on 2026-12-02T14:35:03Z.
Verification — VERIFY-3116
10fcd88fb3; MERGEABLE against current main (69cd4106c) — red_green merged it with main in its scratch worktreepython -I scripts/red_green.py 3116 --remote upstream --no-cargo(runs the PR's tests on main = red, and on PR+main = green); plustests/test_pr_conflict_label.pystandalone on main beforehandAI-assisted: yes (Muse Wonder, Muse by Meta)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:11:54Z.
Verified #3116 on Linux: 17/17 pass merged onto current
main; withmain's tool the new tests are red, including the HTTP 403 rate-limit case.10fcd88fb3(same head as the earlier checks by Kal0s-design and aegish-zagi)main45dc41f95c(git merge --no-ff, clean; merge base40ac041833, 136 commits behind)Ran
Red/green (reverted only
tools/pr_conflict_label.pytomain, kept the new tests):The 1,500-PR case is the one that matters: the fake API allows 1,000 requests and
main's per-PR GET loop hits the 403 the description quotes from theNeeds rebase labelruns.Review
open_pullsraises on a GraphQLerrorsbody or a nullrepositoryinstead of reading it as "no open pull requests", and a test covers it. Good: an empty answer would otherwise unlabel nothing silently but also label nothing.--pr Nkeeps the old one-GET-per-number path (test_one_named_pull_request_is_one_request).elif number in pulls ... else: continue), tested.mergeablestarts GitHub's background merge computation the way the REST GET does. The description reports 0UNKNOWNof 210 on a live read and the threeLIST_WAIT(60 s) waits keep the old time budget, so at worst some answers stayUNKNOWNuntil the next hourly run, which the tool already handles by leaving the label alone.ApiError(200, ...)for a GraphQL error is accurate but reads oddly in a log; harmless.Verdict: ready. No defects. Claim
TOOLS-PR-CONFLICT-LABEL-RATE-LIMIT, AI disclosure and tests present. No check runs are recorded on the head yet (mergeable_state: blocked), so CI still has to run.AI-assisted: Claude Opus 5.5 (Claude Code), verification only.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T20:31:48Z.
RUN (independent run on Windows, head
10fcd88fb3222dbbd82a5a6f1eb682ff4e04ecd5, merged intomainb41763227aeed2d23c98af84bcbc1bddc7acdc90withgit merge --no-ff)Python 3.14.0, standard library only, no cargo, no game data, nothing written to GitHub. Merge commit
8111dc017, clean, in a throwaway worktree. The PR head is unchanged since the earlier comments (read withgit ls-remote).Green
python -I tests/test_pr_conflict_label.pyon the merge: 17 of 17 pass.python -I scripts/check_no_game_data.py tools/pr_conflict_label.py tests/test_pr_conflict_label.py: clean (rc 0).main:tools/pr_conflict_label.pyandtests/test_pr_conflict_label.py.Red
tools/pr_conflict_label.pyswapped back to main's version (restored afterwards), 4 of 17 error:test_1500_open_pull_requests_stay_under_the_token_limit,test_a_pull_request_closed_between_two_listings_is_skipped,test_a_graphql_error_is_not_read_as_no_pull_requests,test_open_pulls_follows_pages. The other 13 pass on both sides.LIST_WAIT60 -> 10 (the test compares the waits to theLIST_WAITconstant itself, so it cannot see the value change). Droppinganswer.get("errors") orfrom the error check (a payload with nodatastill raises; a response with botherrorsand partialdatawould be read as valid). Page sizefirst: 100->first: 50(only the cost per run changes, no test counts requests of a 100-page).decidereturns nothing for that pair, so it is not a real gap.Review
--pr Nstill uses one REST GET per number, decisions go throughdecide()unchanged.unknownPRs are listed again afterwait, a closed PR is skipped, a GraphQL error raisesApiErrorinstead of reading as an empty list,mainpassessorted(pulls)..github/workflows/conflict-label.yml,CONTRIBUTING.md,docs/i18n/fr/contributing.md, plus the tool and its test. The diff touches only the tool and its test, so the workflow and both docs are unchanged.labels(first: 100)would missneeds rebaseon a PR with more than 100 labels (not realistic).tests/test_pr_conflict_label.pypasses on head merged into main; no red run reported. Also a live read-only listing of about 161 open PRs, 2 GraphQL requests per listing,UNKNOWNcleared within 4 x 60 s; says it cannot tell what started the merge checks; no real labeling run.scripts/red_green.py): 17 pass on the PR, 4 fail on main, the same four tests listed above, 0 regressions.45dc41f95c; main's tool errors 4 (the 1,500-PR case as HTTP 403, the others missingopen_pulls); head unchanged. That is three comments and one review.check-runstotal 0, combined statuspendingwith 0 entries). GitHub Actions is having an incident today, so I cannot say whether CI would be green or red; I do not guess.Not covered
LIST_WAITand partial GraphQL errors (see surviving mutations).Verdict
PASS. 17/17 green on the merge into current
main, 4 tests red on main's tool, claim in place, no CI result available. Three weak spots in test strength (LIST_WAIT, partialerrorswithdata, page size), not blockers.AI-assisted (Claude Code), models: Claude Opus 5.5 (checker), separate Claude Opus 5.5 judge.