From 4b4a4c10535353c6156a04d886566c0343afa711 Mon Sep 17 00:00:00 2001 From: "Claude (review agent)" Date: Sat, 21 Nov 2026 22:58:56 +0100 Subject: [PATCH] EV-28 review: pin the restore step in T17a and the counted failure in T15 Review fixes, no logic change: - T17a now asserts the restore is the first write once the charger is back (it was only checked to happen at some point); mutant M3 (restore after SETTLE_S) now turns T17a red. - T15 now asserts the refused restore is counted once (`fails == 1`); a mutant without `_failed` there now turns T15 red. - DECISIONS "The phase sequence" and the carmode docstring reflowed to 79 columns; DECISIONS says D counts as drawing too, as the code does. Co-Authored-By: Claude --- goodwe_controller/DECISIONS/EV-04-manual-mode.md | 16 ++++++++-------- goodwe_controller/app/carmode.py | 6 +++--- goodwe_controller/test_ev28.py | 11 +++++++---- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/goodwe_controller/DECISIONS/EV-04-manual-mode.md b/goodwe_controller/DECISIONS/EV-04-manual-mode.md index 607569f..39c2fa1 100644 --- a/goodwe_controller/DECISIONS/EV-04-manual-mode.md +++ b/goodwe_controller/DECISIONS/EV-04-manual-mode.md @@ -30,14 +30,14 @@ code had to decide that the design left open. ## The phase sequence -0 A, wait until the charger reports under 100 W (mode3 leaving C counts only -when there is no power reading; 20 s at most), select the phases, wait 10 s, write the current. One switch per 10 minutes. A -charger that does not take the 0 A never gets the phases select. A car still -drawing after 20 s gets no select: its current comes back and it counts as a -failed try (EV-28). A sequence that -has begun is finished whatever the mode, because it leaves the car at 0 A -otherwise; a stop of the add-on in the middle gives the car its current back -(`car_shutdown`). +0 A, wait until the charger reports under 100 W (mode3 leaving C and D counts +only when there is no power reading; 20 s at most), select the phases, wait +10 s, write the current. One switch per 10 minutes. A charger that does not +take the 0 A never gets the phases select. A car still drawing after 20 s gets +no select: its current comes back and it counts as a failed try (EV-28). A +sequence that has begun is finished whatever the mode, because it leaves the +car at 0 A otherwise; a stop of the add-on in the middle gives the car its +current back (`car_shutdown`). ## Another writer diff --git a/goodwe_controller/app/carmode.py b/goodwe_controller/app/carmode.py index dbaafb0..af18a32 100644 --- a/goodwe_controller/app/carmode.py +++ b/goodwe_controller/app/carmode.py @@ -17,9 +17,9 @@ THE RULES, each tested in test_ev04.py: * Phases change only through the SAFE SEQUENCE: 0 A, wait until the charger reports under `QUIET_W` (mode3 leaving C only without a power reading; at most `ZERO_WAIT_S`, then the current comes back and it counts as a failed - try), select the phases, wait `SETTLE_S`, write the current again. At most one switch per - `PHASE_GAP_S`. A sequence that has begun is always finished, because it - leaves the car at 0 A otherwise. + try), select the phases, wait `SETTLE_S`, write the current again. At most + one switch per `PHASE_GAP_S`. A sequence that has begun is always finished, + because it leaves the car at 0 A otherwise. * A read-back that differs from the add-on's own last write for `WRITER_S` is ANOTHER WRITER: an info row, and no write over it until the user changes the mode or a value again. diff --git a/goodwe_controller/test_ev28.py b/goodwe_controller/test_ev28.py index 378c3a1..710537e 100644 --- a/goodwe_controller/test_ev28.py +++ b/goodwe_controller/test_ev28.py @@ -518,9 +518,11 @@ async def t17(ramp): w, during, first = run(t17(50.0)) check(f"T17a: back after 30 s at ~800 W: no write while unavailable, no " - f"select, then the restore ({[x[1:3] for x in first]})", + f"select, the restore on the first available step " + f"({[x[1:3] for x in first]})", during == 0 and not w.writes("phases") and w.sim.readback_a == 10 - and w.wr.phase_fails == 1) + and w.wr.phase_fails == 1 + and [x[1:3] for x in first][:1] == [("current", 10.0)]) w, during, first = run(t17(200.0)) ph = w.writes("phases") check(f"T17b: back at 0 W: the select at the first available step " @@ -698,7 +700,8 @@ async def t15(): await w.step(19) w.sim.refuse = "error" await w.step(40) - mid = (list(calls), w.wr.seq is None, bool(w.writes("phases"))) + mid = (list(calls), w.wr.seq is None and w.wr.fails == 1, + bool(w.writes("phases"))) w.sim.refuse = None await w.step(int(carmode.RETRY_S) + 10) return w, mid @@ -708,7 +711,7 @@ w, (calls, over, anyph) = run(t15()) tries = [c for c in calls if c[1] == 16.0] gaps = [round(b[0] - a[0]) for a, b in zip(tries, tries[1:])] check(f"T15: the restore is refused: tried {len(tries)} times ~5 s apart " - f"({gaps}), no select, sequence ends", + f"({gaps}), no select, sequence ends, one failed write counted", len(tries) == MAX_TRIES and all(4 <= g <= 6 for g in gaps) and over and not anyph and not w.writes("phases")) check("T15: after the refusal ends the current is back at 16 A, never a "