code wiki / _hdl_build / nx_ark_snapshot.nx
nx_ark_snapshot.nx
buildroot/runtime/_hdl_build/nx_ark_snapshot.nx
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
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
structs
| none |
consts
| 21 | const ARK_MAGIC_65536: i64 = 65536 |
| 22 | const ARK_MAGIC_1469598103: i64 = 1469598103 |
| 23 | const ARK_MAGIC_262144: i64 = 262144 |
| 25 | const ARK_PACKCAP: i64 = 16777216 |
| 26 | const ARK_MAXENT: i64 = 128 |
functions
| 28 | func 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 } |
| 29 | func 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 } |
| 31 | func ak_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 38 | func ak_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 52 | func ak_readall(path: *u8, szout: *i64) -> *u8 called by 4: ak_setak_manifest_buildak_snapak_verify calls 5: sys_openat_rdsys_lseeksys_mmapsys_readsys_close |
| 69 | func ak_fnv(b: *u8, n: i64) -> i64 |
| 76 | func ak_writefile(path: *u8, b: *u8, n: i64) -> i64 |
| 91 | func ak_set(setpath: *u8, arena: *u8) -> i64 |
| 132 | func ak_manifest_build(arena: *u8, cnt: i64, mb: *u8) -> i64 |
| 160 | func ak_snap(arena: *u8, cnt: i64, packp: *u8, manp: *u8) -> i64 |
| 219 | func ak_verify(packp: *u8, manp: *u8, lfd: i64) -> i64 |
| 288 | func main(argc: i64, argv: *i64) -> i64 |