test(playlists, recommendation): system-mix builds stop drawing covers no test reads; merge repeated cases (#8297)
release / go (push) Successful in 1m44s
release / web (push) Successful in 1m16s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m45s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m40s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
release / go (push) Successful in 1m44s
release / web (push) Successful in 1m16s
release / govulncheck (push) Successful in 18s
release / integration (push) Successful in 2m45s
release / android (push) Successful in 4m29s
release / Build signed APK (push) Successful in 4m40s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Publish the release image to GHCR (dispatch only) (push) Skipped
release / Build + push container image (push) Successful in 14s
release / Verify release artifacts (tag releases only) (push) Skipped
Timings from one run of the integration lane with -v (39c5b1ed, reverted
here) put the system-mix builds at 1.4-3.8s each, most of the playlists
package's 35s. A build draws a JPEG collage per mix; under -race that is
most of its time, and no build test looked at a cover. The build tests now
pass no data folder, which skips drawing, except SufficientActivity, which
keeps drawing and now checks every mix got a cover: nothing tested that the
build wires covers before.
Merged:
- playlists service: 22 tests become 5 scenario tests (access, bad input,
partial update, track-list edits, cover-file cleanup), one database
reset each.
- ARebuildKeepsEachMixsID into DailyNonceDeterminism (both built twice in
one day); the two You might like builds into one.
- capCandidatesByAlbumAndArtist, Score, Similarity, ContextualMatchScore
and the session-vector seed rule: one table each.
- LoadCandidates' six contextual-like database tests: the max and seed
rules are ContextualMatchScore's unit table; the database test keeps what
only it can see, a like reaching its track and a withdrawn like ignored.
Dropped: Score determinism with a fixed RNG (a pure function), Score's
cold-start case (the same input as the base case), and recencyDecay(nil)
and skipRatio's two cases, which Score's table covers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -219,129 +219,39 @@ func helperInsertContextualLike(t *testing.T, f fixture, trackID pgtype.UUID, ve
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_NoContextualLikes_AllZero(t *testing.T) {
|
||||
f := newFixture(t, 5)
|
||||
current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
// LoadCandidates gives each candidate the contextual match of its likes
|
||||
// (ContextualMatchScore, tested on its own above): a track liked in a session
|
||||
// like the current one scores about 1, a track whose like was withdrawn
|
||||
// (soft-deleted) and a track never liked score 0.
|
||||
func TestLoadCandidates_ContextualLikesReachTheirTracks(t *testing.T) {
|
||||
f := newFixture(t, 4)
|
||||
liked, withdrawn := f.tracks[1], f.tracks[2]
|
||||
session := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
helperInsertContextualLike(t, f, liked.ID, session)
|
||||
helperInsertContextualLike(t, f, withdrawn.ID, session)
|
||||
if _, err := f.pool.Exec(context.Background(),
|
||||
`UPDATE contextual_likes SET deleted_at = now() WHERE track_id = $1`, withdrawn.ID); err != nil {
|
||||
t.Fatalf("soft-delete: %v", err)
|
||||
}
|
||||
for _, c := range got {
|
||||
if c.Inputs.ContextualMatchScore != 0 {
|
||||
t.Errorf("track %s ContextualMatchScore = %v, want 0", c.Track.Title, c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_OneMatchingLike_ScoresPositive(t *testing.T) {
|
||||
f := newFixture(t, 3)
|
||||
target := f.tracks[1]
|
||||
likeVec := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
helperInsertContextualLike(t, f, target.ID, likeVec)
|
||||
|
||||
current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current)
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, session)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
var found bool
|
||||
for _, c := range got {
|
||||
if c.Track.ID == target.ID {
|
||||
score := c.Inputs.ContextualMatchScore
|
||||
switch {
|
||||
case c.Track.ID == liked.ID:
|
||||
found = true
|
||||
if c.Inputs.ContextualMatchScore < 0.99 {
|
||||
t.Errorf("target ContextualMatchScore = %v, want ~1.0", c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
} else {
|
||||
if c.Inputs.ContextualMatchScore != 0 {
|
||||
t.Errorf("non-target track has ContextualMatchScore = %v", c.Inputs.ContextualMatchScore)
|
||||
if score < 0.99 {
|
||||
t.Errorf("liked track scores %v, want ~1.0", score)
|
||||
}
|
||||
case score != 0:
|
||||
t.Errorf("track %s scores %v, want 0", c.Track.Title, score)
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
t.Error("target track missing from candidate list")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_MultipleMatchingLikes_TakesMax(t *testing.T) {
|
||||
f := newFixture(t, 3)
|
||||
target := f.tracks[1]
|
||||
helperInsertContextualLike(t, f, target.ID, SessionVector{
|
||||
Artists: []string{"a99"}, Tags: map[string]int{"jazz": 1},
|
||||
})
|
||||
helperInsertContextualLike(t, f, target.ID, SessionVector{
|
||||
Artists: []string{"a1"}, Tags: map[string]int{"rock": 1},
|
||||
})
|
||||
helperInsertContextualLike(t, f, target.ID, SessionVector{
|
||||
Artists: []string{"a1"}, Tags: map[string]int{"jazz": 1},
|
||||
})
|
||||
|
||||
current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
for _, c := range got {
|
||||
if c.Track.ID == target.ID && c.Inputs.ContextualMatchScore < 0.99 {
|
||||
t.Errorf("target = %v, want ~1.0 (max)", c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_SoftDeletedLikes_Ignored(t *testing.T) {
|
||||
f := newFixture(t, 3)
|
||||
target := f.tracks[1]
|
||||
likeVec := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
helperInsertContextualLike(t, f, target.ID, likeVec)
|
||||
if _, err := f.pool.Exec(context.Background(),
|
||||
`UPDATE contextual_likes SET deleted_at = now() WHERE user_id = $1`, f.user); err != nil {
|
||||
t.Fatalf("soft-delete: %v", err)
|
||||
}
|
||||
|
||||
current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
for _, c := range got {
|
||||
if c.Inputs.ContextualMatchScore != 0 {
|
||||
t.Errorf("soft-deleted track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_OnlySeedLikes_ScoresZero(t *testing.T) {
|
||||
f := newFixture(t, 3)
|
||||
target := f.tracks[1]
|
||||
helperInsertContextualLike(t, f, target.ID, SessionVector{
|
||||
Seed: true, Artists: []string{"a1"}, Tags: map[string]int{"rock": 1},
|
||||
})
|
||||
|
||||
current := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, current)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
for _, c := range got {
|
||||
if c.Inputs.ContextualMatchScore != 0 {
|
||||
t.Errorf("seed-only track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadCandidates_CurrentSeed_ScoresZero(t *testing.T) {
|
||||
f := newFixture(t, 3)
|
||||
target := f.tracks[1]
|
||||
likeVec := SessionVector{Artists: []string{"a1"}, Tags: map[string]int{"rock": 1}}
|
||||
helperInsertContextualLike(t, f, target.ID, likeVec)
|
||||
|
||||
currentSeed := SessionVector{Seed: true}
|
||||
got, err := LoadCandidates(context.Background(), f.q, f.user, f.tracks[0].ID, 1, currentSeed)
|
||||
if err != nil {
|
||||
t.Fatalf("load: %v", err)
|
||||
}
|
||||
for _, c := range got {
|
||||
if c.Inputs.ContextualMatchScore != 0 {
|
||||
t.Errorf("seed-current track %s ContextualMatchScore = %v", c.Track.Title, c.Inputs.ContextualMatchScore)
|
||||
}
|
||||
t.Error("the liked track is missing from the candidates")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user