EV-21 fix round 1 (formal round 4): C14 cut due while batteries charge; C15 grace once per value
checks / unit (pull_request) Successful in 46m9s
infra-pin / fresh (pull_request) Successful in 1s

C14 (PM Q2): slowing a battery charge counts as the batteries taking more, so the cut is due whatever the batteries do; their charge counts only as headroom for the 15 s wait. C15 (PM Q1): sent_at is renewed only for a new value, so a retry of a refused cut gets no new 2 s grace. test_ev21_fix1.py: both red on 36e9dd7; C16, C18 and Q1's other writer pinned as the code has them. Test shapes: slow batteries and refusals start after Solar's own start, which C14 would otherwise cut on its start blip; T38 cover off from 300 s; T46 bounds the excess; T39 counts writes after the cut.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ems-agent
2026-11-27 01:33:41 +01:00
co-authored by Claude
parent 36e9dd765e
commit 5759e9dc9f
9 changed files with 250 additions and 36 deletions
+19 -13
View File
@@ -384,11 +384,13 @@ for kind in ("M", "C"):
for n in (2, 1):
# The old period heads over at 1700 (100 s left: at once); the house is
# back to 900 W at 1790, so the new period starts under the aim.
r = near_end(1700, n=n, house_after=9000.0, sun_back=1810, dur=2100,
r = near_end(1700, n=n, house_after=12000.0, sun_back=1810, dur=2100,
house_more=((1790, 900.0),))
w = [(t, a) for t, a, _ in after(r, 1695)]
cut = [t for t, a in w if a == 0.0]
nz = [t for t, a in w if a > 0.0]
# Non-zero writes after the cut only (Solar's own steps before the step
# at 1700 are not a restart).
nz = [t for t, a in w if a > 0.0 and cut and t > cut[0]]
new_q = [x["t"] for x in r["rec"].rows if 1800 <= x["t"] < 1930
and x["cap"] is not None]
check(f"T39 [N={n}]: the old period's cut at {cut[:1]}; none at or "
@@ -495,17 +497,21 @@ lim = None
bad = []
if rb:
car_a = (rec.at(rb[0] + 5) or {}).get("car", 0.0)
lim = max(0.0, (dec.get("want") or 0.0) - (car_b - car_a)) + 150.0
# A cycle whose battery reading moved since the last one reads the
# battery a cycle before the meter (want = battery + excess): a skew of
# the measurement, not a floor raised for the car; those are skipped.
tb = {x["t"]: x["batt"] for x in r["trace"]}
bad = [(x["t"], round(x["want"] or 0)) for x in rec.rows
if rb[0] + 5 <= x["t"] <= rb[0] + 60 and (x["want"] or 0) > lim
and abs(tb.get(x["t"], 0.0) - tb.get(x["t"] - 1, 0.0)) < 50.0]
check(f"T46: from 5 s after the cut's read-back the guard wants no more than "
f"its want at the cut less what the car gave back, +150 W ({lim}; "
f"{bad[:3]})", bool(rb) and not bad)
# Fix round 1: the bound is on the guard's EXCESS (what the site must
# still shed: wanted_w less the batteries' own output). In Shape W the
# batteries answer 20 s late, so the commands sent before the cut reach
# them after it and `wanted_w` (battery + excess) rises with that late
# output while the excess is negative: not a floor raised for the car.
tr_ = {x["t"]: x for x in r["trace"]}
ex_dec = (tr_.get(z) or {}).get("excess") or 0.0
lim = max(0.0, ex_dec - (car_b - car_a)) + 150.0
bad = [(x["t"], round(x["excess"] or 0), round(x["want"] or 0))
for x in r["trace"]
if rb[0] + 5 <= x["t"] <= rb[0] + 60 and (x["excess"] or 0) > lim]
check(f"T46: from 5 s after the cut's read-back the excess the guard asks the "
f"batteries for is no more than at the cut less what the car gave "
f"back, +150 W ({lim}; (t, excess, wanted_w) over it: {bad[:3]})",
bool(rb) and not bad)
# =========================================================================== #
print("\n9. THE WALL CLOCK JUMPS (T48)")