Skip to content

Verify test-quarantine Source B PRs via batched GraphQL - #67115

Merged
wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-graphql-pr-verify
Jun 10, 2026
Merged

wtgodbe merged 2 commits into
dotnet:mainfrom
wtgodbe:wtgodbe/quarantine-graphql-pr-verify

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jun 10, 2026

Copy link
Copy Markdown
Member

Follow-up to #67085. The daily test-quarantine workflow keeps tripping the 25M effective-tokens rail. In the most recent failure the dominant cost was Source B's PR verification: the agent made ~71 sequential pull_request_read MCP calls (one per unique PR) to check base branch and merged status. Because every inference turn re-sends the whole conversation, that per-PR loop dominates token usage — and CI flakiness inflates the unique-PR count.

Prompt-only change to .github/workflows/test-quarantine.md (runtime-imported, so no lockfile recompile):

  • B4 prefilter first — discard PRs with no failed/partiallySucceeded build (using Azure DevOps data already in hand) before any GitHub call. Correctness-preserving (such PRs can never qualify) and shrinks the set to verify from dozens to a handful.
  • Batched GraphQL verification — replace the per-PR MCP loop with a verify_prs helper that verifies B2/B3 for ~50 PRs per single GraphQL request (~71 turns → ~1–2). baseRefName/merged/headRefOid map to REST base.ref/merged/head.sha; headRefOid feeds the B1 SHA match.
  • Fail-closed / fail-loud — exclude any PR that can't be positively verified; abort visibly on systemic failure (missing token, 401/403, primary rate-limit, or every request failing) so the run never silently reports a false "no failures." Handles GraphQL partial errors and null nodes.
  • Aggregate-only output — print only the per-test failure table; raw JSON goes to a file.

The verify_prs helper was validated offline against 8 scenarios (happy path, partial errors, and every fail-loud/fail-closed branch). GITHUB_TOKEN is available to the agent and api.github.com is firewall-allowed.

The daily test-quarantine workflow keeps tripping the 25M effective-tokens
rail. The dominant cost in the 2026-06-09 failure was Source B's PR
verification: the agent made 71 sequential pull_request_read MCP calls (one
per unique PR) to check base branch and merged status. Because every turn
re-sends the whole conversation, that per-PR loop dominates token usage,
especially when CI flakiness inflates the unique-PR count.

Rework Source B (prompt-only, runtime-imported — no lockfile recompile):

- Apply the B4 failed-build filter BEFORE any GitHub call, using Azure DevOps
  build data already in hand. A PR with no failed/partial build can never
  qualify, so this correctness-preserving prefilter shrinks the set to verify
  from dozens to a handful.
- Verify B2/B3 for the surviving PRs with a single batched GraphQL request per
  ~50 PRs (verify_prs helper) instead of one MCP call per PR, collapsing ~71
  turns into ~1-2. baseRefName/merged/headRefOid map to REST base.ref/merged/
  head.sha; headRefOid feeds the B1 SHA match.
- The helper is fail-closed (exclude any PR it cannot positively verify) and
  fail-loud on systemic failures (missing token, 401/403, primary rate-limit,
  or every request failing) so the run aborts visibly rather than silently
  reporting a false 'no failures'. Handles GraphQL partial errors and nulls.
- Print only the aggregated per-test table; never surface raw JSON.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 10, 2026 04:44
@wtgodbe
wtgodbe requested a review from a team as a code owner June 10, 2026 04:44
@github-actions github-actions Bot added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Jun 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the test-quarantine workflow instructions to reduce effective-token usage and CI flakiness impact by eliminating per-PR pull_request_read loops for Source B, replacing them with prefiltering plus batched GitHub GraphQL verification.

Changes:

  • Prefilter Source B PR candidates using Azure DevOps build results (failed/partiallySucceeded) before any GitHub verification.
  • Replace per-PR verification with a batched GraphQL approach and document fail-closed / fail-loud behavior.
  • Add a verify_prs Python helper example in the API Reference section.

Comment thread .github/workflows/test-quarantine.md Outdated
Comment on lines +635 to +639
path = err.get("path") or []
if path and isinstance(path[-1], str) and path[-1].startswith("p"):
errored.add(path[-1])
else:
chunk_untrusted = True

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in 9938ed6. Now scans the whole error path for the first element matching the alias pattern p{n} (so field errors like ["repository","p123","merged"] exclude only that PR), and only treats a path with no alias as chunk-untrusted. Verified with an added unit-test scenario: a field-level error on one PR in a chunk now keeps the other PRs in that chunk.

GraphQL field errors put the alias in the middle of the error path
(e.g. ["repository","p123","merged"]), so checking only path[-1] marked
the whole chunk untrusted and over-excluded valid PRs. Scan the path for the
first element matching the alias pattern p{n} and exclude just that PR.

Co-authored-by: Copilot <[email protected]>
@wtgodbe
wtgodbe merged commit 016ea32 into dotnet:main Jun 10, 2026
10 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants