code wiki / _hdl_build / nx_site_handoff_gate.nx

nx_site_handoff_gate.nx source

↩ module page · 89 lines · 5201 B

1// nx_site_handoff_gate.nx -- referee for R-HANDOFF (nx_site_handoff). Reads the artifacts the wrapper produced: 2// (1) the emitted .site blueprint (from the factory .req, ecommerce archetype), (2) the docroot nx_site_build 3// REBUILT from that blueprint (proving the PRODUCTION editor stack -- siteedit/save/preview/publish -- can own 4// and customize the factory's output), (3) negative-control exit codes (unknown archetype refused, missing brief 5// refused). GREEN iff 6/6. license_tier: ORIGINAL expect_exit: 0 6import "nx_gate.nx" 7import "nx_gate_verdict.nx" 8 9func hg_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 10func hg_has(hay: *u8, hn: i64, needle: *u8) -> i64 { 11 if (hay as i64)==0 { return 0 } 12 let nl: i64 = hg_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 hg_count(hay: *u8, hn: i64, needle: *u8) -> i64 { 19 if (hay as i64)==0 { return 0 } 20 let nl: i64 = hg_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 hg_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 site: *u8 = sys_read_file("/tmp/handoff_ecom.site" as *u8, szp); let sn: i64 = szp[0] 32 let idx: *u8 = sys_read_file("/tmp/handoff_docroot/index.html" as *u8, szp); let iln: i64 = szp[0] 33 let sm: *u8 = sys_read_file("/tmp/handoff_docroot/sitemap.xml" as *u8, szp); let sml: i64 = szp[0] 34 let rc1: *u8 = sys_read_file("/tmp/handoff_rc_badarch" as *u8, szp) 35 let rc2: *u8 = sys_read_file("/tmp/handoff_rc_noreq" as *u8, szp) 36 37 // T1: the blueprint speaks the FULL .site grammar the prod editor validates 38 var t1: i64=0 39 if hg_has(site, sn, "title|" as *u8)==1 { if hg_has(site, sn, "header|Nishi|" as *u8)==1 { 40 if hg_has(site, sn, "hero|" as *u8)==1 { if hg_count(site, sn, "card|" as *u8)>=6 { 41 if hg_count(site, sn, "step|" as *u8)>=3 { if hg_count(site, sn, "sig|" as *u8)>=3 { 42 if hg_has(site, sn, "footer|" as *u8)==1 { t1=1 } } } } } } } 43 // T2: the .req brief's REAL copy landed in the blueprint (data-layer handoff, not defaults) 44 var t2: i64=0 45 if hg_has(site, sn, "Hand-thrown stoneware mug" as *u8)==1 { if hg_has(site, sn, "Linen throw blanket" as *u8)==1 { t2=1 } } 46 // T3: nx_site_build REBUILT a whole site from the handoff blueprint (the andelinwest customize loop) 47 var t3: i64=0 48 if (idx as i64)!=0 { if hg_has(idx, iln, "class=\"skip-link\"" as *u8)==1 { if hg_has(idx, iln, "<nav class=\"top\">" as *u8)==1 { if hg_has(idx, iln, "Hand-thrown stoneware mug" as *u8)==1 { t3=1 } } } } 49 // T4: the rebuilt site self-emitted a sitemap listing home + one page per card 50 var t4: i64=0 51 if hg_count(sm, sml, "<loc>" as *u8) >= 7 { t4=1 } 52 // T5 (NEG): unknown archetype refused (exit 2) 53 var t5: i64=0 54 if (rc1 as i64)!=0 { if (rc1[0] as i64)==50 { t5=1 } } 55 // T6 (NEG): missing brief refused (exit 3) 56 var t6: i64=0 57 if (rc2 as i64)!=0 { if (rc2[0] as i64)==51 { t6=1 } } 58 59 var passes: i64=0 60 if t1==1 { passes=passes+1 } if t2==1 { passes=passes+1 } if t3==1 { passes=passes+1 } 61 if t4==1 { passes=passes+1 } if t5==1 { passes=passes+1 } if t6==1 { passes=passes+1 } 62 var green: i64=0; if passes==6 { green=1 } 63 64 gw("=== nx_site_handoff_gate -- R-HANDOFF factory -> prod-customizable .site ===\n" as *u8) 65 hg_row("T1-blueprint-full-grammar " as *u8, t1) 66 hg_row("T2-req-copy-landed " as *u8, t2) 67 hg_row("T3-prod-emitter-rebuilds-site " as *u8, t3) 68 hg_row("T4-sitemap-lists-pages " as *u8, t4) 69 hg_row("T5-unknown-arch-refused(neg) " as *u8, t5) 70 hg_row("T6-missing-brief-refused(neg) " as *u8, t6) 71 gw("verdict=" as *u8); if green==1 { gw("GREEN" as *u8) } else { gw("RED" as *u8) } 72 gw(" passes=" as *u8); gn(passes); gw("/6\n" as *u8) 73 74 let lg: i64 = sys_openat_append("knowledge/status/site_handoff.log" as *u8, 0x1a4) 75 if lg >= 0 { 76 if green==1 { let m: *u8 = "SITE-HANDOFF rows=6 pass=6 verdict=GREEN\n" as *u8; sys_write(lg, m, 41) } 77 else { let m2: *u8 = "SITE-HANDOFF verdict=RED\n" as *u8; sys_write(lg, m2, 25) } 78 sys_close(lg) 79 } 80 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 81 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 82 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 83 let ctr__dry: *i64 = gv_ctr() 84 ctr__dry[0] = green 85 ctr__dry[1] = 1 86 let rc__dry: i64 = gv_verdict("SITE-HANDOFF-GATE" as *u8, ctr__dry, "teeth unchanged; verdict emission migrated onto the shared base class" as *u8) 87 sys_exit(rc__dry) 88 return rc__dry 89}