code wiki / (root) / nx_skinfit_gate.nx

nx_skinfit_gate.nx

buildroot/runtime/nx_skinfit_gate.nx

9043 B178 linesdepth 5pulls 8 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_gate_verdict.nx nx_skinfit_lib.nx nx_skinfit_gate.nx

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

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ sys_mmap ↻ sg_q fq_div fq_from_int gv_puts ↻ sf_forward km_r_of_mix km_ks_mix fq_mul fq_div ↻ km_r_from_ks fq_mul ↻ fq_sqrt fq_bitlen fq_isqrt vm_isqrt sf_fit sys_mmap ↻ sf_forward ↻ sf_sse

structs

none

consts

34const SG_SLOT: i64 = 8
35const SG_CH: i64 = 3
36const SG_N: i64 = 5
37const SG_MICRO: i64 = 1000000
38const SG_TOL_MICRO: i64 = 20000
39const SG_RESID_MAX_MICRO: i64 = 200
40const SG_BAD_RESID_MIN_MICRO: i64 = 2000
41const SG_SPAN_MIN_MICRO: i64 = 500000
42const SG_DEGEN_MISS_MICRO: i64 = 50000

functions

44func sg_q(micro: i64) -> i64 { return fq_div(fq_from_int(micro), fq_from_int(SG_MICRO)) }
called by 1: main calls 2: fq_divfq_from_int
45func sg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: main
47func main(argc: i64, argv: *i64) -> i64