Repository navigation
test(traex): 修复 auto-model 容量切换通知计数的跨通道时序 flake(#2260) - #2267
Merged
Merged
Conversation
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 24, 2026 06:48
This was referenced Oct 24, 2026
|
🚀 Released in v3.51.0 |
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/traex-auto-model.integration.test.ts>「prefers the earlier available model, proceeds if it queues, then retains it for the next turn」在 CI 上间歇失败(真实 worker + PTY):跨通道时序竞态:用例
f.wait(() => rows(f.submissions).length === 3)等的是 PTY 写入通道(fake CLI 的 submissions 文件),紧接着却在另一条异步 worker IPC 通道(f.messages)上断言容量切换通知有 2 条,没有等待该通道。生产代码里 worker 是先发user_notify再restartCliProcess(通知严格早于重启),但 worker→测试的 IPC 投递在 runner 高负载下会晚于重启后第 3 条 submission 落盘,于是断言时刻只看到 1 条。跨树复现记录见 #2260:不含本 PR 相关改动的 master run(d58850919)在同一用例同一行以相同的 2→1 失败;更早三个 master run 通过;本地低负载整文件 10/10 通过——负载敏感。
改动(仅测试,不动 src)
f.wait到f.messages通道确实出现第 2 条通知(在同一通道上等待再断言)。delaySecondModelOrderNoticeMs:生成一个 worker bootstrap,把第 2 条容量切换通知的process.send延迟指定毫秒,确定性复现「通知晚于第 3 条 submission 到达」。该用例启用 4000ms(本地实测通知领先第 3 条 submission 仅 2–3 秒,4s 稳定反转到达顺序;对 100s 用例超时余量充足)。钩子默认 0、完全不影响其他用例;同时把原有 activityMode 的 heartbeat bootstrap 与新钩子合并为同一段生成逻辑。变异证据(bun 1.4.4,本文件单跑)
即:守卫在真实延迟下旧写法稳定变红、新写法稳定通过,不依赖 CI 负载。
验证
bun test test/traex-auto-model.integration.test.ts:11 pass / 0 fail(本地两次全文件跑)合入后 #2230 rebase/merge 本提交即可解除其 bun-test 门禁(#2260)。
🤖 Generated with Claude Code