Repository navigation
test(pg): stop pinning migration 012 as the last PG migration in pg-log-writer (unblocks #2441) - #2452
Merged
Conversation
…og-writer ## 变更摘要 - 改前:`test/unit/pg-log-writer.test.mjs` 的“PG migrations 011 and 012 …”用例断言 `applyPgMigrations()` 返回的最后一个迁移是 `012_optimize_usage_logs_and_attempts_indexes.sql`。`292743b1f`(2026-11-30)新增 `013_codex_slot_runtime.sql` 时没有同步它,用例自 11-30 起在 `origin/dev` 基线上就是红的(实得 `013_…`);它用 mock 池、不需要真实 PG 就会红,但文件不在 `test:ci` 固定集合里,所以一直没人发现。新增迁移的 PR(例如 #2441 的 `014_vm_daily_session_creations.sql`)每次都会让它多红一次。 - 改后:用例改为用迁移目录里按文件名排序的最后一个文件作为期望,并断言 011 与 012 都被应用且 012 在 011 之后;以后再增加迁移不必回头改它。只改这一个测试文件,没有改任何迁移或生产代码。 - 未改 / 延后:其它仍在基线上红的用例(例如 `scoped-intercept-session`、`scheduler-m0-migrations`、`issue-1776-active-usage-reconcile`、`kernel-switch-recovery`)不在本次范围。 ## 验收记录(Run) - 本机(Node 24)`pg-log-writer` 17 个用例 16 通过、0 失败(1 个依赖真实 PG 的用例被跳过);修复前该用例失败(实得 `013_codex_slot_runtime.sql`)。`biome format` 无需修改。 ## 回退与手破验证(Broken by hand) - 3 处手破(还原后 sha256 一致):往迁移目录临时加一个 `999_zz_tmp_probe.sql` 后用例仍绿(不再钉死 012);把断言改回 `mig012` 在存在新迁移文件时变红;把期望改成错误文件名变红。 ## 真实使用(Real use) - 不适用:只改测试,没有真实 PG;没有 `ph24`。 ## 未运行项(Not run) - 真实 PG18 上的迁移应用不在本测试范围;`npm run test:ci` 由 GitHub `ci` 检查覆盖。
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: c850b727-41e5-4b12-93d1-16dc1c25e3c5) |
Owner
Author
验收评论(head
|
ouyang-2019
pushed a commit
to ouyang-2019/vm2api
that referenced
this pull request
Dec 1, 2026
… unified Gemini circuit/race switch ## 变更摘要 - 改前:(1) 面板与 SSE 席位流依赖 Node 侧内存估算及 `seats_grace` / `conc_waiting` 影子字段,缺少从 Rust `kin-scheduler` 拉取 `/internal/v1/live` 实时快照并统一计算候选排序(`schedule_rank` / `schedule_rank_reason`)的链路;(2) `required_runtime_capabilities`、`guard_large_cold` 等准入门禁与 `session_affinity_first` 尚缺少端到端持久化、Rust Stage 0 准入与 Node/Panel 一致性门禁;(3) Gemini 调度与面板仍部分读取/写入 JS `UnitCircuit`(默认 `circuit_failure_threshold=3` 且 `routing-runtime` 与 CRAGGemini host 双重配置),且发车前额度耗尽竞态仅直接 429 退出,未走 `rt.switchNode` 切换健康兄弟账号。 - 改后:(1) Rust(`scheduler-proto` / `scheduler-core` / `scheduler-daemon`)新增 `/internal/v1/live` 实时快照、`required_runtime_capabilities`、`quota.guard_large_cold`(`GATE_DRAINING` 拦截大请求冷启动并保留已钉选会话)与 `pool.session_affinity_first`;新增 SQLite 075 / PG 014 迁移持久化 `required_runtime_capabilities`,并将面板与 SSE 流切换至 `liveSnap` 与 `schedule_rank` / `schedule_rank_reason`(移除 `seats_grace` / `conc_waiting`,且 `use-pool-seat-stream.test.ts` 已随 `dofastted#2423` 对齐 `mergeSeatVm`);(2) 移除 Gemini 链路对 JS `UnitCircuit` 的配置与状态读写(`routing.json` 中 `gemini.pool.circuit_failure_threshold` 默认收敛为 `0`),`environmentRestriction` 与 `clearRestriction` 直接对齐 Rust `liveNodeState` / `unrestNode`;(3) 在 `gemini/scheduler.mjs` 新增发车前 `quota.exhausted` 的 `rt.switchNode` 竞态切换、`syncAccountQuotaState` 即时遥测推送(`quota_util_5h_pct`)及 `gemini-host.py` 上行对齐。 - 影响文件:共 49 个文件(47 修改 + 2 新增数据库迁移 `075_scheduler_pool_required_capabilities.sql` 与 `014_scheduler_pool_required_capabilities.sql`,`+2332 / -284`),无 `CHANGELOG.md`、`VERSION`、`bin/kin-scheduler` 或本地规则文件。 ## 验收记录(Run) - 环境与基线:WSL Ubuntu + Windows `git.exe` + Rust `1.86.0` + Node `v24.13.0`;基于 `origin/dev` `821e6805f`(含 `dofastted#2452` 对 PG 迁移断言解钉,与期间新落地的 `dofastted#2454` `fp3` 改动 0 文件重叠)清洁 rebase 验证(0 冲突)。 - 已跑命令与结果: - Rust `1.86.0`(`CARGO_TARGET_DIR=/tmp/vm2api-sched-b3`):`cargo fmt --check`、`cargo clippy --workspace --all-targets -- -D warnings`(0 warnings)、`cargo test --workspace --locked` PASS(**138/138**:`scheduler-core` 33+7+10+17+35=102、`scheduler-daemon` 18、`scheduler-proto` 1+17=18);`npm run build:scheduler` 生成 `bin/kin-scheduler` 供测试并清理 `/tmp/vm2api-sched-b3`(`git status --short` 确认已忽略未暂存)。 - 静态与脚本检查:`node --check` + `npx biome check --formatter-enabled=true --linter-enabled=false`(23 个 `.mjs` 改动文件)PASS(`Checked 23 files in 681ms. No fixes applied.`);`pnpm -C web exec prettier --check`(10 个 `web/` 文件)PASS;`python3 -m py_compile scripts/gemini-host.py` + `python3 test/unit/gemini-host-shards.py` + `python3 test/unit/gemini-host-license-align.py` PASS。 - Backend Node(`VM2API_TEST_CONCURRENCY=2`,使用本地重编 `bin/kin-scheduler`):`npm run test:ci` **13/13 文件 / 247/247 用例** PASS(0 fail / 0 skip);13 个关联单元套件(`quota-critical-band` 20/20、`failover-runner` 117/117、`scheduler-client` 8/8、`scheduler-m0-migrations` 8/8 + 1 PG skip、`scheduler-m1b-pools-api` 8/8、`scheduler-m3-runtime` 14/14、`scheduler-m3-cutover` 8/8、`scheduler-m3-parity-session-home` 6/6、`gemini-pool-circuit-config` 3/3、`gemini-scheduling-status` 14/14、`crag-opt2a-scheduler-m1b-joint` 3/3、`routing-runtime-load` 23/23、`pg-log-writer` 16/16 + 1 PG skip)合计 **248** 项 PASS、0 fail、2 skip(仅跳过需 `PG_URL` 的 PostgreSQL 实库 E2E)。 - Web(WSL 独立执行):`pnpm typecheck`(`tsc -b`)PASS;`pnpm test:ci` **9/9 文件 / 99/99 用例** PASS;`pnpm exec vitest run src/features/vm/use-pool-seat-stream.test.ts` **12/12 用例** PASS;`pnpm build`(4522 modules,13.55s)PASS。 ## 回退与手破验证(Broken by hand) - `guard_large_cold`(临时将 `claudeLargeColdQuotaGate` 置为 `null`):`test/unit/quota-critical-band.test.mjs:658` 断言失败(19/20 pass, 1/20 fail)-> 还原后 20/20 PASS。 - `L2-16`(临时禁用 Gemini 调度器中 `switchLease` 额度耗尽切换循环):`test/unit/scheduler-m3-runtime.test.mjs:1616..1620` 失败(13/14 pass, 1/14 fail)-> 还原后 14/14 PASS。 - `L2-17`(临时旁路 `PoolScheduler.seatSnapshot` 中的 `liveSnap` 合并分支):`test/unit/scheduler-m3-runtime.test.mjs:1739..1743` 失败(13/14 pass, 1/14 fail)-> 还原后 14/14 PASS。 ## 真实使用(Real use) - 未执行:未部署至 `ph24` 生产环境或接入真实上游 API 流量,已使用 Rust 1.86.0 实编译的 `bin/kin-scheduler` 守护进程及真实 UDS/HTTP 接口完成端到端单元与集成验证。 ## 未运行项(Not run) - 未运行 Backend 全量 556 文件单测、端到端 E2E、`PG_URL` 真实 PostgreSQL 实库校验(本次 `scheduler-m0-migrations` 与 `pg-log-writer` 共跳过 2 条 PG 实库用例)及 ARM64 CI。 ## 合入顺序说明 - 调度收敛线依赖顺序:**B0(dofastted#2447)→ B1(dofastted#2451)→ B2(dofastted#2455)→ B3(本 PR)**;提示词 0 注入线 **A0(dofastted#2446)→ A1(dofastted#2450)** 与 B 线相互独立。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更摘要
test/unit/pg-log-writer.test.mjs的“PG migrations 011 and 012 …”用例断言applyPgMigrations()返回的最后一个迁移是012_optimize_usage_logs_and_attempts_indexes.sql。292743b1f(2026-11-30)新增013_codex_slot_runtime.sql时没有同步它,用例自 11-30 起在origin/dev基线上就是红的(实得013_…);它用 mock 池、不需要真实 PG 就会红,但文件不在test:ci固定集合里,所以一直没人发现。新增迁移的 PR(例如 feat(quota): add Anthropic daily VM session creation gate #2441 的014_vm_daily_session_creations.sql)每次都会让它多红一次。scoped-intercept-session、scheduler-m0-migrations、issue-1776-active-usage-reconcile、kernel-switch-recovery)不在本次范围。验收记录(Run)
pg-log-writer17 个用例 16 通过、0 失败(1 个依赖真实 PG 的用例被跳过);修复前该用例失败(实得013_codex_slot_runtime.sql)。biome format无需修改。回退与手破验证(Broken by hand)
999_zz_tmp_probe.sql后用例仍绿(不再钉死 012);把断言改回mig012在存在新迁移文件时变红;把期望改成错误文件名变红。真实使用(Real use)
ph24。未运行项(Not run)
npm run test:ci由 GitHubci检查覆盖。Note
Low Risk
Test-only change with no impact on runtime migration behavior or production code.
Overview
Fixes a brittle assertion in the PG migrations 011 and 012 unit test that expected
applyPgMigrations()’s final applied file to always be012_optimize_usage_logs_and_attempts_indexes.sql. That broke once013and later migrations existed, even though the test only cares that 011 and 012 run in order with the expected SQL.The test now expects the last applied migration to match the last sorted
.sqlfile underPG_MIGRATIONS_DIR, and separately asserts that 011 and 012 are both present with 012 after 011. No production or migration files change—test-only.Reviewed by Cursor Bugbot for commit 3ac8d8f. Configure here.