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 3 imports · 0 importers
imports: nx_tool_run.nxnx_propose_verify_lib.nxnx_gramdec_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
| 30 | const AF_MAGIC_131072: i64 = 131072 |
| 31 | const AF_MAGIC_262144: i64 = 262144 |
| 32 | const AF_MAGIC_4000: i64 = 4000 |
| 33 | const AF_MAGIC_1500: i64 = 1500 |
| 34 | const AF_MAGIC_2048: i64 = 2048 |
| 35 | const AF_MAGIC_1048576: i64 = 1048576 |
| 36 | const AF_MAGIC_1024: i64 = 1024 |
| 37 | const AF_MAGIC_4096: i64 = 4096 |
| 38 | const AF_MAGIC_65536: i64 = 65536 |
| 39 | const AF_MAGIC_65500: i64 = 65500 |
| 43 | const AF_BON_N: i64 = 3 // sampled retries after both greedy rounds miss |
| 44 | const AF_BON_TEMP_PM: i64 = 800 // permille temperature (800 = 0.8) |
| 45 | const AF_BON_TOPP_PM: i64 = 950 // permille nucleus mass (950 = 0.95) |
| 46 | const AF_BON_TOPK: i64 = 40 // top-k cutoff (nsv sampler caps at 256) |
| 47 | const AF_BON_SEED0: i64 = 1000003 // seed ladder: seed(s) = SEED0*(s+1); deterministic, never 0 |
functions
| 53 | 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 } |
| 54 | func wn(v: i64) -> i64 |
| 67 | func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 68 | func find_first(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64 |
| 81 | func bcat(b: *u8, off: i64, s: *u8) -> i64 |
| 87 | func bcatn(b: *u8, off: i64, v: i64) -> i64 called by 1: episode |
| 99 | func copyfile(srcp: *u8, dstp: *u8) -> i64 |
| 109 | func apply_fix(path: *u8, finds: *u8, repls: *u8) -> i64 |
| 131 | func append_line(path: *u8, line: *u8, ln: i64) -> i64 |
| 145 | func lf_gen(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64) -> i64 |
| 165 | func lf_gen_t(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64, temp_pm: i64, seed: i64) -> i64 |
| 185 | func grader_run(name: *u8, out: *u8, cap: i64) -> i64 |
| 198 | func fn_failing(out: *u8, n: i64, namebuf: *u8) -> i64 |
| 241 | func extract_fn_line(path: *u8, name: *u8, linebuf: *u8) -> i64 |
| 276 | func collect_cases(cap: *u8, n: i64, name: *u8, fb: *u8) -> i64 |
| 310 | func nrm_fix(raw: *u8, rawlen: i64, out: *u8) -> i64 |
| 338 | func clip_fn(tx: *u8, gl: i64, needle: *u8, dst: *u8) -> i64 |
| 375 | func episode(cname: *u8, cpath: *u8, bakp: *u8, ts: i64, out: *u8, ledp: *u8, strict: i64) -> i64 |
| 669 | func main(argc: i64, argv: *i64) -> i64 |