fix(gateway): write restart markers atomically and avoid Windows runtime-lock read failures - #17842
Closed
johnncenae wants to merge 1 commit into
Closed
Conversation
teknium1
added a commit
that referenced
this pull request
May 1, 2026
Widen PR #17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
Contributor
|
Merged via #18179 — your commit cherry-picked onto current main with rebase-merge so your authorship is preserved. Added a follow-up commit from me widening the same atomic-write fix to two sibling sites (feishu dedup state + |
nickdlkk
pushed a commit
to nickdlkk/hermes-agent
that referenced
this pull request
May 11, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
jsboige
pushed a commit
to jsboige/hermes-agent
that referenced
this pull request
May 14, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
dannyJ848
pushed a commit
to dannyJ848/hermes-agent
that referenced
this pull request
May 17, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
Seven74AI
pushed a commit
to Seven74AI/hermes-agent
that referenced
this pull request
Jun 13, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
13 tasks
melon-xf
added a commit
to melon-xf/hermes-agent
that referenced
this pull request
Sep 3, 2026
Widen PR NousResearch#17842's atomic-write fix to two sibling sites that exhibit the same 'partial JSON on interrupted write' class of bug: - gateway/platforms/feishu.py: dedup state (_dedup_state_path) - gateway/platforms/helpers.py: ParticipatedThreadTracker save Both are small recovery/coordination files that get rewritten frequently and break cross-restart dedup if left partial.
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
This hardens the gateway restart/control-plane persistence paths and fixes a Windows-specific runtime lock issue.
Changes:
atomic_json_write().restart_failure_counts.restart_notify.json.restart_last_processed.jsongateway.status._write_json_file()to atomic JSON writes so runtime status, scoped locks, and takeover markers inherit the same safety1 MiB) so readers can still read the JSON metadata while another process holds the runtime lockWhy
The gateway currently relies on small JSON control-plane files for restart recovery, dedup, and lock/state coordination. Writing those files in-place can leave partial JSON behind on interrupted writes, which degrades recovery behavior.
On Windows, locking byte 0 of
gateway.lockcaused mandatory-lock read failures whenget_running_pid()or related readers tried to inspect the lock record. Locking a byte well past the JSON payload preserves mutual exclusion without blocking metadata reads.Tests
Verified on Windows with:
uv run pytest tests/gateway/test_restart_notification.py tests/gateway/test_restart_resume_pending.py tests/gateway/test_status.py
----- 101 passed