Skip to content

fix(history): keep a rejected hold unknown until its source returns - #1758

Merged
frahlg merged 1 commit into
masterfrom
1750-forget-rejected-hold
Oct 20, 2026
Merged

frahlg merged 1 commit into
masterfrom
1750-forget-rejected-hold

Conversation

@frahlg

@frahlg frahlg commented Oct 20, 2026

Copy link
Copy Markdown
Member

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

holdSourceIntervalTx returns the held sources the guard rejected. recordSourceEnergyTx marks them unknown in last.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.

Minutes 21–49 master this PR
EV energy recorded 666.7 Wh (phantom 2 kW for 20 min) 0 Wh
Minutes with EV unknown 9 of 29 29 of 29

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

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>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T04:55:57.323863Z b73183d PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit 9bd114e into master Oct 20, 2026
22 checks passed
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