--- id: T-102 title: 实现 Windows 进程身份查询和外部实例保守识别 phase: 1 deps: [T-101] status: DONE created: 2026-07-22 owner: codex --- ## 需求与背景 Chub 重启后不能只依赖本进程 registry 判断 profile 状态;需要读取 Windows 进程和 Chromium profile 的系统证据,同时避免误认或误关闭外部进程。 ## 方案与边界 - Windows 使用 `QueryFullProcessImageNameW` 查询 executable,使用进程句柄和 `WaitForSingleObject` 判断存活。 - 使用 `Chrome_MessageWindow` + user data dir 识别 Chrome/Edge profile singleton。 - 使用 lockfile sharing violation 作为占用证据;stale lock 和 stale PID 只记录来源,不转化为可关闭实例。 - executable 名称必须与浏览器类型匹配;无法确认时返回 unknown source。 - 非 Windows 编译为明确 unsupported 降级。 ## 验收要点 - 当前测试进程可读取 executable 和 alive 状态。 - Chrome/Edge executable 类型匹配校验通过。 - 外部 profile 检查不会只凭历史 PID 直接授权关闭。 - `go test ./...`、`go vet ./...` 通过。 ## 执行记录 - 状态:DONE - 变更:新增跨平台 identity port、Windows Win32 实现、message window/lockfile profile inspector 和非 Windows 降级。 - 验证:`gofmt`、`go test ./...`、`go vet ./...` 均通过;包含真实 Windows 当前进程查询。 - 阻塞:无。 - 残余风险:真实 Chrome/Edge profile lock 占用仍需 T-104 用临时 profile smoke 验证。