int_synth + int_entropy are pure i64 (no ort, no float), so the SAME Rust that decodes natively compiles to wasm32 and runs in the browser with no ML runtime at all — and the bytes are identical to native on every machine. This is the integer-entropy contract's payoff made visible: a learned-codec reconstruction whose hash is portable. - int_synth: factor the decode into `decode_from_spec(payload, spec_bytes)` (no std::fs); `decode(payload, path)` now reads the spec and delegates. WASM/no-FS sinks call the bytes entry point with host-supplied weights. Behavior- identical (4 int_synth tests green). - wai-web: add the `neural_int` feature + a `neural_int` wasm-bindgen module: decodeIntSynth(payload, specJson) -> RGB, the int_entropy primitives (fixedScaleEdges / quantizeScale / detBuildIndex), and blake3Hex for the in-page receipt check. Compiles to wasm32 (web + nodejs targets). - demo: int_synth.html/.js — decode a vector to a canvas and verify its BLAKE3 against the frozen native hash in-page. verify_int_synth.sh + verify_int_synth_wasm.mjs — reproducible CLI proof. Verified: all four conformance vectors (incl. the real trained 128×128 photo model, 21.6 dB) decode in wasm32 byte-identical to the frozen NATIVE corpus hashes. Deterministic learned-codec decode in-browser, zero JS ML runtime. Co-Authored-By: Claude Opus 4.8 <[email protected]>
2.1 KiB
wai-web demo — interactive-worlds browser sink
world.html is a conformant wai.world.replay sink running in a tab:
the WWLD payload (a tick-0 world + signed op log, ~1.3 KB for the truss
vector) is re-derived frame by frame in WebGPU by the same wai
crate native sinks run, compiled to wasm32 with the codec chain off
(--no-default-features --features world). At the sealed final tick
the sink recomputes the BLAKE3 state hash and compares it to the
publisher's Ed25519-signed seal — replay-equivalence, demonstrated:
the hash the browser computes is byte-identical to
world-conformance/expected_hashes.json.
Run
# from wai-web/: rebuild the wasm pkg after engine changes
wasm-pack build --target web --out-dir demo/pkg
# vectors come from the conformance corpus
cp ../world-conformance/vectors/{truss_fracture,ballistic_bounce,basic_kinematics}.wwld demo/vectors/
# serve (any static server; WASM needs http, not file://)
python3 -m http.server 8741
# → http://localhost:8741/demo/world.html
Needs a WebGPU browser (Chrome/Edge stable, Safari TP). No build steps beyond wasm-pack; no JS dependencies.
int_synth.html — integer-exact neural image sink (no ML runtime)
int_synth.html decodes a wai.neural.int_synth payload to RGB with the
same pure-i64 Rust that decodes natively, compiled to wasm32 — no
onnxruntime-web, no WebGPU, no float. Because the decode is integer all the
way down (the integer-entropy contract, SPEC §6), the reconstruction is
byte-identical on every machine, so the page re-checks its BLAKE3 against the
hash the native reference froze into neural-conformance/expected_hashes.json.
The four staged vectors (demo/int_synth/, copied from the corpus) include the
real trained photo model (128×128, 21.6 dB PSNR).
# from wai-web/: build the web pkg, then serve
wasm-pack build --release --target web --out-dir demo/pkg --out-name wai_web
python3 -m http.server 8741 # → http://localhost:8741/demo/int_synth.html
Reproducible CLI proof that the wasm decode equals the native corpus (builds the nodejs-target pkg and checks all four vectors' hashes):
./demo/verify_int_synth.sh