Repository navigation
perf(pr-merge): attribute enable-auto-merge's API calls per step - #11151
Conversation
The rate guard's recordReading also tallies, per process, the readings it appends for the job-end api-calls notice, classified as api_budget_emit_calls classifies the file. A process whose step sets API_BUDGET_SCRIPT ends with `::notice title=api-calls::script=<name> github-token=N lanes-app=N not-modified=M graphql=K`. enable-auto-merge's eight counting steps name themselves. No request, output file or hold changes. 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-review needs no new review of No findings. I read the diff, the PR context and the surrounding What I checked
Spend: none. The change adds one log line per named step and makes no extra API calls. Minor, not counted as a finding: the exit-time |
|
claude-security-review needs no new review of No security issues found. I read the full diff and the PR description, and checked the
critical-findings: 0 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f12c42810b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
No related issue: §9 attribution for enable-auto-merge GITHUB_TOKEN spend
Summary
Three enable-auto-merge jobs (runs 40983386272, 40986033944 and 40987581101) logged 337
github-tokencalls in their job-end api-calls notices.babysit_verify_evidence.py'sbabysit-gh-callslines account for 113 of them. Nothing logs where the other 224 (about 75 perjob) go. This PR makes each Node step in the job print its own share. It only measures: the job
sends the same requests, writes the same outputs and keeps the same holds.
Fix
.github/actions/log-api-budget/rate-guard.mjs:recordReadingis the one place every Nodeclient's reading lands (
countRequests, everylatch.guard). It now also keeps a per-processtally of the lines it appends, counted the way
api_budget_emit_callscounts the file:graphqlresource counts as graphql.When
API_BUDGET_SCRIPTnames the step (lower-case kebab case), the process ends with one line,written at exit:
::notice title=api-calls::script=<name> github-token=N lanes-app=N not-modified=M graphql=K.Without that variable nothing prints, so no other workflow's output changes.
.github/workflows/pr-merge.yml: each of the enable-auto-merge job's eight steps that countcalls (
API_BUDGET_TOKEN) now setsAPI_BUDGET_SCRIPT. They arewho,superseded,head-ref-map,listing-carry,carry-run-cache,verify-answers,lane-recordsandenable-auto-merge. The twocarry-run-cache.mjsruns that make no GitHub call are leftunnamed.
api-budget.bash,api_budget_emit_callsand the log-api-budget action are unchanged.pr-require-checks.ymlembedsapi-budget.bashverbatim, so it is left alone.Metrics
The next measurement reads these lines from the enable-auto-merge job log:
::notice title=api-calls::script=<name> github-token=N lanes-app=N not-modified=M graphql=K:one per named step.
enable-auto-mergecovers the arm step's own Node clients, meaning the PRlisting, skip-state, detail and arm queries on the lane token, plus the verifier client on the
job token.
babysit-gh-calls {...}: the Python child processes' calls. These are not in anyscript=line.
::notice title=api-calls::github-token=N ...and::notice title=api-calls::lanes-app=N ...:the job totals, unchanged.
Check: the
script=lines'github-tokenvalues plus thebabysit-gh-callstotals should addup to the job-end
github-tokenvalue. A job-total reader must matchapi-calls::github-token=, not a baregithub-token=, because thescript=lines share theapi-callstitle. No parser in this repository, or found by an org code search, reads thesenotices.
Not counted anywhere, before or after this PR:
rotation.mjsghDownload(gh run downloadthrough
execFileSync). Its artifact downloads on the Actions token never reach the readings file.Verification
node --test .github/actions/log-api-budget/*.test.mjs: 144 of 144 pass. Before: 142 tests onorigin/main. The 2 new tests are incount-requests.test.mjs:read on a second token. It must print exactly
script=who github-token=3 lanes-app=1 not-modified=1 graphql=1. The job-end lines over thesame files must agree (
github-token=3 not-modified=1 graphql=1,lanes-app=1).Who,who::xor an empty string, printnothing.
node --test .github/scripts/pr-merge/*.test.mjs: 727 of 727 pass (726 before).whoandsupersededsteps from the YAML. It nowasserts
script=who github-token=1andscript=superseded github-token=2forenable-auto-merge, which add up to the job-end
github-token=3it already pins. It asserts noscript=line for the merge job.share one.
node --test .github/actions/check-trusted-trigger/*.test.mjs: 365 of 365 pass.scriptCalls.countcommented out, both value tests fail. They pass againonce it is restored.
actionlint .github/workflows/pr-merge.ymlandzizmor --offlinereport no findings.scripts/check-changelog-fragments.sh --checkpasses.Related
🤖 Generated with Claude Code