Skip to content

fix(telemetry): give a new driver its watchdog timeout before the first reading - #1425

Merged
frahlg merged 1 commit into
masterfrom
fix/watchdog-new-driver
Sep 25, 2026
Merged

frahlg merged 1 commit into
masterfrom
fix/watchdog-new-driver

Conversation

@frahlg

@frahlg frahlg commented Sep 25, 2026

Copy link
Copy Markdown
Member

Fixes #1421.

Why

Registry.Add creates a driver's health record before its first emit, with LastSuccess nil. WatchdogScan treated nil as stale, so the next control tick flipped every newly added driver offline, sent its autonomous default and published DriverLost. The registry had already run the startup default (host_start), so the second default only disturbed the device. On the home box, Easee rewrote its phase mode and charging current 2–4 s after every Core restart and driver install: six times between 2026-09-24 18:00 and 07:03 the next morning.

Change

  • DriverHealth.StartedAt is set when the record is created. Until the first success, the watchdog measures from it.
  • A driver that never emits still goes offline and receives its default once the timeout passes.
  • A restart removes the record, and the replacement starts its own window.
  • Dispatch safety does not depend on this. The pre-dispatch freshness boundary works from site-meter readings, and a driver without a reading gets no command.

Evidence

  • TestWatchdogGivesANewDriverItsTimeoutBeforeTheFirstReading fails on the old scan with "a driver added just now went stale" and passes now.
  • go test passes for internal/telemetry, internal/drivers, cmd/ftw, internal/pvmodel and internal/api.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7

…st reading

Registry.Add creates the driver's health record before the first emit,
with no LastSuccess. WatchdogScan counted that as stale, so the next
control tick marked the driver offline, sent its autonomous default and
published DriverLost. The registry had already run the startup default,
so the second one only disturbed the device: on the home box Easee
rewrote its phase mode and charging current 2-4 s after every restart
and driver install (six times on 2026-09-24/25).

The health record now carries StartedAt. Until the first success the
watchdog measures from it, so a driver that has not had time to emit is
not stale, and one that never emits still goes offline after the
timeout. The new test fails on the old scan.

Fixes #1421.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 25, 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-25T06:03:00.357442Z ef33928 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.

@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: ef339287dc

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

h, ok := s.health[name]
if !ok {
h = &DriverHealth{Name: name}
h = &DriverHealth{Name: name, StartedAt: time.Now()}

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 Start the grace period only after initialization succeeds

When driver_init calls host.set_watchdog_timeout_s and subsequently fails, this path creates a health record with a fresh StartedAt, while Registry.add only cleans up the runtime and leaves that record behind. The watchdog therefore treats a driver that never successfully started as online for the full override—up to 15 minutes—and /api/health counts it as OK; the same regression exists for the new StartedAt assignment in SetDriverDeviceFault. Set the grace timestamp when Add succeeds, or remove pre-init health on every failed-add path, so startup failures remain visible.

AGENTS.md reference: AGENTS.md:L22-L23

Useful? React with 👍 / 👎.

@frahlg
frahlg merged commit f60d99d into master Sep 25, 2026
15 checks passed
@frahlg
frahlg deleted the fix/watchdog-new-driver branch September 25, 2026 06:07
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.

Watchdog sends the default mode to a driver that has just started

1 participant