BaselineSnapshots class

Host-facing facade for typed baseline-snapshot access.

Exposed via Synheart.baselineSnapshots. Replaces the Map<String, dynamic>-shaped legacy access pattern with synchronous per-kind typed getters:

final wear = Synheart.baselineSnapshots.latestLongitudinalWear();
if (wear != null) {
  print('HRV baseline: ${wear.reference.dimensions['hrv_rmssd_ms']}');
}

Cache model

In-memory cache keyed by BaselineKind, last-write-wins per kind. Populated by:

  • The on-device producer (engine state → envelope writer) via cache.
  • hydrateFromLocal on cold-start, reading the latest of each kind from on-device storage (including envelopes synced from other devices via the sync engine).

Cross-device transport

Baselines do not have their own cloud client on this facade. They ride the existing sync engine: a baseline envelope written here lands in the local artifacts table with sync_state='pending' and the sync engine pushes it on its normal cadence. Envelopes pulled from other devices land in the same table and are picked up by hydrateFromLocal on init (or by any explicit re-hydrate).

Constructors

BaselineSnapshots()
Singleton instance returned by Synheart.baselineSnapshots. Direct construction is allowed for tests.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

cache(BaselineEnvelope envelope) → void
Push an envelope into the cache. Called by the on-device producer (engine state → envelope writer) after each successful local snapshot, and by hydrateFromLocal after a storage read. Last-write-wins per kind.
envelopeFor(BaselineKind kind) → BaselineEnvelope?
The most recent envelope for kind, or null if no producer has cached one yet. Synchronous — reads in-memory state.
envelopesByKind() → Map<BaselineKind, BaselineEnvelope>
Unmodifiable snapshot of every kind that currently has a cached envelope. Powers the first-launch hydration UI ("show me one summary per baseline kind the user has on file").
hydrateFromLocal() → Future<List<BaselineEnvelope>>
Populate the in-memory cache from locally-persisted artifacts. Called by Synheart on bridge construction so the typed getters (latestHsiAxes, latestSrmMetrics, latestLongitudinalWear) return real data immediately after app cold-start, without requiring a producer to run first.
latestHsiAxes() → HsiAxesBaseline?
Latest session.hsi_axes baseline, or null if none cached.
latestLongitudinalWear() → LongitudinalWearBaseline?
Latest longitudinal.wear baseline, or null if none cached.
latestSrmMetrics() → SessionSrmMetricsBaseline?
Latest session.srm_metrics baseline, or null if none cached.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reset() → void
Forget every cached envelope. Called on logout / user switch.
toString() → String
A string representation of this object.
inherited
wireLocalHydrator(BaselineLocalHydrator? hydrator) → void
Inject the local-storage hydrator. Called by Synheart after the runtime bridge is configured. Pass null to clear (e.g. after disposing the bridge).

Operators

operator ==(Object other) → bool
The equality operator.
inherited