点选题把分类器两次异常说成用户没说清(BUG-722);引擎 429 被压成坏了且重算静默失败(BUG-723);两次 attempt 总预算大于路由 maxDuration(BUG-724)。本单只改归因:classifier_unavailable 请用户重发、busy 分档并可见「这次没有重新比较」、整轮 225s 预算不够则 host fallback。不改计费、分类模型、并发闸门。
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
/**
|
|
* Single definition of rectification Agent wall-clock budgets.
|
|
*
|
|
* Attempt cap stays at 210s (BUG-388). The whole-run budget is strictly less
|
|
* than the route `maxDuration` so a retry cannot start a second attempt that
|
|
* the edge will cut (BUG-059 / BUG-724).
|
|
*/
|
|
export const RECTIFICATION_AGENT_ATTEMPT_TIMEOUT_MS = 210_000;
|
|
export const RECTIFICATION_RUN_BUDGET_MS = 225_000;
|
|
export const RECTIFICATION_MIN_RETRY_ATTEMPT_MS = 20_000;
|
|
export const RECTIFICATION_AGENT_ROUTE_MAX_DURATION_S = 240;
|
|
|
|
export function attemptTimeoutForRemainingBudget(
|
|
remainingMs: number,
|
|
attemptCapMs = RECTIFICATION_AGENT_ATTEMPT_TIMEOUT_MS,
|
|
): number {
|
|
if (!Number.isFinite(remainingMs) || remainingMs <= 0) return 0;
|
|
if (!Number.isFinite(attemptCapMs) || attemptCapMs <= 0) return 0;
|
|
return Math.min(attemptCapMs, remainingMs);
|
|
}
|
|
|
|
export function canStartRetryAttempt(
|
|
remainingMs: number,
|
|
minAttemptMs = RECTIFICATION_MIN_RETRY_ATTEMPT_MS,
|
|
): boolean {
|
|
return Number.isFinite(remainingMs) && remainingMs >= minAttemptMs;
|
|
}
|