code wiki / _hdl_build / nx_collision_plan.nx
nx_collision_plan.nx
buildroot/runtime/_hdl_build/nx_collision_plan.nx
about
nx_collision_plan.nx -- the RESOLUTION PROPOSER: mechanizes the careful merge method for each shadow
collision so the team can resolve sprawl without hand-judging every pair (and without ever losing a
capability). For a shadowed basename it reads BOTH copies (runtime/<n> = A, runtime/_hdl_build/<n> = B),
extracts each copy's FUNCTION-NAME SET, and from the set relationship proposes the resolution:
shared==0 -> CODE 0 RENAME_DISTINCT : disjoint = two DIFFERENT capabilities sharing
a name -> rename both to clear names (GROWTH, like nx_extract vs nx_func_extract).
shared>0, onlyA==0, onlyB==0 -> CODE 1 KEEP_NEWER_GEN : same func-set, different bytes = the SAME
capability in two GENERATIONS -> keep the _hdl_build (probe-first) canon, retire the old runtime gen.
shared>0, onlyA==0, onlyB>0 -> CODE 2 RETIRE_A_SUBSET : B is the SUPERSET and B already RUNS (probe-first) = correct -> retire the runtime subset A.
shared>0, onlyA>0, onlyB==0 -> CODE 3 CAPABILITY-LOSS!: A (runtime) is the SUPERSET but the LESS-capable
B shadows it -> we are SILENTLY LOSING A's extra funcs -> must merge A's extras into B (or promote A). The highest-value catch.
shared>0, onlyA>0, onlyB>0 -> CODE 4 MERGE_UNION : each copy has unique funcs -> merge the union into one.
Toolchain-critical organs (nx_link = the ELF linker, never-brick #26) are flagged REVIEW regardless -- the
proposer NEVER auto-executes; it emits a plan the warden/operator gates. READ-ONLY (never-brick by construction).
RESIDUAL CAVEAT (honest): the program-vs-library signal is "has a top-level main". A LIBRARY that also carries
a self-test main (e.g. nx_research_ledger, prints GREEN x2) looks like a program, so a library-vs-report pair
can still slip through as MERGE_UNION. Full disambiguation needs IMPORT-ANALYSIS (does anything import it and
call its exported funcs?) -- the next rung; for now the benchmark/human layer catches that edge. license_tier: ORIGINAL
dependencies 2 imports · 3 importers
imports: nx_janitor_dupname.nxnx_syscalls.nx
imported by: nx_collision_harm.nxnx_collision_plan_gate.nxnx_collision_retire_safe.nx
structs
| none |
consts
| 21 | const K_MAGIC_1024: i64 = 1024 |
| 22 | const K_MAGIC_1048576: i64 = 1048576 |
| 23 | const K_MAGIC_4000: i64 = 4000 |
functions
| 26 | func crp_is_ident(ch: u8) -> i64 called by 1: crp_extract_funcs |
| 36 | func crp_extract_funcs(buf: *u8, len: i64, names: *u8, noff: *i64, maxn: i64) -> i64 |
| 58 | func crp_name_in(name: *u8, names: *u8, noff: *i64, count: i64) -> i64 |
| 64 | func crp_setcmp(na: *u8, oa: *i64, ca: i64, nb: *u8, ob: *i64, cb: i64, out: *i64) -> i64 |
| 72 | func crp_is_toolchain(name: *u8) -> i64 |
| 80 | func crp_classify(shared: i64, onlyA: i64, onlyB: i64) -> i64 |
| 92 | func crp_classify2(shared: i64, onlyA: i64, onlyB: i64, hasMainA: i64, hasMainB: i64) -> i64 |
| 99 | func crp_plan_one(name: *u8, ba: *u8, bb: *u8, na: *u8, oa: *i64, nb: *u8, ob: *i64, out: *i64) -> i64 |