code wiki / _hdl_build / nx_gate_dry_apply.nx
nx_gate_dry_apply.nx
buildroot/runtime/_hdl_build/nx_gate_dry_apply.nx
about
nx_gate_dry_apply.nx -- THE D001 CANDIDATE GENERATOR (2026-07-31, ws=gate-dry-d001).
WHAT IT IS: a MECHANICAL REWRITER that emits a MINIMAL-FORM migration candidate for one gate. It is
explicitly NOT a correct rewriter and does not need to be -- nx_gate_migrate verify is the safety net,
and that net is independently gate-proven to BITE on real files (a check-dropping edit was refused on
clause (c) while clauses (a) and (b) both waved it through, and the original was restored byte-intact).
So the division of labour is: this organ GUESSES, the verifier DECIDES, and a wrong guess costs nothing
because the verifier restores the original itself.
THE MINIMAL FORM, and why it is the mechanizable one: leave EVERY check row byte-untouched and replace
ONLY the hand-rolled verdict tail. Clause (c) -- the PASS/FAIL vector, which is the hardest clause to
satisfy -- then cannot diverge BY CONSTRUCTION rather than by the author having hand-checked it. And the
verdict tail is precisely the debt D001 names ("2601 gates roll their own verdict emission"), so the
minimal form eats the debt in full. Full gv_check adoption is a separate, optional, later rung.
SAFE BY REFUSAL (the nx_map_delegate discipline): every structural landmark must be found EXACTLY, and
the counter idiom must match one of the three known shapes. Anything else -> SKIP, emit nothing, exit 1.
A SKIP is a fine outcome and must never be dressed up as a migration.
SHAPES RECOGNISED (measured over the local buildroot: 950 of 1390 candidates carry a counter idiom):
A tot[0] / tot[1] -- an mmap'd pair, pass in [0] and fail in [1] (nx_brand_snap_gate)
B var pass / var fail -- two scalars, pass and fail counted separately
C var pass / var tot -- pass counted, total counted
usage: nx_gate_dry_apply <gate> <out-candidate-path>
then: nx_gate_migrate verify <gate> <out-candidate-path>
exit 0 = candidate written · 1 = SKIP (shape not recognised) · 2 = usage · 4 = harness/root failure
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 2 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.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
| 32 | const DA_CAP: i64 = 262144 |
| 33 | const DA_PATH: i64 = 512 |
| 34 | const DA_OUT: i64 = 393216 |
| 35 | const DA_MODE: i64 = 420 |
| 36 | const DA_SKIP: i64 = 1 |
| 37 | const DA_USAGE: i64 = 2 |
| 38 | const DA_HARNESS: i64 = 4 |
| 39 | const DA_NOTE_MAX: i64 = 240 |
functions
| 41 | func da_exists(path: *u8) -> i64 |
| 48 | func da_root_ensure() -> i64 |
| 57 | func da_cat(dst: *u8, o: i64, s: *u8) -> i64 called by 1: main |
| 65 | func da_slurp(path: *u8, buf: *u8, cap: i64) -> i64 |
| 80 | func da_write(path: *u8, buf: *u8, n: i64) -> i64 |
| 96 | func da_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: da_find |
| 99 | func da_find(buf: *u8, n: i64, needle: *u8, from: i64) -> i64 |
| 114 | func da_find_last(buf: *u8, n: i64, needle: *u8) -> i64 |
| 125 | func da_line_start(buf: *u8, off: i64) -> i64 called by 1: main |
| 135 | func da_line_end(buf: *u8, n: i64, off: i64) -> i64 |
| 145 | func da_import_point(buf: *u8, n: i64) -> i64 |
| 154 | func da_name(gate: *u8, out: *u8) -> i64 called by 1: main |
| 178 | func da_note(buf: *u8, n: i64, gat: i64, out: *u8) -> i64 |
| 228 | func main(argc: i64, argv: *i64) -> i64 |