feat: Minstrel stops acquiring music and drops Discover
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
release / go (push) Successful in 1m54s
release / web (push) Failing after 5s
release / integration (push) Failing after 3m44s
release / govulncheck (push) Successful in 20s
release / Attach APK to the Release (tag releases only) (push) Canceled after 0s
release / Build + push container image (push) Canceled after 0s
release / Verify release artifacts (tag releases only) (push) Canceled after 0s
release / Build signed APK (push) Canceled after 19s
release / android (push) Canceled after 2m37s
Minstrel is now a viewer of the library it is pointed at. Finding, downloading and filing music moves out of it. Removed from the server: - the request flow (requests, approval, auto-approve) and the wanted list, follows, release profiles and release blocks; - searching indexers, the download clients, the importer, the album lifecycle and missing-file re-acquisition; - the catalogue's discography, search and art (the MusicBrainz release and track-list cache stays, for the duplicate resolver); - Discover: its suggestions of artists not in the library, snoozes, the candidate-artist tag enrichment and its tuning scope; - writes to acquisition tables from moving the library folder and from merging duplicates, the want-list join on Suspect sources, the sealing of acquisition credentials, and the release-group lookup only re-acquisition used. Settling a wrong-slot duplicate no longer sets the release aside: the copies go and their slots show as missing until a good copy is in the library. Removed from the web: Admin > Acquisition and Requests, /requests, /discover, Follow on the artist page, the auto-approve toggle, and the Collection's wanted-list tabs. The Collection is now the library's health: an overview, Reports, Duplicates, Suspect sources and Missing files. The README and docs no longer describe getting music. The tables stay for now; a later migration drops them. The request notification kinds and the Android screens are still to go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -161,70 +161,6 @@ func applyTastePatch(current TasteTuning, patch map[string]float64) (TasteTuning
|
||||
return next, changes, nil
|
||||
}
|
||||
|
||||
// Discover tuning bounds.
|
||||
const (
|
||||
// A tag-overlap weight above this stops being a boost and becomes the
|
||||
// ranking — at 10, a perfect match multiplies similarity by 11, which lets
|
||||
// tag agreement swamp the similarity signal entirely. The bound is for
|
||||
// typos, not to constrain exploration; the multiplicative blend keeps even
|
||||
// the maximum from reordering an untagged candidate.
|
||||
tagOverlapWeightMax = 10.0
|
||||
// Snooze duration: at least a day (anything less isn't a snooze, it's a
|
||||
// flicker), at most a year — past that it's a permanent dismissal wearing a
|
||||
// snooze's clothes, and suggestions have no permanent "never show" control.
|
||||
snoozeDaysMin = 1.0
|
||||
snoozeDaysMax = 365.0
|
||||
)
|
||||
|
||||
// applyDiscoverPatch validates and applies a partial Discover update.
|
||||
func applyDiscoverPatch(
|
||||
current DiscoverTuning, patch map[string]float64,
|
||||
) (DiscoverTuning, []fieldChange, error) {
|
||||
next := current
|
||||
var changes []fieldChange
|
||||
for field, v := range patch {
|
||||
var target *float64
|
||||
switch field {
|
||||
case "tag_overlap_weight":
|
||||
if v < 0 || v > tagOverlapWeightMax {
|
||||
return current, nil, fmt.Errorf("%w: %s = %v (must be in [0, %v])",
|
||||
ErrOutOfRange, field, v, tagOverlapWeightMax)
|
||||
}
|
||||
target = &next.TagOverlapWeight
|
||||
case "snooze_days":
|
||||
if v < snoozeDaysMin || v > snoozeDaysMax {
|
||||
return current, nil, fmt.Errorf("%w: %s = %v (must be in [%v, %v])",
|
||||
ErrOutOfRange, field, v, snoozeDaysMin, snoozeDaysMax)
|
||||
}
|
||||
target = &next.SnoozeDays
|
||||
default:
|
||||
return current, nil, fmt.Errorf("%w: %q", ErrUnknownField, field)
|
||||
}
|
||||
if *target == v {
|
||||
continue
|
||||
}
|
||||
changes = append(changes, fieldChange{Field: field, Old: *target, New: v})
|
||||
*target = v
|
||||
}
|
||||
return next, changes, nil
|
||||
}
|
||||
|
||||
// diffDiscover returns per-field changes from a to b (empty when equal).
|
||||
func diffDiscover(a, b DiscoverTuning) []fieldChange {
|
||||
var out []fieldChange
|
||||
if a.TagOverlapWeight != b.TagOverlapWeight {
|
||||
out = append(out, fieldChange{
|
||||
Field: "tag_overlap_weight", Old: a.TagOverlapWeight, New: b.TagOverlapWeight,
|
||||
})
|
||||
}
|
||||
if a.SnoozeDays != b.SnoozeDays {
|
||||
out = append(out, fieldChange{
|
||||
Field: "snooze_days", Old: a.SnoozeDays, New: b.SnoozeDays,
|
||||
})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// diffWeights returns per-field changes from a to b (empty when equal).
|
||||
func diffWeights(a, b recommendation.ScoringWeights) []fieldChange {
|
||||
var out []fieldChange
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package recsettings is the DB-backed home of the recommendation
|
||||
// tuning knobs: the scoring-weight profiles (radio, daily_mix,
|
||||
// songs_like), Discover's settings, and the taste-profile build
|
||||
// songs_like) and the taste-profile build
|
||||
// settings (engagement half-life + completion curve). It follows the coverart
|
||||
// SettingsService pattern — boot reconcile seeds shipped defaults for
|
||||
// missing rows, values are cached under a RWMutex, and every change
|
||||
@@ -34,11 +34,6 @@ const (
|
||||
ScopeRadio = "radio"
|
||||
ScopeDailyMix = "daily_mix"
|
||||
ScopeTaste = "taste"
|
||||
// ScopeDiscover is the Discover request surface. Its own scope rather
|
||||
// than columns on taste: SnoozeDays lives here, and a snooze must never
|
||||
// be read as taste signal — filing it under taste would put it one
|
||||
// careless join from that leak.
|
||||
ScopeDiscover = "discover"
|
||||
// ScopeSongsLike is the "Songs like {X}" surface. It is separate from
|
||||
// daily_mix because the two want opposite things: For-You answers "what
|
||||
// will they enjoy today" and is supposed to roam; Songs-like answers
|
||||
@@ -162,32 +157,6 @@ func shippedWeightsFor(scope string) (recommendation.ScoringWeights, bool) {
|
||||
return recommendation.ScoringWeights{}, false
|
||||
}
|
||||
|
||||
// DiscoverTuning is the tunable set for the Discover request surface.
|
||||
type DiscoverTuning struct {
|
||||
// TagOverlapWeight scales the taste-tag term: score × (1 + w × overlap).
|
||||
// 0 disables it and restores pure similarity ranking.
|
||||
TagOverlapWeight float64
|
||||
// SnoozeDays is the default "not right now" duration.
|
||||
SnoozeDays float64
|
||||
}
|
||||
|
||||
// ShippedDiscoverTuning are the shipped Discover defaults.
|
||||
//
|
||||
// TagOverlapWeight 1.0 lets a perfect tag match at most double a candidate's
|
||||
// similarity score — enough to reorder the deck meaningfully, not enough for a
|
||||
// popular-tag coincidence to beat a genuinely strong similarity match. It is a
|
||||
// starting point, not a tuned value: the way to pick it is the metrics trend
|
||||
// view after some real use.
|
||||
//
|
||||
// SnoozeDays 90: long enough that a parked suggestion stops nagging, short
|
||||
// enough that a taste shift brings it back on its own.
|
||||
func ShippedDiscoverTuning() DiscoverTuning {
|
||||
return DiscoverTuning{
|
||||
TagOverlapWeight: 1.0,
|
||||
SnoozeDays: 90,
|
||||
}
|
||||
}
|
||||
|
||||
// ShippedTasteTuning mirrors taste.DefaultConfig's tunable subset.
|
||||
func ShippedTasteTuning() TasteTuning {
|
||||
d := taste.DefaultConfig()
|
||||
@@ -211,7 +180,6 @@ type Service struct {
|
||||
mu sync.RWMutex
|
||||
profiles map[string]recommendation.ScoringWeights
|
||||
taste TasteTuning
|
||||
discover DiscoverTuning
|
||||
}
|
||||
|
||||
// New boots the service: seeds shipped defaults for missing rows,
|
||||
@@ -254,13 +222,6 @@ func (s *Service) reconcile(ctx context.Context) error {
|
||||
}); err != nil {
|
||||
return fmt.Errorf("seed taste tuning: %w", err)
|
||||
}
|
||||
sd := ShippedDiscoverTuning()
|
||||
if err := q.UpsertDiscoverTuningDefaults(ctx, dbq.UpsertDiscoverTuningDefaultsParams{
|
||||
TagOverlapWeight: sd.TagOverlapWeight,
|
||||
SnoozeDays: sd.SnoozeDays,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("seed discover tuning: %w", err)
|
||||
}
|
||||
|
||||
rows, err := q.ListWeightProfiles(ctx)
|
||||
if err != nil {
|
||||
@@ -270,10 +231,6 @@ func (s *Service) reconcile(ctx context.Context) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("get taste tuning: %w", err)
|
||||
}
|
||||
dt, err := q.GetDiscoverTuning(ctx)
|
||||
if err != nil {
|
||||
return fmt.Errorf("get discover tuning: %w", err)
|
||||
}
|
||||
|
||||
s.mu.Lock()
|
||||
s.profiles = map[string]recommendation.ScoringWeights{}
|
||||
@@ -289,10 +246,6 @@ func (s *Service) reconcile(ctx context.Context) error {
|
||||
EraScale: tt.EraScale,
|
||||
MoodScale: tt.MoodScale,
|
||||
}
|
||||
s.discover = DiscoverTuning{
|
||||
TagOverlapWeight: dt.TagOverlapWeight,
|
||||
SnoozeDays: dt.SnoozeDays,
|
||||
}
|
||||
s.mu.Unlock()
|
||||
|
||||
s.push()
|
||||
@@ -327,15 +280,6 @@ func (s *Service) Taste() TasteTuning {
|
||||
return s.taste
|
||||
}
|
||||
|
||||
// Discover returns the cached Discover-tuning values. Read per request by the
|
||||
// suggestions handler, so an admin change takes effect on the next refresh
|
||||
// with no restart.
|
||||
func (s *Service) Discover() DiscoverTuning {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return s.discover
|
||||
}
|
||||
|
||||
// TasteConfig assembles the full taste.Config the profile builder
|
||||
// consumes: shipped non-tunable knobs (like bonuses, floors, caps)
|
||||
// plus the tuned half-life and curve. WindowDays scales with the
|
||||
@@ -395,19 +339,6 @@ func (s *Service) UpdateTaste(ctx context.Context, patch map[string]float64) err
|
||||
return s.persistTaste(ctx, next, "update", changes)
|
||||
}
|
||||
|
||||
// UpdateDiscover applies a partial update to the Discover tuning singleton.
|
||||
func (s *Service) UpdateDiscover(ctx context.Context, patch map[string]float64) error {
|
||||
current := s.Discover()
|
||||
next, changes, err := applyDiscoverPatch(current, patch)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(changes) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.persistDiscover(ctx, next, "update", changes)
|
||||
}
|
||||
|
||||
// Reset restores a scope to its shipped defaults, with one audit row
|
||||
// carrying the full diff. A scope already at defaults is a no-op.
|
||||
func (s *Service) Reset(ctx context.Context, scope string) error {
|
||||
@@ -430,13 +361,6 @@ func (s *Service) Reset(ctx context.Context, scope string) error {
|
||||
return nil
|
||||
}
|
||||
return s.persistTaste(ctx, shipped, "reset", changes)
|
||||
case ScopeDiscover:
|
||||
shipped := ShippedDiscoverTuning()
|
||||
changes := diffDiscover(s.Discover(), shipped)
|
||||
if len(changes) == 0 {
|
||||
return nil
|
||||
}
|
||||
return s.persistDiscover(ctx, shipped, "reset", changes)
|
||||
default:
|
||||
return fmt.Errorf("%w: %q", ErrUnknownScope, scope)
|
||||
}
|
||||
@@ -487,28 +411,6 @@ func (s *Service) persistTaste(
|
||||
return nil
|
||||
}
|
||||
|
||||
// persistDiscover writes the discover row + audit entry and refreshes the
|
||||
// cache. No push(): unlike taste and daily_mix, nothing precomputes from these
|
||||
// — the suggestions handler reads Discover() per request.
|
||||
func (s *Service) persistDiscover(
|
||||
ctx context.Context, d DiscoverTuning, action string, changes []fieldChange,
|
||||
) error {
|
||||
q := dbq.New(s.pool)
|
||||
if _, err := q.UpdateDiscoverTuning(ctx, dbq.UpdateDiscoverTuningParams{
|
||||
TagOverlapWeight: d.TagOverlapWeight,
|
||||
SnoozeDays: d.SnoozeDays,
|
||||
}); err != nil {
|
||||
return fmt.Errorf("update discover tuning: %w", err)
|
||||
}
|
||||
if err := s.audit(ctx, q, ScopeDiscover, action, changes); err != nil {
|
||||
return err
|
||||
}
|
||||
s.mu.Lock()
|
||||
s.discover = d
|
||||
s.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
// audit writes one recommendation_tuning_audit row. Changes are
|
||||
// sorted by field so rows are deterministic and diff-friendly.
|
||||
func (s *Service) audit(
|
||||
|
||||
@@ -281,115 +281,3 @@ func TestUpdate_NoOpWritesNoAudit(t *testing.T) {
|
||||
t.Errorf("no-op update wrote %d audit rows, want 0", len(rows))
|
||||
}
|
||||
}
|
||||
|
||||
// --- Discover scope ---
|
||||
|
||||
func TestNew_SeedsDiscoverDefaults(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
s := newService(t, pool)
|
||||
got := s.Discover()
|
||||
want := ShippedDiscoverTuning()
|
||||
if got != want {
|
||||
t.Errorf("Discover() = %+v, want shipped %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateDiscover_PersistsAndAudits(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
s := newService(t, pool)
|
||||
if err := s.UpdateDiscover(context.Background(), map[string]float64{
|
||||
"tag_overlap_weight": 2.5,
|
||||
"snooze_days": 30,
|
||||
}); err != nil {
|
||||
t.Fatalf("UpdateDiscover: %v", err)
|
||||
}
|
||||
if got := s.Discover().TagOverlapWeight; got != 2.5 {
|
||||
t.Errorf("TagOverlapWeight = %v, want 2.5", got)
|
||||
}
|
||||
if got := s.Discover().SnoozeDays; got != 30 {
|
||||
t.Errorf("SnoozeDays = %v, want 30", got)
|
||||
}
|
||||
|
||||
// The audit row must land under the new scope: a scope missing from
|
||||
// recommendation_tuning_audit's CHECK fails this INSERT at runtime.
|
||||
rows := auditRows(t, pool)
|
||||
if len(rows) != 1 {
|
||||
t.Fatalf("audit rows = %d, want 1", len(rows))
|
||||
}
|
||||
if rows[0].Scope != ScopeDiscover {
|
||||
t.Errorf("audit scope = %q, want %q", rows[0].Scope, ScopeDiscover)
|
||||
}
|
||||
if len(rows[0].Changes) != 2 {
|
||||
t.Errorf("audit changes = %+v, want both fields", rows[0].Changes)
|
||||
}
|
||||
|
||||
// Reload from the DB to prove it persisted rather than only caching.
|
||||
s2 := newService(t, pool)
|
||||
if got := s2.Discover().TagOverlapWeight; got != 2.5 {
|
||||
t.Errorf("after reload TagOverlapWeight = %v, want 2.5 (not re-seeded to shipped)", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestUpdateDiscover_Validation(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
s := newService(t, pool)
|
||||
cases := []struct {
|
||||
name string
|
||||
patch map[string]float64
|
||||
}{
|
||||
{"unknown field", map[string]float64{"nope": 1}},
|
||||
{"negative weight", map[string]float64{"tag_overlap_weight": -1}},
|
||||
{"weight past the typo bound", map[string]float64{"tag_overlap_weight": 100}},
|
||||
// A sub-day snooze isn't a snooze, it's a flicker.
|
||||
{"snooze under a day", map[string]float64{"snooze_days": 0.5}},
|
||||
// Past a year it's a permanent dismissal wearing a snooze's clothes.
|
||||
{"snooze past a year", map[string]float64{"snooze_days": 400}},
|
||||
}
|
||||
for _, c := range cases {
|
||||
if err := s.UpdateDiscover(context.Background(), c.patch); err == nil {
|
||||
t.Errorf("%s: expected rejection, got nil", c.name)
|
||||
}
|
||||
}
|
||||
if got := s.Discover(); got != ShippedDiscoverTuning() {
|
||||
t.Errorf("a rejected patch mutated state: %+v", got)
|
||||
}
|
||||
if rows := auditRows(t, pool); len(rows) != 0 {
|
||||
t.Errorf("rejected patches wrote %d audit rows, want 0", len(rows))
|
||||
}
|
||||
}
|
||||
|
||||
// Weight 0 must be accepted: it's the off switch for the whole tag term, so
|
||||
// a "must be positive" bound would leave no way to disable it.
|
||||
func TestUpdateDiscover_ZeroWeightIsAllowed(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
s := newService(t, pool)
|
||||
if err := s.UpdateDiscover(context.Background(),
|
||||
map[string]float64{"tag_overlap_weight": 0}); err != nil {
|
||||
t.Fatalf("UpdateDiscover(0): %v", err)
|
||||
}
|
||||
if got := s.Discover().TagOverlapWeight; got != 0 {
|
||||
t.Errorf("TagOverlapWeight = %v, want 0", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestResetDiscover_RestoresShippedDefaults(t *testing.T) {
|
||||
pool := newPool(t)
|
||||
s := newService(t, pool)
|
||||
if err := s.UpdateDiscover(context.Background(),
|
||||
map[string]float64{"tag_overlap_weight": 4}); err != nil {
|
||||
t.Fatalf("UpdateDiscover: %v", err)
|
||||
}
|
||||
if err := s.Reset(context.Background(), ScopeDiscover); err != nil {
|
||||
t.Fatalf("Reset: %v", err)
|
||||
}
|
||||
if got := s.Discover(); got != ShippedDiscoverTuning() {
|
||||
t.Errorf("after reset = %+v, want shipped %+v", got, ShippedDiscoverTuning())
|
||||
}
|
||||
// Already-at-defaults is a no-op: update + reset = 2 rows, not 3.
|
||||
if err := s.Reset(context.Background(), ScopeDiscover); err != nil {
|
||||
t.Fatalf("second Reset: %v", err)
|
||||
}
|
||||
if rows := auditRows(t, pool); len(rows) != 2 {
|
||||
t.Errorf("audit rows = %d, want 2 (the no-op reset must not audit)", len(rows))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ func TestShippedWeightsFor_CoversEveryWeightProfile(t *testing.T) {
|
||||
}
|
||||
// Non-weight scopes must NOT resolve here, or Reset would treat the taste
|
||||
// singleton as a weight profile and write nonsense.
|
||||
for _, scope := range []string{ScopeTaste, ScopeDiscover, "nonsense"} {
|
||||
for _, scope := range []string{ScopeTaste, "nonsense"} {
|
||||
if _, ok := shippedWeightsFor(scope); ok {
|
||||
t.Errorf("scope %q resolved as a weight profile and is not one", scope)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user