code wiki / _hdl_build / nx_collision_resolve_sovaudit.nx

nx_collision_resolve_sovaudit.nx source

↩ module page · 39 lines · 2851 B

1// nx_collision_resolve_sovaudit.nx -- one-shot SOVEREIGN resolver for the nx_sovereignty_audit shadow collision 2// (the highest-value of the 22). Ecosystem-grep (nx_buildsearch_gate) confirmed the _hdl_build CHECKER's only 3// functional referrer is its gate (via a MANUAL /tmp/*.sov.elf prereq, no auto-builder) -- so renaming it is 4// safe + tiny. This RENAMES the checker in place via sys_renameat (sovereign, reversible -- rename back to undo; 5// NO delete), freeing the name so `nx_sov_build_run nx_sovereignty_audit` resolves to the runtime/ debt WALKER. 6// SAFETY: aborts unless the checker exists, the walker exists (collision real), AND the new name is free (no 7// clobber). Pair: update nx_sovereignty_audit_gate.nx's /tmp path to the new name. license_tier: ORIGINAL 8import "nx_syscalls.nx" 9 10const CHK_OLD: *u8 = "runtime/_hdl_build/nx_sovereignty_audit.nx" 11const CHK_NEW: *u8 = "runtime/_hdl_build/nx_sov_import_lint.nx" 12const WALKER: *u8 = "runtime/nx_sovereignty_audit.nx" 13 14func rw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func rexists(p: *u8) -> i64 { let fd: i64=sys_openat_rd(p); if fd>=0 { sys_close(fd); return 1 } return 0 } 16 17func main() -> i64 { 18 rw("=== resolve nx_sovereignty_audit collision: rename the _hdl_build checker (sovereign, reversible) ===\n" as *u8) 19 let has_chk: i64=rexists(CHK_OLD); let has_walk: i64=rexists(WALKER); let has_new: i64=rexists(CHK_NEW) 20 rw(" checker exists=\x00" as *u8); if has_chk==1 { rw("yes\x00" as *u8) } else { rw("no\x00" as *u8) } 21 rw(" walker exists=\x00" as *u8); if has_walk==1 { rw("yes\x00" as *u8) } else { rw("no\x00" as *u8) } 22 rw(" new-name free=\x00" as *u8); if has_new==0 { rw("yes\x00" as *u8) } else { rw("no\x00" as *u8) } 23 rw("\n" as *u8) 24 if has_chk != 1 { rw(" ABORT: checker not found (already resolved?)\n" as *u8); sys_exit(1); return 1 } 25 if has_walk != 1 { rw(" ABORT: walker not found (no collision to resolve)\n" as *u8); sys_exit(1); return 1 } 26 if has_new != 0 { rw(" ABORT: new name already exists (would clobber)\n" as *u8); sys_exit(1); return 1 } 27 28 let rc: i64 = sys_renameat(CHK_OLD, CHK_NEW) 29 if rc != 0 { rw(" ABORT: renameat failed\n" as *u8); sys_exit(1); return 1 } 30 31 let old_gone: i64=rexists(CHK_OLD); let new_here: i64=rexists(CHK_NEW) 32 if old_gone==0 { if new_here==1 { 33 rw(" RENAMED: _hdl_build/nx_sovereignty_audit.nx -> nx_sov_import_lint.nx\n" as *u8) 34 rw(" COLLISION RESOLVED: 'nx_sovereignty_audit' now resolves to the runtime/ debt WALKER (22 -> 21).\n" as *u8) 35 rw(" NEXT: update nx_sovereignty_audit_gate.nx /tmp path to nx_sov_import_lint.sov.elf; revert = rename back.\n" as *u8) 36 sys_exit(0); return 0 37 } } 38 rw(" WARN: post-rename state unexpected -- check manually\n" as *u8); sys_exit(1); return 1 39}