Repository navigation
fix(traex): 容量耗尽后独立后继回合等 composer 再投递,并钉住对应回归 - #2240
Merged
Merged
Conversation
「resumes exact native history through exhaustion」用例在等待点只等 next ask 的 submission 落盘,随后立即断言 launches 有 4 条;高负载 CI 上 preferred-model 重启的 launch 记录可晚于断言点,产生 expected [core,backup,last,core] received [core,backup,last] 的偶发失败 (干净 master 并行压测约 1/30)。 改为等待两个持久化条件都齐:第 4 次 launch 落盘且 next ask 仅以 model=core 提交一次。纯时序竞态由此确定性转绿;若输入被切换前的旧 last 进程消费,等待永远不满足、按 35s 超时确定性失败,不会把真实的 投递错配洗成假绿。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 23, 2026 19:08
resetTraexAutoModelBeforePendingTurn 在 !isPromptReady 时只返回 traexAutoModelInputHold():结构化 turn_terminal 已释放活动回合、但 PTY composer 尚未重新渲染的窗口里,该闸门既不切换也不 hold。随后 flushPending 因 !promptReadyAtFlushStart 把后继消息判成前一回合的 type-ahead correction,直接写进仍停在降级模型(如 last)的旧 pane: 后继回合从未触发 last -> core 的 new_turn 切换,turnId 也被记到前一 回合,卡片与用量归属随之错误。高负载 CI 的 bun 集成用例确定性暴露 (三次 spawn 后无第 4 次 core,next ask 落 last)。 在非就绪分支前加一道:isPromptReady 为假且活动回合权威已释放 (activeTurnAuthority.snapshot() 为空)时一律 hold,等真正的 idle/ composer 边沿再驱动 flush——届时按配置做首选模型切换,并把消息作为 独立回合写入。该判定与 reselectPerTurn / 当前池下标无关:回合归属 正确性不依赖是否重选模型;活动回合仍在时的正常 type-ahead correction (authority 已 started)走原路径不受影响。 测试:原 running follow-up 两例补上 started authority(此前夹具从未 覆盖权威已释放形态);新增两例钉住终态后 hold(reselect=true 等到 composer 后触发切换;reselect=false 同样 hold、composer 后不切换直接 放行)。删除该闸门两新例确定性失败。 Co-Authored-By: Claude Code <[email protected]>
上一提交的终态闸门只看 activeTurnAuthority.snapshot():queued type-ahead 后继回合已写入同一 native pane、其 BotMux 权威要到下一个 prompt 边沿才 推进,前一回合 terminal 一释放权威即为空——闸门把发往存活后继的正常 correction 也拦下等 composer(后继不结束就不重绘),desync 复现用例 auto=false/true 两形态在 node 与 bun CI 上确定性超时。 存活判据补上 queuedTypeAheadTurns.length === 0:该队列非空等价于本 generation 确有消息作为 type-ahead 写进当前活 pane(pane 死亡的 restart/exit 路径会清空队列),后继 native 回合仍在运行,correction 必须继续 steer。authority 与该队列皆空、composer 未回时才 hold 等 idle 边沿。 - 删除重复的一行 if (traexAutoModelSwitching) return true; - 三个既有单测 scope 补 queuedTypeAheadTurns: [](旧夹具从未构造过 「权威已释放」形态);新增正例:权威已释放但 type-ahead 队列非空时 不 hold,钉住存活后继 steer 路径。 变异:去掉 queuedTypeAheadTurns 条件,新增正例与 desync 集成两形态 确定性失败;删掉整道闸门,两个终态 hold 单测确定性失败。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
added a commit
that referenced
this pull request
Oct 23, 2026
同步最新 master(含 #2240/#2213,均碰 traex 测试相关文件); merge-tree 零冲突,本 PR 11 文件改动逐字保留(10 文件 patch-id 相同, traex-auto-model 仅 hunk 上下文变化,增删行逐字核实一致)。 Co-Authored-By: Claude Code <[email protected]>
This was referenced Oct 23, 2026
deepcoldy
added a commit
that referenced
this pull request
Oct 24, 2026
复审 #2246 时确认:sendToPty 入队谓词的第二支(queueObserved() 且活动回合权威已 释放)没有任何可达的正向窗口——S1/S3(composer 先于终态、耗尽后仍排队)都由 capacityCurrentlyBlocking() 覆盖,S2(终态先到、composer 后到)由 resetTraexAutoModelBeforePendingTurn 在 #2240 加入的 flush 闸门 hold。该支唯一为真 的形态是 exhausted 闩锁在 reselectPerTurn 关闭(默认)下跨回合残留、而 pane 早已 离开排队之后的所有独立输入,会把它们误标成排队后继,持续抑制相邻消息合并与 markNewTurn/usage 回合起算。删除后行为不变、全套 traex 测试仍绿,粘连风险消失。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 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.
问题
resumes exact native history through exhaustion集成用例在 CI 高负载下红(node vitest 与 bun test 都出现过):收紧等待条件后 bun CI 确定性超时,证明不是落盘时序问题,而是真实的输入投递错配。bun run(job 120604261625)的 worker 日志:
根因(src/worker.ts
resetTraexAutoModelBeforePendingTurn)容量三次排队、模型池在
last耗尽后,结构化turn_terminal释放了活动回合,但 PTY composer 还没重新渲染(isPromptReady === false)。此时非就绪分支只返回traexAutoModelInputHold()(该帧为 false:切换已结束、不在等模型活动、不是 capacity 屏),首选模型重置闸门被直接跳过。flushPending因!promptReadyAtFlushStart把后继消息判成前一回合的 type-ahead correction:last的旧 pane,new_turn: last -> core从未发生;修复
src/worker.ts非就绪分支增加闸门,三个条件同时成立才 hold 等真正的 idle/composer 边沿:activeTurnAuthority.snapshot():BotMux 自己的活动回合权威(本 generation 写入、仍在跑)。queuedTypeAheadTurns:已作为 type-ahead 写进当前活 pane、归属要到下个 prompt 边沿才推进的后继回合。它非空时,即使前一回合 terminal 已释放权威,后继 native 回合仍在运行,下一条 correction 必须继续 steer(pane 死亡的 restart/exit 路径会清空该队列,不会误判活 pane)。活动回合仍在时的正常 type-ahead correction 走原路径;判定与
reselectPerTurn/ 池下标无关,因为归属正确性独立于是否重选模型。test/traex-auto-model.integration.test.ts:等待条件从「只等 next ask submission」改为「第 4 次 launch 落盘 + next ask 恰好一次且 model=core」。真实错配发生时确定性超时,而不是在落盘顺序上偶发断言。验证
queuedTypeAheadTurns: [];新增两例钉终态 hold(reselect=true composer 后切换 / reselect=false composer 后直接放行),一例钉权威已释放但 type-ahead 队列非空时继续 steer。queuedTypeAheadTurns.length === 0→ steer 正例与 desync 复现集成两形态(auto=false/true,node 与 bun)确定性失败。bun run build(tsc + 打包 + 产物审计)通过。影响面:仅 TraeX 自动模型池受管会话的回合边界准入;其它 CLI、其它后端、活动回合内的 type-ahead 不受影响。
🤖 Generated with Claude Code