code wiki / _hdl_build / nx_conductor_pulse_gate.nx
nx_conductor_pulse_gate.nx source
↩ module page · 62 lines · 4565 B
1import "nx_gate_gn.nx"
2import "nx_gate_base.nx"
3// nx_conductor_pulse_gate.nx -- proves pulses/daemons are GOVERNED by the conductor, not spawned ad-hoc.
4// The concrete case: the team-training pulse (the very thing we wanted to "wire to a pulse") must pass the
5// conductor's admission before it can fire.
6// T1 ADMIT : training pulse (owner=engineer, organ=nx_team_train_gate GREEN, software) -> ADMIT.
7// T2 NO-OWNER : a pulse with no Accountable role -> REJECT (not just anyone registers a pulse).
8// T3 BROKEN : a pulse whose organ gate is RED -> REJECT (#7: never pulse a broken organ).
9// T4 NEVER-BRICK: a hardware daemon without a never-brick proof -> REJECT (#26); with proof -> ADMIT.
10// T5 GOVERNED FIRE: an un-admitted pulse CANNOT fire (-1); an admitted one fires GREEN (0) = the enforcement.
11// T6 NEG-CONTROL: the owner predicate has teeth (real role yes, made-up role no).
12// expect_exit: 0 license_tier: ORIGINAL
13import "nx_conductor_pulse.nx"
14import "nx_syscalls.nx"
15
16func grow(name: *u8, ok: i64) -> i64 { if ok==1 { gw(" PASS " as *u8) } else { gw(" FAIL " as *u8) } gw(name); gw("
17" as *u8); return ok }
18
19func main() -> i64 {
20 gw("=== nx_conductor_pulse_gate: do pulses/daemons go THROUGH the conductor (not ad-hoc)? ===\n" as *u8)
21 var pass: i64=0; var total: i64=0
22
23 // T1 ADMIT the real training-loop pulse: owned by engineer, organ gate GREEN, software (no hw)
24 let oeng: i64 = cp_owner_ok("engineer\x00" as *u8)
25 let gx: i64 = cp_run_gate("nx_team_train_gate\x00" as *u8) // GREEN -> 0
26 let a1: i64 = cp_admit(oeng, gx, 0, 0)
27 total=total+1; if a1==CP_ADMIT { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
28 gw("T1 ADMIT training pulse: owner=engineer ok(\x00" as *u8); gn(oeng); gw("), organ gate exit=\x00" as *u8); gn(gx); gw(" -> verdict \x00" as *u8); gn(a1); gw(" (1=ADMIT)\n" as *u8)
29
30 // T2 NO-OWNER -> REJECT
31 let onone: i64 = cp_owner_ok("\x00" as *u8)
32 let a2: i64 = cp_admit(onone, 0, 0, 0)
33 total=total+1; if a2==CP_REJECT { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
34 gw("T2 NO-OWNER: a pulse with no Accountable role -> REJECT(\x00" as *u8); gn(a2); gw(")\n" as *u8)
35
36 // T3 BROKEN ORGAN (gate RED, exit 1) -> REJECT
37 let a3: i64 = cp_admit(1, 1, 0, 0)
38 total=total+1; if a3==CP_REJECT { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) }
39 gw("T3 BROKEN: organ gate RED -> REJECT(\x00" as *u8); gn(a3); gw(") = never pulse a broken organ (#7)\n" as *u8)
40
41 // T4 NEVER-BRICK: hw daemon unproven -> REJECT (even owned + gate-green); proven -> ADMIT
42 let a4u: i64 = cp_admit(1, 0, 1, 0)
43 let a4p: i64 = cp_admit(1, 0, 1, 1)
44 total=total+1; if a4u==CP_REJECT { if a4p==CP_ADMIT { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
45 gw("T4 NEVER-BRICK: hw daemon UNPROVEN -> REJECT(\x00" as *u8); gn(a4u); gw("), PROVEN -> ADMIT(\x00" as *u8); gn(a4p); gw(") = #26 dominates\n" as *u8)
46
47 // T5 GOVERNED FIRE: an un-admitted pulse cannot fire (-1); an admitted one fires GREEN (0)
48 let f_refused: i64 = cp_fire_governed(CP_REJECT, "nx_team_train_gate\x00" as *u8)
49 let f_fired: i64 = cp_fire_governed(CP_ADMIT, "nx_team_train_gate\x00" as *u8)
50 total=total+1; if f_refused==(0-1) { if f_fired==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
51 gw("T5 GOVERNED FIRE: un-admitted REFUSED(\x00" as *u8); gn(f_refused); gw("), admitted fires GREEN(\x00" as *u8); gn(f_fired); gw(") = nothing pulses except through the conductor\n" as *u8)
52
53 // T6 NEG-CONTROL: the owner predicate has teeth
54 let oteeth: i64 = cp_owner_ok("engineer\x00" as *u8)
55 let ofake: i64 = cp_owner_ok("rando_nobody\x00" as *u8)
56 total=total+1; if oteeth==1 { if ofake==0 { pass=pass+1; gw(" [PASS] " as *u8) } else { gw(" [FAIL] " as *u8) } } else { gw(" [FAIL] " as *u8) }
57 gw("T6 NEG-CONTROL: real role owned(\x00" as *u8); gn(oteeth); gw("), made-up role unowned(\x00" as *u8); gn(ofake); gw(")\n" as *u8)
58
59 gw("\n=== nx_conductor_pulse_gate \x00" as *u8); gn(pass); gw("/\x00" as *u8); gn(total)
60 if pass==total { gw(" GREEN -- pulses/daemons go THROUGH the conductor: admitted only if RACI-owned + gate-green + never-brick(#26), and only an admitted pulse may fire. The training loop's pulse is now governed, like publishing through the publisher.\n" as *u8); sys_exit(0); return 0 }
61 gw(" RED\n" as *u8); sys_exit(1); return 1
62}