code wiki / _hdl_build / nx_build_raci_register.nx
nx_build_raci_register.nx source
↩ module page · 57 lines · 3676 B
1// nx_build_raci_register.nx -- GOVERNED registration of the RACI correction: the clean build pipeline
2// (nx_build_raci) + the role-corrected ENGINEER verifier (nx_engineer_verify, formerly misnamed
3// nx_doctor_sov_verify). Each gated on a REAL re-run of its test ELF. license_tier: ORIGINAL
4import "nx_cap_register.nx"
5import "nx_syscalls.nx"
6
7const RR_NLAYERS: i64 = 6
8
9// run path with an optional arg1 (arg1=0 for none); return raw wait status
10func rr_run_arg(path: *u8, arg1: *u8) -> i64 {
11 let pid: i64 = sys_fork()
12 if pid == 0 {
13 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
14 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
15 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = arg1 as i64; argv[2] = 0
16 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0
17 sys_execve(path, argv, envp); sys_exit(127)
18 }
19 let st: *i64 = sys_mmap(16) as *i64
20 sys_wait4(pid, st, 0)
21 return st[0]
22}
23func rr_run_status(path: *u8) -> i64 { return rr_run_arg(path, 0 as *u8) }
24
25func rr_reg_arg(elf: *u8, gate_arg: *u8, idx: i64, layer: i64, name: *u8) -> i64 {
26 let probe: i64 = sys_openat_rd(elf)
27 var present: i64 = 0
28 if probe >= 0 { present = 1; sys_close(probe) }
29 let raw: i64 = rr_run_arg(elf, gate_arg)
30 var ran_no_signal: i64 = 0
31 if (raw % 128) == 0 { ran_no_signal = 1 }
32 var exit_ok: i64 = 0
33 if raw == 0 { exit_ok = 1 }
34 let eng: i64 = ig_engineer(present, present, ran_no_signal, exit_ok)
35 // separation of duties: author_id(1) != admitter_id(2) -- the Council admits, not the author
36 let council: i64 = ig_council(eng, 1, 1, 2)
37 let decision: i64 = ig_decision(eng, council, 1)
38 cr_w(1, " gate raw=" as *u8); cr_wn(1, raw); cr_w(1, " decision=" as *u8); cr_wn(1, decision); cr_w(1, "\n" as *u8)
39 if decision != IG_INGEST { return 0 }
40 if cr_can_register(layer, 2, RR_NLAYERS, decision) != 1 { return 0 }
41 let fd: i64 = sys_openat_append("/tmp/nishi_cap_registry.log" as *u8, 0x1a4)
42 cr_write_entry(fd, idx, layer, name, 2)
43 sys_close(fd)
44 cr_w(1, " CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED\n" as *u8)
45 return 1
46}
47func rr_reg(elf: *u8, idx: i64, layer: i64, name: *u8) -> i64 { return rr_reg_arg(elf, 0 as *u8, idx, layer, name) }
48
49func main() -> i64 {
50 rr_reg("/tmp/nx_build_raci_test.sov.elf" as *u8, 225, 4,
51 "CON BUILD-RACI -- CLEAN RACI for the build pipeline (operator: 'the doctor doesnt test the engineer does, the doctor fixes'). Encodes+ENFORCES: BUILDER authors -> ENGINEER verifies/tests -> on fail DOCTOR heals (doc_rebuild) -> re-test -> COUNCIL admits. br_roles_correct (tester MUST be Engineer, healer MUST be Doctor -- catches the doctor-as-tester misnomer as RACI_BAD), br_separation_ok (author!=tester!=healer = no testing/healing your own build), br_decide (pass->ADMIT, fail+budget->HEAL, fail+exhausted->REJECT never false-admit), raci_clean (exactly 1 Accountable). 8/8 KATs. Composes nx_raci_collab")
52 // gate the verifier by having it VERIFY a known-good module (nx_build_raci_test) -> must exit 0
53 rr_reg_arg("/tmp/nx_engineer_verify.sov.elf" as *u8, "nx_build_raci_test" as *u8, 226, 3,
54 "VER ENGINEER-VERIFY -- the role-CORRECTED one-step batch verifier (RACI fix: TESTING is the ENGINEER's, was misnamed nx_doctor_sov_verify CAPREG211). Same sovereign mechanism (nx_cc->nxasm_x86->run, <10s watchdog, recompile-retry) now correctly attributed: the ENGINEER runs the gate, the DOCTOR heals failures (doc_rebuild). Output relabeled ENGINEER. Supersedes the doctor-named verifier")
55 sys_exit(0)
56 return 0
57}