# SwiftData Retirement Inventory

**Last Updated:** 2026-05-26

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 the Snapshots and Data Types tab roots to archive/cache
observations and deleting unused legacy repair/detail/delta services, 8 app
files still have SwiftData imports because capture, Dashboard review actions,
and remaining model definitions still use prototype snapshot handles.

## Launch Container

This file keeps SwiftData required at app launch:

- `HealthProbe/HealthProbeApp.swift`

Retirement path:
- remove `.modelContainer(...)` once no active view or capture service needs
  `@Query` or `ModelContext`.

## Legacy Model Definitions

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

- `HealthProbe/Models/HealthSnapshot.swift`
- `HealthProbe/Models/TypeCount.swift`
- `HealthProbe/Models/TypeDistributionBin.swift`
- `HealthProbe/Models/YearlyCount.swift`

Retirement path:
- replace `HealthSnapshot`, `TypeCount`, `YearlyCount`,
  and `TypeDistributionBin` active reads/writes with archive/cache DTOs;
- retire active reads/writes before removing the launch container.

## Capture And Maintenance Services

These services still write/read legacy SwiftData transition models:

- `HealthProbe/Services/HealthKitService.swift`

Retirement path:
- make capture persist archive observations without writing prototype
  `HealthSnapshot` bridge rows.

## UI And View Models

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

- `HealthProbe/ViewModels/DashboardViewModel.swift`
- `HealthProbe/Views/Dashboard/DashboardView.swift`

Retirement path:
- move capture/review actions away from `ModelContext`;
- keep status/report rows on archive/cache 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, and archive/cache snapshot rows.
- `HealthProbe/Models/OperationLog.swift` was deleted.
- Snapshot deletion logging now uses
  `HealthProbe/Utilities/LocalOperationLog.swift`, a bounded Codable local log
  outside `ModelContainer`.
- `HealthProbe/ContentView.swift` no longer imports SwiftData; its preview no
  longer creates a legacy model container.
- `HealthProbe/Views/Settings/SettingsView.swift` no longer imports SwiftData.
  Its Data section now reports/rebuilds/deletes the rebuildable Core Data UI
  cache and leaves the SQLite archive untouched.
- `HealthProbe/Views/Dashboard/DashboardView.swift` no longer queries
  `HealthSnapshot` for status rows; Dashboard status now uses archive/cache rows
  only. SwiftData remains there for capture/review actions.
- `HealthProbe/Views/DataTypes/RecordChangeEvolutionChart.swift` now accepts a
  small `RecordChangeEvolutionSnapshot` DTO and loads archive/cache counts
  without importing SwiftData or querying `SnapshotDelta`.
- `HealthProbe/ViewModels/DataTypeTemporalDistributionViewModel.swift` and
  `HealthProbe/Views/DataTypes/DataTypeTemporalDistributionView.swift` now read
  a `TemporalDistributionInput` DTO backed by `TypeCountDetailCache`; they no
  longer import SwiftData, query timeline snapshots, or require `ModelContext`.
- `HealthProbe/Views/Snapshots/SnapshotsView.swift` no longer queries
  `SnapshotDelta` or runs `DeltaService` list-summary repair. Timeline change
  summaries come from archive/cache rows when available; SwiftData remains there
  only for temporary snapshot navigation/deletion handles.
- `HealthProbe/ViewModels/DataTypesViewModel.swift` now resolves baselines from
  small observation contexts and builds rows from Core Data cache + SQLite
  archive diff APIs. It no longer falls back to legacy direct SwiftData
  `TypeCount` relationship traversal.
- `HealthProbe/Views/DataTypes/DataTypesView.swift` no longer imports
  SwiftData or queries `HealthSnapshot`; it loads Core Data cached observation
  rows and opens `DataTypeArchiveDetailView`, an archive/cache-only detail view
  with paged SQLite new/missing record drill-down.
- `HealthProbe/Views/Snapshots/SnapshotsView.swift` no longer imports
  SwiftData or queries `HealthSnapshot`; it loads Core Data cached observation
  rows and opens `SnapshotArchiveDetailView`, an archive/cache-only detail view
  that feeds Data Type drill-down through observation ids and cached summaries.
- The unused legacy SwiftData
  `HealthProbe/Views/Snapshots/SnapshotDetailView.swift`,
  `HealthProbe/Views/Snapshots/DataTypeSnapshotDetailView.swift`, and
  `HealthProbe/Utilities/SnapshotPDFExporter.swift` were deleted. Active
  snapshot/type drill-down now uses archive/cache DTOs.
- The unused legacy maintenance services
  `HealthProbe/Services/SnapshotLifecycleService.swift`,
  `HealthProbe/Services/IntegrityService.swift`,
  `HealthProbe/Services/ObserverService.swift`, and
  `HealthProbe/Utilities/TypeCountArchiveRepair.swift` were deleted. Active
  observation deletion/repair/background-capture policy now belongs to the
  SQLite archive/cache design, not the old SwiftData chain.
- The unused legacy delta stack
  `HealthProbe/Services/DeltaService.swift`,
  `HealthProbe/Models/SnapshotDelta.swift`,
  `HealthProbe/Models/TypeDelta.swift`, and
  `HealthProbe/Models/TypeDeltaClassification.swift` was deleted.
  Capture no longer writes prototype `SnapshotDelta`/`TypeDelta` rows after the
  archive observation is saved.
- The unused SwiftData `HealthRecord` model was deleted from
  `HealthProbe/Models/HealthRecord.swift` and removed from `ModelContainer`.
  The file now only contains the `HealthRecordValue` DTO and compact archive
  helpers used by archive/cache record previews.
- The unused `HealthProbe/Views/DataTypes/TypeEvolutionTimeline.swift` legacy
  chart was deleted, and the remaining `TypeDiff`/`DiffFilter` DTOs now live in
  `HealthProbe/Models/TypeDiff.swift` instead of the removed
  `SnapshotDiffService` helper.
- `HealthProbe/Models/AnomalyRecord.swift`,
  `HealthProbe/Models/AnomalyType.swift`, and
  `HealthProbe/Services/AnomalyDetector.swift` were deleted. The app no longer
  writes count-drop anomaly rows or shows the old Dashboard anomaly review
  section.

## Next Recommended Slices

1. Move `DashboardView` capture review actions away from `ModelContext`.
2. Stop writing prototype `HealthSnapshot` bridge rows during capture once
   Dashboard actions no longer need them.
