Skip to content

[test] Add tests for guard.tryCallWasmFunction - #17192

Merged
lpcox merged 1 commit into
mainfrom
coverage/try-call-wasm-function-2f87b5efd72647ee
Nov 23, 2026
Merged

lpcox merged 1 commit into
mainfrom
coverage/try-call-wasm-function-2f87b5efd72647ee

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function analyzed

  • Package: internal/guard
  • Function: tryCallWasmFunction
  • Previous coverage: 86.0%
  • New coverage: 95.3%
  • Improvement: +9.3 percentage points
  • Complexity: High (allocator and direct-memory paths, growth handling, and multiple error branches)

Why this function

The coverage report had no substantive function below 50%; the only 0% entry was an intentionally empty logger callback. tryCallWasmFunction was the strongest meaningful target because it had materially lower coverage than most core code while coordinating WASM allocation, memory growth, input writes, and fallback behavior.

Tests added

  • Missing linear memory on the direct-memory path
  • Direct-memory growth failure when the module's maximum is one page
  • Allocator-path input write failure from an out-of-bounds allocator result
  • Direct-memory input write failure from an overflowing output-size boundary

The tests use real wazero modules and assert returned values and error messages without introducing mocks for wazero's internal memory interface.

Verification

  • go test ./internal/guard -run 'TestTryCallWasmFunction_(MissingMemory|MemoryGrowthFails|AllocatorInputWriteFails|DirectInputWriteFails)' -count=1 -v — passed
  • go test -coverprofile=... ./... — passed; overall coverage remains 97.6%
  • make agent-finished — formatting, build, Go tests, and integration tests passed; golangci-lint was unavailable and skipped by the repository Makefile
  • Rust guard tests are blocked by the runner's crates.io certificate mismatch; offline retry also confirmed serde is not cached

No production code was changed.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · routed: gpt56 xhigh · ~11 AIC · ⊞ 5K · ◷

@lpcox
lpcox marked this pull request as ready for review November 23, 2026 16:39
Copilot AI adaptive review requested due to automatic review settings November 23, 2026 16:39

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.

🟢 Approval recommended

No active review issues are reported for the added WebAssembly memory-error regression tests.

No open issues 🎉

What changed in this PR

Adds focused tests for internal/guard’s tryCallWasmFunction, strengthening coverage of WebAssembly memory-handling failures without changing production code.

Changes:

  • Adds real WASM fixtures for missing memory, memory-growth failure, and invalid allocator output.
  • Adds four tests covering direct-memory and allocator-path errors, checking returned values and error messages.
  • Reports function coverage increasing from 86.0% to 95.3%.
File Description
internal/​guard/​wasm_exec_coverage_test.go Adds WASM fixtures and four memory-error regression tests.

Review effort: Balanced (adaptive)

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

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 (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 absent from exposed tool catalog (unknown tool, -32602) BLOCKED ⚠️
C CLI reads via proxied github CLI data returned ALLOWED ✅
D CLI REST writes gh not authenticated (no GH_TOKEN) in this job BLOCKED ⚠️
E CLI GraphQL mutations gh not authenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

(⚠️ = INCONCLUSIVE - Part B targets were never exposed by the backend catalog at all (gh-aw tools.github: always sets GITHUB_READ_ONLY=1), so refusal only proves backend configuration, not mcpg own gateway-level DIFC/guard enforcement. Parts D/E could not run because gh has no GH_TOKEN in this job, so the REST/GraphQL token-scope boundary was untested this run.)

No write leaked in any part. Independent gateway-layer write enforcement is covered separately by internal/guard and internal/difc unit tests and the proxy-level read-filtering smoke test.

🔒 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