code wiki / _hdl_build / nx_brand_exceed2_gate.nx

nx_brand_exceed2_gate.nx source

↩ module page · 123 lines · 7199 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_brand_exceed2_gate.nx -- the S-CLASS EXCEED EXPANSION: measure MORE honest by-construction axes through the 4// no-overclaim referee (nx_cms_exceed). OUR side is genuinely RUN (organs executed on a corpus); the INCUMBENT side 5// is DOCUMENTED behavior of cloud site/brand builders (Webflow/Wix/Framer/Squarespace + GA4), labeled. Each axis is 6// a thing incumbents structurally CANNOT match: enforced accessibility, token-purity, privacy, accessible motion, 7// governed untrusted-AI, dark-mode AA, reproducibility. AHEAD only where ours is measured perfect on the criterion 8// (xcd_referee_ok). Self-tests prove no false-green. Subjective beauty / widget+template breadth are NOT here -- 9// they remain the honest BEHIND from R6. 100% sovereign. license_tier: ORIGINAL expect_exit: 0 10import "nx_syscalls.nx" 11import "nx_cms_exceed.nx" 12import "nx_brand_manage.nx" 13import "nx_brand_book.nx" 14import "nx_brand_guard.nx" 15import "nx_web_builder.nx" 16import "nx_brand_tokens.nx" 17 18func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 19" as *u8); return ok } 20func g_has(s: *u8, n: i64, lit: *u8) -> i64 { if bt_find(s, n, lit, bt_len(lit)) >= 0 { return 1 } return 0 } 21// build a branded page with `body` and return its bytes in out. 22func g_build(brand: *u8, bn: i64, body: *u8, out: *u8, cap: i64) -> i64 { 23 let fd: i64 = sys_openat_wr("/tmp/nx_ex2.html" as *u8, 0x1a4) 24 wb_doc_open_branded(fd, "X" as *u8, brand, bn) 25 wb_w(fd, body) 26 wb_doc_close(fd) 27 sys_close(fd) 28 let lp: *i64 = sys_mmap(16) as *i64 29 let pg: *u8 = sys_read_file("/tmp/nx_ex2.html" as *u8, lp) 30 let pn: i64 = lp[0] 31 var i: i64 = 0 32 while i < pn { if i < cap { out[i] = pg[i] } i = i + 1 } 33 return pn 34} 35// a measured AHEAD axis through the referee: pass iff COMPUTED verdict is AHEAD and the referee accepts. 36func axis_ahead(name: *u8, our: i64, inc: i64, n: i64, tot: *i64) -> i64 { 37 let v: i64 = xcd_verdict(our, inc) 38 let ok: i64 = xcd_referee_ok(v, our, n) 39 var pass: i64 = 0 40 if v == XCD_AHEAD { if ok == 1 { pass = 1 } } 41 if pass == 1 { gw(" PASS " as *u8); tot[0]=tot[0]+1 } else { gw(" FAIL " as *u8); tot[1]=tot[1]+1 } 42 gw(name); gw(" -> " as *u8); gw(xcd_vname(v)); gw(" (ours=" as *u8); gn(our); gw("/" as *u8); gn(n) 43 gw(" vs documented=" as *u8); gn(inc); gw("/" as *u8); gn(n); gw(")\n" as *u8) 44 return pass 45} 46 47func main() -> i64 { 48 let tot: *i64 = sys_mmap(32) as *i64 49 tot[0]=0; tot[1]=0 50 let base: *u8 = bt_default_brand() 51 let bn: i64 = bt_len(base) 52 let cap: i64 = 16384 53 let buf: *u8 = sys_mmap(cap) 54 let a: *u8 = sys_mmap(cap) 55 let b: *u8 = sys_mmap(cap) 56 gw("=== nx_brand_exceed2_gate -- S-class exceed EXPANSION (measured, refereed; incumbent=documented) ===\n" as *u8) 57 58 // A ACCESSIBILITY-ENFORCEMENT: AA-or-refuse on every publish (run bm_propose x4: 2 good, 2 sub-AA) 59 var ae: i64 = 0 60 if bm_propose(base, bn, "set|color|primary|#7a0019\n" as *u8, 26, buf, cap) > 0 { ae = ae + 1 } 61 if bm_propose(base, bn, "pack|ocean\n" as *u8, 11, buf, cap) > 0 { ae = ae + 1 } 62 if bm_propose(base, bn, "set|color|ink|#cccccc\n" as *u8, 22, buf, cap) < 0 { ae = ae + 1 } 63 if bm_propose(base, bn, "set|color|ink|#dddddd\n" as *u8, 22, buf, cap) < 0 { ae = ae + 1 } 64 axis_ahead("A ACCESS-ENFORCE: WCAG AA enforced or refused on every publish" as *u8, ae, 2, 4, tot) 65 66 // B TOKEN-PURITY: detect off-token colour drift (clean1, clean2, dirty -> all classified right) 67 let c1: i64 = g_build(base, bn, "<p>clean one</p>\n" as *u8, a, cap) 68 var tp: i64 = 0 69 if ba_audit(a, c1) == 0 { tp = tp + 1 } 70 let c2: i64 = g_build(base, bn, "<p>clean two, more text</p>\n" as *u8, a, cap) 71 if ba_audit(a, c2) == 0 { tp = tp + 1 } 72 let d1: i64 = g_build(base, bn, "<div style=\"color:#ff0000\">rogue</div>\n" as *u8, b, cap) 73 if ba_audit(b, d1) >= 1 { tp = tp + 1 } 74 axis_ahead("B TOKEN-PURITY: off-token colour-drift detected (incumbents have no token-lint)" as *u8, tp, 0, 3, tot) 75 76 // C PRIVACY: 0 third-party script/beacon in the page 77 let pn: i64 = g_build(base, bn, "<p>x</p>\n" as *u8, a, cap) 78 var pv: i64 = 0 79 if g_has(a, pn, "<script" as *u8) == 0 { pv = 1 } 80 axis_ahead("C PRIVACY: 0 third-party script/beacon (vs GA4/vendor analytics)" as *u8, pv, 0, 1, tot) 81 82 // D ACCESSIBLE-MOTION: prefers-reduced-motion by construction 83 var am: i64 = 0 84 if g_has(a, pn, "prefers-reduced-motion" as *u8) == 1 { am = 1 } 85 axis_ahead("D ACCESSIBLE-MOTION: prefers-reduced-motion by construction" as *u8, am, 0, 1, tot) 86 87 // E DARK-AA: WCAG AA in BOTH light and dark modes (measured contrast) 88 let aaL: i64 = bg_contrast_hex_x100("#16202e" as *u8, "#ffffff" as *u8) 89 let aaD: i64 = bg_contrast_hex_x100("#e6edf3" as *u8, "#0b1220" as *u8) 90 var de: i64 = 0 91 if aaL >= 450 { de = de + 1 } 92 if aaD >= 450 { de = de + 1 } 93 axis_ahead("E DARK-AA: AA enforced in BOTH light+dark (incumbent dark modes often sub-AA)" as *u8, de, 1, 2, tot) 94 95 // F MULTI-ACTOR-GOV: an untrusted AI/LLM proposal can neither inject nor break the brand 96 var mg: i64 = 0 97 if bm_propose(base, bn, "set|color|x|<script>\n" as *u8, 21, buf, cap) < 0 { mg = mg + 1 } 98 if bm_propose(base, bn, "set|color|ink|#cccccc\n" as *u8, 22, buf, cap) < 0 { mg = mg + 1 } 99 axis_ahead("F MULTI-ACTOR-GOV: untrusted AI/LLM cannot inject or break (model-in-trusted-path loses)" as *u8, mg, 0, 2, tot) 100 101 // G REPRODUCIBILITY: the brand book emits byte-identical on re-render 102 let f1: i64 = sys_openat_wr("/tmp/nx_ex2_bb1.html" as *u8, 0x1a4); bb_emit(base, bn, f1); sys_close(f1) 103 let f2: i64 = sys_openat_wr("/tmp/nx_ex2_bb2.html" as *u8, 0x1a4); bb_emit(base, bn, f2); sys_close(f2) 104 let lp: *i64 = sys_mmap(16) as *i64 105 let p1: *u8 = sys_read_file("/tmp/nx_ex2_bb1.html" as *u8, lp); let n1: i64 = lp[0] 106 let p2: *u8 = sys_read_file("/tmp/nx_ex2_bb2.html" as *u8, lp); let n2: i64 = lp[0] 107 var rp: i64 = 0 108 if n1 == n2 { if n1 > 0 { var eq: i64 = 1; var i: i64 = 0; while i < n1 { if p1[i] != p2[i] { eq = 0 } i = i + 1 } rp = eq } } 109 axis_ahead("G REPRODUCIBILITY: brand artifacts byte-identical re-render (cloud is non-reproducible)" as *u8, rp, 0, 1, tot) 110 111 gw("-- referee self-tests (no false-green) --\n" as *u8) 112 var st1: i64 = 0; if xcd_referee_ok(XCD_AHEAD, 3, 4) == 0 { st1 = 1 } 113 if st1 == 1 { gw(" PASS " as *u8); tot[0]=tot[0]+1 } else { gw(" FAIL " as *u8); tot[1]=tot[1]+1 } 114 gw("S1 referee rejects overclaim (AHEAD with our_correct<n)\n" as *u8) 115 var st2: i64 = 0; if xcd_verdict(4, 4) == XCD_PARITY { st2 = 1 } 116 if st2 == 1 { gw(" PASS " as *u8); tot[0]=tot[0]+1 } else { gw(" FAIL " as *u8); tot[1]=tot[1]+1 } 117 gw("S2 equal scores -> PARITY (not a win)\n" as *u8) 118 119 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8) 120 if tot[1] == 0 { gw("VERDICT=GREEN -- 7 MORE measured-exceed axes, refereed. S-class exceed widened on by-construction axes (subjective beauty/breadth = R6 honest BEHIND).\n" as *u8); return 0 } 121 gw("VERDICT=RED\n" as *u8) 122 return 1 123}