refactor(quota): separate rate limiting from account availability

Remove the persistent Cooldown state and cooldown_until/availability_reason
columns; rate limiting (429/503) now lives entirely in provider quota data
with projected window rolling, while availability carries only terminal or
intervention-required states (QuotaExhausted for 402, worker auto-recovers
on quota reset). xAI migrated to the same model (runtime cooldown via Redis,
no persistent state). Frontend derives 限流中 from quota window limitReached.

Align quota window parsing with the official codex schema: drop the invented
monthly_limit/spend_control windows, add the top-level code_review_rate_limit
window, prefer upstream limit_name for display labels, and keep duration
guessing only for grouping.

Also fix: account directory degrades one failing quota to an empty projection
instead of failing the whole page; dashboard rate_limited bucket SQL; fake
store Mutex re-entrancy deadlock; remove dead tokenRefreshing field.

Migration 0002 drops cooldown columns and rewrites the availability CHECK.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Zyy
2026-08-03 00:13:56 +08:00
co-authored by Claude Fable 5
parent 3d1e33558a
commit cf03c56cfa
61 changed files with 1007 additions and 2117 deletions
+1 -1
View File
@@ -7,6 +7,7 @@ export interface AccountQuotaWindow {
labelDisplay: string
usedPercent: number | null
usedPercentDisplay: string
limitReached: boolean
localUsage?: unknown
resetAtDisplay: string
}
@@ -102,7 +103,6 @@ export interface Account {
hasRefreshToken: boolean
status: string
displayStatus: string
tokenRefreshing: boolean
availability: string
enabled: boolean
accessTokenExpiresAt: string | null
+1
View File
@@ -144,6 +144,7 @@ export interface DashboardAccountUsage {
export interface DashboardPoolSummary {
total: number
active: number
rateLimited: number
expired: number
quotaExhausted: number
refreshing: number | null