code wiki / _hdl_build / nx_proportion_guard_gate.nx
nx_proportion_guard_gate.nx source
↩ module page · 72 lines · 3968 B
1// nx_proportion_guard_gate.nx -- the ruler for nx_proportion_guard.nx.
2// Operator's law: "the human being has a finite range, and even fantasy or other things would
3// have finite proportions and ranges though they may be ideal or what not."
4// So the teeth check three separate things, and all three are needed:
5// the table is internally sound (T1-T5) · the guard REFUSES bad input (T6-T9) ·
6// generators actually draw through it (T10-T11).
7// license_tier: ORIGINAL No hw writes (Rule 26).
8import "nx_syscalls.nx"
9import "nx_gate_verdict.nx"
10import "nx_proportion_guard.nx"
11import "nx_softtissue.nx"
12
13func main(argc: i64, argv: *i64) -> i64 {
14 let ctr: *i64 = gv_ctr()
15 gv_head("nx_proportion_guard_gate -- every body axis is finite, in every regime" as *u8)
16
17 let f: i64 = pg_selftest()
18 gv_puts(" table selftest faultmask=" as *u8); gv_num(f); gv_puts(" (need 0)\n" as *u8)
19 gv_check("T1 no envelope has min >= max" as *u8, ((f & 1) == 0) as i64, ctr)
20 gv_check("T2 IDEALIZED stays strictly inside HUMAN" as *u8, ((f & 2) == 0) as i64, ctr)
21 gv_check("T3 KIN is wider than HUMAN (fantasy is broader, not narrower)" as *u8,
22 ((f & 4) == 0) as i64, ctr)
23 gv_check("T4 every listed axis carries all three regimes" as *u8, ((f & 8) == 0) as i64, ctr)
24 gv_check("T5 FANTASY IS STILL FINITE: no bound crosses the absolute ceiling" as *u8,
25 ((f & 16) == 0) as i64, ctr)
26
27 // The guard must REFUSE, not shrug.
28 gv_check("T6 a 2 metre breast diameter is REFUSED as above-range" as *u8,
29 (pg_check(NX_AXIS_BREAST_DIAMETER, 2000, PG_HUMAN) == PG_ABOVE) as i64, ctr)
30 gv_check("T7 a 3 mm breast diameter is REFUSED as below-range" as *u8,
31 (pg_check(NX_AXIS_BREAST_DIAMETER, 3, PG_HUMAN) == PG_BELOW) as i64, ctr)
32 gv_check("T8 a plausible 150 mm diameter is accepted" as *u8,
33 (pg_check(NX_AXIS_BREAST_DIAMETER, 150, PG_HUMAN) == PG_OK) as i64, ctr)
34 // The decision that makes it a guard rather than a suggestion.
35 gv_check("T9 an axis with NO BOUND ROW is REFUSED (missing is not permission)" as *u8,
36 (pg_check(9991, 100, PG_HUMAN) == PG_NO_BOUND) as i64, ctr)
37
38 // A value that passes HUMAN may still be outside IDEALIZED -- regimes must actually differ,
39 // or "idealized" is decoration.
40 gv_check("T10 regimes bite differently: 100mm is human but not idealized" as *u8,
41 (pg_check(NX_AXIS_BREAST_DIAMETER, 100, PG_HUMAN) == PG_OK &&
42 pg_check(NX_AXIS_BREAST_DIAMETER, 100, PG_IDEALIZED) == PG_BELOW) as i64, ctr)
43
44 // Generators must DRAW THROUGH the envelope. Sweep seeded bodies and check the axes the
45 // soft-tissue sampler produces land inside the envelope it claims to sample from.
46 var bad: i64 = 0
47 var lo: i64 = 999999
48 var hi: i64 = 0
49 var s: i64 = 0
50 while s < 24 {
51 let pid: i64 = ST_PROF_SEED_BASE + s
52 let diam: i64 = st_profile(pid, ST_PF_A_MM) * 2
53 let proj: i64 = st_profile(pid, ST_PF_C_MM)
54 if pg_check(NX_AXIS_BREAST_DIAMETER, diam, PG_IDEALIZED) != PG_OK { bad = bad + 1 }
55 if pg_check(NX_AXIS_BREAST_PROJECTION, proj, PG_IDEALIZED) != PG_OK { bad = bad + 1 }
56 if diam < lo { lo = diam }
57 if diam > hi { hi = diam }
58 s = s + 1
59 }
60 gv_puts(" 24 seeded bodies: diameter " as *u8); gv_num(lo)
61 gv_puts(".." as *u8); gv_num(hi)
62 gv_puts(" mm, out-of-envelope=" as *u8); gv_num(bad); gv_puts("\n" as *u8)
63 gv_check("T11 every seeded body lands inside the envelope BY CONSTRUCTION" as *u8,
64 (bad == 0) as i64, ctr)
65 // Bounded must not mean identical -- the guard must constrain without collapsing variety.
66 gv_check("T12 the envelope still permits real variation (spread > 25 mm)" as *u8,
67 (hi - lo > 25) as i64, ctr)
68
69 sys_exit(gv_verdict("PROPORTION-GUARD" as *u8, ctr,
70 "finite ranges, refusal on the unknown, variety preserved" as *u8))
71 return 0
72}