[Repo Assist] refactor(guard): consolidate wazero interpreter runtime construction in tests - #11500
Conversation
…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>
There was a problem hiding this comment.
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
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE NotesPart B — INCONCLUSIVE: All 7 targeted write tools ( Parts D/E — INCONCLUSIVE: 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 — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
References: §32255885314
|
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Part A: All MCP reads succeeded — 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 ( Part C: CLI reads via the gateway-backed Parts D/E: No writes succeeded. INCONCLUSIVE due to: (1) write tools absent from MCP catalog (backend GITHUB_READ_ONLY=1 prevents gateway DIFC test), (2) References: §32255885308
|
🤖 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 acrossinternal/guard/wasm_test.go,internal/guard/wasm_dispatch_test.go, andinternal/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
newTestInterpreterRuntime(ctx context.Context) wazero.Runtimeininternal/guard/wasm_test.go.guard) with calls to the new helper.Trade-offs
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 ./...— ✅ succeededgo test ./internal/guard/...— ✅ passedgofmt -l internal/guard/— ✅ no output (properly formatted)Add this agentic workflow to your repo
To install this agentic workflow, run