Repository navigation
fix: treat zero win32 inodes as unknown file identity - #129
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 12, 2026, 12:01 AM ET / 04:01 UTC. ClawSweeper reviewWhat this changesThe PR treats zero Windows device and inode values as unknown during file-identity comparison to avoid intermittent read failures after path-stat fallback. Regression provenancePossible regression — probable (reviewed change; reproduction). No predecessor PR is attributed. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 7 items remain Keep this PR open: its revised test still makes an unknown Win32 inode satisfy a security identity guard, weakening the package’s documented fail-closed TOCTOU protection. Priority: P1 Review scores
Verification
How this fits togetherFilesystem operations compare pre-open and post-open pathname metadata with the opened descriptor to detect swaps before reading, extracting, or modifying a file. The shared identity comparator feeds those guards across regular reads, secure files, and archive staging. flowchart LR
A[Caller path] --> B[Pre-open and post-open path stats]
A --> C[Opened file descriptor stat]
B --> D[File identity comparison]
C --> D
D -->|same identity| E[Read extract or modify]
D -->|mismatch| F[path-mismatch rejection]
Decision needed
Why: The shared helper is a security boundary used by many operations, so choosing availability over unproven file identity requires explicit owner confirmation. Before merge
Findings
Agent review detailsSecurityNeeds attention: The patch weakens a shared post-open identity boundary by treating unavailable identity data as successful verification. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep identity equality fail-closed and add a narrowly bounded Windows re-stat or retry path that proceeds only after known identities match; otherwise retain Do we have a high-confidence way to reproduce the issue? Yes at source level: the proposed table directly reproduces acceptance of an unknown inode against a known unequal inode. No real Windows fallback run is provided for the claimed intermittent-read symptom. Is this the best way to solve the issue? No. Treating unknown identity as equality conflicts with the documented and repository-required fail-closed identity contract; a bounded retry before rejection is the safer path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7a0d57ef5948. LabelsLabel changes:
Label justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
What Problem This Solves
Fixes an issue where Windows consumers performing legitimate reads could nondeterministically receive
FsSafeError("path-mismatch", "File changed during read")when antivirus or indexer contention prevented libuv from opening the path for stat.This was observed in
openclaw/openclawWindows CI after the 0.5.4 bump at commit5295f2578e1be1:checks-windows-node-testintermittently failed insrc/media/local-media-path.windows.test.tswithManagedImageAttachmentErrorafterverifyStableReadTargetrejected an unchanged file.Why This Change Was Made
On Windows, libuv falls back to
FindFirstFiledata whenGetFileInformationByHandlecannot open the file. That fallback reports bothdev=0andino=0.sameFileIdentityalready treated either-side zero device identity as unknown on Win32, but compared inode identity strictly, so a path stat withino=0mismatched an fd stat containing the real nonzero inode.The comparison now uses one symmetric per-field rule: a field differs only when both values are known and unequal. Win32 zero device serials and inodes are unknown; non-Windows comparisons remain strict.
(dev, ino)(dev, ino)(1, 0)(1, 5)(1, 5)(1, 0n)(0, 0)(2, 5)(1, 0)(2, 5)(1, 4)(1, 5)(1, 0)(1, 5)User Impact
Windows reads no longer fail spuriously with
path-mismatchwhen a transient libuv path-stat fallback cannot provide file identity. Known unequal device or inode values still fail closed, and every non-Windows comparison retains the existing strict behavior.Evidence
pnpm test test/coverage-more.test.ts test/regular-file-failure.test.ts test/rename-identity-policy.test.tspnpm checkgit diff --checkpassedStructured autoreview reported no accepted or actionable findings.
Tests added or updated when behavior changed
Security and compatibility impact considered
CHANGELOG.mdupdated when release-relevantNo credentials, private paths, private hosts, or sensitive contents included