code wiki / _hdl_build / nx_council_gate.nx
nx_council_gate.nx
buildroot/runtime/_hdl_build/nx_council_gate.nx
about
nx_council_gate.nx -- THE HIGH-BLAST-RADIUS COUNCIL-APPROVAL GATE: self-preservation so no single LLM can
"delete it all / drop everything / break things." Operator 2026-07-04: "an LLM can PROPOSE things and upon
COUNCIL APPROVAL (multiple Nishi team-member reviews) it can submit the highest-blast-radius actions,
signaled via a UI." Balances quantity (an LLM proposes freely + fast) with quality (heavy actions need quorum).
GROUNDED (nishi researcher): two-person rule / four-eyes (gov_twoperson.raw), quorum = threshold of a body
required for a decision to be valid (gov_quorum.raw), engineering change-management CAB (gov_changemgmt.raw).
COMPOSES, does not fork (Cardinal 15): the Warden (nx_warden_lib) already DENIES W_DELETE/W_OVERWRITE_SRC
BY CONSTRUCTION (the self-preservation FLOOR -- an LLM cannot autonomously destroy). This adds the ESCALATION
PATH the Warden lacked: those DENY-by-default actions become ALLOW *only* with a quorum-approved proposal by
DISTINCT Nishi team roles (from the RACI). Sovereign seg-store, no TSV. Emits a UI-readable status line.
FLOW: propose(action,target,rationale)->id[PENDING] -> review(id, role, APPROVE|REJECT) x N ->
council_verdict(id): APPROVED iff (>=QUORUM distinct-role APPROVEs) AND (0 REJECTs); else PENDING/REJECTED
-> warden_council_authorize(kind,target): ALLOW iff an APPROVED proposal exists for this exact action.
license_tier: ORIGINAL genealogy_id: international-research-sources/{two_person_rule,quorum,change_management}
lineage_id: nishi_council_gate_v1 expect_exit: 0
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_seg_store.nxnx_warden_lib.nx
imported by: nx_unified_conductor.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 24 | const CG_STATUS_LOG: *u8 = "knowledge/status/council_gate.log\x00" // the UI-readable signal |
| 25 | const CG_QUORUM: i64 = 3 // M-of-N: >=3 distinct-role APPROVEs (majority of the 5-role council) + 0 REJECTs |
| 83 | const CG_ROLES: i64 = 5 |
functions
| 23 | func CG_PREFIX() -> *u8 { return "knowledge/store/council-\x00" as *u8 } |
| 27 | func cg_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } calls 1: sys_write |
| 28 | func cg_putn(v: i64) -> i64 |
| 35 | func cg_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } |
| 36 | func cg_cat(dst: *u8, off: i64, src: *u8) -> i64 { var i: i64 = 0; while src[i] != (0 as u8) { dst[off + i] = src[i]; i = i + 1 } dst[off + i] = 0 as u8; return off + i } |
| 37 | func cg_eq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } |
| 43 | func cg_seg_next(prefix: *u8) -> i64 { let n: i64 = ss_next_segid(prefix); if n < 0 { return 1 } return n } |
| 46 | func cg_put(prefix: *u8, key: *u8, val: *u8) -> i64 called by 2: nx_council_proposenx_council_review calls 7: sys_mmapcg_lenss_getss_beginss_addcg_seg_next+1 |
| 54 | func cg_signal(id: *u8, state: *u8, action: *u8, target: *u8) -> i64 |
| 64 | func nx_council_propose(id: *u8, action: *u8, target: *u8, rationale: *u8) -> i64 |
| 76 | func cg_role(n: i64) -> *u8 called by 1: cg_tally |
| 87 | func nx_council_review(id: *u8, role: *u8, decision: *u8) -> i64 |
| 96 | func cg_tally(id: *u8, out_approve: *i64, out_reject: *i64) -> i64 |
| 113 | func nx_council_verdict(id: *u8) -> i64 |
| 126 | func cg_exists(path: *u8) -> i64 { let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 } sys_close(fd); return 1 } |
| 129 | func cg_variant(target: *u8, suffix: *u8, out: *u8) -> i64 |
| 144 | func nx_council_review_auto(id: *u8, target: *u8) -> i64 |
| 159 | func nx_warden_council_authorize(kind: i64, target: *u8, proposal_id: *u8) -> i64 |
| 172 | func cg_w(s: *u8) -> i64 { sys_write(1, s, cg_len(s)); return 0 } |
| 173 | func cg_row(name: *u8, ok: i64) -> i64 { if ok == 1 { cg_w(" PASS " as *u8) } else { cg_w(" FAIL " as *u8) } cg_w(name); cg_w("\n" as *u8); return ok } |
| 177 | func cg_runid(base: *u8, out: *u8) -> i64 |
| 190 | func cg_streq(a: *u8, b: *u8) -> i64 { var i: i64 = 0; while a[i] != (0 as u8) { if a[i] != b[i] { return 0 } i = i + 1 } if b[i] != (0 as u8) { return 0 } return 1 } called by 1: cg_cli |
| 201 | func cg_cli(argc: i64, argv: *i64) -> i64 called by 1: main calls 8: cg_streqcg_wnx_council_proposenx_council_reviewnx_council_review_autocg_putn+2 |
| 239 | func main(argc: i64, argv: *i64) -> i64 |