code wiki / (root) / nx_craft_gait_fit_t139.nx

nx_craft_gait_fit_t139.nx source

↩ module page · 193 lines · 12128 B

1// ORIGINAL. Private generated-page observation; never calls either publishing main. 2import "nx_craft_gait_emit_t139.nx" 3import "nx_estate_path.nx" 4import "nx_readcap_lib.nx" 5import "nx_wasm_memory_lib.nx" 6import "nx_gate_verdict.nx" 7import "nx_glsl_tok_lib.nx" 8const PFG_CANARY: i64 = 173 // Test poison, not a product threshold. 9func pfg_private(path: *u8) -> i64 { 10 let prefix: *u8 = "/tmp/" as *u8 11 var i: i64 = 0 12 while i<5 { if path[i]!=prefix[i] { return 0 };i=i+1 } 13 if path[i]==(0 as u8) { return 0 } 14 while path[i]!=(0 as u8) { 15 if path[i]==(47 as u8) { return 0 } 16 if path[i]==(46 as u8) { if path[i+1]==(46 as u8) { return 0 } } 17 i=i+1 18 } 19 return 1 20} 21func pfg_read(path: *u8,out: *u8,state: *i64) -> i64 { 22 let fd: i64=sys_openat_rd(path) 23 if fd<0 { return 0-1 } 24 let n: i64=rc_fill_file(fd,out,GPE_WASM_CAP,state) 25 let closed: i64=sys_close(fd) 26 if rc_complete(state)!=1||closed!=0 { return 0-1 } 27 return n 28} 29func pfg_extent(text:*u8)->i64 { 30 var value:i64=0;var i:i64=0 31 while text[i]!=(0 as u8) { 32 let c:i64=text[i] as i64 33 if c<48||c>57 {return -1} 34 let digit:i64=c-48 35 if value>(9223372036854775807-digit)/10 {return -1} 36 value=value*10+digit;i=i+1 37 } 38 if i==0||value<=0{return -1} 39 return value 40} 41// Whole-shader canonical references retain incumbent features. Fragment reference only distributes 42// the existing authored guard over its six branches and applies the separately reviewed sun correction. 43func pfg_stage_parity(buf:*u8,n:i64,reference:*u8,rn:i64,begin:*u8,end:*u8)->i64 { 44 let span:*i64=sys_mmap(16) as *i64 45 if rk_world_span(buf,n,begin,end,span)!=1 {sys_munmap(span as *u8,16);return -1} 46 let verdict:*i64=sys_mmap(GT_R_SLOTS*8) as *i64 47 let rc:i64=gt_diff_canon(reference,rn,(buf as i64+span[0]) as *u8,span[1]-span[0],verdict) 48 sys_munmap(span as *u8,16);sys_munmap(verdict as *u8,GT_R_SLOTS*8) 49 return rc 50} 51func pfg_skin_lowered(buf:*u8,n:i64)->i64 { 52 let span:*i64=sys_mmap(16) as *i64 53 if (span as i64)<=0{return 0} 54 if rk_world_span(buf,n,RK_CAST_FS_BEGIN,RK_CAST_FS_END,span)!=1{sys_munmap(span as *u8,16);return 0} 55 let text:*u8=(buf as i64+span[0]) as *u8;let bytes:i64=span[1]-span[0] 56 var valid:i64=1 57 if rk_find(text,bytes,0,"texture(")>=0{valid=0} 58 if rk_find(text,bytes,0,"textureSample(uAtl,uAtl_s,vin.vUV).a")<0{valid=0} 59 if rk_find(text,bytes,0,"textureSample(uNrm,uNrm_s,vin.vUV).a")<0{valid=0} 60 sys_munmap(span as *u8,16);return valid 61} 62 63func pfg_cast_contract(ctr:*i64)->i64 { 64 let vp:*u8="buildroot/knowledge/gates/t73-cast-vertex-reference.glsl" 65 let fp:*u8="buildroot/knowledge/gates/skin-visible-fragment-reference-t138.glsl" 66 let bp:*u8="buildroot/knowledge/gates/skin-sun-t127-cast.txt" 67 let cp:*u8="buildroot/knowledge/gates/skin-sun-authored-t129-cast.txt" 68 let refs:i64=gsb_artifact_matches(vp,"ae259ed446f68961a5fc4fa489964e3053b9bd1b108f033b71163df3c84a8599",16389)&gsb_artifact_matches(fp,"eefab5ec05fb29f18abacba4f7cc062ad0876886641854592f026a75ca083ab7",16098) 69 let negatives:i64=gsb_artifact_matches(bp,"f26004e497d5c1be6a0ff74306a4fed482b9db4f039253a0128f3af0d8c8cbba",49988)&gsb_artifact_matches(cp,"6a907f759e1fe151b676c2eb3277f33906da12657b8fa699a6e37b37f3e6b60e",50168) 70 gv_check("shader reference and known-negative identities verified",refs==1&&negatives==1,ctr) 71 if refs!=1||negatives!=1 {return 0} 72 var vn:i64=0;var fn:i64=0;var bn:i64=0;var cn:i64=0 73 let v:*u8=sys_read_file(vp,&vn);let f:*u8=sys_read_file(fp,&fn);let bad:*u8=sys_read_file(bp,&bn);let old:*u8=sys_read_file(cp,&cn) 74 let current:*u8=sys_mmap(RK_WGSL_CAP);var n:i64=0 75 let capture:i64=gsb_capture_selected(gpe_cast_path,gpe_cast_expected,gpe_cast_expected_bytes,"cast",current,RK_WGSL_CAP,&n,RK_WGSL_TMO_MS) 76 gv_check("exact selected shader producer captured for contract",capture==0&&n>0,ctr) 77 if capture!=0||n<=0 {return 0} 78 gv_check("skin texture operations lowered to WGSL sampler primitive",pfg_skin_lowered(current,n)==1,ctr) 79 var broken_n:i64=0;let broken:*u8=sys_read_file("/tmp/skin-cast-full-t138.txt",&broken_n) 80 gv_check("actual prior generic texture failure refused",(broken as i64)>0&&broken_n>0&&pfg_skin_lowered(broken,broken_n)==0,ctr) 81 if (broken as i64)>0{sys_free_file(broken,broken_n)} 82 gv_check("complete cast capture exclusively retained",fxc_create("/tmp/gait-adopted-cast-canonical-qualified-t139.txt",current,n)==n,ctr) 83 let pv:i64=pfg_stage_parity(current,n,v,vn,RK_CAST_GLSL_VS_BEGIN,RK_CAST_GLSL_VS_END) 84 let pf:i64=pfg_stage_parity(current,n,f,fn,RK_CAST_GLSL_FS_BEGIN,RK_CAST_GLSL_FS_END) 85 gv_check("whole generated vertex retains incumbent face and garment behavior",pv==GT_V_IDENTICAL,ctr) 86 gv_check("whole generated fragment matches reviewed private skin map reference",pf==GT_V_IDENTICAL,ctr) 87 gv_check("known b9e6 capture without authored guards is refused",pfg_stage_parity(bad,bn,f,fn,RK_CAST_GLSL_FS_BEGIN,RK_CAST_GLSL_FS_END)==GT_V_DIFFERS,ctr) 88 gv_check("known c17f capture without face relief is refused",pfg_stage_parity(old,cn,v,vn,RK_CAST_GLSL_VS_BEGIN,RK_CAST_GLSL_VS_END)==GT_V_DIFFERS,ctr) 89 gv_check("truncated shader capture cannot satisfy fragment contract",pfg_stage_parity(current,WM_HEADER,f,fn,RK_CAST_GLSL_FS_BEGIN,RK_CAST_GLSL_FS_END)==-1,ctr) 90 let output:*u8=sys_mmap(RK_WGSL_CAP*2) 91 let emitted:i64=rk_cast_glsl(output,0,current,n) 92 gv_check("selected GLSL capture binds both actual consumer constants",emitted>0&&gsb_failed==0&&rk_find(output,emitted,0,"const MVS=")>=0&&rk_find(output,emitted,0,"const MFS=")>=0,ctr) 93 let count_at:i64=rk_find(current,n,0,"cast_glsl_rc=") 94 if count_at<0 {return 0} 95 let digit_at:i64=count_at+rk_slen("cast_glsl_rc=") 96 let saved:u8=current[digit_at] 97 current[digit_at]=57 as u8 98 let refused:i64=rk_cast_glsl(output,0,current,n) 99 gv_check("mismatched producer byte count refuses GLSL emission",refused==0&&gsb_failed==1,ctr) 100 current[digit_at]=saved;gsb_failed=0 101 sys_munmap(output,RK_WGSL_CAP*2) 102 sys_free_file(v,vn);sys_free_file(f,fn);sys_free_file(bad,bn);sys_free_file(old,cn);sys_munmap(current,RK_WGSL_CAP) 103 if pv!=GT_V_IDENTICAL||pf!=GT_V_IDENTICAL {return 0} 104 return 1 105} 106 107func main(argc: i64,argv: *i64) -> i64 { 108 if argc!=7&&argc!=10 { gv_puts("usage: private-page-fit <plain.wasm> <shared.wasm-or-dash> <recipe-key> </tmp/new-basename.html> <plain-sha256> <shared-sha256-or-dash> [world-producer-path world-sha256 world-bytes]\n" as *u8);return 3 } 109 if pfg_private(argv[4] as *u8)!=1 { return 3 } 110 if ep_anchor()<0 { return 3 } 111 let ctr: *i64=gv_ctr();gv_head("PRIVATE-GENERATED-PAGE-FIT" as *u8) 112 var world_path:*u8=GSB_STAGED 113 var world_sha:*u8="6a63a26f84a4ba353da798e121a1690a89bf4cac3e59f1dd9e7babe948f33139" 114 var world_bytes:i64=1250264 115 if argc==10 {world_path=argv[7] as *u8;world_sha=argv[8] as *u8;world_bytes=pfg_extent(argv[9] as *u8)} 116 let selected:i64=gsb_select_at(world_path,world_sha,world_bytes) 117 gpe_cast_path="/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_wgsl_canonical_skin_t140.sov.elf" as *u8 118 gpe_cast_expected="5eb2ec4370ab497ba5861fb54c3a680db19ac94eaa3aa383fb75725c40327e37" as *u8 119 gpe_cast_expected_bytes=1274336 120 gv_check("declared cast-only producer identity verified" as *u8,gsb_artifact_matches(gpe_cast_path,gpe_cast_expected,gpe_cast_expected_bytes)==1,ctr) 121 gv_check("declared staged shader producer selected" as *u8,selected==1,ctr) 122 if selected!=1 { return 3 } 123 gv_puts("shader_backend_path=");gv_puts(world_path);gv_puts(" shader_backend_sha256=");gv_puts(world_sha);gv_kv("shader_backend_bytes",world_bytes) 124 if pfg_cast_contract(ctr)!=1 {return 3} 125 let wasm: *u8=sys_mmap(GPE_WASM_CAP) 126 let state: *i64=sys_mmap(3*__size_of(i64)) as *i64 127 let digest: *u8=sys_mmap(GPA_SHA_HEX+1) 128 let limits: *i64=sys_mmap(WM_FIELDS*__size_of(i64)) as *i64 129 let recipes: *i64=sys_mmap(GPR_MAXW*8*8) as *i64 130 let controls: *u8=sys_mmap(CE_EV_CAP) 131 // The second full output-capacity span observes contiguous overruns in this isolated gate. 132 // It is not a general capacity fix for production gpe_ap. 133 let out: *u8=sys_mmap(GPE_OUT_CAP+GPE_OUT_CAP) 134 if (wasm as i64)<=0||(state as i64)<=0||(digest as i64)<=0||(limits as i64)<=0||(recipes as i64)<=0||(controls as i64)<=0||(out as i64)<=0 { return 3 } 135 let wn: i64=pfg_read(argv[1] as *u8,wasm,state) 136 gv_check("whole plain artifact read" as *u8,wn>WM_HEADER,ctr) 137 if wn<=WM_HEADER { return 3 } 138 gpa_sha(wasm,wn,digest) 139 gv_check("plain identity equals requested SHA256" as *u8,fsx_seq(digest,argv[5] as *u8)==1,ctr) 140 if fsx_seq(digest,argv[5] as *u8)!=1 { return 3 } 141 gpe_mt_pages=0;gpe_mt_max=0;gpe_mt_sha=0 as *u8;gpe_mt_url=0 as *u8;gpe_mt_bytes=0 142 if fsx_seq(argv[2] as *u8,"-" as *u8)!=1 { 143 let twin: *u8=sys_mmap(GPE_WASM_CAP) 144 if (twin as i64)<=0 { return 3 } 145 let tn: i64=pfg_read(argv[2] as *u8,twin,state) 146 if tn<=WM_HEADER { return 3 } 147 gpa_sha(twin,tn,digest) 148 gv_check("shared identity equals requested SHA256" as *u8,fsx_seq(digest,argv[6] as *u8)==1,ctr) 149 if fsx_seq(digest,argv[6] as *u8)!=1 { return 3 } 150 let mr: i64=wmem_read(twin,tn,limits) 151 gv_check("actual shared descriptor admitted" as *u8,mr==0&&limits[2]==1&&limits[3]==1&&limits[0]>0&&limits[1]>=limits[0],ctr) 152 if mr!=0||limits[2]!=1||limits[3]!=1||limits[0]<1||limits[1]<limits[0] { return 3 } 153 gv_check("shared identity declaration accepted",gpe_mt_declare(twin,tn,0 as *u8,limits[0],limits[1])==1,ctr) 154 if gpe_mt_pages<1 {return 3} 155 sys_munmap(twin,GPE_WASM_CAP) 156 } 157 let nr: i64=gpe_recipes_load("knowledge/world_recipes.conf" as *u8,recipes) 158 if nr<1 { return 3 } 159 var row: i64=0-1;var i: i64=0;var matches: i64=0 160 while i<nr { if fsx_seq(recipes[i*8] as *u8,argv[3] as *u8)==1 { row=i*8;matches=matches+1 };i=i+1 } 161 gv_check("one actual recipe selected" as *u8,matches==1,ctr) 162 if matches!=1 { return 3 } 163 ce_evidence(recipes[row+5] as *u8,controls) 164 i=GPE_OUT_CAP 165 while i<GPE_OUT_CAP+GPE_OUT_CAP { out[i]=PFG_CANARY as u8;i=i+1 } 166 var n: i64=gpe_build_s(wasm,wn,ce_stamp(recipes[row+4] as *u8),CE_NATIVE,controls,recipes[row+1],recipes[row+2],recipes[row+6] as *u8,out) 167 if gpe_mt_pages>0 { 168 let declared:*u8=sys_mmap(GPE_OUT_CAP) 169 let dn:i64=gpa_declare_shared(out,n,gpe_mt_url,declared,GPE_OUT_CAP) 170 gv_check("shared runtime manifest derives from verified artifact" as *u8,dn>0&&dn<=GPE_OUT_CAP,ctr) 171 if dn<=0||dn>GPE_OUT_CAP {return 3} 172 var at:i64=0;while at<dn {out[at]=declared[at];at=at+1};n=dn 173 sys_munmap(declared,GPE_OUT_CAP) 174 } 175 var intact: i64=1;i=GPE_OUT_CAP 176 while i<GPE_OUT_CAP+GPE_OUT_CAP { if out[i]!=(PFG_CANARY as u8) { intact=0 };i=i+1 } 177 gv_check("full adjacent capacity span unchanged" as *u8,intact==1,ctr) 178 gv_check("actual returned page length fits production allocation" as *u8,n>0&&n<=GPE_OUT_CAP,ctr) 179 gv_check("shader capture owner reports success" as *u8,gsb_failed==0,ctr) 180 gv_values_head();gv_kv("page_bytes" as *u8,n);gv_kv("output_capacity" as *u8,GPE_OUT_CAP);gv_kv("headroom_bytes" as *u8,GPE_OUT_CAP-n) 181 gv_kv("twin_minimum_pages" as *u8,gpe_mt_pages);gv_kv("twin_maximum_pages" as *u8,gpe_mt_max) 182 if intact!=1||n<=0||n>GPE_OUT_CAP||gsb_failed!=0 { return gv_verdict("PRIVATE-PAGE-FIT" as *u8,ctr,"private output refused" as *u8) } 183 gpa_sha(out,n,digest);gv_puts("page_sha256=" as *u8);gv_puts(digest);gv_puts("\n" as *u8) 184 let wrote: i64=fxc_create(argv[4] as *u8,out,n) 185 gv_check("private output exclusively created" as *u8,wrote==n,ctr) 186 if wrote==n { 187 let box: *i64=sys_mmap(__size_of(i64)) as *i64 188 if (box as i64)<=0 { return 3 } 189 let actual: *u8=sys_read_file(argv[4] as *u8,box) 190 gv_check("private output readback equals generated bytes" as *u8,(actual as i64)>0&&gpa_same(out,n,actual,box[0])==1,ctr) 191 } 192 return gv_verdict("PRIVATE-PAGE-FIT" as *u8,ctr,"private fixture only; transfer actual bytes for JS syntax; browser and visual acceptance still open" as *u8) 193}