fix: a merge keeps the song link when the removed copy names the song (M498)
release / govulncheck (push) Successful in 18s
release / web (push) Successful in 1m39s
release / go (push) Successful in 1m56s
release / integration (push) Successful in 5m11s
release / android (push) Successful in 5m58s
release / Build signed APK (releases and dev) (push) Successful in 6m11s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Successful in 16s
release / Verify release artifacts (tag releases only) (push) Skipped

MergeInheritSongLink took "linked" to mean song_key <> id, but the copy
whose id became the song's key has no song_id of its own. Removing that
copy dropped the survivor out of the song. It now asks whether another
copy shares the key. The test covers both copies as the one removed, so
it no longer passes or fails on which random id sorts first.

The release-change test counted audit rows other tests left behind
(ResetDB keeps audit_log); it now counts what its own pass adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 22:53:35 -04:00
co-authored by Claude Opus 5.5
parent e1ad1c9ba2
commit 8bd48b4302
4 changed files with 55 additions and 33 deletions
+4 -2
View File
@@ -48,11 +48,13 @@ SELECT id, song_key, (source_verdict IS NOT DISTINCT FROM 'suspect')::boolean AS
-- name: MergeInheritSongLink :exec
-- A merge keeps the removed copy's song link: when the copy being removed was
-- linked to copies on other releases and the survivor was not, the survivor
-- joins that song.
-- joins that song. The copy whose id names the song has no song_id of its
-- own, so "linked" is another copy sharing its key, not a song_id.
UPDATE tracks s
SET song_id = l.song_key
FROM tracks l
WHERE s.id = sqlc.arg(survivor_id)::uuid
AND l.id = sqlc.arg(loser_id)::uuid
AND s.song_id IS NULL
AND l.song_key <> l.id;
AND EXISTS (SELECT 1 FROM tracks o
WHERE o.song_key = l.song_key AND o.id <> l.id AND o.id <> s.id);