code wiki / (root) / nx_targetfit.nx

nx_targetfit.nx

buildroot/runtime/nx_targetfit.nx

9883 B178 linesdepth 5pulls 5 transitivereach 1 importersview sourcekind library
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_canon_proportions.nx nx_proportion_guard.nx nx_targetfit.nx nx_targetfit_gate.nx

imports: nx_syscalls.nxnx_canon_proportions.nxnx_proportion_guard.nx

imported by: nx_targetfit_gate.nx

structs

none

consts

43const TF_TIGHT: i64 = 0
44const TF_SLIGHT: i64 = 1
45const TF_MODERATE: i64 = 2
46const TF_OUTSIDE: i64 = 3
47const TF_UNBOUNDED: i64 = 4 // the axis has no envelope: we cannot say, and we do not pretend to
51const TF_TIGHT_PERMIL_DEFAULT: i64 = 50 // within 5 percent of the plausible range
52const TF_SLIGHT_PERMIL_DEFAULT: i64 = 150
53const TF_MODERATE_PERMIL_DEFAULT: i64 = 300
56const TF_WITHIN: i64 = 0 // every measurable axis landed inside the moderate band
57const TF_OUT: i64 = 1 // at least one axis missed beyond moderate
58const TF_UNMEASURABLE: i64 = 3 // nothing could be measured at all
61const TF_O_AXES: i64 = 0
62const TF_O_TIGHT: i64 = 1
63const TF_O_SLIGHT: i64 = 2
64const TF_O_MODERATE: i64 = 3
65const TF_O_OUTSIDE: i64 = 4
66const TF_O_UNBOUNDED: i64 = 5
67const TF_O_WORST: i64 = 6 // worst variance seen, permil of envelope
68const TF_O_WORSTAXIS: i64 = 7 // which axis that was -- the count alone is not a worklist
69const TF_O_MEANVAR: i64 = 8 // mean variance over MEASURABLE axes only
70const TF_O_BANDT: i64 = 9 // the bands actually used, echoed so a verdict carries its own bar
71const TF_O_BANDS: i64 = 10
72const TF_O_BANDM: i64 = 11
73const TF_O_SLOTS: i64 = 12
75const TF_PERMIL: i64 = 1000

functions

77func tf_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: tf_variance_permil
82func tf_envelope(axis: i64, regime: i64) -> i64
called by 2: tf_variance_permilmain calls 1: pg_bound
91func tf_variance_permil(axis: i64, regime: i64, target: i64, measured: i64) -> i64
called by 2: tf_axis_fitmain calls 2: tf_envelopetf_abs
97func tf_grade(variance_permil: i64, tight: i64, slight: i64, moderate: i64) -> i64
called by 2: tf_axis_fitmain
106func tf_axis_fit(axis: i64, regime: i64, target: i64, measured: i64,
called by 1: tf_fit calls 2: tf_variance_permiltf_grade
120func tf_fit(axes: *i64, targets: *i64, measured: *i64, n: i64, regime: i64,
called by 1: main calls 3: sys_mmaptf_axis_fitsys_munmap
165func tf_reconciles(out: *i64) -> i64
called by 1: main
176func tf_drift(prev: *i64, now: *i64) -> i64
called by 1: main