nx_claim_metric_audit.nx source
↩ module page · 416 lines · 26151 B
1// nx_claim_metric_audit.nx -- THE CLAIM-METRIC ALIGNMENT axis of the SOVEREIGN SOTA auditor (2026-07-04).
2//
3// Operator: the browser-font episode "hit the nail that needs to be added to our state-of-the-art auditing
4// of our whole ecosystem." That nail: OCR proved LEGIBILITY, but I claimed VISUAL QUALITY -- the metric
5// measured a DIFFERENT (easier) property than the claim, and it had no reference it could FAIL against.
6// That is a distinct root flaw from nx_rung_eval's "asserted, not proven": here the property IS proven, but
7// it is the WRONG property, or proven unfalsifiably. This organ makes that flaw a permanent, liar-killed,
8// prove-not-assert check, composed into the evaluator system (emits the same EVAL-COORD line).
9//
10// THE LAW (checkable by scanning the census's own source): a census/gate that emits a QUALITY or EXCEED
11// CLAIM (parity/exceed/ahead/matched/professional/SOTA/beats...) is GROUNDED only if it ALSO:
12// (A) REFERENCE -- compares against a REAL EXTERNAL reference (a competitor artifact / ground truth),
13// not merely its own output; and
14// (B) CAN-FAIL -- carries a falsifiability control that proves the metric can score BADLY
15// (a liar-kill / negative control / discrimination check / must-fail case).
16// Claim WITHOUT (A and B) = UNGROUNDED = a proxy or unfalsifiable claim = the flaw. Reported per-census with
17// WHICH leg is missing, so it is actionable. LIAR-KILLED: known-grounded censuses must read GROUNDED and a
18// synthetic claim-with-no-grounding fixture MUST read UNGROUNDED; else the auditor declares ITSELF broken.
19// license_tier: ORIGINAL expect_exit: 0
20import "nx_syscalls.nx"
21const CMA_MAGIC_1024: i64 = 1024
22const CMA_MAGIC_65536: i64 = 65536
23
24const CMA_BUF: i64 = 2097152
25
26static cma_audited: i64
27static cma_grounded: i64
28static cma_weak: i64
29static cma_ungrounded: i64
30static cma_noclaim: i64
31static cma_missing: i64
32static cma_wl: i64 // worklist buffer (ptr)
33static cma_wlpos: i64 // worklist write position
34static cma_un: i64 // ungrounded-NAMES set buffer (ptr), one "path\n" per ungrounded census
35static cma_unpos: i64 // ungrounded-set write position
36
37func cma_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
38func cma_putn(v: i64) -> i64 { if v==0 { sys_write(1,"0" as *u8,1); return 0 } let d: *u8=sys_mmap(24); var m: i64=v; var k: i64=0; while m>0 { d[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } let b: *u8=sys_mmap(24); var i: i64=0; while i<k { b[i]=d[k-1-i]; i=i+1 } sys_write(1,b,k); return 0 }
39func cma_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
40func cma_apps(buf: *u8, pos: i64, s: *u8) -> i64 { var p: i64=pos; var i: i64=0; while s[i]!=(0 as u8) { buf[p]=s[i]; p=p+1; i=i+1 } return p }
41func cma_appn(buf: *u8, pos: i64, v: i64) -> i64 { var p: i64=pos; var m: i64=v; if m==0 { buf[p]=48 as u8; return p+1 } let t: *u8=sys_mmap(24); var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var i: i64=0; while i<k { buf[p]=t[k-1-i]; p=p+1; i=i+1 } return p }
42func cma_card(buf: *u8, pos: i64, label: *u8, v: i64, color: *u8) -> i64 {
43 var p: i64 = pos
44 p = cma_apps(buf, p, "<div style=\x27background:#0f1526;border:1px solid #1e2740;border-radius:10px;padding:12px 18px\x27><div style=\x27font-size:30px;font-weight:700;color:\x00" as *u8)
45 p = cma_apps(buf, p, color)
46 p = cma_apps(buf, p, "\x27>\x00" as *u8)
47 p = cma_appn(buf, p, v)
48 p = cma_apps(buf, p, "</div><div style=\x27font-size:12px;color:#9fb2dd\x27>\x00" as *u8)
49 p = cma_apps(buf, p, label)
50 p = cma_apps(buf, p, "</div></div>\x00" as *u8)
51 return p
52}
53
54// read whole file into buf; return length, or -1 if missing. (buf caller-provided, CMA_BUF bytes)
55func cma_load(path: *u8, buf: *u8) -> i64 {
56 let fd: i64 = sys_openat_rd(path)
57 if fd < 0 { return 0 - 1 }
58 var total: i64 = 0
59 var run: i64 = 1
60 while run == 1 {
61 let r: i64 = sys_read(fd, ((buf as i64)+total) as *u8, CMA_BUF - total)
62 if r <= 0 { run = 0 } else { total = total + r; if total >= CMA_BUF { run = 0 } }
63 }
64 sys_close(fd)
65 return total
66}
67// does buf[0..len) contain needle?
68func cma_has(buf: *u8, len: i64, needle: *u8) -> i64 {
69 let nlen: i64 = cma_slen(needle)
70 if nlen == 0 { return 1 }
71 var i: i64 = 0
72 while i + nlen <= len {
73 var m: i64 = 0; var ok: i64 = 1
74 while m < nlen { if buf[i+m] != needle[m] { ok=0; m=nlen } else { m=m+1 } }
75 if ok == 1 { return 1 }
76 i = i + 1
77 }
78 return 0
79}
80// (1) a strong QUALITY/EXCEED claim present?
81func cma_has_claim(buf: *u8, len: i64) -> i64 {
82 if cma_has(buf,len,"PARITY" as *u8)==1 { return 1 }
83 if cma_has(buf,len,"parity" as *u8)==1 { return 1 }
84 if cma_has(buf,len,"EXCEED" as *u8)==1 { return 1 }
85 if cma_has(buf,len,"exceed" as *u8)==1 { return 1 }
86 if cma_has(buf,len,"AHEAD" as *u8)==1 { return 1 }
87 if cma_has(buf,len,"SOTA" as *u8)==1 { return 1 }
88 if cma_has(buf,len,"state-of-the-art" as *u8)==1 { return 1 }
89 if cma_has(buf,len,"matched" as *u8)==1 { return 1 }
90 if cma_has(buf,len,"beats" as *u8)==1 { return 1 }
91 if cma_has(buf,len,"professional" as *u8)==1 { return 1 }
92 if cma_has(buf,len,"s-class" as *u8)==1 { return 1 }
93 if cma_has(buf,len,"s class" as *u8)==1 { return 1 }
94 return 0
95}
96// (A) compares against a REAL EXTERNAL reference (competitor artifact / ground truth), not just its own output
97func cma_has_reference(buf: *u8, len: i64) -> i64 {
98 if cma_has(buf,len,"chrome" as *u8)==1 { return 1 }
99 if cma_has(buf,len,"Chrome" as *u8)==1 { return 1 }
100 if cma_has(buf,len,"edge" as *u8)==1 { return 1 }
101 if cma_has(buf,len,"Edge" as *u8)==1 { return 1 }
102 if cma_has(buf,len,"ground truth" as *u8)==1 { return 1 }
103 if cma_has(buf,len,"ground-truth" as *u8)==1 { return 1 }
104 if cma_has(buf,len,"ground_truth" as *u8)==1 { return 1 }
105 if cma_has(buf,len,"reference" as *u8)==1 { return 1 }
106 if cma_has(buf,len,"rival" as *u8)==1 { return 1 }
107 if cma_has(buf,len,"competitor" as *u8)==1 { return 1 }
108 if cma_has(buf,len,"Selenium" as *u8)==1 { return 1 }
109 if cma_has(buf,len,"Playwright" as *u8)==1 { return 1 }
110 if cma_has(buf,len,"vLLM" as *u8)==1 { return 1 }
111 // named ecosystem competitors / external instruments (a real reference need not be a browser)
112 if cma_has(buf,len,"incumbent" as *u8)==1 { return 1 }
113 if cma_has(buf,len,"baseline" as *u8)==1 { return 1 }
114 if cma_has(buf,len,"VaM" as *u8)==1 { return 1 }
115 if cma_has(buf,len,"VirtaMate" as *u8)==1 { return 1 }
116 if cma_has(buf,len,"HS2" as *u8)==1 { return 1 }
117 if cma_has(buf,len,"Replika" as *u8)==1 { return 1 }
118 if cma_has(buf,len,"Civitai" as *u8)==1 { return 1 }
119 if cma_has(buf,len,"TGI" as *u8)==1 { return 1 }
120 if cma_has(buf,len,"Unsloth" as *u8)==1 { return 1 }
121 if cma_has(buf,len,"Wolfram" as *u8)==1 { return 1 }
122 if cma_has(buf,len,"Kindle" as *u8)==1 { return 1 }
123 if cma_has(buf,len,"DocuSign" as *u8)==1 { return 1 }
124 if cma_has(buf,len,"Photoshop" as *u8)==1 { return 1 }
125 if cma_has(buf,len,"HarfBuzz" as *u8)==1 { return 1 }
126 if cma_has(buf,len,"Cloudflare" as *u8)==1 { return 1 }
127 if cma_has(buf,len,"WCAG" as *u8)==1 { return 1 }
128 if cma_has(buf,len,"Nielsen" as *u8)==1 { return 1 }
129 if cma_has(buf,len,"IEEE" as *u8)==1 { return 1 }
130 if cma_has(buf,len,"SonarQube" as *u8)==1 { return 1 }
131 return 0
132}
133// (B) a falsifiability control -- the metric can score BADLY (liar-kill / negative control / discrimination)
134func cma_has_canfail(buf: *u8, len: i64) -> i64 {
135 if cma_has(buf,len,"liar" as *u8)==1 { return 1 }
136 if cma_has(buf,len,"LIAR" as *u8)==1 { return 1 }
137 if cma_has(buf,len,"negative control" as *u8)==1 { return 1 }
138 if cma_has(buf,len,"NEG " as *u8)==1 { return 1 }
139 if cma_has(buf,len,"discriminat" as *u8)==1 { return 1 }
140 if cma_has(buf,len,"garbage" as *u8)==1 { return 1 }
141 if cma_has(buf,len,"overclaim" as *u8)==1 { return 1 }
142 if cma_has(buf,len,"must fail" as *u8)==1 { return 1 }
143 if cma_has(buf,len,"must-fail" as *u8)==1 { return 1 }
144 if cma_has(buf,len,"scores-0" as *u8)==1 { return 1 }
145 if cma_has(buf,len,"scores 0" as *u8)==1 { return 1 }
146 if cma_has(buf,len,"teeth" as *u8)==1 { return 1 }
147 if cma_has(buf,len,"refute" as *u8)==1 { return 1 }
148 if cma_has(buf,len,"adversar" as *u8)==1 { return 1 }
149 if cma_has(buf,len,"fails as it must" as *u8)==1 { return 1 }
150 if cma_has(buf,len,"red-team" as *u8)==1 { return 1 }
151 if cma_has(buf,len,"self-broken" as *u8)==1 { return 1 }
152 if cma_has(buf,len,"BROKEN" as *u8)==1 { return 1 }
153 if cma_has(buf,len,"controls held" as *u8)==1 { return 1 }
154 if cma_has(buf,len,"control failed" as *u8)==1 { return 1 }
155 if cma_has(buf,len,"known-green" as *u8)==1 { return 1 }
156 if cma_has(buf,len,"known-absent" as *u8)==1 { return 1 }
157 if cma_has(buf,len,"must not" as *u8)==1 { return 1 }
158 return 0
159}
160
161// (corroboration) does it actually COMPUTE A COMPARISON vs the reference (not just NAME one in a comment)?
162// This is the difference between "certified GROUNDED" and "name-drops a competitor" -- catches the dangerous
163// false-PASS. A real head-to-head computes a ratio/gap/delta or prints "vs <ref>".
164func cma_has_comparison(buf: *u8, len: i64) -> i64 {
165 if cma_has(buf,len,"ratio" as *u8)==1 { return 1 }
166 if cma_has(buf,len," vs " as *u8)==1 { return 1 }
167 if cma_has(buf,len,"vs " as *u8)==1 { return 1 }
168 if cma_has(buf,len," gap" as *u8)==1 { return 1 }
169 if cma_has(buf,len,"delta" as *u8)==1 { return 1 }
170 if cma_has(buf,len,"head-to-head" as *u8)==1 { return 1 }
171 if cma_has(buf,len,"compared" as *u8)==1 { return 1 }
172 if cma_has(buf,len,"against " as *u8)==1 { return 1 }
173 if cma_has(buf,len,"permille" as *u8)==1 { return 1 }
174 if cma_has(buf,len,"BEHIND" as *u8)==1 { return 1 }
175 if cma_has(buf,len,"AHEAD" as *u8)==1 { return 1 }
176 return 0
177}
178
179// audit one census: returns 1=UNGROUNDED flaw, 0=grounded/weak/no-claim, -1=missing
180func cma_audit(path: *u8, name: *u8, buf: *u8) -> i64 {
181 cma_audited = cma_audited + 1
182 let len: i64 = cma_load(path, buf)
183 if len < 0 { cma_missing = cma_missing + 1; cma_puts(" [MISS] " as *u8); cma_puts(name); cma_puts(" (file not found)\n" as *u8); return 0 - 1 }
184 let claim: i64 = cma_has_claim(buf, len)
185 if claim == 0 { cma_noclaim = cma_noclaim + 1; cma_puts(" [n/a ] " as *u8); cma_puts(name); cma_puts(" (no quality/exceed claim -> nothing to ground)\n" as *u8); return 0 }
186 let refr: i64 = cma_has_reference(buf, len)
187 let cf: i64 = cma_has_canfail(buf, len)
188 if refr == 1 { if cf == 1 {
189 // corroborate: does it actually COMPUTE the comparison, or only NAME the reference?
190 if cma_has_comparison(buf, len) == 1 {
191 cma_grounded = cma_grounded + 1
192 cma_puts(" [GRND] " as *u8); cma_puts(name); cma_puts(" claim + reference + can-fail + real comparison = GROUNDED\n" as *u8)
193 return 0
194 }
195 cma_weak = cma_weak + 1
196 cma_puts(" [WEAK] " as *u8); cma_puts(name); cma_puts(" names a reference + has a control, but NO computed comparison -> verify it actually measures the claim\n" as *u8)
197 if cma_wl != 0 {
198 var qw: i64 = 0
199 let ww: *u8 = cma_wl as *u8
200 while name[qw] != (0 as u8) { if (name[qw]&0xff) != 32 { ww[cma_wlpos]=name[qw]; cma_wlpos=cma_wlpos+1 } qw=qw+1 }
201 ww[cma_wlpos]=9 as u8; cma_wlpos=cma_wlpos+1
202 ww[cma_wlpos]=119 as u8; cma_wlpos=cma_wlpos+1 // 'w' = weak: verify it computes the comparison
203 ww[cma_wlpos]=10 as u8; cma_wlpos=cma_wlpos+1
204 }
205 return 0
206 } }
207 cma_ungrounded = cma_ungrounded + 1
208 cma_puts(" [UNGR] " as *u8); cma_puts(name); cma_puts(" CLAIM but missing:" as *u8)
209 if refr == 0 { cma_puts(" [external-reference]" as *u8) }
210 if cf == 0 { cma_puts(" [can-fail control]" as *u8) }
211 cma_puts(" -> proxy/unfalsifiable claim\n" as *u8)
212 // append to the actionable worklist (path + which leg is missing)
213 if cma_wl != 0 {
214 var q: i64 = 0
215 while name[q] != (0 as u8) { if (name[q]&0xff) != 32 { let w: *u8 = cma_wl as *u8; w[cma_wlpos]=name[q]; cma_wlpos=cma_wlpos+1 } q=q+1 }
216 let w2: *u8 = cma_wl as *u8
217 w2[cma_wlpos]=9 as u8; cma_wlpos=cma_wlpos+1 // tab
218 if refr == 0 { w2[cma_wlpos]=114 as u8; cma_wlpos=cma_wlpos+1 } // 'r' = needs reference
219 if cf == 0 { w2[cma_wlpos]=99 as u8; cma_wlpos=cma_wlpos+1 } // 'c' = needs can-fail
220 w2[cma_wlpos]=10 as u8; cma_wlpos=cma_wlpos+1 // newline
221 }
222 // record the ungrounded NAME (path, no spaces) into the set for the per-name ratchet
223 if cma_un != 0 {
224 let un: *u8 = cma_un as *u8
225 var qn: i64 = 0
226 while name[qn] != (0 as u8) { if (name[qn]&0xff) != 32 { un[cma_unpos]=name[qn]; cma_unpos=cma_unpos+1 } qn=qn+1 }
227 un[cma_unpos]=10 as u8; cma_unpos=cma_unpos+1
228 }
229 return 1
230}
231// is `name` present as a whole line in a set blob? CRLF-robust: a line boundary is \n(10) OR \r(13), so
232// a baseline rewritten with Windows CRLF still matches (the fragility the first test exposed).
233func cma_is_eol(c: i64) -> i64 { if c==10 { return 1 } if c==13 { return 1 } return 0 }
234func cma_set_has(setb: *u8, setlen: i64, name: *u8) -> i64 {
235 let nlen: i64 = cma_slen(name)
236 if nlen == 0 { return 0 }
237 var i: i64 = 0
238 while i + nlen <= setlen {
239 var at_line_start: i64 = 0
240 if i == 0 { at_line_start = 1 } else { if cma_is_eol(setb[i-1]&0xff)==1 { at_line_start = 1 } }
241 if at_line_start == 1 {
242 var m: i64 = 0; var ok: i64 = 1
243 while m < nlen { if (setb[i+m]&0xff) != (name[m]&0xff) { ok=0; m=nlen } else { m=m+1 } }
244 if ok == 1 {
245 if i+nlen == setlen { return 1 } // last line, no trailing EOL
246 if cma_is_eol(setb[i+nlen]&0xff)==1 { return 1 } // followed by \n or \r
247 }
248 }
249 i = i + 1
250 }
251 return 0
252}
253
254func main() -> i64 {
255 cma_puts("=== nx_claim_metric_audit -- CLAIM-METRIC ALIGNMENT axis (does the metric measure the CLAIM, and can it FAIL?) ===\n" as *u8)
256 cma_puts(" law: a quality/exceed CLAIM is GROUNDED only if it (A) compares a REAL external reference AND (B) has a can-fail control\n\n" as *u8)
257 let buf: *u8 = sys_mmap(CMA_BUF)
258 cma_wl = sys_mmap(CMA_BUF) as i64
259 cma_wlpos = 0
260 cma_un = sys_mmap(CMA_BUF) as i64
261 cma_unpos = 0
262
263 // ---- AUDIT the ecosystem's claim-making censuses (DATA-DRIVEN: a manifest of one census path per line,
264 // generated from the census population -> scales to the whole ecosystem, no hand-list to rot) ----
265 let man: *u8 = sys_mmap(CMA_BUF)
266 let mlen: i64 = cma_load("knowledge/status/claimaudit_manifest.txt\x00" as *u8, man)
267 if mlen <= 0 { cma_puts(" (no manifest -> auditing the built-in browser set only)\n" as *u8) }
268 let path: *u8 = sys_mmap(CMA_MAGIC_1024)
269 var i: i64 = 0
270 var p: i64 = 0
271 while i <= mlen {
272 var c: i64 = 10 // treat EOF as a final newline
273 if i < mlen { c = man[i] & 0xff }
274 if c == 10 { // end of line -> audit the accumulated path
275 if p > 0 {
276 path[p] = 0 as u8
277 if (path[0]&0xff) != 35 { cma_audit(path, path, buf) } // '#' = comment
278 }
279 p = 0
280 } else {
281 if c != 13 { if p < 1000 { path[p] = man[i] as u8; p = p + 1 } } // skip CR
282 }
283 i = i + 1
284 }
285
286 // ---- LIAR-KILL: prove the auditor DISCRIMINATES grounded from ungrounded before any verdict is trusted ----
287 // grounded anchor (real): typequality reads Chrome + has a discrimination check -> MUST be grounded
288 let lenA: i64 = cma_load("runtime/_hdl_build/nx_typequality_census.nx" as *u8, buf)
289 var anchorA_ground: i64 = 0
290 if lenA > 0 { if cma_has_claim(buf,lenA)==1 { if cma_has_reference(buf,lenA)==1 { if cma_has_canfail(buf,lenA)==1 { anchorA_ground = 1 } } } }
291 // ungrounded anchor (synthetic fixture): claim + NO reference + NO can-fail -> MUST be ungrounded
292 let lenB: i64 = cma_load("knowledge/status/_claimaudit_badfixture.txt" as *u8, buf)
293 var anchorB_ungr: i64 = 0
294 if lenB > 0 { if cma_has_claim(buf,lenB)==1 { if cma_has_reference(buf,lenB)==0 { if cma_has_canfail(buf,lenB)==0 { anchorB_ungr = 1 } } } }
295
296 var auditor_ok: i64 = 1
297 if anchorA_ground != 1 { auditor_ok = 0 }
298 if anchorB_ungr != 1 { auditor_ok = 0 }
299
300 cma_puts("\n ---- CLAIM-METRIC SCORECARD ----\n" as *u8)
301 cma_puts(" censuses audited=" as *u8); cma_putn(cma_audited)
302 cma_puts(" grounded=" as *u8); cma_putn(cma_grounded)
303 cma_puts(" weak(names-ref-no-comparison)=" as *u8); cma_putn(cma_weak)
304 cma_puts(" UNGROUNDED(flaw)=" as *u8); cma_putn(cma_ungrounded)
305 cma_puts(" no-claim=" as *u8); cma_putn(cma_noclaim)
306 cma_puts(" missing=" as *u8); cma_putn(cma_missing); cma_puts("\n" as *u8)
307
308 if auditor_ok != 1 {
309 cma_puts(" LIAR-KILL FIRED: the auditor cannot tell grounded from ungrounded (anchorA_ground=" as *u8); cma_putn(anchorA_ground)
310 cma_puts(" anchorB_ungr=" as *u8); cma_putn(anchorB_ungr); cma_puts(") -> verdict INVALID\n" as *u8)
311 cma_puts("NX-CLAIM-METRIC-AUDIT: BROKEN (do not trust)\n" as *u8)
312 sys_exit(1); return 1
313 }
314 cma_puts(" auditor liar-kill: PASS (grounded anchor reads GROUNDED, synthetic no-reference claim reads UNGROUNDED)\n" as *u8)
315 // emit the actionable worklist (path<TAB>missing-legs, one per line) for the WMS queue
316 if cma_wlpos > 0 {
317 let wfd: i64 = sys_openat_wr("knowledge/status/claim_metric_worklist.txt\x00" as *u8, 0x1a4)
318 if wfd > 0 { sys_write(wfd, cma_wl as *u8, cma_wlpos); sys_close(wfd); cma_puts(" worklist -> knowledge/status/claim_metric_worklist.txt (r=needs external-reference, c=needs can-fail control)\n" as *u8) }
319 }
320 if cma_ungrounded == 0 {
321 cma_puts("NX-CLAIM-METRIC-AUDIT GREEN: every claim-making census is GROUNDED (real reference + can-fail control)\n" as *u8)
322 } else {
323 cma_puts("NX-CLAIM-METRIC-AUDIT: " as *u8); cma_putn(cma_ungrounded); cma_puts(" UNGROUNDED claim(s) = proxy/unfalsifiable -> add a real reference + a can-fail control (each PROVEN, not asserted)\n" as *u8)
324 }
325
326 // ---- emit a surfaced HTML status (frontend-testable) ----
327 let h: *u8 = sys_mmap(CMA_MAGIC_65536)
328 var hp: i64 = 0
329 hp = cma_apps(h, hp, "<!doctype html><html><head><title>Claim-metric alignment audit</title></head><body style=\x27background:#0b1020;color:#dbe4ff;font-family:system-ui,sans-serif;padding:26px;max-width:900px;margin:auto\x27>\x00" as *u8)
330 hp = cma_apps(h, hp, "<h1>Claim–metric alignment — does the metric measure the CLAIM, and can it FAIL?</h1>\x00" as *u8)
331 hp = cma_apps(h, hp, "<p style=\x27color:#9fb2dd;line-height:1.5\x27>The sibling of “asserted, not proven.” A quality/exceed CLAIM is <b>GROUNDED</b> only if it (A) compares a REAL external reference AND (B) has a control that can score badly. Root case: the browser font — OCR proved <i>legibility</i> while “professional typeface” was claimed. Auditor is liar-killed (a synthetic no-reference claim MUST read UNGROUNDED).</p>\x00" as *u8)
332 hp = cma_apps(h, hp, "<div style=\x27display:flex;gap:14px;margin:18px 0;flex-wrap:wrap\x27>\x00" as *u8)
333 hp = cma_card(h, hp, "audited", cma_audited, "#8ab4ff")
334 hp = cma_card(h, hp, "GROUNDED (really compares)", cma_grounded, "#22c55e")
335 hp = cma_card(h, hp, "WEAK (names ref, no comparison)", cma_weak, "#f0b458")
336 hp = cma_card(h, hp, "UNGROUNDED", cma_ungrounded, "#f43f5e")
337 hp = cma_card(h, hp, "no-claim (honest)", cma_noclaim, "#9fb2dd")
338 hp = cma_apps(h, hp, "</div>\x00" as *u8)
339 // grounding RECIPE (tutor-not-doer: give owners the exact pattern, don't rewrite their organs)
340 hp = cma_apps(h, hp, "<h2 style=\x27margin-top:26px\x27>How to ground a flagged claim (the pattern <code>nx_typequality_census</code> proves)</h2>\x00" as *u8)
341 hp = cma_apps(h, hp, "<ol style=\x27color:#cfe0ff;line-height:1.7\x27><li><b>Load a REAL external reference</b> — the competitor's actual output or a ground truth (e.g. render the same input in Chrome, decode the PNG). Not your own output.</li><li><b>COMPUTE the comparison</b> — a ratio / gap / delta vs the reference (e.g. weight 812‰ vs Chrome=1000). A number that can come out bad.</li><li><b>Add a CAN-FAIL control</b> — a negative control or liar-kill that proves the metric discriminates (garbage scores 0; a known-bad input must FAIL).</li></ol>\x00" as *u8)
342 hp = cma_apps(h, hp, "<p style=\x27color:#7c8db5\x27>r = needs external reference · c = needs can-fail control · w = names a reference but doesn’t compute a comparison (verify it measures the claim). High-recall SCREEN — each is a review item, not an auto-verdict. Per-NAME ratchet: the ungrounded set is banked; CI fails only when a census NEWLY goes ungrounded (attributed by name), and is insensitive to new grounded organs. Composed into <code>nx_rung_eval</code>.</p>\x00" as *u8)
343 // embed the tiered worklist itself (self-contained dashboard)
344 hp = cma_apps(h, hp, "<h3>Worklist (" as *u8)
345 hp = cma_appn(h, hp, cma_ungrounded + cma_weak)
346 hp = cma_apps(h, hp, " items to ground)</h3><pre style=\x27background:#0f1526;border:1px solid #1e2740;border-radius:8px;padding:14px;overflow-x:auto;font-size:12px;color:#c9d6f5\x27>\x00" as *u8)
347 if cma_wl != 0 { var wi: i64 = 0; let wsrc: *u8 = cma_wl as *u8; while wi < cma_wlpos { let ch: i64 = wsrc[wi]&0xff; if ch==9 { hp=cma_apps(h,hp," → \x00" as *u8) } else { if ch==60 { hp=cma_apps(h,hp,"<\x00" as *u8) } else { h[hp]=wsrc[wi]; hp=hp+1 } } wi=wi+1 } }
348 hp = cma_apps(h, hp, "</pre>\x00" as *u8)
349 hp = cma_apps(h, hp, "</body></html>\x00" as *u8)
350 let hfd: i64 = sys_openat_wr("knowledge/status/claim_metric_audit.html\x00" as *u8, 0x1a4)
351 if hfd > 0 { sys_write(hfd, h, hp); sys_close(hfd) }
352
353 // ---- PER-NAME RATCHET (CI guardrail): the honest fix to the count-ratchet's population-sensitivity.
354 // Baseline is the SET of ungrounded census NAMES (claim_metric_baseline_set.txt). We diff it against the
355 // current ungrounded set: a name in CURRENT but not BASELINE = a census that NEWLY went ungrounded (a true
356 // regression OR a new organ shipped ungrounded) -> ATTRIBUTED + fails CI. A name in BASELINE but not
357 // CURRENT = FIXED (debt paid). Insensitive to new GROUNDED organs (population growth no longer false-fires).
358 let base: *u8 = sys_mmap(CMA_BUF)
359 let baselen: i64 = cma_load("knowledge/status/claim_metric_baseline_set.txt\x00" as *u8, base)
360 let curb: *u8 = cma_un as *u8
361 var ratchet_red: i64 = 0
362 if baselen <= 0 {
363 let bfd: i64 = sys_openat_wr("knowledge/status/claim_metric_baseline_set.txt\x00" as *u8, 0x1a4)
364 if bfd > 0 { sys_write(bfd, curb, cma_unpos); sys_close(bfd) }
365 cma_puts(" RATCHET bootstrapped: " as *u8); cma_putn(cma_ungrounded); cma_puts(" ungrounded names banked as the accepted debt SET (new names above this FAIL, by name)\n" as *u8)
366 } else {
367 // walk current ungrounded names; flag any NOT in the baseline set
368 var newc: i64 = 0
369 let nm: *u8 = sys_mmap(CMA_MAGIC_1024)
370 var i2: i64 = 0
371 var np2: i64 = 0
372 while i2 <= cma_unpos {
373 var c2: i64 = 10
374 if i2 < cma_unpos { c2 = curb[i2] & 0xff }
375 if c2 == 10 {
376 if np2 > 0 {
377 nm[np2] = 0 as u8
378 if cma_set_has(base, baselen, nm) == 0 {
379 if newc == 0 { cma_puts(" RATCHET: NEW ungrounded census(es) since baseline (attributed):\n" as *u8) }
380 cma_puts(" + " as *u8); cma_puts(nm); cma_puts("\n" as *u8); newc = newc + 1
381 }
382 }
383 np2 = 0
384 } else { if np2 < 1000 { nm[np2] = curb[i2] as u8; np2 = np2 + 1 } }
385 i2 = i2 + 1
386 }
387 // count FIXED = baseline names no longer ungrounded
388 var fixedc: i64 = 0
389 let bm: *u8 = sys_mmap(CMA_MAGIC_1024)
390 var j2: i64 = 0
391 var bp2: i64 = 0
392 while j2 <= baselen {
393 var c3: i64 = 10
394 if j2 < baselen { c3 = base[j2] & 0xff }
395 if c3 == 10 {
396 if bp2 > 0 { bm[bp2] = 0 as u8; if cma_set_has(curb, cma_unpos, bm) == 0 { fixedc = fixedc + 1 } }
397 bp2 = 0
398 } else { if bp2 < 1000 { bm[bp2] = base[j2] as u8; bp2 = bp2 + 1 } }
399 j2 = j2 + 1
400 }
401 if newc > 0 { ratchet_red = 1 }
402 else { cma_puts(" RATCHET: HELD (no census newly ungrounded by name" as *u8); if fixedc > 0 { cma_puts("; " as *u8); cma_putn(fixedc); cma_puts(" FIXED -> re-bank the baseline set to lock in" as *u8) } cma_puts(")\n" as *u8) }
403 if fixedc > 0 { if newc == 0 {
404 let bfd3: i64 = sys_openat_wr("knowledge/status/claim_metric_baseline_set.txt\x00" as *u8, 0x1a4)
405 if bfd3 > 0 { sys_write(bfd3, curb, cma_unpos); sys_close(bfd3) }
406 } }
407 }
408
409 // ---- COORDINATION: this axis's slot in the full evaluator system (composed by nx_rung_eval) ----
410 cma_puts("\n EVAL-COORD name=nx_claim_metric_audit coverage=CROSS-CUTTING tier=claim-metric-alignment audited=" as *u8)
411 cma_putn(cma_audited); cma_puts(" grounded=" as *u8); cma_putn(cma_grounded); cma_puts(" ungrounded=" as *u8); cma_putn(cma_ungrounded); cma_puts("\n" as *u8)
412 cma_puts(" ADDS to nx_rung_eval [asserted-not-proven] its SIBLING: proven-but-WRONG-property / proven-UNFALSIFIABLY. Root lesson: 'proven' must match the CLAIM.\n" as *u8)
413 if ratchet_red == 1 { cma_puts("NX-CLAIM-METRIC-AUDIT: RATCHET RED (new ungrounded claim vs baseline)\n" as *u8); sys_exit(1); return 1 }
414 sys_exit(0)
415 return 0
416}