emrg: stop_all Restart Manager lock-owner kill (generic DeleteFile code 5 fix) - #827
Conversation
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 594 (1/3). Re-verified: Restart Manager lock-owner scan (rstrtmgr.dll, batched 500-file RmRegisterResources, ERROR_MORE_DATA 234 retry), self+ancestor-chain exclusion (ParentProcessId walk — protects the running install\python-dist\python.exe and Inno setup.exe), Stop-Process -Force with PID/name/cmdline(150) logging + browser-harness restart hint; verify() extension reports survivors → exit 1 (R125 intact); stop order bundled-git → lock-owners → verify. Full pytest 892+1 (893), import + CLI green; CI test + test-windows PASS (32018793024).
argszero
left a comment
There was a problem hiding this comment.
✅ LGTM — cycle 595 (2/3). Re-verified head 00a27f4 unchanged (4 files +308/−2): static PS/C# template (no str.format escaping), Restart Manager scan of $env:USERPROFILE.emrg\install with batched 500-file RmRegisterResources + ERROR_MORE_DATA(234) retry; self+ancestor-chain exclusion (ParentProcessId walk protects running python-dist python + Inno setup.exe); Stop-Process -Force with PID/name/cmdline(150) logging + browser-harness restart hint; stop order bundled-git → lock-owners → verify; _verify_windows() reports surviving file-lock owners → exit 1 (R125 intact). CI test + test-windows PASS (32018793024). Awaiting 3rd LGTM.
Summary
Fixes the generic Windows installer
DeleteFile failed; code 5root cause (rant 2026-08-17T17:55:42, supersedes the EMRG-cmdline-scan fallback #826).Background
Installing v0.2.43 on Windows failed with
DeleteFile failed; code 5oninstall\lib\websockets\speedups.cp313-win_amd64.pyd. Afind_lock_owner.ps1(Restart Manager API) probe showed the actual lock owner was an external process — the browser-harness daemon (standalone uv CPython underAppData\Roaming\uv\tools,-m browser_harness.daemon).emrgd.pid/emrgd.portwere empty and no-m emrgprocess existed, so the existing EMRG cmdline scan (17:03:38 / #826) could never see it. Root cause: a foreign process locking files underinstall\— Restart Manager's lock-owner report is the general solution covering both EMRG and foreign owners.Changes (
emrg/_stop_all.py, pure stdlib — installer runs it standalone)stop_lock_owners()step — inserted instop_all()afterstop_bundled_git(), beforeverify():rstrtmgr.dll, C# wrapper ported from the verifiedfind_lock_owner.ps1) scans$env:USERPROFILE\.emrg\install\recursively for locked-file owners, deduped PID set.RmRegisterResourcesin one session;RmGetListretries onERROR_MORE_DATA(234) with a grown buffer — no per-file session (10k+ files under install).install\python-dist\python.exeloadspython313.dlletc. from install; ancestors include the Innosetup.exe— never killed) viaWin32_Process ParentProcessIdwalk.Stop-Process -Force, printingPID name cmdline(truncated 150 chars) — clearly telling the user a non-EMRG process (e.g. browser-harness daemon) was stopped; emits a restart hint when browser-harness was killed._verify_windows()extension — re-runs the same Restart Manager scan; any remaining non-self/ancestor lock owner is appended asfile-lock owner (pid N, name)→ exit 1 (installer abort semantics R125 unchanged).str.format) so the literal PowerShell/C# braces need no{{ }}escaping.Tests
+9 (Agent.md 885→893):
TestLockOwners(POSIX no-op, tab-output parsing, subprocess-failure → empty, kill-flag rendering, template key elements incl. RM API/batch/234/ancestor-exclusion/truncation/hint, no-format render safety, verify residual) + order wiring (lock owners after bundled-git before verify) + installer textual wiring pin.Full pytest 892 passed + 1 skipped (893 collected), import + CLI green.