nx_arousal_clinical_gate.nx source
↩ module page · 163 lines · 10208 B
1// nx_arousal_clinical_gate.nx -- liar-killed GATE for the dual-control therapy readout.
2//
3// The load-bearing teeth are DISCRIMINATION and REFUSAL, in that order:
4// - three profiles differing ONLY in which inhibition dominates must name three DIFFERENT axes.
5// A readout that always returns the same pathway would satisfy any single-profile test.
6// - a profile where two axes are within the margin must return AMBIGUOUS and name NOTHING. An
7// instrument that always produces a cause is a horoscope, and the refusal is what separates a
8// measurement from a reading.
9// - an unreachable target must report NEVER / UNBOUNDED, never the internal CL_MAXMS cap dressed
10// up as a duration -- "never reaches plateau" must not degrade into "takes a while".
11//
12// Tooth total is DERIVED; G_MIN_TEETH is a floor so a deleted tooth trips RED.
13// license_tier: ORIGINAL expect_exit: 0
14import "nx_syscalls.nx"
15
16const G_OUTCAP: i64 = 16384
17const G_MIN_TEETH: i64 = 18
18
19func g_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
20func g_putn(v: i64) -> i64 {
21 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
22 var m: i64 = v
23 let d: *u8 = sys_mmap(24); var k: i64 = 0
24 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
25 let o: *u8 = sys_mmap(24); var w: i64 = 0
26 while w < k { o[w] = d[k-1-w]; w = w + 1 }
27 sys_write(1, o, k)
28 sys_munmap(d, 24); sys_munmap(o, 24)
29 return 0
30}
31func g_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
32func g_bool(name: *u8, got: i64, want: i64, passp: *i64) -> i64 {
33 passp[1] = passp[1] + 1
34 g_puts("T " as *u8); g_puts(name); g_puts(" got=" as *u8); g_putn(got)
35 if got == want { g_puts(" PASS\n" as *u8); passp[0] = passp[0] + 1 } else { g_puts(" FAIL\n" as *u8) }
36 return 0
37}
38func g_has(hay: *u8, hn: i64, needle: *u8) -> i64 {
39 let nl: i64 = g_slen(needle)
40 if nl == 0 { return 0 }
41 var i: i64 = 0
42 while i + nl <= hn { var k: i64 = 0; var ok: i64 = 1; while k < nl { if hay[i+k] != needle[k] { ok = 0; k = nl } k = k + 1 } if ok == 1 { return 1 } i = i + 1 }
43 return 0
44}
45func g_run(elf: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, a5: *u8, out: *u8, cap: i64) -> i64 {
46 let pb: *i64 = sys_mmap(16) as *i64
47 sys_pipe2(pb, 0)
48 let rfd: i64 = pb[0] & 0xFFFFFFFF
49 let wfd: i64 = (pb[0] >> 32) & 0xFFFFFFFF
50 let pid: i64 = sys_fork()
51 if pid == 0 {
52 sys_dup3(wfd, 1, 0)
53 sys_close(rfd); sys_close(wfd)
54 let av: *i64 = sys_mmap(80) as *i64
55 av[0] = elf as i64
56 var ac: i64 = 1
57 if a1 as i64 != 0 { av[ac] = a1 as i64; ac = ac + 1 }
58 if a2 as i64 != 0 { av[ac] = a2 as i64; ac = ac + 1 }
59 if a3 as i64 != 0 { av[ac] = a3 as i64; ac = ac + 1 }
60 if a4 as i64 != 0 { av[ac] = a4 as i64; ac = ac + 1 }
61 if a5 as i64 != 0 { av[ac] = a5 as i64; ac = ac + 1 }
62 av[ac] = 0
63 sys_execve(elf, av, 0 as *i64)
64 sys_exit(127)
65 }
66 sys_close(wfd)
67 var tot: i64 = 0
68 var n: i64 = sys_read(rfd, out, cap - 1)
69 while n > 0 { tot = tot + n; if tot >= cap - 1 { n = 0 } else { n = sys_read(rfd, (out as i64 + tot) as *u8, cap - 1 - tot) } }
70 sys_close(rfd)
71 let st: *i64 = sys_mmap(16) as *i64
72 sys_wait4(pid, st, 0)
73 out[tot] = 0 as u8
74 return tot
75}
76
77func main(argc: i64, argv: *i64) -> i64 {
78 var elf: *u8 = "_build/nx_arousal_clinical.sov.elf" as *u8
79 if argc >= 2 { elf = argv[1] as *u8 }
80 let pass: *i64 = sys_mmap(16) as *i64
81 pass[0] = 0
82 pass[1] = 0
83 let out: *u8 = sys_mmap(G_OUTCAP)
84 var n: i64 = 0
85
86 // ---- DISCRIMINATION: three profiles, three different limiting axes -------------------------
87 // performance-failure threat dominant (SIS1=600)
88 n = g_run(elf, "profile" as *u8, "900" as *u8, "800" as *u8, "600" as *u8, "50" as *u8, out, G_OUTCAP)
89 g_bool("names-SIS1-performance-threat" as *u8, g_has(out, n, "limiting=SIS1_performance_threat" as *u8), 1, pass)
90 g_bool("SIS1-gain-540" as *u8, g_has(out, n, "gain_sis1=540" as *u8), 1, pass)
91 g_bool("SIS1-routes-to-sensate-focus" as *u8, g_has(out, n, "sensate focus" as *u8), 1, pass)
92 // NEG: must not name the OTHER inhibition on this profile
93 g_bool("NEG-SIS1-case-does-not-name-SIS2" as *u8, g_has(out, n, "limiting=SIS2" as *u8), 0, pass)
94
95 // consequence threat dominant (SIS2=400)
96 n = g_run(elf, "profile" as *u8, "900" as *u8, "800" as *u8, "50" as *u8, "400" as *u8, out, G_OUTCAP)
97 g_bool("names-SIS2-consequence-threat" as *u8, g_has(out, n, "limiting=SIS2_consequence_threat" as *u8), 1, pass)
98 g_bool("SIS2-routes-to-context-pathway" as *u8, g_has(out, n, "privacy, safety" as *u8), 1, pass)
99 g_bool("NEG-SIS2-case-does-not-name-SIS1" as *u8, g_has(out, n, "limiting=SIS1" as *u8), 0, pass)
100
101 // excitation deficit dominant (SES=300, both inhibitions low)
102 n = g_run(elf, "profile" as *u8, "900" as *u8, "300" as *u8, "40" as *u8, "40" as *u8, out, G_OUTCAP)
103 g_bool("names-SES-excitation-deficit" as *u8, g_has(out, n, "limiting=SES_excitation_deficit" as *u8), 1, pass)
104 g_bool("SES-gain-630" as *u8, g_has(out, n, "gain_ses=630" as *u8), 1, pass)
105 // ★NEG: a readout that always returns the same pathway passes every single-profile test above.
106 g_bool("NEG-readout-is-not-constant" as *u8, g_has(out, n, "limiting=SIS1_performance_threat" as *u8), 0, pass)
107
108 // ---- REFUSAL: two axes within the margin must name NOTHING ---------------------------------
109 n = g_run(elf, "profile" as *u8, "900" as *u8, "800" as *u8, "300" as *u8, "300" as *u8, out, G_OUTCAP)
110 g_bool("ambiguous-refuses-to-call-it" as *u8, g_has(out, n, "verdict=REFUSED_TOO_CLOSE_TO_CALL" as *u8), 1, pass)
111 g_bool("ambiguous-reports-its-margin" as *u8, g_has(out, n, "margin=30" as *u8), 1, pass)
112 // ★NEG: the refusal must not smuggle a named axis alongside it
113 g_bool("NEG-ambiguous-names-no-axis" as *u8, g_has(out, n, "pathway=" as *u8), 0, pass)
114 // a profile with NO inhibition at all is not inhibition-limited
115 n = g_run(elf, "profile" as *u8, "900" as *u8, "1000" as *u8, "0" as *u8, "0" as *u8, out, G_OUTCAP)
116 g_bool("no-inhibition-reports-NONE" as *u8, g_has(out, n, "verdict=NOT_INHIBITION_LIMITED" as *u8), 1, pass)
117
118 // ---- REACHABILITY: never must read NEVER, not a capped duration ----------------------------
119 n = g_run(elf, "profile" as *u8, "900" as *u8, "800" as *u8, "600" as *u8, "50" as *u8, out, G_OUTCAP)
120 g_bool("unreachable-reports-NEVER" as *u8, g_has(out, n, "t_base_s=NEVER" as *u8), 1, pass)
121 g_bool("unreachable-saving-is-UNBOUNDED" as *u8, g_has(out, n, "saved_s=UNBOUNDED" as *u8), 1, pass)
122 // ★NEG: the CL_MAXMS cap must never surface as if it were a measured time
123 g_bool("NEG-cap-not-reported-as-duration" as *u8, g_has(out, n, "t_base_s=3600" as *u8), 0, pass)
124 n = g_run(elf, "profile" as *u8, "900" as *u8, "950" as *u8, "60" as *u8, "40" as *u8, out, G_OUTCAP)
125 g_bool("reachable-reports-real-seconds-407" as *u8, g_has(out, n, "t_base_s=407" as *u8), 1, pass)
126
127 // ---- refusals ------------------------------------------------------------------------------
128 n = g_run(elf, "profile" as *u8, "5000" as *u8, "800" as *u8, "50" as *u8, "50" as *u8, out, G_OUTCAP)
129 g_bool("refuses-stim-out-of-range" as *u8, g_has(out, n, "REFUSED reason=stim_out_of_range" as *u8), 1, pass)
130 n = g_run(elf, "profile" as *u8, "900" as *u8, "800" as *u8, "5000" as *u8, "50" as *u8, out, G_OUTCAP)
131 g_bool("refuses-sis1-out-of-range" as *u8, g_has(out, n, "REFUSED reason=sis1_out_of_range" as *u8), 1, pass)
132
133 // ---- OBSERVED MODE: composes with nx_arousal_profile's IDENTIFIABLE output -----------------
134 // The `profile` verb needs SES and SIS1 separately -- the pair the estimator proves confounded.
135 // Without this mode the two organs cannot compose at all, and the architecture would silently
136 // require a questionnaire nobody ran.
137 n = g_run(elf, "observed" as *u8, "900" as *u8, "200" as *u8, "30" as *u8, 0 as *u8, out, G_OUTCAP)
138 g_bool("observed-net-limited" as *u8, g_has(out, n, "limiting=NET_EXCITATION_TERM" as *u8), 1, pass)
139 // ★the net term must be declared UN-ATTRIBUTABLE, never split into SES vs SIS1
140 g_bool("observed-net-is-unattributable" as *u8, g_has(out, n, "attributable=NO" as *u8), 1, pass)
141 g_bool("NEG-observed-never-names-SES-or-SIS1" as *u8, g_has(out, n, "limiting=SES_excitation_deficit" as *u8), 0, pass)
142
143 // ★CLAMPING: a profile whose true drive is negative must difference from the RAW value, not the
144 // clamped 0. Differencing against the clamp understates the gain and can FLIP the verdict.
145 n = g_run(elf, "observed" as *u8, "900" as *u8, "200" as *u8, "400" as *u8, 0 as *u8, out, G_OUTCAP)
146 g_bool("clamped-exposes-raw-drive" as *u8, g_has(out, n, "raw_drive=-220 clamped=1" as *u8), 1, pass)
147 g_bool("clamped-gain-computed-unclamped-400" as *u8, g_has(out, n, "gain_remove_sis2=400" as *u8), 1, pass)
148 // NEG: the pre-fix value differenced against the clamped baseline was 180
149 g_bool("NEG-gain-not-differenced-from-clamp" as *u8, g_has(out, n, "gain_remove_sis2=180" as *u8), 0, pass)
150
151 // observed mode refuses an ambiguous split exactly as the profile mode does
152 n = g_run(elf, "observed" as *u8, "900" as *u8, "640" as *u8, "330" as *u8, 0 as *u8, out, G_OUTCAP)
153 g_bool("observed-ambiguous-refuses" as *u8, g_has(out, n, "verdict=REFUSED_TOO_CLOSE_TO_CALL" as *u8), 1, pass)
154 g_bool("NEG-observed-ambiguous-names-nothing" as *u8, g_has(out, n, "attributable=YES" as *u8), 0, pass)
155 n = g_run(elf, "observed" as *u8, "5000" as *u8, "200" as *u8, "30" as *u8, 0 as *u8, out, G_OUTCAP)
156 g_bool("observed-refuses-stim-out-of-range" as *u8, g_has(out, n, "REFUSED reason=stim_out_of_range" as *u8), 1, pass)
157
158 g_puts("AROUSAL-CLINICAL-GATE pass=" as *u8); g_putn(pass[0]); g_puts("/" as *u8); g_putn(pass[1]); g_puts(" verdict=" as *u8)
159 if pass[1] < G_MIN_TEETH { g_puts("RED reason=teeth_deleted\n" as *u8); return 1 }
160 if pass[0] == pass[1] { g_puts("GREEN\n" as *u8); return 0 }
161 g_puts("RED\n" as *u8)
162 return 1
163}