# SwiftData Retirement Inventory

**Last Updated:** 2026-05-25

This inventory supports Milestone 9 in [`Refactoring-Plan.md`](Refactoring-Plan.md).
SwiftData is legacy/prototype infrastructure only. The target app must launch
and run active Time Machine flows from SQLite archive + Core Data cache, with
local settings stored outside SwiftData where needed.

## Current Count

After moving timeout calibration and local device profile settings out of
SwiftData, 26 app files still have SwiftData imports.

## Launch Container

These files keep SwiftData required at app launch:

- `HealthProbe/HealthProbeApp.swift`
- `HealthProbe/ContentView.swift`

Retirement path:
- move remaining local settings model (`OperationLog`) to non-SwiftData storage
  or Core Data cache/local store;
- replace prototype snapshot model dependencies in tab roots;
- remove `.modelContainer(...)` once no active view needs `@Query` or
  `ModelContext`.

## Legacy Model Definitions

These files define SwiftData `@Model` classes and are the largest retirement
block:

- `HealthProbe/Models/AnomalyRecord.swift`
- `HealthProbe/Models/HealthRecord.swift`
- `HealthProbe/Models/HealthSnapshot.swift`
- `HealthProbe/Models/OperationLog.swift`
- `HealthProbe/Models/SnapshotDelta.swift`
- `HealthProbe/Models/TypeCount.swift`
- `HealthProbe/Models/TypeDelta.swift`
- `HealthProbe/Models/TypeDistributionBin.swift`
- `HealthProbe/Models/YearlyCount.swift`

Retirement path:
- replace `HealthSnapshot`, `TypeCount`, `SnapshotDelta`, `TypeDelta`,
  `YearlyCount`, `TypeDistributionBin`, and `HealthRecord` active reads with
  archive/cache DTOs;
- replace `AnomalyRecord` flows with neutral change/diff DTOs;
- move `OperationLog` to a local non-SwiftData store before removing the launch
  container.

## Capture And Maintenance Services

These services still write/read legacy SwiftData transition models:

- `HealthProbe/Services/DeltaService.swift`
- `HealthProbe/Services/HealthKitService.swift`
- `HealthProbe/Services/ObserverService.swift`
- `HealthProbe/Services/SnapshotLifecycleService.swift`
- `HealthProbe/Utilities/TypeCountArchiveRepair.swift`

Retirement path:
- make capture persist archive observations first and expose only bridge ids
  while transition UI still exists;
- move operation logging out of SwiftData;
- delete legacy record repair once old SwiftData stores are no longer opened;
- remove snapshot deletion/repair logic after archive/cache navigation replaces
  prototype snapshots.

## UI And View Models

These active surfaces still use `@Query`, `ModelContext`, or SwiftData model
types:

- `HealthProbe/ViewModels/DashboardViewModel.swift`
- `HealthProbe/ViewModels/DataTypeTemporalDistributionViewModel.swift`
- `HealthProbe/Views/Dashboard/DashboardView.swift`
- `HealthProbe/Views/DataTypes/DataTypeTemporalDistributionView.swift`
- `HealthProbe/Views/DataTypes/DataTypesView.swift`
- `HealthProbe/Views/DataTypes/RecordChangeEvolutionChart.swift`
- `HealthProbe/Views/Settings/SettingsView.swift`
- `HealthProbe/Views/Snapshots/DataTypeSnapshotDetailView.swift`
- `HealthProbe/Views/Snapshots/SnapshotDetailView.swift`
- `HealthProbe/Views/Snapshots/SnapshotsView.swift`

Retirement path:
- replace tab-root `@Query` snapshot lists with Core Data cache observation
  queries plus archive ids;
- replace detail navigation parameters from SwiftData models to observation/type
  DTOs;
- remove remaining local-only SwiftData rows;
- keep paged record drill-down and export paths on archive APIs.

## Removed During This Pass

The following SwiftData dependencies were removed from active flows:

- `HealthProbe/Services/AnomalyDetector.swift`
- `HealthProbe/Services/IntegrityService.swift`
- `HealthProbe/Models/MetricTimeoutProfile.swift` was deleted.
- Metric timeout learning/calibration now uses
  `HealthProbe/Utilities/LocalMetricTimeoutProfile.swift`, a Codable local
  store outside `ModelContainer`.
- `SettingsView`, `DashboardView`, and `HealthKitService` read/write timeout
  calibration through the local store.
- `HealthProbe/Models/DeviceProfile.swift` was deleted.
- Device display name/color settings now use
  `HealthProbe/Utilities/LocalDeviceProfile.swift`, a Codable local store used
  by Settings, Dashboard, Snapshots, and legacy PDF export.

## Next Recommended Slices

1. Move `OperationLog` away from SwiftData, or delete it if no active reporting
   flow still needs it.
2. Replace `ContentView` preview/container dependency after tab roots stop using
   `@Query`.
3. Move `DashboardView` capture review actions away from `ModelContext`.
4. Replace Snapshots/Data Types navigation handles with archive/cache DTOs.
