Skip to content

fix(mpc): preserve one-sided zero battery limits (Codex follow-up) - #94

Merged
frahlg merged 2 commits into
masterfrom
fix/mpc-preserve-one-sided-zero-limits
Apr 18, 2026
Merged

frahlg merged 2 commits into
masterfrom
fix/mpc-preserve-one-sided-zero-limits

Conversation

@frahlg

@frahlg frahlg commented Apr 17, 2026

Copy link
Copy Markdown
Member

Codex flagged that #93 was too aggressive: it turned every zero override into 'use default', re-enabling a direction the operator explicitly disabled. max_charge_w: 0 is a valid one-sided constraint supported by mpc.Optimize's action grid.

Revised rule:

  • both zero (charge + discharge) → config error, fall back to default + warn
  • one-sided zero → pass through (operator intent preserved)
  • negative → fall back to default + warn

Also fixes a sibling test flake (hardcoded wall-clock date) in TestSlotDirectiveAtDischarge.

🤖 Generated with Claude Code

frahlg and others added 2 commits April 17, 2026 19:41
PR #93 was too aggressive: it treated every non-positive override as
a config error, including intentional one-sided constraints. But
`max_charge_w: 0` is a legitimate "forbid charging, allow discharge"
directive that mpc.Optimize's action grid (`-MaxDischargeW…+MaxChargeW`)
already supports. The fix was overriding operator intent.

Only the both-zero case (charge and discharge both 0) stays treated
as a config error — that leaves the planner with no action space and
produces the empty plan that looked like "disabled" in the UI.
One-sided zero passes through untouched; negative values still fall
back to default 0.5C with a warning.

Also fixes a second time-sensitive flake in TestSlotDirectiveAtDischarge
that was anchored to a hardcoded wall-clock date (same root cause as
the one fixed in #91).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@frahlg
frahlg merged commit f20ee6e into master Apr 18, 2026
1 check passed
@frahlg
frahlg deleted the fix/mpc-preserve-one-sided-zero-limits branch April 18, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant