code wiki / _hdl_build / nx_crew_council.nx

nx_crew_council.nx source

↩ module page · 51 lines · 2502 B

1// nx_crew_council.nx -- the crew's 3 -> 2 -> 1 checks-and-balances council 2// (LIBRARY). The separation-of-powers that gates every autonomous action so the 3// loop self-builds SAFELY. Consumed by nx_crew_council_test (proves the logic) 4// and nx_conductor_council_test (runs it as a LIVE governed tick). 5// 6// TIER 3 -- independent panel, ALL must pass: 7// ENGINEER (proven 1:1?) + GENEALOGIST (non-dup/additive?) + RACING (worth?) 8// TIER 2 -- governance review: 9// WARDEN (additive-only? delete/overwrite-src = HARD DENY) + ARCHIVIST (recorded?) 10// TIER 1 -- final authority: 11// CONDUCTOR commits if 3+2 clear, else escalates to the operator. 12// license_tier: ORIGINAL 13 14import "nx_syscalls.nx" 15 16const CC_ACT: i64 = 0 17const CC_ESCALATE: i64 = 1 18const CC_DENY: i64 = 2 19 20struct CrewAction { 21 name: i64 // *u8 22 verifies: i64 // ENGINEER: 1 = proven 1:1 23 novel: i64 // GENEALOGIST: 1 = non-duplicative + additive 24 worth: i64 // RACING: 1 = cascades / real gap (else defer) 25 safe: i64 // WARDEN: 1 = additive-only (0 = delete/overwrite-src) 26 recorded: i64 // ARCHIVIST: 1 = gated + documented + reproducible 27} 28 29func cc_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 } 30 31// Run the 3 -> 2 -> 1 gauntlet. Writes a governing-reason string ptr to why[0]. 32func cc_council(a: *CrewAction, why: *i64) -> i64 { 33 if a.verifies != 1 { why[0] = ("ENGINEER: not proven 1:1 -> escalate" as *u8) as i64; return CC_ESCALATE } 34 if a.novel != 1 { why[0] = ("GENEALOGIST: duplicative/strips features -> escalate" as *u8) as i64; return CC_ESCALATE } 35 if a.worth != 1 { why[0] = ("RACING/dimret: no cascade at parity -> defer" as *u8) as i64; return CC_ESCALATE } 36 if a.safe != 1 { why[0] = ("WARDEN: delete/overwrite-source -> HARD DENY" as *u8) as i64; return CC_DENY } 37 if a.recorded != 1 { why[0] = ("ARCHIVIST: not gated/documented -> escalate" as *u8) as i64; return CC_ESCALATE } 38 why[0] = ("CONDUCTOR: 3+2 clear -> COMMIT (Warden-gated)" as *u8) as i64 39 return CC_ACT 40} 41 42func cc_set(a: *CrewAction, nm: *u8, v: i64, n: i64, w: i64, s: i64, r: i64) -> i64 { 43 a.name = nm as i64; a.verifies = v; a.novel = n; a.worth = w; a.safe = s; a.recorded = r 44 return 0 45} 46 47func cc_verdict_name(vd: i64) -> *u8 { 48 if vd == CC_ACT { return "ACT " as *u8 } 49 if vd == CC_DENY { return "DENY " as *u8 } 50 return "ESCALATE" as *u8 51}