code wiki / _hdl_build / nx_plane_repair.nx
nx_plane_repair.nx
buildroot/runtime/_hdl_build/nx_plane_repair.nx
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
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
structs
| none |
consts
| 40 | const PR_CAP: i64 = 33554432 |
functions
| 42 | func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 43 | func 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 } |
| 44 | func 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 } |
| 45 | func 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 } |
| 46 | func 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 |
| 48 | func pr_count_rows(buf: *u8, n: i64) -> i64 called by 1: main |
| 55 | func main(argc: i64, argv: *i64) -> i64 |