code wiki / _hdl_build / nx_tissuematerial_gate.nx
nx_tissuematerial_gate.nx source
↩ module page · 135 lines · 7531 B
1// nx_tissuematerial_gate.nx -- THE LAYER STIFFNESS RATIO IS CITED, AND THE NUMBER IT REPLACED IS
2// PROVEN TO HAVE BEEN OUT OF RANGE. (softbody SB4, first leg, 2026-08-25.)
3//
4// WHAT THIS EXISTS TO STOP. nx_softtissue's per-layer distance compliance used to be two hand-tuned
5// constants carrying the names ST_MAGIC_1229 and ST_MAGIC_12288 -- renamed by nx_magic apply, never
6// sourced. A MAGIC NUMBER GIVEN A NAME IS STILL A MAGIC NUMBER: the grep goes quiet and the
7// arbitrariness is untouched, which is strictly worse than a bare literal because it now LOOKS
8// deliberate. Their implied gland/adipose stiffness ratio was 9.998 against a published within-study
9// band of 1.420..5.698 -- 1.75x above the top of the literature, and nothing in the estate could see it.
10//
11// THE BAND IS READ FROM knowledge/gamefeel_oracle.conf, NEVER COMPILED IN. If the row is missing this
12// gate REFUSES rather than passing on a default: a material gate that cannot find its citation and
13// acquits anyway is the exact defect it was built to catch.
14//
15// WHY A RATIO. Elastography moduli for one tissue span ~50x across studies (the source review's own
16// table carries adipose at 0.33, 3.3 and 17.1 kPa). That spread is METHOD, not biology, so absolute
17// values are not transferable and none is banked. The within-study ratio survives because the method
18// cancels on both sides of the division.
19// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0
20import "nx_syscalls.nx"
21import "nx_softtissue.nx"
22import "nx_oracleband_lib.nx"
23import "nx_gate_verdict.nx"
24
25const TM_CONF: *u8 = "knowledge/gamefeel_oracle.conf"
26const TM_KEY: *u8 = "tissue_gland_adipose_ratio_permil"
27// The pair this gate retired. Kept as data so the bite is PERMANENT: every future run re-proves that
28// the gate would have caught the incumbent, rather than that fact living only in a commit message.
29const TM_OLD_ADIPOSE: i64 = 12288
30const TM_OLD_GLAND: i64 = 1229
31const TM_H_MM: i64 = 10
32
33// Implied stiffness ratio in permil. Compliance is INVERSE stiffness, so the stiffness ratio
34// gland/adipose is the COMPLIANCE ratio adipose/gland -- getting that inversion backwards would make
35// the whole gate assert the reciprocal and pass on exactly the wrong models.
36func tm_ratio_permil(alpha_adipose: i64, alpha_gland: i64) -> i64 {
37 if alpha_gland <= 0 { return 0 - 1 }
38 return alpha_adipose * 1000 / alpha_gland
39}
40
41func main() -> i64 {
42 let ctr: *i64 = gv_ctr()
43 gv_head("nx_tissuematerial_gate -- the layer stiffness ratio is cited, and its predecessor was not" as *u8)
44
45 let rows: i64 = ob_load(TM_CONF)
46 let r: i64 = ob_find(TM_KEY)
47 gv_puts(" conf rows="); gv_num(rows)
48 gv_puts(" row_index="); gv_num(r); gv_puts("\n" as *u8)
49
50 // T1 THE CITATION IS PRESENT. This runs FIRST and everything below is meaningless without it: a
51 // band that failed to load would leave lo=hi=0 and every range test would pass vacuously.
52 var t1: i64 = 0
53 if rows > 0 { if r >= 0 { t1 = 1 } }
54 gv_check("T1 THE BAND LOADED FROM THE CONF -- no citation, no verdict, never a compiled-in default" as *u8, t1, ctr)
55
56 var lo: i64 = 0
57 var hi: i64 = 0
58 if t1 == 1 {
59 lo = ob_lo(r)
60 hi = ob_hi(r)
61 }
62 let live: i64 = tm_ratio_permil(st_layer_alpha_dist(ST_LAY_ADIPOSE), st_layer_alpha_dist(ST_LAY_GLAND))
63 let old: i64 = tm_ratio_permil(TM_OLD_ADIPOSE, TM_OLD_GLAND)
64 gv_puts(" cited band="); gv_num(lo); gv_puts(".."); gv_num(hi)
65 gv_puts(" permil | LIVE model="); gv_num(live)
66 gv_puts(" | RETIRED hand-tuned pair="); gv_num(old); gv_puts("\n" as *u8)
67
68 // T2 the claim itself.
69 var t2: i64 = 0
70 if live >= lo { if live <= hi { t2 = 1 } }
71 gv_check("T2 THE LIVE MODEL'S gland/adipose RATIO SITS INSIDE THE CITED BAND" as *u8, t2, ctr)
72
73 // T3 THE BITE, AND IT IS PERMANENT. A band wide enough to admit the number it replaced would be a
74 // band that proves nothing. This tooth fails the moment someone widens the citation to fit a
75 // convenient constant -- which is the way this class of gate is usually defeated.
76 // Gated on t1: with no band loaded hi is 0 and "old > 0" is trivially true, so an unloaded
77 // citation would have this tooth CONGRATULATING ITSELF on discriminating against nothing. Caught
78 // on this gate's first run, which is precisely what the anti-vacuity discipline is for.
79 var t3: i64 = 0
80 if t1 == 1 { if old > hi { t3 = 1 } }
81 gv_check("T3 BITE: the RETIRED hand-tuned ratio falls OUTSIDE the cited band, so the band discriminates" as *u8, t3, ctr)
82
83 // T4 the anchor did not move. Fixing a ratio leaves the SCALE free, and this solver has no
84 // referent for absolute compliance. Adipose was chosen as the anchor by census (below); if it
85 // silently drifted, the ratio could be satisfied while the whole organ changed stiffness.
86 var t4: i64 = 0
87 if st_layer_alpha_dist(ST_LAY_ADIPOSE) == TM_OLD_ADIPOSE { t4 = 1 }
88 gv_check("T4 THE ANCHOR LAYER IS UNCHANGED, so the ratio was fixed WITHOUT rescaling the organ" as *u8, t4, ctr)
89
90 // T5 THE ANCHOR CHOICE IS A MEASUREMENT, NOT A PREFERENCE. Adipose is the anchor because it
91 // carries the overwhelming majority of the distance constraints; that is re-counted here on every
92 // run rather than trusted from a comment. The partition must also SUM, or the census is a leak.
93 let W: *i64 = st_new(ST_PROF_LARGE_SOFT, TM_H_MM)
94 let el: *i64 = W[ST_W_ELA] as *i64
95 let ne: i64 = W[ST_W_NE]
96 var nad: i64 = 0
97 var ngl: i64 = 0
98 var nsum: i64 = 0
99 var i: i64 = 0
100 while i < ne {
101 if el[i] == ST_LAY_ADIPOSE { nad = nad + 1 }
102 if el[i] == ST_LAY_GLAND { ngl = ngl + 1 }
103 if el[i] >= 0 { if el[i] < ST_LAY_N { nsum = nsum + 1 } }
104 i = i + 1
105 }
106 gv_puts(" edges="); gv_num(ne)
107 gv_puts(" adipose="); gv_num(nad)
108 gv_puts(" gland="); gv_num(ngl)
109 gv_puts(" partition_sum="); gv_num(nsum)
110 gv_puts(" adipose_permil="); gv_num(nad*1000/ne); gv_puts("\n" as *u8)
111 var t5: i64 = 0
112 if nsum == ne { if nad > ngl { t5 = 1 } }
113 gv_check("T5 THE ANCHOR IS THE DOMINANT LAYER BY COUNT, and the layer partition SUMS to the edges" as *u8, t5, ctr)
114
115 // T6 direction. A ratio inside the band could still be inverted if both values moved together;
116 // asserting the ORDER separately means an inverted model cannot hide behind a passing magnitude.
117 var t6: i64 = 0
118 if st_layer_alpha_dist(ST_LAY_ADIPOSE) > st_layer_alpha_dist(ST_LAY_GLAND) { t6 = 1 }
119 gv_check("T6 ADIPOSE IS MORE COMPLIANT THAN GLAND -- fat is softer than gland, not merely different" as *u8, t6, ctr)
120
121 // neg-control: the ratio helper must REFUSE a zero denominator rather than trap or return a
122 // number. A rigid layer has alpha 0, so this is reachable from real data, not a synthetic case.
123 var t7: i64 = 0
124 if tm_ratio_permil(TM_OLD_ADIPOSE, 0) == 0 - 1 { t7 = 1 }
125 gv_check("neg-control-a-rigid-layer-zero-compliance-REFUSES-rather-than-dividing" as *u8, t7, ctr)
126
127 // neg-control: the band must be a real interval read from the file, not two zeros. lo==hi==0
128 // would make T2 pass for any model whose ratio were also zero.
129 var t8: i64 = 0
130 if hi > lo { if lo > 0 { t8 = 1 } }
131 gv_check("neg-control-the-loaded-band-is-a-REAL-interval-not-a-pair-of-zeros" as *u8, t8, ctr)
132
133 return gv_verdict("TISSUE-MATERIAL" as *u8, ctr,
134 "gland/adipose compliance ratio read from the cited conf band; the retired hand-tuned pair is proven outside it" as *u8)
135}