Repository navigation
fix(curtail): no spurious release on |PV|=0 + Ferroamp NAK observability - #372
Conversation
Defense-in-depth against the 2026-05-27 Ferroamp brick. Combined with PR #367's driver-side hard fail on pplim arg=0, this eliminates every known trigger path: 1. ComputePVCurtail no longer emits curtail_disable when a previously- curtailed driver drops out of the proportional allocation only because its own |PV| crashed to ~0. That very thing often happens as a direct consequence of OUR prior curtail throttling the inverter — the spurious release would publish pplim arg=0 to Ferroamp (sticky-lock trap). Releases are now only emitted on: - directive truly cleared (no slot + no hold) - driver removed from SupportsPVCurtail (config change) - driver went offline Also: per-driver allocations rounding to ≤ 1 W are suppressed entirely — never publish a near-zero pplim. 2. The Ferroamp driver subscribes to extapi/control/response (was: extapi/result, a wrong topic that never received anything), parses {"status":"ack|nak", ...} responses, and exposes cumulative extapi_nak_count + extapi_ack_count metrics. NAK responses also log as warnings with transId + msg. The brick was preceded by minutes of "nak: no available ESOs detected in system" that we couldn't see through ftw telemetry — operator can now alert on any non-zero NAK rate. Test coverage: - control/pv_curtail_test.go: 4 new regression guards - drivers/lua_ferroamp_curtail_test.go: NAK + ACK counter test Out of scope (separate PR): the self-healing watchdog (E) that auto- publishes pplim release when sso_pv_v > 200V + ipv == 0 in daylight. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e004d0d343
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if w <= curtailMinPerDriverW { | ||
| continue |
There was a problem hiding this comment.
Preserve tiny curtailed shares for later release
When a previously-curtailed driver is still present in next but its newly computed share is <= curtailMinPerDriverW, the release loop treats it as still active and skips adding it to suppressedTrack, then this continue drops it from out; the state update below can therefore remove it from LastCurtailedDrivers without ever sending a release. In a negative-price slot where an inverter's proportional share falls below 1 W after it already received a non-zero cap, the later slot-clear tick will not emit curtail_disable, leaving that inverter capped until an operator or another mechanism clears it.
Useful? React with 👍 / 👎.
Summary
Two independent defenses that close the remaining trigger paths to the 2026-05-27 Ferroamp brick. Combined with #367's driver-side hard fail on
pplim arg=0, this is the full belt-and-suspenders.1. Dispatcher — don't release on |PV|=0 drop-out
Old
ComputePVCurtaillogic emitted acurtail_disablefor any previously-curtailed driver that dropped from the active proportional allocation. That fired wrongly when a curtailed driver's own|PV|crashed to ~0 — often a direct consequence of OUR prior curtail throttling that inverter. The spurious release then publishedpplim arg=0to the driver. On Ferroamp's extapi: sticky-lock until portal reset.New semantics — releases are emitted only when:
state.SupportsPVCurtail(config change), ORA driver that drops from the active allocation while curtail is still active is kept in
LastCurtailedDrivers(suppressed-track) so the next cycle's allocation reasoning stays accurate. The existingpplimon the inverter is left in place — it'll get refreshed when the driver's|PV|returns to a level the allocator can split.Plus: per-driver allocation rounding to
≤ 1 Wis suppressed — never publish a near-zeropplimthat some inverters treat as a hard "limit to 0 W" lock.2. Ferroamp driver — NAK observability
The driver subscribed to
extapi/result(wrong topic — never received anything). It now subscribes toextapi/control/responseand parses{"status":"ack|nak", ...}from each EMS response. Two new metrics:extapi_nak_count— cumulative NAK counterextapi_ack_count— cumulative ACK counterNAK responses also log as warnings with
transId+msgfor correlation. The 2026-05-27 brick was preceded by minutes ofnak: no available ESOs detected in systemthat we couldn't see through ftw telemetry — onlymosquitto_subrevealed it. Operators can now alert on any non-zero NAK rate.Tests
go/internal/control/pv_curtail_test.go— 4 new regressions:TestComputePVCurtail_DroppedDueToZeroPVDoesNotEmitRelease(brick scenario)TestComputePVCurtail_TinyShareSuppressedNotPublishedAsZero(rounding edge)TestComputePVCurtail_RemovedFromSupportsStillEmitsRelease(config-change release)TestComputePVCurtail_SlotClearReleasesEvenZeroPVDrivers(end-of-slot release)go/internal/drivers/lua_ferroamp_curtail_test.go— NAK/ACK counter metric testOut of scope (next PR)
Layer E from the brainstorming: self-healing watchdog that auto-publishes
pplimrelease when the driver detectssso_pv_v > 200V + ipv == 0for >10 min during daylight (sunpos elevation > 5°). Indicates a stuckpplimstate — automatic recovery without portal intervention.Test plan
make verifypassessupports_pv_curtail: trueon Ferroamp on the live SE4 site. During the next negative-spot slot, observe in/api/series:extapi_ack_countincrements on eachpplimcommandextapi_nak_countstays at 0 (or reveals an unexpected EMS issue early)🤖 Generated with Claude Code