code wiki / _hdl_build / nx_research_basis_test.nx
nx_research_basis_test.nx source
↩ module page · 44 lines · 2186 B
1// nx_research_basis_test.nx -- proves the Researcher's knowledge base: every
2// entry is a real failure->fix pattern with a soundness-restoring alternative AND
3// a citation, looked up correctly; the fallback (no entry) returns none. This is
4// the modern-research grounding the self-repair cycle draws on. exit 0 iff the
5// basis is well-formed (5 cited entries; none for out-of-range).
6
7import "nx_research_basis.nx"
8
9func rbt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
10
11func main() -> i64 {
12 rbt_puts("================================================================\n" as *u8)
13 rbt_puts(" RESEARCHER knowledge base -- research-grounded repairs the loop\n" as *u8)
14 rbt_puts(" proposes when a candidate is UNSOUND (vs a hard no)\n" as *u8)
15 rbt_puts("================================================================\n" as *u8)
16
17 var ok: i64 = 0
18 var id: i64 = 1
19 while id <= RB_N {
20 rbt_puts("\n unsound: " as *u8); rbt_puts(rb_unsound_form(id))
21 rbt_puts("\n fix: " as *u8); rbt_puts(rb_fix(id))
22 rbt_puts("\n cite: " as *u8); rbt_puts(rb_citation(id)); rbt_puts("\n" as *u8)
23 // well-formed iff present + fix + citation are real (not the "?" fallback)
24 if rb_has(id) == 1 {
25 let f: *u8 = rb_fix(id)
26 let c: *u8 = rb_citation(id)
27 if f[0] != (63 as u8) { if c[0] != (63 as u8) { ok = ok + 1 } }
28 }
29 id = id + 1
30 }
31
32 rbt_puts("\n----------------------------------------------------------------\n" as *u8)
33 rbt_puts(" the loop knows " as *u8)
34 let b: *u8 = sys_mmap(2); b[0] = 48 + ok; sys_write(1, b, 1)
35 rbt_puts(" research-grounded repairs (growable). when a proposal\n" as *u8)
36 rbt_puts(" is unsound it proposes the cited fix + re-verifies -- not a hard no.\n" as *u8)
37 rbt_puts("----------------------------------------------------------------\n" as *u8)
38
39 if ok != RB_N { sys_exit(1); return 1 }
40 if rb_has(RB_NONE) != 0 { sys_exit(2); return 2 } // no entry for "none"
41 if rb_has(RB_N + 1) != 0 { sys_exit(3); return 3 } // out of range
42 sys_exit(0)
43 return 0
44}