code wiki / _hdl_build / nx_exceed_standard_gate.nx

nx_exceed_standard_gate.nx source

↩ module page · 71 lines · 4521 B

1// nx_exceed_standard_gate.nx -- the team-wide standard in action: MEASURE efficiency/speed exceeds on BOTH surfaces. 2// CUSTOMER-FACING = the andelin page (light bytes + 0 JS + 0 external blocking requests => faster load, less CPU/ 3// battery for the user). INTERNAL-ONLY = the editor authoring tool's render (lean, 0 external). Incumbent = DOCUMENTED 4// (Wix/Webflow ship ~1-3MB JS + external CDN/fonts). Sovereignty-floor can never qualify (self-test). 100% sovereign. 5// expect_exit: 0 6import "nx_syscalls.nx" 7import "nx_sitegate_emit_lib.nx" 8import "nx_exceed_standard.nx" 9import "nx_editor_canvas.nx" 10import "nx_brand_tokens.nx" 11 12 13func g_count(s: *u8, n: i64, lit: *u8) -> i64 { 14 let ll: i64 = bt_len(lit); if ll == 0 { return 0 } 15 var c: i64 = 0; var i: i64 = 0 16 while i + ll <= n { var j: i64=0; var m: i64=1; while j<ll { if s[i+j]!=lit[j] { m=0; break } j=j+1 } if m==1 { c=c+1; i=i+ll } else { i=i+1 } } 17 return c 18} 19func put(c: *i64, i: i64, k: i64, x: i64, y: i64, w: i64, h: i64) -> i64 { c[i*5+0]=k; c[i*5+1]=x; c[i*5+2]=y; c[i*5+3]=w; c[i*5+4]=h; return 0 } 20 21func main() -> i64 { 22 let tot: *i64 = sys_mmap(32) as *i64 23 tot[0]=0; tot[1]=0 24 let lp: *i64 = sys_mmap(16) as *i64 25 gw("=== nx_exceed_standard_gate -- exceed on capability/EFFICIENCY/SPEED, customer-facing AND internal ===\n" as *u8) 26 27 // dimension rubric 28 var d: i64 = 0 29 if es_is_exceed_dim(ES_CAPABILITY)==1 { if es_is_exceed_dim(ES_EFFICIENCY)==1 { if es_is_exceed_dim(ES_SPEED)==1 { if es_is_exceed_dim(ES_CORRECTNESS)==1 { if es_is_exceed_dim(ES_SOVEREIGNTY_FLOOR)==0 { d = 1 } } } } } 30 t_row("D rubric: capability/efficiency/speed/correctness are exceed-dims; sovereignty is the FLOOR" as *u8, d, tot) 31 32 // --- CUSTOMER-FACING: the andelin page is light + 0 JS + 0 external blocking requests --- 33 let pg: *u8 = sys_read_file("web_assets/andelin_branded.html" as *u8, lp) 34 let pn: i64 = lp[0] 35 let js: i64 = g_count(pg, pn, "<script" as *u8) 36 let ext: i64 = g_count(pg, pn, "src=\"http" as *u8) + g_count(pg, pn, "url(http" as *u8) + g_count(pg, pn, "@import" as *u8) 37 var light: i64 = 0; if pn > 0 { if pn < 50000 { light = 1 } } 38 var nojs: i64 = 0; if js == 0 { nojs = 1 } 39 var noext: i64 = 0; if ext == 0 { noext = 1 } 40 let cust: i64 = light + nojs + noext 41 gw(" [customer] page bytes=" as *u8); gn(pn); gw(" <script>=" as *u8); gn(js); gw(" external-blocking=" as *u8); gn(ext); gw(" (incumbent documented: ~1-3MB JS + external CDN/fonts)\n" as *u8) 42 let sx_cust: i64 = es_is_sclass_exceed(ES_EFFICIENCY, ES_CUSTOMER, cust, 0, 3) 43 t_row("CUSTOMER efficiency/speed exceed: light + 0-JS + 0-external (3/3 vs documented 0/3)" as *u8, sx_cust, tot) 44 45 // --- INTERNAL-ONLY: the editor authoring tool renders lean + 0 external --- 46 let c: *i64 = sys_mmap(512) as *i64 47 put(c, 0, 1, 40, 8, 200, 48); put(c, 1, 3, 40, 80, 160, 44); put(c, 2, 2, 40, 140, 360, 80) 48 let fd: i64 = sys_openat_wr("/tmp/nx_es_render.html" as *u8, 0x1a4); ec_render(c, 3, fd); sys_close(fd) 49 let rg: *u8 = sys_read_file("/tmp/nx_es_render.html" as *u8, lp) 50 let rn: i64 = lp[0] 51 let rext: i64 = g_count(rg, rn, "http" as *u8) 52 var rlean: i64 = 0; if rn > 0 { if rn < 2000 { rlean = 1 } } 53 var rnoext: i64 = 0; if rext == 0 { rnoext = 1 } 54 let intl: i64 = rlean + rnoext 55 gw(" [internal] editor render bytes=" as *u8); gn(rn); gw(" external-refs=" as *u8); gn(rext); gw("\n" as *u8) 56 let sx_int: i64 = es_is_sclass_exceed(ES_EFFICIENCY, ES_INTERNAL, intl, 0, 2) 57 t_row("INTERNAL efficiency exceed: lean render + 0-external (2/2 vs 0/2)" as *u8, sx_int, tot) 58 59 t_row("BOTH surfaces covered (customer AND internal), per the standard" as *u8, sx_cust*sx_int, tot) 60 61 // self-tests: the floor never qualifies; an imperfect measurement never qualifies 62 var s1: i64 = 0; if es_is_sclass_exceed(ES_SOVEREIGNTY_FLOOR, ES_CUSTOMER, 5, 0, 5) == 0 { s1 = 1 } 63 t_row("S1 sovereignty-floor can NEVER be an exceed (returns 0)" as *u8, s1, tot) 64 var s2: i64 = 0; if es_is_sclass_exceed(ES_EFFICIENCY, ES_CUSTOMER, 2, 0, 3) == 0 { s2 = 1 } 65 t_row("S2 imperfect measurement (2/3) is NOT an exceed (no-overclaim)" as *u8, s2, tot) 66 67 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8) 68 if tot[1] == 0 { gw("VERDICT=GREEN -- exceed measured on EFFICIENCY/SPEED, customer-facing AND internal; sovereignty stays the floor. Team-wide standard.\n" as *u8); return 0 } 69 gw("VERDICT=RED\n" as *u8) 70 return 1 71}