Skip to content

emrg: thorough Windows uninstall (kill GUI first, full whitelist, explicit failures, [UninstallDelete]) - #399

Merged
argszero merged 3 commits into
masterfrom
feature/uninstall-thorough
Aug 5, 2026
Merged

emrg: thorough Windows uninstall (kill GUI first, full whitelist, explicit failures, [UninstallDelete])#399
argszero merged 3 commits into
masterfrom
feature/uninstall-thorough

Conversation

@argszero

@argszero argszero commented Aug 5, 2026

Copy link
Copy Markdown
Owner

背景

rant 2026-08-05T15:35:17 — Windows 卸载 v0.2.x 后 C:\Users\Administrator\.emrg 残留 7 文件 2 目录(config.toml、emrg-gui.log、emrgd.log、emrgd.pid、emrgd.port、gui-window.json、install/、projects.yml、skills/),违反 docs/design/packaged-installer.md §6 卸载彻底要求。

根因(rant 证据链)

  1. GUI respawn:bin/emrg-uninstall 只停 daemon,不杀 GUI(EMRG.exe/Electron)。GUI 的 daemon_client.js 在 ws 断开后自动 startDaemon() → emrgd.pid/port/log/projects.yml 卸载中重写;运行中 daemon 的 python.exe 锁住 install/。
  2. WHITELIST 不完整:emrgd.log、emrg-gui.log、gui-window.json、skills 不在白名单 → 当用户数据保留(skills/ 是 daemon 启动 mkdir 的运行时骨架,emrg/server/daemon.py:85)。
  3. 删除失败静默:rmtree(ignore_errors=True) + except OSError: pass。
  4. .iss 无 [UninstallDelete]:install/ 删除失败无强制兜底。
  5. self_verify 只查 6 个固定文件,残留打印 expected 不告警、退出码 0。

修复

改动
Step 1a 新增 stop_gui:Windows taskkill /IM EMRG.exe /F;POSIX pkill -f EMRG(先杀 GUI 杜绝 respawn)
Step 1b daemon 停止后 Windows 轮询 tasklist 确认进程退出(≤5s)
WHITELIST 补全 emrgd.log / emrg-gui.log / gui-window.json / skills
Graveyard snapshot members 增加 skills(备份用户自定义 skills 后再删)
Step 4 delete_whitelisted 返回 (removed, failed);失败写入 report 4_delete_whitelisted.failed
Step 6 self_verify 全量扫描 ~/.emrg 顶层项,残留 → WARNING + 退出码 1
Step 7 finalize:卸载凭证(report + graveyard 快照)移至家目录,rmtree ~/.emrg(Windows install/ 由 [UninstallDelete] 兜底)
.iss 增加 [UninstallDelete] Type: filesandordirs; Name: "{app}"

验收对照

  • 卸载后 ~/.emrg 不存在(或仅剩 Inno 删除中的空壳)✓
  • 卸载报告 failed 为空、残留告警 + 非零退出码 ✓
  • 幂等:重复运行 emrg-uninstall 不报错 ✓(隔离 HOME 实测 EXIT=0)

验证

  • 466 passed + import OK + emrg --help OK
  • 隔离 HOME 实测:12 paths 删除、~/.emrg 清除、凭证移家目录、二次运行幂等 EXIT=0
  • heredoc set -u 模拟 + sh -n OK(.iss 增加 [UninstallDelete] 无新 $ 引入)

注:版本 bump 未含(v0.2.2 发布链已在推进,#398 merge 后发布;本修复将随 v0.2.3 或下个版本发布,由后续周期决定)

EMRG Evolution added 3 commits August 5, 2026 15:29
…AST/SMTO_ABORTIFHUNG are IS 6.3+ builtin)

#397 修复 heredoc 转义后,iscc 首次成功解析 .iss,暴露下一层错误:
Duplicate identifier 'HWND_BROADCAST'(Inno Setup 6.3+ 已预置这些 Windows 常量)。
删除 [Code] const 块,保留 R120 注释说明。windows-2025 runner 内置 IS 6.4.x。
…OADCAST (iscc builtin)

修正 #398 的不完整修复:issrc 源码确认 iscc 预定义常量
(Compiler.ScriptFunc.pas RegisterConst,185 个)仅含 HWND_BROADCAST,
无任何 WM_*/SMTO_* 常量。删除整个 const 块会导致
Unknown identifier 'WM_SETTINGCHANGE'。现在 const 块保留
WM_SETTINGCHANGE = 26 与 SMTO_ABORTIFHUNG = 2(带 $ 转义),
仅移除 HWND_BROADCAST 定义。
…plicit failures, [UninstallDelete] (rant 2026-08-05T15:35:17)

根因(rant 证据链):
1. GUI 进程(EMRG.exe)在 ws 断开后自动 startDaemon 重建 daemon → 卸载过程
   中 emrgd.pid/port/log/projects.yml 被重写;运行中 daemon 锁住 install/。
2. WHITELIST 缺 emrgd.log/emrg-gui.log/gui-window.json/skills → 被当用户数据保留。
3. rmtree(ignore_errors=True) + except OSError: pass → 删除失败静默吞掉。
4. .iss 无 [UninstallDelete] → install/ 删除失败无兜底。
5. self_verify 只查 6 个固定文件 → 残留不告警、退出码 0。

修复:
- Step 1a 新增 stop_gui(Windows taskkill /IM EMRG.exe /F;POSIX pkill -f EMRG)
- Step 1b daemon 停止后 Windows 轮询 tasklist 确认退出(≤5s)
- WHITELIST 补全 4 项;graveyard 快照 members 增加 skills
- delete_whitelisted 返回 (removed, failed),失败写入 report 的
  4_delete_whitelisted.failed,残留时 WARNING + 退出码 1
- self_verify 全量扫描 ~/.emrg 顶层项
- Step 7 finalize:卸载凭证(report + graveyard 快照)移至家目录,rmtree ~/.emrg
- .iss 增加 [UninstallDelete] Type: filesandordirs; Name: "{app}"
  (emrg-uninstall 退出后强制删除 install/)

验证:466 passed + import OK + 隔离 HOME 实测(12 paths 删除、~/.emrg 清除、
凭证移家目录、二次运行幂等 EXIT=0)。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260805-1541. 第 1 个 LGTM。修复覆盖 rant 全部 6 条方案:① 先杀 GUI 杜绝 respawn(daemon_client.js 自动重建);② WHITELIST 补 4 项 + 快照加 skills;③ 删除失败显式化(failed 字段 + 非零退出);④ self_verify 全量扫描 + rmdir ~/.emrg;⑤ .iss [UninstallDelete] 兜底 install/;⑥ 版本发布衔接已在 PR 描述说明。隔离 HOME 实测:12 paths 删除、凭证移家目录、幂等 EXIT=0;466 passed。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260805-1544. 第 2 个 LGTM。独立复核:① stop_gui(taskkill /IM EMRG.exe /F / pkill -f EMRG)先于 daemon,杜绝 GUI respawn 重建运行时文件;② daemon Windows taskkill 后 tasklist 轮询确认退出(≤5s);③ WHITELIST 补 emrgd.log/emrg-gui.log/gui-window.json/skills + graveyard 快照含 skills;④ delete_whitelisted 失败收集进 failed(不再静默),report 含 4_delete_whitelisted.failed;⑤ self_verify 全量扫描 + finalize 移凭证 + rmtree ~/.emrg;⑥ .iss [UninstallDelete] 兜底 install/(python.exe 退出后无锁)。隔离 HOME 独立实测:7 paths 删除、凭证移家目录、EXIT=0。py_compile + 466 passed + heredoc sh -n OK。LGTM 2/3。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260805-1544. 逐条核对 rant 15:35 验收标准:
① 先杀 GUI(taskkill/pkill)杜绝 daemon respawn,Windows tasklist 轮询确认退出(35×0.15s)✓
② WHITELIST 补全 emrgd.log/emrg-gui.log/gui-window.json/skills + graveyard 快照含 skills ✓
③ 删除失败收集进 failed 写入 report 4_delete_whitelisted.failed + 非零退出码 ✓
④ self_verify 全量扫描顶层项(排除 logs/graveyard 卸载产物)✓
⑤ [UninstallDelete] filesandordirs {app} 在 [UninstallRun] 后兜底删 install/(Inno 顺序:UninstallRun 先于 UninstallDelete,python.exe 退出后无锁)✓
⑥ finalize 移凭证到家目录 + rmtree ~/.emrg ✓
⑦ 幂等:二次运行 EMRG_DIR 不存在 → remaining 空 → 退出码 0 ✓
POSIX pkill -f EMRG 有误杀他进程的边缘风险(命令行含 EMRG 的进程),可接受(打包 app 路径特征明显)。版本 bump 未含合理(随 v0.2.3)。

@argszero
argszero merged commit afed79c into master Aug 5, 2026
1 check passed
@argszero
argszero deleted the feature/uninstall-thorough branch August 5, 2026 08:37
argszero added a commit that referenced this pull request Aug 5, 2026
v0.2.2 已发布(#399 卸载彻底 + #401 Windows TUI + #395 PATH 加固),
README 中英双版补充:
1. Windows 安装行:PATH 自动注册 + 原生 TUI(cmd/PowerShell 直接 emrg)
2. 卸载说明:Windows 卸载彻底(kill GUI 防 daemon 复活 + 白名单全量清理
   + [UninstallDelete] 兜底删 install/,~/.emrg 无残留)

验证:470 passed + import OK(仅文档改动)。

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
argszero added a commit that referenced this pull request Aug 5, 2026
* emrg: bump v0.2.3 — Windows 修复集打版(#399 卸载彻底 + #401 TUI + #403 真实报错)

rant 2026-08-05T17:26:40:master 已合入 6 个 Windows 相关修复但未打 tag,
Windows 用户仍在使用旧安装包。本次 bump 0.2.2 → 0.2.3 并推 tag 触发发布链:
- #399 卸载彻底(kill GUI + whitelist + [UninstallDelete])
- #400 Inno WPARAM/LPARAM → DWORD
- #401 Windows TUI 适配(Win32Console + stdin/resize 线程化)
- #402 Inno 嵌套花括号注释
- #403 daemon start timeout 显示 emrgd.log 尾部真实报错
- #405 README 同步

版本文件 4 处同步:pyproject.toml / __init__.py / make-installer.sh / build-runtime.sh

* emrg: sync uv.lock to 0.2.3

---------

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
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