code wiki / _hdl_build / nx_frontier_store_seed.nx

nx_frontier_store_seed.nx source

↩ module page · 32 lines · 1502 B

1// nx_frontier_store_seed.nx -- CLI: migrate/re-seed the frontier seg-store FROM the staging .tsv. 2// Operator 2026-07-17 "we arent supposed to be using .tsv" -> the .tsv is put-file STAGING; this makes 3// the sovereign store (knowledge/store/frontier-) the SSOT that nx_frontier_board reads. 4// usage: nx_frontier_store_seed [tsvpath] (default knowledge/registry/frontier_queue.tsv) 5// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 6import "nx_frontier_store.nx" 7import "nx_seg_store.nx" 8import "nx_syscalls.nx" 9 10const FSS_MSGCAP: i64 = 96 11const FSS_SZCAP: i64 = 16 12const FSS_NL: i64 = 10 13const FSS_STDERR: i64 = 2 14 15func fss_werr(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(FSS_STDERR, s, n); return 0 } 16 17func main(argc: i64, argv: *i64) -> i64 { 18 var tsv: *u8 = "knowledge/registry/frontier_queue.tsv" as *u8 19 if argc > 1 { tsv = argv[1] as *u8 } 20 let szp: *i64 = sys_mmap(FSS_SZCAP) as *i64 21 let buf: *u8 = ss_readall(tsv, szp) 22 if buf == (0 as *u8) { fss_werr("SEED-FAIL: cannot read staging tsv\n" as *u8); sys_exit(1); return 1 } 23 let cnt: i64 = frs_seed(FRS_PREFIX, buf, szp[0]) 24 if cnt < 0 { fss_werr("SEED-FAIL: seg-store commit error\n" as *u8); sys_exit(1); return 1 } 25 let msg: *u8 = sys_mmap(FSS_MSGCAP) 26 var o: i64 = ss_cat(msg, 0, "SEEDED knowledge/store/frontier- rows=" as *u8) 27 o = ss_catn(msg, o, cnt) 28 msg[o] = FSS_NL as u8; o = o + 1 29 sys_write(1, msg, o) 30 sys_exit(0) 31 return 0 32}