code wiki / (root) / nx_autofix_candidate.nx

nx_autofix_candidate.nx source

↩ module page · 22 lines · 927 B

1// nx_autofix_candidate.nx -- a REAL buildable "code under repair" for the autonomous fix loop (nx_autofix_gate). 2// It SELF-GRADES against objective cases and emits CGR=<pass> (byte-built, no string literals so the fixer can 3// patch it by targeted line-replace without quote-escaping). SEEDED BUG: max2 returns the first arg always 4// (the same shape as a bug Claude fixed by hand this session) -> pass=1/3. The fixer flips it to the correct 5// body -> pass=3/3. license_tier: ORIGINAL No hw writes (Rule 26). 6import "nx_syscalls.nx" 7func max2(a: i64, b: i64) -> i64 { return a } 8func main() -> i64 { 9 var p: i64 = 0 10 if max2(3, 5) == 5 { p = p + 1 } 11 if max2(7, 2) == 7 { p = p + 1 } 12 if max2(4, 9) == 9 { p = p + 1 } 13 let t: *u8 = sys_mmap(8) 14 t[0] = 67 as u8 15 t[1] = 71 as u8 16 t[2] = 82 as u8 17 t[3] = 61 as u8 18 t[4] = (48 + p) as u8 19 t[5] = 10 as u8 20 sys_write(1, t, 6) 21 return 0 22}