nx_planefit.nx
buildroot/runtime/nx_planefit.nx
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
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
structs
| none |
consts
| 31 | const PF_CEIL: i64 = 67108864 // 64 MiB probe ceiling -- far above any measured organ cap |
| 32 | const PF_DEFAULT_CAP: i64 = 1048576 // 1 MiB: the cap nx_sheriff/nx_pm_board/nx_dora actually used |
| 33 | const PF_SWEEP_ROWCAP: i64 = 60000 // declared-row bound for the sweep; above this: report + skip |
| 34 | const PF_DIRBUF: i64 = 262144 |
| 35 | const PF_STORE: *u8 = "knowledge/store" |
| 36 | const PF_PATHCAP: i64 = 512 |
| 37 | const PF_OUTCAP: i64 = 16 |
| 38 | const PF_ZERO: i64 = 48 |
| 39 | const PF_NINE: i64 = 57 |
| 40 | const PF_B10: i64 = 10 |
| 41 | const PF_EXIT_FITS: i64 = 0 |
| 42 | const PF_EXIT_TRUNC: i64 = 1 |
| 43 | const PF_EXIT_USAGE: i64 = 2 |
functions
| 45 | func 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 } |
| 46 | func pf_n(v: i64) -> i64 |
| 56 | func pf_atoi(s: *u8) -> i64 called by 1: main |
| 66 | func pf_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 67 | func pf_eq(a: *u8, b: *u8) -> i64 called by 1: main |
| 76 | func pf_is_manifest(nm: *u8) -> i64 |
| 87 | func pf_declared_rows(prefix: *u8) -> i64 |
| 95 | func pf_one(prefix: *u8, cap: i64, big: *u8, verbose: i64) -> i64 |
| 124 | func pf_sweep(cap: i64, verbose: i64) -> i64 |
| 195 | func main(argc: i64, argv: *i64) -> i64 |