Skip to content

Add write strategy policy - #3

Merged
Mattie merged 2 commits into
mainfrom
codex/write-strategy
Jul 5, 2026
Merged

Add write strategy policy#3
Mattie merged 2 commits into
mainfrom
codex/write-strategy

Conversation

@Mattie

@Mattie Mattie commented Jul 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add write_strategy policy with in_place as the default and atomic as an opt-in strategy.
  • Wire the option through stashes, models, Model.Meta, create_model, sync, and direct Snapshot construction.
  • Document the Windows-friendly default and atomic tradeoff for snapshot metadata writes.

Why

Atomic temp-file replacement is better for file visibility and failure preservation, but it can fail on Windows when active apps or readers hold the destination file open. The default now matches datafiles-style in-place writes while preserving atomic replacement for callers that choose it.

Validation

  • python.exe -m compileall src\snapclass tests
  • python.exe -m pytest tests\test_sessions_and_frozen.py tests\test_conversion_and_writes.py tests\test_stash_binding_and_api.py tests\test_model_meta.py tests\test_sync.py tests\test_snapshot_locking.py tests\test_snapshot_magic_and_serializers.py
  • python.exe -m pytest

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1a5e884640

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/snapclass/schemas.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a write_strategy policy to control how snapshot files are written, defaulting to Windows-friendly in-place writes while allowing callers to opt into atomic temp-file replacement. It threads the new option through stash/model configuration, runtime helpers, and updates documentation and tests accordingly.

Changes:

  • Add write_strategy propagation via Stash, snapclass/create_model/sync, Model.Meta, and Snapshot configuration.
  • Implement strategy-aware writing (in_place vs atomic) and default to in_place.
  • Expand test coverage for strategy scoping/precedence and document tradeoffs; bump version to 0.1.4.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/test_sync.py Adds a regression test ensuring sync(..., write_strategy=...) is accepted and used.
tests/test_stash_binding_and_api.py Extends stash option plumbing tests to cover write_strategy.
tests/test_snapshot_magic_and_serializers.py Ensures atomic writes are used in a concurrent conflict test scenario.
tests/test_snapshot_locking.py Updates locking/symlink test coverage for atomic writes.
tests/test_sessions_and_frozen.py Adds tests for default in-place behavior, atomic opt-in, and policy precedence.
tests/test_model_meta.py Adds tests for Model.Meta.snapshot_write_strategy precedence and create_model(..., write_strategy=...).
tests/test_conversion_and_writes.py Updates atomic-replace failure test to explicitly opt into atomic strategy.
src/snapclass/stash.py Adds stash-level write_strategy policy, normalization, and inheritance resolution.
src/snapclass/schemas.py Wires write_strategy through public APIs/config and implements strategy-aware _write_text.
README.md Documents the new default and how/when to opt into atomic replacement.
pyproject.toml Bumps project version to 0.1.4.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/test_sessions_and_frozen.py
Comment thread tests/test_sessions_and_frozen.py
Comment thread tests/test_sessions_and_frozen.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

@Mattie
Mattie merged commit d960bd0 into main Jul 5, 2026
5 checks passed
@Mattie
Mattie deleted the codex/write-strategy branch July 5, 2026 02:10
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.

2 participants