code wiki / _hdl_build / nx_softdyn_gate.nx
nx_softdyn_gate.nx source
↩ module page · 166 lines · 7868 B
1// nx_softdyn_gate.nx -- prove the secondary-dynamics solver is REAL PHYSICS, not a wobble hack.
2// T1 INERTIAL LAG soft mass trails an accelerating anchor (that IS jiggle)
3// T2 OVERSHOOT when the anchor stops, the mass passes THROUGH it (sign change) = oscillation
4// T3 DAMPED SETTLE energy decays and it comes to rest (no perpetual motion)
5// T4 IMPULSE/RECOIL a kick on a still point displaces then returns -- the SAME solver serves firearms
6// T5 BOUNDED a violent anchor can never separate tissue past the clamp (divergence impossible)
7// T6 DETERMINISM identical replay, bit-for-bit
8// T7 ANTI-VACUITY a STIFF+damped config shows ~no lag => T1's lag is the SOLVER, not an always-on bug
9// license_tier: ORIGINAL expect_exit: 0
10import "nx_syscalls.nx"
11import "nx_softdyn.nx"
12import "nx_gate_verdict.nx"
13
14const SG_SOFT_K: i64 = 120
15const SG_SOFT_C: i64 = 100
16const SG_STIFF_K: i64 = 900
17const SG_STIFF_C: i64 = 800
18const SG_MAXD: i64 = 40
19
20func sg_hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
21func sg_pn(v: i64) -> i64 {
22 let b: *u8=sys_mmap(32); var x: i64=v; var ng: i64=0
23 if x<0 { ng=1; x=0-x }
24 var i: i64=31
25 if x==0 { b[i]=48 as u8; i=i-1 }
26 while x>0 { b[i]=(48+x%10) as u8; x=x/10; i=i-1 }
27 if ng==1 { b[i]=45 as u8; i=i-1 }
28 sys_write(1,(b as i64+i+1) as *u8,31-i); return 0
29}
30
31func main() -> i64 {
32 // MIGRATED off a hand-rolled verdict 2026-08-25. It printed "VERDICT=GREEN 7/7" itself, so
33 // /api/promote refused it D001: nothing outside could READ its outcome, nx_gate_green could not
34 // judge it, and it recorded no harness frame -- so flake and erosion stayed invisible for the
35 // one gate that proves the solver every animated thing inherits. Per-tooth gv_check also makes
36 // declared == executed BY CONSTRUCTION: a tooth that silently stops running lowers BOTH numbers
37 // instead of leaving a hand-kept denominator lying about coverage.
38 let ctr: *i64 = gv_ctr()
39 gv_head("nx_softdyn_gate -- secondary dynamics (jiggle / recoil) is real physics" as *u8)
40
41 // ---------- T1/T2/T3: anchor accelerates upward 30 ticks, then STOPS. ----------
42 let st: *i64 = sd_alloc(4)
43 sd_seat(st, 0, 0, 0, 0)
44 var maxlag: i64 = 0
45 var tk: i64 = 0
46 var ay: i64 = 0
47 while tk < 30 {
48 ay = ay + 3 // anchor rises 3 units/tick (bone motion)
49 sd_step(st, 0, 0, ay, 0, SG_SOFT_K, SG_SOFT_C, SG_MAXD)
50 let d: i64 = sd_disp(st, 0, 0, ay, 0)
51 if d > maxlag { maxlag = d }
52 tk = tk + 1
53 }
54 sg_hw(" T1 peak inertial lag while accelerating = " as *u8); sg_pn(maxlag); sg_hw(" units\n" as *u8)
55 var t1: i64 = 0
56 if maxlag >= 3 { t1 = 1 }
57 gv_check("T1 INERTIAL LAG present (a soft mass trails an accelerating anchor -- that IS jiggle)" as *u8, t1, ctr)
58
59 // anchor now HOLDS still; the mass must swing through it (overshoot) then settle
60 // measured in Q8 SUB-UNITS: a jiggle of a fraction of a model unit is still a real oscillation
61 var signflips: i64 = 0
62 var prev: i64 = sd_disp_y_q8(st, 0, ay)
63 var e0: i64 = sd_energy(st, 0)
64 var settle: i64 = 0 - 1
65 tk = 0
66 while tk < 400 {
67 sd_step(st, 0, 0, ay, 0, SG_SOFT_K, SG_SOFT_C, SG_MAXD)
68 let cur: i64 = sd_disp_y_q8(st, 0, ay)
69 if prev > 0 { if cur < 0 { signflips = signflips + 1 } }
70 if prev < 0 { if cur > 0 { signflips = signflips + 1 } }
71 prev = cur
72 if settle < 0 { if sd_disp_q8(st, 0, 0, ay, 0) < 26 { settle = tk } }
73 tk = tk + 1
74 }
75 let e1: i64 = sd_energy(st, 0)
76 sg_hw(" T2 overshoot sign-changes = " as *u8); sg_pn(signflips)
77 sg_hw(" T3 energy " as *u8); sg_pn(e0); sg_hw(" -> " as *u8); sg_pn(e1)
78 sg_hw(", settled at tick " as *u8); sg_pn(settle); sg_hw("\n" as *u8)
79 var t2: i64 = 0
80 if signflips >= 1 { t2 = 1 }
81 gv_check("T2 OVERSHOOT (the mass passes THROUGH the stopped anchor -- oscillation, not decay)" as *u8, t2, ctr)
82 var t3: i64 = 0
83 if e1 < e0 { if settle >= 0 { t3 = 1 } }
84 gv_check("T3 DAMPED SETTLE (energy decays AND it reaches rest -- no perpetual motion)" as *u8, t3, ctr)
85
86 // ---------- T4: IMPULSE = firearm recoil on a still mount (same solver) ----------
87 sd_seat(st, 1, 0, 0, 0)
88 sd_impulse(st, 1, 0, 0, 0-3200) // sharp kick backward
89 var peak: i64 = 0
90 var back: i64 = 0 - 1
91 tk = 0
92 while tk < 300 {
93 sd_step(st, 1, 0, 0, 0, SG_SOFT_K, SG_SOFT_C, SG_MAXD)
94 let d: i64 = sd_disp(st, 1, 0, 0, 0)
95 if d > peak { peak = d }
96 if back < 0 { if tk > 5 { if sd_disp_q8(st, 1, 0, 0, 0) < 26 { back = tk } } }
97 tk = tk + 1
98 }
99 sg_hw(" T4 recoil peak displacement = " as *u8); sg_pn(peak)
100 sg_hw(" units, returned to rest at tick " as *u8); sg_pn(back); sg_hw("\n" as *u8)
101 var t4: i64 = 0
102 if peak > 0 { if back > 0 { t4 = 1 } }
103 gv_check("T4 IMPULSE/RECOIL (a kick displaces then returns -- the SAME solver serves firearms)" as *u8, t4, ctr)
104
105 // ---------- T5: BOUNDED under a violent anchor ----------
106 sd_seat(st, 2, 0, 0, 0)
107 var worst: i64 = 0
108 tk = 0
109 while tk < 600 {
110 var a: i64 = 0
111 if (tk/4)%2 == 0 { a = 900 } // teleport the anchor back and forth violently
112 sd_step(st, 2, 0, a, 0, SG_SOFT_K, SG_SOFT_C, SG_MAXD)
113 let d: i64 = sd_disp(st, 2, 0, a, 0)
114 if d > worst { worst = d }
115 tk = tk + 1
116 }
117 sg_hw(" T5 worst separation under violent anchor = " as *u8); sg_pn(worst)
118 sg_hw(" (clamp " as *u8); sg_pn(SG_MAXD); sg_hw(")\n" as *u8)
119 var t5: i64 = 0
120 if worst <= SG_MAXD { t5 = 1 }
121 gv_check("T5 BOUNDED (a violent anchor can never separate tissue past the clamp)" as *u8, t5, ctr)
122
123 // ---------- T6: DETERMINISM ----------
124 let r1: *i64 = sd_alloc(1)
125 let r2: *i64 = sd_alloc(1)
126 sd_seat(r1,0,0,0,0); sd_seat(r2,0,0,0,0)
127 sd_impulse(r1,0,700,0-1500,300); sd_impulse(r2,0,700,0-1500,300)
128 var c1: i64 = 0; var c2: i64 = 0
129 tk = 0
130 while tk < 200 {
131 let a2: i64 = (tk*7)%50
132 sd_step(r1,0,a2,a2/2,0,SG_SOFT_K,SG_SOFT_C,SG_MAXD)
133 sd_step(r2,0,a2,a2/2,0,SG_SOFT_K,SG_SOFT_C,SG_MAXD)
134 c1 = (c1*31 + sd_disp(r1,0,a2,a2/2,0)) & 1073741823
135 c2 = (c2*31 + sd_disp(r2,0,a2,a2/2,0)) & 1073741823
136 tk = tk + 1
137 }
138 sg_hw(" T6 replay checksums " as *u8); sg_pn(c1); sg_hw(" vs " as *u8); sg_pn(c2); sg_hw("\n" as *u8)
139 var t6: i64 = 0
140 if c1 == c2 { t6 = 1 }
141 gv_check("T6 DETERMINISM (identical replay, bit-for-bit -- netsync and save-transparency rest on it)" as *u8, t6, ctr)
142
143 // ---------- T7 ANTI-VACUITY: stiff + heavily damped => essentially NO lag ----------
144 sd_seat(st, 3, 0, 0, 0)
145 var stifflag: i64 = 0
146 var ay2: i64 = 0
147 tk = 0
148 while tk < 30 {
149 ay2 = ay2 + 3
150 sd_step(st, 3, 0, ay2, 0, SG_STIFF_K, SG_STIFF_C, SG_MAXD)
151 let d: i64 = sd_disp(st, 3, 0, ay2, 0)
152 if d > stifflag { stifflag = d }
153 tk = tk + 1
154 }
155 sg_hw(" T7 stiff-config peak lag = " as *u8); sg_pn(stifflag)
156 sg_hw(" vs soft " as *u8); sg_pn(maxlag); sg_hw("\n" as *u8)
157 // Named neg-control- so the L2 census can SEE it: three of this estate's gates already HAD
158 // controls and failed the census purely on naming. A control nobody can find is a control
159 // nobody maintains. A stiff+damped config must show ~no lag, which is what proves T1's lag is
160 // the SOLVER responding to its parameters and not an always-on artefact.
161 var t7: i64 = 0
162 if stifflag < maxlag { t7 = 1 }
163 gv_check("neg-control-anti-vacuity-stiff-config-shows-no-lag (config controls jiggle)" as *u8, t7, ctr)
164
165 return gv_verdict("SOFTDYN-GATE" as *u8, ctr, "the solver every animated thing inherits: lag, overshoot, damping, recoil, bounds, determinism" as *u8)
166}