nx_emitter_bench.nx source
↩ module page · 114 lines · 6937 B
1// nx_emitter_bench.nx -- BENCHMARK the autonomous UI emitters on their ACTUAL emitted output.
2// Operator: "benchmark the autonomous site emitter and template generator ... so we get s class exceeds."
3// For each emitter's real output HTML we MEASURE (never self-score) three honest dimensions:
4// (1) STRUCTURE/A11Y/SOVEREIGNTY -- the 7 page checks of nx_uxcx_grade (composed: uxg_* are pure).
5// (2) DESIGN SIGNALS /9 -- mirrors nx_brand_aesthetic bq_score's objective HTML signals
6// (any-token / :root / type-hierarchy / responsive / reduced-motion / focus-visible /
7// semantic-landmarks / hover / padding), scanned via the composed uxg_has_lit.
8// (3) CANONICAL TOKENS -- does the page use var(--nx-*), the shared design-token SSOT?
9// This is the S-class differentiator: the "fragmented adoption" gap the operator is hitting.
10// SUBJECTIVE beauty stays human-judged (nx_brand_census R6 honest-BEHIND) -- NOT claimed here.
11// (Mirrors bq_score via uxg_has_lit instead of importing nx_brand_aesthetic, which pulls nx_syscalls.nx
12// and would collide with the nx_syscalls_x86_64 file-read layer -- the syscall-dup gotcha.)
13// license_tier: ORIGINAL expect_exit: 0
14import "nx_syscalls_x86_64.nx"
15import "nx_uxcx_grade.nx"
16
17func bw(s: *u8) -> i64 { var n: i64=0; while s[n]!=0 { n=n+1 } sys_write(1,s,n); return 0 }
18func bn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m-(m/10)*10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
19func pad(name: *u8, w: i64) -> i64 { var n: i64=0; while name[n]!=0 { n=n+1 } sys_write(1,name,n); while n<w { sys_write(1," " as *u8,1); n=n+1 } return 0 }
20
21// (1) structural/a11y/sovereignty over the 7 page checks of nx_uxcx_grade.
22func page_uxcx(h: *u8, n: i64) -> i64 {
23 var p: i64=0
24 if uxg_escaping_ok(h,n)==1 { p=p+1 }
25 if uxg_viewport_ok(h,n)==1 { p=p+1 }
26 if uxg_skiplink_ok(h,n)==1 { p=p+1 }
27 if uxg_lang_ok(h,n)==1 { p=p+1 }
28 if uxg_title_ok(h,n)==1 { p=p+1 }
29 if uxg_nav_ok(h,n)==1 { p=p+1 }
30 if uxg_sovereign_ok(h,n)==1 { p=p+1 }
31 return p
32}
33// (2) design signals /9 (mirrors nx_brand_aesthetic bq_score, HTML-observable subset).
34func design_signals(h: *u8, n: i64) -> i64 {
35 var s: i64=0
36 if uxg_has_lit(h,n,"var(--" as *u8)==1 { s=s+1 }
37 if uxg_has_lit(h,n,":root{" as *u8)==1 { s=s+1 }
38 if uxg_has_lit(h,n,"<h1" as *u8)==1 { if uxg_has_lit(h,n,"<h2" as *u8)==1 { s=s+1 } }
39 if uxg_has_lit(h,n,"@media(max-width" as *u8)==1 { s=s+1 }
40 if uxg_has_lit(h,n,"prefers-reduced-motion" as *u8)==1 { s=s+1 }
41 if uxg_has_lit(h,n,":focus-visible" as *u8)==1 { s=s+1 }
42 if uxg_has_lit(h,n,"<header" as *u8)==1 { if uxg_has_lit(h,n,"<footer" as *u8)==1 { s=s+1 } }
43 if uxg_has_lit(h,n,":hover" as *u8)==1 { s=s+1 }
44 if uxg_has_lit(h,n,"padding:" as *u8)==1 { s=s+1 }
45 return s
46}
47// (3) canonical shared design-token SSOT adoption.
48func canonical_tokens(h: *u8, n: i64) -> i64 { return uxg_has_lit(h,n,"var(--nx-" as *u8) }
49
50// print the specific missing signals -> the fix-list per emitter
51func gaps(h: *u8, n: i64) -> i64 {
52 if canonical_tokens(h,n)==0 { bw(" no-canonical-tokens" as *u8) }
53 if uxg_has_lit(h,n,"@media(max-width" as *u8)==0 { bw(" not-responsive" as *u8) }
54 if uxg_has_lit(h,n,"prefers-reduced-motion" as *u8)==0 { bw(" no-reduced-motion" as *u8) }
55 if uxg_has_lit(h,n,":focus-visible" as *u8)==0 { bw(" no-focus-visible" as *u8) }
56 if uxg_skiplink_ok(h,n)==0 { bw(" no-skip-link" as *u8) }
57 if uxg_has_lit(h,n,":root{" as *u8)==0 { bw(" no-:root-tokens" as *u8) }
58 return 0
59}
60
61func grade_one(name: *u8, path: *u8, tot: *i64) -> i64 {
62 let len_p: *i64 = sys_mmap(8) as *i64
63 let h: *u8 = sys_read_file_x86_64(path, len_p)
64 pad(name, 22)
65 if h == (0 as *u8) { bw(" (output not found)\n" as *u8); return 0 }
66 let n: i64 = len_p[0]
67 let ux: i64 = page_uxcx(h,n)
68 let ds: i64 = design_signals(h,n)
69 let ct: i64 = canonical_tokens(h,n)
70 bw("uxcx " as *u8); bn(ux); bw("/7 design " as *u8); bn(ds); bw("/9 canon-tokens " as *u8)
71 if ct==1 { bw("Y" as *u8) } else { bw("N" as *u8) }
72 bw(" " as *u8)
73 // honest verdict
74 var sclass: i64 = 0
75 if ux>=7 { if ds>=8 { if ct==1 { sclass=1 } } }
76 if sclass==1 { bw("[S-CLASS]" as *u8); tot[0]=tot[0]+1 }
77 else { bw("[gaps:" as *u8); gaps(h,n); bw("]" as *u8) }
78 bw("\n" as *u8)
79 tot[1]=tot[1]+1
80 return 0
81}
82
83func main() -> i64 {
84 let tot: *i64 = sys_mmap(32) as *i64
85 tot[0]=0; tot[1]=0 // sclass, graded
86
87 bw("=== nx_emitter_bench -- measured quality of the autonomous UI emitters' OUTPUT ===\n" as *u8)
88 bw("dims: uxcx (structure/a11y/sovereign, 7) + design-signals (9, mirrors nx_brand_aesthetic) + canonical --nx- tokens\n" as *u8)
89 bw("S-CLASS bar = uxcx 7/7 AND design >=8/9 AND canonical tokens. Subjective beauty stays human-judged (not scored).\n\n" as *u8)
90
91 bw("-- MODERN site-builder / brand pipeline (expected on the --nx- SSOT) --\n" as *u8)
92 grade_one("brand:andelin" as *u8, "web_assets/andelin_branded.html" as *u8, tot)
93 grade_one("site_provision:demo" as *u8,"web_assets/site_demo/index.html" as *u8, tot)
94 grade_one("site_provision:jobs" as *u8,"web_assets/site_gatejobs/jobs.html" as *u8, tot)
95 grade_one("site_provision:law" as *u8, "web_assets/_aw_pages_gate/index.html" as *u8, tot)
96 bw("-- HAND-TUNED reference (this session) --\n" as *u8)
97 grade_one("nx_connect_lds_page" as *u8,"web_assets/lds_connect.html" as *u8, tot)
98 bw("-- KIT-COMPOSED via nx_sclass_kit (this session) --\n" as *u8)
99 grade_one("nx_connect_youth_page" as *u8,"web_assets/lds_youth.html" as *u8, tot)
100 bw("-- LEGACY content emitters (pre-token-system) --\n" as *u8)
101 grade_one("nx_games_page" as *u8, "web_assets/games.html" as *u8, tot)
102 grade_one("nx_lib_page" as *u8, "web_assets/library.html" as *u8, tot)
103 grade_one("hub/products" as *u8, "web_assets/products.html" as *u8, tot)
104 grade_one("hub/status" as *u8, "web_assets/status.html" as *u8, tot)
105
106 bw("\n--- SUMMARY ---\n" as *u8)
107 bw(" S-CLASS emitters = " as *u8); bn(tot[0]); bw(" / " as *u8); bn(tot[1]); bw(" graded\n" as *u8)
108 bw(" READ: the [gaps:...] flags per row ARE the fix-list. Dominant gap = canonical-token adoption\n" as *u8)
109 bw(" (emitters declare their own :root vars, not the shared --nx-* SSOT) -> the 'fragmented\n" as *u8)
110 bw(" adoption' the operator hit. FIX = retrofit emitters to compose nx_brand_tokens + an\n" as *u8)
111 bw(" nx_brand_apply_enforced audit that FAILS any output with off-SSOT / hardcoded styling.\n" as *u8)
112 bw(" HONEST: this measures structure + design-signal adoption, NOT subjective beauty (human-judged).\n" as *u8)
113 return 0
114}