code wiki / _hdl_build / nx_retire_path.nx
nx_retire_path.nx
buildroot/runtime/_hdl_build/nx_retire_path.nx
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
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
structs
| none |
consts
| 21 | const RP_NAMEBUF: i64 = 1024 |
| 125 | const RT_COMPARE_ROOT: *u8 = "sites/nishifamily/compare/" |
| 126 | const RT_COMPARE_MIN_SLASHES: i64 = 4 |
| 127 | const RT_SLASH: i64 = 47 |
| 223 | const RT_SERVED_ROOT: *u8 = "sites/" |
functions
| 23 | func 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 } |
| 24 | func 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 } |
| 26 | func rt_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 28 | func rt_has(s: *u8, lit: *u8) -> i64 |
| 44 | func rt_ends(s: *u8, lit: *u8) -> i64 |
| 71 | func rt_deny_n() -> i64 { return 11 } |
| 72 | func rt_deny_tok(i: i64) -> *u8 |
| 90 | func rt_deny_is_secret(i: i64) -> i64 called by 1: rt_refuse_secret |
| 99 | func rt_refuse_secret(path: *u8) -> i64 |
| 111 | func rt_starts(s: *u8, lit: *u8) -> i64 |
| 119 | func rt_slashes(s: *u8) -> i64 |
| 129 | func rt_refuse(path: *u8) -> i64 |
| 225 | func rt_same(a: *u8, b: *u8) -> i64 |
| 235 | func rt_refuse_dir(path: *u8, confirm: *u8) -> i64 |
| 252 | func rt_flatten(dst: *u8, src: *u8) -> i64 |
| 262 | func rt_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 280 | func rt_reason(code: i64) -> *u8 |
| 292 | func rt_retire(path: *u8) -> i64 |
| 339 | func rt_retiredir(path: *u8, confirm: *u8) -> i64 |
| 379 | func main(argc: i64, argv: *i64) -> i64 |