code wiki / _hdl_build / nx_infinibug.nx
nx_infinibug.nx
buildroot/runtime/_hdl_build/nx_infinibug.nx
about
nx_infinibug.nx -- INFINIGEN-FOR-CODE (worldclass/bugforge lane, 2026-07-24). Operator pointed at
Infinigen (arXiv 2306.09310): a PROCEDURAL generator with NO static assets -- every scene is emitted
from seeded random rules, and ground truth comes FREE from the generator. This is that idea ported
from photorealistic worlds to VERIFIED CODE REPAIR: it procedurally emits a "world" of novel pure
integer functions from a seeded grammar with difficulty knobs, so the bug-instance supply is
INFINITE and CURRICULUM-CONTROLLABLE instead of the 35 hand-written functions the disk scan finds.
COMPOSITION (rule 15 -- no duplicated machinery): infinibug ONLY generates the world (function
source files); the PROVEN nx_bugforge miner then extracts ground-truth-labeled (buggy, oracle-fixed,
F2P+P2P) instances from that dir exactly as it mines real code. Infinigen generates, bugforge
harvests. This also proves bugforge is source-AGNOSTIC (real corpus OR procedural world, same loop).
DETERMINISTIC: seeded LCG (reproducible curriculum -- seed is part of the input, like Infinigen's).
SELF-CLEAN under nx_assure: iterative expression builder (NO recursion, P10-R1), no alloc in loops.
verbs: gen <count> <seed> <difficulty 1-5> [outdir] (default outdir runtime/igworld) | selftest
license_tier: ORIGINAL No hw writes (Rule 26).
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
| 19 | const IG_MAGIC_12345: i64 = 12345 |
| 21 | const IG_A: i64 = 1103515245 // LCG multiplier (glibc rand; small, ratchet-safe as a named const) |
| 22 | const IG_C: i64 = 12345 // LCG increment |
| 23 | const IG_SRCCAP: i64 = 8192 |
| 24 | const IG_PATHCAP: i64 = 256 |
| 25 | const IG_ZERO: i64 = 48 |
| 26 | const IG_MODE: i64 = 420 // 0644 |
| 27 | const IG_MAXG: i64 = 3 // guard-clause ceiling |
| 28 | const IG_MAXT: i64 = 7 // terms-per-expression ceiling |
functions
| 32 | func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } |
| 37 | func wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 38 | func bcat(b: *u8, off: i64, s: *u8) -> i64 { var i: i64 = 0; var o: i64 = off; while s[i] != (0 as u8) { b[o] = s[i]; o = o + 1; i = i + 1 } return o } |
| 39 | func bcatn(b: *u8, off: i64, v: i64) -> i64 |
| 53 | func ig_next() -> i64 { g_rng = g_rng * IG_A + IG_C; var v: i64 = g_rng; if v < 0 { v = 0 - v } return v } |
| 54 | func ig_rand(n: i64) -> i64 { if n <= 0 { return 0 } return ig_next() % n } |
| 57 | func ig_param(b: *u8, o: i64, arity: i64) -> i64 { b[o] = (97 + ig_rand(arity)) as u8; return o + 1 } |
| 60 | func ig_leaf(b: *u8, o: i64, arity: i64) -> i64 |
| 66 | func ig_aop(b: *u8, o: i64) -> i64 |
| 76 | func ig_cop(b: *u8, o: i64) -> i64 |
| 83 | func ig_expr(b: *u8, o: i64, arity: i64, nterms: i64) -> i64 |
| 104 | func ig_fnbody(src: *u8, o0: i64, arity: i64, diff: i64) -> i64 |
| 130 | func ig_write(path: *u8, buf: *u8, n: i64) -> i64 |
| 139 | func ig_one(outdir: *u8, seed: i64, idx: i64, diff: i64) -> i64 |
| 165 | func ig_gen(count: i64, seed: i64, diff: i64, outdir: *u8) -> i64 |
| 187 | func ig_selftest() -> i64 |
| 244 | func main(argc: i64, argv: *i64) -> i64 |