Parent: #82
Related: #81
Problem
CoreDataAppRepository builds home and location lookup dictionaries with Dictionary(uniqueKeysWithValues:). If CloudKit import, migration retry, or partial share state ever leaves duplicate CDHome.id or CDStorageLocation.id values in the local store, this call traps instead of throwing.
That is a plausible persistent launch/use crash-loop vector because AppStore.refresh() runs during app startup and refreshes again after remote changes.
Proposed work
- Replace
Dictionary(uniqueKeysWithValues:) in repository mapping with duplicate-aware grouping.
- Log duplicate entity type, UUID, objectID URI, and persistent store scope.
- Pick a deterministic survivor for UI mapping or skip ambiguous records without crashing.
- Decide whether duplicate records should be repaired automatically or only surfaced as diagnostics.
- Add regression tests that insert duplicate home/location UUIDs and prove
listHomes(), listLocations(), and AppStore.refresh() do not trap.
Acceptance criteria
- Duplicate Core Data UUIDs cannot crash the app during refresh or launch.
- Duplicate state produces actionable logs.
- Tests cover duplicate homes and duplicate locations across private/shared-store style data.
Parent: #82
Related: #81
Problem
CoreDataAppRepositorybuilds home and location lookup dictionaries withDictionary(uniqueKeysWithValues:). If CloudKit import, migration retry, or partial share state ever leaves duplicateCDHome.idorCDStorageLocation.idvalues in the local store, this call traps instead of throwing.That is a plausible persistent launch/use crash-loop vector because
AppStore.refresh()runs during app startup and refreshes again after remote changes.Proposed work
Dictionary(uniqueKeysWithValues:)in repository mapping with duplicate-aware grouping.listHomes(),listLocations(), andAppStore.refresh()do not trap.Acceptance criteria