Skip to content

fix(forecast): capture live observation time with telemetry - #1127

Merged
frahlg merged 1 commit into
masterfrom
fix/forecast-observation-time
Sep 8, 2026
Merged

fix(forecast): capture live observation time with telemetry#1127
frahlg merged 1 commit into
masterfrom
fix/forecast-observation-time

Conversation

@frahlg

@frahlg frahlg commented Sep 8, 2026

Copy link
Copy Markdown
Member

A delayed forecast archive write can leave the observer's ticker time behind the latest power readings. The observer then treats fresh readings as future data and clears the current learning interval.

Use the existing telemetry snapshot method that captures the time after acquiring the read lock. Use that same time for observation intervals, availability and curtailment checks. The ticker now only wakes the observer. Explicit forecast origins, frozen issue inputs and the bounded archive retry and shutdown paths keep their current behavior.

This addresses the late review finding on #1125 before publishing the next beta.

Validation:

  • The same accumulator regression fails on the old implementation with its scheduled-time argument: the complete quarter disappears. With the fix, it retains both 1,200 W household load and 800 W PV over the full quarter.
  • A three-minute observation gap still excludes the incomplete quarter. The focused regression passes 20 runs and the race detector.
  • Archive contention, ambiguous commit, bounded retry, shutdown and frozen-snapshot regression tests pass under the race detector.
  • make verify passes.

Note

Medium Risk
Changes live forecast observation timing and interval completion logic, which feeds learning and archived observations; risk is mitigated by focused regression tests and unchanged explicit-origin paths.

Overview
Fixes lost 15-minute forecast learning intervals when archive writes delay the observer tick. If observe ran with the ticker’s scheduled now while newer meter/PV samples were already in the store, interval logic could treat those readings as future data and drop the in-progress quarter.

Live observation now only uses the ticker as a wake-up: observe calls ForecastMeasurementNow and derives now from r.At after the telemetry read lock, so measurement time, curtailment checks, and observationIntervals stay aligned with the snapshot. Explicit forecast origins and frozen issue capture are unchanged.

Adds regression tests for the delayed-observe scenario (full quarter retained at 1200 W load / 800 W PV) and confirms a 3+ minute gap still rejects the quarter. Call sites and occupancy tests updated for the parameterless observe(ctx).

Reviewed by Cursor Bugbot for commit e3076a4. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor

cursor Bot commented Sep 8, 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_cc4ece45-a7c8-4475-99d7-57fd7da4aa39)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 8, 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-08T02:56:08.894811Z e3076a4 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
frahlg merged commit e6b3750 into master Sep 8, 2026
15 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