Context
Evidence writers rely on atomic_write_text() so metadata/export files are not left half-written. The helper sits on a data-integrity boundary and currently lacks a focused regression contract.
Scope
Add deterministic tests for src/headerproof/file_safety.py using tmp_path and monkeypatching only.
Acceptance criteria
- Parent directories are created when needed.
- Replacing an existing destination yields complete new content.
- The temporary sibling is not left behind after a successful write.
- An fsync OSError is tolerated as intended and the destination is still replaced.
- Tests do not weaken atomic replacement semantics.
- Existing tests remain green.
Comment before starting so ownership can be confirmed.
Context
Evidence writers rely on atomic_write_text() so metadata/export files are not left half-written. The helper sits on a data-integrity boundary and currently lacks a focused regression contract.
Scope
Add deterministic tests for src/headerproof/file_safety.py using tmp_path and monkeypatching only.
Acceptance criteria
Comment before starting so ownership can be confirmed.