Skip to content

Ensure VFS state is restored after storage conflicts#3

Open
lydakis wants to merge 2 commits intomainfrom
codex/add-test-for-adapter-version-conflict
Open

Ensure VFS state is restored after storage conflicts#3
lydakis wants to merge 2 commits intomainfrom
codex/add-test-for-adapter-version-conflict

Conversation

@lydakis
Copy link
Owner

@lydakis lydakis commented Nov 16, 2025

Summary

  • add a regression test that simulates an external storage update and ensures the VFS raises a conflict while keeping its cached state intact
  • restore a file's cached content and version whenever a storage adapter write fails so callers observe the previous state after the exception

Testing

  • uv run pytest tests/test_adapters.py

Codex Task

Copy link

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

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.

ℹ️ 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".

sandfs/vfs.py Outdated
Comment on lines +314 to +315
previous_content = node.read(self)
previous_provider = getattr(node, "_provider", None)

Choose a reason for hiding this comment

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

P1 Badge Do not force provider read before every write

The new rollback logic in VirtualFileSystem.write_file (sandfs/vfs.py lines 314‑315) now reads the existing file contents via node.read(self) before every write so it can restore them later. For provider‑backed files, VirtualFile.read (sandfs/nodes.py lines 57‑65) calls the provider and raises ProviderError if the provider fails. Before this change, write_file never touched the provider; callers could overwrite a file even if its provider was currently broken. After this change any failure while reading the provider aborts the write before it even attempts to persist, meaning users can no longer replace or repair a provider‑backed file whose provider errors out. To avoid this regression the rollback data should be captured from the node’s cached attributes (_content and _provider) without invoking the provider.

Useful? React with 👍 / 👎.

@lydakis
Copy link
Owner Author

lydakis commented Nov 17, 2025

@codex

@chatgpt-codex-connector
Copy link

Summary

  • Added a regression test that mounts a provider-backed file which raises when invoked, ensuring VirtualFileSystem.write_file can still overwrite the file without triggering the provider and that subsequent reads return the new content. tests/test_vfs.pyL42-L59

Testing

  • uv run pytest

View task →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant