Skip to content

fix(forecast): restart PV or load learning across both pipelines - #1095

Merged
frahlg merged 6 commits into
masterfrom
fix/forecast-model-relearn
Sep 7, 2026
Merged

fix(forecast): restart PV or load learning across both pipelines#1095
frahlg merged 6 commits into
masterfrom
fix/forecast-model-relearn

Conversation

@frahlg

@frahlg frahlg commented Sep 7, 2026

Copy link
Copy Markdown
Member

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 test passes 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 forecastTracker coordinator persists per-signal learning cutoffs, resets the Energyplan worker (when forecast_reset is 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 503 pending). Pre-cutoff telemetry and observations are rejected; learningEvidence masks archived errors without deleting history. The bundled Energyplan worker moves to 0.2.2 with a new forecast reset action and schemas.

/api/pvmodel/reset and /api/loadmodel/reset delegate to ForecastLearning; GET responses include learning status. 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-07T13:10:36.131769Z d8a9a2e PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread go/cmd/ftw/forecast_learning.go

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale comment

Left a non-blocking comment: Cursor Bugbot completed with no unresolved findings, but APPROVAL_POLICY.md does not authorize auto-approval. No reviewers were assigned because no CODEOWNERS path matches these changes.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Pull Request Router and Approver

@cursor

cursor Bot commented Sep 7, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot 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)

@frahlg
frahlg merged commit f06edbd into master Sep 7, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant