fix: tune sub2api codex pool concurrency
This commit is contained in:
@@ -17,20 +17,14 @@ const credentials = renderSub2ApiTempUnschedulableCredentials(policy) as {
|
||||
};
|
||||
|
||||
const rules = credentials.temp_unschedulable_rules ?? [];
|
||||
const overload429 = rules.find((rule) => rule.error_code === 429);
|
||||
const overloaded529 = rules.find((rule) => rule.error_code === 529);
|
||||
|
||||
assertCondition(credentials.temp_unschedulable_enabled === true, "default policy must enable Sub2API temporary unschedulable mode", credentials);
|
||||
assertCondition(Array.isArray(credentials.temp_unschedulable_rules), "Sub2API rules must be rendered as an array", credentials);
|
||||
assertCondition(rules.length === policy.rules.length, "rendered rule count must match the UniDesk policy", { policy, credentials });
|
||||
assertCondition(overload429 !== undefined, "rendered policy must include 429 handling", rules);
|
||||
assertCondition(overload429?.keywords?.includes("capacity"), "429 handling must catch capacity text", overload429);
|
||||
assertCondition(overload429?.keywords?.includes("too many requests"), "429 handling must catch rate-limit text", overload429);
|
||||
assertCondition(overload429?.duration_minutes === 10, "429 cooldown must match the default policy", overload429);
|
||||
assertCondition(overloaded529 !== undefined, "rendered policy must include provider overloaded status 529", rules);
|
||||
assertCondition(rules.every((rule) => typeof rule.error_code === "number"), "rules must use Sub2API error_code field names", rules);
|
||||
assertCondition(rules.every((rule) => typeof rule.duration_minutes === "number"), "rules must use Sub2API duration_minutes field names", rules);
|
||||
assertCondition(rules.every((rule) => Array.isArray(rule.keywords) && rule.keywords.length > 0), "rules must include non-empty keyword lists", rules);
|
||||
assertCondition(rules.every((rule, index) => rule.error_code === policy.rules[index]?.statusCode), "rules must map statusCode to Sub2API error_code", { policy, credentials });
|
||||
assertCondition(rules.every((rule, index) => rule.duration_minutes === policy.rules[index]?.durationMinutes), "rules must map durationMinutes to Sub2API duration_minutes", { policy, credentials });
|
||||
assertCondition(rules.every((rule, index) => JSON.stringify(rule.keywords ?? []) === JSON.stringify(policy.rules[index]?.keywords ?? [])), "rules must preserve policy keywords", { policy, credentials });
|
||||
assertCondition(rules.every((rule, index) => rule.description === policy.rules[index]?.description), "rules must preserve policy descriptions", { policy, credentials });
|
||||
assertCondition(!("pool_mode" in credentials), "pool_mode must not be enabled because it retries the same account instead of cooling it down", credentials);
|
||||
assertCondition(!("api_key" in credentials) && !("base_url" in credentials), "temporary-unschedulable rendering must not include secrets or endpoints", credentials);
|
||||
|
||||
@@ -46,7 +40,7 @@ console.log(JSON.stringify({
|
||||
ok: true,
|
||||
checks: [
|
||||
"temporary unschedulable policy renders to Sub2API credential field names",
|
||||
"capacity/rate-limit errors cool down an account without enabling pool_mode",
|
||||
"temporary unschedulable rendering follows the input policy without hard-coded policy gates",
|
||||
"disabled policies clear runtime rules",
|
||||
],
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user