code wiki / (root) / nx_autofix_auto.nx

nx_autofix_auto.nx

buildroot/runtime/nx_autofix_auto.nx

46116 B856 linesdepth 11pulls 41 transitivereach 0 importersview sourcekind tooltopic autofix
docsdependenciesstructsconstsfunctions

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

nx_tool_run.nx nx_propose_verify_lib.nx nx_gramdec_lib.nx nx_autofix_lib.nx nx_autofix_auto.nx

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

main w afl_streq afl_status_dir sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ ep_artifact_path sys_openat_rd sys_close ep_join sys_munmap afl_slen afl_cat afl_slen ↻ af_intake_board afl_intake_emit sys_openat_wr sys_mmap ↻ ep_artifact_path ↻ afl_cat ↻ afl_intake_roster sys_mmap ↻ sys_read_file sys_openat_rd ↻ sys_lseek sys_mmap ↻ sys_read

structs

none

consts

31const AF_MAGIC_131072: i64 = 131072
32const AF_MAGIC_262144: i64 = 262144
33const AF_MAGIC_4000: i64 = 4000
34const AF_MAGIC_1500: i64 = 1500
35const AF_MAGIC_2048: i64 = 2048
36const AF_MAGIC_1048576: i64 = 1048576
37const AF_MAGIC_1024: i64 = 1024
38const AF_MAGIC_4096: i64 = 4096
39const AF_MAGIC_65536: i64 = 65536
40const AF_MAGIC_65500: i64 = 65500
44const AF_BON_N: i64 = 3 // sampled retries after both greedy rounds miss
45const AF_BON_TEMP_PM: i64 = 800 // permille temperature (800 = 0.8)
46const AF_BON_TOPP_PM: i64 = 950 // permille nucleus mass (950 = 0.95)
47const AF_BON_TOPK: i64 = 40 // top-k cutoff (nsv sampler caps at 256)
48const AF_BON_SEED0: i64 = 1000003 // seed ladder: seed(s) = SEED0*(s+1); deterministic, never 0
74const AF_FNV_OFFSET: i64 = 0 - 3750763034362895579
75const AF_FNV_PRIME: i64 = 1099511628211
76const AF_HEX_DIGITS: i64 = 16
77const AF_HEX_A_OFF: i64 = 87
78const AF_ASCII_ZERO: i64 = 48

functions

80func af_sandbox_root(ts: i64, cname: *u8, srcpath: *u8, out: *u8) -> i64 { return afl_sandbox_make(ts, cname, srcpath, out) }
called by 1: episode calls 1: afl_sandbox_make
81func af_episode_ledger(row: *u8, n: i64, where: *u8) -> i64 { return afl_ledger_append(row, n, where) }
called by 1: episode calls 1: afl_ledger_append
82func af_admit_untrusted(row: *u8, rl: i64, name: *u8, path: *u8, prov: *u8) -> i64 { return afl_admit_row(row, rl, name, path, prov) }
called by 1: main calls 1: afl_admit_row
83func 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) }
called by 1: episode calls 1: afl_null_controls
84func af_intake_board(outpath: *u8) -> i64 { let e: *u8 = "" as *u8; return afl_intake_emit(outpath, e, e, e, e, e, 1) }
called by 1: main calls 1: afl_intake_emit
85func af_harness_calc(mpath: *u8, strict: i64, gc: i64) -> i64
called by 1: main
107func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
108func wn(v: i64) -> i64
called by 2: episodemain calls 1: w
121func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 1: find_first
122func find_first(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64
135func bcat(b: *u8, off: i64, s: *u8) -> i64
141func bcatn(b: *u8, off: i64, v: i64) -> i64
called by 1: episode
153func copyfile(srcp: *u8, dstp: *u8) -> i64 { return afl_copyfile(srcp, dstp) } // ONE copy: nx_autofix_lib
called by 1: episode calls 1: afl_copyfile
154func apply_fix(path: *u8, finds: *u8, repls: *u8) -> i64 { return afl_apply_fix(path, finds, repls) } // ONE copy: nx_autofix_lib
called by 1: episode calls 1: afl_apply_fix
155func append_line(path: *u8, line: *u8, ln: i64) -> i64
called by 1: episode
169func lf_gen(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64) -> i64
called by 1: episode calls 2: gdx_generatensv_generate
189func lf_gen_t(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64, temp_pm: i64, seed: i64) -> i64
called by 1: episode calls 2: gdx_generatensv_generate
209func grader_run(name: *u8, out: *u8, cap: i64) -> i64
232func fn_failing(out: *u8, n: i64, namebuf: *u8) -> i64 { return afl_fn_failing(out, n, namebuf) }
called by 1: episode calls 1: afl_fn_failing
235func extract_fn_line(path: *u8, name: *u8, linebuf: *u8) -> i64
called by 1: episode calls 2: bcatfind_first
270func collect_cases(cap: *u8, n: i64, name: *u8, fb: *u8) -> i64
called by 1: episode calls 2: bcatfind_first
304func nrm_fix(raw: *u8, rawlen: i64, out: *u8) -> i64
called by 1: clip_fn
332func clip_fn(tx: *u8, gl: i64, needle: *u8, dst: *u8) -> i64
called by 1: episode calls 2: find_firstnrm_fix
369func episode(cname: *u8, cpath: *u8, bakp: *u8, ts: i64, out: *u8, ledp: *u8, strict: i64) -> i64
708func main(argc: i64, argv: *i64) -> i64