harbor run -t scale-ai/hil-bench-swe_45-ask_humanharbor download scale-ai/hil-bench-swe_45-ask_humanFeature / Refactor
Model (album/artist)
Artist refresh logic is currently tied to persistence-layer SQL aggregation, coupling refresh behavior to the database and duplicating aggregation responsibilities. Artist data should be computed at the model level from album data.
Artist information is refreshed from album data and should produce deterministic artist attributes for album count, song count, genres, size, and MusicBrainz identifiers.
The implementation should preserve functional parity for existing artist update flows.
The change introduces a model-level method on Albums that aggregates an artist value from album records.
ToAlbumArtist must exist in the model package, defined on the public type Albums (a slice of Album).ToAlbumArtist must return an Artist value that aggregates attributes from all albums in the collection.Artist.ID, Artist.Name, Artist.SortArtistName, and Artist.OrderArtistName must be derived from the corresponding artist fields in the provided albums.Artist.SongCount must equal the sum of the SongCount values of all albums.Artist.Size must equal the sum of the Size values of all albums.Artist.Genres must include unique Genre values from the albums.Artist.MbzArtistID should represent the dominant identifier across albums. Album records may store placeholder values when no MusicBrainz assignment exists; such entries must be excluded from the candidate pool before determining dominance.refreshArtists must batch IDs in fixed-size chunks that stay within repository-safe bounds, because oversized batches can fail during large scans.Artist.SortArtistName from Album.SortAlbumArtistName and Artist.OrderArtistName from Album.OrderAlbumArtistName. Similarly, Artist.Name comes from Album.AlbumArtist and Artist.ID from Album.AlbumArtistID. The track-level fields (ArtistID, Artist, SortArtistName) describe the performing artist of individual tracks, not the credited album artist.The following new public interface must be implemented:
Name: ToAlbumArtist
Type: Method (on model.Albums)
Path: model/album.go
Inputs: receiver als model.Albums
Outputs: model.Artist
Description: Aggregates a collection of albums into a single artist value. Sets artist identity fields from the provided albums; computes AlbumCount, sums SongCount and Size; deduplicates genres are deduplicated by unique Genre.ID; selects MbzArtistID from album MusicBrainz data.