code wiki / _hdl_build / nx_conductor_council_test.nx

nx_conductor_council_test.nx source

↩ module page · 79 lines · 4151 B

1// nx_conductor_council_test.nx -- the council, OPERATIONAL: a conductor TICK that 2// runs the loop's real candidate-action queue through the 3 -> 2 -> 1 crew council 3// and produces the GOVERNED outcome -- commit the clear ones, hard-deny the unsafe, 4// route the doubtful to the operator (NEEDS-REVIEW). This is the crew governing the 5// LIVE loop, not deciding on hypotheticals: the conductor never commits an action 6// the council didn't clear. Composes nx_crew_council (the proven decision logic). 7// 8// Known answer: a tick over 6 candidate actions -> 3 COMMIT, 1 DENY, 2 ESCALATE; 9// exit 0 iff the conductor governed the tick exactly so. license_tier: ORIGINAL 10 11import "nx_crew_council.nx" 12 13const TICK_N: i64 = 6 14 15func _tputn(v: i64) -> i64 { 16 let b: *u8 = sys_mmap(24); var n: i64 = v; if n < 0 { n = 0 - n } 17 let t: *u8 = sys_mmap(24); var k: i64 = 0 18 if n == 0 { t[0] = 48; k = 1 } 19 while n > 0 { t[k] = 48 + (n % 10); n = n / 10; k = k + 1 } 20 var i: i64 = 0; while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 21 sys_write(1, b, k); return 0 22} 23 24func main() -> i64 { 25 // The loop's candidate-action queue this beat (name + the 5 role-facts). 26 let nm: *i64 = sys_mmap(8 * TICK_N) as *i64 27 let v: *i64 = sys_mmap(8 * TICK_N) as *i64 28 let n: *i64 = sys_mmap(8 * TICK_N) as *i64 29 let w: *i64 = sys_mmap(8 * TICK_N) as *i64 30 let s: *i64 = sys_mmap(8 * TICK_N) as *i64 31 let r: *i64 = sys_mmap(8 * TICK_N) as *i64 32 33 nm[0]=("enroll: nx_ecosystem_test (self-model)" as *u8) as i64; v[0]=1; n[0]=1; w[0]=1; s[0]=1; r[0]=1 34 nm[1]=("enroll: nx_crew_council_test (governance)" as *u8) as i64; v[1]=1; n[1]=1; w[1]=1; s[1]=1; r[1]=1 35 nm[2]=("commit: shipped divider+mulh emitter (census-verified)" as *u8) as i64; v[2]=1; n[2]=1; w[2]=1; s[2]=1; r[2]=1 36 nm[3]=("heal: overwrite nx_opt.nx source in place" as *u8) as i64; v[3]=1; n[3]=1; w[3]=1; s[3]=0; r[3]=1 37 nm[4]=("author: 64-bit Goldschmidt (not yet proven)" as *u8) as i64; v[4]=0; n[4]=1; w[4]=1; s[4]=1; r[4]=1 38 nm[5]=("optimize: 0.5% micro-opt at parity, no cascade" as *u8) as i64; v[5]=1; n[5]=1; w[5]=0; s[5]=1; r[5]=1 39 40 cc_puts("================================================================\n" as *u8) 41 cc_puts(" CONDUCTOR TICK -- governing " as *u8); _tputn(TICK_N) 42 cc_puts(" candidate actions through the crew council\n" as *u8) 43 cc_puts("================================================================\n" as *u8) 44 45 let a: *CrewAction = sys_mmap(64) as *CrewAction 46 let why: *i64 = sys_mmap(8) as *i64 47 var committed: i64 = 0 48 var denied: i64 = 0 49 var escalated: i64 = 0 50 51 var i: i64 = 0 52 while i < TICK_N { 53 cc_set(a, nm[i] as *u8, v[i], n[i], w[i], s[i], r[i]) 54 let vd: i64 = cc_council(a, why) 55 cc_puts(" beat " as *u8); _tputn(i + 1); cc_puts(" [" as *u8); cc_puts(cc_verdict_name(vd)); cc_puts("] " as *u8) 56 cc_puts(a.name as *u8); cc_puts("\n " as *u8); cc_puts(why[0] as *u8); cc_puts("\n" as *u8) 57 if vd == CC_ACT { committed = committed + 1 } 58 if vd == CC_DENY { denied = denied + 1 } 59 if vd == CC_ESCALATE { escalated = escalated + 1 } 60 i = i + 1 61 } 62 63 cc_puts("----------------------------------------------------------------\n" as *u8) 64 cc_puts(" tick governed: COMMIT " as *u8); _tputn(committed) 65 cc_puts(" | DENY " as *u8); _tputn(denied) 66 cc_puts(" | ESCALATE " as *u8); _tputn(escalated) 67 cc_puts("\n the conductor committed only council-cleared actions; the unsafe\n" as *u8) 68 cc_puts(" one was hard-denied, the doubtful ones routed to the OPERATOR.\n" as *u8) 69 cc_puts(" -> the loop self-builds, but never acts unilaterally.\n" as *u8) 70 cc_puts("----------------------------------------------------------------\n" as *u8) 71 72 // SELF-VERIFY the governed tick: the conductor must commit exactly the cleared 73 // actions, deny the unsafe, escalate the doubtful. 74 if committed != 3 { sys_exit(1); return 1 } 75 if denied != 1 { sys_exit(2); return 2 } 76 if escalated != 2 { sys_exit(3); return 3 } 77 sys_exit(0) 78 return 0 79}