nx_evidence_fleet_gate.nx source
↩ module page · 57 lines · 3872 B
1// nx_evidence_fleet_gate.nx -- proves the census-of-censuses honesty rollup counts correctly on the REAL
2// knowledge/compare/ dir: total matrix domains, evidence-backed (>=3: librarian+medbilling+projectmgmt),
3// permille math, and that a KNOWN evidence-backed domain's gates rows are counted while a KNOWN symbol-only
4// domain has zero. Exits 0 iff ALL pass. license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_evidence_fleet.nx"
7
8func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
9func g_putn(v: i64) -> i64 { if v==0{sys_write(1,"0" as *u8,1);return 0} var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} let d: *u8=sys_mmap(24); var k: i64=0; while m>0{d[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let r: *u8=sys_mmap(24); var i: i64=0; while k>0{k=k-1;r[i]=d[k];i=i+1} sys_write(1,r,i); return 0 }
10func chk(name: *u8, got: i64, want: i64, st: *i64) -> i64 {
11 if got==want { st[0]=st[0]+1; g_puts(" PASS " as *u8); g_puts(name); g_puts("\n" as *u8) }
12 else { st[1]=st[1]+1; g_puts(" FAIL " as *u8); g_puts(name); g_puts(" got=" as *u8); g_putn(got); g_puts(" want=" as *u8); g_putn(want); g_puts("\n" as *u8) }
13 return 0
14}
15
16func main() -> i64 {
17 let st: *i64 = sys_mmap(16) as *i64; st[0]=0; st[1]=0
18 let acc: *i64 = sys_mmap(64) as *i64
19 let total: i64 = ef_run(acc, 0)
20 var tot_ok: i64=0; if total >= 20 { tot_ok=1 }
21 chk("fleet has >=20 head-to-head censuses" as *u8, tot_ok, 1, st)
22 var backed_ok: i64=0; if acc[1] >= 3 { backed_ok=1 }
23 chk("at least 3 domains evidence-backed (librarian+medbilling+projectmgmt)" as *u8, backed_ok, 1, st)
24 var fewer: i64=0; if acc[1] < total { fewer=1 }
25 chk("evidence-backed < total (most censuses still symbol-only = honest)" as *u8, fewer, 1, st)
26 var rows_ok: i64=0; if acc[2] >= acc[1] { rows_ok=1 }
27 chk("total gate rows >= backed domains" as *u8, rows_ok, 1, st)
28
29 // known evidence-backed domain has gate rows
30 var libr: i64=0; if ef_gate_rows("knowledge/compare/librarian.gates\x00" as *u8) >= 4 { libr=1 }
31 chk("librarian.gates counted (>=4 gates)" as *u8, libr, 1, st)
32 var mbr: i64=0; if ef_gate_rows("knowledge/compare/medbilling.gates\x00" as *u8) >= 4 { mbr=1 }
33 chk("medbilling.gates counted (>=4 gates, robust to co-editing)" as *u8, mbr, 1, st)
34 // known symbol-only domain has NO gates file
35 chk("NEG containers has no .gates (symbol-only)" as *u8, ef_gate_rows("knowledge/compare/containers.gates\x00" as *u8), 0, st)
36 chk("NEG absent file -> 0 rows" as *u8, ef_gate_rows("knowledge/compare/florblegork.gates\x00" as *u8), 0, st)
37
38 let permil: i64 = (acc[1]*1000)/total
39 var pm_ok: i64=0; if permil < 500 { pm_ok=1 }
40 chk("fleet honesty < 500 permille (most censuses NOT yet evidence-backed = the honest state)" as *u8, pm_ok, 1, st)
41
42 // claim-weighted metric: reads the registry, total coverage > verified coverage > 0
43 let cw: *i64 = sys_mmap(64) as *i64
44 let doms: i64 = ef_claimweight(cw)
45 var doms_ok: i64=0; if doms >= 20 { doms_ok=1 }
46 chk("claim-weight reads >=20 domains from the registry" as *u8, doms_ok, 1, st)
47 var tot_pos: i64=0; if cw[0] > 0 { tot_pos=1 }
48 chk("total published coverage > 0" as *u8, tot_pos, 1, st)
49 var ver_lt: i64=0; if cw[1] < cw[0] { if cw[1] > 0 { ver_lt=1 } }
50 chk("verified coverage in (0, total) = honest (some but not all)" as *u8, ver_lt, 1, st)
51
52 g_puts("=== fleet honesty: " as *u8); g_putn(acc[1]); g_puts("/" as *u8); g_putn(total); g_puts(" backed = " as *u8); g_putn(permil); g_puts(" permille ===\n" as *u8)
53 g_puts("nx_evidence_fleet_gate: PASS=" as *u8); g_putn(st[0]); g_puts(" FAIL=" as *u8); g_putn(st[1]); g_puts("\n" as *u8)
54 if st[1]==0 { g_puts("EVIDENCE-FLEET nx_evidence_fleet: GREEN\n" as *u8); return 0 }
55 g_puts("EVIDENCE-FLEET nx_evidence_fleet: RED\n" as *u8)
56 return 1
57}