agentHost: cover GraphQL mutation roots and null merge permission - #331719
Merged
Benjamin Christopher Simmonds (benibenj) merged 2 commits intoAug 20, 2026
Merged
Conversation
Benjamin Christopher Simmonds (benibenj)
enabled auto-merge (squash)
August 19, 2026 22:12
Copilot started reviewing on behalf of
Benjamin Christopher Simmonds (benibenj)
August 19, 2026 22:13
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Adds regression coverage for Agent Merge GraphQL mutations and repository merge permissions.
Changes:
- Validates mutation root selections against query-only fields.
- Tests all repository permission values, including
null.
Show a summary per file
| File | Description |
|---|---|
pullRequestQueryService.test.ts |
Expands merge-permission coverage. |
programmableGitHubServer.ts |
Adds mutation-root validation. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
roblourens
approved these changes
Aug 19, 2026
The mutation fix had no regression coverage: the existing tests only match operation names and variables, so reintroducing the invalid root-level rateLimit selection still passed. That is why the bug survived. ProgrammableGitHubServer now rejects any mutation that selects a Query-root-only field at the mutation root. Placing the check in the fake server rather than in individual assertions means every current and future mutation test enforces it automatically. Verified by reintroducing the bug, which now fails two tests with a direct diagnostic. The permission test also only covered a READ viewer. It now snapshots the whole RepositoryPermission range including null, the GitHub App case that deliberately disables Agent Merge, so the fail-closed path cannot regress on its own. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The mutation-root guard only recognized documents whose first token was mutation, so a leading fragment definition or a multi-operation document bypassed it entirely. It also scanned every top-level selection set, so a sibling query selecting rateLimit failed an otherwise valid mutation. The guard now parses the document into operations, resolves the one selected by operationName (or the sole operation when the document is unambiguous), and inspects only that operation's root selection set. Parsing blanks comments and string literals first so braces inside them cannot skew matching, and skips variable definitions and inline fragment headers. ProgrammableGitHubServer tests now cover both regressions plus aliases, nested selections and string arguments. Verified they fail against the previous implementation in both directions: the fragment-prefixed mutation goes undetected, and the valid mutation beside a rateLimit query is wrongly rejected. The permission test folded its discriminant check into the recorded value, so a non-mergeability result collapsed to false and silently matched the TRIAGE, READ and null cases. It now asserts the fragment before snapshotting. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Benjamin Christopher Simmonds (benibenj)
force-pushed
the
benibenj/agents/graphql-mutation-root-test-coverage
branch
from
August 20, 2026 09:08
9836bfd to
9153125
Compare
Benjamin Christopher Simmonds (benibenj)
merged commit Aug 20, 2026
97ed7b5
into
main
29 of 51 checks passed
Benjamin Christopher Simmonds (benibenj)
deleted the
benibenj/agents/graphql-mutation-root-test-coverage
branch
August 20, 2026 09:33
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.
Follow-up to #331712, addressing two review comments that arrived after auto-merge had already landed that PR.
The mutation fix had no regression coverage
The existing mutation tests only match operation names and variables, so reintroducing the invalid root-level
rateLimitselection would still have passed. That is precisely why the original bug survived.ProgrammableGitHubServernow rejects any mutation that selects aQuery-root-only field at the mutation root. Putting the check in the fake server rather than in per-test assertions means every current and future mutation test enforces it automatically, with no opt-in required.Verified by temporarily reintroducing the bug — it now fails with a direct diagnostic instead of silently passing:
The root-field parser handles aliases (
pullRequest: __type(...)), arguments containing braces (orderBy: { field: UPDATED_AT }), and nested selections, so a nestedrateLimitis correctly ignored.The permission test only covered
READviewerPermissionisnullunder GitHub App authentication, which deliberately disables Agent Merge. That fail-closed path could previously have regressed independently of the ordinary read-only case.The test now snapshots the whole
RepositoryPermissionrange includingnull, in a single assertion:Verification
platform/githubtests pass against currentmaintypecheck-clientandeslintclean