nx_jrnl_archive.nx source
↩ module page · 21 lines · 1263 B
1// nx_jrnl_archive.nx -- "archive it deliberately", as a verb (2026-08-23, lane L).
2// The sanctioned reset for an append-only status journal that reached its budget: hash-verified copy
3// to <dir>/archive/<name>.<epoch> (or a named dir), THEN reset the live file -- never the other way
4// round. All logic lives in nx_jrnl_archive_lib.nx (ja_archive) so the gate composes it in-process.
5// nx_jrnl_archive <journal> [archive_dir]
6// exit: 0 archived+reset | 1 empty (nothing to do) | 2 usage | 3 cannot read | 4 archive write failed
7// | 5 verify mismatch (live untouched) | 6 reset failed (archive verified, live untouched)
8// license_tier: ORIGINAL No hw writes (Rule 26).
9import "nx_syscalls.nx"
10import "nx_jrnl_archive_lib.nx"
11
12func main(argc: i64, argv: *i64) -> i64 {
13 if argc < 2 {
14 ja_puts("usage: nx_jrnl_archive <journal> [archive_dir] -- hash-verified copy to <dir-of-journal>/archive/<name>.<epoch> (or archive_dir), then reset the live journal to 0 bytes; preserve-before-remove by construction\n" as *u8)
15 sys_exit(2); return 2
16 }
17 var dir: *u8 = 0 as *u8
18 if argc >= 3 { dir = argv[2] as *u8 }
19 let rc: i64 = ja_archive(argv[1] as *u8, dir, sys_now_realtime_sec(), 0 as *i64)
20 sys_exit(rc); return rc
21}