Spending limits for agent payment operations.
Defines per-request, per-session (sliding window), and lifetime caps.
Used by the Ledger to enforce budget constraints before signing payments.
Example
policy = %SpendingPolicy{
per_request_max: Decimal.new("1.00"),
session_max: Decimal.new("10.00"),
session_window_ms: 3_600_000,
lifetime_max: Decimal.new("100.00"),
currency: "USDC",
approved_domains: ["api.example.com"],
require_confirmation_above: Decimal.new("5.00")
}
Summary
Functions
Create a policy with sensible defaults for development.
Check if a domain is approved under this policy.
Check if a payment amount requires user confirmation.
Create an unrestricted policy (for testing only).
Types
Functions
@spec dev() :: t()
Create a policy with sensible defaults for development.
Check if a domain is approved under this policy.
Returns true if approved_domains is nil (all domains allowed)
or if the domain matches an entry in the list. Matching is
case-insensitive and respects domain boundaries -- evil-example.com
does not match example.com, but api.example.com does.
Empty strings in the approved list are ignored. An empty domain string never matches.
Check if a payment amount requires user confirmation.
@spec unrestricted() :: t()
Create an unrestricted policy (for testing only).