code wiki / _hdl_build / nx_raci_collab.nx

nx_raci_collab.nx source

↩ module page · 54 lines · 2969 B

1// nx_raci_collab.nx -- structured inter-organ collaboration: organs INGEST each other's deliverables and 2// go BACK AND FORTH (feedback rounds) while keeping a CLEAN RACI (operator: "build their capabilities to 3// ingest and work together and go back and forth while still keeping a clean raci"). The rule that keeps 4// roles non-blurred: exactly ONE Accountable owns each decision; Consulted organs iterate two-way, but only 5// the Accountable COMMITS. Iteration is bounded -> escalate if it can't converge. license_tier: ORIGINAL 6// Composes the RACI doctrine (separation of duties) with the council/peer-review patterns. 7 8import "nx_syscalls.nx" 9 10const RACI_RESPONSIBLE: i64 = 1 // does the work 11const RACI_ACCOUNTABLE: i64 = 2 // owns the decision -- exactly ONE per item 12const RACI_CONSULTED: i64 = 3 // two-way feedback (the back-and-forth) 13const RACI_INFORMED: i64 = 4 // one-way notification 14 15// a RACI is clean iff EXACTLY ONE organ is Accountable (the non-blurring invariant). 16func raci_clean(accountable_count: i64) -> i64 { if accountable_count == 1 { return 1 } return 0 } 17 18// only the single Accountable organ may COMMIT the decision -- never a Consulted/Responsible one. 19func raci_may_commit(committer_role: i64) -> i64 { if committer_role == RACI_ACCOUNTABLE { return 1 } return 0 } 20 21const COLLAB_CONVERGED: i64 = 1 // Consulted organs satisfied -> Accountable commits 22const COLLAB_ITERATE: i64 = 2 // open objections, rounds remain -> another revision 23const COLLAB_ESCALATE: i64 = 3 // out of rounds, still contested -> escalate to council/operator 24 25// one feedback round: converge if no objections, iterate if rounds remain, else escalate (no infinite loops). 26func collab_round(consulted_objections: i64, round: i64, max_rounds: i64) -> i64 { 27 if consulted_objections == 0 { return COLLAB_CONVERGED } 28 if round >= max_rounds { return COLLAB_ESCALATE } 29 return COLLAB_ITERATE 30} 31 32// run the back-and-forth to a verdict: simulate objections dropping each revision; returns the final 33// COLLAB_* outcome and writes the number of rounds taken into out_rounds[0]. 34func collab_run(initial_objections: i64, resolved_per_round: i64, max_rounds: i64, out_rounds: *i64) -> i64 { 35 var obj: i64 = initial_objections 36 var round: i64 = 1 37 while round <= max_rounds { 38 let v: i64 = collab_round(obj, round, max_rounds) 39 if v == COLLAB_CONVERGED { out_rounds[0] = round; return COLLAB_CONVERGED } 40 if v == COLLAB_ESCALATE { out_rounds[0] = round; return COLLAB_ESCALATE } 41 obj = obj - resolved_per_round // the revision resolves some objections 42 if obj < 0 { obj = 0 } 43 round = round + 1 44 } 45 out_rounds[0] = max_rounds 46 if obj == 0 { return COLLAB_CONVERGED } 47 return COLLAB_ESCALATE 48} 49 50func collab_label(v: i64) -> *u8 { 51 if v == COLLAB_CONVERGED { return "CONVERGED" as *u8 } 52 if v == COLLAB_ITERATE { return "ITERATE" as *u8 } 53 return "ESCALATE" as *u8 54}