code wiki / _hdl_build / nx_site_migrate_gate.nx
nx_site_migrate_gate.nx source
↩ module page · 67 lines · 3836 B
1// nx_site_migrate_gate.nx -- the full migration loop: import a lock-in site -> rebuild sovereignly -> the rebuilt page
2// preserves content, is tracker-free (0 JS), and is MORE accessible than the original (ab_score higher). A capability
3// lock-in platforms lack -- and it IMPROVES the migrated site. 100% sovereign. expect_exit: 0
4import "nx_syscalls.nx"
5import "nx_sitegate_emit_lib.nx"
6import "nx_site_migrate.nx"
7import "nx_a11y_breadth.nx"
8import "nx_exceed_standard.nx"
9import "nx_brand_tokens.nx"
10
11// gw/gn/t_row shared via nx_sitegate_emit_lib.nx (rule-15 extraction of the funcmine dup group)
12func has(s: *u8, n: i64, lit: *u8) -> i64 { if bt_find(s, n, lit, bt_len(lit)) >= 0 { return 1 } return 0 }
13func slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
14
15func main() -> i64 {
16 let tot: *i64 = sys_mmap(32) as *i64
17 tot[0]=0; tot[1]=0
18 let lp: *i64 = sys_mmap(16) as *i64
19 let foreign: *u8 = "<!doctype html><html><head><title>Acme Plumbing</title><script>track(7)</script></head><body><div><h1>Acme Plumbing</h1><p>We fix leaks fast in your area.</p><h2>Services</h2><p>Drains and water heaters.</p><a href=/contact>Contact us</a></div><script>more(9)</script></body></html>" as *u8
20 let fn: i64 = slen(foreign)
21 gw("=== nx_site_migrate_gate -- import a lock-in site -> REBUILD sovereignly (and improve it) ===\n" as *u8)
22
23 // import -> blueprint
24 let fd1: i64 = sys_openat_wr("/tmp/mig_bp.site" as *u8, 0x1a4)
25 mi_to_blueprint(foreign, fn, fd1); sys_close(fd1)
26 let bp: *u8 = sys_read_file("/tmp/mig_bp.site" as *u8, lp)
27 let bn: i64 = lp[0]
28
29 // rebuild through the branded builder
30 let brand: *u8 = bt_default_brand(); let blen: i64 = bt_len(brand)
31 let fd2: i64 = sys_openat_wr("/tmp/migrated.html" as *u8, 0x1a4)
32 mig_rebuild(bp, bn, brand, blen, fd2); sys_close(fd2)
33 let pg: *u8 = sys_read_file("/tmp/migrated.html" as *u8, lp)
34 let pn: i64 = lp[0]
35
36 // M1 content preserved through import -> rebuild
37 var m1: i64 = 0
38 if has(pg, pn, "Acme Plumbing" as *u8) == 1 { if has(pg, pn, "We fix leaks fast" as *u8) == 1 { m1 = 1 } }
39 t_row("M1 content preserved through the loop (title + body)" as *u8, m1, tot)
40
41 // M2 the rebuilt site is sovereign: tracking gone, 0 JS
42 var m2: i64 = 0
43 if has(pg, pn, "<script" as *u8) == 0 { if has(pg, pn, "track" as *u8) == 0 { m2 = 1 } }
44 t_row("M2 rebuilt site is SOVEREIGN: 0 <script, tracking removed" as *u8, m2, tot)
45
46 // M3 the rebuilt site is ACCESSIBLE by construction
47 let sc: i64 = ab_score(pg, pn)
48 gw(" migrated page a11y score = " as *u8); gn(sc); gw(" / 12\n" as *u8)
49 var m3: i64 = 0; if sc >= 10 { m3 = 1 }
50 t_row("M3 rebuilt site ACCESSIBLE by construction (a11y >= 10/12)" as *u8, m3, tot)
51
52 // S1 proof it IMPROVES: original foreign page scores much lower
53 let sc0: i64 = ab_score(foreign, fn)
54 gw(" original foreign a11y score = " as *u8); gn(sc0); gw(" / 12 (migration raised it)\n" as *u8)
55 var s1: i64 = 0; if sc > sc0 { s1 = 1 }
56 t_row("S1 migration IMPROVES accessibility (rebuilt > original)" as *u8, s1, tot)
57
58 // M4 the CAPABILITY exceed: full migration off a lock-in platform (content + sovereign + accessible)
59 var ours: i64 = 0; if m1 == 1 { if m2 == 1 { if m3 == 1 { ours = 1 } } }
60 let cx: i64 = es_is_sclass_exceed(ES_CAPABILITY, ES_CUSTOMER, ours, 0, 1)
61 t_row("M4 CAPABILITY: full platform migration (import->rebuild, sovereign+accessible) vs lock-in" as *u8, cx, tot)
62
63 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8)
64 if tot[1] == 0 { gw("VERDICT=GREEN -- migration loop CLOSED: import a lock-in site, rebuild it sovereignly + MORE accessible. The no-lock-in capability, end-to-end.\n" as *u8); return 0 }
65 gw("VERDICT=RED\n" as *u8)
66 return 1
67}