Repository navigation
Conversation
Concurrent Stop workers share one daily memory file (worktrees and synced folders). Multiple echo/write syscalls let heading, anchor comment, and summary interleave across sessions. Build each entry in memory and append with one printf write so the block stays whole under O_APPEND. Cover the codex worker with sequential and concurrent tests. Fixes zilliztech#727
This branch has not been deployed
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.
Problem
The Stop hook writes one session entry with several separate echo/write syscalls into a single >> redirect. Two sessions stopping at the same moment on a shared daily memory file can interleave heading, anchor comment, and summary lines (see #727).
Fix
Build each entry in memory and append it with one printf write:
One O_APPEND write keeps the entry whole against other appenders, matching what the JS integrations already get from a single �ppendFile. No lock (unavailable on macOS).
Tests
`
python -m pytest tests/test_stop_hook_atomic_append.py -v
2 passed
`
Notes
A duplicate ## Session heading is still possible when grep and append are not one operation; that only costs a repeated heading, while interleaving mis-resolves the progressive-disclosure anchor.
Fixes #727