SAFETY-119: no "not keeping up" when the loop takes the wire back

When the peak guard or a maintenance charge hands the wire back, the loop's
integrator is re-seeded from that owner's command and kicked by a meter that
does not show it yet. It crossed its rail for a cycle or two and raised
goodwe_integrator_bound while the battery gave what it was told.

The loop's integrator bound is not counted until the plant's settle
(SHORT_CYCLES, SHORT_SPAN_S) has passed since the hand-back. An over-rating
always counts; a bound that lasts warns after the settle. No command
changes and no text changes. test_safety119.py; DECISIONS entry.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
glenn schrooyen
2026-10-19 14:14:08 +02:00
co-authored by Claude
parent 75f0804f9d
commit c4e15ec4cd
3 changed files with 404 additions and 1 deletions
@@ -0,0 +1,27 @@
# SAFETY-119 - no "not keeping up" when the loop takes the wire back
**Status: for review.** Tests: `test_safety119.py`.
**Cause.** When another owner (the peak guard, a maintenance charge) has set
the wire and the loop wins again, `cycle()` re-seeds the integrator from that
owner's command, and `compute()` adds `gain * error` from a meter that does
not show that command yet. On the TEST-23 rig (SAFETY-118 I-2) the guard's
last-seconds step went from -2000 W to +429 W. The next cycle's ask crossed
the +2500 W rail and beat the guard's floor, so SAFETY-85 rule 1 counted it
as the loop's own bound and raised `goodwe_integrator_bound`. The battery gave
what it was told; the cap held.
**Decision.** On the cycles after a hand-back, the loop's integrator bound is
not counted until the plant's settle has passed (`SHORT_CYCLES` cycles and
`SHORT_SPAN_S`, the same window SAFETY-85 grades a battery on). After that it
counts as before. An over-rating (`clamped`, a bug) always counts. No command
changes, and no text was added or changed.
**Kept.** The loop in charge at its rail warns on the same cycle as before. A
loop still at its rail after the window warns then (about 22 s later): delay,
not loss. The start and a restart after a stop are not hand-backs.
**Not changed.** The kick itself is control behaviour: for a few seconds at
a quarter's edge the loop asks up to its rail. In `test_safety119.py` part 1
that is more discharge than the guard asked at a quarter's end, and about
1700 Ws more charge (2 W on that quarter's average) at the next one's start.