Add Channels: the last social pillar with nothing built before this
Per the original vision doc, Channels are the creator hub - users host
Vibe Sets, Audio Stories, and remix showcases. This pillar had zero
model, router, or definition beyond one paragraph before this commit.
New models (src/core/database.py): Channel, ChannelFollow, VibeSet +
VibeSetTrack (a curated, ordered song collection - same shape as the
existing Playlist/PlaylistTrack pair, owned by a channel instead of a
user), AudioStory (ephemeral - expires_at defaults to 24h from
creation; expired stories are filtered out of the "active" listing
rather than deleted, the same soft-expiry pattern this codebase
already uses for DiscoveredSong's 24h history), and ChannelShowcase
(pins an existing Post - i.e. an actual remix from the tree - to a
channel).
New router (src/api/routers/channels.py): create/list channels, get
channel detail with follower count, follow/unfollow (idempotent),
create/list vibe sets + get one with its tracks, create/list stories,
showcase/list showcased posts. Vibe sets/stories/showcase are owner-
only (403 for anyone else), matching the "creator hub" framing -
followers can browse, only the owner publishes.
Found and fixed a real SQLAlchemy bug while testing create_vibe_set:
returning an ORM object after a *second* db.commit() (for the
VibeSetTrack rows, after the VibeSet itself was already committed and
refreshed) serialized as an empty {} with no error - SQLAlchemy's
expire_on_commit default re-expires already-loaded objects on every
commit, not just the one that touched them. A final db.refresh()
right before returning fixes it. Caught by an actual assertion on the
response body, not just a status-code check.
Also added a route-ordering regression test: GET /channels/vibe-sets/
{id} must be registered before the generic /{channel_id} catch-all,
or FastAPI matches "vibe-sets" against {channel_id}:int first and
422s instead of ever reaching the real route.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BCxXmJVvDFJVHTUi4QgNzi