# HealthProbe - Implementation Status

**Last Updated:** 2026-05-24

## Current Reality

The app currently contains a working SwiftUI + SwiftData prototype with HealthKit capture, snapshot/delta screens, and an initial SQLite archive store.

The product direction has changed. The target architecture is now:
- iOS 15-era compatible;
- direct SQLite archive/analysis database as source of truth;
- differential observation storage;
- Core Data UI/report cache;
- Time Machine UI and scoped exports;
- recovery-compatible archive/export format;
- no in-app restore, backup patching, or HealthKit re-publication.

Current SwiftData models and anomaly-oriented naming are legacy/prototype implementation details.

There are no real deployments, only test installations. Existing prototype databases are disposable: the archive v2 refactor should reset, ignore, or reinitialize old SwiftData/prototype SQLite stores instead of preserving backward compatibility with them.

## Status By Area

| Area | Current Status | Target / Next Work |
|------|----------------|--------------------|
| Product docs | Updated | Keep `HealthProbe/Doc/README.md` as canonical index |
| HealthKit capture | Prototype exists | Adapt capture to write differential SQLite observations first |
| SQLite archive | Archive v2 schema, differential write path, daily aggregate rebuilds, integrity report, v2 record reads, SQL diff/count/aggregate/provenance/consolidation-evidence APIs, and XCTest coverage are in place; legacy write mirror still exists | Add large synthetic-data timing/memory tests, then retire `archive_samples` |
| Core Data cache | Not implemented | Add rebuildable cache for expensive counts, summaries, report metadata, UI state |
| SwiftData cache | Exists | Treat as disposable prototype data; reset/ignore during v2 transition |
| UI | Prototype exists | Reframe screens around observations, diffs, export, archive status |
| Diff/change explanation | Prototype/legacy anomaly logic exists | Move heavy diffing into SQLite and use neutral change classifications |
| Export | Prototype scoped JSON export exists | Add recovery-compatible manifests and streaming/paged export |
| Legacy device support | Not implemented | Remove SwiftData dependency and simplify heavy views for low-memory devices |
| Recovery workflows | Not supported | Preserve export/archive structure for external recovery tools only |

## Refactoring Priorities

Detailed checkable milestones live in [`Refactoring-Plan.md`](Refactoring-Plan.md).

1. Expand the synthetic large-data test harness for diff/export memory behavior.
2. Add Core Data UI/report cache and rebuild pipeline.
3. Replace SwiftData UI dependencies with Core Data/cache DTOs.
4. Update UI language from anomaly/status to observation/diff/export.
5. Add streaming exports with manifests.
6. Validate on low-memory/legacy-class devices.

## Known Prototype Mismatches

- SwiftData currently blocks iOS 15-era device support.
- Existing `Anomaly*` model/service names are legacy language.
- Some screens still imply snapshot-count monitoring rather than Time Machine inspection.
- Current archive schema is not sufficient as the long-term source of truth.
- Existing implementation may decode or cache too much data for low-end devices.
- Old prototype database compatibility is no longer required.
- Initial SQLite archive tests cover open/init/reset/idempotency, small observation diffs, materialized aggregate comparison, source/provenance breakdowns, and consolidation-evidence labels, but not yet large-volume diff/export behavior.

## Verification Checklist

- [ ] SQLite archive v2 can reconstruct records visible at observation T.
- [ ] No recurring complete snapshot copies are written for high-volume types.
- [x] SQL diff between two observations runs without loading full datasets into Swift arrays.
- [ ] Expensive counts used by reports/UI are cached and rebuildable.
- [ ] Deleting Core Data cache and rebuilding from SQLite restores UI/report summaries.
- [ ] Export can stream large selected record sets.
- [ ] Export manifests include hashes and observation metadata.
- [ ] iOS app remains read-only with respect to HealthKit.
- [ ] Docs and UI do not claim in-app restore/re-publication support.
- [ ] Legacy/small-device UI mode preserves capture/report/export.

## Historical Notes

Older status docs described a completed snapshot/anomaly/SwiftData system. That was true for the prototype direction, but it is no longer the target architecture.
