From a81f6f6779ac55f03293c58c50087a1106661be2 Mon Sep 17 00:00:00 2001 From: ted Date: Tue, 1 Dec 2026 20:37:13 +0800 Subject: [PATCH] fix(pool): give license_invalid and crag_prompt_replace_empty_unsupported a schedule-state row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 变更摘要 - 改前:`src/lib/pool/upstream-error-policy.mjs` 会发出两个调度原因 `license_invalid`(单槽 resync + 退避重试后仍答 `license_invalid`、尚未提交,换槽重试且不冷却)和 `crag_prompt_replace_empty_unsupported`(旧 CRAG 不支持空 prompt replace,换槽重试且不冷却),但 `src/lib/pool/schedule-state.mjs` 的原因表里没有这两行。`test/unit/schedule-state.test.mjs` 的“every emitted reason has exactly one row in the table”因此在 `origin/dev` 基线上一直失败(`add these reasons to schedule-state.mjs: crag_prompt_replace_empty_unsupported, license_invalid`)。该文件不在 `test:ci` 固定集合里,平时没人发现;任何改到它的 PR(例如 #2441)CI 都会因它变红。 - 改后:两个原因归入 `STATELESS`(“不改变槽位状态”:它们都经 `continueWithoutCooldown` 发出,语义是换槽重试而不是冷却或摘除),并加进测试里已有的“不改变槽位状态”断言列表。 - 未改 / 延后:不改 `upstream-error-policy.mjs` 的发出逻辑,不改任何其它原因的归类,不动面板文案。 ## 验收记录(Run) - 本机(Node 24)`schedule-state` 12/12(修复前 11/12);Node 22.23.5 容器 + 真实 `kin-scheduler` 跑引用 `schedule-state` 的 5 个测试文件(`schedule-state`、`codex-slot-pool`、`crag-zombie-guard`、`organization-disabled-probe`、`scheduler-fastpath`)76/76。`biome format` 无需修改。 ## 回退与手破验证(Broken by hand) - 3 处手破(唯一锚点,还原后 sha256 一致):整行去掉、只去掉 `license_invalid`、只去掉 `crag_prompt_replace_empty_unsupported`,各让 `schedule-state` 变红。 ## 真实使用(Real use) - 不适用:只补原因表的归类,没有真实槽位或流量;没有 `ph24`。 ## 未运行项(Not run) - 面板上这两个原因的展示文案没有看(它们归入“不改变槽位状态”,面板不为它们显示状态);`npm run test:ci` 由 GitHub `ci` 检查覆盖。 --- src/lib/pool/schedule-state.mjs | 2 ++ test/unit/schedule-state.test.mjs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib/pool/schedule-state.mjs b/src/lib/pool/schedule-state.mjs index a9f8ef8d1f..ee46ff00de 100644 --- a/src/lib/pool/schedule-state.mjs +++ b/src/lib/pool/schedule-state.mjs @@ -98,6 +98,8 @@ const STATELESS = [ /^(wrap_connection_error|worker_transport_failure|worker_timeout|worker_process_exit|upstream_network_error|stream_interrupted|empty_response|incomplete_assistant|downstream_committed_or_incomplete|provider_timeout|client_cancelled|oauth_unconfirmed)$/, // Quota reset-boundary write-guard rejections (stale pre-reset samples ignored; never restrict a slot). /^(pre_reset_generation|pre_reset_started_at|pre_reset_probed_at|missing_reset_timing)$/, + // Worker answers that move the request to another slot without cooling this one down (continueWithoutCooldown). + /^(license_invalid|crag_prompt_replace_empty_unsupported)$/, // Seat placement labels (why this VM was picked), not a slot condition. /^sticky$/, ] diff --git a/test/unit/schedule-state.test.mjs b/test/unit/schedule-state.test.mjs index 5d2b15d41f..ee618443ab 100644 --- a/test/unit/schedule-state.test.mjs +++ b/test/unit/schedule-state.test.mjs @@ -68,6 +68,8 @@ test('risk-audit and request-level codes never change the slot state', () => { 'pre_reset_started_at', 'pre_reset_probed_at', 'missing_reset_timing', + 'license_invalid', + 'crag_prompt_replace_empty_unsupported', ] for (const code of stateless) assert.equal(stateOfReason(code)?.state, 'on', code) })