Conversation
…#603) writeFileAtomically created the replacement at mode 0666, so rename left 0666 & ~umask and dropped +x on scripts. chmod the temp file with the original ordinary bits before rename.
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.
Related issue
Closes #603
Problem / pressure
Code Collab
saveTextreports success and then replaces the file with a new inode whose mode is0666 & ~umask. Saving a0755script drops+x(EACCESon the next run). A0600file is widened to0664/0644. Digest conflicts already skip the write; the successful path does not keep the ordinary mode.Summary
writeFileAtomicallystill writes a temp file andrenames it over the original path. On non-Windows it nowlstats an existing regular file,chmods the temp path withmode & 0o777before rename, and leaves conflict /file_deletedreturns on the existing no-write paths. Adapter/core gitlinks are unchanged.Visual explanation
Conflict and deleted-file checks still run in
saveTextbefore this helper. A digest mismatch or missing file returns without creating the temp file.Before / after
0755under umask 0022 →0644, next exec isEACCES0755; script still runs0600→0664/06440600Test plan
apps/cliVitestsrc/lib/code-collab/code-collab-v2-service.test.ts: 48 passed on Linux (Node 24.15.0). New coverage: umask 0022 +0755remains executable,0600stays0600,0644stays0644, digest conflict leaves0755, deleted file returnsfile_deletedand is not recreated. Existing save/conflict tests still pass.oxlinton the two changed TypeScript files: 0 warnings / 0 errors.pnpm run docs check: 0 new errors (pre-existing AGENTS.md size warnings only).check:code-collab-imports,check:platform-boundaries,check:public-boundary: passed.Context handoff
Instructions for reviewing agents
writeFileAtomicallyinapps/cli/src/lib/code-collab/code-collab-v2-service.tsand the POSIX save tests; chmod must land on the temp path before rename, and conflict/deleted returns must still skip the write.mode & 0o777(dropping setuid/setgid/sticky), skipping Windows chmod, and not restoring ACL/xattr on the new inode.Authoring context
Original user prompt