code wiki / (root) / nx_twinfit_gate.nx

nx_twinfit_gate.nx source

↩ module page · 322 lines · 23505 B

1// nx_twinfit_gate.nx -- the referee for nx_twinfit_lib (aesthetictwin AT34 / AT35 / AT40, 2026-09-17). The target reader is held 2// to a planted file (five axes, a bogus axis row that must be ignored, an absent file that must read zero); the reach predicate 3// to both sides of its band; the level arithmetic to the declared ranges; the fit from stated landmarks; then the render lane on 4// the seed-42 identity whose render the outside oracle also judged: the in-process measurement places both eyes, the lip unit's 5// surface ratio agrees with its statement, and the same identity through the PNG door (nx_twinface's path) decodes to the 6// in-process render byte for byte and reproduces the in-process tilts and ratios exactly. The eye unit's landmark truth (AT39) 7// has its own gate, nx_twintruth_gate, since 2026-09-18: its fixed-step surface scans were 58% of this gate's runtime and the 8// whole no longer fitted the roster's per-gate deadline. AT44 (2026-09-18) holds the photo ruler on the same in-process render (no 9// new render) to the construction: its mouth landmarks against the lip unit's projected statement, its lip ratio (4909 permil before 10// AT44 against a constructed 612) within a pixel per line of the projected ratio, its canthi against the stated corners with neither 11// lateral canthus on its band's edge. Every phase prints its wall time. Values are printed with gv_kv. 12// license_tier: ORIGINAL No hw writes (Rule 26). 13import "nx_syscalls.nx" 14import "nx_gate_verdict.nx" 15import "nx_twinfit_lib.nx" 16 17const TG_DIR: *u8 = "/tmp/twinfit_gate" 18const TG_TARGET_PATH: *u8 = "/tmp/twinfit_gate/target.axes" 19const TG_ABSENT_PATH: *u8 = "/tmp/twinfit_gate/absent/none.axes" 20const TG_PNG_PATH: *u8 = "/tmp/twinfit_gate/seed42.png" 21const TG_TARGET_TEXT: *u8 = "# planted target: five axes and one bogus axis row the reader must ignore\naxis|canthal_tilt_R|76|33\naxis|canthal_tilt_L|91|18\naxis|nose_width|500|10\naxis|intercanthal_index|354|11\naxis|intercanthal_eq_fissure|1087|46\naxis|upper_over_lower_lip|607|130\n" 22const TG_MODE755: i64 = 493 23const TG_MODE644: i64 = 420 24const TG_I64: i64 = 8 25const TG_PLANTED_AXES: i64 = 5 26const TG_TILT_R: i64 = 76 27const TG_TILT_R_ERR: i64 = 33 28const TG_TILT_L: i64 = 91 29const TG_ICI: i64 = 354 30const TG_ICF: i64 = 1087 31const TG_LIP: i64 = 607 32const TG_LIP_ERR: i64 = 130 33const TG_ENV_MIN: i64 = 90 34const TG_ENV_MAX: i64 = 110 35const TG_IN: i64 = 100 36const TG_TOUCH: i64 = 120 37const TG_TOUCH_ERR: i64 = 10 38const TG_ABOVE: i64 = 150 39const TG_BELOW: i64 = 50 40const TG_GENE_WIDTH: i64 = 0 41const TG_WIDTH_FLOOR: i64 = 85 42const TG_WIDTH_MID: i64 = 101 43const TG_WIDTH_CEIL: i64 = 118 44const TG_SEED: i64 = 42 45const TG_YAW: i64 = 0 46// seed 42's identity as persongen_build derives it (the render the outside oracle judged): width, length, jaw, eyes, lips, nose, cheek 47const TG_G_W: i64 = 89 48const TG_G_L: i64 = 96 49const TG_G_J: i64 = 100 50const TG_G_E: i64 = 108 51const TG_G_P: i64 = 109 52const TG_G_N: i64 = 105 53const TG_G_C: i64 = 106 54const TG_SKIN_R: i64 = 130 55const TG_SKIN_G: i64 = 98 56const TG_SKIN_B: i64 = 70 57const TG_ID_EYES: i64 = 3 58 59func tg_write(path: *u8, text: *u8) -> i64 { 60 let fd: i64 = sys_openat_wr(path, TG_MODE644) 61 if fd < 0 { return 0 - 1 } 62 let n: i64 = sys_write(fd, text, ri_slen(text)) 63 sys_close(fd) 64 return n 65} 66func tg_same(a: *u8, b: *u8, n: i64) -> i64 { 67 var i: i64 = 0 68 while i < n { if a[i] != b[i] { return 0 } i = i + 1 } 69 return 1 70} 71// the PNG door's file decoded back to interleaved RGB through the same codec the ruler reads it with (nx_png_decode, then 72// pm_png_rgb); dw[0], dw[1] carry its size. 0 when the file does not decode to an 8-bit plane the ruler would read 73const TG_DECODE_SLOTS: i64 = 2 74func tg_png_rgb(path: *u8, dw: *i64) -> *u8 { 75 dw[0] = 0 76 dw[1] = 0 77 let fl: *i64 = sys_mmap(TG_DECODE_SLOTS * TG_I64) as *i64 78 fl[0] = 0 79 let raw: *u8 = sys_read_file(path, fl) 80 if (raw as i64) == 0 { return 0 as *u8 } 81 if fl[0] <= 0 { return 0 as *u8 } 82 let pr: *NxPngResult = nx_png_decode(raw, fl[0]) 83 if (pr as i64) == 0 { return 0 as *u8 } 84 if pr.error_code != 0 { return 0 as *u8 } 85 let hdr: *NxPngHeader = pr.header 86 if (hdr as i64) == 0 { return 0 as *u8 } 87 if hdr.bit_depth != PM_PNG_DEPTH { return 0 as *u8 } 88 if pr.pixels_size < hdr.width * hdr.height * pr.n_channels { return 0 as *u8 } 89 dw[0] = hdr.width 90 dw[1] = hdr.height 91 return pm_png_rgb(pr.pixels, hdr.width, hdr.height, pr.n_channels) 92} 93func tg_same_or_absent(a: *u8, b: *u8, n: i64) -> i64 { 94 if (b as i64) == 0 { return 0 } 95 return tg_same(a, b, n) 96} 97// ---- AT40: the fit from stated landmarks ------------------------------------------------------------------------------------------ 98const TG40_KNOWN_WIDTH: i64 = 108 // a planted genome the fit must recover the AXES of (not the genes: several genomes share axes) 99const TG40_KNOWN_EYES: i64 = 94 100const TG40_KNOWN_TILT: i64 = 70 101const TG40_GENE_WIDTH: i64 = 0 102const TG40_GENE_JAW: i64 = 2 103const TG40_GENE_EYES: i64 = 3 104const TG40_GENE_LIPS: i64 = 4 105const TG40_GENE_NOSE: i64 = 5 106const TG40_TILT_ERR: i64 = 4 107const TG40_RATIO_ERR: i64 = 6 108// the opening's half-width is a whole number of model units (110 at the canon), and one unit moves the fissure ratio about 21 permil 109// at this scale, so a fit is held to ONE LATTICE STEP of that axis, not to a tolerance the generator's own resolution cannot state. 110// Sub-unit opening precision is the named limit for fitting a likeness closer than this (queued on the board). 111const TG40_ICF_LATTICE_ERR: i64 = 24 112const TG40_FAR_TILT: i64 = 300 // thirty degrees: outside anything the tilt gene's declared range can state 113const TG40_FAR_ERR: i64 = 5 114const TG40_LIP_TARGET: i64 = 607 115const TG40_LIP_ERR: i64 = 130 116// the cost's planted case: three axes inside their bands, then the left tilt pushed 13 outside its band 117const TG40_C_TILT_R: i64 = 80 118const TG40_C_TILT_L_IN: i64 = 80 119const TG40_C_TILT_L_OUT: i64 = 60 120const TG40_C_ICI: i64 = 350 121const TG40_C_ICF: i64 = 1100 122const TG40_T_TILT_R: i64 = 76 123const TG40_T_TILT_L: i64 = 91 124const TG40_T_ICI: i64 = 354 125const TG40_T_ICF: i64 = 1087 126const TG40_E_TILT_R: i64 = 33 127const TG40_E_TILT_L: i64 = 18 128const TG40_E_ICI: i64 = 11 129const TG40_E_ICF: i64 = 46 130const TG40_COST_IN: i64 = 32 // 4 + 11 + 4 + 13, every axis inside its band 131const TG40_COST_OUT: i64 = 260 // the left tilt at 60 is 31 off, 13 beyond its band: 13 * 16 + 31 = 239, plus 4 + 4 + 13 132const TG40_OUTSIDE_X: i64 = 5000 // a point far outside any lid shell's silhouette 133const TG44_LINES_PER_HEIGHT: i64 = 2 // a vermilion height runs between two lines (its outer border and the seam's edge), a pixel each 134 135func tg_at40(ctr: *i64, vals: *i64) -> i64 { 136 let base: i64 = sys_mmap(sdf_bytes()) as i64 137 let ga: *i64 = sys_mmap(TW_ALL_GENES * TG_I64) as *i64 138 let t: *i64 = sys_mmap(TW_T_N * TG_I64) as *i64 139 let ax: *i64 = sys_mmap(TW_AXES * TG_I64) as *i64 140 let tv: *i64 = sys_mmap(TW_AXES * TG_I64) as *i64 141 let te: *i64 = sys_mmap(TW_AXES * TG_I64) as *i64 142 let cost: *i64 = sys_mmap(TG_I64) as *i64 143 // the cost, on planted numbers 144 tv[TW_AX_TILT_R] = TG40_T_TILT_R; tv[TW_AX_TILT_L] = TG40_T_TILT_L; tv[TW_AX_ICI] = TG40_T_ICI; tv[TW_AX_ICF] = TG40_T_ICF; tv[TW_AX_LIP] = TG40_LIP_TARGET 145 te[TW_AX_TILT_R] = TG40_E_TILT_R; te[TW_AX_TILT_L] = TG40_E_TILT_L; te[TW_AX_ICI] = TG40_E_ICI; te[TW_AX_ICF] = TG40_E_ICF; te[TW_AX_LIP] = TG40_LIP_ERR 146 ax[TW_AX_TILT_R] = TG40_C_TILT_R; ax[TW_AX_TILT_L] = TG40_C_TILT_L_IN; ax[TW_AX_ICI] = TG40_C_ICI; ax[TW_AX_ICF] = TG40_C_ICF; ax[TW_AX_LIP] = TW_UNSET 147 gv_check_eq("fit-cost-inside-every-band-is-the-summed-distance" as *u8, tw_fit_cost(ax, tv, te), TG40_COST_IN, ctr) 148 ax[TW_AX_TILT_L] = TG40_C_TILT_L_OUT 149 gv_check_eq("fit-cost-outside-a-band-weights-the-excess" as *u8, tw_fit_cost(ax, tv, te), TG40_COST_OUT, ctr) 150 gv_check_eq("fit-an-unstated-axis-is-named-unstated" as *u8, tw_axis_state(ax, tv, te, TW_AX_LIP), TW_AXIS_UNSTATED, ctr) 151 gv_check_eq("fit-an-axis-outside-its-band-is-unreached" as *u8, tw_axis_state(ax, tv, te, TW_AX_TILT_L), TW_AXIS_UNREACHED, ctr) 152 // the stated corner's depth is arithmetic on the shell, and refuses where there is no shell to be on 153 tw_all_canon_fill(ga) 154 tw_build_all(base, ga) 155 gv_check_eq("neg-control-a-point-outside-the-shell-silhouette-has-no-depth" as *u8, fa_lid_corner_z(base, TW_EYE_IMAGE_RIGHT, TG40_OUTSIDE_X, 0), FA_LIP_NOSURF, ctr) 156 gv_check_eq("stated-landmarks-exist-on-the-canon-face" as *u8, tw_stated_landmarks(base, TW_YAW_FRONTAL, t), 1, ctr) 157 // a planted genome's axes, then the fit from the canon must reach every one of them 158 tw_all_canon_fill(ga) 159 ga[TG40_GENE_WIDTH] = TG40_KNOWN_WIDTH 160 ga[TG40_GENE_EYES] = TG40_KNOWN_EYES 161 ga[TW_GENES + FA_EG_TILT] = TG40_KNOWN_TILT 162 tw_build_all(base, ga) 163 tw_stated_landmarks(base, TW_YAW_FRONTAL, t) 164 tw_axes_from_landmarks(t, tv) 165 te[TW_AX_TILT_R] = TG40_TILT_ERR; te[TW_AX_TILT_L] = TG40_TILT_ERR; te[TW_AX_ICI] = TG40_RATIO_ERR; te[TW_AX_ICF] = TG40_ICF_LATTICE_ERR; te[TW_AX_LIP] = 0 166 let known_ici: i64 = tv[TW_AX_ICI] 167 tw_all_canon_fill(ga) 168 let evals: i64 = tw_fit(base, tv, te, ga, ax, cost) 169 gv_check_eq("fit-recovers-the-planted-right-tilt" as *u8, tw_axis_state(ax, tv, te, TW_AX_TILT_R), TW_AXIS_REACHED, ctr) 170 gv_check_eq("fit-recovers-the-planted-left-tilt" as *u8, tw_axis_state(ax, tv, te, TW_AX_TILT_L), TW_AXIS_REACHED, ctr) 171 gv_check_eq("fit-recovers-the-planted-intercanthal-index" as *u8, tw_axis_state(ax, tv, te, TW_AX_ICI), TW_AXIS_REACHED, ctr) 172 gv_check_eq("fit-recovers-the-planted-fissure-ratio-to-one-lattice-step" as *u8, tw_axis_state(ax, tv, te, TW_AX_ICF), TW_AXIS_REACHED, ctr) 173 gv_check_eq("fit-leaves-the-jaw-gene-it-cannot-use-at-the-canon" as *u8, ga[TG40_GENE_JAW], TW_CANON_PCT, ctr) 174 gv_check_eq("fit-leaves-the-lips-gene-it-cannot-use-at-the-canon" as *u8, ga[TG40_GENE_LIPS], TW_CANON_PCT, ctr) 175 gv_check_eq("fit-leaves-the-nose-gene-it-cannot-use-at-the-canon" as *u8, ga[TG40_GENE_NOSE], TW_CANON_PCT, ctr) 176 gv_check("fit-evaluated-more-than-one-genome" as *u8, (evals > 1) as i64, ctr) 177 let planted_cost: i64 = cost[0] 178 // neg-control: a tilt no declared range can state ends UNREACHED with the tilt gene ON its ceiling, which names the range 179 tv[TW_AX_TILT_R] = TG40_FAR_TILT; tv[TW_AX_TILT_L] = TG40_FAR_TILT; tv[TW_AX_ICI] = TW_UNSET; tv[TW_AX_ICF] = TW_UNSET; tv[TW_AX_LIP] = TW_UNSET 180 te[TW_AX_TILT_R] = TG40_FAR_ERR; te[TW_AX_TILT_L] = TG40_FAR_ERR 181 tw_all_canon_fill(ga) 182 tw_fit(base, tv, te, ga, ax, cost) 183 gv_check_eq("neg-control-an-unreachable-tilt-stays-unreached" as *u8, tw_axis_state(ax, tv, te, TW_AX_TILT_R), TW_AXIS_UNREACHED, ctr) 184 gv_check_eq("neg-control-and-the-tilt-gene-ends-on-its-declared-ceiling" as *u8, ga[TW_GENES + FA_EG_TILT], fa_eye_gene_hi(FA_EG_TILT), ctr) 185 vals[0] = known_ici; vals[1] = evals; vals[2] = planted_cost; vals[3] = ax[TW_AX_TILT_R] 186 return 0 187} 188func main(argc: i64, argv: *i64) -> i64 { 189 gv_head("nx_twinfit_gate -- twin loop substrate: target reader, reach predicate, level arithmetic, render determinism, PNG door parity" as *u8) 190 let ctr: *i64 = gv_ctr() 191 sys_mkdir(TG_DIR, TG_MODE755) 192 // the target reader 193 let tv: *i64 = sys_mmap(TW_AXES * TG_I64) as *i64 194 let te: *i64 = sys_mmap(TW_AXES * TG_I64) as *i64 195 gv_need("fixture-target-written" as *u8, (tg_write(TG_TARGET_PATH, TG_TARGET_TEXT) > 0) as i64, ctr) 196 gv_check_eq("target-reads-the-five-planted-axes-and-ignores-the-bogus-row" as *u8, tw_load_target(TG_TARGET_PATH, tv, te), TG_PLANTED_AXES, ctr) 197 gv_check_eq("target-tilt-R-value" as *u8, tv[TW_AX_TILT_R], TG_TILT_R, ctr) 198 gv_check_eq("target-tilt-R-err" as *u8, te[TW_AX_TILT_R], TG_TILT_R_ERR, ctr) 199 gv_check_eq("target-tilt-L-value" as *u8, tv[TW_AX_TILT_L], TG_TILT_L, ctr) 200 gv_check_eq("target-intercanthal-index-value" as *u8, tv[TW_AX_ICI], TG_ICI, ctr) 201 gv_check_eq("target-intercanthal-eq-fissure-value" as *u8, tv[TW_AX_ICF], TG_ICF, ctr) 202 gv_check_eq("target-lip-value" as *u8, tv[TW_AX_LIP], TG_LIP, ctr) 203 gv_check_eq("target-lip-err" as *u8, te[TW_AX_LIP], TG_LIP_ERR, ctr) 204 gv_check_eq("neg-control-absent-target-reads-zero-axes" as *u8, tw_load_target(TG_ABSENT_PATH, tv, te), 0, ctr) 205 gv_check_eq("neg-control-absent-target-leaves-every-axis-unset" as *u8, tv[TW_AX_TILT_R] + tv[TW_AX_LIP], TW_UNSET + TW_UNSET, ctr) 206 // the reach predicate 207 gv_check_eq("reach-target-inside-envelope" as *u8, tw_reach(TG_IN, 0, TG_ENV_MIN, TG_ENV_MAX), 1, ctr) 208 gv_check_eq("reach-error-band-touching-envelope" as *u8, tw_reach(TG_TOUCH, TG_TOUCH_ERR, TG_ENV_MIN, TG_ENV_MAX), 1, ctr) 209 gv_check_eq("neg-control-reach-target-above-envelope" as *u8, tw_reach(TG_ABOVE, TG_TOUCH_ERR, TG_ENV_MIN, TG_ENV_MAX), 0, ctr) 210 gv_check_eq("neg-control-reach-target-below-envelope" as *u8, tw_reach(TG_BELOW, TG_TOUCH_ERR, TG_ENV_MIN, TG_ENV_MAX), 0, ctr) 211 // the level arithmetic over the declared ranges 212 gv_check_eq("level-floor-is-the-declared-floor" as *u8, tw_level_pct(TG_GENE_WIDTH, 0), TG_WIDTH_FLOOR, ctr) 213 gv_check_eq("level-middle-is-the-integer-midpoint" as *u8, tw_level_pct(TG_GENE_WIDTH, 1), TG_WIDTH_MID, ctr) 214 gv_check_eq("level-ceiling-is-the-declared-ceiling" as *u8, tw_level_pct(TG_GENE_WIDTH, 2), TG_WIDTH_CEIL, ctr) 215 var ok: i64 = 1 216 var k: i64 = 0 217 while k < TW_GENES { if tw_lo(k) > tw_mid(k) { ok = 0 } if tw_mid(k) > tw_hi(k) { ok = 0 } if tw_lo(k) >= tw_hi(k) { ok = 0 } k = k + 1 } 218 gv_check("every-gene-floor-below-middle-below-ceiling" as *u8, ok, ctr) 219 // every phase stamps its wall time, printed with the values: the roster admits a gate by its runtime, so the gate says where it goes 220 // (the eye unit's truth scans, measured the costliest phase, have their own gate since 2026-09-18: nx_twintruth_gate) 221 let ms_start: i64 = sys_now_ms() 222 // AT40: the fit from stated landmarks (no render) 223 let v40: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 224 tg_at40(ctr, v40) 225 let ms_at40: i64 = sys_now_ms() 226 // the render lane: the seed-42 identity in-process, its determinism, and the PNG door's parity 227 let cs: *i64 = sys_mmap(2 * TG_I64) as *i64 228 gv_need("fixture-reached-the-condition-cascades-loaded" as *u8, tw_load_cascades(cs), ctr) 229 let face_c: *HaarCascade = cs[0] as *HaarCascade 230 let eye_c: *HaarCascade = cs[1] as *HaarCascade 231 let base: i64 = sys_mmap(sdf_bytes()) as i64 232 let npx: i64 = ww() * hh() * TW_RGB_BPP 233 let rgb: *u8 = sys_mmap(npx) 234 let res: *i64 = sys_mmap(PM_R_N * TG_I64) as *i64 235 let g: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 236 let skin: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 237 g[0] = TG_G_W; g[1] = TG_G_L; g[2] = TG_G_J; g[3] = TG_G_E; g[4] = TG_G_P; g[5] = TG_G_N; g[6] = TG_G_C 238 skin[TW_SKIN_SLOT_R] = TG_SKIN_R; skin[TW_SKIN_SLOT_G] = TG_SKIN_G; skin[TW_SKIN_SLOT_B] = TG_SKIN_B 239 // AT39: the identity is the SEED (seven morphs, tone AND eye genes), so the in-process lane grows the same person the PNG door does 240 let idv0: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 241 let ms_cascades: i64 = sys_now_ms() 242 let rc: i64 = tw_measure_seed(base, TG_SEED, skin, idv0, rgb, res, face_c, eye_c) 243 let ms_measure: i64 = sys_now_ms() 244 gv_check_eq("seed42-genome-in-process-measured" as *u8, rc, PM_OK, ctr) 245 gv_check_eq("seed42-genome-both-eyes-placed" as *u8, res[PM_R_EYES], 2, ctr) 246 // AT39: THE TOOTH THAT STOOD HERE ASSERTED THE PHOTO RULER FINDS THE MOUTH ON THIS RENDER. It held for the old face because 247 // the ruler derives its mouth window from its own eye span and the old lash bars made the eyes read wide; with a real eye 248 // opening the window stops short of the lower lip. A render's landmarks are now the generator's own statement (the eye unit 249 // above), and the mouth's successor is lip truth: since the lip unit (AT43, 2026-09-18) the generator STATES its vermilion 250 // lines (fa_lip_stated) and the surface ruler reads them back from the ray-marched midline (fa_lip_ratio). On this seed's 251 // MORPHED identity the two routes must agree, within the ratio error one refine step on each height allows (the borders land 252 // on the stated outline exactly; only the stomion carries error -- see nx_lipratio_gate T11). 253 let lipo: *i64 = sys_mmap(FA_LIP_O_FIELDS * TG_I64 + FA_LIP_SLACK) as *i64 254 let seed_lip: i64 = fa_lip_ratio(base, lipo) 255 let lipst: *i64 = sys_mmap(FA_LS_O_FIELDS * TG_I64 + FA_LIP_SLACK) as *i64 256 fa_lip_stated(base, lipst) 257 let lipend: i64 = FA_LIP_REFINE_STEP 258 let liptol: i64 = lipst[FA_LS_O_RATIO] * lipend / lipst[FA_LS_O_UPPER_H] + lipst[FA_LS_O_RATIO] * lipend / lipst[FA_LS_O_LOWER_H] 259 gv_check_eq("seed42-lip-ratio-measured-from-the-surface-nothing-refused" as *u8, lipo[FA_LIP_O_REASON], FA_LIP_R_OK, ctr) 260 gv_check_near("seed42-lip-surface-ratio-agrees-with-the-lip-units-statement" as *u8, seed_lip, lipst[FA_LS_O_RATIO], liptol, ctr) 261 // AT44: THE PHOTO RULER ON THIS SAME RENDER, JUDGED AGAINST THE CONSTRUCTION -- no new render. Before AT44 its mouth band ran from 262 // the nose's shadow to the chin fold and the lip ratio read 4909 permil against a constructed 612, and both lateral canthi sat on 263 // their cascade bands' edges (212 and 302). Now its five mouth landmarks are held to the lip unit's projected statement, its lip 264 // ratio to the ratio of those projected points within two pixels per lip height (a height's two lines, one pixel each), and its 265 // canthi to the stated corners with neither lateral canthus on its band's edge 266 let lt: *i64 = sys_mmap(TW_LT_N * TG_I64) as *i64 267 let lj: *i64 = sys_mmap(TW_LJ_N * TG_I64) as *i64 268 let st: *i64 = sys_mmap(TW_T_N * TG_I64) as *i64 269 let ej: *i64 = sys_mmap(TW_J_N * TG_I64) as *i64 270 gv_check_eq("seed42-lip-truth-projects" as *u8, tw_lip_truth(base, TW_YAW_FRONTAL, lt), 1, ctr) 271 gv_check_eq("seed42-ruler-mouth-rests-on-a-verified-seam" as *u8, res[PM_R_MOUTH_WHY], PM_MW_OK, ctr) 272 let lnmax: i64 = tw_lip_judge(res, lt, lj) 273 gv_check("seed42-ruler-mouth-landmarks-found-against-the-lip-truth" as *u8, (lnmax <= PM_NME_FOUND_PERMIL) as i64, ctr) 274 let uh: i64 = lt[TW_LT_STO_X + 1] - lt[TW_LT_LS_X + 1] 275 let lh: i64 = lt[TW_LT_LI_X + 1] - lt[TW_LT_STO_X + 1] 276 let ratiotol: i64 = lt[TW_LT_RATIO_PIXEL] * TG44_LINES_PER_HEIGHT * TW_DECI / pm_max(uh, 1) + lt[TW_LT_RATIO_PIXEL] * TG44_LINES_PER_HEIGHT * TW_DECI / pm_max(lh, 1) 277 gv_check_near("seed42-ruler-lip-ratio-within-a-pixel-per-line-of-the-projected-truth" as *u8, res[PM_R_LIP], lt[TW_LT_RATIO_PIXEL], ratiotol, ctr) 278 gv_check_eq("seed42-stated-corners-project" as *u8, tw_stated_landmarks(base, TW_YAW_FRONTAL, st), 1, ctr) 279 let enmax: i64 = tw_judge(res, st, ej) 280 gv_check("seed42-ruler-canthi-found-against-the-stated-corners" as *u8, (enmax <= PM_NME_FOUND_PERMIL) as i64, ctr) 281 gv_check("seed42-image-left-lateral-canthus-is-not-its-bands-edge" as *u8, (res[PM_R_RLAT_X] != res[PM_R_EX0]) as i64, ctr) 282 gv_check("seed42-image-right-lateral-canthus-is-not-its-bands-edge" as *u8, (res[PM_R_LLAT_X] != res[PM_R_LX1] - 1) as i64, ctr) 283 let ms_lip: i64 = sys_now_ms() 284 // THE SECOND RENDER IS THE PNG DOOR'S (2026-09-18). It used to be the third: the in-process lane rendered seed 42 twice to prove 285 // determinism and the door rendered it once more. The door's render, decoded back to pixels and compared byte for byte with 286 // the first in-process render, proves the same determinism (two independent renders of one identity) and that the PNG round 287 // trip is lossless, for one render fewer -- the roster admits a gate by its runtime. 288 let pskin: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 289 let idv: *i64 = sys_mmap(TW_SLOTS * TG_I64) as *i64 290 let png: i64 = tw_render_png(base, TG_SEED, TG_YAW, TG_PNG_PATH, pskin, idv) 291 let ms_png: i64 = sys_now_ms() 292 gv_check("png-door-render-landed-on-disk" as *u8, (png > 0) as i64, ctr) 293 let dw: *i64 = sys_mmap(TG_DECODE_SLOTS * TG_I64) as *i64 294 let drgb: *u8 = tg_png_rgb(TG_PNG_PATH, dw) 295 gv_check_eq("png-door-decodes-to-the-render-frame-width" as *u8, dw[0], ww(), ctr) 296 gv_check_eq("png-door-decodes-to-the-render-frame-height" as *u8, dw[1], hh(), ctr) 297 gv_check("render-of-the-same-identity-is-byte-identical-through-the-png-door" as *u8, tg_same_or_absent(rgb, drgb, npx), ctr) 298 gv_check_eq("seed42-identity-eyes-percent-is-the-planted-genome" as *u8, idv[TG_ID_EYES], TG_G_E, ctr) 299 gv_check_eq("seed42-identity-skin-red-is-the-planted-tone" as *u8, pskin[TW_SKIN_SLOT_R], TG_SKIN_R, ctr) 300 let res2: *i64 = sys_mmap(PM_R_N * TG_I64) as *i64 301 let rc2: i64 = pm_landmarks_file_auto(TG_PNG_PATH, res2, face_c, eye_c) 302 let ms_door: i64 = sys_now_ms() 303 gv_check_eq("png-door-seed42-measured" as *u8, rc2, PM_OK, ctr) 304 gv_check_eq("png-door-announces-png-codec" as *u8, res2[PM_R_CODEC], PM_CODEC_PNG, ctr) 305 gv_check_eq("png-door-right-tilt-equals-in-process" as *u8, res2[PM_R_TILT_R], res[PM_R_TILT_R], ctr) 306 gv_check_eq("png-door-left-tilt-equals-in-process" as *u8, res2[PM_R_TILT_L], res[PM_R_TILT_L], ctr) 307 gv_check_eq("png-door-intercanthal-index-equals-in-process" as *u8, res2[PM_R_ICI], res[PM_R_ICI], ctr) 308 gv_check_eq("png-door-lip-ratio-equals-in-process" as *u8, res2[PM_R_LIP], res[PM_R_LIP], ctr) 309 gv_values_head() 310 gv_kv("ruler_mouth_found_on_render" as *u8, res[PM_R_MOUTH]); gv_kv("seed42_lip_truth_ratio_or_unmeasured" as *u8, seed_lip) 311 gv_kv("seed42_lip_ratio_pixel_truth" as *u8, lt[TW_LT_RATIO_PIXEL]); gv_kv("seed42_lip_ratio_tolerance" as *u8, ratiotol); gv_kv("seed42_lip_nmax_permil" as *u8, lnmax); gv_kv("seed42_lip_nmean_permil" as *u8, lj[TW_LJ_NMEAN]) 312 gv_kv("seed42_canthi_nmax_permil" as *u8, enmax); gv_kv("seed42_rlat_dx_deci" as *u8, ej[TW_J_DX]); gv_kv("seed42_rlat_dy_deci" as *u8, ej[TW_J_DY]) 313 gv_kv("seed42_llat_dx_deci" as *u8, ej[(TW_LANDMARKS - 1) * TW_J_FIELDS + TW_J_DX]); gv_kv("seed42_llat_dy_deci" as *u8, ej[(TW_LANDMARKS - 1) * TW_J_FIELDS + TW_J_DY]) 314 gv_kv("fit_planted_ici_permil" as *u8, v40[0]); gv_kv("fit_planted_evals" as *u8, v40[1]); gv_kv("fit_planted_final_cost" as *u8, v40[2]); gv_kv("fit_unreachable_tilt_best_deg10" as *u8, v40[3]) 315 gv_kv("tilt_R_deg10" as *u8, res[PM_R_TILT_R]); gv_kv("tilt_L_deg10" as *u8, res[PM_R_TILT_L]); gv_kv("tilt_err_deg10" as *u8, res[PM_R_TILT_ERR]) 316 gv_kv("ici_permil" as *u8, res[PM_R_ICI]); gv_kv("icf_permil" as *u8, res[PM_R_ICF]); gv_kv("lip_permil" as *u8, res[PM_R_LIP]) 317 gv_kv("fissure_R_px" as *u8, res[PM_R_FISSURE_R]); gv_kv("fissure_L_px" as *u8, res[PM_R_FISSURE_L]); gv_kv("png_bytes" as *u8, png) 318 gv_kv("ms_fit" as *u8, ms_at40 - ms_start); gv_kv("ms_cascades" as *u8, ms_cascades - ms_at40) 319 gv_kv("ms_measure_seed" as *u8, ms_measure - ms_cascades); gv_kv("ms_lip_units" as *u8, ms_lip - ms_measure) 320 gv_kv("ms_render_png" as *u8, ms_png - ms_lip); gv_kv("ms_png_door_decode_and_ruler" as *u8, ms_door - ms_png); gv_kv("ms_total_timed" as *u8, ms_door - ms_start) 321 return gv_verdict("nx_twinfit_gate" as *u8, ctr, "the twin loop substrate: the target reader held to a planted file, the reach predicate to both sides of its band, the level arithmetic to the declared ranges, and the seed-42 render measured in-process, reproduced byte for byte by the PNG door's own render and measured identically through it" as *u8) 322}