Repository navigation
fix(injected-deps-syncer): identify a file by its device as well as its inode - #13847
Conversation
…ts inode An inode number is only unique within one filesystem, so comparing bare inode numbers lets an unrelated file on another device collide with the one being synced. The diff then reads the two as the same file, skips the replacement, and leaves that path stale in the injected copy. Carry the device alongside it, as a `<device>:<inode>` string. The identity stays a primitive, so the comparison the inode map is built around is still a `===` rather than a structural one; `dev` comes from the same stat that already supplied `ino`, so this costs no extra syscall. Nothing changes where injection works at all: a hardlink cannot cross a filesystem, so the device is equal on both sides and the comparison is the one it was before. It only affects the broken cross-device case, which now reaches a clear EXDEV from `fs.link` instead of silently skipping the file. Matches pacquet, which took the same identity in #13834.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe injected-dependency syncer now identifies files with device and inode numbers. Tests and patch release metadata use the new ChangesInjected syncer identity
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix injected-deps-syncer file identity to use : (avoid cross-device inode collisions)
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Confidence Score: 5/5The PR appears safe to merge, with the file-identity representation updated consistently across production code and tests. The changed runtime path always constructs device-qualified string identities, all internal consumers accept that representation, and focused coverage verifies the cross-device inode-collision case without exposing an incompatible public or persisted boundary. Reviews (1): Last reviewed commit: "test(injected-deps-syncer): carry the de..." | Re-trigger Greptile |
Code Review by Qodo
1. Lossy dev/ino identity
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
extendFilesMapidentified a file by its inode number alone. An inode number is only unique within one filesystem, so an unrelated file on another device could collide with the one being synced — the diff reads the two as the same file, skips the replacement, and leaves that path stale in the injected copy.A file's identity is now
<device>:<inode>.devcomes from the samestatthat already suppliedino, so this costs no extra syscall, and the identity stays a primitive — the property the inode map is built around, per the note aboveFile:so the comparison is still a
===rather than a structural one. The cost is one short string per file instead of a number; a template literal was chosen over packing both halves into a single number becausedevandinoare each up to 64-bit and would not survive the 53-bit safe-integer range.Scope of the behavior change is narrow, and worth being explicit about. An injected copy is materialized with
fs.link, which cannot cross a filesystem, so in any configuration where the feature works at all the device is equal on both sides and<device>:<inode>and bare<inode>are the same comparison. This only bites in the already-broken cross-device case, where a coincidental inode collision previously caused a silent skip and a stale file; now the file is scheduled andfs.linksurfaces a clearEXDEV. That is a better failure rather than a fix to a working setup.Rust: already correct. pacquet took
FileId { device, inode }in #13834 — this is the TypeScript half, called out as a follow-up in that PR's review, and closes the divergence.Tests: a new case in
extendFilesMap.test.tsdrives two files that share an inode number on different devices through the injected-stats seam and asserts their identities differ; it fails when the device is dropped from the identity. The existing fixtures acrossextendFilesMap,diffDir,applyPatch, andDirPatchernow carry a device. Thepnpm/test/syncInjectedDepsAfterScriptsend-to-end suite still passes against a rebuilt bundle.No cross-device fixture: a test would have to mount a second filesystem, which the suite cannot do portably, and the only assertion available to it (
fs.linkrejects withEXDEV) is the platform's behavior rather than this package's.Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5[1m]).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests
Documentation