Skip to content

fix(pacquet): preserve exec bit on clone/reflink import path - #12502

Merged
zkochan merged 8 commits into
pnpm:mainfrom
kimulaco:fix/12500
Jun 19, 2026
Merged

zkochan merged 8 commits into
pnpm:mainfrom
kimulaco:fix/12500

Conversation

@kimulaco

@kimulaco kimulaco commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #12500. Follow-up to #12385.

pacquet stores executable CAFS entries under paths ending in -exec. Its
default Auto import 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::reflink uses FICLONE, which clones only the data
into a freshly-created 0o644 target, so a native binary such as
@esbuild/linux-x64/bin/esbuild (which has no bin field, so pacquet never
runs ensure_executable_bits to paper over it) lands non-executable and fails
to spawn with EACCES. macOS clonefile copies the mode, so the bug only
surfaces on filesystems where the Linux reflink path succeeds (e.g. CircleCI).
hardlink shares the store inode's 0o755 and copy was already fixed, so only
clone was affected.

The fix extracts the -exec-suffix restoration (previously duplicated in
copy_file and git-fetcher's materialize_into) into a shared
pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix, and routes the clone
tier 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 no
pnpm-side change is needed.

Squash Commit Body

On Linux reflink_copy::reflink uses FICLONE, which clones only the data into a
freshly-created 0o644 target, dropping the exec bit pacquet encodes in the
`-exec` CAS suffix. pnpm/pnpm#12385 restored it for the copy tier but left clone
out, so an undeclared executable like `@esbuild/linux-x64/bin/esbuild` failed
with EACCES. hardlink shares the store inode's 0o755 and copy was fixed, so only
clone was affected.

Extract the restoration (already duplicated in copy_file and git-fetcher's
materialize_into) into a shared
pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix and route clone through
it. In auto_link / clone_or_copy_link only a reflink failure downgrades; the
post-reflink restoration error stays terminal, so it can't trigger a hardlink
retry against the just-created file that would mask it behind AlreadyExists.

Fixes pnpm/pnpm#12500.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

Summary by CodeRabbit

  • New Features
    • Executable file permissions are restored when materializing and copying CAS entries marked with an executable -exec suffix, including clone/reflink flows.
  • Bug Fixes
    • Prevents permission broadening for non-executable CAS entries.
    • Avoids redundant updates when executable bits are already correct.
    • Heals existing targets appropriately on AlreadyExists for executable -exec sources.
  • Tests
    • Added Unix-only unit and integration tests covering exec-bit restoration and non-widening across materialize, copy, clone, and AlreadyExists scenarios.
  • Documentation
    • Updated contributor guidance on documenting shared rationale once and referencing it.

@kimulaco
kimulaco requested a review from zkochan as a code owner June 18, 2026 15:05
@coderabbitai

coderabbitai Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

A new shared helper restore_exec_bit_from_cas_suffix is added to pacquet_fs::file_mode, replacing previously duplicated inline Unix exec-bit restoration logic throughout the codebase. The helper is wired into git-fetcher's materialize_into and package-manager's copy/clone/import/auto-link paths. make_file_executable is optimized to skip the set_permissions syscall when all executable bits are already present. Unit and integration tests validate both the helper and its integration points.

Changes

Exec-bit restoration refactor

Layer / File(s) Summary
restore_exec_bit_from_cas_suffix helper and unit tests
pacquet/crates/fs/src/file_mode.rs, pacquet/crates/fs/src/file_mode/tests.rs
Adds restore_exec_bit_from_cas_suffix(cas_path, target) that on Unix ORs EXEC_MASK into the target's permissions when cas_path ends with -exec; is a no-op on non-Unix platforms. Optimizes make_file_executable to skip set_permissions when all exec bits are already set. Three unit tests verify exec-suffix, non-exec-suffix, and partial-bit-filling behavior.
git-fetcher materialize_into wired to shared helper
pacquet/crates/git-fetcher/src/cas_io.rs, pacquet/crates/git-fetcher/src/cas_io/tests.rs
Imports and replaces 15 lines of inline #[cfg(unix)] exec-bit logic with a single call to restore_exec_bit_from_cas_suffix; adds an integration test asserting -exec-suffixed CAS entries materialize as 0o755 and non-exec entries remain restrictive.
package-manager copy/clone paths wired to shared helper
pacquet/crates/package-manager/src/link_file.rs, pacquet/crates/package-manager/src/link_file/tests.rs
Routes try_import's Clone branch through clone_file for centralized logging. Refactors copy_file and clone_file to call restore_exec_bit_from_cas_suffix after the underlying syscall, removing platform-specific inline permission logic.
package-manager import/auto_link paths wired to shared helper
pacquet/crates/package-manager/src/link_file.rs, pacquet/crates/package-manager/src/link_file/tests.rs
Adds exec-bit restoration to import_into_fresh_target's EEXIST handler to re-assert executable bits from the -exec suffix rather than leaving existing target permissions untouched. Updates auto_link and clone_or_copy_link post-reflink success paths to perform exec-bit restoration, making restoration failures terminal. Adds two Unix-only tests validating EEXIST behavior with and without the -exec suffix.
Supporting visibility and documentation changes
pacquet/crates/fs/src/ensure_file.rs, AGENTS.md, pacquet/AGENTS.md
Exposes retry_on_fd_pressure as pub(crate) for cross-module reuse. Updates documentation guidance to recommend documenting shared rationale once at a common location and referencing it from related functions.

Sequence Diagram

sequenceDiagram
  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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#12385: Introduced cas_path_is_executable and inline exec-bit preservation in the copy fallback path—the exact logic this PR centralizes into restore_exec_bit_from_cas_suffix.
  • pnpm/pnpm#11864: Introduced import_into_fresh_target helper that this PR extends with exec-bit healing on EEXIST.
  • pnpm/pnpm#11856: Modified AlreadyExists handling logic in link_file.rs—this PR further refines that path with exec-bit restoration from the -exec suffix.

Suggested reviewers

  • zkochan
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix pacquet reflink imports dropping executable bit for -exec CAS entries
🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

Description

• Restore executable bits after Linux reflink (FICLONE) materialization when CAS path ends with
 -exec.
• Deduplicate exec-bit restoration logic into a shared filesystem helper.
• Add Unix-only regression tests covering exec and non-exec CAS materialization.
Diagram

graph TD
  I(["Package import"]) --> M{"Import tier"}
  M -->|"Clone / reflink"| R["reflink_copy::reflink"] --> X["restore_exec_bit_from_cas_suffix"] --> T[("Target file")]
  M -->|"Hardlink"| H["fs::hard_link"] --> T
  M -->|"Copy"| C["fs::copy"] --> X --> T
  subgraph Legend
    direction LR
    _step["Operation"] ~~~ _dec{"Decision"} ~~~ _file[("File")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Preserve mode inside reflink implementation
  • ➕ Avoids a post-reflink chmod on macOS and other platforms where reflink already preserves mode
  • ➕ Keeps permission handling closer to the low-level reflink operation
  • ➖ Still needs CAS-suffix semantics to know when to add exec bits if the source lost them earlier
  • ➖ Requires changing/depending on reflink_copy crate behavior and may be less portable across OS/filesystem quirks
2. Always run a higher-level “ensure executable bits” pass
  • ➕ Centralizes behavior at a single layer after all imports/materializations
  • ➖ Can miss undeclared executables that never hit that pass (the bug trigger described in PR)
  • ➖ More expensive: would require scanning more files rather than only -exec CAS entries

Recommendation: The PR’s approach is the best trade-off: treat the CAS -exec suffix as the source of truth and apply a targeted, shared restoration step after materialization. It fixes Linux reflink’s 0644-target behavior without widening permissions for non-exec entries, and it removes duplicated logic across pacquet components.

Files changed (5) +130 / -37

Bug fix (1) +30 / -22
link_file.rsRestore exec bits after reflink clone tier and dedupe copy logic +30/-22

Restore exec bits after reflink clone tier and dedupe copy logic

• Routes the explicit 'Clone' import method through a new 'clone_file' wrapper that reflinks then restores exec bits from the CAS suffix. Also updates the 'Auto' and 'CloneOrCopy' reflink tiers to restore exec bits after successful reflink, and clarifies fallback behavior so only reflink failure triggers downgrading tiers.

pacquet/crates/package-manager/src/link_file.rs

Refactor (2) +26 / -15
file_mode.rsAdd shared helper to restore exec bit from '-exec' CAS suffix +22/-0

Add shared helper to restore exec bit from '-exec' CAS suffix

• Introduces 'restore_exec_bit_from_cas_suffix(cas_path, target)' to re-add POSIX exec bits when the CAS path ends with '-exec'. On Unix it chmods only when needed; on non-Unix it is a no-op.

pacquet/crates/fs/src/file_mode.rs

cas_io.rsUse shared exec-bit restoration in git fetcher materialization +4/-15

Use shared exec-bit restoration in git fetcher materialization

• Replaces duplicated '-exec' permission restoration logic in 'materialize_into' with a call to 'restore_exec_bit_from_cas_suffix' after 'fs::copy'.

pacquet/crates/git-fetcher/src/cas_io.rs

Tests (2) +74 / -0
tests.rsAdd unit tests for exec-bit restoration helper +42/-0

Add unit tests for exec-bit restoration helper

• Adds Unix-only tests verifying that '-exec' sources restore the target to '0o755' and that non-'-exec' sources do not widen restrictive modes (e.g. '0o600').

pacquet/crates/fs/src/file_mode/tests.rs

tests.rsAdd regression test for exec-bit restoration during git materialize +32/-0

Add regression test for exec-bit restoration during git materialize

• Adds a Unix-only test that strips exec bits from a stored '-exec' CAS file, materializes it, and asserts the target becomes '0o755' while a non-exec sibling retains its restrictive mode.

pacquet/crates/git-fetcher/src/cas_io/tests.rs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 18, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Restore error leaves stale file ✓ Resolved 🐞 Bug ☼ Reliability
Description
If reflink succeeds but restore_exec_bit_from_cas_suffix fails, the target file has already been
created and the import aborts, leaving a stale on-disk file behind. Subsequent “repair” imports can
treat that path as AlreadyExists/no-op and still place the completion marker, potentially completing
with a non-executable binary.
Code

pacquet/crates/package-manager/src/link_file.rs[R254-257]

+fn clone_file(source_file: &Path, target_link: &Path) -> io::Result<()> {
+    reflink_copy::reflink(source_file, target_link)?;
+    pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix(source_file, target_link)
}
Evidence
The clone tier now performs a two-step operation (reflink then chmod). The codebase’s repair logic
explicitly relies on EEXIST tolerance and reruns imports into marker-less directories, so leaving a
created file behind can prevent restoration from ever being retried while still allowing the marker
to be written later.

pacquet/crates/package-manager/src/link_file.rs[254-257]
pacquet/crates/package-manager/src/link_file.rs[161-185]
pacquet/crates/package-manager/src/import_indexed_dir.rs[142-153]
pacquet/crates/package-manager/src/import_indexed_dir.rs[218-237]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
After a successful `reflink_copy::reflink`, exec-bit restoration runs as a second step; if that second step fails, the created file remains on disk. Because later repair/populate passes tolerate `AlreadyExists` (and do not retry restoration), a subsequent run can incorrectly treat the stale file as “done” and complete the import.
### Issue Context
- `clone_file` (and the reflink success path in `auto_link`/`clone_or_copy_link`) creates the target before calling `restore_exec_bit_from_cas_suffix`.
- `import_into_fresh_target` treats `ErrorKind::AlreadyExists` as success.
- `import_indexed_dir` explicitly repairs marker-less directories by re-running population without pre-flight stats, relying on EEXIST tolerance.
### Fix Focus Areas
- pacquet/crates/package-manager/src/link_file.rs[254-257]
- pacquet/crates/package-manager/src/link_file.rs[161-185]
- pacquet/crates/package-manager/src/link_file.rs[312-356]
- pacquet/crates/package-manager/src/link_file.rs[365-392]
- pacquet/crates/package-manager/src/import_indexed_dir.rs[142-153]
- pacquet/crates/package-manager/src/import_indexed_dir.rs[218-237]
### Suggested change
On the reflink-success path, if `restore_exec_bit_from_cas_suffix` returns `Err(e)`, best-effort remove the just-created `target` (e.g., `let _ = fs::remove_file(target);`) before returning `Err(e)`. This prevents leaving behind an incorrectly-permissioned file that later repair passes will treat as a completed entry.
(Apply in `clone_file` and in the reflink-success branches inside `auto_link` and `clone_or_copy_link`.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Exec restore needs read 🐞 Bug ☼ Reliability
Description
restore_exec_bit_from_cas_suffix always does a read-only File::open(target) before chmodding, so
restoration can fail on targets without read permission (e.g. unusual umask/ACL), even though
chmod via path could still succeed. Because import_into_fresh_target invokes this helper on
AlreadyExists, a benign concurrent-import race can now become a hard install failure if the
existing target isn’t readable.
Code

pacquet/crates/fs/src/file_mode.rs[R37-51]

+pub fn restore_exec_bit_from_cas_suffix(cas_path: &Path, target: &Path) -> io::Result<()> {
+    #[cfg(unix)]
+    if cas_path_is_executable(cas_path) {
+        // Open once and chmod through the fd. A path-based
+        // `metadata()` + `set_permissions()` pair leaves a TOCTOU window where
+        // a concurrent writer could swap `target` between the two calls and
+        // redirect the chmod onto an unintended inode; binding both to one
+        // opened file closes it. Defense-in-depth on the install hot path.
+        //
+        // Retry the open under fd-table exhaustion like every other open on
+        // the parallel import path: a transient `EMFILE`/`ENFILE` from a
+        // sibling rayon worker must not fail the install.
+        let file = crate::ensure_file::retry_on_fd_pressure(|| std::fs::File::open(target))?;
+        make_file_executable(&file)?;
+    }
Evidence
The new helper unconditionally uses a read-only open when the CAS path ends with -exec, and the
package import code now calls this helper on the AlreadyExists recovery path, propagating any open
failure as an import error.

pacquet/crates/fs/src/file_mode.rs[28-55]
pacquet/crates/package-manager/src/link_file.rs[155-190]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`restore_exec_bit_from_cas_suffix` opens `target` with `std::fs::File::open` (O_RDONLY) before calling `make_file_executable`. If the existing target is not readable by the current process (possible under atypical umask or ACLs), the open fails and restoration errors. This error is now used on the `AlreadyExists` recovery path in `import_into_fresh_target`, so an otherwise-successful concurrent import can now abort the install.
### Issue Context
The helper is intended as defense-in-depth (fd-bound chmod) and is used on hot import paths, including the `AlreadyExists` adoption path.
### Fix Focus Areas
- pacquet/crates/fs/src/file_mode.rs[37-55]
- pacquet/crates/package-manager/src/link_file.rs[175-190]
### Suggested fix approach
- Change the open strategy to not require read permission (e.g. try `OpenOptions::new().write(true).open(target)` on Unix) since `fchmod` does not require a read-only fd.
- If opening still fails with `PermissionDenied` but the file already has all exec bits, consider short-circuiting via a path-based `metadata()` check.
- As a last-resort fallback for `PermissionDenied`/non-openable targets, consider a path-based `set_permissions` (accepting the narrower TOCTOU risk only in the exceptional failure case) so installs don’t fail solely due to lack of read permission when chmod would have succeeded.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. FD-pressure not retried 🐞 Bug ☼ Reliability
Description
restore_exec_bit_from_cas_suffix adds an unconditional File::open() for -exec entries; under
parallel imports this can fail with transient EMFILE/ENFILE and abort an install even though other
pacquet hot paths explicitly retry on fd pressure. This is a reliability regression specifically
introduced by the new exec-bit restoration path.
Code

pacquet/crates/fs/src/file_mode.rs[R37-46]

+pub fn restore_exec_bit_from_cas_suffix(cas_path: &Path, target: &Path) -> io::Result<()> {
+    #[cfg(unix)]
+    if cas_path_is_executable(cas_path) {
+        // Open once and chmod through the fd. A path-based
+        // `metadata()` + `set_permissions()` pair leaves a TOCTOU window where
+        // a concurrent writer could swap `target` between the two calls and
+        // redirect the chmod onto an unintended inode; binding both to one
+        // opened file closes it. Defense-in-depth on the install hot path.
+        make_file_executable(&std::fs::File::open(target)?)?;
+    }
Evidence
The new restore function performs File::open() per exec-suffixed file, and package materialization
imports files in parallel via rayon. The fs crate already documents and implements fd-pressure
retry/backoff to prevent installs failing under heavy concurrency, but the new restore path doesn’t
use it.

pacquet/crates/fs/src/file_mode.rs[28-50]
pacquet/crates/package-manager/src/import_indexed_dir.rs[218-237]
pacquet/crates/fs/src/ensure_file.rs[26-64]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`restore_exec_bit_from_cas_suffix()` opens the newly-imported target with `std::fs::File::open()` (for exec-suffixed CAS entries) and immediately propagates any error. In the parallel import hot path, this can surface transient `EMFILE`/`ENFILE` failures as hard install failures.
## Issue Context
The repo already contains a `retry_on_fd_pressure` helper (used by CAS writes/reads) to avoid failing installs under temporary fd-table exhaustion. The new restore path introduces additional fds but does not use similar retry/backoff.
## Fix Focus Areas
- pacquet/crates/fs/src/file_mode.rs[37-46]
- pacquet/crates/fs/src/ensure_file.rs[26-64]
- pacquet/crates/package-manager/src/import_indexed_dir.rs[218-237]
## Suggested approach
- Add a small fd-pressure retry around the `File::open(target)` in `restore_exec_bit_from_cas_suffix` (Unix only), matching the behavior of `retry_on_fd_pressure`.
- If you don’t want to expose `retry_on_fd_pressure` publicly, consider factoring a small shared helper into `pacquet_fs` (module-level, not test-only) that can be used by both `ensure_file` and `file_mode`.
- Keep the existing “single fd” TOCTOU hardening (fd-based chmod) intact; only wrap the open in retry/backoff for `EMFILE/ENFILE`.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Cleanup can break concurrent import 🐞 Bug ☼ Reliability
Description
On reflink success, restore_after_reflink deletes target_link if exec-bit restoration fails;
meanwhile import_into_fresh_target treats AlreadyExists as success and does not re-check the
target. If one importer observes AlreadyExists and returns success while another later hits a
restore error and deletes the shared target, the successful importer can be left with a missing
file.
Code

pacquet/crates/package-manager/src/link_file.rs[R265-270]

+fn restore_after_reflink(source_file: &Path, target_link: &Path) -> io::Result<()> {
+    pacquet_fs::file_mode::restore_exec_bit_from_cas_suffix(source_file, target_link).inspect_err(
+        |_| {
+            let _ = fs::remove_file(target_link);
+        },
+    )
Evidence
The new code explicitly deletes the target on restore failure, and the existing import primitive
explicitly treats AlreadyExists as success due to concurrent installs, without validating after
that point. Those two behaviors together create a concrete way for one concurrent importer to
observe success while the file is later removed.

pacquet/crates/package-manager/src/link_file.rs[155-185]
pacquet/crates/package-manager/src/link_file.rs[258-271]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`restore_after_reflink()` now removes the target file on restoration failure. However, `import_into_fresh_target()` explicitly treats `AlreadyExists` from the import syscall as a no-op success, and it does not validate that the target remains present/correct afterwards. Under concurrent imports to the same target, a process that returns success on `AlreadyExists` can be invalidated if another process later deletes the file due to a restore failure.
## Issue Context
The code comments already acknowledge concurrent installs and races leading to `AlreadyExists`. The new deletion-on-restore-error changes the behavior of those races from “benign duplicate work” to potential “successful caller ends with missing file.”
## Fix Focus Areas
- pacquet/crates/package-manager/src/link_file.rs[155-185]
- pacquet/crates/package-manager/src/link_file.rs[258-271]
## Suggested approach
- Consider handling `AlreadyExists` by verifying the target still exists (and, for `-exec` CAS sources, ensure restoration has been applied) before returning `Ok(())`.
- Alternatively, avoid deleting `target_link` on restore failure unless you can prove you’re deleting the inode you created (hard cross-platform), or make the delete conditional on error kinds where leaving the file would be strictly worse.
- Keep the goal of avoiding stale `0o644` files, but ensure the concurrency/EEXIST fast path can’t report success while another worker/process removes the file.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (2)
5. Path-based chmod race ✓ Resolved 🐞 Bug ⛨ Security
Description
restore_exec_bit_from_cas_suffix does a path-based metadata()+set_permissions() sequence, and the PR
newly invokes it on the successful reflink/clone tier; a concurrent writer that can replace the
target path between these operations could redirect the chmod to an unintended inode. This is mainly
a defense-in-depth hardening issue (requires ability to manipulate the destination directory
concurrently), but it expands the existing copy-tier pattern onto the clone hot path.
Code

pacquet/crates/fs/src/file_mode.rs[R39-44]

+    if cas_path_is_executable(cas_path) {
+        use std::os::unix::fs::PermissionsExt;
+        let mut perms = std::fs::metadata(target)?.permissions();
+        perms.set_mode(perms.mode() | EXEC_MASK);
+        std::fs::set_permissions(target, perms)?;
+    }
Evidence
The helper performs path-based metadata() then set_permissions() on target, and the package
import clone tier now calls this helper after a successful reflink, extending this pattern onto the
reflink/clone path.

pacquet/crates/fs/src/file_mode.rs[28-48]
pacquet/crates/package-manager/src/link_file.rs[246-257]
pacquet/crates/package-manager/src/link_file.rs[318-330]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`restore_exec_bit_from_cas_suffix()` uses `std::fs::metadata(target)` and `std::fs::set_permissions(target, ...)` (both path-based). Since this helper is now used on the reflink/clone success path, there is a TOCTOU window where the target path could be replaced between the metadata read and the chmod, potentially applying permission changes to the wrong inode.
### Issue Context
This is defense-in-depth: it requires a concurrent actor with the ability to modify the destination directory. However, using an fd-based approach is cheap and removes the internal race between stat and chmod.
### Fix Focus Areas
- pacquet/crates/fs/src/file_mode.rs[37-44]
### Suggested change
On Unix, open the `target` as a `File` first and then use `file.metadata()` + `file.set_permissions()` so the permission update is bound to the opened inode (removes the stat→chmod race window).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


6. Unconditional chmod on exec ✓ Resolved 🐞 Bug ➹ Performance
Description
restore_exec_bit_from_cas_suffix always calls set_permissions for -exec CAS entries even when the
target already has all exec bits set, adding avoidable syscalls to package import hot paths (notably
clone on macOS where mode is already preserved). This also needlessly mutates ctime/metadata for
already-correct files.
Code

pacquet/crates/fs/src/file_mode.rs[R37-44]

+pub fn restore_exec_bit_from_cas_suffix(cas_path: &Path, target: &Path) -> io::Result<()> {
+    #[cfg(unix)]
+    if cas_path_is_executable(cas_path) {
+        use std::os::unix::fs::PermissionsExt;
+        let mut perms = std::fs::metadata(target)?.permissions();
+        perms.set_mode(perms.mode() | EXEC_MASK);
+        std::fs::set_permissions(target, perms)?;
+    }
Evidence
The helper always chmods any -exec entry (no check for whether exec bits are already present), and
the package-manager clone tier explicitly calls this restoration even on platforms where the mode is
expected to already be correct.

pacquet/crates/fs/src/file_mode.rs[28-48]
pacquet/crates/package-manager/src/link_file.rs[246-257]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`restore_exec_bit_from_cas_suffix` unconditionally does a `set_permissions` when the CAS path ends with `-exec`, even if the destination already has `EXEC_MASK` set. This adds extra syscalls (and metadata churn) to a hot path.
### Issue Context
`link_file` now runs exec-bit restoration for the reflink/clone tier as well, and the code comment notes macOS `clonefile` already carries the mode across.
### Fix Focus Areas
- pacquet/crates/fs/src/file_mode.rs[28-48]
- pacquet/crates/package-manager/src/link_file.rs[246-257]
### Suggested change
On Unix, after reading `perms.mode()`, short-circuit if `(perms.mode() & EXEC_MASK) == EXEC_MASK` before calling `set_permissions`. This preserves the Linux reflink fix (where the bits are missing) but avoids redundant chmod on platforms/FS where reflink/copy already preserved exec bits.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread pacquet/crates/fs/src/file_mode.rs Resolved
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 18, 2026
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit adb7bff

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.086 ± 0.204 3.969 4.631 1.89 ± 0.13
pacquet@main 4.099 ± 0.168 3.900 4.345 1.90 ± 0.12
pnpr@HEAD 2.169 ± 0.119 2.008 2.308 1.00 ± 0.07
pnpr@main 2.163 ± 0.110 2.020 2.351 1.00
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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 647.1 ± 10.6 636.8 661.8 1.00
pacquet@main 649.8 ± 28.6 624.4 706.8 1.00 ± 0.05
pnpr@HEAD 691.0 ± 7.6 680.9 705.9 1.07 ± 0.02
pnpr@main 685.2 ± 15.8 655.1 705.2 1.06 ± 0.03
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.185 ± 0.039 4.123 4.231 1.96 ± 0.11
pacquet@main 4.183 ± 0.051 4.076 4.255 1.96 ± 0.11
pnpr@HEAD 2.176 ± 0.131 2.031 2.372 1.02 ± 0.08
pnpr@main 2.130 ± 0.118 2.010 2.443 1.00
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.304 ± 0.004 1.298 1.310 2.01 ± 0.04
pacquet@main 1.319 ± 0.037 1.291 1.417 2.03 ± 0.07
pnpr@HEAD 0.650 ± 0.012 0.636 0.681 1.00
pnpr@main 0.679 ± 0.088 0.632 0.918 1.04 ± 0.14
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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.954 ± 0.041 2.928 3.064 4.57 ± 0.07
pacquet@main 2.958 ± 0.058 2.917 3.113 4.58 ± 0.10
pnpr@HEAD 0.658 ± 0.007 0.646 0.670 1.02 ± 0.01
pnpr@main 0.646 ± 0.005 0.638 0.654 1.00
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
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12502
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark 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%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12502
Testbedpnpr

⚠️ 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-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,175.87 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
657.88 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
649.90 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,169.11 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
690.99 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan

zkochan commented Jun 18, 2026

Copy link
Copy Markdown
Member

There are unresolved comments

@kimulaco

Copy link
Copy Markdown
Contributor Author

I'm planning to address these comments. Please bear with me. 🙏

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit e129905

@codecov-commenter

codecov-commenter commented Jun 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.17%. Comparing base (2dd79e3) to head (d27d15b).

Files with missing lines Patch % Lines
pacquet/crates/package-manager/src/link_file.rs 47.05% 9 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kimulaco

Copy link
Copy Markdown
Contributor Author

All automated reviews have been resolved.

Only #12502 (comment) was not automatically resolved, so I replied to it and resolved it manually.

Comment thread pacquet/crates/fs/src/file_mode.rs Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2c3d88a

zkochan added 2 commits June 19, 2026 08:49
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.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit ffb1967

zkochan added 2 commits June 19, 2026 09:10
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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pacquet/crates/package-manager/src/link_file.rs (1)

254-258: 💤 Low value

Incomplete 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

📥 Commits

Reviewing files that changed from the base of the PR and between ffb1967 and d27d15b.

📒 Files selected for processing (4)
  • pacquet/crates/fs/src/ensure_file.rs
  • pacquet/crates/fs/src/file_mode.rs
  • pacquet/crates/package-manager/src/link_file.rs
  • pacquet/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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit d27d15b

@zkochan
zkochan merged commit 11ebd9d into pnpm:main Jun 19, 2026
31 checks passed
@kimulaco
kimulaco deleted the fix/12500 branch June 19, 2026 10:22
@kimulaco

Copy link
Copy Markdown
Contributor Author

Thanks for the fixes and merge!

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet: exec bit is not preserved when clone/reflink is used on Linux

3 participants