code wiki / (root) / nx_proportion_guard.nx

nx_proportion_guard.nx source

↩ module page · 166 lines · 8051 B

1// nx_proportion_guard.nx -- FINITE plausibility envelopes for body axes. 2// 3// nx_canon_proportions.nx already seals the axis vocabulary (NX_AXIS_*, ids 1..32) and the 4// RATIO canon (this ratio should be phi-ish, within tolerance). What it does not carry is an 5// ABSOLUTE envelope: a body can satisfy every ratio and still be 3 metres tall. Ratio-only 6// checking is exactly how an alien figure passes review. 7// 8// THE LAW THIS ENCODES (operator, 2026-07-30): a human being has a finite range, and even 9// idealized or fantasy forms have finite proportions -- wider, differently centred, still 10// bounded. So regimes are DATA and every one of them is closed at both ends: 11// HUMAN -- population range for an adult female 12// IDEALIZED -- narrower aesthetic band, strictly INSIDE human-possible 13// KIN -- monsterkin/fantasy: wider than human, still finite by construction 14// 15// ★THE DESIGN DECISION THAT MAKES THIS A GUARD: an axis with no bound row REFUSES. Treating 16// "no bound" as "anything goes" is how impossible values get in -- the same shape as a 17// capability-denied read being mistaken for "unavailable". Missing is not permission. 18// Callers must REFUSE on a non-zero verdict, never silently clamp: a clamped body is a lie 19// told to whoever reads the number back. 20// 21// PROVENANCE (honest): the rows below are literature-typical adult-female ranges entered by 22// hand, not yet an ingest of a measured anthropometric dataset. They are bounds we can defend 23// as plausible, not bounds we have measured ourselves -- see the debt filed alongside this 24// file. Widen or narrow them by MEASUREMENT, never by feel. 25// license_tier: ORIGINAL No hw writes (Rule 26). 26import "nx_syscalls.nx" 27// The axis ids are SEALED vocabulary and are imported, never re-declared -- two copies of an 28// id table is how the two copies drift apart. 29import "nx_canon_proportions.nx" 30const NX_MAGIC_1400: i64 = 1400 31const NX_MAGIC_1950: i64 = 1950 32const NX_MAGIC_1550: i64 = 1550 33const NX_MAGIC_1850: i64 = 1850 34const NX_MAGIC_1200: i64 = 1200 35const NX_MAGIC_2400: i64 = 2400 36 37// Extension to the sealed vocabulary: nx_canon_proportions.nx ends at id 32 38// (NX_AXIS_HIP_TO_GLUTE_DROP). 33 is the next free id. 39const NX_AXIS_BREAST_PROJECTION: i64 = 33 // chest wall to nipple, mm 40 41const PG_HUMAN: i64 = 0 42const PG_IDEALIZED: i64 = 1 43const PG_KIN: i64 = 2 44const PG_REGIME_N: i64 = 3 45 46const PG_OK: i64 = 0 47const PG_BELOW: i64 = 1 48const PG_ABOVE: i64 = 2 49const PG_NO_BOUND: i64 = 3 50 51const PG_MIN: i64 = 0 52const PG_MAX: i64 = 1 53 54// Absolute ceiling no regime may cross. "Fantasy" must still be finite: a KIN row wider than 55// this is a data-entry error, and pg_selftest refuses it. 56const PG_ABSOLUTE_CEILING_MM: i64 = 3000 57 58// Bound rows, ALL VALUES IN MILLIMETRES. 59// axis, regime -> min or max 60// Every axis listed here must carry all three regimes or pg_selftest fails. 61func pg_bound(axis: i64, regime: i64, which: i64) -> i64 { 62 if axis == NX_AXIS_BREAST_DIAMETER { 63 if regime == PG_HUMAN { if which == PG_MIN { return 90 } return 230 } 64 if regime == PG_IDEALIZED { if which == PG_MIN { return 120 } return 190 } 65 if regime == PG_KIN { if which == PG_MIN { return 70 } return 300 } 66 } 67 if axis == NX_AXIS_BREAST_PROJECTION { 68 if regime == PG_HUMAN { if which == PG_MIN { return 25 } return 110 } 69 if regime == PG_IDEALIZED { if which == PG_MIN { return 40 } return 85 } 70 if regime == PG_KIN { if which == PG_MIN { return 20 } return 150 } 71 } 72 if axis == NX_AXIS_TOTAL_HEIGHT { 73 if regime == PG_HUMAN { if which == PG_MIN { return NX_MAGIC_1400 } return NX_MAGIC_1950 } 74 if regime == PG_IDEALIZED { if which == PG_MIN { return NX_MAGIC_1550 } return NX_MAGIC_1850 } 75 if regime == PG_KIN { if which == PG_MIN { return NX_MAGIC_1200 } return NX_MAGIC_2400 } 76 } 77 if axis == NX_AXIS_SHOULDER_WIDTH { 78 if regime == PG_HUMAN { if which == PG_MIN { return 300 } return 470 } 79 if regime == PG_IDEALIZED { if which == PG_MIN { return 330 } return 420 } 80 if regime == PG_KIN { if which == PG_MIN { return 260 } return 580 } 81 } 82 if axis == NX_AXIS_WAIST_WIDTH { 83 if regime == PG_HUMAN { if which == PG_MIN { return 200 } return 420 } 84 if regime == PG_IDEALIZED { if which == PG_MIN { return 230 } return 320 } 85 if regime == PG_KIN { if which == PG_MIN { return 170 } return 500 } 86 } 87 if axis == NX_AXIS_HIP_WIDTH { 88 if regime == PG_HUMAN { if which == PG_MIN { return 280 } return 460 } 89 if regime == PG_IDEALIZED { if which == PG_MIN { return 320 } return 410 } 90 if regime == PG_KIN { if which == PG_MIN { return 240 } return 560 } 91 } 92 if axis == NX_AXIS_THIGH_MID_WIDTH { 93 if regime == PG_HUMAN { if which == PG_MIN { return 95 } return 230 } 94 if regime == PG_IDEALIZED { if which == PG_MIN { return 110 } return 185 } 95 if regime == PG_KIN { if which == PG_MIN { return 80 } return 300 } 96 } 97 if axis == NX_AXIS_GLUTE_PROJECTION { 98 if regime == PG_HUMAN { if which == PG_MIN { return 60 } return 200 } 99 if regime == PG_IDEALIZED { if which == PG_MIN { return 80 } return 160 } 100 if regime == PG_KIN { if which == PG_MIN { return 50 } return 280 } 101 } 102 return 0 - 1 103} 104 105func pg_has_bound(axis: i64, regime: i64) -> i64 { 106 if pg_bound(axis, regime, PG_MIN) < 0 { return 0 } 107 if pg_bound(axis, regime, PG_MAX) < 0 { return 0 } 108 return 1 109} 110 111// The guard. Returns PG_OK only for a value inside a KNOWN, closed envelope. 112func pg_check(axis: i64, value_mm: i64, regime: i64) -> i64 { 113 if pg_has_bound(axis, regime) == 0 { return PG_NO_BOUND } 114 if value_mm < pg_bound(axis, regime, PG_MIN) { return PG_BELOW } 115 if value_mm > pg_bound(axis, regime, PG_MAX) { return PG_ABOVE } 116 return PG_OK 117} 118 119// Draw a value inside the envelope BY CONSTRUCTION. A generator that samples through this 120// cannot emit an out-of-range body -- checking after the fact only reports the mistake, this 121// prevents it. h01 is any hash in 0..1000. 122func pg_sample(axis: i64, regime: i64, h01: i64) -> i64 { 123 if pg_has_bound(axis, regime) == 0 { return 0 - 1 } 124 let lo: i64 = pg_bound(axis, regime, PG_MIN) 125 let hi: i64 = pg_bound(axis, regime, PG_MAX) 126 var t: i64 = h01 127 if t < 0 { t = 0 } 128 if t > 1000 { t = 1000 } 129 return lo + (hi - lo) * t / 1000 130} 131 132// Self-audit of the TABLE itself, so a data-entry error cannot masquerade as a guard. 133// Returns a bitmask of faults: 1 min>=max, 2 idealized escapes human, 4 kin narrower than 134// human, 8 a regime missing for a listed axis, 16 a bound beyond the absolute ceiling. 135func pg_selftest() -> i64 { 136 let axes: *i64 = sys_mmap(16*8) as *i64 137 axes[0] = NX_AXIS_BREAST_DIAMETER 138 axes[1] = NX_AXIS_BREAST_PROJECTION 139 axes[2] = NX_AXIS_TOTAL_HEIGHT 140 axes[3] = NX_AXIS_SHOULDER_WIDTH 141 axes[4] = NX_AXIS_WAIST_WIDTH 142 axes[5] = NX_AXIS_HIP_WIDTH 143 axes[6] = NX_AXIS_THIGH_MID_WIDTH 144 axes[7] = NX_AXIS_GLUTE_PROJECTION 145 var faults: i64 = 0 146 var i: i64 = 0 147 while i < 8 { 148 let a: i64 = axes[i] 149 var r: i64 = 0 150 while r < PG_REGIME_N { 151 if pg_has_bound(a, r) == 0 { faults = faults | 8 } else { 152 let lo: i64 = pg_bound(a, r, PG_MIN) 153 let hi: i64 = pg_bound(a, r, PG_MAX) 154 if lo >= hi { faults = faults | 1 } 155 if hi > PG_ABSOLUTE_CEILING_MM { faults = faults | 16 } 156 } 157 r = r + 1 158 } 159 if pg_bound(a, PG_IDEALIZED, PG_MIN) < pg_bound(a, PG_HUMAN, PG_MIN) { faults = faults | 2 } 160 if pg_bound(a, PG_IDEALIZED, PG_MAX) > pg_bound(a, PG_HUMAN, PG_MAX) { faults = faults | 2 } 161 if pg_bound(a, PG_KIN, PG_MIN) > pg_bound(a, PG_HUMAN, PG_MIN) { faults = faults | 4 } 162 if pg_bound(a, PG_KIN, PG_MAX) < pg_bound(a, PG_HUMAN, PG_MAX) { faults = faults | 4 } 163 i = i + 1 164 } 165 return faults 166}