SPIKE: package the engine's declarative plane as WebAssembly#249
Draft
sksizer wants to merge 1 commit into
Draft
SPIKE: package the engine's declarative plane as WebAssembly#249sksizer wants to merge 1 commit into
sksizer wants to merge 1 commit into
Conversation
… findings De-risk packaging `markdown-contract-engine` as WebAssembly for the TS `packages/core` declarative-validation plane (engine-axis plan). Adds a throwaway `wasm-spike/` crate (its own Cargo workspace, publish = false) exposing one entry point via wasm-bindgen — `validate_document(source, contract_yaml, path) -> Finding[] JSON` — over the engine's `load_contract` + `validate`. Builds for wasm-pack nodejs/web/bundler targets; a Node harness proves the round-trip and a browser harness documents the async-init story. The engine crate, its API, and its tests are untouched (isolated workspace; depends on the engine with default-features = false, i.e. the fs-free core). FINDINGS.md is the deliverable: sizes (1.42 MiB wasm / 404 KiB brotli vs ~99 KiB gz for the TS bundle), sync Node / async browser init, one binary + per-target glue, JSON-boundary ergonomics, and a GO recommendation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Spike — not for merge. De-risks packaging
markdown-contract-engineas WebAssembly so the TSpackages/coredeclarative-validation plane could become a thin wasm wrapper (engine-axis plan). Findings only; no production migration.What's here
A throwaway
crates/markdown-contract-engine/wasm-spike/crate (its own Cargo workspace,publish = false) exposing one entry point via wasm-bindgen:over the engine's
load_contract+validate. Built for wasm-pack nodejs / web / bundler; a Node harness proves the round-trip and a browser harness documents the async-init story.The engine crate, its API, and its tests are untouched — the spike is an isolated workspace that depends on the engine with
default-features = false(the fs-free core).cargo test -p markdown-contract-engine→ 149 unit + 1 corpus golden, still green.Headline findings (full detail in
FINDINGS.md)initSync(bytes).wasm, per-target glue. bun runs the nodejs artifact unmodified (verified)JSON.parse;Findingis the frozen interchange shape, so goldens hold by constructionWhy it de-risks cleanly: the core compiled to
wasm32-unknown-unknownon the first try — nogetrandom/js-sys/std::fs/ panic-hook surprises. The existingnativefeature gate already did the hard part.Main risk: binary size (comrak + regex + serde). Irrelevant for CLI/daemon; a one-time cached download for the browser dashboard.
Verified
[], fail →frontmatter/enum+structure/section-missing), and a malformed contract throws a JSError.Tooling note
wasm-opt(binaryen 117) rejected the module until passed explicit--enable-bulk-memory/etc. flags — rustc 1.95 emits post-MVP wasm features andstrip = truedrops thetarget_featuressection it auto-detects from. Flags are set inCargo.toml; a CI setup needs the same (or a newer binaryen).Next step if go
Opaque
Contracthandle (compile once, validate many) → wasm build inpackages/core's pipeline → a wasm-parity CI check over the shared corpus.