code wiki / _hdl_build / nx_aesthetic_canon_gate.nx
nx_aesthetic_canon_gate.nx source
↩ module page · 107 lines · 7033 B
1// nx_aesthetic_canon_gate.nx -- GATE for aesthetictwin rung AT1 (the evidence-graded aesthetic canon)
2// and AT7 (the pelvic-bone floor under the waist), proven END TO END against the PROMOTED nx_body_proc.
3//
4// THE LOAD-BEARING TEETH ARE THE TWO NEG-CONTROLS: a canon row whose refkey does not resolve REFUSES
5// BY NAME, and a waist dialled below the model's own bone REFUSES rather than emitting. Both are proven
6// on the SHIPPED binary with fixtures ASSEMBLED AT RUNTIME in /tmp (the fixture-ratchet law: a detector
7// that scans source will find its own test fixture, and a production conf is never the gate's fixture).
8// POSITIVE CONTROLS ARE NOT OPTIONAL: a deny-guard with no firing positive control passes every negative
9// test while wholly broken -- so T1 grades the LIVE canon, T5 proves a fixture canon CAN pass, and T6
10// proves the floor passes the real conf before T7 proves it bites a doctored one.
11// T8 is the derivation tooth: the floor must MOVE when the conf moves, or it is a typed number wearing
12// a function.
13import "nx_syscalls.nx"
14import "nx_gate_verdict.nx"
15import "nx_gatekit_lib.nx"
16
17const AG_DIR: *u8 = "/tmp/nx_aesthetic_canon_gate" as *u8
18const AG_REFS: *u8 = "/tmp/nx_aesthetic_canon_gate/refs.txt" as *u8
19const AG_BADKEY: *u8 = "/tmp/nx_aesthetic_canon_gate/badkey.conf" as *u8
20const AG_REFTGT: *u8 = "/tmp/nx_aesthetic_canon_gate/refutedtarget.conf" as *u8
21const AG_GOOD: *u8 = "/tmp/nx_aesthetic_canon_gate/good.conf" as *u8
22const AG_DIMLOW: *u8 = "/tmp/nx_aesthetic_canon_gate/dim_low.conf" as *u8
23const AG_DIMBIG13: *u8 = "/tmp/nx_aesthetic_canon_gate/dim_big13.conf" as *u8
24const AG_ELF: *u8 = "./nx_body_proc.elf" as *u8
25const AG_CAP: i64 = 262144
26const AG_ABSENT: i64 = 0 - 999999
27
28func ag_num_after(buf: *u8, n: i64, tag: *u8) -> i64 {
29 let p: i64 = gk_out_pos(buf, n, tag)
30 if p < 0 { return AG_ABSENT }
31 var i: i64 = p + gk_len(tag)
32 var v: i64 = 0
33 var any: i64 = 0
34 var go: i64 = 1
35 while go == 1 {
36 if i >= n { go = 0 } else {
37 let c: i64 = buf[i] as i64
38 if c >= 48 { if c <= 57 { v = v*10 + (c-48); any = 1; i = i + 1 } else { go = 0 } } else { go = 0 }
39 }
40 }
41 if any == 0 { return AG_ABSENT }
42 return v
43}
44func main(argc: i64, argv: *i64) -> i64 {
45 // THE SUBJECT COMES FROM argv[1] WHEN GIVEN: nx_gate_bite rebuilds the subject per mutant and hands
46 // its path here. A gate that ignores argv judges the PROMOTED binary on every mutant and reports
47 // SURVIVED forever -- measured on this very gate's first three bite runs before this line existed.
48 var subj: *u8 = AG_ELF
49 if argc > 1 { subj = argv[1] as *u8 }
50 let ctr: *i64 = gv_ctr()
51 gv_head("=== NX-AESTHETIC-CANON-GATE -- AT1 evidence grade + AT7 bone floor, proven on the PROMOTED nx_body_proc ===" as *u8)
52 gk_mkdir(AG_DIR)
53 gk_write(AG_REFS, "ref|goodkey|fixture row|url|m|p|d|c|g\n" as *u8)
54 gk_write(AG_BADKEY, "A x m1 1 0 u CONTESTED AXIS goodkey\nA x m2 1 0 u CONTESTED AXIS zz_nokey\n" as *u8)
55 gk_write(AG_REFTGT, "A x m3 1 0 u REFUTED TARGET goodkey\n" as *u8)
56 gk_write(AG_GOOD, "A r m01 1 0 u REPLICATED TARGET goodkey\nA r m02 -1 0 u CONTESTED AXIS goodkey\nA r m03 1 0 u CONTESTED POPULATION goodkey\nA r m04 1 0 u REFUTED AXIS goodkey\nA r m05 1 0 u REPLICATED AXIS goodkey\nA r m06 1 0 u CONTESTED AXIS goodkey\nA r m07 1 0 u CONTESTED AXIS goodkey\nA r m08 1 0 u CONTESTED AXIS goodkey\nA r m09 1 0 u CONTESTED AXIS goodkey\nA r m10 1 0 u REPLICATED TARGET goodkey\n" as *u8)
57 gk_write(AG_DIMLOW, "D 0 112\nD 1 20\nD 2 95\nD 3 22\nD 4 10\nD 5 12\nD 6 0\nD 7 99\nD 8 6\nD 9 68\nD 10 26\nD 11 39\nD 12 6\nD 13 22\nD 14 130\nD 15 60\nD 16 300\nD 17 900\nD 18 780\nD 19 140\nD 20 260\n" as *u8)
58 gk_write(AG_DIMBIG13, "D 0 112\nD 1 20\nD 2 95\nD 3 22\nD 4 86\nD 5 12\nD 6 34\nD 7 99\nD 8 6\nD 9 68\nD 10 26\nD 11 39\nD 12 6\nD 13 44\nD 14 130\nD 15 60\nD 16 300\nD 17 900\nD 18 780\nD 19 140\nD 20 260\n" as *u8)
59 let out: *u8 = sys_mmap(AG_CAP)
60 let ol: *i64 = sys_mmap(16) as *i64
61
62 let r1: i64 = gk_run_capture(subj, "evidence" as *u8, 0 as *u8, 0 as *u8, 0 as *u8, out, AG_CAP, ol)
63 var c1: i64 = 0
64 if r1 == 0 { if gk_out_has(out, ol[0], "partition_ok=1" as *u8) == 1 { c1 = 1 } }
65 gv_check("live-canon-grades-exit0-partition-ok" as *u8, c1, ctr)
66 let rows: i64 = ag_num_after(out, ol[0], "AESTHETIC-CANON rows=" as *u8)
67 let nr: i64 = ag_num_after(out, ol[0], " replicated=" as *u8)
68 let nc2: i64 = ag_num_after(out, ol[0], " contested=" as *u8)
69 let nf: i64 = ag_num_after(out, ol[0], " refuted=" as *u8)
70 var c2: i64 = 0
71 if rows >= 10 { if nr + nc2 + nf == rows { c2 = 1 } }
72 gv_check("live-partition-re-added-by-the-gate-rows-at-least-ten" as *u8, c2, ctr)
73
74 let r3: i64 = gk_run_capture(subj, "evidence" as *u8, AG_BADKEY, AG_REFS, 0 as *u8, out, AG_CAP, ol)
75 var c3: i64 = 0
76 if r3 == 4 { if gk_out_has(out, ol[0], "refkey does not resolve" as *u8) == 1 { if gk_out_has(out, ol[0], "zz_nokey" as *u8) == 1 { c3 = 1 } } }
77 gv_check("neg-control-unknown-refkey-refused-by-name" as *u8, c3, ctr)
78 gv_check("fixture-reached-the-condition-first-valid-row-parsed-before-the-refusal" as *u8, gk_out_has(out, ol[0], "CANON x/m1" as *u8), ctr)
79
80 let r4: i64 = gk_run_capture(subj, "evidence" as *u8, AG_REFTGT, AG_REFS, 0 as *u8, out, AG_CAP, ol)
81 var c4: i64 = 0
82 if r4 == 4 { if gk_out_has(out, ol[0], "never be a steering target" as *u8) == 1 { if gk_out_has(out, ol[0], "m3" as *u8) == 1 { c4 = 1 } } }
83 gv_check("neg-control-refuted-target-refused-by-name" as *u8, c4, ctr)
84
85 let r5: i64 = gk_run_capture(subj, "evidence" as *u8, AG_GOOD, AG_REFS, 0 as *u8, out, AG_CAP, ol)
86 var c5: i64 = 0
87 if r5 == 0 { if gk_out_has(out, ol[0], "rows=10" as *u8) == 1 { if gk_out_has(out, ol[0], "partition_ok=1" as *u8) == 1 { c5 = 1 } } }
88 gv_check("positive-control-a-fixture-canon-can-pass" as *u8, c5, ctr)
89
90 let r6: i64 = gk_run_capture(subj, "floorcheck" as *u8, "1000" as *u8, "300" as *u8, 0 as *u8, out, AG_CAP, ol)
91 var c6: i64 = 0
92 if r6 == 0 { if gk_out_has(out, ol[0], "verdict=OK" as *u8) == 1 { c6 = 1 } }
93 gv_check("floor-positive-control-real-conf-emits" as *u8, c6, ctr)
94
95 let r7: i64 = gk_run_capture(subj, "floorcheck" as *u8, "1000" as *u8, "300" as *u8, AG_DIMLOW, out, AG_CAP, ol)
96 var c7: i64 = 0
97 if r7 == 6 { if gk_out_has(out, ol[0], "verdict=REFUSE" as *u8) == 1 { c7 = 1 } }
98 gv_check("neg-control-subfloor-waist-refused-exit6" as *u8, c7, ctr)
99
100 let r8: i64 = gk_run_capture(subj, "floorcheck" as *u8, "1000" as *u8, "300" as *u8, AG_DIMBIG13, out, AG_CAP, ol)
101 let flr8: i64 = ag_num_after(out, ol[0], "floor=" as *u8)
102 var c8: i64 = 0
103 if r8 == 0 { if flr8 == 43 { c8 = 1 } }
104 gv_check("floor-derived-moves-with-the-conf-not-typed" as *u8, c8, ctr)
105
106 return gv_verdict("NX-AESTHETIC-CANON-GATE" as *u8, ctr, "AT1+AT7 proven on the shipped binary with runtime-assembled /tmp fixtures; every deny-guard here carries a firing positive control" as *u8)
107}