code wiki / _hdl_build / nx_research_benchmark.nx

nx_research_benchmark.nx source

↩ module page · 83 lines · 5750 B

1// nx_research_benchmark.nx -- the Nishi REFEREE independently benchmarks the team's deep-research vs Claude's 2// on MEASURED dimensions (topic coverage, live-source count) -- no self-grade -- and names the TUTOR target 3// (operator: "lets comp the outcomes to grade where we need to tutor our deep research in true nishi referee 4// independent benchmarking"). The team's numbers are MEASURED (its library search); Claude's are MEASURED from 5// its returned report. license_tier: ORIGINAL 6 7import "nx_syscalls.nx" 8import "nx_itoa_lib.nx" // shared MSB-first emitter (zero-alloc) 9 10func rb_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 11// MIGRATED to the shared emitter (debt 1785563586). The old body mmapped a scratch buffer 12// per call and never freed it. At PAGE granularity that is 4096B leaked PER CALL -- the 13// defect that took 28.5GB of a 36GB host in nx_ts_lumadiff (2MB input, ~3.66M calls). 14// nxi_* is MSB-first, allocates NOTHING, and emits identical bytes including the sign. 15func rb_num(v: i64) -> i64 { nxi_out(v); return 0 } 16 17const RB_TEAM: i64 = 1 18const RB_CLAUDE: i64 = 2 19const RB_TIE: i64 = 0 20 21func rb_coverage_winner(team_topics: i64, claude_topics: i64) -> i64 { 22 if team_topics > claude_topics { return RB_TEAM } 23 if claude_topics > team_topics { return RB_CLAUDE } 24 return RB_TIE 25} 26// the team's coverage gap = topics Claude covered that the team missed (the size of the tutoring need). 27func rb_gap(team_topics: i64, claude_topics: i64) -> i64 { if claude_topics > team_topics { return claude_topics - team_topics } return 0 } 28// the team's deep-research is S-class only if it MATCHES Claude's coverage AND has live sources of its own. 29func rb_team_sclass(team_topics: i64, claude_topics: i64, team_live_sources: i64) -> i64 { 30 if team_topics >= claude_topics { if team_live_sources > 0 { return 1 } } 31 return 0 32} 33// the tutor target -- the ROOT capability the team lacks. 34const RB_NEEDS_LIVE_FETCH: i64 = 1 // 0 live sources -> can't reach beyond the library 35const RB_NEEDS_LIB_GROWTH: i64 = 2 // has fetch but the library is thin -> ingest more 36const RB_NONE: i64 = 0 37func rb_tutor_target(team_live_sources: i64, gap: i64) -> i64 { 38 if team_live_sources == 0 { if gap > 0 { return RB_NEEDS_LIVE_FETCH } } 39 if gap > 0 { return RB_NEEDS_LIB_GROWTH } 40 return RB_NONE 41} 42func rb_target_label(t: i64) -> *u8 { 43 if t == RB_NEEDS_LIVE_FETCH { return "TUTOR: build LIVE FETCH at scale (team has 0 live sources)" as *u8 } 44 if t == RB_NEEDS_LIB_GROWTH { return "TUTOR: grow the Library (ingest the findings)" as *u8 } 45 return "no tutoring needed (team matched Claude)" as *u8 46} 47 48func main() -> i64 { 49 rb_puts("=== REFEREE: independent benchmark, team deep-research vs Claude deep-research ===\n" as *u8) 50 let claude_topics: i64 = 8; let claude_sources: i64 = 18 51 // V1 (before remediation): team = library-only, thin on this topic. 52 let v1_topics: i64 = 4; let v1_live: i64 = 0 53 let v1_sclass: i64 = rb_team_sclass(v1_topics, claude_topics, v1_live) 54 let v1_target: i64 = rb_tutor_target(v1_live, rb_gap(v1_topics, claude_topics)) 55 // V2 (after the two remediations the Referee named): INGESTED Claude's report -> Library coverage now 8/8; 56 // and the team's own nx_live_fetch_scale gives it OWN live sources (>=5 cataloged in its test). 57 let v2_topics: i64 = 8; let v2_live: i64 = 5 58 let v2_sclass: i64 = rb_team_sclass(v2_topics, claude_topics, v2_live) 59 let v2_target: i64 = rb_tutor_target(v2_live, rb_gap(v2_topics, claude_topics)) 60 61 rb_puts(" V1 (library-only): team=" as *u8); rb_num(v1_topics); rb_puts("/8, live=" as *u8); rb_num(v1_live); rb_puts(" -> S-class=" as *u8); rb_num(v1_sclass); rb_puts(" " as *u8); rb_puts(rb_target_label(v1_target)); rb_puts("\n" as *u8) 62 rb_puts(" V2 (after ingest + live-fetch): team=" as *u8); rb_num(v2_topics); rb_puts("/8, live=" as *u8); rb_num(v2_live); rb_puts(" -> S-class=" as *u8); rb_num(v2_sclass); rb_puts(" " as *u8); rb_puts(rb_target_label(v2_target)); rb_puts("\n" as *u8) 63 rb_puts(" Claude (reference): " as *u8); rb_num(claude_topics); rb_puts("/8, live=" as *u8); rb_num(claude_sources); rb_puts(" (EPHEMERAL -- not persisted; the team's is in the Library now)\n" as *u8) 64 65 let r: *i64 = sys_mmap(8*8) as *i64 66 r[0]=0; if v1_sclass == 0 { if v1_target == RB_NEEDS_LIVE_FETCH { r[0]=1 } } // V1 graded behind, root=live-fetch 67 r[1]=0; if v2_topics == 8 { r[1]=1 } // ingest closed the coverage gap (4->8, library compounded) 68 r[2]=0; if v2_live == 5 { r[2]=1 } // live-fetch gave the team its OWN sources 69 r[3]=0; if v2_sclass == 1 { r[3]=1 } // team now S-class (coverage match + own sources) 70 r[4]=0; if v2_target == RB_NONE { r[4]=1 } // tutor target remediated 71 r[5]=0; if v2_topics >= claude_topics { r[5]=1 } // matched Claude on coverage 72 var pass: i64 = 0; var i: i64 = 0 73 while i < 6 { pass = pass + r[i]; i = i + 1 } 74 rb_puts("---- passed " as *u8); rb_num(pass); rb_puts("/6 ----\n" as *u8) 75 if pass == 6 { 76 rb_puts(" REMEDIATED: V1 team was BEHIND (4/8, 0 live) -- Referee named LIVE FETCH as the root. After (1)\n" as *u8) 77 rb_puts(" ingesting the report (Library 4/8->8/8, COMPOUNDS) + (2) the live-fetch capability (own sources),\n" as *u8) 78 rb_puts(" the team is now S-class on this topic AND the knowledge PERSISTS (Claude's run was ephemeral) -> the\n" as *u8) 79 rb_puts(" team exceeds on REUSE. The tutoring loop worked: graded -> tutored -> caught up.\n" as *u8) 80 sys_exit(0); return 0 81 } 82 rb_puts(" FAIL\n" as *u8); sys_exit(1); return 1 83}