Repository navigation
feat(wasm): decode WebAssembly components offline - #2406
all-black-493 wants to merge 16 commits into
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Review & Verification SummaryVerdict: LGTM (Approved) 🚀 1. Architecture & Design Alignment
2. Local Verification
|
|
@greptileai review |
[Medium impact] The PR adds component-file inspection and changes routing for component headers in existing WebAssembly workflows. Not ready to merge: exported instances still hide known function sources, and the WABT probe still ignores cancellation. Findings
Fix with agent prompt### Issue 1
src/wasm/WasmComponentRelationships.ts:77-80
`inlineExportLookup` reads the instance's immediate origin without following its export chain. Import function `f`, put it in inline instance 0 as `g`, export that instance to define instance 1, then alias `g` from instance 1 and lower it. Instance 1 has an `export` origin, so this lookup misses instance 0. The lower reports `instance-export` with `instance_import: null` instead of import `f`, losing a known source despite complete decoding.
Resolve the instance's defining index before looking up its members.
### Issue 2
src/wasm/WasmCoreModuleInterface.ts:137-140
A failure late in a core import or export section discards the entries already decoded from that section. `decodeImports` and `decodeExports` return their local arrays only after the whole section succeeds, so the catch retains none of its earlier entries. `component-name` maps have the same problem.
This loses useful names from damaged components, contrary to the promise to keep names read before a failure. The reported missing range also starts after those lost names. Append each completed entry to the retained result before reading the next one.
### Issue 3
src/wasm/WasmComponentNames.ts:undefined-22
A `component-name` subsection with an ID other than `0` or `1` is silently skipped. No failure reaches the decoder, so `names.status` remains `"decoded"` and `coverage.status` can remain `"complete"` despite unread content. Callers cannot see which bytes were skipped. Record an `unsupported` gap for the skipped subsection, as the documented coverage contract promises.
### Issue 4
src/wasm/WasmComponentRelationships.ts:247-248
`coreSource` looks up a module's decoded interface using its new export index rather than its original index. If embedded module 0 exports `run`, is re-exported as module 1, and is then instantiated, a lift from that instance reports `declared_by_module: null` despite the fully decoded interface. Lower bindings have the same problem.
This loses a useful check against the module's declared imports and exports. Follow the module's export chain before looking up its interface.
### Issue 5
src/wasm/WabtComponentRouting.ts:undefined-58
`rejectWasmComponent` passes no cancellation signal to `withArtifactRegularFile`. If the caller cancels while the header is read or a recently written Windows file settles, the probe keeps waiting and can return a component refusal instead of cancellation. The provider's final cancellation check runs only after a runtime exists, which this early route never creates.
`AGENTS.md` requires cancellation to survive reads and cleanup. Before merging, forward the caller's signal through the probe and preserve its typed cancellation rather than swallowing it.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.SummaryAdds offline WebAssembly component inspection through CLI and MCP. The latest update requires absolute paths in the shared contract and strengthens relative-path error checks.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
CLI["CLI selected path"] --> Resolve["Make caller path absolute"]
Resolve --> Input["Check shared input contract"]
MCP["MCP absolute path"] --> Input
Input --> Read["Read stable file snapshot"]
Read --> Decode["Decode component structure"]
Decode --> Trace["Trace lifts and lowers"]
Trace --> Evidence["Return Evidence with identity and coverage"]
Reviews (13) · Last reviewed commit: "fix(wasm): require an absolute component..." · Reviewed by Greptile |
Comments Outside DiffThese findings could not be posted inline.
|
|
Addressed the Greptile review in
|
|
Addressed Greptile's second review (head
|
Add inspect_wasm_component / rea inspect-wasm-component, an in-process decoder for component-model binaries (version 0xd, layer 1) pinned to component-model Binary.md at 06e3db0. It reports the file SHA-256, section ranges, typed imports and exports with name attributes, type definitions in flat declaration scopes, embedded core modules by range, SHA-256 and import/export names, instances, aliases, canonical definitions, nested components and the component-name section. Canonical lifts are traced to the core exports they wrap, and lowers to their component imports and the core imports they are bound to. Decoding is structural only: validation is never claimed, and the component and its modules are never instantiated or executed. Unsupported constructs are recorded with their ranges, decoding continues with the next section, and indices that later definitions add to the affected sorts become null. Malformed framing fails with its offset. open_binary and inspect_wasm_artifact now route component headers to the new tool instead of treating them as unknown or core binaries. Refs morluto#2350
Address review findings on component decoding: - Count start-section results in constant time instead of allocating one index-space entry per file-controlled result. - Trace canonical lifts and lowers through lookup tables built once, so tracing is linear, and fail with the output-budget resource error when more than 65,536 lower bindings would be materialized. - Keep a leading U+FEFF in length-prefixed names. - Drop every scope registered by a type that fails partway, so no partial scope with a provisional range is reported. - Route a component in inspect_wasm_artifact before any WABT configuration or command; the stable read still decides. Refs morluto#2350
Address the second review of component decoding: - Charge every decoded vector entry and section against one decode-wide budget before decoding it; past 524,288 entries the decode fails with a resource-constraint error instead of building an oversized result. - Append embedded core module imports and exports in loops, so modules with very many entries no longer overflow call arguments. - Resolve core functions re-exported through inline-export aliases to the function that defines them, so lowered functions keep their core import bindings. - Replace the fixed export-chain hop limit with a memoized walk that guards against cycles, so long valid chains keep their sources. Refs morluto#2350
Adopt the stable-read ownership pattern from b955b82 for inspect_wasm_component and the WABT component pre-check. - WasmComponentProvider reads through an ArtifactResourceScope, reports a failed descriptor release as cleanup_incomplete with the primary error, and retries that owner on close() or the next read. - WasmComponentService exposes close(); MCP binds and closes one shared instance at shutdown, and the CLI finishes through finishAnalysisCommand. - The WABT component probe moves to WabtComponentRouting and releases its handle through the provider scope instead of closing it directly. Validation: check:fast, docs:check, knip; artifactReadCleanupRetry and serverLifecycleMcp extended to the component provider and service, plus component CLI/MCP, WASM artifact MCP, target diagnostics, capture cleanup, decoder and WABT provider suites.
e1e9960 to
c103ec3
Compare
|
Rebased onto
|
- Relationship facts repeat names, so one long import name could expand multiplicatively before the post-build size check. Each lift, lower and core binding is now charged by serialized size as it is traced, against the same 8 MiB inline budget, which replaces the binding count. Both output-limit paths map to one transport resource-constraint error. - Component inline-export instances recorded no origin, so a function aliased out of one lost its import source. Core and component instances share one inline-exports origin and lookup, and tracing follows both. - An undecoded section hid every index of its sorts. Index spaces keep the known prefix; only indices defined after the gap are unknown. - Embedded core module interface and component-name failures did not reach coverage. The decoder records every gap through one function, and not_decoded entries say whether content is malformed or unsupported. Validation: check:fast, docs:check, knip, jscpd; decoder tests for each case fail on the previous source; component CLI/MCP (oversized result), schema validity, WASM artifact, routing, lifecycle and cleanup suites. Real jco components decode to identical output.
| const origin = spaces.origin(instanceSort, instance); | ||
| byInstance.set( | ||
| instance, | ||
| origin?.kind === "inline-exports" |
There was a problem hiding this comment.
Exported instances hide sources
inlineExportLookup reads the instance's immediate origin without following its export chain. Import function f, put it in inline instance 0 as g, export that instance to define instance 1, then alias g from instance 1 and lower it. Instance 1 has an export origin, so this lookup misses instance 0. The lower reports instance-export with instance_import: null instead of import f, losing a known source despite complete decoding.
Resolve the instance's defining index before looking up its members.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WasmComponentRelationships.ts
Line: 79-82
Comment:
**Exported instances hide sources**
`inlineExportLookup` reads the instance's immediate origin without following its export chain. Import function `f`, put it in inline instance 0 as `g`, export that instance to define instance 1, then alias `g` from instance 1 and lower it. Instance 1 has an `export` origin, so this lookup misses instance 0. The lower reports `instance-export` with `instance_import: null` instead of import `f`, losing a known source despite complete decoding.
Resolve the instance's defining index before looking up its members.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.| if (id === IMPORT_SECTION) | ||
| for (const entry of decodeImports(section)) imports.push(entry); | ||
| else if (id === EXPORT_SECTION) | ||
| for (const entry of decodeExports(section)) exports.push(entry); |
There was a problem hiding this comment.
Earlier decoded names disappear
A failure late in a core import or export section discards the entries already decoded from that section. decodeImports and decodeExports return their local arrays only after the whole section succeeds, so the catch retains none of its earlier entries. component-name maps have the same problem.
This loses useful names from damaged components, contrary to the promise to keep names read before a failure. The reported missing range also starts after those lost names. Append each completed entry to the retained result before reading the next one.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WasmCoreModuleInterface.ts
Line: 137-140
Comment:
**Earlier decoded names disappear**
A failure late in a core import or export section discards the entries already decoded from that section. `decodeImports` and `decodeExports` return their local arrays only after the whole section succeeds, so the catch retains none of its earlier entries. `component-name` maps have the same problem.
This loses useful names from damaged components, contrary to the promise to keep names read before a failure. The reported missing range also starts after those lost names. Append each completed entry to the retained result before reading the next one.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
Edit: new results on head f10cbea are in #2406 (comment). TL;DR: The new I tested head b2523d7 as pushed. GitHub says it conflicts with main b7dcf78. For "before", I used main b7dcf78, which has no component command. Results
The 2 skipped tests are SQLite tests that skip unless the Node SQLite object has a limits property. Node 22.23.1 skips them. The PR did not add them. Before and after, Node 24.18.0, on a 302-byte component from the PR's own fixture builder:
On head, the decode lists two imports, The stand-in scripts are mine. They print 1.0.42 and write one line per call. They are not real WABT. More head checks (Node 24.18.0)
One open finding reproduces. Greptile's open P1 says an exported instance hides where a lowered function came from. In my build of that case, head reports CI. Four lanes fail on head: web_runtime, web_source_map, the Windows lane and CI required. The Windows lane fails in a step about native inspection failure ownership. That is near this PR's read cleanup work. I did not confirm a link. Earlier pushes have no finished Windows run to compare. The latest CI run on main passes. Not run
Thanks, all-black-493, for the decoder and for fixtures built in memory. Another job ran on this box. Load average (busy tasks over 1 minute, on 24 threads) was 2.3 to 4.3. Test setupCommandsEach run sat under 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
# Conflicts: # src/application/BinaryTargetResolver.ts # src/application/CapabilityInventory.ts # src/server/createServer.ts # src/wasm/WabtArtifactProvider.test.ts
|
Merged latest
Validation:
|
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
|
TL;DR: My earlier result still holds on the new head f10cbea. The Edit: I retested on head 2ed3b71. The open finding still reproduces. New results are here. This follows my earlier result on head b2523d7. Head is now f10cbea, a merge of main by Kaoru0822. The author's note says the merge fixed four conflicts. The merge-base with today's main 9d6651e is 6fcfc5b. GitHub now reports a conflict with today's main. I did not check that myself.
Last time the seven files held 63 tests. Main's new tests came in with the merge, so the count is higher. The 2 skipped tests are the same SQLite tests as before, which Node 22.23.1 skips. Node 24.18.0, on the same 302-byte component from the PR's fixture builder:
The decode lists the import The open finding still reproduces. An open Greptile note says an exported instance hides a function's source. I built the same case as before. Head reports Speed. Three decodes took 0.99 to 1.07 s and used 325 to 327 MB at peak. The box was busier this time, with a load average of about 6, so my earlier 0.77 s is not a fair comparison. Not run
Thanks, all-black-493, for the decoder. Thanks, Kaoru0822, for the merge. The box was shared with other test jobs. Timings are not benchmarks. Test setupCommandsnpm ci && npm run build && npm run test:prepare
node scripts/run-development-tests.mjs focused src/wasm/WasmComponentDecoder.test.ts src/wasm/WabtArtifactProvider.test.ts src/contracts/toolEffects.test.ts tests/acceptance/wasmComponentCli.test.ts tests/boundary/mcp/wasmComponentMcp.test.ts tests/boundary/mcp/serverLifecycleMcp.test.ts tests/boundary/providers/artifactReadCleanupRetry.test.ts
node scripts/rea.mjs inspect-wasm-component <component> --json
node scripts/rea.mjs inspect-wasm-artifact <component or core module> --json
node scripts/rea.mjs inspect <component or core module> --json
/usr/bin/time -f "elapsed=%e user=%U maxrss_kb=%M" node scripts/rea.mjs inspect-wasm-component <component> --jsonEach test run sat under 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
Resolve the conflicts with main at 32f0e51. No rebase or force-push. - src/cli/wasmCommands.ts: keep the component command and take main's absoluteCallerPath (morluto#4067). The component path now uses it too, instead of path.resolve, so `link/../file` selects the file the filesystem names. Pass the command signal to finishAnalysisCommand, which main now requires (279c590). - src/server/createServer.ts: keep main's rustBinary service and this PR's wasmComponent service in construction, shutdown and the tool context. - tests/boundary/mcp/serverLifecycleMcp.test.ts: keep main's scenario capture service and this PR's component service in the shutdown test. - src/wasm/WabtComponentRouting.ts: the component probe reads its header through main's withArtifactFileHandle, so a failed close is retained as a lease and its error resolves on retry, as main's WABT descriptor-retry test requires. - tests/boundary/cli/callerPathSymlinkParentCli.test.ts: cover inspect-wasm-component through a symlink and `..`; it fails with path.resolve.
Main now gives every stable read one descriptor owner, withArtifactFileHandle. A failed close throws ArtifactFileCleanupFailure with a cleanup lease, and providers bind that lease to the error they return, so the error resolves once a later close succeeds. - WasmComponentProvider classifies the physical primary failure inside ArtifactFileCleanupFailure, binds its lease to the returned error and to close() failures, and runs the whole operation inside its scope, as main's Go, Rust and PE providers do. - Cancellation is the decoder's exact abort reason. Previously any failure seen with an aborted signal became cancelled, so a read denied or over the size limit was misreported when cancellation arrived during close. - File-size refusals name selected-input recovery, as in main. Validation: main's stableArtifactConsumers cases now include the component provider (the two read-failure cases failed before this fix); check:fast, docs:check, knip and jscpd; 115 source and 134 boundary, acceptance and process-global tests.
| sub.expectEnd("component name subsection"); | ||
| return; | ||
| } | ||
| if (id !== 1) return; |
There was a problem hiding this comment.
A component-name subsection with an ID other than 0 or 1 is silently skipped. No failure reaches the decoder, so names.status remains "decoded" and coverage.status can remain "complete" despite unread content. Callers cannot see which bytes were skipped. Record an unsupported gap for the skipped subsection, as the documented coverage contract promises.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WasmComponentNames.ts
Line: 21
Comment:
**Skipped names look complete**
A `component-name` subsection with an ID other than `0` or `1` is silently skipped. No failure reaches the decoder, so `names.status` remains `"decoded"` and `coverage.status` can remain `"complete"` despite unread content. Callers cannot see which bytes were skipped. Record an `unsupported` gap for the skipped subsection, as the documented coverage contract promises.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Pick up main's plist and UI finalization test alignment (d1adc60), which the keyed-archive date and number tests on this branch's previous base need.
CI shard 2 failed when a cli-boundary worker reached its 384 MiB heap limit. Every test passed; the worker aborted. Those workers reuse one module graph, and this PR added about 3 MiB to it at CLI startup. Two static paths loaded the component code into every CLI process: composition/wasm.ts imported the component service and decoder, and wasmToolContracts.ts built the component result schema, both pulled in just to register inspect-wasm-artifact. - Component composition moves to composition/wasmComponent.ts, which the component command loads on demand, as main's deferred commands do (a4dd4e8). MCP still composes it at server start. - The component contract moves to wasmComponentToolContracts.ts, read by the tool catalog and the catalog scripts. Main already keeps that catalog out of CLI startup. - cliStartupImports lists the component composition, decoder and schema, so `rea --help` must not resolve them. Measured in a cli-boundary worker against main at a80575c (3 runs each): module graph before the first command 185.2 MiB vs 185.6 MiB on main, previously 187.7 MiB. After a command that loads the tool catalog, 219.8 MiB vs 217.8 MiB; that 2 MiB is this tool's schema in the catalog. The startup bundle no longer contains the decoder.
|
CI on Head is now
Measured in a
The remaining 2 MiB is this tool's schema in the catalog, which every catalog consumer needs. The startup bundle no longer contains the decoder. The crashed worker still had about 356–379 MiB live after a full collection. This PR now adds at most 2 MiB of that, so Validation: |
| const module = instance?.kind === "core-instantiate" ? instance.module : null; | ||
| const declared = module === null ? undefined : interfaces.exports.get(module); |
There was a problem hiding this comment.
Re-exported modules lose known checks
coreSource looks up a module's decoded interface using its new export index rather than its original index. If embedded module 0 exports run, is re-exported as module 1, and is then instantiated, a lift from that instance reports declared_by_module: null despite the fully decoded interface. Lower bindings have the same problem.
This loses a useful check against the module's declared imports and exports. Follow the module's export chain before looking up its interface.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WasmComponentRelationships.ts
Line: 249-250
Comment:
**Re-exported modules lose known checks**
`coreSource` looks up a module's decoded interface using its new export index rather than its original index. If embedded module 0 exports `run`, is re-exported as module 1, and is then instantiated, a lift from that instance reports `declared_by_module: null` despite the fully decoded interface. Lower bindings have the same problem.
This loses a useful check against the module's declared imports and exports. Follow the module's export chain before looking up its interface.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.|
TL;DR: My earlier results still hold on the new head, 2ed3b71. The command This follows my earlier result on head f10cbea. Since then the branch got two merges of main. It also got two commits by the author. They are 8d8c098 (read cleanup) and 2ed3b71 (load the decoder only when used). I tested head 2ed3b71 as pushed. Its base with main is a80575c. Today's main is 974487f, and I did not test main. My earlier checksI used the same 302-byte component from the PR's fixture builder. I used the same stand-in WABT scripts. Results were the same on Node 22.23.1, 24.18.0 and 26.11.1.
The decode is the real test of 2ed3b71, since that commit moved the component code to load on demand. Open review findingStill reproduces. The thread is Exported instances hide sources. Head still reports Bot threads at 2ed3b71There are 5 open threads, all from Greptile. I built a small case for each.
Details for each thread
Not run
Thanks, all-black-493, for the quick work on the startup load and the read cleanup. Test setup
CommandsThe probe file builds five small components with the PR's fixture helpers and asserts the correct behaviour, so a failing probe means the thread is real. The stand-in folder held three small scripts named like the real WABT tools. Each printed 1.0.42 and wrote one line per call. REA_WABT_BIN_DIRECTORY pointed at it. Every build and test run sat under None of the ten test files runs the doctor command. cliStartupImports names doctor modules only to check they do not load. 🤖 Generated with Claude Code (Sonnet 5.5, verified by Opus 5.5) 🦊 |
| ); | ||
| const report = { | ||
| artifact: { | ||
| path: input.path, |
There was a problem hiding this comment.
[P2] Retain the completed file identity after component decoding fails
A task-owned 10-byte component (0061736d0d0001000a05) passes the verified read with SHA256 bea22b525205cfb7749116a24459824d91fb9932c175d7ca0088205c48859cb1. The production decoder then refuses the section extent, and both WasmComponentProvider.inspect and the shared service return AnalysisInputError with no partial observation/digest/byte count (cause: section extends past its enclosing range at offset10). The successful snapshot lives only inside #inspect, while outer inspect maps only the cause/path, so an already completed observation is lost before CLI/MCP delivery. Retain successful verified-read facts in the owning failure representation through decoder refusal and post-read cancellation, following the existing artifact-failure pattern, and add those regressions. The public result should still report decoding failure, with the known source identity accessible. This was a bounded production provider/service probe at2ed3b7152c; no component was instantiated or executed and no compiled adapter behavior is claimed.
|
@all-black-493 thanks for the PR — there are 6 open review threads here:
Could you address or reply to these? Once they're resolved and CI is green we can take another look. |
|
@all-black-493 also, this branch has merge conflicts with |
Resolve conflicts by expressing the component tool on main's current owners: - Registration moves to the contract, capability, tool-family, CLI and MCP binding declarations; the removed cliCommandNames, registerWasmTools and per-tool effect tables are not restored. - The port moves to src/ports. The service uses executeArtifactInspection, and the provider uses the shared failure classifier and stable artifact projection, which keep the completed file identity on later failures. - The decoder uses the shared parse-failure, LEB128, UTF-8, SHA-256, budget and coverage owners. Malformed components are now target refusals (unsupported_target, failure_kind malformed), as for other readers on main. - The WABT component probe admits only regular files. - The fixed input, entry and report allowances are registered as pending a control (morluto#14235). - The component guide moves to docs/guides/wasm/wasm-artifacts.md.
|
Merge conflicts are resolved. Head is now
Validation: CI passes on |
| component = await withArtifactRegularFile( | ||
| path, | ||
| scope, | ||
| undefined, |
There was a problem hiding this comment.
rejectWasmComponent passes no cancellation signal to withArtifactRegularFile. If the caller cancels while the header is read or a recently written Windows file settles, the probe keeps waiting and can return a component refusal instead of cancellation. The provider's final cancellation check runs only after a runtime exists, which this early route never creates.
AGENTS.md requires cancellation to survive reads and cleanup. Before merging, forward the caller's signal through the probe and preserve its typed cancellation rather than swallowing it.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/wasm/WabtComponentRouting.ts
Line: 58
Comment:
**Probe ignores cancellation**
`rejectWasmComponent` passes no cancellation signal to `withArtifactRegularFile`. If the caller cancels while the header is read or a recently written Windows file settles, the probe keeps waiting and can return a component refusal instead of cancellation. The provider's final cancellation check runs only after a runtime exists, which this early route never creates.
`AGENTS.md` requires cancellation to survive reads and cleanup. Before merging, forward the caller's signal through the probe and preserve its typed cancellation rather than swallowing it.
**Context Used:** AGENTS.md ([source](https://github.com/morluto/rea/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.The service checked isAbsolute itself before it moved to the shared artifact inspection executor. Its schema still admitted relative paths, so the merge dropped that refusal. Declare it on the input schema, as sibling tools do.
Summary
Adds
inspect_wasm_component/rea inspect-wasm-component, an in-process decoder for WebAssembly component-model binaries. Refs #2350. The proposal and its open questions are in this comment.Before this change, REA had no route for components. WABT 1.0.42 cannot parse them, and
open_binarydid not recognize their header.Problem and expected behavior
A component (preamble
00 61 73 6D 0D 00 01 00) carries its own index spaces, typed imports and exports, embedded core modules and canonical ABI definitions. Treating it as a core module loses that structure.Expected: given one local component file, REA returns its structure with byte ranges and provenance, and traces how component functions connect to core module exports and imports. It never validates, instantiates or executes anything.
Change and scope
src/wasm/and pinned to component-modelBinary.mdat06e3db0(2026-09-23). It admits only version0xd, layer1. It reads the file throughreadStableArtifactand starts no subprocess, writes no temporary file, needs no WABT, and never instantiates or executes. Like the Go build-info reader (feat(go): inspect embedded binary build metadata #1363), it has its own provider identity,wasm-component-binaryv1.type_scopeslist, so neither the JSON nor the advertised schema is recursive.component-namesection, custom sections, and nested components linked byparent.liftstrace each canonical lift through the core instance alias to the core export it wraps.lowerstrace each lower to its component import and to the core imports it is bound to through inline-export core instances.declared_by_modulechecks the module's own import or export section, and is null when that interface was not decoded.validationis alwaysnot_performed. Malformed framing (LEB128, lengths, UTF-8, trailing bytes, truncation) is a target failure (unsupported_target,failure_kind: "malformed") with the file offset, and keeps the file's SHA-256 and size as a partial observation. A well-framed construct that isn't decoded (GC core types, unknown section ids or opcodes, nesting beyond 16 components or 32 type scopes) is listed incoverage.not_decodedwith its range. Decoding continues with the next section, and indices that later definitions add to the affected sorts become null, because their positions are unknown.gated_featureslists the feature gates of encodings actually present.open_binaryreturns the new constraintwasm_component_requires_static_inspection, with a remediation pointing toinspect_wasm_component.inspect_wasm_artifactreturnsunsupported_targetfor a component before resolving WABT or running any command. An 8-byte probe routes early; the stable read still decides.src/domain/wasm/wasmPreamble.ts, which the core-module check now uses too.fixed-ceiling-registry.jsonlists the input, entry and report allowances as pending under [Feature] Give native readers' fixed structural, text and inventory allowances a control or a stated fixed reason #14235.Not included: validation, the canonical ABI layout, value decoding, tracing through outer aliases or instantiated nested components, and summary delivery (asked about in #2350). The issue asks for spec/plan/tasks under
docs/specs/. That directory doesn't exist, and AGENTS.md says not to commit local planning artifacts, so the design is in the issue comment and here, and the user docs are indocs/guides/wasm/wasm-artifacts.md.Follow the contribution scope. This is read-only static format inspection with no execution or mutation authority. #2350 asks whether a new in-process provider needs a separate maintainer decision; that is still pending.
Contract and boundary impact
src/domain/wasm/wasmComponent.tsandwasmComponentTypes.ts(contract),src/wasm/WasmComponent*.ts(decoder),src/domain/wasm/wasmPreamble.ts(header identity).BinaryTargetErrorconstraint.inspect_wasm_artifactandopen_binarychange only for component headers.wasm-component-binaryv1. No host tools are required.file; locations include the artifact path and any undecoded ranges.main(b955b82), the stable read and the WABT component probe release their file handles through a provider-ownedArtifactResourceScope. A failed release returnscleanup_incompletewith the primary error, and the handle is retried on the next read or at CLI/MCP shutdown, where the server closes the sameWasmComponentServiceit binds to the tool.artifactsurface with its own provider identity. The skill gets one entry and a reference line, with no version bump, following recent feature PRs.Expected effects:
Evidence and regression coverage
Tests added or updated:
src/wasm/WasmComponentDecoder.test.ts: index spaces across interleaved sections, lift/lower tracing, instance types with resources, names, gated encodings, nesting and its bound, partial coverage with null indices, an invalid name section, a non-core embedded module, malformed framing, unadmitted preambles and cancellation.tests/acceptance/wasmComponentCli.test.tsandtests/boundary/mcp/wasmComponentMcp.test.ts: public CLI and MCP calls. They validate the advertised input and output JSON Schemas with Ajv 2020 after SDK conversion, and cover availability without an active target, session Evidence, typed errors and partial coverage.tests/boundary/filesystem/targetDiagnostics.test.ts(open_binaryrouting) andsrc/wasm/WabtArtifactProvider.test.ts(WABT pre-check: no command runs and no workspace is created, with and without WABT configured).src/wasm/WasmComponentBinary.fixture.ts; no binary is committed.Base reproduction: on
main,open_binarydoes not recognize a component header, andinspect_wasm_artifactpasses component bytes to WABT, which cannot decode them.Real-producer cross-check (manual, not a CI lane):
@bytecodealliance/jco1.35.0, which bundleswasm-tools, run in an isolated directory.jco printparses all three fixtures, with the same index numbering the decoder reports.jco parsefrom WAT (records, variants, enums, flags, options, results, tuples,resource.new/drop/rep, a component-typed import, instantiation, inline-export instances, a module type and an outer alias) decodes to the same indices asjco printshows.jco new --wasi-command(17,552 bytes) decodes completely. It has 8 imports, 4 core modules, 15 core instances, 13 lowers, 1 lift and 4resource.drop, matchingjco print. All 13 lowers trace to their WASI imports and adapter-module imports withdeclared_by_module: true. The lift traces towasi:cli/[email protected]#run.User-visible CLI/MCP output, from the WASI command component above (trimmed; ranges omitted, one entry per list shown):
{ "operation": "inspect_wasm_component", "normalized_result": { "validation": "not_performed", "coverage": { "status": "complete", "not_decoded": [] }, "components": [{ "imports": [ { "name": "wasi:io/[email protected]", "attributes": [], "type": { "sort": "instance", "type": 0 }, "defines": { "sort": "instance", "index": 0 } }, "… 7 more: wasi:io/streams, wasi:cli/stdin|stdout|stderr, wasi:clocks/wall-clock, wasi:filesystem/types|preopens" ], "exports": [ { "name": "wasi:cli/[email protected]", "attributes": [], "target": { "sort": "instance", "index": 8 }, "type": null, "defines": { "sort": "instance", "index": 9 } } ], "lowers": [{ "canon": 4, "func": 0, "core_func": 16, "component_source": { "kind": "instance-export", "instance": 4, "name": "get-stderr", "instance_import": "wasi:cli/[email protected]" }, "satisfies": [{ "core_instance": 12, "core_module": 1, "import_module": "wasi:cli/[email protected]", "import_name": "get-stderr", "declared_by_module": true }] }], "lifts": [{ "canon": 17, "func": 13, "core_func": 31, "type": 21, "core_source": { "core_instance": 12, "name": "wasi:cli/[email protected]#run", "core_module": 1, "declared_by_module": true }, "exported_as": [] }] }] } }Remaining proof gaps:
cargo component,componentize-py) was decoded.jco printparsing, not by producer output.For evidence-bearing changes:
Validation performed
npm run check:knip,metadata:checkand architecture guards pass.format:checkflagged only untracked local build output outside this diff;oxfmt --checkon the changed files passes.registerGoTools.npm run docs:check: passes.e1e9960db), the decoder and WABT provider suites pass (32 tests), as do the component CLI/MCP, WASM artifact MCP and target diagnostics suites (31 tests) andcheck:fast. Both real-producer components decode with identical output.mainat11f8b7625(headc103ec369):check:fast,docs:check,knipandjscpdpass (2.99% duplicated lines, threshold 3.5%).serverLifecycleMcpandartifactReadCleanupRetry. The last two are upstream's ownership tests, extended to the component provider and service. With the scope removed from the provider, the retry case fails withcancelledinstead ofcleanup_incomplete.mainat299c592b6(mergec6e02f105, headfb8f71aec):check:fastpasses on the head.knipanddocs:checkpass on the merge.verify:advertised-schemasshows no schema difference on the head (its optional Rust and C++ engines are not installed here). Typed lint on the 49 changed files has 0 errors.c6e02f105: moving the service to the shared executor had dropped its absolute-path check, whichcliContractCommandParitycaught.fb8f71aecdeclares the rule on the input schema and adds a relative-path regression.localToolContracts"captures real process choices … untruncated" exceeded the MCP input-element allowance once, then passed on two reruns; it does not involve components. After it, 49 CLI, schema and path test files pass (1,667 tests).lint:typed(it did not finish on this host) and the manual real-producer comparison, so the real-component results above predate this merge.tests/boundary/mcp/firmwareMcp.test.ts("Unsupported tool version 26.6.4"). It fails the same way on the unmodified base on this host.Compatibility, safety, and release
mainand not repeated;mainnow omits output schemas fromtools/listby default.tools/listgrew by 33,919 bytes (about 1.35% of 2,516,115). Of that, 32,440 bytes is the typed output schema, 3rd largest of 188 tools (median 8,445), in the range ofinspect_web_pageandanalyze_javascript_application. Tokens were not measured; at about 4 bytes per token that is roughly 8.5k tokens, an estimate.Before merge
type(scope): outcome.Refs #2350