EV-04 round 2: race-free another-writer check, refused phase select, undo before the select, clamped restore, energy-corroborated car figure
checks / unit (pull_request) Successful in 21m14s
infra-pin / fresh (pull_request) Successful in 1s

M1 the writer ignores a reading taken before its latest confirmed write.
M2 a refused phase select gives the current back and stops after 3 tries (amber row).
M3 Off, shadow mode or a control/safety stop before the select undoes the change.
M4 the restore on shutdown (and the undo) is clamped.
M5 the car's power reaches the alarm path only while the charger's energy meter agrees with it.
L1 fuzz other-writer branch reachable and shown to run. L2 one wording. L3 Batteries-help-off text.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-11-16 06:51:15 +01:00
co-authored by Claude
parent 0c92239a63
commit 661a3b009a
11 changed files with 493 additions and 68 deletions
@@ -62,13 +62,23 @@ stops holding late in a period that the car already pushed over, because
`excess_w` grows as the seconds run out; the average form does not, and it is the
same test for a steady car.
**A stale or stuck car figure must never hide a real overload.** Only
**A stale, stuck or frozen car figure must never hide a real overload.** Only
`CarTracker.car_w_trusted` is used: fresh (the EV-03 rules, which also make an
unavailable reading None at once), not stuck (power and read-back unchanged 60 s
after a write that moved the setpoint by 1 A or more, SAFETY-37's shape), and never
above what the read-back allows the car to draw. A figure that is stuck from the
start with no write is not caught by the stuck rule; it is bounded by the
read-back and is the one hole this card leaves (the design's own rule).
unavailable reading None at once), not stuck after a write (SAFETY-37's shape),
never above what the read-back allows, and CORROBORATED by the charger's energy
meter (round 2). The rule (`CarTracker.corroborated`, constants `CORR_*` in
`chargers.py`): the charger reports charging (mode3 C) and has an energy entity,
and over the last 60 s of unbroken charging readings the meter has gained at
least 50 % of what the reported power adds up to, less 15 Wh (the meter shows
10 Wh steps). A gap, a state other than C or a meter that goes back starts the
window again. With less than a window of readings (a session just began, or
the add-on just started) the figure is believed, so a charge does not raise the
false alarms for its first minute; a frozen figure is believed for that minute
only. No energy entity: never corroborated, so the normal alarms stand. The
tolerance is loose on purpose (ramps, 10 Wh steps, the sampling) and tight
enough that a frozen power figure on a car that has stopped, or everything
frozen together, fails inside a window. Below about 0.5 kW the rule passes by
itself; such a figure cannot hide an overload that matters.
## Decision 1 (`ev_batt_cover`)