code wiki / _hdl_build / nx_suitebench.nx
nx_suitebench.nx source
↩ module page · 357 lines · 17456 B
1// nx_suitebench.nx -- THE SUITE RULER. Operator 2026-07-25: "get our website components like opaque,
2// personal calendar, shared calendar, personal gallery, shared gallery, personal contact info, shared
3// contact info, digital gifts, etc above telegram discord etc ... benchmark and make our ux easier and
4// keep it web app based so anyone with a browser can use it."
5//
6// WHY A RULER FIRST. The existing instruments cannot answer that request. nx_connect_maturity grades 16
7// MESSAGING axes and has no row at all for calendar, gallery, contact info or gifts -- the operator's whole
8// component list is UNMEASURED there. nx_connect_h2h_exceed grades 4 integrity axes. Neither can say which
9// component to build next, so the build order would be taste. This ruler makes it a measurement.
10//
11// THE THREE RULES THAT KEEP IT HONEST (each is mechanical, none is a promise):
12// 1. OUR side goes through hg_grade, the shared cynical bar. A stub-tell in the evidence caps the row at
13// STUB and a REAL claim without an active reality token caps at PARTIAL. Wording cannot lift a toy.
14// 2. THEIR side must be CITED. Every "the incumbent HAS this" cell names a file and a literal phrase, and
15// the phrase is searched in the banked bytes at run time. One uncited claim turns the whole ruler RED.
16// An incumbent fact I cannot cite is a fact I am not allowed to assert.
17// 3. ONLY EXT CELLS COUNT. Parity and beat are computed over cells where an incumbent actually HAS the
18// capability. Cells they lack are excluded, so we can never look good by scoring ourselves against a
19// capability nobody ships. Unmeasured cells are excluded AND counted AND printed, so the instrument
20// declares its own blind spots rather than hiding them inside a clean percentage.
21//
22// Rows are DATA (knowledge/registry/suitebench.axes + .rivals), so a new axis needs no rebuild (rule 11).
23// The gap_queue is COMPUTED -- rank = (how many incumbents ship it) * (how far short we are) -- so the
24// build order falls out of the measurement instead of being asserted by the author.
25//
26// nx_suitebench human-readable table + summary
27// nx_suitebench --json machine JSON for the page emitter and MCP callers
28//
29// license_tier: ORIGINAL expect_exit: 0
30import "nx_suitebench_lib.nx"
31import "nx_honesty_grade_lib.nx"
32
33const SB_MAXAX: i64 = 64
34const SB_MAXRV: i64 = 512
35const SB_AXBUF: i64 = 65536
36const SB_RVBUF: i64 = 65536
37const SB_CORPUS: i64 = 1048576
38const SB_CACHE: i64 = 12
39const SB_PATH: i64 = 512
40
41func sb_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
42func sb_wn(v: i64) -> i64 {
43 let bb: *u8=sys_mmap(28); var m: i64=v
44 if m<0 { m=0-m; sys_write(1,"-" as *u8,1) }
45 let t: *u8=sys_mmap(28); var k: i64=0
46 if m==0 { t[0]=48 as u8; k=1 }
47 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 }
48 var i: i64=0
49 while i<k { bb[i]=t[k-1-i]; i=i+1 }
50 sys_write(1,bb,k); return 0
51}
52// pad a label to width w so the table lines up without a formatter
53func sb_pad(s: *u8, w: i64) -> i64 {
54 sb_w(s)
55 var n: i64 = sb_len(s)
56 while n<w { sb_w(" " as *u8); n=n+1 }
57 return 0
58}
59
60// whole-file read into buf; returns bytes (0 if the file will not open)
61// literal substring search over n bytes
62
63// Split one '|'-separated line IN PLACE: every separator and the newline become NUL, so each field is a
64// normal C string pointing into the buffer -- no copying, no second allocation.
65// Returns the number of fields found; fld[] receives the field pointers.
66
67func main(argc: i64, argv: *i64) -> i64 {
68 var want_json: i64 = 0
69 if argc>1 { if sb_eq(argv[1] as *u8, "--json" as *u8)==1 { want_json=1 } }
70
71 // ---- load the two data planes ----
72 let axbuf: *u8 = sys_mmap(SB_AXBUF)
73 let rvbuf: *u8 = sys_mmap(SB_RVBUF)
74 let scratch: *u8 = sys_mmap(SB_PATH)
75 let n_ax: i64 = sb_read_rooted("knowledge/registry/suitebench.axes" as *u8, axbuf, SB_AXBUF, scratch)
76 let n_rv: i64 = sb_read_rooted("knowledge/registry/suitebench.rivals" as *u8, rvbuf, SB_RVBUF, scratch)
77 // ask separately WHERE the evidence answered from, into its own probe buffer -- reusing axbuf here
78 // would overwrite the rows we are about to parse
79 let probe: *u8 = sys_mmap(SB_PATH)
80 let evroot: i64 = sb_which_root("knowledge/registry/suitebench.axes" as *u8, scratch, probe, SB_PATH)
81 if n_ax<=0 { sb_w("SUITEBENCH RED: knowledge/registry/suitebench.axes unreadable -- fail loud\n" as *u8); sys_exit(1) }
82 if n_rv<=0 { sb_w("SUITEBENCH RED: knowledge/registry/suitebench.rivals unreadable -- fail loud\n" as *u8); sys_exit(1) }
83
84 let ax_id: **u8 = sys_mmap(8*SB_MAXAX) as **u8
85 let ax_grp: **u8 = sys_mmap(8*SB_MAXAX) as **u8
86 let ax_ev: **u8 = sys_mmap(8*SB_MAXAX) as **u8
87 let ax_claim: *i64 = sys_mmap(8*SB_MAXAX) as *i64
88 let ax_honest: *i64 = sys_mmap(8*SB_MAXAX) as *i64
89 let ax_has: *i64 = sys_mmap(8*SB_MAXAX) as *i64
90 let ax_unk: *i64 = sys_mmap(8*SB_MAXAX) as *i64
91 let ax_lack: *i64 = sys_mmap(8*SB_MAXAX) as *i64
92 let ax_op: *i64 = sys_mmap(8*SB_MAXAX) as *i64
93 var nax: i64=0
94 var downgrades: i64=0
95 var op_axes: i64=0
96
97 let fld: **u8 = sys_mmap(8*SB_NFIELD) as **u8
98 var p: i64=0
99 while p<n_ax {
100 var e: i64=p
101 while e<n_ax { if axbuf[e]==(10 as u8) { break } e=e+1 }
102 if axbuf[p]!=(35 as u8) {
103 if e>p {
104 let nf: i64 = sb_split(axbuf, p, e, fld)
105 if nf>=5 {
106 if nax<SB_MAXAX {
107 ax_id[nax]=fld[0]; ax_grp[nax]=fld[1]
108 let op: i64 = sb_atoi(fld[2])
109 let claimed: i64 = sb_atoi(fld[3])
110 ax_ev[nax]=fld[4]
111 ax_op[nax]=op
112 ax_claim[nax]=claimed
113 if op==1 { op_axes=op_axes+1 }
114 let honest: i64 = hg_grade(claimed, fld[4])
115 ax_honest[nax]=honest
116 if honest<claimed { downgrades=downgrades+1 }
117 ax_has[nax]=0; ax_unk[nax]=0; ax_lack[nax]=0
118 nax=nax+1
119 }
120 }
121 }
122 }
123 p=e+1
124 }
125
126 // ---- rivals: every HAS cell must prove itself against banked bytes ----
127 let rv_ax: **u8 = sys_mmap(8*SB_MAXRV) as **u8
128 let rv_who: **u8 = sys_mmap(8*SB_MAXRV) as **u8
129 let rv_file: **u8 = sys_mmap(8*SB_MAXRV) as **u8
130 let rv_ph: **u8 = sys_mmap(8*SB_MAXRV) as **u8
131 let rv_state: *i64 = sys_mmap(8*SB_MAXRV) as *i64
132 let rv_cited: *i64 = sys_mmap(8*SB_MAXRV) as *i64
133 var nrv: i64=0
134
135 p=0
136 while p<n_rv {
137 var e: i64=p
138 while e<n_rv { if rvbuf[e]==(10 as u8) { break } e=e+1 }
139 if rvbuf[p]!=(35 as u8) {
140 if e>p {
141 let nf: i64 = sb_split(rvbuf, p, e, fld)
142 if nf>=3 {
143 if nrv<SB_MAXRV {
144 rv_ax[nrv]=fld[0]; rv_who[nrv]=fld[1]
145 rv_state[nrv]=sb_atoi(fld[2])
146 if nf>=5 { rv_file[nrv]=fld[3]; rv_ph[nrv]=fld[4] }
147 else { rv_file[nrv]="" as *u8; rv_ph[nrv]="" as *u8 }
148 rv_cited[nrv]=0
149 nrv=nrv+1
150 }
151 }
152 }
153 }
154 p=e+1
155 }
156
157 // corpus cache: read each distinct file ONCE, then answer every citation from memory
158 let cch_name: **u8 = sys_mmap(8*SB_CACHE) as **u8
159 let cch_buf: **u8 = sys_mmap(8*SB_CACHE) as **u8
160 let cch_len: *i64 = sys_mmap(8*SB_CACHE) as *i64
161 var ncch: i64=0
162 var uncited: i64=0
163
164 var i: i64=0
165 while i<nrv {
166 if rv_state[i]==SB_HAS {
167 var slot: i64=-1
168 var c: i64=0
169 while c<ncch { if sb_eq(cch_name[c], rv_file[i])==1 { slot=c; c=ncch } else { c=c+1 } }
170 if slot<0 {
171 if ncch<SB_CACHE {
172 let cb: *u8 = sys_mmap(SB_CORPUS)
173 let cl: i64 = sb_read_rooted(rv_file[i], cb, SB_CORPUS, scratch)
174 cch_name[ncch]=rv_file[i]; cch_buf[ncch]=cb; cch_len[ncch]=cl
175 slot=ncch; ncch=ncch+1
176 }
177 }
178 if slot>=0 {
179 if cch_len[slot]>0 { rv_cited[i]=sb_find(cch_buf[slot], cch_len[slot], rv_ph[i]) }
180 }
181 if rv_cited[i]==0 { uncited=uncited+1 }
182 }
183 i=i+1
184 }
185
186 // ---- fold rival cells onto their axis ----
187 i=0
188 while i<nrv {
189 var a: i64=0
190 while a<nax {
191 if sb_eq(rv_ax[i], ax_id[a])==1 {
192 if rv_state[i]==SB_HAS { if rv_cited[i]==1 { ax_has[a]=ax_has[a]+1 } }
193 if rv_state[i]==SB_UNKNOWN { ax_unk[a]=ax_unk[a]+1 }
194 if rv_state[i]==SB_LACKS { ax_lack[a]=ax_lack[a]+1 }
195 a=nax
196 } else { a=a+1 }
197 }
198 i=i+1
199 }
200
201 // ---- the head-to-head math, over EXT cells only ----
202 var ext_cells: i64=0
203 var parity_cells: i64=0
204 var beat_cells: i64=0
205 var unk_cells: i64=0
206 var moat_axes: i64=0
207 var lvl_sum: i64=0
208 i=0
209 while i<nax {
210 lvl_sum=lvl_sum+ax_honest[i]
211 ext_cells=ext_cells+ax_has[i]
212 unk_cells=unk_cells+ax_unk[i]
213 if ax_honest[i]>=SB_PARITY { parity_cells=parity_cells+ax_has[i] }
214 if ax_honest[i]==SB_MAXLVL { beat_cells=beat_cells+ax_has[i] }
215 if ax_has[i]==0 { if ax_unk[i]==0 { if ax_honest[i]>=SB_PARITY { moat_axes=moat_axes+1 } } }
216 i=i+1
217 }
218 var parity_permil: i64=0
219 var beat_permil: i64=0
220 if ext_cells>0 { parity_permil=(parity_cells*1000)/ext_cells; beat_permil=(beat_cells*1000)/ext_cells }
221 let readiness: i64 = hg_readiness(lvl_sum, nax)
222
223 // ---- gap_queue. Two sort keys, deliberately NOT blended into one weighted number: nobody could
224 // justify the weight, and an unjustifiable constant is how taste sneaks back in dressed as arithmetic.
225 // KEY 1 (structural): did the operator name this component? Their brief is the authority on WHAT.
226 // KEY 2 (measured): (incumbents_shipping + 1) * our shortfall. The ruler is the authority on HOW FAR.
227 // An axis enters the queue if we are short AND (someone ships it OR the operator asked for it).
228 let gq: *i64 = sys_mmap(8*SB_MAXAX) as *i64
229 let gs: *i64 = sys_mmap(8*SB_MAXAX) as *i64
230 let go: *i64 = sys_mmap(8*SB_MAXAX) as *i64
231 var ngq: i64=0
232 i=0
233 while i<nax {
234 let short: i64 = SB_MAXLVL - ax_honest[i]
235 if short>0 {
236 var admit: i64=0
237 if ax_has[i]>0 { admit=1 }
238 if ax_op[i]==1 { admit=1 }
239 if admit==1 {
240 gq[ngq]=i; gs[ngq]=(ax_has[i]+1)*short; go[ngq]=ax_op[i]; ngq=ngq+1
241 }
242 }
243 i=i+1
244 }
245 // selection sort: operator-named first, then by measured rank. Ties keep file order, so the queue is
246 // byte-identical run to run -- a build order that reshuffles itself is not a build order.
247 var s: i64=0
248 while s<ngq {
249 var best: i64=s
250 var t: i64=s+1
251 while t<ngq {
252 var better: i64=0
253 if go[t]>go[best] { better=1 }
254 if go[t]==go[best] { if gs[t]>gs[best] { better=1 } }
255 if better==1 { best=t }
256 t=t+1
257 }
258 let ti: i64=gq[s]; let ts: i64=gs[s]; let to: i64=go[s]
259 gq[s]=gq[best]; gs[s]=gs[best]; go[s]=go[best]
260 gq[best]=ti; gs[best]=ts; go[best]=to
261 s=s+1
262 }
263
264 if want_json==1 {
265 sb_w("{\x22organ\x22:\x22nx_suitebench\x22,\x22axes\x22:" as *u8); sb_wn(nax)
266 sb_w(",\x22rival_cells\x22:" as *u8); sb_wn(nrv)
267 sb_w(",\x22ext_cells\x22:" as *u8); sb_wn(ext_cells)
268 sb_w(",\x22parity_cells\x22:" as *u8); sb_wn(parity_cells)
269 sb_w(",\x22beat_cells\x22:" as *u8); sb_wn(beat_cells)
270 sb_w(",\x22unmeasured_cells\x22:" as *u8); sb_wn(unk_cells)
271 sb_w(",\x22parity_permil\x22:" as *u8); sb_wn(parity_permil)
272 sb_w(",\x22beat_permil\x22:" as *u8); sb_wn(beat_permil)
273 sb_w(",\x22readiness_permil\x22:" as *u8); sb_wn(readiness)
274 sb_w(",\x22moat_axes\x22:" as *u8); sb_wn(moat_axes)
275 sb_w(",\x22author_downgrades\x22:" as *u8); sb_wn(downgrades)
276 sb_w(",\x22uncited_claims\x22:" as *u8); sb_wn(uncited)
277 sb_w(",\x22evidence_root\x22:\x22" as *u8); sb_w(sb_root(evroot)); sb_w("\x22" as *u8)
278 sb_w(",\x22rows\x22:[" as *u8)
279 i=0
280 while i<nax {
281 if i>0 { sb_w("," as *u8) }
282 sb_w("{\x22axis\x22:\x22" as *u8); sb_w(ax_id[i])
283 sb_w("\x22,\x22group\x22:\x22" as *u8); sb_w(ax_grp[i])
284 sb_w("\x22,\x22ours\x22:" as *u8); sb_wn(ax_honest[i])
285 sb_w(",\x22claimed\x22:" as *u8); sb_wn(ax_claim[i])
286 sb_w(",\x22operator_named\x22:" as *u8); sb_wn(ax_op[i])
287 sb_w(",\x22incumbents_shipping\x22:" as *u8); sb_wn(ax_has[i])
288 sb_w(",\x22unmeasured\x22:" as *u8); sb_wn(ax_unk[i])
289 sb_w("}" as *u8)
290 i=i+1
291 }
292 sb_w("],\x22gap_queue\x22:[" as *u8)
293 i=0
294 while i<ngq {
295 if i>0 { sb_w("," as *u8) }
296 sb_w("{\x22axis\x22:\x22" as *u8); sb_w(ax_id[gq[i]])
297 sb_w("\x22,\x22operator_named\x22:" as *u8); sb_wn(go[i])
298 sb_w(",\x22rank\x22:" as *u8); sb_wn(gs[i])
299 sb_w("}" as *u8)
300 i=i+1
301 }
302 sb_w("],\x22method\x22:\x22ours is hg_grade(claim,evidence) so wording cannot lift a toy. an incumbent cell counts only if its literal phrase is FOUND in the banked corpus at run time; one uncited claim is RED. parity and beat divide by EXT cells only (cells an incumbent actually ships), so a capability nobody ships cannot flatter us. unmeasured cells are excluded from both sides and reported. gap_queue rank = incumbents_shipping * (3 - ours).\x22}\n" as *u8)
303 if uncited>0 { sys_exit(1) }
304 sys_exit(0)
305 }
306
307 sb_w("=== nx_suitebench -- the family suite measured against Telegram / Discord / WhatsApp / Google / iCloud ===\n" as *u8)
308 sb_w("levels: 0 ABSENT 1 STUB 2 PARTIAL 3 REAL (ours = what the EVIDENCE earns, not what I claimed)\n" as *u8)
309 sb_w(" axis group ours ship unk note\n" as *u8)
310 i=0
311 while i<nax {
312 sb_w(" " as *u8); sb_pad(ax_id[i], 20); sb_pad(ax_grp[i], 11)
313 sb_w(" " as *u8)
314 if ax_honest[i]==0 { sb_w("ABSENT " as *u8) }
315 if ax_honest[i]==1 { sb_w("STUB " as *u8) }
316 if ax_honest[i]==2 { sb_w("PARTIAL" as *u8) }
317 if ax_honest[i]==3 { sb_w("REAL " as *u8) }
318 sb_w(" " as *u8); sb_wn(ax_has[i])
319 sb_w(" " as *u8); sb_wn(ax_unk[i])
320 if ax_honest[i]<ax_claim[i] { sb_w(" (author claimed higher; downgraded)" as *u8) }
321 if ax_has[i]==0 { if ax_unk[i]==0 { if ax_honest[i]>=SB_PARITY { sb_w(" (MOAT: nobody measured ships this)" as *u8) } } }
322 sb_w("\n" as *u8)
323 i=i+1
324 }
325 sb_w("\n axes=" as *u8); sb_wn(nax)
326 sb_w(" rival cells=" as *u8); sb_wn(nrv)
327 sb_w(" EXT (incumbent actually ships)=" as *u8); sb_wn(ext_cells)
328 sb_w(" UNMEASURED=" as *u8); sb_wn(unk_cells); sb_w("\n" as *u8)
329 sb_w(" PARITY-OR-BETTER on EXT cells = " as *u8); sb_wn(parity_cells); sb_w("/" as *u8); sb_wn(ext_cells)
330 sb_w(" = " as *u8); sb_wn(parity_permil); sb_w("/1000\n" as *u8)
331 sb_w(" BEAT (ours REAL) on EXT cells = " as *u8); sb_wn(beat_cells); sb_w("/" as *u8); sb_wn(ext_cells)
332 sb_w(" = " as *u8); sb_wn(beat_permil); sb_w("/1000\n" as *u8)
333 sb_w(" suite readiness = " as *u8); sb_wn(readiness); sb_w("/1000 moat axes = " as *u8); sb_wn(moat_axes)
334 sb_w(" author downgrades caught by the bar = " as *u8); sb_wn(downgrades); sb_w("\n" as *u8)
335 sb_w(" operator-named components = " as *u8); sb_wn(op_axes); sb_w(" of " as *u8); sb_wn(nax); sb_w("\n" as *u8)
336 sb_w(" evidence root = '" as *u8); sb_w(sb_root(evroot))
337 sb_w("' (the ruler names where it looked, so a moved corpus never reads as a regression)\n" as *u8)
338 sb_w("\n BUILD ORDER -- operator-named components first, then measured shortfall. Not the author's taste.\n" as *u8)
339 i=0
340 while i<ngq {
341 sb_w(" " as *u8); sb_wn(i+1); sb_w(". " as *u8); sb_pad(ax_id[gq[i]], 20)
342 if go[i]==1 { sb_w("[operator asked] " as *u8) } else { sb_w(" " as *u8) }
343 sb_w("rank=" as *u8); sb_wn(gs[i])
344 sb_w(" (" as *u8); sb_wn(ax_has[gq[i]]); sb_w(" incumbents ship it, we are " as *u8)
345 sb_wn(SB_MAXLVL-ax_honest[gq[i]]); sb_w(" levels short)\n" as *u8)
346 i=i+1
347 }
348 sb_w("\n uncited incumbent claims = " as *u8); sb_wn(uncited)
349 sb_w(" (any value above zero is RED: a fact I cannot cite is a fact I may not assert)\n" as *u8)
350 if uncited>0 {
351 sb_w("VERDICT: RED\n" as *u8)
352 sys_exit(1)
353 }
354 sb_w("VERDICT: verdict=GREEN (every incumbent cell cited in banked bytes; our side graded by the cynical bar)\n" as *u8)
355 sys_exit(0)
356 return 0
357}