Repository navigation
perf(ci): read CI Status labels and comments from the GraphQL pool - #16644
kyle-sexton wants to merge 3 commits into
Conversation
CI Status read the pull request's labels and its issue comments over REST, spending the per-repository GITHUB_TOKEN core limit that every open pull request's CI shares. Two new gh-read.sh helpers, pr_labels and pr_comments, read them in one GraphQL send each, which GitHub meters in a separate pool, and print the REST shape the steps already parse. Any doubt (a failed send, an errors answer, another page, a comment author REST would show differently) reads REST through gh_read as before, so a GraphQL failure costs a core read and never a red required check. PR files and issue events stay on REST: GraphQL has no previous path for a renamed file and no performed_via_github_app on a label event. Refs: #15497 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The full REST answer carried an organization node id that the typos check reads as a misspelling; the parity case compares only the fields the steps and filterLaneHolds read, so the fixture keeps just those. Refs: #15497 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A hold comment's updated_at feeds lane-binding.mjs wasEdited, and GraphQL's updatedAt is not shown to move only when REST's does: a reaction or a minimize that moved one and not the other could drop a real hold's footer and pass the check. pr_comments now reads REST whenever any comment carries a review-lane hold marker, so only the no-hold path, the common one, reads GraphQL. Tests pin the hold fallback, the no-hold GraphQL path in the hold-lift step, and a secondary-limit answer stopping every pool as on REST. Refs: #15497 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis 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. |
|
Closing on its own measurement, not on a defect. CI Status spends 5.7 core calls per job; this moves about 1.1 of them to GraphQL. At about 60-65 CI Status jobs an hour that saves about 70 core calls an hour, about 1.4% of the 5,000 limit, and it adds 323 lines of GraphQL-with-REST-fallback logic to a required check. The other jobs could move only about 2.3 (review lanes) and 1.2 (Check Intent) calls each, so the whole GraphQL route tops out around 6%, well below the 21-to-26-PR estimate in #15497. PR files, events and Actions runs have no GraphQL equivalent (introspection). The ceiling has to move through a design choice, not read shuffling. The branch stays, so this can be reopened if a later measurement changes the sums. Refs #15497 |
Refs: #15497
Summary
CI Status (
pr-require-checks.yml, jobci-status) now reads the pull request's labels and issue comments from GitHub's GraphQL API. GitHub meters GraphQL forGITHUB_TOKENin a separate pool from the per-repository core REST limit of 5,000 per hour. CI on every open pull request spends that core limit, so these reads no longer count against it.Fix
gh-read.shgains two helpers,pr_labels <n>andpr_comments <n>. Each sends one GraphQL query and prints the result in the REST shape the steps already parse:idis GraphQL'sdatabaseId;[bot]suffix that GraphQL drops;user.typecomes from__typename.Three reads move to these helpers:
Fail-safe: anything short of a whole, well-formed answer reads REST through
gh_read, every page, exactly as before. That covers:errorsanswer;hasNextPageon the connection;updated_atfeedslane-binding.mjswasEdited, and nothing shows that GraphQL'supdatedAtmoves only when REST's does. So holds keep the REST read, and only the common no-hold path reads GraphQL.A GraphQL failure costs one core read, never a red required check, including in
merge_groupruns. A spent GraphQL primary limit stops only thegraphqlpool in the rate guard, so the REST fallback still goes out (tested).Known residual: a
RATE_LIMITEDanswer that still shows GraphQL points left is a secondary limit. The generated rate guard stops every pool for it, so the REST fallback is not sent and the step fails closed. A REST secondary limit does the same today; this is not a new kind of failure, and a test pins it.The new calls go through the api-budget
ghwrapper, so they are counted, asgraphql=, in the job'sapi-callsnotice line.Reads that stay on REST, by parity check against the live schema:
PullRequestChangedFilehaspath,changeType,additions,deletionsandviewerViewedState, with no previous path. ci-status reads.previous_filename.LabeledEventhasactor,createdAt,labelandlabelable, with noperformed_via_github_app. The hold-lift step uses that field to refuse an App lifting a hold for a person.merge-holds.mjs, which reads more REST fields.Verification
GraphQL pool measurement (hub call logs
gh-token-windows.jsonlandgh-job-calls.jsonl, github-token only):limitheader)pull_requestCI Status job (3 while held), at most 98 jobs/hour (under +300 points)The GraphQL rate-limit docs state 1,000 points/hour for
GITHUB_TOKEN. The measured header says 5,000. Against 1,000, today's peak is already 87%. The measured value governs here; if GitHub enforces the documented number, the REST fallback covers it.Parity:
scripts/fixtures/ci-gh-read-graphql/.scripts/ci-gh-read-graphql.test.shasserts the adapter's output equals the REST answer on every field the steps andfilterLaneHoldsread:id,node_id,body,created_at,updated_at,user.login,user.idanduser.type. It asserts label names too.api-callscount.[bot]mapping removed, the parity and login cases go red.Core calls per CI Status job:
The estimate removes the labels route (0.58 per job) and the hold-lift step's comments read on pull requests with no hold comment (up to 0.57 per job). At the 98-jobs/hour peak that is about 110 fewer core calls per hour.
Measure after merge: in
gh-job-calls.jsonl, compare rows withsourcepr-require-checks.yml:CI Statusdone after the merge against those before:calls / jobsshould fall by about 1.1;graphql / jobsshould rise by about 1.1;routesfield should showrepos/{repo}/issues/{n}/labelsnear 0 per job.Tests run (all green):
scripts/ci-gh-read-graphql.test.sh(new)ci-gh-readci-hold-human-gatedci-hold-lifted-by(updated for the GraphQL send; adds a no-hold GraphQL case and a hold-reads-REST case)ci-hold-cost-decisionci-hold-merge-groupscripts/check-affected.sh --base origin/main --no-fetchpr-require-checks.ymlis on the trusted-path hold list, so this pull request holds for a person.Related
Check Intent: its heaviest routes are Actions artifacts and runs, which have no GraphQL.commits/{sha}/pulls(1.18 per job) can move toassociatedPullRequests.Review Subscription:pulls/{n}(1.27 per job) and comments (1.0 per job) can move.compare(2.0 per job) needs a parity check.Wait For Refine:pulls/{n}(1.14 per job). Its runs and artifacts reads stay.🤖 Generated with Claude Code