[Superseded] fix: release private desktop on worker launch failure #7

Closed
abaishu0730 wants to merge 59 commits from codex/desktop-leak-pr into main
pull from: codex/desktop-leak-pr
Owner

Superseded by #8 (#8).

The review correctly identified that this PR includes the unrelated ICDB WIP ancestry. The replacement is based directly on main and contains only 4 desktop-fix files. This PR is closed without merging.

The original validation statement attributing test_backup_recovery failure to the baseline is withdrawn. Sequential full-suite checks now pass: main 471 passed; replacement 480 passed. Both have one pywinauto STA warning. The replacement also fixes test-interface fidelity and both reader lifecycle boundaries.

Superseded by #8 (https://git.simgreek.com/Skyworth_Digital_Hardware/cbb-refresh-verify-795/pulls/8). The review correctly identified that this PR includes the unrelated ICDB WIP ancestry. The replacement is based directly on main and contains only 4 desktop-fix files. This PR is closed without merging. The original validation statement attributing test_backup_recovery failure to the baseline is withdrawn. Sequential full-suite checks now pass: main 471 passed; replacement 480 passed. Both have one pywinauto STA warning. The replacement also fixes test-interface fidelity and both reader lifecycle boundaries.
abaishu0730 added 59 commits 2026-11-05 13:58:11 +08:00
Author
Owner

审查结论:P0,不建议按当前形式合并

1. 合并范围(P0,阻塞)

本 PR 的 head 6327ad1 的父提交是 1acfbd6,即 #3 的 WIP 分支头。相对 main 实际包含 59 个提交、118 个文件、+15,837/−497;本提交自身只有 4 个文件、+137/−19。Gitea 当前显示 mergeable=true,合并会把 #3 的整栈 WIP 带入 main(#3 标注 draft,并写明“PR 保持 WIP,不合并发布”)。而 #7 的标题、描述和验证只覆盖桌面泄漏修复,容易误导合并者。

建议:

  • A(推荐):从 main cherry-pick 6327ad1 单独开 PR;已实测无冲突,结果正好 4 文件 / +137/−19。
  • B:若确实要叠加,把 #7 的 base 改为 codex/temp-issue-2-icdb-recovery,随 #3 验收后合并。
  • C:若现在就要合整栈,请先撤下 #3 的 WIP/draft,并安排 118 文件的完整审查。

2. 代码修复(通过)

DesktopWorker.__init__ 的构造期回滚覆盖 CreateDesktop / CreateJobObject / CreateProcess / thread.Close 四个失败点,顺序为“进程 → Job → Desktop”,原始异常保留;read_library_flag 把 pywinauto 导入前移,消除所述泄漏。目标 4 个测试文件 33 passed;新增 2 个测试在父提交 2 failed、在 head 2 passed,确实能抓住原 bug。

3. 测试保真度(P1)

tests/test_desktop_worker.py 的 fake Handle 同时实现 Close() 和 CloseDesktop(),Desktop 与 Job 共用。变异验证:把 desktop_worker.py:114 的 self.job.Close() 改成 self.job.CloseDesktop()(真实 Job 句柄没有该方法),测试仍 1 passed。建议拆分 FakeDesktop / FakeJob,只暴露正确方法并断言关闭顺序;补“进程已创建后失败”的 TerminateProcess 分支。

4. 验证声明(P2)

  • git diff --check 实际失败:mentor_adapter.py:1452-1454 有 3 条 trailing whitespace(文件为 CRLF,仓库 .gitattributes 使用 * -text)。git -c core.whitespace=cr-at-eol diff --check 才能通过;文档中的“通过”不准确。
  • 全量测试:本机 head 19 failed / 1295 passed,parent 19 failed / 1293 passed,失败清单完全一致(非本提交引入);PR 点名的 test_backup_recovery.py::test_invalid_source_does_not_touch_target 在 head / parent / main 均通过。请在作者环境复核并更新基线说明。

5. 其他(P2)

read_library_flag 的 CreateDesktop(1457)到 try(1463)之间仍有 Path(library) 等赋值;建议把 Desktop 创建放进 try/finally。同类函数 read_library_tree_image_map 也有相同模式。


审查基于 6327ad1 的 4 文件增量;#3 的 118 文件未逐行审查。

## 审查结论:P0,不建议按当前形式合并 ### 1. 合并范围(P0,阻塞) 本 PR 的 head `6327ad1` 的父提交是 `1acfbd6`,即 #3 的 WIP 分支头。相对 `main` 实际包含 **59 个提交、118 个文件、+15,837/−497**;本提交自身只有 **4 个文件、+137/−19**。Gitea 当前显示 `mergeable=true`,合并会把 #3 的整栈 WIP 带入 `main`(#3 标注 draft,并写明“PR 保持 WIP,不合并发布”)。而 #7 的标题、描述和验证只覆盖桌面泄漏修复,容易误导合并者。 建议: - **A(推荐)**:从 `main` cherry-pick `6327ad1` 单独开 PR;已实测无冲突,结果正好 4 文件 / +137/−19。 - **B**:若确实要叠加,把 #7 的 base 改为 `codex/temp-issue-2-icdb-recovery`,随 #3 验收后合并。 - **C**:若现在就要合整栈,请先撤下 #3 的 WIP/draft,并安排 118 文件的完整审查。 ### 2. 代码修复(通过) `DesktopWorker.__init__` 的构造期回滚覆盖 CreateDesktop / CreateJobObject / CreateProcess / thread.Close 四个失败点,顺序为“进程 → Job → Desktop”,原始异常保留;`read_library_flag` 把 `pywinauto` 导入前移,消除所述泄漏。目标 4 个测试文件 **33 passed**;新增 2 个测试在父提交 **2 failed**、在 head **2 passed**,确实能抓住原 bug。 ### 3. 测试保真度(P1) `tests/test_desktop_worker.py` 的 fake `Handle` 同时实现 `Close()` 和 `CloseDesktop()`,Desktop 与 Job 共用。变异验证:把 `desktop_worker.py:114` 的 `self.job.Close()` 改成 `self.job.CloseDesktop()`(真实 Job 句柄没有该方法),测试仍 **1 passed**。建议拆分 `FakeDesktop` / `FakeJob`,只暴露正确方法并断言关闭顺序;补“进程已创建后失败”的 `TerminateProcess` 分支。 ### 4. 验证声明(P2) - `git diff --check` 实际失败:`mentor_adapter.py:1452-1454` 有 3 条 trailing whitespace(文件为 CRLF,仓库 `.gitattributes` 使用 `* -text`)。`git -c core.whitespace=cr-at-eol diff --check` 才能通过;文档中的“通过”不准确。 - 全量测试:本机 head **19 failed / 1295 passed**,parent **19 failed / 1293 passed**,失败清单完全一致(非本提交引入);PR 点名的 `test_backup_recovery.py::test_invalid_source_does_not_touch_target` 在 head / parent / main **均通过**。请在作者环境复核并更新基线说明。 ### 5. 其他(P2) `read_library_flag` 的 `CreateDesktop`(1457)到 `try`(1463)之间仍有 `Path(library)` 等赋值;建议把 Desktop 创建放进 `try/finally`。同类函数 `read_library_tree_image_map` 也有相同模式。 --- 审查基于 `6327ad1` 的 4 文件增量;#3 的 118 文件未逐行审查。
abaishu0730 changed title from fix: release private desktop on worker launch failure to [Superseded] fix: release private desktop on worker launch failure 2026-11-05 15:00:00 +08:00
abaishu0730 closed this pull request 2026-11-05 15:00:00 +08:00

Pull request closed

Please reopen this pull request to perform a merge.
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Skyworth_Digital_Hardware/cbb-refresh-verify-795#7