Define observed cost values and aggregation

This commit is contained in:
2026-11-22 18:24:33 +00:00
parent 3d82cad2c9
commit 6ed0e037c4
13 changed files with 215 additions and 2 deletions

30
cost.go Normal file
View File

@@ -0,0 +1,30 @@
package promptkit
import "go.maximumdirect.net/promptkit/internal/domain"
// CostSource identifies how an observed USD cost was supplied.
type CostSource string
const (
CostSourceNone CostSource = ""
CostSourceProvider CostSource = "provider"
CostSourceConfiguredZero CostSource = "configured_zero"
CostSourceMixed CostSource = "mixed"
)
// ObservedCost reports an available USD subtotal and its coverage and source.
// Complete describes coverage of dispatched attempts, not billing verification.
type ObservedCost struct {
Value float64 `json:"value"`
Known bool `json:"known"`
Complete bool `json:"complete"`
Source CostSource `json:"source"`
}
func fromDomainCost(value domain.ObservedCost) ObservedCost {
return ObservedCost{Value: value.Value, Known: value.Known, Complete: value.Complete, Source: CostSource(value.Source)}
}
func toDomainCost(value ObservedCost) domain.ObservedCost {
return domain.ObservedCost{Value: value.Value, Known: value.Known, Complete: value.Complete, Source: domain.CostSource(value.Source)}
}