Skip to content

fix: atomic writes for sync queue markers#34

Merged
davidpoblador merged 1 commit intomainfrom
worktree-polymorphic-snacking-gosling
Apr 7, 2026
Merged

fix: atomic writes for sync queue markers#34
davidpoblador merged 1 commit intomainfrom
worktree-polymorphic-snacking-gosling

Conversation

@davidpoblador
Copy link
Copy Markdown
Member

Summary

  • Concurrent blob uploads each trigger nudge_pending in separate threads. write_text truncates the file before writing, so a concurrent reader sees empty/partial content and logs spurious "Skipping malformed marker" warnings.
  • All marker file writes now use temp file + os.replace (atomic on POSIX), so readers always see either old or new content, never partial.
  • Malformed marker warnings now include the actual exception for debuggability.

Test plan

  • Added test_corrupted_marker_file_skipped_gracefully — corrupted markers are skipped without affecting valid ones
  • Added test_atomic_write_produces_valid_marker — markers remain valid JSON after writes and updates
  • Full test suite passes (78/78)

🤖 Generated with Claude Code

Concurrent blob uploads each trigger nudge_pending in separate threads.
write_text truncates before writing, so a concurrent reader sees partial
content and logs spurious "malformed marker" warnings. Use temp file +
os.replace for all marker writes so readers always see complete content.

Also logs the actual exception in malformed marker warnings for future
debuggability.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@davidpoblador davidpoblador merged commit 867a0d1 into main Apr 7, 2026
1 check passed
@davidpoblador davidpoblador deleted the worktree-polymorphic-snacking-gosling branch April 7, 2026 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant