code wiki / _hdl_build / nx_scribe_query_test.nx
nx_scribe_query_test.nx source
↩ module page · 44 lines · 3173 B
1// nx_scribe_query_test.nx -- the Scribe M2: query the crew's deliverable history for clarity +
2// efficiency metrics. Replays a real overnight self-heal conversation and asks it questions: verdict
3// counts, the doctor<->engineer handoff frequency, the last failure, the heal efficiency. Exit 0 if
4// the Scribe answers them all. license_tier: ORIGINAL
5
6import "nx_scribe_query.nx"
7import "nx_syscalls.nx"
8
9func qt_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
10func qt_num(v: i64) -> i64 { let bb: *u8 = sys_mmap(28); var m: i64=v; if m<0 {m=0-m}; let t: *u8 = sys_mmap(28); var k: i64=0; if m==0 {t[0]=48;k=1}; while m>0 {t[k]=48+(m%10); 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 }
11
12func main() -> i64 {
13 qt_puts("=== SCRIBE M2: query the deliverable history for clarity + efficiency metrics ===\n" as *u8)
14 // a real self-heal conversation: conductor->doctor build OK ; doctor->engineer HEALED ;
15 // engineer->doctor BAD ; doctor->engineer HEALED ; engineer->council OK ; council->conductor OK
16 let N: i64 = 6
17 let fr: *i64 = sys_mmap(8*8) as *i64; let to: *i64 = sys_mmap(8*8) as *i64; let vd: *i64 = sys_mmap(8*8) as *i64
18 fr[0]=ORG_CONDUCTOR; to[0]=ORG_DOCTOR; vd[0]=V_OK
19 fr[1]=ORG_DOCTOR; to[1]=ORG_ENGINEER; vd[1]=V_HEALED
20 fr[2]=ORG_ENGINEER; to[2]=ORG_DOCTOR; vd[2]=V_BAD
21 fr[3]=ORG_DOCTOR; to[3]=ORG_ENGINEER; vd[3]=V_HEALED
22 fr[4]=ORG_ENGINEER; to[4]=ORG_COUNCIL; vd[4]=V_OK
23 fr[5]=ORG_COUNCIL; to[5]=ORG_CONDUCTOR; vd[5]=V_OK
24
25 let ok: i64 = scq_count_verdict(N, vd, V_OK)
26 let bad: i64 = scq_count_verdict(N, vd, V_BAD)
27 let healed: i64 = scq_count_verdict(N, vd, V_HEALED)
28 let doc_eng: i64 = scq_count_handoff(N, fr, to, ORG_DOCTOR, ORG_ENGINEER)
29 let lastbad: i64 = scq_last(N, vd, V_BAD)
30 let heal_eff: i64 = scq_heal_efficiency(N, vd)
31 qt_puts(" verdicts: OK=" as *u8); qt_num(ok); qt_puts(" BAD=" as *u8); qt_num(bad); qt_puts(" HEALED=" as *u8); qt_num(healed); qt_puts("\n" as *u8)
32 qt_puts(" doctor->engineer handoffs=" as *u8); qt_num(doc_eng); qt_puts(" last failure at deliverable #" as *u8); qt_num(lastbad); qt_puts(" heal-efficiency=" as *u8); qt_num(heal_eff); qt_puts("/1000\n" as *u8)
33
34 let r: *i64 = sys_mmap(8*8) as *i64
35 r[0] = 0; if ok == 3 { if bad == 1 { if healed == 2 { r[0] = 1 } } } // verdict counts (clarity)
36 r[1] = 0; if doc_eng == 2 { r[1] = 1 } // handoff graph
37 r[2] = 0; if lastbad == 2 { r[2] = 1 } // triage the last failure
38 r[3] = 0; if heal_eff == 666 { r[3] = 1 } // 2 healed / 3 (2 healed + 1 bad) = 666
39 var pass: i64 = 0; var i: i64 = 0
40 while i < 4 { pass = pass + r[i]; i = i + 1 }
41 qt_puts("----\n passed " as *u8); qt_num(pass); qt_puts("/4\n" as *u8)
42 if pass == 4 { qt_puts(" SCRIBE LEVELED UP (M1->M2): the deliverable history is QUERYABLE -> clarity + efficiency metrics. No regression.\n" as *u8); sys_exit(0); return 0 }
43 qt_puts(" FAIL\n" as *u8); sys_exit(1); return 1
44}