code wiki / _hdl_build / nx_rom_provenance_gate.nx

nx_rom_provenance_gate.nx source

↩ module page · 42 lines · 2977 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" 7 8func main() -> i64 { 9 g_puts("nx_rom_provenance gate (legal-containment liar-kill over rom_provenance.tsv)\n" as *u8) 10 var pass: i64 = 0 11 var total: i64 = 0 12 13 let box: *i64 = sys_mmap(16) as *i64 14 let tsv: *u8 = sys_read_file("knowledge/registry/rom_provenance.tsv" as *u8, box) 15 if (tsv as i64) == 0 { g_puts(" FAIL cannot read rom_provenance.tsv\nverdict=RED\n" as *u8); sys_exit(1); return 1 } 16 let tn: i64 = box[0] 17 g_puts(" [measure] registry bytes=" as *u8); g_pn(tn); g_puts("\n" as *u8) 18 19 // 1) free 3rd-party WITH a real source -> ALLOW 20 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 21 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 22 23 // 2) LIAR-KILL: a free-license claim with NO source -> DENY_NOSRC 24 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 25 26 // 3) OWNED stays DARK until the lawyer flips the flag (even WITH proof of purchase) 27 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 28 // ...and ALLOWED only once lawyer_ok AND proof are both present 29 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 30 31 // 4) deny-by-default: unknown license, and a key not in the registry at all 32 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 33 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 34 35 // 5) the lawyer sign-off flag is ABSENT by default -> the owned corpus is dark out of the box 36 pass = pass + g_check("lawyer_ok flag ABSENT by default (owned corpus dark)" as *u8, nx_rom_lawyer_ok() == 0); total = total + 1 37 38 g_puts("---- rom_provenance gate: passed " as *u8); g_pn(pass); g_puts(" / " as *u8); g_pn(total); g_puts(" ----\n" as *u8) 39 if pass == total { g_puts("verdict=GREEN\n" as *u8); sys_exit(0); return 0 } 40 g_puts("verdict=RED\n" as *u8); sys_exit(1) 41 return 1 42}