Build one sync plan for dry-run reporting and real execution #49

Closed
opened 2026-09-05 22:42:24 +00:00 by tophattedcat · 0 comments
Owner

Problem

sync_playlists separately implements item-list construction, missing-track collection, counters, and change detection in dry-run and normal execution. Policy changes therefore need to be made twice.

Meanwhile _resolve_tracks performs persistent beets writes during what appears to be a calculation phase, making the boundary between planning and mutation difficult to audit.

Proposed change

Introduce a small, explicit desired-operation representation computed once. Dry-run renders that plan; execution applies it. Keep the abstraction proportionate to this plugin rather than introducing a general workflow framework.

Acceptance criteria

  • One path determines association decisions, desired item IDs, missing tracks, counters, memberships, and pruning intent.
  • Building the plan does not mutate beets, plugin state, or playlistmanager.
  • Dry-run output describes the same decisions real execution applies.
  • Preserve duplicate occurrences, skipped tracks, target validation, and independent-store failure recovery.
  • Add parity coverage for representative dry-run and execution scenarios.

References: beetsplug/appleplaylists/sync.py:26-47, sync.py:141-202. Audit finding 8 (maintainability). Related to batch matching and state transaction improvements, but focuses on shared planning/execution structure.

## Problem sync_playlists separately implements item-list construction, missing-track collection, counters, and change detection in dry-run and normal execution. Policy changes therefore need to be made twice. Meanwhile _resolve_tracks performs persistent beets writes during what appears to be a calculation phase, making the boundary between planning and mutation difficult to audit. ## Proposed change Introduce a small, explicit desired-operation representation computed once. Dry-run renders that plan; execution applies it. Keep the abstraction proportionate to this plugin rather than introducing a general workflow framework. ## Acceptance criteria - One path determines association decisions, desired item IDs, missing tracks, counters, memberships, and pruning intent. - Building the plan does not mutate beets, plugin state, or playlistmanager. - Dry-run output describes the same decisions real execution applies. - Preserve duplicate occurrences, skipped tracks, target validation, and independent-store failure recovery. - Add parity coverage for representative dry-run and execution scenarios. References: `beetsplug/appleplaylists/sync.py:26-47`, `sync.py:141-202`. Audit finding 8 (maintainability). Related to batch matching and state transaction improvements, but focuses on shared planning/execution structure.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
coop/beets-appleplaylists#49
No description provided.