code wiki / (root) / nx_craft_visitors_inspection_fit_t142.nx

nx_craft_visitors_inspection_fit_t142.nx source

↩ module page · 206 lines · 12588 B

1// ORIGINAL. Private generated-page observation; never calls either publishing main. 2import "nx_craft_visitors_inspection_emit_t142.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_capture_retain(path:*u8,current:*u8,n:i64)->i64 { 64 let box:*i64=sys_mmap(8) as *i64 65 if (box as i64)<=0 {return 0} 66 let existing:*u8=sys_read_file(path,box) 67 if (existing as i64)>0 { 68 let same:i64=gpa_same(current,n,existing,box[0]) 69 sys_munmap(existing,box[0]);sys_munmap(box,8) 70 return same 71 } 72 sys_munmap(box,8) 73 if fxc_create(path,current,n)==n {return 1} 74 return 0 75} 76func pfg_cast_contract(ctr:*i64)->i64 { 77 let vp:*u8="buildroot/knowledge/gates/t73-cast-vertex-reference.glsl" 78 let fp:*u8="buildroot/knowledge/gates/skin-visible-fragment-reference-t138.glsl" 79 let bp:*u8="buildroot/knowledge/gates/skin-sun-t127-cast.txt" 80 let cp:*u8="buildroot/knowledge/gates/skin-sun-authored-t129-cast.txt" 81 let refs:i64=gsb_artifact_matches(vp,"ae259ed446f68961a5fc4fa489964e3053b9bd1b108f033b71163df3c84a8599",16389)&gsb_artifact_matches(fp,"eefab5ec05fb29f18abacba4f7cc062ad0876886641854592f026a75ca083ab7",16098) 82 let negatives:i64=gsb_artifact_matches(bp,"f26004e497d5c1be6a0ff74306a4fed482b9db4f039253a0128f3af0d8c8cbba",49988)&gsb_artifact_matches(cp,"6a907f759e1fe151b676c2eb3277f33906da12657b8fa699a6e37b37f3e6b60e",50168) 83 gv_check("shader reference and known-negative identities verified",refs==1&&negatives==1,ctr) 84 if refs!=1||negatives!=1 {return 0} 85 var vn:i64=0;var fn:i64=0;var bn:i64=0;var cn:i64=0 86 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) 87 let current:*u8=sys_mmap(RK_WGSL_CAP);var n:i64=0 88 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) 89 gv_check("exact selected shader producer captured for contract",capture==0&&n>0,ctr) 90 if capture!=0||n<=0 {return 0} 91 gv_check("skin texture operations lowered to WGSL sampler primitive",pfg_skin_lowered(current,n)==1,ctr) 92 var broken_n:i64=0;let broken:*u8=sys_read_file("/tmp/skin-cast-full-t138.txt",&broken_n) 93 gv_check("actual prior generic texture failure refused",(broken as i64)>0&&broken_n>0&&pfg_skin_lowered(broken,broken_n)==0,ctr) 94 if (broken as i64)>0{sys_free_file(broken,broken_n)} 95 gv_check("complete cast capture newly retained or exact prior bytes",pfg_capture_retain("/tmp/visitors-cast-canonical-qualified-t140.txt",current,n)==1,ctr) 96 let pv:i64=pfg_stage_parity(current,n,v,vn,RK_CAST_GLSL_VS_BEGIN,RK_CAST_GLSL_VS_END) 97 let pf:i64=pfg_stage_parity(current,n,f,fn,RK_CAST_GLSL_FS_BEGIN,RK_CAST_GLSL_FS_END) 98 gv_check("whole generated vertex retains incumbent face and garment behavior",pv==GT_V_IDENTICAL,ctr) 99 gv_check("whole generated fragment matches reviewed private skin map reference",pf==GT_V_IDENTICAL,ctr) 100 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) 101 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) 102 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) 103 let output:*u8=sys_mmap(RK_WGSL_CAP*2) 104 let emitted:i64=rk_cast_glsl(output,0,current,n) 105 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) 106 let count_at:i64=rk_find(current,n,0,"cast_glsl_rc=") 107 if count_at<0 {return 0} 108 let digit_at:i64=count_at+rk_slen("cast_glsl_rc=") 109 let saved:u8=current[digit_at] 110 current[digit_at]=57 as u8 111 let refused:i64=rk_cast_glsl(output,0,current,n) 112 gv_check("mismatched producer byte count refuses GLSL emission",refused==0&&gsb_failed==1,ctr) 113 current[digit_at]=saved;gsb_failed=0 114 sys_munmap(output,RK_WGSL_CAP*2) 115 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) 116 if pv!=GT_V_IDENTICAL||pf!=GT_V_IDENTICAL {return 0} 117 return 1 118} 119 120func main(argc: i64,argv: *i64) -> i64 { 121 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 } 122 if pfg_private(argv[4] as *u8)!=1 { return 3 } 123 if ep_anchor()<0 { return 3 } 124 let ctr: *i64=gv_ctr();gv_head("PRIVATE-GENERATED-PAGE-FIT" as *u8) 125 var world_path:*u8=GSB_STAGED 126 var world_sha:*u8="6a63a26f84a4ba353da798e121a1690a89bf4cac3e59f1dd9e7babe948f33139" 127 var world_bytes:i64=1250264 128 if argc==10 {world_path=argv[7] as *u8;world_sha=argv[8] as *u8;world_bytes=pfg_extent(argv[9] as *u8)} 129 let selected:i64=gsb_select_at(world_path,world_sha,world_bytes) 130 gpe_cast_path="/volume1/homes/elderwesto/nishihost/buildroot/_build/nx_wgsl_canonical_skin_t140.sov.elf" as *u8 131 gpe_cast_expected="5eb2ec4370ab497ba5861fb54c3a680db19ac94eaa3aa383fb75725c40327e37" as *u8 132 gpe_cast_expected_bytes=1274336 133 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) 134 gv_check("declared staged shader producer selected" as *u8,selected==1,ctr) 135 if selected!=1 { return 3 } 136 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) 137 if pfg_cast_contract(ctr)!=1 {return 3} 138 let wasm: *u8=sys_mmap(GPE_WASM_CAP) 139 let state: *i64=sys_mmap(3*__size_of(i64)) as *i64 140 let digest: *u8=sys_mmap(GPA_SHA_HEX+1) 141 let limits: *i64=sys_mmap(WM_FIELDS*__size_of(i64)) as *i64 142 let recipes: *i64=sys_mmap(GPR_MAXW*8*8) as *i64 143 let controls: *u8=sys_mmap(CE_EV_CAP) 144 // The second full output-capacity span observes contiguous overruns in this isolated gate. 145 // It is not a general capacity fix for production gpe_ap. 146 let out: *u8=sys_mmap(GPE_OUT_CAP+GPE_OUT_CAP) 147 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 } 148 let wn: i64=pfg_read(argv[1] as *u8,wasm,state) 149 gv_check("whole plain artifact read" as *u8,wn>WM_HEADER,ctr) 150 if wn<=WM_HEADER { return 3 } 151 gpa_sha(wasm,wn,digest) 152 gv_check("plain identity equals requested SHA256" as *u8,fsx_seq(digest,argv[5] as *u8)==1,ctr) 153 if fsx_seq(digest,argv[5] as *u8)!=1 { return 3 } 154 gpe_mt_pages=0;gpe_mt_max=0;gpe_mt_sha=0 as *u8;gpe_mt_url=0 as *u8;gpe_mt_bytes=0 155 if fsx_seq(argv[2] as *u8,"-" as *u8)!=1 { 156 let twin: *u8=sys_mmap(GPE_WASM_CAP) 157 if (twin as i64)<=0 { return 3 } 158 let tn: i64=pfg_read(argv[2] as *u8,twin,state) 159 if tn<=WM_HEADER { return 3 } 160 gpa_sha(twin,tn,digest) 161 gv_check("shared identity equals requested SHA256" as *u8,fsx_seq(digest,argv[6] as *u8)==1,ctr) 162 if fsx_seq(digest,argv[6] as *u8)!=1 { return 3 } 163 let mr: i64=wmem_read(twin,tn,limits) 164 gv_check("actual shared descriptor admitted" as *u8,mr==0&&limits[2]==1&&limits[3]==1&&limits[0]>0&&limits[1]>=limits[0],ctr) 165 if mr!=0||limits[2]!=1||limits[3]!=1||limits[0]<1||limits[1]<limits[0] { return 3 } 166 gv_check("shared identity declaration accepted",gpe_mt_declare(twin,tn,0 as *u8,limits[0],limits[1])==1,ctr) 167 if gpe_mt_pages<1 {return 3} 168 sys_munmap(twin,GPE_WASM_CAP) 169 } 170 let nr: i64=gpe_recipes_load("knowledge/world_recipes.conf" as *u8,recipes) 171 if nr<1 { return 3 } 172 var row: i64=0-1;var i: i64=0;var matches: i64=0 173 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 } 174 gv_check("one actual recipe selected" as *u8,matches==1,ctr) 175 if matches!=1 { return 3 } 176 ce_evidence(recipes[row+5] as *u8,controls) 177 i=GPE_OUT_CAP 178 while i<GPE_OUT_CAP+GPE_OUT_CAP { out[i]=PFG_CANARY as u8;i=i+1 } 179 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) 180 if gpe_mt_pages>0 { 181 let declared:*u8=sys_mmap(GPE_OUT_CAP) 182 let dn:i64=gpa_declare_shared(out,n,gpe_mt_url,declared,GPE_OUT_CAP) 183 gv_check("shared runtime manifest derives from verified artifact" as *u8,dn>0&&dn<=GPE_OUT_CAP,ctr) 184 if dn<=0||dn>GPE_OUT_CAP {return 3} 185 var at:i64=0;while at<dn {out[at]=declared[at];at=at+1};n=dn 186 sys_munmap(declared,GPE_OUT_CAP) 187 } 188 var intact: i64=1;i=GPE_OUT_CAP 189 while i<GPE_OUT_CAP+GPE_OUT_CAP { if out[i]!=(PFG_CANARY as u8) { intact=0 };i=i+1 } 190 gv_check("full adjacent capacity span unchanged" as *u8,intact==1,ctr) 191 gv_check("actual returned page length fits production allocation" as *u8,n>0&&n<=GPE_OUT_CAP,ctr) 192 gv_check("shader capture owner reports success" as *u8,gsb_failed==0,ctr) 193 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) 194 gv_kv("twin_minimum_pages" as *u8,gpe_mt_pages);gv_kv("twin_maximum_pages" as *u8,gpe_mt_max) 195 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) } 196 gpa_sha(out,n,digest);gv_puts("page_sha256=" as *u8);gv_puts(digest);gv_puts("\n" as *u8) 197 let wrote: i64=fxc_create(argv[4] as *u8,out,n) 198 gv_check("private output exclusively created" as *u8,wrote==n,ctr) 199 if wrote==n { 200 let box: *i64=sys_mmap(__size_of(i64)) as *i64 201 if (box as i64)<=0 { return 3 } 202 let actual: *u8=sys_read_file(argv[4] as *u8,box) 203 gv_check("private output readback equals generated bytes" as *u8,(actual as i64)>0&&gpa_same(out,n,actual,box[0])==1,ctr) 204 } 205 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) 206}