Skip to content

fix(forecast): keep learning when an update moves the driver scripts - #1492

Merged
frahlg merged 2 commits into
masterfrom
1488-learning-revision
Oct 1, 2026
Merged

frahlg merged 2 commits into
masterfrom
1488-learning-revision

Conversation

@frahlg

@frahlg frahlg commented Oct 1, 2026

Copy link
Copy Markdown
Member

Problem

On a native install every Core update restarts the PV and load models. The learning revision hashes each measurement driver's resolved Lua path, and that path lives in the release's own folder (/opt/ftw-native/releases/<version>/drivers/…). A new release means a new path, a new revision and a reset, even when the script is byte-identical.

Home box, 22 Sep–1 Oct: 25 learning revisions in 9 days; the longest stable stretch was 53.7 h. Energyplan's load model needs two days to leave cold start and eight to be ready, so it never got there, and Core used the legacy load twin for 81 % of forecast points.

Change

  • forecastStaticRevision hashes each driver as configured (drivers/<name>.lua) and keeps the script content digest. A real script change still resets learning; a moved script does not.
  • Configure recognises learning IDs accepted under the old resolved-path policy (both the beta.4 measurement-driver form and the beta.3 all-driver form) and carries them over.

What a site sees on this update

  • Docker and Home Assistant: paths did not move, so the old learning ID carries over. No reset.
  • Native: the old revision hashed the previous release folder, which Core cannot rebuild. Learning starts over one last time, as every update did before. Later updates keep it.

Tests

  • TestForecastLearningSurvivesReleaseDirectoryMove: the same scripts in a new release folder keep the revision; changed script content changes it.
  • TestForecastLearningIDCarriesAcrossPortablePathPolicy: a learning ID accepted under the old policy carries over when the paths did not move.
  • make verify clean.

Fixes #1488. One of four forecast fixes found while evaluating #1482, with #1489, #1490 and #1491. They touch nearby code in go/cmd/ftw/forecast_site.go; merge order #1488 → #1489 → #1490.

🤖 Generated with Claude Code

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 1, 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-10-01T17:26:17.511257Z 6a19d50 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.

frahlg and others added 2 commits October 1, 2026 19:43
The learning revision hashed each measurement driver's resolved Lua path.
On a native install that path is the release's own directory, so every
update produced a new revision and started the PV and load models over,
even with byte-identical scripts. The home box saw 25 resets in 9 days.

Hash the configured path (drivers/<name>.lua) instead and keep the script
content digest, so a real measurement change still resets. A site whose
scripts did not move (Docker, Home Assistant) keeps the learning ID it
accepted under the old policy; a native site starts over once more, as
every update did before.

Fixes #1488

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
With a relative drivers directory the resolved path stays relative, so
Core cannot read the script and hashes "unavailable". Hashing only the
configured path then gave two directories with different measurement
code the same learning revision. Keep the resolved path for any driver
without a content digest, so a different script still resets learning.

Found by a local Codex review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Fredrik Ahlgren <[email protected]>
@frahlg
frahlg force-pushed the 1488-learning-revision branch from 6a19d50 to 1a40291 Compare October 1, 2026 17:51
@frahlg
frahlg merged commit 608aad5 into master Oct 1, 2026
15 checks passed
@frahlg
frahlg deleted the 1488-learning-revision branch November 11, 2026 09:11
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.

Forecast learning resets on every native update

1 participant