Mechanized, behaviorally-verified extraction of copy-pasted gate helpers into one shared sovereign base — with the evidence standard, and the design law it produced.
nx_gate_base.nxrule-15 DRYbyte-identical proofbehavioral verification2026-07-21nx_funcmine measured ~9,495 duplicate function bodies across the _hdl_build tree (~23% of the codebase). Corrected measurement shows it is dominated by one dominant byte-identical variant per helper — the copy-pasted gate test-harness family (gw stdout, g_slen strlen, gn int-print, grow PASS/FAIL emit).
| Helper | Copies → base | Proof | Status |
|---|---|---|---|
gw (stdout write) | 399 → 1 | exact-match remove-local (nothing to shadow) + build-verify + behavioral spot-check | CONSOLIDATED |
g_slen (strlen) | 33 → 1 | single logic-variant ⇒ canonical behaviorally identical to every copy | CONSOLIDATED |
gn (int-print) | 432 → 1 | behavioral-verify-every-importer: each adopter proven output-byte-identical before/after; 72 variants rejected, 22 non-deterministic skipped | CONSOLIDATED |
grow (PASS/FAIL) | 10 → 1 | compiler else-desync fixed (plain-if); only 10 output-identical — grow's PASS/FAIL formats genuinely vary per gate, so 419 were correctly rejected | CONSOLIDATED (partial) |
874 copy-pasted helper bodies collapsed to canonical sources (gw 399 + g_slen 33 + gn 432 + grow 10), each provably behavior-preserving. Full-scale, not sampled — the un-consolidatable variants were rejected, not force-fit.
The gn consolidation used the behavioral applier (nx_behav_consolidate.sh) — the correct oracle for multi-variant helpers, where build-success is invalid: it runs each gate's self-test before and after and keeps only the output-byte-identical adopters, rejecting any variant a canonical would change. A separate per-helper lib avoids the cross-helper import shadow.
gw adopters by construction (exact-match-only), so it is a proof over the whole set, not a sample.Import shadows a same-signature local function. Adding a helper to a shared base that importers already pull in retroactively replaces any importer's same-signature local variant with the canonical — and a build still succeeds, so build-success cannot detect the behavior change. Therefore the only safe shared-base consolidator is exact-match-remove-local (the gw pass) or behavioral-verify-every-importer — never build-success alone. gn/grow were reverted to a provably-original state rather than shipped unverified.
nx_funcmine <dir> — measures byte-identical duplicate-function groups.nx_dominant_consolidate.sh <helper> — folds a helper's dominant byte-identical variant into the shared base, build-verified, revert-on-fail.nx_helper_equiv.sh <helper> <arity> — runs a variant battery against the canonical to prove/refute behavioral equivalence.Sovereign Nishi ecosystem · built and verified on the NAS build tree · no external toolchain.