code wiki / _hdl_build / nx_diff_gen.nx
nx_diff_gen.nx
buildroot/runtime/_hdl_build/nx_diff_gen.nx
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
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
structs
| none |
consts
| 27 | const DG_MAGIC_1103515245: i64 = 1103515245 |
| 28 | const DG_MAGIC_12345: i64 = 12345 |
| 29 | const DG_MAGIC_2800: i64 = 2800 |
| 30 | const DG_MAGIC_4096: i64 = 4096 |
| 31 | const DG_MAGIC_4095: i64 = 4095 |
| 32 | const DG_MAGIC_1106202601: i64 = 1106202601 |
| 33 | const DG_MAGIC_1469598103: i64 = 1469598103 |
| 35 | const DG_FILEPAD: i64 = 3072 |
| 36 | const DG_BUFCAP: i64 = 4096 |
functions
| 38 | func 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 |
| 39 | func 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 } |
| 44 | func dg_fn(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 46 | func dg_cat(dst: *u8, off: i64, s: *u8) -> i64 |
| 52 | func dg_catn(dst: *u8, off: i64, v: i64) -> i64 |
| 66 | func dg_rnd(st: *i64, k: i64) -> i64 |
| 72 | func dg_catv(dst: *u8, off: i64, idx: i64) -> i64 |
| 79 | func dg_st_arith(b: *u8, off: i64, st: *i64) -> i64 |
| 115 | func dg_st_branch(b: *u8, off: i64, st: *i64) -> i64 |
| 141 | func dg_st_loop(b: *u8, off: i64, st: *i64, sidx: i64) -> i64 |
| 163 | func dg_program(b: *u8, st: *i64, idx: i64, max_stmts: i64) -> i64 |
| 193 | func dg_write(path: *u8, b: *u8, len: i64) -> i64 |
| 209 | func dg_conf(buf: *u8, n: i64, key: *u8, kl: i64, dflt: i64) -> i64 |
| 239 | func main(argc: i64, argv: *i64) -> i64 |