Skip to content

fix(windows): 修复安装器运行时诊断调用 - #108

Merged
uvwt merged 1 commit into
mainfrom
fix/windows-runtime-diagnostics-20260914
Sep 14, 2026
Merged

uvwt merged 1 commit into
mainfrom
fix/windows-runtime-diagnostics-20260914

Conversation

@uvwt

@uvwt uvwt commented Sep 14, 2026

Copy link
Copy Markdown
Owner

修复内容

  • 让 Windows runtime diagnostics 测试显式接收并传递 AgentDock 原生 task launcher
  • Windows Installer workflow 在诊断步骤构建当前 AgentDock 二进制并传入测试
  • 修正 CLSIDFromProgID:从 oleaut32.dll 改为 ole32.dll
  • WTSGetActiveConsoleSessionId 改用 x/sys/windows 官方生成绑定,避免手写错误 DLL 映射
  • 增加 Windows-only COM / WTS procedure resolve 测试,防止动态 API 绑定错误只在运行时暴露
  • 增加 workflow/诊断脚本静态契约测试,防止 launcher 参数再次漂移
  • 修复标准用户安装 E2E 的等待方式:不再用 Start-Process -Wait 等整个长期运行进程树,改为只等待直接测试进程,并设置 10 分钟显式超时与失败日志输出
  • Windows PowerShell 5.1 下 Start-Process -Credential -PassThruExitCode 可能保持 $null;E2E 改用成功哨兵文件,Setup 用户上下文守卫改用结构化 Success=false + Code=setup-elevated-context 判定
  • Setup E2E 改为用真实 Core + Tray 构造可迁移的旧 PowerShell 安装,不再用生产逻辑明确拒绝的 marker-only 不完整夹具
  • 稳定 Windows shim 在 service launch-core 场景复用现有 Job Object 控制器持有 generation Core;Scheduled Task 被结束时由内核清理 Core,避免孤儿进程

原因

#107 将临时 Scheduled Task 的启动收敛到 agentdock service task-start 后,正式 Windows Installer workflow 暴露了三层运行时遗漏:

  1. diagnostics 仍按旧接口调用 launch-windows-process.ps1,缺少必填 -AgentDockBinary
  2. CLSIDFromProgID 错误绑定到 oleaut32.dll,进入原生 Task Scheduler COM 后 panic
  3. WTSGetActiveConsoleSessionId 错误绑定到 wtsapi32.dll;该入口实际由 kernel32.dll 导出

进一步完整验证还发现三处既有测试封装问题:

  • main 上标准用户 E2E 已连续多次在同一步挂满 GitHub 6 小时,因为 Start-Process -Wait 会等待长期运行的 AgentDock 后代进程
  • 改为直接进程等待后,Windows PowerShell 5.1 的 -Credential 路径真实复现到 ExitCode=$null;产品安装、就地升级和 redirected manifest recovery 已实际通过,只是封装误判失败
  • Setup E2E 只创建 start-agentdock.ps1 标记却声称是旧安装,与现在“迁移前必须存在真实 Core/Tray”的生产安全边界冲突;修复测试夹具,不放宽生产保护
  • 夹具修正后又真实暴露 Scheduler 只结束稳定 shim、generation Core 继续运行的问题;稳定 shim 现在仅对 service launch-core 建立 kill-on-close Job,普通 CLI/update 调用保持原行为

现在测试链使用有界直接进程等待 + 显式成功/结构化结果,并用完整旧版布局验证一次性迁移。

验证

  • go test ./scripts/test -count=1
  • Windows amd64 go test -cinternal/desktopruntimescripts/test
  • Windows amd64 go vetcmd/agentdock-shiminternal/processinternal/desktopruntimescripts/test
  • Windows amd64 go test -ccmd/agentdock-shiminternal/processinternal/desktopruntimescripts/test
  • git diff --check
  • Windows Rescue 真机最小复现:Start-Process -Credential -PassThru + WaitForExit()ExitCode$null
  • GitHub Windows Installer workflow_dispatch:34835544019 在当前 head 7c15674 完整成功

@uvwt
uvwt force-pushed the fix/windows-runtime-diagnostics-20260914 branch 8 times, most recently from 1f9163e to 26e61d2 Compare September 14, 2026 06:44
@uvwt
uvwt force-pushed the fix/windows-runtime-diagnostics-20260914 branch from 26e61d2 to 7c15674 Compare September 14, 2026 10:55
@uvwt
uvwt merged commit df0093b into main Sep 14, 2026
8 checks passed
@uvwt
uvwt deleted the fix/windows-runtime-diagnostics-20260914 branch September 14, 2026 11:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant