Documentation
¶
Overview ¶
Package usagenorm validates and normalizes provider token-usage wire values.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddTokenCounts ¶
func AddTokenCounts(field Field, left, right content.TokenCount) (content.TokenCount, error)
AddTokenCounts adds normalized counts without wrapping.
func RequireEqual ¶
func RequireEqual(field Field, reported, calculated content.TokenCount) error
RequireEqual rejects contradictory reported and calculated values.
func SubtractTokenCounts ¶
func SubtractTokenCounts(field Field, total, first, second content.TokenCount) (content.TokenCount, error)
SubtractTokenCounts removes two disjoint components from a reported total.
Types ¶
type Count ¶
type Count struct {
// contains filtered or unexported fields
}
Count preserves whether a JSON count field was absent and defers semantic validation until the owning codec supplies its typed field identity.
func (Count) OptionalTokenCount ¶
func (c Count) OptionalTokenCount(field Field) (content.TokenCount, error)
OptionalTokenCount returns zero when an optional usage-detail field is absent or explicitly null. Every present non-null value retains TokenCount's strict numeric validation.
func (Count) TokenCount ¶
func (c Count) TokenCount(field Field) (content.TokenCount, error)
TokenCount returns zero for an absent count and rejects malformed or negative explicit values before converting an int64 to TokenCount.
func (*Count) UnmarshalJSON ¶
UnmarshalJSON captures one syntactically valid JSON value without losing explicit null or numeric representation details.