Problem
validateWasmShape (packages/mds/src/backend/wasm.ts:125-135) checks that required exports exist (compile, check, compileMessages) but does not validate the shape of return values crossing the WASM FFI boundary.
Current Behavior
Checks presence of export names only:
if (!wasm.compile || !wasm.check || !wasm.compileMessages)
Does not validate:
- Return type structure (e.g., CompileResult shape)
- Presence of required fields (e.g.,
.code, .messages)
- JSON schema compliance
Root Cause
This is a pre-existing pattern — both compile and check functions have the same validation gap. Not introduced by #87 (compileMessages added), but worth addressing as part of a broader boundary-hardening pass.
Solution
Extend validateWasmShape to parse and validate return shapes:
- Call each export with minimal/empty input
- Assert return structure matches
CompileResult / CompileMessagesResult shape
- May be combined with other WASM boundary validations
Priority
Low — Correctness is ensured at call sites; this adds parse-don't-validate rigor at the boundary.
Related
Problem
validateWasmShape(packages/mds/src/backend/wasm.ts:125-135) checks that required exports exist (compile,check,compileMessages) but does not validate the shape of return values crossing the WASM FFI boundary.Current Behavior
Checks presence of export names only:
if (!wasm.compile || !wasm.check || !wasm.compileMessages)Does not validate:
.code,.messages)Root Cause
This is a pre-existing pattern — both
compileandcheckfunctions have the same validation gap. Not introduced by #87 (compileMessages added), but worth addressing as part of a broader boundary-hardening pass.Solution
Extend
validateWasmShapeto parse and validate return shapes:CompileResult/CompileMessagesResultshapePriority
Low — Correctness is ensured at call sites; this adds parse-don't-validate rigor at the boundary.
Related