EV-05 round 7: Solar watches while not writing; shadow start writes nothing
checks / unit (pull_request) Successful in 24m28s
infra-pin / fresh (pull_request) Successful in 2s

Review of b4a222f, brief v6 Expected 11 (owner 2026-11-18):
- Solar keeps watching for another writer while it is not writing (Stop,
  shadow, safety stop), so hold is true for every reader: the exit, the
  shutdown, the peak alarms, and Start afterwards.
- car_solar_can_cut() also needs Solar to be writing: the peak alarms stand
  as in Off and the quarter is banked.
- A start or restart in Solar with shadow on writes nothing (the
  not-writing 0 A is owed only when Solar had the charger before).
- Once that exit 0 A is taken, nothing more is written, shutdown included.

Tests: alarm rows for Stop, shadow on and safety stop against an Off twin;
shutdown after another writer in shadow and Stop; a start in shadow with the
car already charging; Start after a stop; two variants inside the 30 s watch.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ems-agent
2026-11-18 20:17:58 +01:00
co-authored by Claude
parent b4a222f9e8
commit fa11dc3d85
4 changed files with 150 additions and 3 deletions
+116
View File
@@ -1967,6 +1967,122 @@ check(f"R6 both batteries switched Off: the guard catches the cloud edge with "
f"them (wanted {len(want6o)} s), so no cut and no pause ({w6o})",
0 < len(want6o) < 15 and not first_cut(r6o, 900)
and 0.0 not in [v for _t, v in w6o])
# =========================================================================== #
print("\nROUND 7. NOT WRITING: SOLAR WATCHES, THE ALARMS STAND, NOTHING OVER OTHERS")
# =========================================================================== #
OUT7 = (("Stop (shadow_mode auto)", act("auto_toggle", None),
{"shadow_mode": "auto"}),
("shadow on", lambda p, c: c.o.__setitem__("shadow_mode", "on"), {}),
("safety stop", lambda p, c: setattr(c.circ_wd, "tripped", True), {}))
# 1. The review's p_out: Solar wrote its one 0 A at 500 s, another writer
# sets 16 A at 600 s, the house steps at 1000 s. As in Off: the alarm, the
# quarter banked, the car never explained away.
for name, trig, opts7 in OUT7:
o7 = dict({"ev_phases": "3", "slew_w": 0}, **opts7)
ev7 = {500: trig, 600: _other16}
r7 = S.drive(house=steps((0, 500.0), (1000, 3000.0)), sun=const(7000.0),
first="car", socs=CUT10, dur=1810, opts=o7, phases=3,
events=dict(ev7))
r7o = S.drive(house=steps((0, 500.0), (1000, 3000.0)), sun=const(7000.0),
first="car", socs=CUT10, dur=1810, opts=o7, phases=3,
events=dict(ev7), mode="off", sim=SimCharger(setpoint_a=9))
a7, a7o = first_alarm(r7, 900), first_alarm(r7o, 900)
ex7 = sum(1 for x in r7["trace"] if 900 <= x["t"] < 1800 and x["explains"])
q7 = {q: g for q, g, _c in quarters(r7, 3400.0)}
check(f"R7 {name}, then another writer at a peak: the alarm stands as in "
f"Off (+2 s) ({a7} vs {a7o}), the quarter ({round(q7.get(900, -1))} "
f"W) is banked ({len(r7['c'].car_peak_q)}), the car is never "
f"explained away ({ex7} cycles), and Solar writes nothing over the "
f"other writer ({after(r7, 600)})",
a7 is not None and a7o is not None and abs(a7 - a7o) <= 2
and q7.get(900, 0) > 3400.0 and len(r7["c"].car_peak_q) >= 1
and ex7 == 0 and after(r7, 600) == [])
# 2. Shutdown after the exit 0 A was taken, in shadow or Stop, with another
# writer at 16 A since 400 s: nothing is written (T53 (b), T28, N10).
def shut_rec7(rec):
async def f(p, c):
rec["n0"] = len(p.sets)
await c.shutdown()
rec["sets"] = [x for x in p.sets[rec["n0"]:] if x[1] == S.SET]
rec["sp"] = p.ch.setpoint_a
return f
for name, trig, opts7 in (
("shadow on", lambda p, c: c.o.__setitem__("shadow_mode", "on"), {}),
("Stop (shadow_mode auto)", act("auto_toggle", None),
{"shadow_mode": "auto"}),
("Stop (shadow_mode off)", act("auto_toggle", None),
{"shadow_mode": "off"})):
rec7 = {}
r7s = S.drive(house=const(500.0), sun=const(2900.0), first="car",
socs=FULL, dur=601, opts=opts7, events={
300: trig, 400: _other16, 600: shut_rec7(rec7)})
check(f"R7 {name}, another writer at 16 A, then shutdown: no write at "
f"shutdown ({rec7.get('sets')}), the charger stays at 16 A; the only "
f"0 A was the exit's ({after(r7s, 300)})",
rec7.get("sets") == [] and rec7.get("sp") == 16.0
and [v for _t, v in after(r7s, 300)] == [0.0])
# Inside the first 30 s, before the watch can call it another writer, each
# clause decides on its own: the alarm (Solar is not writing) and the
# shutdown (the exit 0 A was taken).
o7s = {"ev_phases": "3", "slew_w": 0, "shadow_mode": "auto"}
ev7s = {500: act("auto_toggle", None), 890: _other16}
r7e = S.drive(house=steps((0, 500.0), (895, 3000.0)), sun=const(7000.0),
first="car", socs=CUT10, dur=1810, opts=o7s, phases=3,
events=dict(ev7s))
r7eo = S.drive(house=steps((0, 500.0), (895, 3000.0)), sun=const(7000.0),
first="car", socs=CUT10, dur=1810, opts=o7s, phases=3,
events=dict(ev7s), mode="off", sim=SimCharger(setpoint_a=0))
a7e, a7eo = first_alarm(r7e, 895), first_alarm(r7eo, 895)
check(f"R7 Stop, another writer 10 s before the period (no hold yet): the "
f"alarm stands as in Off (+2 s) ({a7e} vs {a7eo})",
a7e is not None and a7eo is not None and abs(a7e - a7eo) <= 2)
rec7e = {}
r7f = S.drive(house=const(500.0), sun=const(2900.0), first="car", socs=FULL,
dur=601, opts={"shadow_mode": "on"},
events={300: lambda p, c: c.o.__setitem__("shadow_mode", "on"),
590: _other16, 600: shut_rec7(rec7e)})
check(f"R7 shadow on, another writer 10 s before the shutdown (no hold yet): "
f"no write at shutdown ({rec7e.get('sets')}), the charger stays at 16 A",
rec7e.get("sets") == [] and rec7e.get("sp") == 16.0)
# 3. Brief v6, Expected 11: a start in Solar with shadow on writes nothing,
# even with a car already charging under another writer.
for name, opts7, ev7 in (("shadow on", {"shadow_mode": "on"}, {}),
("shipped auto, control stopped",
{"shadow_mode": "auto"},
{0: lambda p, c: setattr(c, "auto", False)})):
r7t = S.drive(house=const(500.0), sun=const(2900.0), first="car",
socs=FULL, dur=300, setpoint=16, opts=opts7, events=ev7)
check(f"R7 start in Solar with {name}, the car charging at 16 A set by "
f"another writer: nothing is written ({cur(r7t)}), the charger stays "
f"at 16 A, the card says what it would set "
f"({r7t['c'].car_solar.would})",
cur(r7t) == [] and r7t["sim"].setpoint_a == 16.0
and r7t["c"].car_solar.would is not None)
# 4. The root: Solar keeps watching while it is not writing. Stop at 300 s
# (its 0 A), another writer sets 16 A at 400 s, Start at 600 s: Solar holds
# off, writes nothing over it, and shows the row.
st7 = {}
def _rows7(p, c, t):
if t == 620:
st7["rows"] = [x["id"] for x in c.checks()]
r7r = solar_exit(act("auto_toggle", None), dur=800,
opts={"shadow_mode": "off"},
events={400: _other16, 600: act("auto_toggle", None)},
on_cycle=_rows7)
check(f"R7 Start after a stop during which another writer took the charger: "
f"Solar holds off (writes after 400 s {after(r7r, 400)}, hold "
f"{r7r['c'].car_solar.hold}, row {'charger_other' in st7.get('rows', [])})",
after(r7r, 400) == [] and r7r["c"].car_solar.hold
and "charger_other" in st7.get("rows", [])
and r7r["sim"].setpoint_a == 16.0)
print("\n(T39, T44, T45, T50 and T51, the long runs, are in test_ev05_long.py)")
print()