Consolidate wazero guard runtime/module config and disable DWARF debug info by default - #11505
Conversation
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Consolidates wazero guard configuration to reduce drift and disable unnecessary DWARF processing by default.
Changes:
- Centralizes production runtime, module, and cache configuration.
- Adds shared WASM test helpers.
- Adds coverage for module naming and cache-selection paths.
Show a summary per file
| File | Description |
|---|---|
internal/guard/wasm_lifecycle.go |
Centralizes wazero configuration and synchronizes cache reads. |
internal/guard/wasm_testruntime_test.go |
Adds shared test runtime helpers. |
internal/guard/wasm_config_test.go |
Tests runtime and module configuration. |
internal/guard/wasm_test.go |
Adopts shared test helpers. |
internal/guard/wasm_dispatch_test.go |
Reuses centralized guard setup. |
internal/guard/wasm_parse_coverage_test.go |
Reuses centralized guard setup. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 6/6 changed files
- Comments generated: 1
- Review effort level: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Resolved the merge conflicts and pushed merge commit |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Fixed in 3fed... — the The |
🔒 mcpg Read-Only Stress — defaultSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. No FAIL conditions observed. References: §32268247381
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes succeeded. No data was created, modified, or leaked.
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Gaps:
No writes succeeded. All reads returned data.
|
The wazero module review flagged duplicated runtime/module construction across production and test code, and suggested disabling DWARF debug info for the production guard compiler since guard binaries are untrusted artifacts whose stack traces are never symbolicated.
Production (
internal/guard/wasm_lifecycle.go)newGuardRuntimeConfig(opts): compiler engine,WithCloseOnContextDone(true),WithMemoryLimitPages(guardMemoryLimitPages)(named constant replacing the inline512), and the three-way compilation-cache selection (opt-out / injected / global).WithDebugInfoEnabled(logWasm.Enabled())), so DWARF parsing cost is skipped in production while remaining available underDEBUG=guard:wasm.newGuardModuleConfig(name, stdout, stderr)so theWithStartFunctions()suppression and stdin/stdout isolation guarantees are defined once.getGlobalCompilationCache(), which reads the process-global cache under the existing mutex. Previously the cache was read unlocked whileConfigureGlobalCompilationCache/CloseGlobalCompilationCachecould concurrently swap it.Tests
wasm_testruntime_test.goprovidesnewTestWasmRuntime,newTestWasmModuleConfig,instantiateTestWasmModule, andsetupTestWasmGuard. The near-identicalsetupRawWasmModule/setupWasmGuardhelpers and the inline interpreter constructions inwasm_test.gonow route through them, removing the test/production config drift risk called out in the review.wasm_config_test.gocovers module-name defaulting (""→"guard") and instantiation through each cache-selection path of the runtime config builder.Disk-backed caching (recommendation 3) is left as-is: it is already opt-in via
MCP_GATEWAY_WASM_CACHE_DIR/ConfigureGlobalCompilationCache, and changing the default is a deployment-policy decision rather than a code fix.