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:
@@ -143,6 +143,15 @@ function formatRatio(ratio: number | undefined): string {
|
||||
return ratio.toFixed(4)
|
||||
}
|
||||
|
||||
function quotaSaturationKindLabel(
|
||||
kind: 'overflow' | 'underflow' | 'nan',
|
||||
t: (key: string) => string
|
||||
): string {
|
||||
if (kind === 'overflow') return t('Overflow')
|
||||
if (kind === 'underflow') return t('Underflow')
|
||||
return t('Invalid (NaN)')
|
||||
}
|
||||
|
||||
function BillingBreakdown(props: {
|
||||
log: UsageLog
|
||||
other: LogOtherData
|
||||
@@ -704,6 +713,41 @@ export function DetailsDialog(props: DetailsDialogProps) {
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{/* Quota saturation marker (admin only) */}
|
||||
{props.isAdmin && other?.admin_info?.quota_saturation && (
|
||||
<DetailSection
|
||||
icon={<AlertTriangle className='size-3.5' aria-hidden='true' />}
|
||||
label={t('Quota clamped')}
|
||||
variant='danger'
|
||||
>
|
||||
<p className='mb-1 text-xs wrap-break-word'>
|
||||
{t('Quota saturation protection triggered')}
|
||||
</p>
|
||||
<DetailRow
|
||||
label={t('Kind')}
|
||||
value={quotaSaturationKindLabel(
|
||||
other.admin_info.quota_saturation.kind,
|
||||
t
|
||||
)}
|
||||
/>
|
||||
<DetailRow
|
||||
label={t('Original value')}
|
||||
value={String(other.admin_info.quota_saturation.original)}
|
||||
mono
|
||||
/>
|
||||
<DetailRow
|
||||
label={t('Clamped to')}
|
||||
value={String(other.admin_info.quota_saturation.clamped)}
|
||||
mono
|
||||
/>
|
||||
<DetailRow
|
||||
label={t('Operation')}
|
||||
value={other.admin_info.quota_saturation.op}
|
||||
mono
|
||||
/>
|
||||
</DetailSection>
|
||||
)}
|
||||
|
||||
{/* Reject reason (admin only) */}
|
||||
{props.isAdmin && other?.reject_reason && (
|
||||
<DetailSection
|
||||
|
||||
Reference in New Issue
Block a user