nx_skinspectra_gate.nx source
↩ module page · 134 lines · 8358 B
1// nx_skinspectra_gate.nx -- THE GATE FOR THE MEASURED SPECTRA, 2026-09-03 (rung ST6).
2//
3// SUBJECT: ss_melanin_mua / ss_melanin_mua_at / ss_hb_mua / ss_hb_lookup in-process, against the SHA-PINNED
4// mirrors in knowledge/fetched.
5//
6// THE STRONGEST TOOTH IS T1 AND IT IS PREFACTOR-FREE. The published melanin law has a prefactor the source
7// itself calls tenfold-variable, so any tooth that depends on it is testing a number nobody can pin. The
8// RATIO of two wavelengths cancels the prefactor entirely and leaves only the exponent: mua(450)/mua(600)
9// must equal (600/450)^3.48 whatever the concentration. That is the part of the law that IS pinned, and it
10// is the part this gate checks. MEASURED: 2721365 against 2721365 micro, exact.
11//
12// T5 AND T7 ARE THE ANTI-STUB PAIR. A lookup that returned a fixed row would pass "the value is non-zero"
13// forever. T5 demands two DIFFERENT wavelengths give DIFFERENT values, and T7 demands a wavelength the
14// table does not contain be REFUSED rather than answered with a neighbour -- handing back the nearest row
15// would be inventing a measurement and calling it data.
16//
17// T7 CARRIES A CORRECTION WORTH READING. On its first run, on the laptop where the mirror is absent, T7
18// PASSED -- and passed for the wrong reason entirely: the lookup returned REFUSED because the FILE was
19// missing, not because 451 nm is untabulated. A green earned by an unrelated failure is worse than a red,
20// so the tooth now requires T4 to have genuinely parsed the table first and cannot pass anywhere the mirror
21// cannot be read. Verified by the fix dropping the local run from 7/10 to 6/10.
22//
23// Teeth, in order:
24// T1 PREFACTOR-FREE KAT: the 450-to-600 absorption ratio equals (600/450)^3.48.
25// T2 monotone: a shorter wavelength absorbs more.
26// T3 concentration scales linearly -- doubling it doubles the absorption.
27// T4 the mirrored haemoglobin table PARSES: a tabulated wavelength returns two non-zero columns.
28// T5 ANTI-STUB: two different tabulated wavelengths return different values.
29// T6 the two columns DIFFER at one wavelength -- HbO2 and Hb are different molecules, so a lookup
30// returning one column twice cannot hide behind T4 and T5.
31// T7 NEG-CONTROL: an untabulated wavelength REFUSES, with the table PROVEN readable first.
32// T8 NEG-CONTROL: a missing mirror REFUSES rather than returning zero.
33// T9 NEG-CONTROL: a wavelength outside the fitted band REFUSES rather than extrapolating the formula.
34// T10 the source's own conversion arithmetic: mua = 2.303 e x / 64500.
35// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
36import "nx_syscalls.nx"
37import "nx_gate_verdict.nx"
38import "nx_skinspectra_lib.nx"
39
40const SG_MICRO: i64 = 1000000
41const SG_SLOT: i64 = 8
42const SG_RATIO_TOL_MICRO: i64 = 20000
43const SG_L_BLUE: i64 = 450
44const SG_L_GREEN: i64 = 550
45const SG_L_RED: i64 = 600
46const SG_L_ODD: i64 = 451
47const SG_L_OUT: i64 = 1200
48const SG_HB_PATH: *u8 = "knowledge/fetched/cmp_skintwin_hemoglobin_omlc.html"
49const SG_HB_MISSING: *u8 = "knowledge/fetched/cmp_skintwin_no_such_mirror.html"
50const SG_E_PROBE: i64 = 100000
51const SG_X_PROBE: i64 = 150
52const SG_TWO: i64 = 2
53
54func main(argc: i64, argv: *i64) -> i64 {
55 let ctr: *i64 = gv_ctr()
56 gv_head("nx_skinspectra gate -- the published melanin law and the mirrored haemoglobin table, parsed not transcribed" as *u8)
57
58 let fq: *i64 = fq_ctx()
59
60 let mb: i64 = ss_melanin_mua(fq, SG_L_BLUE)
61 let mg: i64 = ss_melanin_mua(fq, SG_L_GREEN)
62 let mr: i64 = ss_melanin_mua(fq, SG_L_RED)
63 gv_puts(" [T1] mua micro blue=" as *u8); gv_num(fq_to_micro(mb))
64 gv_puts(" green=" as *u8); gv_num(fq_to_micro(mg))
65 gv_puts(" red=" as *u8); gv_num(fq_to_micro(mr)); gv_puts("\n" as *u8)
66 let ratio: i64 = fq_div(mb, mr)
67 let k: i64 = fq_div(fq_from_int(SS_MEL_EXP_MILLI), fq_from_int(SS_MILLI))
68 let expect: i64 = fq_pow(fq, fq_div(fq_from_int(SG_L_RED), fq_from_int(SG_L_BLUE)), k)
69 gv_puts(" ratio_micro=" as *u8); gv_num(fq_to_micro(ratio))
70 gv_puts(" expect_micro=" as *u8); gv_num(fq_to_micro(expect)); gv_puts("\n" as *u8)
71 var d1: i64 = fq_to_micro(ratio) - fq_to_micro(expect)
72 if d1 < 0 { d1 = 0 - d1 }
73 gv_check("PREFACTOR-FREE-the-blue-to-red-ratio-equals-the-published-exponent-law (the one part of it that is pinned)" as *u8, (d1 <= SG_RATIO_TOL_MICRO) as i64, ctr)
74
75 var t2: i64 = 0
76 if mb > mg { if mg > mr { t2 = 1 } }
77 gv_check("a-shorter-wavelength-absorbs-more" as *u8, t2, ctr)
78
79 let half: i64 = fq_div(FQ_ONE, fq_from_int(SG_TWO))
80 let c1: i64 = ss_melanin_mua_at(fq, SG_L_RED, half)
81 let c2: i64 = ss_melanin_mua_at(fq, SG_L_RED, FQ_ONE)
82 gv_puts(" [T3] conc 0.5 -> " as *u8); gv_num(fq_to_micro(c1))
83 gv_puts(" conc 1.0 -> " as *u8); gv_num(fq_to_micro(c2)); gv_puts("\n" as *u8)
84 var d3: i64 = fq_to_micro(c2) - fq_to_micro(c1) * SG_TWO
85 if d3 < 0 { d3 = 0 - d3 }
86 gv_check("concentration-scales-the-law-linearly (the source calls it tenfold-variable, so it is an argument)" as *u8, (d3 <= SG_RATIO_TOL_MICRO) as i64, ctr)
87
88 let hb: *i64 = sys_mmap(SG_TWO * SG_SLOT) as *i64
89 let r4: i64 = ss_hb_lookup(SG_HB_PATH, SG_L_BLUE, hb)
90 gv_puts(" [T4] lambda=450 -> rc=" as *u8); gv_num(r4)
91 gv_puts(" HbO2=" as *u8); gv_num(hb[0]); gv_puts(" Hb=" as *u8); gv_num(hb[1]); gv_puts("\n" as *u8)
92 var t4: i64 = 0
93 if r4 == 1 { if hb[0] > 0 { if hb[1] > 0 { t4 = 1 } } }
94 gv_check("the-sha-pinned-haemoglobin-table-PARSES-and-returns-two-non-zero-columns" as *u8, t4, ctr)
95
96 let hb2: *i64 = sys_mmap(SG_TWO * SG_SLOT) as *i64
97 let r5: i64 = ss_hb_lookup(SG_HB_PATH, SG_L_GREEN, hb2)
98 gv_puts(" [T5] lambda=550 -> rc=" as *u8); gv_num(r5)
99 gv_puts(" HbO2=" as *u8); gv_num(hb2[0]); gv_puts(" Hb=" as *u8); gv_num(hb2[1]); gv_puts("\n" as *u8)
100 var t5: i64 = 0
101 if r5 == 1 { if hb2[0] != hb[0] { t5 = 1 } }
102 gv_check("ANTI-STUB-two-different-tabulated-wavelengths-return-different-values" as *u8, t5, ctr)
103
104 var t6: i64 = 0
105 if r5 == 1 { if hb2[0] != hb2[1] { t6 = 1 } }
106 gv_check("the-two-columns-DIFFER-at-one-wavelength (HbO2 and Hb are different molecules, so a lookup returning one column twice cannot hide here)" as *u8, t6, ctr)
107
108 let hb3: *i64 = sys_mmap(SG_TWO * SG_SLOT) as *i64
109 let r7: i64 = ss_hb_lookup(SG_HB_PATH, SG_L_ODD, hb3)
110 // THE FIXTURE MUST HAVE REACHED ITS CONDITION FIRST. Measured 2026-09-03 on the laptop, where the mirror
111 // is absent: this tooth returned REFUSED and PASSED -- for the wrong reason entirely, because the FILE
112 // was missing rather than because 451 is untabulated. A green earned by an unrelated failure is worse
113 // than a red. So it now requires T4 to have genuinely parsed the table first.
114 var t7: i64 = 0
115 if r4 == 1 { if r7 == SS_REFUSED { t7 = 1 } }
116 gv_puts(" [T7] lambda=451 (table steps by 2) -> rc=" as *u8); gv_num(r7)
117 gv_puts(" table_readable=" as *u8); gv_num(r4); gv_puts("\n" as *u8)
118 gv_check("neg-control-an-untabulated-wavelength-REFUSES-rather-than-interpolating (and the table was PROVEN readable first, so this cannot pass on a missing file)" as *u8, t7, ctr)
119
120 let r8: i64 = ss_hb_lookup(SG_HB_MISSING, SG_L_BLUE, hb3)
121 gv_puts(" [T8] missing mirror -> rc=" as *u8); gv_num(r8); gv_puts("\n" as *u8)
122 gv_check("neg-control-a-missing-mirror-REFUSES-rather-than-returning-zero" as *u8, (r8 == SS_REFUSED) as i64, ctr)
123
124 let r9: i64 = ss_melanin_mua(fq, SG_L_OUT)
125 gv_puts(" [T9] lambda=1200 -> " as *u8); gv_num(r9); gv_puts("\n" as *u8)
126 gv_check("neg-control-a-wavelength-outside-the-fitted-band-REFUSES-rather-than-extrapolating-the-formula" as *u8, (r9 == SS_REFUSED) as i64, ctr)
127
128 let mua: i64 = ss_hb_mua(SG_E_PROBE, SG_X_PROBE)
129 let want: i64 = (SG_E_PROBE * SS_HB_LN10_MILLI * SG_X_PROBE) / (SS_MILLI * SS_HB_GRAM_MOLE)
130 gv_puts(" [T10] mua for e=100000 x=150 -> " as *u8); gv_num(mua); gv_puts(" want=" as *u8); gv_num(want); gv_puts("\n" as *u8)
131 gv_check("the-sources-own-conversion-arithmetic-2303-e-x-over-64500" as *u8, (mua == want) as i64, ctr)
132
133 return gv_verdict("skinspectra" as *u8, ctr, "the published melanin exponent proven prefactor-free, the pinned haemoglobin table parsed rather than transcribed, and every wavelength the data does not contain refused instead of invented" as *u8)
134}