Skip to content

fix: clear stale property values on panel reboot to prevent mixed-gen snapshots#130

Merged
cayossarian merged 3 commits intomainfrom
release/v2.5.2
Apr 7, 2026
Merged

fix: clear stale property values on panel reboot to prevent mixed-gen snapshots#130
cayossarian merged 3 commits intomainfrom
release/v2.5.2

Conversation

@cayossarian
Copy link
Copy Markdown
Member

When the SPAN panel reboots, the MQTT accumulator previously retained pre-reboot property values. This could produce snapshots mixing stale pre-reboot data with fresh post-reboot data during the brief window before all circuits re-publish.

The accumulator now conditionally clears property/target/timestamp storage when $description arrives after a lifecycle reset, with a generation counter that invalidates the consumer's snapshot cache. Covers both normal reboots (via LWT $state=disconnected) and fast reboots (via $state=init without LWT).

Bumps version to 2.5.2.

…eration snapshots

When the SPAN panel reboots, the MQTT accumulator previously retained
pre-reboot property values. This could produce snapshots mixing stale
pre-reboot data with fresh post-reboot data during the brief window
before all circuits re-publish.

The accumulator now conditionally clears property/target/timestamp
storage when $description arrives after a lifecycle reset, with a
generation counter that invalidates the consumer's snapshot cache.
Covers both normal reboots (via LWT $state=disconnected) and fast
reboots (via $state=init without LWT).

Bumps version to 2.5.2.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a SPAN panel reboot edge case where the MQTT accumulator could retain pre-reboot property values, causing snapshots to temporarily mix stale data with fresh post-reboot data. It adds a generation counter to invalidate cached snapshots when a reboot-driven $description triggers a property clear.

Changes:

  • Clear accumulated property/target/timestamp state when $description is received after a lifecycle reset, and increment an accumulator generation counter.
  • Invalidate HomieDeviceConsumer’s cached snapshot when the accumulator generation advances.
  • Add unit tests covering reboot + fast-reboot scenarios and bump project version to 2.5.2.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/span_panel_api/mqtt/accumulator.py Clears stale values on reboot-indicated $description, adds generation, and adjusts $state handling.
src/span_panel_api/mqtt/homie.py Invalidates snapshot cache when accumulator generation changes.
tests/test_accumulator.py Adds reboot/fast-reboot tests validating clears + generation behavior.
tests/test_mqtt_homie.py Adds regression test ensuring cache invalidation prevents stale snapshot reuse.
pyproject.toml Bumps package version to 2.5.2.
uv.lock Updates lockfile and package version entry.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Address PR review feedback:
- _handle_state else branch now unconditionally sets lifecycle to
  CONNECTED, fixing a bug where is_ready() could return True when
  the device was in init/sleeping/alert state
- Updated property-clear comment to reflect all reset triggers
- Fixed generation docstring to match actual increment semantics
@cayossarian cayossarian merged commit ea22c9f into main Apr 7, 2026
6 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.

2 participants