fix: 拒绝无效的 Sub2API 零优先级
This commit is contained in:
@@ -35,7 +35,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool runtime events --target PK0
|
||||
- 单 target 运行面先用 `status --target <id>`;
|
||||
- 代理、数据库和公网路径的完整判定用 `validate --target <id>`。
|
||||
|
||||
- `priority` 数值越小优先级越高,`0` 合法且最高:
|
||||
- `priority` 数值越小优先级越高,合法范围为 `1..1000`,`1` 最高:
|
||||
- 这是 Sub2API 调度的稳定合同,后续调优不得为确认方向重复检索源码;
|
||||
- 只有真实调度结果与该合同冲突时,才下钻官方 scheduler 实现。
|
||||
- 查询账号周限保护统一使用 `runtime get --account <id-or-exact-name>`:
|
||||
|
||||
@@ -116,7 +116,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts <id-or-exact-name,...> --template <template-id>
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts <id-or-exact-name,...> --template <template-id> --confirm
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --template <template-id> --select-configured-policy --account-type apikey --exclude-accounts <id-or-exact-name,...>
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts <id-or-exact-name,...> --kind priority --priority <0-1000> --confirm
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts <id-or-exact-name,...> --kind priority --priority <1-1000> --confirm
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --accounts <id-or-exact-name,...> --kind capacity --capacity <1-100000> --confirm
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --target PK01 --account <id-or-exact-name> --kind account-name --name <new-name> --confirm
|
||||
bun scripts/cli.ts platform-infra sub2api codex-pool runtime delete --target PK01 --account <name-or-id> --kind temp-unschedulable
|
||||
@@ -238,7 +238,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool cleanup-probes --target D60
|
||||
- 手工账号需要采用模板时:
|
||||
- 写入使用显式 `runtime apply --account ...` 或 `--accounts ... --template ... --confirm`。
|
||||
- 删除使用相同显式 selector 的 `runtime delete --kind temp-unschedulable --confirm`。
|
||||
- 账号全局 `priority` 使用 `runtime apply --kind priority --priority <0-1000>`:
|
||||
- 账号全局 `priority` 使用 `runtime apply --kind priority --priority <1-1000>`:
|
||||
- 数值越小优先级越高,不存在分组级 priority;
|
||||
- 单账号和精准批量都必须先 dry-run,确认写入后逐账号回读并显示 before、desired、actual 与 reconciled;
|
||||
- 只更新账号 priority,不携带 credentials、分组、容量、代理、状态、可调度或临时不可调度字段。
|
||||
@@ -256,7 +256,7 @@ bun scripts/cli.ts platform-infra sub2api codex-pool cleanup-probes --target D60
|
||||
- 同一次账号级查询直接读取评分、可归因上游失败率、TTFT、用量、Token、标准 API 计费基数、当前名称成本标注和 priority;
|
||||
- 只有需要确认 capacity、schedulable、proxy、临时不可调度规则或上游 5h/7d 周窗口保护时,才补一次 `runtime get --account <account>`;
|
||||
- 只有需要跨账号比较时才使用全组 `runtime errors --group <group>`;单账号任务不得先跑全组大报表,再重复账号级查询;
|
||||
- priority 数值越小越优先,`0` 合法且最高;这是稳定合同,除非真实调度结果冲突,不得重复检索源码确认方向。成本只参与人工经济性判断,必须同时考虑可靠性、TTFT、容量、可调度状态和样本置信度,不得按成本自动排序;
|
||||
- priority 数值越小越优先,合法范围为 `1..1000`,`1` 最高;CLI 必须在提交远端作业前拒绝 `0` 和负数。成本只参与人工经济性判断,必须同时考虑可靠性、TTFT、容量、可调度状态和样本置信度,不得按成本自动排序;
|
||||
- 名称成本标注和 priority 是两个独立 runtime 字段:分别先 dry-run,再顺序 confirm;禁止并发更新同一账号,避免整对象更新互相覆盖;
|
||||
- 两项 confirm 已各自回读一致后,最后只执行一次 `runtime get` 验收完整状态;不重复 confirm,不用全组查询代替账号回读。
|
||||
- 模型路由先用 `runtime get --account ...` 获取账号配置,再用 `runtime errors --account ... --full` 获取原生 Ops 已观测模型证据:
|
||||
|
||||
@@ -722,8 +722,8 @@ export function readAccountPriority(value: unknown, key: string, fallback?: numb
|
||||
throw new Error(`${codexPoolConfigPath}.${key} is required`);
|
||||
}
|
||||
const priority = numberValue(value);
|
||||
if (priority === null || !Number.isInteger(priority) || priority < 0 || priority > 1000) {
|
||||
throw new Error(`${codexPoolConfigPath}.${key} must be an integer from 0 to 1000`);
|
||||
if (priority === null || !Number.isInteger(priority) || priority < 1 || priority > 1000) {
|
||||
throw new Error(`${codexPoolConfigPath}.${key} must be an integer from 1 to 1000`);
|
||||
}
|
||||
return priority;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export interface RuntimeOptions {
|
||||
export function parseRuntimeOptions(args: string[]): RuntimeOptions {
|
||||
const [actionRaw = "list", ...rest] = args;
|
||||
if (!(["list", "get", "errors", "events", "infrastructure", "apply", "delete"] as string[]).includes(actionRaw)) {
|
||||
throw new Error("runtime usage: list|get|errors|events|infrastructure|apply|delete [--account <name-or-id>|--accounts <selectors>|--select-configured-policy --account-type apikey [--exclude-accounts <selectors>]] [--recent 24h] [--group <name-or-id>|--all-groups] [--platform <name>] [--page-token <token>] [--since 24h] [--tail 50000] [--template <id>] [--kind temp-unschedulable|priority|account-name|capacity] [--priority <0-1000>|--name <account-name>|--capacity <1-100000>] [--confirm] [--target <id>] [--json|--full|--raw]");
|
||||
throw new Error("runtime usage: list|get|errors|events|infrastructure|apply|delete [--account <name-or-id>|--accounts <selectors>|--select-configured-policy --account-type apikey [--exclude-accounts <selectors>]] [--recent 24h] [--group <name-or-id>|--all-groups] [--platform <name>] [--page-token <token>] [--since 24h] [--tail 50000] [--template <id>] [--kind temp-unschedulable|priority|account-name|capacity] [--priority <1-1000>|--name <account-name>|--capacity <1-100000>] [--confirm] [--target <id>] [--json|--full|--raw]");
|
||||
}
|
||||
let account: string | null = null;
|
||||
let accounts: string[] = [];
|
||||
@@ -130,7 +130,7 @@ export function parseRuntimeOptions(args: string[]): RuntimeOptions {
|
||||
if (!selectConfiguredPolicy && excludeAccounts.length > 0) throw new Error("--exclude-accounts requires --select-configured-policy");
|
||||
if (action === "apply" && kind === "temp-unschedulable" && !template) throw new Error("runtime apply --kind temp-unschedulable requires --template <id>");
|
||||
if (kind === "priority" && action !== "apply") throw new Error("runtime --kind priority only supports apply");
|
||||
if (kind === "priority" && priority === null) throw new Error("runtime apply --kind priority requires --priority <0-1000>");
|
||||
if (kind === "priority" && priority === null) throw new Error("runtime apply --kind priority requires --priority <1-1000>");
|
||||
if (kind === "priority" && template !== null) throw new Error("runtime apply --kind priority does not accept --template");
|
||||
if (kind !== "priority" && priority !== null) throw new Error("--priority requires --kind priority");
|
||||
if (kind === "capacity" && action !== "apply") throw new Error("runtime --kind capacity only supports apply");
|
||||
@@ -184,7 +184,7 @@ function parseCapacity(value: string): number {
|
||||
|
||||
function parsePriority(value: string): number {
|
||||
const parsed = Number(value);
|
||||
if (!Number.isInteger(parsed) || parsed < 0 || parsed > 1000) throw new Error("--priority must be an integer from 0 to 1000");
|
||||
if (!Number.isInteger(parsed) || parsed < 1 || parsed > 1000) throw new Error("--priority must be an integer from 1 to 1000");
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ def account_summary(detail, include_rules=False, token=None):
|
||||
"priority": detail.get("priority"),
|
||||
"createdAt": detail.get("created_at"),
|
||||
"updatedAt": detail.get("updated_at"),
|
||||
"prioritySemantics": {"order": "lower-is-higher", "highest": 0},
|
||||
"prioritySemantics": {"order": "lower-is-higher", "highest": 1},
|
||||
"tempUnschedulable": {key: policy[key] for key in ("enabled", "ruleCount", "statusCodes")},
|
||||
"matchingTemplate": matching_template(credentials),
|
||||
"poolModeEnabled": credentials.get("pool_mode") is True,
|
||||
|
||||
@@ -509,7 +509,7 @@ function renderRuntimeErrors(lines: string[], runtime: Record<string, unknown>,
|
||||
]));
|
||||
}
|
||||
const scoreRule = runtimeRecord(accountQuality.scoreRule) ?? {};
|
||||
lines.push(`SCORE RULE reliability=${runtimeText(scoreRule.reliabilityWeight)} latency=${runtimeText(scoreRule.latencyWeight)} availability=${runtimeText(scoreRule.availabilityWeight)} confidence=separate priority=lower-is-higher highest=0`);
|
||||
lines.push(`SCORE RULE reliability=${runtimeText(scoreRule.reliabilityWeight)} latency=${runtimeText(scoreRule.latencyWeight)} availability=${runtimeText(scoreRule.availabilityWeight)} confidence=separate priority=lower-is-higher highest=1`);
|
||||
if (typeof accountQuality.attribution === "string") lines.push(`NOTE: ${accountQuality.attribution}`);
|
||||
}
|
||||
const errorModels = runtimeRecords(customerErrors.modelBuckets);
|
||||
|
||||
@@ -180,7 +180,7 @@ function renderRuntimeHelp(args: string[]): RenderedCliResult {
|
||||
"",
|
||||
"Kinds:",
|
||||
" temp-unschedulable Requires --template <id>",
|
||||
" priority Requires --priority <0-1000>; lower is higher",
|
||||
" priority Requires --priority <1-1000>; lower is higher",
|
||||
" capacity Requires --capacity <1-100000>; account concurrency guard",
|
||||
" account-name Requires one --account and --name <new-name>",
|
||||
"",
|
||||
|
||||
@@ -442,7 +442,7 @@ export function codexPoolHelp(): unknown {
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --account <name-or-id> --template <id> [--target PK01] [--confirm]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts <name-or-id,...> --template <id> [--target PK01] [--confirm] [--full|--raw]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --template <id> --select-configured-policy --account-type apikey [--exclude-accounts <name-or-id,...>] [--target PK01] [--confirm] [--json|--full|--raw]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts <name-or-id,...> --kind priority --priority <0-1000> [--target PK01] [--confirm]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts <name-or-id,...> --kind priority --priority <1-1000> [--target PK01] [--confirm]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --accounts <name-or-id,...> --kind capacity --capacity <1-100000> [--target PK01] [--confirm]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime apply --account <name-or-id> --kind account-name --name <new-name> [--target PK01] [--confirm]",
|
||||
"bun scripts/cli.ts platform-infra sub2api codex-pool runtime delete --account <name-or-id> --kind temp-unschedulable [--target PK01] [--confirm]",
|
||||
|
||||
Reference in New Issue
Block a user