Skip to content

Promote test → main: remove Songstats quota ledger + budget gate (#674)#676

Merged
sweetmantech merged 5 commits into
mainfrom
test
Jun 16, 2026
Merged

Promote test → main: remove Songstats quota ledger + budget gate (#674)#676
sweetmantech merged 5 commits into
mainfrom
test

Conversation

@sweetmantech

@sweetmantech sweetmantech commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Promotes test to main. Net change vs main: #674 — removes the local quota ledger + budget gate (chat#1797 bullet 2, code half). Songstats is the rate authority; the drain no longer stalls on a stale ledger.

(#673 backoff/logging and #671 measurement-jobs card gate are already on main from #675; included here as part of the test branch history.)

Follow-up: apply recoupable/database#35 (drop songstats_quota_ledger table) AFTER this deploys.


Summary by cubic

Promotes test to main and removes the local Songstats quota ledger and budget gate so the backfill relies on Songstats' own rate limiting and no longer stalls on a stale ledger.

  • Refactors

    • Deleted songstats_quota_ledger insert/select utilities, getBackfillBudgetStep, and related tests.
    • backfillTrackStep: removed quota writes and hitsSpent; now returns { ok, deferred? } and still marks rows done or pending.
    • songstatsBackfillWorkflow: removed budget gating; always claims up to 25, stops on a defer (releases remaining claims), drains until no claimable rows; result now returns { backfilled, terminal, deferred }.
  • Migration

    • Drop the songstats_quota_ledger table after deploy.

Written for commit 5f45946. Summary will update on new commits.

Review in cubic

…ckfill drain (#671)

Two chat#1796 refinements on the historical (Songstats) path:

1. Free-tier card-on-file link. The gate was issuing the paid subscription
   checkout ($99/mo after a 30-day trial). New createCardOnFileSession uses
   Stripe Checkout `mode: "setup"` — collects a card for $0, no subscription,
   no Stripe product. The account then pays only for metered usage via credits.

2. Instant drain. After enqueuing a historical job, fire-and-forget
   start(songstatsBackfillWorkflow) so the backfill begins immediately instead
   of waiting up to 24h for the cron. Safe by reuse: the workflow's budget gate
   (limit − reserve − rolling-30d ledger) caps it to the Songstats quota and
   SKIP LOCKED prevents double-claiming with the daily cron, which stays as the
   backstop. Only kicks when something was actually enqueued.

26 new/updated unit tests; research+stripe+workflows suite 453 green; tsc/lint/format clean.
…t#1797) (#673)

Pacing/backoff + per-step logging for the Songstats backfill drain (chat#1797 bullets 1 & 3). Bounded exponential backoff (fetchSongstatsWithBackoff, 502/503/504/408/429), defer-to-pending past the bound with claimed-batch release, per-step + per-batch logging.
…97) (#674)

Bullet 2 of chat#1797 (code half). Songstats is the rate authority — removes getBackfillBudgetStep, the budget gate, and insertSongstatsQuotaLedger/selectSongstatsQuotaSpent. The drain now claims+processes regardless of the ledger (un-stalls the backfill); the songstats_quota_ledger table is dropped in recoupable/database#35 (apply AFTER this deploys).
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
api Building Building Preview Jun 16, 2026 10:15pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@sweetmantech, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 6 minutes and 5 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7294b181-abfb-4989-9004-ed6a0a05552b

📥 Commits

Reviewing files that changed from the base of the PR and between 4a846e5 and 5f45946.

⛔ Files ignored due to path filters (5)
  • app/workflows/__tests__/backfillTrackStep.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by app/**
  • app/workflows/__tests__/getBackfillBudgetStep.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by app/**
  • app/workflows/__tests__/songstatsBackfillWorkflow.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by app/**
  • lib/supabase/songstats_quota_ledger/__tests__/insertSongstatsQuotaLedger.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/supabase/songstats_quota_ledger/__tests__/selectSongstatsQuotaSpent.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (5)
  • app/workflows/backfillTrackStep.ts
  • app/workflows/getBackfillBudgetStep.ts
  • app/workflows/songstatsBackfillWorkflow.ts
  • lib/supabase/songstats_quota_ledger/insertSongstatsQuotaLedger.ts
  • lib/supabase/songstats_quota_ledger/selectSongstatsQuotaSpent.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

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.

@sweetmantech sweetmantech merged commit 40e2ab0 into main Jun 16, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant