code wiki / (root) / nx_identity_persist_gate.nx

nx_identity_persist_gate.nx source

↩ module page · 62 lines · 4974 B

1// nx_identity_persist_gate.nx -- GATE for nx_identity_persist: the sovereign drift-catcher rejects a 2// wrong-identity prompt BEFORE a gen is wasted, mirroring the old triangulation panel (disasters.json). Proves: 3// (T1) canonical Elara PRESERVED (2/2); (T2) MY EXACT BRUNETTE ERROR caught (chestnut/brunette/dark -> hair drift); 4// (T3) wrong-subject-but-blonde caught (missing Nata Lee -> caption drift); (T4) the asian-drift disaster caught 5// (dark hair + no identity tokens); (T5) no FALSE drift on the canonical. Sovereign, no 3rd-party face lib. 6// license_tier: ORIGINAL expect_exit: 0 7import "nx_identity_persist.nx" 8import "nx_gate_verdict.nx" 9 10// Elara's canonical identity SPEC (data, rule 11): required identity tokens + forbidden (non-blonde) hair terms. 11const ELARA_REQ: *u8 = "blonde|Nata Lee" as *u8 12const ELARA_FORBID: *u8 = "brunette|chestnut|dark hair|dark-haired|black hair|raven|redhead|red hair|ginger|auburn|brown hair" as *u8 13 14func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 15func gn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} 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(1,bb,k); return 0 } 16func gl(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } 17 18func main() -> i64 { 19 gw("=== nx_identity_persist_gate (sovereign drift-catcher -- the #1 media-gen guardrail) ===\n" as *u8) 20 var pass: i64 = 0 21 var tot: i64 = 0 22 let o: *i64 = sys_mmap(16) as *i64 23 24 // T1 canonical Elara -> PRESERVED (2/2) 25 tot=tot+1 26 let CANON: *u8 = "Elara, eighteen, the face of Nata Lee, a slim petite frame, long warm golden platinum-blonde hair with sun-bleached highlights, faint freckles, wearing a band tee, in her cozy bedroom" as *u8 27 let v1: i64 = idp_prompt_verdict(CANON, gl(CANON), ELARA_REQ, ELARA_FORBID, o) 28 if v1==2 { if o[0]==1 { if o[1]==1 { pass=pass+1; gw("PASS T1 canonical Elara -> PRESERVED 2/2 (hair_ok, caption_ok)\n" as *u8) } else {gw("FAIL T1 cap\n" as *u8)} } else {gw("FAIL T1 hair\n" as *u8)} } else { gw("FAIL T1 v=" as *u8); gn(v1); gw("\n" as *u8) } 29 30 // T2 MY BRUNETTE ERROR -> DRIFT (hair fails) 31 tot=tot+1 32 let BRUN: *u8 = "Elara, the face of Nata Lee, long dark chestnut beach-wave brunette hair, heart-shape face, wearing a tee" as *u8 33 let v2: i64 = idp_prompt_verdict(BRUN, gl(BRUN), ELARA_REQ, ELARA_FORBID, o) 34 if o[0]==0 { if v2<2 { pass=pass+1; gw("PASS T2 the brunette error CAUGHT: hair_ok=0 -> DRIFT (chestnut/brunette/dark)\n" as *u8) } else {gw("FAIL T2 v=" as *u8); gn(v2); gw("\n" as *u8)} } else { gw("FAIL T2 hair_ok=" as *u8); gn(o[0]); gw(" (missed the drift!)\n" as *u8) } 35 36 // T3 wrong subject but blonde -> DRIFT (caption fails: no Nata Lee) 37 tot=tot+1 38 let WRONG: *u8 = "a blonde woman relaxing on a bed in soft light, photograph" as *u8 39 let v3: i64 = idp_prompt_verdict(WRONG, gl(WRONG), ELARA_REQ, ELARA_FORBID, o) 40 if o[1]==0 { if v3<2 { pass=pass+1; gw("PASS T3 wrong-subject (blonde but not Elara) CAUGHT: caption_ok=0 -> DRIFT (no Nata Lee)\n" as *u8) } else {gw("FAIL T3 v=" as *u8); gn(v3); gw("\n" as *u8)} } else { gw("FAIL T3 caption_ok=" as *u8); gn(o[1]); gw("\n" as *u8) } 41 42 // T4 the asian-drift disaster (disasters.json) -> DRIFT (both fail) 43 tot=tot+1 44 let ASIAN: *u8 = "an asian woman with dark hair lying back with dappled window light" as *u8 45 let v4: i64 = idp_prompt_verdict(ASIAN, gl(ASIAN), ELARA_REQ, ELARA_FORBID, o) 46 if v4==0 { pass=pass+1; gw("PASS T4 asian-drift disaster CAUGHT: 0/2 (dark hair + no identity tokens)\n" as *u8) } else { gw("FAIL T4 v=" as *u8); gn(v4); gw(" hair=" as *u8); gn(o[0]); gw(" cap=" as *u8); gn(o[1]); gw("\n" as *u8) } 47 48 // T5 no FALSE drift on the canonical (idp_prompt_ok) 49 tot=tot+1 50 if idp_prompt_ok(CANON, gl(CANON), ELARA_REQ, ELARA_FORBID)==1 { if idp_prompt_ok(BRUN, gl(BRUN), ELARA_REQ, ELARA_FORBID)==0 { pass=pass+1; gw("PASS T5 gate discipline: canonical OK=1, brunette OK=0 (no false drift, real drift caught)\n" as *u8) } else {gw("FAIL T5 brunette passed!\n" as *u8)} } else { gw("FAIL T5 canonical falsely flagged\n" as *u8) } 51 52 gw("nx_identity_persist_gate pass=" as *u8); gn(pass); gw("/" as *u8); gn(tot) 53 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 54 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 55 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 56 let ctr__dry: *i64 = gv_ctr() 57 ctr__dry[0] = pass 58 ctr__dry[1] = tot 59 let rc__dry: i64 = gv_verdict("IDENTITY-PERSIST-GATE" as *u8, ctr__dry, "a good-quality WRONG-PERSON image is now rejected at the prompt -- the old #1 failure, caught sovereignly)" as *u8) 60 sys_exit(rc__dry) 61 return rc__dry 62}