fix(billing): surface quota saturation events for admin auditing

Thread int32 saturation clamps from tiered settlement and video task
recompute into the consume/task logs under admin_info, so oversized or
malformed billing inputs stay auditable. Clamp negative audio duration
before token conversion and gate the saturation UI markers on admin.
This commit is contained in:
CaIon
2026-07-07 12:20:07 +08:00
parent c9943d37ad
commit bae799ccb1
32 changed files with 710 additions and 104 deletions
+7
View File
@@ -3,6 +3,8 @@ package billingexpr
import (
"crypto/sha256"
"fmt"
"github.com/QuantumNous/new-api/common"
)
type RequestInput struct {
@@ -57,6 +59,11 @@ type TieredResult struct {
ActualQuotaAfterGroup int `json:"actual_quota_after_group"`
MatchedTier string `json:"matched_tier"`
CrossedTier bool `json:"crossed_tier"`
// Clamp records an int32 saturation event during quota conversion so the
// caller can surface it on the consume log for admin auditing. Nil when no
// clamping occurred. Not serialized: the marker is attached separately via
// the shared quota-saturation audit path.
Clamp *common.QuotaClamp `json:"-"`
}
// ExprHashString returns the SHA-256 hex digest of an expression string.