code wiki / _hdl_build / nx_collision_resolve_batch.nx

nx_collision_resolve_batch.nx source

↩ module page · 42 lines · 4896 B

1// nx_collision_resolve_batch.nx -- resolve shadow collisions per the operator's rule: "the more performant and 2// capable should be wired into the nishi ecosystem all the way up." For each entry the LESS-capable copy is 3// renamed OUT OF THE WAY (sovereign sys_renameat, reversible, NO delete) so the MORE-capable copy becomes the 4// one `nx_sov_build_run <name>` resolves to (= wired in by name, all the way up). Each judged per-organ by 5// READING both copies first. SAFETY: each rename aborts unless old exists AND new is free (no clobber). 6// entry 0: nx_galx_thumb -- KEEP runtime/ (batch, CID-addressed /thumb/<CID>, fork-per-image, daemon-served); 7// rename the _hdl_build/ one-shot bilinear CLI -> nx_galx_thumb_oneshot.nx. 8// license_tier: ORIGINAL 9import "nx_syscalls.nx" 10 11func rb_n() -> i64 { return 10 } 12func rb_old(i: i64) -> *u8 { if i==0 { return "runtime/_hdl_build/nx_galx_thumb.nx" as *u8 } if i==1 { return "runtime/nx_cidr.nx" as *u8 } if i==2 { return "runtime/nx_telemetry.nx" as *u8 } if i==3 { return "runtime/nx_aec.nx" as *u8 } if i==4 { return "runtime/nx_extract.nx" as *u8 } if i==5 { return "runtime/nx_synth.nx" as *u8 } if i==6 { return "runtime/nx_clarity.nx" as *u8 } if i==7 { return "runtime/_hdl_build/nx_research_ledger.nx" as *u8 } if i==8 { return "runtime/nx_genealogist.nx" as *u8 } if i==9 { return "runtime/nx_raster.nx" as *u8 } return "" as *u8 } 13func rb_new(i: i64) -> *u8 { if i==0 { return "runtime/_hdl_build/nx_galx_thumb_oneshot.nx" as *u8 } if i==1 { return "runtime/nx_cidr_smoke.nx" as *u8 } if i==2 { return "runtime/nx_telemetry_bus.nx" as *u8 } if i==3 { return "runtime/nx_aec_q15.nx" as *u8 } if i==4 { return "runtime/nx_func_extract.nx" as *u8 } if i==5 { return "runtime/nx_primitive_synth.nx" as *u8 } if i==6 { return "runtime/nx_image_clarity.nx" as *u8 } if i==7 { return "runtime/_hdl_build/nx_research_integrate.nx" as *u8 } if i==8 { return "runtime/nx_genealogist_gapscan.nx" as *u8 } if i==9 { return "runtime/nx_raster_legacy.nx" as *u8 } return "" as *u8 } 14func rb_keep(i: i64) -> *u8 { if i==0 { return "runtime/nx_galx_thumb.nx (batch CID, more capable)" as *u8 } if i==1 { return "_hdl_build/nx_cidr.nx (UNIFIED lib: notation-parse + longest-prefix tier + match, merged, no loss)" as *u8 } if i==2 { return "DISTINCT caps both kept: nx_telemetry=_hdl_build consent-device-telemetry; bus preserved as nx_telemetry_bus" as *u8 } if i==3 { return "_hdl_build/nx_aec.nx (UNIFIED: NLMS+ERLE+gate, MERGED IN the Geigel double-talk detector; T5 verifies, no loss)" as *u8 } if i==7 { return "runtime/nx_research_ledger.nx (the RESEARCH_MEMORY library rl_query/rl_learn -- operator standing order 2026-06-16, now UN-SHADOWED + reachable + importable; the _hdl_build copy was a mis-named STATUS REPORT, renamed nx_research_integrate; two distinct caps, no loss)" as *u8 } if i==8 { return "_hdl_build/nx_genealogist.nx (the anti-DUPLICATION library -- don't rebuild what exists; stays canonical, imported); the runtime gap-SCANNER program -- find what's MISSING -- renamed nx_genealogist_gapscan; two distinct facets, no loss" as *u8 } if i==9 { return "_hdl_build/nx_raster.nx (THE rasterizer, 338 callers -- stays canonical); the runtime copy was DORMANT (0 callers per nx_collision_harm) = dead duplicate -> renamed _legacy, reversible, no loss" as *u8 } return "" as *u8 } 15 16func rw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 17func rexists(p: *u8) -> i64 { let fd: i64=sys_openat_rd(p); if fd>=0 { sys_close(fd); return 1 } return 0 } 18 19func main() -> i64 { 20 rw("=== collision batch resolve: keep the more-capable copy, rename the lesser (sovereign, reversible) ===\n" as *u8) 21 var done: i64=0; var skipped: i64=0 22 var i: i64=0 23 while i<rb_n() { 24 let old: *u8=rb_old(i); let new: *u8=rb_new(i) 25 rw(" [" as *u8); rw(old); rw("]\n" as *u8) 26 if rexists(old)==0 { rw(" SKIP: lesser copy not present (already resolved?)\n" as *u8); skipped=skipped+1 } 27 else { if rexists(new)==1 { rw(" SKIP: new name already exists (would clobber)\n" as *u8); skipped=skipped+1 } 28 else { 29 let rc: i64=sys_renameat(old, new) 30 if rc==0 { if rexists(old)==0 { if rexists(new)==1 { 31 rw(" RENAMED -> " as *u8); rw(new); rw("\n" as *u8) 32 rw(" KEEP (now canonical by name): " as *u8); rw(rb_keep(i)); rw("\n" as *u8) 33 done=done+1 34 } } } else { rw(" SKIP: renameat failed\n" as *u8); skipped=skipped+1 } 35 } } 36 i=i+1 37 } 38 rw(" resolved=" as *u8); if done==0 { rw("0" as *u8) } else { let b: *u8=sys_mmap(8); b[0]=(48+done) as u8; sys_write(1,b,1) } 39 rw(" skipped=" as *u8); if skipped==0 { rw("0" as *u8) } else { let b2: *u8=sys_mmap(8); b2[0]=(48+skipped) as u8; sys_write(1,b2,1) } 40 rw("\n" as *u8) 41 sys_exit(0); return 0 42}