Skip to content

Reuse bounded GraphQL parses and cover Unicode rewrite offsets - #16757

Merged
lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-gqlparser-v2
Nov 18, 2026
Merged

lpcox merged 2 commits into
mainfrom
copilot/go-fan-review-gqlparser-v2

Conversation

@lpcox

@lpcox lpcox commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

The GraphQL PR guard parsed the same query up to four times, while source-preserving rewrites lacked Unicode offset coverage.

  • Parse reuse: Share a request-local AST across operation selection, routing, alias detection, and field injection. Reparse when selection changes source text, preserving offset correctness and the 100,000-token limit.
  • Regression coverage: Exercise Unicode descriptions, strings, fragments, and insertion points; verify cache invalidation and injection idempotence.
  • Performance: Add PR-path benchmarks showing ~26–35% lower latency and fewer allocations.
  • Parser contract: Document rune-based offsets and schema-validation boundaries. Retain both required lexer passes and the existing dependency pin.

@lpcox lpcox changed the title [WIP] Review Go module github.com/vektah/gqlparser/v2 usage Reuse bounded GraphQL parses and cover Unicode rewrite offsets Nov 18, 2026
@lpcox
lpcox marked this pull request as ready for review November 18, 2026 15:33
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 15:33
@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default (standard AWF container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (add_issue_comment/star_repository/issue_write/create_branch/create_or_update_file/create_pull_request) all 6 absent from 23-tool catalog BLOCKED ⚠️
C CLI reads (github list_issues, get_file_contents) data returned ALLOWED ✅
D CLI REST writes not attempted BLOCKED ⚠️
E CLI GraphQL mutations not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ gaps:

  • Part B: all 6 targeted write tools were absent from the exposed GitHub MCP catalog (backend runs with GITHUB_READ_ONLY=1 per gh-aw's tools.github: wrapper), so this only confirms backend/toolset config, not mcpg's own gateway-level DIFC/guard enforcement.
  • Part D/E: gh auth status showed not authenticated (You are not logged into any GitHub hosts), so REST/GraphQL write-rejection via token scopes could not be exercised this run.

No write leaked through any surface. No security regression evidence found.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

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.

🔵 Needs a closer look

Shared AST reuse couples operation selection, alias rejection, security routing, and guard-field injection, requiring human review of cache lifecycle, source-offset consistency, and fail-closed behavior when query text is rebuilt.

No open issues 🎉

What changed in this PR

This PR reduces repeated parsing in the proxy’s GraphQL guard and adds Unicode regression coverage, addressing issue #16696 without changing the parser dependency.

Changes:

  • Reuse request-local parses across operation selection, routing, alias checks, and field injection; reparse when query text changes.
  • Add Unicode offset, cache reuse, invalidation, and injection-idempotence tests, plus PR-path benchmarks.
  • Document parsing limits, rune-based offsets, and schema-validation boundaries.
File Description
internal/​proxy/​read_only.go Uses the shared parse cache during operation selection.
internal/​proxy/​read_only_test.go Tests Unicode preservation when selecting operations and fragments.
internal/​proxy/​handler.go Shares a request-local cache across GraphQL processing stages.
internal/​proxy/​graphql.go Adds bounded parse caching for routing and alias checks.
internal/​proxy/​graphql_rewrite.go Reuses cached parses during PR guard-field injection.
internal/​proxy/​graphql_pr_guard_test.go Adds Unicode injection tests and guard-path benchmarks.
internal/​proxy/​graphql_parse_test.go Tests cache reuse, invalidation, errors, and pipeline integration.
docs/​PROXY_MODE.md Documents parser limits, cache lifetime, and rewrite-offset requirements.

Review effort: Balanced (adaptive)

@lpcox
lpcox merged commit 9f02311 into main Nov 18, 2026
37 checks passed
@lpcox
lpcox deleted the copilot/go-fan-review-gqlparser-v2 branch November 18, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[go-fan] Go Module Review: github.com/vektah/gqlparser/v2

3 participants