Skip to content

refactor(hass): extract discovery domain#4729

Draft
AlCalzone wants to merge 34 commits into
alcalzone-backend-refactor-socket-handlersfrom
alcalzone-backend-refactor-hass-domain
Draft

refactor(hass): extract discovery domain#4729
AlCalzone wants to merge 34 commits into
alcalzone-backend-refactor-socket-handlersfrom
alcalzone-backend-refactor-hass-domain

Conversation

@AlCalzone

@AlCalzone AlCalzone commented Jul 11, 2026

Copy link
Copy Markdown
Member

Extracts the Home Assistant discovery domain from Gateway.

  • Separates entity generation, custom-device loading, persistence, and watcher ownership.
  • Keeps discovery payloads, identifiers, templates, command mappings, and synchronous projection compatible.
  • Review focus: cache/watcher lifecycle, stale publication fencing, and exact MQTT discovery output.

Part of #4722. Stacked on #4728.

@coveralls

coveralls commented Jul 11, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 29567758133

Warning

No base build found for commit b9dd3b4 on alcalzone-backend-refactor-socket-handlers.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 43.056%

Details

  • Patch coverage: 95 uncovered changes across 7 files (786 of 881 lines covered, 89.22%).

Uncovered Changes

File Changed Covered %
api/hass/DiscoveryGenerator.ts 592 544 91.89%
api/lib/Gateway.ts 136 109 80.15%
api/lib/ZwaveClient.ts 12 1 8.33%
api/app.ts 16 12 75.0%
api/hass/CustomDeviceRegistry.ts 78 75 96.15%
api/runtime/AppRuntime.ts 4 3 75.0%
api/socket/hassApi.ts 4 3 75.0%
Total (12 files) 881 786 89.22%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 6992
Covered Lines: 3196
Line Coverage: 45.71%
Relevant Branches: 4479
Covered Branches: 1743
Branch Coverage: 38.91%
Branches in Coverage %: Yes
Coverage Strength: 30.34 hits per line

💛 - Coveralls

@AlCalzone
AlCalzone marked this pull request as draft July 11, 2026 21:11
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-socket-handlers branch from fc3970a to 428aa02 Compare July 16, 2026 05:51
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-hass-domain branch from d0a95f8 to 48c2e1b Compare July 16, 2026 06:51
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-socket-handlers branch from 428aa02 to 122277f Compare July 16, 2026 12:14
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-hass-domain branch from 48c2e1b to d8adedf Compare July 16, 2026 13:01
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-socket-handlers branch from 122277f to ac5c083 Compare July 16, 2026 18:56
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-hass-domain branch from d8adedf to 7d7c6af Compare July 16, 2026 19:23
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-socket-handlers branch from ac5c083 to b9dd3b4 Compare July 17, 2026 08:11
AlCalzone and others added 19 commits July 17, 2026 10:16
Move legacy HASS DTOs and editor persistence behind typed domain ports, and replace Gateway's process-global custom catalog with disposable per-instance registries while preserving legacy loader seams.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Preserve the legacy two-watcher import lifecycle through a shared source while each Gateway owns an isolated subscribed catalog view. Dispose views and event listeners across restart and failed teardown, and tolerate legacy malformed catalogs without poisoning hash retries.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Emit the current node projection after concurrent persistence and keep cover STOP writes bound to the cached MQTT mapping even if the live value disappears.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep legacy undefined metadata coercion in entity names and replace vacuous rediscovery and RAW availability checks with exact, non-empty payload assertions.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Load discovery and Gateway modules only after the temporary STORE_DIR is active, verify the repository store byte-for-byte, and restore watchers, modules, and environment state during teardown.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Accept the emitter's optional value-change flag while preserving the legacy false default, keeping restart-safe listener bindings strict-neutral.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Assert isolated config, secrets, logs, and concrete watcher paths at import time without racing unrelated parallel logger tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove redundant changed comments and keep repository-store isolation checks stable when logger tests write concurrently.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Ignore only logger-owned repository artifacts across concurrent isolation snapshots.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Clone per-device array containers at fork boundaries so dynamic climate discovery cannot mutate sibling Gateway catalogs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
AlCalzone and others added 15 commits July 17, 2026 10:17
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Evict the resolved CommonJS module before watcher reloads so same-path customDevices.js edits propagate to active registry forks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@AlCalzone
AlCalzone force-pushed the alcalzone-backend-refactor-hass-domain branch from 7d7c6af to 1ca0240 Compare July 17, 2026 08:49
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