You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7819e97
Browse filesBrowse the repository at this point in the historyBrowse files
fix(octopus): don't keep the grace clock across a restart; judge saved state on the skewed clock (#5316 review)
- The "not charging since" clock is no longer saved. A restart is a stretch with
no evidence, after which the running check starts the grace afresh - the car
may have charged meanwhile - and restoring it cancelled on the first "off"
reading. It also changed with every flap of an unreliable sensor, rewriting
the store from the 15 second poll.
- Saved times are recorded on the clock_skew axis, so what is still current is
now judged on it too rather than on now_utc_real.
- A confirmation whose half hour is over is dropped from the saved state.
- The storage mocks used by the plan and dynamic load persistence tests move to
tests/test_infra.py.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
failed|=_check("t49 still trusted", my_predbat.dynamic_load_car_cancelled.get(0) isFalse, "cancelled {}".format(my_predbat.dynamic_load_car_cancelled))
1142
-
# The grace runs from the restored clock, not from the restart
1141
+
# The car may have charged while Predbat was down, so the grace runs from the first reading after the restart
1143
1142
changed=_cycle(my_predbat, 404, 30, slots=slots)
1144
-
failed|=_check("t49 cancelled on the restored clock", changedandmy_predbat.dynamic_load_car_cancelled.get(0), "changed {}".format(changed))
1143
+
failed|=_check("t49 not cancelled on the old clock", notchangedandnotmy_predbat.dynamic_load_car_cancelled.get(0), "changed {}".format(changed))
1144
+
changed=_cycle(my_predbat, 406, 30, slots=slots)
1145
+
failed|=_check("t49 cancelled after a fresh grace", changedandmy_predbat.dynamic_load_car_cancelled.get(0), "changed {}".format(changed))
1145
1146
failed|=_check("t49 strip from 07:00", my_predbat.dynamic_load_car_strip_from(0) ==420, "strip from {}".format(my_predbat.dynamic_load_car_strip_from(0)))
1146
1147
1147
1148
print("Test 50: a cancellation survives a restart, with no evidence either way after it")
# With the clock 5 minutes fast, 06:52 real is 06:57 on the plan's clock
1185
+
my_predbat.args["clock_skew"] =5
1186
+
_cycle(my_predbat, 387, slots=slots)
1187
+
failed|=_check("t53 confirmed 06:30-07:00 on the skewed clock", my_predbat.dynamic_load_car_confirmed.get(0) ==my_predbat.midnight_utc+timedelta(minutes=420), "confirmed {}".format(my_predbat.dynamic_load_car_confirmed))
1188
+
# Real 06:57 is 07:02 on the plan's clock: that half hour is over
1189
+
_at(my_predbat, 417)
1190
+
_restart(my_predbat)
1191
+
failed|=_check("t53 over on the skewed clock is not restored", my_predbat.dynamic_load_car_confirmed.get(0) isNone, "confirmed {}".format(my_predbat.dynamic_load_car_confirmed))
1192
+
finally:
1193
+
ifsaved_skewisNone:
1194
+
my_predbat.args.pop("clock_skew", None)
1195
+
else:
1196
+
my_predbat.args["clock_skew"] =saved_skew
1197
+
1198
+
print("Test 54: a comparison run, a car with no dispatch and a missing or broken store write and restore nothing")
0 commit comments