code wiki / _hdl_build / nx_capreg_restore.nx

nx_capreg_restore.nx source

↩ module page · 21 lines · 1128 B

1// nx_capreg_restore.nx -- the LIBRARIAN's production registry repair driver: canonicalize the NTFS 2// journal (dedup the snapshot bloat, renumber the 212-227 cross-session collisions ONCE) and restore 3// the crash-wiped live registry at /tmp/nishi_cap_registry.log. Idempotent: re-running on the 4// canonical journal is a pure dedup (KAT-proven stable). Run from the repo root. license_tier: ORIGINAL 5import "nx_capreg_librarian.nx" 6import "nx_syscalls.nx" 7 8func main() -> i64 { 9 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8 10 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8 11 let before: i64 = cl_max_idx(jp) 12 let nu: i64 = cl_canonicalize(jp, lp) 13 if nu < 0 { cl_w(1, "RESTORE FAILED\n" as *u8); sys_exit(1) } 14 cl_w(1, "LIBRARIAN RESTORE: unique entries=" as *u8); cl_wn(1, nu) 15 cl_w(1, " max_idx_before=" as *u8); cl_wn(1, before) 16 cl_w(1, " max_idx_after=" as *u8); cl_wn(1, cl_max_idx(jp)) 17 cl_w(1, " next_alloc=" as *u8); cl_wn(1, cl_next_idx(lp, jp)) 18 cl_w(1, "\nlive=/tmp/nishi_cap_registry.log journal=canonical raw-archived\n" as *u8) 19 sys_exit(0) 20 return 0 21}