code wiki / _hdl_build / nx_char_asset_gate.nx
nx_char_asset_gate.nx source
↩ module page · 77 lines · 5648 B
1// nx_char_asset_gate.nx -- the operator's full ask ENFORCED: license a nude model (graded standard->explicit),
2// deliver into nude-art-modeling coaching / games, and add layers (armor/clothing) that set the delivered tier.
3// Proves the tier+use matrix via the gate, and the REAL wired glTF export (mesh) for an allowed case + a refused
4// case. expect_exit:0 license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_char_asset.nx"
7
8func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
9func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 }
10func yn(v: i64) -> i64 { if v==1 { hw("ALLOW" as *u8) } else { hw("REFUSE" as *u8) } return 0 }
11func is_glb(path: *u8) -> i64 {
12 let fd: i64 = sys_openat_rd(path); if fd < 0 { return 0 }
13 let b: *u8 = sys_mmap(8); let r: i64 = sys_read(fd, b, 4); sys_close(fd)
14 if r < 4 { return 0 }
15 if (b[0]&0xff)==0x67 { if (b[1]&0xff)==0x6C { if (b[2]&0xff)==0x54 { if (b[3]&0xff)==0x46 { return 1 } } } }
16 return 0
17}
18// one matrix row: set the license, ask if this delivery is allowed, compare to expected.
19func row(rec: *i64, label: *u8, outfit: i64, explicit: i64, uses: i64, now: i64, want: i64, fp: *i64) -> i64 {
20 let got: i64 = char_deliver_ok(rec, now, outfit, explicit, uses)
21 hw(" "); hw(label); hw(" -> "); yn(got)
22 if got == want { hw(" ok\n" as *u8) } else { hw(" MISMATCH (want "); yn(want); hw(")\n" as *u8); fp[0] = fp[0] + 1 }
23 return 0
24}
25
26func main() -> i64 {
27 hw("=== nx_char_asset_gate -- licensed nude model + layers + art-coaching, consent ENFORCED ===\n" as *u8)
28 let rec: *i64 = sys_mmap(8 * 8) as *i64
29 let now: i64 = 1000000
30 let fp: *i64 = sys_mmap(8) as *i64; fp[0] = 0
31
32 // -- the license/tier/layer matrix (the operator's cases) --
33 consent_init(rec, PROV_SYNTH, 0, 0, 0, 0, 0, 0)
34 row(rec, "synthetic char, bare, any use " as *u8, 0, 0, USE_ART_COACH + USE_GAME, now, 1, fp) // ungated
35
36 consent_init(rec, PROV_SCAN, 1, LIC_ARTISTIC, USE_ART_COACH, 2000000, 9001, 70)
37 row(rec, "artistic license, BARE, art-coaching " as *u8, 0, 0, USE_ART_COACH, now, 1, fp) // life-drawing reference: OK
38
39 consent_init(rec, PROV_SCAN, 1, LIC_CLOTHED, USE_ART_COACH + USE_GAME + USE_DISTRIBUTE, 2000000, 9002, 70)
40 row(rec, "clothed-only license, BARE delivery " as *u8, 0, 0, USE_GAME, now, 0, fp) // nude beyond license: REFUSE
41 row(rec, "clothed-only license, ARMORED delivery " as *u8, 4, 0, USE_GAME, now, 1, fp) // layered down to clothed: OK
42
43 consent_init(rec, PROV_SCAN, 1, LIC_ARTISTIC, USE_ART_COACH, 2000000, 9003, 70) // licensed for art-coaching ONLY
44 row(rec, "artistic license, EXPLICIT delivery " as *u8, 0, 1, USE_ART_COACH, now, 0, fp) // explicit>artistic tier: REFUSE
45 row(rec, "artistic(art-coach only), BARE GAME use " as *u8, 0, 0, USE_GAME, now, 0, fp) // game use not in license: REFUSE
46
47 consent_init(rec, PROV_SCAN, 1, LIC_EXPLICIT, USE_ART_COACH, 2000000, 9004, 70)
48 row(rec, "explicit license, EXPLICIT, per contract" as *u8, 0, 1, USE_ART_COACH, now, 1, fp) // contracted explicit: OK
49 if fp[0] == 0 { hw("T1 PASS the tier+use+layer matrix is enforced exactly\n" as *u8) } else { hw("T1 FAIL matrix\n" as *u8) }
50
51 // -- the REAL wired game-asset export (mesh->glTF), gated --
52 let base: i64 = sys_mmap(sdf_bytes()) as i64
53 let F: *i64 = sys_mmap((MG_N + 1) * (MG_N + 1) * (MG_N + 1) * 8) as *i64
54 let cubevi: *i64 = sys_mmap(MG_N * MG_N * MG_N * 8) as *i64
55 let vbuf: *i64 = sys_mmap(MG_MAXV * 3 * 8) as *i64
56 let fbuf: *i64 = sys_mmap(MG_MAXF * 3 * 8) as *i64
57 let out: *i64 = sys_mmap(16) as *i64
58
59 // artistic-nude model licensed for art-coaching -> export the bare figure as a reference asset: ALLOWED
60 char_build(base, 0, 0, 0, 0, 100, FIG_FEM, 0)
61 consent_init(rec, PROV_SCAN, 1, LIC_ARTISTIC, USE_ART_COACH + USE_DISTRIBUTE, 2000000, 9005, 70)
62 let rok: i64 = char_export_gltf_gated(base, F, cubevi, vbuf, fbuf, out, rec, now, 0, 0, USE_ART_COACH + USE_DISTRIBUTE, "knowledge/char_artref.glb" as *u8)
63 hw(" export bare artistic reference (licensed): "); pn(rok); hw("B glTF\n" as *u8)
64 var t2: i64 = 0
65 if rok > 0 { if is_glb("knowledge/char_artref.glb" as *u8) == 1 { t2 = 1 } }
66
67 // clothed-only model -> bare export REFUSED at the mesh boundary (fail-closed, no file)
68 consent_init(rec, PROV_SCAN, 1, LIC_CLOTHED, USE_ART_COACH + USE_DISTRIBUTE, 2000000, 9006, 70)
69 let rref: i64 = char_export_gltf_gated(base, F, cubevi, vbuf, fbuf, out, rec, now, 0, 0, USE_ART_COACH + USE_DISTRIBUTE, "knowledge/char_should_not_exist.glb" as *u8)
70 hw(" export bare from clothed-only license: "); pn(rref); hw(" (fail-closed)\n" as *u8)
71 if t2 == 1 { if rref < 0 { hw("T2 PASS wired export: licensed reference writes glTF; off-tier export refused (no file)\n" as *u8) } else { hw("T2 FAIL off-tier export not blocked\n" as *u8); fp[0]=fp[0]+1 } }
72 else { hw("T2 FAIL licensed export did not produce glTF\n" as *u8); fp[0]=fp[0]+1 }
73
74 if fp[0] == 0 { hw("CHAR-ASSET-GATE GREEN -- nude model licensed standard->explicit, layered, delivered into art-coaching/games ONLY within contract; fail-closed\n" as *u8); sys_exit(0); return 0 }
75 hw("CHAR-ASSET-GATE RED fails="); pn(fp[0]); hw("\n" as *u8)
76 sys_exit(1); return 1
77}