code wiki / (root) / nx_census_completeness.nx

nx_census_completeness.nx source

↩ module page · 88 lines · 5777 B

1// nx_census_completeness.nx -- THE COMPLETENESS ADVERSARY (operator 2026-07-14: "you missed readability on a mobile 2// device in sunlight ... should have been caught in our research system but it was a miss ... the critic and adversary 3// need work"). ROOT DEFECT: a census that only grades the axes you REMEMBERED is always green -- nothing checks the 4// axis SPACE for blind spots. This adversary reads a RESEARCHED axis TAXONOMY (the full dimension space for a domain, 5// grounded in the banked literature) and diffs it against the published census matrix's AXIS LABELS: every taxonomy 6// dimension whose keyword appears in NO census axis label is flagged as a MISS. So misses are caught by the SYSTEM, 7// not the operator. Usage: nx_census_completeness <domain> (reads knowledge/compare/<domain>.taxonomy + .matrix). 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10const K_MAGIC_262144: i64 = 262144 11 12func cp(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 13func cn(v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; var k: i64 = 0; if m == 0 { t[0] = 48 as u8; k = 1 } while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } let b: *u8 = sys_mmap(28); var i: i64 = 0; while i < k { b[i] = t[k - 1 - i]; i = i + 1 } sys_write(1, b, k); return 0 } 14func cread(path: *u8, buf: *u8, cap: i64) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 - 1 } var tot: i64 = 0; while tot < cap { let r: i64 = sys_read(fd, (buf as i64 + tot) as *u8, cap - tot); if r <= 0 { break } tot = tot + r } sys_close(fd); return tot } 15func clc(c: i64) -> i64 { if c >= 65 { if c <= 90 { return c + 32 } } return c } 16// case-insensitive: does hay[0..hl) contain the NUL-terminated needle? 17func chas(hay: *u8, hl: i64, needle: *u8) -> i64 { 18 var nl: i64 = 0; while needle[nl] != (0 as u8) { nl = nl + 1 } 19 if nl == 0 { return 0 } 20 var i: i64 = 0 21 while i + nl <= hl { 22 var j: i64 = 0; var ok: i64 = 1 23 while j < nl { if clc(hay[i + j] as i64) != clc(needle[j] as i64) { ok = 0; j = nl } else { j = j + 1 } } 24 if ok == 1 { return 1 } 25 i = i + 1 26 } 27 return 0 28} 29// build a buffer holding ONLY the axis LABELS (chars before the first '|') of each matrix data row, newline-joined. 30func build_labels(mat: *u8, mn: i64, lab: *u8) -> i64 { 31 var p: i64 = 0; var lo: i64 = 0 32 while p < mn { 33 var e: i64 = p; while e < mn { if mat[e] == (10 as u8) { break } e = e + 1 } 34 let c0: i64 = mat[p] as i64 35 if c0 != 35 { if c0 != 64 { if e > p { 36 var q: i64 = p 37 while q < e { if mat[q] == (124 as u8) { q = e } else { lab[lo] = mat[q]; lo = lo + 1; q = q + 1 } } 38 lab[lo] = 10 as u8; lo = lo + 1 39 } } } 40 p = e + 1 41 } 42 lab[lo] = 0 as u8 43 return lo 44} 45func main(argc: i64, argv: *i64) -> i64 { 46 if argc < 2 { cp("usage: nx_census_completeness <domain>\n" as *u8); return 2 } 47 let dom: *u8 = argv[1] as *u8 48 let cap: i64 = K_MAGIC_262144 49 let tax: *u8 = sys_mmap(cap); let mat: *u8 = sys_mmap(cap); let lab: *u8 = sys_mmap(cap) 50 // build paths knowledge/compare/<dom>.taxonomy and .matrix 51 let tp: *u8 = sys_mmap(512); let mp: *u8 = sys_mmap(512) 52 let pre: *u8 = "knowledge/compare/" as *u8 53 var o: i64 = 0; var pi: i64 = 0; while pre[pi] != (0 as u8) { tp[o] = pre[pi]; mp[o] = pre[pi]; o = o + 1; pi = pi + 1 } 54 var di: i64 = 0; while dom[di] != (0 as u8) { tp[o] = dom[di]; mp[o] = dom[di]; o = o + 1; di = di + 1 } 55 var to: i64 = o; let s1: *u8 = ".taxonomy" as *u8; var a: i64 = 0; while s1[a] != (0 as u8) { tp[to] = s1[a]; to = to + 1; a = a + 1 } tp[to] = 0 as u8 56 var mo: i64 = o; let s2: *u8 = ".matrix" as *u8; var b2: i64 = 0; while s2[b2] != (0 as u8) { mp[mo] = s2[b2]; mo = mo + 1; b2 = b2 + 1 } mp[mo] = 0 as u8 57 let tn: i64 = cread(tp, tax, cap) 58 if tn <= 0 { cp("NO TAXONOMY: " as *u8); cp(tp); cp(" -- author the researched full axis space first\n" as *u8); sys_exit(1); return 1 } 59 let mn: i64 = cread(mp, mat, cap) 60 if mn <= 0 { cp("NO MATRIX: " as *u8); cp(mp); cp("\n" as *u8); sys_exit(1); return 1 } 61 let ln: i64 = build_labels(mat, mn, lab) 62 cp("=== COMPLETENESS ADVERSARY: " as *u8); cp(dom); cp(" (researched axis-space vs published census labels) ===\n" as *u8) 63 var total: i64 = 0; var covered: i64 = 0; var missed: i64 = 0 64 var p: i64 = 0 65 while p < tn { 66 var e: i64 = p; while e < tn { if tax[e] == (10 as u8) { break } e = e + 1 } 67 tax[e] = 0 as u8 68 let line: *u8 = (tax as i64 + p) as *u8 69 p = e + 1 70 let c0: i64 = line[0] as i64 71 if c0 != 0 { if c0 != 35 { 72 var bp: i64 = 0 73 while line[bp] != (0 as u8) { if line[bp] == (124 as u8) { break } bp = bp + 1 } 74 if line[bp] == (124 as u8) { 75 let kw: *u8 = (line as i64 + bp + 1) as *u8 76 line[bp] = 0 as u8 77 total = total + 1 78 if chas(lab, ln, kw) == 1 { covered = covered + 1 } else { missed = missed + 1; cp(" MISS: " as *u8); cp(line); cp(" (no census axis label mentions '" as *u8); cp(kw); cp("')\n" as *u8) } 79 } 80 } } 81 } 82 cp("COMPLETENESS " as *u8); cp(dom); cp(": covered=" as *u8); cn(covered); cp("/" as *u8); cn(total) 83 var pm: i64 = 0; if total > 0 { pm = (covered * 1000) / total } 84 cp(" (" as *u8); cn(pm); cp("permil of the researched axis-space) MISSES=" as *u8); cn(missed); cp("\n" as *u8) 85 if missed > 0 { cp("VERDICT: census INCOMPLETE -- " as *u8); cn(missed); cp(" researched axes have NO census coverage; add them or the coverage score is over-optimistic\n" as *u8); return 0 } 86 cp("VERDICT: census COMPLETE vs the researched taxonomy\n" as *u8) 87 return 0 88}