code wiki / _hdl_build / nx_hostop_sweep.nx

nx_hostop_sweep.nx source

↩ module page · 57 lines · 3543 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_hostop_sweep.nx -- the NISHI HOST OPERATOR required-gate sweep. Forks/execs the sovereign build runner on each 4// host-operator gate; RED if ANY fails. The canonical "these must be GREEN to ship the host-operator role" set: the 5// role census + the receive contract + atomic-apply/rollback/never-brick + the no-direct-host law + dns-apply. 6// Same fork/exec idiom as nx_pub_sweep. CWD must be nxc2. license_tier: ORIGINAL 7import "nx_syscalls.nx" 8 9const HSWEEP_RUNNER: *u8 = "_offc/nx_sov_build_run.elf" 10 11func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 12" as *u8); return ok } 13 14func run_gate(name: *u8) -> i64 { 15 let pid: i64 = sys_fork() 16 if pid == 0 { 17 let dn: i64 = sys_openat_wr("/dev/null\x00" as *u8, 420) 18 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 19 let argv: *i64 = sys_mmap(64) as *i64 20 argv[0] = HSWEEP_RUNNER as i64; argv[1] = name as i64; argv[2] = 0 21 let envp: *i64 = sys_mmap(16) as *i64 22 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0 23 sys_execve(HSWEEP_RUNNER, argv, envp) 24 sys_exit(127) 25 } 26 let st: *i64 = sys_mmap(16) as *i64 27 sys_wait4(pid, st, 0) 28 return (st[0] >> 8) & 0xff 29} 30func report(name: *u8, tally: *i64) -> i64 { 31 let code: i64 = run_gate(name) 32 gw(" " as *u8); gw(name); gw(": " as *u8) 33 if code == 0 { gw("GREEN\n" as *u8); tally[0] = tally[0] + 1 } else { gw("RED (exit " as *u8); gn(code); gw(")\n" as *u8); tally[1] = tally[1] + 1 } 34 return code 35} 36 37func main() -> i64 { 38 gw("=== nx_hostop_sweep: NISHI HOST OPERATOR required-gate sweep (owner of host-facing application) ===\n" as *u8) 39 let tally: *i64 = sys_mmap(16) as *i64 40 tally[0] = 0; tally[1] = 0 41 report("nx_hostop_census\x00" as *u8, tally) // role census 13/13 42 report("nx_hostop_receive_gate\x00" as *u8, tally) // R1 publisher coordination contract 43 report("nx_hostop_apply_gate\x00" as *u8, tally) // R2/R3/R5 atomic host-swap + rollback + never-brick 44 report("nx_hostop_law_gate\x00" as *u8, tally) // R4 no-direct-host law 45 report("nx_hostop_dns_gate\x00" as *u8, tally) // R6 dns-apply executor 46 report("nx_hostop_progressive_gate\x00" as *u8, tally) // R7 multi-host fan-out + rolling + blue-green 47 report("nx_hostop_state_gate\x00" as *u8, tally) // R8 drift + dry-run + idempotent 48 report("nx_hostop_obs_gate\x00" as *u8, tally) // R9 host history + DORA + notify 49 report("nx_hostop_recover_gate\x00" as *u8, tally) // R10 wedge-aware host recovery (pr_recover) 50 report("nx_hostop_ctl_gate\x00" as *u8, tally) // R11 control-plane: prehealth decision + supervise cmd 51 report("nx_hostop_watchdog_gate\x00" as *u8, tally) // R12 watchdog the publisher daemon (heartbeat->restart) 52 report("nx_hostop_func_census\x00" as *u8, tally) // honest S-class scorecard (10/22, liar-killed) 53 report("nx_pub_hostop_e2e_gate\x00" as *u8, tally) // publisher<->host-operator coordination capstone 54 gw("---\nGREEN=" as *u8); gn(tally[0]); gw(" RED=" as *u8); gn(tally[1]); gw(" total=" as *u8); gn(tally[0]+tally[1]); gw("\n" as *u8) 55 if tally[1] == 0 { gw("HOSTOP-SWEEP verdict=ALL-GREEN (host-operator role: receive->apply->verify->rollback, never-brick, no-direct-host)\n" as *u8); sys_exit(0); return 0 } 56 gw("HOSTOP-SWEEP verdict=REGRESSION\n" as *u8); sys_exit(1); return 1 57}