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