Skip to main content

Overview

Baselines is the host-facing read facade for wearable baselines. Apps subscribe to a reactive snapshot stream and get a fully-typed view of the user’s most recent sleep / recovery / readiness scores plus the current WearableReferenceView; no JSON parsing, no FFI. It does NOT compute scores or own ingest pipelines — it caches whatever the host SDK feeds in. The full Flutter Baselines.ingestVendorSleep orchestration (Whoop / Garmin / Apple Health / Health Connect → score → snapshot) lives only on the Flutter SDK at this time. On Kotlin / Swift, hosts wire vendor ingest themselves and call the cache* setters.

Surface

Process-wide singleton (Baselines.shared) with:

BaselinesSnapshot

Derived properties (computed without storage):
  • isEmpty — nothing has been ingested and the engine hasn’t produced a reference yet
  • isReady — true when the reference reports READY status, i.e. all five primary SRM dimensions are mature enough for personalized scoring (see SRM maturity states).
  • priorNightCount — what the scorer saw (nil if no score)
  • nightsLoggedCount — items in the recent-scores ring (capped at 7)
  • recentMedian — median of the ring when populated; falls back to reference.recentSleepScoreMedian

Kotlin

Swift

Recent-scores ring semantics

cacheSleepScore pushes the score (if non-nil) onto a FIFO ring capped at 7. This is the “nights logged” surface for the user — it reflects cumulative ingests in the current session, not what the scorer saw (priorNightCount gives you that). The median of the ring is available after the 3rd attach, regardless of HSI window state.

Cross-language parity

The shape is identical across Flutter / Kotlin / Swift. The stream type differs by platform idiom (Dart Stream, Kotlin Flow, Swift AnyPublisher) but the snapshot content is byte-equivalent.
  • Flutter: lib/src/modules/baselines/baselines_snapshot.dart + (full ingest) baselines.dart
  • Kotlin: synheart-core/src/main/kotlin/ai/synheart/core/modules/baselines/{Baselines,BaselinesSnapshot}.kt
  • Swift: SynheartCore/Modules/Baselines/{Baselines,BaselinesSnapshot}.swift