code wiki / _hdl_build / nx_pub_ship_meet_gate.nx

nx_pub_ship_meet_gate.nx source

↩ module page · 63 lines · 5085 B

1import "nx_gate_gn.nx" 2// nx_pub_ship_meet_gate.nx -- proves the FULL governed WET SHIP of the meet bundle end-to-end. ENGINEER ROOT-CAUSE 3// (tech debt resolved): pub_run_governed is sound; the earlier crash was running the wet drain against the POLLUTED 4// shared knowledge/publish/ dir -- a CLEAN per-workstream dir (rp_path) works (proven by nx_pub_drain_diag G=3). So: 5// fresh isolated stage/live/appr -> submit 3 meet pages (outward) + operator pub_approve each by sha -> drain 6// (verify-sha + atomic-promote) -> the pages land LIVE, sovereign; the UNAPPROVED page is HELD (fail-closed). This 7// is the definitive "the meet site ships wet, end-to-end" proof -- exactly what the daemon does on the host. expect_exit: 0 8import "nx_syscalls.nx" 9import "nx_publisher.nx" 10import "nx_runpath.nx" 11 12func gp(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func dmk(p: *u8) -> i64 { __syscall(83, p as i64, 493, 0, 0, 0, 0); return 0 } 14func djoin(d: *u8, name: *u8) -> *u8 { let p: *u8 = sys_mmap(700); pub_join(d, name, p); return p } 15func dunlink(path: *u8) -> i64 { __syscall(87, path as i64, 0, 0, 0, 0, 0); return 0 } 16func gexists(path: *u8) -> i64 { let lp: *i64 = sys_mmap(16) as *i64; lp[0]=0; let d: *u8 = sys_read_file(path, lp); if (d as i64)==0 { return 0 } return 1 } 17func ghas(path: *u8, needle: *u8) -> i64 { let lp: *i64 = sys_mmap(16) as *i64; lp[0]=0; let d: *u8 = sys_read_file(path, lp); if (d as i64)==0 { return 0 } return pub_substr(d, lp[0], needle) } 18 19func main() -> i64 { 20 gp("=== nx_pub_ship_meet_gate: FULL governed WET SHIP of the meet bundle (submit -> approve -> drain -> LIVE) ===\n" as *u8) 21 let wsid: *u8 = sys_mmap(64); rp_wsid(wsid); rp_ensure(wsid) 22 let D: *u8 = sys_mmap(512); rp_path(wsid, "meetship" as *u8, D); dmk(D) 23 let stage: *u8 = djoin(D, "stage" as *u8); dmk(stage) 24 let live: *u8 = djoin(D, "live" as *u8); dmk(live) 25 let appr: *u8 = djoin(D, "appr" as *u8); dmk(appr) 26 let q: *u8 = djoin(D, "q.tsv" as *u8); dunlink(q) 27 let led: *u8 = djoin(D, "led.tsv" as *u8); dunlink(led) 28 29 // submit 3 representative meet pages (outward) + operator pub_approve each by content sha 30 var approved: i64 = 0 31 let s1: *u8 = "web_assets/site_demo/index.html" as *u8; let h1: *u8 = sys_mmap(72) 32 if pub_sha_file(s1, h1) == 1 { pub_submit_to(q, s1, "meet/index.html" as *u8, "meet" as *u8, "meet-ship" as *u8, "outward" as *u8); if pub_approve(h1, appr)==1 { approved=approved+1 } } 33 let s2: *u8 = "web_assets/site_demo/jobs.html" as *u8; let h2: *u8 = sys_mmap(72) 34 if pub_sha_file(s2, h2) == 1 { pub_submit_to(q, s2, "meet/jobs.html" as *u8, "meet" as *u8, "meet-ship" as *u8, "outward" as *u8); if pub_approve(h2, appr)==1 { approved=approved+1 } } 35 let s3: *u8 = "web_assets/site_demo/apply.html" as *u8; let h3: *u8 = sys_mmap(72) 36 if pub_sha_file(s3, h3) == 1 { pub_submit_to(q, s3, "meet/apply.html" as *u8, "meet" as *u8, "meet-ship" as *u8, "outward" as *u8); if pub_approve(h3, appr)==1 { approved=approved+1 } } 37 // an UNAPPROVED page (distinct src -> distinct sha, never approved) -> must be HELD 38 pub_submit_to(q, "web_assets/meet_demo.meet" as *u8, "meet/unapproved.html" as *u8, "meet" as *u8, "meet-ship" as *u8, "outward" as *u8) 39 40 gp(" approved=" as *u8); gn(approved); gp("/3 ; draining (clean isolated dir)...\n" as *u8) 41 let published: i64 = pub_run_governed(q, led, stage, live, "meetship_lock" as *u8, appr) 42 gp(" published=" as *u8); gn(published); gp("\n" as *u8) 43 44 let idx: *u8 = djoin(live, "meet/index.html" as *u8) 45 let jobs: *u8 = djoin(live, "meet/jobs.html" as *u8) 46 let apply: *u8 = djoin(live, "meet/apply.html" as *u8) 47 let unap: *u8 = djoin(live, "meet/unapproved.html" as *u8) 48 49 var pass: i64 = 0; var fail: i64 = 0 50 if approved == 3 { pass=pass+1 } else { fail=fail+1; gp(" FAIL not-all-approved\n" as *u8) } 51 if published == 3 { pass=pass+1 } else { fail=fail+1; gp(" FAIL not-3-published\n" as *u8) } 52 if gexists(idx) == 1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL index-not-live\n" as *u8) } 53 if ghas(idx, "Community Meet" as *u8) == 1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL live-no-brand\n" as *u8) } 54 if ghas(idx, "<script" as *u8) == 0 { pass=pass+1 } else { fail=fail+1; gp(" FAIL live-has-script\n" as *u8) } 55 if gexists(jobs) == 1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL jobs-not-live\n" as *u8) } 56 if gexists(apply) == 1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL apply-not-live\n" as *u8) } 57 if gexists(unap) == 0 { pass=pass+1 } else { fail=fail+1; gp(" FAIL unapproved-leaked-live\n" as *u8) } 58 if ghas(led, "meet/index.html" as *u8) == 1 { pass=pass+1 } else { fail=fail+1; gp(" FAIL ledger-missing-entry\n" as *u8) } 59 60 gp("MEET-SHIP-GATE pass=" as *u8); gn(pass); gp(" fail=" as *u8); gn(fail) 61 if fail == 0 { gp(" verdict=GREEN (FULL WET SHIP: 3 approved -> verify-sha -> promoted LIVE + ledgered; unapproved HELD fail-closed)\n" as *u8); sys_exit(0); return 0 } 62 gp(" verdict=RED\n" as *u8); sys_exit(1); return 1 63}