feat(server/m7-352): BuildSystemPlaylists with atomic replace + concurrency guard

Implements T5 of #352 slice 2: adds CreateSystemPlaylist sqlc query,
BuildSystemPlaylists function (For-You + Songs-like mixes, tx atomic
replace, in_flight guard, tieBreakHash determinism), and 7 integration
tests covering activity, quarantine exclusion, atomic replace, concurrency,
daily nonce stability, ListActiveUsers, and stale-in-flight recovery.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-04 08:35:02 -04:00
parent ef478778ef
commit 46a9de8e9a
4 changed files with 668 additions and 0 deletions
+10
View File
@@ -140,3 +140,13 @@ SELECT id, user_id, name, description, is_public, kind, system_variant,
WHERE user_id = $1
AND ($2::text = 'all' OR kind = $2)
ORDER BY updated_at DESC;
-- name: CreateSystemPlaylist :one
-- Inserts a system-generated playlist. Used by BuildSystemPlaylists.
-- For 'for_you' variant, pass seed_artist_id as NULL (zero-value pgtype.UUID
-- with Valid=false).
INSERT INTO playlists (
user_id, name, description, is_public,
kind, system_variant, seed_artist_id, cover_path
) VALUES ($1, $2, '', false, 'system', $3, $4, $5)
RETURNING *;