Repository navigation
perf(source-control): batch the demotion record reads - #10668
Conversation
read_demotion read each candidate demotion issue in its own GraphQL query: 39 of the 47 GraphQL calls of a full post-merge check. It now reads them 20 to an aliased query, as read_pins does, and reads on its own any record a batch fails or leaves out, so the answer is the per-issue read's. Live: 42 calls to 5 over 39 candidates, equal result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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 this pull request. critical-findings: 0 What I read: the whole diff (3 files), the PR context, and the surrounding code of Trust control check: the demotion hold is not weakened.
Other surfaces: the change fragment under Spend: none. The change reduces GITHUB_TOKEN API calls. |
|
claude-review reviewed No findings. I read the full diff and the surrounding
|
Post-merge mutation testingKilled 0, survived 0, timeout 0, no coverage 0, invalid 0, not run 8.
The run's summary has the full report. |
No related issue: post-merge-dispatch GITHUB_TOKEN cut, measured on 4 schedule runs
Summary
pr-merge's
post-merge-dispatchjob made 83, 86, 23 and 89 GITHUB_TOKEN calls in 4 schedule runs (2026-10-28, 12:25-12:57Z). In 3 of them, the "Check earlier lane merges" step could not reuse the last report, so it ranbabysit_postmerge.py --lane-merges-onlyin full. Each of those full runs made 66-68 calls, 47 of them GraphQL.A trace of every gh call in one full run (read-only, against this repository on 2026-10-28) shows where the 47 GraphQL calls go:
read_demotion, insidedefault_floor: onePolicyDemotionRecordread per candidate issueread_demotion: issues-by-author listingsThe total, 39+2+3+3 = 47, matches
"default graphql": 47on thebabysit-gh-callsline of each of the 3 full-run job logs. The demotion record read is the cost. The merged walk and the pins are 6 calls.Fix
read_demotionreads its candidate records 20 to one aliased GraphQL query (_demotion_records,DEMOTION_BATCH). This follows the patternbabysit_postmerge.read_pinsuses for pins.DEMOTION_RECORDquery. Every outcome is therefore the per-issue read's outcome, including its error text.DEMOTION_RECORDand the batch query share one field list (DEMOTION_FIELDS).read_demotionalso serves the merge gate (assess),settle_shared's demotion-changed path andlane_room. They get the same reduction, with the same answers.Before and after:
read_demotion, 39 candidate issues (measured live)babysit_postmerge.py --lane-merges-onlyfull runpost-merge-dispatchjob when reuse failspost-merge-dispatchjob when reuse holdsVerification
test_babysit_merge_policy.py, written first. On the unchangedbabysit_merge_policy.pythe new test and all 6 equality subtests failed: 7 failed, 20 passed.ReadDemotionBatched.test_45_records_take_two_listings_and_three_batchespins the call count. 45 records take 2 listings and 3 batch queries, where the per-issue read took 47 calls.test_batched_reads_equal_per_issue_readsruns the batched read and the per-issue read (_demotion_recordsanswering nothing) over the same 30-record fixtures and asserts equalDemotionresults. It covers: all clear, a hold before an unreadable record, a truncated edit history, a batch error that falls back (it asserts the fallback reads one at a time up to the hold), an issue missing from a batch answer (one single read), and a missing issue that no single read finds either.test_the_cases_reach_their_answerschecks that those cases are not all one answer:#12 edit-history-incompleteanddemotion-unreadable: issue #30 returned nothing.demotion_fakenow answers the batch query too, sotest_role_label_removed_is_still_offkeeps its 3-query count: 2 listings and 1 batch, where before it was 2 listings and 1 single read.scripts/run-ruff.sh checkis clean, andcheck-changelog-fragments.sh --check-required origin/mainpasses.read_demotionand a batched read returned equalDemotionresults over 39 candidate issues and 15 records. With this branch's code,read_demotiontook 5 calls and returned the sameDemotion.Related
babysit_postmerge.read_pins, whose batching this follows.🤖 Generated with Claude Code