Skip to content

fix(gateway): scrub worker scope from Windows root launches - #82964

Open
texasich wants to merge 1 commit into
NousResearch:mainfrom
texasich:fix/windows-root-launcher-env-isolation
Open

fix(gateway): scrub worker scope from Windows root launches#82964
texasich wants to merge 1 commit into
NousResearch:mainfrom
texasich:fix/windows-root-launcher-env-isolation

Conversation

@texasich

Copy link
Copy Markdown
Contributor

Summary

  • remove delegated/Kanban worker ownership markers from generated Windows gateway CMD and VBS launchers
  • apply the same isolation to direct detached gateway spawning and the post-update restart watcher
  • source the marker set from agent.delegation_context so launcher behavior follows the existing ownership authority

Problem

A Windows root gateway can be launched by a process that is currently operating as a delegated child or Kanban worker. The generated launchers, direct detached spawn path, and post-update restart watcher previously inherited those ownership markers unchanged.

The new root gateway could therefore misidentify itself as the parent worker instead of establishing a fresh root process boundary.

A harmless-child probe against current main observed all ten seeded ownership markers in both generated launcher children. The same probe against this change observed none of them while preserving HERMES_HOME and an unrelated sentinel variable.

Changes

  • define the Windows root-gateway ownership marker set from DELEGATED_CHILD_ENV_MARKER, KANBAN_ENV_KEYS, and the two legacy Kanban branch/worktree markers
  • clear those markers before generated CMD and VBS launchers start Python
  • add root_gateway_subprocess_env(), which applies the normal gateway overlay and then removes ownership markers
  • use the helper in _spawn_detached()
  • give the Windows post-update restart watcher a scrubbed environment in both its primary launch and no-breakaway fallback
  • add native-Windows regression coverage for CMD, VBS, direct spawn, and restart-watcher behavior

Verification

  • tests/hermes_cli/test_gateway_windows.py: 11 passed
  • tests/hermes_cli/test_gateway.py: 10 passed, 5 skipped
  • tests/hermes_cli/test_update_gateway_launcher_refresh.py: 2 passed
  • related Windows-native gateway tests: 12 passed
  • native CMD/VBS harmless-child probe: passed
  • Ruff: passed
  • git diff --check: passed
  • Windows footgun scan: passed

Scope

  • Windows automated gateway launch and relaunch paths only
  • no Scheduled Task ACL changes
  • no POSIX behavior change
  • manually invoking foreground hermes gateway run from inside a worker shell remains outside this change

Prevent Windows root gateway processes from inheriting delegated and Kanban worker ownership markers through generated CMD/VBS launchers, direct detached spawning, and the post-update restart watcher.

Reuse the authoritative delegation-context marker definitions and preserve unrelated environment values.
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management platform/windows Native Windows-specific behavior or breakage P3 Low — cosmetic, nice to have sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state 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 Aug 10, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related to #70809, #70898, and #81843: this covers the distinct Windows root-gateway launcher and restart boundary in the broader inherited-worker-scope family.

@texasich
texasich marked this pull request as ready for review August 10, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management P3 Low — cosmetic, nice to have platform/windows Native Windows-specific behavior or breakage 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 sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants