From 45df1ac54991a60e1e18805a4b50ec1f1eb48684 Mon Sep 17 00:00:00 2001 From: ems-agent Date: Wed, 25 Nov 2026 00:04:10 +0100 Subject: [PATCH] EV-51 review: T45 sweeps N8 on own age for retries and phase-change closing currents; docs name the decision words and C23 T45: race order, 5 s and 10 s cycles, silence onset swept 1 s at a time, (a) a raise the charger ignores (re-sends) and (b) a 1 -> 3 phase change (closing current): no non-zero current write at own age > 30 s. Red on 5bff894 and on the reviewer's R4 (nz_block from the snapshot, C23 on own age), green on head. T26 also checks the DECISIONS entry names every decision word and the C23 value rule. DECISIONS and the car_sun_own / _car_step_debug docstrings: snapshot values are used only while the step's own age says fresh (C23); the decision words are listed. No code change. Co-Authored-By: Claude --- .../DECISIONS/EV-20-solar-mode.md | 13 +++-- goodwe_controller/app/ctl_car.py | 11 +++- goodwe_controller/test_ev51.py | 56 ++++++++++++++++++- 3 files changed, 72 insertions(+), 8 deletions(-) diff --git a/goodwe_controller/DECISIONS/EV-20-solar-mode.md b/goodwe_controller/DECISIONS/EV-20-solar-mode.md index 4baec40..ac58f63 100644 --- a/goodwe_controller/DECISIONS/EV-20-solar-mode.md +++ b/goodwe_controller/DECISIONS/EV-20-solar-mode.md @@ -172,10 +172,15 @@ one small set of facts and derives every path from them: late-readings hold with its stale rule (a spare read while the hold was on is not used once the step's own late time reaches `stale_input_s`). The meter's VALUES (spare, target) stay the cycle's, one cycle of sensor latency - being normal; `car.held` and `car.reading` are unchanged. Arrival sources - keep the cycle's age for their "spare unknown" check. At log level debug - each Solar step logs one line: time, the meter age at the step, the decision - and the write. + being normal, but only while the step's own age says the meter is fresh: + once it is past `meter_max_age_s` the spare is unknown, so nothing starts or + rises from it (C23). `car.held` and `car.reading` are unchanged. Arrival + sources keep the cycle's age for their "spare unknown" check. At log level + debug each Solar step logs one line: time, the meter age at the step, the + decision and the write. The decision is one word: `steady`, `start`, + `raise`, `lower`, `pause`, `hold` (the late-readings hold), `wait-unknown` + (the spare is unknown and the pause timer counts) or `wait-held` (a held + charger read). - **No non-zero write while the meter is silent (SPIKE-06 C17, N8 strict):** while the meter's age is past `meter_max_age_s`, Solar sends no non-zero current: no retry, no raise, no phase change begun, and a phase change diff --git a/goodwe_controller/app/ctl_car.py b/goodwe_controller/app/ctl_car.py index a23543c..4b59668 100644 --- a/goodwe_controller/app/ctl_car.py +++ b/goodwe_controller/app/ctl_car.py @@ -384,8 +384,11 @@ class CarMixin: def _car_step_debug(self, held, now, sun, a0, n_log) -> None: """EV-51: one DEBUG line per Solar writer step: the time, the meter's - age at the step, what was decided and what was written. Nothing at - info and above; no secrets in it.""" + age at the step, what was decided and what was written. The decision + is one word: steady, start, raise, lower, pause, hold (the + late-readings hold), wait-unknown (the spare is unknown and the pause + timer counts) or wait-held (a held charger read). Nothing at info and + above; no secrets in it.""" w = self.car_solar a1 = w.plan.a if a0 > 0.0 and a1 <= 0.0: @@ -421,7 +424,9 @@ class CarMixin: cycle saw one step earlier: the write block while the meter is silent (N8), the unknown/pause timing (held reads too) and the late-readings hold with its stale rule. The meter's VALUES (spare, target) stay the - cycle's; arrival sources' `car_spare_w` keeps the cycle's age.""" + cycle's only while the step's own age says the meter is fresh; once it + is past `meter_max_age_s` they are unknown (C23). Arrival sources' + `car_spare_w` keeps the cycle's age.""" own = copy.copy(snap) own.silent = self._car_meter_silent() own.unknown_s = self._car_meter_over_s() diff --git a/goodwe_controller/test_ev51.py b/goodwe_controller/test_ev51.py index 2a613ed..aabfc13 100644 --- a/goodwe_controller/test_ev51.py +++ b/goodwe_controller/test_ev51.py @@ -1,5 +1,6 @@ """EV-51: every meter-age decision of a Solar writer step is judged on the -step's OWN age (T1-T43; N1-N12 of reports/EV-51-test-plan.md). +step's OWN age (T1-T45; N1-N12 of reports/EV-51-test-plan.md; T44 and T45 +from the round-1 formal check and the review). `python3 -B test_ev51.py` The real Controller on `tools/ev20_sun.py` (the harness now takes a cycle @@ -574,6 +575,14 @@ check("T26: DECISIONS states the rule once: 0 A on the first car step whose own "bound 330 s + one cycle" not in doc and doc.count("EV-51: decided at the step's own meter age") == 1 and "held steps included" in doc) +_words = ("steady", "start", "raise", "lower", "pause", "hold", "wait-unknown", + "wait-held") +_ev51 = doc.split("EV-51: decided at the step's own meter age", 1)[-1].split("\n- **", 1)[0] +check("T26 (review): the EV-51 entry names every decision word of the DEBUG " + "line and says the snapshot values are unknown once the step's own age " + "is past meter_max_age_s (C23)", + all(f"`{w}`" in _ev51 for w in _words) and "(C23)" in _ev51 + and "only while the step's own age says the meter is fresh" in _ev51) # =========================================================================== # print("\n5. THE DEBUG LINE (T28-T34; N9, N10, N11)") @@ -947,4 +956,49 @@ for cyc in (5, 10): f"({n_back} onsets start after back; {len(bad)} bad: {bad[:2]})", not bad and n_back >= 9) +# T45 (review, N8 / C22 on the paths that do not come from the plan's target): +# (a) the re-send of an ignored write, (b) the closing current of a 1 -> 3 +# phase change. Race order, the silence onset swept 1 s at a time: no non-zero +# current write at a step whose own age is > meter_max_age_s (30 s). The C23 +# hiding of spare/target cannot stop these; only `nz_block` on own age does. +def _t45_retry(cyc): + hits, resent = [], 0 + for onset in range(300, 440): + r, st = run_log(go, onset=onset, dur=onset + 60, cyc=cyc, phase=0, + race=True, + sim=TSim(setpoint_a=0, windows=[(335.0, 900.0, "ignore")]), + sun=lambda t: 3000.0 if t >= 340 else 2300.0) + if len([a for s in st if s["now"] >= 340 for a, _t, _o in s["writes"] + if a > 0.0]) >= 2: + resent += 1 # the ignored raise was sent again + if n8(st): + hits.append((onset, n8(st)[:1])) + return hits, resent + + +def _t45_phase(cyc): + hits, changed = [], 0 + for onset in range(240, 340): + r, st = run_log(go, onset=onset, dur=onset + 60, cyc=cyc, phase=0, + race=True, opts={"ev_phases": "auto"}, car_phases=3, + sun=7600.0) + if [s for s in st if s["phases"]]: + changed += 1 # a 1 -> 3 phase change ran + if n8(st): + hits.append((onset, n8(st)[:1])) + return hits, changed + + +for cyc in (5, 10): + hits, resent = _t45_retry(cyc) + check(f"T45 retry [{cyc} s race]: a raise to 10 A at 340 the charger ignores, " + f"silence onset 300-439: no re-send at own age > 30 ({resent} runs " + f"re-sent; {len(hits)} onsets with a hit: {hits[:2]})", + not hits and resent >= 20) + hits, changed = _t45_phase(cyc) + check(f"T45 phase change [{cyc} s race]: 1 -> 3 phases (sun 7600 W, 3-phase " + f"car), silence onset 240-339: no closing current at own age > 30 " + f"({changed} runs with a phase change; {len(hits)} onsets with a hit: " + f"{hits[:2]})", not hits and changed >= 20) + report()