code wiki / _hdl_build / nx_dr_retention.nx

nx_dr_retention.nx

buildroot/runtime/_hdl_build/nx_dr_retention.nx

7315 B95 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic dr
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_sha256.nx nx_seg_store.nx nx_dr_retention.nx

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

main rt_w sys_write sys_exit sys_mmap rt_join rt_streq ss_manifest ss_manifest_file sys_mmap ↻ ss_cat ss_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ss_segname ss_cat ↻ ss_catn sys_mmap ↻ rt_read sys_openat_rd ↻ sys_read ↻ sys_close ↻ sha256_digest sys_mmap ↻ sha256_init sys_mmap ↻ sha256_k sha256_update sha256_compress_ni_blocks blk_set_byte sha256_compress sha256_compress_ni blk_word blk_byte sha256_final blk_set_byte ↻ sha256_compress ↻

structs

none

consts

12const K_MAGIC_1536: i64 = 1536
13const K_MAGIC_4194304: i64 = 4194304

functions

15func 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 }
called by 1: main calls 1: sys_write
16func 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 }
called by 1: main calls 2: sys_writesys_mmap
17func rt_read(path: *u8, out: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
23func 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
24func 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
25func 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 }
called by 2: rt_getcountmain
26func 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 }
called by 2: rt_snapkeymain calls 1: sys_mmap
27func rt_is_keep(idx: i64, total: i64, keepN: i64) -> i64 { if idx >= total - keepN { return 1 } return 0 }
called by 1: main
29func 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 }
called by 1: main calls 1: rt_itoa
30func rt_getcount(sprefix: *u8) -> i64
called by 1: main calls 3: sys_mmapss_getrt_atoi
36func main(argc: i64, argv: *i64) -> i64