code wiki / _hdl_build / nx_studio_exceed_gate.nx
nx_studio_exceed_gate.nx source
↩ module page · 192 lines · 14346 B
1// nx_studio_exceed_gate.nx -- MEASURED head-to-head EXCEED for the WYSIWYG EDITOR (nx_sitegen_studio) vs the
2// Wix/Webflow/WordPress visual editors, through the no-overclaim referee (nx_cms_exceed). This complements the
3// builder-output exceed gate (nx_sitegen_exceed_gate) by measuring the EDITOR itself, and -- per the no-wave law
4// -- it turns the previously hand-waved "editor maturity BEHIND" into a real MEASURED, mixed ledger: we run OUR
5// editor's actual /build decision (se_build_site) over a real corpus; the verdict is COMPUTED (cannot be
6// hand-set); the referee rejects any overclaim; and the gate reports our LOSSES honestly, refusing to log them
7// as wins. The incumbent oracle = the DOCUMENTED behavior of the incumbents (we cannot run real Wix -- cloud,
8// no sovereignty), anchored to citable facts, NOT fabricated:
9// AXIS A editor governance: Wix/WP/Webflow editors impose NO publish-time structural gate (anything-goes
10// canvas). OURS: the editor's /build (se_build_site) refuses a non-UX-compliant blueprint (0 bytes).
11// AXIS B editor-saved-document portability: the doc the editor saves IS portable rebuildable data (.site) ->
12// byte-identical off-platform rebuild. Wix = no export; Webflow = frozen static, no editable model.
13// AXIS C editor injection-safety: a hostile field typed into the editor is escaped by construction. Wix also
14// sanitizes -> measured PARITY (NOT claimed as a win).
15// AXIS D free-form drag-drop canvas: ours is a BLOCK editor, no pixel canvas -> COMPUTE BEHIND, honest.
16// AXIS E component/template breadth: ours is a small fixed palette -> COMPUTE BEHIND, honest.
17// AXIS F live preview: both have it -> measured PARITY.
18// license_tier: ORIGINAL
19import "nx_sitegen_studio.nx"
20import "nx_cms_exceed.nx"
21import "nx_syscalls.nx"
22
23func xs_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
24func xs_num(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; 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%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 }
25func xs_cat(dst: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var k: i64=0; while s[k]!=(0 as u8){dst[o]=s[k];o=o+1;k=k+1} return o }
26func xs_catnum(dst: *u8, off: i64, v: i64) -> i64 { var o: i64=off; let t: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; var k: i64=0; if m==0{t[0]=48 as u8;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{dst[o]=t[k-1-i];o=o+1;i=i+1} return o }
27func xs_row(id: i64, ok: i64, what: *u8) -> i64 { xs_w("XSROW " as *u8); xs_num(id); xs_w(" " as *u8); if ok==1 { xs_w("PASS " as *u8) } else { xs_w("FAIL " as *u8) } xs_w(what); xs_w("\n" as *u8); return ok }
28func xs_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
29func xs_contains(hay: *u8, hn: i64, needle: *u8) -> i64 {
30 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1}
31 if nl==0 { return 1 } if nl>hn { return 0 }
32 let last: i64=hn-nl; var i: i64=0
33 while i<=last { var j: i64=0; var hit: i64=1; while j<nl { if (hay[i+j] as i64)!=(needle[j] as i64){hit=0;j=nl} if hit==1{j=j+1} } if hit==1 { return 1 } i=i+1 }
34 return 0
35}
36func xs_eq(a: *u8, an: i64, b: *u8, bn: i64) -> i64 { if an!=bn { return 0 } var i: i64=0; while i<an { if (a[i] as i64)!=(b[i] as i64){return 0} i=i+1 } return 1 }
37
38// ours: the editor's actual publish decision for a posted blueprint (1 = built/shipped, 0 = refused).
39func xs_editor_pub(blob: *u8, out: *u8, cap: i64) -> i64 {
40 let n: i64 = se_build_site(blob, xs_len(blob), out, cap)
41 if n > 0 { return 1 }
42 return 0
43}
44
45func main() -> i64 {
46 let out: *u8 = sys_mmap(262144)
47 let out2: *u8 = sys_mmap(262144)
48
49 // ===== AXIS A: editor governance -- run OUR editor's /build over a real corpus (2 good, 3 bad) =====
50 // GOOD = UX-compliant (header+CTA, hero+CTA, search, trust>=1, steps in [1..3]); BAD = a real violation.
51 let blobs: *i64 = sys_mmap(8*16) as *i64
52 let truth: *i64 = sys_mmap(8*16) as *i64
53 blobs[0]="title|Test Law\nheader|BrandCo|Free consult|#c\nhero|We help Utah families|Talk to an attorney today|Start free consult|#c\nsearch|/search|Search...\ncards|How we help\ncard|Family Law|Divorce and custody.\ncard|Estate|Wills and trusts.\nsteps|3 steps\nstep|Tell us what happened\nstep|We review and call back\ntrust|\nsig|Utah State Bar\nsig|Free consultation\nfooter|BrandCo, PLLC\n" as *u8 as i64; truth[0]=1
54 blobs[1]="title|Pet Care\nheader|PetCo|Book now|#b\nhero|Happy healthy pets|We care for your pets|Book a visit|#b\nsearch|/find|Find...\ncards|Services\ncard|Grooming|Full grooming.\nsteps|Easy steps\nstep|Call us\nstep|Drop off\nstep|Pick up happy\ntrust|\nsig|Licensed vets\nfooter|PetCo Inc\n" as *u8 as i64; truth[1]=1
55 blobs[2]="title|X\nheader|B|C|#x\nhero|H|S|Go|#x\nfooter|F\n" as *u8 as i64; truth[2]=0
56 blobs[3]="footer|just a footer\n" as *u8 as i64; truth[3]=0
57 blobs[4]="title|X\nheader|B|C|#x\nhero|H|S|Go|#x\nsearch|/s|q\ncards|C\ncard|A|a\nsteps|S\nstep|1\nstep|2\nstep|3\nstep|4\ntrust|\nsig|T\nfooter|F\n" as *u8 as i64; truth[4]=0
58 let nA: i64 = 5
59 var oursA: i64 = 0
60 var incA: i64 = 0
61 var brk_ours: i64 = 0
62 var brk_inc: i64 = 0
63 var i: i64 = 0
64 while i < nA {
65 let pub: i64 = xs_editor_pub(blobs[i] as *u8, out, 262143) // ours: gates on the standard
66 let inc: i64 = 1 // incumbent editor: ships anything (no gate)
67 if pub == truth[i] { oursA = oursA + 1 }
68 if inc == truth[i] { incA = incA + 1 }
69 if truth[i] == 0 { if pub == 1 { brk_ours = brk_ours + 1 } }
70 if truth[i] == 0 { if inc == 1 { brk_inc = brk_inc + 1 } }
71 i = i + 1
72 }
73 let vA: i64 = xcd_verdict(oursA, incA)
74 let refA: i64 = xcd_referee_ok(vA, oursA, nA)
75
76 // ===== AXIS B: editor-saved-document portability (the .site the editor saves rebuilds off-platform) =====
77 let lenB0: i64 = se_build_site(blobs[0] as *u8, xs_len(blobs[0] as *u8), out, 262143) // GOOD1 build
78 let lenB0b: i64 = se_build_site(blobs[0] as *u8, xs_len(blobs[0] as *u8), out2, 262143) // GOOD1 again
79 var okB0: i64 = 0
80 if lenB0 > 0 { if xs_eq(out, lenB0, out2, lenB0b)==1 { okB0=1 } } // byte-identical rebuild
81 let lenB1: i64 = se_build_site(blobs[1] as *u8, xs_len(blobs[1] as *u8), out2, 262143) // GOOD2 build
82 var okB1: i64 = 0
83 if lenB1 > 0 { if xs_eq(out, lenB0, out2, lenB1)==0 { if xs_contains(out2, lenB1, "Grooming" as *u8)==1 { okB1=1 } } } // distinct, data-driven
84 let oursB: i64 = okB0 + okB1
85 let incB: i64 = 0 // documented: Wix no-export / Webflow frozen-static -> no editable portable saved doc
86 let nB: i64 = 2
87 let vB: i64 = xcd_verdict(oursB, incB)
88 let refB: i64 = xcd_referee_ok(vB, oursB, nB)
89
90 // ===== AXIS C: editor injection-safety (hostile field typed in the editor) -- measured PARITY =====
91 let mal: *i64 = sys_mmap(8*8) as *i64
92 mal[0]="title|X\nheader|<script>alert(1)</script>|C|#x\nhero|H|S|Go|#x\nsearch|/s|q\ncards|C\ncard|A|a\nsteps|S\nstep|1\ntrust|\nsig|T\nfooter|F\n" as *u8 as i64
93 mal[1]="title|X\nheader|B|C|#x\nhero|H|S|Go|#x\nsearch|/s|q\ncards|C\ncard|<script>alert(2)</script>|a\nsteps|S\nstep|1\ntrust|\nsig|T\nfooter|F\n" as *u8 as i64
94 let nC: i64 = 2
95 var oursC: i64 = 0
96 var k: i64 = 0
97 while k < nC {
98 let ln: i64 = se_build_site(mal[k] as *u8, xs_len(mal[k] as *u8), out, 262143)
99 var safe: i64 = 0
100 if ln > 0 { if xs_contains(out, ln, "<script>alert" as *u8)==0 { if xs_contains(out, ln, "<script>alert" as *u8)==1 { safe=1 } } }
101 oursC = oursC + safe
102 k = k + 1
103 }
104 let incC: i64 = 2 // documented: mature platforms sanitize user-entered fields too -> honest PARITY, not a win
105 let vC: i64 = xcd_verdict(oursC, incC)
106
107 // ===== AXIS D: free-form drag-drop canvas -- WE ARE BEHIND (honest) =====
108 let vD: i64 = xcd_verdict(0, 1)
109
110 // ===== AXIS E: component/template breadth -- WE ARE BEHIND (honest) =====
111 // ours = 7 block types in the palette; incumbent = the documented large Wix template/widget library.
112 let our_palette: i64 = 7
113 let inc_library: i64 = 900
114 let vE: i64 = xcd_verdict(our_palette, inc_library)
115
116 // ===== AXIS F: live preview -- both have it -> measured PARITY =====
117 // ours: the live preview IS se_build_site (a good blob returns a real built page) -> 1; incumbent has it too.
118 var our_preview: i64 = 0
119 if lenB0 > 0 { our_preview = 1 }
120 let vF: i64 = xcd_verdict(our_preview, 1)
121
122 // ---- raw measurements first (no overclaim) ----
123 xs_w("AXIS-A editor-publish-gate: ours=" as *u8); xs_num(oursA); xs_w("/" as *u8); xs_num(nA)
124 xs_w(" incumbent=" as *u8); xs_num(incA); xs_w("/" as *u8); xs_num(nA)
125 xs_w(" broken_shipped ours=" as *u8); xs_num(brk_ours); xs_w(" incumbent=" as *u8); xs_num(brk_inc)
126 xs_w(" verdict=" as *u8); xs_w(xcd_vname(vA)); xs_w("\n" as *u8)
127 xs_w("AXIS-B editor-doc-portability: ours=" as *u8); xs_num(oursB); xs_w("/" as *u8); xs_num(nB)
128 xs_w(" incumbent=" as *u8); xs_num(incB); xs_w("/" as *u8); xs_num(nB); xs_w(" verdict=" as *u8); xs_w(xcd_vname(vB)); xs_w("\n" as *u8)
129 xs_w("AXIS-C editor-injection-safety: ours=" as *u8); xs_num(oursC); xs_w("/" as *u8); xs_num(nC)
130 xs_w(" incumbent=" as *u8); xs_num(incC); xs_w("/" as *u8); xs_num(nC); xs_w(" verdict=" as *u8); xs_w(xcd_vname(vC)); xs_w(" (both safe -- NOT claimed)\n" as *u8)
131 xs_w("AXIS-D free-form-canvas (HONEST): ours=0 incumbent=1 verdict=" as *u8); xs_w(xcd_vname(vD)); xs_w(" -- NOT claimed (Wix leads)\n" as *u8)
132 xs_w("AXIS-E component/template breadth (HONEST): ours=" as *u8); xs_num(our_palette); xs_w(" block-types incumbent=" as *u8); xs_num(inc_library); xs_w("+ templates(documented) verdict=" as *u8); xs_w(xcd_vname(vE)); xs_w(" -- NOT claimed (Wix leads)\n" as *u8)
133 xs_w("AXIS-F live-preview: ours=" as *u8); xs_num(our_preview); xs_w(" incumbent=1 verdict=" as *u8); xs_w(xcd_vname(vF)); xs_w("\n" as *u8)
134
135 var rows: i64 = 0
136 var pass: i64 = 0
137 var ok: i64 = 0
138
139 // R0: AXIS A measured AHEAD + referee-honest + exact counts (ours 5/5, incumbent 2/5, ours ships 0 broken, incumbent 3)
140 ok = 0; if vA==XCD_AHEAD { if refA==1 { if oursA==5 { if incA==2 { if brk_ours==0 { if brk_inc==3 { ok=1 } } } } } }
141 rows=rows+1; pass=pass+xs_row(0, ok, "AXIS A AHEAD: editor gates 5/5, incumbent ships 3 broken (measured+referee)" as *u8)
142
143 // R1: AXIS B measured AHEAD + referee-honest
144 ok = 0; if vB==XCD_AHEAD { if refB==1 { if oursB==2 { if incB==0 { ok=1 } } } }
145 rows=rows+1; pass=pass+xs_row(1, ok, "AXIS B AHEAD: editor doc rebuilds 2/2 off-platform, incumbent 0 (measured+referee)" as *u8)
146
147 // R2: AXIS C measured PARITY -- ours fully safe, NOT claimed as a win
148 ok = 0; if vC==XCD_PARITY { if oursC==2 { ok=1 } }
149 rows=rows+1; pass=pass+xs_row(2, ok, "AXIS C PARITY: editor escapes 2/2 hostile fields; incumbent safe too (not claimed)" as *u8)
150
151 // R3: HONESTY -- AXIS D computed BEHIND, NOT claimed
152 ok = 0; if vD==XCD_BEHIND { ok=1 }
153 rows=rows+1; pass=pass+xs_row(3, ok, "HONEST: free-form canvas computes BEHIND (Wix leads); harness reports losses" as *u8)
154
155 // R4: HONESTY -- AXIS E computed BEHIND, NOT claimed
156 ok = 0; if vE==XCD_BEHIND { ok=1 }
157 rows=rows+1; pass=pass+xs_row(4, ok, "HONEST: component/template breadth computes BEHIND (Wix leads)" as *u8)
158
159 // R5: AXIS F measured PARITY (both have live preview)
160 ok = 0; if vF==XCD_PARITY { if our_preview==1 { ok=1 } }
161 rows=rows+1; pass=pass+xs_row(5, ok, "AXIS F PARITY: live preview present both sides (measured)" as *u8)
162
163 // R6: self-test -- referee REJECTS an overclaim (AHEAD while still failing cases)
164 ok = 0; if xcd_referee_ok(XCD_AHEAD, 4, 5)==0 { ok=1 }
165 rows=rows+1; pass=pass+xs_row(6, ok, "self-test: referee rejects overclaim (AHEAD but not fully correct)" as *u8)
166
167 // R7: self-test -- referee accepts honest AHEAD, rejects no-measurement
168 ok = 0; if xcd_referee_ok(XCD_AHEAD, 5, 5)==1 { if xcd_referee_ok(XCD_AHEAD, 5, 0)==0 { ok=1 } }
169 rows=rows+1; pass=pass+xs_row(7, ok, "self-test: referee accepts honest AHEAD, rejects no-measurement claim" as *u8)
170
171 xs_w("NX-STUDIO-EXCEED-GATE rows=" as *u8); xs_num(rows); xs_w(" pass=" as *u8); xs_num(pass); xs_w("\n" as *u8)
172 if pass == rows {
173 let line: *u8 = sys_mmap(512)
174 var off: i64 = xs_cat(line, 0, "CMSEXCEED feature=wysiwyg-editor axis=editor-publish-gate ours=" as *u8)
175 off = xs_catnum(line, off, oursA); off = xs_cat(line, off, "/" as *u8); off = xs_catnum(line, off, nA)
176 off = xs_cat(line, off, " incumbent=" as *u8); off = xs_catnum(line, off, incA); off = xs_cat(line, off, "/" as *u8); off = xs_catnum(line, off, nA)
177 off = xs_cat(line, off, " broken_shipped_ours=" as *u8); off = xs_catnum(line, off, brk_ours)
178 off = xs_cat(line, off, " broken_shipped_incumbent=" as *u8); off = xs_catnum(line, off, brk_inc)
179 off = xs_cat(line, off, " verdict=AHEAD (incumbent=documented anything-goes editor, no publish-time gate)\n" as *u8)
180 let line2: *u8 = sys_mmap(512)
181 var o2: i64 = xs_cat(line2, 0, "CMSEXCEED feature=wysiwyg-editor axis=editor-doc-portability ours=" as *u8)
182 o2 = xs_catnum(line2, o2, oursB); o2 = xs_cat(line2, o2, "/" as *u8); o2 = xs_catnum(line2, o2, nB)
183 o2 = xs_cat(line2, o2, " incumbent=" as *u8); o2 = xs_catnum(line2, o2, incB); o2 = xs_cat(line2, o2, "/" as *u8); o2 = xs_catnum(line2, o2, nB)
184 o2 = xs_cat(line2, o2, " verdict=AHEAD (incumbent=documented Wix no-export / Webflow frozen-static) -- editor BEHIND on canvas+breadth (honest, not logged)\n" as *u8)
185 let gf: i64 = sys_openat_append("knowledge/status/cms_exceed.log" as *u8, 0x1a4)
186 if gf >= 0 { sys_write(gf, line, off); sys_write(gf, line2, o2); sys_close(gf) }
187 xs_w("NX-STUDIO-EXCEED-GATE verdict=PASS -- 2 measured AHEAD editor axes + 2 PARITY recorded; 2 honest BEHIND NOT claimed\n" as *u8)
188 sys_exit(0); return 0
189 }
190 xs_w("NX-STUDIO-EXCEED-GATE verdict=FAIL -- NOT recorded (no fake-green)\n" as *u8)
191 sys_exit(1); return 1
192}