Repository navigation
fix(dsh): honor cancellation when command probes finish - #8520
huangruiteng merged 1 commit into
Conversation
Signed-off-by: xiaobaifly7 <196511160+xiaobaifly7@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.1-sol · OpenAI · runtime_reported · max
动机 / Motivation
这项修复影响已启用 LoopX 自动续跑的 DSH 会话:用户或宿主取消一次维护任务时,命令探测可能恰好结束。旧版能在取消后接受刚返回的有效版本;非零结果和普通拒绝仍会进入备用探测,Driver 也可能把一次正常取消报成缺少 CLI。这次变更让已取消的探测统一返回不可重试的 aborted;Driver 安静结束这次尝试,不排队,未取消的备用路径仍可用。范围限于版本探测完成时的取消;不改变安装、版本下限、续跑授权、GoalBar 或其他故障诊断。
改动思路 / Approach
同一会话 Driver 和 AbortSignal 持有取消;命令解析器负责读取版本并返回原 typed 错误。 成功和拒绝都在现有 await 边界检查原 AbortSignal;沿用既有非重试错误和 Driver 消费,无需全局重试或更改宿主。 直接撤掉备用解析会破坏无取消的 Windows 或托管安装。正反路径都在同一解析器验证,未激活 Session 的 Driver 及 GoalBar 仍按原条件工作。 当前范围只在 resolver 完成时重新读取信号;Driver 生产代码继续使用原取消处理。 复用已有取消结果即可;把检查移到 Driver 会漏掉其他解析器调用者,改变 fallback 或延迟会引入无关风险。
具体改动 / Changes
依据 DSH 设计:docs/plans/2026-08-20-dsh-native-skill-driver.md,固定修订 d3ac3bd。逐项:Same-session cancellation — implemented;Retry ownership — implemented。
关键代码讲解
- cli.ts:380:探测完成先读信号,再决定能否采纳版本,因此晚到的有效结果也不能复活被取消的工作。
- cli.ts:385:普通拒绝若与取消重叠仍输出 aborted;未取消时原候选循环接续。已经是 typed aborted 的异常保持原语义。
- driver.spec.ts:470:维护控制器和 Driver 控制器不同,回归覆盖维护信号的来源;CLI 测试同时覆盖三种完成结果。生产代码只加了六行,其他两文件均为回归测试。
对主干的风险 / Risks
无阻断发现。 实际 Node 进程的成功、非零和 adapter 拒绝在取消后均成为 aborted 且只有一候选;基线一例接受旧结果、另外两例进入备用 runner。Driver 对照基线有 missing 警告,head 无警告、无排队。 真实子进程在未取消时先返回非零,第二候选仍被接受,版本下限和 argv 保持原合同。 完整的三个受影响测试文件共 112 项通过;host、client 和 tests TypeScript 配置、源包 build、DCO、diff/RFC 配对及公开边界检查均通过。精确差异的变更质量回执已验证。 #8521 在同一区域只改诊断;本地合成两变更后取消用例仍过,诊断缺陷单列,不影响本 head 的结论。
我的整体评价 / Verdict
精确 head:4e8fbaeb308eba2e0e7be060bcfe1d4a5f68321f。长程推进:正常取消不会被当成缺少 CLI 或激活另一候选,下一次合法触发仍可继续。用户体验:少一次误报警告,不需要重填配置。检查了命令解析、Driver 取消和现有 GoalBar service 调用。没有新增或修改渲染页面。 未在已安装 DSH、Windows 或旧 SDK 上重启会话;未查询远端 CI,也未跑整仓 premerge。本地 package build 不代表安装或合并资格。
English verdict: APPROVE — 4e8fbae; real spawned completion tests preserve cancellation and the uncancelled fallback, with no blocking finding.
Goal And Delivered Outcome
The resolver can report
missingafter a version probe completes at the same time its maintenance signal is cancelled. It checks cancellation only when the runner throws this module'sLoopXCliError('aborted'); a returned nonzero result or another rejected error is swallowed, and a late successful result can be accepted.Recheck the supplied signal when the probe resolves or rejects. Cancellation now remains a nonretryable
abortedresult, which the existing Driver suppresses, and no fallback candidate is probed after cancellation.main, fresh branch fromd3ac3bd8d69821ae5843b7cef5fdb6dcbc7cae74.Author Declaration
Implemented against
packages/dsh-loopx-plugin/src/cli.ts:resolveLoopXCommandandsrc/driver.ts:evaluateat the base above.src/cli.ts:resolveLoopXCommandtests/cli.spec.tsevaluatecatchtests/driver.spec.tsmaintenance-signal caseScope And Continuation
Complete within this cancellation race. Resolver preference, durable Windows runtime provisioning, diagnostic enrichment and GoalBar failure projection are independent. In particular, this does not implement the GoalBar work claimed in #8506.
Validation
4e8fbaeb308eba2e0e7be060bcfe1d4a5f68321f.tests/driver.spec.ts: 65 passed. CLIrunJsonCommandgroup: 22 passed; three unchanged mutation/reaping cases excluded.ERR_PNPM_VERIFY_DEPS_BEFORE_RUN; direct installed compiler/test-runner entrypoints were used without changing package or lock files.The tests exercise the actual resolver and Driver with controlled probe completions. They qualify cancellation handling, not installed-host recovery or the timing of a historical incident.
Frontend / Visual Evidence
Type of Change
LoopX Area
Technical Direction
Preserve the existing DSH Driver cancellation contract. No new capability, shared authority or migration claim.
Shared-authority RFC fixture impact
N/A; no shared-authority or storage semantics change.
Boundary Checklist