Files
music_library/backlog/tasks/ml-150 - Extract-Records-sub-contexts-to-reduce-module-size.md
T
2026-04-30 11:50:07 +01:00

1.7 KiB

id, title, status, assignee, created_date, labels, dependencies, references, priority
id title status assignee created_date labels dependencies references priority
ML-150 Extract Records sub-contexts to reduce module size To Do
2026-04-30 10:47
refactor
records
lib/music_library/records.ex
medium

Description

The Records context module (450+ lines in lib/music_library/records.ex) handles CRUD, FTS5 search, MusicBrainz import, cover management, genre population, color extraction, PubSub notifications, and similarity embedding dispatch — too many responsibilities for a single module.

Extract focused sub-contexts:

  • Records.Search — FTS5 search, SearchParser integration, search result formatting
  • Records.Import — MusicBrainz release/group import, barcode scan integration
  • Records.Enrichment — genre population, color extraction, cover management, embedding dispatch

Keep the public Records module as a facade that re-exports key functions for backward compatibility with all existing callers (LiveViews, workers, controllers).

The SearchIndex schema, Record schema, Similarity module, TracklistPdf, and Batch sub-modules stay as-is. Only records.ex itself is being split.

Acceptance Criteria

  • #1 Records.Search, Records.Import, and Records.Enrichment modules exist with focused responsibilities
  • #2 Public Records module re-exports all previously-public functions through delegation
  • #3 All callers (LiveViews, workers, controllers, tests) continue to work without changes to their import/alias lines
  • #4 Full test suite passes with no regressions
  • #5 @moduledoc for each new module explains its responsibility