feat(files): add an overwrite option to file write - #7295
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThe PR adds a user-controlled overwrite option to File Write while preserving suffixing as the default behavior.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported absent-target race now uses exact-name creation backed by folder-and-name uniqueness and returns a conflict for the losing concurrent writer.
|
| Filename | Overview |
|---|---|
| apps/sim/lib/internal/file/operations.ts | Implements exact-path overwrite resolution, optimistic update conflicts, provenance handling, and race-safe exact-name creation. |
| apps/sim/lib/internal/file/operations.test.ts | Covers replacement, absent-target creation, concurrent conflicts, folder matching, default suffixing, binary input, and provenance behavior. |
| apps/sim/blocks/blocks/file.ts | Adds the overwrite switch and maps its persisted boolean value into File Write execution. |
| apps/sim/tools/file/write.ts | Adds the user-only overwrite parameter to the executable tool contract. |
| apps/sim/lib/api/contracts/tools/file.ts | Extends write request validation with an optional boolean overwrite field. |
| apps/sim/tools/generated/tool-metadata.ts | Regenerates serializable tool metadata to include the overwrite option. |
| apps/docs/content/docs/integrations/file.mdx | Documents overwrite semantics and the unchanged default suffixing behavior. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[File Write request] --> B{Overwrite enabled?}
B -->|No| C[Create file with suffixing allowed]
B -->|Yes| D[Resolve exact folder and leaf name]
D -->|Exact file exists| E[Update with expected content timestamp]
D -->|No exact file| F[Create with exact name]
F -->|Concurrent name collision| G[Return conflict]
E --> H[Return overwritten file]
F -->|Created| I[Return new file]
Reviews (3): Last reviewed commit: "docs(files): describe overwrite as an ex..." | Re-trigger Greptile
Collaborator
Author
|
@greptile review |
Contributor
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
Collaborator
Author
|
@greptile review |
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
data (1).csv.fileInput(the bytes and encoding flow through unchanged, so a binary copy overwrites correctly).Three things worth a look in review:
report.txtat the root could otherwise have silently destroyedarchive/report.txt.resolveWriteOverwriteTargetaccepts a hit only when its folder and leaf name match the write target exactly; anything else falls through to create.expectedUpdatedAtand fails with a conflict if the file changed underneath it, rather than taking the Redis lock append needs.user-onlyvisibility. An agent callingfile_writecannot setoverwriteitself — replacing existing content stays an explicit choice on the block.Provenance follows the append precedent: overwriting a file owned by another user downgrades exact resolved-secret provenance to
unknown.Type of Change
Testing
Tested manually. 6 new unit tests cover the replace path, the create-when-absent fallback, the wrong-folder rejection, the default-off path, the cross-user provenance downgrade, and overwrite with a
fileInputsource.type-check,lint,check:audits(39 audits), and the block-registry check all pass.Checklist