code wiki / _hdl_build / nx_vsgap.nx
nx_vsgap.nx source
↩ module page · 140 lines · 6366 B
1// nx_vsgap.nx -- THE COMPARISON GAP: per domain, what stands between here and a legitimate S-CLASS.
2//
3// The board reads "S-class reached in 0 domains". After today that zero is TRUSTWORTHY -- four
4// fabrication routes are closed, so it means no domain has EARNED a comparative rung, not that the
5// claim was unmakeable. But a trustworthy zero is still just a verdict. This turns it into a WORK
6// LIST: for every domain, does a domain-SCOPED admitted claim exist, is there only narrower
7// evidence, or is there nothing at all?
8//
9// ★★★★★A GAP REPORT IS WORTH MORE THAN A GRADE. "0/26 at S-class" tells you where you are; "these 26
10// comparisons, each against this named competitor, would change it" tells you what to do. The first
11// invites arguing about the number, the second cannot be argued with -- you either ran it or not.
12// license_tier: ORIGINAL No hw writes (Rule 26).
13import "nx_vsbest_lib.nx"
14
15const VG_LOG: *u8 = "knowledge/status/vsbest_claims.log"
16const VG_NAME_CAP: i64 = 128
17
18// Does the claims ledger hold a DOMAIN-LIFTING claim for this domain? We require both the exact
19// `domain=<name> ` token AND `domain_lifting=1` on the same line -- a narrow claim mentioning the
20// domain must not read as coverage of it, which is the whole point of the scope leg.
21func vg_has_lifting(buf: *u8, n: i64, domain: *u8) -> i64 {
22 var p: i64 = 0
23 while p < n {
24 var e: i64 = p
25 var go: i64 = 1
26 while go == 1 {
27 if e >= n { go = 0 } else { if (buf[e] as i64) == 10 { go = 0 } else { e = e + 1 } }
28 }
29 if e > p {
30 let dtok: *u8 = sys_mmap(VG_NAME_CAP + 16)
31 var o: i64 = 0
32 let pre: *u8 = " domain=" as *u8
33 var q: i64 = 0
34 while pre[q] != (0 as u8) { dtok[o] = pre[q]; o = o + 1; q = q + 1 }
35 q = 0
36 while domain[q] != (0 as u8) { if o < VG_NAME_CAP { dtok[o] = domain[q]; o = o + 1 } q = q + 1 }
37 dtok[o] = 32 as u8
38 dtok[o+1] = 0 as u8
39 var hit: i64 = 0
40 var i: i64 = p
41 let dl: i64 = el_len(dtok)
42 while i + dl <= e { if el_match(buf, i, dtok, dl) == 1 { hit = 1 } i = i + 1 }
43 if hit == 1 {
44 var lift: i64 = 0
45 let lt: *u8 = "domain_lifting=1" as *u8
46 let ll: i64 = el_len(lt)
47 var j: i64 = p
48 while j + ll <= e { if el_match(buf, j, lt, ll) == 1 { lift = 1 } j = j + 1 }
49 if lift == 1 { return 1 }
50 }
51 }
52 p = e + 1
53 }
54 return 0
55}
56
57// Any claim at all for this domain, lifting or not -- narrower evidence is still evidence and the
58// report must not treat "we measured something" as "we measured nothing".
59func vg_has_any(buf: *u8, n: i64, domain: *u8) -> i64 {
60 let dtok: *u8 = sys_mmap(VG_NAME_CAP + 16)
61 var o: i64 = 0
62 let pre: *u8 = " domain=" as *u8
63 var q: i64 = 0
64 while pre[q] != (0 as u8) { dtok[o] = pre[q]; o = o + 1; q = q + 1 }
65 q = 0
66 while domain[q] != (0 as u8) { if o < VG_NAME_CAP { dtok[o] = domain[q]; o = o + 1 } q = q + 1 }
67 dtok[o] = 32 as u8
68 dtok[o+1] = 0 as u8
69 if el_contains(buf, n, dtok) == 1 { return 1 }
70 return 0
71}
72
73func main(argc: i64, argv: *i64) -> i64 {
74 var store: *u8 = ECOMAT_STORE
75 if argc >= 2 { store = argv[1] as *u8 }
76
77 _p("=== NX-VSGAP: what stands between each domain and a legitimate S-CLASS ===\n" as *u8)
78 let szp: *i64 = sys_mmap(16) as *i64
79 let cb: *u8 = ss_readall(VG_LOG, szp)
80 var cn: i64 = szp[0]
81 if cn < 0 { cn = 0 }
82 _p(" claims ledger: " as *u8); _p(VG_LOG); _p(" bytes=" as *u8); _fn(1, cn); _p("\n\n" as *u8)
83
84 let h: *i64 = ss_open(store)
85 if (h as i64) == 0 { _p("NX-VSGAP verdict=RED reason=no-store\n" as *u8); sys_exit(101); return 101 }
86 let pq: *i64 = sys_mmap(16) as *i64
87 let lq: *i64 = sys_mmap(16) as *i64
88 let dom: *u8 = sys_mmap(ECOMAT_DOM_CAP)
89 var k: i64 = 0
90 var go: i64 = 1
91 var n_none: i64 = 0
92 var n_narrow: i64 = 0
93 var n_lift: i64 = 0
94 while go == 1 {
95 let key: *u8 = sys_mmap(64)
96 ec_key(k, key)
97 if ss_hget(h, key, pq, lq) == 1 {
98 let v: *u8 = pq[0] as *u8
99 ec_str(v, 0, dom, ECOMAT_DOM_CAP)
100 var cur: i64 = ec_cur(v)
101 let tout: *i64 = sys_mmap(16) as *i64
102 let dl: i64 = em_domain_level(v, tout)
103 if tout[0] != 0 { cur = dl }
104 _p(" " as *u8); _p(dom)
105 var pad: i64 = el_len(dom)
106 while pad < 24 { _p(" " as *u8); pad = pad + 1 }
107 _p(mat_label(cur))
108 var pad2: i64 = el_len(mat_label(cur))
109 while pad2 < 12 { _p(" " as *u8); pad2 = pad2 + 1 }
110 if cn > 0 {
111 if vg_has_lifting(cb, cn, dom) == 1 {
112 _p(" DOMAIN-SCOPED CLAIM PRESENT -- comparative rung is earned\n" as *u8)
113 n_lift = n_lift + 1
114 } else {
115 if vg_has_any(cb, cn, dom) == 1 {
116 _p(" narrow evidence only -- needs a claim SCOPED TO THE WHOLE DOMAIN\n" as *u8)
117 n_narrow = n_narrow + 1
118 } else {
119 _p(" NO CLAIM -- name a competitor, state a re-runnable method, produce a log\n" as *u8)
120 n_none = n_none + 1
121 }
122 }
123 } else {
124 _p(" NO CLAIM (ledger empty)\n" as *u8)
125 n_none = n_none + 1
126 }
127 k = k + 1
128 } else { go = 0 }
129 }
130 _p("\n-- THE GAP --\n" as *u8)
131 _p(" domain-scoped claims (earn a comparative rung): " as *u8); _fn(1, n_lift); _p("\n" as *u8)
132 _p(" narrow evidence only (real, but earns PRODUCTION): " as *u8); _fn(1, n_narrow); _p("\n" as *u8)
133 _p(" no comparison at all: " as *u8); _fn(1, n_none); _p("\n\n" as *u8)
134 _p(" Each `no claim` row is ONE runnable job: pick the named best-in-class, run the same\n" as *u8)
135 _p(" workload on both, keep the log, then `nx_vsbest <domain> <domain> <competitor> ...`.\n" as *u8)
136 _p(" A claim whose scope IS the domain is the ONLY thing that moves S-class off zero.\n" as *u8)
137 _p("NX-VSGAP verdict=GREEN (gap enumerated from the store and the claims ledger)\n" as *u8)
138 sys_exit(0)
139 return 0
140}