code wiki / _hdl_build / nx_dedup_migrate.nx

nx_dedup_migrate.nx

buildroot/runtime/_hdl_build/nx_dedup_migrate.nx

43990 B899 linesdepth 5pulls 9 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_dedup_migrate.nx -- D001-FAMILY ORGAN-DEDUP MIGRATION VERIFIER (2026-07-23, dedupq-/TS03 lane). THE DEBT (measured): 245 organs in _hdl_build re-implement the same ~10 span/JSON helpers inline (~2400 duplicated funcs, D001-family; queue = knowledge/store/dedupq-). The canonical base is nx_sovjson_lib.nx (proven consumers: nx_seat/nx_clawf_route/nx_actlog/nx_tokroi/nx_ctxcost). The EDIT (delegate local helpers to sj_*) is mechanical -- an author lane or the local maker produces a .migrated source; THIS organ is the unfailable judge that makes committing it safe, which is what lets the migration run AUTONOMOUSLY (a tool that cannot do the wrong thing beats a session that must remember). THE SOUND ORACLE = BEHAVIOR-EQUIVALENCE (source-byte equivalence is the WRONG oracle -- param names/registers differ across organs; the exact lesson that unblocked the D001 gate campaign via judge-equivalence): (a) exit code identical (original argless probe vs migrated argless probe) (b) stdout byte-identical -- or, when the original is not self-deterministic (two baseline runs differ, e.g. epoch stamps), digit-normalized-identical; the MODE is DECLARED in the report, never silently weakened (c) non-vacuity: the migrated source imports nx_sovjson_lib AND calls sj_* AND differs from the original (an unchanged "migration" is a lie -> REFUSE) commit-or-restore: on ANY refusal/build-failure/harness error the ORIGINAL source is restored AND rebuilt (so /tmp + staged artifacts match reality); the pre-migration copy is kept as <src>.premigrate, FIRST-TOUCH preserved (rule 13 additive -- a second run never clobbers the true original). never-brick: touches ONLY buildroot sources + /tmp build artifacts; live elf promotion stays a separate deliberate /api step. No hw writes (Rule 26). nx_dedup_migrate stage <organ> -- copy <src> -> <src>.migrated (edit substrate) nx_dedup_migrate verify <organ> <migrated-src> -- judge + commit-or-restore nx_dedup_migrate selftest -- hermetic oracle teeth (gv lib) license_tier: ORIGINAL expect_exit: 0

dependencies 6 imports · 0 importers

nx_syscalls.nx nx_gate_verdict.nx nx_tool_run.nx nx_sovjson_lib.nx nx_store_seed_lib.nx nx_seg_store.nx nx_dedup_migrate.nx

imports: nx_syscalls.nxnx_gate_verdict.nxnx_tool_run.nxnx_sovjson_lib.nxnx_store_seed_lib.nxnx_seg_store.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sj_werr sys_write sys_exit dd_eqz gv_ctr sys_mmap gv_head gv_puts sys_write ↻ sj_vlen sys_mmap ↻ gv_check gv_puts ↻ dd_oracle dd_byteeq dd_normeq dd_normeq ↻ dd_edit de_linestart de_at sys_mmap ↻ de_try de_isws de_at ↻ de_endswith sj_vlen ↻ sj_lit_eq de_suffix sys_mmap ↻ sj_lit_eq ↻ de_sig sj_span_has sj_vlen ↻ de_close de_nulterm sj_span_has ↻ sj_cat de_target tr_contains

structs

none

consts

36const DD_MAGIC_4096: i64 = 4096
37const DD_MAGIC_1024: i64 = 1024
38const DD_MAGIC_65536: i64 = 65536
40const DD_CAP: i64 = 262144
41const DD_PATH: i64 = 512
42const DD_MODE: i64 = 420
43const DD_XMODE: i64 = 493
44const DD_ELF_MAG0: i64 = 127
45const DD_SLOT: i64 = 16
46const DD_ARGV: i64 = 40
47const DD_RES_BYTES: i64 = 64
48const DD_SRC: i64 = 524288
49const DD_PLANE: i64 = 1048576
50const DD_USAGE: i64 = 2
51const DD_REFUSE: i64 = 3
52const DD_HARNESS: i64 = 4
54const DD_R_EXIT: i64 = 0
55const DD_R_OUT: i64 = 1
56const DD_R_NORM: i64 = 2
57const DD_R_IMPORT: i64 = 3
58const DD_R_CALLS: i64 = 4
59const DD_R_CHANGED: i64 = 5
60const DD_R_RAN: i64 = 6
61const DD_RESN: i64 = 7
62const DD_UNMEASURED: i64 = 0 - 1
309const DE_N: i64 = 9

functions

64func dd_eqz(a: *u8, b: *u8) -> i64
called by 1: main
71func dd_read(path: *u8, lenp: *i64) -> *u8
79func dd_write_file(path: *u8, buf: *u8, n: i64) -> i64 { return dd_write_file_m(path, buf, n, DD_MODE) }
called by 2: dd_reportmain calls 1: dd_write_file_m
81func dd_write_file_m(path: *u8, buf: *u8, n: i64, mode: i64) -> i64
97func dd_byteeq(a: *u8, na: i64, b: *u8, nb: i64) -> i64
called by 2: dd_oraclemain
106func dd_normeq(a: *u8, na: i64, b: *u8, nb: i64) -> i64
called by 2: dd_oraclemain
126func dd_oracle(rcA: i64, rcB: i64, outA: *u8, nA: i64, outB: *u8, nB: i64, selfdet: i64, imp: i64, calls: i64, changed: i64, res: *i64) -> i64
called by 1: main calls 2: dd_byteeqdd_normeq
143func dd_path_src(organ: *u8, out: *u8) -> i64
called by 1: main calls 1: sj_cat
151func dd_path_art(organ: *u8, out: *u8) -> i64
called by 2: dd_builddd_run calls 1: sj_cat
161func dd_build(organ: *u8) -> i64
189func dd_run(organ: *u8, out: *u8, ol: *i64) -> i64
202func dd_report(organ: *u8, verdict: *u8, res: *i64, rcA: i64, rcB: i64, nA: i64, nB: i64, srcA: i64, srcB: i64, reason: *u8) -> i64
253func de_isws(c: i64) -> i64 { if c == 32 { return 1 } if c == 9 { return 1 } return 0 }
called by 1: de_try
255func de_at(q: *u8, n: i64, i: i64, lit: *u8) -> i64
265func de_linestart(q: *u8, i: i64) -> i64
272func de_close(q: *u8, n: i64, open: i64) -> i64
called by 1: de_try
299func de_endswith(q: *u8, s: i64, e: i64, lit: *u8) -> i64
called by 1: de_try calls 2: sj_vlensj_lit_eq
310func de_suffix(k: i64) -> *u8
called by 1: de_try
322func de_sig(k: i64) -> *u8
called by 1: de_try
334func de_target(k: i64) -> *u8
called by 1: de_try
348func de_nulterm(q: *u8, ob: i64, cb: i64) -> i64
called by 1: de_try calls 1: sj_span_has
356func de_try(q: *u8, n: i64, i: i64, out: *u8, o: i64, res2: *i64) -> i64
444func dd_edit(q: *u8, n: i64, out: *u8, lenp: *i64) -> i64
478func dd_insert_import(q: *u8, n: i64, out: *u8, lenp: *i64) -> i64
called by 1: main calls 3: de_linestartde_atsj_cat
498func dd_qparse(q: *u8, ls: i64, le: i64, res: *i64) -> i64
called by 1: main calls 2: sys_mmapsj_lit_eq
518func main(argc: i64, argv: *i64) -> i64