Repository navigation
fix(telemetry): give a new driver its watchdog timeout before the first reading - #1425
Conversation
…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
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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()} |
There was a problem hiding this comment.
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 👍 / 👎.
Fixes #1421.
Why
Registry.Addcreates a driver's health record before its first emit, withLastSuccessnil.WatchdogScantreated nil as stale, so the next control tick flipped every newly added driver offline, sent its autonomous default and publishedDriverLost. 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.StartedAtis set when the record is created. Until the first success, the watchdog measures from it.Evidence
TestWatchdogGivesANewDriverItsTimeoutBeforeTheFirstReadingfails on the old scan with "a driver added just now went stale" and passes now.go testpasses forinternal/telemetry,internal/drivers,cmd/ftw,internal/pvmodelandinternal/api.🤖 Generated with Claude Code
https://claude.ai/code/session_01MuerPFZFG88kgu8sWVHeq7