docs: server comments say what the code does, not how it came to be (#6277)

Comment blocks in cmd/minstrel and 30 smaller internal packages, rewritten
to rule 32's standard with each citation read in context: task, milestone
and rule ids go, and so do the stories they were attached to ("used to",
"Before #N", measurements from one install, quotes, pointers to Fabled
Librarian's records and to docs/superpowers files that are not in the
repo). Where a story wrapped a real constraint, the constraint stays as a
present-tense fact.

Comments that had gone stale are corrected:
- taste.Config: the tuned values are overlaid by internal/recsettings;
  it is no longer "a later follow-up".
- StorageConfig: the data dir holds art, caches and the stream secret,
  not only playlist covers.
- the Subsonic album list and getUser comments describe what they do
  today rather than a milestone that would change it.

Checked: the non-comment token stream of every changed file matches
HEAD, and gofmt -l is empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 12:15:05 -04:00
co-authored by Claude Opus 5.5
parent 9f9609591d
commit d191a28217
107 changed files with 485 additions and 597 deletions
+8 -8
View File
@@ -5,14 +5,14 @@
//
// For recordings it keeps LB's whole answer in listenbrainz_similar_recordings
// and derives the track_similarity edges from it in SQL, against whatever is
// in the library at the time (#5296). Matching once at fetch time missed every
// recording that reached the library afterwards, through an import or an MBID
// the AcoustID lookup filled in. For artists it stores the in-library matches in
// artist_similarity and the rest in artist_similarity_unmatched, as before.
// in the library at the time, so a recording that reaches the library later
// (an import, or an MBID the AcoustID lookup fills in) gains its edges without
// asking LB again. For artists it stores the in-library matches in
// artist_similarity and the rest in artist_similarity_unmatched.
//
// Every answer is recorded as a fetch, an empty one included, and the queue
// reads those records: freshness used to be read from the edges, so a seed
// that matched nothing was never fresh and held the head of the queue.
// reads those records rather than the edges: a seed that matched nothing is
// still fresh and does not hold the head of the queue.
package similarity
import (
@@ -200,8 +200,8 @@ func (w *Worker) upsertArtistSimilar(ctx context.Context, q *dbq.Queries, artist
}
sort.Slice(results, func(i, j int) bool { return results[i].Score > results[j].Score })
// Scores are stored relative to the seed's closest artist, as track edges
// are (#6177): LB's raw scores are counts (16 to 10,875 on the operator's
// library), and both the candidate pool and the suggestions read 0 to 1.
// are: LB's raw scores are unbounded counts, and both the candidate pool
// and the suggestions read 0 to 1.
best := results[0].Score
mbids := make([]string, 0, len(results))
+11 -11
View File
@@ -209,9 +209,9 @@ func TestTickOnce_MapsLBResponseToLocalLibrary(t *testing.T) {
}
}
// LB's scores are counts, not 0 to 1 (16 to 1445 on the operator's library).
// An edge is stored over the seed's best score in the whole answer, in the
// library or not, so the scorer reads it as 0 to 1 (#6177).
// LB's scores are counts, not 0 to 1. An edge is stored over the seed's best
// score in the whole answer, in the library or not, so the scorer reads it as
// 0 to 1.
func TestTickOnce_EdgeIsRelativeToTheSeedsBest(t *testing.T) {
f := newFixture(t)
mbidA := "11111111-1111-1111-1111-111111111111"
@@ -241,8 +241,8 @@ func TestTickOnce_EdgeIsRelativeToTheSeedsBest(t *testing.T) {
}
}
// The 20-per-seed cap is gone with the cache (#5296): LB's answer is at most
// 50, and every recording of it that is in the library becomes an edge.
// LB's answer is at most 50, and every recording of it that is in the library
// becomes an edge: no per-seed cap.
func TestTickOnce_KeepsEveryInLibraryMatch(t *testing.T) {
f := newFixture(t)
mbidSeed := "11111111-1111-1111-1111-111111111111"
@@ -311,7 +311,7 @@ func TestTickOnce_RefreshesStaleRow(t *testing.T) {
_ = f.pool.QueryRow(context.Background(),
`SELECT score, fetched_at FROM track_similarity WHERE track_a_id = $1 AND track_b_id = $2 AND source = 'listenbrainz'`,
trackA.ID, other.ID).Scan(&score, &fetchedAt)
// The seed's only answer is its best, so the refreshed edge is 1.0 (#6177).
// The seed's only answer is its best, so the refreshed edge is 1.0.
if score != 1.0 {
t.Errorf("score = %v, want 1.0 (refreshed, relative to the seed's best)", score)
}
@@ -452,7 +452,7 @@ func TestUpsertArtistSimilar_PersistsUnmatchedToTable(t *testing.T) {
w := newTestWorker(f, "")
similars := []listenbrainz.SimilarArtist{
// LB's scores are counts; rows are stored over the seed's best (#6177).
// LB's scores are counts; rows are stored over the seed's best.
{MBID: inLibMBID, Name: "InLib Artist", Score: 1000},
{MBID: "out-mbid-1", Name: "Outsider One", Score: 850},
{MBID: "out-mbid-2", Name: "Outsider Two", Score: 800},
@@ -543,9 +543,9 @@ func recordingLB(answer func(mbid string) string) (*httptest.Server, func() []st
}
}
// The starvation #3879 measured: a seed whose answer matched nothing in the
// library wrote nothing, stayed due, and was asked again every tick ahead of
// everything behind it. Recording the fetch moves the queue on.
// A seed whose answer matches nothing in the library writes no edges, and
// must still leave the head of the queue: recording the fetch moves it on,
// so it is not asked again every tick ahead of everything behind it.
func TestTickOnce_UnmatchedAnswerDoesNotHoldTheQueue(t *testing.T) {
f := newFixture(t)
mbids := []string{
@@ -583,7 +583,7 @@ func TestTickOnce_UnmatchedAnswerDoesNotHoldTheQueue(t *testing.T) {
}
}
// The point of the cache (#5296): a recording LB named while it was not in the
// The point of the cache: a recording LB named while it was not in the
// library becomes an edge once it arrives, on the next tick's resolve, without
// asking LB again. One edge per recording when the library holds two copies,
// and none to a copy that is missing.