fix(forecast): restart PV or load learning across both pipelines - #1095
Conversation
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.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d8a9a2e. Configure here.
There was a problem hiding this comment.
Stale comment
Left a non-blocking comment: Cursor Bugbot finished with an unresolved finding (reset can succeed without applying), and APPROVAL_POLICY.md does not authorize auto-approval. No reviewers were assigned because no CODEOWNERS path matches these changes.
Sent by Cursor Approval Agent: Pull Request Router and Approver
There was a problem hiding this comment.
Left a non-blocking comment: Cursor Bugbot completed with no unresolved findings, but APPROVAL_POLICY.md does not authorize auto-approval. Human review is still required; no reviewers were assigned because no CODEOWNERS path matches these changes.
Sent by Cursor Approval Agent: Pull Request Router and Approver
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_31c5c86b-4f46-45b0-9370-b17a42f2e846) |



The forecast reset endpoints previously cleared only the legacy Go models, leaving the primary Energyplan forecast unchanged. “Relearn solar production” and “Relearn consumption” now start separate learning periods across the primary model, its legacy fallback and error calibration. Measured history and the other model remain available.
Core saves the cutoff before resetting either pipeline, holds the site binding stable through the reset, replays incomplete work after restart or identity resolution, and blocks old or straddling observations. Resetting consumption clears every legacy profile and learned heating fit while keeping explicit configuration. A new replan supersedes work that captured old models. The API and advanced diagnostics show the primary learning state, start time and pending failures; retries preserve an already saved cutoff.
Includes the Energyplan 0.2.2 binary bundle from private source commit
b78cde268432671762e8c76c2c739f7a71f91087. The paired private worker change is Energyplan #4. It adds selective reset, exact state replay and compatible revision handling for skipped batches; no private source is included here.Validation: the combined beta candidate passes
make verify-all, including the real bundled worker, artifact checks, Go suites, vet, and Linux ARM64/AMD64 and Windows builds. Affected Go packages pass with the race detector;npm testpasses all 548 tests. Native integration tests cover selective reset, DB restart, delayed data, concurrent updates, pending recovery, identity gating and per-signal calibration. Six fault cases exercise the Energyplan wrapper and publication path with an active EV, measured 2.5% battery SoC, and a timeout or invalid worker plan: valid DP fallback retains the measured energy and meets the EV target; infeasible cases publish no replacement and preserve any previous plan. Browser checks cover the UI at desktop and mobile widths. A combined Core container also passed Settings save/reload and the PV learning restart through the actual UI; a separate load reset through HTTP preserved the PV learning period. Human visual review remains pending.A native regression also runs both selective resets through SQLite config import and a full backup restored at a new path. It checks exact learning periods, all load profiles, retained Go/Rust model state, resumed learning and rejection of old observations. This covers the integration with the config change in #1094. Physical-box installation is outside this change.
Note
High Risk
Changes forecast training, MPC inputs, and durable state across Go, Rust worker, and backup/restore paths; incorrect cutoffs or partial resets would directly affect planning quality.
Overview
Relearn solar production and Relearn consumption no longer wipe only the legacy Go twins. A new
forecastTrackercoordinator persists per-signal learning cutoffs, resets the Energyplan worker (whenforecast_resetis supported), legacy PV/load models, and per-signal error calibration together, and triggers MPC replan so plans do not keep stale models.Reset intent is saved before any pipeline changes and replayed on startup, after identity resolution, and when worker resets fail (
LearningRestartPendingError→ API 503pending). Pre-cutoff telemetry and observations are rejected;learningEvidencemasks archived errors without deleting history. The bundled Energyplan worker moves to 0.2.2 with a new forecastresetaction and schemas./api/pvmodel/resetand/api/loadmodel/resetdelegate toForecastLearning; GET responses includelearningstatus. Advanced twins UI shows engine, learning period, and guarded relearn actions instead of a full model wipe.Reviewed by Cursor Bugbot for commit 4c66b2f. Bugbot is set up for automated code reviews on this repo. Configure here.