Add local database mirror for ServerManager persistence#4472
Open
Add local database mirror for ServerManager persistence#4472
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a GRDB-backed “mirror” persistence layer for ServerManager so non-secret server metadata can be recovered if Keychain entries are lost (e.g., during developer account migration), while keeping Keychain as the source of truth for secrets.
Changes:
- Introduces
ServerManagerMirrorStore+ GRDB implementation and a newserverInfoMirrortable to persist sanitizedServerInfo. - Updates
ServerManagerImplto keep Keychain + mirror in sync, and to fall back to the mirror when Keychain entries are missing. - Extends
ServerInfowith sanitization helpers and updates unit tests/DB schema tests to cover the new table and mirror behavior.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| Tests/Shared/ServerManager.test.swift | Adds a fake mirror store and tests for backfill/fallback/precedence behavior. |
| Tests/Shared/Database/TableSchemaTests.test.swift | Adds schema validation for ServerInfoMirrorTable and updates total table count. |
| Tests/Shared/Database/GRDB+Initialization.test.swift | Updates initialization expectations to include the new table and new total count. |
| Tests/Shared/Database/DatabaseTableProtocol.test.swift | Adds conformance test for ServerInfoMirrorTable and updates total table count. |
| Sources/Shared/Database/Tables/ServerInfoMirrorTable.swift | Defines the GRDB table schema for the mirror store. |
| Sources/Shared/Database/GRDB+Initialization.swift | Registers the new table in DatabaseQueue.tables(). |
| Sources/Shared/Database/DatabaseTables.swift | Adds serverInfoMirror table name + column enum. |
| Sources/Shared/API/ServerManagerPersistence.swift | Extracts Keychain/mirror persistence protocols and Keychain helpers. |
| Sources/Shared/API/ServerManagerMirrorStore.swift | Implements GRDB-backed mirror persistence (ServerManagerGRDBMirrorStore). |
| Sources/Shared/API/ServerManager.swift | Integrates mirror store into ServerManagerImpl (sync, fallback reads, merged listing). |
| Sources/Shared/API/Server.swift | Adds mirroredForPersistence and placeholder token used for sanitized persistence. |
| HomeAssistant.xcodeproj/project.pbxproj | Adds new source files to the Xcode project. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Introduce a GRDB-backed sanitized mirror for ServerManager so non-secret server metadata can be recovered if Keychain entries are lost (e.g. during developer-account migration). Key changes:
This ensures the app can restore server shells without exposing secrets outside the Keychain, while keeping Keychain as the source of truth.
Screenshots
Link to pull request in Documentation repository
Documentation: home-assistant/companion.home-assistant#
Any other notes