code wiki / (root) / nx_planefit.nx

nx_planefit.nx

buildroot/runtime/nx_planefit.nx

11008 B244 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_planefit.nx -- READ-ONLY: does a plane FIT a caller's read cap, and by how much does it miss? WHY THIS EXISTS. sts_load silently drops bytes once its output buffer fills and returns a byte count that looks perfectly healthy, so an under-capped reader reports on a PARTIAL board and is indistinguishable from a healthy one. The truncation WARNING added 2026-08-06 makes that visible at the moment of the read -- but only for someone watching stderr of a run that already happened. This answers the question BEFORE the run, for any plane and any cap, without writing anything. MEASURED MOTIVATION (2026-08-06): knowledge/store/debt- loads to 4,396,892B while nx_sheriff (SHF_CAP), nx_pm_board (PB_CAP) and nx_dora (DCAP) each read it with a 1 MiB cap -- each losing 76% of the board, newest rows first. On-disk bytes are NOT the answer (they include superseded segment versions), so the only honest number is what sts_load actually returns. nx_planefit <plane-prefix> [cap] -- one plane; exit 1 if it truncates at that cap nx_planefit sweep [cap] -- EVERY plane under knowledge/store; exit 1 if any truncates ★THE SWEEP IS THE POINT. Checking four planes by hand is a spot check; the defect class is "which of my readers is silently blind RIGHT NOW", and that is a census question. This is the complement to nx_capcliff, which scans FLAT LEDGERS against ONE hardcoded cap and has no notion of seg-store planes. ⚠TWO DECLARED BOUNDS, NEITHER SILENT: (1) the probe ceiling PF_CEIL -- if true_bytes comes back EQUAL to it, the number is a FLOOR and the tool says so; (2) PF_SWEEP_ROWCAP -- a plane declaring more rows than this is REPORTED AND SKIPPED rather than walked, because sts_load walks q:0..q:n-1 and a multi-million-row plane would turn a census into an outage. A skipped plane is printed with its declared count, so the sweep can never pass off partial coverage as complete. license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_store_seed_lib.nx nx_seg_store.nx nx_syscalls.nx nx_planefit.nx

imports: nx_store_seed_lib.nxnx_seg_store.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main pf_w sys_write sys_exit pf_atoi pf_eq pf_sweep sys_openat_rd pf_w ↻ sys_exit ↻ sys_mmap nxa_die sys_write ↻ sys_exit ↻ nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ pf_n pf_w ↻ sys_mmap ↻ sys_write ↻ sys_getdents64 dirent_reclen dirent_name pf_is_manifest pf_len ss_cat pf_len ↻ pf_declared_rows sys_mmap ↻ ss_get sys_mmap ↻

structs

none

consts

31const PF_CEIL: i64 = 67108864 // 64 MiB probe ceiling -- far above any measured organ cap
32const PF_DEFAULT_CAP: i64 = 1048576 // 1 MiB: the cap nx_sheriff/nx_pm_board/nx_dora actually used
33const PF_SWEEP_ROWCAP: i64 = 60000 // declared-row bound for the sweep; above this: report + skip
34const PF_DIRBUF: i64 = 262144
35const PF_STORE: *u8 = "knowledge/store"
36const PF_PATHCAP: i64 = 512
37const PF_OUTCAP: i64 = 16
38const PF_ZERO: i64 = 48
39const PF_NINE: i64 = 57
40const PF_B10: i64 = 10
41const PF_EXIT_FITS: i64 = 0
42const PF_EXIT_TRUNC: i64 = 1
43const PF_EXIT_USAGE: i64 = 2

functions

45func pf_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 4: pf_npf_onepf_sweepmain calls 1: sys_write
46func pf_n(v: i64) -> i64
56func pf_atoi(s: *u8) -> i64
called by 1: main
66func pf_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
67func pf_eq(a: *u8, b: *u8) -> i64
called by 1: main
76func pf_is_manifest(nm: *u8) -> i64
called by 1: pf_sweep calls 1: pf_len
87func pf_declared_rows(prefix: *u8) -> i64
called by 1: pf_sweep calls 3: sys_mmapss_getsts_atoi
95func pf_one(prefix: *u8, cap: i64, big: *u8, verbose: i64) -> i64
called by 1: pf_sweep calls 3: sts_loadpf_wpf_n
124func pf_sweep(cap: i64, verbose: i64) -> i64
195func main(argc: i64, argv: *i64) -> i64