code wiki / _hdl_build / nx_uiq_visual_gate.nx

nx_uiq_visual_gate.nx source

↩ module page · 51 lines · 2672 B

1// nx_uiq_visual_gate.nx -- D001 gate for the sovereign visual-render organ (gv-verdict anchored). 2// Proves the deterministic-pixel oracle DISCRIMINATES on encode->decode->analyze fixtures: a rich 3// gradient renders (high ink, many colors, full extent); a solid fill is BLANK-SUSPECT (0 ink, 0 extent); 4// a content band gives the EXACT rendered height. Composes the shipped sovereign decoder (nx_visual_diff 5// vd_load) + encoder (nx_png_write_rgb) -- no new decode code (rule 15). 6// license_tier: ORIGINAL expect_exit: 0 7import "nx_uiq_visual_lib.nx" 8import "nx_gate_verdict.nx" 9 10func main() -> i64 { 11 let ctr: *i64 = gv_ctr() 12 gv_head("nx_uiq_visual_gate -- sovereign real-pixel render metrics: blank-detect + extent, liar-killed" as *u8) 13 uv_mk_rich("uiqviskat_rich.png" as *u8, 64, 64) 14 let ir: *VdImg = vd_load("uiqviskat_rich.png" as *u8) 15 var t1: i64=0 16 if (ir as i64)!=0 { t1=1 } 17 gv_check("T1 sovereign encode->decode round-trips (nx_png_write_rgb -> vd_load)" as *u8, t1, ctr) 18 let orr: *i64 = sys_mmap(64) as *i64 19 if (ir as i64)!=0 { uv_metrics(ir, orr) } 20 var t2: i64=0 21 if orr[0]>=500 { if orr[1]>=8 { t2=1 } } 22 gv_check("T2 rich gradient = RENDERED (ink>=500permille, many colors)" as *u8, t2, ctr) 23 var t3: i64=0 24 let er: i64 = vd_content_extent(ir, UV_INK_DELTA) 25 if er==64 { t3=1 } 26 gv_check("T3 full-bleed content extent = full height (64)" as *u8, t3, ctr) 27 uv_mk_solid("uiqviskat_blank.png" as *u8, 64, 64, 128, 128, 128) 28 let ib: *VdImg = vd_load("uiqviskat_blank.png" as *u8) 29 let ob: *i64 = sys_mmap(64) as *i64 30 if (ib as i64)!=0 { uv_metrics(ib, ob) } 31 var t4: i64=0 32 if ob[0]==0 { t4=1 } 33 gv_check("T4 solid fill = 0 ink (BLANK-SUSPECT: the marker-vs-rendered catch)" as *u8, t4, ctr) 34 var t5: i64=0 35 let eb: i64 = vd_content_extent(ib, UV_INK_DELTA) 36 if eb==0 { t5=1 } 37 gv_check("T5 solid fill content extent = 0 (no rendered content)" as *u8, t5, ctr) 38 uv_mk_band("uiqviskat_band.png" as *u8, 64, 64, 16, 48) 39 let iband: *VdImg = vd_load("uiqviskat_band.png" as *u8) 40 var t6: i64=0 41 let ext: i64 = vd_content_extent(iband, UV_INK_DELTA) 42 if ext==48 { t6=1 } 43 gv_check("T6 content band [16,48) -> EXACT extent 48 (layout-height parity)" as *u8, t6, ctr) 44 let sf: i64 = uv_selftest() 45 var t7: i64=0 46 if sf==0 { t7=1 } 47 gv_check("T7 embedded selftest (the CLI --kat contract) 0 fails" as *u8, t7, ctr) 48 let rc: i64 = gv_verdict("UIQ-VISUAL-GATE" as *u8, ctr, "sovereign real-pixel render metrics: rich=RENDERED, solid=BLANK-SUSPECT, band=exact-extent; composes the shipped PNG decoder" as *u8) 49 sys_exit(rc) 50 return rc 51}