code wiki / _hdl_build / nx_gate_author_gate.nx
nx_gate_author_gate.nx source
↩ module page · 52 lines · 2947 B
1// nx_gate_author_gate.nx -- the X-AUT-GATE-001 close gate: proves the team authors GATE organs from
2// DATA specs, hands-off (the gate/benchmark emitter shape, the rung after pe14 PERMIL_VERDICT).
3//
4// Evidence: pe16 gained a SPEC-INPUT mode (additive); two gate-specs (knowledge/specs/gate_nv1l.spec,
5// gate_fc.spec) were authored into round-trip+tamper gates BY pe16 reading the spec -- zero hand-written
6// gate logic per rider. This gate RUNS both spec-authored KATs (fork/exec nx_sov_build_run, which
7// builds+runs each test and passes its exit through) and is GREEN iff both pass. Two riders FROM A DATA
8// SPEC = pe16 EARNED (was BOOTSTRAP-PROVISIONAL). The no-false-green property is the gate template's
9// tamper arm (proven on pe16's _rt_bad fixture -> RED). fork/exec, not import, dodges the double-
10// nx_syscalls-import rc=6 landmine. license_tier: ORIGINAL
11import "nx_syscalls.nx"
12
13func gag_w(fd: i64, s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(fd, s, n); return 0 }
14func gag_wn(fd: i64, v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m; sys_write(fd,"-" as *u8,1)}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48 as u8;k=1}; while m>0 {t[k]=(48+(m%10)) as u8; m=m/10; k=k+1}; var i: i64=0; while i<k {bb[i]=t[k-1-i]; i=i+1}; sys_write(fd, bb, k); return 0 }
15
16// build+run runtime/_hdl_build/<name>.nx via the durable sovereign runner; return its exit (0=GREEN).
17func gag_run(name: *u8) -> i64 {
18 let pid: i64 = sys_fork()
19 if pid == 0 {
20 let argv: *i64 = sys_mmap(32) as *i64
21 let envp: *i64 = sys_mmap(16) as *i64; envp[0] = 0
22 let dn: i64 = sys_openat_wr("/dev/null" as *u8, 0x1a4); if dn >= 0 { sys_dup3(dn, 1, 0); sys_dup3(dn, 2, 0) }
23 let sbr: *u8 = "_offc/nx_sov_build_run.elf" as *u8
24 argv[0] = sbr as i64; argv[1] = name as i64; argv[2] = 0
25 sys_execve(sbr, argv, envp)
26 sys_exit(127)
27 }
28 let st: *i64 = sys_mmap(16) as *i64
29 sys_wait4(pid, st, 0)
30 if (st[0] % 128) != 0 { return 0 - 1 }
31 return (st[0] >> 8) & 0xff
32}
33
34func gag_report(fd: i64, rc1: i64, rc2: i64, ok: i64) -> i64 {
35 gag_w(fd, "GATEAUTHOR authored=organ shape=GATE_HARNESS source=spec(gate_nv1l.spec,gate_fc.spec) riders=2 spec_driven=YES nv1l_rc=" as *u8); gag_wn(fd, rc1)
36 gag_w(fd, " fc_rc=" as *u8); gag_wn(fd, rc2)
37 if ok == 1 { gag_w(fd, " pe16=EARNED verdict=GREEN\n" as *u8) } else { gag_w(fd, " verdict=RED\n" as *u8) }
38 return 0
39}
40
41func main() -> i64 {
42 let rc1: i64 = gag_run("_nv1l_rtgate_sa_test" as *u8)
43 let rc2: i64 = gag_run("_fc_rtgate_sa_test" as *u8)
44 var ok: i64 = 1
45 if rc1 != 0 { ok = 0 }
46 if rc2 != 0 { ok = 0 }
47 gag_report(1, rc1, rc2, ok)
48 let lf: i64 = sys_openat_append("knowledge/status/gate_author.log" as *u8, 420)
49 if lf >= 0 { gag_report(lf, rc1, rc2, ok); sys_close(lf) }
50 if ok == 1 { sys_exit(0); return 0 }
51 sys_exit(1); return 1
52}