Skip to content

feat: add connected-health integration architecture (#202) - #244

Open
Nayira wants to merge 1 commit into
oss-slu:mainfrom
Nayira:feat/202-integration-architecture
Open

Nayira wants to merge 1 commit into
oss-slu:mainfrom
Nayira:feat/202-integration-architecture

Conversation

@Nayira

@Nayira Nayira commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Defines a provider-neutral integration layer for optional connected-health imports, so imported values always record their source and timestamp, and users grant access one measurement type at a time.

Closes #202
Part of #151

Changes Made

  • Added IntegrationConnection, which stores a user's explicit, read-only grant for one provider and a list of measurement types. allows(type) is the single permission check, and it is false for any type not granted or once the connection is disconnected.
  • Added ImportedMeasurement, which requires provider, connection_id, unit and recorded_at, so a value without provenance cannot be saved.
  • Added src/integrations.py with a provider registry (PROVIDERS) and an IntegrationAdapter protocol, so pages and endpoints never depend on provider-specific code. Apple Health and Health Connect are registered with plain-language limitations (neither has a web API).
  • Added an INTEGRATIONS_ENABLED flag, off by default, so integrations stay optional and core features never depend on them.
  • Added endpoints:
    • GET /api/v1/integrations/providers, which returns { enabled, providers }, with an empty providers list while the flag is off
    • GET /api/v1/users/me/connections, which lists the user's own connections and is not gated by consent or the flag, so users can always see what is connected
    • POST /api/v1/users/me/connections, which grants or replaces a connection and requires health consent and the flag
  • Validation errors have clear codes: INTEGRATIONS_DISABLED, UNKNOWN_PROVIDER, UNSUPPORTED_MEASUREMENT_TYPE and VALIDATION_ERROR.
  • Added docs/integrations.md covering principles, architecture, data model, permission rules, API and how to add a provider.

Testing

  • Full backend test suite passed (75 tests), including 19 new integration tests covering:
    • the feature flag
    • authentication and health consent
    • unknown providers and unsupported types
    • re-granting
    • users only seeing their own connections
    • the permission check
    • required provenance fields
  • The integration tests turn the flag off by default, so they pass whatever is set in a developer's local .env.

Checklist

  • The code follows project conventions
  • Documentation has been updated if needed
  • No sensitive information is included
  • Breaking changes are clearly documented
  • Reviewers have enough context to review this PR

Additional Notes

  • Backend only. There is no UI yet, and nothing changes for users while INTEGRATIONS_ENABLED is off, which is the default.
  • No provider adapters are included. Reading Apple Health and Health Connect data belongs to the discovery and prototype issues under [Big Rock] Add optional connected-health integrations #151.
  • No breaking changes. The two new collections are created on startup.

Part of oss-slu#151. Define the integration boundary, provenance and permission
rules for optional connected-health imports:

- IntegrationConnection stores a user's explicit, read-only grant per
  provider and measurement type; allows() is the permission check.
- ImportedMeasurement requires provider, connection, unit and
  recorded_at so every value keeps its source and timestamp.
- integrations.py holds the provider registry and adapter protocol so
  pages and endpoints never depend on provider-specific code.
- INTEGRATIONS_ENABLED flag (off by default) keeps integrations optional.
- Endpoints to list providers, list own connections, and grant a
  connection, with tests and docs/integrations.md.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Small Rock] Define integration architecture, provenance, and permission rules

1 participant