Skip to content

fix(savings): reject long telemetry gaps - #892

Merged
frahlg merged 2 commits into
masterfrom
agent/savings-gap-coverage
Aug 11, 2026
Merged

frahlg merged 2 commits into
masterfrom
agent/savings-gap-coverage

Conversation

@frahlg

@frahlg frahlg commented Aug 11, 2026

Copy link
Copy Markdown
Member

What

  • reject raw telemetry intervals over 20 minutes in the production daily cost path
  • fetch a predecessor and clip valid intervals to the requested range
  • deduplicate equal timestamps in hot, warm, cold order
  • expose expected, history-covered and priced-covered durations per day and as weighted totals
  • add bounded history and priced coverage fractions
  • label the endpoint as value_scope: site_total with an explicit no-PV/no-battery baseline
  • preserve all existing response fields and saved_ore semantics

Why

The old integrator applied the next power sample across any gap. A long outage could therefore create energy, cost and reported savings. The endpoint also looked like an optimizer metric even though it combines PV, battery, export and vehicle timing value.

This removes fabricated value and exposes how much data supports each result. It does not claim incremental optimizer gain.

Part of #885.

Tests

  • full go test ./internal/state ./internal/api
  • changed-path race tests
  • make verify
  • pre-push make verify-all, including linux/arm64, linux/amd64 and windows/amd64 builds

Behavior

Cold-tier daily points and any other raw cadence above 20 minutes now report missing coverage instead of extrapolating power. No database migration is needed. The API additions are backward-compatible.

@frahlg
frahlg marked this pull request as ready for review August 11, 2026 07:00
@frahlg
frahlg merged commit 6e3d9fb into master Aug 11, 2026
14 checks passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 81323b3c2c

ℹ️ 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".

Comment on lines +238 to +239
"history_coverage_pct": ds.HistoryCoverage,
"priced_coverage_pct": ds.PricedCoverage,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use coverage before presenting savings as complete

When a day has price slots but no usable telemetry—or loses intervals to the new 20-minute gap limit—resolutionFor still returns "slot" while these fields report partial or zero coverage. The existing consumers ignore the new fields: web/components/savings-periods.js:25-33 treats every non-no_prices day as complete, and web/components/ftw-savings-card.js:685-700 renders the aggregate totals without a coverage warning. Consequently, the tested prices-without-history case is shown to operators as a complete +0 saved result, and partially covered periods are shown as authoritative totals; update the card/period completeness logic to account for history and priced coverage.

Useful? React with 👍 / 👎.

@frahlg
frahlg deleted the agent/savings-gap-coverage branch August 17, 2026 18:18
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