code wiki / _hdl_build / nx_deploy_manifest_gate.nx

nx_deploy_manifest_gate.nx source

↩ module page · 73 lines · 4113 B

1// nx_deploy_manifest_gate.nx -- GATE: the NAS remote-access deploy manifest (one coordinated push, prereq-gated). 2// Steps: 0 cert -> 1 relay -> 2 gateway -> 3 OPAQUE-login -> 4 WAF -> 5 audit -> 6 mTLS. 3// T1 FIRST -- from nothing, the next step is the cert (prereq of everything). 4// T2 ORDER -- with cert+relay done, the next step is the gateway (prereq-gated). 5// T3 READY -- all 7 done -> ready; next = -1 (nothing left). 6// T4 HEALTH -- the API is live only when ALL components pass health; one down -> not live. 7// T5 NEVER-BRICK- deterministic. 8// GREEN iff all. Sovereign nx_cc->nxasm. Run this when networked to push the whole remote-access stack at once. expect_exit: 0 license_tier: ORIGINAL 9import "nx_deploy_manifest.nx" 10import "nx_syscalls.nx" 11 12func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func wn(v: i64) -> i64 { var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t:*u8=sys_mmap(24); var k:i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i:i64=0; let o:*u8=sys_mmap(24); while i<k{o[i]=t[k-1-i];i=i+1} sys_write(1,o,k); return 0 } 14 15func main() -> i64 { 16 w("=== nx_deploy_manifest_gate: NAS remote-access deploy manifest (cert->relay->gateway->OPAQUE->WAF->audit->mTLS) ===\n" as *u8) 17 var pass: i64 = 0; var total: i64 = 0 18 let n: i64 = 7 19 let nm: *i64=sys_mmap(8*8) as *i64 20 nm[0]="cert(*.nishifamily.com)" as *u8 as i64 21 nm[1]="sovereign-relay" as *u8 as i64 22 nm[2]="api-gateway" as *u8 as i64 23 nm[3]="OPAQUE-login" as *u8 as i64 24 nm[4]="WAF/DDoS" as *u8 as i64 25 nm[5]="audit-log" as *u8 as i64 26 nm[6]="mTLS" as *u8 as i64 27 let prereq: *i64=sys_mmap(8*8) as *i64 28 prereq[0]=0-1; prereq[1]=0; prereq[2]=1; prereq[3]=2; prereq[4]=2; prereq[5]=2; prereq[6]=3 29 let done: *i64=sys_mmap(8*8) as *i64 30 let i: i64 = 0 31 var z: i64 = 0; while z < n { done[z]=0; z=z+1 } 32 33 // emit the plan 34 w(" --- DEPLOY PLAN ---\n" as *u8) 35 z = 0; while z < n { w(" " as *u8); wn(z); w(". " as *u8); w(nm[z] as *u8); w("\n" as *u8); z=z+1 } 36 37 // T1 first step 38 let s1: i64 = mf_next(done, prereq, n) 39 total=total+1; if s1==0 { pass=pass+1; w(" [PASS] " as *u8) } else { w(" [FAIL] " as *u8) } 40 w("T1 first: next step = " as *u8); wn(s1); w(" (" as *u8); w(nm[0] as *u8); w(", prereq of all)\n" as *u8) 41 42 // T2 order 43 done[0]=1; done[1]=1 44 let s2: i64 = mf_next(done, prereq, n) 45 total=total+1; if s2==2 { pass=pass+1; w(" [PASS] " as *u8) } else { w(" [FAIL] " as *u8) } 46 w("T2 order: cert+relay done -> next = " as *u8); wn(s2); w(" (" as *u8); w(nm[2] as *u8); w(")\n" as *u8) 47 48 // T3 ready 49 z = 0; while z < n { done[z]=1; z=z+1 } 50 let rdy: i64 = mf_ready(done, n) 51 let s3: i64 = mf_next(done, prereq, n) 52 total=total+1; if rdy==1 { if s3==(0-1) { pass=pass+1; w(" [PASS] " as *u8) } else { w(" [FAIL] " as *u8) } } else { w(" [FAIL] " as *u8) } 53 w("T3 ready: all 7 done ready=" as *u8); wn(rdy); w(" next=" as *u8); wn(s3); w("\n" as *u8) 54 55 // T4 health 56 let up: *i64=sys_mmap(8*8) as *i64 57 z = 0; while z < n { up[z]=1; z=z+1 } 58 let h1: i64 = mf_health(up, n) 59 up[2]=0 60 let h2: i64 = mf_health(up, n) 61 total=total+1; if h1==1 { if h2==0 { pass=pass+1; w(" [PASS] " as *u8) } else { w(" [FAIL] " as *u8) } } else { w(" [FAIL] " as *u8) } 62 w("T4 health: all-up live=" as *u8); wn(h1); w(" ; gateway-down live=" as *u8); wn(h2); w(" (live only when ALL healthy)\n" as *u8) 63 64 // T5 never-brick 65 z = 0; while z < n { up[z]=1; z=z+1 } 66 let h3: i64 = mf_health(up, n) 67 total=total+1; if h3==1 { pass=pass+1; w(" [PASS] " as *u8) } else { w(" [FAIL] " as *u8) } 68 w("T5 never-brick: deterministic (live=" as *u8); wn(h3); w(")\n" as *u8) 69 70 w("\n=== nx_deploy_manifest_gate " as *u8); wn(pass); w("/" as *u8); wn(total) 71 if pass == total { w(" GREEN (deploy manifest: ordered prereq-gated push, health-verified; run when networked to bring the whole remote API live)\n" as *u8); sys_exit(0); return 0 } 72 w(" RED\n" as *u8); sys_exit(1); return 1 73}