EV-20 review r3: a held read moves no plan count; only the meter-age pause may fire
checks / unit (pull_request) Successful in 54m0s
infra-pin / fresh (pull_request) Successful in 1s

On a held charger read no writer steps and the Solar plan does nothing: no
phase change or switching start begins, no _set or end_switch, ok_since,
up_since, down_since, low_since and set_at stay, and the hold pause does not
fire; a decision due then runs on the next real reading. The one exception
is the pause by the meter's age (C18, SolarWriter.held_pause). Rows: the
reviewer's three shapes with 1- and 2-read gaps on and before the decision
cycle, and the hold pause on a held cycle. DECISIONS wording fixed.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
This commit is contained in:
Claude
2026-11-24 06:54:07 +01:00
parent a60ebd3286
commit 0cfb99ed65
4 changed files with 118 additions and 13 deletions
@@ -152,8 +152,11 @@ one small set of facts and derives every path from them:
that got no answer, or every required entity unavailable; one entity
missing, a wrong power unit or the login off stay readings of their own
(EV-03 round 4, unchanged); nothing is decided
or written in that cycle (`ctl_car.car_step` returns), and it neither arms
nor clears the stuck check. At `stale_input_s` the missing reading is taken
or written in that cycle: no writer steps (`ctl_car.car_step` returns), no
plan count moves (start, phase change, hold, `set_at`) and a decision due
then runs on the next real reading (review r3, PM design). The one
exception is Solar's pause by the meter's age (C18, `held_pause`). It
neither arms nor clears the stuck check. At `stale_input_s` the missing reading is taken
as before (the safe path: the charger is gone, 0 A first on its return).
This also ends the false PEAK_GUARD_FLOOR_LIMITED after one gap (EV-18
T10(b) changed accordingly).
@@ -166,9 +169,11 @@ one small set of facts and derives every path from them:
current: no retry, no raise, no phase change begun, and a phase change
under way ends at its 0 A (no select after that, no closing current); the
plan pauses. 0 A is always allowed. Also on a held read (`nz_block`).
- **The age pause on a held read (C18):** on a held cycle Solar still steps
(Manual does not), so a pause due on that cycle is not slipped; it can only
write a NEW 0 A there (no retry to a charger that is not answering).
- **The age pause on a held read (C18):** on a held cycle Solar does not step
(review r3, PM design); only `held_pause` runs: while the meter is silent
and its age has reached `meter_max_age_s` + `ev_pause_min`, the plan pauses
and a NEW 0 A goes out (no retry to a charger that is not answering). No
phase change, start, hold pause or other count moves on a held cycle.
- **Accepted (PM, P9g):** a frozen charger that also stops answering is
flagged only once it answers again; the 15 s safe path covers the gap.
- **A held read during a phase change (SPIKE-06 C19):** a phase change under
+20
View File
@@ -993,6 +993,26 @@ class SolarWriter(ManualWriter):
"prev": None, "from": r.phases_allowed}
# ------------------------------------------------------------- step
async def held_pause(self, drv, r, *, sun, now, tracker) -> None:
"""EV-20 (C18, PM design r3): on a held charger read only the pause by
the meter's age may come (0 A): nothing else in the plan moves, no
phase change begins or goes on, no retry. Called instead of `step`."""
if not self.engaged or self.seq is not None or self.hold \
or self.fault is not None or self.restart \
or self.plan.a <= 0.0 or self.plan.switch:
return
if not getattr(sun, "silent", False) \
or getattr(sun, "unknown_s", 0.0) < sun.pause_s:
return
self.nz_block = self.held_step = True
try:
self.plan.pause("unknown")
cur = None if r is None else (
r.allowed_a if r.allowed_a is not None else r.setpoint_a)
await self._put(drv, 0.0, cur, now, tracker)
finally:
self.nz_block = self.held_step = False
async def step(self, drv, r, *, mode, sun, clamp, now, tracker, writing,
status, clock=None, held=False):
"""One cycle. `sun` is `SunInputs` (None outside Solar); `writing` is
+14 -8
View File
@@ -370,11 +370,21 @@ class CarMixin:
return
held = bool(self.car.held)
now = self.car_now()
if held and self.car_mode != carmode.SOLAR \
and not self.car_solar.engaged:
sun = None
if self.car_mode == carmode.SOLAR:
sun = getattr(self, "_car_sun_now", None) \
or self.car_sun_inputs(now)
if held:
# EV-20 rig round 2 (PM): the charger missed a read for less than
# `stale_input_s`; the last trusted figure stands and nothing is
# decided or written from the gap.
# decided or written from the gap. No writer steps and no plan
# count (start, phase change, hold) moves (review r3, PM design);
# a decision due now runs on the next real reading. The one
# exception: Solar's pause by the meter's age (C18).
if sun is not None and self.car_writing():
await self.car_solar.held_pause(
self.charger, self.car.reading, sun=sun, now=now,
tracker=self.car)
return
if self.car_mode != carmode.SOLAR and not held:
await self.car_writer.step(
@@ -387,16 +397,12 @@ class CarMixin:
if self.car_mode == carmode.SOLAR or w.engaged:
# C6: one write clock: Manual's latest non-zero write counts.
w.other_at = self.car_writer.nonzero_at
sun = None
if self.car_mode == carmode.SOLAR:
sun = getattr(self, "_car_sun_now", None) \
or self.car_sun_inputs(now)
await w.step(
self.charger, self.car.reading, mode=self.car_mode,
sun=sun,
clamp=self.car_clamp(), now=now, tracker=self.car,
writing=self.car_writing(), status=self.car.status(now, True),
clock=self.car_now, held=held)
clock=self.car_now)
# ------------------------------------------------------- EV-20: Solar
def car_may_charge(self, inv) -> bool:
+74
View File
@@ -713,4 +713,78 @@ check(f"C19: a 17 s gap during the change takes the safe path: nothing while "
and r["c"].car_solar.seq is None)
nevers(r, "C19 long gap")
# =========================================================================== #
print("\n10. REVIEW R3: A HELD READ ON A DECISION CYCLE (PM design)")
# =========================================================================== #
# The reviewer's three shapes (house 500 W, Car first, 3-phase car). A 1- or
# 2-sample read gap on the cycle a phase change or a switching start is due,
# or on the cycle before it: the decision waits for the next real reading and
# every write lands within 2 s of the run without the gap (a60ebd3: the wait
# restarted, and 3 -> 1 became a 0 A pause in full sun).
def sun_b(t):
return 7600.0 if t < 1000 else (300.0 if t < 1400 else 2600.0)
SHAPES = (("A 1 -> 3", const(7600.0), 700, 301),
("B a start that needs 3 -> 1", sun_b, 1900, 1521),
("C 3 -> 1", lambda t: 7600.0 if t < 1000 else 4300.0, 1700, 1301))
def shape_run(sunf, dur, events=None):
return S.drive(const(500.0), sunf, dur=dur, first="car",
socs={"a": 100.0, "b": 100.0}, car_phases=3,
events=events or {})
def after(r, t0, t1):
return [(t, a) for t, a, _ in cur_writes(r) if t0 <= t < t1]
for name, sunf, dur, d in SHAPES:
twin = after(shape_run(sunf, dur), d - 5, d + 200)
for off in (-1, 0):
for n in (1, 2):
g = d + off
r = shape_run(sunf, dur,
{g: lambda p, c: p.ch.go_unavailable(),
g + n: lambda p, c: p.ch.go_unavailable(False)})
got = after(r, d - 5, d + 200)
same = (len(got) == len(twin) and all(
a1 == a2 and abs(t1 - t2) <= 2.0
for (t1, a1), (t2, a2) in zip(got, twin)))
check(f"review r3 [{name}] {n}-read gap at {g} (decision due "
f"{d}): the writes of the run without the gap, within 2 s "
f"({got[:4]} vs {twin[:4]})", same and bool(twin))
nevers(r, f"review r3 [{name}] gap {n} at {g}")
# The hold's pause (low_since past ev_pause_min) never fires on a held cycle:
# it comes on the next real reading, and only if that reading still says low.
base = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
opts={"ev_phases": "1"})
z0 = nth([t for t, a, _ in cur_writes(base) if a == 0.0 and t > 400], 0)
check(f"hold twin: 0 A at {z0} (300 s from the drop at 400, +2)",
present(z0) and 699 <= z0 <= 702)
if present(z0):
zi = int(z0)
r = S.drive(const(500.0), lambda t: 900.0 if t >= 400 else 2900.0,
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
opts={"ev_phases": "1"},
events={zi: lambda p, c: p.ch.go_unavailable(),
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
check(f"hold pause due on a held read ({zi}): 0 A on the next real "
f"reading ({z[:1]}), not on the held cycle",
present(nth(z, 0)) and nth(z, 0) == zi + 1)
r = S.drive(const(500.0),
lambda t: 900.0 if 400 <= t < zi else 2900.0,
dur=900, first="car", socs={"a": 100.0, "b": 100.0},
opts={"ev_phases": "1"},
events={zi: lambda p, c: p.ch.go_unavailable(),
zi + 1: lambda p, c: p.ch.go_unavailable(False)})
z = [t for t, a, _ in cur_writes(r) if a == 0.0 and t > 400]
check(f"hold pause due on a held read ({zi}), the sun back from that "
f"second, so the next real reading ({zi + 1}) is not low: no pause "
f"({z[:1]})", z == [])
report()