code wiki / _hdl_build / nx_researcher_test.nx
nx_researcher_test.nx source
↩ module page · 65 lines · 4763 B
1// nx_researcher_test.nx -- the NISHI RESEARCHER runs the team's OWN research synthesis over the
2// REAL findings of the six ingested deep-research reports (with their real 3-vote outcomes), and
3// must: re-derive the confirmed/refuted verdicts DETERMINISTICALLY, synthesize, and emit SPECIFIC
4// TASKS for the confirmed+actionable findings -- while generating ZERO tasks from refuted/contested
5// claims (no wasted build effort). This is the team exceeding a one-shot LLM synthesis on the axes
6// that matter: reproducible + task-generating + no-waste. Exit 0 if all hold. license_tier: ORIGINAL
7
8import "nx_researcher.nx"
9import "nx_syscalls.nx"
10
11func rt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
12func rt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(1, bb, k); return 0 }
13
14func main() -> i64 {
15 rt_puts("=== NISHI RESEARCHER: the team verifies + synthesizes + tasks its own research ===\n" as *u8)
16 // real findings from the 6 ingested reports: cv=confirm votes, rv=refute votes (of 3),
17 // act=actionable, org=owning organ (3=BUILDER, 6=RESEARCHER). The last few are the REFUTED /
18 // CONTESTED ones the team must NOT turn into work.
19 let N: i64 = 11
20 let cv: *i64 = sys_mmap(8*16) as *i64
21 let rv: *i64 = sys_mmap(8*16) as *i64
22 let act: *i64 = sys_mmap(8*16) as *i64
23 let org: *i64 = sys_mmap(8*16) as *i64
24 // confirmed + actionable -> tasks
25 cv[0]=3; rv[0]=0; act[0]=1; org[0]=3 // imatrix K-quant
26 cv[1]=3; rv[1]=0; act[1]=1; org[1]=3 // KIVI 2-bit KV
27 cv[2]=3; rv[2]=0; act[2]=1; org[2]=3 // PagedAttention accounting
28 cv[3]=3; rv[3]=0; act[3]=1; org[3]=3 // one resident base + adapter hot-swap
29 cv[4]=3; rv[4]=0; act[4]=1; org[4]=3 // text-encoder loss -> structured recaptioning
30 cv[5]=3; rv[5]=0; act[5]=1; org[5]=6 // close the 3x rate-distortion gap (Researcher-led)
31 // refuted -> NO task
32 cv[6]=0; rv[6]=3; act[6]=0; org[6]=0 // QTIP exact 2-bit numbers
33 cv[7]=0; rv[7]=3; act[7]=0; org[7]=0 // unified backbone = no quality loss
34 cv[8]=0; rv[8]=3; act[8]=0; org[8]=0 // encoder is the SOLE cause
35 cv[9]=1; rv[9]=2; act[9]=0; org[9]=0 // KV dominates beyond 50k tokens
36 // contested + actionable -> still NO task (rigor: never build on a split verdict)
37 cv[10]=1; rv[10]=1; act[10]=1; org[10]=3
38
39 let confirmed: i64 = res_count_verdict(N, cv, rv, RES_CONFIRMED)
40 let refuted: i64 = res_count_verdict(N, cv, rv, RES_REFUTED)
41 let contested: i64 = res_count_verdict(N, cv, rv, RES_CONTESTED)
42 let tidx: *i64 = sys_mmap(8*16) as *i64; let torg: *i64 = sys_mmap(8*16) as *i64
43 let tasks: i64 = res_synthesize(N, cv, rv, act, org, tidx, torg)
44 rt_puts(" verdicts: confirmed=" as *u8); rt_num(confirmed); rt_puts(" refuted=" as *u8); rt_num(refuted); rt_puts(" contested=" as *u8); rt_num(contested); rt_puts("\n" as *u8)
45 rt_puts(" -> generated " as *u8); rt_num(tasks); rt_puts(" specific tasks (finding# -> organ):" as *u8)
46 var i: i64 = 0
47 while i < tasks { rt_puts(" f" as *u8); rt_num(tidx[i]); rt_puts("->" as *u8); rt_num(torg[i]); i = i + 1 }
48 rt_puts("\n reproducible (same evidence -> same tasks): " as *u8); rt_num(res_is_reproducible(N, cv, rv, act, org)); rt_puts("\n" as *u8)
49
50 // no-waste: every refuted/contested finding yields ZERO tasks
51 var wasted: i64 = 0; var j: i64 = 6
52 while j < N { if res_is_task(res_verify(cv[j], rv[j]), act[j]) == 1 { wasted = wasted + 1 } j = j + 1 }
53
54 let r: *i64 = sys_mmap(8*8) as *i64
55 r[0] = 0; if confirmed == 6 { r[0] = 1 } // re-derived the confirmed set
56 r[1] = 0; if refuted == 4 { r[1] = 1 } // re-derived the refuted set (killed bad claims)
57 r[2] = 0; if tasks == 6 { r[2] = 1 } // 6 specific tasks generated
58 r[3] = 0; if res_is_reproducible(N, cv, rv, act, org) == 1 { r[3] = 1 } // deterministic (the exceed)
59 r[4] = 0; if wasted == 0 { r[4] = 1 } // ZERO work on refuted/contested
60 var pass: i64 = 0; var k: i64 = 0
61 while k < 5 { pass = pass + r[k]; k = k + 1 }
62 rt_puts("----\n passed " as *u8); rt_num(pass); rt_puts("/5\n" as *u8)
63 if pass == 5 { rt_puts(" SELF-SUFFICIENT RESEARCH: team verifies + synthesizes + TASKS its own research -- reproducible, no waste, refuted-claims killed. Exceeds a one-shot synthesis. Librarian grades+persists.\n" as *u8); sys_exit(0); return 0 }
64 rt_puts(" FAIL\n" as *u8); sys_exit(1); return 1
65}