code wiki / (root) / nx_autofix_candidate5.nx

nx_autofix_candidate5.nx source

↩ module page · 60 lines · 2254 B

1// nx_autofix_candidate5.nx -- the WILD-BUG candidate: retires "seeded" from the autofix loop. 2// PROVENANCE: the buggy function below is VERBATIM model-written code -- the 1.5B coder's own 3// minipack-T1 near-miss (knowledge/forge/fix/cand_mpT1.nx, generated 2026-07-15/16): it computed 4// "sum100" as a sum of fibonacci terms INCLUDING fib3..fib9 which are NEVER DECLARED (the 5// use-before-declare-compiles gotcha reads garbage), instead of the sum 1..100. Nobody planted this 6// bug; it emerged from generation. fib() is also verbatim from the same artifact (it is CORRECT -- 7// the model's good half; fib(10)=55). Only the FNRES harness (main + tests) is ecosystem-authored. 8// DELIBERATE: NO FNCASE rows here -- revealing "want 5050" would let the maker pass by constant- 9// stuffing; withholding the oracle forces an actual computation. (The checker still knows.) 10// license_tier: ORIGINAL 11import "nx_syscalls.nx" 12const K_MAGIC_5050: i64 = 5050 13 14func cw(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 15func cn(v: i64) -> i64 { 16 var m: i64 = v 17 if m < 0 { cw("-" as *u8); m = 0 - m } 18 let t: *u8 = sys_mmap(24) 19 var k: i64 = 0 20 if m == 0 { t[0] = 48 as u8; k = 1 } 21 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 22 let o: *u8 = sys_mmap(24) 23 var i: i64 = 0 24 while i < k { o[i] = t[k - 1 - i]; i = i + 1 } 25 sys_write(1, o, k) 26 return 0 27} 28 29func fib(n: i64) -> i64 { 30 if n == 0 { 31 return 0 32 } else if n == 1 { 33 return 1 34 } else { 35 return fib(n - 1) + fib(n - 2) 36 } 37} 38 39func sum100() -> i64 { 40 let n: i64 = 10 41 let fib10: i64 = fib(n) 42 let fib1: i64 = fib(n - 1) 43 let fib2: i64 = fib(n - 2) 44 let sum100: i64 = fib10 + fib1 + fib2 + fib3 + fib4 + fib5 + fib6 + fib7 + fib8 + fib9 + fib10 45 return sum100 46} 47 48func main() -> i64 { 49 var p: i64 = 0 50 var f1: i64 = 0 51 if fib(10) == 55 { f1 = f1 + 1 } 52 if fib(1) == 1 { f1 = f1 + 1 } 53 var f2: i64 = 0 54 if sum100() == K_MAGIC_5050 { f2 = f2 + 1 } 55 p = f1 + f2 56 cw("FNRES fib " as *u8); cn(f1); cw(" 2\n" as *u8) 57 cw("FNRES sum100 " as *u8); cn(f2); cw(" 1\n" as *u8) 58 cw("CGR=" as *u8); cn(p); cw("\n" as *u8) 59 return 0 60}