Budgets & Policies

Budgets are scoped across global, tenant, user, cost center, provider, model, agent, and purpose dimensions. Policies add declarative actions: block, require_approval, downgrade, throttle, and queue.

BudgetResolver

Resolves the applicable budget tree for the envelope context and period.

PolicyEngine

Evaluates kill switches, hard budgets, and policy DSL rules.

Approvals

Converts selected high-cost calls into a pending approval workflow.

Enforcement behavior

HTTP 402

Hard blocks throw BudgetExceededException and surface as HTTP 402 with a generic public message. Internal reason details stay on the exception for logging and audit.

Policy lifecycle

  1. Create a rule
    Define the scope match and optional minimum-cost or model criteria.
  2. Validate
    Use /policies/validate before storing a rule.
  3. Simulate
    Use /policies/{id}/simulate against sample context.
  4. Audit
    Governance model mutations are recorded in ai_finops_audit_log.