code wiki / (root) / nx_charjudge_census.nx

nx_charjudge_census.nx source

↩ module page · 1576 lines · 79158 B

1// nx_charjudge_census.nx -- THE CHARACTER REFEREE AS A STANDING INSTRUMENT: judge an ENTIRE named corpus in 2// one call, one line per image, with the partition reconciled -- AND (2026-08-19, GR1 of /compare/graphics, 3// Phase 0 of the past-MetaHuman roadmap) THE JUDGE PANEL `cjc_panel`: a multi-lens referee that can see 4// what the single statistics judge is proven blind to. 5// 6// WHY IT EXISTS: the judge was a single-image CLI, so grading a corpus meant one invocation per file. That 7// cost is exactly what turns "measure the population" into "measure a sample", and a tooling gap is never a 8// licence to sample. The whole render corpus is now one call. 9// 10// WHY THE PANEL EXISTS (measured 2026-08-16, both directions): nx_charjudge scored a GREEN CLAY figure crop 11// 257 (the operator saw gumby) and a smooth photoreal-class splat render 0 ("smooth = no detail"). Its axes 12// (composition, palette, contour, face) are hue- and semantics-agnostic BY CONSTRUCTION, so every fidelity 13// claim graded through it alone is ungradeable. The panel COMPOSES incumbents, never re-implements: 14// stats = ./nx_charjudge.elf (the statistics judge, forked -- the artifact that ships) 15// skin = nx_color_kovac_skin_pixel (Kovac 2003 published skin gamut, over the figure / centre) 16// sym = ./nx_image_beauty.elf path (bilateral symmetry Q1000, forked) 17// percept = ./nx_percept.elf judge (RELATIVE perceptual position vs the 10 human-confirmed 18// commercial frames minus the junk controls; admitted only 19// while its own ladder reproduces the human ordering) 20// vlm = UNOBSERVABLE (no sovereign VLM oracle exists on the estate -- measured 21// 2026-08-19 by tree grep + local probe; the slot abstains, 22// it never acquits) 23// THE LAW THE PANEL IS BUILT UNDER: AN UNCALIBRATED CLASSIFIER REPORTS NUMBERS, NEVER VERDICTS. `panel` 24// prints every lens value for every image always; it prints a GOOD/BAD verdict ONLY while an admission 25// receipt written by `calibrate` says FP=0 and FN=0 on a LABELLED corpus with both classes present -- and 26// the receipt is bound to the exact floors it was measured at, so editing the conf silently un-admits. 27// Floors are DATA (knowledge/cjc_panel.conf), never literals here. A lens with no floor in the conf is 28// REPORT-ONLY (printed, not voting): that is how a lens proven blind is retired from the vote by evidence. 29// Composite = AND over voting lenses (the MIN-headline doctrine: no lens may be compensated by another). 30// 31// WHY IT FORKS rather than looping in-process: chj_judge allocates several w*h*8 working buffers per frame, 32// so an in-process sweep multiplies every one of them by the corpus size -- measured, that is gigabytes of 33// address space on a box already sitting at 727 permil swap. A child returns its entire working set to the 34// OS on exit, so peak RSS is ONE frame regardless of corpus size. Forking also means this census measures 35// the artifact that ACTUALLY SHIPS rather than a second compiled copy of the same lib: if the promoted 36// binary is stale or missing, that surfaces here instead of being hidden by an identical rebuild. 37// The panel keeps that design: the parent forks ITSELF (`lens <path> <conf>`) per image; the child decodes 38// once (nx_img_to_rgb: PNG/JPEG/GIF/WebP-lossless/BMP/...), computes the in-process lenses on a bounded 39// fit-resampled frame, forks the three sibling judges, and prints ONE anchored line. 40// 41// NO SAMPLING, NO SILENT CAP: every row is attempted; failures are counted AND NAMED; a truncated child 42// capture is counted and forces a non-zero exit; the partition is printed and must reconcile or the census 43// refuses its own numbers. 44// argv: 45// <list-file> [judge-elf] legacy census (unchanged): one path per line, '#' comments skipped 46// panel <list-file> [conf] the panel: rows `path[<TAB>GOOD|BAD]`; verdicts only if admitted 47// calibrate <labelled-list> [conf] panel + confusion per lens + receipt; exit 0 admitted, 1 refused 48// lens <image> [conf] one image, one anchored line (the per-image child) 49// topng <in-image> <out.png> bank any decodable reference as PNG (sibling judges are PNG-only) 50// figcrop <in-image> <out.png> [conf] SAME-FRAMING instrument: crop to the figure bbox (pixels that differ 51// from the corner-mean background by > bg_tol) + a margin derived from 52// the bbox itself; the GR2 done-rule compares "on the same framing" 53// license_tier: ORIGINAL No hw writes (Rule 26). 54import "nx_syscalls.nx" 55import "nx_itoa_lib.nx" 56import "nx_tool_run.nx" 57import "nx_img_to_rgb.nx" 58import "nx_png_write.nx" 59import "nx_nxfh_lib.nx" 60import "nx_color_v2.nx" 61 62const CJX_PATHCAP: i64 = 1024 63const CJX_OUTCAP: i64 = 8192 64const CJX_TIMEOUT_MS: i64 = 60000 65const CJX_ARGV_SLOTS: i64 = 4 66const CJX_HASH: i64 = 35 67const CJX_NL: i64 = 10 68const CJX_CR: i64 = 13 69const CJX_TAB: i64 = 9 70const CJX_D0: i64 = 48 71const CJX_D9: i64 = 57 72const CJX_MINUS: i64 = 45 73const CJX_PERMIL_MAX: i64 = 1000 74 75// ---- panel constants: sentinels and formats, never thresholds (thresholds ride the conf) ---- 76const CJP_UNOBS: i64 = 0 - 9999 // a lens that could not see: abstain, never acquit 77const CJP_CONFCAP: i64 = 65536 78const CJP_RECEIPTCAP: i64 = 4096 79const CJP_CHILD_ARGV: i64 = 5 80const CJP_CHILD_OUTCAP: i64 = 16384 81const CJP_LABEL_GOOD: i64 = 1 82const CJP_LABEL_BAD: i64 = 0 83const CJP_LABEL_NONE: i64 = 0 - 1 84const CJP_FNV_BASIS: i64 = 2166136261 85const CJP_FNV_PRIME: i64 = 16777619 86const CJP_FNV_MASK: i64 = 4294967295 87const CJP_MODE_644: i64 = 420 88const CJP_BYTE: i64 = 256 89const CJP_LENSES: i64 = 5 // stats skin sym percept vlm 90const CJP_SKRULES: i64 = 3 // kovac | chroma | locus -- every run reports all three 91const CJP_SK_KOVAC: i64 = 0 92const CJP_SK_CHROMA: i64 = 1 93const CJP_SK_LOCUS: i64 = 2 94const CJP_L_STATS: i64 = 0 95const CJP_L_SKIN: i64 = 1 96const CJP_L_SYM: i64 = 2 97const CJP_L_PERCEPT: i64 = 3 98const CJP_L_VLM: i64 = 4 99// conf defaults that are CONTRACTS of the organs composed, not tuning: nx_percept's frame is 400x240 NXFH1 100// (its own PJ_W/PJ_H); override in the conf if nx_percept ever changes its contract. 101const CJP_DEF_PERCEPT_W: i64 = 400 102const CJP_DEF_PERCEPT_H: i64 = 240 103const CJP_DEF_CENTER_PERMIL: i64 = 500 104const CJP_DEF_BG_TOL: i64 = 24 105const CJP_DEF_CROP_MARGIN_PERMIL: i64 = 50 // figcrop margin = 5 percent of the larger bbox side (conf: crop_margin_permil) 106const CJP_DEF_BG_INSET_PX: i64 = 4 // background sampled this far inside each corner (conf: bg_inset_px) -- 107 // a clipped canvas capture carries its 1-px CSS border at the very corner 108const CJP_DEF_EDGE_IGNORE_PX: i64 = 2 // figcrop ignores this edge ring when scanning for figure pixels (conf) 109 110func cjx_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 111func cjx_n(v: i64) -> i64 { nxi_out(v); return 0 } 112func cjx_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 113func cjx_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; var p: i64=o; while s[i]!=(0 as u8){ d[p]=s[i]; p=p+1; i=i+1 } d[p]=0 as u8; return p } 114func cjx_catn(d: *u8, o: i64, v: i64) -> i64 { 115 var m: i64 = v 116 var p: i64 = o 117 if m < 0 { d[p] = CJX_MINUS as u8; p = p + 1; m = 0 - m } 118 let t: *u8 = sys_mmap(32) 119 var k: i64 = 0 120 if m == 0 { t[0] = CJX_D0 as u8; k = 1 } 121 while m > 0 { t[k] = (CJX_D0 + (m % 10)) as u8; m = m / 10; k = k + 1 } 122 while k > 0 { d[p] = t[k-1]; p = p + 1; k = k - 1 } 123 d[p] = 0 as u8 124 return p 125} 126func cjx_streq(a: *u8, b: *u8) -> i64 { 127 var i: i64 = 0 128 while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } 129 if b[i] != (0 as u8) { return 0 } 130 return 1 131} 132 133// Read the integer that follows an ANCHORED field name. The child emits this token exactly once per line, 134// so the parse cannot drift onto a value that merely looks like the answer -- the failure mode that has bit 135// this estate three times when an unanchored or greedy pattern matched a report's own prose instead of its 136// data. Returns -1 when the field is absent, which is a DISTINCT outcome from a value of 0. 137func cjx_field(buf: *u8, n: i64, key: *u8) -> i64 { 138 var kn: i64 = 0 139 while key[kn] != (0 as u8) { kn = kn + 1 } 140 var i: i64 = 0 141 while i + kn <= n { 142 var k: i64 = 0 143 var hit: i64 = 1 144 while k < kn { 145 if buf[i+k] != key[k] { hit = 0; k = kn } 146 if hit == 1 { k = k + 1 } 147 } 148 if hit == 1 { 149 var q: i64 = i + kn 150 var v: i64 = 0 151 var got: i64 = 0 152 var go: i64 = 1 153 while go == 1 { 154 if q >= n { go = 0 } 155 if go == 1 { 156 let c: i64 = buf[q] as i64 157 if c >= CJX_D0 { if c <= CJX_D9 { v = v*10 + (c-CJX_D0); got = 1; q = q + 1 } } 158 if c < CJX_D0 { go = 0 } 159 if c > CJX_D9 { go = 0 } 160 } 161 } 162 if got == 1 { return v } 163 return 0-1 164 } 165 i = i + 1 166 } 167 return 0-1 168} 169 170// SIGNED anchored field: nx_percept's score is legitimately negative (similar to junk), and an unsigned 171// parse would read "score":-57 as ABSENT and the lens would silently become unobservable. Returns 172// `absent` (caller-chosen sentinel) when the field is missing. 173func cjx_sfield(buf: *u8, n: i64, key: *u8, absent: i64) -> i64 { 174 var kn: i64 = 0 175 while key[kn] != (0 as u8) { kn = kn + 1 } 176 var i: i64 = 0 177 while i + kn <= n { 178 var k: i64 = 0 179 var hit: i64 = 1 180 while k < kn { 181 if buf[i+k] != key[k] { hit = 0; k = kn } 182 if hit == 1 { k = k + 1 } 183 } 184 if hit == 1 { 185 var q: i64 = i + kn 186 var neg: i64 = 0 187 if q < n { if (buf[q] as i64) == CJX_MINUS { neg = 1; q = q + 1 } } 188 var v: i64 = 0 189 var got: i64 = 0 190 var go: i64 = 1 191 while go == 1 { 192 if q >= n { go = 0 } 193 if go == 1 { 194 let c: i64 = buf[q] as i64 195 if c >= CJX_D0 { if c <= CJX_D9 { v = v*10 + (c-CJX_D0); got = 1; q = q + 1 } } 196 if c < CJX_D0 { go = 0 } 197 if c > CJX_D9 { go = 0 } 198 } 199 } 200 if got == 1 { if neg == 1 { return 0 - v } return v } 201 return absent 202 } 203 i = i + 1 204 } 205 return absent 206} 207 208func cjp_nl(b: *u8, at: i64) -> i64 { if (b[at] as i64) == CJX_NL { return 1 } return 0 } 209 210// ---- conf: `key=value` lines, '#' comments. An ABSENT key is a distinct answer from a value of 0 (a 211// lens whose floor is absent is report-only; a floor of 0 is a floor). found[0] says which. 212func cjp_conf_int(cf: *u8, n: i64, key: *u8, def: i64, found: *i64) -> i64 { 213 found[0] = 0 214 let kn: i64 = cjx_slen(key) 215 var i: i64 = 0 216 while i < n { 217 // line start 218 var e: i64 = i 219 var go: i64 = 1 220 while go == 1 { if e >= n { go = 0 } else { if cjp_nl(cf, e) == 1 { go = 0 } else { e = e + 1 } } } 221 if (cf[i] as i64) != CJX_HASH { 222 if e - i > kn { 223 var k: i64 = 0 224 var hit: i64 = 1 225 while k < kn { if cf[i+k] != key[k] { hit = 0; k = kn } if hit == 1 { k = k + 1 } } 226 if hit == 1 { if (cf[i+kn] as i64) == 61 { 227 var q: i64 = i + kn + 1 228 var neg: i64 = 0 229 if q < e { if (cf[q] as i64) == CJX_MINUS { neg = 1; q = q + 1 } } 230 var v: i64 = 0 231 var got: i64 = 0 232 var go2: i64 = 1 233 while go2 == 1 { 234 if q >= e { go2 = 0 } else { 235 let c: i64 = cf[q] as i64 236 if c >= CJX_D0 { if c <= CJX_D9 { v = v*10 + (c-CJX_D0); got = 1; q = q + 1 } else { go2 = 0 } } else { go2 = 0 } 237 } 238 } 239 if got == 1 { found[0] = 1; if neg == 1 { return 0 - v } return v } 240 } } 241 } 242 } 243 i = e + 1 244 } 245 return def 246} 247 248// string-valued conf key (elf paths, receipt path); returns def when absent. Value is copied to a fresh buf. 249func cjp_conf_str(cf: *u8, n: i64, key: *u8, def: *u8) -> *u8 { 250 let kn: i64 = cjx_slen(key) 251 var i: i64 = 0 252 while i < n { 253 var e: i64 = i 254 var go: i64 = 1 255 while go == 1 { if e >= n { go = 0 } else { if cjp_nl(cf, e) == 1 { go = 0 } else { e = e + 1 } } } 256 if (cf[i] as i64) != CJX_HASH { 257 if e - i > kn { 258 var k: i64 = 0 259 var hit: i64 = 1 260 while k < kn { if cf[i+k] != key[k] { hit = 0; k = kn } if hit == 1 { k = k + 1 } } 261 if hit == 1 { if (cf[i+kn] as i64) == 61 { 262 var q: i64 = i + kn + 1 263 var ln: i64 = e - q 264 if ln > 0 { if (cf[e-1] as i64) == CJX_CR { ln = ln - 1 } } 265 if ln > 0 { 266 let d: *u8 = sys_mmap(ln + 1) 267 var c: i64 = 0 268 while c < ln { d[c] = cf[q+c]; c = c + 1 } 269 d[ln] = 0 as u8 270 return d 271 } 272 } } 273 } 274 } 275 i = e + 1 276 } 277 return def 278} 279 280// FNV-1a over a string: a stable, collision-poor name for a per-image scratch file (no getpid in the 281// syscall surface; two concurrent panels over the SAME image path would share a scratch name -- declared). 282func cjp_fnv(s: *u8) -> i64 { 283 var h: i64 = CJP_FNV_BASIS 284 var i: i64 = 0 285 while s[i] != (0 as u8) { 286 h = h ^ (s[i] as i64) 287 h = (h * CJP_FNV_PRIME) & CJP_FNV_MASK 288 i = i + 1 289 } 290 return h 291} 292func cjp_hex8(d: *u8, o: i64, v: i64) -> i64 { 293 var k: i64 = 7 294 var p: i64 = o 295 while k >= 0 { 296 let nib: i64 = (v >> (k*4)) & 15 297 if nib < 10 { d[p] = (CJX_D0 + nib) as u8 } else { d[p] = (87 + nib) as u8 } 298 p = p + 1 299 k = k - 1 300 } 301 d[p] = 0 as u8 302 return p 303} 304 305// ONE corner-background estimator for the lens child and figcrop (the duplicate-ruler law: two copies of 306// "what is the background" would drift apart). Mean of the four pixels `inset` px inside each corner 307// (clamped so a tiny image still samples inside itself); out3 = r,g,b. 308func cjp_corner_bg(rgb: *u8, w: i64, h: i64, inset: i64, out3: *i64) -> i64 { 309 var ins: i64 = inset 310 if ins < 0 { ins = 0 } 311 if ins * 2 >= w { ins = (w - 1) / 2 } 312 if ins * 2 >= h { ins = (h - 1) / 2 } 313 var sr: i64 = 0 314 var sg: i64 = 0 315 var sb: i64 = 0 316 var ci: i64 = 0 317 while ci < 4 { 318 var cx: i64 = ins 319 var cy: i64 = ins 320 if ci == 1 { cx = w - 1 - ins } 321 if ci == 2 { cy = h - 1 - ins } 322 if ci == 3 { cx = w - 1 - ins; cy = h - 1 - ins } 323 let o: i64 = (cy*w + cx) * 3 324 sr = sr + (rgb[o] as i64) 325 sg = sg + (rgb[o+1] as i64) 326 sb = sb + (rgb[o+2] as i64) 327 ci = ci + 1 328 } 329 out3[0] = sr / 4 330 out3[1] = sg / 4 331 out3[2] = sb / 4 332 return 0 333} 334 335// ---- THE PER-IMAGE CHILD: decode once, every lens, one anchored line -------------------------------- 336// Prints: CJP-LENS path=<p> src_w= src_h= fit_w= fit_h= cjp_stats= cjp_comp= cjp_pal= cjp_cont= cjp_face= 337// cjp_skin_all= cjp_skin_center= cjp_skin_fig= cjp_fig_permil= cjp_sym= cjp_percept= cjp_vlm= 338// Every cjp_* key appears exactly once. -1 on a permil lens and CJP_UNOBS on percept mean UNOBSERVABLE. 339func cjp_lens(path: *u8, confp: *u8) -> i64 { 340 let cfl: *i64 = sys_mmap(16) as *i64 341 cfl[0] = 0 342 var cf: *u8 = sys_read_file(confp, cfl) 343 var cfn: i64 = 0 344 if (cf as i64) != 0 { cfn = cfl[0] } else { cf = sys_mmap(16); cf[0] = 0 as u8 } 345 let fnd: *i64 = sys_mmap(16) as *i64 346 let pw: i64 = cjp_conf_int(cf, cfn, "percept_w" as *u8, CJP_DEF_PERCEPT_W, fnd) 347 let ph: i64 = cjp_conf_int(cf, cfn, "percept_h" as *u8, CJP_DEF_PERCEPT_H, fnd) 348 let center_permil: i64 = cjp_conf_int(cf, cfn, "center_permil" as *u8, CJP_DEF_CENTER_PERMIL, fnd) 349 let bg_tol: i64 = cjp_conf_int(cf, cfn, "bg_tol" as *u8, CJP_DEF_BG_TOL, fnd) 350 let elf_cj: *u8 = cjp_conf_str(cf, cfn, "elf_charjudge" as *u8, "./nx_charjudge.elf" as *u8) 351 let elf_ib: *u8 = cjp_conf_str(cf, cfn, "elf_beauty" as *u8, "./nx_image_beauty.elf" as *u8) 352 let elf_pj: *u8 = cjp_conf_str(cf, cfn, "elf_percept" as *u8, "./nx_percept.elf" as *u8) 353 let tmpdir: *u8 = cjp_conf_str(cf, cfn, "tmp_dir" as *u8, "/tmp" as *u8) 354 355 // 1. decode ONCE through the estate's single decode chokepoint 356 let wh: *i64 = sys_mmap(32) as *i64 357 wh[0] = 0 358 wh[1] = 0 359 let rgb: *u8 = nx_img_to_rgb(path, wh) 360 cjx_p("CJP-LENS path=" as *u8); cjx_p(path) 361 if (rgb as i64) == 0 { 362 cjx_p(" decoded=0 src_w=0 src_h=0 fit_w=0 fit_h=0 cjp_stats=-1 cjp_comp=-1 cjp_pal=-1 cjp_cont=-1 cjp_face=-1 cjp_skin_all=-1 cjp_skin_center=-1 cjp_skin_fig=-1 cjp_kc_all=-1 cjp_kc_center=-1 cjp_kc_fig=-1 cjp_cn_all=-1 cjp_cn_center=-1 cjp_cn_fig=-1 cjp_fig_permil=-1 cjp_sym=-1 cjp_percept=-9999 cjp_vlm=-1 note=undecodable\n" as *u8) 363 return 2 364 } 365 let w: i64 = wh[0] 366 let h: i64 = wh[1] 367 if w <= 0 { cjx_p(" decoded=0 src_w=0 src_h=0 note=zero-width\n" as *u8); return 2 } 368 if h <= 0 { cjx_p(" decoded=0 src_w=0 src_h=0 note=zero-height\n" as *u8); return 2 } 369 370 // 2. fit-resample into the percept frame (box filter, aspect kept, centred, padded with the image's own 371 // corner-mean colour so no artificial black bar reads as a flat-junk region). The in-process lenses 372 // run on the fitted region only -- bounded cost whatever the source size, proportions preserved. 373 var fw: i64 = pw 374 var fh: i64 = ph 375 if w * ph >= h * pw { fh = h * pw / w; if fh < 1 { fh = 1 } } else { fw = w * ph / h; if fw < 1 { fw = 1 } } 376 let ox: i64 = (pw - fw) / 2 377 let oy: i64 = (ph - fh) / 2 378 // corner-mean background (inset past any 1-px canvas border a capture may carry) 379 let bg_inset: i64 = cjp_conf_int(cf, cfn, "bg_inset_px" as *u8, CJP_DEF_BG_INSET_PX, fnd) 380 let bg3: *i64 = sys_mmap(32) as *i64 381 cjp_corner_bg(rgb, w, h, bg_inset, bg3) 382 let bgr: i64 = bg3[0] 383 let bgg: i64 = bg3[1] 384 let bgb: i64 = bg3[2] 385 let fb: *i64 = sys_mmap(pw*ph*8) as *i64 386 var pi: i64 = 0 387 while pi < pw*ph { fb[pi] = bgr + bgg*CJP_BYTE + bgb*CJP_BYTE*CJP_BYTE; pi = pi + 1 } 388 // skin + figure tallies over the fitted region. 389 // THREE SKIN RULERS ARE TALLIED SIDE BY SIDE, ALWAYS, whichever one votes (conf: skin_rule): 390 // n_skin_* = Kovac daylight rule (the incumbent, luminance-gated) -- kept so the incumbent stays runnable 391 // n_kc_* = the same published Cb/Cr window with the luminance gate dropped (grading-invariant) 392 // n_cn_* = Chai & Ngan 1999 skin-colour map, chroma-only as published (grading-invariant) 393 // Reporting all three on every line is what lets the ruler be CHOSEN on measured separability 394 // rather than on taste, and lets a later reader re-adjudicate that choice without a rebuild. 395 // The scratch struct is hoisted HERE, above the loop: nx_color_skin_flags_at allocates nothing. 396 let ycc: *YCbCrColor = (sys_mmap(24)) as *YCbCrColor 397 var n_all: i64 = 0 398 var n_skin_all: i64 = 0 399 var n_center: i64 = 0 400 var n_skin_center: i64 = 0 401 var n_fig: i64 = 0 402 var n_skin_fig: i64 = 0 403 var n_kc_all: i64 = 0 404 var n_kc_center: i64 = 0 405 var n_kc_fig: i64 = 0 406 var n_cn_all: i64 = 0 407 var n_cn_center: i64 = 0 408 var n_cn_fig: i64 = 0 409 let cx0: i64 = fw * (1000 - center_permil) / 2000 410 let cx1: i64 = fw - cx0 411 let cy0: i64 = fh * (1000 - center_permil) / 2000 412 let cy1: i64 = fh - cy0 413 var ty: i64 = 0 414 while ty < fh { 415 let sy0: i64 = ty * h / fh 416 var sy1: i64 = (ty + 1) * h / fh 417 if sy1 <= sy0 { sy1 = sy0 + 1 } 418 var tx: i64 = 0 419 while tx < fw { 420 let sx0: i64 = tx * w / fw 421 var sx1: i64 = (tx + 1) * w / fw 422 if sx1 <= sx0 { sx1 = sx0 + 1 } 423 var sr: i64 = 0 424 var sg: i64 = 0 425 var sb: i64 = 0 426 var cnt: i64 = 0 427 var yy: i64 = sy0 428 while yy < sy1 { 429 var xx: i64 = sx0 430 while xx < sx1 { 431 let o2: i64 = (yy*w + xx) * 3 432 sr = sr + (rgb[o2] as i64) 433 sg = sg + (rgb[o2+1] as i64) 434 sb = sb + (rgb[o2+2] as i64) 435 cnt = cnt + 1 436 xx = xx + 1 437 } 438 yy = yy + 1 439 } 440 let r: i64 = sr / cnt 441 let g: i64 = sg / cnt 442 let b: i64 = sb / cnt 443 fb[(oy+ty)*pw + ox + tx] = r + g*CJP_BYTE + b*CJP_BYTE*CJP_BYTE 444 // ONE conversion, three predicates. Flag sum: 1 = Kovac daylight, 2 = chroma-only, 4 = locus. 445 // Decoded by / and % rather than a mask so no bitwise operator is required. 446 let skf: i64 = nx_color_skin_flags_at(r, g, b, ycc) 447 let sk: i64 = skf % 2 448 let skc: i64 = (skf / 2) % 2 449 let skl: i64 = (skf / 4) % 2 450 n_all = n_all + 1 451 n_skin_all = n_skin_all + sk 452 n_kc_all = n_kc_all + skc 453 n_cn_all = n_cn_all + skl 454 var incenter: i64 = 0 455 if tx >= cx0 { if tx < cx1 { if ty >= cy0 { if ty < cy1 { incenter = 1 } } } } 456 if incenter == 1 { n_center = n_center + 1; n_skin_center = n_skin_center + sk; n_kc_center = n_kc_center + skc; n_cn_center = n_cn_center + skl } 457 var dmax: i64 = r - bgr 458 if dmax < 0 { dmax = 0 - dmax } 459 var dg: i64 = g - bgg 460 if dg < 0 { dg = 0 - dg } 461 var db: i64 = b - bgb 462 if db < 0 { db = 0 - db } 463 if dg > dmax { dmax = dg } 464 if db > dmax { dmax = db } 465 if dmax > bg_tol { n_fig = n_fig + 1; n_skin_fig = n_skin_fig + sk; n_kc_fig = n_kc_fig + skc; n_cn_fig = n_cn_fig + skl } 466 tx = tx + 1 467 } 468 ty = ty + 1 469 } 470 var skin_all: i64 = 0 471 if n_all > 0 { skin_all = n_skin_all * CJX_PERMIL_MAX / n_all } 472 var skin_center: i64 = 0 - 1 473 if n_center > 0 { skin_center = n_skin_center * CJX_PERMIL_MAX / n_center } 474 var skin_fig: i64 = 0 - 1 475 if n_fig > 0 { skin_fig = n_skin_fig * CJX_PERMIL_MAX / n_fig } 476 // the two grading-invariant rulers, same three regions, same denominators 477 var kc_all: i64 = 0 478 if n_all > 0 { kc_all = n_kc_all * CJX_PERMIL_MAX / n_all } 479 var kc_center: i64 = 0 - 1 480 if n_center > 0 { kc_center = n_kc_center * CJX_PERMIL_MAX / n_center } 481 var kc_fig: i64 = 0 - 1 482 if n_fig > 0 { kc_fig = n_kc_fig * CJX_PERMIL_MAX / n_fig } 483 var cn_all: i64 = 0 484 if n_all > 0 { cn_all = n_cn_all * CJX_PERMIL_MAX / n_all } 485 var cn_center: i64 = 0 - 1 486 if n_center > 0 { cn_center = n_cn_center * CJX_PERMIL_MAX / n_center } 487 var cn_fig: i64 = 0 - 1 488 if n_fig > 0 { cn_fig = n_cn_fig * CJX_PERMIL_MAX / n_fig } 489 var fig_permil: i64 = 0 490 if n_all > 0 { fig_permil = n_fig * CJX_PERMIL_MAX / n_all } 491 492 // 3. the forked lenses 493 let out: *u8 = sys_mmap(CJX_OUTCAP) 494 let olen: *i64 = sys_mmap(16) as *i64 495 let trunc: *i64 = sys_mmap(16) as *i64 496 let av: *i64 = sys_mmap(CJP_CHILD_ARGV*8) as *i64 497 // stats: ./nx_charjudge.elf <path> <label> 498 av[0] = elf_cj as i64 499 av[1] = path as i64 500 av[2] = "panel" as *u8 as i64 501 av[3] = 0 502 olen[0] = 0 503 tr_run_capture_tr(elf_cj, av, out, CJX_OUTCAP, olen, CJX_TIMEOUT_MS, trunc) 504 var stats: i64 = 0 - 1 505 var comp: i64 = 0 - 1 506 var pal: i64 = 0 - 1 507 var cont: i64 = 0 - 1 508 var face: i64 = 0 - 1 509 if olen[0] > 0 { 510 stats = cjx_field(out, olen[0], "\x22CHARJUDGE\x22:" as *u8) 511 comp = cjx_field(out, olen[0], "\x22composition\x22:" as *u8) 512 pal = cjx_field(out, olen[0], "\x22palette_axis\x22:" as *u8) 513 cont = cjx_field(out, olen[0], "\x22contour_axis\x22:" as *u8) 514 face = cjx_field(out, olen[0], "\x22face_axis\x22:" as *u8) 515 } 516 // sym: ./nx_image_beauty.elf path <png> 517 av[0] = elf_ib as i64 518 av[1] = "path" as *u8 as i64 519 av[2] = path as i64 520 av[3] = 0 521 olen[0] = 0 522 tr_run_capture_tr(elf_ib, av, out, CJX_OUTCAP, olen, CJX_TIMEOUT_MS, trunc) 523 var sym: i64 = 0 - 1 524 if olen[0] > 0 { sym = cjx_field(out, olen[0], "\x22symmetry_q1000\x22:" as *u8) } 525 // percept: write the fitted frame as NXFH1 (the shared codec), fork ./nx_percept.elf judge <nxfh>, unlink 526 let tmp: *u8 = sys_mmap(CJX_PATHCAP) 527 var to: i64 = cjx_cat(tmp, 0, tmpdir) 528 to = cjx_cat(tmp, to, "/cjp_lens_" as *u8) 529 to = cjp_hex8(tmp, to, cjp_fnv(path)) 530 to = cjx_cat(tmp, to, ".nxfh" as *u8) 531 var percept: i64 = CJP_UNOBS 532 let wrote: i64 = nxl_dump(tmp, fb, pw, ph) 533 if wrote > 0 { 534 av[0] = elf_pj as i64 535 av[1] = "judge" as *u8 as i64 536 av[2] = tmp as i64 537 av[3] = 0 538 olen[0] = 0 539 tr_run_capture_tr(elf_pj, av, out, CJX_OUTCAP, olen, CJX_TIMEOUT_MS, trunc) 540 if olen[0] > 0 { percept = cjx_sfield(out, olen[0], "\x22score\x22:" as *u8, CJP_UNOBS) } 541 sys_unlinkat(tmp) 542 } 543 // vlm: no sovereign VLM oracle exists on the estate (measured 2026-08-19). The slot abstains. 544 let vlm: i64 = 0 - 1 545 546 cjx_p(" decoded=1 src_w=" as *u8); cjx_n(w) 547 cjx_p(" src_h=" as *u8); cjx_n(h) 548 cjx_p(" fit_w=" as *u8); cjx_n(fw) 549 cjx_p(" fit_h=" as *u8); cjx_n(fh) 550 cjx_p(" cjp_stats=" as *u8); cjx_n(stats) 551 cjx_p(" cjp_comp=" as *u8); cjx_n(comp) 552 cjx_p(" cjp_pal=" as *u8); cjx_n(pal) 553 cjx_p(" cjp_cont=" as *u8); cjx_n(cont) 554 cjx_p(" cjp_face=" as *u8); cjx_n(face) 555 cjx_p(" cjp_skin_all=" as *u8); cjx_n(skin_all) 556 cjx_p(" cjp_skin_center=" as *u8); cjx_n(skin_center) 557 cjx_p(" cjp_skin_fig=" as *u8); cjx_n(skin_fig) 558 cjx_p(" cjp_kc_all=" as *u8); cjx_n(kc_all) 559 cjx_p(" cjp_kc_center=" as *u8); cjx_n(kc_center) 560 cjx_p(" cjp_kc_fig=" as *u8); cjx_n(kc_fig) 561 cjx_p(" cjp_cn_all=" as *u8); cjx_n(cn_all) 562 cjx_p(" cjp_cn_center=" as *u8); cjx_n(cn_center) 563 cjx_p(" cjp_cn_fig=" as *u8); cjx_n(cn_fig) 564 cjx_p(" cjp_fig_permil=" as *u8); cjx_n(fig_permil) 565 cjx_p(" cjp_sym=" as *u8); cjx_n(sym) 566 cjx_p(" cjp_percept=" as *u8); cjx_n(percept) 567 cjx_p(" cjp_vlm=" as *u8); cjx_n(vlm) 568 cjx_p(" vlm=UNOBSERVABLE\n" as *u8) 569 return 0 570} 571 572// ---- receipt: the admission contract, bound to the floors it was measured at ---------------------- 573// Format (one key per line): admitted= fp= fn= good= bad= epoch= floors=<stats>,<skin>,<sym>,<percept> 574// A floor that was REPORT-ONLY at calibration is written as the word `none`, so a later conf edit that 575// ADDS a floor also un-admits (the set of voting lenses changed, so the FP/FN measured no longer apply). 576// ---- AT8 (aesthetictwin): THE FIDELITY TIER OF THE SUBJECT. -------------------------------------- 577// A floor is never a number on its own -- it is a number ABOUT a measurement, which is why this file 578// already binds the skin REGION and the skin RULER into the receipt. The fidelity TIER of the rendered 579// subject is the third such dimension, and it is the one the published record shows actually FLIPS the 580// answer rather than merely shifting it: the optimally attractive leg-to-body ratio sits fractionally 581// BELOW baseline on silhouettes and about half a standard deviation ABOVE it on detailed computer- 582// generated figures, with rater sensitivity lowest on silhouettes (Versluys and Skylark 2017, mirrored 583// and pinned as aesthetictwin.refs key versluys2017). A floor calibrated on one tier and applied to 584// another is therefore not a stricter or a looser bar -- it is a bar about a different question, and 585// this estate renders at clay while its far-bar references are photoreal. 586// ROW GRAMMAR, ADDITIVE: path<TAB>LABEL<TAB>TIER. A row with no third field takes the conf's 587// tier_default, so every list written before this rung means exactly what it meant before it. 588const CJP_TIERS: i64 = 4 589const CJP_T_SIL: i64 = 0 590const CJP_T_CLAY: i64 = 1 591const CJP_T_TEX: i64 = 2 592const CJP_T_PHOTO: i64 = 3 593func cjp_tier_of(s: *u8) -> i64 { 594 if cjx_streq(s, "silhouette" as *u8) == 1 { return CJP_T_SIL } 595 if cjx_streq(s, "clay" as *u8) == 1 { return CJP_T_CLAY } 596 if cjx_streq(s, "textured" as *u8) == 1 { return CJP_T_TEX } 597 if cjx_streq(s, "photoreal" as *u8) == 1 { return CJP_T_PHOTO } 598 return 0 - 1 599} 600func cjp_tier_name(t: i64) -> *u8 { 601 if t == CJP_T_SIL { return "silhouette" as *u8 } 602 if t == CJP_T_CLAY { return "clay" as *u8 } 603 if t == CJP_T_TEX { return "textured" as *u8 } 604 if t == CJP_T_PHOTO { return "photoreal" as *u8 } 605 return "?" as *u8 606} 607func cjp_lens_name(li: i64) -> *u8 { 608 if li == CJP_L_STATS { return "stats" as *u8 } 609 if li == CJP_L_SKIN { return "skin" as *u8 } 610 if li == CJP_L_SYM { return "sym" as *u8 } 611 if li == CJP_L_PERCEPT { return "percept" as *u8 } 612 return "vlm" as *u8 613} 614// floor_<lens>_<tier>, built from the SAME name tables the reader prints, so the key parsed and the key 615// documented cannot drift apart. 616func cjp_tier_key(d: *u8, li: i64, t: i64) -> i64 { 617 var p: i64 = cjx_cat(d, 0, "floor_" as *u8) 618 p = cjx_cat(d, p, cjp_lens_name(li)) 619 p = cjx_cat(d, p, "_" as *u8) 620 p = cjx_cat(d, p, cjp_tier_name(t)) 621 return p 622} 623// The tier SET as a stable canonical string -- what the receipt binds, so a corpus whose tier set moves 624// un-admits by construction exactly as a moved floor does. 625func cjp_tierset_str(d: *u8, o: i64, seen: *i64) -> i64 { 626 var p: i64 = o 627 var first: i64 = 1 628 var t: i64 = 0 629 while t < CJP_TIERS { 630 if seen[t] == 1 { 631 if first == 0 { p = cjx_cat(d, p, "," as *u8) } 632 p = cjx_cat(d, p, cjp_tier_name(t)) 633 first = 0 634 } 635 t = t + 1 636 } 637 if first == 1 { p = cjx_cat(d, p, "none" as *u8) } 638 return p 639} 640// WHOLE-TOKEN membership in a comma-separated set. Never a substring test: `clay` must not match 641// `clayish`, and a set test that matches a prefix is how an unadmitted tier would slip through. 642func cjp_tierset_has(s: *u8, name: *u8) -> i64 { 643 var nl: i64 = 0 644 while name[nl] != (0 as u8) { nl = nl + 1 } 645 if nl == 0 { return 0 } 646 var i: i64 = 0 647 var go: i64 = 1 648 while go == 1 { 649 var k: i64 = 0 650 var eq: i64 = 1 651 while k < nl { if s[i+k] != name[k] { eq = 0; k = nl } else { k = k + 1 } } 652 if eq == 1 { 653 let after: i64 = s[i+nl] as i64 654 if after == 0 { return 1 } 655 if after == 44 { return 1 } 656 } 657 var scan: i64 = 1 658 while scan == 1 { 659 if s[i] == (0 as u8) { scan = 0; go = 0 } else { 660 if (s[i] as i64) == 44 { i = i + 1; scan = 0 } else { i = i + 1 } 661 } 662 } 663 } 664 return 0 665} 666func cjp_floor_str(d: *u8, o: i64, has: i64, v: i64) -> i64 { 667 if has == 0 { return cjx_cat(d, o, "none" as *u8) } 668 return cjx_catn(d, o, v) 669} 670func cjp_floors_line(d: *u8, o: i64, has: *i64, fl: *i64) -> i64 { 671 var p: i64 = cjx_cat(d, o, "floors=" as *u8) 672 p = cjp_floor_str(d, p, has[CJP_L_STATS], fl[CJP_L_STATS]); p = cjx_cat(d, p, "," as *u8) 673 p = cjp_floor_str(d, p, has[CJP_L_SKIN], fl[CJP_L_SKIN]); p = cjx_cat(d, p, "," as *u8) 674 p = cjp_floor_str(d, p, has[CJP_L_SYM], fl[CJP_L_SYM]); p = cjx_cat(d, p, "," as *u8) 675 p = cjp_floor_str(d, p, has[CJP_L_PERCEPT], fl[CJP_L_PERCEPT]) 676 return p 677} 678// Does the receipt say admitted=1 AND describe THE SAME MEASUREMENT we are about to make? 679// 680// A floor is not a number on its own -- it is a number ABOUT a specific measurement. The same 681// floor_skin means three different things under three different skin rulers, and three more under 682// three different regions. Binding only the floors therefore left two silent escapes: swapping 683// skin_lens or skin_rule kept admitted=1 while measuring something the calibration never saw. 684// All three are bound here, so any of them moving un-admits by construction. 685// on_list[0] receives the receipt's `list` so the caller can PUBLISH which corpus admitted it -- 686// an admission is only evidence about the corpus it was measured on. 687// tadm[0] receives the receipt's `tiers_admitted` set (empty string when the receipt predates tiers). 688// A LEGACY RECEIPT IS NOT A PERMISSIVE ONE: an empty set means the caller must decide, and the caller 689// only lets it stand for a single-tier corpus -- because a receipt written before tiers existed can 690// only have been measured on whatever single question its corpus asked. 691func cjp_receipt_admits(rpath: *u8, floors: *u8, slens: *u8, srule: *u8, on_list: *i64, tadm: *i64) -> i64 { 692 let rl: *i64 = sys_mmap(16) as *i64 693 rl[0] = 0 694 let rb: *u8 = sys_read_file(rpath, rl) 695 if (rb as i64) == 0 { return 0 } 696 let n: i64 = rl[0] 697 let fnd: *i64 = sys_mmap(16) as *i64 698 let adm: i64 = cjp_conf_int(rb, n, "admitted" as *u8, 0, fnd) 699 if adm != 1 { return 0 } 700 let rf: *u8 = cjp_conf_str(rb, n, "floors" as *u8, "" as *u8) 701 // compare against the value part of our floors line ("floors=" stripped) 702 let ours: *u8 = ((floors as i64) + 7) as *u8 703 if cjx_streq(rf, ours) == 0 { return 0 } 704 let rlens: *u8 = cjp_conf_str(rb, n, "skin_lens" as *u8, "" as *u8) 705 if cjx_streq(rlens, slens) == 0 { return 0 } 706 // A receipt written before skin_rule existed carries no such key and was, in fact, measured with 707 // the incumbent Kovac ruler -- so `kovac` is the honest default here, not a permissive one. 708 let rrule: *u8 = cjp_conf_str(rb, n, "skin_rule" as *u8, "kovac" as *u8) 709 if cjx_streq(rrule, srule) == 0 { return 0 } 710 on_list[0] = cjp_conf_str(rb, n, "list" as *u8, "?" as *u8) as i64 711 tadm[0] = cjp_conf_str(rb, n, "tiers_admitted" as *u8, "" as *u8) as i64 712 return 1 713} 714 715// ---- THE PANEL DRIVER (the watch symbol). mode 0 = panel, 1 = calibrate. --------------------------- 716// Returns: panel -> 0 clean / 1 leak-or-unjudged; calibrate -> 0 ADMITTED / 1 REFUSED / 2 unreadable. 717func cjc_panel(selfp: *u8, listp: *u8, confp: *u8, mode: i64) -> i64 { 718 let lenp: *i64 = sys_mmap(16) as *i64 719 lenp[0] = 0 720 let lbuf: *u8 = sys_read_file(listp, lenp) 721 if (lbuf as i64) == 0 { 722 cjx_p("PANEL-REFUSED list-unreadable path=" as *u8); cjx_p(listp); cjx_p("\n" as *u8) 723 return 2 724 } 725 let n: i64 = lenp[0] 726 let cfl: *i64 = sys_mmap(16) as *i64 727 cfl[0] = 0 728 var cf: *u8 = sys_read_file(confp, cfl) 729 var cfn: i64 = 0 730 if (cf as i64) != 0 { cfn = cfl[0] } else { cf = sys_mmap(16); cf[0] = 0 as u8 } 731 // floors (DATA). absent key => report-only lens. 732 let has: *i64 = sys_mmap(CJP_LENSES*8) as *i64 733 let fl: *i64 = sys_mmap(CJP_LENSES*8) as *i64 734 let fnd: *i64 = sys_mmap(16) as *i64 735 fl[CJP_L_STATS] = cjp_conf_int(cf, cfn, "floor_stats" as *u8, 0, fnd); has[CJP_L_STATS] = fnd[0] 736 fl[CJP_L_SKIN] = cjp_conf_int(cf, cfn, "floor_skin" as *u8, 0, fnd); has[CJP_L_SKIN] = fnd[0] 737 fl[CJP_L_SYM] = cjp_conf_int(cf, cfn, "floor_sym" as *u8, 0, fnd); has[CJP_L_SYM] = fnd[0] 738 fl[CJP_L_PERCEPT] = cjp_conf_int(cf, cfn, "floor_percept" as *u8, 0, fnd); has[CJP_L_PERCEPT] = fnd[0] 739 fl[CJP_L_VLM] = 0; has[CJP_L_VLM] = 0 740 let skin_lens: *u8 = cjp_conf_str(cf, cfn, "skin_lens" as *u8, "center" as *u8) 741 let skin_rule: *u8 = cjp_conf_str(cf, cfn, "skin_rule" as *u8, "kovac" as *u8) 742 let rpath: *u8 = cjp_conf_str(cf, cfn, "receipt" as *u8, "knowledge/status/cjc_panel_admission.txt" as *u8) 743 // AN UNRECOGNISED SELECTOR REFUSES; IT NEVER SILENTLY BECOMES THE INCUMBENT. A mistyped rule that 744 // fell through to the default would measure one thing while the conf, the receipt and every reader 745 // said another -- the silent class, in the one file that decides what the referee is measuring. 746 var rule_ok: i64 = 0 747 if cjx_streq(skin_rule, "kovac" as *u8) == 1 { rule_ok = 1 } 748 if cjx_streq(skin_rule, "chroma" as *u8) == 1 { rule_ok = 1 } 749 if cjx_streq(skin_rule, "locus" as *u8) == 1 { rule_ok = 1 } 750 if rule_ok == 0 { 751 cjx_p("PANEL-REFUSED unknown skin_rule=" as *u8); cjx_p(skin_rule) 752 cjx_p(" -- expected kovac|chroma|locus (nothing measured)\n" as *u8) 753 return 2 754 } 755 var lens_ok: i64 = 0 756 if cjx_streq(skin_lens, "center" as *u8) == 1 { lens_ok = 1 } 757 if cjx_streq(skin_lens, "all" as *u8) == 1 { lens_ok = 1 } 758 if cjx_streq(skin_lens, "fig" as *u8) == 1 { lens_ok = 1 } 759 if lens_ok == 0 { 760 cjx_p("PANEL-REFUSED unknown skin_lens=" as *u8); cjx_p(skin_lens) 761 cjx_p(" -- expected center|all|fig (nothing measured)\n" as *u8) 762 return 2 763 } 764 // ---- AT8: the tier default, and floors that are ABOUT a tier. ------------------------------- 765 let tier_def_s: *u8 = cjp_conf_str(cf, cfn, "tier_default" as *u8, "clay" as *u8) 766 let tier_def: i64 = cjp_tier_of(tier_def_s) 767 if tier_def < 0 { 768 cjx_p("PANEL-REFUSED unknown tier_default=" as *u8); cjx_p(tier_def_s) 769 cjx_p(" -- expected silhouette|clay|textured|photoreal (nothing measured)\n" as *u8) 770 return 2 771 } 772 // tfl/thas/texp are indexed lens*CJP_TIERS+tier. texp records whether the floor is EXPLICITLY 773 // per-tier: the fall-back to the global floor is what keeps this rung additive on a single-tier 774 // corpus, and is exactly what must never be leaned on once a corpus spans tiers. 775 let tfl: *i64 = sys_mmap(CJP_LENSES*CJP_TIERS*8) as *i64 776 let thas: *i64 = sys_mmap(CJP_LENSES*CJP_TIERS*8) as *i64 777 let texp: *i64 = sys_mmap(CJP_LENSES*CJP_TIERS*8) as *i64 778 let tkey: *u8 = sys_mmap(96) 779 var tli: i64 = 0 780 while tli < CJP_LENSES { 781 var tti: i64 = 0 782 while tti < CJP_TIERS { 783 cjp_tier_key(tkey, tli, tti) 784 let tv: i64 = cjp_conf_int(cf, cfn, tkey, 0, fnd) 785 let tix: i64 = tli*CJP_TIERS + tti 786 if fnd[0] == 1 { tfl[tix] = tv; thas[tix] = 1; texp[tix] = 1 } else { tfl[tix] = fl[tli]; thas[tix] = has[tli]; texp[tix] = 0 } 787 tti = tti + 1 788 } 789 tli = tli + 1 790 } 791 // The lens-line keys, built ONCE from the same strings the receipt binds -- so the key parsed and 792 // the rule declared cannot drift apart. ALL THREE rulers get a key for the CURRENT region, because 793 // every run reports all three; skin_key is simply whichever one the conf selected to vote. 794 var ksuf: *u8 = "_center=" as *u8 795 if cjx_streq(skin_lens, "all" as *u8) == 1 { ksuf = "_all=" as *u8 } 796 if cjx_streq(skin_lens, "fig" as *u8) == 1 { ksuf = "_fig=" as *u8 } 797 let skkey: *i64 = sys_mmap(CJP_SKRULES*8) as *i64 798 let kb0: *u8 = sys_mmap(64) 799 let kb1: *u8 = sys_mmap(64) 800 let kb2: *u8 = sys_mmap(64) 801 cjx_cat(kb0, cjx_cat(kb0, 0, " cjp_skin" as *u8), ksuf) 802 cjx_cat(kb1, cjx_cat(kb1, 0, " cjp_kc" as *u8), ksuf) 803 cjx_cat(kb2, cjx_cat(kb2, 0, " cjp_cn" as *u8), ksuf) 804 skkey[CJP_SK_KOVAC] = kb0 as i64 805 skkey[CJP_SK_CHROMA] = kb1 as i64 806 skkey[CJP_SK_LOCUS] = kb2 as i64 807 var skin_key: *u8 = kb0 808 if cjx_streq(skin_rule, "chroma" as *u8) == 1 { skin_key = kb1 } 809 if cjx_streq(skin_rule, "locus" as *u8) == 1 { skin_key = kb2 } 810 let floors: *u8 = sys_mmap(256) 811 cjp_floors_line(floors, 0, has, fl) 812 var voting: i64 = 0 813 var li: i64 = 0 814 while li < CJP_LENSES { voting = voting + has[li]; li = li + 1 } 815 // ---- AT8 PRE-SCAN: read every row's TIER before anything is measured. A refusal about what the 816 // measurement would have MEANT has to be reachable without having judged a single image, which is 817 // why this is a separate pass over the list text and forks nothing. 818 let tseen: *i64 = sys_mmap(CJP_TIERS*8) as *i64 819 var tz: i64 = 0 820 while tz < CJP_TIERS { tseen[tz] = 0; tz = tz + 1 } 821 let tsc: *u8 = sys_mmap(CJX_PATHCAP) 822 var si: i64 = 0 823 while si < n { 824 var se: i64 = si 825 var sgo: i64 = 1 826 while sgo == 1 { 827 if se >= n { sgo = 0 } 828 if sgo == 1 { if lbuf[se] == (CJX_NL as u8) { sgo = 0 } } 829 if sgo == 1 { se = se + 1 } 830 } 831 var sln: i64 = se - si 832 if sln > 0 { if lbuf[si] != (CJX_HASH as u8) { 833 if sln > CJX_PATHCAP-1 { sln = CJX_PATHCAP-1 } 834 var sk: i64 = 0 835 while sk < sln { tsc[sk] = lbuf[si+sk]; sk = sk + 1 } 836 if sln > 0 { if tsc[sln-1] == (CJX_CR as u8) { sln = sln - 1 } } 837 tsc[sln] = 0 as u8 838 var stabs: i64 = 0 839 var st3: i64 = 0 - 1 840 var sq: i64 = 0 841 while sq < sln { 842 if (tsc[sq] as i64) == CJX_TAB { 843 stabs = stabs + 1 844 tsc[sq] = 0 as u8 845 if stabs == 2 { st3 = sq + 1 } 846 } 847 sq = sq + 1 848 } 849 if tsc[0] != (0 as u8) { 850 var srt: i64 = tier_def 851 if st3 >= 0 { srt = cjp_tier_of(((tsc as i64) + st3) as *u8) } 852 if srt < 0 { 853 cjx_p("PANEL-REFUSED unknown tier=" as *u8); cjx_p(((tsc as i64) + st3) as *u8) 854 cjx_p(" path=" as *u8); cjx_p(tsc) 855 cjx_p(" -- expected silhouette|clay|textured|photoreal (nothing measured)\n" as *u8) 856 return 2 857 } 858 tseen[srt] = 1 859 } 860 } } 861 si = se + 1 862 } 863 var spans: i64 = 0 864 tz = 0 865 while tz < CJP_TIERS { spans = spans + tseen[tz]; tz = tz + 1 } 866 let tset: *u8 = sys_mmap(128) 867 cjp_tierset_str(tset, 0, tseen) 868 // A LENS MAY VOTE ON A TIER ONLY WITH A FLOOR THAT IS ABOUT THAT TIER. On a single-tier corpus the 869 // global floor IS about that tier, so nothing changes. The moment a corpus spans tiers, a global 870 // floor would be one bar answering two different questions -- so it stops voting and says so, per 871 // tier, rather than quietly deciding both. 872 let tvote: *i64 = sys_mmap(CJP_LENSES*CJP_TIERS*8) as *i64 873 let votingt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 874 tz = 0 875 while tz < CJP_TIERS { votingt[tz] = 0; tz = tz + 1 } 876 tli = 0 877 while tli < CJP_LENSES { 878 var tti2: i64 = 0 879 while tti2 < CJP_TIERS { 880 let vix: i64 = tli*CJP_TIERS + tti2 881 var canv: i64 = 0 882 if thas[vix] == 1 { if spans == 1 { canv = 1 } else { if texp[vix] == 1 { canv = 1 } } } 883 tvote[vix] = canv 884 votingt[tti2] = votingt[tti2] + canv 885 tti2 = tti2 + 1 886 } 887 tli = tli + 1 888 } 889 var admitted: i64 = 0 890 let onl: *i64 = sys_mmap(16) as *i64 891 onl[0] = "?" as *u8 as i64 892 let tadmp: *i64 = sys_mmap(16) as *i64 893 tadmp[0] = "" as *u8 as i64 894 if mode == 0 { admitted = cjp_receipt_admits(rpath, floors, skin_lens, skin_rule, onl, tadmp) } 895 // A LEGACY RECEIPT (no tiers_admitted key) can only stand for a SINGLE-TIER corpus: it recorded an 896 // admission for one question, and a multi-tier corpus asks more than one. Never widened silently. 897 var legacy_receipt: i64 = 0 898 if cjx_slen(tadmp[0] as *u8) == 0 { legacy_receipt = 1 } 899 900 cjx_p("=== CJC PANEL list=" as *u8); cjx_p(listp) 901 cjx_p(" conf=" as *u8); cjx_p(confp) 902 cjx_p(" " as *u8); cjx_p(floors) 903 cjx_p(" skin_lens=" as *u8); cjx_p(skin_lens) 904 cjx_p(" skin_rule=" as *u8); cjx_p(skin_rule) 905 cjx_p(" skin_key=" as *u8); cjx_p(skin_key) 906 cjx_p(" voting_lenses=" as *u8); cjx_n(voting) 907 // AT8: the tier set travels with every header, so a reader can never mistake which question the 908 // floors below were answers to. spans>1 with only global floors is the cross-tier case. 909 cjx_p(" tiers=" as *u8); cjx_p(tset) 910 cjx_p(" spans=" as *u8); cjx_n(spans) 911 cjx_p(" tier_default=" as *u8); cjx_p(tier_def_s) 912 cjx_p(" tier_voting=" as *u8) 913 tz = 0 914 var tvfirst: i64 = 1 915 while tz < CJP_TIERS { 916 if tseen[tz] == 1 { 917 if tvfirst == 0 { cjx_p("," as *u8) } 918 cjx_p(cjp_tier_name(tz)); cjx_p(":" as *u8); cjx_n(votingt[tz]) 919 tvfirst = 0 920 } 921 tz = tz + 1 922 } 923 if tvfirst == 1 { cjx_p("none" as *u8) } 924 // AN ADMISSION IS EVIDENCE ONLY ABOUT THE CORPUS IT WAS MEASURED ON, so the corpus travels with it. 925 // Printing it is what makes a stale admission visible to a reader running a DIFFERENT list. 926 if mode == 0 { if admitted == 1 { cjx_p(" admission=ADMITTED admitted_on=" as *u8); cjx_p(onl[0] as *u8) } else { cjx_p(" admission=UNADMITTED" as *u8) } } 927 if mode == 1 { cjx_p(" admission=CALIBRATING" as *u8) } 928 cjx_p("\n" as *u8) 929 930 let path: *u8 = sys_mmap(CJX_PATHCAP) 931 let out: *u8 = sys_mmap(CJP_CHILD_OUTCAP) 932 let olen: *i64 = sys_mmap(16) as *i64 933 let trunc: *i64 = sys_mmap(16) as *i64 934 let av: *i64 = sys_mmap(CJP_CHILD_ARGV*8) as *i64 935 var total: i64 = 0 936 var judged: i64 = 0 937 var failed: i64 = 0 938 var truncated: i64 = 0 939 var n_good: i64 = 0 940 var n_bad: i64 = 0 941 var n_unlab: i64 = 0 942 // confusion per lens + composite: fp (BAD judged pass), fn (GOOD judged fail), unobs among labelled 943 let fp: *i64 = sys_mmap((CJP_LENSES+1)*8) as *i64 944 let fneg: *i64 = sys_mmap((CJP_LENSES+1)*8) as *i64 945 let unob: *i64 = sys_mmap((CJP_LENSES+1)*8) as *i64 946 // separation margins: min over GOOD, max over BAD, per lens (for the human who sets the floor) 947 let gmin: *i64 = sys_mmap(CJP_LENSES*8) as *i64 948 let bmax: *i64 = sys_mmap(CJP_LENSES*8) as *i64 949 // per-SKIN-RULER margins, tracked for all three whatever the conf selected to vote, so ONE run 950 // carries everything needed to adjudicate the ruler choice on evidence. 951 let skgmin: *i64 = sys_mmap(CJP_SKRULES*8) as *i64 952 let skbmax: *i64 = sys_mmap(CJP_SKRULES*8) as *i64 953 let skval: *i64 = sys_mmap(CJP_SKRULES*8) as *i64 954 li = 0 955 while li <= CJP_LENSES { fp[li] = 0; fneg[li] = 0; unob[li] = 0; li = li + 1 } 956 li = 0 957 while li < CJP_LENSES { gmin[li] = 0 - CJP_UNOBS; bmax[li] = CJP_UNOBS; li = li + 1 } 958 li = 0 959 while li < CJP_SKRULES { skgmin[li] = 0 - CJP_UNOBS; skbmax[li] = CJP_UNOBS; li = li + 1 } 960 // AT8: composite confusion PER TIER. A corpus that spans tiers is several calibrations wearing one 961 // filename, so each tier earns (or fails to earn) its admission on its own rows. 962 let fpt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 963 let fnt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 964 let unobt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 965 let goodt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 966 let badt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 967 tz = 0 968 while tz < CJP_TIERS { fpt[tz] = 0; fnt[tz] = 0; unobt[tz] = 0; goodt[tz] = 0; badt[tz] = 0; tz = tz + 1 } 969 let vals: *i64 = sys_mmap(CJP_LENSES*8) as *i64 970 971 var i: i64 = 0 972 while i < n { 973 var e: i64 = i 974 var go: i64 = 1 975 while go == 1 { 976 if e >= n { go = 0 } 977 if go == 1 { if lbuf[e] == (CJX_NL as u8) { go = 0 } } 978 if go == 1 { e = e + 1 } 979 } 980 var ln: i64 = e - i 981 if ln > 0 { if lbuf[i] != (CJX_HASH as u8) { 982 if ln > CJX_PATHCAP-1 { ln = CJX_PATHCAP-1 } 983 // split path<TAB>label 984 var k: i64 = 0 985 var tab: i64 = 0 - 1 986 while k < ln { 987 path[k] = lbuf[i+k] 988 if tab < 0 { if (lbuf[i+k] as i64) == CJX_TAB { tab = k } } 989 k = k + 1 990 } 991 if ln > 0 { if path[ln-1] == (CJX_CR as u8) { ln = ln - 1 } } 992 path[ln] = 0 as u8 993 var label: i64 = CJP_LABEL_NONE 994 var plen: i64 = ln 995 var rtier: i64 = tier_def 996 if tab >= 0 { 997 plen = tab 998 path[tab] = 0 as u8 999 let lc: i64 = path[tab+1] as i64 1000 if lc == 71 { label = CJP_LABEL_GOOD } // 'G'OOD 1001 if lc == 66 { label = CJP_LABEL_BAD } // 'B'AD 1002 // AT8: the optional THIRD field is the fidelity tier. The pre-scan has already refused 1003 // an unrecognised one with nothing measured, so any name arriving here resolves. 1004 var t2: i64 = tab + 1 1005 while t2 < ln { 1006 if (path[t2] as i64) == CJX_TAB { 1007 path[t2] = 0 as u8 1008 rtier = cjp_tier_of(((path as i64) + t2 + 1) as *u8) 1009 t2 = ln 1010 } else { t2 = t2 + 1 } 1011 } 1012 if rtier < 0 { rtier = tier_def } 1013 } 1014 if plen > 0 { 1015 total = total + 1 1016 av[0] = selfp as i64 1017 av[1] = "lens" as *u8 as i64 1018 av[2] = path as i64 1019 av[3] = confp as i64 1020 av[4] = 0 1021 olen[0] = 0 1022 trunc[0] = 0 1023 let rc: i64 = tr_run_capture_tr(selfp, av, out, CJP_CHILD_OUTCAP, olen, CJX_TIMEOUT_MS*4, trunc) 1024 if trunc[0] != 0 { truncated = truncated + 1 } 1025 var dec: i64 = 0 - 1 1026 if olen[0] > 0 { dec = cjx_field(out, olen[0], " decoded=" as *u8) } 1027 if dec == 1 { 1028 judged = judged + 1 1029 vals[CJP_L_STATS] = cjx_sfield(out, olen[0], " cjp_stats=" as *u8, 0-1) 1030 // Read ALL THREE rulers from the one lens line and track each one's margins. 1031 // They cost nothing extra -- the child already measured them on the same pixels -- 1032 // and having them here is what makes the ruler choice re-auditable without a rebuild. 1033 var sr: i64 = 0 1034 while sr < CJP_SKRULES { 1035 skval[sr] = cjx_sfield(out, olen[0], skkey[sr] as *u8, 0-1) 1036 if label != CJP_LABEL_NONE { if skval[sr] >= 0 { 1037 if label == CJP_LABEL_GOOD { if skval[sr] < skgmin[sr] { skgmin[sr] = skval[sr] } } 1038 if label == CJP_LABEL_BAD { if skval[sr] > skbmax[sr] { skbmax[sr] = skval[sr] } } 1039 } } 1040 sr = sr + 1 1041 } 1042 vals[CJP_L_SKIN] = cjx_sfield(out, olen[0], skin_key, 0-1) 1043 vals[CJP_L_SYM] = cjx_sfield(out, olen[0], " cjp_sym=" as *u8, 0-1) 1044 vals[CJP_L_PERCEPT] = cjx_sfield(out, olen[0], " cjp_percept=" as *u8, CJP_UNOBS) 1045 vals[CJP_L_VLM] = cjx_sfield(out, olen[0], " cjp_vlm=" as *u8, 0-1) 1046 // votes: 1 pass / 0 fail / -1 abstain (unobservable or report-only) 1047 var all_pass: i64 = 1 1048 var any_fail: i64 = 0 1049 var any_unobs: i64 = 0 1050 var observed_voting: i64 = 0 1051 cjx_p("{\x22path\x22:\x22" as *u8); cjx_p(path) 1052 cjx_p("\x22,\x22label\x22:\x22" as *u8) 1053 if label == CJP_LABEL_GOOD { cjx_p("GOOD" as *u8) } 1054 if label == CJP_LABEL_BAD { cjx_p("BAD" as *u8) } 1055 if label == CJP_LABEL_NONE { cjx_p("-" as *u8) } 1056 cjx_p("\x22,\x22stats\x22:" as *u8); cjx_n(vals[CJP_L_STATS]) 1057 cjx_p(",\x22skin\x22:" as *u8); cjx_n(vals[CJP_L_SKIN]) 1058 cjx_p(",\x22sym\x22:" as *u8); cjx_n(vals[CJP_L_SYM]) 1059 cjx_p(",\x22percept\x22:" as *u8); cjx_n(vals[CJP_L_PERCEPT]) 1060 cjx_p(",\x22vlm\x22:" as *u8); cjx_n(vals[CJP_L_VLM]) 1061 cjx_p(",\x22votes\x22:\x22" as *u8) 1062 li = 0 1063 while li < CJP_LENSES { 1064 var v: i64 = 0 - 1 1065 var unobserved: i64 = 0 1066 if li == CJP_L_PERCEPT { if vals[li] == CJP_UNOBS { unobserved = 1 } } else { if vals[li] < 0 { unobserved = 1 } } 1067 // AT8: this lens votes on THIS image only with a floor that is about THIS 1068 // image's tier. On a single-tier corpus that is the global floor and nothing 1069 // moves; across tiers a global floor stops voting rather than answering two 1070 // questions with one bar. 1071 let vix2: i64 = li*CJP_TIERS + rtier 1072 if tvote[vix2] == 1 { 1073 if unobserved == 1 { any_unobs = 1; v = 0 - 1 } else { 1074 observed_voting = observed_voting + 1 1075 if vals[li] >= tfl[vix2] { v = 1 } else { v = 0; all_pass = 0; any_fail = 1 } 1076 } 1077 } 1078 if v == 1 { cjx_p("P" as *u8) } 1079 if v == 0 { cjx_p("F" as *u8) } 1080 if v < 0 { if tvote[vix2] == 1 { cjx_p("?" as *u8) } else { cjx_p("." as *u8) } } 1081 // per-lens confusion and margins on labelled rows (floor lenses only for fp/fneg; 1082 // margins for every observed lens so a report-only lens can still be adjudicated) 1083 if label != CJP_LABEL_NONE { 1084 if unobserved == 0 { 1085 if label == CJP_LABEL_GOOD { if vals[li] < gmin[li] { gmin[li] = vals[li] } } 1086 if label == CJP_LABEL_BAD { if vals[li] > bmax[li] { bmax[li] = vals[li] } } 1087 } 1088 if tvote[vix2] == 1 { 1089 if unobserved == 1 { unob[li] = unob[li] + 1 } else { 1090 if label == CJP_LABEL_GOOD { if vals[li] < tfl[vix2] { fneg[li] = fneg[li] + 1 } } 1091 if label == CJP_LABEL_BAD { if vals[li] >= tfl[vix2] { fp[li] = fp[li] + 1 } } 1092 } 1093 } 1094 } 1095 li = li + 1 1096 } 1097 cjx_p("\x22" as *u8) 1098 // composite: AND over voting lenses; abstain if any voting lens was unobservable or none vote 1099 var comp: i64 = 0 - 1 // -1 unobservable, 0 BAD, 1 GOOD 1100 // AT8: the denominator is THIS TIER's voting lenses. A tier no lens can vote on is 1101 // UNOBSERVABLE by construction -- abstain, never acquit with another tier's bar. 1102 if votingt[rtier] > 0 { 1103 if any_fail == 1 { comp = 0 } else { if any_unobs == 0 { if observed_voting == votingt[rtier] { comp = 1 } } } 1104 } 1105 if label != CJP_LABEL_NONE { 1106 if comp < 0 { unob[CJP_LENSES] = unob[CJP_LENSES] + 1; unobt[rtier] = unobt[rtier] + 1 } 1107 if comp == 1 { if label == CJP_LABEL_BAD { fp[CJP_LENSES] = fp[CJP_LENSES] + 1; fpt[rtier] = fpt[rtier] + 1 } } 1108 if comp == 0 { if label == CJP_LABEL_GOOD { fneg[CJP_LENSES] = fneg[CJP_LENSES] + 1; fnt[rtier] = fnt[rtier] + 1 } } 1109 if label == CJP_LABEL_GOOD { goodt[rtier] = goodt[rtier] + 1 } 1110 if label == CJP_LABEL_BAD { badt[rtier] = badt[rtier] + 1 } 1111 } 1112 cjx_p(",\x22composite\x22:\x22" as *u8) 1113 if comp == 1 { cjx_p("pass" as *u8) } 1114 if comp == 0 { cjx_p("fail" as *u8) } 1115 if comp < 0 { cjx_p("unobservable" as *u8) } 1116 cjx_p("\x22,\x22tier\x22:\x22" as *u8); cjx_p(cjp_tier_name(rtier)) 1117 cjx_p("\x22,\x22verdict\x22:\x22" as *u8) 1118 if mode == 0 { 1119 // AT8: AN ADMISSION IS ABOUT A TIER. A receipt written before tiers existed 1120 // carries no set and stands only for a single-tier corpus; otherwise this 1121 // image's tier must be named in the admitted set or no verdict is returned. 1122 var tier_adm: i64 = 0 1123 if legacy_receipt == 1 { if spans == 1 { tier_adm = 1 } } else { tier_adm = cjp_tierset_has(tadmp[0] as *u8, cjp_tier_name(rtier)) } 1124 if admitted == 1 { 1125 if tier_adm == 1 { 1126 if comp == 1 { cjx_p("GOOD" as *u8) } 1127 if comp == 0 { cjx_p("BAD" as *u8) } 1128 if comp < 0 { cjx_p("UNOBSERVABLE" as *u8) } 1129 } else { cjx_p("TIER-UNADMITTED" as *u8) } 1130 } else { cjx_p("UNADMITTED" as *u8) } 1131 } 1132 if mode == 1 { cjx_p("CALIBRATING" as *u8) } 1133 cjx_p("\x22}\n" as *u8) 1134 if label == CJP_LABEL_GOOD { n_good = n_good + 1 } 1135 if label == CJP_LABEL_BAD { n_bad = n_bad + 1 } 1136 if label == CJP_LABEL_NONE { n_unlab = n_unlab + 1 } 1137 } 1138 // A FAILURE IS NAMED, NEVER JUST COUNTED: rc and bytes separate a missing self/judge binary 1139 // (127, zero bytes) from an undecodable image (a CJP-LENS line with decoded=0). 1140 if dec != 1 { 1141 failed = failed + 1 1142 cjx_p("CJP-FAILED rc=" as *u8); cjx_n(rc) 1143 cjx_p(" bytes=" as *u8); cjx_n(olen[0]) 1144 cjx_p(" path=" as *u8); cjx_p(path); cjx_p("\n" as *u8) 1145 } 1146 } 1147 } } 1148 i = e + 1 1149 } 1150 cjx_p("\n=== CJC PANEL CENSUS ===\n" as *u8) 1151 cjx_p("corpus=" as *u8); cjx_n(total) 1152 cjx_p(" judged=" as *u8); cjx_n(judged) 1153 cjx_p(" failed=" as *u8); cjx_n(failed) 1154 cjx_p(" truncated=" as *u8); cjx_n(truncated) 1155 cjx_p(" labelled_good=" as *u8); cjx_n(n_good) 1156 cjx_p(" labelled_bad=" as *u8); cjx_n(n_bad) 1157 cjx_p(" unlabelled=" as *u8); cjx_n(n_unlab) 1158 cjx_p("\n" as *u8) 1159 var recon: i64 = 0 1160 if judged + failed == total { if n_good + n_bad + n_unlab == judged { recon = 1 } } 1161 cjx_p("partition judged+failed=" as *u8); cjx_n(judged+failed) 1162 cjx_p(" corpus=" as *u8); cjx_n(total) 1163 cjx_p(" good+bad+unlabelled=" as *u8); cjx_n(n_good+n_bad+n_unlab) 1164 if recon == 1 { cjx_p(" RECONCILES\n" as *u8) } 1165 if recon == 0 { cjx_p(" LEAKS -- these numbers are not publishable\n" as *u8) } 1166 // margins: what the labelled corpus says about EVERY observed lens, floor or not 1167 if n_good + n_bad > 0 { 1168 cjx_p("margins (min over GOOD | max over BAD | separable?) per lens:\n" as *u8) 1169 li = 0 1170 while li < CJP_LENSES - 1 { 1171 cjx_p(" " as *u8) 1172 if li == CJP_L_STATS { cjx_p("stats " as *u8) } 1173 if li == CJP_L_SKIN { cjx_p("skin " as *u8) } 1174 if li == CJP_L_SYM { cjx_p("sym " as *u8) } 1175 if li == CJP_L_PERCEPT { cjx_p("percept" as *u8) } 1176 cjx_p(" good_min=" as *u8) 1177 if gmin[li] == 0 - CJP_UNOBS { cjx_p("none" as *u8) } else { cjx_n(gmin[li]) } 1178 cjx_p(" bad_max=" as *u8) 1179 if bmax[li] == CJP_UNOBS { cjx_p("none" as *u8) } else { cjx_n(bmax[li]) } 1180 var sep: i64 = 0 1181 if gmin[li] != 0 - CJP_UNOBS { if bmax[li] != CJP_UNOBS { if gmin[li] > bmax[li] { sep = 1 } } } 1182 if sep == 1 { cjx_p(" separable=1" as *u8) } else { cjx_p(" separable=0" as *u8) } 1183 if has[li] == 1 { 1184 cjx_p(" floor=" as *u8); cjx_n(fl[li]) 1185 cjx_p(" fp=" as *u8); cjx_n(fp[li]) 1186 cjx_p(" fn=" as *u8); cjx_n(fneg[li]) 1187 cjx_p(" unobservable=" as *u8); cjx_n(unob[li]) 1188 } else { cjx_p(" floor=none (report-only)" as *u8) } 1189 cjx_p("\n" as *u8) 1190 li = li + 1 1191 } 1192 cjx_p(" vlm UNOBSERVABLE -- no sovereign VLM oracle on the estate; the slot abstains by construction\n" as *u8) 1193 // THE RULER-CHOICE EVIDENCE, in the same run and over the same corpus, so which skin ruler 1194 // should vote is decided by measured separability rather than by taste -- and re-decidable 1195 // later without a rebuild, because every run carries all three. 1196 cjx_p("skin rulers on region " as *u8); cjx_p(skin_lens) 1197 cjx_p(" (min over GOOD | max over BAD | separable? | margin) -- voting: " as *u8); cjx_p(skin_rule); cjx_p("\n" as *u8) 1198 li = 0 1199 while li < CJP_SKRULES { 1200 cjx_p(" " as *u8) 1201 if li == CJP_SK_KOVAC { cjx_p("kovac (daylight: Cb/Cr AND Y>80) " as *u8) } 1202 if li == CJP_SK_CHROMA { cjx_p("chroma (Kovac Cb/Cr, NO luminance) " as *u8) } 1203 if li == CJP_SK_LOCUS { cjx_p("locus (Chai-Ngan 99, NO luminance) " as *u8) } 1204 cjx_p(" good_min=" as *u8) 1205 if skgmin[li] == 0 - CJP_UNOBS { cjx_p("none" as *u8) } else { cjx_n(skgmin[li]) } 1206 cjx_p(" bad_max=" as *u8) 1207 if skbmax[li] == CJP_UNOBS { cjx_p("none" as *u8) } else { cjx_n(skbmax[li]) } 1208 var ssep: i64 = 0 1209 if skgmin[li] != 0 - CJP_UNOBS { if skbmax[li] != CJP_UNOBS { if skgmin[li] > skbmax[li] { ssep = 1 } } } 1210 if ssep == 1 { 1211 cjx_p(" separable=1 margin=" as *u8); cjx_n(skgmin[li] - skbmax[li]) 1212 cjx_p(" midpoint_floor=" as *u8); cjx_n((skgmin[li] + skbmax[li]) / 2) 1213 } else { cjx_p(" separable=0 margin=none midpoint_floor=none" as *u8) } 1214 cjx_p("\n" as *u8) 1215 li = li + 1 1216 } 1217 } 1218 if mode == 1 { 1219 // ADMISSION IS EARNED: both classes present, every labelled row observed by every voting lens, 1220 // composite FP=0 and FN=0, at least one voting lens. Then the receipt binds the floors. 1221 // AT8: ADMISSION IS EARNED PER TIER. Both classes present IN THAT TIER, every labelled row of 1222 // it observed by every lens that votes on it, and its composite FP and FN zero. A tier that 1223 // cannot separate is simply not admitted, and the panel then ABSTAINS on its images rather than 1224 // judging them against a bar calibrated on a different question. 1225 let admt: *i64 = sys_mmap(CJP_TIERS*8) as *i64 1226 var adm: i64 = 0 1227 tz = 0 1228 while tz < CJP_TIERS { 1229 var a1: i64 = 0 1230 if tseen[tz] == 1 { if votingt[tz] > 0 { if goodt[tz] > 0 { if badt[tz] > 0 { if recon == 1 { 1231 if fpt[tz] == 0 { if fnt[tz] == 0 { if unobt[tz] == 0 { a1 = 1 } } } 1232 } } } } } 1233 admt[tz] = a1 1234 adm = adm + a1 1235 tz = tz + 1 1236 } 1237 if adm > 1 { adm = 1 } 1238 let tadmset: *u8 = sys_mmap(128) 1239 cjp_tierset_str(tadmset, 0, admt) 1240 // The per-tier evidence prints whatever the outcome, and a tier that fails says WHY: a refusal 1241 // that will not name which tier failed and on how many rows is a count without a worklist. 1242 cjx_p("tiers per fidelity tier (good | bad | fp | fn | unobservable | lenses | admitted):\n" as *u8) 1243 tz = 0 1244 while tz < CJP_TIERS { 1245 if tseen[tz] == 1 { 1246 cjx_p(" " as *u8); cjx_p(cjp_tier_name(tz)) 1247 cjx_p(" good=" as *u8); cjx_n(goodt[tz]) 1248 cjx_p(" bad=" as *u8); cjx_n(badt[tz]) 1249 cjx_p(" fp=" as *u8); cjx_n(fpt[tz]) 1250 cjx_p(" fn=" as *u8); cjx_n(fnt[tz]) 1251 cjx_p(" unobs=" as *u8); cjx_n(unobt[tz]) 1252 cjx_p(" lenses=" as *u8); cjx_n(votingt[tz]) 1253 cjx_p(" admitted=" as *u8); cjx_n(admt[tz]) 1254 if admt[tz] == 0 { 1255 cjx_p(" WHY=" as *u8) 1256 if votingt[tz] == 0 { cjx_p("no-lens-votes-on-this-tier" as *u8) } else { 1257 if goodt[tz] == 0 { cjx_p("no-GOOD-rows" as *u8) } else { 1258 if badt[tz] == 0 { cjx_p("no-BAD-rows" as *u8) } else { cjx_p("does-not-separate" as *u8) } 1259 } 1260 } 1261 } 1262 cjx_p("\n" as *u8) 1263 } 1264 tz = tz + 1 1265 } 1266 cjx_p("calibration composite fp=" as *u8); cjx_n(fp[CJP_LENSES]) 1267 cjx_p(" fn=" as *u8); cjx_n(fneg[CJP_LENSES]) 1268 cjx_p(" unobservable=" as *u8); cjx_n(unob[CJP_LENSES]) 1269 cjx_p(" good=" as *u8); cjx_n(n_good) 1270 cjx_p(" bad=" as *u8); cjx_n(n_bad) 1271 cjx_p(" voting_lenses=" as *u8); cjx_n(voting) 1272 cjx_p("\n" as *u8) 1273 let rb: *u8 = sys_mmap(CJP_RECEIPTCAP) 1274 var ro: i64 = cjx_cat(rb, 0, "# cjc_panel admission receipt -- written by nx_charjudge_census calibrate; bound to the floors below.\n# A conf whose floors differ from this line is UNADMITTED by construction (recalibrate).\nadmitted=" as *u8) 1275 ro = cjx_catn(rb, ro, adm) 1276 ro = cjx_cat(rb, ro, "\nfp=" as *u8); ro = cjx_catn(rb, ro, fp[CJP_LENSES]) 1277 ro = cjx_cat(rb, ro, "\nfn=" as *u8); ro = cjx_catn(rb, ro, fneg[CJP_LENSES]) 1278 ro = cjx_cat(rb, ro, "\nunobservable=" as *u8); ro = cjx_catn(rb, ro, unob[CJP_LENSES]) 1279 ro = cjx_cat(rb, ro, "\ngood=" as *u8); ro = cjx_catn(rb, ro, n_good) 1280 ro = cjx_cat(rb, ro, "\nbad=" as *u8); ro = cjx_catn(rb, ro, n_bad) 1281 ro = cjx_cat(rb, ro, "\nvoting_lenses=" as *u8); ro = cjx_catn(rb, ro, voting) 1282 ro = cjx_cat(rb, ro, "\nlist=" as *u8); ro = cjx_cat(rb, ro, listp) 1283 ro = cjx_cat(rb, ro, "\nconf=" as *u8); ro = cjx_cat(rb, ro, confp) 1284 ro = cjx_cat(rb, ro, "\nskin_lens=" as *u8); ro = cjx_cat(rb, ro, skin_lens) 1285 ro = cjx_cat(rb, ro, "\nskin_rule=" as *u8); ro = cjx_cat(rb, ro, skin_rule) 1286 // AT8: the tier set the corpus presented, the subset that EARNED admission, and every floor that 1287 // is explicitly about a tier. All three are bound, so a corpus whose tiers move, or a tier that 1288 // stops separating, un-admits by construction exactly as a moved floor does. 1289 ro = cjx_cat(rb, ro, "\ntiers=" as *u8); ro = cjx_cat(rb, ro, tset) 1290 ro = cjx_cat(rb, ro, "\ntiers_admitted=" as *u8); ro = cjx_cat(rb, ro, tadmset) 1291 ro = cjx_cat(rb, ro, "\ntier_floors=" as *u8) 1292 var tfany: i64 = 0 1293 tli = 0 1294 while tli < CJP_LENSES { 1295 var tt3: i64 = 0 1296 while tt3 < CJP_TIERS { 1297 let eix: i64 = tli*CJP_TIERS + tt3 1298 if texp[eix] == 1 { 1299 if tfany == 1 { ro = cjx_cat(rb, ro, "," as *u8) } 1300 ro = cjx_cat(rb, ro, cjp_lens_name(tli)); ro = cjx_cat(rb, ro, "_" as *u8) 1301 ro = cjx_cat(rb, ro, cjp_tier_name(tt3)); ro = cjx_cat(rb, ro, "=" as *u8) 1302 ro = cjx_catn(rb, ro, tfl[eix]) 1303 tfany = 1 1304 } 1305 tt3 = tt3 + 1 1306 } 1307 tli = tli + 1 1308 } 1309 if tfany == 0 { ro = cjx_cat(rb, ro, "none" as *u8) } 1310 ro = cjx_cat(rb, ro, "\nepoch=" as *u8); ro = cjx_catn(rb, ro, sys_now_realtime_sec()) 1311 ro = cjx_cat(rb, ro, "\n" as *u8); ro = cjx_cat(rb, ro, floors) 1312 ro = cjx_cat(rb, ro, "\n" as *u8) 1313 let fd: i64 = sys_openat_wr(rpath, CJP_MODE_644) 1314 if fd < 0 { 1315 cjx_p("RECEIPT-UNWRITABLE path=" as *u8); cjx_p(rpath); cjx_p("\n" as *u8) 1316 return 1 1317 } 1318 sys_write(fd, rb, ro) 1319 sys_close(fd) 1320 cjx_p("receipt=" as *u8); cjx_p(rpath) 1321 cjx_p(" bytes=" as *u8); cjx_n(ro) 1322 if adm == 1 { cjx_p(" ADMITTED -- the panel may return verdicts at these floors\n" as *u8); return 0 } 1323 cjx_p(" REFUSED -- the panel reports numbers only (fix the MECHANISM that fails to separate, never retune to fit)\n" as *u8) 1324 return 1 1325 } 1326 if recon == 0 { return 1 } 1327 if truncated > 0 { return 1 } 1328 if judged == 0 { cjx_p("headline UNMEASURED -- zero images judged\n" as *u8); return 1 } 1329 return 0 1330} 1331 1332// bank any decodable reference as PNG (the sibling judges decode PNG only): one decode, one encode. 1333func cjp_topng(inp: *u8, outp: *u8) -> i64 { 1334 let wh: *i64 = sys_mmap(32) as *i64 1335 wh[0] = 0 1336 wh[1] = 0 1337 let rgb: *u8 = nx_img_to_rgb(inp, wh) 1338 if (rgb as i64) == 0 { cjx_p("TOPNG-REFUSED undecodable path=" as *u8); cjx_p(inp); cjx_p("\n" as *u8); return 2 } 1339 if wh[0] <= 0 { cjx_p("TOPNG-REFUSED zero-dims\n" as *u8); return 2 } 1340 let rc: i64 = nx_png_write_rgb(outp, rgb, wh[0], wh[1]) 1341 if rc != 0 { cjx_p("TOPNG-FAILED write path=" as *u8); cjx_p(outp); cjx_p("\n" as *u8); return 1 } 1342 cjx_p("TOPNG-OK src=" as *u8); cjx_p(inp) 1343 cjx_p(" w=" as *u8); cjx_n(wh[0]) 1344 cjx_p(" h=" as *u8); cjx_n(wh[1]) 1345 cjx_p(" dst=" as *u8); cjx_p(outp); cjx_p("\n" as *u8) 1346 return 0 1347} 1348 1349// SAME-FRAMING crop: the figure bbox over the FULL-RESOLUTION decode (the lens child works on a fitted frame; 1350// a crop must not inherit that downsample), margin = bbox-derived (crop_margin_permil of the larger side, conf), 1351// clamped to the image. Prints the bbox so the framing is auditable; REFUSES when no figure pixel exists 1352// (a crop of nothing would be the whole image wearing a new name). 1353func cjp_figcrop(inp: *u8, outp: *u8, confp: *u8) -> i64 { 1354 let cfl: *i64 = sys_mmap(16) as *i64 1355 cfl[0] = 0 1356 var cf: *u8 = sys_read_file(confp, cfl) 1357 var cfn: i64 = 0 1358 if (cf as i64) != 0 { cfn = cfl[0] } else { cf = sys_mmap(16); cf[0] = 0 as u8 } 1359 let fnd: *i64 = sys_mmap(16) as *i64 1360 let bg_tol: i64 = cjp_conf_int(cf, cfn, "bg_tol" as *u8, CJP_DEF_BG_TOL, fnd) 1361 let margin_permil: i64 = cjp_conf_int(cf, cfn, "crop_margin_permil" as *u8, CJP_DEF_CROP_MARGIN_PERMIL, fnd) 1362 let wh: *i64 = sys_mmap(32) as *i64 1363 wh[0] = 0 1364 wh[1] = 0 1365 let rgb: *u8 = nx_img_to_rgb(inp, wh) 1366 if (rgb as i64) == 0 { cjx_p("FIGCROP-REFUSED undecodable path=" as *u8); cjx_p(inp); cjx_p("\n" as *u8); return 2 } 1367 let w: i64 = wh[0] 1368 let h: i64 = wh[1] 1369 if w <= 0 { cjx_p("FIGCROP-REFUSED zero-dims\n" as *u8); return 2 } 1370 if h <= 0 { cjx_p("FIGCROP-REFUSED zero-dims\n" as *u8); return 2 } 1371 let bg_inset: i64 = cjp_conf_int(cf, cfn, "bg_inset_px" as *u8, CJP_DEF_BG_INSET_PX, fnd) 1372 // a capture's 1-px canvas border would otherwise BE the bbox: ignore an edge ring when scanning 1373 var edge_ignore: i64 = cjp_conf_int(cf, cfn, "edge_ignore_px" as *u8, CJP_DEF_EDGE_IGNORE_PX, fnd) 1374 if edge_ignore * 2 >= w { edge_ignore = 0 } 1375 if edge_ignore * 2 >= h { edge_ignore = 0 } 1376 let bg3: *i64 = sys_mmap(32) as *i64 1377 cjp_corner_bg(rgb, w, h, bg_inset, bg3) 1378 let bgr: i64 = bg3[0] 1379 let bgg: i64 = bg3[1] 1380 let bgb: i64 = bg3[2] 1381 var x0: i64 = w 1382 var y0: i64 = h 1383 var x1: i64 = 0 - 1 1384 var y1: i64 = 0 - 1 1385 var nfig: i64 = 0 1386 var y: i64 = edge_ignore 1387 while y < h - edge_ignore { 1388 var x: i64 = edge_ignore 1389 while x < w - edge_ignore { 1390 let o2: i64 = (y*w + x) * 3 1391 var d: i64 = (rgb[o2] as i64) - bgr 1392 if d < 0 { d = 0 - d } 1393 var dg: i64 = (rgb[o2+1] as i64) - bgg 1394 if dg < 0 { dg = 0 - dg } 1395 var db: i64 = (rgb[o2+2] as i64) - bgb 1396 if db < 0 { db = 0 - db } 1397 if dg > d { d = dg } 1398 if db > d { d = db } 1399 if d > bg_tol { 1400 nfig = nfig + 1 1401 if x < x0 { x0 = x } 1402 if x > x1 { x1 = x } 1403 if y < y0 { y0 = y } 1404 if y > y1 { y1 = y } 1405 } 1406 x = x + 1 1407 } 1408 y = y + 1 1409 } 1410 if nfig == 0 { cjx_p("FIGCROP-REFUSED no figure pixel differs from the corner background (bg_tol=" as *u8); cjx_n(bg_tol); cjx_p(") path=" as *u8); cjx_p(inp); cjx_p("\n" as *u8); return 1 } 1411 var side: i64 = x1 - x0 + 1 1412 if y1 - y0 + 1 > side { side = y1 - y0 + 1 } 1413 let m: i64 = side * margin_permil / CJX_PERMIL_MAX 1414 var cx0: i64 = x0 - m 1415 var cy0: i64 = y0 - m 1416 var cx1: i64 = x1 + m 1417 var cy1: i64 = y1 + m 1418 if cx0 < 0 { cx0 = 0 } 1419 if cy0 < 0 { cy0 = 0 } 1420 if cx1 > w - 1 { cx1 = w - 1 } 1421 if cy1 > h - 1 { cy1 = h - 1 } 1422 let cw: i64 = cx1 - cx0 + 1 1423 let chh: i64 = cy1 - cy0 + 1 1424 let out: *u8 = sys_mmap(cw*chh*3 + 16) 1425 var yy: i64 = 0 1426 while yy < chh { 1427 var xx: i64 = 0 1428 while xx < cw { 1429 let so: i64 = ((cy0+yy)*w + cx0 + xx) * 3 1430 let do2: i64 = (yy*cw + xx) * 3 1431 out[do2] = rgb[so] 1432 out[do2+1] = rgb[so+1] 1433 out[do2+2] = rgb[so+2] 1434 xx = xx + 1 1435 } 1436 yy = yy + 1 1437 } 1438 let rc: i64 = nx_png_write_rgb(outp, out, cw, chh) 1439 if rc != 0 { cjx_p("FIGCROP-FAILED write path=" as *u8); cjx_p(outp); cjx_p("\n" as *u8); return 1 } 1440 cjx_p("FIGCROP-OK src=" as *u8); cjx_p(inp) 1441 cjx_p(" src_w=" as *u8); cjx_n(w); cjx_p(" src_h=" as *u8); cjx_n(h) 1442 cjx_p(" fig_pixels=" as *u8); cjx_n(nfig) 1443 cjx_p(" bbox=" as *u8); cjx_n(x0); cjx_p("," as *u8); cjx_n(y0); cjx_p("," as *u8); cjx_n(x1); cjx_p("," as *u8); cjx_n(y1) 1444 cjx_p(" margin=" as *u8); cjx_n(m) 1445 cjx_p(" crop_w=" as *u8); cjx_n(cw); cjx_p(" crop_h=" as *u8); cjx_n(chh) 1446 cjx_p(" dst=" as *u8); cjx_p(outp); cjx_p("\n" as *u8) 1447 return 0 1448} 1449 1450func main(argc: i64, argv: *i64) -> i64 { 1451 if argc < 2 { cjx_p("usage: nx_charjudge_census <list-file> [judge-elf] | panel <list> [conf] | calibrate <labelled-list> [conf] | lens <image> [conf] | topng <in> <out.png> | figcrop <in> <out.png> [conf]\n" as *u8); return 3 } 1452 let a1: *u8 = argv[1] as *u8 1453 var confp: *u8 = "knowledge/cjc_panel.conf" as *u8 1454 if cjx_streq(a1, "lens" as *u8) == 1 { 1455 if argc < 3 { cjx_p("usage: nx_charjudge_census lens <image> [conf]\n" as *u8); return 3 } 1456 if argc >= 4 { confp = argv[3] as *u8 } 1457 return cjp_lens(argv[2] as *u8, confp) 1458 } 1459 if cjx_streq(a1, "panel" as *u8) == 1 { 1460 if argc < 3 { cjx_p("usage: nx_charjudge_census panel <list> [conf]\n" as *u8); return 3 } 1461 if argc >= 4 { confp = argv[3] as *u8 } 1462 return cjc_panel(argv[0] as *u8, argv[2] as *u8, confp, 0) 1463 } 1464 if cjx_streq(a1, "calibrate" as *u8) == 1 { 1465 if argc < 3 { cjx_p("usage: nx_charjudge_census calibrate <labelled-list> [conf]\n" as *u8); return 3 } 1466 if argc >= 4 { confp = argv[3] as *u8 } 1467 return cjc_panel(argv[0] as *u8, argv[2] as *u8, confp, 1) 1468 } 1469 if cjx_streq(a1, "topng" as *u8) == 1 { 1470 if argc < 4 { cjx_p("usage: nx_charjudge_census topng <in> <out.png>\n" as *u8); return 3 } 1471 return cjp_topng(argv[2] as *u8, argv[3] as *u8) 1472 } 1473 if cjx_streq(a1, "figcrop" as *u8) == 1 { 1474 if argc < 4 { cjx_p("usage: nx_charjudge_census figcrop <in> <out.png> [conf]\n" as *u8); return 3 } 1475 if argc >= 5 { confp = argv[4] as *u8 } 1476 return cjp_figcrop(argv[2] as *u8, argv[3] as *u8, confp) 1477 } 1478 // ---- legacy census, byte-for-byte the 2026-08-15 behaviour ---- 1479 let listp: *u8 = a1 1480 var elfp: *u8 = "./nx_charjudge.elf" as *u8 1481 if argc >= 3 { elfp = argv[2] as *u8 } 1482 let lenp: *i64 = sys_mmap(16) as *i64 1483 let lbuf: *u8 = sys_read_file(listp, lenp) 1484 if (lbuf as i64) == 0 { 1485 cjx_p("CENSUS-REFUSED list-unreadable path=" as *u8); cjx_p(listp); cjx_p("\n" as *u8) 1486 return 2 1487 } 1488 let n: i64 = lenp[0] 1489 let path: *u8 = sys_mmap(CJX_PATHCAP) 1490 let out: *u8 = sys_mmap(CJX_OUTCAP) 1491 let olen: *i64 = sys_mmap(16) as *i64 1492 let trunc: *i64 = sys_mmap(16) as *i64 1493 let av: *i64 = sys_mmap(CJX_ARGV_SLOTS*8) as *i64 1494 var total: i64 = 0 1495 var judged: i64 = 0 1496 var failed: i64 = 0 1497 var truncated: i64 = 0 1498 var sum: i64 = 0 1499 var mn: i64 = CJX_PERMIL_MAX + 1 1500 var mx: i64 = 0-1 1501 var i: i64 = 0 1502 while i < n { 1503 var e: i64 = i 1504 var go: i64 = 1 1505 while go == 1 { 1506 if e >= n { go = 0 } 1507 if go == 1 { if lbuf[e] == (CJX_NL as u8) { go = 0 } } 1508 if go == 1 { e = e + 1 } 1509 } 1510 var ln: i64 = e - i 1511 if ln > 0 { if lbuf[i] != (CJX_HASH as u8) { 1512 if ln > CJX_PATHCAP-1 { ln = CJX_PATHCAP-1 } 1513 var k: i64 = 0 1514 while k < ln { path[k] = lbuf[i+k]; k = k + 1 } 1515 if ln > 0 { if path[ln-1] == (CJX_CR as u8) { ln = ln - 1 } } 1516 path[ln] = 0 as u8 1517 if ln > 0 { 1518 total = total + 1 1519 av[0] = elfp as i64 1520 av[1] = path as i64 1521 av[2] = path as i64 1522 av[3] = 0 1523 olen[0] = 0 1524 trunc[0] = 0 1525 let rc: i64 = tr_run_capture_tr(elfp, av, out, CJX_OUTCAP, olen, CJX_TIMEOUT_MS, trunc) 1526 if trunc[0] != 0 { truncated = truncated + 1 } 1527 var hv: i64 = 0-1 1528 if olen[0] > 0 { hv = cjx_field(out, olen[0], "\x22CHARJUDGE\x22:" as *u8) } 1529 if hv >= 0 { 1530 judged = judged + 1 1531 sum = sum + hv 1532 if hv < mn { mn = hv } 1533 if hv > mx { mx = hv } 1534 sys_write(1, out, olen[0]) 1535 } 1536 // A FAILURE IS NAMED, NEVER JUST COUNTED. rc and captured bytes are printed together 1537 // because they separate the causes that need opposite work: a missing judge binary forks 1538 // to exit 127 with zero bytes and reads exactly like a corrupt image if only one is shown. 1539 if hv < 0 { 1540 failed = failed + 1 1541 cjx_p("CJ-FAILED rc=" as *u8); cjx_n(rc) 1542 cjx_p(" bytes=" as *u8); cjx_n(olen[0]) 1543 cjx_p(" path=" as *u8); cjx_p(path); cjx_p("\n" as *u8) 1544 } 1545 } 1546 } } 1547 i = e + 1 1548 } 1549 cjx_p("\n=== CHARJUDGE CENSUS ===\n" as *u8) 1550 cjx_p("corpus=" as *u8); cjx_n(total) 1551 cjx_p(" judged=" as *u8); cjx_n(judged) 1552 cjx_p(" failed=" as *u8); cjx_n(failed) 1553 cjx_p(" truncated=" as *u8); cjx_n(truncated) 1554 cjx_p("\n" as *u8) 1555 // A PARTITION IS A CLAIM: CHECK THE PARTS SUM, AND PRINT THE SUM. An unexplained residual is a leak, 1556 // and a census that cannot reconcile its own buckets must not have its numbers quoted. 1557 var recon: i64 = 0 1558 if judged + failed == total { recon = 1 } 1559 cjx_p("partition judged+failed=" as *u8); cjx_n(judged+failed) 1560 cjx_p(" corpus=" as *u8); cjx_n(total) 1561 if recon == 1 { cjx_p(" RECONCILES\n" as *u8) } 1562 if recon == 0 { cjx_p(" LEAKS -- these numbers are not publishable\n" as *u8) } 1563 if judged > 0 { 1564 cjx_p("headline min=" as *u8); cjx_n(mn) 1565 cjx_p(" max=" as *u8); cjx_n(mx) 1566 cjx_p(" mean=" as *u8); cjx_n(sum/judged) 1567 cjx_p("\n" as *u8) 1568 } 1569 // ZERO JUDGED IS UNMEASURED, NOT ZERO. A mean over an empty set is a fabricated number, and this is the 1570 // shape that lets a census whose subject never ran report a confident distribution of nothing. 1571 if judged == 0 { cjx_p("headline UNMEASURED -- zero images judged\n" as *u8) } 1572 if recon == 0 { return 1 } 1573 if truncated > 0 { return 1 } 1574 if judged == 0 { return 1 } 1575 return 0 1576}