code wiki / _hdl_build / nx_gate_dry_apply.nx

nx_gate_dry_apply.nx

buildroot/runtime/_hdl_build/nx_gate_dry_apply.nx

32284 B707 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic gate
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_gate_dry_apply.nx

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

main gv_puts sys_write da_root_ensure da_exists sys_openat_rd sys_close gv_puts ↻ sys_chdir sys_mmap sys_mmap ↻ da_cat da_slurp sys_openat_rd ↻ sys_read sys_close ↻ da_find da_slen da_find_last da_find ↻ da_import_point da_find_last ↻ da_line_end da_line_start da_name da_note da_line_end ↻ gv_ctr sys_mmap ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻

structs

none

consts

32const DA_CAP: i64 = 262144
33const DA_PATH: i64 = 512
34const DA_OUT: i64 = 393216
35const DA_MODE: i64 = 420
36const DA_SKIP: i64 = 1
37const DA_USAGE: i64 = 2
38const DA_HARNESS: i64 = 4
39const DA_NOTE_MAX: i64 = 240

functions

41func da_exists(path: *u8) -> i64
48func da_root_ensure() -> i64
called by 1: main calls 3: da_existsgv_putssys_chdir
57func da_cat(dst: *u8, o: i64, s: *u8) -> i64
called by 1: main
65func da_slurp(path: *u8, buf: *u8, cap: i64) -> i64
called by 1: main calls 3: sys_openat_rdsys_readsys_close
80func da_write(path: *u8, buf: *u8, n: i64) -> i64
96func 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
99func da_find(buf: *u8, n: i64, needle: *u8, from: i64) -> i64
called by 2: da_find_lastmain calls 1: da_slen
114func da_find_last(buf: *u8, n: i64, needle: *u8) -> i64
called by 2: da_import_pointmain calls 1: da_find
125func da_line_start(buf: *u8, off: i64) -> i64
called by 1: main
135func da_line_end(buf: *u8, n: i64, off: i64) -> i64
145func da_import_point(buf: *u8, n: i64) -> i64
called by 1: main calls 2: da_find_lastda_line_end
154func da_name(gate: *u8, out: *u8) -> i64
called by 1: main
178func da_note(buf: *u8, n: i64, gat: i64, out: *u8) -> i64
called by 1: main calls 1: da_line_end
228func main(argc: i64, argv: *i64) -> i64