code wiki / _hdl_build / nx_raci_sov_gate.nx

nx_raci_sov_gate.nx source

↩ module page · 86 lines · 6606 B

1import "nx_gate_gn.nx" 2import "nx_gate_base.nx" 3// nx_raci_sov_gate.nx -- proves the conductor's RACI is OFF the TSV and ownership reads from the sovereign store. 4// T1 MIGRATED : every RACI row migrates into the seg_store BYTE-EXACT (ver == tot, a real contract not a stub). 5// T2 REAL OWNERS: roles the OLD hardcoded list MISSED are correctly Accountable (workstream/publisher/supervisor/warden). 6// T3 KNOWN OWNERS: the roles the list did have are still right (engineer/pm/doctor/researcher). 7// T4 BUG FIXED : the list's ERRORS are now caught -- "adversarial" is NOT a RACI role (0); "operator" is only Informed (0). 8// T5 SOVEREIGN : ownership is read from the STORE (re-read persists); the TSV is no longer the source of truth. 9// expect_exit: 0 license_tier: ORIGINAL 10import "nx_raci_sov.nx" 11import "nx_syscalls.nx" 12 13func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw(" 14" as *u8); return ok } 15 16func main() -> i64 { 17 gw("=== nx_raci_sov_gate: is the conductor's RACI OFF the TSV (sovereign seg_store)? ===\n" as *u8) 18 var pass: i64=0; var total: i64=0 19 let totp: *i64=sys_mmap(16) as *i64; let verp: *i64=sys_mmap(16) as *i64 20 raci_migrate(totp, verp) 21 gw(" migrated knowledge/registry/nishi_raci.tsv -> knowledge/store/raci : rows=\x00" as *u8); gn(totp[0]); gw(" verified=\x00" as *u8); gn(verp[0]); gw("\n" as *u8) 22 23 // T1 MIGRATED byte-exact 24 total=total+1; if verp[0]==totp[0] { if totp[0]>0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 25 gw("T1 MIGRATED: every RACI row byte-exact in the seg_store (ver==tot)\n" as *u8) 26 27 // T2 REAL OWNERS the hardcoded list MISSED 28 let ws: i64=raci_is_accountable("workstream\x00" as *u8); let pubr: i64=raci_is_accountable("publisher\x00" as *u8) 29 let sup: i64=raci_is_accountable("supervisor\x00" as *u8); let war: i64=raci_is_accountable("warden\x00" as *u8) 30 total=total+1; if ws==1 { if pubr==1 { if sup==1 { if war==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 31 gw("T2 REAL OWNERS (list missed): workstream=\x00" as *u8); gn(ws); gw(" publisher=\x00" as *u8); gn(pubr); gw(" supervisor=\x00" as *u8); gn(sup); gw(" warden=\x00" as *u8); gn(war); gw(" (all Accountable, from the store)\n" as *u8) 32 33 // T3 KNOWN OWNERS 34 let eng: i64=raci_is_accountable("engineer\x00" as *u8); let pm: i64=raci_is_accountable("pm\x00" as *u8) 35 let doc: i64=raci_is_accountable("doctor\x00" as *u8); let res: i64=raci_is_accountable("researcher\x00" as *u8) 36 total=total+1; if eng==1 { if pm==1 { if doc==1 { if res==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 37 gw("T3 KNOWN OWNERS: engineer=\x00" as *u8); gn(eng); gw(" pm=\x00" as *u8); gn(pm); gw(" doctor=\x00" as *u8); gn(doc); gw(" researcher=\x00" as *u8); gn(res); gw("\n" as *u8) 38 39 // T4 the hardcoded list's BUGS, now caught 40 let adv: i64=raci_is_accountable("adversarial\x00" as *u8); let op: i64=raci_is_accountable("operator\x00" as *u8); let fake: i64=raci_is_accountable("nobody_xyz\x00" as *u8) 41 total=total+1; if adv==0 { if op==0 { if fake==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 42 gw("T4 BUG FIXED: 'adversarial' not a RACI role(\x00" as *u8); gn(adv); gw("), 'operator' only Informed(\x00" as *u8); gn(op); gw("), fake(\x00" as *u8); gn(fake); gw(") -- all 0\n" as *u8) 43 44 // T5 SOVEREIGN: a real contract (>=30 rows) read back from the store (persisted, no TSV needed) 45 let eng2: i64=raci_is_accountable("engineer\x00" as *u8) 46 total=total+1; if totp[0]>=30 { if eng2==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 47 gw("T5 SOVEREIGN: real contract (\x00" as *u8); gn(totp[0]); gw(" rows) re-read from the store, no TSV in the read path\n" as *u8) 48 49 // T6 raci_row export: row 0 real, far row = -1 sentinel (the reader-flip iteration contract) 50 let rb: *u8 = sys_mmap(512) 51 let r0: i64 = raci_row(0, rb, 512) 52 let rfar: i64 = raci_row(99999, rb, 512) 53 total=total+1; if r0>0 { if rfar==(0-1) { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 54 gw("T6 raci_row: row0 len=\x00" as *u8); gn(r0); gw(", far-row sentinel=\x00" as *u8); gn(rfar); gw(" (-1)\n" as *u8) 55 56 // T7 raci_accountable_for: activity->owner from the store (live row: arch_board -> architect); fake -> 0 57 let orole: *u8 = sys_mmap(64) 58 let f1: i64 = raci_accountable_for("arch_board\x00" as *u8, orole) 59 var t7: i64 = 0 60 if f1==1 { if rsv_streq(orole, "architect\x00" as *u8)==1 { t7=1 } } 61 let f0: i64 = raci_accountable_for("no_such_activity_xyz\x00" as *u8, orole) 62 total=total+1; if t7==1 { if f0==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) } 63 gw("T7 raci_accountable_for: arch_board -> \x00" as *u8); gw(orole); gw(" (found=\x00" as *u8); gn(f1); gw("), fake-activity=\x00" as *u8); gn(f0); gw("\n" as *u8) 64 65 // T8 raci_read_all: full contract reconstituted from the store; first line == raci_row(0); row-count parity 66 let ab: *u8 = sys_mmap(65536) 67 let al: i64 = raci_read_all(ab, 65536) 68 var t8: i64 = 0 69 if al > 0 { if r0 > 0 { 70 var eq8: i64 = 1 71 var x8: i64 = 0 72 while x8 < r0 { if ab[x8] != rb[x8] { eq8 = 0 } x8 = x8 + 1 } 73 if ab[r0] == (10 as u8) { if eq8 == 1 { 74 var nlc: i64 = 0 75 var y8: i64 = 0 76 while y8 < al { if ab[y8] == (10 as u8) { nlc = nlc + 1 } y8 = y8 + 1 } 77 if nlc == totp[0] { t8 = 1 } 78 } } 79 } } 80 total=total+1; if t8==1 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } 81 gw("T8 raci_read_all: \x00" as *u8); gn(al); gw(" bytes, first row == raci_row(0), rows == migrated total\n" as *u8) 82 83 gw("\n=== nx_raci_sov_gate \x00" as *u8); gn(pass); gw("/\x00" as *u8); gn(total) 84 if pass==total { gw(" GREEN -- the RACI is OFF the TSV: byte-exact in the sovereign seg_store, ownership read from the store, and the hardcoded-list bugs are fixed. Same proven pattern liberates every other TSV.\n" as *u8); sys_exit(0); return 0 } 85 gw(" RED\n" as *u8); sys_exit(1); return 1 86}