Skip to content

perf(monitor-signals): read job lists and annotations through GraphQL - #15434

Merged
kyle-sexton merged 2 commits into
mainfrom
feat/monitor-signals-graphql-batch
Nov 11, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
feat/monitor-signals-graphql-batch

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

No related issue: GITHUB_TOKEN call cut, hub analysis 2026-11-11 (lessons L547)

session: GitHub Support

Summary

maintenance-monitor-signals.yml runs hourly and spent 201 core REST calls on its GITHUB_TOKEN in sample run 43015959548: actions/runs/{n}/jobs x114, check-runs/{n}/annotations x44, workflows/{x}/runs x19, other x24. That pool (5,000 an hour) is shared with the PR pipeline. This PR moves part of those reads to the separate GraphQL pool. It does not reach the brief's target of about 40 core calls a run; the reasons and the measured numbers are below.

Fix

The read change is in .github/scripts/maintenance-monitor-signals/collect.mjs; signals.mjs gets comment updates and the tests get a recorded fixture, recorded-annotations.json:

  • Annotations go through GraphQL wherever annotationsOf reads them. They are read with nodes(ids:) on CheckRun, 25 check runs a query, using each REST or GraphQL job's node_id. This covers the pr-merge budget, lane budget, failed runs, lane variables, main full run and every hold lane. Each source first reads its runs' jobs in its loop's own order. It stops where the loop would: at the lane budget's 10 mint jobs, or at a failed read, which the loop then meets at the same run without a second call. It then reads the picked jobs' annotations in batches, and the loop runs as before. A job carried from the last run has no node_id, so its annotations stay on REST.
  • Job lists go through GraphQL only for sources that read no step. These are the pr-merge budget, Actions jobs in use, failed runs, and the hold lanes without a holdStep: work-resolve-issue, work-unblock, pr-refine, intake-triage and pr-merge. They are read with nodes(ids:) on WorkflowRun -> checkSuite.checkRuns(first: 30, filterBy: {checkType: ALL}), 25 runs a query, without steps. The result is shaped as the REST list: sorted by id ascending (GraphQL answers newest first), with lower-case status and conclusion. These lists live in their own memo. A source that reads steps never gets one, and none is carried in monitor-signals-jobs, so the carry file can be smaller while signal output stays the same.
  • Steps stay on REST. That keeps REST jobs reads for the lane budget mint check, lane variables, merge groups, and pr-verify's and pr-review-main's Note the hold filter. These were measured through ghx on this repository's runs. A GraphQL read with steps(first: 100) returned HTTP 502 after about 10.6 s on every cold batch tried: 25, 10 and 5 runs, and 10 check runs queried directly. Two other reads answered quickly. A check-run list without steps took 0.96 s for 25 cold runs, at cost 1. Annotations took 0.82 s for 25 cold check runs, at cost 1. This applies the brief's "keep that read on REST and say so" rule to a field that exists but cannot be read at batch scale.
  • Fallback. A node falls back to REST for that run or check run when it is null, an error's path names its index, its connection is cut short (totalCount above the nodes returned, for example over 30 check runs or over 100 annotations) or holds a null, it answers for another id, or its run is a re-run (run_attempt other than 1; REST filter=latest keeps only the last attempt). An answer with no data, a data.nodes that is not an array, an error that names no node index, or a thrown call, sends the whole batch to REST (readNodes in collect.mjs). So a gap stays a gap and never reads as "no hold".
  • Call counting is unchanged. Every GraphQL query goes through the same call("POST", "/graphql") client, so it counts against CALL_BUDGET (250) and is logged as graphql by log-api-budget, whose step stays as it is.
  • Cost comments are updated (LIMITS.laneRuns, LIMITS.holdRuns, and the HOLD_LANES cost lines in signals.mjs). The hold scan's worst case drops from 710 calls to 204, plus the 7 marker lists either way.

GraphQL fields used, confirmed in GitHub's GraphQL reference:

Verification

  • node --test over the five test files in .github/scripts/maintenance-monitor-signals/: 189 pass, 0 fail. That is 181 existing tests, unchanged and still exercising the REST path, plus 8 new ones in collect.test.mjs:
    • The adapters reproduce a recorded pair from pr-merge run 43092202279: GraphQL check runs mapped to that run's REST jobs list, and check run 130771889983's full 28 GraphQL annotations mapped to its REST annotations, in the same order (recorded-annotations.json, read live from both APIs).
    • A table of malformed answers to every nodes query returns the same collect data and sends the ids it does not answer for to REST:
      • a 200 whose error names no node, and a data.nodes that is not an array, send the whole batch;
      • fewer nodes than ids sends the missing one;
      • an error on a field inside a node sends that node.
    • Cut-short, null, another run's and re-run answers are refused.
    • A full scenario across every source returns identical collect data and detect findings with and without node ids. The GraphQL path makes 12 nodes queries and none of the 13 replaced REST reads.
    • A null node (one run and one check run) is read through REST, and only those two REST calls are added.
    • A failing GraphQL call leaves the REST calls identical.
    • A failed jobs read ends its source at that run, once.
    • A re-run is not listed through GraphQL.
  • Hand mutants (no sort, no lower-casing of job enums or of annotation level, a null list taken as empty, no attempt check, a failed read taken as empty, an error with no node index ignored, a node an error names kept) are all killed by the new tests.

Risk: readNodes catches every error a GraphQL call throws, a rate-limit latch included. When the latch also stops the REST fallback, that source fails and is recorded as a gap, the safe direction. It never reads as a false "no hold".

Estimated cost per run (hub rule R461). The per-source split of today's 114 jobs reads is UNVERIFIED, estimated from the HOLD_LANES run-rate comments. Those comments give about 21 pr-verify and 18 pr-review-main green runs an hour, which totals about 39. Add up to 10 lane-budget runs and about 2 for merge groups, main and audits, and about 51 jobs reads stay on REST. The other ~63 move to GraphQL lists, and the 44 annotation reads move to GraphQL.

  • REST core: 19 run lists + 24 other + ~51 jobs reads + ~1 carried-job annotation read = ~95 a run, down from 201.
  • GraphQL: list queries (pr-merge budget 1, in-progress 1-2, failed runs 0-1, five hold lanes up to 5) plus annotation queries (pr-merge budget 1, lane budget 1, failed runs 0-1, main 0-1, seven hold lanes up to 7) = ~13-19 queries a run. Each costs about 1 point; the 25-node probes measured cost 1.
  • The first scheduled runs after merge measure the real numbers through the job's api-budget and api-calls notices.

Related

  • The about-40 target needs pr-verify's and pr-review-main's ~39 REST jobs reads gone. That would mean reading every green hold job's annotations without the holdStep (Note the hold) filter. This PR does not do that, because it could change output: an annotation in a job whose Note the hold did not succeed would then count. For pr-verify, the step's if: (pr-verify.yml:232) matches the conditions of both notices its HOLD_NOTICES entry parses. pr-review-main's notice comes from its select steps and needs its own check.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQb9Q1HHi6JACp77x2ZbE7

kyle-sexton and others added 2 commits November 11, 2026 16:00
The monitoring lane spent about 201 core calls a run on GITHUB_TOKEN, most
of them one REST read per run's jobs and per check run's annotations.

Annotations now come from GraphQL nodes(ids:), 25 check runs a query, for
every source that reads them. Job lists come from GraphQL, 25 runs a query
and without steps, for the sources that read no step: the pr-merge budget,
Actions jobs in use, failed runs, and the hold lanes without a holdStep.
Sources that read steps (lane budget, lane variables, merge groups, and
pr-verify and pr-review-main's Note the hold) keep REST job reads, since a
GraphQL read of 5 runs' steps timed out at 10 s. A GraphQL list is never
carried. A node that is null, named by an error, cut short, another run's
or a re-run's is read through REST, so every signal reads the same data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q1HHi6JACp77x2ZbE7
…ormed answers

The annotation reader is now checked against check run 130771889983's
full 28 annotations, as REST and GraphQL each answered them, kept in
recorded-annotations.json. A table test drives collect with four
malformed GraphQL answers (an error naming no node, data.nodes not an
array, fewer nodes than ids, an error on a field inside a node) and
asserts the ids left unanswered go to REST with the same signal data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VQb9Q1HHi6JACp77x2ZbE7
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 11, 2026 21:24
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T21:26:35.502530Z 02a2360 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed 02a23606331f7e76c5d3e93acc8448aa466e958f: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #15434 (head 02a23606)

I found no security issues.

I read every hunk of all 4 changed files: collect.mjs, collect.test.mjs, recorded-annotations.json and signals.mjs under .github/scripts/maintenance-monitor-signals/. None of them is on the trusted-path list. They are not a trust control, merge hold, token request, kill switch or plugin manifest, so no manifest lines apply. This is the lane's first review of the PR, so it was not blocking only.

What I checked:

  • Injection in the GraphQL queries. None. RUN_CHECK_RUNS and CHECK_RUN_ANNOTATIONS (collect.mjs#L51-L52) are fixed strings. The only value interpolated into them is the constant CHECK_RUNS_PAGE = 30. The node ids come from the REST answers and are passed as the $ids variable, never spliced into the query text.
  • Answers credited to the wrong run or job. Blocked. restJobs and restAnnotations (collect.mjs#L79-L90) check the following, and fall back to REST otherwise:
    • the node's databaseId matches the expected run or job id;
    • runAttempt === 1;
    • the connection is complete (totalCount equals the number of nodes, with no null nodes).
  • Run selection is unchanged. The filters that decide which runs are read still run before any GraphQL call: trustedPrMerge, ownHead, defaultBranchCode and completedInWindow. So GraphQL brings no new untrusted runs into the read set. The annotations read are the same check runs' annotations REST returned, parsed by the same parseHold, budgetReading and levelAndMessage.
  • A failure cannot read as "no hold". readNodes (collect.mjs#L55-L72) leaves every unanswered or errored id null, and those go back to REST. In prefetch, a failed jobs read is thrown again at the same run, so it is still recorded as a gap. Nothing here can turn a missing answer into "no hold", so no hold signal is weakened.
  • Token use is unchanged. The new queries go through the existing graphql / call client on the same token. The PR adds no new permission or secret.
  • The recorded test file is harmless. recorded-annotations.json holds only rate-limit and budget numbers from existing annotations. It contains no tokens or secrets.

Spend (not a finding): each hourly run makes about 13–19 extra GraphQL queries on GITHUB_TOKEN and about 106 fewer core REST calls. That is rate-limit budget only, with no billing impact.

I found no instructions embedded in the PR context.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed 02a23606331f7e76c5d3e93acc8448aa466e958f: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #15434, perf(monitor-signals): read job lists and annotations through GraphQL

This is a complete review. I read every hunk of all 4 changed files: collect.mjs, collect.test.mjs, recorded-annotations.json and signals.mjs. I also read the unchanged code the new lines call: jobsOf, annotationsOf, the carry logic, the hold-lane loop, levelAndMessage, budgetReading and parseHold, plus the test input helper. This is the first review of the PR (blocking only: no), and there are no prior findings.

No blocking or advisory findings. What I checked:

  • Shape of GraphQL answers. restJobs lower-cases status and conclusion. The GraphQL enum values CheckStatusState and CheckConclusionState lower-case to the same strings REST uses, including startup_failure and timed_out. It sorts by id ascending and refuses:

    • a re-run (it compares the node's own runAttempt with 1, not the listed attempt, so a re-run started after the listing is caught too);
    • a node for a different run;
    • a cut-short connection, an empty one, or one that holds a null.

    restAnnotations returns only annotation_level, title and message, which are the only fields levelAndMessage, budgetReading and parseHold read. A check run with over 100 annotations goes to REST, which reads the same first 100 as before.

  • readNodes error handling. An error with no node index, a data.nodes that is not an array, or a thrown call sends the whole batch to REST. An error that names a node sends only that node. If a batch returns extra nodes, they can spill into the next batch's slots, but the databaseId match in restJobs and restAnnotations refuses them. Either way, a gap stays a gap and never reads as "no hold".

  • prefetch keeps the old loop behaviour. The lane budget stops at laneMintJobs exactly where the loop did. A failed jobs read is thrown again at the same run without a second call. The only difference: when an annotation read fails, more jobs reads may already have been made, because job lists are now read before annotations. That changes call counts only, not output.

  • Steps and carry. Only jobListOf, used by sources that read no step, ever returns a step-less GraphQL list. jobsOf users (lane budget, lane variables, merge groups, and pr-verify's and pr-review-main's holdStep filter) still read REST. carriedHit keeps carried reads ahead of GraphQL. Carrying a run cached by run id across sources had the same staleness before this change.

  • Cost comments. I re-derived the hold scan's worst case of 204 calls: 26 list pages, 150 REST jobs reads, 9 list queries and 19 annotation queries. It matches the comment in collect.mjs.

The PR's verification (189 tests passing, mutants killed, the live recorded pair) is the author's claim; I had no shell, so I did not run the tests. No closing issue is linked ("No related issue"), so there are no acceptance criteria to check. No .claude/rules file mentions these paths. No plugin manifest is changed. There is no embedded instruction text in the PR context.

Spend: about 13–19 GraphQL nodes queries per hourly run on the GITHUB_TOKEN GraphQL rate limit, in place of roughly 100 core REST calls. This is a rate limit, not a billed charge, so it is not a hold.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 11, 2026
Merged via the queue into main with commit b6fe438 Nov 11, 2026
91 checks passed
@kyle-sexton
kyle-sexton deleted the feat/monitor-signals-graphql-batch branch November 11, 2026 21:47
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Post-merge mutation testing

Killed 6, survived 1, timeout 0, no coverage 0, invalid 0, not run 0.
Covered-code score 86%; mutation score 86%.

File Killed Survived Timeout No coverage Invalid Not run
.github/scripts/maintenance-monitor-signals/collect.mjs 6 1 0 0 0 0

Surviving mutants

Location Operator Disposition Cause
.github/scripts/maintenance-monitor-signals/collect.mjs:334 ROR productive no-assertion

The run's summary has the full report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant