code wiki / _hdl_build / nx_retire_path.nx

nx_retire_path.nx

buildroot/runtime/_hdl_build/nx_retire_path.nx

32666 B524 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic retire
docsdependenciesstructsconstsfunctions

about

nx_retire_path.nx -- the missing sovereign primitive: take a file or directory OUT of a served tree without ever deleting it. The estate had governance/atlas/debt sweeps but nothing that could retire a path, so scratch artifacts accumulated on PUBLIC surfaces and the only "fix" anyone had was ssh rm. SAFE BY CONSTRUCTION (mirrors the established md_promote_deny substring-deny pattern rather than inventing a new safety model): * NEVER deletes -- sys_renameat only, so the bytes survive and the move is reversible (rule 13). * moves INTO knowledge/retired/ (outside every docroot) so a retired path stops being served. * REFUSES: any path containing ".." (traversal), a shallow path -- the rule COUNTS SLASHES and needs at least 2, i.e. dir/subdir/file, so `knowledge/x.tsv` is REFUSED while `knowledge/status/x.tsv` is allowed. (The message used to say "must be >=2 segments deep", which names the wrong unit and reads as satisfied by the very path it rejects; corrected 2026-08-14 after it sent a caller hunting.) so it can never retire a whole docroot or a hub-root file), and any path whose name carries a dangerous substring (elf, key, cap, secret, opaque, .reg, .conf, daemon, serve, vault, mint). * REFUSES a target that does not exist -- a no-op must never look like a success. verbs: retire <path> | selftest expect_exit: 0 license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_emit_guard.nx nx_retire_path.nx

imports: nx_syscalls.nxnx_emit_guard.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main rt_say sys_write sys_exit rt_has rt_len rt_refuse rt_len ↻ rt_has ↻ rt_ends rt_len ↻ rt_refuse_secret rt_deny_n rt_deny_is_secret rt_has ↻ rt_deny_tok rt_slashes rt_starts rt_deny_n ↻ rt_deny_tok ↻ rt_retire rt_refuse ↻ rt_say ↻ rt_num sys_write ↻ sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻

structs

none

consts

21const RP_NAMEBUF: i64 = 1024
125const RT_COMPARE_ROOT: *u8 = "sites/nishifamily/compare/"
126const RT_COMPARE_MIN_SLASHES: i64 = 4
127const RT_SLASH: i64 = 47
223const RT_SERVED_ROOT: *u8 = "sites/"

functions

23func rt_say(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: rt_retirert_retiredirmain calls 1: sys_write
24func rt_num(v: i64) -> i64 { if v == 0 { sys_write(1, "0" as *u8, 1); return 0 } var m: i64 = v; if m < 0 { sys_write(1, "-" as *u8, 1); m = 0 - m } let t: *u8 = sys_mmap(28); var k: i64 = 0; while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } while k > 0 { k = k - 1; sys_write(1, (((t as i64) + k) as *u8), 1) } return 0 }
26func rt_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
28func rt_has(s: *u8, lit: *u8) -> i64
44func rt_ends(s: *u8, lit: *u8) -> i64
called by 1: rt_refuse calls 1: rt_len
71func rt_deny_n() -> i64 { return 11 }
72func rt_deny_tok(i: i64) -> *u8
90func rt_deny_is_secret(i: i64) -> i64
called by 1: rt_refuse_secret
99func rt_refuse_secret(path: *u8) -> i64
111func rt_starts(s: *u8, lit: *u8) -> i64
119func rt_slashes(s: *u8) -> i64
129func rt_refuse(path: *u8) -> i64
225func rt_same(a: *u8, b: *u8) -> i64
called by 2: rt_refuse_dirmain
235func rt_refuse_dir(path: *u8, confirm: *u8) -> i64
252func rt_flatten(dst: *u8, src: *u8) -> i64
262func rt_cat(dst: *u8, off: i64, s: *u8) -> i64
280func rt_reason(code: i64) -> *u8
292func rt_retire(path: *u8) -> i64
339func rt_retiredir(path: *u8, confirm: *u8) -> i64
379func main(argc: i64, argv: *i64) -> i64