code wiki / _hdl_build / nx_ark_snapshot.nx

nx_ark_snapshot.nx

buildroot/runtime/_hdl_build/nx_ark_snapshot.nx

12595 B345 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic ark
docsdependenciesstructsconstsfunctions

about

nx_ark_snapshot.nx -- X-REP-005 (CALLOUT-002 REP-1): the ARK. Packs the data-driven survival set (knowledge/registry/ark_set.tsv) into ONE file with a CID manifest -- the dead-laptop seed's first organ. snap (default): read every set row -> entry CIDs -> manifest text. If the manifest is BYTE-IDENTICAL to the existing one, SKIP the pack write entirely (unchanged=1; the resource-conscious beat is a read pass). Else write pack.new + manifest.new and renameat both (atomic; the lane's temp-rename discipline). verify: walk the pack against the manifest -- entry count, path, size, recomputed CID must all match; any mismatch = named row + RED. An ark that cannot prove itself is hope, not backup. Pack format NXARK1: "NXARK1\n" then per entry "ENT <pathlen> <bytes> <cid>\n" + path bytes + raw content. Manifest rows are DETERMINISTIC (no epoch -- epoch lives in the ARKSNAP log row only) so unchanged detection is a byte compare. argv[1]=mode snap|verify argv[2]=set argv[3]=pack argv[4]=manifest Evidence: ARKSNAP / ARKVERIFY rows -> stdout + knowledge/status/ark.log. license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_ark_snapshot.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main sys_openat_append ak_verify sys_mmap ak_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close ak_fnv ak_w sys_write ak_wn sys_mmap ↻ sys_write ↻ ak_cat ak_catn sys_mmap ↻ ak_w ↻ ak_wn ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real sys_mmap ↻ ak_set sys_mmap ↻ ak_readall ↻ sys_exit ak_snap sys_mmap ↻ ak_manifest_build ak_cat ↻ ak_catn ↻ sys_mmap ↻ ak_readall ↻ ak_w ↻ ak_fnv ↻ ak_readall ↻ ak_cat ↻

structs

none

consts

21const ARK_MAGIC_65536: i64 = 65536
22const ARK_MAGIC_1469598103: i64 = 1469598103
23const ARK_MAGIC_262144: i64 = 262144
25const ARK_PACKCAP: i64 = 16777216
26const ARK_MAXENT: i64 = 128

functions

28func ak_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
29func ak_wn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 }
called by 2: ak_verifymain calls 2: sys_mmapsys_write
31func ak_cat(dst: *u8, off: i64, s: *u8) -> i64
38func ak_catn(dst: *u8, off: i64, v: i64) -> i64
52func ak_readall(path: *u8, szout: *i64) -> *u8
69func ak_fnv(b: *u8, n: i64) -> i64
76func ak_writefile(path: *u8, b: *u8, n: i64) -> i64
91func ak_set(setpath: *u8, arena: *u8) -> i64
called by 1: main calls 2: sys_mmapak_readall
132func ak_manifest_build(arena: *u8, cnt: i64, mb: *u8) -> i64
160func ak_snap(arena: *u8, cnt: i64, packp: *u8, manp: *u8) -> i64
219func ak_verify(packp: *u8, manp: *u8, lfd: i64) -> i64
288func main(argc: i64, argv: *i64) -> i64