Skip to content

fix(ci): route post-merge classifier to ECS and yield CLI workers - #14293

Merged
yiliang114 merged 4 commits into
mainfrom
codex/fix-14219-classify-push-runner
Oct 16, 2026
Merged

yiliang114 merged 4 commits into
mainfrom
codex/fix-14219-classify-push-runner

Conversation

@yiliang114

@yiliang114 yiliang114 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Run the post-merge classifier on the ECS Linux pool when ECS is enabled, matching downstream Linux jobs. The existing disable switch still selects GitHub-hosted Linux.

Let CLI test workers take a real event-loop turn between tests so queued progress replies can drain, including when a suite installs fake timers. Clean up mounted replay-test fixtures between tests so the yield cannot expose stale renders from an earlier test. Unhandled errors remain fatal.

Why it's needed

A main push queued its classifier on hosted Linux for 49m32s before doing four seconds of work, blocking the downstream ECS jobs. Separately, synchronous test batches can prevent workers from processing progress replies. The worker-yield change also exposed a reproducible fixture leak: earlier mounted components wrote to a shared spy during a later model-change assertion.

Reviewer Test Plan

How to verify

For a main push, the classifier and downstream Linux jobs should both choose ECS when enabled and hosted Linux when disabled. Trusted/untrusted PR routing should retain its existing behavior.

A real macrotask queued by one synchronous CLI test should finish before the next test, both with real and fake timers. The progressive-replay model-change guard should still retain all 203 items; a real model-triggered reset must fail it.

Evidence (Before & After)

The historical push classifier queued 49m32s and executed for four seconds. The local routing regression evaluates the real workflow expression and executes the downstream shell selector (39 checks pass).

At fffb13ace0, the model-change fixture failed 3/3 paired runs with worker yielding, and passed 3/3 with the original setup. Adding fixture cleanup makes all 33 replay tests and four yield tests pass. A controlled mutation that actually resets replay on model change still fails the retained 203-item assertion (53 received), so cleanup does not weaken the guard.

Application UI verification: N/A. The changed consumers are the Actions scheduler and Vitest's test-only setup; no product CLI/Web renderer or outbound product protocol changes. Live post-merge queue latency needs this workflow to land.

Tested on

OS Status
🍏 macOS ✅ routing/budget checks, targeted tests, build, typecheck, formatting and lint
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ existing CI failure inspected; repaired-head run pending

Environment (optional)

Node 22.23.2, Vitest 3.2.7, isolated worktree. The current main was merged to supply the CI-budget script invoked by the base workflow. Full Linux CLI CI is not claimed locally. A fresh source review found no blocker. The earlier Qwen automated review timed out and remains unverified.

Risk & Scope

  • Main risk or tradeoff: the classifier shares ECS availability with downstream jobs; the disable switch remains effective. Yielding between tests does not repair a single test or collection hook that blocks longer than the RPC deadline.
  • Not validated / out of scope: post-merge scheduling latency, runner capacity, and an independent replay of the earlier 650-case RPC benchmark. This round verifies the real/fake-timer boundary and the reported fixture regression.
  • Breaking changes / migration notes: none; no application behavior changes.

Linked Issues

Fixes #14219

中文说明

本 PR 的修改

ECS 开启时,将合并后的分类任务放到 ECS Linux 池,与下游 Linux 任务一致;既有禁用开关仍选择 GitHub 托管 Linux。

让 CLI 测试 worker 在测试之间运行一轮真实事件循环,以处理排队的进度回复,安装虚拟时钟也适用。同时在每个测试后清理已挂载的 replay 测试组件,防止新增 yield 暴露上一个测试的旧渲染。未捕获错误仍然阻断。

修改原因

一次 main push 的分类任务在托管 Linux 排队 49 分 32 秒,实际只执行四秒,下游 ECS 任务必须等待。另一个问题是同步测试批次可能阻塞进度回复的处理。新增 worker yield 还暴露了可复现的 fixture 泄漏:早先挂载的组件在后一个模型切换断言中继续写共享 spy。

Reviewer Test Plan

如何验证

main push 在 ECS 开启时,分类与下游 Linux 任务均应选择 ECS;禁用时均应选择托管 Linux。可信及不可信 PR 路由保持既有行为。

一个同步 CLI 测试排入的真实宏任务应在下一个测试前完成,真实和虚拟时钟均适用。渐进回放的模型切换 guard 应保留全部 203 项;真实的模型触发重置必须使它失败。

前后证据

历史 push 分类任务 排队 49 分 32 秒,执行四秒。本地路由回归直接求值真实 workflow 表达式,并执行下游 shell 选择器,39 项检查通过。

fffb13ace0 上,模型切换 fixture 在 worker yield 下连续三次失败,使用原 setup 则连续三次通过。补充 fixture cleanup 后,33 项 replay 测试及四项 yield 测试通过。受控注入真实的模型切换重置后,保留的 203 项断言仍失败(实际 53 项),证明 cleanup 没有削弱 guard。

应用 UI 验证不适用:消费者是 Actions 调度器及 Vitest 专用 setup,不改变产品 CLI/Web 渲染或产品出站协议。真实的合并后排队延迟需等工作流合入。

测试平台

OS 状态
🍏 macOS ✅ 路由和预算检查、聚焦测试、构建、类型检查、格式及 lint
🪟 Windows ⚠️ 未测试
🐧 Linux ⚠️ 已检查既有 CI 失败,修复后运行待完成

环境

Node 22.23.2、Vitest 3.2.7,独立 worktree。已合并当前 main,补齐 base workflow 调用的 CI 预算脚本。不声称本地运行了完整 Linux CLI CI。新的源码 review 未发现阻塞问题;此前 Qwen 自动 review 超时,仍为未验证。

风险与范围

  • 主要风险或取舍:分类与下游任务共用 ECS 可用性,禁用开关仍有效。测试之间的 yield 无法修复单个测试或收集 hook 连续阻塞超过 RPC 时限的情况。
  • 未验证及范围外:合并后的实际调度延迟、runner 容量,以及独立重放此前 650 项 RPC 压力实验。本轮验证真实/虚拟时钟边界和已报告的 fixture 回归。
  • 破坏性变更或迁移:无,不修改应用行为。

关联 Issue

Fixes #14219

@github-actions github-actions Bot added the review/self-reported The linked issue was opened by the PR author (self-reported) label Oct 15, 2026
Yield with a captured real timer so synchronous test batches cannot starve progress acknowledgements, even when fake timers are installed. Keep unhandled errors fatal on Linux.
@yiliang114 yiliang114 changed the title fix(ci): route post-merge classifier to ECS fix(ci): route post-merge classifier to ECS and yield CLI workers Oct 15, 2026
@yiliang114

yiliang114 commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator Author

CI closeout: merged current main to include the required CI-budget script, and fixed the reproduced progressive-replay test failure by unmounting each test fixture. The unchanged regression assertion still fails under a deliberate replay-reset mutation. Two final runs passed 37/37 tests each; routing 39/39, build, typecheck, lint and CI budget passed locally. Fresh hosted checks remain a separate gate.

Scope remains CI routing and test infrastructure; no application behavior was changed.

@yiliang114

Copy link
Copy Markdown
Collaborator Author

Local verification: PASS for the CI-routing and test-infrastructure scope. Application UI: N/A.

Tested candidate: 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1, incorporating main 87de74860b and the test cleanup. Historical failing PR head: fffb13ace0ef681e16b2d97f6c5173ccc0195671; the original setup comparison used 476f624b53 on that same candidate. Local runs used macOS, the repository Vitest configuration, CI=true, RUNNER_NAME=ecs-qwen-local-probe, one worker, and no retry. That environment flag selects the CI configuration; it does not make this a Linux run.

  • On the historical head, the added setup yield reproduced the progressive-replay failure three out of three times: after changing the model, the test expected 203 items and received 103. The same candidate using only the original setup passed three out of three times. Two failing runs included only MainContent, so the new control test file was not required to trigger it.
  • The root agent also retained a failure after merging main but before applying cleanup: the same assertion still reported 203 versus 103. This was an unsuccessful cleanup application followed by an actual test run; its failure is retained rather than discarded. It separates the merge from the cleanup result.
  • On the final candidate, two independent runs of MainContent and event-loop-yield passed 37/37 tests each. The 203-item assertion remains unchanged. Both real-timer and fake-timer cases observed a real queued macrotask draining before the next synchronous test.
  • The root agent's negative control deliberately reintroduced a model-triggered replay reset; the unchanged assertion failed with 203 versus 53. I inspected that raw log; I did not execute this mutation. The mutation was restored before the final candidate runs.
  • The routing gate passed 39 tests in the root agent's run. It checks the actual workflow expression and runner-selection shell path, including push alignment, the kill switch, and nearby trusted/untrusted routing controls. Retained earlier negative-control output shows the push classifier returning ubuntu-latest where the regression expected ECS. These are local workflow-contract tests, not a fresh hosted Actions scheduling experiment.

The application UI route is N/A because the changed workflow is consumed by GitHub Actions and the setup/cleanup files are consumed only by Vitest. The cleanup unmounts test renderings after each test; no application renderer, service protocol, persisted user state, or outbound application request was changed. Screenshots or a normal CLI launch would not observe the changed contract.

The root agent reported the full build, repository typecheck, formatting, ESLint, routing and CI-budget gates passed. The old-head Linux CI log still contains the valid 203/103 failure and no RPC timeout; local results do not retroactively turn that run green or establish the status of fresh hosted checks. The historical 650-case/65-second RPC starvation benchmark was not independently rerun or relied on here. The four timer controls establish the yield boundary only, not throughput or immunity to every RPC timeout.

Evidence is retained under /tmp/qwen-quick-issues/14293-verify: the original three paired runs in paired/, two final runs in cleaned-after/, manifests with exact commands and SHAs, and sanitized replay.py / replay-after.py drivers. Root-agent evidence: ready-14293-rebased-before-cleanup.log, ready-14293-replay-guard-negative.log, ready-14293-routing.log; historical routing negative control: 14219-before.log. Temporary config/setup files were removed and the checkout was clean after verification. No dependencies were installed and no build or product edits were performed by this verification.

本地验证:CI 路由和测试基础设施范围内 PASS;应用 UI 不适用。

最终验证候选为 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1,已合入 main 87de74860b。旧候选 fffb13ace0ef681e16b2d97f6c5173ccc0195671 在新增 yield 下 3 次均出现 203/103 失败;同一候选仅换成来自 476f624b53 的原 setup 后 3 次均通过。根 agent 另保留了合入 main 但尚未成功加入 cleanup 的失败日志,因此不能把修复效果归给 merge main。

最终候选的两次独立目标运行均为 37/37 通过,包括未放宽的 203 项断言,以及 real/fake timer 下真实宏任务在下一测试前执行的 4 项控制。根 agent 注入模型切换触发 replay reset 的负对照使原断言以 203/53 失败;我检查了该日志,并未亲自执行 mutation。根 agent 的 39 项路由验证及构建、类型、格式、lint、CI budget 检查也已通过。

本次未修改应用代码,因此没有可对应的应用 UI、协议或用户持久化状态变化。没有重新调度真实 Actions 队列,也没有独立重跑 650 case、65 秒 RPC 压力实验;宏任务控制只证明测试边界会让出执行机会。旧 head 的 Linux CI 红灯仍是有效历史结果,新 head 的远程 CI 状态须另行确认。证据、命令和可重放脚本均已保留,临时文件已删除,验证后工作树干净。

@yiliang114
yiliang114 marked this pull request as ready for review October 16, 2026 07:51
@qwen-code-review-bot

qwen-code-review-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — CI landed green on 3066a0e and the deferred approval was posted. finalize run

✅ Qwen Triage 已完成 —— 3066a0e 的 CI 全绿,延迟审批已提交。查看 finalize 运行

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR!

Template looks good ✓

Problem — the routing half is an observed bug, not a hypothesis. #14219 is open and carries a concrete run: the post-merge classifier queued 49m32s and then did four seconds of work. I checked the mechanism against the base YAML rather than taking the description's word for it — classify_pr's runs-on had no push arm while its own pick_runner step did, so a push to main parked the gate on hosted Linux and sent test / lint_and_static to ECS. Both needs: classify_pr, so the entire post-merge lane waited on a queue that had nothing to do with the work being done.

The worker-yield half has no linked issue and no failing run behind it, and your own description says "Separately" — more under Approach.

Direction — aligned, and the trust boundary is not widened. ci.yml's push trigger is branches: ['main'] (pinned by scripts/tests/ci-platform-lanes.test.js), so github.event_name == 'push' in this workflow can only mean code already merged to main; a fork cannot produce that event. The kill-switch still wraps the new clause. On the "canonical expression the mirrors follow" claim in the comment you edited: sdk-java.yml already admits push through its event_name != 'pull_request' form and serve-ab.yml is pull-request-only — and the routing tests assert serve-ab clause-by-clause rather than by equality against classify_pr, so this arm drifts nothing.

Size — not applicable, no core paths touched. For the record: 12 changed lines in the workflow, 5 in packages/cli/test-setup.ts (test-only setup), the remaining 87 are test files.

Approach — the routing fix is the minimal version of itself: one clause added to an expression that already existed, no new indirection. Swapping the test that pinned the old asymmetry for one that evaluates the real expression text, executes the real pick_runner shell, and asserts the two halves agree on push is a stronger guard than what it replaced, not a weaker one. I also ran the AGENTS.md check for stale workflow meta-tests: .github/scripts/ci-runner-routing.test.mjs is the only file that reads classify_pr['runs-on'], and no scripts/tests/*.test.js pins it, so nothing else needed to move. ✓

Two genuine questions before the code review:

  1. workflow_dispatch still carries the asymmetry you just fixed for push. On a dispatch run with the default linux_runner: self-hosted, pick_runner sends the downstream Linux jobs to ECS while runs-on leaves classify_pr hosted — same shape, same needs edge, same potential for a long hosted queue gating ECS work. Is omitting it deliberate (dispatch is manual, rare, and a human is watching) or did it simply not come up? If deliberate, one line in the comment would save the next reader this investigation.

  2. Is the CLI worker-yield part of this fix, or a second fix sharing a branch? I can see the coupling argument: moving more post-merge work onto the shared ECS pool is exactly the contention that makes vitest's fixed 60s onTaskUpdate RPC budget fire, and packages/cli is the one suite that was absorbing that risk with dangerouslyIgnoreUnhandledErrors rather than a yield. But "Separately" reads like two changes. Worth saying which, because the answer changes what evidence this PR needs.

Risk — no elevated risk signals; the revert-correlated path scan matched nothing.

Moving on to code review. 🔍

中文说明

感谢贡献!

模板完整 ✓

问题:路由这一半是已观测到的 bug,不是假设。#14219 处于 open 状态,并附有具体的 run:合并后的分类任务排队 49 分 32 秒,实际只执行了四秒。我没有只采信描述,而是对照 base 分支的 YAML 核实了机制——classify_pr 的 runs-on 没有 push 分支,而它自己的 pick_runner step 有;因此一次到 main 的 push 会把闸口任务留在托管 Linux 上,同时把 test / lint_and_static 送到 ECS。两者都 needs: classify_pr,于是整条合并后链路都在等一个与实际工作量无关的队列。

worker yield 那一半没有关联 issue,也没有失败 run 作为支撑,而且你自己的描述里写的是"另一个问题"(Separately)——见"方案"部分。

方向:对齐,且没有放宽信任边界。ci.yml 的 push 触发是 branches: ['main'](由 scripts/tests/ci-platform-lanes.test.js 固定),所以在这个 workflow 里 github.event_name == 'push' 只可能代表已经合入 main 的代码;fork 无法产生该事件。kill-switch 仍然包住新增分支。关于你修改的注释中"下游镜像遵循的规范表达式"这一说法:sdk-java.yml 本来就通过 event_name != 'pull_request' 形式放行 push,而 serve-ab.yml 只在 pull request 上触发——并且路由测试对 serve-ab 是逐条断言而非与 classify_pr 做全等比较,所以新增这一分支不会造成漂移。

规模:不适用,未触及核心路径。仅供参考:workflow 改动 12 行,packages/cli/test-setup.ts 改动 5 行(仅测试用 setup),其余 87 行为测试文件。

方案:路由修复已是最小实现——只在既有表达式上加一个分支,没有引入新的间接层。把原本"固定旧的非对称行为"的测试,换成一个真实求值表达式文本、真实执行 pick_runner shell、并断言 push 时两半一致的测试,比它替换掉的守卫更强,而不是更弱。我也按 AGENTS.md 检查了是否有 workflow 元测试失效:读取 classify_pr['runs-on'] 的文件只有 .github/scripts/ci-runner-routing.test.mjs,scripts/tests/*.test.js 中没有任何文件固定它,因此不需要改动其他地方。✓

进入代码审查前,有两个真实的问题:

  1. workflow_dispatch 仍然存在你刚为 push 修掉的这种非对称。 在默认 linux_runner: self-hosted 的 dispatch run 中,pick_runner 会把下游 Linux 任务送到 ECS,而 runs-on 把 classify_pr 留在托管 runner 上——同样的结构、同样的 needs 边、同样可能出现"托管长队列卡住 ECS 工作"。这是有意省略(dispatch 是手动的、少见、有人盯着),还是只是没考虑到?如果是有意的,注释里加一行能让后来人省下这次排查。

  2. CLI 的 worker yield 属于本次修复,还是共用一个分支的第二个修复? 我能理解耦合的理由:把更多合并后的工作放到共享 ECS 池,正是会让 vitest 固定 60 秒 onTaskUpdate RPC 预算超时的争抢场景;而 packages/cli 恰恰是唯一一个用 dangerouslyIgnoreUnhandledErrors 而非 yield 来吸收该风险的测试套件。但"Separately"读起来像是两件事。值得明确说明是哪一种,因为这决定了本 PR 需要什么证据。

风险:无升级风险信号;与 revert 相关的高风险路径扫描无命中。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1 · re-run with @qwen-code /triage

@yiliang114

Copy link
Copy Markdown
Collaborator Author

Two scope clarifications for the stage-1 questions:

  1. This change addresses the observed push-to-main path in ci: post-merge Classify PR is pinned to a congested hosted runner and gates every job — 4s of work behind a 49-64min queue #14219. Manual workflow_dispatch routing is unchanged. With a self-hosted downstream selection, the classifier can still gate it through the hosted queue; this PR does not claim to fix or measure that path. Extending manual dispatch routing can be handled separately with its own input/kill-switch controls.
  2. The CLI worker yield is a second test-infrastructure fix carried in this PR, not a prerequisite for evaluating the runner expression, and there is no evidence here that the routing expression itself caused RPC starvation. The title and description distinguish both changes. The local evidence establishes a real macrotask draining between synchronous tests under real and fake timers. It also reproduced the cleanup regression introduced by that yield, fixed it by unmounting old fixtures, and verified the unchanged replay assertion still detects an actual replay reset. It does not independently establish the historical 650-case RPC stress result or a Linux timeout-rate improvement. Those limits are stated in the verification report; the fresh Linux suite is still running.

No application behavior or manual-dispatch policy was changed during this closeout.

中文:本次路由修复针对 #14219 已观测到的 main push;手动 dispatch 的既有非对称没有修改,也没有声称测量其排队耗时。CLI yield 是同 PR 中的第二项测试基础设施修改,不是路由表达式的必要条件,不能据此推断路由造成 RPC 饥饿。本地证明了真实/假时钟下测试之间会让出宏任务,复现并修复了 yield 暴露的旧 render 实例污染,负对照也确认原 replay 断言仍有效;没有独立验证历史压力实验或 Linux 超时率改善。当前 Linux CI 仍在运行,验证报告保留这些边界。

@qwen-code-review-bot

qwen-code-review-bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Code review

My independent proposal before opening the diff was: reuse the runner-selection expression the downstream jobs already read, add the one missing event arm, and don't build new machinery. That is exactly what this does — one clause appended to an expression that already existed, with the comment updated to match. On the test-infra half I would have reached for a captured-real-timer yield in the package's setup file, and it turns out the repo already has that pattern, documented, in scripts/tests/test-setup.ts. This ports it verbatim rather than inventing a parallel one, which is the right call.

No blocking issues. What I verified rather than assumed:

  • The new push arm cannot widen the self-hosted trust boundary. ci.yml's push trigger is branches: ['main'], and scripts/tests/ci-platform-lanes.test.js pins that shape, so github.event_name == 'push' here can only mean code already merged to main. No fork can produce the event. The kill-switch still wraps the clause, and both the old and new arms fail toward ubuntu-latest.

  • The routing-test swap strengthens the guard instead of weakening it. The removed test asserted only the shell half for push, plus a doesNotMatch pinning the absence of the arm. The replacement evaluates the real runs-on text and executes the real pick_runner shell, asserting both halves agree under both kill-switch states. I traced the substitutions by hand: ecsDisabled=false, eventName=push yields ECS on both halves, ecsDisabled=true yields hosted on both. The added github.event_name == 'push' substitution is load-bearing, not cosmetic — without it the function's trailing "carries a term the matrix does not model" assertion throws, so an edited expression fails loud instead of passing silently. The insertion point is also safe: the new pattern is quote-anchored on == 'push' and cannot match inside the != 'pull_request*' patterns whose longest-first order the file's comment depends on.

  • The AGENTS.md workflow meta-test rule is satisfied. Nine files under scripts/tests/ parse ci.yml; none of them reads classify_pr['runs-on']. The one place that pins the expression is .github/scripts/ci-runner-routing.test.mjs, which this PR updates. ci-platform-lanes.test.js pins classify_pr's if: allowlist, and this PR does not touch that line.

  • The captured-timer mechanism is order-safe under every fake-timer installation point I could construct. Setup files evaluate before the test file is imported, so vi.useFakeTimers() at module scope, in beforeAll, or in beforeEach all land after const realSetTimeout = setTimeout has captured the real global. And setup-file hooks run ahead of file-level hooks, so a suite that installs fake timers in its own beforeEach cannot starve the yield that precedes it. No deadlock path found.

  • The MainContent diagnosis holds, and the fix does not mask a product defect. staticItemsSpy is file-scoped and the model-change guard asserts .at(-1). Earlier tests render ink trees that were never unmounted; a global yield now hands those trees an event-loop turn, so they re-render and append to the shared spy after the test's own mockClear(). afterEach(cleanup) is the correct fix and matches existing convention in ContextMenuContext.test.tsx and use-text-selection.test.tsx. Production unmounts normally, so this is a fixture leak rather than a missing effect cleanup — and the mutation check (a genuinely model-triggered reset still fails the 203-item assertion) is the right way to demonstrate the guard survived the cleanup.

Non-blocking, but worth your attention:

  1. The yield is global to packages/cli; the cleanup is one file. Roughly forty files import render from ink-testing-library and only three call cleanup. Any of them holding a file-scoped spy that is asserted positionally can now surface the same class of failure, because every test boundary yields where none did before. Nothing in the diff tells us whether MainContent was the only such file — only the full suite does.

  2. The new test arms its flag with a different binding than the mechanism it pins. event-loop-yield.test.ts queues via import { setTimeout } from 'node:timers', while test-setup.ts captures the global setTimeout. It is still load-bearing — if the setup's captured timer were faked, the beforeEach promise would never resolve and the file would die on hookTimeout rather than pass quietly — but the precedent it mirrors arms with the plain global, so a reader may reasonably wonder which binding is under test.

  3. workflow_dispatch keeps the asymmetry this PR removes for push (raised in the gate comment). With the default linux_runner: self-hosted, dispatch still parks classify_pr on hosted Linux while sending its dependents to ECS.

  4. Cost: about 1ms of real timer per test, across the largest suite in the repo. The same tradeoff is already accepted in scripts/tests; noting it only because the multiplier is much bigger here.

I skipped the sequence diagram and the changed-files table — five files, CI config and test infrastructure, no runtime flow to trace and no navigation problem for a reviewer to solve.

Test evidence

Unattended CI run: I did not build, run, or check out any of this PR's code. Everything below is the PR's own CI, read through the API for 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1.

Final CI results for 3066a0e (auto-updated by the triage finalize job after CI completed):

Check Conclusion
Classify PR ✅ success
Integration Tests (no-AK, No Sandbox) ✅ success
Lint & Static (ubuntu-latest, Node 22.x) ✅ success
OpenTUI no-flicker gate ✅ success
Test (ubuntu-latest, Node 22.x) ✅ success
TUI parity snapshots (ink vs opentui) ✅ success
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ✅ success

One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。

No check is red at the time of writing. Lint & Static passing is meaningful for this diff specifically: it is the lane that runs the .github/scripts helper suites, so ci-runner-routing.test.mjs is green against the edited expression, and it also settles formatting and typecheck for the two TypeScript files.

Two honest gaps in what CI can tell us here:

  • Test (ubuntu-latest, Node 22.x) is the decisive check for the test-infra half and it is still running. It is the only lane that executes the full packages/cli suite under the new global yield, which is precisely what observation 1 above needs. The author states plainly that full Linux CLI CI was not claimed locally, and I have not re-run anything — so this is unverified until that check lands, and I have deferred my verdict accordingly.
  • The macOS and Windows Test lanes are skipped on pull_request, so the yield change gets no non-Linux signal from this PR at all. The first one will be the nightly. The change itself is platform-neutral, so I do not read this as a risk — just as the reason "author tested on macOS only" is the whole of the local evidence.

On sandboxed lanes: neither /verify nor /tmux can settle anything this PR claims, so I am not naming one. /tmux has no surface — no product CLI or renderer behavior changes. /verify does A/B against the base product build, and the central claim here is GitHub Actions runner scheduling, which no sandboxed product lane can observe. The routing decision itself is already substantiated pre-merge by a regression test that evaluates the real expression text and executes the real selector shell; the latency outcome is only observable on the first post-merge push to main, as the description says. The remaining open question — whether the global yield breaks any other CLI suite — is settled by the pending Linux Test check above, not by a lane.

中文说明

代码审查

我在看 diff 之前的独立方案是:复用下游任务已经在读的那个 runner 选择表达式,补上缺失的那一个事件分支,不要引入新机制。这个 PR 做的正是如此——只在既有表达式后追加一个分支,并同步更新了注释。测试基础设施那一半,我本来会想到在包的 setup 文件里用"捕获真实定时器再 yield"的做法,而仓库里其实已经有这个模式,并且带完整文档,就在 scripts/tests/test-setup.ts。本 PR 是原样移植而非另造一套,这个选择是对的。

没有阻断性问题。以下是我核实过、而非默认成立的几点:

  • 新增的 push 分支不会放宽 self-hosted 的信任边界。 ci.yml 的 push 触发是 branches: ['main'],且 scripts/tests/ci-platform-lanes.test.js 固定了这一形状,所以这里的 github.event_name == 'push' 只可能代表已合入 main 的代码,fork 无法产生该事件。kill-switch 仍然包住该分支,新旧分支的失败方向都回落到 ubuntu-latest。

  • 路由测试的替换是加强而非削弱守卫。 被删掉的测试只断言了 push 时的 shell 一半,外加一个固定"表达式中不含该分支"的 doesNotMatch。替换后的测试同时求值真实的 runs-on 文本、执行真实的 pick_runner shell,并断言两种 kill-switch 状态下两半一致。我手工推演了替换过程:ecsDisabled=false, eventName=push 两半都得到 ECS,ecsDisabled=true 两半都得到托管。新增的 github.event_name == 'push' 替换项是关键而非装饰——缺了它,函数末尾"表达式含有矩阵未建模的项"的断言会抛错,因此表达式被改动时会明确失败,而不是静默通过。插入位置也是安全的:新模式以 == 'push' 的引号锚定,不可能匹配进那些依赖"最长优先"顺序的 != 'pull_request*' 模式内部。

  • 满足 AGENTS.md 的 workflow 元测试规则。 scripts/tests/ 下有九个文件解析 ci.yml,没有一个读取 classify_pr['runs-on']。唯一固定该表达式的是 .github/scripts/ci-runner-routing.test.mjs,而本 PR 已更新它。ci-platform-lanes.test.js 固定的是 classify_pr 的 if: 白名单,本 PR 未改动该行。

  • 捕获真实定时器的机制在各种 fake timer 安装时机下都是安全的。 setup 文件先于测试文件求值,因此无论 vi.useFakeTimers() 写在模块顶层、beforeAll 还是 beforeEach,都发生在 const realSetTimeout = setTimeout 捕获真实全局之后。而且 setup 文件的 hook 先于文件级 hook 运行,所以在自己的 beforeEach 里装 fake timers 的套件不会饿死它前面的 yield。没有找到死锁路径。

  • MainContent 的诊断成立,且修复没有掩盖产品缺陷。 staticItemsSpy 是文件级共享的,而模型切换守卫断言的是 .at(-1)。文件里更早的测试渲染的 ink 树从未卸载;全局 yield 现在给了这些树一轮事件循环,于是它们重新渲染,并在该测试自己 mockClear() 之后继续往共享 spy 里追加调用。afterEach(cleanup) 是正确的修法,也与 ContextMenuContext.test.tsx、use-text-selection.test.tsx 中的既有约定一致。生产环境会正常卸载,所以这是测试 fixture 泄漏,而不是缺失的 effect cleanup——而受控注入(真正由模型触发的重置仍会让 203 项断言失败)正是证明该守卫没有在 cleanup 之后被削弱的正确方式。

不阻断、但值得注意:

  1. yield 对整个 packages/cli 生效,cleanup 却只加在一个文件。 约四十个文件从 ink-testing-library 导入 render,只有三个调用 cleanup。任何一个持有文件级共享 spy 且按位置断言的文件,现在都可能暴露出同一类失败,因为每个测试边界都会 yield,而此前不会。diff 本身无法告诉我们 MainContent 是否是唯一这样的文件——只有跑完整套件才知道。

  2. 新测试用来置位的绑定,与它要固定的机制并不是同一个。 event-loop-yield.test.ts 通过 import { setTimeout } from 'node:timers' 排队,而 test-setup.ts 捕获的是全局 setTimeout。它仍然是有效的——如果 setup 捕获的定时器被 fake 掉,beforeEach 的 promise 永不 resolve,该文件会因 hookTimeout 失败而不是静默通过——但它所镜像的先例用的是普通全局,读者有理由疑惑到底在固定哪个绑定。

  3. workflow_dispatch 仍保留本 PR 为 push 去掉的那种非对称(已在 gate 评论中提出)。在默认 linux_runner: self-hosted 下,dispatch 依然把 classify_pr 留在托管 Linux,同时把其下游送到 ECS。

  4. 成本: 每个测试约 1ms 真实定时器,作用在仓库里最大的套件上。scripts/tests 已经接受了同样的取舍,这里只是提醒倍数量级不同。

我省略了时序图和改动文件总览表——五个文件、CI 配置与测试基础设施,没有需要梳理的运行时流程,也不存在需要为 reviewer 解决的导航问题。

测试证据

无人值守 CI 运行:我没有构建、运行或检出本 PR 的任何代码。以下全部内容来自 PR 自身的 CI,通过 API 读取 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1 的检查结果。

(CI 表格见上方英文部分的机器可读区域。)

撰写时没有任何检查为红。Lint & Static 通过对这个 diff 有具体意义:它就是运行 .github/scripts 辅助测试套件的那条 lane,所以 ci-runner-routing.test.mjs 在被修改的表达式上是绿的;它同时也确认了两个 TypeScript 文件的格式化与类型检查。

关于 CI 在此处能告诉我们什么,有两个诚实的缺口:

  • Test (ubuntu-latest, Node 22.x) 是测试基础设施那一半的决定性检查,而它仍在运行。 它是唯一会在全局 yield 下执行完整 packages/cli 套件的 lane,也正是上面第 1 点所需要的证据。作者明确说明本地未主张跑完整 Linux CLI CI,我也没有重跑任何东西——因此在该检查落地前这一点属于未验证,我据此推迟了结论。

  • macOS 与 Windows 的 Test lane 在 pull_request 上被跳过,所以本 PR 对 yield 改动完全没有任何非 Linux 信号,第一次要等到 nightly。改动本身与平台无关,因此我不认为这是风险——这只是"作者仅在 macOS 上测试"即为全部本地证据的原因。

关于沙箱验证 lane:/verify 和 /tmux 都无法确证本 PR 的任何主张,所以我不点名任何一个。/tmux 没有可测表面——产品 CLI 与渲染行为都没有变化。/verify 做的是与 base 产品构建的 A/B 对比,而本 PR 的核心主张是 GitHub Actions 的 runner 调度,任何沙箱产品 lane 都观察不到。路由决策本身在合并前已由一个"求值真实表达式文本 + 执行真实选择器 shell"的回归测试确证;而排队延迟这个结果只能在合并后第一次 push 到 main 时观察到,正如描述所说。剩下那个未决问题——全局 yield 是否会破坏其他 CLI 套件——由上方仍在运行的 Linux Test 检查来回答,而不是由某个 lane。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1 · re-run with @qwen-code /triage

@yiliang114 yiliang114 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

COMMENT — code review on head 3066a0e12a. Two disjoint scopes share this PR; both are clean.

Scope 1 — CI routing fix. The push event is added to classify_pr's runs-on expression so the post-merge classifier goes to the same ECS pool as the Test job it feeds. The old "keep push out of the expression" test is correctly removed and replaced with a "both halves agree on push" assertion. The comment about the deliberate asymmetry is also removed from ci.yml. Both changes are coherent and the test rewrite is tighter than the original.

Scope 2 — Test infrastructure hardening. MainContent.test.tsx gains afterEach(cleanup) (prevents cross-test fixture leaks in the progressive-replay suite), test-setup.ts gains a beforeEach macrotask drain (lets worker RPC replies settle between tests), and event-loop-yield.test.ts is a new 33-line harness that proves the drain works under both real and fake timers. The harness is a nice minimal witness — it would fail under a regression that breaks the drain.

No blockers. Both scopes are PR-caused and bounded. The verification report at 10-16 07:51 records 37/37 passes on the CI-routing test plus the new yield harness.

中文

COMMENT — 在 head 3066a0e12a 上的代码评审。两个不相关的范围共享这张 PR;两边都干净。

范围 1 — CI 路由修复。 push 事件被加进 classify_pr 的 runs-on 表达式,让 post-merge 分类器跟它喂的 Test job 走同一个 ECS 池。旧的「push 故意留在 hosted」测试被正确删掉,换成「两半在 push 上一致」的断言。ci.yml 里关于故意不对称的注释也一并删掉。两边改动一致,测试重写比原版更紧。

范围 2 — 测试基建加固。 MainContent.test.tsx 加了 afterEach(cleanup),test-setup.ts 加了 beforeEach 宏任务 drain,event-loop-yield.test.ts 是新的 33 行 harness。无阻塞,两个范围都是 PR 引入且有界。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 4/5 — clean, minimal, and it reuses a mitigation this repo already proved rather than inventing one; the nits are real but none is a reason to hold it, and the only thing between this and an approval is the Linux suite still running.

Stepping back, the scope question I raised at the gate turned out to be my misreading, not the PR's. scripts/tests/test-setup.ts already carries this exact captured-real-timer yield, with a comment naming vitest's fixed 60s onTaskUpdate RPC budget and the failure class behind #10438. So the CLI half is not a second unrelated fix that hitched a ride on a CI change — it extends an established, documented mitigation to the one large suite that was absorbing the same risk with dangerouslyIgnoreUnhandledErrors instead of a yield, and it is more likely to bite now that more post-merge work lands on the shared pool. The MainContent cleanup has to ship with it, because the yield is what exposed the leak. The three changes belong together.

The routing fix I would merge without hesitation. I traced the mechanism in the base YAML instead of trusting the description, and the story holds: the gate had no push arm while its own selector step did, so a merge parked a four-second job behind a hosted queue and every needs: classify_pr job waited on it. The new arm cannot admit anything untrusted, because the push trigger is branches: ['main'] and a meta-test pins that. The kill-switch still wraps it and both arms fail toward hosted. And the test it swaps in is stronger than the one it deletes — it evaluates the real expression text and executes the real selector shell under both kill-switch states, where the old one only asserted an absence.

What keeps this at 4 rather than 5 is small, and I don't want to overstate it:

  • workflow_dispatch still carries the asymmetry this removes for push. Not a defect — dispatch behaviour is untouched here, it is manual and rare, and a human is watching it. But the fix stops one event short of the general shape and the comment doesn't say why, so the next reader repeats my investigation.
  • The yield is suite-wide; the cleanup is one file. If another CLI file holds a positional assertion on a shared spy, we find out when the Linux check lands rather than now. That is a discoverable, fixable failure, not a blocking one.
  • The new yield test pins the mechanism through a different timer binding than the mechanism uses. It still fails loud if the capture breaks, so it earns its place; it just doesn't read as obviously as it could.

None of that is worth another round, and I'd rather name it than manufacture a blocker out of it.

Verdict: approve. The Linux Test check on this commit is still in flight, so I'm deferring the approval until CI lands green on the reviewed commit rather than attesting to a result that doesn't exist yet — the finalize job posts the commit-pinned approval once every check on that SHA completes, and withholds it if anything goes red or the head moves.

中文说明

Confidence: 4/5 —— 干净、最小化,并且复用了本仓库已经验证过的缓解手段而非另造一套;那些小问题是真实存在的,但没有一个构成拦下它的理由,而它与"批准"之间唯一的距离就是仍在运行的 Linux 套件。

退一步看,我在 gate 阶段提出的"范围"问题,结果是我读错了,而不是 PR 的问题。scripts/tests/test-setup.ts 里已经有这个完全相同的"捕获真实定时器再 yield"的做法,注释中还点名了 vitest 固定的 60 秒 onTaskUpdate RPC 预算,以及 #10438 背后的那类失败。所以 CLI 那一半并不是搭车夹带的第二个无关修复——它是把一个既有且有文档的缓解手段,扩展到唯一一个此前用 dangerouslyIgnoreUnhandledErrors 而非 yield 来吸收同类风险的大套件上;而在更多合并后的工作落到共享池之后,这个风险更容易被触发。MainContent 的 cleanup 必须与它一起合入,因为正是这个 yield 暴露了那处泄漏。这三处改动属于同一件事。

路由修复我会毫不犹豫地合入。我是在 base 分支的 YAML 里自己追出了机制,而不是采信描述,而这个故事是成立的:闸口任务没有 push 分支,而它自己的选择器 step 有,于是一次合并把一个四秒钟的任务堵在托管队列后面,所有 needs: classify_pr 的任务都得等它。新增分支不可能放进任何不可信代码,因为 push 触发是 branches: ['main'],而且有元测试固定这一点。kill-switch 仍然包住它,两个分支的失败方向都回落到托管。而它替换进来的测试比被删掉的更强——它在两种 kill-switch 状态下求值真实表达式文本并执行真实的选择器 shell,而旧的只是断言"某个东西不存在"。

让它停在 4 分而不是 5 分的地方都很小,我也不想夸大:

  • workflow_dispatch 仍保留本 PR 为 push 去掉的那种非对称。 这不是缺陷——dispatch 的行为在此处未被改动,它是手动的、少见的、有人盯着的。但这个修复在离完整形态还差一个事件的地方停下了,注释也没说明原因,于是下一个读者要重做我这次排查。
  • yield 作用于整个套件,cleanup 只加在一个文件。 如果还有别的 CLI 文件对共享 spy 做位置断言,我们要等 Linux 检查落地才知道,而不是现在。那是可发现、可修复的失败,不是阻断性的。
  • 新的 yield 测试通过与该机制所用不同的定时器绑定来固定它。 如果捕获被破坏它仍会明确失败,所以它有存在价值;只是读起来没有它本可以的那样直白。

这些都不值得再来一轮,我更愿意把它们说出来,而不是从中硬造一个阻断项。

结论:批准。该提交上的 Linux Test 检查仍在进行,因此我把批准推迟到 CI 在被审查的提交上全绿之后,而不是为一个尚不存在的结果背书——所有检查在该 SHA 上完成后,收尾任务会发出与该提交绑定的批准;若有任何检查变红或 head 发生移动,则不予批准。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at 3066a0e12aa112d428e48f8d925c2b4e49fdbfe1 · re-run with @qwen-code /triage

@yiliang114 yiliang114 added the type/enhancement Non-bug improvement or optimization label Oct 16, 2026

@chiga0 chiga0 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking findings.
Approval blockers: none.

Tier: Standard — two independent scopes: CI YAML routing and test infrastructure.

Checked:

  • CI routing correctness (Class 10 / stated intent): Adding || github.event_name == 'push' to classify_pr's runs-on expression aligns the classifier with the downstream Test jobs. The old asymmetry (classifier hosted, jobs on ECS) caused ECS-bound jobs to queue behind a late classifier, confirmed by the "49m32s" wait cited in the PR body.
  • Test expression coverage (Class 5): The evalRunsOn substitution table now includes [/github\.event_name == 'push'/, ...], which was previously absent — meaning the old routing tests silently skipped evaluating the push condition in the expression. The updated test routes the push classifier and downstream jobs to the same pool evaluates both evalRunsOn and runPickRunner under ECS-enabled and kill-switched modes.
  • Event-loop yield (test-setup.ts): realSetTimeout is captured before any test suite can install fake timers. The beforeEach macrotask boundary runs after each test, allowing queued worker RPC replies to drain before the next assertion window opens. The new event-loop-yield.test.ts proves the boundary works under both real and fake timer modes with a concrete macrotaskRan flag.
  • MainContent.test.tsx cleanup: afterEach(cleanup) prevents stale ink renders from leaking across tests. Consistent with Ink testing best practice.
  • Cross-check: yiliang114 COMMENTED (no blockers) confirming 37/37 passes on the CI-routing test and the new yield harness.

Not covered: Windows runner behavior not exercised (no test coverage claimed for Windows); workflow_dispatch routing asymmetry explicitly scoped out per author.

Reviewed with AI assistance.

@qwen-code-review-bot qwen-code-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, looks ready to ship — CI landed green after the review. ✅

@yiliang114
yiliang114 merged commit 631b860 into main Oct 16, 2026
122 of 123 checks passed
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/self-reported The linked issue was opened by the PR author (self-reported) type/enhancement Non-bug improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ci: post-merge Classify PR is pinned to a congested hosted runner and gates every job — 4s of work behind a 49-64min queue

3 participants