code wiki / _hdl_build / nx_dedupe_source_lib.nx
nx_dedupe_source_lib.nx
buildroot/runtime/_hdl_build/nx_dedupe_source_lib.nx
about
nx_dedupe_source_lib.nx -- the RESOLUTION half of the seq207/seq169 dual-copy source hazard.
The mgmt build guard (ma_build_dup_divergent) DETECTS when <t>.nx exists in BOTH buildroot/runtime/
and buildroot/runtime/_hdl_build/ with DIFFERENT bytes and REFUSES the build (a divergent runtime twin
silently regresses its consumer once a build resolves the _hdl_build SSOT). Until now there was NO
sovereign FIX -- only ssh. This is it, ecosystem-wide + reusable for the whole class.
ACTION (rule-13 SOFT-DELETE, never a hard rm): the _hdl_build tree is the build SSOT, so the stale
runtime/ shadow is RENAMED out of the build path to <t>.nx.dupe-reconciled (bytes preserved = rollback).
After: only ONE <t>.nx remains in the source tree -> the guard's missing-either branch passes -> the
canonical (fixed) source builds -> no consumer regresses. Server-side atomic sys_renameat; fail-safe:
refuse if the canonical SSOT is absent (never reconcile toward a missing truth); benign no-op if there
is no shadow (already single-copy); VERIFY the shadow is gone + the backup exists after.
license_tier: ORIGINAL genealogy: seq207 class; pairs with nx_mgmt_api ma_build_dup_divergent
dependencies 1 imports · 2 importers
imports: nx_syscalls.nx
imported by: nx_dedupe_source.nxnx_dedupe_source_gate.nx
structs
| none |
consts
| 14 | const K_MAGIC_65536: i64 = 65536 |
| 15 | const K_MAGIC_1024: i64 = 1024 |
functions
| 17 | func ds_cat(d: *u8, o: i64, s: *u8) -> i64 { var i: i64=0; var p: i64=o; while s[i]!=(0 as u8){d[p]=s[i]; p=p+1; i=i+1} d[p]=0 as u8; return p } |
| 18 | func ds_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 19 | func ds_w_num(v: i64) -> i64 { let b: *u8 = sys_mmap(28); let n: i64 = ds_catn(b, 0, v); sys_write(1, b, n); return 0 } |
| 20 | func ds_catn(d: *u8, o: i64, v: i64) -> i64 |
| 25 | func ds_namec(c: i64) -> i64 called by 1: ds_sanitize |
| 33 | func ds_sanitize(src: *u8, out: *u8, cap: i64) -> i64 |
| 46 | func ds_exists(path: *u8) -> i64 |
| 52 | func ds_filesize(path: *u8) -> i64 |
| 65 | func ds_reconcile(canon: *u8, shadow: *u8, bakout: *u8) -> i64 |
| 83 | func ds_resolve_pair(nm: *u8, canon_dir: *u8, shadow_dir: *u8, emit: i64) -> i64 |
| 119 | func ds_resolve_target(nm: *u8, emit: i64) -> i64 |
| 124 | func ds_write_kat(path: *u8, body: *u8) -> i64 |
| 132 | func ds_selftest() -> i64 |