code wiki / _hdl_build / nx_warden_build_test.nx
nx_warden_build_test.nx source
↩ module page · 111 lines · 5913 B
1// nx_warden_build_test.nx -- ENGINEER's gate for the Warden's one-command build: four REAL specs go
2// in as feature vectors + params; three covered shapes must come out ADMITTED with their authored
3// tests green and ZERO hand-driving between steps; the novel one must come out NEEDS_TUTOR (honest).
4// Batch autonomy must measure exactly 750 permil (3 of 4) -- measured, not asserted. license_tier: ORIGINAL
5import "nx_warden_build.nx"
6import "_pm_log_spec.nx"
7
8func wt_vec(a: i64, b: i64) -> *i64 {
9 let f: *i64 = plc_new_features()
10 if a >= 0 { f[a] = 1 }
11 if b >= 0 { f[b] = 1 }
12 return f
13}
14
15func main() -> i64 {
16 let p: *i64 = sys_mmap(64) as *i64
17 let out: *i64 = sys_mmap(32) as *i64
18 let pats: *i64 = sys_mmap(128) as *i64
19 var pass: i64 = 0
20 // spec 1: litho dose window verdict (180..230) -- the jam_check/dose shape
21 p[0] = 180; p[1] = 230
22 var st: i64 = wb_build(wt_vec(PLC_OUT_VERDICT, 0-1), "_wb_dose" as *u8, p, out)
23 wb_report("_wb_dose" as *u8, out[0], st, out[2])
24 pats[0] = out[0]
25 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
26 // spec 2: NAS-pull pacing governor (2s gap, 250ms base backoff, 16s cap)
27 p[0] = 2000; p[1] = 250; p[2] = 16000
28 st = wb_build(wt_vec(PLC_HAS_TIME, PLC_IN_STATE), "_wb_pace" as *u8, p, out)
29 wb_report("_wb_pace" as *u8, out[0], st, out[2])
30 pats[1] = out[0]
31 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
32 // spec 3: oven PI loop (kp=2000 ki=20 imax=10000 -- sim-preflighted gains)
33 p[0] = 2000; p[1] = 20; p[2] = 10000
34 st = wb_build(wt_vec(PLC_HAS_PLANT, PLC_IN_STATE), "_wb_oven" as *u8, p, out)
35 wb_report("_wb_oven" as *u8, out[0], st, out[2])
36 pats[2] = out[0]
37 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
38 // spec 4: TLS-extension walker (framed binary, type-first, 2-byte type + 2-byte length) --
39 // shape 12 WIRE_TLV, first route through the one-command dispatch
40 p[0] = 2; p[1] = 2; p[2] = 1
41 st = wb_build(wt_vec(PLC_IN_FRAMED, 0-1), "_wb_ext" as *u8, p, out)
42 wb_report("_wb_ext" as *u8, out[0], st, out[2])
43 pats[3] = out[0]
44 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
45 // spec 5: ClientHello-style field sequence (version FIXED2, random FIXED32, session VAR8,
46 // ciphers VAR16, then the mandatory kind-3 REST terminator pe8's refusal rail requires) --
47 // shape 13 STRUCT_WALK from its field table
48 let kinds: *i64 = sys_mmap(64) as *i64
49 let widths: *i64 = sys_mmap(64) as *i64
50 kinds[0]=0; widths[0]=2
51 kinds[1]=0; widths[1]=32
52 kinds[2]=1; widths[2]=0
53 kinds[3]=2; widths[3]=0
54 kinds[4]=3; widths[4]=0
55 p[0] = kinds as i64; p[1] = widths as i64; p[2] = 5
56 st = wb_build(wt_vec(PLC_IN_FRAMED, PLC_IN_TABLE), "_wb_walk" as *u8, p, out)
57 wb_report("_wb_walk" as *u8, out[0], st, out[2])
58 pats[4] = out[0]
59 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
60 // spec 6: JPEG marker walker (0xFF prefix, SOI/EOI/RSTn standalone, SOS terminator) --
61 // shape 15 WIRE_MARKER, the shape the sync gate caught live on its first pulse beat
62 let sa: *i64 = sys_mmap(128) as *i64
63 sa[0] = 10
64 sa[1] = 0xD8; sa[2] = 0xD9
65 sa[3] = 0xD0; sa[4] = 0xD1; sa[5] = 0xD2; sa[6] = 0xD3
66 sa[7] = 0xD4; sa[8] = 0xD5; sa[9] = 0xD6; sa[10] = 0xD7
67 p[0] = 0xFF; p[1] = sa as i64; p[2] = 0xDA
68 st = wb_build(wt_vec(PLC_IN_MARKED, 0-1), "_wb_jpeg" as *u8, p, out)
69 wb_report("_wb_jpeg" as *u8, out[0], st, out[2])
70 pats[5] = out[0]
71 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
72 // spec 7: NV1 LPC residual coder (order 2, Int16 bound) -- shape 16 PREDICTOR_CODER, grown
73 // from the NV2 FLAC-class rung the library could not author; first route through dispatch
74 p[0] = 2; p[1] = 32767
75 st = wb_build(wt_vec(PLC_IN_ARRAY, PLC_HAS_INVERSE), "_wb_lpc" as *u8, p, out)
76 wb_report("_wb_lpc" as *u8, out[0], st, out[2])
77 pats[6] = out[0]
78 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
79 // spec 8: CMS block renderer rows (escaped <p>, raw <b>) -- shape 17
80 // TEMPLATE_TABLE, the route that mis-verdicted REJECTED before wiring.
81 // mid = NULL (0) for single-slot rows -- the ""-literal aliasing landmine.
82 let tt: *i64 = sys_mmap(128) as *i64
83 tt[0]=1; tt[1]="<p>" as *u8 as i64; tt[2]=0; tt[3]="</p>" as *u8 as i64; tt[4]=0
84 tt[5]=2; tt[6]="<b>" as *u8 as i64; tt[7]=0; tt[8]="</b>" as *u8 as i64; tt[9]=1
85 p[0] = tt as i64; p[1] = 2
86 st = wb_build(wt_vec(PLC_IN_TABLE, PLC_IN_BYTES), "_wb_tmpl" as *u8, p, out)
87 wb_report("_wb_tmpl" as *u8, out[0], st, out[2])
88 pats[7] = out[0]
89 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
90 // spec 9: f64 natural log from the REAL oracle spec (_pm_log_spec,
91 // mpmath@60dps) -- shape 11 MATH_KERNEL, the paid "bespoke modfile" debt
92 let c6: *i64 = sys_mmap(8 * 32) as *i64
93 let nco: i64 = pm_log_spec_fill(c6)
94 p[0] = c6 as i64; p[1] = nco
95 st = wb_build(wt_vec(PLC_IN_COEFFS, PLC_OUT_VALUE), "_wb_mathk" as *u8, p, out)
96 wb_report("_wb_mathk" as *u8, out[0], st, out[2])
97 pats[8] = out[0]
98 if st == BP_ADMITTED { if out[2] == 1 { pass = pass + 1 } }
99 // spec 10: a pure value function with no recognized trait (a hash) -> NOVEL, NEEDS_TUTOR, honest
100 st = wb_build(wt_vec(PLC_OUT_VALUE, 0-1), "_wb_hash" as *u8, p, out)
101 wb_report("_wb_hash" as *u8, out[0], st, out[2])
102 pats[9] = out[0]
103 if st == BP_NEEDS_TUTOR { if out[1] == 0 { pass = pass + 1 } }
104 // the batch autonomy METER: exactly 9 of 10 hands-off
105 if bp_autonomy_permil(pats, 10) == 900 { pass = pass + 1 }
106
107 wb_w(1, "WARDEN ONE-COMMAND BUILD: passed=" as *u8); wb_wn(1, pass); wb_w(1, "/11 (9 specs ADMITTED hands-off incl. TEMPLATE_TABLE+MATH_KERNEL newly wired, 1 honest NEEDS_TUTOR, autonomy=900)\n" as *u8)
108 if pass == 11 { sys_exit(0) }
109 sys_exit(1)
110 return 1
111}