release: capture-path resilience — 429 backoff, durable mapping retries, ISRC dedupe (test → main)

Merged
SW
6mo ago
+243-70

Promotes #666 (chat#1794): three layered capture-path defenses — in-process Retry-After backoff in getTracks, the fetch/map step split with memoized actor payloads + RetryableError escalation, and the in-batch ISRC dedupe that was the real killer of the 570-album run.

Scale-verified on preview: the 150-album batch went 67/1,220 → 1,164/1,220 (95%) across the fix (results tables on #666). Content delta vs main: 12 files, +243/−70.

After this lands: the full 570-album portfolio re-snapshot completes chat#1794's data item.

🤖 Generated with Claude Code


Summary by cubic

Improves playcount capture reliability by adding Spotify 429 backoff, splitting chunk processing into memoized fetch and durable map+write steps, and deduping ISRCs to prevent in-batch upsert conflicts. In preview, a 150‑album batch rose from 67/1,220 to 1,164/1,220 (95%).

  • Bug Fixes

    • Added Retry-After backoff in getTracks (3 retries); throws SpotifyRateLimitError on exhaustion; non-429 errors return an error result.
    • Dedupes songs by ISRC before upsertSongs; keeps both track-id mappings; mapUnmappedAlbumTracks rethrows rate-limit errors for workflow handling.
  • Refactors

    • Replaced captureSnapshotChunkStep with fetchChunkStep (memoized actor result) and mapAndWriteChunkStep (map + write; escalates to RetryableError with a 30s retryAfter).
    • Updated snapshot workflow to the two-step flow; added targeted tests for each step and the 429 logic.