fix(bp): keep non-physiological readings out of the seed and the series

The demo seed's random-walk BP generator could drift below the
physiological floor and mint a systolic-0 row (iOS #33). Clamp the walk
to the same band the input validator enforces (systolic >= 40,
diastolic >= 20), reusing the VALUE_RANGES floors, so a fresh seed never
writes a sub-floor reading. Add a read-side selection guard on the blood
pressure series endpoint that excludes rows below those floors from both
the series and the implicit latest point, so a corrupt row that slipped
in before the floor was enforced can never surface as the latest
reading. Export VALUE_RANGES so both sites share one source of truth.
This commit is contained in:
Marc-André Bombeck committed 2026-06-19 20:34:20 +02:00
1 parent a3b274171c
commit f002a9d565
3 files changed
+23 -6

No files matched your search

+1 -1
View File
@@ -343,7 +343,7 @@ export function getUnitForType(type: string): string {
}
// Plausible ranges per measurement type
const VALUE_RANGES: Record<string, { min: number; max: number }> = {
export const VALUE_RANGES: Record<string, { min: number; max: number }> = {
WEIGHT: { min: 1, max: 500 },
BLOOD_PRESSURE_SYS: { min: 40, max: 300 },
BLOOD_PRESSURE_DIA: { min: 20, max: 200 },