code wiki / _hdl_build / nx_elara_prompt_probe.nx
nx_elara_prompt_probe.nx source
↩ module page · 84 lines · 5488 B
1// nx_elara_prompt_probe.nx -- GPU-FREE verification of the chat photo-prompt composition.
2// Runs the REAL composer (go_compose_photo_prompt: trigger -> camera -> body, SHARED with the daemon) against the REAL
3// data files, so it proves the CODE and the DATA together. Run it from /volume1/ai/gen (the daemon's
4// cwd) -- the loaders read elara_appearance.txt / elara_shots.txt / elara_quality.txt RELATIVE to cwd,
5// so running it anywhere else silently exercises the baked defaults instead of what actually ships.
6// license_tier: ORIGINAL
7import "nx_syscalls.nx"
8import "nx_companion_identity.nx"
9import "nx_companion_wardrobe.nx"
10const K_MAGIC_16384: i64 = 16384
11
12func pr(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1, s, n); return n }
13func pr_num(v: i64) -> i64 { let t: *u8 = sys_mmap(28); var m: i64 = v; 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 } let o: *u8 = sys_mmap(28); var q: i64 = 0; while k>0 { k=k-1; o[q]=t[k]; q=q+1 } o[q]=0 as u8; return pr(o) }
14
15func compose(scene: *u8, seed: i64, out: *u8) -> i64 {
16 // ONE COMPOSER (2026-08-27): the probe calls the SAME go_compose_photo_prompt the daemon's chat photo path
17 // calls (nx_companion_wardrobe.nx), so this can no longer pass on an order the daemon does not use.
18 let expr: *u8 = sys_mmap(256); expr[0]=0 as u8
19 var sl: i64 = 0; while scene[sl]!=(0 as u8) { sl=sl+1 }
20 return go_compose_photo_prompt(scene, sl, expr, seed, out)
21}
22
23func main() -> i64 {
24 let out: *u8 = sys_mmap(K_MAGIC_16384)
25 pr("=== ELARA PHOTO-PROMPT PROBE (cwd-sensitive; run from /volume1/ai/gen) ===\n" as *u8)
26
27 pr("\n--- seed 0 : clothed scene ---\n" as *u8)
28 compose("at a cafe in a sundress" as *u8, 0, out); pr(out); pr("\n" as *u8)
29
30 pr("\n--- seed 6 : rear/over-shoulder shot line (variety check) ---\n" as *u8)
31 compose("walking on the beach" as *u8, 6, out); pr(out); pr("\n" as *u8)
32
33 pr("\n--- seed 9 : POV shot line ---\n" as *u8)
34 compose("in the kitchen making coffee" as *u8, 9, out); pr(out); pr("\n" as *u8)
35
36 pr("\n=== CHECKS ===\n" as *u8)
37 var fail: i64 = 0
38 compose("at a cafe in a sundress" as *u8, 0, out)
39 // T1: the REAL slot order -- the realism trigger (elara_trigger.txt, or the baked June default) must LEAD
40 // byte-for-byte when present, and the camera line must follow it immediately; with a BLANK trigger file the
41 // camera line must lead (the 2026-08-06 order). Either way "photograph of Elara" never comes first.
42 let trig: *u8 = sys_mmap(512); let tl: i64 = go_load_trigger(trig, 512)
43 pr("trigger_len=" as *u8); pr_num(tl); pr("\n" as *u8)
44 var t1: i64 = 1
45 if tl > 0 { var ti: i64 = 0; while ti < tl { if out[ti]!=trig[ti] { t1=0; ti=tl } ti=ti+1 } }
46 if t1==1 { if cw_contains_ci(out, tl+60, "close framing" as *u8)==0 { t1=0 } }
47 if t1==1 { pr("T1 trigger-then-camera PASS\n" as *u8) }
48 else { pr("T1 trigger-then-camera FAIL\n" as *u8); fail=1 }
49 var ol: i64 = 0; while out[ol]!=(0 as u8) { ol=ol+1 }
50 // T2: the retired booru tail must be GONE
51 if cw_contains_ci(out, ol, "photorealistic" as *u8)==0 { pr("T2 no booru tail PASS\n" as *u8) }
52 else { pr("T2 no booru tail FAIL\n" as *u8); fail=1 }
53 if cw_contains_ci(out, ol, "8k" as *u8)==0 { pr("T3 no 8k PASS\n" as *u8) }
54 else { pr("T3 no 8k FAIL\n" as *u8); fail=1 }
55 // T4: identity must still be present (never strip the anchor)
56 if cw_contains_ci(out, ol, "Elara" as *u8)==1 { pr("T4 identity present PASS\n" as *u8) }
57 else { pr("T4 identity present FAIL\n" as *u8); fail=1 }
58 // T5: the quality tail must be present
59 if cw_contains_ci(out, ol, "dewy" as *u8)==1 { pr("T5 quality tail PASS\n" as *u8) }
60 else { pr("T5 quality tail FAIL\n" as *u8); fail=1 }
61 // T6: wardrobe occlusion assertion still fires on a clothed scene
62 if cw_contains_ci(out, ol, "completely covers" as *u8)==1 { pr("T6 occlusion assert PASS\n" as *u8) }
63 else { pr("T6 occlusion assert FAIL\n" as *u8); fail=1 }
64 // T7: NON-VACUITY -- a nude scene must take the OTHER branch, else T6 proves nothing
65 compose("completely nude in the shower" as *u8, 0, out)
66 var nl: i64 = 0; while out[nl]!=(0 as u8) { nl=nl+1 }
67 if cw_contains_ci(out, nl, "completely bare" as *u8)==1 { pr("T7 opposite branch PASS\n" as *u8) }
68 else { pr("T7 opposite branch FAIL\n" as *u8); fail=1 }
69 // T8: shot variety -- seed 0 and seed 6 must differ
70 let a: *u8 = sys_mmap(K_MAGIC_16384); let b: *u8 = sys_mmap(K_MAGIC_16384)
71 compose("at a cafe" as *u8, 0, a); compose("at a cafe" as *u8, 6, b)
72 // compare the 60 bytes AFTER the trigger prefix: the prefix is identical by design for every seed, so a
73 // window starting at 0 would read two different shot lines as "the same" (measured 2026-08-27: T8 went
74 // RED the moment the trigger led the prompt, while the printed prompts above plainly differed).
75 let tq: *u8 = sys_mmap(512); let tql: i64 = go_load_trigger(tq, 512)
76 var skip: i64 = 0; if tql > 0 { skip = tql + 2 }
77 var same: i64 = 1; var i: i64 = 0
78 while i < 60 { if a[skip+i]!=b[skip+i] { same=0; i=60 } i=i+1 }
79 if same==0 { pr("T8 shot variety PASS\n" as *u8) }
80 else { pr("T8 shot variety FAIL\n" as *u8); fail=1 }
81
82 if fail==0 { pr("\nPROBE VERDICT=GREEN 8/8\n" as *u8) } else { pr("\nPROBE VERDICT=RED\n" as *u8) }
83 return fail
84}