Commit 4ecd10f
committed
fix: validation stopped at the arguments, and three paths went around it
The checks added here guard what is passed in. Three things the actuator then
derives from those arguments were left unguarded, and each one puts a
non-finite number into the output the integrator reads.
The range was checked for ordering only, so `(inf, inf)` passed. Clamping a
finite initial output against it stores `inf`, and the next ordinary command
lands on `(1 - alpha) * inf`, which is `0.0 * inf`, and stores NaN. `_reset()`
then restores it at the start of every later flight. `(-inf, -inf)` is the same
in the other direction, and both are reachable through
`Rocket.add_throttle_control`.
Endpoints still are not required to be finite, because an infinite bound is how
this class says "unbounded on that side" and the base default really is
`(-inf, inf)`. The weaker property is what matters and is what is now checked:
clamping a finite value has to give back a finite one. Given `lower <= upper`
that fails exactly when the lower bound is `+inf` or the upper is `-inf`, so
one-sided ranges such as `(0, inf)` are unaffected.
The endpoints are also copied into a new tuple. They were the caller's own
object, so a list mutated after construction moved the range out from under a
validation that had already run.
The IIR coefficient forms `Ts = 1 / demand_rate` before combining it with the
time constant, and that intermediate is not something either argument contains.
A subnormal demand rate of 5e-324 is finite and positive and passes every check
at the boundary, but `1.0 / 5e-324` is `inf` and `inf / (1.0 + inf)` is NaN, so
the first finite command stores NaN and stays there. A time constant of 1e308
overflows the denominator the other way and pins alpha to zero, freezing the
actuator where the answer is about 0.5. Writing the same expression as
`1 / (1 + tau * rate)` avoids forming the intermediate at all. Over 2000 random
pairs across the ranges a real configuration uses, the two agree to 2.2e-16.
The third is in `rocket.py`. Each `add_*_control` built the actuator and the
controller from the same argument, and only the actuator normalized it. With
`sampling_rate="100"` the actuator held `100.0` and the controller held
`"100"`, the call returned a rocket that looked complete, and the failure
surfaced later inside Flight at `1 / controller.sampling_rate`. The controller
now takes the actuator's normalized value. Refusing strings and bools outright
is the other available fix and is a wider behaviour change than this needs.
Thrust vector control reads that value off its x axis: `ThrustVectorActuator2D`
holds no `demand_rate` of its own, only the two axes it builds from the
argument. Its class docstring lists one, along with six other attributes it
also never assigns. That gap is left alone here.
Seven mutations, one per fix and one per call site, each fail a named test; a
control mutation survives. Existing suites unchanged: unit 1945 passed with the
four pre-existing test_sensitivity import failures, integration and acceptance
168 passed.
Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>1 parent f55358e commit 4ecd10f
4 files changed
Lines changed: 261 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
50 | 93 | | |
51 | 94 | | |
52 | 95 | | |
| |||
102 | 145 | | |
103 | 146 | | |
104 | 147 | | |
105 | | - | |
| 148 | + | |
| 149 | + | |
106 | 150 | | |
107 | 151 | | |
108 | | - | |
109 | | - | |
110 | | - | |
| 152 | + | |
| 153 | + | |
111 | 154 | | |
112 | 155 | | |
113 | 156 | | |
| |||
153 | 196 | | |
154 | 197 | | |
155 | 198 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
159 | 212 | | |
160 | 213 | | |
161 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2095 | 2095 | | |
2096 | 2096 | | |
2097 | 2097 | | |
2098 | | - | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
2099 | 2113 | | |
2100 | 2114 | | |
2101 | 2115 | | |
| |||
2228 | 2242 | | |
2229 | 2243 | | |
2230 | 2244 | | |
2231 | | - | |
| 2245 | + | |
| 2246 | + | |
2232 | 2247 | | |
2233 | 2248 | | |
2234 | 2249 | | |
| |||
2364 | 2379 | | |
2365 | 2380 | | |
2366 | 2381 | | |
2367 | | - | |
| 2382 | + | |
| 2383 | + | |
2368 | 2384 | | |
2369 | 2385 | | |
2370 | 2386 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
0 commit comments