From eadb2ffe85c43cf6fc741c9823cd28eedb4a844c Mon Sep 17 00:00:00 2001 From: Chia Date: Wed, 5 Aug 2026 22:01:29 +1200 Subject: feat: harden prepaid billing and commercial operations --- internal/domain/types.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'internal/domain') diff --git a/internal/domain/types.go b/internal/domain/types.go index b1decc9..94e56c1 100644 --- a/internal/domain/types.go +++ b/internal/domain/types.go @@ -32,7 +32,27 @@ type Route struct { type Model struct { ID string + DisplayName string + Description string OwnedBy string + InputModalities []string + OutputModalities []string + ContextWindow int64 + MaxOutputTokens int64 + Capabilities []string + Regions []string + Lifecycle string + ReleasedAt *time.Time + DeprecatedAt *time.Time + RetiredAt *time.Time + ReplacementModel string + Aliases []string + AllowedTenantIDs map[string]struct{} + AllowedKeyIDs map[string]struct{} + PriceVersionID string + PriceVersion int + PriceCurrency string + PriceEffectiveFrom time.Time InputPriceMicrosPerMillion int64 OutputPriceMicrosPerMillion int64 CacheReadPriceMicrosPerMillion int64 @@ -40,6 +60,20 @@ type Model struct { Routes []Route } +func (m Model) Allows(principal Principal) bool { + if len(m.AllowedTenantIDs) > 0 { + if _, ok := m.AllowedTenantIDs[principal.TenantID]; !ok { + return false + } + } + if len(m.AllowedKeyIDs) > 0 { + if _, ok := m.AllowedKeyIDs[principal.KeyID]; !ok { + return false + } + } + return true +} + type Usage struct { InputTokens int64 `json:"input_tokens,omitempty"` OutputTokens int64 `json:"output_tokens,omitempty"` @@ -65,6 +99,7 @@ type UsageEvent struct { StartedAt time.Time `json:"started_at"` DurationMS int64 `json:"duration_ms"` Usage Usage `json:"usage"` + UsageReported bool `json:"usage_reported"` } // LimitPolicy is the immutable runtime view of a project's commercial limits. -- cgit v1.2.3