From 4e7c2128f3f529cf9381f9e88794ea64c2e50e9c Mon Sep 17 00:00:00 2001 From: Deluan Date: Sun, 24 May 2026 22:24:50 -0300 Subject: [PATCH] docs(scanner): document artistIDMap many-to-one collapse behavior MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Per Copilot review on PR #5527: the 'first prevID wins' check looked like a bug. It is intentional but the rationale wasn't obvious from context. Annotate the code with the merge-collision relationship to ReassignAnnotation's missing merge semantics — the follow-up that fixes the SQL side will benefit both album and artist re-PID paths. --- scanner/phase_1_folders.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scanner/phase_1_folders.go b/scanner/phase_1_folders.go index aa67a68b6..77409344c 100644 --- a/scanner/phase_1_folders.go +++ b/scanner/phase_1_folders.go @@ -306,6 +306,15 @@ func (p *phaseFolders) loadTagsFromFiles(entry *folderEntry, toImport map[string // Build artistIDMap: for each participant on this track, if the previous // spec produces a different ID than the current one, record the mapping. + // + // The map is keyed by the new artist ID so it stores ONE previous ID per + // new ID, even when many old IDs collapse to the same new one (e.g. + // switching from "name" to "musicbrainz_artistid|name" where multiple + // name-keyed IDs share an MBID). This is intentional: ReassignAnnotation + // is idempotent and the other prior IDs orphan their annotations into + // the unique-constraint collision case documented in the spec — a + // known limitation tracked for a separate follow-up that fixes + // ReassignAnnotation merge semantics at the SQL level. if p.prevArtistPIDConf != "" && p.prevArtistPIDConf != conf.Server.PID.Artist { for _, list := range track.Participants { for _, part := range list {