fix: import result follows the commit; dropped route runs reach the store (#495)

Apply re-validated the preview token after both halves were durable, so a
TTL that lapsed during the write, or an eviction by a newer preview of the
same user, answered "preview expired" for a plan that was already replaced
and withheld both update events. The token is now simply spent after the
commit; validity is decided once, on entry under write_lock.

Route runs dropped by drop_unknown_routes never reached the store unless a
marker happened to be orphaned in the same pass; an idle robot kept them in
memory only and a restart brought them back. The drop now happens under
_refresh_lock, leaves with the orphan transaction or with an immediate
write of its own, and rolls back like #335 when the store refuses.

Tests: HA harness for both apply races and a live config/set route drop,
recorder stubs for the four durability cases; five mutants caught by the
standard runner.

Issue: #495
User-Visible: yes
This commit is contained in:
Codex
2026-09-09 08:34:46 +03:00
parent adbd349920
commit 2946e28352
8 changed files with 427 additions and 50 deletions
+8
View File
@@ -2,6 +2,14 @@
## Unreleased
- Applying a backup import no longer reports "preview expired" after the plan
was already replaced: once both halves of the import are written, the result
and the update events follow the commit even if the preview timed out or was
displaced by a newer preview while the write was in flight. Deleting or
re-targeting a robot map route now removes its recorded runs from disk as
well as from memory, so a Home Assistant restart cannot bring them back
([#495](https://github.com/Matysh/houseplan-card/issues/495)).
## v1.73.0-beta.7 — 2026-09-09
- Summary-panel settings stay responsive with large Home Assistant installs:
+8
View File
@@ -8,6 +8,14 @@
## Не выпущено
- Применение импорта из резервной копии больше не отвечает «preview expired»
после того, как план уже заменён: когда обе половины импорта записаны, ответ
и события обновления следуют за записью, даже если срок предпросмотра истёк
или его вытеснил более новый предпросмотр во время записи. Удаление или
перенацеливание маршрута карты робота теперь убирает записанные проезды и с
диска, а не только из памяти — перезапуск Home Assistant их не вернёт
([#495](https://github.com/Matysh/houseplan-card/issues/495)).
## v1.73.0-beta.7 — 2026-09-09
- Настройки сводной панели теперь остаются отзывчивыми даже при большом числе