summaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-05-26 20:27:36 +0000
committerClaude <noreply@anthropic.com>2026-05-26 20:27:36 +0000
commit39f74dbbc7adca0e2058112408bb99694deefcaf (patch)
treefb657954c1eba928567403b0e320b976e23f734a /internal/config/config.go
parent561915c5182c3fb39cd6a8b6613c489b35b7c1bf (diff)
feat(budget,storage,config): per-provider spend accounting substrate (Phase 6)
Adds the budget accountant foundation: - storage: a per-execution `agent` column (additive migration, populated by the dispatcher) and SpendByProviderSince(since), summing cost_usd per provider in a window. Accurate attribution survives a task running on different providers across retries. - internal/budget: Accountant over a SpendSource + Limits, exposing Headroom (remaining/fraction per provider), Allow (would estCost breach the cap), and All (one query, sorted). Unconfigured/local providers are unlimited. - config: a [budget] section (window + provider_5h_usd map). No default cap — gating is opt-in by configuring limits. Fully unit-tested; dispatcher gating and the API/UI surface follow. https://claude.ai/code/session_01SESwn7kQ7oP62trWw6pc39
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 94f3ec7..58de95c 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -69,6 +69,17 @@ type Config struct {
VAPIDEmail string `toml:"vapid_email"`
ClaudeConfigDir string `toml:"claude_config_dir"`
LocalModel LocalModel `toml:"local_model"`
+ Budget BudgetConfig `toml:"budget"`
+}
+
+// BudgetConfig configures rolling per-provider spend caps. With no providers
+// set, budget gating is disabled (nothing is blocked) — there is intentionally
+// no default cap; the user must opt in by configuring limits.
+type BudgetConfig struct {
+ // Window is the rolling lookback duration (e.g. "5h"); defaults to 5h.
+ Window string `toml:"window"`
+ // Provider5hUSD maps a provider (claude/gemini) to its USD cap within Window.
+ Provider5hUSD map[string]float64 `toml:"provider_5h_usd"`
}
func Default() (*Config, error) {