Skip to content

Add regression test for VFS copy overwrites#11

Open
lydakis wants to merge 4 commits intomainfrom
codex/add-test-for-vfs.copy-functionality
Open

Add regression test for VFS copy overwrites#11
lydakis wants to merge 4 commits intomainfrom
codex/add-test-for-vfs.copy-functionality

Conversation

@lydakis
Copy link
Copy Markdown
Owner

@lydakis lydakis commented Nov 16, 2025

Summary

  • add a regression test to ensure copying over an existing file overwrites the destination contents and tracks versions
  • preserve node version metadata when cloning nodes so copy operations keep file versions in sync with their source

Testing

  • uv run pytest tests/test_vfs.py

Codex Task

Copy link
Copy Markdown

@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".

Comment thread sandfs/vfs.py
Comment on lines 466 to 470
clone = VirtualFile(name=node.name, metadata=dict(node.metadata))
clone.policy = self._clone_policy(node.policy)
clone.write(node.read(self))
clone.version = node.version
return clone
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Advance version when overwriting via copy

When _clone_node copies a file or directory it now copies the source version (sandfs/vfs.py lines 466‑469). During copy, overwriting an existing path removes the destination node and adds this clone without incrementing the version. As a result, a destination file that previously had version 1 is still reported as version 1 after being overwritten, so clients using optimistic concurrency (see tests/test_persistence.py lines 8‑13) cannot detect the change—write_file(..., expected_version=1) will succeed even though another operation replaced the file in between. Copying over an existing file should advance the destination’s version just like any other write to keep versions monotonic; mirroring the source version breaks that guarantee.

Useful? React with 👍 / 👎.

@lydakis
Copy link
Copy Markdown
Owner Author

lydakis commented Nov 17, 2025

@codex

@chatgpt-codex-connector
Copy link
Copy Markdown

Summary

  • Updated VirtualFileSystem.copy to proactively remove any existing destination node—either when copying directly onto a path or when placing a file inside a directory—and to advance the destination’s version so optimistic concurrency checks observe overwrites. sandfs/vfs.pyL421-L475
  • Added regression coverage that ensures copy operations trigger version-mismatch errors for stale expected_version values, both for direct file targets and when copying into directories that already contain the file. tests/test_vfs.pyL1-L76

Testing

  • uv run pytest tests/test_vfs.py

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