code wiki / (root) / nx_swebench_status.nx

nx_swebench_status.nx source

↩ module page · 86 lines · 3944 B

1// nx_swebench_status.nx -- MCP tools/call surface for the autonomous-fix capability (2026-07-17). 2// Returns the LIVE SWE-bench-contract resolve rate as compact machine JSON, read from the NAS-published 3// autograde dashboard (sites/nishifamily/compare/autograde/api.json -- the same measurement the public 4// page shows, so the tool can never drift from what's published). This is a CURATED capability surface: 5// a named, discoverable tools/call that emits STRUCTURED fields (resolve_pct as an integer + honest 6// scope), not a raw url proxy. Read-only, no args, exit 0; fail-closed JSON if the source is absent. 7// The measurement itself is produced laptop-side by nx_swebench_local_gate over the fix-loop ledger and 8// published here by the autograde pulse -- this tool is the NAS-side read of that published truth. 9// license_tier: ORIGINAL expect_exit: 0 10import "nx_syscalls.nx" 11 12const APIJSON: *u8 = "sites/nishifamily/compare/autograde/api.json" as *u8 13 14func slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } 15func w(s: *u8) -> i64 { let n: i64 = slen(s); sys_write(1, s, n); return 0 } 16func wn(v: i64) -> i64 { 17 var m: i64 = v 18 if m < 0 { w("-" as *u8); m = 0 - m } 19 let t: *u8 = sys_mmap(24) 20 var k: i64 = 0 21 if m == 0 { t[0] = 48 as u8; k = 1 } 22 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 23 let o: *u8 = sys_mmap(24) 24 var i: i64 = 0 25 while i < k { o[i] = t[k - 1 - i]; i = i + 1 } 26 sys_write(1, o, k) 27 return 0 28} 29// first index of needle in hay[from,n), or -1 30func find_first(hay: *u8, n: i64, needle: *u8, from: i64) -> i64 { 31 let m: i64 = slen(needle) 32 if m == 0 { return 0 - 1 } 33 var i: i64 = from 34 while i + m <= n { 35 var j: i64 = 0 36 var ok: i64 = 1 37 while j < m { if hay[i+j] != needle[j] { ok = 0; j = m } else { j = j + 1 } } 38 if ok == 1 { return i } 39 i = i + 1 40 } 41 return 0 - 1 42} 43// parse the leading unsigned integer at buf[p..n); -1 if no digit there 44func parse_uint_at(buf: *u8, p: i64, n: i64) -> i64 { 45 var i: i64 = p 46 var v: i64 = 0 47 var got: i64 = 0 48 var done: i64 = 0 49 while done == 0 { 50 if i >= n { done = 1 } 51 else { 52 let c: i64 = buf[i] as i64 53 if c >= 48 { if c <= 57 { v = v * 10 + (c - 48); got = 1; i = i + 1 } else { done = 1 } } else { done = 1 } 54 } 55 } 56 if got == 0 { return 0 - 1 } 57 return v 58} 59 60func main(argc: i64, argv: *i64) -> i64 { 61 let lb: *i64 = sys_mmap(8) as *i64 62 let buf: *u8 = sys_read_file(APIJSON, lb) 63 if (buf as i64) == 0 { 64 w("{\"tool\":\"nx_swebench_status\",\"error\":\"published api.json unreadable\",\"source\":\"/compare/autograde/api.json\"}\n" as *u8) 65 return 1 66 } 67 let n: i64 = lb[0] 68 // resolve_pct: anchor on the SWE-bench question, then the FIRST integer in its answer value. 69 var pct: i64 = 0 - 1 70 let q: i64 = find_first(buf, n, "resolve rate?" as *u8, 0) 71 if q >= 0 { 72 let a: i64 = find_first(buf, n, "\"answer\":\"" as *u8, q) 73 if a >= 0 { pct = parse_uint_at(buf, a + 10, n) } 74 } 75 // generated_unix 76 var gen: i64 = 0 - 1 77 let g: i64 = find_first(buf, n, "\"generated_unix\":" as *u8, 0) 78 if g >= 0 { gen = parse_uint_at(buf, g + 17, n) } 79 80 w("{\"tool\":\"nx_swebench_status\",\"capability\":\"autonomous-bug-fix\",\"contract\":\"SWE-bench: FAIL_TO_PASS pass AND PASS_TO_PASS hold; fresh compile+run is the sole judge\",\"resolve_pct\":" as *u8) 81 if pct >= 0 { wn(pct) } else { w("null" as *u8) } 82 w(",\"generated_unix\":" as *u8) 83 if gen >= 0 { wn(gen) } else { w("null" as *u8) } 84 w(",\"scope\":\"sovereign NishiLang analog over our foreign-bug instances -- NOT the Python 2294/500-Verified set; no agent-parity claim\",\"source\":\"nishifamily.com/compare/autograde/api.json\",\"measured_by\":\"nx_swebench_local_gate over the fix-loop ledger\"}\n" as *u8) 85 return 0 86}