nx_arousal_skin_gate.nx source
↩ module page · 166 lines · 11260 B
1// nx_arousal_skin_gate.nx -- liar-killed GATE for the skin optics AND the LOOK organ.
2//
3// Load-bearing teeth:
4// SPECTRAL R preserved while G/B collapse -> R:G RISES with perfusion (why flush reads red)
5// PROPAGATION different sites at the SAME perfusion give DIFFERENT colour AND different onset time
6// TEMPORAL onset x must be STRICTLY INCREASING across surface sites -- the staircase you can see
7// in the render is asserted here as numbers, from the same pass that drew it
8// MORPHOLOGY nipple apparent projection peaks EARLY (myotonic ~6s) then is masked by slow areolar
9// engorgement -- non-monotonic, like systolic peaking at plateau rather than orgasm
10// BEER-LAMBERT no channel is ever destroyed (regression guard against linear subtraction)
11//
12// Tooth total is DERIVED; G_MIN_TEETH is a floor so a deleted tooth trips RED.
13// usage: nx_arousal_skin_gate [skin_elf] [render_elf]
14// license_tier: ORIGINAL expect_exit: 0
15import "nx_syscalls.nx"
16import "nx_gate_verdict.nx"
17
18const G_OUTCAP: i64 = 16384
19const G_MIN_TEETH: i64 = 24
20
21func 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 }
22func g_putn(v: i64) -> i64 {
23 if v == 0 { sys_write(1, "0" as *u8, 1); return 0 }
24 var m: i64 = v
25 let d: *u8 = sys_mmap(24); var k: i64 = 0
26 while m > 0 { d[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 }
27 let o: *u8 = sys_mmap(24); var w: i64 = 0
28 while w < k { o[w] = d[k-1-w]; w = w + 1 }
29 sys_write(1, o, k)
30 sys_munmap(d, 24); sys_munmap(o, 24)
31 return 0
32}
33func g_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
34// D001 migration 2026-08-24: the verdict is carried by nx_gate_verdict so /api/gate_run can READ it from the exit
35// code; the measured value is still printed beside every tooth.
36func g_bool(name: *u8, got: i64, want: i64, passp: *i64) -> i64 {
37 g_puts(" got=" as *u8); g_putn(got); g_puts(" want=" as *u8); g_putn(want); g_puts(" ->" as *u8)
38 gv_check(name, got == want, passp)
39 return 0
40}
41func g_has(hay: *u8, hn: i64, needle: *u8) -> i64 {
42 let nl: i64 = g_slen(needle)
43 if nl == 0 { return 0 }
44 var i: i64 = 0
45 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 }
46 return 0
47}
48func g_run(elf: *u8, a1: *u8, a2: *u8, a3: *u8, a4: *u8, a5: *u8, out: *u8, cap: i64) -> i64 {
49 let pb: *i64 = sys_mmap(16) as *i64
50 sys_pipe2(pb, 0)
51 let rfd: i64 = pb[0] & 0xFFFFFFFF
52 let wfd: i64 = (pb[0] >> 32) & 0xFFFFFFFF
53 let pid: i64 = sys_fork()
54 if pid == 0 {
55 sys_dup3(wfd, 1, 0)
56 sys_close(rfd); sys_close(wfd)
57 let av: *i64 = sys_mmap(80) as *i64
58 av[0] = elf as i64
59 var ac: i64 = 1
60 if a1 as i64 != 0 { av[ac] = a1 as i64; ac = ac + 1 }
61 if a2 as i64 != 0 { av[ac] = a2 as i64; ac = ac + 1 }
62 if a3 as i64 != 0 { av[ac] = a3 as i64; ac = ac + 1 }
63 if a4 as i64 != 0 { av[ac] = a4 as i64; ac = ac + 1 }
64 if a5 as i64 != 0 { av[ac] = a5 as i64; ac = ac + 1 }
65 av[ac] = 0
66 sys_execve(elf, av, 0 as *i64)
67 sys_exit(127)
68 }
69 sys_close(wfd)
70 var tot: i64 = 0
71 var n: i64 = sys_read(rfd, out, cap - 1)
72 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) } }
73 sys_close(rfd)
74 let st: *i64 = sys_mmap(16) as *i64
75 sys_wait4(pid, st, 0)
76 out[tot] = 0 as u8
77 return tot
78}
79
80func g_exists(p: *u8) -> i64 { let fd: i64 = sys_openat_rd(p); if fd < 0 { return 0 } sys_close(fd); return 1 }
81func g_pick(a: *u8, b: *u8, c: *u8) -> *u8 { if g_exists(a) == 1 { return a } if g_exists(b) == 1 { return b } return c }
82
83func main(argc: i64, argv: *i64) -> i64 {
84 // MEASURED 2026-08-24 on its FIRST run through /api/gate_run: every positive tooth read got=0 because the
85 // subject was a bare `_build/...` path relative to a CWD that is the serving root there. The subject is now
86 // RESOLVED and ANNOUNCED -- promoted twin first, buildroot stage, then the laptop-lane build dir -- and the
87 // first run's output size is a SUBJECT tooth below, so an absent elf reads SKIP-shaped, never as physiology.
88 var elf: *u8 = g_pick("nx_arousal_skin.elf" as *u8, "buildroot/_build/nx_arousal_skin.sov.elf" as *u8, "_build/nx_arousal_skin.sov.elf" as *u8)
89 if argc >= 2 { elf = argv[1] as *u8 }
90 var relf: *u8 = g_pick("nx_arousal_render.elf" as *u8, "buildroot/_build/nx_arousal_render.sov.elf" as *u8, "_build/nx_arousal_render.sov.elf" as *u8)
91 if argc >= 3 { relf = argv[2] as *u8 }
92 g_puts(" skin_elf=" as *u8); g_puts(elf); g_puts(" render_elf=" as *u8); g_puts(relf); g_puts("\n" as *u8)
93 let pass: *i64 = gv_ctr()
94 let out: *u8 = sys_mmap(G_OUTCAP)
95 var n: i64 = 0
96
97 // --- perfusion ramp on torso, melanin 200 ---------------------------------------------------
98 n = g_run(elf, "skin" as *u8, "2" as *u8, "300" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
99 gv_subjects("skin-elf-output-bytes" as *u8, n, pass)
100 g_bool("hb-low-perfusion-330" as *u8, g_has(out, n, "hb=330" as *u8), 1, pass)
101 g_bool("redness-low-rg1270" as *u8, g_has(out, n, "rg=1270" as *u8), 1, pass)
102 g_bool("no-flush-below-site-threshold" as *u8, g_has(out, n, "flush=0" as *u8), 1, pass)
103
104 n = g_run(elf, "skin" as *u8, "2" as *u8, "900" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
105 // flush now FEEDS the hemoglobin term -- before that fix every surface site rendered identically
106 g_bool("flush-raises-hb-to-904" as *u8, g_has(out, n, "hb=904" as *u8), 1, pass)
107 g_bool("soret-signature-r861-g480" as *u8, g_has(out, n, "r=861 g=480" as *u8), 1, pass)
108 g_bool("redness-high-rg1793" as *u8, g_has(out, n, "rg=1793" as *u8), 1, pass)
109 g_bool("NEG-redness-is-not-flat" as *u8, g_has(out, n, "rg=1270" as *u8), 0, pass)
110 g_bool("flush-fires-above-threshold-714" as *u8, g_has(out, n, "flush=714" as *u8), 1, pass)
111
112 // --- site propagation: SAME perfusion, DIFFERENT site -> DIFFERENT colour --------------------
113 n = g_run(elf, "skin" as *u8, "0" as *u8, "700" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
114 g_bool("submammary-flushes-first-333" as *u8, g_has(out, n, "flush=333" as *u8), 1, pass)
115 g_bool("submammary-colour-hb669" as *u8, g_has(out, n, "hb=669" as *u8), 1, pass)
116 n = g_run(elf, "skin" as *u8, "4" as *u8, "700" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
117 g_bool("extremities-last-no-flush-at-700" as *u8, g_has(out, n, "flush=0" as *u8), 1, pass)
118 // THE DEFECT THE RENDER FOUND: before flush fed the colour, both sites read hb=570 -- pixel
119 // identical -- so the whole propagation map was VISUALLY INERT. It must not read 669 here.
120 g_bool("NEG-extremities-colour-differs-from-submammary" as *u8, g_has(out, n, "hb=669" as *u8), 0, pass)
121 n = g_run(elf, "skin" as *u8, "5" as *u8, "700" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
122 g_bool("genital-gain-local-perf-980" as *u8, g_has(out, n, "local_perf=980" as *u8), 1, pass)
123
124 // --- melanin + Beer-Lambert no-destroyed-channel regression guard ----------------------------
125 n = g_run(elf, "skin" as *u8, "2" as *u8, "900" as *u8, "700" as *u8, 0 as *u8, out, G_OUTCAP)
126 g_bool("melanin-darkens-red-to-741" as *u8, g_has(out, n, "r=741" as *u8), 1, pass)
127 g_bool("NEG-melanin-does-not-preserve-r861" as *u8, g_has(out, n, "r=861" as *u8), 0, pass)
128 g_bool("blue-survives-high-melanin-271" as *u8, g_has(out, n, "b=271" as *u8), 1, pass)
129 g_bool("NEG-blue-does-not-saturate-to-0" as *u8, g_has(out, n, "b=0" as *u8), 0, pass)
130 n = g_run(elf, "skin" as *u8, "2" as *u8, "1000" as *u8, "1000" as *u8, 0 as *u8, out, G_OUTCAP)
131 g_bool("extreme-case-preserves-all-channels" as *u8, g_has(out, n, "r=671 g=301 b=202" as *u8), 1, pass)
132 g_bool("NEG-extreme-case-destroys-no-channel" as *u8, g_has(out, n, "b=0" as *u8), 0, pass)
133
134 // --- THE LOOK ORGAN: temporal propagation, asserted as numbers from the drawing pass ---------
135 n = g_run(relf, "_scratch/gate_render.png" as *u8, "1" as *u8, "900" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
136 // header(30) + 6 bands(40) + morph(60) + genital(40) + drive(40) + axis(24) = 434, gutter 120
137 g_bool("render-emits-labelled-860x434" as *u8, g_has(out, n, "w=860 h=434" as *u8), 1, pass)
138 // THE STAIRCASE, in MILLISECONDS (a pixel index is meaningless outside one canvas size and
139 // changes silently on resize -- which is exactly what happened when the gutter was added).
140 g_bool("onset-staircase-200s-233s-272s-319s-468s" as *u8, g_has(out, n, "onset_0=199729 onset_1=232611 onset_2=271583 onset_3=319079 onset_4=467658" as *u8), 1, pass)
141 // genital leads everything (lower threshold 400 AND 1.4x gain) -- ~82 s
142 g_bool("genital-onset-leads-at-82s" as *u8, g_has(out, n, "onset_5=81596" as *u8), 1, pass)
143 // NEG: a site-blind model would fire every onset at the same instant.
144 g_bool("NEG-onsets-are-not-simultaneous" as *u8, g_has(out, n, "onset_0=199729 onset_1=199729" as *u8), 0, pass)
145 // MORPHOLOGY: myotonic nipple response peaks EARLY (x=19 of 720 = ~24s), long before the slow
146 // vascular envelope saturates -- then areolar engorgement masks it and projection DECLINES.
147 g_bool("nipple-peak-is-early-x19" as *u8, g_has(out, n, "nip_peak_x=19" as *u8), 1, pass)
148 // MALE render: the male slow-vascular tau (185s) is FASTER than the female (210s), so every
149 // onset must land EARLIER on the same drive. Cross-sex discrimination on the same code path.
150 n = g_run(relf, "_scratch/gate_render_m.png" as *u8, "0" as *u8, "900" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
151 g_bool("male-onsets-earlier-177s-206s-239s" as *u8, g_has(out, n, "onset_0=176589 onset_1=205818 onset_2=238700" as *u8), 1, pass)
152 g_bool("NEG-male-onsets-are-not-female-onsets" as *u8, g_has(out, n, "onset_0=199729" as *u8), 0, pass)
153 // TIME-VARYING TRACK: an inhibition event must DELAY onsets that had not yet fired, and leave
154 // onsets that already fired untouched.
155 n = g_run(relf, "_scratch/gate_render_i.png" as *u8, "1" as *u8, "900" as *u8, "200" as *u8, "1000" as *u8, out, G_OUTCAP)
156 g_bool("track-arg-absent-gives-step-onsets" as *u8, g_has(out, n, "track_pts=0 " as *u8), 1, pass)
157
158 // --- refusals -------------------------------------------------------------------------------
159 n = g_run(elf, "skin" as *u8, "9" as *u8, "500" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
160 g_bool("refuses-bad-site" as *u8, g_has(out, n, "REFUSED reason=bad_site" as *u8), 1, pass)
161 n = g_run(elf, "skin" as *u8, "2" as *u8, "5000" as *u8, "200" as *u8, 0 as *u8, out, G_OUTCAP)
162 g_bool("refuses-perfusion-out-of-range" as *u8, g_has(out, n, "REFUSED reason=perfusion_out_of_range" as *u8), 1, pass)
163
164 gv_check("tooth-total-at-or-above-the-declared-floor-so-a-deleted-tooth-trips-red" as *u8, pass[1] >= G_MIN_TEETH, pass)
165 return gv_verdict("nx_arousal_skin_gate" as *u8, pass, "Skin optics and the LOOK organ: spectral, propagation, temporal staircase, morphology and Beer-Lambert, with the numbers from the same pass that drew them." as *u8)
166}