Repository navigation
fix(planner): use remaining slot time and score active decisions - #1130
Merged
Merged
Conversation
frahlg
marked this pull request as ready for review
September 8, 2026 07:18
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_61125591-78a5-4155-8e61-752f9cd2fb1d) |
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 was referenced Sep 8, 2026
frahlg
added a commit
that referenced
this pull request
Sep 8, 2026
…et (#1172) The load rain-check still integrated the first price slot as LenMin after #1130 trimmed it to remaining time. Energyplan's worker budget was model-size only, so a late-in-slot fleet replan could spend 5s on a result that firstSlotExpired then discarded. Use DurationHours() for rain-check energy. Cap TimeLimitS and the process wait by remaining first-slot time minus a short publish margin, and fail fast when remaining time is below the small-model budget. Closes #1144 Closes #1148 Signed-off-by: Fredrik Ahlgren <[email protected]>
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.
A replan at 04:57:28.939 used live battery SoC but credited a full 04:45–05:00 interval. Its 1514 W charge represented 379 Wh in the model even though only 151 seconds remained, enough for 64 Wh at that power. Slot delivery metrics also compared the full measured quarter with the last replan, which could report a sign mismatch after an ordinary change of direction.
Add
execution_start_msinside the first price interval. Energyplan 0.3.1, Core DP, independent validation, baselines, shadows, diagnostic restore, battery/EV directives and the app protocol now use the same remaining time. Price and forecast identity remain tied to the original interval. Core rejects a plan whose first interval ends before publication and queues one fresh retry. Existing catch-up, SoC, fuse, stale-meter and direction protections remain in the control path; partial intervals retain the full interval's intent threshold.Delivery accounting now combines the decisions observed during each part of the price interval. A replan changes only the remaining target. Logs identify this basis and count replans; gaps without measurements or a plan do not add energy to either side. Support reports compare measured energy with
PlannedSoFarWhover those same intervals, so a future direction change cannot trigger a false historical shortfall. They describe elapsed-time and replan credits as budget accounting, separate from measured energy.Paired private worker PR: https://github.com/srcfl/energyplan/pull/8, source
0ef352a5842c2827421a50f83ca446397527cae7. FTW contains only its compiled Linux ARM64/AMD64 and macOS ARM64 workers and public integration metadata.Execution starts at the read of the latest battery state, before solving. Sensor age and physical changes during solving remain model latency; an expired first interval cannot publish.
Validation:
make verify, including charge/discharge, multiple batteries and EV, invalid intervals and 0/7.5/12.5 minutes elapsed, the observed 151.061-second case and one second remaining.make verifyand the real compiled-worker contract suite.go test -race ./internal/mpc ./internal/control ./internal/appproto, plus the control/API race suites after the report fix.donecould read the callback count too soon. These behavior tests now finishrunJobbefore checking the result. The updater race suite and 100 repeated ordering tests pass; updater production code is unchanged.Physical verification for the combined beta, owned by the release coordinator:
No merge, box installation or release performed by this task. Hardware validation remains pending.
Note
High Risk
Changes core planner publication, optimizer contract, and dispatch energy accounting—errors could mis-size battery commands or slot-delivery diagnostics on live sites.
Overview
Late replans were modeling and dispatching against a full price interval even when only seconds remained, which inflated energy/SoC and could spike catch-up power. This PR introduces
execution_start_mson the first slot so Core DP, Energyplan 0.3.1, validation, shadows, EV budgets, directives, and app plan projection all use the same remaining execution window while price slot identity stays on the original interval.Publication rejects a solve whose first interval ends before install and triggers a
slot_elapsedretry from live state. Dispatch seeds the execution budget from elapsed-time credit without counting that credit as measured energy; idle/charge/discharge intent still uses the full price-interval threshold viaintentEnergyWh.Slot delivery metrics and support reports now compare measured Wh to
PlannedSoFarWhover the intervals each accepted decision actually covered, so a later direction change cannot rewrite earlier expectations or infer “reactive path” from budget accounting alone.Updater self-replace tests wait for
runJobto finish before asserting sidecar replacement, fixing a race wheredonecould be read before the callback ran.Reviewed by Cursor Bugbot for commit 918cac5. Bugbot is set up for automated code reviews on this repo. Configure here.