Repository navigation
fix(mpc): publish the worker's plan when only the car's room breaks - #2037
Conversation
Since #2023, Core rejects a worker plan in which the battery covers the house while a car it may not cover charges on the import room that frees. A single battery and car then get Core DP's plan. A site Core DP cannot model, such as two batteries or two cars, got no new plan: Core kept the previous one. The car's room now joins a clock hour's import as a rule live control holds by itself (planOverrun). When Core cannot plan the site, it publishes the worker's plan with a warning, as it already does for the hours; the charger's live room leaves battery discharge out (control.evBatteryDischargeW). The EV pulse check splits a battery that discharges past the house, which stays a hard rule, from the car's room. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ce13516982
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if overrun.carRoom != nil { | ||
| heldCarRoom = true | ||
| warnings = append(warnings, "Core cannot plan this site itself, so the plan lets the battery make room for the car; the charger still leaves that room out: "+overrun.carRoom.Error()) |
There was a problem hiding this comment.
Mark caution off when accepting a point-forecast overrun
For a multi-battery site using the bundled Energyplan worker with forecast caution enabled, this branch can publish a point-forecast plan while leaving CautionOff false. When the cautious solve fails and the point solve returns a car-room overrun, planWithForecastMargin returns that point error with withoutCaution false (pointErr == nil is false). Previously this car-room error prevented publication; accepting it here now publishes the point plan without the caution-off status, so web/plan-brief.js suppresses its “Plan without extra forecast margin” indicator. Preserve whether the accepted overrun used the point forecast and update the caution status and warning accordingly.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, thanks. Fixed in 8fbceb6. When Core publishes an overrun's plan and a downside worker planned a caution forecast that differed, the plan came from the point solve, since planWithForecastMargin returns only a point solve's error. Core now sets CautionOff and adds "Forecast caution gave no plan Core could publish; using the point forecast." TestCarRoomPointPlanIsWithoutCaution failed before (caution off = false) and passes now.
This also covers an hour's overrun, which had the same gap before this PR.
A worker that plans the caution forecast first returns only its point plan's error once caution fails. When Core publishes that overrun's plan because it cannot plan the site itself, the plan leaves out a caution forecast that differed, yet CautionOff stayed false, so the plan view hid "Plan without extra forecast margin". Core now sets CautionOff and says why. This also covers an hour's overrun, which had the same gap. Found by the Codex review on #2037. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Fredrik Ahlgren <[email protected]>
Problem
Follows #2023. Core now rejects a worker plan in which the battery covers
the house while a car it may not cover charges on the import room that
frees. With one battery and one car, Core then plans the site with its own
DP. Core DP cannot model two batteries or two cars (
coreDPModelError), sosuch a site got no new plan: Core kept the previous one until a plan passed.
The bundled Energyplan worker hits this. It sends every request with a car
that can charge to its fleet model, which still makes that room.
srcfl/energyplan#83 changed only the battery library, which plans requests
in which no car can charge. On a two-battery site with the field night's
house and fuse, Core rejected the bundled worker's plan and published none.
Change
itself.
importHourOverrunbecomesplanOverrun, withhoursandcarRoom.validatePlanrecords the first slot that breaks the car's roomand checks every other rule before it returns the overrun.
use), it publishes the worker's plan with a warning: "Core cannot plan this
site itself, so the plan lets the battery make room for the car; the
charger still leaves that room out: …". The charger's live room leaves
battery discharge out for the fuse and the import limit alike
(
control.evBatteryDischargeW, from fix(control,mpc): a battery that may not cover the car makes it no room #2023), so battery energy does notreach the car.
house stays a hard error. A pulse that fits only beside the discharge
returns
errPulseCarRoom, whichvalidatePlancounts as the car's room.published overrun is the point plan, since
planWithForecastMarginreturnsonly a point solve's error. Core then sets
CautionOffand says so. Thisalso covers an hour's overrun, which had the same gap. Found by the Codex
review (8fbceb6).
Not in this PR
Energyplan, and its search needs work first.
change nothing here, since fix(config): respect -drivers flag when resolving Lua paths #83 does not reach the fleet model.
docs/energyplan-contract.mdstates what the worker must do, not how Corehandles a breach, so it does not change.
Tests
TestValidatePlanNamesTheCarRoomOverrun: a steady car and a pulsing carthat break only the room give a
planOverrun; a battery that dischargespast the house gives a plain error. Before the fix both room cases gave
plain errors.
TestCarRoomWorkerPlanWhenCoreCannotPlan: with one battery Core's planstands, without the warning; with two batteries the worker's plan goes out
with it. Before the fix the two-battery site published no plan.
TestCarRoomPointPlanIsWithoutCaution: a downside worker whose cautionand point plans both break only the room; the published plan reads as
without caution. Failed before 8fbceb6 (
caution off = false).TestNativeFleetCarRoomWhenCoreCannotPlanruns with the bundled worker:two batteries, a 3,800 W house, a 9,250 W fuse. On master Core rejected the
plan and published none. With the fix the worker's
fleet_milp_rustplangoes out with the warning. Run on Linux arm64.
make native-solver-testpassed on Linux arm64 (Mac mini, Asahi Linux) atce13516 and 8fbceb6.
make verifypassed locally on macOS at both.Overlap
#1956 also changes
service.go, at other lines.Checklist
🤖 Generated with Claude Code