nx_autofix_auto.nx
buildroot/runtime/nx_autofix_auto.nx
about
nx_autofix_auto.nx -- THE SELF-LOCALIZING FIX LOOP (2026-07-16): removes the last a-priori knowledge
from the autonomous fix episode. nx_autofix_localfix proved the LOCAL MAKER (model-generated fix,
machine-verified) but was TOLD the buggy line. This organ DISCOVERS it: it parses the candidate
grader's own per-function FNRES rows to find WHICH function fails, extracts that function's current
source line from the file (brace-depth clip), and only then hands it to the local maker. The
independent grader (fresh compile+run) remains the only judge at every stage.
THE NOT-HARDCODED TOOTH: the SAME organ runs against TWO candidates whose seeded bugs live in
DIFFERENT functions (candidate2 -> sgn, candidate3 -> dbl; neither is in the few-shot template).
Correct localization must name a different function in each episode -- data-driven, not baked in.
Episode: [1 IDENTIFY+LOCATE] grader run -> failing FNRES row -> function name [2 FLAG w/ the
DISCOVERED name] [3 BACKUP] [4 FIX = local 1.5B i8 greedy, few-shot, buggy line = the EXTRACTED
source] [5 VERIFY = no failing FNRES row] [6 REVERT + re-grade = original failing row returns].
RETRY LADDER (2026-07-17): round-2 = ONE greedy retry on a reframed prompt (echo-aware + machine
report); rounds 3+ = AF_BON_N SAMPLED retries (pinned temp/top-p/top-k, FIXED seed ladder -> the
whole sweep stays deterministic: seeds are part of the input, xorshift64* is seed-deterministic).
Greedy is a fixed point (same prompt -> same bytes -- the v2 sweep showed every greedy round-2 on
a miss reproduced round-1 byte-identically); independent samples break it (A1 best-of-N precedent).
The fresh compile+run grader stays the ONLY judge at every rung; failed samples are reverted.
argv: <model> [manifest] [ledger-override] -- the override is the TESTING LANE: a validation run
writes episode rows to a scratch ledger so it can never masquerade as the newest official batch
(the swebench gate + autograde pulse read the real ledger's newest ts batch).
Green-only: CGB localpass row per verified fix (generator=15b-autofix-auto). Misses bank curriculum.
exit: 0 = every episode's loop sound (fix green OR honest miss) | 1 = a loop-integrity failure.
license_tier: ORIGINAL
dependencies 4 imports · 0 importers
imports: nx_tool_run.nxnx_propose_verify_lib.nxnx_gramdec_lib.nxnx_autofix_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
| 31 | const AF_MAGIC_131072: i64 = 131072 |
| 32 | const AF_MAGIC_262144: i64 = 262144 |
| 33 | const AF_MAGIC_4000: i64 = 4000 |
| 34 | const AF_MAGIC_1500: i64 = 1500 |
| 35 | const AF_MAGIC_2048: i64 = 2048 |
| 36 | const AF_MAGIC_1048576: i64 = 1048576 |
| 37 | const AF_MAGIC_1024: i64 = 1024 |
| 38 | const AF_MAGIC_4096: i64 = 4096 |
| 39 | const AF_MAGIC_65536: i64 = 65536 |
| 40 | const AF_MAGIC_65500: i64 = 65500 |
| 44 | const AF_BON_N: i64 = 3 // sampled retries after both greedy rounds miss |
| 45 | const AF_BON_TEMP_PM: i64 = 800 // permille temperature (800 = 0.8) |
| 46 | const AF_BON_TOPP_PM: i64 = 950 // permille nucleus mass (950 = 0.95) |
| 47 | const AF_BON_TOPK: i64 = 40 // top-k cutoff (nsv sampler caps at 256) |
| 48 | const AF_BON_SEED0: i64 = 1000003 // seed ladder: seed(s) = SEED0*(s+1); deterministic, never 0 |
| 74 | const AF_FNV_OFFSET: i64 = 0 - 3750763034362895579 |
| 75 | const AF_FNV_PRIME: i64 = 1099511628211 |
| 76 | const AF_HEX_DIGITS: i64 = 16 |
| 77 | const AF_HEX_A_OFF: i64 = 87 |
| 78 | const AF_ASCII_ZERO: i64 = 48 |
functions
| 80 | func af_sandbox_root(ts: i64, cname: *u8, srcpath: *u8, out: *u8) -> i64 { return afl_sandbox_make(ts, cname, srcpath, out) } |
| 81 | func af_episode_ledger(row: *u8, n: i64, where: *u8) -> i64 { return afl_ledger_append(row, n, where) } |
| 82 | func af_admit_untrusted(row: *u8, rl: i64, name: *u8, path: *u8, prov: *u8) -> i64 { return afl_admit_row(row, rl, name, path, prov) } |
| 83 | func af_null_control(sb: *u8, cname: *u8, sbsrc: *u8, snap: *u8, buggy: *u8, prior: *u8, out: *u8) -> i64 { return afl_null_controls(sb, cname, sbsrc, snap, buggy, prior, out, AF_MAGIC_1048576, g_af_wall_ms, g_af_as_bytes) } |
| 84 | func af_intake_board(outpath: *u8) -> i64 { let e: *u8 = "" as *u8; return afl_intake_emit(outpath, e, e, e, e, e, 1) } |
| 85 | func af_harness_calc(mpath: *u8, strict: i64, gc: i64) -> i64 called by 1: main |
| 107 | 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 } |
| 108 | func wn(v: i64) -> i64 |
| 121 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: find_first |
| 122 | func find_first(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64 |
| 135 | func bcat(b: *u8, off: i64, s: *u8) -> i64 |
| 141 | func bcatn(b: *u8, off: i64, v: i64) -> i64 called by 1: episode |
| 153 | func copyfile(srcp: *u8, dstp: *u8) -> i64 { return afl_copyfile(srcp, dstp) } // ONE copy: nx_autofix_lib |
| 154 | func apply_fix(path: *u8, finds: *u8, repls: *u8) -> i64 { return afl_apply_fix(path, finds, repls) } // ONE copy: nx_autofix_lib |
| 155 | func append_line(path: *u8, line: *u8, ln: i64) -> i64 called by 1: episode |
| 169 | func lf_gen(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64) -> i64 |
| 189 | func lf_gen_t(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64, temp_pm: i64, seed: i64) -> i64 |
| 209 | func grader_run(name: *u8, out: *u8, cap: i64) -> i64 |
| 232 | func fn_failing(out: *u8, n: i64, namebuf: *u8) -> i64 { return afl_fn_failing(out, n, namebuf) } |
| 235 | func extract_fn_line(path: *u8, name: *u8, linebuf: *u8) -> i64 |
| 270 | func collect_cases(cap: *u8, n: i64, name: *u8, fb: *u8) -> i64 |
| 304 | func nrm_fix(raw: *u8, rawlen: i64, out: *u8) -> i64 called by 1: clip_fn |
| 332 | func clip_fn(tx: *u8, gl: i64, needle: *u8, dst: *u8) -> i64 |
| 369 | func episode(cname: *u8, cpath: *u8, bakp: *u8, ts: i64, out: *u8, ledp: *u8, strict: i64) -> i64 |
| 708 | func main(argc: i64, argv: *i64) -> i64 |