Repository navigation
fix(planner): keep replan inputs consistent and demand history on the tariff rule - #1451
Conversation
… tariff rule - #25 Config reload swaps fuse, export ceiling, export prices, VAT, demand tariff and timezone in one locked UpdateSiteEconomics call. Each replan copies them, k and the arbitrage spread with its params, so one plan never mixes old and new values and the hot-reload data race is gone. - #26 SetMode and SetSafetyK change the setting and queue a background replan under one lock instead of solving on the caller's context. A disconnecting HTTP client no longer cancels the solve into a fallback plan, and saving planner prefs no longer runs two solves under configWriteMu. Startup sets the restored mode and restores the persisted plan before the planner starts. - #27 Demand-charge history (AlreadyKW) applies the Ellevio night weight and keeps one peak per local day, like the planned hours. - #46 SavePrices removes cached rows that a new row overlaps, and the ENTSO-E parser keeps the finer series where PT15M and PT60M overlap, so a mixed resolution no longer stops every replan. - #28 unchanged: covering the current clock hour needs an Energyplan contract change and pin bump. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
…riff Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e2ed1392f2
ℹ️ 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 o.SlotLenMin < r.SlotLenMin && o.SlotStart.Before(end) && | ||
| r.SlotStart.Before(o.SlotStart.Add(time.Duration(o.SlotLenMin)*time.Minute)) { | ||
| finer = true | ||
| break |
There was a problem hiding this comment.
Preserve partially uncovered coarse price slots
When an ENTSO-E document contains a coarse slot that is only partly covered by finer rows—for example, one 60-minute row plus a single overlapping 15-minute row—this marks the entire coarse row as superseded and drops the remaining 45 minutes of valid coverage. The resulting price timeline has a gap where dispatch cannot obtain a planned action; split the coarse row around finer coverage or remove it only when finer rows cover its full interval.
Useful? React with 👍 / 👎.
Round 2 of the multi-agent hardening and refactor review. A skeptic confirmed each finding against the code, and a second reviewer checked this diff and ran its tests. Removals follow the owner decisions of 2026-09-26.
Changes
Not done
Evidence
All run from go/ with PATH=/go/bin and GOTMPDIR=$HOME/.cache/go-tmp:
Review
The planner hardening is sound. Every new test fails without its fix. The skip of #28 is justified: fixing it needs an Energyplan contract change and a pin bump, which is cross-repo.
#25: every hot-reload writer of the economics fields now goes through UpdateSiteEconomics or UpdatePlannerScalars under s.mu. Grep finds the remaining direct writes to mpcSvc fields only at startup, before Start. beginReplanLocked copies the site economics, safetyK and minSpread, and runReplan, onlineFleetParams and demandChargesFor read only that copy. Hot reload with no price section now zeroes the tariff inputs, which matches startup.
#26: SetMode and SetSafetyK apply their change and bump the generation under one lock, then run on the existing coalescing background worker with context.Background(). A client disconnect can therefore no longer publish a fallback plan. When SetSafetyK supersedes SetMode, the service cancels the first solve (canceledByService), so no fallback is published. The window where ctrl.Mode has changed but the plan has not also existed before, because the handler sets ctrl.Mode before calling SetMode.
On the reordered startup: the mode is set and the persisted plan …
🤖 Generated with Claude Code
https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7