code wiki / _hdl_build / nx_diff_gen.nx

nx_diff_gen.nx

buildroot/runtime/_hdl_build/nx_diff_gen.nx

11029 B311 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic diff
docsdependenciesstructsconstsfunctions

about

nx_diff_gen.nx -- R1-T1-001: the differential-testing CORPUS GENERATOR (the PREVENT instrument for the miscompile class; spec arc T1). Emits N deterministic random programs in the SUPPORTED dialect envelope, so any build/run failure is a NEW toolchain bug by construction, never a known landmine: counted while loops only (literal bound <=10 -> termination by construction); ifs <=2 deep; i64 + - * only (no division); every shift masked (LM-005); literals non-negative (LM-004); sys_exit((sum)&1) so legal exits are EXACTLY {0,1} -- lane rc 3/4 = toolchain fail, >128 = crash, anything else loud. DETERMINISM: same conf (knowledge/registry/diff_corpus.conf: n/seed/ max_stmts) = byte-identical corpus (LCG PRNG, no time, no env) -- proven by the gate via corpus-hash equality across runs. Programs land in runtime/_hdl_build/<prefix><i>.nx because expand_imports resolves only there (probed 2026-06-11: /tmp sources fail expand_imports) -- which also means the DURABLE LANE builds any corpus program by basename, retry guard included. Every file is PADDED to a fixed 3072 bytes with trailing newlines: rewrites always cover prior content (LM-022 stale-tail killer even across seed changes). argv[1]=conf override argv[2]=name-prefix override (default _dgp) argv[3]=hash-file override (default /tmp/_dg_hash.txt) Evidence: DIFFGEN row -> stdout + knowledge/status/diff_gen.log. license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_diff_gen.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main sys_mmap sys_openat_rd sys_read sys_close dg_conf dg_program dg_cat dg_catv dg_catn sys_mmap ↻ dg_rnd dg_st_arith dg_rnd ↻ dg_cat ↻ dg_catv ↻ dg_catn ↻ dg_st_branch dg_rnd ↻ dg_cat ↻ dg_catv ↻ dg_st_loop dg_rnd ↻ dg_cat ↻ dg_catn ↻ dg_catv ↻ dg_cat ↻ dg_catn ↻ dg_write sys_openat_wr sys_write sys_close ↻ sys_openat_wr ↻ dg_fn nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap dg_fp

structs

none

consts

27const DG_MAGIC_1103515245: i64 = 1103515245
28const DG_MAGIC_12345: i64 = 12345
29const DG_MAGIC_2800: i64 = 2800
30const DG_MAGIC_4096: i64 = 4096
31const DG_MAGIC_4095: i64 = 4095
32const DG_MAGIC_1106202601: i64 = 1106202601
33const DG_MAGIC_1469598103: i64 = 1469598103
35const DG_FILEPAD: i64 = 3072
36const DG_BUFCAP: i64 = 4096

functions

38func dg_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
calls 1: sys_write
39func dg_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 }
called by 1: main calls 1: sys_write
44func dg_fn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
46func dg_cat(dst: *u8, off: i64, s: *u8) -> i64
52func dg_catn(dst: *u8, off: i64, v: i64) -> i64
66func dg_rnd(st: *i64, k: i64) -> i64
72func dg_catv(dst: *u8, off: i64, idx: i64) -> i64
79func dg_st_arith(b: *u8, off: i64, st: *i64) -> i64
115func dg_st_branch(b: *u8, off: i64, st: *i64) -> i64
called by 1: dg_program calls 3: dg_rnddg_catdg_catv
141func dg_st_loop(b: *u8, off: i64, st: *i64, sidx: i64) -> i64
163func dg_program(b: *u8, st: *i64, idx: i64, max_stmts: i64) -> i64
193func dg_write(path: *u8, b: *u8, len: i64) -> i64
209func dg_conf(buf: *u8, n: i64, key: *u8, kl: i64, dflt: i64) -> i64
239func main(argc: i64, argv: *i64) -> i64