code wiki / _hdl_build / nx_bugforge.nx

nx_bugforge.nx

buildroot/runtime/_hdl_build/nx_bugforge.nx

38859 B907 linesdepth 3pulls 4 transitivereach 0 importersview sourcekind orphan library
docsdependenciesstructsconstsfunctions

about

nx_bugforge.nx -- SWE-SCALE INSTANCE MINER (bugforge-swe-scale, 2026-07-24). The oracle today is 14 hand-seeded toy candidates; a frontier harness needs HUNDREDS of real-code instances plus a learned fix corpus. This organ mines them MECHANICALLY from the real runtime tree: 1 SCAN real .nx files for LEAF-PURE functions (all-i64 params, i64 return, no calls, no loops, no division, no pointers -- the v1 safety envelope, every exclusion COUNTED not silent) 2 MUTATE one operator swap per instance (data-driven op table: +/-, -/+, </>, >/<, */+) 3 VERIFY a generated PROBE compiles orig (renamed) + mutant side by side and sweeps the domain; the ORIGINAL IS THE ORACLE -- divergent cases are real failing tests, agreement cases are pass-to-pass regression teeth (the SWE-bench F2P+P2P contract, mechanically minted). No divergence proof => instance DISCARDED (absence of proof is not equivalence). 4 EMIT a self-contained candidate (mutant under its REAL name + FNRES/FNCASE grader main) that is byte-compatible with nx_autofix_auto's episode loop, a manifest row (name|path), and a (buggy TAB fixed) corpus row for retrieval few-shots (single-line fns). verbs: mine [maxn] [dir] (defaults 16, runtime) | selftest bf_manifest.txt / bf_fixcorpus.txt are DERIVED artifacts regenerated per run (documented REPLACE). license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 3 imports · 0 importers

nx_tool_run.nx nx_itoa_lib.nx nx_syscalls.nx nx_bugforge.nx

imports: nx_tool_run.nxnx_itoa_lib.nxnx_syscalls.nx

imported by: nobody (leaf or entry point)

structs

none

consts

21const BF_FCAP: i64 = 262144 // per-source-file read cap (bigger files skipped + counted)
22const BF_DCAP: i64 = 65536 // getdents buffer
23const BF_TCAP: i64 = 4096 // one extracted function text
24const BF_SRCCAP: i64 = 32768 // generated probe/candidate source
25const BF_OCAP: i64 = 524288 // build+run capture
26const BF_LISTCAP: i64 = 131072 // manifest/corpus accumulators
27const BF_PATHCAP: i64 = 256
28const BF_DOM: i64 = 6 // sweep half-width arity 1-2 (13 values/axis)
29const BF_DOM3: i64 = 4 // sweep half-width arity 3 (9^3=729 evals)
30const BF_MAXCASE: i64 = 6 // banked divergent (fail-to-pass) cases
31const BF_MAXPASS: i64 = 6 // banked agreement (pass-to-pass) cases
32const BF_PERFN: i64 = 2 // max instances per function (corpus diversity)
33const BF_MINB: i64 = 30 // min fn bytes (below = trivial)
34const BF_MAXB: i64 = 1200 // max fn bytes (fits the episode splice path)
35const BF_NOPS: i64 = 5
36const BF_ZERO: i64 = 48
37const BF_MODE: i64 = 420 // 0644 file mode (decimal per the magic ratchet)

functions

39func w(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
44func wn(v: i64) -> i64 { nxi_out(v); return 0 }
calls 1: nxi_out
45func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
46func sfind(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64
59func bcat(b: *u8, off: i64, s: *u8) -> i64
65func bcatr(b: *u8, off: i64, s: *u8, n: i64) -> i64
called by 2: bf_mutatebf_rename
71func bcatn(b: *u8, off: i64, v: i64) -> i64
calls 1: sys_mmap
84func bq(b: *u8, off: i64) -> i64 { b[off] = 34 as u8; return off + 1 }
called by 1: bqs
86func bqs(b: *u8, off: i64, s: *u8) -> i64
calls 2: bqbcat
92func scontains(hay: *u8, hn: i64, needle: *u8) -> i64 { if sfind(hay, hn, needle, 0) >= 0 { return 1 } return 0 }
called by 1: bf_eligible calls 1: sfind
95func bf_read(path: *u8, buf: *u8, cap: i64) -> i64
110func bf_write(path: *u8, buf: *u8, n: i64) -> i64
119func bf_run(name: *u8, out: *u8, cap: i64) -> i64
131func bf_intafter(buf: *u8, n: i64, token: *u8, from: i64, box: *i64) -> i64
calls 2: sfindslen
156func bf_fnend(fbuf: *u8, n: i64, at: i64) -> i64
177func bf_fnsig(t: *u8, tn: i64, nb: *u8) -> i64
calls 1: sfind
208func bf_eligible(t: *u8, tn: i64) -> i64
252func bf_opget(i: i64, box: *i64) -> i64
261func bf_mutate(t: *u8, tn: i64, find: *u8, repl: *u8, out: *u8) -> i64
275func bf_rename(dst: *u8, o0: i64, t: *u8, tn: i64, newname: *u8) -> i64
calls 3: sfindbcatbcatr
284func bf_gen_head(g: *u8) -> i64
299func bf_gen_cw(g: *u8, o0: i64, lit: *u8) -> i64
307func bf_gen_nl(g: *u8, o0: i64) -> i64
320func bf_probe_src(g: *u8, t: *u8, tn: i64, mut: *u8, mn: i64, arity: i64) -> i64
395func bf_cand_src(g: *u8, mut: *u8, mn: i64, fname: *u8, arity: i64, cargs: *i64, cwant: *i64, ncase: i64, pargs: *i64, pval: *i64, npass: i64, srcpath: *u8, oplab: *u8) -> i64
486func bf_collect(outb: *u8, on: i64, tag: *u8, arity: i64, args: *i64, vals: *i64, maxn: i64) -> i64
547func bf_try(t: *u8, tn: i64, fname: *u8, arity: i64, opfind: *u8, oprepl: *u8, oplab: *u8, srcpath: *u8, verbose: i64) -> i64
635func bf_name_ok(nm: *u8) -> i64
651func bf_mine(maxn: i64, dir: *u8, app: i64) -> i64
829func bf_selftest() -> i64
888func main(argc: i64, argv: *i64) -> i64