fix(sources): ladder STRESS_SCORE so the source collapse stays deterministic

STRESS_SCORE has no source-priority ladder, so metricKeyForType returns null
and the SQL source collapse falls to an alphabetical rank-90 tiebreak. It is
safe today because the only producer is the COMPUTED HRV-derived proxy, but
the instant a device-native producer (Oura daily_stress) is enabled both rows
survive and blend nondeterministically.

Add a stress metric key with an OURA-above-COMPUTED default ladder, wire it
through metricKeyForType and RANKED_TYPES, and surface it in the Sources
settings (all six locales). A guard test asserts every RANKED_TYPES member
resolves to a non-null metric key so a future ranked type can't ship unladdered.
Regenerate the OpenAPI for the additive source-priority key.
This commit is contained in:
Marc-André Bombeck committed 2026-06-20 16:52:10 +02:00
1 parent 013241ba74
commit 56d8cf19c5
12 files changed
+154 -7

No files matched your search

+96
View File
@@ -3606,6 +3606,22 @@ paths:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
metricPriority:
type: object
properties:
@@ -3881,6 +3897,22 @@ paths:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
deviceTypePriority:
type: object
properties:
@@ -14406,6 +14438,22 @@ components:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
metricPriority:
type: object
properties:
@@ -14681,6 +14729,22 @@ components:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
additionalProperties: false
deviceTypePriority:
type: object
@@ -15002,6 +15066,22 @@ components:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
metricPriority:
type: object
properties:
@@ -15277,6 +15357,22 @@ components:
- NIGHTSCOUT
- POLAR
- OURA
stress:
maxItems: 8
type: array
items:
type: string
enum:
- MANUAL
- WITHINGS
- IMPORT
- APPLE_HEALTH
- COMPUTED
- WHOOP
- FITBIT
- NIGHTSCOUT
- POLAR
- OURA
additionalProperties: false
deviceTypePriority:
type: object