code wiki / (root) / nx_rigbench_gate.nx

nx_rigbench_gate.nx source

↩ module page · 134 lines · 9577 B

1// nx_rigbench_gate.nx -- proves the REAL-CHARACTER REFEREE (nx_rigbench_lib) measures what it claims, then runs it on 2// the house rig control ref9d (an artist-rigged character with SKEL, SKIN and a POSE library) so the M2 numbers are 3// EMITTED for independent adjudication. Two layers: (1) the RULERS are proven on known answers with no file at all -- 4// the artist-bone coverage bar is derived from a 3-joint skeleton whose bone lengths are declared, the SKIN L1 reads 5// exactly zero on identical rows and exactly the maximum on rows sharing no joint (the neg-control that pins the 6// scale); (2) the bench runs end to end on ref9d and every value it rests on is printed. This gate deliberately puts 7// NO BAR on the deformation deviation: an uncalibrated ruler reports numbers, never verdicts, and the bar is set once 8// the referee panel has graded the live surface. What it DOES assert is non-vacuity: the artist skeleton was read, 9// our skeleton reached at least one artist joint, our weights are not disjoint from the artist's, the served player 10// ran both rigs, and the mesh ruler judged them. SUBJECT: nx_rigbench_lib (rb_run, rb_mean_bone, rb_skin_l1), in-process. 11// SKIPS (exit 3) with a named absence when ref9d is not on this host -- a laptop has no house rig. 12// license_tier: ORIGINAL expect_exit: 0 13import "nx_syscalls.nx" 14import "nx_gate_verdict.nx" 15import "nx_rigbench_lib.nx" 16 17const RG_DIR: *u8 = "/tmp/nx_rigbench_gate" 18const RG_MODE_DIR: i64 = 493 19const RG_REF: *u8 = "sites/nishifamily/world/ref9d.nxa" 20const RG_POSE: i64 = 1 21const RG_CELLS: i64 = 96 22const RG_EXIT_SKIP: i64 = 3 23// KAT skeleton: root at origin, j1 50 mm along x, j2 40 mm further along y -> bones 5000 and 4000 (0.01 mm) -> mean 4500 24const RG_KAT_NJ: i64 = 3 25const RG_KAT_B1: i64 = 5000 26const RG_KAT_B2: i64 = 4000 27const RG_KAT_MEAN: i64 = 4500 28const RG_KAT_LEAVES: i64 = 1 29// KAT skin: four equal influences of 1024; a row sharing NO joint with it reads L1 = 2 x 4096 -- the scale's maximum 30const RG_W_EQUAL: i64 = 1024 31const RG_L1_DISJOINT: i64 = 8192 32const RG_L1_DISJOINT_PERMIL: i64 = 2000 33const RG_SKIN_OTHER_BASE: i64 = 4 34const RG_KAT_NJ_SKIN: i64 = 8 35 36func rgw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 37func rg_exists(p: *u8) -> i64 { let fd: i64 = sys_openat_rd(p); if fd < 0 { return 0 } sys_close(fd); return 1 } 38// a SKEL section in memory: word 0 = count, then CS_JOINT_WORDS per joint; swo = 0 so rb_jw reads it directly 39func rg_kat_skel() -> *i64 { 40 let w: *i64 = sys_mmap((1 + RG_KAT_NJ * CS_JOINT_WORDS) * 8 + 64) as *i64 41 w[0] = RG_KAT_NJ 42 var j: i64 = 0 43 while j < RG_KAT_NJ * CS_JOINT_WORDS { w[1 + j] = 0; j = j + 1 } 44 w[1 + 0 * CS_JOINT_WORDS + RB_W_PARENT] = 0 - 1 45 w[1 + 1 * CS_JOINT_WORDS + RB_W_PARENT] = 0 46 w[1 + 1 * CS_JOINT_WORDS + RB_W_X] = RG_KAT_B1 47 w[1 + 2 * CS_JOINT_WORDS + RB_W_PARENT] = 1 48 w[1 + 2 * CS_JOINT_WORDS + RB_W_X] = RG_KAT_B1 49 w[1 + 2 * CS_JOINT_WORDS + RB_W_Y] = RG_KAT_B2 50 return w 51} 52// a one-vertex SKIN section: word 0 = count, then 8 words; joints base..base+3, four equal weights 53func rg_kat_skin(base: i64) -> *i64 { 54 let w: *i64 = sys_mmap((1 + RB_SKIN_WORDS) * 8 + 64) as *i64 55 w[0] = 1 56 var k: i64 = 0 57 while k < RB_SKIN_INF { w[1 + k] = base + k; w[1 + RB_SKIN_INF + k] = RG_W_EQUAL; k = k + 1 } 58 return w 59} 60 61func main() -> i64 { 62 let ctr: *i64 = gv_ctr() 63 gv_head("nx_rigbench_gate -- the real-character referee's rulers are proven on known answers, then the bench runs on the house rig ref9d and emits every number it rests on" as *u8) 64 sys_mkdir(RG_DIR, RG_MODE_DIR) 65 66 // ---- layer 1: the rulers, on known answers ---- 67 let ks: *i64 = rg_kat_skel() 68 let mean: i64 = rb_mean_bone(ks, 0, RG_KAT_NJ) 69 gv_check_eq("T1 KAT coverage bar: the artist mean bone length of a declared 3-joint chain (bones 50 mm and 40 mm) reads exactly their mean in 0.01 mm" as *u8, mean, RG_KAT_MEAN, ctr) 70 let leaves: i64 = rb_leaves(ks, 0, RG_KAT_NJ) 71 gv_check_eq("T2 KAT leaves: the chain has exactly one leaf joint" as *u8, leaves, RG_KAT_LEAVES, ctr) 72 let sa: *i64 = rg_kat_skin(0) 73 let sb: *i64 = rg_kat_skin(0) 74 let sc: *i64 = rg_kat_skin(RG_SKIN_OTHER_BASE) 75 let dense: *i64 = sys_mmap(RG_KAT_NJ_SKIN * 8 + 64) as *i64 76 let l1_same: i64 = rb_skin_l1(sa, 0, sb, 0, 0, RG_KAT_NJ_SKIN, dense) 77 gv_check_eq("T3 KAT weight ruler positive control: identical SKIN rows read L1 = 0" as *u8, l1_same, 0, ctr) 78 let l1_disj: i64 = rb_skin_l1(sa, 0, sc, 0, 0, RG_KAT_NJ_SKIN, dense) 79 gv_check_eq("T4 neg-control-disjoint-weights-read-max-L1: SKIN rows sharing no joint read exactly 2 x 4096 -- the ruler's scale, so the bench's permil is anchored" as *u8, l1_disj, RG_L1_DISJOINT, ctr) 80 gv_check_eq("T5 KAT top-1 joint of the equal-weight row is its first influence (ties resolve to the first, deterministically)" as *u8, rb_top1(sa, 0, 0), 0, ctr) 81 82 // ---- layer 2: the bench on the house rig ---- 83 if rg_exists(RG_REF) == 0 { 84 rgw(" SKIP: house rig control absent on this host: " as *u8); rgw(RG_REF); rgw(" -- a named absence, NOT a pass; run on the NAS\n" as *u8) 85 gv_values_head() 86 gv_kv("kat_mean_bone_umm" as *u8, mean) 87 gv_kv("kat_l1_disjoint" as *u8, l1_disj) 88 gv_kv("ref_present" as *u8, 0) 89 gv_verdict("nx_rigbench_gate" as *u8, ctr, "rulers proven; bench SKIPPED, house rig absent" as *u8) 90 return RG_EXIT_SKIP 91 } 92 let rep: *i64 = sys_mmap(RB_R_WORDS * 8) as *i64 93 let rc: i64 = rb_run(RG_REF, RG_DIR, RG_POSE, RG_CELLS, rep) 94 rb_report(rep) 95 gv_check_eq("T6 the bench ran all three legs on ref9d and returned OK (a refusal or an abstention is named, never scored)" as *u8, rc, RB_EXIT_OK, ctr) 96 gv_check("T7 fixture-reached-the-condition: the artist rig carries joints, leaves and vertices, and its mean bone length is positive" as *u8, ((rep[RB_R_ART_JOINTS] > 0) as i64) * ((rep[RB_R_ART_LEAVES] > 0) as i64) * ((rep[RB_R_VERTS] > 0) as i64) * ((rep[RB_R_BONE_MEAN_UMM] > 0) as i64), ctr) 97 gv_check("T8 our skeleton exists: the bare mesh peeled at least one limb and at least one joint with no hint" as *u8, ((rep[RB_R_OUR_LIMBS] > 0) as i64) * ((rep[RB_R_OUR_JOINTS] > 0) as i64), ctr) 98 gv_check("T9 non-vacuity of the skeleton leg: at least one artist joint lies within one artist bone length of one of ours (covered_permil > 0)" as *u8, ((rep[RB_R_COVERED_PERMIL] > 0) as i64), ctr) 99 gv_check("T10 non-vacuity of the weight leg: our weights are not disjoint from the artist's (mean L1 below the 2000 permil a disjoint rig reads) and at least one vertex agrees on its strongest joint" as *u8, ((rep[RB_R_W_L1_MEAN_PERMIL] < RG_L1_DISJOINT_PERMIL) as i64) * ((rep[RB_R_TOP1_MATCH_PERMIL] > 0) as i64), ctr) 100 gv_check("T11 deformation leg measured: the served player ran the artist rig and ours (rc 0 both) and md_measure judged the two posed skins (not refused)" as *u8, ((rep[RB_R_PLAY_A_RC] == 0) as i64) * ((rep[RB_R_PLAY_O_RC] == 0) as i64) * ((rep[RB_R_MD_REFUSED] == 0) as i64), ctr) 101 // T12 exists because the leg was silently vacuous on 2026-09-06: pose_id=1 does not exist on ref9d, the player 102 // replayed bind, and md read 0.2 mm of nothing. rb_run now auto-selects a pose that moves joints and abstains when 103 // none does; this tooth makes a replayed bind RED instead of a flattering near-zero. 104 // OWED, named not hidden: a neg-control fixture whose POSE library is all static must make rb_run ABSTAIN 105 // (deform_pose -1, md -1); it needs an NXA writer in this gate and is queued on dcc.plan. 106 gv_check("T12 non-vacuity of the deformation leg: the auto-selected pose exists (deform_pose >= 0) and moved at least one joint on the artist play, so md judged a deformation and never a replayed bind" as *u8, ((rep[RB_R_DEFORM_POSE] >= 0) as i64) * ((rep[RB_R_DEFORM_JOINTS] > 0) as i64), ctr) 107 108 gv_values_head() 109 gv_kv("deform_pose" as *u8, rep[RB_R_DEFORM_POSE]) 110 gv_kv("deform_pose_joints_moved" as *u8, rep[RB_R_DEFORM_JOINTS]) 111 gv_kv("md_scale_div" as *u8, rep[RB_R_MD_SCALE_DIV]) 112 gv_kv("kat_mean_bone_umm" as *u8, mean) 113 gv_kv("kat_l1_disjoint" as *u8, l1_disj) 114 gv_kv("ref_present" as *u8, 1) 115 gv_kv("bench_rc" as *u8, rc) 116 gv_kv("artist_joints" as *u8, rep[RB_R_ART_JOINTS]) 117 gv_kv("artist_leaves" as *u8, rep[RB_R_ART_LEAVES]) 118 gv_kv("our_joints" as *u8, rep[RB_R_OUR_JOINTS]) 119 gv_kv("our_limbs" as *u8, rep[RB_R_OUR_LIMBS]) 120 gv_kv("artist_mean_bone_umm" as *u8, rep[RB_R_BONE_MEAN_UMM]) 121 gv_kv("artist_joints_covered_permil" as *u8, rep[RB_R_COVERED_PERMIL]) 122 gv_kv("our_joints_spurious_permil" as *u8, rep[RB_R_SPURIOUS_PERMIL]) 123 gv_kv("joint_err_mean_umm" as *u8, rep[RB_R_JOINT_ERR_MEAN_UMM]) 124 gv_kv("joint_err_max_umm" as *u8, rep[RB_R_JOINT_ERR_MAX_UMM]) 125 gv_kv("verts" as *u8, rep[RB_R_VERTS]) 126 gv_kv("weight_l1_mean_permil" as *u8, rep[RB_R_W_L1_MEAN_PERMIL]) 127 gv_kv("top1_joint_match_permil" as *u8, rep[RB_R_TOP1_MATCH_PERMIL]) 128 gv_kv("artist_top1_distinct_joints" as *u8, rep[RB_R_ART_TOP1_DISTINCT]) 129 gv_kv("our_top1_distinct_joints" as *u8, rep[RB_R_OUR_TOP1_DISTINCT]) 130 gv_kv("poses_in_library" as *u8, rep[RB_R_POSES]) 131 gv_kv("md_ours_vs_artist_max_0p1mm" as *u8, rep[RB_R_MD_MAX_0P1MM]) 132 gv_kv("md_ours_vs_artist_p95_0p1mm" as *u8, rep[RB_R_MD_P95_0P1MM]) 133 return gv_verdict("nx_rigbench_gate" as *u8, ctr, "referee rulers proven on known answers; bench ran on the house rig with every value emitted and no bar on the deviation until the panel grades it" as *u8) 134}