code wiki / (root) / nx_planepeek.nx

nx_planepeek.nx

buildroot/runtime/nx_planepeek.nx

19208 B393 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_planepeek.nx -- READ ONE RAW KEY OUT OF A SEG-STORE PLANE. Read-only, writes nothing. WHY IT EXISTS. The debt- plane is refusing every add/eat because ONE row is reachable past the declared q:n (nx_plane_check: rows=3696 identical=3696 declared_qn=3696 beyond_qn=1), and nx_plane_repair correctly refuses to reconcile it: "an older seeding generation -- reseeding would revive eaten rows and duplicate live ones. That needs a generation diff, not a reconcile." To DO that generation diff somebody has to look at the row. And nothing in the estate could: nx_store_put reads its own N-column planes, nx_plane_check verifies round-trips, nx_store_hist is a column histogram -- none of them will hand you the value at an arbitrary key. ★★★★★A PLANE YOU CAN VERIFY AND REPAIR BUT CANNOT READ A SINGLE KEY OUT OF FORCES EVERY DIAGNOSIS TO BE A GUESS. I made two wrong guesses about this exact row before building this. It is deliberately the smallest thing that closes that gap: resolve a key through the SAME production ss_get every reader uses, print the bytes, exit. No writes, no repair, no opinion. =========================================================================================== THE FALSE-ABSENCE DEFECT (debt 1787282525, sev 6, fixed 2026-08-21). =========================================================================================== v1 printed exactly one word for every non-hit: `if ss_get(...) != 1 { MISS }`. ss_get's OWN contract (nx_seg_store.nx: "1=found, 0=tombstoned, -1=absent") already carried a state v1 threw away, and the scan underneath it carried three more: 1. ss_get==0 -> the key EXISTS and was explicitly DELETED. v1 said MISS. A tombstone is a POSITIVE fact about a key, and reporting it as absence inverts its meaning. 2. no manifest -> ss_manifest_dyn returns 0, ss_scan returns 0, ss_get returns -1. So a MISTYPED PREFIX printed the same MISS as a real absence. Nothing could tell them apart. 3. a segment NAMED in manifest.txt but UNREADABLE on disk -> ss_readall sets sz=-1 and ss_scan_seglist's `while i + 9 <= sz` loop never executes. The segment contributes ZERO rows and NO error. A plane half of which could not be opened answered a confident "absent". 4. a caller passing a COLUMN VALUE where the plane's keys are q:<n> (every N-col plane written by nx_store_put) got MISS, which reads as "your row is gone" rather than "wrong grammar". FIVE distinguishable conditions, ONE word, and that word is a NEGATIVE ASSERTION. Measured cost: a seat nearly filed "the enqueue lane is dead" on it, and a build-refusal message shipped `verify with nx_planepeek deployq- BQ-<target>` -- pointing every caller at a false-absence generator. ★★★★★★AN UNBOUNDED SEARCH THAT GIVES UP MUST NOT REPORT THE SAME WORD AS AN EXHAUSTIVE ONE THAT FOUND NOTHING -- otherwise every quote of it silently rewrites the evidential status of the claim that quotes it. ⇒ MISS now means ONE thing: the plane resolved, EVERY declared segment was read, the key is not there. Everything else gets its own word and its own exit code, and every answer -- hit or miss -- prints the coverage it was computed from. ★PRESENCE NEEDS ONE WITNESS; ABSENCE NEEDS PROVEN COVERAGE. So the HIT path stays a cheap point

dependencies 2 imports · 0 importers

nx_seg_store.nx nx_syscalls.nx nx_planepeek.nx

imports: nx_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 pk_puts sys_write pk_len 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 ↻ pk_coverage sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn sys_mmap ↻ ss_cat ss_readall sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close sys_munmap pk_segsize sys_mmap ↻ ss_cat ↻ sys_openat_rd ↻ sys_munmap ↻ sys_lseek ↻ sys_close ↻

structs

none

consts

57const PK_KEYCAP: i64 = 256
58const PK_MAXRANGE: i64 = 200
59const PK_ZERO: i64 = 48
60const PK_NINE: i64 = 57
64const PK_TAB: i64 = 9
67const PK_PATHCAP: i64 = 512
71const PK_EX_HIT: i64 = 0
72const PK_EX_MISS: i64 = 1
73const PK_EX_USAGE: i64 = 2
74const PK_EX_UNPROVEN: i64 = 3
75const PK_EX_NOPLANE: i64 = 4
76const PK_EX_TOMBSTONED: i64 = 5
77const PK_EX_NOTAKEY: i64 = 6
81const PK_SS_TOMB: i64 = 0
82const PK_SS_HIT: i64 = 1
85const PK_COV_SLOTS: i64 = 8
86const PK_COV_DECLARED: i64 = 0
87const PK_COV_READABLE: i64 = 1
88const PK_COV_UNREADABLE: i64 = 2
89const PK_COV_BYTES: i64 = 3
90const PK_COV_ARCHIVE: i64 = 4
91const PK_COV_KEYS: i64 = 5
92const PK_COV_SEGS: i64 = 6

functions

94func pk_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
95func pk_puts(s: *u8) -> i64 { sys_write(1, s, pk_len(s)); return 0 }
96func pk_putn(v: i64) -> i64
106func pk_atoi(s: *u8) -> i64
called by 1: main
116func pk_streq(a: *u8, b: *u8) -> i64
called by 1: main
123func pk_rowkey(seq: i64, out: *u8) -> i64
called by 1: main calls 1: ss_catn
137func pk_segsize(prefix: *u8, segname: *u8) -> i64
153func pk_coverage(prefix: *u8, cov: *i64) -> i64
178func pk_name_unreadable(prefix: *u8, cov: *i64) -> i64
called by 2: pk_resolvemain calls 2: pk_segsizepk_puts
195func pk_put_coverage(cov: *i64) -> i64
called by 1: main calls 2: pk_putspk_putn
214func pk_scan_for_colvalue(prefix: *u8, key: *u8, cov: *i64, rk: *i64, rkl: *i64) -> i64
260func pk_put_value(pp: *i64, lp: *i64) -> i64
270func pk_resolve(prefix: *u8, key: *u8, cov: *i64) -> i64
315func main(argc: i64, argv: *i64) -> i64