code wiki / _hdl_build / nx_migrate_ingest_gate.nx

nx_migrate_ingest_gate.nx source

↩ module page · 77 lines · 3958 B

1// nx_migrate_ingest_gate.nx -- SOVEREIGN in-process gate for the site-migration ingest transform. Feeds a 2// fixture HTML page straight into the PURE mi_emit_site and asserts the emitted .site blueprint: title/header 3// (with CTA)/hero/search/cards/trust/footer all present (so nx_site_provision's compliance check will pass), 4// the <title>/<h1>/<p>/<h2> text is actually extracted, nested tags are stripped, AND -- the load-bearing 5// safety check -- the '|' delimiter is SANITIZED out of extracted text (a leaked '|' corrupts the format). 6// GREEN iff T1..T7. license_tier: ORIGINAL 7import "nx_migrate_ingest.nx" 8import "nx_syscalls.nx" 9 10func g_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 11func g_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 12func g_row(name: *u8, ok: i64) -> i64 { 13 if ok == 1 { g_w(" PASS " as *u8) } else { g_w(" FAIL " as *u8) } 14 g_w(name); g_w("\n" as *u8) 15 return ok 16} 17func g_contains(hay: *u8, n: i64, needle: *u8) -> i64 { 18 let nn: i64 = g_len(needle) 19 var i: i64 = 0 20 while i + nn <= n { 21 var m: i64 = 1 22 var j: i64 = 0 23 while j < nn { if (hay[i + j] as i64) != (needle[j] as i64) { m = 0; j = nn } else { j = j + 1 } } 24 if m == 1 { return 1 } 25 i = i + 1 26 } 27 return 0 28} 29 30func main() -> i64 { 31 g_w("migrate-ingest SOVEREIGN gate (pure HTML -> .site transform, in-process, no fetch)\n" as *u8) 32 let html: *u8 = "<!DOCTYPE html><html><head><title>Jason West Law</title></head><body><h1>Trusted Utah Counsel|Since 1998</h1><p>We help families <a href=\"x\">and</a> businesses.</p><h2>Practice Areas</h2><p>x</p><h2>Contact Us</h2></body></html>" as *u8 33 let hn: i64 = g_len(html) 34 let out: *u8 = sys_mmap(262144) 35 let on: i64 = mi_emit_site(html, hn, "jasonewest.com" as *u8, 14, out) 36 var pass: i64 = 0 37 38 var t1: i64 = g_contains(out, on, "title|Jason West Law" as *u8) 39 pass = pass + g_row("T1 <title> extracted -> title|Jason West Law\x00" as *u8, t1) 40 41 var t2: i64 = g_contains(out, on, "header|Jason West Law|Contact|#contact" as *u8) 42 pass = pass + g_row("T2 header| has brand + CTA (#contact)\x00" as *u8, t2) 43 44 var t3: i64 = g_contains(out, on, "hero|Trusted Utah Counsel Since 1998|" as *u8) 45 pass = pass + g_row("T3 <h1> -> hero| with the '|' sanitized to space\x00" as *u8, t3) 46 47 var t4: i64 = g_contains(out, on, "We help families and businesses." as *u8) 48 pass = pass + g_row("T4 first <p> extracted with nested <a> stripped\x00" as *u8, t4) 49 50 var t5: i64 = 0 51 if g_contains(out, on, "card|Practice Areas" as *u8) == 1 { if g_contains(out, on, "card|Contact Us" as *u8) == 1 { t5 = 1 } } 52 pass = pass + g_row("T5 <h2> headings -> cards (Practice Areas + Contact Us)\x00" as *u8, t5) 53 54 var t6: i64 = 0 55 if g_contains(out, on, "search|/search" as *u8) == 1 { 56 if g_contains(out, on, "\ntrust|" as *u8) == 1 { 57 if g_contains(out, on, "footer|jasonewest.com" as *u8) == 1 { t6 = 1 } 58 } 59 } 60 pass = pass + g_row("T6 compliance fields present (search/trust/footer) -> provision-ready\x00" as *u8, t6) 61 62 // SAFETY neg-control: the '|' from the <h1> must NOT survive into the output (would corrupt the .site format). 63 var leak: i64 = g_contains(out, on, "Counsel|Since" as *u8) 64 var t7: i64 = 0 65 if leak == 0 { t7 = 1 } 66 pass = pass + g_row("T7 NEG: raw '|' did NOT leak into the blueprint (delimiter-safe)\x00" as *u8, t7) 67 68 if pass == 7 { 69 let lg: i64 = sys_openat_append("knowledge/status/migrate_ingest_gate.log" as *u8, 0x1a4) 70 if lg >= 0 { sys_write(lg, "MIGRATE-INGEST-GATE pass=7/7 verdict=GREEN\n" as *u8, 42); sys_close(lg) } 71 g_w("MIGRATE-INGEST GATE GREEN 7/7 (HTML -> compliant .site, tags stripped, delimiter-safe)\n" as *u8) 72 sys_exit(0) 73 } 74 g_w("MIGRATE-INGEST GATE RED\n" as *u8) 75 sys_exit(1) 76 return 1 77}