caelum0x f4f57cb563 feat(wasm): C-ABI browser bindings over lawsynth-wasm for the playground
crates/lawsynth-wasm-bindings (new): the browser layer apps/playground was
designed to consume but that didn't exist. A hand-rolled #[no_mangle] extern "C"
surface (no wasm-bindgen, no external crates, std-only) over lawsynth-wasm:
- Vec-backed linear-memory allocator (ls_alloc/ls_free) + length-prefixed
  packing protocol; entry points ls_simulate/ls_validate_world/ls_derivative/
  ls_eval_expression/ls_bundle_encode/ls_bundle_decode, plus ls_result_len/
  ls_last_error/ls_version.
- Hand-rolled std-only JSON codec (json.rs), World-JSON lowering (convert.rs),
  operations (api.rs). Deterministic: fixed-step RK4, pure eval, byte-exact
  bundle codecs; no clock/RNG/fs/net. Panics contained with catch_unwind.
- crate-type cdylib+rlib so the exports are host-compiled AND host-tested
  through the exact C-ABI a JS caller uses: 11 tests (simulate → e^-1, parameter
  folding, derivative, expression eval, INVALID_WORLD/UNSUPPORTED/MEMORY_LIMIT
  error paths, version, validate, bundle round-trip). Every unsafe block carries
  a SAFETY invariant.
- web/lawsynth_wasm.mjs — zero-dependency ES-module glue matching the
  playground's wasm.ts simulate contract (zero delta). scripts/build-wasm.sh +
  README document the wasm build.

Honest status: the deployable .wasm is NOT built here — wasm32-unknown-unknown
needs a one-time network install this offline env can't run; the bindings are
host-compiled + host-tested and build to wasm via scripts/build-wasm.sh on a
networked machine. Wiring into apps/playground (asset copy + loader) is the
next integration step.
2026-08-18 21:30:50 +03:00
..