Conversation
Covers the previously-untested branch where both the previous compilation cache Close() and the replacement cache Close() fail, verifying errors.Join wraps both errors and the global cache state is left unchanged. Introduces a minimal newCompilationCacheFn indirection to allow test injection of a failing replacement cache. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds targeted coverage for dual cache-close failures in WASM cache replacement.
Changes:
- Adds an injectable cache factory for testing.
- Tests cleanup, retained global state, and combined errors.
Show a summary per file
| File | Description |
|---|---|
internal/guard/wasm_lifecycle.go |
Adds the test seam. |
internal/guard/wasm_test.go |
Covers dual close failures. |
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: 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>
🔒 mcpg Read-Only Stress — default AWFSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE Notes:
Run: §32587684434
|
🔒 mcpg Read-Only Stress — docker-sbxSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked. Run is INCONCLUSIVE (not FAIL). References:
|
🔒 mcpg Read-Only Stress — gVisorSurface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Overall: INCONCLUSIVE
No writes leaked in any part. Zero sentinel issues/branches/comments created. References: §32587684415
|
Test Coverage Improvement: ConfigureGlobalCompilationCache
Function Analyzed
internal/guardConfigureGlobalCompilationCacheWhy This Function?
ConfigureGlobalCompilationCachereplaces the process-level wazero WASM compilation cache and is security/reliability critical: it must correctly release the previous cache and roll back cleanly on failure. While the function was already well tested (95.2%), one branch was completely uncovered: the case where both the previous cache'sClose()and the newly-created replacement cache'sClose()fail. This path useserrors.Jointo combine both errors and must leave the global cache state pointing at the (still-open) previous cache. This is exactly the kind of tricky double-failure error-handling logic that's easy to get wrong and valuable to lock in with a test.Implementation Note
newCompilationCacheis called internally and there was no existing way to inject a cache whoseClose()fails for the replacement cache (only the previous cache could be swapped directly via the existingglobalCompilationCachepackage variable in tests). I added a minimal, behavior-preserving test seam: a package-level function variablenewCompilationCacheFnthat defaults tonewCompilationCacheand is only reassigned in tests. Production code path is unchanged.Tests Added
joins errors when both previous and replacement cache close failinTestWasmGuardCompilationCache(table-drivent.Runstyle consistent with existing tests in the file)errors.Joinoutput contains both underlying error messagesClose()invokedCoverage Report
Test Execution
All tests pass:
go vet ./internal/guard/...andgofmt -l internal/guard/both clean.Generated by Test Coverage Improver
Next run will target the next most complex under-tested function