nx_evidence_fleet.nx source
↩ module page · 170 lines · 9727 B
1// nx_evidence_fleet.nx -- THE CENSUS-OF-CENSUSES HONESTY ROLLUP (operator 2026-07-10: "review again everything
2// and make sure our wiring of our systems is showing us a more real census iteratively so we can really get to
3// state of the art"). Every /compare/<domain> matrix publishes a coverage number, but a number is only as real
4// as its EVIDENCE: a domain with a <domain>.gates file has its capabilities FORKED-and-proven-GREEN by
5// nx_swcompare_evidence; a domain WITHOUT one is symbol-presence only (the weakest tier -- the code exists on
6// disk, unverified it works or is wired). This organ walks knowledge/compare/, and for every head-to-head census
7// (<domain>.matrix) reports EVIDENCE-BACKED (has .gates, N executable gates) vs SYMBOL-ONLY, and the FLEET
8// HONESTY permille = evidence-backed / total. It names exactly which domains still need a .gates file = the
9// rollout worklist. Read-only. See [[feedback-census-evidence-backed-not-symbol-presence]]. license_tier: ORIGINAL
10import "nx_syscalls.nx"
11const EF_MAGIC_65536: i64 = 65536
12const EF_MAGIC_65535: i64 = 65535
13const EF_MAGIC_131072: i64 = 131072
14const EF_MAGIC_262144: i64 = 262144
15const EF_MAGIC_262143: i64 = 262143
16
17const EF_DIR: *u8 = "knowledge/compare"
18
19func ef_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
20func ef_wn(v0: i64) -> i64 {
21 if v0==0 { sys_write(1,"0" as *u8,1); return 0 }
22 var v: i64=v0; if v<0{sys_write(1,"-" as *u8,1);v=0-v}
23 let t: *u8=sys_mmap(24); var k: i64=0; while v>0{t[k]=(48+(v%10)) as u8;v=v/10;k=k+1}
24 let r: *u8=sys_mmap(24); var i: i64=0; while k>0{k=k-1;r[i]=t[k];i=i+1} sys_write(1,r,i); return 0
25}
26func ef_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
27func ef_ends(name: *u8, nl: i64, suf: *u8) -> i64 {
28 let sl: i64=ef_slen(suf); if sl>nl {return 0}
29 var i: i64=0; while i<sl { if name[nl-sl+i]!=suf[i]{return 0} i=i+1 } return 1
30}
31func ef_exists(path: *u8) -> i64 { let fd: i64=sys_openat_rd(path); if fd<0{return 0} sys_close(fd); return 1 }
32// count non-comment, non-blank rows in a gates file (= number of executable proofs). 0 if absent.
33func ef_gate_rows(path: *u8) -> i64 {
34 let fd: i64=sys_openat_rd(path); if fd<0{return 0}
35 let buf: *u8=sys_mmap(EF_MAGIC_65536); var n: i64=0; var r: i64=sys_read(fd, buf, EF_MAGIC_65535)
36 while r>0 { n=n+r; if n>=EF_MAGIC_65535 {r=0} else { r=sys_read(fd, buf+n, EF_MAGIC_65535-n) } }
37 sys_close(fd)
38 var rows: i64=0; var ls: i64=0; var i: i64=0
39 while i<=n {
40 var eol: i64=0
41 if i==n { eol=1 } else { if buf[i]==(10 as u8) { eol=1 } }
42 if eol==1 { if i>ls { if buf[ls]!=(35 as u8) { rows=rows+1 } } ls=i+1 }
43 i=i+1
44 }
45 return rows
46}
47
48// walk EF_DIR; st[0]=matrix-domains(total census) st[1]=evidence-backed st[2]=total-gate-rows.
49// if verbose==1, prints each domain's status. returns total matrix domains.
50func ef_run(st: *i64, verbose: i64) -> i64 {
51 st[0]=0; st[1]=0; st[2]=0
52 let fd: i64 = sys_openat_rd(EF_DIR); if fd<0 { return 0 }
53 let gbuf: *u8 = sys_mmap(EF_MAGIC_131072)
54 let dom: *u8 = sys_mmap(128)
55 let gpath: *u8 = sys_mmap(256)
56 var nread: i64 = sys_getdents64(fd, gbuf, EF_MAGIC_131072)
57 while nread > 0 {
58 var off: i64 = 0
59 while off < nread {
60 let rl: *u8 = ((gbuf as i64)+off+16) as *u8
61 let reclen: i64 = (rl[0] as i64) + ((rl[1] as i64)*256)
62 if reclen<=0 { off=nread } else {
63 let name: *u8 = ((gbuf as i64)+off+19) as *u8
64 var nl: i64=0; while name[nl]!=(0 as u8){nl=nl+1}
65 if ef_ends(name, nl, ".matrix\x00" as *u8)==1 {
66 st[0]=st[0]+1
67 // domain = name without .matrix
68 var d: i64=0; while d < nl-7 { dom[d]=name[d]; d=d+1 } dom[d]=0 as u8
69 // gpath = knowledge/compare/<domain>.gates
70 var o: i64=0; let pre: *u8="knowledge/compare/\x00" as *u8
71 var pi: i64=0; while pre[pi]!=(0 as u8){gpath[o]=pre[pi];o=o+1;pi=pi+1}
72 var di: i64=0; while dom[di]!=(0 as u8){gpath[o]=dom[di];o=o+1;di=di+1}
73 let suf: *u8=".gates\x00" as *u8; var si: i64=0; while suf[si]!=(0 as u8){gpath[o]=suf[si];o=o+1;si=si+1} gpath[o]=0 as u8
74 let rows: i64 = ef_gate_rows(gpath)
75 if rows > 0 {
76 st[1]=st[1]+1; st[2]=st[2]+rows
77 if verbose==1 { ef_w(" [EVIDENCE ] "); ef_w(dom); ef_w(" -- "); ef_wn(rows); ef_w(" executable gates (forked GREEN by nx_swcompare_evidence)\n" as *u8) }
78 } else {
79 if verbose==1 { ef_w(" [symbol ] "); ef_w(dom); ef_w(" -- no .gates: coverage is symbol-presence only (needs executed evidence)\n" as *u8) }
80 }
81 }
82 off = off + reclen
83 }
84 }
85 nread = sys_getdents64(fd, gbuf, EF_MAGIC_131072)
86 }
87 sys_close(fd)
88 return st[0]
89}
90
91// find NUL-terminated needle in buf[from..to); -1 if absent.
92func ef_find(buf: *u8, from: i64, to: i64, needle: *u8) -> i64 {
93 let m: i64 = ef_slen(needle); if m==0 { return from }
94 var i: i64 = from
95 while i+m <= to { var j: i64=0; var hit: i64=1; while j<m { if buf[i+j]!=needle[j] { hit=0; j=m } else { j=j+1 } } if hit==1 { return i } i=i+1 }
96 return 0-1
97}
98
99// CLAIM-WEIGHTED fleet honesty: read the registry, and of the TOTAL published coverage-points, how many belong
100// to domains that are EXECUTED-EVIDENCE-BACKED (have a .gates file). A big unverified domain (e.g. 1000/1000
101// symbol-only) rightly drags the number down more than a small one. st[0]=total-cov st[1]=verified-cov st[2]=doms.
102func ef_claimweight(st: *i64) -> i64 {
103 st[0]=0; st[1]=0; st[2]=0
104 let buf: *u8 = sys_mmap(EF_MAGIC_262144)
105 let fd: i64 = sys_openat_rd("knowledge/compare/registry\x00" as *u8); if fd<0 { return 0 }
106 var n: i64=0; var r: i64=sys_read(fd, buf, EF_MAGIC_262143)
107 while r>0 { n=n+r; if n>=EF_MAGIC_262143 {r=0} else { r=sys_read(fd, buf+n, EF_MAGIC_262143-n) } }
108 sys_close(fd)
109 let dom: *u8 = sys_mmap(128); let gp: *u8 = sys_mmap(256)
110 var ls: i64=0; var i: i64=0
111 while i<=n {
112 var eol: i64=0
113 if i==n { eol=1 } else { if buf[i]==(10 as u8) { eol=1 } }
114 if eol==1 {
115 if i>ls { if buf[ls]!=(35 as u8) {
116 // coverage number: "coverage NNN"
117 let cpos: i64 = ef_find(buf, ls, i, "coverage \x00" as *u8)
118 // domain: after "/compare/"
119 let dpos: i64 = ef_find(buf, ls, i, "/compare/\x00" as *u8)
120 if cpos >= 0 { if dpos >= 0 {
121 // parse coverage digits after "coverage " (9 chars)
122 var p: i64 = cpos + 9; var cov: i64 = 0; var any: i64 = 0
123 while p < i { let c: i64 = buf[p] as i64; if c>=48 { if c<=57 { cov=cov*10+(c-48); any=1; p=p+1 } else { p=i } } else { p=i } }
124 // extract domain after "/compare/" (9 chars): [a-z0-9] until non
125 var q: i64 = dpos + 9; var d: i64 = 0
126 while q < i { let c: i64 = buf[q] as i64
127 var ok: i64=0; if c>=97 { if c<=122 { ok=1 } } if c>=48 { if c<=57 { ok=1 } }
128 if ok==1 { dom[d]=buf[q] as u8; d=d+1; q=q+1 } else { q=i } }
129 dom[d]=0 as u8
130 if any==1 { if d>0 {
131 st[0] = st[0] + cov; st[2] = st[2] + 1
132 var go: i64 = ef_slen("knowledge/compare/\x00" as *u8)
133 var o: i64=0; let pre: *u8="knowledge/compare/\x00" as *u8; var pi: i64=0
134 while pre[pi]!=(0 as u8){gp[o]=pre[pi];o=o+1;pi=pi+1}
135 var di: i64=0; while dom[di]!=(0 as u8){gp[o]=dom[di];o=o+1;di=di+1}
136 let suf: *u8=".gates\x00" as *u8; var si: i64=0; while suf[si]!=(0 as u8){gp[o]=suf[si];o=o+1;si=si+1} gp[o]=0 as u8
137 if go < 0 { }
138 if ef_exists(gp)==1 { st[1] = st[1] + cov }
139 } }
140 } }
141 } }
142 ls=i+1
143 }
144 i=i+1
145 }
146 return st[2]
147}
148
149func main(argc: i64, argv: *i64) -> i64 {
150 let st: *i64 = sys_mmap(64) as *i64
151 ef_w("=== NISHI CENSUS-OF-CENSUSES: how real is our /compare fleet? (evidence-backed vs symbol-only) ===\n" as *u8)
152 ef_run(st, 1)
153 let total: i64 = st[0]
154 let backed: i64 = st[1]
155 var permil: i64 = 0
156 if total > 0 { permil = (backed * 1000) / total }
157 ef_w("\n FLEET HONESTY (by domain count): "); ef_wn(backed); ef_w(" of "); ef_wn(total)
158 ef_w(" head-to-head censuses are EXECUTED-EVIDENCE-BACKED = "); ef_wn(permil); ef_w(" permille\n" as *u8)
159 ef_w(" ("); ef_wn(st[2]); ef_w(" executable gates across the backed domains; the rest publish symbol-presence numbers)\n" as *u8)
160 // claim-weighted: of the TOTAL published coverage-points, how many are executed-verified
161 let cw: *i64 = sys_mmap(64) as *i64
162 ef_claimweight(cw)
163 var cwpm: i64 = 0
164 if cw[0] > 0 { cwpm = (cw[1] * 1000) / cw[0] }
165 ef_w(" FLEET HONESTY (claim-weighted): of "); ef_wn(cw[0]); ef_w(" total published coverage-points across "); ef_wn(cw[2])
166 ef_w(" domains, "); ef_wn(cw[1]); ef_w(" are executed-evidence-backed = "); ef_wn(cwpm); ef_w(" permille\n" as *u8)
167 ef_w(" (a big unverified domain drags this down more than a small one -- the honest SOTA-readiness fraction)\n" as *u8)
168 ef_w(" ROLLOUT: give each symbol-only domain a knowledge/compare/<domain>.gates file -> nx_swcompare_evidence -> /compare/<domain>/bench.\n" as *u8)
169 return 0
170}