Skip to content

fix(gateway-windows): atomic write for .cmd and startup launcher scripts#30435

Closed
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/gateway-windows-atomic-write
Closed

fix(gateway-windows): atomic write for .cmd and startup launcher scripts#30435
sprmn24 wants to merge 1 commit into
NousResearch:mainfrom
sprmn24:fix/gateway-windows-atomic-write

Conversation

@sprmn24

@sprmn24 sprmn24 commented May 22, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

_write_task_script() and _install_startup_entry() both use Path.write_text() to write the scheduled-task .cmd script and the Startup-folder launcher directly. If the process is killed or crashes mid-write (OOM, power loss, SIGKILL during install), the target file is left partially written. On the next Windows login the Scheduled Task fires against a truncated script and the gateway silently never starts — with no diagnostic in Task Scheduler.

Type of Change

  • Bug fix

Changes Made

  • _write_task_script(): write to script_path.with_suffix('.tmp') first, then tmp.replace(script_path)
  • _install_startup_entry(): same temp-file + atomic rename pattern

This matches the pattern already used throughout the codebase (cron/jobs.py, agent/google_oauth.py, agent/anthropic_adapter.py, etc.).

How to Test

  1. Review hermes_cli/gateway_windows.py_write_task_script() and _install_startup_entry()
  2. Verify both now use with_suffix('.tmp') + tmp.replace() instead of direct write_text()
  3. Run python -m pytest tests/ -q — no regressions expected

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix
  • I've tested on my platform: Ubuntu 24.04 (WSL2)

Documentation & Housekeeping

  • No documentation changes needed
  • Cross-platform considered — fix is Windows-only code path, no Linux/macOS impact

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery labels May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants