* feat(rust): read cargo-auditable dependencies from WebAssembly modules cargo-auditable embeds the same zlib-compressed `.dep-v0` JSON in a WebAssembly custom section for wasm32 targets, but inspect_rust_binary rejected every module as an unsupported target because only ELF, PE and thin Mach-O containers were recognized. Walk the section framing of version 1 core modules to locate the `.dep-v0` custom-section payload and the data section, where rustc keeps its constant /rustc/<hash>/ paths. Rust lookups now read one format-neutral layout, so native and WebAssembly images share a single dependency-section owner. WebAssembly declares no container word size, so `bits` is null for that format only; the Evidence subject format is `file`, as for inspect_wasm_artifact. Truncated sections, invalid LEB128 sizes, custom-section names that run past their section or are not UTF-8, duplicate `.dep-v0` sections and a second data section are malformed. Components, such as wasm32-wasip2 output, embed core modules and are refused as unsupported, like universal Mach-O containers, rather than inspected through one selected module. * fix(rust): bound the WebAssembly section walk The WebAssembly reader visited every section synchronously, and the format sets no section count. A 256 MiB input of three-byte custom sections with empty names walked about 89 million sections and held the event loop for about 7.4 seconds, delaying cancellation and other MCP requests; empty type sections took about 1.9 seconds. Refuse a module with more than 65,536 sections with a typed cpu resource constraint that reports maximum_wasm_sections, as the Go header search reports its work budget. Producer output holds a few dozen sections, and the same inputs are now refused within tens of milliseconds. * fix(rust): accept WebAssembly Evidence in retained dependency views Retained Rust views compared the parent subject with a Mach-O-only format mapping, so WebAssembly Evidence, whose subject format is file, was refused as a different artifact. The report domain now owns the subject format next to the architecture mapping, and the service and the view both use it. The real CLI/MCP view workflow now also covers a WebAssembly module. * fix(rust): name the WebAssembly section-walk allowance in recovery Fixed-allowance recovery mapped every Rust resource other than capacity and transport to the parser allowance, so the section-walk refusal said host memory does not raise it. Each Rust resource now maps to its own allowance, and the cpu bound is a fixed work allowance. The MCP error contract test checks that the refusal is not retryable and names that allowance. * fix(rust): require WebAssembly container facts in reports The report schema tied a null word size to WebAssembly, but it accepted a wasm report that named a native architecture or big-endian byte order, and a native report that named the wasm architecture. Retained views parse imported Evidence with this schema, so such a contradictory report was accepted. The architecture is now wasm exactly when the container is WebAssembly, and a WebAssembly report must be little-endian. * docs(rust): record the WebAssembly dependency-metadata feature Feature work now carries a spec, plan and task list under docs/specs. This adds that record for reading cargo-auditable metadata from WebAssembly core modules and indexes it. The record states that it was written during review and lists the verification that remains open. * fix(rust): bind section names to containers and share the LEB128 reader The report schema accepted a dependency section name that does not belong to the report's container, such as a WebAssembly report naming the Mach-O section. rustDependencySectionName now owns that name for the reader and the schema, which refuses a mismatch for every container. The WebAssembly reader decoded section sizes with its own loop. It now uses the shared readLeb128, and an integer cut off by the end of the file is truncated rather than malformed. * fix(rust): classify a cut-off WebAssembly integer by its boundary The reader called an unfinished LEB128 integer truncated whenever its limit equalled the file length. A name length cut off inside the final section was therefore truncated, and the same bytes followed by another section were malformed. Each caller now states whether the file or the enclosing section bounds the integer. * fix(rust): report a duplicate WebAssembly dependency section first The section walk kept two .dep-v0 matches but walked on, so a module with two dependency sections and more than 65,536 sections after them was refused for the section bound instead of the duplicate it had already established. The walk now ends at the second match. * test(rust): assert WebAssembly container facts instead of limitation prose The CLI acceptance test matched an English limitation sentence. It now checks format, architecture, bits and byte order on the parsed report. * fix(rust): state container word size as 32 | 64 | null Output contract: inspect_rust_binary bits, including the summary view, is 32 | 64 | null. Null is valid only for WebAssembly and is not a number. ELF, PE and Mach-O reports stay 32 or 64. The schema description, guide, feature record and skill state that, and CLI renderers keep null instead of substituting a word size. --------- Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com>
4.3 KiB
Rust dependency metadata in WebAssembly modules
Problem and outcome
cargo auditable build for a wasm32 target stores the same zlib-compressed
.dep-v0 JSON that native builds carry, in a WebAssembly custom section.
inspect_rust_binary and inspect-rust-binary recognized only ELF, PE and
Mach-O containers, so every .wasm input was refused as an unsupported target
and an agent could not read a module's embedded crate list.
This feature lets the existing tool and command read that list from a WebAssembly core module. It adds no tool, command or input.
Rust binary dependency metadata describes the current behavior and limitations. This directory is the feature specification, implementation plan and task list. The guide does not replace these files.
This record was written on 2026-11-17, during review, after the repository adopted feature records. The requirements restate the contract the implementation already had; no earlier plan is reconstructed.
Requirements
- The module is a local file read through the stable artifact read. It is not validated, instantiated or executed. Only section framing is walked.
- A version 1 core module is accepted. A component (layer 1) and any other module version are unsupported targets, because a component embeds several core modules and no input selects one.
- A custom section named
.dep-v0supplies the dependency list, and the report'ssection_nameis.dep-v0; the report schema binds each container to its section name.file_offsetandsection_byteslocate the payload after the section name, in the original file. A second.dep-v0section is malformed; the walk ends there, so a later failure such as the section bound does not replace it. - A missing
.dep-v0section is null metadata with a limitation. It is not evidence that the module has no dependencies. formatandarchitecturearewasmandbyte_orderislittle.bitsis32 | 64 | null, and isnullfor this container because WebAssembly declares no container word size and memory address types are not inspected. Null is not a number and must not be coerced. ELF, PE and Mach-O reports stay 32 or 64. The report schema, its field description and the summary view refuse any report that combines these facts differently.- The rustc commit is inferred from
/rustc/<40-hex>/paths in the module's data section. Limitations name that source. A second data section is malformed. - A header, section or section size that ends past the file is truncated. A size or name length that does not fit a 32-bit LEB128 integer, a custom-section name or name length that extends past its section, and a name that is not UTF-8 are malformed. Integers are decoded by the shared LEB128 reader.
- The section walk stops after 65,536 sections with a
cpuresource constraint. The format sets no section count and the walk is synchronous. The allowance is fixed;producer_limitsdoes not raise it. Retained state is at most two.dep-v0ranges and one data-section range. - The Evidence subject format is
file, as forinspect_wasm_artifact, with no architecture. Retained summaries, package and edge pages and the CycloneDX view accept a WebAssembly parent. architectureon a module is rejected, as on any image that is not a universal Mach-O.- ELF, PE and Mach-O reports are unchanged apart from limitation wording that names where compiler paths were searched.
Acceptance
- Boundary tests cover a module with and without
.dep-v0, each refusal in requirements 2, 3, 6 and 7 by failure kind, format, offset and field, and the section bound at 65,536 and 65,537 sections. - CLI acceptance covers a module report, its
filesubject and the component refusal. The retained-view acceptance workflow runs on a module. - MCP boundary tests validate a module report against the advertised output schema and check the section-bound refusal through the public error contract.
- A view test refuses imported reports whose container facts contradict requirements 3 and 5.
Non-goals
- Reading a component's embedded core modules.
- Validating, instantiating or executing a module.
- Decoding memory address types or any section other than the framing, the
.dep-v0payload and the data-section byte range.