GeezerVison is showing github.com — feat(mcpx): WASM tool-source spike — wazero host, capability test (#1970) by dezren39 · Pull Request #2002 · developing-today/code
Conversation
dezren39
commented
Oct 28, 2026
•
edited by blacksmith-sh
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Spike for #1970 (queue task 2907): Approach B — a core-WASM .wasm module as an mcpx tool source, hosted by wazero.
What this adds
pkgs/mcpx/internal/wasmtools: a standalone wazero host for a core-WASM tool source. It instantiates no WASI at all, so a guest gets no filesystem, network, clock, or environment by default; the only imports that can exist are host grants (today: mcpx.log). Any ungranted import — WASI included — fails instantiation: deny-by-default is a property of the loader.
- Guest ABI mirrors
mcpclient.Client (ListTools / CallTool shapes in internal/mcpclient/client.go), shaped so a component-model ABI can replace it underneath later (Approach C).
- Test guests (Zig sources + prebuilt
.wasm in testdata/): echo (lists/calls one tool, logs via the granted import) and greedy (imports mcpx.read_file, which the host never offers).
Interface gap (per the spike brief)
There is no registration point yet for a new tool-source kind: upstreams are concrete transports in internal/mcpclient and internal/adapter, and the tool-source interface is still tracked by #1885. So this package is deliberately a standalone spike, not a parallel/fifth composition path. Wiring it in waits for #1885's interface; the ABI above is designed to sit behind it unchanged.
Capability test (acceptance)
TestListAndCallWithGrantedLog — granted log import works; tool list + call round-trip.
TestSameModuleWithoutGrantIsDenied — same module without the grant fails to instantiate.
TestUngrantedCapabilityImportIsDenied — greedy.wasm is denied even with every grantable capability granted; the error names the missing read_file import.
Verified on the laptop worktree: go test -count=1 ./internal/wasmtools/ — PASS.
Constraints
- Pure Go: no cgo introduced (wazero only, already in-tree for embeddings).
- Existing JS-runtime script behaviour and process/HTTP tool sources unchanged — this adds one new internal package only.
Gating research answer
Posted on #1970: wazero does not host Component Model components at acceptable maturity today (component support is still under active development upstream); the mature component host is wasmtime, whose Go bindings require cgo — which would forfeit the pure-Go premise. Recommendation: proceed with B on core WASM now; defer C until wazero component hosting matures or a pure-Go lowering path lands.
Refs #1970, #1885
![Autofix with [code]smith](/api/image?u=https%3A%2F%2Fcamo.githubusercontent.com%2F33b6f70f3541c4e93f4503d29cbfec051fa1b040d8e0ae9313a51c4ece44a627%2F68747470733a2f2f70722d636f6d6d656e74732d6173736574732e626c61636b736d6974682e73682f636f6465736d6974682f6175746f6669782d776974682d636f6465736d6974682d6461726b2d33782e706e67)
Need help on this PR? Tag @codesmith-bot with what you need.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Warning
Review limit reached
You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.
Next included review available in 34 minutes.
Check out review usage here.
View limit details
-
Limit details: You’ve used the included review currently available.
Learn how review limits work.
Review configuration:
Run configuration
-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
0207bd8a-5b2d-4be9-9b89-db14fc431ca0
Commits
-
Reviewing files that changed from the base of the PR and between 77918e0 and 019ee02.
Files ignored due to path filters: 2
-
pkgs/mcpx/internal/wasmtools/testdata/echo.wasm is excluded by !**/*.wasm
pkgs/mcpx/internal/wasmtools/testdata/greedy.wasm is excluded by !**/*.wasm
Files selected for processing: 4
-
pkgs/mcpx/internal/wasmtools/testdata/guest/echo.zig
pkgs/mcpx/internal/wasmtools/testdata/guest/greedy.zig
pkgs/mcpx/internal/wasmtools/wasmtools.go
pkgs/mcpx/internal/wasmtools/wasmtools_test.go
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
-
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Codex Review Summary
This comment shows the latest Codex review activity on this pull request.
| Review |
Status |
Commit |
Review trigger |
| 📝 Code Review |
✅ Completed 2026-10-28T23:46:56.314809Z |
019ee02 |
PR opened |
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 019ee02b90
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+98
to
+102
|
|
for _, fn := range []string{inputPtrFn, outputPtrFn, listFn, callFn} {
|
|
|
if mod.ExportedFunction(fn) == nil {
|
|
|
rt.Close(ctx)
|
|
|
return nil, fmt.Errorf("wasmtools: guest does not export %s", fn)
|
|
|
}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate guest memory and function signatures during loading
If a guest exports all four required names but omits linear memory or uses an incompatible result signature, Load succeeds even though subsequent calls can panic the Go host. For example, a valid WASM module whose mcpx_list_tools returns no values reaches res[0] in ListTools, while a module without memory reaches a nil memory dereference in readOutput or CallTool. Validate the required memory and function parameter/result types before returning the source so malformed guests produce load errors rather than host panics.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
|
// grant set — WASI included — makes Load fail.
|
|
|
func Load(ctx context.Context, src []byte, grants ...string) (*Source, error) {
|
|
|
s := &Source{}
|
|
|
rt := wazero.NewRuntime(ctx)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enable context cancellation for guest execution
If a guest tool enters an infinite loop, canceling or timing out the context passed to ListTools or CallTool will not interrupt it, leaving the caller goroutine executing indefinitely. The wazero v1.9.0 runtime configuration documentation explicitly states that execution-termination checks are disabled by default, which is the configuration selected by NewRuntime here. Construct the runtime with WithCloseOnContextDone(true) so callers can actually bound guest execution through the contexts these methods accept.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Oct 29, 2026
This was referenced Nov 3, 2026
This was referenced Nov 16, 2026
This was referenced Nov 23, 2026
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|