code wiki / _hdl_build / nx_rom_provenance_gate.nx
nx_rom_provenance_gate.nx source
↩ module page · 49 lines · 3422 B
1// nx_rom_provenance_gate.nx -- R0.2 liar-kill gate for nx_rom_provenance. Proves the legal-containment policy
2// on a real registry: free-with-source ALLOW, free-without-source REFUSED (liar-kill), owned DARK until
3// lawyer_ok, unknown/unlisted DENY, and the lawyer flag absent by default. NISHI: pure organ + gate, no .sh.
4import "nx_syscalls.nx"
5import "nx_gate_emit_lib.nx"
6import "nx_rom_provenance.nx"
7import "nx_gate_verdict.nx"
8
9func main() -> i64 {
10 g_puts("nx_rom_provenance gate (legal-containment liar-kill over rom_provenance.tsv)\n" as *u8)
11 var pass: i64 = 0
12 var total: i64 = 0
13
14 let box: *i64 = sys_mmap(16) as *i64
15 let tsv: *u8 = sys_read_file("knowledge/registry/rom_provenance.tsv" as *u8, box)
16 if (tsv as i64) == 0 { g_puts(" FAIL cannot read rom_provenance.tsv\nverdict=RED\n" as *u8); sys_exit(1); return 1 }
17 let tn: i64 = box[0]
18 g_puts(" [measure] registry bytes=" as *u8); g_pn(tn); g_puts("\n" as *u8)
19
20 // 1) free 3rd-party WITH a real source -> ALLOW
21 pass = pass + g_check("pd + source -> ALLOW (chip8-pong)" as *u8, nx_rom_decide_buf(tsv, tn, "chip8-pong" as *u8, 0) == RD_ALLOW); total = total + 1
22 pass = pass + g_check("freeware + source -> ALLOW (dos-freedoom)" as *u8, nx_rom_decide_buf(tsv, tn, "dos-freedoom" as *u8, 0) == RD_ALLOW); total = total + 1
23
24 // 2) LIAR-KILL: a free-license claim with NO source -> DENY_NOSRC
25 pass = pass + g_check("pd claim, NO source-> DENY (liar-kill, liar-pd-nosrc)" as *u8, nx_rom_decide_buf(tsv, tn, "liar-pd-nosrc" as *u8, 0) == RD_DENY_NOSRC); total = total + 1
26
27 // 3) OWNED stays DARK until the lawyer flips the flag (even WITH proof of purchase)
28 pass = pass + g_check("owned, lawyer_ok=0 -> DENY (dark, owned-snes-y)" as *u8, nx_rom_decide_buf(tsv, tn, "owned-snes-y" as *u8, 0) == RD_DENY_OWNED); total = total + 1
29 // ...and ALLOWED only once lawyer_ok AND proof are both present
30 pass = pass + g_check("owned, lawyer_ok=1 + proof -> ALLOW (owned-snes-y)" as *u8, nx_rom_decide_buf(tsv, tn, "owned-snes-y" as *u8, 1) == RD_ALLOW); total = total + 1
31
32 // 4) deny-by-default: unknown license, and a key not in the registry at all
33 pass = pass + g_check("unknown license -> DENY (unknown-z)" as *u8, nx_rom_decide_buf(tsv, tn, "unknown-z" as *u8, 1) == RD_DENY); total = total + 1
34 pass = pass + g_check("not listed -> DENY (deny-by-default)" as *u8, nx_rom_decide_buf(tsv, tn, "no-such-id" as *u8, 1) == RD_DENY); total = total + 1
35
36 // 5) the lawyer sign-off flag is ABSENT by default -> the owned corpus is dark out of the box
37 pass = pass + g_check("lawyer_ok flag ABSENT by default (owned corpus dark)" as *u8, nx_rom_lawyer_ok() == 0); total = total + 1
38
39 g_puts("---- rom_provenance gate: passed " as *u8); g_pn(pass); g_puts(" / " as *u8); g_pn(total); g_puts(" ----\n" as *u8)
40 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
41 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
42 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
43 let ctr__dry: *i64 = gv_ctr()
44 ctr__dry[0] = pass
45 ctr__dry[1] = total
46 let rc__dry: i64 = gv_verdict("ROM-PROVENANCE-GATE" as *u8, ctr__dry, "teeth unchanged; verdict emission migrated onto the shared base class" as *u8)
47 sys_exit(rc__dry)
48 return rc__dry
49}