code wiki / _hdl_build / nx_race_harness_register.nx
nx_race_harness_register.nx source
↩ module page · 40 lines · 3035 B
1// nx_race_harness_register.nx -- records RACE_HARNESS (race-1's third and last growth rung).
2// Engineer gate = oracle + referee both run green on the real manifest (the tamper-RED proof is
3// in knowledge/status/race_harness.log). Librarian alloc + dual-write. license_tier: ORIGINAL
4import "nx_cap_register.nx"
5import "nx_capreg_librarian.nx"
6import "nx_syscalls.nx"
7
8func rhr_run(path: *u8) -> i64 {
9 let pid: i64 = sys_fork()
10 if pid == 0 {
11 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4)
12 if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
13 let argv: *i64 = sys_mmap(32) as *i64; argv[0] = path as i64; argv[1] = 0
14 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
15 sys_execve(path, argv, envp); sys_exit(127)
16 }
17 let st: *i64 = sys_mmap(16) as *i64
18 sys_wait4(pid, st, 0)
19 return st[0]
20}
21
22func main() -> i64 {
23 var allok: i64 = 1
24 if rhr_run("/tmp/oc.elf" as *u8) != 0 { allok = 0 }
25 if rhr_run("/tmp/rr.elf" as *u8) != 0 { allok = 0 }
26 cr_w(1, "ENGINEER: oracle+referee green=" as *u8); cr_wn(1, allok); cr_w(1, "\n" as *u8)
27 let eng: i64 = ig_engineer(1, 1, 1, allok)
28 let dec: i64 = ig_decision(eng, ig_council(eng, 1, 1, 2), 1)
29 if dec != IG_INGEST { cr_w(1, "HELD\n" as *u8); sys_exit(1) }
30 if cr_can_register(5, 2, 6, dec) != 1 { cr_w(1, "REFUSED\n" as *u8); sys_exit(1) }
31 let lp: *u8 = "/tmp/nishi_cap_registry.log" as *u8
32 let jp: *u8 = "knowledge/status/cap_registry_durable.log" as *u8
33 let idx: i64 = cl_next_idx(lp, jp)
34 let ok: i64 = cl_register_dual(lp, jp, idx, 5,
35 2, "CON RACE-HARNESS (race-1's last growth rung LANDED -- autonomy races now run Claude-free past assignment-naming). nx_race_referee = GENERIC manifest-driven Referee: lanes/cases/rows are DATA (/tmp/race_manifest.txt: lane <name> <elf> x4, case <name> <file> x8, row <case> <key> <want> x64); for each lane x case it stages the input, runs the lane ELF, parses <key><int> from stdout, scores rows, per-lane permil + lane0-vs-lane1 verdict -> knowledge/status/race_harness.log; malformed manifest = LOUD exit 2. nx_ch_census_oracle = the per-assignment stager pattern: composes the TEAM's _pe_chwalk locate (real CH ext block 108B) + SHIPPED tls13_ext_find ground truth -> case files + manifest + a TAMPERED twin. PROVEN: RACE 3 ran fully harness-driven, 12/12 both lanes, verdict=LANE0-MATCHES (team 1000 v claude 1000, third consecutive parity); TAMPER RUN = tampered manifest turns the harness RED at exactly the corrupted row (916 permil both lanes, FAIL row named) -- the gate can fail, so its green means something. A NEW race = write an oracle stager + manifest; referee unchanged. Completes the race-1 growth triple: STRUCT_WALK(13)+IO_CONTRACT(14)+RACE_HARNESS. Composes CAPREG273/282" as *u8)
36 if ok != 1 { cr_w(1, "DUAL-WRITE FAILED\n" as *u8); sys_exit(1) }
37 cr_w(1, "CAPREG idx=" as *u8); cr_wn(1, idx); cr_w(1, " REGISTERED -- RACE_HARNESS landed, races now manifest-driven\n" as *u8)
38 sys_exit(0)
39 return 0
40}