Repository navigation
Description
Outcome
Create the trustworthy, source-aware health-data spine that every meal, sleep, activity, Apple Health, Health Connect, correlation, and AI feature can safely build on.
Current state
OpenGlucose already has normalized health models and a SQLite HealthRepository, but imported activity, sleep, and heart-rate rows use append-only integer IDs. Repeating an import would duplicate rows, and the schema does not retain the provenance needed to explain or delete imported data.
Relevant code and plan:
packages/cgm_core/lib/src/health_samples.dartpackages/cgm_core/lib/src/health_repository.dartopenhealth/lib/src/persistence/sqflite_health_repository.dartdocs/product-foundations-2026.md
Scope
- Make the health repository an application-lifetime service injected into relevant controllers and screens.
- Add stable external identifiers and uniqueness constraints for imported samples.
- Retain source platform, bundle/package, source name, device, recording method, interval, revision, and deletion/tombstone state.
- Persist one incremental synchronization anchor/cursor per platform and data type.
- Define source-priority and overlap rules without blindly summing Apple Watch, iPhone, Oura, Whoop, or similar sources.
- Add migration and rollback behavior for existing schema v1 databases.
- Expose a unified, source-aware timeline query contract for later UI and analytics.
Parallelization
Ready now. This is the critical data-contract lane and should have one owner.
Can run in parallel with:
- navigation/design-system work;
- pure-Dart analytics fixtures;
- AI evidence/safety contract work.
Avoid parallel edits to the same schema and repository files.
Acceptance criteria
- Repeating the same import creates zero duplicate rows.
- Updated and deleted source records reconcile by stable external identity.
- Every imported datum can report its platform, source application/device, and observed interval.
- Source overlap policy is deterministic and unit tested.
- App-lifetime repository initialization, shutdown, and failure recovery are tested.
- Migration tests cover upgrade, rollback, corrupt rows, DST, out-of-order samples, and interrupted migration.
- Unified timeline queries remain bounded and performant with dense heart-rate/activity fixtures.
- No sample data, identifiers, or health payloads appear in logs or test artifacts.
- Risk-class R2 Definition of Done and independent review are satisfied.
Out of scope
- Permission UI and native platform imports.
- Journal screens.
- Final dashboard visualization.
- Generative AI output.
Product boundary
This work preserves provenance and data quality. It must not infer causality, diagnosis, treatment, dosing, or emergency conclusions.
Activity
shroominic commentedon Sep 1, 2026
Superseded by #89, recreated by the repository owner under
shroominic.