Skip to content

feat(bot): enforce artist and source diversity caps in autoplay selection - #273

Merged
LucasSantana-Dev merged 1 commit into
mainfrom
feat/recommendation-diversity-constraints
Mar 15, 2026
Merged

LucasSantana-Dev merged 1 commit into
mainfrom
feat/recommendation-diversity-constraints

Conversation

@LucasSantana-Dev

Copy link
Copy Markdown
Owner

Summary

Closes #265

  • Artist diversity: selectDiverseCandidates now uses a Map<string, number> counter instead of a Set — up to MAX_TRACKS_PER_ARTIST (2) tracks per artist are allowed, preventing a single artist from being excluded after one match while still ensuring variety.
  • Source diversity: Added sourceCount tracking with MAX_TRACKS_PER_SOURCE (3) cap so no single platform (YouTube, Spotify, SoundCloud) dominates the autoplay queue.
  • Scoring fix: Replaced the same-source bonus (+0.1) with a same-source penalty (−0.15) in calculateRecommendationScore, so cross-platform candidates are now preferred.
  • Config extension: RecommendationConfig gains maxTracksPerArtist and maxTracksPerSource fields (defaults 2 and 3) for future tunability via MusicRecommendationService.

Tests

  • 2 new tests in queueManipulation.spec.ts covering artist-cap and source-cap behaviour
  • All 358 bot tests pass (60 suites)

…tion

- Replace hardcoded artist cap of 1 with configurable Map-based counting
  (MAX_TRACKS_PER_ARTIST=2) in selectDiverseCandidates so up to 2 tracks
  per artist can appear while still ensuring variety
- Add source diversity cap (MAX_TRACKS_PER_SOURCE=3) to prevent a single
  platform from dominating the autoplay queue
- Replace same-source bonus (+0.1) in calculateRecommendationScore with a
  same-source penalty (-0.15) to prefer cross-platform variety
- Extend RecommendationConfig with maxTracksPerArtist and maxTracksPerSource
  fields (defaults 2 and 3) for future tunability
- Add 2 new tests covering artist-cap and source-cap behaviour (358 pass)

Closes #265
@vercel

vercel Bot commented Mar 15, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lucky Ready Ready Preview, Comment Mar 15, 2026 3:56pm

Request Review

@coderabbitai

coderabbitai Bot commented Mar 15, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@LucasSantana-Dev has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ded5d84a-ef55-4fff-a53f-ef8bf1c2c08c

📥 Commits

Reviewing files that changed from the base of the PR and between 96be1da and b03a1c8.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • packages/bot/src/services/musicRecommendation/index.ts
  • packages/bot/src/services/musicRecommendation/types.ts
  • packages/bot/src/utils/music/queueManipulation.spec.ts
  • packages/bot/src/utils/music/queueManipulation.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/recommendation-diversity-constraints
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@netlify

netlify Bot commented Mar 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for regal-bunny-0c8efe ready!

Name Link
🔨 Latest commit b03a1c8
🔍 Latest deploy log https://app.netlify.com/projects/regal-bunny-0c8efe/deploys/69b6d689ea3fc60009a34d16
😎 Deploy Preview https://deploy-preview-273--regal-bunny-0c8efe.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
41.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

@LucasSantana-Dev
LucasSantana-Dev merged commit 4fbff87 into main Mar 15, 2026
15 checks passed
@LucasSantana-Dev
LucasSantana-Dev deleted the feat/recommendation-diversity-constraints branch March 15, 2026 20:16
LucasSantana-Dev added a commit that referenced this pull request May 13, 2026
#273)

- Replace hardcoded artist cap of 1 with configurable Map-based counting
  (MAX_TRACKS_PER_ARTIST=2) in selectDiverseCandidates so up to 2 tracks
  per artist can appear while still ensuring variety
- Add source diversity cap (MAX_TRACKS_PER_SOURCE=3) to prevent a single
  platform from dominating the autoplay queue
- Replace same-source bonus (+0.1) in calculateRecommendationScore with a
  same-source penalty (-0.15) to prefer cross-platform variety
- Extend RecommendationConfig with maxTracksPerArtist and maxTracksPerSource
  fields (defaults 2 and 3) for future tunability
- Add 2 new tests covering artist-cap and source-cap behaviour (358 pass)

Closes #265

This branch was successfully deployed

1 active deployment
Preview — b03a1c84 Deployed Mar 15, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(bot): recommendation diversity constraints for autoplay

1 participant