8000 [Feature] Source-aware health data spine and import identity · Issue #89 · shroominic/OpenGlucose · GitHub
[go: up one dir, main page]

Skip to content
  • [Feature] Source-aware health data spine and import identity #89

    Open

    Description

    @shroominic

    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.dart
    • packages/cgm_core/lib/src/health_repository.dart
    • openhealth/lib/src/persistence/sqflite_health_repository.dart
    • docs/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.

    Activity

    1. added this to the 0.2 Data & Context milestone on Sep 1, 2026
    2. added
      enhancementNew feature or request
      risk:R2Health data, persistence, integration, AI, accessibility, or native risk
      parallel:readyCan begin independently in the current wave
      priority:P0Critical path or release-blocking work
      area:dataData model, persistence, migration, export, deletion
      on Sep 1, 2026
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      area:dataData model, persistence, migration, export, deletionenhancementNew feature or requestparallel:readyCan begin independently in the current wavepriority:P0Critical path or release-blocking workrisk:R2Health data, persistence, integration, AI, accessibility, or native risk

      Projects

      No projects

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions

      • 0