Skip to content

Commit 8368f14

Browse files
u917 recut rung 1: answer the seven review threads on safe write
Answers the changes-requested verdict coderabbitai[bot] submitted at 16:37:33Z against c480143, cluster by cluster, each with the case that would have failed before it. - safeWriteText.ts:106 (staging privacy on Windows): make the staging directory private before the first staged byte, with icacls <dir> /inheritance:r /grant:r "<account>:(OI)(CI)F". Measured on a Windows host the directory went from three inherited ACEs (SYSTEM, Administrators, the user) to that one explicit ACE, and a file written inside inherited only the user. mkdirSync's mode is ignored by Windows directory creation and chmodSync establishes no DACL, so the notices below step 5 could not be enough. A host where icacls fails still saves and reports the leftover exposure. - safeWriteText.ts:257 (link-walk bound): MAX_SYMLINK_HOPS = 40, the longest chain Node resolves at all, so a chain the operating system itself can follow is never cut off short of its referent and two writers cannot take two locks for one file. This changes a value this file declares by design, not ported content, and says so. - safeWriteText.ts:284 (created-directory entries): fs.mkdir reports the shallowest directory it had to create; fsync each containing directory up to the nearest one that already existed, deepest first, because syncing a created directory's inode does not sync the entry in its parent that names it. - safeWriteText.ts:303 (staging location compare): compare canonical directories through canonicalDirKey instead of path spellings, so a caller that staged through an alias of the target's own directory - the same directory, a legal same-directory rename - is no longer failed for how the path was spelled. - safeWriteText.ts:512 (backup copy mode): copy the backup through descriptors this code opened - seed with "wx" at 0o600, read the target, write the seed, including the short write loop - instead of fs.copyFile, which takes its destination mode from the source on POSIX and carries the read-only attribute on Windows. No chmod follows, because the mode this code chose never moved. The exposure window itself is only directly measurable on POSIX; the row proves no copyFile and no chmod on the backup plus content integrity. - postCommitDurability.spec.ts (test-only): fail the staged write at its own open, through the fs option Node's WriteStream calls, so the staged name is never created and the residue assertion is not a timing race. This cluster is a test change, so its control is the assertion inside the row rather than a run against the old source. - safeWriteJson.ts:240 (dangling-alias recovery): recover beside the lock key the walk already resolved instead of the spelling the caller named, so an interrupted publish is healed where its backup actually sits and the write stops rejecting on every retry. Proof, both directions, whole suites of every touched file: - with these changes: 7 files passed, 148 passed | 4 skipped (152). - with the two source files reverted to c480143 and the new rows left in: 15 failed | 133 passed | 4 skipped (152). Six of those are rows this commit adds and nine are rows it re-pins to the new contract. At the unit's own parent f98fcf7 the file these threads name does not exist at all, so that base has no run to compare against. - eslint --max-warnings=0 over the nine touched paths: 0 problems, with the shared prune switch left off; src/eslint-suppressions.json is byte identical to its head blob ae3d504 and no count moved. - prettier 3.9.10 --check over the same nine paths: all matched files use Prettier style. No changeset, no changelog.
1 parent c480143 commit 8368f14

5 files changed

Lines changed: 611 additions & 128 deletions

File tree

0 commit comments

Comments
 (0)