fix: super admins bypass AI build quota limits

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-02-24 23:35:53 -05:00
parent 9dc667eb3c
commit a6abd23727
2 changed files with 9 additions and 1 deletions

View File

@@ -85,12 +85,14 @@ async def check_ai_quota(
account_id: UUID,
db: AsyncSession,
billing_anchor: Optional[datetime] = None,
is_super_admin: bool = False,
) -> tuple[bool, dict]:
"""Check if user can make an AI generation.
Returns (allowed, quota_status_dict).
Monthly counts only rows with counts_toward_quota=True.
Daily counts only rows with generation_type in ('scaffold', 'branch_detail').
Super admins bypass all limits.
"""
plan = await get_user_plan(account_id, db)
monthly_limit, daily_limit = await _get_effective_limits(account_id, plan, db)
@@ -120,6 +122,10 @@ async def check_ai_quota(
allowed = True
deny_reason = None
if is_super_admin:
# Super admins bypass all limits
monthly_limit = None
daily_limit = None
if monthly_limit is not None and monthly_count >= monthly_limit:
allowed = False
deny_reason = "monthly"