Repository navigation
Open
Labels
area:dataData model, persistence, migration, export, deletionData model, persistence, migration, export, deletionenhancementNew feature or requestNew feature or requestparallel:readyCan begin independently in the current waveCan begin independently in the current wavepriority:P0Critical path or release-blocking workCritical path or release-blocking workrisk:R2Health data, persistence, integration, AI, accessibility, or native riskHealth data, persistence, integration, AI, accessibility, or native risk
Milestone
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.
Repository-owner recreation of the legacy issue at #36. The original discussion remains available there.
Metadata
Metadata
Assignees
Labels
area:dataData model, persistence, migration, export, deletionData model, persistence, migration, export, deletionenhancementNew feature or requestNew feature or requestparallel:readyCan begin independently in the current waveCan begin independently in the current wavepriority:P0Critical path or release-blocking workCritical path or release-blocking workrisk:R2Health data, persistence, integration, AI, accessibility, or native riskHealth data, persistence, integration, AI, accessibility, or native risk
Activity