Skip to content

fix: batch concurrency (#429), ghost-abort rescue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385) - #439

Closed
yeshilei-QWQ wants to merge 1 commit into
huiliyi37:mainfrom
yeshilei-QWQ:fix/concurrency-and-lifecycle-bugs
Closed

yeshilei-QWQ wants to merge 1 commit into
huiliyi37:mainfrom
yeshilei-QWQ:fix/concurrency-and-lifecycle-bugs

Conversation

@yeshilei-QWQ

Copy link
Copy Markdown
Collaborator

摘要 (Summary)

本 PR 修复了当前活跃存在的 5 项关键生命周期与并发稳定性缺陷(#429, #430, #431, #432, #385),并附带全量针对性单测与全量构建验证证据。


修复问题与变更详情 (Changes & Fixes)

  1. fix(coordinator): 顶层并发 delegate_batch 批级表隔离 ([bug] 顶层 delegate_batch 并发时 order.id 碰撞,批级共享表跨批互删/污染 #429)

    • 问题: 当顶层调用并发执行 delegate_batch 时,两批内相同 order.id(如 batch:0)发生碰撞,导致 batchPrewarmByOrder、batchStigmergyByOrder、policyCancelledIds 与 orderControllers 跨批互相覆盖/删除。
    • 修复: 在保持 order.id 外部展示与 dependsOn 解析稳定的前提下,引入内部隔离键 orderDispatchKey(order) 索引批级私有状态表,防止并发互相干扰。
    • 测试: src/agent/__tests__/coordinator-concurrency-tables.test.ts
  2. fix(agent): 看门狗误杀 rescue 后重置 abortController 与状态同步 ([bug] P7 watchdog ghost-abort rescue 结构性失效:rescue 后本轮仍被立即再中止 #430)

    • 问题: P7 watchdog ghost-abort rescue 后,abortController.signal.aborted 仍然为 true,后续步骤(如 compaction)立刻被中止;且未检查是否为用户显式 Esc 中止。
    • 修复: 区分看门狗超时中止与用户主动 Esc;仅在看门狗误杀且用户未主动 abort 时执行 rescue,重置 abortController 并清理看门狗中止标志位。
    • 测试: src/agent/__tests__/ghost-abort-rescue.test.ts
  3. fix(turn-orch): 清理工具批 abort drain 泄漏定时器 ([bug] 工具批 abort drain 竞速定时器不 clear 也不 unref(同类先例 #184) #431)

    • 问题: 工具批中止 drain 定时器既未 unref() 也未在批完成时 clearTimeout,导致定时器堆积并拖慢进程退出高达 6s。
    • 修复: 对 drain 定时器添加 drainTimer.unref?.(),并在 Promise 结算的 finally 块中执行 clearTimeout(drainTimer)。
  4. fix(mcp): MCP close 失败时保留连接登记供退出兜底清理 ([bug] MCP 连接 close 失败路径被提前摘除登记,子进程沦为孤儿 #432)

    • 问题: shutdownServer 等在 transport.close() 失败时提前将连接从 connections Map 中移除,导致进程退出阶段 killChildrenSync() 无法感知失败连接的僵尸子进程。
    • 修复: 调整清理逻辑,仅当 transport.close() 成功后才从 this.connections 移除;若异常则保留在表中,并设置 suppressReconnect,由 killChildrenSync() 在退出阶段兜底强杀。
    • 测试: src/mcp/__tests__/manager-close-failure.test.ts
  5. fix(skills): 兼容 Windows 反斜杠 SKILL.md 路径解析 ([bug] Windows 技能快照构建全线失败:endsWith('/SKILL.md') 正斜杠恒假导致 Missing linked skill resource(v3.29.0) #385)

    • 问题: Windows 下 current.path.endsWith('/SKILL.md') 因路径分隔符为 \ 导致恒为 false,技能资源包扫描失败。
    • 修复: 改用 basename(current.path) === 'SKILL.md' 进行跨平台路径判定。
    • 测试: src/skills/__tests__/skill-windows-path.test.ts

测试与验证证据 (Test Evidence)

  • 新增/针对性单测: 全部通过 (6/6 PASS)
    • src/skills/__tests__/skill-windows-path.test.ts ✔
    • src/mcp/__tests__/manager-close-failure.test.ts ✔
    • src/agent/__tests__/coordinator-concurrency-tables.test.ts ✔
    • src/agent/__tests__/ghost-abort-rescue.test.ts ✔
  • 子系统集成回归测试:
    • npm test -- src/mcp/__tests__/ src/skills/__tests__/: 233/233 PASS (0 failed)
  • 编译与构建:
    • npm run build: Build success in 6079ms (dist 包、Native 模块与 runtime checks 全绿)
    • npm run typecheck: Typecheck clean (pre-push hook 自动化校验通过)

… ghost abort rescue (huiliyi37#430), drain timer leak (huiliyi37#431), MCP orphan process (huiliyi37#432) and Windows skill path (huiliyi37#385)

- fix(coordinator): scope delegate_batch prewarm, stigmergy, orderControllers, and policy tables with orderDispatchKey(order) to prevent collisions during top-level batch concurrency (huiliyi37#429)
- fix(agent): clear watchdog abort state and reset abortController upon rescue if user has not explicitly aborted; differentiate watchdog stall from user Esc (huiliyi37#430)
- fix(turn-orch): unref tool abort drain timer and clear it in finally block to prevent lingering event loop timer leaks (huiliyi37#431)
- fix(mcp): do not drop connection registration when transport.close() throws so killChildrenSync can still terminate orphan processes (huiliyi37#432)
- fix(skills): use basename(current.path) === 'SKILL.md' instead of endsWith('/SKILL.md') for Windows path separator compatibility (huiliyi37#385)
huiliyi37 added a commit that referenced this pull request Oct 10, 2026
…ue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385)

内容已经 sync 流程合入(dev 收编记录:未检索到),本提交为作者署名落账(提交页归属)。

Co-authored-by: yeshilei-QWQ <89763253+yeshilei-QWQ@users.noreply.github.com>
huiliyi37 pushed a commit that referenced this pull request Oct 10, 2026
…, ghost-abort rescue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385)
@huiliyi37

Copy link
Copy Markdown
Owner

已通过 sync 流程合入 dev,感谢 @yeshilei-QWQ 的贡献 🎉

本 PR 的改动(fix: batch concurrency (#429), ghost-abort rescue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385))已经 sync 流程合入主仓(本次 sync),并已收录进 CONTRIBUTORS.md。

按仓库的双仓流程,公开仓 PR 不经 merge 按钮合入(保持 dev 主仓唯一事实源),现以 sync-merged 标记关闭。欢迎继续贡献!

@huiliyi37 huiliyi37 added the sync-merged 内容已通过 sync 流程合入 dev 主仓(PR 形态留痕,作者计入 CONTRIBUTORS) label Oct 10, 2026
@huiliyi37 huiliyi37 closed this Oct 10, 2026
huiliyi37 added a commit that referenced this pull request Oct 23, 2026
…ue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385)

内容已经 sync 流程合入(dev 收编记录:未检索到),本提交为作者署名落账(提交页归属)。

Co-authored-by: yeshilei-QWQ <89763253+yeshilei-QWQ@users.noreply.github.com>
huiliyi37 pushed a commit that referenced this pull request Oct 23, 2026
…, ghost-abort rescue (#430), drain timer leak (#431), MCP orphan process (#432) and Windows skill path (#385)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sync-merged 内容已通过 sync 流程合入 dev 主仓(PR 形态留痕,作者计入 CONTRIBUTORS)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants