EV-22 review round 1: press covers one reading, unknown read keeps the count, window ends on the close's clock
checks / unit (pull_request) Successful in 53m40s
infra-pin / fresh (pull_request) Successful in 2s

Major 1: the `pressed` mark of a sequence is consumed by the first `_advance`
(the first reading judged after the press); a later raise in the same zero
stage gets the raise-check hold again (Solar and Manual).
Major 2: with `cur` None `_watch` does not judge the current: the count
neither starts nor clears (phases are still judged).
Finding 4 (PM): the DA3 window uses the close's own clock and comparison
(`now - t1 < SETTLE_S`) and the one step that closes at its end is still
inside it, so a `last_done` a fraction of a second after the step's now no
longer pushes the close step outside the window.
Tests: rows A-D, R1 (Manual red under the mutant), the two fraction rows,
all red on b7c91ff. test_ev60: comment exactly as ruled, unused imports gone.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-12-03 12:30:17 +01:00
parent b7c91ff746
commit e0e51dac12
4 changed files with 194 additions and 20 deletions
+32 -16
View File
@@ -310,6 +310,9 @@ class ManualWriter:
before our own write of this step, so the current is not judged and
the count stands."""
known, diff = [], None
if cur is None:
judge = False # an unknown read: the count neither starts
# nor clears (phases are still judged)
if judge:
known = self._own_values()
if known and cur is not None:
@@ -492,6 +495,7 @@ class ManualWriter:
async def _advance(self, drv, r, cur, now, tracker, want_a, clamp, rev):
q = self.seq
pressed = q.pop("pressed", False) # covers the first reading only
if q["stage"] in ("zero", "select") and cur is not None \
and cur >= CH.MIN_A:
# Something else raised the current while the car was being
@@ -500,9 +504,11 @@ class ManualWriter:
# changes something.
self.seq = None
self.last_a = self.attempted_a = self.prior_a = None
if q.get("pressed"):
# EV-22 (DA1): the user's change came during this change: the
# charger is taken as it is, never held over that value.
if pressed:
# EV-22 (DA1): the user's change came during this change and
# this is the first reading judged after it: the charger is
# taken as it is, never held over that value. A later raise
# is held as ever.
self._took_as_is()
return
self.hold = self.other = True
@@ -968,12 +974,13 @@ class SolarWriter(ManualWriter):
self.refused_cut = None # a cut value the charger did not take
self._cap_end = False # EV-60: a capped close ended the change
# EV-22 (D4): the phases Solar itself chose. `_own_n`: the last it
# TOOK (or the start state); `_sel_n` and `_win_end`: its latest
# select try and the SETTLE_S after that try returned, in which a
# read-back is not judged.
# TOOK (or the start state); `_sel_n` and `_win_t1`: its latest
# select try and when that try returned; SETTLE_S after it (and the
# one step that closes there, `_win_last`) a read-back is not judged.
self._own_n = None
self._sel_n = None
self._win_end = None
self._win_t1 = None
self._win_last = False
def owe_start(self) -> None:
"""C1: the add-on starts in Off while an exit 0 A of its own was still
@@ -1349,7 +1356,8 @@ class SolarWriter(ManualWriter):
unless it is kept."""
self._own_n, self._ph_diff = None, False
if window:
self._sel_n = self._win_end = None
self._sel_n = self._win_t1 = None
self._win_last = False
def _select_try(self, n, ok) -> None:
"""EV-22 (DA3): our own select try returned. SETTLE_S from now a
@@ -1357,23 +1365,31 @@ class SolarWriter(ManualWriter):
taken select is our phases at once, one the charger did not confirm
becomes ours if a read inside the window shows it."""
self._sel_n = n
self._win_end = float(self.last_done) + SETTLE_S
self._win_t1 = float(self.last_done)
self._win_last = False
if ok:
self._own_n, self._ph_diff = n, False
def _judge_phases(self, r, now) -> None:
"""EV-22 (D4): the read-back phases against the phases Solar itself
chose (never the plan's adopted `n`). Unknown phases and reads inside
a select's window start nothing and lift nothing."""
a select's window start nothing and lift nothing. The window is the
sequence's settle time on the same clock and with the same
comparison as the close (`now - t1 < SETTLE_S`), and the one step
that closes at its end is still inside it, whatever fraction of a
second `last_done` lies after the step's `now`."""
p = getattr(r, "phases_allowed", None)
if p not in (1, 3):
return
if self._win_end is not None:
if now <= self._win_end:
if p == self._sel_n:
if self._win_t1 is not None:
inside = now - self._win_t1 < SETTLE_S
if not inside and not self._win_last:
self._win_last = inside = True # the closing step
if inside:
if p in (1, 3) and p == self._sel_n:
self._own_n, self._ph_diff = p, False # the take
return
self._sel_n = self._win_end = None
self._sel_n = self._win_t1 = None
if p not in (1, 3):
return
if self._own_n is None:
self._own_n, self._ph_diff = p, False # the start state
return