code wiki / _hdl_build / nx_asset_floor_gate.nx

nx_asset_floor_gate.nx source

↩ module page · 294 lines · 13820 B

1// nx_asset_floor_gate.nx -- THE ASSET FLOOR: measure our shipped character against a declared 2// game-ready floor, and NAME WHAT IS MISSING. Operator 2026-08-02 pointed at a commercial 3// game-ready character listing as "the floor we need to reach". That listing is behind a bot 4// challenge and could not be read, so this gate does the honest version instead: it parses OUR 5// OWN asset and reports the capability gaps a commercial game-ready character would carry. 6// 7// THE POINT IS THE GAP LIST, NOT A GREEN LIGHT. A gate that only says PASS/FAIL on triangle 8// count would call our figure "game ready" while she ships with no face geometry, no breast 9// bones and no blend shapes -- the exact defects the operator saw on screen. So every capability 10// is REPORTED, present or absent, and the absent ones are the roadmap. 11// 12// Reads the NXA container directly (the format the browser loads): magic NXANIM01, u64 version, 13// u64 section count, then 32-byte section headers {tag[4], _, off, wordlen, ck_lo, ck_hi}. 14// Sections: VERT TRIS SKEL SKIN ANIM (required) + GVRT GTRI (garment) HSTR (hair) POSE (idle). 15// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 16import "nx_syscalls.nx" 17import "nx_gate_verdict.nx" 18 19// the SHIPPED asset: the page fetches ref9d.nxa (DYNA-bearing) first and falls back to ref9. 20// This gate once pointed at the fallback and its DYNA tooth failed against an artifact nothing 21// serves preferentially -- measure what ships, not what shipped before it. 22const AF_PATH: *u8 = "sites/nishifamily/world/ref9d.nxa" 23// midline threshold in bind-x units -- THE SAME 3000 the page's chj classifier uses (one meaning, 24// one number). The previous span/12 (~14294 here) swallowed the REAL pectoral chain (|x|~8800, 25// joints 76-79, skinned 230-428 verts each, tracked) into the "midline spine" count and reported 26// LATERAL PAIR = 0 against a rig that has carried a wired 2-bone-per-side pair all along. Months 27// of vertex-band workaround rode that false RED. 28const AF_MIDLINE: i64 = 3000 29const AF_HDR: i64 = 32 30const AF_SECHDR: i64 = 32 31// declared floor -- every bound carries its reason, and the tri ceiling comes from the measured 32// VR budget (Quest 3 1.3-1.8M tris/frame; a cast of 12 must fit inside a fraction of that) 33const AF_TRI_MIN: i64 = 8000 34const AF_TRI_MAX: i64 = 120000 35const AF_JOINT_MIN: i64 = 40 36const AF_VERT_MIN: i64 = 4000 37 38func af_rd64(b: *u8, off: i64) -> i64 { 39 var v: i64 = 0 40 var i: i64 = 7 41 while i >= 0 { v = v*256 + ((b[off + i] & 0xff) as i64); i = i - 1 } 42 return v 43} 44func af_tag(b: *u8, off: i64, t: *u8) -> i64 { 45 var i: i64 = 0 46 while i < 4 { if b[off + i] != t[i] { return 0 } i = i + 1 } 47 return 1 48} 49// section offset by tag, or -1 50func af_find(b: *u8, nsec: i64, t: *u8) -> i64 { 51 var s: i64 = 0 52 while s < nsec { 53 let e: i64 = AF_HDR + s*AF_SECHDR 54 if af_tag(b, e, t) == 1 { return af_rd64(b, e + 8) } 55 s = s + 1 56 } 57 return 0 - 1 58} 59func af_report(name: *u8, present: i64) -> i64 { 60 gv_puts(" " as *u8) 61 gv_puts(name) 62 if present == 1 { gv_puts(": PRESENT\n" as *u8) } else { gv_puts(": ABSENT -- gap to the floor\n" as *u8) } 63 return present 64} 65 66func main(argc: i64, argv: *i64) -> i64 { 67 let ctr: *i64 = gv_ctr() 68 gv_head("nx_asset_floor gate -- our shipped character measured against a game-ready floor" as *u8) 69 // ★ THE ASSET UNDER TEST IS AN ARGUMENT. A gate that can only ever read ONE hardcoded path 70 // cannot measure a candidate against the shipped one, so it can never PROVE an improvement -- 71 // it can only ever describe the status quo. Defaults to the shipped asset when given nothing. 72 var apath: *u8 = AF_PATH 73 if argc >= 2 { apath = argv[1] as *u8 } 74 gv_puts(" asset: " as *u8); gv_puts(apath); gv_puts("\n" as *u8) 75 let lp: *i64 = sys_mmap(16) as *i64 76 let b: *u8 = sys_read_file(apath, lp) 77 if (b as i64) == 0 { 78 gv_puts(" cannot read the character asset\n" as *u8) 79 gv_check("asset present" as *u8, 0, ctr) 80 let rcx: i64 = gv_verdict("ASSET-FLOOR" as *u8, ctr, "no asset" as *u8) 81 sys_exit(rcx) 82 return rcx 83 } 84 let n: i64 = lp[0] 85 gv_puts(" container bytes=" as *u8); gv_num(n); gv_puts("\n" as *u8) 86 var magic: i64 = 1 87 let mg: *u8 = "NXANIM01" as *u8 88 var i: i64 = 0 89 while i < 8 { if b[i] != mg[i] { magic = 0 } i = i + 1 } 90 gv_check("container magic is NXANIM01" as *u8, magic, ctr) 91 if magic == 0 { 92 let rcm: i64 = gv_verdict("ASSET-FLOOR" as *u8, ctr, "bad container" as *u8) 93 sys_exit(rcm) 94 return rcm 95 } 96 let nsec: i64 = af_rd64(b, 16) 97 gv_puts(" sections=" as *u8); gv_num(nsec); gv_puts("\n" as *u8) 98 // ★A CAPABILITY REPORT THAT ONLY NAMES WHAT IT LOOKED FOR CANNOT TELL YOU WHAT YOU HAVE. 99 // This gate checked 7 tags against an asset carrying 11 sections, so four were invisible to 100 // its own inventory -- and the texture-capability question ("does this mesh carry UVs at all?") 101 // lives in exactly that blind spot. Enumerate every tag the file declares, then answer. 102 gv_puts(" declared tags:" as *u8) 103 let tagbuf: *u8 = sys_mmap(8) 104 var si: i64 = 0 105 while si < nsec { 106 let se: i64 = AF_HDR + si*AF_SECHDR 107 gv_puts(" " as *u8) 108 var ci: i64 = 0 109 while ci < 4 { tagbuf[ci] = b[se + ci]; ci = ci + 1 } 110 tagbuf[4] = 0 111 gv_puts(tagbuf) 112 gv_puts(":" as *u8); gv_num(af_rd64(b, se + 16)) 113 si = si + 1 114 } 115 gv_puts("\n" as *u8) 116 117 // ---- geometry the floor requires ---- 118 let ov: i64 = af_find(b, nsec, "VERT" as *u8) 119 let ot: i64 = af_find(b, nsec, "TRIS" as *u8) 120 let ok9: i64 = af_find(b, nsec, "SKEL" as *u8) 121 var nv: i64 = 0 122 var nt: i64 = 0 123 var nj: i64 = 0 124 if ov >= 0 { nv = af_rd64(b, ov) } 125 if ot >= 0 { nt = af_rd64(b, ot) } 126 if ok9 >= 0 { nj = af_rd64(b, ok9) } 127 gv_puts(" verts=" as *u8); gv_num(nv) 128 gv_puts(" tris=" as *u8); gv_num(nt) 129 gv_puts(" joints=" as *u8); gv_num(nj); gv_puts("\n" as *u8) 130 var vok: i64 = 0 131 if nv >= AF_VERT_MIN { vok = 1 } 132 gv_check("vertex count clears the floor" as *u8, vok, ctr) 133 var tok: i64 = 0 134 if nt >= AF_TRI_MIN { if nt <= AF_TRI_MAX { tok = 1 } } 135 gv_check("triangle count inside the VR-budget band" as *u8, tok, ctr) 136 var jok: i64 = 0 137 if nj >= AF_JOINT_MIN { jok = 1 } 138 gv_check("skeleton has enough joints to deform" as *u8, jok, ctr) 139 140 // ---- the capability gaps: reported whether present or not ---- 141 gv_puts("\n -- capability inventory (absent rows ARE the roadmap) --\n" as *u8) 142 var have: i64 = 0 143 var want: i64 = 0 144 let gv1: i64 = af_find(b, nsec, "GVRT" as *u8) 145 var p1: i64 = 0 146 if gv1 >= 0 { p1 = 1 } 147 af_report("garment geometry (GVRT)" as *u8, p1) 148 have = have + p1 149 want = want + 1 150 let hs1: i64 = af_find(b, nsec, "HSTR" as *u8) 151 var p2: i64 = 0 152 if hs1 >= 0 { p2 = 1 } 153 af_report("hair strands (HSTR)" as *u8, p2) 154 have = have + p2 155 want = want + 1 156 let po1: i64 = af_find(b, nsec, "POSE" as *u8) 157 var p3: i64 = 0 158 if po1 >= 0 { p3 = 1 } 159 af_report("idle pose (POSE)" as *u8, p3) 160 have = have + p3 161 want = want + 1 162 // a commercial game-ready character ships these; ours does not yet. Named, not hidden. 163 let fa1: i64 = af_find(b, nsec, "FACE" as *u8) 164 var p4: i64 = 0 165 if fa1 >= 0 { p4 = 1 } 166 af_report("face geometry (FACE) -- we PAINT the face from ratios instead" as *u8, p4) 167 have = have + p4 168 want = want + 1 169 let mo1: i64 = af_find(b, nsec, "MORF" as *u8) 170 var p5: i64 = 0 171 if mo1 >= 0 { p5 = 1 } 172 af_report("blend shapes / morph targets (MORF) -- no expressions without these" as *u8, p5) 173 have = have + p5 174 want = want + 1 175 let tx1: i64 = af_find(b, nsec, "TEXM" as *u8) 176 var p6: i64 = 0 177 if tx1 >= 0 { p6 = 1 } 178 af_report("PBR texture maps (TEXM) -- we shade procedurally from genome" as *u8, p6) 179 have = have + p6 180 want = want + 1 181 let dy1: i64 = af_find(b, nsec, "DYNA" as *u8) 182 var p7: i64 = 0 183 if dy1 >= 0 { p7 = 1 } 184 af_report("per-bone physics declarations (DYNA)" as *u8, p7) 185 have = have + p7 186 want = want + 1 187 // ★ PRESENCE OF A SECTION IS NOT PRESENCE OF THE CAPABILITY. A DYNA section carrying two 188 // midline bones would satisfy "DYNA: PRESENT" while leaving soft tissue exactly as unriggable 189 // as before -- so the tooth is the LATERAL PAIR itself: one bone declared left of the midline 190 // and one right of it, each with a real anchor. That is what a spine chain cannot fake. 191 var latpair: i64 = 0 192 if dy1 >= 0 { 193 let ndb: i64 = af_rd64(b, dy1) 194 let dstr: i64 = af_rd64(b, dy1 + 8) 195 gv_puts(" DYNA bones=" as *u8); gv_num(ndb) 196 gv_puts(" stride=" as *u8); gv_num(dstr); gv_puts("\n" as *u8) 197 var sawL: i64 = 0 198 var sawR: i64 = 0 199 var d: i64 = 0 200 while d < ndb { 201 let db: i64 = dy1 + 16 + d*dstr*8 202 let dside: i64 = af_rd64(b, db) 203 let dx: i64 = af_rd64(b, db + 8) 204 let dz: i64 = af_rd64(b, db + 24) 205 let dk: i64 = af_rd64(b, db + 32) 206 let dmax: i64 = af_rd64(b, db + 48) 207 gv_puts(" bone side=" as *u8); gv_num(dside) 208 gv_puts(" x=" as *u8); gv_num(dx) 209 gv_puts(" z=" as *u8); gv_num(dz) 210 gv_puts(" k=" as *u8); gv_num(dk) 211 gv_puts(" travel=" as *u8); gv_num(dmax); gv_puts("\n" as *u8) 212 if dside < 0 { if dx < 0 { sawL = 1 } } 213 if dside > 0 { if dx > 0 { sawR = 1 } } 214 d = d + 1 215 } 216 if sawL == 1 { if sawR == 1 { latpair = 1 } } 217 } 218 gv_check("DYNA declares a LATERAL soft-tissue pair (not the spine)" as *u8, latpair, ctr) 219 220 // ---- SOFT-TISSUE BONES: the defect the anatomy probe already proved ---- 221 // a bust bone would sit near 744 permil of stature, front hemisphere. Its ABSENCE is why 222 // the chest had to be driven at the vertex band instead of a joint. 223 // ★NORMALIZE ON THE VERTEX SPAN, exactly as the browser-side anatomy probe does. A first 224 // version normalized on the JOINT span and reported 5 bust-band joints where the browser 225 // reported none -- two instruments measuring the SAME asset and CONTRADICTING each other, 226 // purely because the joint ladder is shorter than the mesh (feet and crown carry no bones). 227 // A shared basis is what makes two probes corroborate instead of argue. 228 var bust: i64 = 0 229 var central: i64 = 0 230 var latL: i64 = 0 231 var latR: i64 = 0 232 if ok9 >= 0 { if ov >= 0 { 233 var zmin: i64 = 0 234 var zmax: i64 = 0 235 var first: i64 = 1 236 var vi: i64 = 0 237 while vi < nv { 238 let vz: i64 = af_rd64(b, ov + 8 + (vi*3 + 2)*8) 239 if first == 1 { zmin = vz; zmax = vz; first = 0 } 240 if vz < zmin { zmin = vz } 241 if vz > zmax { zmax = vz } 242 vi = vi + 1 243 } 244 let span: i64 = zmax - zmin 245 if span > 0 { 246 var j: i64 = 0 247 while j < nj { 248 let jb2: i64 = ok9 + 8 + j*64 249 let bz2: i64 = af_rd64(b, jb2 + 24) 250 let by2: i64 = af_rd64(b, jb2 + 16) 251 let permil: i64 = (bz2 - zmin)*1000/span 252 let bx2: i64 = af_rd64(b, jb2 + 8) 253 var ax2: i64 = bx2 254 if ax2 < 0 { ax2 = 0 - ax2 } 255 // CENTRAL vs LATERAL decides usability: a sternum/chest joint sits near the 256 // midline; a clavicle or shoulder sits far off it and would swing the ARM. 257 // Counting them together is how "the rig has bust joints" and "the rig has 258 // none" can both look true. 259 if permil >= 700 { if permil <= 790 { if by2 < 0 { 260 bust = bust + 1 261 if ax2 < AF_MIDLINE { central = central + 1 } 262 if ax2 >= AF_MIDLINE { if bx2 < 0 { latL = latL + 1 } } 263 if ax2 >= AF_MIDLINE { if bx2 > 0 { latR = latR + 1 } } 264 } } } 265 j = j + 1 266 } 267 } 268 } } 269 gv_puts(" bust-band joints (700..790 permil, front): " as *u8); gv_num(bust) 270 gv_puts(" | midline (spine/sternum chain): " as *u8); gv_num(central) 271 gv_puts(" | lateral L=" as *u8); gv_num(latL) 272 gv_puts(" R=" as *u8); gv_num(latR); gv_puts("\n" as *u8) 273 // a PAIR means one per side -- four same-side helpers must not pass as a pair 274 var skelpair: i64 = 0 275 if latL >= 1 { if latR >= 1 { skelpair = 1 } } 276 if skelpair == 1 { 277 gv_puts(" <- THE SKELETON CARRIES THE LATERAL PAIR (wired: skinned + tracked). The vertex-band\n" as *u8) 278 gv_puts(" chest workaround is now driving AROUND real bones -- route the spring onto them.\n" as *u8) 279 } 280 if skelpair == 0 { 281 gv_puts(" <- NO LATERAL PAIR IN THE SKELETON: real breast bones come in L/R pairs OFF the\n" as *u8) 282 gv_puts(" midline; midline joints at chest height are the SPINE chain. Soft tissue must\n" as *u8) 283 gv_puts(" then be driven at the vertex band (and nx_nxa_dyna can declare the pair).\n" as *u8) 284 } 285 gv_check("SKEL carries a lateral bust pair (one bone per side, off-midline, front)" as *u8, skelpair, ctr) 286 287 gv_puts("\n capability score: " as *u8); gv_num(have); gv_puts("/" as *u8); gv_num(want) 288 gv_puts(" -- every ABSENT row above is a named rung, not a hidden failure\n" as *u8) 289 // the floor gate PASSES on geometry and REPORTS capability: a red here would say the asset 290 // is broken, which it is not. What it lacks is coverage, and coverage is tracked as debt. 291 let rc: i64 = gv_verdict("ASSET-FLOOR" as *u8, ctr, "geometry clears the floor; capability gaps enumerated" as *u8) 292 sys_exit(rc) 293 return rc 294}