Collect costs for dispatched model attempts

This commit is contained in:
2026-11-22 18:27:01 +00:00
parent cd0e1f5d39
commit 81a2a7591d
9 changed files with 129 additions and 6 deletions

View File

@@ -41,6 +41,25 @@ func TestGroupTerminalAccounting(t *testing.T) {
}
}
func TestGroupCostCoverageIsIndependentOfTerminalCoverage(t *testing.T) {
var group Group
if got := group.Snapshot().CostUSD; got != (domain.ObservedCost{Known: true, Complete: true}) {
t.Fatalf("empty=%+v", got)
}
group.Observe(domain.ExecutionEvent{Kind: domain.ExecutionStarted, RunID: "pending"})
if got := group.Snapshot().CostUSD; got != (domain.ObservedCost{}) {
t.Fatalf("pending=%+v", got)
}
charge := domain.ObservedCost{Value: .25, Known: true, Complete: true, Source: domain.CostSourceProvider}
terminal := domain.ExecutionEvent{Kind: domain.ExecutionFinished, RunID: "done", CostUSD: charge}
group.Observe(terminal)
group.Observe(terminal)
got := group.Snapshot()
if got.TerminalCoverageComplete || got.CostUSD != charge {
t.Fatalf("snapshot=%+v", got)
}
}
func TestGroupConcurrentSnapshots(t *testing.T) {
var group Group
var wg sync.WaitGroup