code wiki / _hdl_build / nx_nxa_skin_gate.nx

nx_nxa_skin_gate.nx source

↩ module page · 197 lines · 9684 B

1// nx_nxa_skin_gate.nx -- THE REFEREE nx_nxa_skin NEVER HAD (2026-09-04). 2// 3// WHY THIS EXISTS. nx_nxa_skin is 43,728 B of source that SYNTHESISES a large fraction of its own 4// output -- measured live on two real donors at 19422/50230 (387 permil) and 27758/54351 (511 permil) 5// of vertices whose skin weights are INFERRED rather than read from the donor's FBX clusters. Until 6// today `nx_catalog nx_nxa_skin_gate` answered "VERDICT ABSENT -- no source, no binary, nothing 7// promoted. It does not exist." Its sibling nx_fbx2nxa HAS a gate that pins all four donors; the half 8// of the rig chain that INVENTS data had none. An organ that makes up half its answer with no referee 9// is the estate's own worst shape. 10// 11// SUBJECT: ./nx_nxa_skin.elf -- the PROMOTED serving-root binary, forked end-to-end, never an 12// in-process re-derive of the logic under test. 13// 14// ★THE LOAD-BEARING TOOTH IS THE PARTITION, AND THE ORGAN HANDS IT TO US. Its own status line reports 15// `skinned=<authored> autoskinned=<inferred>/<total>`, so authored + inferred MUST equal total. That is 16// a claim the organ makes about itself and it is checkable without any bar anyone had to pick. A 17// partition that does not sum is a leak, and this is the estate's standing rule applied to the one 18// organ that had nobody applying it. 19// 20// ★ANTI-VACUITY, BOTH DIRECTIONS. An implementation that authored NOTHING and synthesised everything 21// would still emit a valid file and still sum -- T4 catches it (inferred must be strictly less than 22// total, or no donor weight was ever read). An implementation that read the FBX but wrote no rig would 23// fail T1 (joints and authored counts must be non-zero) BEFORE any outcome tooth is allowed to speak. 24// 25// ⚠DECLARED DEBT, NOT HIDDEN: ns_num_after duplicates fg_num_after in nx_fbx2nxa_gate. Two gates now 26// need the same keyed-integer parser, which by the estate's own extract-the-fix law OWES a lift to 27// gk_num_after in nx_gatekit_lib. It is written local here rather than landed in a lib the entire gate 28// roster imports while build admission is flapping; the lift is owed and named so it is not forgotten. 29// 30// ⚠The subprocess primitive is gk_run_capture from nx_gatekit_lib and is NEVER re-rolled -- its own 31// header records a production DEADLOCK (50+ min in pipe_wait) from a hand-rolled fork/pipe/wait. 32// 33// nx_nxa_skin_gate 34// license_tier: ORIGINAL expect_exit: 0 No hw writes (Rule 26). 35import "nx_syscalls.nx" 36import "nx_gate_verdict.nx" 37import "nx_gatekit_lib.nx" 38 39const NS_ELF: *u8 = "./nx_nxa_skin.elf" 40const NS_GATE: *u8 = "nxnsgate" 41const NS_CAP: i64 = 65536 42const NS_PATH: i64 = 512 43const NS_W_FBX: *u8 = "knowledge/rigcorpus/fbx/dark_witch.fbx" 44const NS_W_REF: *u8 = "knowledge/rigcorpus/dark_witch_geom.nxa" 45const NS_P_FBX: *u8 = "knowledge/rigcorpus/fbx/paladin.fbx" 46const NS_P_REF: *u8 = "knowledge/rigcorpus/paladin_geom.nxa" 47const NS_BAD_FBX: *u8 = "knowledge/rigcorpus/fbx/no_such_donor.fbx" 48const NS_PERMIL: i64 = 1000 49 50func ns_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 51 52// integer following <key> in buf; -1 if the key is absent. OWES a lift to gk_num_after (see header). 53func ns_num_after(buf: *u8, key: *u8) -> i64 { 54 let kl: i64 = ns_slen(key) 55 let bl: i64 = ns_slen(buf) 56 var i: i64 = 0 57 while i + kl <= bl { 58 var j: i64 = 0 59 var hit: i64 = 1 60 while j < kl { if buf[i + j] != key[j] { hit = 0; j = kl } else { j = j + 1 } } 61 if hit == 1 { 62 var p: i64 = i + kl 63 var v: i64 = 0 64 var any: i64 = 0 65 while buf[p] >= (48 as u8) { 66 if buf[p] > (57 as u8) { p = bl } 67 if p < bl { v = v * 10 + ((buf[p] as i64) - 48); any = 1; p = p + 1 } 68 } 69 if any == 1 { return v } 70 return 0 - 1 71 } 72 i = i + 1 73 } 74 return 0 - 1 75} 76 77// the DENOMINATOR of "<key>N/M": skip the numerator, step over the slash, parse M. -1 if absent. 78func ns_denom_after(buf: *u8, key: *u8) -> i64 { 79 let kl: i64 = ns_slen(key) 80 let bl: i64 = ns_slen(buf) 81 var i: i64 = 0 82 while i + kl <= bl { 83 var j: i64 = 0 84 var hit: i64 = 1 85 while j < kl { if buf[i + j] != key[j] { hit = 0; j = kl } else { j = j + 1 } } 86 if hit == 1 { 87 var p: i64 = i + kl 88 while p < bl { if buf[p] == (47 as u8) { p = bl } else { p = p + 1 } } 89 var q: i64 = i + kl 90 var slash: i64 = 0 - 1 91 while q < bl { if buf[q] == (47 as u8) { slash = q; q = bl } else { q = q + 1 } } 92 if slash < 0 { return 0 - 1 } 93 var r: i64 = slash + 1 94 var v: i64 = 0 95 var any: i64 = 0 96 while buf[r] >= (48 as u8) { 97 if buf[r] > (57 as u8) { r = bl } 98 if r < bl { v = v * 10 + ((buf[r] as i64) - 48); any = 1; r = r + 1 } 99 } 100 if any == 1 { return v } 101 return 0 - 1 102 } 103 i = i + 1 104 } 105 return 0 - 1 106} 107 108func main(argc: i64, argv: *i64) -> i64 { 109 let ctr: *i64 = gv_ctr() 110 gv_head("nx_nxa_skin_gate -- the rig importer that synthesises half its own weights, finally refereed" as *u8) 111 112 let dir: *u8 = sys_mmap(NS_PATH) as *u8 113 gk_fixture_dir(NS_GATE, dir) 114 let o1: *u8 = sys_mmap(NS_PATH) as *u8 115 let o2: *u8 = sys_mmap(NS_PATH) as *u8 116 let o3: *u8 = sys_mmap(NS_PATH) as *u8 117 let o4: *u8 = sys_mmap(NS_PATH) as *u8 118 gk_join(o1, dir, "witch1.nxa" as *u8) 119 gk_join(o2, dir, "witch2.nxa" as *u8) 120 gk_join(o3, dir, "paladin.nxa" as *u8) 121 gk_join(o4, dir, "refused.nxa" as *u8) 122 123 let b1: *u8 = sys_mmap(NS_CAP) as *u8 124 let b2: *u8 = sys_mmap(NS_CAP) as *u8 125 let b3: *u8 = sys_mmap(NS_CAP) as *u8 126 let b4: *u8 = sys_mmap(NS_CAP) as *u8 127 let n1: *i64 = sys_mmap(16) as *i64 128 let n2: *i64 = sys_mmap(16) as *i64 129 let n3: *i64 = sys_mmap(16) as *i64 130 let n4: *i64 = sys_mmap(16) as *i64 131 132 // ---- donor 1: dark_witch 133 let rc1: i64 = gk_run_capture(NS_ELF, NS_W_FBX, NS_W_REF, o1, 0 as *u8, b1, NS_CAP, n1) 134 let joints: i64 = ns_num_after(b1, "joints=" as *u8) 135 let authored: i64 = ns_num_after(b1, "skinned=" as *u8) 136 let inferred: i64 = ns_num_after(b1, "autoskinned=" as *u8) 137 let total: i64 = ns_denom_after(b1, "autoskinned=" as *u8) 138 139 // T1 is the FIXTURE-REACHED tooth and it runs FIRST: no outcome tooth may speak about a run that 140 // never produced a rig. A subject that read nothing fails here rather than passing everything below. 141 var t1: i64 = 0 142 if joints > 0 { if authored > 0 { if total > 0 { t1 = 1 } } } 143 gv_check("T1 FIXTURE REACHED: the donor yields joints and AUTHORED weights before any outcome is judged" as *u8, t1, ctr) 144 145 var t2: i64 = 0 146 if authored + inferred == total { t2 = 1 } 147 gv_check("T2 THE PARTITION SUMS: authored plus inferred equals the vertex total the organ itself reports" as *u8, t2, ctr) 148 149 var t3: i64 = 0 150 if gk_size(o1) > 0 { t3 = 1 } 151 gv_check("T3 IT WROTE A RIGGED ASSET: the output exists and is non-empty" as *u8, t3, ctr) 152 153 // T4 is the anti-vacuity tooth: an organ that synthesised EVERYTHING would satisfy T1..T3. 154 var t4: i64 = 0 155 if inferred < total { if inferred >= 0 { t4 = 1 } } 156 gv_check("T4 NOT ALL SYNTHESISED: inferred is strictly fewer than total, so donor weights were really read" as *u8, t4, ctr) 157 158 // ---- determinism, on the reported counts AND the artifact size (named for what it checks) 159 let rc2: i64 = gk_run_capture(NS_ELF, NS_W_FBX, NS_W_REF, o2, 0 as *u8, b2, NS_CAP, n2) 160 var t5: i64 = 1 161 if ns_num_after(b2, "joints=" as *u8) != joints { t5 = 0 } 162 if ns_num_after(b2, "skinned=" as *u8) != authored { t5 = 0 } 163 if ns_num_after(b2, "autoskinned=" as *u8) != inferred { t5 = 0 } 164 if gk_size(o2) != gk_size(o1) { t5 = 0 } 165 gv_check("T5 DETERMINISTIC on reported counts and artifact size across two runs of the same donor" as *u8, t5, ctr) 166 167 // ---- population, not one sample: a SECOND donor must also reach 168 let rc3: i64 = gk_run_capture(NS_ELF, NS_P_FBX, NS_P_REF, o3, 0 as *u8, b3, NS_CAP, n3) 169 let pj: i64 = ns_num_after(b3, "joints=" as *u8) 170 let pa: i64 = ns_num_after(b3, "skinned=" as *u8) 171 let pi: i64 = ns_num_after(b3, "autoskinned=" as *u8) 172 let pt: i64 = ns_denom_after(b3, "autoskinned=" as *u8) 173 var t6: i64 = 0 174 if pj > 0 { if pa + pi == pt { if gk_size(o3) > 0 { t6 = 1 } } } 175 gv_check("T6 SECOND DONOR: paladin also yields joints, a summing partition and a written asset" as *u8, t6, ctr) 176 177 // ---- negative control: a donor that is not there must REFUSE and must not write an asset 178 let rc4: i64 = gk_run_capture(NS_ELF, NS_BAD_FBX, NS_W_REF, o4, 0 as *u8, b4, NS_CAP, n4) 179 var nc1: i64 = 0 180 if rc4 != 0 { if gk_exists(o4) == 0 { nc1 = 1 } } 181 gv_check("neg-control-absent-donor-refuses-and-writes-no-asset" as *u8, nc1, ctr) 182 183 gv_values_head() 184 gv_kv("witch_joints" as *u8, joints) 185 gv_kv("witch_authored" as *u8, authored) 186 gv_kv("witch_inferred" as *u8, inferred) 187 gv_kv("witch_total" as *u8, total) 188 gv_kv("witch_inferred_permil" as *u8, inferred * NS_PERMIL / total) 189 gv_kv("paladin_joints" as *u8, pj) 190 gv_kv("paladin_inferred_permil" as *u8, pi * NS_PERMIL / pt) 191 gv_kv("witch_asset_bytes" as *u8, gk_size(o1)) 192 gv_kv("paladin_asset_bytes" as *u8, gk_size(o3)) 193 gv_kv("absent_donor_rc" as *u8, rc4) 194 195 return gv_verdict("NXA-SKIN-GATE" as *u8, ctr, 196 "the rig importer is refereed at last: fixture reached, the authored-plus-inferred partition sums, not all weights synthesised, deterministic, a second donor, and an absent donor refused" as *u8) 197}