feat: a wanted list — follow artists on release-type profiles; requests and re-acquisition become wants (M502 #5520)
release / govulncheck (push) Successful in 15s
release / web (push) Failing after 1m21s
release / go (push) Successful in 1m35s
release / integration (push) Failing after 4m57s
release / android (push) Successful in 5m11s
release / Build signed APK (releases and dev) (push) Successful in 5m28s
release / Attach APK to the Release (tag releases only) (push) Skipped
release / Build + push container image (push) Skipped
release / Verify release artifacts (tag releases only) (push) Skipped

Minstrel keeps its own list of what it is to get, keyed by MusicBrainz
release group. A want comes from an approved request, a new release by a
followed artist, or an album whose files went missing, and is held once the
library has a full edition of it.

- Migration 0081: release_type_profiles (Standard seeded: Album, EP,
  Single, studio only), follows, follow_seen_groups and wants.
  lidarr_requests becomes requests with plain *_mbid columns; approved
  album and track requests move onto the wanted list, approved artist
  requests become follows, and the library's album artists start out
  followed. missing_reacquisitions and the retry settings go.
- internal/wanted: follows are checked against MusicBrainz discographies
  daily. The first check sets a baseline, and only releases after it are
  wanted unless the follow asked for what already exists. Profiles filter
  by primary and secondary type, so live recordings stay out unless a
  profile ticks Live.
- internal/requests (was lidarrrequests): approving puts the request on
  the wanted list, and an artist request can be approved on a chosen
  profile. A request completes when its want is held.
- The re-acquisition sweeper wants a missing album back instead of asking
  Lidarr; searching for it is the search schedule's (#5521).
- Web: an admin Wanted page (Wanted, Missing files, Held, Following), a
  follow control on artist pages, a release-type profiles card on
  Integrations, "Approve on a profile" on Requests, and want state on
  Missing files. The artist detail API returns the artist's MBID.
- Android: the request body sends artist_mbid, album_mbid and track_mbid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-10 00:46:22 -04:00
co-authored by Claude Opus 5.5
parent 867f52358c
commit 04515a977c
93 changed files with 6522 additions and 4484 deletions
-85
View File
@@ -3,69 +3,8 @@ package reacquisition
import (
"errors"
"testing"
"time"
)
func TestBackoffSchedule(t *testing.T) {
s := Defaults // 6h base, 168h (one week) cap, 3 attempts
cases := []struct {
name string
attempts int32
want time.Duration
}{
// Never tried is always due — the grace window, not the backoff, is
// what holds the first attempt back.
{"never attempted", 0, 0},
{"negative is treated as never", -1, 0},
{"after one attempt", 1, 6 * time.Hour},
{"after two", 2, 12 * time.Hour},
{"after three", 3, 24 * time.Hour},
{"after four", 4, 48 * time.Hour},
{"after five", 5, 96 * time.Hour},
// 6h * 2^5 = 192h, past the one-week cap.
{"clamped at the cap", 6, 168 * time.Hour},
{"still clamped far out", 20, 168 * time.Hour},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
if got := s.Backoff(c.attempts); got != c.want {
t.Errorf("Backoff(%d) = %v, want %v", c.attempts, got, c.want)
}
})
}
}
// The doubling must not be able to overflow int32 before the clamp is
// consulted — a large base with a high attempt count is the case that would
// wrap negative and make a spent album look due immediately.
func TestBackoffDoesNotOverflow(t *testing.T) {
s := Settings{BackoffBaseHours: 168, BackoffMaxHours: 720}
for attempts := int32(1); attempts <= 40; attempts++ {
got := s.Backoff(attempts)
if got <= 0 {
t.Fatalf("Backoff(%d) = %v, want a positive duration", attempts, got)
}
if got > 720*time.Hour {
t.Fatalf("Backoff(%d) = %v, want <= the 720h cap", attempts, got)
}
}
}
func TestBackoffRespectsCustomSettings(t *testing.T) {
s := Settings{BackoffBaseHours: 1, BackoffMaxHours: 4}
for attempts, want := range map[int32]time.Duration{
1: 1 * time.Hour,
2: 2 * time.Hour,
3: 4 * time.Hour,
4: 4 * time.Hour, // clamped
} {
if got := s.Backoff(attempts); got != want {
t.Errorf("Backoff(%d) = %v, want %v", attempts, got, want)
}
}
}
func TestValidateRejectsWhatTheCheckWouldReject(t *testing.T) {
// Each case mirrors a CHECK in migration 0056. Validating in Go as well
// means the API answers 400 with a readable message instead of surfacing
@@ -77,15 +16,6 @@ func TestValidateRejectsWhatTheCheckWouldReject(t *testing.T) {
{"zero grace would fire on every transient unmount",
mutate(func(s *Settings) { s.GraceHours = 0 })},
{"grace beyond a month", mutate(func(s *Settings) { s.GraceHours = 721 })},
{"zero backoff base", mutate(func(s *Settings) { s.BackoffBaseHours = 0 })},
{"backoff base beyond a week", mutate(func(s *Settings) { s.BackoffBaseHours = 169 })},
{"zero backoff cap", mutate(func(s *Settings) { s.BackoffMaxHours = 0 })},
{"cap below base is incoherent", mutate(func(s *Settings) {
s.BackoffBaseHours = 48
s.BackoffMaxHours = 24
})},
{"zero attempts means never try", mutate(func(s *Settings) { s.MaxAttempts = 0 })},
{"attempts beyond ten", mutate(func(s *Settings) { s.MaxAttempts = 11 })},
{"zero per pass means never sweep", mutate(func(s *Settings) { s.MaxPerPass = 0 })},
{"per pass beyond the cap", mutate(func(s *Settings) { s.MaxPerPass = 201 })},
}
@@ -104,21 +34,6 @@ func TestValidateAcceptsDefaults(t *testing.T) {
}
}
// Equal base and cap is legal — it is how an operator asks for a flat retry
// interval rather than an escalating one.
func TestValidateAcceptsFlatBackoff(t *testing.T) {
s := mutate(func(s *Settings) {
s.BackoffBaseHours = 12
s.BackoffMaxHours = 12
})
if err := validate(s); err != nil {
t.Fatalf("flat backoff should be allowed, got %v", err)
}
if got := s.Backoff(5); got != 12*time.Hour {
t.Errorf("flat backoff gave %v, want 12h at every attempt", got)
}
}
func mutate(f func(*Settings)) Settings {
s := Defaults
f(&s)