Repository navigation
fix(history): keep a rejected hold unknown until its source returns - #1758
Merged
Merged
Conversation
The negative-balance guard cleared only the interval's copy of a held value; the cursor kept it. While the source stayed unknown, a later rise in house use made the same rejected charge valid again, so Home use lost it and a phantom charge was recorded. The rejected sources now stay unknown in the cursor until they report again. Found by Codex's adversarial review of #1753. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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.
Follow-up to #1753. Relates to #1750. Found by Codex's adversarial review of #1753 (medium).
Problem
#1753 holds an unknown source at its last known value, and stops the hold when the held value would make the household negative. That guard cleared only the interval's copy. The writer cursor (
last.Held) kept the value, so while the source stayed unknown it was offered again on every snapshot.Example: a held 2 kW charge is rejected when the car finishes and grid import falls to 1 kW. A heater then raises the house to 4 kW. The same rejected 2 kW passes the guard again, so Home use loses 2 kW and a phantom charge is recorded until the charger reports again.
Change
holdSourceIntervalTxreturns the held sources the guard rejected.recordSourceEnergyTxmarks them unknown inlast.Held. A new reading from the source makes it known again, as before.Evidence
TestSourceLoadForgetsARejectedHold: a 1 kW house with a 2 kW charge. The charger falls silent at 10 minutes, the car finishes at 20, a heater adds 3 kW at 30, and the charger reports 0 W after 50.make verify: passed: all Go suites, protocol, scripts, the Docker release context, vet and build. Nothing skipped.Not verified
Not run on a box. Nothing was changed on any box.
#1755 changes only a comment at the top of
history_sources.go; the two merge without conflict.🤖 Generated with Claude Code