fix(desktop): re-read live argv before gateway exemption in venv-blocker scan - #79195
Closed
skyer-flyyy wants to merge 1 commit into
Closed
skyer-flyyy wants to merge 1 commit into
skyer-flyyy wants to merge 1 commit into
Conversation
This was referenced Aug 31, 2026
Collaborator
|
Thanks @skyer-flyyy. Same verdict as #78095: the root cause (the detector truncating cmdlines to 120 chars before the gateway exemption ran) was fixed on main in commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Desktop update preflight (
venv\Scripts\python.exe -m hermes_cli._scan_venv_blockers) still aborts withvenv-blockedon gateway-enabled Windows installs even after the pausable-gateway exemption from #75881. The exemption classifies holders from a cmdline truncated to 120 characters by_detect_venv_python_processes(), while a gateway worker launched from the uv-managed runtime (.hermes-runtime\python\generation-<id>\cpython-3.11-windows-x86_64-none\python.exe) has a ~186-char cmdline — the trailinggateway runtokens fall past the cut, the matcher returnsFalse, and the preflight dead-ends before the CLI updater's_pause_windows_gateways_for_update()ever runs. Every Desktop update aborts; the only workaround is stopping the gateway by hand.Root cause
_scan_venv_blockers.pyclassifies every holder with_is_pausable_gateway(cmdline), wherecmdlineis the 120-char prefix captured at scan time. The CLI-side guard (update_cmd._leftover_pausable_gateway_pids) already compensates for this truncation by re-reading the live argv via psutil — the Desktop preflight never got that compensation, so the two views of the same process table drifted apart and the exemption silently stopped matching.Verified live on Windows 10, Hermes v0.20.0 (HEAD
34c3f06f9, contains #75881), three always-on profile gateways (default/github-agent/teacherlaunched via scheduled startup scripts):PID 7728 ...\cpython-3.11-windows-x86_64-none\pyth <- captured prefix, cut at 120 chars looks_like_gateway_command_line(full argv) = True looks_like_gateway_command_line(truncated) = False <- exemption defeated
Scan output before the fix:
{"blocked": true, "pausable_gateways": 1}— the scan's own diagnostic contradicted its verdict, exactly the #78089 pattern.Fix
In
hermes_cli/_scan_venv_blockers.py, re-read the live argv via psutil before the gateway exemption runs, falling back to the captured cmdline when the process is gone or unreadable (same pattern as_leftover_pausable_gateway_pids, sametry/excepttolerance). Blocked-process reports now also show the full redacted cmdline instead of a truncated prefix, so users can actually see which process holds the install.Design note: this keeps the capture layer (
_detect_venv_python_processes) untouched and makes the preflight self-healing regardless of where truncation happens upstream — an alternative to #78094 / #78188, which move the truncation out of the capture layer entirely. Non-gateway holders (servebackends, operator REPLs, stray scripts) keep blocking exactly as before:_is_pausable_gatewaystill rejects them and the re-read only widens what is visible, never what blocks.Verification
tests/hermes_cli/test_scan_venv_blockers.py:test_main_rereads_truncated_argv_before_gateway_exemption— a 120-char-truncated uv-side gateway worker is exempted when the live argv is readabletest_main_truncated_gateway_worker_without_live_argv_falls_back— pre-fix behavior is preserved when psutil cannot re-read (dead PID / access denied)scripts/run_tests.sh tests/hermes_cli/test_scan_venv_blockers.py(canonical CI-equivalent runner, clean env): 25/25 passed, 0 failed.pausable_gateways: 1); after the fix the worker is exempted (pausable_gateways: 2, only the Desktopservebackend remains — whichreleaseBackendLockForUpdatestops before the updater spawns anyway).Related