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 bare top-level name (must be >=2 segments deep,
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
| 18 | const RP_NAMEBUF: i64 = 1024 |
functions
| 20 | 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 } |
| 21 | 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 } |
| 23 | func rt_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 25 | func rt_has(s: *u8, lit: *u8) -> i64 |
| 41 | func rt_ends(s: *u8, lit: *u8) -> i64 |
| 54 | func rt_refuse_secret(path: *u8) -> i64 |
| 63 | func rt_slashes(s: *u8) -> i64 called by 1: rt_refuse |
| 70 | func rt_refuse(path: *u8) -> i64 |
| 106 | func rt_flatten(dst: *u8, src: *u8) -> i64 called by 1: rt_retire |
| 116 | func rt_cat(dst: *u8, off: i64, s: *u8) -> i64 called by 1: rt_retire |
| 124 | func rt_retire(path: *u8) -> i64 |
| 161 | func main(argc: i64, argv: *i64) -> i64 |