nx_targetfit.nx
buildroot/runtime/nx_targetfit.nx
about
nx_targetfit.nx -- DID THE GENERATOR HIT ITS TARGET, AND BY HOW MUCH DID IT MISS.
THE QUESTION THIS ANSWERS, AND WHY IT IS NOT ONE WE ALREADY ASK. The estate owns two rulers that
look adjacent and answer different things. nx_mmdev_lib md_measure gives exact per-vertex deviation
against a reference -- how far apart two SHAPES are. nx_proportion_guard pg_check gives absolute
plausibility -- whether a body is a POSSIBLE body at all. Neither answers the operator's question,
which is: we ingested a reference, we derived a target from it, the generator produced something --
DID IT HIT THE TARGET, while still being allowed to vary.
THE WHOLE DIFFICULTY IS THE WORD 'ALLOWED'. A conformance ruler that demands exactness destroys the
thing it is measuring: procedural generation exists to produce variety, and a checker that passes
only near-identical output would drive the generator toward a single figure. Rule 25 is explicit --
build intelligence, never strip features; over-efficiency destroys variety and richness. So the
verdict here is a BAND, never a point, and the band's width is published beside every verdict.
THE BAND IS NORMALISED BY THE AXIS'S OWN PLAUSIBLE ENVELOPE, WHICH IS THE PART THAT MAKES IT MEAN
ANYTHING. A naive ruler expresses tolerance as a percentage of the target: five percent. But five
percent of total height is about 87 mm and five percent of breast projection is about 4 mm, and
those are not comparable quantities -- one is a shrug, the other is a different body. So a miss here
is expressed as PERMIL OF THE AXIS'S PLAUSIBLE RANGE, taken from pg_bound. A tenth of the human
range means the same thing on every axis, which is the only way a multi-axis verdict can be summed
without secretly weighting whichever axis happens to have the biggest numbers.
WHAT IS DERIVED AND WHAT IS DECLARED, stated rather than blurred: the NORMALISATION is derived --
it comes from bounds nx_proportion_guard already holds and defends. The BAND EDGES (tight, slight,
moderate) are DECLARED DEFAULTS, not measured, and they are parameters so a caller can drive them
from conf. Anyone who tightens them by feel rather than by measurement is doing the thing that
file's own provenance note forbids.
AND THE ENVELOPE'S REFUSAL PROPAGATES. pg_bound REFUSES an axis with no bound row, on the principle
that missing is not permission. An axis we cannot normalise is UNMEASURABLE here, never a pass:
silently treating an unbounded axis as conforming would let the axes nobody has characterised be
exactly the ones that always agree.
license_tier: ORIGINAL No hardware writes (Rule 26). Pure integer, pure buffer.
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_canon_proportions.nxnx_proportion_guard.nx
imported by: nx_targetfit_gate.nx
structs
| none |
consts
| 43 | const TF_TIGHT: i64 = 0 |
| 44 | const TF_SLIGHT: i64 = 1 |
| 45 | const TF_MODERATE: i64 = 2 |
| 46 | const TF_OUTSIDE: i64 = 3 |
| 47 | const TF_UNBOUNDED: i64 = 4 // the axis has no envelope: we cannot say, and we do not pretend to |
| 51 | const TF_TIGHT_PERMIL_DEFAULT: i64 = 50 // within 5 percent of the plausible range |
| 52 | const TF_SLIGHT_PERMIL_DEFAULT: i64 = 150 |
| 53 | const TF_MODERATE_PERMIL_DEFAULT: i64 = 300 |
| 56 | const TF_WITHIN: i64 = 0 // every measurable axis landed inside the moderate band |
| 57 | const TF_OUT: i64 = 1 // at least one axis missed beyond moderate |
| 58 | const TF_UNMEASURABLE: i64 = 3 // nothing could be measured at all |
| 61 | const TF_O_AXES: i64 = 0 |
| 62 | const TF_O_TIGHT: i64 = 1 |
| 63 | const TF_O_SLIGHT: i64 = 2 |
| 64 | const TF_O_MODERATE: i64 = 3 |
| 65 | const TF_O_OUTSIDE: i64 = 4 |
| 66 | const TF_O_UNBOUNDED: i64 = 5 |
| 67 | const TF_O_WORST: i64 = 6 // worst variance seen, permil of envelope |
| 68 | const TF_O_WORSTAXIS: i64 = 7 // which axis that was -- the count alone is not a worklist |
| 69 | const TF_O_MEANVAR: i64 = 8 // mean variance over MEASURABLE axes only |
| 70 | const TF_O_BANDT: i64 = 9 // the bands actually used, echoed so a verdict carries its own bar |
| 71 | const TF_O_BANDS: i64 = 10 |
| 72 | const TF_O_BANDM: i64 = 11 |
| 73 | const TF_O_SLOTS: i64 = 12 |
| 75 | const TF_PERMIL: i64 = 1000 |
functions
| 77 | func tf_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: tf_variance_permil |
| 82 | func tf_envelope(axis: i64, regime: i64) -> i64 |
| 91 | func tf_variance_permil(axis: i64, regime: i64, target: i64, measured: i64) -> i64 |
| 97 | func tf_grade(variance_permil: i64, tight: i64, slight: i64, moderate: i64) -> i64 |
| 106 | func tf_axis_fit(axis: i64, regime: i64, target: i64, measured: i64, |
| 120 | func tf_fit(axes: *i64, targets: *i64, measured: *i64, n: i64, regime: i64, |
| 165 | func tf_reconciles(out: *i64) -> i64 called by 1: main |
| 176 | func tf_drift(prev: *i64, now: *i64) -> i64 called by 1: main |