Skip to content

fix(automation): atomic state file writing and Windows PermissionError retry (T-20261107-192001888) - #13

Merged
lukisch merged 1 commit into
mainfrom
fix/atomic-state-files
Nov 9, 2026
Merged

lukisch merged 1 commit into
mainfrom
fix/atomic-state-files

Conversation

@lukisch

@lukisch lukisch commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Introduces atomic writing helper functions _atomic_write_bytes\ and _atomic_write_json\ in \�utomation_control.py\ using temp files on the same directory, fsync, and \os.replace.
  • Preserves file permissions/mode if original file already exists.
  • Catches transient Windows \PermissionError\ during \os.replace\ with exponential backoff retries.
  • Updates \paused-by-carecenter.json\ to be written atomically.
  • Flushes buffer in _append_event\ for \�vents.jsonl.
  • Comprehensive unit tests covering atomic writes, failure cleanup, and transient retry resilience.

Fixes part B of T-20261107-192001888.

…r retry (T-20261107-192001888)

- implement _atomic_write_bytes and _atomic_write_json with temp file in same directory and os.replace
- preserve original file mode when target exists
- retry os.replace with exponential backoff on transient Windows PermissionError
- write paused-by-carecenter.json atomically
- flush append buffer for events.jsonl
- add unit tests for atomic state writing, transient retry and permanent failure cleanup
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown

Welcome! 👋 Thanks for your first pull request in this repository.

A maintainer will review it soon. Please make sure:

  • Your changes are tested
  • Documentation is updated if needed
  • The PR description explains what and why

Thanks for contributing!

@lukisch
lukisch merged commit a0fed44 into main Nov 9, 2026
7 checks passed
@lukisch
lukisch deleted the fix/atomic-state-files branch November 9, 2026 10:11
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