EV-21: Solar cuts the car first for the quarter peak #278

Merged
ems-agent merged 5 commits from EV-21 into release/1.0 2026-11-29 03:24:39 +01:00
Collaborator

EV-21: Solar's car is cut first for the quarter peak (brief v2, R3; PM rulings Q1-Q6, OQ1-OQ10, Q-A to Q-D).

What changes

  • In Solar, when the 15-minute period heads over the aim and the batteries would have to give more for it, the car is lowered first: floor((car W - excess) / (230 x phases)) A, 0 A under 6 A, never above Solar's current.
  • At once without real headroom (saturated, floor-limited, excess beyond what the batteries can add, a battery figure missing, cover off, the last 120 s); otherwise after at most 15 s (monotonic).
  • One cut per episode, sized from its start (car then less the largest excess); deeper only when the excess grows. While due or standing: no raise, no start, no phase change; the plan may lower.
  • Restart: the projection with the 6 A start power under the aim for the start time (counted from under); none after a 2nd cut in the period. No cut state crosses the period's edge or a restart.
  • Grading (C2 fixed): Solar takes the car out of the alarm path only while it can cut it (writing, own read-back, no other writer, no fault). Otherwise car_alarm_w is None, exactly as Off: alarms, banking and the guard's cover-off exclusion as Off. A Solar car is never banked.
  • UI: the card's Why and one grey note per session say "Solar lowered the car for the peak."; no car-over row while the cut works.
  • Manual and Off: unchanged (hash-compared with c79eb37 in test_ev21_same.py).

Where: app/ctl_car.py (_car_cut_tick, car_solar_can_cut, _car_cut_headroom, the hold path), app/carmode.py (cut_amps, the plan's cap, _seq_want, the write rule for a new lower cut value), app/ctl_cycle.py (hold calls, check_car_cut), app/messages.py, app/homeview.py, ui_text, DOCS, CHANGELOG, DECISIONS/EV-21-car-cut-first.md.

Tests: test_ev21.py, test_ev21_paths.py, test_ev21_same.py (new; T1-T54 of reports/EV-21-test-plan.md), test_ev20_fuzz.py (T50 extension), tools/ev20_day.py (T49), test_ev20_guard.py section 8 (EV-20 N15 rows changed on purpose, T51). Details, mutants and deviations: reports/EV-21-dev-report.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w

EV-21: Solar's car is cut first for the quarter peak (brief v2, R3; PM rulings Q1-Q6, OQ1-OQ10, Q-A to Q-D). **What changes** - In Solar, when the 15-minute period heads over the aim and the batteries would have to give more for it, the car is lowered first: `floor((car W - excess) / (230 x phases))` A, 0 A under 6 A, never above Solar's current. - At once without real headroom (saturated, floor-limited, excess beyond what the batteries can add, a battery figure missing, cover off, the last 120 s); otherwise after at most 15 s (monotonic). - One cut per episode, sized from its start (car then less the largest excess); deeper only when the excess grows. While due or standing: no raise, no start, no phase change; the plan may lower. - Restart: the projection with the 6 A start power under the aim for the start time (counted from under); none after a 2nd cut in the period. No cut state crosses the period's edge or a restart. - Grading (C2 fixed): Solar takes the car out of the alarm path only while it can cut it (writing, own read-back, no other writer, no fault). Otherwise `car_alarm_w` is None, exactly as Off: alarms, banking and the guard's cover-off exclusion as Off. A Solar car is never banked. - UI: the card's Why and one grey note per session say "Solar lowered the car for the peak."; no car-over row while the cut works. - Manual and Off: unchanged (hash-compared with c79eb37 in test_ev21_same.py). **Where**: `app/ctl_car.py` (`_car_cut_tick`, `car_solar_can_cut`, `_car_cut_headroom`, the hold path), `app/carmode.py` (`cut_amps`, the plan's cap, `_seq_want`, the write rule for a new lower cut value), `app/ctl_cycle.py` (hold calls, `check_car_cut`), `app/messages.py`, `app/homeview.py`, ui_text, DOCS, CHANGELOG, `DECISIONS/EV-21-car-cut-first.md`. **Tests**: test_ev21.py, test_ev21_paths.py, test_ev21_same.py (new; T1-T54 of reports/EV-21-test-plan.md), test_ev20_fuzz.py (T50 extension), tools/ev20_day.py (T49), test_ev20_guard.py section 8 (EV-20 N15 rows changed on purpose, T51). Details, mutants and deviations: reports/EV-21-dev-report.md. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VSY9UpTaUYnjJF5oVtbM1w
ems-agent added 1 commit 2026-11-25 17:01:14 +01:00
EV-21: Solar cuts the car first for the quarter peak
infra-pin / fresh (pull_request) Successful in 2s
checks / unit (pull_request) Failing after 1h10m59s
7bc8988be0
In Solar, when the 15-minute period heads over the aim and the batteries
would have to give more, the car is lowered first: floor((car - excess) /
(230 x phases)) A, 0 under 6 A. At once without real headroom (saturated,
floor-limited, excess beyond what the batteries can add, no battery figure,
cover off, last 120 s), else after at most 15 s. One cut per episode from
its start, deeper only on a growing excess; restart with the start power
under the aim for the start time; none after a 2nd cut in the period.

Grading (formal C2): a Solar car Solar cannot cut is graded, banked and
left in the guard as in Off. A Solar car is never banked. Grey note and Why
"Solar lowered the car for the peak." Manual and Off unchanged.

Tests: test_ev21.py, test_ev21_paths.py, test_ev21_same.py; T49 in
tools/ev20_day.py; T50 in test_ev20_fuzz.py; test_ev20_guard section 8
moved from "as Manual" to "as Off" where Solar cannot cut (T51).

Co-Authored-By: Claude <noreply@anthropic.com>
ems-agent added 1 commit 2026-11-25 17:26:43 +01:00
EV-21: test fixes (T41/T46 on base, test_ev20_writers T46 with the cut first)
checks / unit (pull_request) Successful in 47m29s
infra-pin / fresh (pull_request) Successful in 1s
36e9dd765e
Co-Authored-By: Claude <noreply@anthropic.com>
ems-agent added 1 commit 2026-11-27 01:33:44 +01:00
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
5759e9dc9f
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>
ems-agent added 1 commit 2026-11-28 18:27:21 +01:00
EV-21 fix round 2 (review): a cut during Solar's own phase change ends it; wait cap in watts
checks / unit (pull_request) Successful in 46m35s
infra-pin / fresh (pull_request) Successful in 2s
83e5b9c51f
PM R1: a cut due while Solar's own phase change is under way (seq set or plan.switch) is 0 A at once and ends the change at its 0 A; the 15 s wait cap is held in watts and converted with the phases at the write. test_ev21_fix2.py: T34 (iv) red at 5759e9d, T34 (v) 3->1, N6/P27 refused close red with seq_uncapped, N9 standing cap red with stale_drop. test_ev21_fix1.py: C18 now R1; C16 and Q1 accepted as coded (R5).

Co-Authored-By: Claude <noreply@anthropic.com>
ems-agent added 1 commit 2026-11-29 02:29:28 +01:00
EV-21 fix round 3 (re-review, tests only): refused-close retry under a cut under 6 A; R1 standing cut
checks / unit (pull_request) Successful in 46m15s
infra-pin / fresh (pull_request) Successful in 2s
1c7761d2c2
test_ev21_fix2.py: N6/P27 (a) writer-level cuts of 3 A and 0 A, no write after the cut and the charger at 0 A; N6/P27 (b) controller level (close refused at 313, house 18 kW at 315: cut 0 A at once, no retry); R1 standing cut unit row on _car_cut_tick. Red with seq_nopause_retry and r1_nostand. No app/ change.

Co-Authored-By: Claude <noreply@anthropic.com>
ems-agent merged commit 02166e28eb into release/1.0 2026-11-29 03:24:39 +01:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: admin/goodwe-addon#278