Skip to content

fix: never remove registry rows on runtime inventory changes (1.8.73) - #116

Merged
1bobby-git merged 1 commit into
mainfrom
fix/runtime-migration-no-removal-1.8.73
Nov 10, 2026
Merged

1bobby-git merged 1 commit into
mainfrom
fix/runtime-migration-no-removal-1.8.73

Conversation

@1bobby-git

Copy link
Copy Markdown
Owner

문제

1.8.72 적용 후 재시작 5분 뒤(2026-11-10 01:21Z) 실행 중에 엔티티 323개가 지워졌습니다(button 287, binary_sensor 5, light 4, update 4, number 12, switch 3). 삭제 시각이 Bridge의 state_sync_watchdog(interval, 약 30분) 로그와 정확히 겹치고, 같은 패턴이 00:20Z·00:51Z에도 있었습니다.

  • Bridge 재조정은 observeAdvancedInventorySnapshot(..., { authoritativeWholeSnapshot: true })로 전체 스냅샷을 적용하고 buildAdvancedCommandCatalog는 void로 비동기 실행합니다.
  • 통합은 컨트롤·기기 종류 변화로 토폴로지 변경을 감지해 _migrate_entity_registry를 다시 돌리고, 그 순간의 불완전한 인벤토리로 판단해 명령 버튼과 읽기 전용 가전 전원 binary_sensor 등을 지웠습니다. 지금 인벤토리에서는 같은 기기에 명령이 있고 읽기 전용 가전으로도 정상 분류됩니다.
  • 플랫폼의 known 집합 때문에 같은 실행 중에는 다시 만들어지지 않아, 다음 재시작까지 사라진 상태로 남았습니다.

어느 필드가 정확히 비는지(명령, 기기 종류, presentation 중)는 Bridge 내부 타이밍이라 직접 관측하지 못했습니다.

수정

  • _migrate_entity_registry(..., allow_removal=True) 키워드를 추가했습니다. False면 엔티티 행 삭제와 고아 기기 카드 정리를 건너뛰고 이름 정리만 합니다.
  • 스케줄러는 ready 인벤토리로 한 번 정리한 뒤(설정 토폴로지의 즉시 실행과 15초 재시도)에 일어난 토폴로지 변경에는 allow_removal=False를 씁니다. 정말 사라진 기기는 다음 시작 때 정리됩니다.

테스트

  • 새 테스트 test_runtime_inventory_change_never_removes_entities: 수정 전 실패(재조정 후 명령 버튼 삭제), 수정 후 통과합니다. 설정 시점 정리(select.counter_gone)는 계속 지워지는지도 확인합니다.
  • 기존 스케줄러 테스트의 stub이 새 키워드를 받도록 고쳤습니다.
  • Python 426 통과. vitest는 Windows tar 관련 2건만 로컬 실패합니다(CI 통과 이력 있음).

🤖 Generated with Claude Code

The Bridge's periodic state reconciliation re-applies a whole inventory
snapshot and rebuilds the command catalog asynchronously. Topology-
triggered migrations during that window saw a partial inventory and
removed command buttons, read-only appliance power binary sensors and
more; platforms never re-add an entity they created in the same run, so
those stayed gone until the next start (observed every ~30 minutes).

Removal (entity rows and orphan device cards) now happens only until one
pass has run on a ready inventory at setup. Later passes only repair
entity IDs; genuinely removed devices are cleaned up on the next start.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@1bobby-git
1bobby-git merged commit 7180f6e into main Nov 10, 2026
7 checks passed
@1bobby-git
1bobby-git deleted the fix/runtime-migration-no-removal-1.8.73 branch November 10, 2026 01:35
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