code wiki / _hdl_build / nx_brand_voice_gate.nx
nx_brand_voice_gate.nx source
↩ module page · 49 lines · 3071 B
1// nx_brand_voice_gate.nx -- brand voice tokens resolve + the clarity check flags run-on copy. 100% sovereign.
2// expect_exit: 0
3import "nx_syscalls.nx"
4import "nx_brand_voice.nx"
5import "nx_gate_verdict.nx"
6
7func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
8func gn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} 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 }
9func t_row(name: *u8, ok: i64, tot: *i64) -> i64 {
10 if ok == 1 { gw(" PASS " as *u8); tot[0]=tot[0]+1 } else { gw(" FAIL " as *u8); tot[1]=tot[1]+1 }
11 gw(name); gw("\n" as *u8); return 0
12}
13func g_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while a[i]!=(0 as u8){ if a[i]!=b[i] { return 0 } i=i+1 } if b[i]!=(0 as u8){ return 0 } return 1 }
14func g_len(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n }
15
16func main() -> i64 {
17 let tot: *i64 = sys_mmap(32) as *i64
18 tot[0]=0; tot[1]=0
19 gw("=== nx_brand_voice_gate -- brand voice & tone guidelines + clarity check ===\n" as *u8)
20
21 let vb: *u8 = "voice|tone|professional-warm\nvoice|reading-grade|8\nvoice|person|second\n" as *u8
22 let vn: i64 = g_len(vb)
23 let out: *u8 = sys_mmap(64)
24 bv_lookup(vb, vn, "tone" as *u8, out, 64)
25 t_row("V1 voice token resolves (voice|tone -> professional-warm)" as *u8, g_streq(out, "professional-warm" as *u8), tot)
26
27 let clear: *u8 = "We help families. You make one call. We handle the rest." as *u8
28 let cl: i64 = bv_longest_sentence_words(clear, g_len(clear))
29 gw(" clear copy longest sentence = " as *u8); gn(cl); gw(" words\n" as *u8)
30 t_row("V2 clear copy passes the clarity check (<=12 words/sentence)" as *u8, bv_clarity_ok(clear, g_len(clear), 12), tot)
31
32 let runon: *u8 = "We are a comprehensive full service law firm that handles every conceivable matter for families and businesses across the entire state without exception" as *u8
33 let rl: i64 = bv_longest_sentence_words(runon, g_len(runon))
34 gw(" run-on copy longest sentence = " as *u8); gn(rl); gw(" words\n" as *u8)
35 var v3: i64 = 0
36 if bv_clarity_ok(runon, g_len(runon), 12) == 0 { v3 = 1 }
37 t_row("V3 run-on copy is FLAGGED (>12 words/sentence)" as *u8, v3, tot)
38
39 gw("\nrows pass=" as *u8); gn(tot[0]); gw(" fail=" as *u8); gn(tot[1]); gw("\n" as *u8)
40 // MIGRATED onto nx_gate_verdict by nx_gate_dry_apply (D001, minimal form): every check
41 // row above is untouched, so the PASS/FAIL vector cannot change; only the hand-rolled
42 // verdict emission is replaced by the ONE shared base class. Proven by nx_gate_migrate verify.
43 let ctr__dry: *i64 = gv_ctr()
44 ctr__dry[0] = tot[0]
45 ctr__dry[1] = tot[0] + tot[1]
46 let rc__dry: i64 = gv_verdict("BRAND-VOICE-GATE" as *u8, ctr__dry, "brand voice guidelines (data) + clarity check work (deep tone = the Writer arc)" as *u8)
47 sys_exit(rc__dry)
48 return rc__dry
49}