code wiki / (root) / nx_meshgap_gate.nx

nx_meshgap_gate.nx source

↩ module page · 149 lines · 8257 B

1// nx_meshgap_gate.nx -- THE COHERENCE TOOTH: does a shipped character hold together in space? 2// 3// WHY (measured 2026-08-23). The models page card FEMALE DARK KNIGHT renders as FRAGMENTED 4// GEOMETRY -- hair floating far above the body, blobs below -- while EVERY NUMBER ON ITS CARD IS 5// GREEN (33 geometry nodes merged, rig 113 joints, 3729 clusters = 33 x 113, albedo carried). 6// The arithmetic closed and the picture was broken. Third time in one day the eye beat the teeth, 7// and always for the same reason: every tooth measured a COUNT or a SUM, and none measured whether 8// the thing HOLDS TOGETHER IN SPACE. 9// 10// THE BOUND IS DERIVED FROM A MEASURED POPULATION, NOT PICKED. All four ingested FBX donors were 11// measured with nx_meshgap and the ranking matched the eye exactly, in order: 12// toon3d8 max_gap_permil = 8 renders coherent 13// dark_witch max_gap_permil = 20 renders coherent 14// paladin max_gap_permil = 101 one boot detached (mild) 15// dark_knight max_gap_permil = 298 severely fragmented 16// The coherent population tops out at 20; the fragmented population starts at 101. Any bound in 17// between separates them, so rather than pick a point in that range the bound is the GEOMETRIC MEAN 18// of the two boundary values -- sqrt(20 * 101) = 44.9 -> 45 -- which sits at an equal RATIO margin 19// (2.25x) above the worst coherent donor and below the best fragmented one. Ratio-symmetric is the 20// right symmetry here because the measure is itself a ratio (permil of the axis's own span). 21// 22// AND THE BOUND CANNOT SILENTLY GO STALE: T5 re-derives the separation from the live corpus on every 23// run and FAILS if the two populations ever stop being separated by this bound. A frozen number that 24// nobody re-checks is how a threshold becomes folklore. 25// 26// THE NEG-CONTROLS ARE REAL RECORDED DEFECTS, NOT SYNTHETIC MUTANTS: dark_knight and paladin are 27// genuinely fragmented assets sitting in the corpus right now. Biting against the estate's own 28// history is stronger than any mutant, because it proves the tooth catches what actually happened. 29 30import "nx_syscalls.nx" 31import "nx_gate_verdict.nx" 32import "nx_gatekit_lib.nx" 33 34const MGG_ELF: *u8 = "./nx_meshgap.elf" 35const MGG_CAP: i64 = 65536 36// derived above: geometric mean of the coherent maximum (20) and the fragmented minimum (101) 37const MGG_BOUND: i64 = 45 38const MGG_COHERENT_MAX: i64 = 20 39const MGG_FRAGMENTED_MIN: i64 = 101 40 41const MGG_TOON: *u8 = "knowledge/rigcorpus/toon3d8_rigged.nxa" 42const MGG_WITCH: *u8 = "knowledge/rigcorpus/dark_witch_rigged.nxa" 43const MGG_PALADIN: *u8 = "knowledge/rigcorpus/paladin_rigged.nxa" 44const MGG_KNIGHT: *u8 = "knowledge/rigcorpus/dark_knight_rigged.nxa" 45const MGG_KNIGHT_GEOM: *u8 = "knowledge/rigcorpus/dark_knight_geom.nxa" 46 47func mgg_bound_str() -> *u8 { return "45" } 48 49// pull "max_gap_permil=<n>" out of the captured stdout. Anchored on the field name, and the field 50// is emitted exactly once per run so there is no last-match ambiguity. 51func mgg_gap(buf: *u8, n: i64) -> i64 { 52 let key: *u8 = "max_gap_permil=" 53 var kl: i64 = 0 54 while key[kl] != (0 as u8) { kl = kl + 1 } 55 var i: i64 = 0 56 while i + kl < n { 57 var j: i64 = 0 58 var hit: i64 = 1 59 while j < kl { 60 if buf[i+j] != key[j] { hit = 0; j = kl } 61 j = j + 1 62 } 63 if hit == 1 { 64 var v: i64 = 0 65 var p: i64 = i + kl 66 var got: i64 = 0 67 while p < n { 68 let c: i64 = buf[p] as i64 69 if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); got = 1; p = p + 1 } } 70 if c < 48 { p = n } 71 if c > 57 { p = n } 72 } 73 if got == 1 { return v } 74 return 0 - 1 75 } 76 i = i + 1 77 } 78 return 0 - 1 79} 80 81func mgg_measure(path: *u8, buf: *u8, blen: *i64, rcp: *i64) -> i64 { 82 blen[0] = 0 83 let rc: i64 = gk_run_capture(MGG_ELF, path, 0 as *u8, 0 as *u8, 0 as *u8, buf, MGG_CAP, blen) 84 rcp[0] = rc 85 if blen[0] < 1 { return 0 - 1 } 86 return mgg_gap(buf, blen[0]) 87} 88 89func main(argc: i64, argv: *i64) -> i64 { 90 let ctr: *i64 = sys_mmap(64) 91 gv_init(ctr) 92 gv_puts("nx_meshgap_gate -- a shipped character must hold together in space, not merely count correctly\n\n") 93 94 let buf: *u8 = sys_mmap(MGG_CAP) as *u8 95 let blen: *i64 = sys_mmap(64) 96 let rcp: *i64 = sys_mmap(64) 97 98 // ---- the subject ran at all ------------------------------------------------------------ 99 let g_toon: i64 = mgg_measure(MGG_TOON, buf, blen, rcp) 100 let rc_toon: i64 = rcp[0] 101 gv_puts(" toon3d8 rc="); gv_num(rc_toon); gv_puts(" bytes="); gv_num(blen[0]); gv_puts(" max_gap_permil="); gv_num(g_toon); gv_puts("\n"); 102 gv_check("subject-ran-and-produced-output (127 = elf absent, the stale-offc tell)", rc_toon == 0, ctr) 103 gv_check("measurement-parsed-from-the-subject (a missing field reads -1, never a silent zero)", g_toon >= 0, ctr) 104 105 let g_witch: i64 = mgg_measure(MGG_WITCH, buf, blen, rcp) 106 gv_puts(" dark_witch max_gap_permil="); gv_num(g_witch); gv_puts("\n"); 107 let g_paladin: i64 = mgg_measure(MGG_PALADIN, buf, blen, rcp) 108 gv_puts(" paladin max_gap_permil="); gv_num(g_paladin); gv_puts("\n"); 109 let g_knight: i64 = mgg_measure(MGG_KNIGHT, buf, blen, rcp) 110 gv_puts(" dark_knight max_gap_permil="); gv_num(g_knight); gv_puts("\n"); 111 112 // ---- anti-vacuity: a run that examined nothing must not read as a pass ------------------- 113 var subjects: i64 = 0 114 if g_toon >= 0 { subjects = subjects + 1 } 115 if g_witch >= 0 { subjects = subjects + 1 } 116 if g_paladin >= 0 { subjects = subjects + 1 } 117 if g_knight >= 0 { subjects = subjects + 1 } 118 gv_puts(" subjects_measured="); gv_num(subjects); gv_puts(" of 4\n"); 119 gv_check("four-subjects-measured (count bound IN the condition: a zero-subject run cannot pass)", subjects == 4, ctr) 120 121 // ---- the coherent population passes ----------------------------------------------------- 122 gv_check("toon3d8-is-COHERENT (renders as a whole figure)", g_toon >= 0 && g_toon <= MGG_BOUND, ctr) 123 gv_check("dark_witch-is-COHERENT (renders as a whole figure)", g_witch >= 0 && g_witch <= MGG_BOUND, ctr) 124 125 // ---- the neg-controls: REAL recorded defects, and they must FIRE ------------------------- 126 gv_bite("neg-control-dark_knight-FRAGMENTED-detected (hair floats above the body on the live page)", g_knight > MGG_BOUND, g_witch > MGG_BOUND, ctr) 127 gv_bite("neg-control-paladin-FRAGMENTED-detected (one boot detached on the live page)", g_paladin > MGG_BOUND, g_toon > MGG_BOUND, ctr) 128 129 // ---- the bound must still SEPARATE the two populations ----------------------------------- 130 var worst_ok: i64 = g_toon 131 if g_witch > worst_ok { worst_ok = g_witch } 132 var best_bad: i64 = g_knight 133 if g_paladin < best_bad { best_bad = g_paladin } 134 gv_puts(" worst_coherent="); gv_num(worst_ok); gv_puts(" bound="); gv_num(MGG_BOUND); gv_puts(" best_fragmented="); gv_num(best_bad); gv_puts("\n"); 135 gv_check("bound-still-SEPARATES-the-populations (re-derived live, so a frozen number cannot go stale)", worst_ok < MGG_BOUND && MGG_BOUND < best_bad, ctr) 136 137 // ---- the defect predates rigging: geom and rigged must agree ----------------------------- 138 let g_kgeom: i64 = mgg_measure(MGG_KNIGHT_GEOM, buf, blen, rcp) 139 gv_puts(" dark_knight_GEOM max_gap_permil="); gv_num(g_kgeom); gv_puts(" (rigged="); gv_num(g_knight); gv_puts(")\n"); 140 gv_check("fragmentation-PREDATES-rigging (geom == rigged, so nx_nxa_skin is exonerated and the FBX merge owns it)", g_kgeom == g_knight, ctr) 141 142 // ---- the subject's own verdict path works ------------------------------------------------ 143 blen[0] = 0 144 let rc_v: i64 = gk_run_capture(MGG_ELF, MGG_KNIGHT, mgg_bound_str(), 0 as *u8, 0 as *u8, buf, MGG_CAP, blen) 145 gv_puts(" bounded-run rc="); gv_num(rc_v); gv_puts("\n"); 146 gv_check("subject-EXITS-NONZERO-on-a-fragmented-asset (the verdict is in the exit code, so a caller branches without parsing)", rc_v == 1, ctr) 147 148 return gv_verdict("NX-MESHGAP-GATE", ctr, "coherence is measured in mesh space, the bound is derived from a measured population, and both neg-controls are real assets that are genuinely broken") 149}