code wiki / _hdl_build / nx_vsbest_lib.nx
nx_vsbest_lib.nx source
↩ module page · 142 lines · 7297 B
1// nx_vsbest_lib.nx -- THE COMPARATIVE AXIS: admit or refuse a vs-best-in-class claim.
2//
3// WHY THIS DID NOT EXIST AND WHY THAT MATTERED. nx_maturity_auditor defines level 4 S-CLASS as
4// TRIANGULATED PARITY vs a named best-in-class and level 5 EXCEED as a triangulated WIN. Those are
5// CLAIMS ABOUT A COMPARISON -- and there was nowhere to put one. The only thing that could reach
6// those rungs was permil_to_level awarding them from a COVERAGE PERCENTAGE (capped at PRODUCTION on
7// 2026-07-31). So the board reporting "S-class reached in 0 domains" was never evidence that nothing
8// is good; it is evidence that THE CLAIM COULD NOT BE MADE HONESTLY. This lib is the missing place.
9//
10// A claim is ADMISSIBLE only if ALL FOUR hold:
11// competitor -- a NAMED external artifact (gcc, llvm, qemu, seL4, Vortex 3.0), never "the baseline"
12// method -- how it was run, stated well enough to be RE-RUN by someone else
13// evidence -- a READABLE log in which the declared pattern ACTUALLY APPEARS
14// verdict -- behind | parity | ahead
15//
16// ★★★★★A CLAIM MISSING ANY OF THESE IS REFUSED, NOT DOWNGRADED. An unverifiable comparison is not a
17// weaker comparison, it is the ABSENCE of one -- the same DANGLING-vs-measured split em_derive_level
18// enforces for capability evidence, applied to the comparative axis.
19//
20// ★★★★★AND THE COMPARATOR MUST BE NON-EMPTY BY NAME. The corpus already banks the failure this
21// prevents: a census scored "vs 0 SOTA-src" -- an EMPTY comparator, self-referential, able only to
22// drift upward. Comparing against nothing is how 1000-permil coverage coexists with PROVEN 0/40.
23// license_tier: ORIGINAL No hw writes (Rule 26).
24import "nx_ecomat_lib.nx"
25
26const VB_BEHIND: i64 = 0
27const VB_PARITY: i64 = 1
28const VB_AHEAD: i64 = 2
29
30// refusal codes -- distinct so the caller learns WHICH leg failed, never a bare no
31const VB_OK: i64 = 0
32const VB_NO_COMPETITOR: i64 = 0 - 1
33const VB_NO_METHOD: i64 = 0 - 2
34const VB_NO_EVIDENCE: i64 = 0 - 3
35const VB_PATTERN_ABSENT: i64 = 0 - 4
36const VB_BAD_VERDICT: i64 = 0 - 5
37const VB_MIN_METHOD_LEN: i64 = 12
38const VB_NO_SCOPE: i64 = 0 - 6
39const VB_SCOPE_NARROWER: i64 = 0 - 7
40
41// ★★★★★A CLAIM CARRIES A SCOPE, AND A NARROW WIN IS NOT A DOMAIN WIN.
42// Found the moment the FIRST real comparison was attempted: our SPIR-V emitter is validated by the
43// Khronos reference validator (spirv-val, SPIRV-Tools v2025.1, verdict=VALID, full battery). That is
44// genuine triangulated PARITY -- but on SPIR-V VALIDITY, not on the gpu domain, which also spans a
45// 3D pipeline, tensor cores and real-silicon submit. Granting the DOMAIN S-CLASS from a
46// conformance-axis parity would be the same overclaim as minting it from a coverage percentage.
47// So scope is a FIFTH MANDATORY LEG, and a claim lifts a domain's level ONLY when its scope IS that
48// domain. A narrower scope is still ADMITTED and recorded -- it is real evidence and must not be
49// discarded -- but it earns PRODUCTION, not a comparative rung.
50func vb_scope_covers(scope: *u8, domain: *u8) -> i64 {
51 if (scope as i64) == 0 { return 0 }
52 if scope[0] == (0 as u8) { return 0 }
53 if el_streq(scope, domain) == 1 { return 1 }
54 return 0
55}
56
57func vb_verdict_parse(s: *u8) -> i64 {
58 if el_streq(s, "behind" as *u8) == 1 { return VB_BEHIND }
59 if el_streq(s, "parity" as *u8) == 1 { return VB_PARITY }
60 if el_streq(s, "ahead" as *u8) == 1 { return VB_AHEAD }
61 return 0 - 1
62}
63
64func vb_verdict_label(v: i64) -> *u8 {
65 if v == VB_BEHIND { return "behind" as *u8 }
66 if v == VB_PARITY { return "parity" as *u8 }
67 if v == VB_AHEAD { return "ahead" as *u8 }
68 return "INVALID" as *u8
69}
70
71// The level a verdict EARNS. behind grants nothing above PRODUCTION -- losing to the best in class
72// is not a comparative achievement, so it must not lift the capability grade at all.
73func vb_level_for(v: i64) -> i64 {
74 if v == VB_PARITY { return MAT_SCLASS }
75 if v == VB_AHEAD { return MAT_EXCEED }
76 return MAT_PRODUCTION
77}
78
79// A competitor name must be a REAL external artifact. Empty, or the self-referential placeholders
80// the corpus caught scoring "vs 0 SOTA-src", are refused: comparing against nothing can only drift up.
81func vb_competitor_ok(c: *u8) -> i64 {
82 if (c as i64) == 0 { return 0 }
83 if c[0] == (0 as u8) { return 0 }
84 if el_streq(c, "none" as *u8) == 1 { return 0 }
85 if el_streq(c, "n/a" as *u8) == 1 { return 0 }
86 if el_streq(c, "baseline" as *u8) == 1 { return 0 }
87 if el_streq(c, "self" as *u8) == 1 { return 0 }
88 if el_streq(c, "ourselves" as *u8) == 1 { return 0 }
89 if el_streq(c, "0" as *u8) == 1 { return 0 }
90 return 1
91}
92
93// ADMIT or REFUSE. out[0]=verdict out[1]=earned level out[2]=evidence bytes read.
94// Every leg is checked against reality: the evidence log is actually READ and the declared pattern
95// must actually APPEAR in it. A pointer to a log that does not contain what it claims is the
96// dangling-evidence defect, and it is refused rather than believed.
97// out[3] = 1 when the claim's SCOPE covers the whole domain, 0 when it is narrower. A narrower
98// claim is still ADMITTED (real evidence is never discarded) but earns PRODUCTION, not 4/5.
99func vb_admit_scoped(competitor: *u8, method: *u8, evlog: *u8, evpat: *u8, verdict: *u8, scope: *u8, domain: *u8, out: *i64) -> i64 {
100 let rc: i64 = vb_admit(competitor, method, evlog, evpat, verdict, out)
101 if rc != VB_OK { return rc }
102 if (scope as i64) == 0 { out[1] = MAT_PRODUCTION; return VB_NO_SCOPE }
103 if scope[0] == (0 as u8) { out[1] = MAT_PRODUCTION; return VB_NO_SCOPE }
104 if vb_scope_covers(scope, domain) == 1 {
105 out[3] = 1
106 return VB_OK
107 }
108 // Admitted, recorded, but NOT domain-lifting: a conformance-axis parity is not a domain parity.
109 out[3] = 0
110 out[1] = MAT_PRODUCTION
111 return VB_SCOPE_NARROWER
112}
113
114func vb_admit(competitor: *u8, method: *u8, evlog: *u8, evpat: *u8, verdict: *u8, out: *i64) -> i64 {
115 out[0] = 0 - 1
116 out[1] = MAT_PRODUCTION
117 out[2] = 0
118 out[3] = 0
119 if vb_competitor_ok(competitor) == 0 { return VB_NO_COMPETITOR }
120 if (method as i64) == 0 { return VB_NO_METHOD }
121 if el_len(method) < VB_MIN_METHOD_LEN { return VB_NO_METHOD }
122 let v: i64 = vb_verdict_parse(verdict)
123 if v < 0 { return VB_BAD_VERDICT }
124 let szp: *i64 = sys_mmap(16) as *i64
125 let eb: *u8 = ss_readall(evlog, szp)
126 var en: i64 = szp[0]
127 if en <= 0 { return VB_NO_EVIDENCE }
128 out[2] = en
129 if el_contains(eb, en, evpat) == 0 { return VB_PATTERN_ABSENT }
130 out[0] = v
131 out[1] = vb_level_for(v)
132 return VB_OK
133}
134
135func vb_refusal_label(rc: i64) -> *u8 {
136 if rc == VB_OK { return "ADMITTED" as *u8 }
137 if rc == VB_NO_COMPETITOR { return "REFUSED: competitor is empty or self-referential -- name a real external artifact" as *u8 }
138 if rc == VB_NO_METHOD { return "REFUSED: method missing or too short to be re-run by anyone else" as *u8 }
139 if rc == VB_NO_EVIDENCE { return "REFUSED: evidence log missing or empty -- an unreadable witness is NO witness" as *u8 }
140 if rc == VB_PATTERN_ABSENT { return "REFUSED: the declared pattern does NOT appear in the evidence log" as *u8 }
141 return "REFUSED: verdict must be behind|parity|ahead" as *u8
142}