Skip to content

tech-debt: Parse WASM return shape at FFI boundary #91

@dean0x

Description

@dean0x

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions