code wiki / (root) / nx_autofix_auto.nx

nx_autofix_auto.nx

buildroot/runtime/nx_autofix_auto.nx

40216 B774 linesdepth 11pulls 30 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 3 imports · 0 importers

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

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

main w sys_now_realtime_sec sys_mmap sys_clock_gettime_real nsv_init_i8 nsv_init sys_now_ms sys_mmap ↻ sys_clock_gettime_mono nsv_log sys_write nf_pool nx_pool_new nx_hw_worker_count nx_hw_cpu_count sys_mmap ↻ nx_chan_new sys_mmap ↻ _nx_chan_cell sys_thread_create nx_thread_spawn nx_thread_spawn_fn sys_mmap ↻ sys_mmap ↻ nsv_load_meta sys_mmap ↻ nsv_log ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_gguf_parse nx_le_read_u32 nx_le_read_u64 nx_le_read_u32 ↻ _gguf_skip_value nx_le_read_u64 ↻

structs

none

consts

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

functions

53func w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 3: wnepisodemain
54func wn(v: i64) -> i64
called by 2: episodemain calls 1: w
67func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: find_firstapply_fix
68func find_first(hay: *u8, hn: i64, needle: *u8, from: i64) -> i64
81func bcat(b: *u8, off: i64, s: *u8) -> i64
87func bcatn(b: *u8, off: i64, v: i64) -> i64
called by 1: episode
99func copyfile(srcp: *u8, dstp: *u8) -> i64
called by 1: episode calls 2: sys_read_filesys_openat_wr
109func apply_fix(path: *u8, finds: *u8, repls: *u8) -> i64
131func append_line(path: *u8, line: *u8, ln: i64) -> i64
called by 1: episode calls 2: sys_read_filesys_openat_wr
145func lf_gen(pb: *u8, plen: i64, tx: *u8, mt: *i64, max_new: i64) -> i64
called by 1: episode calls 2: gdx_generatensv_generate
165func 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
185func grader_run(name: *u8, out: *u8, cap: i64) -> i64
called by 1: episode calls 1: tr_run_capture
198func fn_failing(out: *u8, n: i64, namebuf: *u8) -> i64
called by 1: episode calls 1: find_first
241func extract_fn_line(path: *u8, name: *u8, linebuf: *u8) -> i64
called by 1: episode calls 3: sys_read_filebcatfind_first
276func collect_cases(cap: *u8, n: i64, name: *u8, fb: *u8) -> i64
called by 1: episode calls 2: bcatfind_first
310func nrm_fix(raw: *u8, rawlen: i64, out: *u8) -> i64
338func clip_fn(tx: *u8, gl: i64, needle: *u8, dst: *u8) -> i64
called by 1: episode calls 2: find_firstnrm_fix
375func episode(cname: *u8, cpath: *u8, bakp: *u8, ts: i64, out: *u8, ledp: *u8, strict: i64) -> i64
669func main(argc: i64, argv: *i64) -> i64