code wiki / _hdl_build / nx_roster_full_test.nx

nx_roster_full_test.nx source

↩ module page · 105 lines · 5849 B

1// nx_roster_full_test.nx -- ACCEPTANCE GATE for the complete roster + RACING. All 20 roles present + 2// distinct; the eval cluster stays distinct; the v1 Racing/Referee fold is caught. 3import "nx_roster_full.nx" 4import "nx_racing.nx" 5import "nx_syscalls.nx" 6 7func ft_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 8func ft_putn(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 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;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 } 9 10func main() -> i64 { 11 var pass: i64 = 0 12 var total: i64 = 0 13 14 let verbs: *i64 = sys_mmap(256) as *i64 15 let present: *i64 = sys_mmap(256) as *i64 16 tr_verbs(verbs) 17 var i: i64 = 0 18 while i < RST_N { present[i] = 1; i = i + 1 } // all 20 roles now have a capability (RACING built) 19 20 // T1: 20 roles, 0 conflating pairs, eval cluster distinct -> roster clean 21 total = total + 1 22 var t1: i64 = 1 23 if tr_conflating_pairs(verbs, RST_N) != 0 { t1 = 0 } 24 if tr_eval_cluster_distinct() != 1 { t1 = 0 } 25 if tr_all_staffed(present, RST_N) != 1 { t1 = 0 } 26 if tr_roster_clean(verbs, present, RST_N) != 1 { t1 = 0 } 27 if t1 == 1 { pass = pass + 1 } else { ft_puts("T1 FAIL clean conflate=" as *u8); ft_putn(tr_conflating_pairs(verbs, RST_N)); ft_puts("\n" as *u8) } 28 29 // T2: the novel roles are PRESENT in the roster (genealogist, examiner, critic, auditor, scientist, 30 // caretaker, racing, market-researcher, hub) -- the ones the 10-role audit MISSED 31 total = total + 1 32 var t2: i64 = 1 33 if verbs[11] != TV_COMPETE { t2 = 0 } // RACING 34 if verbs[12] != TV_SELFGRADE { t2 = 0 } // EXAMINER 35 if verbs[13] != TV_COUNTER { t2 = 0 } // CRITIC 36 if verbs[14] != TV_AUDIT { t2 = 0 } // AUDITOR 37 if verbs[15] != TV_DEDUP { t2 = 0 } // GENEALOGIST 38 if verbs[16] != TV_PRUNE { t2 = 0 } // CARETAKER 39 if verbs[17] != TV_PUBLISH { t2 = 0 } // SCIENTIST 40 if verbs[18] != TV_ANALYZE { t2 = 0 } // ANALYST (renamed from market-researcher 2026-06-10) 41 if verbs[19] != TV_GROW { t2 = 0 } // HUB 42 if t2 == 1 { pass = pass + 1 } else { ft_puts("T2 FAIL novel-roles\n" as *u8) } 43 44 // T3: HONESTY -- re-fold Racing into Referee (give RACING the JUDGE verb) -> conflation caught 45 total = total + 1 46 let bad: *i64 = sys_mmap(256) as *i64 47 var b: i64 = 0 48 while b < RST_N { bad[b] = verbs[b]; b = b + 1 } 49 bad[11] = TV_JUDGE // Racing now JUDGE -> conflates with Referee (the v1 error) 50 if tr_conflating_pairs(bad, RST_N) != 1 { ft_puts("T3 FAIL fold-not-caught=" as *u8); ft_putn(tr_conflating_pairs(bad, RST_N)); ft_puts("\n" as *u8) } else { pass = pass + 1 } 51 52 // T4: a MISSING capability (unstaff Genealogist) -> roster not clean 53 total = total + 1 54 let miss: *i64 = sys_mmap(256) as *i64 55 var m: i64 = 0 56 while m < RST_N { miss[m] = 1; m = m + 1 } 57 miss[15] = 0 // Genealogist has no capability 58 if tr_roster_clean(verbs, miss, RST_N) == 0 { pass = pass + 1 } else { ft_puts("T4 FAIL missing-genealogist passed\n" as *u8) } 59 60 // T5: RACING the role -- COMPETE distinct from JUDGE; runs a fair track + reports (does NOT judge) 61 total = total + 1 62 var t5: i64 = 1 63 if rc_separate_from_referee() != 1 { t5 = 0 } // Racing != Referee 64 if rc_track_fair(100, 100, 9, 9) != 1 { t5 = 0 } // same input + oracle = fair 65 if rc_track_fair(100, 200, 9, 9) != 0 { t5 = 0 } // different input = unfair 66 let rout: *i64 = sys_mmap(32) as *i64 67 if rc_run_track(42, 60, 1, rout) != RC_RAN { t5 = 0 } // recorded both, ran 68 if rout[0] != 42 { t5 = 0 } 69 if rc_hands_to_referee(TV_JUDGE) != 1 { t5 = 0 } // hands to the Referee (the judge) 70 if rc_hands_to_referee(TV_COMPETE) != 0 { t5 = 0 } // Racing cannot self-judge 71 if t5 == 1 { pass = pass + 1 } else { ft_puts("T5 FAIL racing\n" as *u8) } 72 73 // T6: RACING suite tally -- over 3 fair tracks (ours < theirs on a lower-is-better metric) we lead 2 74 total = total + 1 75 let our: *i64 = sys_mmap(64) as *i64 76 let their: *i64 = sys_mmap(64) as *i64 77 let fair: *i64 = sys_mmap(64) as *i64 78 our[0]=40; their[0]=50; fair[0]=1 // we lead 79 our[1]=70; their[1]=60; fair[1]=1 // we lose 80 our[2]=30; their[2]=90; fair[2]=1 // we lead 81 if rc_tracks_we_lead(our, their, fair, 3) == 2 { pass = pass + 1 } else { ft_puts("T6 FAIL tally=" as *u8); ft_putn(rc_tracks_we_lead(our, their, fair, 3)); ft_puts("\n" as *u8) } 82 83 // T7: the ANALYST blur guard -- EXPLAIN stays distinct from the verbs it could fold into 84 // (Researcher GATHERS evidence, Analyst EXPLAINS it; also != JUDGE/AUDIT), and folding the 85 // Analyst back into the Researcher is CAUGHT as exactly one conflating pair. 86 total = total + 1 87 var t7: i64 = 1 88 if ra_distinct(TV_ANALYZE, TV_SEARCH) != 1 { t7 = 0 } 89 if ra_distinct(TV_ANALYZE, TV_JUDGE) != 1 { t7 = 0 } 90 if ra_distinct(TV_ANALYZE, TV_AUDIT) != 1 { t7 = 0 } 91 let bad2: *i64 = sys_mmap(256) as *i64 92 var b2: i64 = 0 93 while b2 < RST_N { bad2[b2] = verbs[b2]; b2 = b2 + 1 } 94 bad2[18] = TV_SEARCH // Analyst folded into Researcher -> must be caught 95 if tr_conflating_pairs(bad2, RST_N) != 1 { t7 = 0 } 96 if tr_roster_clean(bad2, present, RST_N) != 0 { t7 = 0 } 97 if t7 == 1 { pass = pass + 1 } else { ft_puts("T7 FAIL analyst-blur\n" as *u8) } 98 99 tr_report(verbs, present, RST_N) 100 101 ft_puts("ROSTER-FULL " as *u8); ft_putn(pass); ft_puts("/" as *u8); ft_putn(total); ft_puts("\n" as *u8) 102 if pass == total { ft_puts("ROSTER-FULL ALL-PASS\n" as *u8); sys_exit(0) } 103 sys_exit(1) 104 return 1 105}