wasm-component-wit-compatibility
Audit WebAssembly Component Model WIT world evolution offline with pinned wasm-tools AST/semver-check across imports, exports, signatures, types, resources, and binary components.
Try your first task
A source-grounded starter task has not been verified for this skill yet.
SKILL.md
name: wasm-component-wit-compatibilitydescription: "Audit WebAssembly Component Model WIT world evolution offline with pinned wasm-tools AST/semver-check across imports, exports, signatures, types, resources, and binary components."category: developmentrisk: safesource: selfsource_type: selfdate_added: "2026-12-01"author: Koushik-Katkamtags: [webassembly, wasm, component-model, wit, wasm-tools, compatibility]WebAssembly Component WIT Compatibility
Overview
Compare WebAssembly Component Model WIT world contracts offline using the real pinned wasm-tools parser (wasm-tools component wit --json and wasm-tools component semver-check) over both .wit packages and validated .wasm binary components, without regular-expression scraping over WIT text and without executing WebAssembly code. Verifies removed required exports, newly required host imports, parameter/result contract changes, package/interface semver versions, nominal type and resource identities, and compatibility direction.
Distinction from existing repository skills:
rust-migration,axum-development, andapi-contract-testing: zero WebAssembly Component Model,.witinterface parsing, world import/export compatibility, orwasm-toolsusage exists anywhere inupstream/main(0hits across3,092skills).
When to Use
- Auditing breaking vs. additive changes between
v1andv2WebAssembly Component Model WIT worlds before publishing components or upgrading hosts. - Inspecting compiled
.wasmcomponents safely offline to extract their resolved WIT JSON contract without running untrusted Wasm code. - Verifying compatibility direction (
new component drops into existing v1 host) across imports, exports, and resource handles. - Do not use this skill to execute
.wasmmodules/components, benchmark runtime host bindings, or prove behavioral/ABI equivalence from identical interface names.
Prerequisites
- Official
wasm-toolsCLI (wasm-tools --version, tested on1.263.0) onPATHor pointed to byWASM_TOOLS_BIN. - Python
3.10+withpytest(tested with Python3.12.10andpytest==9.1.1). - No Wasm runtime execution (
wasmtime) or network access required.
How It Works
1. Define the compatibility direction explicitly
Audit direction defaults strictly to NEW_COMPONENT_ON_OLD_HOST:
- Exports (what the old host expects the component to provide): Removing an exported function, type, or interface or changing exported type definitions (
type id = u32->type id = string), parameter types, or result error payloads breaks existing hosts (REMOVED_REQUIRED_EXPORT/CONTRACT_CHANGE). Adding a new optional export is non-breaking for old hosts (ADDED_EXPORT). - Imports (what the component requires the old host to provide): Adding a new required host import or mutating imported type/function definitions breaks old hosts (
NEW_REQUIRED_IMPORT/CONTRACT_CHANGE). - Package-qualified identities, resources & canonical AST types: Constructor signatures, resource methods, package-qualified interface keys,
variant/enum/flagsmembers, and nominal type definitions are canonicalized structurally without comparing unstable integer AST type IDs (UNSUPPORTEDif an unmodeled type kind is encountered).
2. Parse genuine WIT ASTs and binary components with wasm-tools
Run the local verification suite in WIT compatibility harness:
- Run
wasm-tools component wit <target> --json(rejects invalid WIT/Wasm asINVALID_INPUTcleanly) to inspect resolvedpackages,worlds,interfaces,types, andfunctions. - Run
wasm-tools component semver-check --prev <new-world> --new <old-world> <wit>only when both worlds live in the same.witfile/package source (never substituting an unrelated third.witfixture) to confirm official Component Model semver compatibility alongside structured AST diff diagnostics. - Build and validate an actual
.wasmbinary component offline (wasm-tools parse+component embed+component new+validate --features component-model) and extract its embedded WIT contract viacomponent wit component.wasm --jsonwithout instantiation or execution.
3. Distinguish conservative structural differences from proven incompatibility
Always state explicitly that structural AST differences flag conservative compatibility breaks (some changes, such as compatible minor package version bumps or nominal aliases, can require host/guest ABI review), whereas passing matching WIT identifiers, function signatures, and semver checks never proves behavioral equivalence or canonical-ABI runtime safety across different guest implementations or memory allocators.
Examples
Run the self-contained verification suite in WIT compatibility harness:
User request: "Check whether our plugin-v2 WIT world breaks hosts compiled against plugin-v1."
Inputs: WIT package(s) or binary .wasm components audited via wasm-tools 1.263.0.
Expected result: Backward-compatible export addition passes semver-check and reports NEW_COMPONENT_ON_OLD_HOST;
removed export, newly required host import, u32->u64 param change, and changed resource method return BREAKING findings;
syntax errors return INVALID_INPUT.
Limitations
- Audits WIT syntactic/type resolution via
wasm-tools==1.263.0(component wit --jsonandcomponent semver-check); does not prove runtime behavioral parity, canonical-ABIcabi_reallocsafety, or runtime execution correctness. - Core non-component Wasm modules (missing component-model
witmetadata) cannot yield WIT worlds and classify asUNSUPPORTED. @unstablegated WIT items require explicit--features/--all-featuresflags to be visible in AST resolution.
Safety and Side Effects
- Strictly offline and read-only over synthetic
.wit/.wat/.wasmfiles inside temporary directories with15ssubprocess timeouts. - Never runs
wasmtimeor executes untrusted WebAssembly guest code.