Repository navigation
fix(planner): Codex review follow-ups from overhaul chain (P1+P2) - #103
Merged
Merged
Conversation
Bundles 8 issues Codex flagged across PRs #97-#101. Ordered by what blocks Erik's hardware testing most. ## P1 — charger kept running after slot ended (#101) When the current MPC slot had no EV allocation, the dispatch loop `continue`d without sending any command. Easee would keep drawing at its previous setpoint — including across a "stop charging" slot transition. Now we default cmdW=0 and always send the explicit ev_set_current command so the charger actively stands down. ## P1 — plugin_soc_pct never reached the runtime (#101) Added to loadpoint.Config in Phase 4.1 but never copied from YAML. Config knob was a no-op. Plumbed through config.Loadpoint and centralised the YAML→runtime mapping in a new buildLoadpointConfigs helper so boot-time init and hot-reload can't drift. ## P1 — TargetSlotIdx assumed 15-min slots (#100) Hard-coded `int(delta / (15 * time.Minute))` in main's LoadpointProbe, but Nordic day-ahead prices come as 60-min slots. A 2-hour deadline on hourly data mapped to slot 8, not slot 2 — DP thought it had 4× the time it actually did. LoadpointProbe now takes slotLenMin from the actual plan and mpc.Service passes it in from slots[0].LenMin. ## P1 — race on lastLoadpointID (#100) SlotDirectiveAt read s.last under RLock then s.lastLoadpointID outside. A concurrent replan could swap one without the other and produce a directive keyed under the wrong driver. Snapshot both under the same lock. ## P1 — infeasible DP states picked full-discharge fallback (#99) When mode + PowerLimits eliminated every action at a (slot, soc, ev) state, bestV stayed +Inf but bestPolicy defaulted to 0 — which encodes (ba=0, ea=0) = "full battery discharge, EV off", the WORST possible fallback. Now overrides bestPolicy to the closest-to-idle action index ((A-1)/2 * EA), so forward-sim produces a sane plan even in operator-induced infeasibility. ## P1 — persisted PV/load models misaligned after UTC switch (#97) pvmodel's β coefficients were fitted against local-zone hour-of-day harmonic features; loadmodel's buckets were indexed on local weekday+hour. After the Phase 1 UTC coercion in Features / HourOfWeek, restoring the old state silently misaligned both models against the new coordinate system. Bumped state keys (`pvmodel/state` → `pvmodel/state_utc`, `loadmodel/state` → `loadmodel/state_utc`) so old state is ignored on upgrade — model retrains from telemetry over a day or so. ## P2 — config hot-reload didn't touch loadpoints (#99) configreload callback skipped newCfg.Loadpoints entirely. Added a Load() call on the manager inside the callback — the manager preserves observed state across reloads, so adding / tuning loadpoints live no longer needs a process restart. ## P2 — session anchor lost on config reload (#101) loadpoint.Manager.Load preserved pluggedIn and delivered_wh_session but not sessionPluginSoCPct. A hot-reload mid-charge would reset the SoC inference baseline back to PluginSoCPct, making the estimate jump backward even though the car kept getting energy. Carry the anchor too. ## Tests - Added `TestOptimizeInfeasibleStatePicksNearIdle` covering the DP fallback. - All existing tests still pass incl. e2e (27s). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
5 tasks
frahlg
added a commit
that referenced
this pull request
Aug 30, 2026
#1008) Move the pin to srcfl/device-drivers@f98d5c5f (#103): easee_cloud emits request_active (false on Easee reason 50 / op_mode 4), which turns on the session-completion latch, manual-hold auto-release and interruption-noise suppression for Easee sites. Part of #1002. Claude-Session: https://claude.ai/code/session_01C1d4uknzs7QUv7nE9rW4fi Co-authored-by: Claude Fable 5 <[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.
Summary
Bundles the 8 issues Codex flagged across PRs #97-#101, ordered by how badly each blocks @erikarenhill's real-hardware testing on the v0.17.0 release.
P1 — critical
Charger kept running after slot ended (from feat(ems): EV dispatch + Easee command wiring (Phase 4.1) #101). When the current MPC slot had no EV allocation, dispatch
continued without sending anything — Easee kept drawing at its previous setpoint across a "stop" transition. Now we defaultcmdW=0and always send the explicit command so the charger actively stands down.plugin_soc_pctnever reached the runtime (from feat(ems): EV dispatch + Easee command wiring (Phase 4.1) #101). Added toloadpoint.Configin Phase 4.1 but never copied from YAML. Plumbed throughconfig.Loadpointand centralised YAML→runtime in a newbuildLoadpointConfigshelper so boot + hot-reload share one path.TargetSlotIdxassumed 15-min slots (from feat(mpc): unified battery + EV MPC (Phase 4 — ONE system) #100). Nordic day-ahead prices come as 60-min slots, so a 2 h deadline mapped to slot 8 instead of slot 2 — DP saw 4× the time it actually had.LoadpointProbenow takesslotLenMinfrom the actual plan and the service passes inslots[0].LenMin.Race on
lastLoadpointID(from feat(mpc): unified battery + EV MPC (Phase 4 — ONE system) #100).SlotDirectiveAtreads.lastunder RLock thens.lastLoadpointIDoutside — a concurrent replan could swap one without the other, routing a directive under the wrong driver. Snapshot both under the same lock.Infeasible DP states picked full-discharge fallback (from feat(mpc): PowerLimits per slot + Loadpoint observable skeleton #99). When mode + PowerLimits eliminated every action,
bestPolicydefaulted to 0 which encodes(ba=0, ea=0)= full battery discharge, EV off — the worst fallback. Now overrides to the closest-to-idle action so forward-sim produces a sane plan even in operator-induced infeasibility.Persisted PV/load models misaligned after UTC switch (from fix(mpc): DST/timezone audit — coerce planner time indexing to UTC #97).
pvmodel's β coefficients were fitted against local-zone harmonic features;loadmodel's buckets were indexed on local weekday+hour. After Phase 1's UTC coercion, restoring the old state silently misaligned both models. Bumped state keys (pvmodel/state→pvmodel/state_utc,loadmodel/state→loadmodel/state_utc) so old state is ignored on upgrade. Models retrain from telemetry over ~a day.P2
Config hot-reload didn't touch loadpoints (from feat(mpc): PowerLimits per slot + Loadpoint observable skeleton #99).
configreloadcallback skippednewCfg.Loadpointsentirely. Now the manager reloads inside the callback — it preserves observed state across reloads, so live loadpoint edits no longer need a process restart.Session anchor lost on config reload (from feat(ems): EV dispatch + Easee command wiring (Phase 4.1) #101).
loadpoint.Manager.LoadpreservedpluggedInanddelivered_wh_sessionbut notsessionPluginSoCPct. A hot-reload mid-charge would reset the SoC inference baseline. Carry the anchor too.Tests
mpc.TestOptimizeInfeasibleStatePicksNearIdle— covers the DP fallbackWhat @erikarenhill should expect after this lands
plugin_soc_pctconfig value will now actually take effect.GET /api/mpc/diagnosenow reliably reflects the loadpoint's driver even under concurrent replans.🤖 Generated with Claude Code