A flat MusicBrainz /recording text search ties every take of a song at the
same score, so "AC/DC — Highway to Hell" returns a wall of live bootlegs and
compilations with the 1979 studio version buried (or below the fetch limit).
- build_recording_query: drop live-ONLY recordings (`-secondarytype:Live`).
Compilations are deliberately kept — they REUSE the studio recording, so
filtering them cuts the very recording we want (verified against MB).
- _best_release / parse_recording_doc: pick the canonical studio album
(primary Album, no Live/Compilation/Remix/... secondary type) for the
displayed album/year, and expose a `studio` flag.
- rank_candidates: since the combined score caps at 1.0 (perfect text match
ties), break ties on the studio flag and — when the caller knows the audio
length — on duration proximity, so the studio take wins over live/extended
cuts. The studio distinction is intentionally NOT scored (a live take is
still the right SONG), only re-ordered.
- /api/enrichment/search: accept an optional `duration` param so a caller that
has the audio but no library row (the editor's create modal) can pass the
master-track length for the duration tiebreak.
Verified end-to-end against live MusicBrainz: AC/DC "Highway to Hell" now
returns the 1979 studio recording at #1 with the correct album + year.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>