code wiki / (root) / nx_visual_arc_gate.nx

nx_visual_arc_gate.nx source

↩ module page · 130 lines · 9380 B

1// nx_visual_arc_gate.nx -- GATE for nx_visual_arc: proves the "clothes stayed the same, arcs never shifted" 2// defect is FIXED. (T1) identity anchor CONSTANT across the whole arc -- always the same person; (T2) advancing 3// the arc SHIFTS the outfit -- clothes change; (T3) ODOMETER -- the first nO*nS steps produce all-distinct 4// (outfit,scene) pairs, no premature repeat; (T4) scenes shift after the wardrobe cycles; (T5) deterministic -- 5// same step, same prompt; (T6) DEFECT REGRESSION -- pinned to step 0 (the old default-outfit behavior) the 6// outfit never changes, but advancing yields 5 distinct outfits over 5 steps; (T7) the stateful advance works 7// and matches the pure function; (T8) per-persona grounding -- two personas keep their own identity + closet. 8// Timestamp-fresh /tmp store. license_tier: ORIGINAL expect_exit: 0 9import "nx_visual_arc.nx" 10import "nx_gate_verdict.nx" 11 12func vw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 13func vn(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 } 14func vfind(hay: *u8, hlen: i64, needle: *u8) -> i64 { 15 var nl: i64=0; while needle[nl]!=(0 as u8){nl=nl+1} 16 if nl==0 { return 1 } 17 if hlen<nl { return 0 } 18 var i: i64=0 19 while i<=hlen-nl { var m: i64=1; var c: i64=0; while c<nl { if hay[i+c]!=needle[c]{m=0;c=nl} else {c=c+1} } if m==1 {return 1} i=i+1 } 20 return 0 21} 22func vpeq(a: *u8, al: i64, b: *u8, bl: i64) -> i64 { if al!=bl {return 0} var i: i64=0; while i<al { if a[i]!=b[i]{return 0} i=i+1 } return 1 } 23 24func main() -> i64 { 25 vw("=== nx_visual_arc_gate (FIX: 'clothes stayed the same, arcs never shifted') ===\n" as *u8) 26 let VP: *u8 = sys_mmap(256) 27 var po: i64=0; var i: i64=0; let pre: *u8="/tmp/varc-test-" as *u8; while pre[i]!=(0 as u8){VP[po]=pre[i];po=po+1;i=i+1} 28 var ms: i64 = sys_now_ms() % 100000000; var dd: i64=7; while dd>=0 { VP[po+dd]=(48+(ms%10)) as u8; ms=ms/10; dd=dd-1 } po=po+8 29 VP[po]=0x2D as u8; po=po+1; VP[po]=0 as u8 30 31 // Aria: naturist -- her closet reflects her nature (rule 25, no censor). nO=5 nS=4 nA=4. 32 vid_put_pfx(VP, "aria" as *u8, 33 "Aria, twenty-two, long dark chestnut beach-wave hair center part, heart-shape face high cheekbones, heavy-lidded hazel eyes, full natural figure, fair freckled skin, a beauty mark near her lip" as *u8, 34 "wearing a loose oversized cotton tee|wearing a sheer sundress|natural and unclothed, at ease in her own skin|wearing a silk robe loosely tied|wearing a tiny bikini" as *u8, 35 "in a sunlit bedroom by the window|in a golden-hour garden among the gardenias|in a warm kitchen at morning|on a quiet beach at dawn" as *u8, 36 "curled up reading|stretching lazily in the light|laughing over her shoulder|reaching toward you" as *u8) 37 38 var pass: i64 = 0 39 var tot: i64 = 0 40 let idx: *i64 = sys_mmap(32) as *i64 41 let a: *u8 = sys_mmap(8192); let b: *u8 = sys_mmap(8192) 42 43 // T1 identity CONSTANT across the arc 44 tot=tot+1 45 let la: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 0, a, 8192) 46 let lb: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 37, b, 8192) 47 if vfind(a, la, "chestnut" as *u8)==1 { if vfind(b, lb, "chestnut" as *u8)==1 { pass=pass+1; vw("PASS T1 identity CONSTANT: 'chestnut'-haired Aria present at step 0 AND step 37 (same person)\n" as *u8) } else { vw("FAIL T1 step37\n" as *u8) } } else { vw("FAIL T1 step0\n" as *u8) } 48 49 // T2 outfit SHIFTS (the core fix) 50 tot=tot+1 51 varc_indices_pfx(VP, "aria" as *u8, 0, idx); let o0: i64 = idx[0] 52 varc_indices_pfx(VP, "aria" as *u8, 1, idx); let o1: i64 = idx[0] 53 var t2: i64 = 0 54 if o0 != o1 { if vfind(a, la, "oversized cotton tee" as *u8)==1 { varc_prompt_at_pfx(VP, "aria" as *u8, 1, b, 8192); if vfind(b, lb, "sheer sundress" as *u8)==1 { t2=1 } } } 55 if t2==1 { pass=pass+1; vw("PASS T2 outfit SHIFTS: step0=cotton tee, step1=sheer sundress (clothes change)\n" as *u8) } else { vw("FAIL T2 o0=" as *u8); vn(o0); vw(" o1=" as *u8); vn(o1); vw("\n" as *u8) } 56 57 // T3 ODOMETER: first nO*nS=20 steps -> 20 distinct (outfit,scene) pairs (no premature repeat) 58 tot=tot+1 59 let seen: *i64 = sys_mmap(8*32) as *i64 60 var nseen: i64 = 0 61 var s: i64 = 0 62 var distinct: i64 = 1 63 while s < 20 { 64 varc_indices_pfx(VP, "aria" as *u8, s, idx) 65 let key: i64 = idx[0]*4 + idx[1] 66 var dup: i64 = 0; var j: i64 = 0; while j < nseen { if seen[j]==key { dup=1 } j=j+1 } 67 if dup==1 { distinct=0 } else { seen[nseen]=key; nseen=nseen+1 } 68 s = s + 1 69 } 70 if distinct==1 { if nseen==20 { pass=pass+1; vw("PASS T3 odometer: 20 steps -> 20 DISTINCT (outfit,scene) pairs, no repeat\n" as *u8) } else { vw("FAIL T3 nseen=" as *u8); vn(nseen); vw("\n" as *u8) } } else { vw("FAIL T3 early repeat\n" as *u8) } 71 72 // T4 scene shifts after the wardrobe cycles (step 0 scene vs step 5 scene) 73 tot=tot+1 74 varc_indices_pfx(VP, "aria" as *u8, 0, idx); let sc0: i64 = idx[1] 75 varc_indices_pfx(VP, "aria" as *u8, 5, idx); let sc5: i64 = idx[1] 76 if sc0 != sc5 { pass=pass+1; vw("PASS T4 scene shifts: after the 5 outfits cycle, the scene advances (arc moves)\n" as *u8) } else { vw("FAIL T4 sc0=" as *u8); vn(sc0); vw(" sc5=" as *u8); vn(sc5); vw("\n" as *u8) } 77 78 // T5 deterministic 79 tot=tot+1 80 let l1: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 7, a, 8192) 81 let l2: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 7, b, 8192) 82 if vpeq(a, l1, b, l2)==1 { pass=pass+1; vw("PASS T5 deterministic: same step -> byte-identical prompt (reproducible)\n" as *u8) } else { vw("FAIL T5\n" as *u8) } 83 84 // T6 DEFECT REGRESSION: pinned to step 0 = same outfit forever (the OLD bug); advancing = all distinct 85 tot=tot+1 86 var pinned_distinct: i64 = 0 87 let pseen: *i64 = sys_mmap(8*8) as *i64; var pn: i64 = 0 88 var st: i64 = 0 89 while st < 5 { varc_indices_pfx(VP, "aria" as *u8, 0, idx); let o: i64 = idx[0]; var d: i64=0; var j: i64=0; while j<pn { if pseen[j]==o {d=1} j=j+1 } if d==0 { pseen[pn]=o; pn=pn+1 } st=st+1 } 90 pinned_distinct = pn // pinned to step 0 -> only 1 distinct outfit (the bug) 91 var adv_distinct: i64 = 0 92 let aseen: *i64 = sys_mmap(8*8) as *i64; var an: i64 = 0 93 st = 0 94 while st < 5 { varc_indices_pfx(VP, "aria" as *u8, st, idx); let o: i64 = idx[0]; var d: i64=0; var j: i64=0; while j<an { if aseen[j]==o {d=1} j=j+1 } if d==0 { aseen[an]=o; an=an+1 } st=st+1 } 95 adv_distinct = an // advancing -> 5 distinct outfits (the fix) 96 if pinned_distinct==1 { if adv_distinct==5 { pass=pass+1; vw("PASS T6 DEFECT vs FIX: pinned-to-step-0 = 1 outfit (old bug); advancing = 5 distinct outfits over 5 steps (fixed)\n" as *u8) } else { vw("FAIL T6 adv=" as *u8); vn(adv_distinct); vw("\n" as *u8) } } else { vw("FAIL T6 pinned=" as *u8); vn(pinned_distinct); vw("\n" as *u8) } 97 98 // T7 stateful advance matches the pure function 99 tot=tot+1 100 varc_reset_pfx(VP, "aria" as *u8) 101 varc_advance_pfx(VP, "aria" as *u8); varc_advance_pfx(VP, "aria" as *u8); varc_advance_pfx(VP, "aria" as *u8) 102 let curstep: i64 = varc_step_pfx(VP, "aria" as *u8) 103 let lc: i64 = varc_prompt_pfx(VP, "aria" as *u8, a, 8192) 104 let ld: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 3, b, 8192) 105 if curstep==3 { if vpeq(a, lc, b, ld)==1 { pass=pass+1; vw("PASS T7 stateful advance: 3 advances -> step 3, current prompt == prompt_at(3)\n" as *u8) } else { vw("FAIL T7 prompt mismatch\n" as *u8) } } else { vw("FAIL T7 step=" as *u8); vn(curstep); vw("\n" as *u8) } 106 107 // T8 per-persona grounding: a second persona keeps her own identity + closet 108 tot=tot+1 109 vid_put_pfx(VP, "vera" as *u8, 110 "Vera, reserved, dark hair in a low bun, grey eyes, slender, understated" as *u8, 111 "wearing a high-neck wool sweater and long skirt|wearing a tailored blouse buttoned to the collar" as *u8, 112 "in a book-lined study|by a rain-streaked window" as *u8, 113 "reading in an armchair|writing at her desk" as *u8) 114 let lv: i64 = varc_prompt_at_pfx(VP, "vera" as *u8, 0, b, 8192) 115 let laa: i64 = varc_prompt_at_pfx(VP, "aria" as *u8, 0, a, 8192) 116 var t8: i64 = 0 117 if vfind(b, lv, "grey eyes" as *u8)==1 { if vfind(b, lv, "chestnut" as *u8)==0 { if vfind(a, laa, "chestnut" as *u8)==1 { t8=1 } } } 118 if t8==1 { pass=pass+1; vw("PASS T8 per-persona grounding: Vera keeps her own identity+modest closet; no bleed from Aria\n" as *u8) } else { vw("FAIL T8\n" as *u8) } 119 120 vw("nx_visual_arc_gate pass=" as *u8); vn(pass); vw("/" as *u8); vn(tot) 121 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check 122 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled 123 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify. 124 let ctr__dry: *i64 = gv_ctr() 125 ctr__dry[0] = pass 126 ctr__dry[1] = tot 127 let rc__dry: i64 = gv_verdict("VISUAL-ARC-GATE" as *u8, ctr__dry, "same person, grounded in our scenes; outfit+scene+pose SHIFT every step -- the defect is fixed)" as *u8) 128 sys_exit(rc__dry) 129 return rc__dry 130}