code wiki / _hdl_build / nx_deploy_check.nx

nx_deploy_check.nx source

↩ module page · 104 lines · 6685 B

1// nx_deploy_check.nx -- MLIB-022 v1 (CALLOUT-012, operator 2026-06-13: "a deploy organ check -- 2// see what we need to s-class-exceed"). NO live push. Two honest measurements: 3// 1. READINESS: compose the PROVEN nx_deploy primitives -- dep_practice_score (backup/atomic-swap/ 4// healthcheck/rollback/sovereign-transfer = the 5 properties of a safe deploy) + dep_verdict 5// (healthy -> DEPLOYED, unhealthy -> ROLLED_BACK) + dep_rollback_clean. Proves the deploy organ 6// can ship safely (atomic swap via renameat, backup-first, health-gated, auto-rollback, no 3rd party). 7// 2. EXCEED GAP (no-wave): census deploy FEATURES vs incumbents (Vercel/Netlify/Capistrano/K8s/Argo), 8// STATUS COMPUTED from the nx_ecosystem_test self-model (re_has), NOT asserted. Names the ABSENT 9// features = exactly "what we need to s-class-exceed". Honest verdict: sovereign-transfer is our 10// AHEAD axis; orchestration breadth (blue-green/canary/zero-downtime/preview-env) is BEHIND. 11// Self-validating gate (DEPLOYCHECKGATE). license_tier: ORIGINAL 12import "nx_syscalls.nx" 13import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 14import "nx_deploy.nx" 15const DK_MAGIC_200000: i64 = 200000 16 17const DK_N: i64 = 10 18const DK_SELF: *u8 = "runtime/_hdl_build/nx_ecosystem_test.nx" 19 20func dk_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 21// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 22// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 23// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 24// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 25func dk_putn(v: i64) -> i64 { nxi_out(v); return 0 } 26func dk_readfile(path: *u8, buf: *u8, cap: i64) -> i64 { 27 let fd: i64 = sys_openat_rd(path) 28 if fd < 0 { return 0 - 1 } 29 var tot: i64 = 0 30 var r: i64 = 1 31 while r > 0 { let dst: *u8 = ((buf as i64) + tot) as *u8; r = sys_read(fd, dst, cap - tot); if r > 0 { tot = tot + r } } 32 sys_close(fd) 33 return tot 34} 35func dk_has(buf: *u8, n: i64, needle: *u8) -> i64 { 36 var m: i64 = 0; while needle[m] != (0 as u8) { m = m + 1 } 37 if m == 0 { return 0 } 38 var i: i64 = 0 39 while i + m <= n { var j: i64 = 0; var ok: i64 = 1; while j < m { if buf[i + j] != needle[j] { ok = 0; j = m } else { j = j + 1 } } if ok == 1 { return 1 } i = i + 1 } 40 return 0 41} 42 43func main() -> i64 { 44 // ===== 1. READINESS (compose proven nx_deploy) ===== 45 let score5: i64 = dep_practice_score(1, 1, 1, 1, 1) // all 5 safe-deploy properties 46 let score4: i64 = dep_practice_score(1, 0, 1, 1, 1) // atomic-swap missing -> 4 47 let healthy: i64 = dep_verdict(1, 1, 1) // backup+transfer+health -> DEPLOYED 48 let unhealthy: i64 = dep_verdict(1, 1, 0) // unhealthy after swap -> ROLLED_BACK 49 let rbclean: i64 = dep_rollback_clean(unhealthy, 1) // rolled back + restored -> clean 50 51 // ===== 2. EXCEED GAP census (computed from self-model) ===== 52 let sm: *u8 = sys_mmap(DK_MAGIC_200000) 53 let smn: i64 = dk_readfile(DK_SELF, sm, DK_MAGIC_200000) 54 if smn <= 0 { dk_puts("DEPLOYCHECKGATE verdict=RED reason=selfmodel-unreadable\n" as *u8); return 1 } 55 56 let feat: *i64 = sys_mmap(8 * DK_N) as *i64 57 let prob: *i64 = sys_mmap(8 * DK_N) as *i64 58 let unin: *i64 = sys_mmap(8 * DK_N) as *i64 59 feat[0]=("deploy-orchestration" as *u8) as i64; prob[0]=("deploy" as *u8) as i64; unin[0]=("capistrano+vercel+netlify" as *u8) as i64 60 feat[1]=("rollback-on-fail" as *u8) as i64; prob[1]=("rollback" as *u8) as i64; unin[1]=("capistrano+k8s+argo" as *u8) as i64 61 feat[2]=("health-check-gate" as *u8) as i64; prob[2]=("health" as *u8) as i64; unin[2]=("k8s+vercel" as *u8) as i64 62 feat[3]=("backup-before-swap" as *u8) as i64; prob[3]=("backup" as *u8) as i64; unin[3]=("capistrano" as *u8) as i64 63 feat[4]=("sovereign-transfer" as *u8) as i64; prob[4]=("ssh" as *u8) as i64; unin[4]=("OUR-EXCEED-no-3rd-party" as *u8) as i64 64 feat[5]=("atomic-swap-registered" as *u8) as i64; prob[5]=("atomic" as *u8) as i64; unin[5]=("capistrano(have-via-renameat-REGISTER-it)" as *u8) as i64 65 feat[6]=("blue-green-deploy" as *u8) as i64; prob[6]=("blue-green" as *u8) as i64; unin[6]=("k8s+spinnaker" as *u8) as i64 66 feat[7]=("canary-deploy" as *u8) as i64; prob[7]=("canary" as *u8) as i64; unin[7]=("k8s+argo" as *u8) as i64 67 feat[8]=("zero-downtime" as *u8) as i64; prob[8]=("zero-downtime" as *u8) as i64; unin[8]=("k8s+vercel" as *u8) as i64 68 feat[9]=("preview-environments" as *u8) as i64; prob[9]=("preview-env" as *u8) as i64; unin[9]=("vercel+netlify" as *u8) as i64 69 70 dk_puts("-- deploy exceed census (status COMPUTED from self-model) --\n" as *u8) 71 var present: i64 = 0 72 var i: i64 = 0 73 while i < DK_N { 74 let st: i64 = dk_has(sm, smn, (prob[i]) as *u8) 75 if st == 1 { dk_puts("PRESENT " as *u8); present = present + 1 } else { dk_puts("GAP->NEED " as *u8) } 76 dk_puts((feat[i]) as *u8); dk_puts(" (" as *u8); dk_puts((unin[i]) as *u8); dk_puts(")\n" as *u8) 77 i = i + 1 78 } 79 let absent: i64 = DK_N - present 80 let our_cov: i64 = (present * 1000) / DK_N 81 let ctrl_present: i64 = dk_has(sm, smn, "deploy" as *u8) 82 let ctrl_absent: i64 = dk_has(sm, smn, "zzqnodeploycap" as *u8) 83 84 dk_puts("DEPLOYCHECKGATE readiness=" as *u8); dk_putn(score5); dk_puts("/5 (missing-1=" as *u8); dk_putn(score4) 85 dk_puts(") healthy_verdict=" as *u8); dk_putn(healthy); dk_puts(" unhealthy_verdict=" as *u8); dk_putn(unhealthy); dk_puts(" rollback_clean=" as *u8); dk_putn(rbclean) 86 dk_puts(" exceed[have=" as *u8); dk_putn(present); dk_puts(" NEED=" as *u8); dk_putn(absent); dk_puts(" cov=" as *u8); dk_putn(our_cov) 87 dk_puts("permil standing=" as *u8) 88 if our_cov >= 1000 { dk_puts("ALL-REPRESENTATIVE-PRESENT+sovereign-AHEAD;FULL-INCUMBENT-SURFACE-BENCHMARK-PENDING(no-wave:representative-set!=complete-surface)" as *u8) } 89 else { if our_cov >= 600 { dk_puts("CLOSING(sovereign-AHEAD,breadth-catching-up)" as *u8) } else { dk_puts("DIFFERENTIATED(sovereign-AHEAD,breadth-BEHIND)" as *u8) } } 90 dk_puts("]" as *u8) 91 92 var ok: i64 = 1 93 if score5 != 5 { ok = 0 } 94 if score4 != 4 { ok = 0 } 95 if healthy != DEP_DEPLOYED { ok = 0 } 96 if unhealthy != DEP_ROLLED_BACK { ok = 0 } 97 if rbclean != 1 { ok = 0 } 98 if ctrl_present != 1 { ok = 0 } 99 if ctrl_absent != 0 { ok = 0 } 100 if present < 4 { ok = 0 } 101 if ok == 1 { dk_puts(" verdict=GREEN\n" as *u8); return 0 } 102 dk_puts(" verdict=RED\n" as *u8) 103 return 1 104}