EV-59: Manual gives one value at most MAX_TRIES tries per user change

A refused phase-change close ended its sequence with one `_failed`, so the
same value got 5 tries (3 closes, then 2 on the normal path). Manual now
counts the not-taken closes of the value owed since the last user change
(`_close_k`); at the capped close end `fails` = that count, so `gave_up` and
CHARGER_REFUSED come at the 3rd refused close, and a value changed during the
retries still gets 3 tries. SolarWriter overrides the end hook and is
unchanged (EV-60).

Tests: new test_ev59.py; test_ev56 T5, T5b and the T20 T5 [R] golden,
test_ev28 T15 and the test_ev13 T13 text per the brief rulings.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude
2026-12-01 02:40:49 +01:00
parent 1b909fb7bd
commit 009393a5ee
5 changed files with 709 additions and 16 deletions
+8 -4
View File
@@ -704,7 +704,8 @@ async def t15():
await w.step(19)
w.sim.refuse = "error"
await w.step(40)
mid = (list(calls), w.wr.seq is None and w.wr.fails == 1,
mid = (list(calls), w.wr.seq is None and w.wr.fails == MAX_TRIES
and w.wr.gave_up,
bool(w.writes("phases")))
w.sim.refuse = None
await w.step(int(carmode.RETRY_S) + 10)
@@ -715,11 +716,14 @@ 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, one failed write counted",
f"({gaps}), no select, sequence ends, the 3 closes counted: given up "
"(EV-59)",
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 "
"select", w.sim.readback_a == 16 and not w.writes("phases"))
check("T15: EV-59: given up after the 3 closes: no 4th try, the current stays "
"at 0 A until a user change, never a select",
w.sim.readback_a == 0 and len(tries) == MAX_TRIES
and not w.writes("phases"))
# --- T14: the controller level (the EV-15 harness) ------------------------- #