nx_skinfit_gate.nx
buildroot/runtime/nx_skinfit_gate.nx
about
nx_skinfit_gate.nx -- THE GATE FOR THE CHROMOPHORE FIT, 2026-09-03.
SUBJECT: sf_forward / sf_sse / sf_fit in-process (nx_skinfit_lib has no main).
THE ORACLE IS SELF-CONTAINED. Pick a chromophore pair, forward-model three channel reflectances, fit them
back, and demand the pair returns to where it started. No external dataset can be missing or stale, and a
fitter that returns a constant, a grid centre, or its first cell cannot survive a spread of true pairs.
THE COEFFICIENTS HERE ARE PROBE VALUES, NOT MEASURED SPECTRA, AND THE GATE SAYS SO. They are shaped the way
the real absorbers are -- melanin rising toward blue, haemoglobin peaking in green -- because that spectral
DIFFERENCE is what makes two unknowns identifiable from three channels. Nothing below asserts a physical
constant; the teeth test the inversion, and real coefficients arrive later as pinned reference data.
Teeth, in order:
T1 the forward model evaluates for every true pair on the grid (the fixture reached its condition).
T2 the true pairs SPAN real range, so nothing below can pass on a degenerate fixture.
T3 ROUND TRIP: every true pair is recovered within tolerance. Whole grid, no sampling.
T4 the residual at the recovered point is essentially zero for synthetic data -- the fit is not merely
close in parameters, it explains the measurement.
T5 MONOTONE: a higher true melanin yields a higher fitted melanin across the ladder.
T6 IDENTIFIABILITY NEG-CONTROL: with PROPORTIONAL coefficient vectors the two absorbers are
indistinguishable, and the fit must NOT be trusted -- proven by the recovered pair missing badly on
at least one axis. Without this tooth the suite would claim an inverse that the physics does not have.
T7 NEG-CONTROL: a non-positive scattering coefficient REFUSES rather than fitting nonsense.
T8 HONESTY: an unreachable measurement (reflectance far outside anything the model can make) must come
back with a LARGE residual, never a confident chromophore pair with a small one.
PROVEN 8/8 GREEN on the laptop build farm 2026-09-03: worst recovery error 2.2e-4, residual 0 on every
synthetic row, the degenerate case missing by 0.30 and 0.60, and the unreachable case returning 0.5.
license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
dependencies 3 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_skinfit_lib.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 34 | const SG_SLOT: i64 = 8 |
| 35 | const SG_CH: i64 = 3 |
| 36 | const SG_N: i64 = 5 |
| 37 | const SG_MICRO: i64 = 1000000 |
| 38 | const SG_TOL_MICRO: i64 = 20000 |
| 39 | const SG_RESID_MAX_MICRO: i64 = 200 |
| 40 | const SG_BAD_RESID_MIN_MICRO: i64 = 2000 |
| 41 | const SG_SPAN_MIN_MICRO: i64 = 500000 |
| 42 | const SG_DEGEN_MISS_MICRO: i64 = 50000 |
functions
| 44 | func sg_q(micro: i64) -> i64 { return fq_div(fq_from_int(micro), fq_from_int(SG_MICRO)) } |
| 45 | func sg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: main |
| 47 | func main(argc: i64, argv: *i64) -> i64 |