code wiki / _hdl_build / nx_gate_migrate.nx
nx_gate_migrate.nx
buildroot/runtime/_hdl_build/nx_gate_migrate.nx
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
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
structs
| none |
consts
| 41 | const GM_CAP: i64 = 262144 |
| 42 | const GM_PATH: i64 = 512 |
| 43 | const GM_RES: i64 = 64 |
| 44 | const GM_MODE: i64 = 0x1a4 |
| 48 | const GM_BUILDER: *u8 = "_offc/nx_sov_build_run.elf" |
| 49 | const GM_BUILDONLY: *u8 = "--build-only" |
| 51 | const GM_ROOTMARK: *u8 = "runtime/nx_gate_verdict.nx" |
| 52 | const GM_ROOTALT: *u8 = "buildroot" |
| 54 | const GM_ARTDIR: *u8 = "_build/" |
| 55 | const GM_ARTALT: *u8 = "/tmp/" |
| 61 | const GM_BUILD_MS: i64 = 300000 |
| 62 | const GM_RUN_MS: i64 = 120000 |
| 63 | const GM_USAGE: i64 = 2 |
| 64 | const GM_REFUSE: i64 = 3 |
| 65 | const GM_HARNESS: i64 = 4 |
| 68 | const GM_SLOT: i64 = 16 |
| 69 | const GM_UNCHECKED: i64 = 0 - 1 |
| 80 | const GM_ENRICHED: i64 = 2 |
| 83 | const GM_RESN: i64 = 11 |
| 84 | const GM_R_EXIT: i64 = 0 |
| 85 | const GM_R_JUDGE: i64 = 1 |
| 86 | const GM_R_VEC: i64 = 2 |
| 87 | const GM_R_EVID: i64 = 3 |
| 88 | const GM_R_BYTES: i64 = 4 |
| 89 | const GM_R_PASSA: i64 = 5 |
| 90 | const GM_R_PASSB: i64 = 6 |
| 91 | const GM_R_FAILA: i64 = 7 |
| 92 | const GM_R_FAILB: i64 = 8 |
| 93 | const GM_R_GREENA: i64 = 9 |
| 94 | const GM_R_GREENB: i64 = 10 |
| 96 | const GM_A_EXIT: i64 = 0 |
| 97 | const GM_A_VEC: i64 = 1 |
| 98 | const GM_A_BEFORE_CLEAN: i64 = 2 |
| 99 | const GM_A_AFTER_HAS: i64 = 3 |
| 100 | const GM_A_AGREES: i64 = 4 |
| 101 | const GM_ARESN: i64 = 5 |
functions
| 103 | func gm_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 105 | func gm_cat(dst: *u8, o: i64, s: *u8) -> i64 |
| 114 | func gm_count(buf: *u8, n: i64, needle: *u8) -> i64 |
| 128 | func gm_write_file(path: *u8, buf: *u8, n: i64) -> i64 |
| 145 | func gm_copy(src: *u8, dst: *u8) -> i64 |
| 154 | func gm_fsize(path: *u8) -> i64 |
| 168 | func gm_root_ensure() -> i64 |
| 179 | func gm_resolve(gate: *u8, out: *u8) -> i64 |
| 197 | func gm_artifact(gate: *u8, out: *u8) -> i64 |
| 210 | func gm_build(gate: *u8) -> i64 |
| 225 | func gm_run(gate: *u8, out: *u8, outlen: *i64) -> i64 |
| 236 | func gm_clauses(outA: *u8, nA: i64, rcA: i64, outB: *u8, nB: i64, rcB: i64, dA: i64, dB: i64, res: *i64) -> i64 |
| 290 | func an_clauses(outA: *u8, nA: i64, rcA: i64, outB: *u8, nB: i64, rcB: i64, res: *i64) -> i64 |
| 311 | func an_report(res: *i64, accepted: i64) -> i64 |
| 328 | func gm_anchor(gate: *u8, ancsrc: *u8) -> i64 |
| 381 | func gm_report(res: *i64, accepted: i64) -> i64 |
| 401 | func gm_verify(gate: *u8, migsrc: *u8, evid: *u8) -> i64 |
| 468 | func gm_probe(gate: *u8) -> i64 |
| 498 | func gm_selftest() -> i64 |
| 595 | func main(argc: i64, argv: *i64) -> i64 |