code wiki / _hdl_build / nx_wasm_craft_vm_gate.nx

nx_wasm_craft_vm_gate.nx

buildroot/runtime/_hdl_build/nx_wasm_craft_vm_gate.nx

31378 B526 linesdepth 6pulls 35 transitivereach 0 importersview sourcekind gate/prooftopic wasm
docsdependenciesstructsconstsfunctions

about

nx_wasm_craft_vm_gate.nx -- RUN THE SHIPPED CRAFT WASM, IN THE MEMORY THE BROWSER GIVES IT. WHY THIS EXISTS, stated plainly. On 2026-08-14 /craft shipped BROKEN TWICE while nx_wasm_craft_gate reported 59/59 GREEN both times, because that gate is NATIVE: it sys_mmaps CRAFT_TOTAL and therefore never meets the wasm memory bound at all. The WAT backend emits a FIXED 192 pages (12,582,912 bytes) without consulting the module's constants, so when the render ceiling was raised the arena outgrew it by 9.4 MB and every browser frame trapped with "index out of bounds". A page that traps paints NOTHING -- which is also how the characters disappeared, since mob_draw runs inside that render. ★THE LESSON THIS ORGAN ENCODES: A GATE THAT TESTS A DIFFERENT BUILD THAN THE ONE THAT SHIPS IS NOT TESTING THE PRODUCT. The native gate and the wasm are two builds of one source, and only one of them is what a visitor loads. This runs the ACTUAL .wasm the emitter produced, in a linear memory sized to exactly what the module declares, through the estate's own VM -- the same shape six sibling sims already use (nx_pendulum_wasm_vm_gate and friends) and which craft, the biggest of them, lacked. The two teeth are the two ways it broke, in the order it broke them: FITS -- the worst-case framebuffer (q=1, one ray per pixel) must lie inside the declared memory PAINTS -- after init+render the framebuffer must carry more than one colour PERF -- (2026-09-04) the long-frame door: perf_frame/perf_n/perf_long through the exports the page calls Neither can be satisfied by a trapping module, and PAINTS cannot be satisfied by a blank frame. license_tier: ORIGINAL expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_wasm_vm.nx nx_wasm_craft.nx nx_gate_verdict.nx nx_wasm_craft_vm_gate.nx

imports: nx_syscalls.nxnx_wasm_vm.nxnx_wasm_craft.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

structs

none

consts

27const CV_WASM: *u8 = "buildroot/_build/nx_wasm_craft_emit.wasm"
28const CV_COLCAP: i64 = 4096
29const CV_PERF_SHORT_MS: i64 = 7 // a frame under every bar: budget and the 50 ms long-frame line
30const CV_PERF_LONG_MS: i64 = 60 // one frame past the Long Animation Frame bar (50 ms, ref ge-loaf)
53const CV_SEED: i64 = 20260728
56const CV_PATCH: i64 = 8
57const CV_PATCH_X0: i64 = 60
58const CV_PATCH_Z0: i64 = 60
59const CV_CAM_UP: i64 = 3 // the seed rows 1-3 of world_recipes.conf ship at
60const CV_LAT: i64 = 24 // lattice side -> 576 height queries per scenario
61const CV_STRIDE: i64 = 5 // blocks between lattice points: >= the detail octave's own
63const CV_ERK: i64 = 1 // THE BUDGET CRAFT ACTUALLY SHIPS AT -- kept equal to the
71const CV_TBASE: i64 = 4 // craft's shipped identity (wc_spec v0), so the subject is
72const CV_TAMP1: i64 = 17 // the land the visitor actually arrives on rather than a
73const CV_TAMP2: i64 = 5 // shape invented for the test
74const CV_TALPROBE: i64 = 384 // 1.5 blocks in WC_ER_Q units -- a representative threshold
75const CV_DSWEEP: i64 = 2048 // +-8 blocks in WC_ER_Q units, wider than craft's relief

functions

32func cv_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
33func cv_n(v: i64) -> i64
42func cv_rd64(m: *u8, o: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v = v | ((m[o+i] as i64) << (i*8)); i=i+1 } return v }
43func cv_wr64(m: *u8, o: i64, v: i64) -> i64 { var i: i64=0; while i<8 { m[o+i] = ((v >> (i*8)) & 255) as u8; i=i+1 } return 0 }
77func cv_spec(mod: *WasmMod, a1: i64, a2: i64, k: i64) -> i64
85func cv_sample(mod: *WasmMod, fn: *u8, out: *i64) -> i64
103func cv_hi(h: *i64, n: i64) -> i64
117func cv_ndiff(a: *i64, b: *i64, n: i64) -> i64
125func cv_sample_at(mod: *WasmMod, fn: *u8, st: i64, out: *i64) -> i64
151func cv_rug(h: *i64, side: i64) -> i64
192func cv_arg_equal(a: *u8, b: *u8) -> i64
202func main(argc: i64, argv: *i64) -> i64