Skip to content

fix(windows): align async/sync safe-open identity checks#25917

Merged
steipete merged 2 commits intomainfrom
fix/windows-fs-safe-dev-ino-mismatch
Feb 25, 2026
Merged

fix(windows): align async/sync safe-open identity checks#25917
steipete merged 2 commits intomainfrom
fix/windows-fs-safe-dev-ino-mismatch

Conversation

@steipete
Copy link
Contributor

@steipete steipete commented Feb 25, 2026

Summary

  • extract file-identity matching into shared src/infra/file-identity.ts
  • use the same identity rule in both async (fs-safe.ts) and sync (safe-open-sync.ts) safe-open paths
  • keep strict dev checks when both sides are non-zero, while allowing Windows dev=0 fallback parity with existing sync behavior
  • add focused unit coverage for number/bigint + win32/non-win32 cases

Why this shape

safe-open-sync already had a Windows fallback for dev=0; async openVerifiedLocalFile did not, so reasoning/media attachment reads on Windows could be dropped with Local media path is not safe to read. Sharing one helper removes drift risk.

Tests

  • pnpm test src/infra/file-identity.test.ts src/infra/fs-safe.test.ts
  • pnpm check
  • pnpm build

Related

Greptile Summary

Extracted file identity comparison into a shared helper (src/infra/file-identity.ts) to unify Windows dev=0 handling across async (fs-safe.ts) and sync (safe-open-sync.ts) safe-open paths. Previously, only the sync path had the Windows fallback, causing Local media path is not safe to read errors in async flows (reasoning/media attachments).

Key changes:

  • Created sameFileIdentity helper with platform-aware dev=0 fallback for Windows while preserving strict checks when both dev values are non-zero
  • Added comprehensive test coverage for number/bigint types and win32/non-win32 platforms
  • Both async and sync paths now use the same identity validation logic, eliminating drift risk

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The refactoring extracts duplicated logic into a well-tested shared helper, improving code maintainability while preserving existing behavior. The Windows dev=0 fallback logic was already present in the sync path and is now properly shared with the async path. Comprehensive test coverage validates all edge cases (number/bigint, win32/non-win32, dev=0 handling, strict mode). The change fixes real user-reported issues without introducing new risks.
  • No files require special attention

Last reviewed commit: 5678903

@cursor
Copy link

cursor bot commented Feb 25, 2026

PR Summary

Low Risk
Small, well-scoped refactor of file identity checks with added tests; behavioral change is limited to Windows dev=0 edge cases in safe-open validation.

Overview
Fixes Windows false negatives in async safe-open validation by treating dev=0 stats as an unknown device and falling back to inode-only comparison when appropriate.

Extracts the identity comparison into shared src/infra/file-identity.ts and switches both fs-safe.ts (async) and safe-open-sync.ts (sync) to use it, with new unit tests covering win32/non-win32 and number/bigint cases.

Written by Cursor Bugbot for commit 0c9242d. This will update automatically on new commits. Configure here.

@openclaw-barnacle openclaw-barnacle bot added size: S maintainer Maintainer-authored PR labels Feb 25, 2026
shenghui kevin and others added 2 commits February 25, 2026 00:36
…ocalFile

On Windows, device IDs (dev) returned by handle.stat() and fs.lstat()
may differ even for the same file, causing false-positive 'path-mismatch'
errors when reading local media files.

This fix introduces a statsMatch() helper that:
- Always compares inode (ino) values
- Skips device ID (dev) comparison on Windows where it's unreliable
- Maintains full comparison on Unix platforms

Fixes #25699
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@steipete steipete force-pushed the fix/windows-fs-safe-dev-ino-mismatch branch from 5678903 to 0c9242d Compare February 25, 2026 00:42
@steipete steipete merged commit 943b8f1 into main Feb 25, 2026
10 checks passed
@steipete steipete deleted the fix/windows-fs-safe-dev-ino-mismatch branch February 25, 2026 00:42
@steipete
Copy link
Contributor Author

Landed via temp rebase onto main.

  • Gate: pnpm test src/infra/file-identity.test.ts src/infra/fs-safe.test.ts && pnpm check && pnpm build
  • Land commit: 0c9242d
  • Merge commit: 943b8f1

Thanks @steipete!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment