improvement(billing): replace daily refresh credits with weekly refresh

Merged
IC
2mo ago
+338-263

Summary

  • Replace daily refresh credits with weekly refresh: Pro +2,000 credits/week, Max +4,000 credits/week (team plans scale per seat; legacy pro/team plans take the Pro amount; enterprise unchanged with no refresh)
  • Refresh stays computed at read time from the usage ledger — buckets are now 7-day windows anchored at billing period start; no cron, no env vars, no DB migration
  • Replace the uniform DAILY_REFRESH_RATE with fixed per-tier weeklyRefreshCredits and a getPlanWeeklyRefreshDollars resolver shared by the billing math and every display surface
  • Update all copy: upgrade cards, pricing comparison table, upgrade emails, docs, comparison content
  • Surface the allowance as a subtle "Weekly refresh" row in Settings → Subscription (paid non-enterprise plans only)

Type of Change

  • Improvement

Testing

  • lib/billing suite passes (672 tests) including the rewritten weekly-refresh tests: weekly cap shared across days, unprorated partial final week, boundary bucketing, straggler clamping, seat scaling
  • Verified the SQL bucketing against a real Postgres database: exact 7-day window boundary, partial-final-week allowance, straggler clamping into edge weeks, pooled team seats, billing-period scoping, and that every plan resolves to its advertised amount
  • lint, check:api-validation:strict, check:migrations (no new migrations — schema change is comment-only), and the full audit suite pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)