Repository navigation
fix(pacquet): preserve exec bit on clone/reflink import path - #12502
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughA new shared helper ChangesExec-bit restoration refactor
Sequence DiagramsequenceDiagram
participant git_fetcher as git-fetcher<br/>materialize_into
participant pkg_mgr as package-manager<br/>copy_file/clone_file
participant restore as restore_exec_bit_from_cas_suffix
participant fs_ops as fs::copy /<br/>reflink_copy::reflink
git_fetcher->>fs_ops: Copy/reflink file
fs_ops-->>git_fetcher: Ok(target)
git_fetcher->>restore: restore_exec_bit_from_cas_suffix(cas_path, target)
restore-->>git_fetcher: Ok(()) / Err
pkg_mgr->>fs_ops: Copy/reflink file
fs_ops-->>pkg_mgr: Ok(target)
pkg_mgr->>restore: restore_exec_bit_from_cas_suffix(source, target)
restore-->>pkg_mgr: Ok(()) / Err
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests (beta)
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 pacquet reflink imports dropping executable bit for Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1.
|
|
Code review by qodo was updated up to the latest commit adb7bff |
Integrated-Benchmark Report (Linux)Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.08563647538,
"stddev": 0.2041469382416594,
"median": 3.9983781778800003,
"user": 3.7874738,
"system": 3.4672203799999997,
"min": 3.96890894738,
"max": 4.631337161379999,
"times": [
3.96890894738,
4.205107980379999,
3.9867118623800004,
4.0385051253799995,
4.631337161379999,
4.06540021138,
3.98887096838,
4.00526990038,
3.99148645538,
3.9747661413800004
]
},
{
"command": "pacquet@main",
"mean": 4.09903906858,
"stddev": 0.167691301452313,
"median": 4.06546291938,
"user": 3.7869877999999995,
"system": 3.48500108,
"min": 3.8996674813800003,
"max": 4.345026241379999,
"times": [
4.00503241638,
3.93423703938,
3.96898176638,
4.267841413379999,
4.27857880838,
4.2202616293799995,
4.345026241379999,
3.8996674813800003,
4.12589342238,
3.94487046738
]
},
{
"command": "pnpr@HEAD",
"mean": 2.16911270158,
"stddev": 0.11865810464218618,
"median": 2.1780750828800004,
"user": 2.5972915,
"system": 2.98088408,
"min": 2.00821789138,
"max": 2.3080671443800003,
"times": [
2.25855636038,
2.1734079203800003,
2.29133476338,
2.13474938538,
2.02785732838,
2.00821789138,
2.3080671443800003,
2.28861949038,
2.18274224538,
2.01757448638
]
},
{
"command": "pnpr@main",
"mean": 2.16261506888,
"stddev": 0.10994649345795511,
"median": 2.15552555588,
"user": 2.6401373,
"system": 2.95949048,
"min": 2.01968214238,
"max": 2.3512939853800003,
"times": [
2.2209862293800002,
2.07636314838,
2.02551681438,
2.15209491938,
2.14752169738,
2.1589561923800002,
2.1602413833800003,
2.01968214238,
2.3134941763800003,
2.3512939853800003
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.64711574994,
"stddev": 0.010554755606534147,
"median": 0.6434376257400001,
"user": 0.38017776,
"system": 1.31126236,
"min": 0.6368208927400001,
"max": 0.6617922567400001,
"times": [
0.63734559574,
0.66076596074,
0.6368208927400001,
0.64578442274,
0.6410908287400001,
0.6617922567400001,
0.64012069274,
0.6488233747400001,
0.6615529187400001,
0.6370605557400001
]
},
{
"command": "pacquet@main",
"mean": 0.6498126548400001,
"stddev": 0.028576058043254325,
"median": 0.6412073442400001,
"user": 0.36773506,
"system": 1.32389606,
"min": 0.62435531874,
"max": 0.70684832474,
"times": [
0.69215871774,
0.64103384374,
0.62648901974,
0.6323521227400001,
0.62435531874,
0.62520793374,
0.6413808447400001,
0.70684832474,
0.6568834347400001,
0.6514169877400001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6909881041400001,
"stddev": 0.007564308141588686,
"median": 0.6907291472400001,
"user": 0.39303846,
"system": 1.35292616,
"min": 0.6808827557400001,
"max": 0.70588572774,
"times": [
0.6973131517400001,
0.6914854787400001,
0.6957840737400001,
0.6808827557400001,
0.68556459674,
0.6926070027400001,
0.68997281574,
0.70588572774,
0.68889525774,
0.6814901807400001
]
},
{
"command": "pnpr@main",
"mean": 0.6852039394400001,
"stddev": 0.015764719813435975,
"median": 0.6882878532400001,
"user": 0.3865087599999999,
"system": 1.34627716,
"min": 0.65513432674,
"max": 0.7051658147400001,
"times": [
0.6642809617400001,
0.6957151907400001,
0.65513432674,
0.7051658147400001,
0.6956573877400001,
0.68379732374,
0.69277838274,
0.69798277074,
0.68345297274,
0.67807426274
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.1845475507800005,
"stddev": 0.039250972575692405,
"median": 4.1852438663800005,
"user": 3.66421576,
"system": 3.3468447599999998,
"min": 4.12336326938,
"max": 4.23147589438,
"times": [
4.18350418838,
4.23147589438,
4.18472400138,
4.22323225638,
4.21766686938,
4.12336326938,
4.14010011438,
4.13746206238,
4.21818312038,
4.18576373138
]
},
{
"command": "pacquet@main",
"mean": 4.18316026218,
"stddev": 0.051278680089368464,
"median": 4.19688731838,
"user": 3.69009286,
"system": 3.3283987600000002,
"min": 4.07636474738,
"max": 4.25504809038,
"times": [
4.25504809038,
4.07636474738,
4.1988861033800005,
4.21589692738,
4.14980314138,
4.23390126238,
4.1539277953800005,
4.15399991738,
4.1983571063800005,
4.19541753038
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1758672763800004,
"stddev": 0.13072749848745918,
"median": 2.1470866608800003,
"user": 2.47622556,
"system": 2.8836918599999994,
"min": 2.03122119338,
"max": 2.37207734738,
"times": [
2.13983322238,
2.05714130938,
2.05492442138,
2.35455752038,
2.15434009938,
2.2707888133800003,
2.26812657838,
2.37207734738,
2.05566225838,
2.03122119338
]
},
{
"command": "pnpr@main",
"mean": 2.12974586808,
"stddev": 0.11842598078921014,
"median": 2.11273740788,
"user": 2.48251296,
"system": 2.8831059599999995,
"min": 2.00964822238,
"max": 2.44280033638,
"times": [
2.13150945138,
2.00964822238,
2.08504618138,
2.12307008238,
2.03770126138,
2.44280033638,
2.11041934638,
2.0854724133800002,
2.11505546938,
2.15673591638
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3042640696799999,
"stddev": 0.004175473378136324,
"median": 1.30479338508,
"user": 1.3048352800000003,
"system": 1.6859889199999998,
"min": 1.29803282508,
"max": 1.31034668908,
"times": [
1.30452399708,
1.30158175508,
1.31034668908,
1.29908538808,
1.3010904080799999,
1.29803282508,
1.30732787308,
1.30506277308,
1.3087891490799999,
1.30679983908
]
},
{
"command": "pacquet@main",
"mean": 1.31868188708,
"stddev": 0.0365826864348276,
"median": 1.30549324408,
"user": 1.3003914800000003,
"system": 1.7023301200000003,
"min": 1.29105483708,
"max": 1.41711388408,
"times": [
1.30601640608,
1.31227983108,
1.41711388408,
1.33495092408,
1.29105483708,
1.3165615600799998,
1.30404138608,
1.29715861908,
1.30267134108,
1.3049700820799999
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6499023676800001,
"stddev": 0.01207033839096831,
"median": 0.6469610535800001,
"user": 0.33573548,
"system": 1.27245192,
"min": 0.6357180320800001,
"max": 0.68089631208,
"times": [
0.65576200108,
0.6502886550800001,
0.6357180320800001,
0.64932635108,
0.6433805170800001,
0.6460897790800001,
0.68089631208,
0.64767171808,
0.6436399220800001,
0.6462503890800001
]
},
{
"command": "pnpr@main",
"mean": 0.6788971598799999,
"stddev": 0.08750387365531254,
"median": 0.6510158125800001,
"user": 0.33935758,
"system": 1.26950112,
"min": 0.63185959008,
"max": 0.9180247810800001,
"times": [
0.71787912608,
0.6534698600800001,
0.6523082560800001,
0.6522118050800001,
0.64118267908,
0.63185959008,
0.64981982008,
0.6349132120800001,
0.6373024690800001,
0.9180247810800001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.95350472032,
"stddev": 0.0414567331199155,
"median": 2.93859792392,
"user": 1.71721294,
"system": 1.9161997200000003,
"min": 2.92801541742,
"max": 3.0643038974200003,
"times": [
2.9343894394200003,
2.9409204514200002,
2.9531007004200003,
2.92855882042,
2.92865739042,
2.9465225324200004,
2.92801541742,
2.9743031574200005,
3.0643038974200003,
2.93627539642
]
},
{
"command": "pacquet@main",
"mean": 2.9579802774200004,
"stddev": 0.057518075397937095,
"median": 2.9438030709200005,
"user": 1.7112153400000003,
"system": 1.9318699200000005,
"min": 2.91707145842,
"max": 3.11336540842,
"times": [
2.9458910144200003,
2.95593647942,
2.9782057654200003,
2.91707145842,
2.93662486942,
2.9260098294200003,
2.91909180742,
3.11336540842,
2.94538900142,
2.9422171404200004
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6578810649200001,
"stddev": 0.006786507506287063,
"median": 0.65672862592,
"user": 0.33252644,
"system": 1.29097242,
"min": 0.64565457242,
"max": 0.66966253342,
"times": [
0.65720066742,
0.66328576742,
0.66467163242,
0.64565457242,
0.65304945342,
0.65942356042,
0.65625658442,
0.6560523514200001,
0.66966253342,
0.65355352642
]
},
{
"command": "pnpr@main",
"mean": 0.6463379730199998,
"stddev": 0.0050027432710042985,
"median": 0.64694080842,
"user": 0.33333793999999994,
"system": 1.27556702,
"min": 0.6382659054200001,
"max": 0.65379581142,
"times": [
0.63902582342,
0.65128970742,
0.64876153642,
0.64512008042,
0.6382659054200001,
0.64898259942,
0.65379581142,
0.6442124744200001,
0.64881118642,
0.64511460542
]
}
]
} |
|
| Branch | pr/12502 |
| Testbed | pacquet |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,184.55 ms(-0.74%)Baseline: 4,215.93 ms | 5,059.11 ms (82.71%) |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot 🚷 view threshold | 2,953.50 ms(-1.55%)Baseline: 3,000.12 ms | 3,600.14 ms (82.04%) |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 1,304.26 ms(-1.64%)Baseline: 1,326.07 ms | 1,591.28 ms (81.96%) |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot 🚷 view threshold | 4,085.64 ms(-1.53%)Baseline: 4,149.09 ms | 4,978.91 ms (82.06%) |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot 🚷 view threshold | 647.12 ms(+5.21%)Baseline: 615.09 ms | 738.11 ms (87.67%) |
|
| Branch | pr/12502 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,175.87 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 657.88 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 649.90 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,169.11 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 690.99 ms |
|
There are unresolved comments |
|
I'm planning to address these comments. Please bear with me. 🙏 |
|
Code review by qodo was updated up to the latest commit e129905 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12502 +/- ##
==========================================
- Coverage 88.18% 88.17% -0.01%
==========================================
Files 313 313
Lines 43085 43096 +11
==========================================
+ Hits 37994 38001 +7
- Misses 5091 5095 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
All automated reviews have been resolved. Only #12502 (comment) was not automatically resolved, so I replied to it and resolved it manually. |
|
Code review by qodo was updated up to the latest commit 2c3d88a |
The "-exec suffix is the source of truth / FICLONE drops the mode" why was repeated across copy_file, clone_file, make_file_executable, and the added tests. Keep it once on restore_exec_bit_from_cas_suffix and let the call sites and tests reference or assume it, trimming the duplicated prose.
Generalize the "do not restate the callee's doc at the call site" rule to peers that share a common helper, so a single why is documented once at the common home instead of repeated in each sibling function.
|
Code review by qodo was updated up to the latest commit ffb1967 |
restore_exec_bit_from_cas_suffix opens the target to chmod through the fd. Wrap that open in retry_on_fd_pressure, like every other open on the parallel import path, so a transient EMFILE/ENFILE from a sibling rayon worker can't fail the install.
…ore failure Deleting the just-reflinked target when exec-bit restoration failed could race a concurrent importer that already returned success on EEXIST, leaving it with a missing file. Drop the delete and instead re-assert the exec bit in import_into_fresh_target's EEXIST branch: a target a failed restore left at 0o644 is healed on the next import without anyone deleting a file out from under a concurrent writer. Diverges from pnpm's linkOrCopy EEXIST no-op because pacquet's reflink, unlike pnpm's FICLONE_FORCE copy, drops the mode.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pacquet/crates/package-manager/src/link_file.rs (1)
254-258: 💤 Low valueIncomplete doc comment for
clone_file.The doc comment contains only a cross-reference without describing the function's purpose or contract. Consider expanding it:
-/// [`pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix`]. +/// Clones `source_file` to `target_link` via reflink and restores executable +/// bits when the CAS path ends with `-exec`. See +/// [`pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix`]. fn clone_file(source_file: &Path, target_link: &Path) -> io::Result<()> {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pacquet/crates/package-manager/src/link_file.rs` around lines 254 - 258, The doc comment for the clone_file function is incomplete and only contains a cross-reference without describing its purpose or contract. Expand the doc comment to explain what the function does, describe the parameters source_file and target_link, explain the return type io::Result<()>, and clarify any important behavior such as how it reflinks the file and restores executable bits from the CAS suffix. Ensure the documentation provides sufficient context for callers to understand the function's purpose and usage.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pacquet/crates/package-manager/src/link_file.rs`:
- Around line 254-258: The doc comment for the clone_file function is incomplete
and only contains a cross-reference without describing its purpose or contract.
Expand the doc comment to explain what the function does, describe the
parameters source_file and target_link, explain the return type io::Result<()>,
and clarify any important behavior such as how it reflinks the file and restores
executable bits from the CAS suffix. Ensure the documentation provides
sufficient context for callers to understand the function's purpose and usage.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1d16f27a-42cd-44a1-9528-3029cc6abc76
📒 Files selected for processing (4)
pacquet/crates/fs/src/ensure_file.rspacquet/crates/fs/src/file_mode.rspacquet/crates/package-manager/src/link_file.rspacquet/crates/package-manager/src/link_file/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
- pacquet/crates/fs/src/file_mode.rs
|
Code review by qodo was updated up to the latest commit d27d15b |
|
Thanks for the fixes and merge! |
Summary
Fixes #12500. Follow-up to #12385.
pacquet stores executable CAFS entries under paths ending in
-exec. Itsdefault
Autoimport method tries clone (reflink) → hardlink → copy.#12385 restored the exec bit on the copy tier, but the clone
(reflink) tier was left out and still dropped it.
On Linux
reflink_copy::reflinkusesFICLONE, which clones only the datainto a freshly-created
0o644target, so a native binary such as@esbuild/linux-x64/bin/esbuild(which has nobinfield, so pacquet neverruns
ensure_executable_bitsto paper over it) lands non-executable and failsto spawn with
EACCES. macOSclonefilecopies the mode, so the bug onlysurfaces on filesystems where the Linux reflink path succeeds (e.g. CircleCI).
hardlink shares the store inode's
0o755and copy was already fixed, so onlyclone was affected.
The fix extracts the
-exec-suffix restoration (previously duplicated incopy_fileandgit-fetcher'smaterialize_into) into a sharedpacquet_fs::file_mode::restore_exec_bit_from_cas_suffix, and routes the clonetier through it so reflinked binaries are re-marked
0o755.This is a pacquet-only bug. pnpm's TS importer clones with
copyFileSync(COPYFILE_FICLONE_FORCE), which carries the mode across, so nopnpm-side change is needed.
Squash Commit Body
Checklist
pacquet/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.
Summary by CodeRabbit
-execsuffix, including clone/reflink flows.AlreadyExistsfor executable-execsources.AlreadyExistsscenarios.