EV-10 round 3: grade the floor case on the same landing with and without the car; per-quarter latches independent of the cover option; stricter write-mute test
checks / unit (pull_request) Successful in 20m56s
infra-pin / fresh (pull_request) Successful in 1s

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-11-16 19:28:02 +01:00
parent 646f61e730
commit 269b89d6b0
3 changed files with 100 additions and 42 deletions
+31 -16
View File
@@ -52,7 +52,8 @@ class CarMixin:
self._car_over_since = None
self._car_over_gone = None
self._car_batt_prev = None
self._car_needed = False # EV-10: SAFETY-126's latch without the car
self._car_need_real = self._car_need_excl = False # EV-10 latches
self._car_latch_block = None
self._car_over_notified = None # the session a notice was raised for
self._car_session = 0
self._car_prev_state = None
@@ -262,11 +263,10 @@ class CarMixin:
explains = over = False
if real_proj is not None and target_w is not None \
and real_proj.block_start is not None:
# EV-10: every cycle, so the latches do not depend on the option.
graded = self._car_explains_alarm(real_proj, guard, target_w, w)
if self.car_cover:
# EV-10: the car explains the ALARM (`_car_explains_alarm`).
explains = self._car_explains_alarm(real_proj, guard,
target_w, w)
over = explains
explains = over = graded
elif w is not None:
ex = float(real_proj.projected_w) - float(target_w)
over = ex > 0.0 and self.car_avg_w(real_proj, w) >= ex
@@ -289,26 +289,40 @@ class CarMixin:
def _car_explains_alarm(self, real_proj, guard, target_w, w) -> bool:
"""EV-10: is the alarm's own test true with the car and false without
its fresh, corroborated share (`car_exclude`)? The tests are the
alarms': a saturated guard and a floor with other batteries left are
graded by `load_too_high` on where the period lands (SAFETY-81 / 87); a
floor that leaves nothing is graded by `within_aim`, which SAFETY-126
latches for the quarter once the batteries at 0 W would miss the aim.
`_car_needed` is that latch on the period without the car; an
untrusted car figure (`w` None) sets it, so nothing is explained."""
its fresh, corroborated share (`car_exclude`), on the same landing? The
tests are the alarms': a saturated guard and a floor with other
batteries left are graded by `load_too_high` on where the period lands
(SAFETY-81 / 87); a floor that leaves nothing is graded by SAFETY-126's
`misses_aim` (the batteries at 0 W from now on), latched for the
quarter. That latch is kept here twice, on the period as it is
(`_car_need_real`) and without the car (`_car_need_excl`), from the
same `misses_aim` and the same batteries reading. Both reset at a new
quarter and when the guard no longer wants power, whatever the cover
option says (this runs every cycle). A car that is 0 W, or untrusted
(`w` None sets the second latch), makes the two equal and explains
nothing."""
batt, prev = self.site_batt_w, self._car_batt_prev
self._car_batt_prev = batt
wants = bool(guard is not None and guard.engaged
and guard.blind is None
and (guard.wanted_w or 0.0) > 0.0)
if real_proj.block_start != self._car_latch_block:
self._car_latch_block = real_proj.block_start
self._car_need_real = self._car_need_excl = False
if not wants:
self._car_needed = False
self._car_need_real = self._car_need_excl = False
if batt is not None and prev is not None:
batt = min(float(batt), float(prev))
excl = self.car_exclude(real_proj, w)
if wants:
self._car_needed = self._car_needed or w is None or batt is None \
or peakguard.misses_aim(excl, batt_w=batt, target_w=target_w)
if batt is None:
self._car_need_real = self._car_need_excl = True
else:
self._car_need_real = self._car_need_real or \
peakguard.misses_aim(real_proj, batt_w=batt,
target_w=target_w)
self._car_need_excl = self._car_need_excl or w is None or \
peakguard.misses_aim(excl, batt_w=batt, target_w=target_w)
if w is None or batt is None or not wants \
or not (guard.saturated or guard.floor_limited):
return False
@@ -317,7 +331,8 @@ class CarMixin:
elif (guard.floor_w or 0.0) > 0.0 and guard.able_w is not None:
rating = guard.able_w
else:
return bool(not guard.within_aim and not self._car_needed)
return bool(not guard.within_aim and self._car_need_real
and not self._car_need_excl)
def high(p):
return peakguard.load_too_high(