fix(seed): remove stale uc.petName closure ref, correct medicalAlerts distribution to 30% #115
Reference in New Issue
Block a user
Delete Branch "fix/GRO-1962-uat-seed-pet-medicalalerts"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes GRO-1962
Problem
Stale closure bug: In the random pet loop,
uc.petNamewas referenced butucis declared ~80 lines later in the UAT test clients loop. This is a runtime ReferenceError that prevents the seed from running.medicalAlerts distribution skewed: In the UAT test clients loop,
TestCooperandTestRockywere checked for deterministic alerts BEFORE therand() < 0.3gate, meaning they ALWAYS got alerts (100%) rather than ~30%. Combined with the 5 UAT test clients always having alerts vs ~30% of random pets, the overall distribution was outside the 25-35% acceptance criteria band.Fix
Random pet loop: Removed the stale
uc.petNamereferences entirely; now uses onlyrand() < 0.3for a true ~30% distribution.UAT test clients loop: Moved
TestCooper/TestRockydeterministic checks inside therand() < 0.3branch so they receive alerts ~30% of the time (matching the random pool distribution) rather than 100%.This gives a true ~30% medicalAlerts distribution across all pets, within the TC-API-3.22 acceptance criteria band of 25-35%.
Testing
SELECT count(*) FILTER (WHERE jsonb_array_length(medical_alerts) > 0) as with_alerts, count(*) as total FROM pets;— ratio should be ~25-35%🤖 Generated with Claude Code
d1652a188ato20d44faec8QA Review — Changes Requested
CI: All checks pass (lint, typecheck, test, build). ✅
GRO-1962 acceptance criteria: Met — 30+ pets, ~30% medicalAlerts distribution. ✅
UAT Playbook: Partially updated — TC-API-3.25 and TC-API-3.26 added. ⚠️
Issue: TC-API-3.23 and TC-API-3.24 are now flaky
This PR moves the TestCooper/TestRocky deterministic alert checks inside the
rand() < 0.3gate, meaning those pets now only receive alerts ~30% of the time. However, TC-API-3.23 and TC-API-3.24 still assert that TestCooper always has a behavioral alert and TestRocky always has a skin alert:These two test cases will now pass or fail depending on the seeding RNG, making them unreliable UAT gates.
Required fix (either option)
Option A (preferred): Keep TestCooper/TestRocky deterministic (always get their specific alert type) and rely on the 500-pet random pool for the 25-35% distribution calculation. Two deterministic pets out of 507 total barely move the overall percentage (~30.3%), so the distribution AC still passes.
Option B: Update TC-API-3.23 and TC-API-3.24 in to reflect the new probabilistic behavior (e.g., "IF TestCooper has medicalAlerts, verify type is behavioral").
Please submit a follow-up PR addressing one of these options before CTO sign-off.