Repository navigation
Conversation
On github.com, the default branch, visibility and full name of the scanned repository, the branches branchMustBeProtected names with their protected flag, and the authors of its latest releases now come from one GraphQL query, sent before the first read and kept for the run. The protected flag is a classic rule or an applying ruleset, which matches REST's protected flag on the 11 corpus repositories. The branch listing and each protected branch's protection details stay on REST: listing with the protected flag over GraphQL is several times slower. GitHub Enterprise Server keeps all these reads on REST, since its schema may lack Ref.rules. Refs #637 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
perf
What this PR does / why we need it:
Step 2 of #637. A GitHub analyze read the scanned repository over REST with one request per question: the repository itself, each branch
branchMustBeProtectednames (main,master,dev,productionby default), and the releases for the default token check. On github.com these now come from one GraphQL query, sent before the first read and kept for the run: default branch, visibility, full name, the named branches with their protected flag, and the authors of the latest 20 releases.REST's
protectedflag is true for a classic rule or a ruleset, and no single GraphQL field gives it. The query readsrefUpdateRule(the classic rule a non-admin token can see) andrules(the rulesets that apply). Together they matched REST on about 620 branches of the 11 corpus repositories;refUpdateRulealone missed ruleset-only branches such as every branch of vercel/next.js.Measured on the 11 repositories of the #619 corpus, against a build of step 1 (#639):
The JSON reports are identical on all 11 apart from
cliVersion, with the same exit codes. Each repository saves 5 to 12 REST requests for one GraphQL query. Both sides ran back to back against the live API, so part of the time difference is noise.Which issue(s) this PR is related to:
Refs #637 (step 3 follows in its own PR)
This PR is stacked on #639 (step 1), which builds on #619. It stays a draft until those are merged, then gets rebased on main.
Special notes for your reviewer:
/protection,/rules/branches/{b}) stay on REST, as do environments and the Actions workflows and runs, as the issue says.Ref.rules. The existing REST tests now run against an Enterprise host so they keep covering that path.FORBIDDENone like a 403, and a query that fails as a whole keeps each read's REST behavior for the same status. A branch GitHub could not answer for is reported as an error, never as absent.github/scanned_repo.go;control/task_github.gosends the query with the configured branch names. The protection-details code is now one helper shared by the targeted and listing paths.Does this PR introduce a user-facing change?
How was this tested?
github/scanned_repo_test.go(one query answers every read, values sent as variables, lazy load and the extra query for a missing branch, not found, unauthorized, server error, a failed branch alias, no token, GHES staying on REST) andTestRunGitHubAnalysis_PrefetchesTheScannedRepositoryincontrol/task_github_test.go. A test that would send this query to github.com without a stub fails instead of reaching the network.make build,make test, andgolangci-linton./github/...and./control/.... Lint reports one govet finding incontrol/catalog.gothat is already on main.plumber analyze --debugon the 11 corpus repositories with this branch and with step 1, comparing the JSON reports, exit codes and request reports (table above).AI usage disclosure:
YES. Claude Code wrote the code and tests under my direction, checked the GraphQL fields against REST, ran the corpus comparison and drafted this description. I reviewed the changes.
🤖 Generated with Claude Code