feat(valuation): link the searched Spotify artist for a populated roster (chat#1881 P0)

Merged
SW
3mo ago
+153-8

What

Item 1b (the P0 lead domino) of chat#1881. Fixes the empty-roster bug for marketing-funnel signups: they claim a catalog but land on an empty /artists.

Root cause

POST /api/valuation → createSnapshotCatalog attached only the ISRC → song_artists canonical artist (attachCanonicalArtistToAccount). That graph resolves nothing when a signup's songs aren't yet ingested into song_artists, so no roster artist was created — the account landed empty.

Fix

  • createSnapshotCatalog now returns the attached canonical artist id (or null).
  • runValuationHandler falls back to a new best-effort linkSearchedArtistToAccount only when that id is null — so no duplicate artist when the graph works, but a guaranteed roster artist when it doesn't. It links the searched Spotify artist (name + Spotify social), the server-side, account-scoped replacement for marketing's old client-side linkArtistToAccount.
  • A failed link never fails the valuation (best-effort, mirrors attachCanonicalArtistToAccount).

No response-shape change ({ status, catalog, band, songs_measured } unchanged) — this is a roster-side effect.

Tests (TDD red→green)

  • linkSearchedArtistToAccount 4/4 (creates+links+attaches social; null on unresolved Spotify artist; null on failed create; never throws).
  • createSnapshotCatalog updated to assert the new attachedArtistId return (+ a null-graph case). Full lib/valuation + lib/catalog suites 76/76. tsc --noEmit adds 0 errors to my files (repo baseline unchanged); eslint clean.

Verification gate

End-to-end (a real funnel signup → /api/valuation → non-empty /artists) is preview-verification pending — that's the gate before merge.

Sequencing

Contract-first: docs note (item 1a) → this. Unblocks marketing's endpoint swap (item 1c) and the P1 roster/socials work. Tracking: chat#1881.


Summary by cubic

Guarantees a populated roster for funnel signups by linking the searched Spotify artist when the ISRC→song_artists graph resolves no artist. Addresses chat#1881 P0 to prevent users landing on an empty /artists after claiming a catalog.

  • Bug Fixes
    • createSnapshotCatalog now returns attachedArtistId to signal whether a canonical artist was linked.
    • runValuationHandler falls back to linkSearchedArtistToAccount when attachedArtistId is null, creating the searched artist and attaching its Spotify social; best-effort and does not fail the valuation.
    • No API response shape changes.

Summary by CodeRabbit

  • New Features

    • Improved artist linking during valuation when catalog data cannot identify a canonical artist.
    • Searched Spotify artists can now be linked directly to an account as a fallback.
    • Catalog creation now tracks the artist successfully attached during processing.
  • Reliability

    • Artist linking failures are handled gracefully without interrupting valuation results.