Skip to content

fix(windows): discover S4U gateways from profile PID files - #73267

Open
Sagittarius987 wants to merge 1 commit into
NousResearch:mainfrom
Sagittarius987:fix/windows-s4u-gateway-update
Open

fix(windows): discover S4U gateways from profile PID files#73267
Sagittarius987 wants to merge 1 commit into
NousResearch:mainfrom
Sagittarius987:fix/windows-s4u-gateway-update

Conversation

@Sagittarius987

Copy link
Copy Markdown

Summary

  • include validated per-profile PID/lock records in all-profile gateway discovery
  • preserve existing service/process-table fallbacks, PID exclusions, and deduplication
  • allow hermes update to pause Windows S4U/Session 0 gateways whose command lines are inaccessible to CIM, WMIC, or psutil

Problem

On Windows, an S4U Scheduled Task runs in Session 0 without an interactive logon. The gateway remains visible by PID, and its validated profile gateway.pid/runtime lock remains readable, but an unelevated interactive updater may receive no CommandLine or ExecutablePath from CIM/WMIC/psutil.

find_gateway_pids(all_profiles=True) previously skipped the current-profile PID lookup and depended on service/process-table discovery. That meant the updater could miss an S4U gateway during its pause phase, then correctly abort later when the venv-holder guard found the still-running Python process.

This complements the broader Windows update recovery work discussed in #53124: that PR explicitly identified S4U/Session 0 command-line visibility as an uncovered case.

Fix

When all_profiles=True, merge the already-validated records returned by find_profile_gateway_processes() before the existing service and process-table scans. _append_unique_pid() continues to enforce caller exclusions, self-PID rejection, and deduplication.

The regression test models inaccessible process argv and verifies that:

  • the profile PID is still discovered
  • exclude_pids is propagated and enforced defensively
  • a PID repeated by service discovery is returned only once

Verification

  • native Windows isolated per-file runner: 26 passed
  • python -m py_compile hermes_cli/gateway.py tests/hermes_cli/test_update_concurrent_quarantine.py
  • git diff --check origin/main...HEAD
  • independent pre-commit review: no security concerns or logic errors
  • real S4U Scheduled Task validation on Windows 11 IoT Enterprise LTSC 2024 (Session 0):
    • before the fix, all-profile discovery missed the live gateway while profile PID discovery found it
    • after the fix, all-profile discovery returned the profile PID
    • update pause released all Hermes venv holders
    • resume relaunched the gateway with a new validated PID

Scope

Two files only; no account names, task names, machine paths, or deployment-specific process names are hardcoded.

Include validated per-profile PID/lock records in all-profile gateway discovery before service and process scans. This lets Windows updates pause Session 0 scheduled-task gateways whose command lines are hidden from CIM, WMIC, and psutil while preserving PID exclusions and deduplication.
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard platform/windows Native Windows-specific behavior or breakage P2 Medium — degraded but workaround exists sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades labels Jul 28, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused Windows recovery fix. Current main still skips profile PID-file discovery when find_gateway_pids(all_profiles=True) is used (hermes_cli/gateway.py:606-624), while the update pause path depends on that all-profile result (hermes_cli/update_cmd.py:2710).

The proposed call to find_profile_gateway_processes(exclude_pids=_exclude) uses the existing validated profile source (hermes_cli/gateway.py:628-652), and _append_unique_pid preserves exclusion, self-PID, and duplicate handling (hermes_cli/gateway.py:326-333). The regression test in commit d5601b4f exercises the inaccessible-command-line case and duplicate service discovery.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/profiles Multi-profile isolation, HERMES_HOME scoping labels Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/profiles Multi-profile isolation, HERMES_HOME scoping comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists platform/windows Native Windows-specific behavior or breakage sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-platform-windows Sweeper risk: may break or behave differently on native Windows type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants