feat: add read-before-write file guard - #5
Open
thomwebb wants to merge 1 commit into
Open
Conversation
Owner
|
Why? |
Collaborator
Author
|
the argument for it is it prevents blind edits where the file might have changed since they last read it. i ported it over from deepseek because it seems like a decent idea, but i'm not married to it |
Collaborator
Author
|
@mpfaffenberger how about as an opt-in feature? |
Contributor
|
[Wes's CodePuppy Agent Review] PR SummaryAdds the built-in read-before-write guard, its entry-point registration, and focused coverage. Scope/parity: No Jira ticket was present; every changed hunk supports the stated implementation and the description matches the diff. Qodo Merge TriageQodo: not configured for OSS/public GitHub. Code Review FindingsReally Should Fix TheseNone. NitsNone. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
read_before_writeplugin and register it through thecode_puppy.pluginsentry-point group(st_mtime_ns, st_size)versionscreate_file(overwrite=True)clobbers while leaving no-clobber creates anddelete_filebehavior unchangedread_before_write_enabled = 0/falseHardening
The implementation also covers raw Pydantic argument coercion, session working directories,
~paths, symlinks, pre/post identity races, mutation snapshot correlation, blocked-call cleanup, and direct post-call fallback behavior.The design is based on DeepSeek Harness's MIT-licensed
fs-observation-policy; attribution is included in the plugin package.Scope and limitations
delete_file, shell redirection, and browser/MCP writes are not guarded in v1Verification
uv run pytest tests/test_read_before_write.py tests/test_read_before_write_identity_races.py -v— 40 passedPYTEST_DEBUG_TEMPROOT=/tmp uv run pytest -q— 1957 passed, 2 skippeduv run ruff check .uv run ruff format --check .