fix(plan): clip export windows with no SoC above reserve - #4434
Merged
Conversation
…ose below their own limit For #4171: an export window whose SoC forecast never rises above the battery reserve throughout its span has nothing exportable, but clip_export_slots' existing "clip off" check only compared soc_max against the window's own requested limit_soc. For a window asking to drain to 0%, limit_soc is 0, which soc_max (always >= reserve) can never be below - so that branch could never fire, and the window fell into the "clip up" branch instead, surviving with a near-zero limit that is technically "on" but physically a no-op (execute.py already clamps any discharge target to the reserve floor). Confirmed via a reporter debug.yaml that this produces a real, harmless-but-confusing "planned to export from an empty battery" plan entry: toggling the window on vs off in a replay produces an identical metric, proving no real energy ever moved. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
springfall2008
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clip_export_slotshad a "clip off, nothing achievable" check that compared a window's predictedsoc_maxagainst its own requested limit (limit_soc). For a window asking to drain to 0%,limit_socis 0, andsoc_maxcan never be below that (the battery physically can't go below reserve) - so that branch could never fire, and the window fell into the "clip up" branch instead, surviving in the plan with a near-zero limit that's technically "on" but physically a no-op.export_window_best/export_limits_bestas computed by their instance) had a window at 23:50-00:00 stuck at a 0% export target while the battery was already flat at the 4% reserve for the whole evening. Forcing that window on vs off in a replay produces an identical metric - proof no real energy ever moved, it was purely a display/plan-entry artifact.Test plan
test_normal_export_clipped_off_when_soc_never_above_reserve- the Predbat plans to export when battery is empty #4171 regression casetest_normal_export_clipped_up_when_soc_above_reserve_with_zero_limit- guards that genuine clip-up behaviour is untouched when there's real energy above reserve./run_all --quickpasses with no regressions./run_pre_commitpasses (ruff, black, cspell, markdownlint, full test suite)plan_preclip): the window that wastarget: 0.0now clips to100.0🤖 Generated with Claude Code