code wiki / _hdl_build / nx_plane_repair.nx

nx_plane_repair.nx

buildroot/runtime/_hdl_build/nx_plane_repair.nx

9064 B154 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind tooltopic plane
docsdependenciesstructsconstsfunctions

about

nx_plane_repair.nx -- the MISSING RECOVERY VERB for a lossy seg-store plane. THE HOLE THIS FILLS. When a plane's declared `q:n` exceeds what the loader can reach, every writer correctly refuses: *"lossy load ... committing would BAKE the loss into the next generation. NOTHING COMMITTED."* nx_plane_migrate says **REPAIR-FIRST**. Nothing repairs. So the plane is write-blocked forever — measured live 2026-07-30 on the debt- plane, the ecosystem's own ledger of what is broken: it could not record that it was broken. ★★A GUARD THAT IS FAIL-SAFE BUT HAS NO RECOVERY VERB IS A PERMANENT DENIAL OF SERVICE ON ITSELF. The refusal is right. The missing half is a deliberate, loss-RECORDING reconciliation. ★IT DOES NOT HIDE THE DAMAGE — that is the whole difference between this and a migrator that "fixes" a plane by making it self-consistent. A sibling shipped exactly that mistake and wrote the law: *"A MIGRATOR MUST NEVER MAKE A DAMAGED PLANE LOOK HEALTHY. The rows were unreachable either way; what I removed was the ALARM."* So this writes a durable RECEIPT (declared/loaded/lost/epoch/prefix) BEFORE it rewrites anything. The alarm is not deleted; it is PROMOTED from "everything is blocked forever" into "here is exactly what was lost, recorded permanently, and writes work again". ★THE LOST ROWS ARE NOT RECOVERABLE. Their keys are absent from every segment — sts_seed reassigns q:<i> each generation, so the old rows are not merely unindexed, they are gone. This organ makes that fact explicit and permanent rather than pretending a repair restored them. ---- REFUSALS (each one is a way this could destroy data, so each is checked BEFORE any write) ---- 1. NOT-LOSSY declared <= loaded ⇒ nothing to repair. Idempotent: safe to re-run. 2. READ-TRUNCATED rows counted in the BUFFER != flags[1]. ★THE LETHAL ONE: sts_load_honest increments flags[1] for every row it FINDS, but sts_emit_row is bounded by `cap` — so an undersized buffer silently drops rows the counter still counted. Reseeding from that buffer would DESTROY the tail, turning a recoverable index problem into real data loss. Refuse unless the two agree exactly. 3. ROWS-BEYOND-QN flags[2] > 0 ⇒ rows exist past the declared count. That is a DIFFERENT defect (an older seeding generation) and reconciling it needs a generation diff, not a reseed. 4. NO-CONFIRM acknowledging permanent loss is an operator act, never a side effect. usage: nx_plane_repair <store-prefix> [confirm=yes] (CWD = the store's root) exit 0 = repaired (or nothing to repair) · 2 = refused, nothing written · 3 = verify failed after write license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_store_seed_lib.nx nx_plane_repair.nx

imports: nx_syscalls.nxnx_store_seed_lib.nx

imported by: nobody (leaf or entry point)

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

main w sys_write sys_exit streq sys_mmap sts_load_honest ss_open_cached ssc_init sys_mmap ↻ ssc_sig_of ss_cat sys_fstatat ssc_streq ss_open ss_open2 sys_mmap ↻ ss_manifest_dyn ss_manifest_file_dyn ss_cat ↻ ss_loadfile sys_map_file ss_readall ss_load_aux2 sys_mmap ↻ ss_cat ↻ ss_loadfile ↻ ss_r32 sys_munmap ssl_total_keys ss_r32 ↻ ssl_pow2 ssl_build ss_r32 ↻ ssl_hash_entry ssl_key_eq ss_r32 ↻ ssl_lookup ssl_hash_entry ↻ ssl_key_eq ↻

structs

none

consts

40const PR_CAP: i64 = 33554432

functions

42func 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 1: main calls 1: sys_write
43func wn(v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
44func wf(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
45func wnf(fd: i64, v: i64) -> i64 { let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} let b: *u8=sys_mmap(28); var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(fd,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
46func streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i]{return 0} i=i+1 } if b[i]!=(0 as u8){return 0} return 1 }
called by 1: main
48func pr_count_rows(buf: *u8, n: i64) -> i64
called by 1: main
55func main(argc: i64, argv: *i64) -> i64