The first public release of Fabled Minstrel #158

Merged
bvandeusen merged 256 commits from dev into main 2026-12-03 21:41:58 -05:00
11 changed files with 152 additions and 25 deletions
Showing only changes of commit dbe075c686 - Show all commits
-2
View File
@@ -51,8 +51,6 @@ Open `http://<host>:4533/register` and create the first account with that setup
3. **Invite the household.** In **Admin › Users** (`/admin/users`), make an invite token or turn on open registration. Each person gets their own likes, history and recommendations. 3. **Invite the household.** In **Admin › Users** (`/admin/users`), make an invite token or turn on open registration. Each person gets their own likes, history and recommendations.
4. **Optional: connect ListenBrainz.** Each person adds their own ListenBrainz token in **Settings › Connections**. 4. **Optional: connect ListenBrainz.** Each person adds their own ListenBrainz token in **Settings › Connections**.
<a href="docs/screenshots/library-scan.png"><img src="docs/screenshots/library-scan.png" width="820" alt="The Admin page, where the library scan runs and reports progress"></a>
## Configuration ## Configuration
The quick start sets everything that's required. These are the settings people most often change: The quick start sets everything that's required. These are the settings people most often change:
+12 -12
View File
@@ -1,19 +1,19 @@
# README screenshots # README screenshots
Drop the files below into this directory with these **exact names** — the The root `README.md` shows `home.png`. The other files here are the set to
root `README.md` already references them, so no Markdown editing is needed. capture for it. Export as PNG, capture while logged in as an admin and after
Export as PNG. Capture while logged in as admin and *after* the first the first library scan so nothing looks empty, and keep the same browser width
library scan so nothing looks empty; keep the same browser width and theme and theme across all shots. Use a demo account and a library you are happy to
across all shots for a consistent look. publish: the shots go out with the repository.
| Filename | Route | What to capture | | Filename | Route | What to capture |
|---|---|---| |---|---|---|
| `home.png` | `/` | The home page with a populated library (system playlists / recently added) | | `home.png` | `/` | The home page with a populated library (system playlists, recently added) |
| `register.png` | `/register` | The account-creation form on a fresh instance | | `register.png` | `/register` | The account-creation form on a fresh instance |
| `library-scan.png` | `/admin` | The library scan running in stages (grab it mid-scan so stage tallies show) | | `library-scan.png` | `/admin` | The library scan running in stages (grab it mid-scan so the stage tallies show) |
| `integrations.png` | `/admin/acquisition` | Indexers, download clients and searching | | `collection.png` | `/collection` | The Collection queues: reports, duplicates, suspect sources and Needs a file |
| `android-download.png` | `/settings` | The "Install the Android app" download card | | `android-download.png` | `/settings` | The "Install the Android app" card |
| `invite-users.png` | `/admin/users` | The invite-token generation / users list | | `invite-users.png` | `/admin/users` | The users list and invite generation |
Tip: to control display width in the README, you can swap the Markdown To control the display width in the README, use an HTML tag instead of
`![alt](path)` for an HTML tag, e.g. `<img src="docs/screenshots/home.png" width="800" alt="...">`. Markdown, e.g. `<img src="docs/screenshots/home.png" width="800" alt="...">`.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

+2 -3
View File
@@ -1073,9 +1073,8 @@ type SetAlbumReleaseGroupMbidIfNullParams struct {
ReleaseGroupMbid *string ReleaseGroupMbid *string
} }
// Heal the release-group id on an existing album row, from a rescan's // Heal the release-group id on an existing album row from a rescan's tags.
// tags or from the re-acquisition sweeper's MusicBrainz lookup. Only fills a // Only fills a NULL, so a stored id is never overwritten.
// NULL, so a tag never gets overwritten by a later guess or vice versa.
func (q *Queries) SetAlbumReleaseGroupMbidIfNull(ctx context.Context, arg SetAlbumReleaseGroupMbidIfNullParams) error { func (q *Queries) SetAlbumReleaseGroupMbidIfNull(ctx context.Context, arg SetAlbumReleaseGroupMbidIfNullParams) error {
_, err := q.db.Exec(ctx, setAlbumReleaseGroupMbidIfNull, arg.ID, arg.ReleaseGroupMbid) _, err := q.db.Exec(ctx, setAlbumReleaseGroupMbidIfNull, arg.ID, arg.ReleaseGroupMbid)
return err return err
+1 -1
View File
@@ -66,7 +66,7 @@ type ListMissingTrackPairsRow struct {
// Missing-pair pass. A track marked missing whose replacement is already // Missing-pair pass. A track marked missing whose replacement is already
// on disk under another row — most often a quality upgrade, mp3 → flac at a new // on disk under another row — most often a quality upgrade, mp3 → flac at a new
// path — is folded into that replacement, so its history moves across and // path — is folded into that replacement, so its history moves across and
// re-acquisition stops chasing music the library already has. // the track stops waiting for a file the library already has.
// //
// Move adoption cannot catch these: it links a new file to a missing row // Move adoption cannot catch these: it links a new file to a missing row
// at the moment the file is first inserted, and the replacement arrives as a // at the moment the file is first inserted, and the replacement arrives as a
+2 -3
View File
@@ -230,9 +230,8 @@ UPDATE albums
WHERE id = $1 AND mbid IS NULL; WHERE id = $1 AND mbid IS NULL;
-- name: SetAlbumReleaseGroupMbidIfNull :exec -- name: SetAlbumReleaseGroupMbidIfNull :exec
-- Heal the release-group id on an existing album row, from a rescan's -- Heal the release-group id on an existing album row from a rescan's tags.
-- tags or from the re-acquisition sweeper's MusicBrainz lookup. Only fills a -- Only fills a NULL, so a stored id is never overwritten.
-- NULL, so a tag never gets overwritten by a later guess or vice versa.
UPDATE albums UPDATE albums
SET release_group_mbid = $2, SET release_group_mbid = $2,
updated_at = now() updated_at = now()
+1 -1
View File
@@ -1,7 +1,7 @@
-- Missing-pair pass. A track marked missing whose replacement is already -- Missing-pair pass. A track marked missing whose replacement is already
-- on disk under another row — most often a quality upgrade, mp3 → flac at a new -- on disk under another row — most often a quality upgrade, mp3 → flac at a new
-- path — is folded into that replacement, so its history moves across and -- path — is folded into that replacement, so its history moves across and
-- re-acquisition stops chasing music the library already has. -- the track stops waiting for a file the library already has.
-- --
-- Move adoption cannot catch these: it links a new file to a missing row -- Move adoption cannot catch these: it links a new file to a missing row
-- at the moment the file is first inserted, and the replacement arrives as a -- at the moment the file is first inserted, and the replacement arrives as a
+3 -3
View File
@@ -1,7 +1,7 @@
// Package secret seals the credentials Minstrel keeps for outside systems // Package secret seals the credentials Minstrel keeps for outside systems
// (indexer and download-client keys, the SMTP password, provider API keys, // (the SMTP password, the backup destination's secret key, metadata provider
// ListenBrainz tokens, Subsonic passwords) so the database holds ciphertext, // and AcoustID API keys, ListenBrainz tokens, Subsonic passwords) so the
// not the credential. // database holds ciphertext, not the credential.
// //
// Each column has its own key, derived from the install's master key with // Each column has its own key, derived from the install's master key with
// HKDF-SHA256 and the column as the info string, so a value sealed for one // HKDF-SHA256 and the column as the info string, so a value sealed for one
+131
View File
@@ -0,0 +1,131 @@
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
}