code wiki / (root) / nx_imported_body_placement_gate_t316.nx

nx_imported_body_placement_gate_t316.nx source

↩ module page · 80 lines · 7019 B

1// Actual compiled plain/shared body API and movement execution through the existing sovereign VM. 2import "nx_wasm_vm.nx" 3import "_hdl_build/nx_wasm_craft_imported_t262.nx" 4import "nx_gate_verdict.nx" 5func bv_module(bytes:*u8,n:i64,ctr:*i64)->i64{ 6 let mod:*WasmMod=wm_new(bytes,n);let parsed:i64=wm_parse(mod) 7 gv_check("actual compiled body module parses",parsed==0,ctr) 8 if parsed!=0{return 3} 9 gv_kv("parsed_exports",mod.n_exports);gv_kv("parsed_functions",mod.n_funcs) 10 let stage:i64=wm_run(mod,"body_stage_off",0,0,0,0,0,0) 11 let read_off:i64=wm_run(mod,"body_read_off",0,0,0,0,0,0) 12 let required_pages:i64=wm_run(mod,"wasm_pages_req",0,0,0,0,0,0) 13 gv_check_eq("ABI stage offset",stage,O_IMPORTED_STAGE,ctr) 14 gv_check_eq("ABI read offset",read_off,O_IMPORTED_READ,ctr) 15 gv_check_eq("ABI required pages",required_pages,WASM_PAGES_REQ,ctr) 16 gv_check("compiled exports pin source-owned record and arena bounds",stage==O_IMPORTED_STAGE&&read_off==O_IMPORTED_READ&&required_pages==WASM_PAGES_REQ,ctr) 17 if stage!=O_IMPORTED_STAGE||read_off!=O_IMPORTED_READ||required_pages!=WASM_PAGES_REQ{return 3} 18 // Model the existing page's required-memory growth, retaining the module's initialized bytes. 19 if mod.mem_bytes<required_pages*WASM_PAGE_BYTES{ 20 let expanded:*u8=sys_mmap(required_pages*WASM_PAGE_BYTES);var i:i64=0 21 while i<mod.mem_bytes{expanded[i]=mod.mem[i];i=i+1} 22 mod.mem=expanded;mod.mem_bytes=required_pages*WASM_PAGE_BYTES 23 } 24 let affine_at:i64=wm_run(mod,"body_affine_input_off",0,0,0,0,0,0) 25 let affine_out:i64=wm_run(mod,"body_affine_bounds_off",0,0,0,0,0,0) 26 gv_check("compiled static affine ABI owns fixed scratch",affine_at==O_BODY_AFFINE_INPUT&&affine_out==O_BODY_AFFINE_BOUNDS&&wm_run(mod,"body_affine_input_words",0,0,0,0,0,0)==13,ctr) 27 if affine_at!=O_BODY_AFFINE_INPUT||affine_out!=O_BODY_AFFINE_BOUNDS{return 3} 28 let affine_input:*i64=(mod.mem+affine_at) as *i64 29 affine_input[0]=3368583808; affine_input[1]=3369967584; affine_input[2]=3284336640; affine_input[3]=1221100160; affine_input[4]=1197423872; affine_input[5]=1231684256; affine_input[6]=0; affine_input[7]=1065353216; affine_input[8]=925768117; affine_input[9]=1043803405; affine_input[10]=1056964608; affine_input[11]=1111229202; affine_input[12]=1123876864 30 let bounds_rc:i64=wm_run(mod,"body_static_bounds",1,0,0,0,0,1) 31 let actual_bounds:*i64=(mod.mem+affine_out) as *i64 32 gv_check("compiled static transform encloses actual VERT reference",bounds_rc==0&&actual_bounds[0]<=0-68&&actual_bounds[1]<=12032&&actual_bounds[2]<=32356&&actual_bounds[3]>=324&&actual_bounds[4]>=12489&&actual_bounds[5]>=32600,ctr) 33 let unchanged_bound:i64=actual_bounds[0] 34 gv_check("compiled unsupported deformation contract refuses without output mutation",wm_run(mod,"body_static_bounds",2,0,0,0,0,1)==IBR_BAD&&actual_bounds[0]==unchanged_bound,ctr) 35 gv_check("compiled fresh capacity reports zero",wm_run(mod,"body_capacity_current",0,0,0,0,0,0)==0,ctr) 36 gv_check("compiled init refuses insufficient available memory",wm_run(mod,"body_init",2,CRAFT_EXT_TOTAL-1,0,0,0,2)==IBR_CAPACITY,ctr) 37 gv_check("compiled init accepts bounded explicit capacity",wm_run(mod,"body_init",2,mod.mem_bytes,0,0,0,2)==0,ctr) 38 gv_check("compiled existing nondefault capacity is observable",wm_run(mod,"body_capacity_current",0,0,0,0,0,0)==2,ctr) 39 gv_check("compiled explicit incompatible reinit refuses without changing capacity",wm_run(mod,"body_init",3,mod.mem_bytes,0,0,0,2)==IBR_CONFLICT&&wm_run(mod,"body_capacity_current",0,0,0,0,0,0)==2,ctr) 40 let record:*i64=(mod.mem+stage) as *i64 41 record[IBR_ID_HI]=7;record[IBR_ID_LO]=111;record[IBR_REV]=1;record[IBR_SHAPE_REV]=1;record[IBR_POSE_REV]=1 42 record[IBR_WORLD_X]=1000;record[IBR_WORLD_Y]=0;record[IBR_WORLD_Z]=1024 43 record[IBR_MIN_X]=0-100;record[IBR_MIN_Y]=0;record[IBR_MIN_Z]=0-100 44 record[IBR_MAX_X]=100;record[IBR_MAX_Y]=500;record[IBR_MAX_Z]=100 45 record[IBR_LAYER]=4;record[IBR_MASK]=BODY_LAYER_PLAYER|BODY_LAYER_NPC;record[IBR_ENABLED]=1;record[IBR_KIND]=1 46 let handle:i64=wm_run(mod,"body_bind",0,0,0,0,0,0) 47 gv_check("compiled bind retains stable physical handle",handle>0&&wm_run(mod,"body_bind",0,0,0,0,0,0)==handle&&wm_run(mod,"body_count",0,0,0,0,0,0)==1,ctr) 48 gv_check("compiled instance lookup and read exposes geometry revisions",wm_run(mod,"body_handle",7,111,0,0,0,2)==handle&&wm_run(mod,"body_read",handle,0,0,0,0,1)==0,ctr) 49 let exposed:*i64=(mod.mem+read_off) as *i64 50 gv_check("compiled body read preserves authored policy and coordinates",exposed[IBR_SHAPE_REV]==1&&exposed[IBR_WORLD_X]==1000&&exposed[IBR_KIND]==IBR_SHAPE_AABB,ctr) 51 record[IBR_REV]=2;record[IBR_MIN_X]=0-101 52 gv_check("compiled unchanged shape revision refuses changed geometry",wm_run(mod,"body_bind",0,0,0,0,0,0)==IBR_CONFLICT,ctr) 53 record[IBR_REV]=1;record[IBR_MIN_X]=0-100 54 let state:*i64=(mod.mem+O_ST) as *i64;state[S_CX]=0;state[S_CY]=EYE;state[S_CZ]=1024 55 let moved:i64=wm_run(mod,"wc_player_axis_apply",0,0,2000,0,0,4) 56 gv_check("actual compiled player movement stops before imported body",moved==900&&state[S_CX]==900,ctr) 57 let collision:*i64=(mod.mem+O_CONTACT+(2*CONTACT_BOX_WORDS+CONTACT_RESULT_WORDS)*8) as *i64 58 gv_check("compiled player collision audit records blocked axis",collision[1]==1,ctr) 59 let arguments:*i64=sys_mmap(48) as *i64 60 arguments[0]=0;arguments[1]=0;arguments[2]=0;arguments[3]=1024;arguments[4]=0;arguments[5]=2000 61 let fidx:i64=wm_find_export(mod,"wc_body_mob_axis") 62 gv_check("compiled NPC movement helper is callable",fidx>=0,ctr) 63 if fidx>=0{gv_check("actual compiled NPC shape stops before imported body",wm_call(mod,fidx,arguments,6)==900-MOB_R_Q8,ctr)} 64 if fidx>=0{arguments[1]=1000;arguments[2]=600;arguments[3]=1024;arguments[4]=1;arguments[5]=0-2000;gv_check("compiled NPC downward sweep stops on imported top",wm_call(mod,fidx,arguments,6)==0-100,ctr)} 65 state[S_CX]=0-4096;state[S_WOX]=16 66 gv_check("compiled origin-relative movement keeps physical body fixed",wm_run(mod,"wc_player_axis_apply",0,0,2000,0,0,4)==900&&state[S_CX]==900-4096,ctr) 67 gv_check("compiled identity survives origin transition",wm_run(mod,"body_handle",7,111,0,0,0,2)==handle,ctr) 68 state[S_CX]=1000-4096 69 gv_check("compiled overlap refuses arbitrary displacement",wm_run(mod,"wc_player_axis_apply",0,0,100,0,0,4)==0&&state[S_CX]==1000-4096,ctr) 70 return 0 71} 72func main()->i64{ 73 let ctr:*i64=gv_ctr();gv_head("IMPORTED-BODY-ACTUAL-WASM") 74 let length:*i64=sys_mmap(8) as *i64 75 let plain:*u8=sys_read_file("/volume1/homes/elderwesto/nishihost/buildroot/knowledge/gates/imported-placement-plain-r2-t316.wasm",length);let pn:i64=length[0] 76 let shared:*u8=sys_read_file("/volume1/homes/elderwesto/nishihost/buildroot/knowledge/gates/imported-placement-shared-r2-t316.wasm",length);let sn:i64=length[0] 77 if (plain as i64)<=0||(shared as i64)<=0{return 3} 78 bv_module(plain,pn,ctr);bv_module(shared,sn,ctr) 79 return gv_verdict("IMPORTED-BODY-ACTUAL-WASM",ctr,"Actual bytecode interpreted; required host memory growth modeled; threaded execution, page wiring, shape/visual coverage and serialization remain unqualified.") 80}