code wiki / _hdl_build / nx_site_wholesale_gate.nx
nx_site_wholesale_gate.nx source
↩ module page · 92 lines · 5399 B
1// nx_site_wholesale_gate.nx -- referee for R-SITESHAPE (nx_site_wholesale). Reads the artifacts the wrapper
2// produced by emitting the andelinwest `site:` graph from the LIVE corpus: proves the whole site re-emits
3// wholesale -- same relative page paths (subdir preserved), the SITE'S OWN nav (not the factory default),
4// seq-faithful sections, complete page set + sitemap -- and a bogus key is refused (no fabrication).
5// GREEN iff 7/7. license_tier: ORIGINAL expect_exit: 0
6import "nx_gate.nx"
7import "nx_gate_verdict.nx"
8
9func wg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
10func wg_has(hay: *u8, hn: i64, needle: *u8) -> i64 {
11 if (hay as i64)==0 { return 0 }
12 let nl: i64 = wg_slen(needle)
13 if nl==0 { return 1 }
14 var i: i64=0
15 while i+nl<=hn { var j: i64=0; var ok: i64=1; while j<nl { if (hay[i+j] as i64)!=(needle[j] as i64) { ok=0; j=nl } else { j=j+1 } } if ok==1 { return 1 } i=i+1 }
16 return 0
17}
18func wg_count(hay: *u8, hn: i64, needle: *u8) -> i64 {
19 if (hay as i64)==0 { return 0 }
20 let nl: i64 = wg_slen(needle)
21 if nl==0 { return 0 }
22 var c: i64=0
23 var i: i64=0
24 while i+nl<=hn { var j: i64=0; var ok: i64=1; while j<nl { if (hay[i+j] as i64)!=(needle[j] as i64) { ok=0; j=nl } else { j=j+1 } } if ok==1 { c=c+1; i=i+nl } else { i=i+1 } }
25 return c
26}
27func wg_row(name: *u8, ok: i64) -> i64 { gw(" " as *u8); gw(name); if ok==1 { gw(" PASS\n" as *u8) } else { gw(" FAIL\n" as *u8) } return 0 }
28
29func main() -> i64 {
30 let szp: *i64 = sys_mmap(16) as *i64
31 let idx: *u8 = sys_read_file("/tmp/wholesale_out/index.html" as *u8, szp); let iln: i64 = szp[0]
32 let p1: *u8 = sys_read_file("/tmp/wholesale_out/practice/family-law.html" as *u8, szp); let p1n: i64 = szp[0]
33 let p2: *u8 = sys_read_file("/tmp/wholesale_out/practice/estate-planning.html" as *u8, szp); let p2n: i64 = szp[0]
34 let p3: *u8 = sys_read_file("/tmp/wholesale_out/practice/business-law.html" as *u8, szp); let p3n: i64 = szp[0]
35 let p4: *u8 = sys_read_file("/tmp/wholesale_out/practice/personal-injury.html" as *u8, szp); let p4n: i64 = szp[0]
36 let sm: *u8 = sys_read_file("/tmp/wholesale_out/sitemap.xml" as *u8, szp); let sml: i64 = szp[0]
37 let rc: *u8 = sys_read_file("/tmp/wholesale_rc_badkey" as *u8, szp)
38
39 // T1: index emitted with the ADA shell
40 var t1: i64=0
41 if (idx as i64)!=0 { if wg_has(idx, iln, "class=\"skip-link\"" as *u8)==1 { if wg_has(idx, iln, "<main id=\"main\"" as *u8)==1 { t1=1 } } }
42 // T2: subdir page re-emitted at the SAME relative path (structure preserved wholesale)
43 var t2: i64=0; if (p1 as i64)!=0 { if p1n > 500 { t2=1 } }
44 // T3: the SITE'S OWN nav (graph edges), NOT the factory default nav
45 var t3: i64=0
46 if wg_has(idx, iln, "href=\"/practice/family-law.html\"" as *u8)==1 { if wg_has(idx, iln, ">Gallery<" as *u8)==0 { t3=1 } }
47 // T4: the COMPLETE page set re-emitted (all 4 practice pages + index)
48 var np: i64=0
49 if (p1 as i64)!=0 { np=np+1 }
50 if (p2 as i64)!=0 { np=np+1 }
51 if (p3 as i64)!=0 { np=np+1 }
52 if (p4 as i64)!=0 { np=np+1 }
53 var t4: i64=0; if np==4 { if (idx as i64)!=0 { t4=1 } }
54 // T5: sitemap lists all 5 pages
55 var t5: i64=0; if wg_count(sm, sml, "<loc>" as *u8)==5 { t5=1 }
56 // T6: seq-faithful -- the source pages carry an on-site search form, so the re-emit must too
57 var t6: i64=0; if wg_has(idx, iln, "role=\"search\"" as *u8)==1 { t6=1 }
58 // T7 (NEG): bogus key refused (exit 3), nothing fabricated
59 var t7: i64=0; if (rc as i64)!=0 { if (rc[0] as i64)==51 { t7=1 } }
60
61 var passes: i64=0
62 if t1==1 { passes=passes+1 } if t2==1 { passes=passes+1 } if t3==1 { passes=passes+1 }
63 if t4==1 { passes=passes+1 } if t5==1 { passes=passes+1 } if t6==1 { passes=passes+1 } if t7==1 { passes=passes+1 }
64 var green: i64=0; if passes==7 { green=1 }
65
66 gw("=== nx_site_wholesale_gate -- R-SITESHAPE site-graph -> whole-site emission ===\n" as *u8)
67 wg_row("T1-index-ada-shell " as *u8, t1)
68 wg_row("T2-subdir-path-preserved " as *u8, t2)
69 wg_row("T3-site-own-nav-not-default " as *u8, t3)
70 wg_row("T4-complete-page-set " as *u8, t4)
71 wg_row("T5-sitemap-all-pages " as *u8, t5)
72 wg_row("T6-seq-faithful-search-form " as *u8, t6)
73 wg_row("T7-bogus-key-refused(neg) " as *u8, t7)
74 gw("verdict=" as *u8); if green==1 { gw("GREEN" as *u8) } else { gw("RED" as *u8) }
75 gw(" passes=" as *u8); gn(passes); gw("/7\n" as *u8)
76
77 let lg: i64 = sys_openat_append("knowledge/status/site_wholesale.log" as *u8, 0x1a4)
78 if lg >= 0 {
79 if green==1 { let m: *u8 = "SITE-WHOLESALE rows=7 pass=7 verdict=GREEN\n" as *u8; sys_write(lg, m, 43) }
80 else { let m2: *u8 = "SITE-WHOLESALE verdict=RED\n" as *u8; sys_write(lg, m2, 27) }
81 sys_close(lg)
82 }
83 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
84 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
85 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
86 let ctr__dry: *i64 = gv_ctr()
87 ctr__dry[0] = green
88 ctr__dry[1] = 1
89 let rc__dry: i64 = gv_verdict("SITE-WHOLESALE-GATE" as *u8, ctr__dry, "teeth unchanged; verdict emission migrated onto the shared base class" as *u8)
90 sys_exit(rc__dry)
91 return rc__dry
92}