code wiki / _hdl_build / nx_raci_audit_test.nx
nx_raci_audit_test.nx source
↩ module page · 60 lines · 3201 B
1// nx_raci_audit_test.nx -- ACCEPTANCE GATE for the full RACI audit. Proves the partition is clean
2// when roles are distinct, and that the audit CATCHES a deliberate conflation (the honesty test).
3import "nx_raci_audit.nx"
4import "nx_syscalls.nx"
5
6func at_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
7func at_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 }
8
9func main() -> i64 {
10 var pass: i64 = 0
11 var total: i64 = 0
12
13 let verbs: *i64 = sys_mmap(128) as *i64
14 let present: *i64 = sys_mmap(128) as *i64
15 raa_verbs(verbs)
16 var i: i64 = 0
17 while i < RA_N_ROLES { present[i] = 1; i = i + 1 } // all roles staffed
18
19 // T1: canonical partition is CLEAN -- 0 conflating pairs, all present
20 total = total + 1
21 var t1: i64 = 1
22 if raa_conflating_pairs(verbs, RA_N_ROLES) != 0 { t1 = 0 }
23 if raa_all_present(present, RA_N_ROLES) != 1 { t1 = 0 }
24 if raa_partition_clean(verbs, present, RA_N_ROLES) != 1 { t1 = 0 }
25 if t1 == 1 { pass = pass + 1 } else { at_puts("T1 FAIL clean conflate=" as *u8); at_putn(raa_conflating_pairs(verbs, RA_N_ROLES)); at_puts("\n" as *u8) }
26
27 // T2: HONESTY -- inject the doctor=tester blur (give DOCTOR the TEST verb) -> conflation caught
28 total = total + 1
29 let bad: *i64 = sys_mmap(128) as *i64
30 var b: i64 = 0
31 while b < RA_N_ROLES { bad[b] = verbs[b]; b = b + 1 }
32 bad[2] = V_TEST // DOCTOR now also TEST -> conflates with ENGINEER
33 var t2: i64 = 1
34 if raa_conflating_pairs(bad, RA_N_ROLES) != 1 { t2 = 0 } // exactly one conflating pair
35 if raa_partition_clean(bad, present, RA_N_ROLES) != 0 { t2 = 0 } // partition now dirty
36 if t2 == 1 { pass = pass + 1 } else { at_puts("T2 FAIL blur-not-caught pairs=" as *u8); at_putn(raa_conflating_pairs(bad, RA_N_ROLES)); at_puts("\n" as *u8) }
37
38 // T3: MISSING role caught -- unstaff the Referee (no objective scorer) -> not clean
39 total = total + 1
40 let miss: *i64 = sys_mmap(128) as *i64
41 var m: i64 = 0
42 while m < RA_N_ROLES { miss[m] = 1; m = m + 1 }
43 miss[4] = 0 // Referee missing
44 if raa_partition_clean(verbs, miss, RA_N_ROLES) == 0 { pass = pass + 1 } else { at_puts("T3 FAIL missing-role passed\n" as *u8) }
45
46 // T4: the specific fix verified -- Engineer tests, Doctor heals (roles correct + separated)
47 total = total + 1
48 var t4: i64 = 1
49 if br_roles_correct(BR_ENGINEER, BR_DOCTOR) != 1 { t4 = 0 }
50 if br_separation_ok(V_AUTHOR, V_TEST, V_HEAL) != 1 { t4 = 0 }
51 if t4 == 1 { pass = pass + 1 } else { at_puts("T4 FAIL engineer-doctor\n" as *u8) }
52
53 // emit the audit table (operator-reviewable)
54 raa_report(verbs, present, RA_N_ROLES)
55
56 at_puts("RACI-AUDIT " as *u8); at_putn(pass); at_puts("/" as *u8); at_putn(total); at_puts("\n" as *u8)
57 if pass == total { at_puts("RACI-AUDIT ALL-PASS\n" as *u8); sys_exit(0) }
58 sys_exit(1)
59 return 1
60}