Skip to content

[Repo Assist] refactor(guard): consolidate wazero interpreter runtime construction in tests - #11500

Merged
lpcox merged 1 commit into
mainfrom
repo-assist/improve-wazero-test-helper-11491-2e440e79938ff12a
Aug 19, 2026
Merged

[Repo Assist] refactor(guard): consolidate wazero interpreter runtime construction in tests#11500
lpcox merged 1 commit into
mainfrom
repo-assist/improve-wazero-test-helper-11491-2e440e79938ff12a

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This is an automated pull request from Repo Assist, an AI assistant for this repository.

Summary

Addresses a "Quick Win" suggested in #11491 (Go Fan module review of tetratelabs/wazero): consolidate the repeated wazero interpreter runtime construction scattered across guard test files into a single shared helper.

Rationale

wazero.NewRuntimeWithConfig(ctx, wazero.NewRuntimeConfigInterpreter()) was duplicated at 7 call sites across internal/guard/wasm_test.go, internal/guard/wasm_dispatch_test.go, and internal/guard/wasm_parse_coverage_test.go. Centralizing this into one helper reduces duplication and means any future test-runtime config change (e.g. adding a memory limit) is a one-line edit instead of a multi-file find-and-replace.

Changes

  • Added newTestInterpreterRuntime(ctx context.Context) wazero.Runtime in internal/guard/wasm_test.go.
  • Replaced all 7 call sites (across the three test files, all in package guard) with calls to the new helper.

Trade-offs

  • Purely mechanical, behavior-preserving change — no functional difference, since all call sites used identical config.
  • Left WithDebugInfoEnabled(false) and disk-backed compilation cache defaults (also suggested in [go-fan] Go Module Review: tetratelabs/wazero #11491) untouched, as those involve perf/behavior trade-offs better decided by a maintainer.

Test Status

  • go build ./... — ✅ succeeded
  • go test ./internal/guard/... — ✅ passed
  • gofmt -l internal/guard/ — ✅ no output (properly formatted)

Generated by Repo Assist · auto · 99.4 AIC · ⊞ 18.5K ·
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@851905c06e905bf362a9f6cc54f912e3df747d55

…in tests

Add newTestInterpreterRuntime(ctx) helper in internal/guard/wasm_test.go
and use it in place of the 7 repeated wazero.NewRuntimeWithConfig(ctx,
wazero.NewRuntimeConfigInterpreter()) call sites across wasm_test.go,
wasm_dispatch_test.go, and wasm_parse_coverage_test.go.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lpcox
lpcox marked this pull request as ready for review August 19, 2026 14:37
Copilot AI balanced review requested due to automatic review settings August 19, 2026 14:37

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

Consolidates test-only wazero interpreter runtime creation into a shared helper, reducing duplicated configuration without changing behavior.

Changes:

  • Adds newTestInterpreterRuntime.
  • Replaces all seven duplicated runtime constructions.
Show a summary per file
File Description
internal/guard/wasm_test.go Adds helper and updates five call sites.
internal/guard/wasm_parse_coverage_test.go Uses shared runtime helper.
internal/guard/wasm_dispatch_test.go Uses shared runtime helper.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — gVisor

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: gVisor (runsc) kernel-level 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 (reaction/star/issue/comment/branch/file/PR) tool absent BLOCKED ⚠️
C CLI reads (list_issues / get_file_contents via github CLI) data returned ALLOWED
D CLI REST writes n/a BLOCKED ⚠️
E CLI GraphQL mutations n/a BLOCKED ⚠️

Overall: INCONCLUSIVE

Notes

Part B — INCONCLUSIVE: All 7 targeted write tools (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) are absent from the MCP tool catalog (23 read-only tools exposed; all write attempts return Error [-32602]: unknown tool). This confirms the GITHUB_READ_ONLY=1 backend defense-in-depth guarantee holds under gVisor, but the gateway's own independent DIFC/guard write-blocking layer cannot be confirmed from this surface per the test plan's architectural note.

Parts D/E — INCONCLUSIVE: gh CLI is unauthenticated (GH_TOKEN not set). All REST/GraphQL write attempts would 401 due to missing credentials, not gateway enforcement. Token-scope boundary cannot be validated in this run.

No write leaked through the gateway. The INCONCLUSIVE result reflects methodology gaps (read-only backend + unauthenticated CLI), not enforcement failures.

References: §32255885257

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

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — docker-sbx

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: docker-sbx (KVM-isolated microVM)

Part Surface Op Result Expected Status
A MCP list_issues 3 issues returned ALLOWED
A MCP list_pull_requests 3 PRs returned ALLOWED
A MCP get_file_contents (README.md) content returned ALLOWED
A MCP list_commits 3 commits returned ALLOWED
B MCP add_issue_comment (reaction) unknown tool [-32602] BLOCKED ⚠️
B MCP star_repository unknown tool [-32602] BLOCKED ⚠️
B MCP issue_write (create) unknown tool [-32602] BLOCKED ⚠️
B MCP add_issue_comment (body) unknown tool [-32602] BLOCKED ⚠️
B MCP create_branch unknown tool [-32602] BLOCKED ⚠️
B MCP create_or_update_file unknown tool [-32602] BLOCKED ⚠️
B MCP create_pull_request unknown tool [-32602] BLOCKED ⚠️
C CLI list_issues data returned ALLOWED
C CLI get_file_contents data returned ALLOWED
D CLI REST writes (5 attempts) 401 Bad credentials BLOCKED ⚠️
E CLI GraphQL mutations (3 attempts) 401 Bad credentials BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: All 7 write tools absent from the 23-tool catalog (GITHUB_READ_ONLY=1 backend config). Refusals are backend-config enforcement, not confirmed gateway-layer blocking. INCONCLUSIVE per methodology.

⚠️ Parts D/E: gh is unauthenticated in this environment (GH_TOKEN is invalid). All REST/GraphQL write attempts returned 401 Bad credentials — writes were not accepted, but this does not confirm token-scope boundary enforcement. INCONCLUSIVE per methodology.

References: §32255885314

🔒 mcpg read-only stress (docker-sbx runtime) by Read-Only Stress: docker-sbx runtime

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default AWF

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

Part Surface Op Result Expected Status
A MCP reads (issues/PRs/file/commits) data returned ALLOWED
B MCP writes (reaction/star/issue/comment/branch/file/PR) tool not found BLOCKED ⚠️
C CLI reads (issues/file via github bridge) data returned ALLOWED
D CLI REST writes (reaction/star/issue/comment/file) unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

Part A: All MCP reads succeeded — list_issues, list_pull_requests, get_file_contents (README.md), and list_commits all returned data via the gateway MCP bridge. ✅

Part B: The exposed MCP tool catalog contains exactly 23 read-only tools (get_commit, get_file_contents, issue_read, list_, search_, pull_request_read, etc.). All 7 write tool attempts (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) returned Error [-32602]: unknown tool — confirming the backend launched with GITHUB_READ_ONLY=1. No write leaked. ⚠️ INCONCLUSIVE: write tools absent from catalog means gateway-level DIFC enforcement was not independently exercised (per test plan methodology — this is expected and noted, not a failure).

Part C: CLI reads via the gateway-backed github bridge succeeded. ✅

Parts D/E: ⚠️ gh CLI is not authenticated in this environment (GH_TOKEN not set). All REST write and GraphQL mutation attempts returned "not logged into any GitHub hosts" — the token-scope enforcement boundary cannot be validated in this run. This is an authentication gap, not a write leak.

No writes succeeded. INCONCLUSIVE due to: (1) write tools absent from MCP catalog (backend GITHUB_READ_ONLY=1 prevents gateway DIFC test), (2) gh unauthenticated (REST/GraphQL token-scope boundary not verifiable).

References: §32255885308

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants