code wiki / _hdl_build / nx_fissure_gate.nx
nx_fissure_gate.nx source
↩ module page · 179 lines · 9623 B
1// nx_fissure_gate.nx -- GATE for aesthetictwin rung AT16: the PALPEBRAL FISSURE, so that a canthus
2// exists to be measured at all.
3//
4// WHY THIS RUNG IS FIRST. AT4 (canthal tilt) ranked #1 on this board for weeks and was NOT BUILDABLE: a
5// canthus is the junction of the upper and lower lid margins, and the face carried a socket, a globe and
6// a lash with no lid at all. Worse, the obvious proxy was provably vacuous -- the socket carve and the
7// globe are axis-aligned and share cx exactly, so their intersection is mirror-symmetric, both ends land
8// at the SAME y, and a tilt read off it is identically zero for every face forever. An axis that cannot
9// fail is not an axis, so shipping fa_canthal_tilt against that geometry would have lit the board green
10// with nothing behind it.
11//
12// THE LOAD-BEARING TOOTH IS T4 AND IT IS THE ONE THAT COULD NOT HAVE PASSED YESTERDAY: the two canthi
13// must sit at DIFFERENT y. That is exactly the assertion the old geometry made impossible, so it is the
14// tooth that proves the prerequisite actually landed rather than that a name was written. T5 pins its
15// SIGN -- lateral above medial, a positive canthal tilt -- because a non-zero number of the wrong sign
16// would still pass T4 while describing an anatomy nobody has.
17//
18// T7 IS THE NEGATIVE CONTROL AND IT IS THE PRE-AT16 FACE ITSELF: dropping the part count back to 27
19// reproduces exactly the model that could not be measured, and the ruler must refuse BY NAME rather than
20// return the most flattering reading available. A measure that answered anyway would be reading its own
21// parameters back out.
22import "nx_syscalls.nx"
23import "nx_gate_verdict.nx"
24import "nx_gatekit_lib.nx"
25import "nx_faceanat.nx"
26
27const FG_ASCII0: i64 = 48
28const FG_MINUS: i64 = 45
29const FG_NL: i64 = 10
30const FG_FIELDS: i64 = 6
31const FG_PART_CY: i64 = 1
32const FG_LID_LU: i64 = 27
33const FG_PRE_AT16_PARTS: i64 = 27
34const FG_LEFT: i64 = 0 - 1
35const FG_RIGHT: i64 = 1
36// A displacement 6x the 4-unit x sampling step: unambiguous against quantisation, and small enough that
37// the lid still overlaps its partner so the aperture continues to exist and stays measurable.
38const FG_SHIFT: i64 = 24
39
40func fg_pnum(tag: *u8, v: i64) -> i64 {
41 let b: *u8 = sys_mmap(96)
42 let d: *u8 = sys_mmap(64)
43 var n: i64 = 0
44 var x: i64 = v
45 if x < 0 { b[n] = FG_MINUS; n = n + 1; x = 0 - x }
46 var m: i64 = 0
47 if x == 0 { d[m] = FG_ASCII0; m = m + 1 }
48 while x > 0 {
49 let q: i64 = x / 10
50 d[m] = FG_ASCII0 + (x - q * 10)
51 m = m + 1
52 x = q
53 }
54 while m > 0 { m = m - 1; b[n] = d[m]; n = n + 1 }
55 b[n] = FG_NL
56 n = n + 1
57 sys_write(1, tag, gk_len(tag))
58 sys_write(1, b, n)
59 return 0
60}
61
62func fg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
63
64func main(argc: i64, argv: *i64) -> i64 {
65 let ctr: *i64 = gv_ctr()
66 gv_head("=== NX-FISSURE-GATE -- AT16 palpebral fissure, canthi found on the surface ===" as *u8)
67
68 let base: i64 = sys_mmap(sdf_bytes()) as i64
69 faceanat_build(base)
70 let o: *i64 = sys_mmap(FA_PF_O_FIELDS * 8 + FA_LIP_SLACK) as *i64
71 let r: i64 = fa_palpebral_fissure(base, FG_LEFT, o)
72 fg_pnum("FISSURE left_return=" as *u8, r)
73 fg_pnum("FISSURE left_reason=" as *u8, o[FA_PF_O_REASON])
74 fg_pnum("FISSURE left_medial_x=" as *u8, o[FA_PF_O_MED_X])
75 fg_pnum("FISSURE left_medial_y=" as *u8, o[FA_PF_O_MED_Y])
76 fg_pnum("FISSURE left_lateral_x=" as *u8, o[FA_PF_O_LAT_X])
77 fg_pnum("FISSURE left_lateral_y=" as *u8, o[FA_PF_O_LAT_Y])
78 fg_pnum("FISSURE left_width=" as *u8, o[FA_PF_O_WIDTH])
79 fg_pnum("FISSURE left_peak_depth=" as *u8, o[FA_PF_O_PEAK_D])
80 fg_pnum("FISSURE left_peak_x=" as *u8, o[FA_PF_O_PEAK_X])
81 // The slit span beside the depth: when the slit-vs-bowl bar is ever disputed, the number that
82 // decides it is already in this output rather than needing a rebuild to obtain.
83 fg_pnum("FISSURE left_peak_span=" as *u8, o[FA_PF_O_PEAK_SPAN])
84
85 // T1 -- every tooth below reads these landmarks, so a run that never measured them would score its
86 // outcomes against initialised sentinels and report that as agreement.
87 var t1: i64 = 0
88 if r == 0 { if o[FA_PF_O_REASON] == FA_PF_R_OK { t1 = 1 } }
89 gv_check("fixture-reached-the-condition-the-fissure-was-measured" as *u8, t1, ctr)
90
91 // T2 -- an aperture deeper than the marcher's own resolution. A groove shallower than the sampling
92 // step is not a groove that was measured, it is quantisation wearing a landmark's name.
93 var t2: i64 = 0
94 if o[FA_PF_O_PEAK_D] >= FA_PF_MIN_STEPS * FA_LIP_ZSTEP { t2 = 1 }
95 gv_check("aperture-deeper-than-the-sampling-resolution-that-found-it" as *u8, t2, ctr)
96
97 // T3 -- two DISTINCT landmarks. One point is not a fissure.
98 var t3: i64 = 0
99 if o[FA_PF_O_MED_X] != o[FA_PF_O_LAT_X] { if o[FA_PF_O_WIDTH] > 0 { t3 = 1 } }
100 gv_check("medial-and-lateral-canthi-are-distinct-points" as *u8, t3, ctr)
101
102 // T4 -- THE TOOTH THAT COULD NOT HAVE PASSED BEFORE THIS RUNG. On the old geometry both ends landed
103 // at the same y by construction, so a non-zero separation is the proof the prerequisite is real.
104 var t4: i64 = 0
105 if o[FA_PF_O_MED_Y] != o[FA_PF_O_LAT_Y] { t4 = 1 }
106 gv_check("canthi-sit-at-DIFFERENT-heights-so-a-tilt-axis-can-exist-at-all" as *u8, t4, ctr)
107
108 // T5 -- and the SIGN. A non-zero tilt of the wrong sign passes T4 while describing an anatomy nobody
109 // has; lateral above medial is the positive canthal tilt the canon's population row reports.
110 var t5: i64 = 0
111 if o[FA_PF_O_LAT_Y] > o[FA_PF_O_MED_Y] { t5 = 1 }
112 gv_check("lateral-canthus-sits-ABOVE-medial-a-positive-canthal-tilt" as *u8, t5, ctr)
113
114 // T6 -- surface, not slider: move the lid and the measurement must follow. A ruler that read the part
115 // table would give a plausible number here too, and only a geometry change separates them.
116 let b2: i64 = sys_mmap(sdf_bytes()) as i64
117 faceanat_build(b2)
118 // AT39: the lid is a shell whose opening carries a roll; LEVEL it and the found lateral canthus must come DOWN and the
119 // found medial canthus UP, with the scan still measuring -- a direction, not merely a difference
120 sdf_set_roll(b2, FA_LID_L, 0)
121 let o2: *i64 = sys_mmap(FA_PF_O_FIELDS * 8 + FA_LIP_SLACK) as *i64
122 let r2: i64 = fa_palpebral_fissure(b2, FG_LEFT, o2)
123 fg_pnum("FISSURE levelled_return=" as *u8, r2)
124 fg_pnum("FISSURE levelled_lateral_y=" as *u8, o2[FA_PF_O_LAT_Y])
125 fg_pnum("FISSURE levelled_medial_y=" as *u8, o2[FA_PF_O_MED_Y])
126 var t6: i64 = 0
127 if r2 == 0 { if o2[FA_PF_O_LAT_Y] < o[FA_PF_O_LAT_Y] { if o2[FA_PF_O_MED_Y] > o[FA_PF_O_MED_Y] { t6 = 1 } } }
128 gv_check("surface-not-slider-levelling-the-opening-brings-the-found-lateral-canthus-down-and-the-medial-up" as *u8, t6, ctr)
129
130 // T7 -- NEGATIVE CONTROL, and it is the PRE-AT16 FACE EXACTLY: drop the count back to 27 and the lid
131 // parts are gone. This is the model AT4 was ranked against, and the ruler must refuse BY NAME on it.
132 let b3: i64 = sys_mmap(sdf_bytes()) as i64
133 faceanat_build(b3)
134 let nb3: *i64 = (b3 + O_NPART) as *i64
135 nb3[0] = FG_PRE_AT16_PARTS
136 let o3: *i64 = sys_mmap(FA_PF_O_FIELDS * 8 + FA_LIP_SLACK) as *i64
137 let r3: i64 = fa_palpebral_fissure(b3, FG_LEFT, o3)
138 fg_pnum("FISSURE no_lids_return=" as *u8, r3)
139 fg_pnum("FISSURE no_lids_reason=" as *u8, o3[FA_PF_O_REASON])
140 fg_pnum("FISSURE no_lids_peak_depth=" as *u8, o3[FA_PF_O_PEAK_D])
141 var t7: i64 = 0
142 if r3 == FA_LIP_UNMEASURED {
143 if o3[FA_PF_O_MED_X] == FA_LIP_UNMEASURED {
144 if o3[FA_PF_O_REASON] != FA_PF_R_OK { t7 = 1 }
145 }
146 }
147 gv_check("neg-control-the-pre-AT16-face-with-no-lids-refuses-by-name-and-returns-no-landmark" as *u8, t7, ctr)
148
149 // T8 -- the two eyes are one code path driven by a sign, so a mirrored reading must agree in
150 // magnitude. An extractor that had hard-coded one eye passes everything above and fails only here.
151 let o4: *i64 = sys_mmap(FA_PF_O_FIELDS * 8 + FA_LIP_SLACK) as *i64
152 let r4: i64 = fa_palpebral_fissure(base, FG_RIGHT, o4)
153 fg_pnum("FISSURE right_return=" as *u8, r4)
154 fg_pnum("FISSURE right_medial_y=" as *u8, o4[FA_PF_O_MED_Y])
155 fg_pnum("FISSURE right_lateral_y=" as *u8, o4[FA_PF_O_LAT_Y])
156 fg_pnum("FISSURE right_width=" as *u8, o4[FA_PF_O_WIDTH])
157 var t8: i64 = 0
158 if r4 == 0 {
159 if o4[FA_PF_O_WIDTH] == o[FA_PF_O_WIDTH] {
160 if o4[FA_PF_O_MED_Y] == o[FA_PF_O_MED_Y] {
161 if o4[FA_PF_O_LAT_Y] == o[FA_PF_O_LAT_Y] { t8 = 1 }
162 }
163 }
164 }
165 gv_check("mirror-invariant-both-eyes-read-the-same-magnitudes-through-one-signed-path" as *u8, t8, ctr)
166
167 // RAW COLUMN PROFILES, printed unconditionally -- the instrument the last four designs never had.
168 // Four discrimination mechanisms in a row were designed from armchair geometry and each was refuted
169 // by its own negative control; the fifth gets designed FROM THESE NUMBERS. One mid-eye column
170 // (x=-258), wider than the measurement band on both ends so the lid apexes and brow slope are
171 // visible, for the with-lids face and the no-lids face side by side.
172 var py: i64 = 340
173 while py >= 40 {
174 fg_pnum("PROFILE y=" as *u8, py)
175 fg_pnum("PROFILE lids_z=" as *u8, fa_surface_z(base, 0 - 258, py))
176 fg_pnum("PROFILE bare_z=" as *u8, fa_surface_z(b3, 0 - 258, py))
177 py = py - 12
178 }
179 return gv_verdict("NX-FISSURE-GATE" as *u8, ctr, "AT16: the eye has an aperture whose two ends are found on the rendered surface, so a canthal axis has a subject for the first time" as *u8)
180}