code wiki / _hdl_build / nx_wiki_exceed_gate.nx

nx_wiki_exceed_gate.nx source

↩ module page · 122 lines · 6170 B

1// nx_wiki_exceed_gate.nx -- REFEREE for the wiki feature census. 2// 3// Proves nx_wiki_exceed MEASURES honestly + can SEE every case (no fabricated greens): 4// T1 real page (web_assets/charter.html): behind > 0 -- the measurement runs and honestly reports we 5// are behind the incumbent (our current page is far less functional than a wiki page). 6// N1 full fixture (contains every feature signal): behind == 0 -- proves it is NOT always-behind; it 7// reports parity ONLY when the page actually has the features (an earned-exceed is reportable). 8// N2 sparse fixture (no signals): ours_match == 0 AND behind == incumbent_total -- full sensitivity. 9// N3 one-feature fixture (exactly class="toc"): ours_match == 1 AND behind == incumbent_total-1 -- 10// per-feature specificity (not all-or-nothing; no false-present of the other 15). 11// GREEN iff T1..N3 all hold. Evidence -> knowledge/status/wiki_exceed_gate.log. Exit 0/1. 12// Sovereign: imports the organ + nx_framed_append + nx_syscalls. license_tier: ORIGINAL 13import "nx_wiki_exceed.nx" 14import "nx_framed_append.nx" 15import "nx_syscalls.nx" 16 17const WEG_LOG: *u8 = "knowledge/status/wiki_exceed_gate.log" 18const WEG_REAL: *u8 = "web_assets/charter.html" 19const WEG_CENSUS: *u8 = "knowledge/registry/wiki_feature_census.tsv" 20const WEG_RECCAP: i64 = 512 21 22func weg_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != 0 as u8 { dst[off + i] = s[i]; i = i + 1 } return off + i } 23func weg_catn(dst: *u8, off: i64, v: i64) -> i64 { 24 var m: i64 = v; var o: i64 = off 25 if m < 0 { m = 0 - m } 26 let t: *u8 = sys_mmap(28); var k: i64 = 0 27 if m == 0 { t[0] = 48 as u8; k = 1 } 28 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 29 var i: i64 = 0 30 while i < k { dst[o + i] = t[k - 1 - i]; i = i + 1 } 31 return o + k 32} 33func weg_write_file(path: *u8, content: *u8) -> i64 { 34 let fd: i64 = sys_openat_wr(path, 0x1a4) 35 if fd < 0 { return 0 - 1 } 36 var n: i64 = 0; while content[n] != 0 as u8 { n = n + 1 } 37 sys_write(fd, content, n) 38 sys_close(fd) 39 return 0 40} 41func weg_tmppath(out: *u8, stem: *u8, epoch: i64, pid: i64) -> i64 { 42 var o: i64 = 0 43 o = weg_cat(out, o, stem); o = weg_catn(out, o, epoch); o = weg_cat(out, o, "." as *u8) 44 o = weg_catn(out, o, pid); o = weg_cat(out, o, ".html" as *u8) 45 out[o] = 0 as u8 46 return o 47} 48func weg_row(name: *u8, pass: i64) -> i64 { 49 let buf: *u8 = sys_mmap(WEG_RECCAP + 16) 50 var o: i64 = 0 51 o = weg_cat(buf, o, "WEGATE row=\x00" as *u8); o = weg_cat(buf, o, name) 52 if pass == 1 { o = weg_cat(buf, o, " verdict=PASS\x00" as *u8) } else { o = weg_cat(buf, o, " verdict=FAIL\x00" as *u8) } 53 buf[o] = 0 as u8 54 fa_appendz(WEG_LOG, buf, WEG_RECCAP) 55 sys_write(1, " \x00" as *u8, 2) 56 var n: i64 = 0; while name[n] != 0 as u8 { n = n + 1 } sys_write(1, name, n) 57 if pass == 1 { sys_write(1, " PASS\n\x00" as *u8, 6) } else { sys_write(1, " FAIL\n\x00" as *u8, 6) } 58 return 0 59} 60 61func main() -> i64 { 62 let epoch: i64 = sys_now_realtime_sec() 63 let pid: i64 = __syscall(39, 0, 0, 0, 0, 0, 0) 64 let outs: *i64 = sys_mmap(256) as *i64 65 66 // T1: the REAL page is now S-class -- parity on all standard features AND >=1 exceed axis. 67 var t1: i64 = 0 68 if we_measure(WEG_CENSUS, WEG_REAL, outs) == 0 { if outs[3] == 0 { if outs[4] > 0 { t1 = 1 } } } 69 70 let pf: *u8 = sys_mmap(256); weg_tmppath(pf, "/tmp/we_full." as *u8, epoch, pid) 71 let ps: *u8 = sys_mmap(256); weg_tmppath(ps, "/tmp/we_sparse." as *u8, epoch, pid) 72 let po: *u8 = sys_mmap(256); weg_tmppath(po, "/tmp/we_one." as *u8, epoch, pid) 73 74 // full: contains EVERY feature signal -> behind==0. 75 weg_write_file(pf, "<h1 name=\"viewport\" class=\"fresh\" class=\"toc\" <h2 id= href=\"/wiki/ class=\"references\" type=\"search\" <nav class=\"infobox\" class=\"catlinks\" id=\"seealso\" rel=\"bookmark\" media=\"print\" class=\"wiki-edit\" hreflang= verdict= regenerate to refresh\n" as *u8) 76 // sparse: no signal at all -> ours_match==0, behind==incumbent_total. 77 weg_write_file(ps, "<p>nothing here</p>\n" as *u8) 78 // one: exactly the toc signal -> ours_match==1, behind==incumbent_total-1. 79 weg_write_file(po, "<div class=\"toc\">only one feature</div>\n" as *u8) 80 81 var n1: i64 = 0 82 if we_measure(WEG_CENSUS, pf, outs) == 0 { if outs[3] == 0 { if outs[4] > 0 { n1 = 1 } } } 83 var n2: i64 = 0 84 if we_measure(WEG_CENSUS, ps, outs) == 0 { if outs[2] == 0 { if outs[3] == outs[1] { if outs[4] == 0 { n2 = 1 } } } } 85 var n3: i64 = 0 86 if we_measure(WEG_CENSUS, po, outs) == 0 { if outs[2] == 1 { if outs[3] == outs[1] - 1 { if outs[4] == 0 { n3 = 1 } } } } 87 88 var passes: i64 = 0 89 if t1 == 1 { passes = passes + 1 } 90 if n1 == 1 { passes = passes + 1 } 91 if n2 == 1 { passes = passes + 1 } 92 if n3 == 1 { passes = passes + 1 } 93 var green: i64 = 0 94 if passes == 4 { green = 1 } 95 96 sys_write(1, "wiki-exceed census gate (honest measured head-to-head vs MediaWiki)\n\x00" as *u8, 67) 97 weg_row("T1-real-page-is-s-class \x00" as *u8, t1) 98 weg_row("N1-full-fixture-parity \x00" as *u8, n1) 99 weg_row("N2-sparse-full-sensitivity \x00" as *u8, n2) 100 weg_row("N3-one-feature-specificity \x00" as *u8, n3) 101 102 let vb: *u8 = sys_mmap(WEG_RECCAP + 16) 103 var o: i64 = 0 104 o = weg_cat(vb, o, "WIKI-EXCEED verdict=\x00" as *u8) 105 if green == 1 { o = weg_cat(vb, o, "GREEN\x00" as *u8) } else { o = weg_cat(vb, o, "RED\x00" as *u8) } 106 o = weg_cat(vb, o, " passes=\x00" as *u8); o = weg_catn(vb, o, passes); o = weg_cat(vb, o, "/4\x00" as *u8) 107 if green == 0 { 108 o = weg_cat(vb, o, " reason=\x00" as *u8) 109 if t1 == 0 { o = weg_cat(vb, o, "real-not-behind?? \x00" as *u8) } 110 if n1 == 0 { o = weg_cat(vb, o, "full-not-parity \x00" as *u8) } 111 if n2 == 0 { o = weg_cat(vb, o, "sparse-sensitivity \x00" as *u8) } 112 if n3 == 0 { o = weg_cat(vb, o, "one-specificity \x00" as *u8) } 113 } 114 o = weg_cat(vb, o, " END\x00" as *u8) 115 vb[o] = 0 as u8 116 fa_appendz(WEG_LOG, vb, WEG_RECCAP) 117 sys_write(1, vb, o) 118 sys_write(1, "\n\x00" as *u8, 1) 119 120 if green == 1 { return 0 } 121 return 1 122}