code wiki / _hdl_build / nx_gate_migrate.nx

nx_gate_migrate.nx

buildroot/runtime/_hdl_build/nx_gate_migrate.nx

33982 B633 linesdepth 5pulls 7 transitivereach 0 importersview sourcekind tooltopic gate
docsdependenciesstructsconstsfunctions

about

nx_gate_migrate.nx -- D001 GATE-DRY MIGRATION VERIFIER (2026-07-22). THE DEBT: 1918 of 1996 gate organs (96%) hand-roll their verdict scaffold instead of inheriting nx_gate_verdict. Every prior attempt to eat it reached for a BYTE-equivalence proof and refused, because byte-identity is UNACHIEVABLE BY CONSTRUCTION here: gv_check emits " <name>: PASS" where a hand-rolled row emits " <name> PASS", and gv_verdict reformats the summary line entirely. The wrong oracle -- not a hard problem -- is why D001 never moved. THE SOUND ORACLE = JUDGE-EQUIVALENCE, 4 clauses, measured before vs after in the SAME environment: (a) exit code identical -- the gate still passes/fails the same way (b) judge verdict identical -- gg_line_green(last "verdict=" line, "GREEN") agrees. We COMPOSE nx_gate_green (the ecosystem's ONE judge) rather than reimplement it: the migration is sound exactly when the thing that JUDGES gates cannot tell the difference. (c) PASS/FAIL vector identical -- same checks, same results, same counts (d) evidence side-effect preserved -- OPTIONAL, only when the caller names the file; when absent it is reported UNCHECKED, never silently assumed clean (self-ceiling law L011). Byte-difference alone MUST NOT refuse -- that is the whole point (tooth T5). DIVISION OF LABOUR (deliberate): the EDIT is semantic and belongs to the gate's owner lane; the PROOF is mechanizable and belongs here. So this is a VERIFIER with commit-or-restore, never an auto-editor. never-brick: on ANY divergence, failed build, or harness error the ORIGINAL source is RESTORED and the verdict is REFUSE. The pre-migration copy is kept (rule 13 additive) as <src>.premigrate. nx_gate_migrate verify <gate> <migrated-src> [evidence-file] nx_gate_migrate anchor <gate> <anchored-src> -- seq585: adopt the canonical verdict= anchor nx_gate_migrate probe <gate> nx_gate_migrate selftest ANCHOR RUNG (seq585, MUST precede the DRY rung for the 953 unjudgeable gates): a gate that emits PASS/FAIL + exit 0/1 but no "verdict=" line is machine-read as NOT-GREEN by gg_line_green (missing anchor == failure, nx_gate_green.nx:56) -- a silent false negative. `anchor` verifies an anchor-ADOPTION edit: before must have NO anchor in its output, after MUST have one, exit + PASS/FAIL vector identical, and the emitted verdict must AGREE with the exit code (GREEN iff exit 0 -- an anchor that lies about the exit is worse than no anchor). Same commit-or-restore as verify. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0

dependencies 4 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_gate_green.nx nx_tool_run.nx nx_gate_migrate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_gate_green.nxnx_tool_run.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 sys_exit gm_count gm_slen gm_slen ↻ gm_selftest gv_ctr sys_mmap gv_head gv_puts ↻ sys_mmap ↻ gm_slen ↻ gm_clauses gg_line_green gg_line_judge gg_last nx_str_len gm_count ↻ gv_check gv_puts ↻ an_clauses gm_count ↻ gg_line_green ↻ gv_verdict gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_journal sys_openat_append sys_mmap ↻ gv_catn sys_mmap ↻ sys_munmap ↻ sys_now_realtime_sec sys_mmap ↻ sys_clock_gettime_real

structs

none

consts

41const GM_CAP: i64 = 262144
42const GM_PATH: i64 = 512
43const GM_RES: i64 = 64
44const GM_MODE: i64 = 0x1a4
48const GM_BUILDER: *u8 = "_offc/nx_sov_build_run.elf"
49const GM_BUILDONLY: *u8 = "--build-only"
51const GM_ROOTMARK: *u8 = "runtime/nx_gate_verdict.nx"
52const GM_ROOTALT: *u8 = "buildroot"
54const GM_ARTDIR: *u8 = "_build/"
55const GM_ARTALT: *u8 = "/tmp/"
61const GM_BUILD_MS: i64 = 300000
62const GM_RUN_MS: i64 = 120000
63const GM_USAGE: i64 = 2
64const GM_REFUSE: i64 = 3
65const GM_HARNESS: i64 = 4
68const GM_SLOT: i64 = 16
69const GM_UNCHECKED: i64 = 0 - 1
80const GM_ENRICHED: i64 = 2
83const GM_RESN: i64 = 11
84const GM_R_EXIT: i64 = 0
85const GM_R_JUDGE: i64 = 1
86const GM_R_VEC: i64 = 2
87const GM_R_EVID: i64 = 3
88const GM_R_BYTES: i64 = 4
89const GM_R_PASSA: i64 = 5
90const GM_R_PASSB: i64 = 6
91const GM_R_FAILA: i64 = 7
92const GM_R_FAILB: i64 = 8
93const GM_R_GREENA: i64 = 9
94const GM_R_GREENB: i64 = 10
96const GM_A_EXIT: i64 = 0
97const GM_A_VEC: i64 = 1
98const GM_A_BEFORE_CLEAN: i64 = 2
99const GM_A_AFTER_HAS: i64 = 3
100const GM_A_AGREES: i64 = 4
101const GM_ARESN: i64 = 5

functions

103func gm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
105func gm_cat(dst: *u8, o: i64, s: *u8) -> i64
114func gm_count(buf: *u8, n: i64, needle: *u8) -> i64
128func gm_write_file(path: *u8, buf: *u8, n: i64) -> i64
145func gm_copy(src: *u8, dst: *u8) -> i64
154func gm_fsize(path: *u8) -> i64
called by 1: gm_verify calls 2: sys_mmapgg_read
168func gm_root_ensure() -> i64
179func gm_resolve(gate: *u8, out: *u8) -> i64
197func gm_artifact(gate: *u8, out: *u8) -> i64
called by 1: gm_run calls 3: gm_catsys_mmapgg_read
210func gm_build(gate: *u8) -> i64
225func gm_run(gate: *u8, out: *u8, outlen: *i64) -> i64
236func gm_clauses(outA: *u8, nA: i64, rcA: i64, outB: *u8, nB: i64, rcB: i64, dA: i64, dB: i64, res: *i64) -> i64
290func an_clauses(outA: *u8, nA: i64, rcA: i64, outB: *u8, nB: i64, rcB: i64, res: *i64) -> i64
311func an_report(res: *i64, accepted: i64) -> i64
called by 1: gm_anchor calls 1: gv_puts
328func gm_anchor(gate: *u8, ancsrc: *u8) -> i64
381func gm_report(res: *i64, accepted: i64) -> i64
called by 1: gm_verify calls 2: gv_putsgv_num
401func gm_verify(gate: *u8, migsrc: *u8, evid: *u8) -> i64
468func gm_probe(gate: *u8) -> i64
498func gm_selftest() -> i64
595func main(argc: i64, argv: *i64) -> i64