1 Allowance
Virgil edited this page 2026-02-19 18:36:59 +00:00

Allowance Management

Overview

The allowance system tracks AI usage quotas per workspace, preventing overuse and enabling fair resource distribution across tenants.

Data Model

type Allowance struct {
    WorkspaceID string
    Model       string
    Used        int
    Limit       int
    ResetAt     time.Time
}

Operations

Tracking

allowance_service.go provides persistence and enforcement:

  • Check: Verify remaining quota before making AI calls
  • Consume: Decrement quota after successful completion
  • Reset: Periodic quota reset (daily/monthly)
  • Report: Current usage statistics

Per-Workspace Isolation

Each workspace has independent quotas. The BelongsToWorkspace pattern from core/php-tenant is mirrored here — allowances are automatically scoped to the current workspace context.

Multi-Model Support

Quotas can be tracked per model (Opus, Sonnet, Haiku) or as a combined pool, depending on configuration.

Embedded Resources

embed.go provides embedded prompt templates via Go's embed package:

  • prompts/commit.md — Template for AI-assisted commit message generation