Task
Back the usage half of Entitlements (remaining / consume) with per-plan AI token allowances.
Actions
- Add a
token_allowance and a monthly reset period to each plan.
- Create an
ai_usage_counters table (user_id, period_start, tokens_used); this storage lives in the cloud plugin, never core.
- Implement
remaining('ai_tokens') as allowance minus current-period usage, and consume('ai_tokens', n) as an idempotent increment keyed by chat message id, inside the cloud Entitlements implementation.
Acceptance
- A user over their allowance gets a quota-exceeded response from
POST /api/v1/ai/chat.
- The counter equals the summed usage stored in
ChatMessage.result['usage'] and rolls over monthly.
- A deployment with the cloud plugin disabled stays unlimited.
Task
Back the usage half of
Entitlements(remaining/consume) with per-plan AI token allowances.Actions
token_allowanceand a monthly reset period to each plan.ai_usage_counterstable (user_id,period_start,tokens_used); this storage lives in the cloud plugin, never core.remaining('ai_tokens')as allowance minus current-period usage, andconsume('ai_tokens', n)as an idempotent increment keyed by chat message id, inside the cloudEntitlementsimplementation.Acceptance
POST /api/v1/ai/chat.ChatMessage.result['usage']and rolls over monthly.