Documentation Index
Fetch the complete documentation index at: https://docs.synheart.ai/llms.txt
Use this file to discover all available pages before exploring further.
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:
| Surface | Description |
|---|---|
updates | Observable stream of BaselinesSnapshot — emits after every cache* call. Replays the current snapshot to late subscribers. |
latestSleepScore / latestRecoveryScore / latestReadinessScore | Sync getters for the most recent score in each pipeline. |
reference | The most recent WearableReferenceView from the SRM (see Self-Reference Model). |
lastSource | Provider id of whoever produced the latest sleep score (whoop, garmin, apple_health, health_connect, self_report, …). |
cacheSleepScore(result, source) | Push a new sleep score, roll into the recent-scores ring (cap 7), emit. |
cacheRecoveryScore(result) | Push a new recovery score, emit. |
cacheReadinessScore(result) | Push a new readiness score, emit. |
cacheReference(view) | Push a new wearable reference, emit. |
reset() | Forget everything (logout / user switch). |
current() | Synchronous snapshot read. |
BaselinesSnapshot
isEmpty— nothing has been ingested and the engine hasn’t produced a reference yetisReady— true when the reference reportsREADYstatus, 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 toreference.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 (DartStream, 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
Related
- Self-Reference Model (SRM) — the longitudinal engine that produces
reference; defines dimensions, maturity states, and snapshot lifecycle - Scoring models — produces the inputs to
cacheSleepScore/cacheRecoveryScore/cacheReadinessScore - Health Connect / HealthKit backfill — populates the SRM that backs
reference