code wiki / _hdl_build / nx_store_fold_beat.nx

nx_store_fold_beat.nx

buildroot/runtime/_hdl_build/nx_store_fold_beat.nx

9865 B223 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic store
docsdependenciesstructsconstsfunctions

about

nx_store_fold_beat.nx -- seg-store plane bloat auto-heal (seq1311). The toolreg plane silently grew to 1355 segments -> every ss_get walked all of them -> tools/list 10-22s/page = the 2026-07-30 MCP-surface outage. This beat DISCOVERS every knowledge/ plane (any *manifest.txt), and when one exceeds the segment threshold it runs the proven `nx_store_compact <prefix> fold` (store-native ss_compact_cap merge + production-ss_get byte-verify + manifest restore on mismatch). Sweep-row contract: exit 0 = every plane under threshold OR successfully folded (healed); exit 1 = a fold FAILED or a bloated plane is too big to fold safely (surfaced RED, never silent). Thresholds are DATA-DRIVEN (knowledge/store_fold.conf: threshold=N, max_docs_mb=M; defaults 64/256). license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_tool_run.nx nx_store_fold_beat.nx

imports: nx_syscalls.nxnx_tool_run.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap fb_readfile sys_openat_rd sys_read sys_close fb_conf_val fb_slen sys_openat_rd ↻ fb_puts sys_write fb_slen ↻ sys_exit sys_getdents64 fb_slen ↻ fb_endswith fb_slen ↻ fb_cat fb_plane_stats sys_mmap ↻ fb_is_seg_row fb_cat ↻ fb_filesize sys_openat_rd ↻ sys_lseek sys_close ↻ fb_putn sys_mmap ↻ sys_write ↻ tr_run_capture sys_mmap ↻ sys_pipe2 sys_fork sys_close ↻ sys_dup3 sys_execve_clean sys_close ↻ sys_execve sys_exit ↻ sys_read ↻

structs

none

consts

13const FB_MAGIC_4096: i64 = 4096
14const FB_MAGIC_4095: i64 = 4095
16const FB_DIRBUF: i64 = 262144
17const FB_MFCAP: i64 = 4194304
18const FB_PATHCAP: i64 = 1024
19const FB_OUTCAP: i64 = 65536
20const FB_NL: i64 = 10
21const FB_DEF_THRESH: i64 = 64
22const FB_DEF_MAXMB: i64 = 256
23const FB_KNOW: *u8 = "knowledge/" as *u8
24const FB_CONF: *u8 = "knowledge/store_fold.conf" as *u8
25const FB_COMPACT: *u8 = "./nx_store_compact.elf" as *u8
26const FB_MB: i64 = 1048576

functions

28func fb_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
29func fb_puts(s: *u8) -> i64 { sys_write(1, s, fb_slen(s)); return 0 }
called by 1: main calls 2: sys_writefb_slen
30func fb_putn(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
37func fb_cat(dst: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; while s[i] != (0 as u8) { dst[off+i] = s[i]; i = i + 1 } return off + i }
called by 2: fb_plane_statsmain
38func fb_endswith(name: *u8, nl: i64, sfx: *u8) -> i64
called by 1: main calls 1: fb_slen
46func fb_conf_val(buf: *u8, n: i64, key: *u8, def: i64) -> i64
called by 1: main calls 1: fb_slen
68func fb_readfile(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
81func fb_filesize(path: *u8) -> i64
94func fb_is_seg_row(b: *u8, ls: i64, le: i64) -> i64
called by 1: fb_plane_stats
104func fb_plane_stats(prefix: *u8, mfb: *u8, mfn: i64, segsout: *i64, bytesout: *i64) -> i64
132func main(argc: i64, argv: *i64) -> i64