code wiki / _hdl_build / nx_store_fold_beat.nx
nx_store_fold_beat.nx
buildroot/runtime/_hdl_build/nx_store_fold_beat.nx
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
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
structs
| none |
consts
| 13 | const FB_MAGIC_4096: i64 = 4096 |
| 14 | const FB_MAGIC_4095: i64 = 4095 |
| 16 | const FB_DIRBUF: i64 = 262144 |
| 17 | const FB_MFCAP: i64 = 4194304 |
| 18 | const FB_PATHCAP: i64 = 1024 |
| 19 | const FB_OUTCAP: i64 = 65536 |
| 20 | const FB_NL: i64 = 10 |
| 21 | const FB_DEF_THRESH: i64 = 64 |
| 22 | const FB_DEF_MAXMB: i64 = 256 |
| 23 | const FB_KNOW: *u8 = "knowledge/" as *u8 |
| 24 | const FB_CONF: *u8 = "knowledge/store_fold.conf" as *u8 |
| 25 | const FB_COMPACT: *u8 = "./nx_store_compact.elf" as *u8 |
| 26 | const FB_MB: i64 = 1048576 |
functions
| 28 | func fb_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 29 | func fb_puts(s: *u8) -> i64 { sys_write(1, s, fb_slen(s)); return 0 } |
| 30 | func fb_putn(v: i64) -> i64 |
| 37 | func 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 } |
| 38 | func fb_endswith(name: *u8, nl: i64, sfx: *u8) -> i64 |
| 46 | func fb_conf_val(buf: *u8, n: i64, key: *u8, def: i64) -> i64 |
| 68 | func fb_readfile(path: *u8, buf: *u8, cap: i64) -> i64 |
| 81 | func fb_filesize(path: *u8) -> i64 |
| 94 | func fb_is_seg_row(b: *u8, ls: i64, le: i64) -> i64 called by 1: fb_plane_stats |
| 104 | func fb_plane_stats(prefix: *u8, mfb: *u8, mfn: i64, segsout: *i64, bytesout: *i64) -> i64 |
| 132 | func main(argc: i64, argv: *i64) -> i64 |