Context
Follow-up to the providers UI 3-screen refactor (commit b1eb991) which shipped a placeholder /providers/quota view.
Current state
/providers/quota exists and renders a mock summary table
- Shows: provider kind, connection count, configured models, active/not-configured status
- Banner: "Per-provider quota tracking is in development. Each provider exposes quota differently."
Goal
Replace the mock data with REAL per-provider quota data.
Why this is hard
Each provider exposes quota differently:
- OpenAI: account-level hard limits in dashboard, per-organization tier (free/team/enterprise). No public quota API; usage comes from response headers.
- Anthropic: workspace-level limits in console. No public quota API.
- Google Gemini:
generateContent returns usageMetadata with prompt/candidate token counts, no rate-limit info in body.
- Groq: returns rate limit headers (
x-ratelimit-remaining-requests, x-ratelimit-remaining-tokens).
- Ollama: no quota (self-hosted), view should degrade gracefully.
Suggested approach
- Define a
Quota port in rook-core (or extend ProviderPort):
#[async_trait]
pub trait QuotaPort: Send + Sync {
async fn current_usage(&self) -> Result<QuotaSnapshot, CortexError>;
}
- Per-provider implementations wrapping actual usage data:
- HTTP providers: parse rate-limit headers from last response
- Local: return
None or "local/no quota" stub
- Background poller that snapshots every N minutes (similar to health_check)
- Storage layer for historical quota data (extend
audit-sqlite or new quota-sqlite crate)
- Wire to existing
usage_recorder — we already record token counts per request; that's the source of truth for "how much I've used". The quota port would aggregate.
Acceptance
Related
- Spec:
openspec/changes/providers-ui-3-screen-refactor/specs/providers-ui/spec.md REQ-8
- Design:
openspec/changes/providers-ui-3-screen-refactor/design.md section D7
- Code marker:
TODO(issue-XXX) in apps/rook/dashboard/src/views/ProvidersQuotaView.vue
Estimate
Large — 1-2 week piece of work touching 4-5 crates (rook-core, rook-usecases, transport-axum, providers-*, audit-sqlite or new quota-sqlite).
Context
Follow-up to the providers UI 3-screen refactor (commit b1eb991) which shipped a placeholder
/providers/quotaview.Current state
/providers/quotaexists and renders a mock summary tableGoal
Replace the mock data with REAL per-provider quota data.
Why this is hard
Each provider exposes quota differently:
generateContentreturnsusageMetadatawith prompt/candidate token counts, no rate-limit info in body.x-ratelimit-remaining-requests,x-ratelimit-remaining-tokens).Suggested approach
Quotaport inrook-core(or extendProviderPort):Noneor "local/no quota" stubaudit-sqliteor newquota-sqlitecrate)usage_recorder— we already record token counts per request; that's the source of truth for "how much I've used". The quota port would aggregate.Acceptance
/providers/quotashows real per-provider data (not mock)Related
openspec/changes/providers-ui-3-screen-refactor/specs/providers-ui/spec.mdREQ-8openspec/changes/providers-ui-3-screen-refactor/design.mdsection D7TODO(issue-XXX)inapps/rook/dashboard/src/views/ProvidersQuotaView.vueEstimate
Large — 1-2 week piece of work touching 4-5 crates (rook-core, rook-usecases, transport-axum, providers-*, audit-sqlite or new quota-sqlite).