code wiki / _hdl_build / nx_dr_retention.nx
nx_dr_retention.nx
buildroot/runtime/_hdl_build/nx_dr_retention.nx
about
nx_dr_retention.nx -- CAP-DR-RETENTION (sovereign-format): versioned snapshot history + keep-policy on the
SOVEREIGN nx_seg_store (.docs append-only + .keys binary-search) -- NO TSV. A snapshot = a point-in-time
fingerprint of the archive = sha256(receipt.docs). Stored as key "snap-<id>" -> "<id> <epoch> <fp>", with a
"count" key so `policy` iterates snap-1..count via point lookups. ADDITIVE (append-only; never deletes -- history
sacred; prune is an explicit operator step). restic-`forget`-style keep-last-N.
nx_dr_retention snapshot <archive-dir>
nx_dr_retention policy <archive-dir> <keepN>
license_tier: ORIGINAL
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_sha256.nxnx_seg_store.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
| 12 | const K_MAGIC_1536: i64 = 1536 |
| 13 | const K_MAGIC_4194304: i64 = 4194304 |
functions
| 15 | func rt_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 16 | func rt_wn(v: i64) -> i64 { var t: i64=v; if t<0{sys_write(1,"-" as *u8,1);t=0-t} let tm:*u8=sys_mmap(24); var k:i64=0; if t==0{tm[0]=48 as u8;k=1} while t>0{tm[k]=(48+(t%10)) as u8;t=t/10;k=k+1} let b:*u8=sys_mmap(24); var j:i64=0; while j<k{b[j]=tm[k-1-j];j=j+1} sys_write(1,b,k); return 0 } |
| 17 | func rt_read(path: *u8, out: *u8, cap: i64) -> i64 |
| 23 | func rt_join(out: *u8, dir: *u8, name: *u8) -> i64 { var o: i64=0; var i: i64=0; while dir[i]!=(0 as u8){out[o]=dir[i];o=o+1;i=i+1} out[o]=47 as u8; o=o+1; i=0; while name[i]!=(0 as u8){out[o]=name[i];o=o+1;i=i+1} out[o]=0 as u8; return o } called by 1: main |
| 24 | func rt_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8) { if a[i]!=b[i] { return 0 } i=i+1 } if b[i]!=(0 as u8) { return 0 } return 1 } called by 1: main |
| 25 | func rt_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8) { if s[i]>=(48 as u8) { if s[i]<=(57 as u8) { v=v*10+((s[i] as i64)-48) } } i=i+1 } return v } |
| 26 | func rt_itoa(v: i64, out: *u8) -> i64 { var t: i64=v; if t<0{t=0-t} let tm:*u8=sys_mmap(24); var k:i64=0; if t==0{tm[0]=48 as u8;k=1} while t>0{tm[k]=(48+(t%10)) as u8;t=t/10;k=k+1} var i:i64=0; while i<k{out[i]=tm[k-1-i];i=i+1} out[k]=0 as u8; return k } |
| 27 | func rt_is_keep(idx: i64, total: i64, keepN: i64) -> i64 { if idx >= total - keepN { return 1 } return 0 } called by 1: main |
| 29 | func rt_snapkey(id: i64, out: *u8) -> i64 { out[0]=115 as u8; out[1]=110 as u8; out[2]=97 as u8; out[3]=112 as u8; out[4]=45 as u8; let l: i64=rt_itoa(id, (out as i64 + 5) as *u8); return 5 + l } |
| 30 | func rt_getcount(sprefix: *u8) -> i64 |
| 36 | func main(argc: i64, argv: *i64) -> i64 |