feat(valuation): link the searched Spotify artist for a populated roster (chat#1881 P0)
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
createSnapshotCatalognow returns the attached canonical artist id (ornull).runValuationHandlerfalls back to a new best-effortlinkSearchedArtistToAccountonly when that id isnull— 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-sidelinkArtistToAccount.- 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)
linkSearchedArtistToAccount4/4 (creates+links+attaches social; null on unresolved Spotify artist; null on failed create; never throws).createSnapshotCatalogupdated to assert the newattachedArtistIdreturn (+ a null-graph case). Fulllib/valuation+lib/catalogsuites 76/76.tsc --noEmitadds 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
createSnapshotCatalognow returnsattachedArtistIdto signal whether a canonical artist was linked.runValuationHandlerfalls back tolinkSearchedArtistToAccountwhenattachedArtistIdis 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.