code wiki / _hdl_build / nx_revive_register.nx

nx_revive_register.nx source

↩ module page · 39 lines · 3347 B

1// nx_revive_register.nx -- records the crash-recovery rungs CR1-CR3. Engineer gate = the 9-row 2// crash drill (nx_revive_gate) green, fresh, on THIS run. Registered via Librarian alloc + 3// dual-write. license_tier: ORIGINAL 4import "nx_cap_register.nx" 5import "nx_capreg_librarian.nx" 6import "nx_syscalls.nx" 7 8func rr_run(path: *u8) -> i64 { 9 let pid: i64 = sys_fork() 10 if pid == 0 { 11 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4) 12 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) } 13 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0 14 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0 15 sys_execve(path, argv, envp); sys_exit(127) 16 } 17 let st: *i64 = sys_mmap(16) as *i64 18 sys_wait4(pid, st, 0) 19 return st[0] 20} 21 22func main() -> i64 { 23 var allok: i64 = 1 24 if rr_run("/tmp/nx_revive_gate.sov.elf" as *u8) != 0 { allok = 0 } 25 cr_w(1, "ENGINEER: 9-row crash drill fresh-run all-pass=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8) 26 let eng: i64 = ig_engineer(1, 1, 1, allok) 27 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1) 28 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) } 29 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) } 30 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 31 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 32 let idx: i64 = cl_next_idx(lp, jp) 33 let ok: i64 = cl_register_dual(lp, jp, idx, 5, 34 2, "HEAL BOOT-REVIVE CR1-CR3 (crash-recovery ladder, spec 2026-06-10-crash-recovery-ladder.md; operator: team must recover from sudden/overnight crashes of fragile command-prompt systems with ZERO sessions). The 2026-06-10 reboot proved recovery REQUIRED a live session (daemon restarted only by hand; self-heal lazy). CR1 nx_boot_revive (Doctor, verb=HEAL): boot detect via now-/proc/uptime -> ONE durable BOOT row per boot in boot_journal.log incl dark_gap (substrate downtime MEASURED from last DAEMON-BEAT); proactive rebuild of every absent-but-recoverable E-row organ via _offc/nx_sov_build_run.elf each under a hard per-organ watchdog (conf B row; WNOHANG poll + SIGKILL reap -- a hung build can never wedge boot); D-row daemons re-armed idempotently (pidfile dup-guard). CR2 zero-session hooks: systemd nx-boot-revive.service enabled (ANY WSL start revives; settled source knowledge/boot/) + Windows ONLOGON task NishiBootRevive (wsl --cd repo -e _offc/nx_boot_revive.elf; live-fired LastTaskResult=0); blessed durable _offc/nx_boot_revive.elf (survives what it heals). CR3 nx_revive_gate (Engineer, verb=TEST) 9-row fault-injection drill ALL-GREEN first run: fail-loud conf, REAL organ delete->revive, idempotence (organs_revived=0), no-source tamper RED, W-lane honesty RED, boot-journal exactly-once, armed nx_drill_hang reaped at 2054ms under B=2s, REAL pulse-daemon SIGKILL (pid cmdline-verified vs OWN pidfile -- concurrent-session safe) -> re-armed, production run real conf GREEN; durable crash_drill.log. NEXT CR4 intent-WAL CR5 examiner crash-awareness CR6 ONSTART/NAS-watch" as *u8) 35 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) } 36 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED -- crash recovery is now a sessionless capability\n" as *u8) 37 sys_exit(0) 38 return 0 39}