ed77acf0fe
max(created_at)+equality-join returned both rows when two like events shared an identical created_at (realistic: likes carry a client-supplied timestamp from offline sync), double-counting the track. Replace with DISTINCT ON (track_id) + deterministic tiebreaker (created_at desc, id desc) across get_latest_state / liked-tracks / count. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>