From ad75f3ac7e5f6cd0684f177241e33c34e9766ac8 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Tue, 24 Nov 2026 18:58:58 -0500 Subject: [PATCH] chore: comments and tests explain themselves, and the dev compose drops its healthcheck Test names, assertion messages and comments no longer cite internal task or rule numbers; each says the reason itself. The dev compose starts Minstrel after the database without a healthcheck to gate on, since Minstrel waits for its database at startup on its own. The published-names test is removed; that check is a local grep before publishing. Co-Authored-By: Claude Opus 5.5 --- docker-compose.yml | 10 +- internal/api/metrics_significance_test.go | 4 +- .../recommendation/songs_like_limits_test.go | 4 +- internal/server/release_names_test.go | 131 ------------------ internal/server/release_version_test.go | 2 +- web/src/app.css | 2 +- web/src/lib/api/errors.test.ts | 2 +- web/src/lib/components/AcoustIDCard.test.ts | 2 +- .../components/RecommendationMetrics.test.ts | 2 +- web/src/lib/player/events.svelte.test.ts | 2 +- web/src/routes/admin/tuning/tuning.test.ts | 2 +- 11 files changed, 14 insertions(+), 149 deletions(-) delete mode 100644 internal/server/release_names_test.go diff --git a/docker-compose.yml b/docker-compose.yml index 83437538..2d1cf0b4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,17 +20,13 @@ services: # Creates minstrel_test on a fresh volume. On an existing volume, # make test-integration creates it instead. - ./deploy/initdb:/docker-entrypoint-initdb.d:ro - healthcheck: - test: ["CMD-SHELL", "pg_isready -U minstrel -d minstrel"] - interval: 5s - timeout: 5s - retries: 10 minstrel: build: . + # Minstrel waits for the database itself at startup, so it needs no + # healthcheck to gate on. depends_on: - postgres: - condition: service_healthy + - postgres environment: MINSTREL_DATABASE_URL: postgres://minstrel:minstrel@postgres:5432/minstrel?sslmode=disable MINSTREL_LOG_FORMAT: text diff --git a/internal/api/metrics_significance_test.go b/internal/api/metrics_significance_test.go index f07e33f9..5c3a6499 100644 --- a/internal/api/metrics_significance_test.go +++ b/internal/api/metrics_significance_test.go @@ -15,11 +15,11 @@ func TestProportionDelta_ReproducesTheDiscoverCase(t *testing.T) { if math.Abs(d.DeltaPP-(-13.3)) > 0.1 { t.Errorf("DeltaPP = %.2f, want ≈ -13.3", d.DeltaPP) } - // This is the assertion the whole task exists for: at these sample sizes + // The assertion that matters most: at these sample sizes // the margin swallows the difference. if d.Distinguishable { t.Errorf("13.3pp on n=59/70 reported as distinguishable (margin %.2f) — "+ - "this is exactly the false confidence #2495 set out to remove", d.MarginPP) + "a gap this small at these sample sizes is noise, not a finding", d.MarginPP) } if d.MarginPP <= 13.3 { t.Errorf("MarginPP = %.2f, expected it to exceed the 13.3pp delta", d.MarginPP) diff --git a/internal/recommendation/songs_like_limits_test.go b/internal/recommendation/songs_like_limits_test.go index 8e8bce87..865cae3a 100644 --- a/internal/recommendation/songs_like_limits_test.go +++ b/internal/recommendation/songs_like_limits_test.go @@ -37,11 +37,11 @@ func TestSongsLikeLimits_KeepATierThreeFloor(t *testing.T) { s := SongsLikeCandidateSourceLimits() if s.RandomFill <= 0 { t.Error("RandomFill is zero: a seed with thin similarity coverage now produces " + - "a short or empty mix instead of degrading (rule 131)") + "a short or empty mix instead of stepping down to looser picks") } if s.TasteOverlap <= 0 { t.Error("TasteOverlap is zero: the graded floor is gone, leaving only random " + - "fill between a sparse seed and an empty playlist (rule 131)") + "fill between a sparse seed and an empty playlist") } } diff --git a/internal/server/release_names_test.go b/internal/server/release_names_test.go deleted file mode 100644 index 2002cedf..00000000 --- a/internal/server/release_names_test.go +++ /dev/null @@ -1,131 +0,0 @@ -package server - -import ( - "bytes" - "errors" - "io/fs" - "os" - "os/exec" - "path/filepath" - "slices" - "testing" -) - -// The published repository names none of the music-finding tools that used to -// live in Minstrel or run beside it: not in code, comments, docs, config or a -// file's path. Minstrel plays the library it is given; whatever fills that -// library is the operator's choice, and the public tree points at none of them. -// -// The names are held as FNV-1a 64-bit hashes of their lowercase spelling, -// keyed by length, so this file does not carry them either. A name matches -// case-insensitively and inside a longer word, as `git grep -i` would. -var unpublishedNames = map[int][]uint64{ - 6: {0xf9a02fd5dc574c88, 0xf44b33950e1b02a5}, - 8: {0x8cb31206e3250360}, - 10: {0x49db22150da0e6a4}, -} - -// The tracked files are what a clone of the repository carries, so they are -// what is checked: a build output or an untracked scratch file is not -// published. -func TestPublishedTreeNamesNoMusicFindingTool(t *testing.T) { - root := repoRoot(t) - cmd := exec.Command("git", "ls-files", "-z") - cmd.Dir = root - out, err := cmd.Output() - if err != nil { - t.Fatalf("git ls-files: %v (the check reads the checkout's git metadata)", err) - } - paths := bytes.Split(bytes.TrimRight(out, "\x00"), []byte{0}) - // An empty or truncated listing would pass by checking nothing. - if len(paths) < 500 { - t.Fatalf("git ls-files listed %d files; expected the whole repository", len(paths)) - } - for _, p := range paths { - path := string(p) - if len(findNames(p, unpublishedNames)) > 0 { - t.Errorf("%s: the path names a music-finding tool", path) - } - body, err := os.ReadFile(filepath.Join(root, path)) - if errors.Is(err, fs.ErrNotExist) { - continue // deleted in the working tree and not yet committed - } - if err != nil { - t.Fatalf("read %s: %v", path, err) - } - // Binary files are skipped, as git grep -I skips them. - if bytes.IndexByte(body[:min(len(body), 8000)], 0) >= 0 { - continue - } - for _, line := range findNames(body, unpublishedNames) { - t.Errorf("%s:%d names a music-finding tool", path, line) - } - } -} - -// The matcher finds a name in any case, inside a longer word and on the right -// line, and ignores a different word of the same length. It is shown working -// on a stand-in name, since the real ones are only hashes here. -func TestFindNames_MatchesTheWayGrepIDoes(t *testing.T) { - names := map[int][]uint64{9: {fnv1a([]byte("zebrafish"))}} - text := []byte("first line\nthe ZebraFishTank is here\nzebrafist\nZEBRAFISH, twice: zebrafish\n") - if got, want := findNames(text, names), []int{2, 4}; !slices.Equal(got, want) { - t.Errorf("lines = %v, want %v", got, want) - } - if got := findNames([]byte("nothing to see"), names); len(got) != 0 { - t.Errorf("lines = %v, want none", got) - } -} - -// findNames returns the lines of text that hold one of names (FNV-1a hashes -// by length), matched in any case and inside longer words. A line is reported -// once however many names it holds. -func findNames(text []byte, names map[int][]uint64) []int { - var lines []int - line, i := 1, 0 - for i < len(text) { - switch c := text[i]; { - case c == '\n': - line++ - i++ - continue - case !isASCIILetter(c): - i++ - continue - } - start := i - for i < len(text) && isASCIILetter(text[i]) { - i++ - } - if wordHoldsName(bytes.ToLower(text[start:i]), names) && - (len(lines) == 0 || lines[len(lines)-1] != line) { - lines = append(lines, line) - } - } - return lines -} - -func wordHoldsName(word []byte, names map[int][]uint64) bool { - for n, hashes := range names { - for j := 0; j+n <= len(word); j++ { - if slices.Contains(hashes, fnv1a(word[j:j+n])) { - return true - } - } - } - return false -} - -func isASCIILetter(c byte) bool { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') -} - -// fnv1a is FNV-1a, 64-bit. -func fnv1a(b []byte) uint64 { - h := uint64(0xcbf29ce484222325) - for _, c := range b { - h ^= uint64(c) - h *= 0x100000001b3 - } - return h -} diff --git a/internal/server/release_version_test.go b/internal/server/release_version_test.go index 6244a5df..128f8c40 100644 --- a/internal/server/release_version_test.go +++ b/internal/server/release_version_test.go @@ -330,7 +330,7 @@ func TestMainChannel_PublishesLatestAndTheRollbackUnit(t *testing.T) { // :latest tracks main's tip, and a second name for the same // image sends readers looking for a distinction that does not exist. if strings.Contains(arm, "${IMAGE}:main") { - t.Errorf("main arm publishes :main — rule 147 says that tag should not exist\n%s", arm) + t.Errorf("main arm publishes :main, a second name for :latest that should not exist\n%s", arm) } } diff --git a/web/src/app.css b/web/src/app.css index 31ac15c9..a4cdac89 100644 --- a/web/src/app.css +++ b/web/src/app.css @@ -45,7 +45,7 @@ --font-mono: var(--fs-font-mono); } -/* Tailwind 3's preflight defaults that 4 changed (#5021). Kept so the upgrade +/* Tailwind 3's preflight defaults that 4 changed. Kept so the upgrade * changes nothing on screen; each can go once the elements relying on it name * the value themselves. * - A border with no colour utility was gray-200; 4 makes it currentcolor. diff --git a/web/src/lib/api/errors.test.ts b/web/src/lib/api/errors.test.ts index fc874041..2cc04b6f 100644 --- a/web/src/lib/api/errors.test.ts +++ b/web/src/lib/api/errors.test.ts @@ -50,7 +50,7 @@ describe('errMessage', () => { }); }); -describe('errMessage detail codes (#3918)', () => { +describe('errMessage detail codes', () => { const detail = 'Minstrel runs as uid 1000, gid 1000 and cannot delete from /music/A (read-only file system). ' + 'The library mount must be writable by that user. Nothing was deleted.'; diff --git a/web/src/lib/components/AcoustIDCard.test.ts b/web/src/lib/components/AcoustIDCard.test.ts index 45c7b610..bbbff27e 100644 --- a/web/src/lib/components/AcoustIDCard.test.ts +++ b/web/src/lib/components/AcoustIDCard.test.ts @@ -107,7 +107,7 @@ describe("AcoustIDCard", () => { expect(saveButton()).toHaveProperty("disabled", true); }); - // Rule 164: off, keyless or unreachable is a visible state, not a silent one. + // Off, keyless or unreachable is a visible state, not a silent one. test("says why it is not looking anything up", async () => { await renderCard( overview({ diff --git a/web/src/lib/components/RecommendationMetrics.test.ts b/web/src/lib/components/RecommendationMetrics.test.ts index d3a7d465..ff3ee7b3 100644 --- a/web/src/lib/components/RecommendationMetrics.test.ts +++ b/web/src/lib/components/RecommendationMetrics.test.ts @@ -36,7 +36,7 @@ describe('RecommendationMetrics (Library › Your listening)', () => { ...over }); - test('breakdown rows are collapsed by default and expand on toggle (#1249/#1270)', async () => { + test('breakdown rows are collapsed by default and expand on toggle', async () => { metricsMock.data = { window_days: 30, baseline: metric('manual', 'Manual library plays', { plays: 100 }), diff --git a/web/src/lib/player/events.svelte.test.ts b/web/src/lib/player/events.svelte.test.ts index a22e6473..9cf6dad0 100644 --- a/web/src/lib/player/events.svelte.test.ts +++ b/web/src/lib/player/events.svelte.test.ts @@ -92,7 +92,7 @@ describe('useEventsDispatcher', () => { cleanup(); }); - test('auto-advance after reaching duration POSTs play_ended, not skip (#426)', async () => { + test('auto-advance after reaching duration POSTs play_ended, not skip', async () => { const cleanup = $effect.root(() => useEventsDispatcher()); playQueue([track('1', 200), track('2', 200)]); diff --git a/web/src/routes/admin/tuning/tuning.test.ts b/web/src/routes/admin/tuning/tuning.test.ts index 63f70b8f..a637b284 100644 --- a/web/src/routes/admin/tuning/tuning.test.ts +++ b/web/src/routes/admin/tuning/tuning.test.ts @@ -157,7 +157,7 @@ describe('Admin tuning page', () => { ).toBeInTheDocument(); }); - test('renders weekly trend rows with sparklines and knob-turn markers (#1251)', async () => { + test('renders weekly trend rows with sparklines and knob-turn markers', async () => { (getTuning as ReturnType).mockResolvedValue(snapshot()); (getTrends as ReturnType).mockResolvedValue({ weeks: 12,