code wiki / _hdl_build / nx_build_raci.nx
nx_build_raci.nx source
↩ module page · 56 lines · 3410 B
1// nx_build_raci.nx -- CLEAN RACI for the build pipeline (operator: "the doctor doesnt test the engineer
2// does, the doctor fixes... make sure the raci is clean as we keep building up the team"). Encodes +
3// ENFORCES who does what so roles never blur again:
4// BUILDER AUTHORS the module (Responsible)
5// ENGINEER VERIFIES/TESTS it (the gate) (Responsible) <- NOT the Doctor
6// DOCTOR HEALS it when the test fails (Responsible) <- the FIX, doc_rebuild
7// COUNCIL ADMITS/registers the proven cap (Accountable) <- exactly one owner
8// The flow: author -> Engineer test; if FAIL -> Doctor heal -> Engineer RE-test; admit only when the
9// test PASSES. SEPARATION OF DUTIES: the tester, the healer, and the author must be DIFFERENT roles --
10// you cannot test your own build, nor heal-and-pass your own failure. Composes nx_raci_collab
11// (raci_clean = exactly 1 accountable). LAWS: struct-free, integer-only. license_tier: ORIGINAL
12import "nx_raci_collab.nx"
13import "nx_syscalls.nx"
14
15// the four pipeline roles (distinct ids)
16const BR_BUILDER: i64 = 1
17const BR_ENGINEER: i64 = 2
18const BR_DOCTOR: i64 = 3
19const BR_COUNCIL: i64 = 4
20
21// stage outcomes
22const BR_FLOW_ADMIT: i64 = 1 // tested green -> admitted
23const BR_FLOW_HEAL: i64 = 2 // tested red -> route to Doctor to heal, then re-test
24const BR_FLOW_REJECT: i64 = 3 // healed and STILL red after the heal budget -> reject (no false-admit)
25const BR_FLOW_RACI_BAD: i64 = 0 // roles blurred (separation violated) -> the pipeline itself is invalid
26
27// SEPARATION OF DUTIES: author, tester, healer must be three DIFFERENT roles. Returns 1 if clean.
28func br_separation_ok(author: i64, tester: i64, healer: i64) -> i64 {
29 if author == tester { return 0 }
30 if author == healer { return 0 }
31 if tester == healer { return 0 }
32 return 1
33}
34
35// is the RIGHT role doing each job? tester must be the ENGINEER, healer must be the DOCTOR.
36func br_roles_correct(tester: i64, healer: i64) -> i64 {
37 if tester != BR_ENGINEER { return 0 } // testing is the Engineer's, never the Doctor's
38 if healer != BR_DOCTOR { return 0 } // healing is the Doctor's, never the Engineer's
39 return 1
40}
41
42// one pipeline decision. test_pass = did the Engineer's gate pass? heals_used / heal_budget bound the
43// Doctor's retry. admitter must be the single Accountable role (Council). Returns the flow verdict.
44func br_decide(author: i64, tester: i64, healer: i64, admitter_accountable_count: i64,
45 test_pass: i64, heals_used: i64, heal_budget: i64) -> i64 {
46 // the pipeline is only valid if roles are separated AND correctly assigned AND exactly-1-accountable
47 if br_separation_ok(author, tester, healer) == 0 { return BR_FLOW_RACI_BAD }
48 if br_roles_correct(tester, healer) == 0 { return BR_FLOW_RACI_BAD }
49 if raci_clean(admitter_accountable_count) == 0 { return BR_FLOW_RACI_BAD }
50 if test_pass == 1 { return BR_FLOW_ADMIT }
51 if heals_used < heal_budget { return BR_FLOW_HEAL } // failed but the Doctor still has heal budget
52 return BR_FLOW_REJECT // failed + out of heals -> reject, never false-admit
53}
54
55// only the ACCOUNTABLE role (Council) may commit the registration (composes raci_may_commit)
56func br_may_admit(committer_role_code: i64) -> i64 { return raci_may_commit(committer_role_code) }