Skip to content

feat(pacquet-cli): add dedupe command - #12586

Merged
zkochan merged 13 commits into
pnpm:mainfrom
kairosci:feat/pacquet-dedupe
Jun 24, 2026
Merged

zkochan merged 13 commits into
pnpm:mainfrom
kairosci:feat/pacquet-dedupe

Conversation

@kairosci

@kairosci kairosci commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Ports the pnpm dedupe command to the pacquet Rust CLI. Runs the install pipeline with lockfile_only=true and dry_run=true when --check is passed, matching pnps dedupe behavior which performs a full resolution pass to collapse duplicate dependency ranges.

Related to #11633

Squash Commit Body

Ports the dedupe command from pnpm to pacquet. The CliCommand::Dedupe variant dispatches to DedupeArgs::run. When --check is passed, both lockfile_only and dry_run are set so the pipeline resolves without writing.

Related to pnpm/pnpm#11633

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, or the description notes what still needs porting. Implemented in pacquet only; the TypeScript CLI already has this command at pnpm11/installing/commands/src/dedupe.ts.
  • No changeset needed pacquet-internal changes do not affect published packages.
  • Tests added for dedupe and dedupe --check command execution.
  • No documentation changes needed.

Summary by CodeRabbit

Summary

  • New Features
    • Added a new pacquet dedupe CLI subcommand to deduplicate dependencies using lockfile-only installs for production, development, and optional groups.
    • Added --check to validate deduplication against the current lockfile; if changes are detected, the original lockfile state is restored and the command fails.
  • Bug Fixes
    • Ensured dedupe emits the standard end-of-command execution-time footer like other install-family commands.
  • Tests
    • Added integration tests covering lockfile creation and confirming dedupe --check does not materialize node_modules or alter pnpm-lock.yaml.

@kairosci
kairosci requested a review from zkochan as a code owner June 22, 2026 15:12
@coderabbitai

coderabbitai Bot commented Jun 22, 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

Adds a dedupe CLI subcommand with --check, wires it into CLI dispatch and install-family timing, and runs a lockfile-only install flow. Check mode compares and restores pnpm-lock.yaml; integration tests cover both paths.

Changes

dedupe CLI subcommand

Layer / File(s) Summary
CLI registration and dispatch
pacquet/crates/cli/src/cli_args.rs
Declares pub mod dedupe, imports DedupeArgs, adds Dedupe(DedupeArgs) to CliCommand, includes Dedupe in install-family timing, applies the clippy stack-frame allowance around Install, and adds the Dedupe dispatcher branch with DedupePipeline orchestration.
Config root and pipeline run
pacquet/crates/cli/src/cli_args.rs
Introduces derive_config_root_and_package_manager_to_sync, builds the lockfile path under config_root, reads the existing lockfile snapshot in check mode, and runs package-manager sync, config-dependency installation, and updateConfig hooks before calling DedupeArgs::run.
DedupeArgs struct and run implementation
pacquet/crates/cli/src/cli_args/dedupe.rs
Defines DedupeArgs with a --check boolean flag and implements run, which runs a lockfile-only install for Prod, Dev, and Optional groups, then compares or restores the lockfile when --check is enabled.
Dedupe integration tests
pacquet/crates/cli/tests/dedupe.rs
Adds two tests: one verifying that dedupe creates pnpm-lock.yaml with expected dependencies, and one verifying that dedupe --check succeeds without materializing node_modules or changing the lockfile.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • zkochan

Possibly related PRs

  • pnpm/pnpm#12585: Both PRs modify CliArgs::run in pacquet/crates/cli/src/cli_args.rs to extend the install-family dispatch with a new subcommand.

Sequence Diagram(s)

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.

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

Copy link
Copy Markdown

PR Summary by Qodo

feat(pacquet-cli): add dedupe and metadata cache subcommands
✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

Description

• Add dedupe subcommand to re-resolve dependencies and reduce lockfile duplication.
• Add cache subcommand to list/view/delete local registry metadata cache entries.
• Expose resolver mirror helpers and add CLI tests for cache behavior.
Diagram

graph TD
  U["User"] --> CLI["pacquet CLI"] --> DEDUPE["dedupe cmd"] --> INSTALL["Install pipeline"]
  CLI --> CACHE["cache cmd"] --> META[("Metadata cache")]
  CACHE --> INDEX[("Store index")]
  CACHE --> MIRROR["resolver::mirror helpers"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Implement dedupe as a lockfile-only transform
  • ➕ Avoids running the full install/resolution pipeline
  • ➕ Potentially faster and less network-dependent
  • ➖ Hard to match pnpm behavior without a full resolution pass
  • ➖ Higher risk of subtle incompatibilities in dependency selection
2. Keep `mirror` internal and expose a narrow cache API
  • ➕ Preserves encapsulation of resolver internals
  • ➕ Reduces surface area for downstream coupling
  • ➖ Requires creating/maintaining an additional facade module
  • ➖ May duplicate constants/encoding logic across crates if not centralized
3. Use `walkdir` + `globset` instead of `wax`
  • ➕ More common ecosystem choice; potentially easier contributor familiarity
  • ➕ Fine-grained control over walking and matching
  • ➖ More boilerplate vs wax's glob+walk integration
  • ➖ Would require reworking the current implementation

Recommendation: Reusing the Install pipeline for dedupe is the most reliable way to match pnpm’s “resolve to collapse ranges” behavior; the --check mapping to lockfile_only + dry_run is a clean way to avoid writes while still performing a full resolution pass. For cache, exporting resolver::mirror is acceptable given the CLI’s need for shared cache layout/encoding, but consider a small public facade API later if other crates start depending on mirror internals.

Files changed (7) +389 / -3

Enhancement (4) +302 / -3
cli_args.rsWire 'cache' and 'dedupe' into CLI subcommand dispatch +21/-2

Wire 'cache' and 'dedupe' into CLI subcommand dispatch

• Adds new modules and 'CliCommand' variants for 'cache' and 'dedupe', and routes execution through the appropriate reporter implementation for 'dedupe'. Updates cache dispatch to pass '&Config' directly and adds a clippy allow for large stack frames in 'run'.

pacquet/crates/cli/src/cli_args.rs

cache.rsAdd 'pacquet cache' subcommands (list, view, delete, list-registries) +221/-0

Add 'pacquet cache' subcommands (list, view, delete, list-registries)

• Implements metadata cache inspection and management, including registry discovery, glob-filtered listing, deletion across meta directory variants, and a JSON view that reports cached vs non-cached versions by consulting the store index. Uses registry/name encoding helpers and rejects path traversal sequences in package inputs.

pacquet/crates/cli/src/cli_args/cache.rs

dedupe.rsAdd 'pacquet dedupe' command backed by Install pipeline +59/-0

Add 'pacquet dedupe' command backed by Install pipeline

• Introduces 'DedupeArgs' with '--check' and runs the Install pipeline over prod/dev/optional groups to perform a full resolution pass. When '--check' is set, it enables 'lockfile_only' and 'dry_run' to resolve without writing, mirroring pnpm dedupe behavior.

pacquet/crates/cli/src/cli_args/dedupe.rs

lib.rsExport 'mirror' module for cross-crate cache tooling +1/-1

Export 'mirror' module for cross-crate cache tooling

• Makes the 'mirror' module public so the CLI crate can reuse cache layout constants and helper functions for encoding and metadata loading.

pacquet/crates/resolving-npm-resolver/src/lib.rs

Refactor (1) +3 / -0
mirror.rsAnnotate mirror helpers with '#[must_use]' +3/-0

Annotate mirror helpers with '#[must_use]'

• Adds '#[must_use]' to key mirror helper functions to prevent silently ignoring returned values (e.g., encoded names and loaded metadata).

pacquet/crates/resolving-npm-resolver/src/mirror.rs

Tests (1) +83 / -0
cache.rsAdd CLI tests for cache list-registries, list, and delete +83/-0

Add CLI tests for cache list-registries, list, and delete

• Adds integration tests that create a mock cache directory structure, then assert 'cache list-registries' output, 'cache list' output paths, and 'cache delete' side effects on the filesystem.

pacquet/crates/cli/tests/cache.rs

Other (1) +1 / -0
Cargo.tomlAdd 'wax' dependency for cache glob walking +1/-0

Add 'wax' dependency for cache glob walking

• Introduces the 'wax' workspace dependency to support glob-based discovery of cached metadata files used by the new cache subcommand.

pacquet/crates/cli/Cargo.toml

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

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (17) 📘 Rule violations (0) 📎 Requirement gaps (0) 📜 Skill insights (0)

Context used
✅ Tickets: 🎫 Rust Roadmap

Grey Divider


Action required

1. Rollback errors silently ignored 🐞 Bug ☼ Reliability
Description
LockfileGuard suppresses errors when restoring/removing pnpm-lock.yaml on drop, so `dedupe
--check` can leave the workspace with a modified lockfile if rollback fails (e.g., permission/disk
issues) without emitting any warning or error about the failed restore.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R118-130]

+impl Drop for LockfileGuard {
+    fn drop(&mut self) {
+        if self.disarmed {
+            return;
+        }
+        match self.existing.take() {
+            Some(ref old) => {
+                let _ = atomic_write(&self.lockfile_path, old.as_bytes());
+            }
+            None => {
+                let _ = std::fs::remove_file(&self.lockfile_path);
+            }
+        }
Evidence
The guard’s Drop implementation ignores failures from both the atomic rewrite and the delete path,
making rollback failure silent.

pacquet/crates/cli/src/cli_args/dedupe.rs[85-96]
pacquet/crates/cli/src/cli_args/dedupe.rs[118-130]

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

## Issue description
Rollback is implemented in `Drop` and intentionally discards errors (`let _ = ...`). If restoration fails, the command can return an error (or even success) while the lockfile remains modified, breaking the core guarantee of `--check` mode.
## Issue Context
`Drop` cannot propagate failures, so suppressing errors makes rollback failures invisible.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[118-130]
- pacquet/crates/cli/src/cli_args/dedupe.rs[85-96]
## Implementation directions
- Prefer explicit rollback on the failing path (before returning the `--check` error), so rollback errors can be returned (or at least logged prominently).
- Keep `Drop` only as a best-effort fallback, but log failures with `tracing::warn!` (or emit a reporter event) so operators see when cleanup didn’t happen.
- If rollback must remain in `Drop`, record the error somewhere observable (log/telemetry) instead of discarding it.

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


2. trustLockfile ignored 🐞 Bug ➹ Performance
Description
pacquet dedupe hard-codes trust_lockfile: false when constructing
pacquet_package_manager::Install, so it ignores config.trust_lockfile unlike pacquet install.
This can force expensive lockfile verification (extra registry I/O) and can make dedupe fail in
offline/air-gapped setups where installs succeed by skipping verification.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R40-45]

+            frozen_lockfile: false,
+            prefer_frozen_lockfile: Some(false),
+            ignore_manifest_check: false,
+            skip_runtimes: false,
+            trust_lockfile: false,
+            update_checksums: false,
Evidence
The dedupe path forces verifier construction/verification by passing trust_lockfile: false, while
Install explicitly skips building verifiers when trust_lockfile is true, and the install CLI
honors config.trust_lockfile when computing the effective value.

pacquet/crates/cli/src/cli_args/dedupe.rs[26-56]
pacquet/crates/package-manager/src/install.rs[817-856]
pacquet/crates/cli/src/cli_args/install.rs[435-440]

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

## Issue description
`pacquet dedupe` constructs `pacquet_package_manager::Install` with `trust_lockfile: false`, which bypasses the repo/user configuration (`Config.trust_lockfile`) and diverges from the `install` command’s resolved semantics.
### Issue Context
`Install` uses `trust_lockfile` to decide whether to build and run resolution verifiers (which can trigger per-entry registry verification work). The `install` CLI explicitly computes `trust_lockfile` as an OR of the config value and the CLI flag, but `dedupe` doesn’t.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[26-56]
- pacquet/crates/package-manager/src/install.rs[844-856]
- pacquet/crates/cli/src/cli_args/install.rs[435-440]
### Suggested change
Set `trust_lockfile` in `DedupeArgs::run` to `config.trust_lockfile` (or, if you later add a `--trust-lockfile` flag for `dedupe`, follow the same OR/precedence logic as `InstallArgs::run`).

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


3. --check no error rollback 🐞 Bug ☼ Reliability
Description
The --check rollback only happens after a successful Install::run; if the install fails after
starting a lockfile write, dedupe --check can exit early without restoring the previous lockfile.
Because the wanted lockfile writer uses fs::write (non-atomic truncate+write), an I/O failure can
leave pnpm-lock.yaml partially written/corrupted.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R26-90]

+        Install {
+            tarball_mem_cache: std::sync::Arc::clone(tarball_mem_cache),
+            http_client,
+            http_client_arc: std::sync::Arc::clone(http_client),
+            config,
+            manifest,
+            lockfile: pacquet_lockfile::MaybeLazyLockfile::Lazy(lockfile),
+            lockfile_path: Some(lockfile_path),
+            dependency_groups: [
+                DependencyGroup::Prod,
+                DependencyGroup::Dev,
+                DependencyGroup::Optional,
+            ]
+            .into_iter(),
+            frozen_lockfile: false,
+            prefer_frozen_lockfile: Some(false),
+            ignore_manifest_check: false,
+            skip_runtimes: false,
+            trust_lockfile: false,
+            update_checksums: false,
+            is_full_install: true,
+            resolved_packages,
+            supported_architectures: config.supported_architectures.clone(),
+            node_linker: config.node_linker,
+            lockfile_only: true,
+            dry_run: false,
+            update_seed_policy: pacquet_package_manager::UpdateSeedPolicy::DropAll,
+            auth_override: None,
+            resolution_observer: None,
+            catalogs_override: None,
+        }
+        .run::<Reporter>()
+        .await
+        .wrap_err("deduplicating dependencies")?;
+
+        if self.check {
+            let current = match std::fs::read_to_string(lockfile_path) {
+                Ok(content) => Some(content),
+                Err(e) if e.kind() == std::io::ErrorKind::NotFound => None,
+                Err(e) => {
+                    return Err(e).into_diagnostic().wrap_err("reading lockfile after dedupe");
+                }
+            };
+            if existing != current {
+                if let Some(old) = existing {
+                    let dir = lockfile_path.parent().unwrap_or_else(|| Path::new("."));
+                    let mut tmp = tempfile::NamedTempFile::new_in(dir)
+                        .into_diagnostic()
+                        .wrap_err("creating temp file for atomic lockfile restore")?;
+                    tmp.write_all(old.as_bytes())
+                        .into_diagnostic()
+                        .wrap_err("writing temp lockfile for rollback")?;
+                    tmp.as_file()
+                        .sync_all()
+                        .into_diagnostic()
+                        .wrap_err("syncing temp lockfile for rollback")?;
+                    tmp.persist(lockfile_path)
+                        .into_diagnostic()
+                        .wrap_err("restoring lockfile after check")?;
+                } else {
+                    std::fs::remove_file(lockfile_path)
+                        .into_diagnostic()
+                        .wrap_err("removing lockfile after check")?;
+                }
+                return Err(miette::miette!("Lockfile would be modified by deduplication"));
Evidence
dedupe --check performs its rollback comparison only after awaiting Install::run; on any error,
it returns immediately and never reaches the restore logic. Separately, the wanted lockfile writer
uses fs::write, which is a non-atomic overwrite that can leave partial content when errors occur
mid-write.

pacquet/crates/cli/src/cli_args/dedupe.rs[17-92]
pacquet/crates/lockfile/src/save_lockfile.rs[75-91]

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

## Issue description
`pacquet dedupe --check` restores the lockfile only after a successful install. If the install returns an error after modifying (or partially writing) `pnpm-lock.yaml`, the function returns early and does not restore the prior lockfile content.
## Issue Context
- The rollback code is inside `if self.check { ... }` and runs only after `Install { .. }.run().await` succeeds.
- The wanted lockfile save path uses `std::fs::write`, which is non-atomic and can leave a truncated/partial file on write errors.
## Fix Approach
- In `--check` mode, introduce a guard that always attempts restoration on **any** non-success exit (including `Install::run` returning `Err`).
- Example: create a scope guard that, by default, restores `existing` on drop, and is disarmed only when `existing == current` and the run is considered successful.
- Optionally (strongly preferred), rework `--check` to avoid writing the wanted lockfile at all by using a dry-run/"compute wanted lockfile" path and comparing in-memory.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[17-92]
- pacquet/crates/lockfile/src/save_lockfile.rs[75-91]

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


View more (12)
4. --check skips config hooks 🐞 Bug ≡ Correctness
Description
DedupePipeline::run skips run_update_config_hooks when --check is set, so `pacquet dedupe
--check can resolve with stale config-derived inputs (e.g. config.catalogs`) and incorrectly
report that the lockfile would not change. This undermines --check as a CI gate in repos using
.pnpmfile.cjs updateConfig hooks or plugin hooks to affect resolution.
Code

pacquet/crates/cli/src/cli_args.rs[R826-842]

+        if !args.check {
+            if let Some(pm) = package_manager_to_sync.as_ref() {
+                config_deps::sync_package_manager_dependencies(
+                    cfg,
+                    &config_root,
+                    &pm.specifier,
+                    &pm.version,
+                    false,
+                )
+                .await?;
+            }
+            config_deps::install_config_deps::<Reporter>(cfg, &config_root, false).await?;
+            config_deps::run_update_config_hooks::<Reporter>(cfg, &config_root).await?;
+        }
+        let cfg: &'static Config = cfg;
+        let state = State::init(manifest_path, cfg, false).wrap_err("initialize the state")?;
+        args.run::<Reporter>(state, existing, &lockfile_path).await
Evidence
The CLI explicitly skips config-deps installation and updateConfig hooks under --check, but
run_update_config_hooks is where hook-derived catalogs are adopted into Config::catalogs, and
the install pipeline prefers config.catalogs for resolution. The existing test shows a
updateConfig hook injecting catalogs that change the resolved version, demonstrating that skipping
these hooks can change lockfile output and therefore invalidate --check results.

pacquet/crates/cli/src/cli_args.rs[794-843]
pacquet/crates/cli/src/config_deps.rs[255-340]
pacquet/crates/package-manager/src/install.rs[578-590]
pacquet/crates/cli/tests/config_dependencies.rs[148-175]

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

## Issue description
`pacquet dedupe --check` currently skips `config_deps::run_update_config_hooks`, which can change resolution inputs (especially `config.catalogs`). As a result, `--check` may be a false negative: it can exit successfully even though a real `pacquet dedupe` (non-check) would produce a different lockfile.
### Issue Context
- `run_update_config_hooks` is not only for plugin pnpmfiles; it also loads the project pnpmfile (`.pnpmfile.cjs`) and writes its result into `Config::catalogs`.
- The install/resolution pipeline explicitly prefers `config.catalogs` over re-reading `pnpm-workspace.yaml`.
- There is an existing integration test demonstrating an `updateConfig` hook injecting catalogs that affect dependency resolution.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[794-843]
- pacquet/crates/cli/src/config_deps.rs[255-340]
### What to change
1. Make `dedupe --check` run `updateConfig` hooks so the config used for resolution matches real dedupe.
- At minimum, run the project pnpmfile hook even when skipping config-deps installation.
2. Adjust `run_update_config_hooks` behavior (if needed) so that, when config deps are not installed, it does not fail trying to load plugin pnpmfiles under `node_modules/.pnpm-config` (e.g., only include plugin pnpmfile paths that exist on disk).
3. Keep the “do not materialize `node_modules/.pnpm-config`” guarantee for `--check` (i.e., don’t install config deps in check mode), but still apply hook-derived config mutations used by resolution (catalogs, overrides, etc.).

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


5. Lockfile symlink overwrite 🐞 Bug ⛨ Security
Description
pacquet dedupe writes pnpm-lock.yaml through Lockfile::save_to_path, which ultimately uses
std::fs::write and will follow a symlink at pnpm-lock.yaml while truncating in-place. In an
attacker-controlled workspace where pnpm-lock.yaml is a symlink, running dedupe (including
--check) can overwrite an arbitrary file writable by the user/CI account.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R27-57]

+        Install {
+            tarball_mem_cache: std::sync::Arc::clone(tarball_mem_cache),
+            http_client,
+            http_client_arc: std::sync::Arc::clone(http_client),
+            config,
+            manifest,
+            lockfile: pacquet_lockfile::MaybeLazyLockfile::Lazy(lockfile),
+            lockfile_path: Some(lockfile_path),
+            dependency_groups: [
+                DependencyGroup::Prod,
+                DependencyGroup::Dev,
+                DependencyGroup::Optional,
+            ]
+            .into_iter(),
+            frozen_lockfile: false,
+            prefer_frozen_lockfile: Some(false),
+            ignore_manifest_check: false,
+            skip_runtimes: false,
+            trust_lockfile: false,
+            update_checksums: false,
+            is_full_install: true,
+            resolved_packages,
+            supported_architectures: config.supported_architectures.clone(),
+            node_linker: config.node_linker,
+            lockfile_only: true,
+            dry_run: false,
+            update_seed_policy: pacquet_package_manager::UpdateSeedPolicy::DropAll,
+            auth_override: None,
+            resolution_observer: None,
+            catalogs_override: None,
+        }
Evidence
The new dedupe command always runs the installer with a concrete lockfile_path and `dry_run:
false`, which causes the install pipeline to persist the wanted lockfile. The wanted-lockfile writer
in pacquet_lockfile uses fs::write, which is a symlink-following, non-atomic write primitive,
enabling arbitrary file overwrite if pnpm-lock.yaml is a symlink in an untrusted workspace.

pacquet/crates/cli/src/cli_args/dedupe.rs[24-57]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[1244-1274]
pacquet/crates/lockfile/src/save_lockfile.rs[75-91]

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

## Issue description
`pacquet dedupe` triggers a wanted-lockfile write to `pnpm-lock.yaml`. The underlying writer (`pacquet_lockfile::save_value_to_path`) uses `std::fs::write`, which follows symlinks and is non-atomic (create+truncate). In a malicious/untrusted repo, a committed `pnpm-lock.yaml` symlink can redirect this write to an arbitrary file path, causing unintended file overwrite.
## Issue Context
The new dedupe command constructs `pacquet_package_manager::Install` with `lockfile_path: Some(lockfile_path)` and `dry_run: false`, so the install pipeline persists the wanted lockfile to disk. The wanted-lockfile implementation currently uses `fs::write`.
## Fix Focus Areas
- pacquet/crates/lockfile/src/save_lockfile.rs[75-91]
- pacquet/crates/lockfile/src/save_lockfile.rs[142-200]
## Implementation notes
- Replace the `fs::write(path, output)` in `save_value_to_path` with an atomic temp-file + `rename` approach (reuse `write_atomic` already present in this module).
- Ensure the atomic write path still preserves the env-lockfile document prefix behavior.
- Consider explicitly failing when the target path is a symlink (or rely on atomic rename to replace the symlink itself) to avoid any symlink-following write/truncate behavior.

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


6. --check writes node_modules 🐞 Bug ≡ Correctness
Description
DedupePipeline::run always installs configDependencies and runs updateConfig hooks, which
installs/linkes packages under /node_modules/.pnpm-config, so pacquet dedupe --check can still
create/modify node_modules despite being intended as a non-materializing check mode.
Code

pacquet/crates/cli/src/cli_args.rs[R814-825]

+        if let Some(pm) = package_manager_to_sync.as_ref() {
+            config_deps::sync_package_manager_dependencies(
+                cfg,
+                &config_root,
+                &pm.specifier,
+                &pm.version,
+                false,
+            )
+            .await?;
+        }
+        config_deps::install_config_deps::<Reporter>(cfg, &config_root, false).await?;
+        config_deps::run_update_config_hooks::<Reporter>(cfg, &config_root).await?;
Evidence
The dedupe pipeline unconditionally runs config-dependency install + hook execution before dedupe,
and the config-deps subsystem explicitly installs into node_modules/.pnpm-config, so --check can
still create/modify node_modules even though the main install run is lockfile_only.

pacquet/crates/cli/src/cli_args.rs[783-829]
pacquet/crates/cli/src/config_deps.rs[36-52]
pacquet/crates/cli/src/config_deps.rs[255-266]
pacquet/crates/env-installer/src/lib.rs[3-8]

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

## Issue description
`pacquet dedupe --check` is expected to be non-materializing, but it currently runs config-dependency installation + `updateConfig` hooks against the real workspace root. Config dependencies are installed under `node_modules/.pnpm-config`, so `--check` can still create/modify `node_modules` and do extra FS work.
### Issue Context
This comes from the new `DedupePipeline` which mirrors install’s config-finalization steps. For `--check`, those steps should either be skipped or run in a sandbox so the workspace is not dirtied.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[799-828]
### Implementation direction (one of)
1) **Sandbox config deps for `--check`:** when `args.check` is true, run `sync_package_manager_dependencies` / `install_config_deps` / `run_update_config_hooks` against a temp directory (so the `.pnpm-config` links land outside the repo) while still snapshotting/restoring the real lockfile as needed.
2) **Make env-installer support dry-run/no-link:** extend the config-deps installer to avoid linking into `node_modules/.pnpm-config` in check mode (resolve only, or install into store only), and use that from `DedupePipeline`.
3) **Skip config-deps install in check mode** only if you can prove it doesn’t change resolution inputs for dedupe (often it will, so sandboxing is usually safer).

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


7. Symlink-following rollback write 🐞 Bug ⛨ Security
Description
DedupeArgs::run restores pnpm-lock.yaml using std::fs::write, which follows symlinks, so a
malicious workspace (or a race) can redirect the rollback into overwriting an arbitrary file outside
the repo. This bypasses the repo’s established lockfile/FS hardening that uses temp-file+rename
specifically to avoid symlink writes and torn files.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R79-88]

+            if existing != current {
+                if let Some(old) = existing {
+                    std::fs::write(&lockfile_path, &old)
+                        .into_diagnostic()
+                        .wrap_err("restoring lockfile after check")?;
+                } else {
+                    std::fs::remove_file(&lockfile_path)
+                        .into_diagnostic()
+                        .wrap_err("removing lockfile after check")?;
+                }
Evidence
The rollback path uses std::fs::write on the lockfile path, which follows symlinks. Elsewhere in
the repo, lockfile and other critical writes are explicitly implemented with temp-file + rename and
create_new(true) to avoid symlink-following writes, showing this is a known threat model that the
new code bypasses.

pacquet/crates/cli/src/cli_args/dedupe.rs[71-90]
pacquet/crates/lockfile/src/save_lockfile.rs[142-152]
pacquet/crates/fs/src/ensure_file.rs[254-266]

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

## Issue description
`pacquet dedupe --check` restores/removes `pnpm-lock.yaml` using `std::fs::write` / `std::fs::remove_file`. `std::fs::write` follows symlinks, so if `pnpm-lock.yaml` is (or becomes) a symlink, rollback can overwrite an arbitrary path outside the workspace. This contradicts the repo’s own lockfile/file-write hardening approach.
### Issue Context
The codebase already treats these paths as attacker-controlled and uses temp-file + atomic rename (opened with `create_new(true)`) to avoid following symlinks when writing lockfiles and other critical files.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[71-90]
### Suggested fix
- Replace the rollback `std::fs::write(&lockfile_path, ...)` with an atomic, symlink-safe write (e.g., a reusable helper modeled on `pacquet_lockfile::save_lockfile`’s `write_atomic` or `pacquet_fs::ensure_file`’s atomic rewrite path).
- Ensure the rollback path is safe even if `pnpm-lock.yaml` is swapped to a symlink between the pre/post reads and the restore step (avoid any API that follows the final path).
- Keep `remove_file` semantics for the “no prior lockfile” case, but ensure you aren’t leaving behind any attacker-directed writes as a result of following symlinks during restore.

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


8. Symlink rollback overwrite 🐞 Bug ⛨ Security
Description
In DedupeArgs::run, the --check rollback restores the lockfile using
std::fs::write(lockfile_path, old), which follows symlinks and is vulnerable to TOCTOU if
pnpm-lock.yaml is swapped to a symlink between the initial read and the rollback write. In an
untrusted repo/workspace, this enables arbitrary file overwrite with attacker-controlled contents
under the user/CI account running pacquet.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R79-88]

+            if existing != current {
+                if let Some(old) = existing {
+                    std::fs::write(&lockfile_path, &old)
+                        .into_diagnostic()
+                        .wrap_err("restoring lockfile after check")?;
+                } else {
+                    std::fs::remove_file(&lockfile_path)
+                        .into_diagnostic()
+                        .wrap_err("removing lockfile after check")?;
+                }
Evidence
The new --check rollback path uses std::fs::write directly on pnpm-lock.yaml, which follows
symlinks; the repo’s own guidance and filesystem helpers emphasize symlink-hardening and atomic
rename to prevent exactly this class of arbitrary write/TOCTOU issues.

pacquet/crates/cli/src/cli_args/dedupe.rs[71-90]
pacquet/crates/fs/src/ensure_file.rs[250-306]
pacquet/crates/fs/src/ensure_file.rs[355-430]
REVIEW_GUIDE.md[30-59]
REVIEW_GUIDE.md[90-97]

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

## Issue description
`pacquet dedupe --check` rolls back `pnpm-lock.yaml` by calling `std::fs::write(&lockfile_path, &old)`, which follows symlinks. If a repo-controlled process (or attacker with workspace write access) replaces `pnpm-lock.yaml` with a symlink after the snapshot read but before rollback, the rollback can overwrite an arbitrary file.
### Issue Context
This repository already contains hardened patterns for atomic writes and symlink-safety (temp-file + rename, create_new, and symlink scrubbing). The rollback should use the same approach so `--check` cannot be abused as an arbitrary file overwrite primitive.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[71-90]
- pacquet/crates/fs/src/ensure_file.rs[250-306]
- pacquet/crates/fs/src/ensure_file.rs[355-430]
### Suggested fix
- Replace rollback `std::fs::write/remove_file` with a symlink-safe atomic replacement:
- Write the snapshot bytes to a unique temp file in the same directory (opened with `create_new(true)`), then `rename` it over `pnpm-lock.yaml`.
- Optionally, before rollback, use `symlink_metadata` to reject non-regular targets (or ensure `rename` replaces a symlink rather than following it).
- Consider factoring a reusable helper (public) for “atomic write arbitrary file contents” so CLI code doesn’t reimplement this incorrectly.

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


9. --check misses env writes 🐞 Bug ≡ Correctness
Description
DedupePipeline::run installs/syncs config dependencies (which can persist the env-lockfile
document into pnpm-lock.yaml) before DedupeArgs::run snapshots the “existing” lockfile, so
pacquet dedupe --check can mutate pnpm-lock.yaml and still exit 0 without detecting/restoring
it.
Code

pacquet/crates/cli/src/cli_args.rs[R798-813]

+        if let Some(pm) = package_manager_to_sync.as_ref() {
+            config_deps::sync_package_manager_dependencies(
+                cfg,
+                &config_root,
+                &pm.specifier,
+                &pm.version,
+                false,
+            )
+            .await?;
+        }
+        config_deps::install_config_deps::<Reporter>(cfg, &config_root, false).await?;
+        config_deps::run_update_config_hooks::<Reporter>(cfg, &config_root).await?;
+        let cfg: &'static Config = cfg;
+        let state = State::init(manifest_path, cfg, false).wrap_err("initialize the state")?;
+        args.run::<Reporter>(state).await
+    }
Evidence
DedupePipeline runs config-deps install and hook finalization before dispatching to args.run,
while the --check baseline read happens inside DedupeArgs::run. Config-deps is
documented/implemented to write the env-lockfile document into pnpm-lock.yaml, so those writes
occur before the baseline snapshot and can slip past the check/restore logic.

pacquet/crates/cli/src/cli_args.rs[794-813]
pacquet/crates/cli/src/cli_args/dedupe.rs[19-35]
pacquet/crates/cli/src/config_deps.rs[1-10]
pacquet/crates/env-installer/src/resolve_and_install_config_deps.rs[108-124]
pacquet/crates/env-installer/src/verify_env_lockfile.rs[11-19]

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

## Issue description
`pacquet dedupe --check` snapshots `pnpm-lock.yaml` only inside `DedupeArgs::run`, but the CLI-level `DedupePipeline` performs config-dependency syncing/installation and `updateConfig` hooks *before* dispatching to `args.run`. Those config-deps steps can write the env-lockfile document into `pnpm-lock.yaml`, so `--check` may leave the lockfile modified while still succeeding.
### Issue Context
- `config_deps` is explicitly designed to write the env lockfile (first YAML document) into `pnpm-lock.yaml` during config-finalization.
- The `--check` guarantee should cover *all* lockfile mutations performed by the command, including pre-state config-deps.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[794-813]
- pacquet/crates/cli/src/cli_args/dedupe.rs[19-91]
- pacquet/crates/cli/src/config_deps.rs[1-10]
### Implementation direction
- Move the `--check` baseline capture + restore logic up into `DedupePipeline::run` so it wraps **everything** that can write the lockfile (config-deps + main install pipeline).
- E.g. if `args.check`:
- Read `pnpm-lock.yaml` bytes *before* `sync_package_manager_dependencies` / `install_config_deps`.
- Run the full pipeline.
- After completion (including error), compare/restore and return the appropriate failure if a change occurred.
- Use a guard (`Drop` impl) or `tokio::select`-safe `scopeguard` pattern to ensure restore happens even on early returns.

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


10. Dedupe arm breaks dispatch 🐞 Bug ≡ Correctness
Description
CliArgs::run builds command_future: CommandFuture from match command, but the new
CliCommand::Dedupe arm awaits the future inside the match and returns (), so the match no longer
returns a CommandFuture. This causes a type mismatch and the CLI will fail to compile.
Code

pacquet/crates/cli/src/cli_args.rs[R659-665]

+            CliCommand::Dedupe(args) => match reporter {
+                ReporterType::Default | ReporterType::AppendOnly => {
+                    Box::pin(args.run::<DefaultReporter>(state(false)?)).await?;
+                }
+                ReporterType::Ndjson => Box::pin(args.run::<NdjsonReporter>(state(false)?)).await?,
+                ReporterType::Silent => Box::pin(args.run::<SilentReporter>(state(false)?)).await?,
+            },
Evidence
The dispatch is explicitly typed as CommandFuture and other arms return Box::pin(...) futures;
the new dedupe arm awaits and returns unit, which cannot satisfy the required CommandFuture return
type for the match expression.

pacquet/crates/cli/src/cli_args.rs[349-377]
pacquet/crates/cli/src/cli_args.rs[651-665]

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

## Issue description
`CliArgs::run` assigns `let command_future: CommandFuture<'_> = match command { ... }`, so every match arm must evaluate to a `CommandFuture` (typically `Box::pin(...)`). The `CliCommand::Dedupe` arm currently *awaits* the dedupe future inside the match and therefore returns `()` instead of a boxed future, breaking compilation.
### Issue Context
Other commands (e.g. `Add`, `Update`, `Runtime`) return `Box::pin(args.run::<...>(state))` without awaiting in the dispatch match, keeping the type uniform.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[659-665]
### Suggested fix
Rewrite the `CliCommand::Dedupe` arm to return a `CommandFuture` like other arms, e.g.:
- compute `let command_state = state(false)?;` once, then
- `match reporter { ... => Box::pin(args.run::<ReporterType>(command_state)) ... }`
(Alternatively, wrap the reporter match in `Box::pin(async move { ...; Ok(()) })`, but do not `.await` directly in the `match command` expression.)

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


11. Wrong workspace lockfile path 🐞 Bug ≡ Correctness
Description
DedupeArgs::run derives lockfile_path and uses State.lockfile from the current package
directory, but Install treats the lockfile as workspace-root state; in a workspace invoked from a
subdirectory this will load/seed from the wrong pnpm-lock.yaml (or treat it as missing) and
trigger unnecessary full resolution and incorrect dedupe output.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R19-31]

+        let lockfile_path = manifest
+            .path()
+            .parent()
+            .map(|parent| parent.join(pacquet_lockfile::Lockfile::FILE_NAME));
+
+        Install {
+            tarball_mem_cache: std::sync::Arc::clone(tarball_mem_cache),
+            http_client,
+            http_client_arc: std::sync::Arc::clone(http_client),
+            config,
+            manifest,
+            lockfile: pacquet_lockfile::MaybeLazyLockfile::Lazy(lockfile),
+            lockfile_path: lockfile_path.as_deref(),
Evidence
The dedupe command’s lockfile inputs are derived from the manifest directory, but State::init and
LazyLockfile will only ever load /pnpm-lock.yaml, while Install explicitly treats the lockfile
directory as the workspace root and then forces lockfile.get() after its fast-path checks. This
mismatch makes dedupe behave incorrectly in workspaces invoked from subdirectories and can force
extra full-resolution work.

pacquet/crates/cli/src/cli_args/dedupe.rs[15-32]
pacquet/crates/cli/src/cli_args.rs[291-335]
pacquet/crates/cli/src/cli_args.rs[535-544]
pacquet/crates/cli/src/state.rs[59-73]
pacquet/crates/lockfile/src/lazy_lockfile.rs[19-58]
pacquet/crates/package-manager/src/install.rs[551-566]
pacquet/crates/package-manager/src/install.rs[696-699]

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

## Issue description
`pacquet dedupe` currently computes `lockfile_path` from `manifest.path().parent()` and passes `State.lockfile` (which is deferred from the CLI `--dir` manifest directory). In a workspace, `Install` uses workspace-root semantics (lockfileDir = workspace root), so running `dedupe` from a workspace subdirectory will read/seed from the wrong lockfile (or no lockfile), causing incorrect resolution inputs and unnecessary work.
## Issue Context
- `State::init` defers lockfile loading from `manifest_path.parent()`.
- `LazyLockfile` only loads `<dir>/pnpm-lock.yaml` (no workspace-root search).
- `Install::run_inner` treats the lockfile as workspace-root state and loads it via `lockfile.get()`.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[15-54]
### Suggested approach
1. Compute the workspace root for lockfile purposes (prefer `config.workspace_dir.clone()` when present; fallback to `manifest.path().parent()`), and build `lockfile_path` from that root.
2. Do **not** reuse `state.lockfile` for dedupe; instead create a local `pacquet_lockfile::LazyLockfile::deferred(workspace_root.clone())` and pass `MaybeLazyLockfile::Lazy(&local_lazy_lockfile)` into `Install`.
3. Pass `lockfile_path: Some(workspace_root.join(Lockfile::FILE_NAME).as_path())` (or keep `None` if you intentionally want to disable verification caching, but do it deliberately rather than pointing at the wrong file).

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


12. Dedupe preserves lockfile pins 🐞 Bug ≡ Correctness
Description
DedupeArgs::run sets update_seed_policy to KeepAll, which seeds the resolver with *all*
existing lockfile pins. The fresh-resolve path is explicitly designed to bias toward these seeds so
pins that still satisfy their ranges survive re-resolution, which prevents dedupe from collapsing
duplicates that require changing versions within allowed ranges.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R44-50]

+            is_full_install: true,
+            resolved_packages,
+            supported_architectures: config.supported_architectures.clone(),
+            node_linker: config.node_linker,
+            lockfile_only: self.check,
+            dry_run: self.check,
+            update_seed_policy: pacquet_package_manager::UpdateSeedPolicy::KeepAll,
Evidence
The dedupe command hard-codes UpdateSeedPolicy::KeepAll. The resolver’s fresh-lockfile path uses
update_seed_policy to decide whether to seed preferred versions from the existing lockfile
snapshots, and the comments explicitly state this bias keeps prior pins when they still satisfy
ranges—exactly the opposite of what a dedupe run needs when collapsing duplicates requires version
movement within semver ranges.

pacquet/crates/cli/src/cli_args/dedupe.rs[24-54]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[188-214]
pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[918-970]

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

## Issue description
`pacquet dedupe` currently runs `Install` with `update_seed_policy: UpdateSeedPolicy::KeepAll`, which is documented/implemented to preserve existing lockfile pins during fresh resolution. That undermines dedupe’s purpose when collapsing duplicates requires upgrading one side to a different (still-in-range) version.
### Issue Context
`UpdateSeedPolicy::KeepAll` is intended for `install/add` stability (keep pinned resolutions), while `DropAll` exists specifically to force highest-in-range re-resolution.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[44-51]
- pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[188-214]
- pacquet/crates/package-manager/src/install_with_fresh_lockfile.rs[918-970]
### Suggested change
In `DedupeArgs::run`, set:
- `update_seed_policy: pacquet_package_manager::UpdateSeedPolicy::DropAll`
This ensures the preferred-version seeding does not preserve duplicate pins and allows the resolver to converge on fewer versions when ranges permit.

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


13. Check writes lockfile 🐞 Bug ≡ Correctness
Description
DedupeArgs::run sets both lockfile_only and dry_run when --check is passed, but the install
pipeline’s lockfile-only frozen fast-path writes pnpm-lock.yaml and returns without honoring
dry_run. Because prefer_frozen_lockfile defaults to true, pacquet dedupe --check can
unexpectedly modify the lockfile in common cases where a lockfile is already present and fresh.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R48-49]

+            lockfile_only: self.check,
+            dry_run: self.check,
Evidence
The PR wires --check to both lockfile_only and dry_run, and the installer has an early-return
branch that writes pnpm-lock.yaml when lockfile_only is set on the frozen path, without
considering dry_run. Since prefer_frozen_lockfile defaults to true, the frozen path is commonly
selected when the lockfile is present and fresh, making the unintended write path realistic.

pacquet/crates/cli/src/cli_args/dedupe.rs[24-54]
pacquet/crates/package-manager/src/install.rs[984-1025]
pacquet/crates/config/src/lib.rs[564-569]

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

## Issue description
`pacquet dedupe --check` is intended to be non-mutating, but it currently sets both `lockfile_only=true` and `dry_run=true`. In the shared installer, the `lockfile_only && take_frozen_path` early return persists `pnpm-lock.yaml` without checking `dry_run`, so `--check` can still write to disk.
### Issue Context
- `prefer_frozen_lockfile` defaults to `true`, making the frozen path likely when an existing lockfile is fresh.
- The lockfile-only frozen path explicitly saves `pnpm-lock.yaml`.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[44-54]
- pacquet/crates/package-manager/src/install.rs[984-1025]
### Suggested fix
Pick one (or do both for robustness):
1) In `DedupeArgs::run`, when `check` is true, set **only** `dry_run: true` and leave `lockfile_only: false` (since `dry_run` already implies no materialization), avoiding the lockfile-only early return.
2) In `Install::run` (package-manager), ensure `dry_run` suppresses all writes even if `lockfile_only` is also true (e.g., guard the `lockfile_only && take_frozen_path` branch with `&& !dry_run`).

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


14. Dedupe skips config-finalization 🐞 Bug ≡ Correctness
Description
pacquet dedupe initializes State and runs Install without first installing
configDependencies and running updateConfig pnpmfile hooks, unlike pacquet install. As a
result, dedupe can resolve using stale config-derived inputs (notably config.catalogs produced by
updateConfig hooks) and write a lockfile that diverges from the install pipeline’s intended
config-finalized behavior.
Code

pacquet/crates/cli/src/cli_args.rs[R520-526]

+            CliCommand::Dedupe(args) => match reporter {
+                ReporterType::Default | ReporterType::AppendOnly => {
+                    Box::pin(args.run::<DefaultReporter>(state(false)?)).await?;
+                }
+                ReporterType::Ndjson => Box::pin(args.run::<NdjsonReporter>(state(false)?)).await?,
+                ReporterType::Silent => Box::pin(args.run::<SilentReporter>(state(false)?)).await?,
+            },
Evidence
install explicitly performs config-dependency installation + updateConfig hooks before
initializing State, and updateConfig hooks can write Config::catalogs, which the installer
prefers for resolution. The new dedupe dispatch bypasses this prelude entirely by directly
constructing State and running Install.

pacquet/crates/cli/src/cli_args.rs[520-526]
pacquet/crates/cli/src/cli_args.rs[561-588]
pacquet/crates/cli/src/config_deps.rs[1-10]
pacquet/crates/cli/src/config_deps.rs[240-254]
pacquet/crates/package-manager/src/install.rs[557-566]

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

## Issue description
`pacquet dedupe` is dispatched via `state(false)?` and then calls the package-manager `Install` pipeline, but it never runs the config-finalization steps that `pacquet install` runs first (install `configDependencies`, then execute `updateConfig` hooks). This means dedupe can operate with a different effective configuration than install.
## Issue Context
- The CLI’s install path has a dedicated `InstallPipeline` that runs config-dep install and `updateConfig` hooks before `State::init`.
- `updateConfig` hooks can populate `Config::catalogs`, and the installer prefers `config.catalogs` over reading catalogs from disk.
## Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[520-526]
- pacquet/crates/cli/src/cli_args/dedupe.rs[15-54]
## Suggested fix approach
- Mirror `InstallPipeline` for dedupe:
- Load `cfg = config()?` (mutable).
- Compute `config_root` the same way `install` does (`cfg.workspace_dir.clone().unwrap_or_else(|| dir.clone())`).
- Run `config_deps::install_config_deps::<Reporter>(cfg, &config_root, /*frozen_lockfile*/ false).await?`.
- Run `config_deps::run_update_config_hooks::<Reporter>(cfg, &config_root).await?`.
- Convert to `&'static Config` and then call `State::init(...)` *after* hooks so any hook-mutated network/catalog settings are reflected.
- Finally call into the dedupe install execution (either keep `DedupeArgs::run(State)` or refactor dedupe to accept `&Config`/`manifest_path` similarly to `InstallArgs`).

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


15. --check never fails 🐞 Bug ≡ Correctness
Description
pacquet dedupe --check is implemented by setting dry_run=true, but the install pipeline is
explicitly documented/implemented to exit successfully even when changes are detected, so CI cannot
rely on --check to enforce a deduped lockfile. This diverges from pnpm’s dedupe --check
contract, which requires a non-zero exit when changes are possible.
Code

pacquet/crates/cli/src/cli_args/dedupe.rs[R48-49]

+            lockfile_only: self.check,
+            dry_run: self.check,
Evidence
The PR wires --check to dry_run, and the install pipeline explicitly guarantees dry_run exits
0 even when changes are found; pnpm’s own help text defines --check as non-zero on potential
changes.

pacquet/crates/cli/src/cli_args/dedupe.rs[44-54]
pacquet/crates/package-manager/src/install.rs[211-217]
pacquet/crates/package-manager/src/install.rs[1438-1455]
pnpm11/installing/commands/src/dedupe.ts[28-39]

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

## Issue description
`pacquet dedupe --check` currently sets `dry_run`/`lockfile_only` and then relies on `Install::run`, but `dry_run` is designed to print a report and return `Ok(())` regardless of whether the lockfile would change. This makes `--check` ineffective for CI gating.
### Issue Context
- `dry_run` is explicitly “npm-style preview semantics” (always exit 0), while pnpm’s `dedupe --check` must exit non-zero when changes are possible.
- There is already a lockfile diff implementation (`pacquet_package_manager::dry_run::diff_lockfiles`) that can be reused to decide whether changes would occur.
### Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[14-59]
### Suggested fix approach
- Implement a real check mode that:
1. Computes the would-be deduped wanted lockfile without writing it.
2. Diffs it against the existing lockfile.
3. Returns an error (so the process exits non-zero) when the diff is non-empty.
Concretely, either:
- Refactor `pacquet_package_manager::Install` to return the computed wanted lockfile (or diff) in `dry_run` mode instead of only printing it, **or**
- Bypass `Install` for `--check` and run `InstallWithFreshLockfile` directly to get `InstallWithFreshLockfileResult::wanted_lockfile`, then call `dry_run::diff_lockfiles(existing, new)` and error if not empty.
Ensure `--check` still writes nothing to disk.

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



<img src="https://img.shiel...

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

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

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

@kairosci
kairosci force-pushed the feat/pacquet-dedupe branch from 9a9565b to 4531b4b Compare June 22, 2026 15:18

@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.

Actionable comments posted: 4

🤖 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.

Inline comments:
In `@pacquet/crates/cli/src/cli_args.rs`:
- Around line 490-496: The new CliCommand::Dedupe reporter dispatch logic (which
routes through DefaultReporter, NdjsonReporter, and SilentReporter) lacks
end-to-end test coverage for the dedupe command execution path. Add dedicated
regression tests that exercise the pacquet dedupe and pacquet dedupe --check
commands with different reporter types to ensure parity in dispatch behavior,
output formatting, and lockfile write operations remain consistent across
changes.

In `@pacquet/crates/cli/src/cli_args/cache.rs`:
- Around line 54-58: Remove the `.." rejection check to align with pnpm's
behavior and support valid npm package names. Delete the entire if statement
block that checks `pkg.contains("..")` and returns the miette error (the
reject_path_traversal validation), as the security boundary is already enforced
by the glob pattern and strip_prefix validation that follows. This will allow
package names like "foo..bar" to be processed normally, matching pnpm's approach
of passing filter arguments directly without pre-validation.
- Around line 196-209: The cachedAt field in the meta_files_by_path insertion is
using milliseconds since UNIX_EPOCH as a string format, but pnpm expects
JavaScript Date.toString() format (like "Mon Jan 01 2024 12:00:00 GMT+0000").
Update the mtime mapping to convert the SystemTime to the appropriate JavaScript
date string format instead of milliseconds. Additionally, the registry_name
replacement should use replaceAll instead of replace to handle registry names
with multiple plus characters correctly, ensuring all occurrences of '+' are
replaced with ':' not just the first one. Finally, add test cases for the cache
view command to verify the output JSON schema matches pnpm's expected format.

In `@pacquet/crates/cli/src/cli_args/dedupe.rs`:
- Around line 48-49: In the dedupe command configuration, fix the incorrect flag
assignments for lockfile_only and dry_run. The issue is that both fields are
currently tied to the self.check flag, but they should behave independently.
Change lockfile_only to always be true (since dedupe must always operate on the
lockfile only without installing packages) and change dry_run to self.check (so
changes are only written when not in check mode). This ensures dedupe always
performs lockfile-focused operations while the check flag controls whether
modifications are actually persisted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 83c560c6-b6d1-42dd-b068-0ce003bd7642

📥 Commits

Reviewing files that changed from the base of the PR and between 85d9e77 and 9a9565b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (7)
  • pacquet/crates/cli/Cargo.toml
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/cache.rs
  • pacquet/crates/cli/src/cli_args/dedupe.rs
  • pacquet/crates/cli/tests/cache.rs
  • pacquet/crates/resolving-npm-resolver/src/lib.rs
  • pacquet/crates/resolving-npm-resolver/src/mirror.rs

@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.

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 4

🤖 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.

Inline comments:
In `@pacquet/crates/cli/src/cli_args.rs`:
- Around line 490-496: The new CliCommand::Dedupe reporter dispatch logic (which
routes through DefaultReporter, NdjsonReporter, and SilentReporter) lacks
end-to-end test coverage for the dedupe command execution path. Add dedicated
regression tests that exercise the pacquet dedupe and pacquet dedupe --check
commands with different reporter types to ensure parity in dispatch behavior,
output formatting, and lockfile write operations remain consistent across
changes.

In `@pacquet/crates/cli/src/cli_args/cache.rs`:
- Around line 54-58: Remove the `.." rejection check to align with pnpm's
behavior and support valid npm package names. Delete the entire if statement
block that checks `pkg.contains("..")` and returns the miette error (the
reject_path_traversal validation), as the security boundary is already enforced
by the glob pattern and strip_prefix validation that follows. This will allow
package names like "foo..bar" to be processed normally, matching pnpm's approach
of passing filter arguments directly without pre-validation.
- Around line 196-209: The cachedAt field in the meta_files_by_path insertion is
using milliseconds since UNIX_EPOCH as a string format, but pnpm expects
JavaScript Date.toString() format (like "Mon Jan 01 2024 12:00:00 GMT+0000").
Update the mtime mapping to convert the SystemTime to the appropriate JavaScript
date string format instead of milliseconds. Additionally, the registry_name
replacement should use replaceAll instead of replace to handle registry names
with multiple plus characters correctly, ensuring all occurrences of '+' are
replaced with ':' not just the first one. Finally, add test cases for the cache
view command to verify the output JSON schema matches pnpm's expected format.

In `@pacquet/crates/cli/src/cli_args/dedupe.rs`:
- Around line 48-49: In the dedupe command configuration, fix the incorrect flag
assignments for lockfile_only and dry_run. The issue is that both fields are
currently tied to the self.check flag, but they should behave independently.
Change lockfile_only to always be true (since dedupe must always operate on the
lockfile only without installing packages) and change dry_run to self.check (so
changes are only written when not in check mode). This ensures dedupe always
performs lockfile-focused operations while the check flag controls whether
modifications are actually persisted.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 83c560c6-b6d1-42dd-b068-0ce003bd7642

📥 Commits

Reviewing files that changed from the base of the PR and between 85d9e77 and 9a9565b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (7)
  • pacquet/crates/cli/Cargo.toml
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/cache.rs
  • pacquet/crates/cli/src/cli_args/dedupe.rs
  • pacquet/crates/cli/tests/cache.rs
  • pacquet/crates/resolving-npm-resolver/src/lib.rs
  • pacquet/crates/resolving-npm-resolver/src/mirror.rs
🛑 Comments failed to post (4)
pacquet/crates/cli/src/cli_args.rs (1)

490-496: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add a dedicated dedupe command regression test.

Line 490 introduces a new reporter-dispatched dedupe execution path, but this PR context provides no test that exercises pacquet dedupe/pacquet dedupe --check behavior end-to-end. That leaves parity regressions (dispatch/output/lockfile write behavior) unguarded.

Based on learnings, REVIEW_GUIDE.md requires meaningful regression coverage for dedupe/check behavior at the command level, and pacquet/AGENTS.md requires parity-focused command testing.

🤖 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/cli/src/cli_args.rs` around lines 490 - 496, The new
CliCommand::Dedupe reporter dispatch logic (which routes through
DefaultReporter, NdjsonReporter, and SilentReporter) lacks end-to-end test
coverage for the dedupe command execution path. Add dedicated regression tests
that exercise the pacquet dedupe and pacquet dedupe --check commands with
different reporter types to ensure parity in dispatch behavior, output
formatting, and lockfile write operations remain consistent across changes.

Source: Coding guidelines

pacquet/crates/cli/src/cli_args/cache.rs (2)

54-58: ⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check pnpm's cache command for path traversal validation
rg -n -C5 '\.\.' pnpm11/cache/src --type=ts

# Find cache delete/list implementations
ast-grep --pattern $'function deleteCache($$$) {
  $$$
}'

# Check how pnpm encodes package names in cache paths
rg -n 'encode.*package|package.*encode' pnpm11/cache/src --type=ts

Repository: pnpm/pnpm

Length of output: 167


🏁 Script executed:

#!/bin/bash
# Find cache-related files in the repository
find . -type f -name "*cache*" | head -20
ls -la pnpm/ | head -20

Repository: pnpm/pnpm

Length of output: 907


🏁 Script executed:

#!/bin/bash
# Search for cache implementation in the correct locations
git ls-files | grep -i cache | grep -E '(\.ts|\.js)$' | head -30

Repository: pnpm/pnpm

Length of output: 1216


🏁 Script executed:

#!/bin/bash
# Look for where cache/delete operations are implemented
rg -l 'export.*cache|cache.*command|deleteCache' --type=ts --type=js | head -20

Repository: pnpm/pnpm

Length of output: 757


🌐 Web query:

npm package naming rules - are package names allowed to contain ".." (double dot)?

💡 Result:

Yes, npm package names are allowed to contain a double dot (".."). According to npm naming conventions, package names must be URL-safe [1][2], must not contain spaces [2], and must not contain certain non-URL-safe characters such as ~)('!* [2]. While the official documentation and the validate-npm-package-name library prohibit names that start with a dot (for unscoped packages) [2][3], they do not explicitly forbid the use of ".." (double dot) within the name string itself. The primary constraints on package names are as follows: - They must be 214 characters or fewer [1][4]. - They must not contain uppercase letters [1][2]. - They cannot contain spaces [2]. - They cannot contain specific non-URL-safe characters: ~)('!* [2]. - They should not start with a dot or underscore (unless scoped) [2][3]. As long as the name complies with these general rules, including URL-safety and the absence of forbidden characters, ".." is permitted within the package name.

Citations:


🏁 Script executed:

#!/bin/bash
# Read pnpm's cache delete implementation to check for path traversal validation
cat pnpm11/cache/api/src/cacheDelete.ts

Repository: pnpm/pnpm

Length of output: 472


🏁 Script executed:

#!/bin/bash
# Read pnpm's cache view implementation to check output format
cat pnpm11/cache/api/src/cacheView.ts

Repository: pnpm/pnpm

Length of output: 2493


🏁 Script executed:

#!/bin/bash
# Read the pacquet cache.rs file to compare
head -100 pacquet/crates/cli/src/cli_args/cache.rs

Repository: pnpm/pnpm

Length of output: 3722


🏁 Script executed:

#!/bin/bash
# Check if pacquet cache tests verify the ".." behavior
cat pacquet/crates/cli/tests/cache.rs

Repository: pnpm/pnpm

Length of output: 4358


Remove the .. rejection as it diverges from pnpm and breaks valid npm package names.

The code at lines 54–58 rejects any package name containing .., but:

  1. pnpm has no equivalent check — it passes filter arguments directly to glob without pre-validation (see pnpm11/cache/api/src/cacheDelete.ts).
  2. ".." is valid in npm package names per npm naming rules; the rejection would break legitimate packages like "foo..bar" if they exist.
  3. Per the cardinal rule, pacquet must match pnpm's behavior exactly; this check diverges unnecessarily.
  4. The actual security boundary is elsewhere — the glob pattern {registry_prefix}/{pkg}.jsonl combined with glob.walk(cache_dir) and strip_prefix(cache_dir) already confines file access to the cache directory; even with .. in a name, the relative path cannot escape.

Remove the reject_path_traversal check and its call site (lines 47–58, 56–57), matching pnpm's approach. The glob walking and strip_prefix validation are sufficient.

🤖 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/cli/src/cli_args/cache.rs` around lines 54 - 58, Remove the
`.." rejection check to align with pnpm's behavior and support valid npm package
names. Delete the entire if statement block that checks `pkg.contains("..")` and
returns the miette error (the reject_path_traversal validation), as the security
boundary is already enforced by the glob pattern and strip_prefix validation
that follows. This will allow package names like "foo..bar" to be processed
normally, matching pnpm's approach of passing filter arguments directly without
pre-validation.

Source: Coding guidelines


196-209: ⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find pnpm's cache view implementation and output format
rg -n -C10 'cachedVersions|nonCachedVersions|cachedAt' pnpm11/cache/src --type=ts

# Check registry name encoding in pnpm cache output
rg -n 'registry.*replace|host.*port' pnpm11/cache/src --type=ts

# Find the cache view handler
ast-grep --pattern $'function.*view.*cache($$$) {
  $$$
}'

Repository: pnpm/pnpm

Length of output: 167


🏁 Script executed:

#!/bin/bash
# List top-level directories to understand repo structure
git ls-files | head -30 | cut -d/ -f1 | sort -u

# Search for cache-related files in the repo
fd -t f "cache" | grep -E "\.(ts|js|rs)$" | head -20

# Look for "cachedVersions" string in the repo
rg -l "cachedVersions" --type=ts --type=js | head -10

Repository: pnpm/pnpm

Length of output: 1244


🏁 Script executed:

#!/bin/bash
# Read pnpm's cacheView implementation
cat pnpm11/cache/api/src/cacheView.ts

# Also check the test file for expected output
cat pnpm11/cache/commands/test/cacheView.cmd.test.ts

Repository: pnpm/pnpm

Length of output: 5646


🏁 Script executed:

#!/bin/bash
# Check pacquet's cache test to see expected output
cat pacquet/crates/cli/tests/cache.rs

# Look at more context in pacquet's cache.rs
cat pacquet/crates/cli/src/cli_args/cache.rs

Repository: pnpm/pnpm

Length of output: 14906


🏁 Script executed:

#!/bin/bash
# Look at pnpm test expectations for cachedAt format
rg -A20 "cachedAt" pnpm11/cache/commands/test/cacheView.cmd.test.ts

# Check if pacquet has tests that verify cachedAt format
rg -n "cachedAt\|toMatchObject" pacquet/crates/cli/tests/cache.rs -A5 -B5

# Look for any snapshot tests or other view tests in pacquet
fd cache pacquet/crates/cli/tests --type f -exec grep -l "view\|View" {} \;

Repository: pnpm/pnpm

Length of output: 258


🏁 Script executed:

#!/bin/bash
# Look at pnpm test expectations for cachedAt format
rg -A20 "cachedAt" pnpm11/cache/commands/test/cacheView.cmd.test.ts

# Check if pacquet has tests that verify cachedAt format
rg -n "cachedAt" pacquet/crates/cli/tests/cache.rs

# Look for any snapshot tests or other view tests in pacquet
find pacquet/crates/cli/tests -type f -name "*.rs" | xargs grep -l "view\|View"

Repository: pnpm/pnpm

Length of output: 88


🏁 Script executed:

#!/bin/bash
# Check pnpm test for cachedAt expectations
grep -A5 -B5 "cachedAt\|toMatchObject" pnpm11/cache/commands/test/cacheView.cmd.test.ts

# Search for cache view tests in pacquet
find pacquet -name "*cache*" -type f | grep test

# Check if there's a side effects cache test
cat pacquet/crates/cli/tests/side_effects_cache.rs

Repository: pnpm/pnpm

Length of output: 4608


The cachedAt field format does not match pnpm's output schema.

pnpm's cache view outputs cachedAt as a JavaScript Date.toString() value (e.g., "Mon Jan 01 2024 12:00:00 GMT+0000"), but pacquet uses RFC3339 format (e.g., "2024-01-01T12:00:00.000Z"). These formats are incompatible and will break consumers expecting pnpm-compatible JSON output.

Additionally:

  • Registry names use .replace('+', ':') which only replaces the first occurrence; pnpm uses .replaceAll('+', ':') to handle registry names with multiple + characters.
  • No test exists for the cache view command to verify the output schema matches pnpm.
🤖 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/cli/src/cli_args/cache.rs` around lines 196 - 209, The
cachedAt field in the meta_files_by_path insertion is using milliseconds since
UNIX_EPOCH as a string format, but pnpm expects JavaScript Date.toString()
format (like "Mon Jan 01 2024 12:00:00 GMT+0000"). Update the mtime mapping to
convert the SystemTime to the appropriate JavaScript date string format instead
of milliseconds. Additionally, the registry_name replacement should use
replaceAll instead of replace to handle registry names with multiple plus
characters correctly, ensuring all occurrences of '+' are replaced with ':' not
just the first one. Finally, add test cases for the cache view command to verify
the output JSON schema matches pnpm's expected format.

Source: Coding guidelines

pacquet/crates/cli/src/cli_args/dedupe.rs (1)

48-49: ⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify pnpm's dedupe command behavior for lockfile_only flag

# Search for the dedupe command implementation in pnpm
rg -n -C5 'lockfileOnly.*dedupe|dedupe.*lockfileOnly' --type=ts

# Find the dedupe command entry point
ast-grep --pattern $'export function dedupe($$$) {
  $$$
}'

# Search for Install configuration in dedupe command
rg -n -C10 'function dedupe|export.*dedupe' pnpm11/installing/commands/src/dedupe.ts

Repository: pnpm/pnpm

Length of output: 636


🏁 Script executed:

#!/bin/bash
# Read the pacquet dedupe.rs file to see the full context
cat -n pacquet/crates/cli/src/cli_args/dedupe.rs

Repository: pnpm/pnpm

Length of output: 2460


🏁 Script executed:

#!/bin/bash
# Search for dedupe command handler in pnpm to understand lockfile_only behavior
rg -n -A20 "export async function handler.*dedupe|export const handler.*=.*async" --type=ts | grep -A20 "dedupe"

Repository: pnpm/pnpm

Length of output: 35


🏁 Script executed:

#!/bin/bash
# Look for how Install configuration is used in pnpm dedupe and related commands
rg -n "lockfileOnly" --type=ts -B3 -A3 | head -100

Repository: pnpm/pnpm

Length of output: 8422


🏁 Script executed:

#!/bin/bash
# Search for pnpm dedupe command handler
find . -name "*.ts" -type f | xargs grep -l "export.*handler.*dedupe\|export.*dedupe" | grep -E "(command|handler)" | head -5

Repository: pnpm/pnpm

Length of output: 138


🏁 Script executed:

#!/bin/bash
# Search for dedupe.ts files in pnpm
fd dedupe -e ts --type f

Repository: pnpm/pnpm

Length of output: 715


🏁 Script executed:

#!/bin/bash
# Look at the dedupe command implementation in pnpm/installing/commands
cat -n pnpm11/installing/commands/src/dedupe.ts 2>/dev/null || echo "File not found, searching nearby..."

Repository: pnpm/pnpm

Length of output: 3062


🏁 Script executed:

#!/bin/bash
# Find dedupe command in pnpm
rg -l "dedupe" --type=ts | grep -i command | head -10

Repository: pnpm/pnpm

Length of output: 537


🏁 Script executed:

#!/bin/bash
# Search for how lockfile_only is used in pacquet Install
rg -n "lockfile_only" pacquet --type=rs -B2 -A2 | head -80

Repository: pnpm/pnpm

Length of output: 80


🏁 Script executed:

#!/bin/bash
# Search for Install struct definition to understand what lockfile_only does
rg -n "struct Install" pacquet --type=rs -A30 | head -100

Repository: pnpm/pnpm

Length of output: 80


🏁 Script executed:

#!/bin/bash
# Check if pacquet has a lockfileCheck equivalent or how --check is supposed to work
rg -n "check|Check" pacquet/crates/cli/src/cli_args/dedupe.rs --type=rs

Repository: pnpm/pnpm

Length of output: 80


🏁 Script executed:

#!/bin/bash
# Search for lockfile_only usage in the pacquet codebase
rg -n "lockfile_only" --type=rust -B2 -A2 | head -80

Repository: pnpm/pnpm

Length of output: 5543


🏁 Script executed:

#!/bin/bash
# Find and read the Install struct definition in pacquet
fd "lib.rs\|install.rs" pacquet | head -5 | xargs grep -l "struct Install" 2>/dev/null

Repository: pnpm/pnpm

Length of output: 37


🏁 Script executed:

#!/bin/bash
# Search for Install struct definition more broadly
rg "struct Install" -B2 -A30 | head -150

Repository: pnpm/pnpm

Length of output: 16302


🏁 Script executed:

#!/bin/bash
# Check what dry_run and lockfile_only do by searching their usage in pacquet
rg "dry_run|lockfile_only" pacquet/crates/package-manager/src --type=rust -B1 -A3 | head -100

Repository: pnpm/pnpm

Length of output: 8756


Fix lockfile_only and dry_run for dedupe command.

The current implementation incorrectly ties both lockfile_only and dry_run to the --check flag. Dedupe should always operate on the lockfile only (without installing packages); the --check flag should only control whether changes are written.

pnpm's dedupe handler always passes dryRun: false and uses a separate lockfileCheck callback for the check behavior. Pacquet's equivalent should be:

  • lockfile_only: true (always—dedupe is lockfile-focused)
  • dry_run: self.check (true only when checking)

Current code would make normal dedupe (without --check) skip lockfile materialization while attempting a full install, contradicting both dedupe semantics and pnpm's behavior.

🤖 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/cli/src/cli_args/dedupe.rs` around lines 48 - 49, In the
dedupe command configuration, fix the incorrect flag assignments for
lockfile_only and dry_run. The issue is that both fields are currently tied to
the self.check flag, but they should behave independently. Change lockfile_only
to always be true (since dedupe must always operate on the lockfile only without
installing packages) and change dry_run to self.check (so changes are only
written when not in check mode). This ensures dedupe always performs
lockfile-focused operations while the check flag controls whether modifications
are actually persisted.

Source: Coding guidelines

Comment thread pacquet/crates/cli/src/cli_args.rs Outdated
Comment on lines +507 to +517
CliCommand::CatFile(args) => {
args.run(|| config().map(|m| &*m))?;
}
CliCommand::CatIndex(args) => {
CliCommand::Dedupe(args) => match reporter {
ReporterType::Default | ReporterType::AppendOnly => {
Box::pin(args.run::<DefaultReporter>(state(false)?)).await?;
}
ReporterType::Ndjson => Box::pin(args.run::<NdjsonReporter>(state(false)?)).await?,
ReporterType::Silent => Box::pin(args.run::<SilentReporter>(state(false)?)).await?,
},
CliCommand::CatIndex(args) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Match arm missing comma 🐞 Bug ≡ Correctness

CliArgs::run inserts the new CliCommand::Dedupe arm immediately after CliCommand::CatFile
without a comma after the CatFile arm, so the match command { ... } does not parse and the CLI
will not compile.
Agent Prompt
### Issue description
`match command { ... }` in `CliArgs::run` is missing a comma between the `CliCommand::CatFile` arm and the newly-added `CliCommand::Dedupe` arm, which is a Rust syntax error.

### Issue Context
The new `Dedupe` dispatch was inserted into the large command `match`, but the preceding arm (`CatFile`) ends with `}` and no trailing comma.

### Fix Focus Areas
- pacquet/crates/cli/src/cli_args.rs[507-519]

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

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4531b4b

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@pacquet/crates/cli/src/cli_args.rs`:
- Line 510: The CliCommand::Dedupe match arm on line 510 has excessive
indentation and does not align with the peer match arms (Store, Cache, CatFile)
above it. Remove the extra leading whitespace from the CliCommand::Dedupe(args)
=> match reporter { line to make it align horizontally with the other match arms
at the same nesting level in the match expression.
- Line 241: The #[allow(clippy::large_stack_frames)] attribute on the run
function is overly broad and silences the lint for the entire method, but the
justification (documented in lines 422-424) only applies to the Install arm.
Move the allow attribute from the function level to either the match expression
on line 320 or directly to the specific match arm (Install) that requires the
exception, so the lint suppression is scoped only to where it is genuinely
needed rather than affecting all dispatch arms in the run method.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a0dc6275-286c-436b-b510-04e41ba8016e

📥 Commits

Reviewing files that changed from the base of the PR and between 9a9565b and 4531b4b.

📒 Files selected for processing (2)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/dedupe.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pacquet/crates/cli/src/cli_args/dedupe.rs

Comment thread pacquet/crates/cli/src/cli_args.rs Resolved
Comment thread pacquet/crates/cli/src/cli_args.rs Resolved
Comment on lines +38 to +50
frozen_lockfile: false,
prefer_frozen_lockfile: None,
ignore_manifest_check: false,
skip_runtimes: false,
trust_lockfile: false,
update_checksums: false,
is_full_install: true,
resolved_packages,
supported_architectures: config.supported_architectures.clone(),
node_linker: config.node_linker,
lockfile_only: self.check,
dry_run: self.check,
update_seed_policy: pacquet_package_manager::UpdateSeedPolicy::KeepAll,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Dedupe skips full resolve 🐞 Bug ≡ Correctness

DedupeArgs::run wires Install in a way that allows both the optimistic repeat-install early
return and the preferFrozenLockfile frozen path, so pacquet dedupe can succeed without
performing any re-resolution and therefore not deduplicate the lockfile. This is likely to happen by
default because both fast paths are enabled in config defaults.
Agent Prompt
## Issue description
`pacquet dedupe` should always perform a fresh resolution pass, but the current `Install { ... }` options allow `Install::run` to short-circuit as “Already up to date” (optimistic repeat-install) or take the frozen path (preferFrozenLockfile), both of which skip re-resolution.

## Issue Context
- `Install::run` can return early on the optimistic repeat-install path when `is_full_install && UpdateSeedPolicy::KeepAll && !frozen_lockfile`.
- `Install::run` also derives `prefer_frozen_lockfile` from config when the per-invocation value is `None`, and config defaults enable these fast paths.

## Fix Focus Areas
- pacquet/crates/cli/src/cli_args/dedupe.rs[15-54]

### Suggested implementation direction
- Ensure dedupe cannot take either fast path. Minimal options:
  - Pass `prefer_frozen_lockfile: Some(false)` so `Install::run` won’t choose the frozen dispatch.
  - Also disable the optimistic repeat-install short-circuit for this invocation. If you don’t want to change lifecycle-script semantics by flipping `is_full_install`, add a dedicated `Install` option (e.g. `disable_optimistic_repeat_install: bool`) and gate the optimistic fast path on it.
- Keep `dry_run` behavior for `--check` as-is, but ensure non-check dedupe still forces fresh resolve.

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

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 4531b4b

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

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

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

1 similar comment
@qodo-free-for-open-source-projects

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

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

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

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

Copy link
Copy Markdown

Code Review by Qodo

Grey Divider

New Review Started

This review has been superseded by a new analysis

Grey Divider

Qodo Logo

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

Copy link
Copy Markdown

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 22, 2026
@codecov-commenter

codecov-commenter commented Jun 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.57143% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.57%. Comparing base (05dc494) to head (12b7a78).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pacquet/crates/cli/src/cli_args/dedupe.rs 75.58% 21 Missing ⚠️
pacquet/crates/cli/src/cli_args.rs 85.39% 13 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12586      +/-   ##
==========================================
- Coverage   88.60%   88.57%   -0.03%     
==========================================
  Files         336      337       +1     
  Lines       48910    49047     +137     
==========================================
+ Hits        43338    43445     +107     
- Misses       5572     5602      +30     

☔ 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.

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: dd9140040152

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.455 ± 0.191 4.325 4.891 1.55 ± 0.08
pacquet@main 4.399 ± 0.141 4.295 4.765 1.53 ± 0.07
pnpr@HEAD 2.873 ± 0.083 2.779 3.055 1.00
pnpr@main 2.927 ± 0.137 2.810 3.217 1.02 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.45532232754,
      "stddev": 0.19060096125546008,
      "median": 4.3900417886400005,
      "user": 3.72359084,
      "system": 3.40757482,
      "min": 4.3246612011400005,
      "max": 4.890722307140001,
      "times": [
        4.890722307140001,
        4.33880159414,
        4.398775473140001,
        4.719708633140001,
        4.370711536140001,
        4.3875697351400005,
        4.393023702140001,
        4.33673525114,
        4.3246612011400005,
        4.3925138421400005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.39899188424,
      "stddev": 0.1407005206686483,
      "median": 4.33752357164,
      "user": 3.7160376399999997,
      "system": 3.38063102,
      "min": 4.295201238140001,
      "max": 4.76515965114,
      "times": [
        4.318688324140001,
        4.32686108814,
        4.47288937214,
        4.76515965114,
        4.331752933140001,
        4.295201238140001,
        4.37025616814,
        4.343294210140001,
        4.32274311914,
        4.443072738140001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.87293286584,
      "stddev": 0.0826357370647307,
      "median": 2.87092643564,
      "user": 2.74705564,
      "system": 3.00593582,
      "min": 2.77875800514,
      "max": 3.05480138914,
      "times": [
        2.81075352714,
        2.77875800514,
        3.05480138914,
        2.86596063514,
        2.89616274814,
        2.8790063801400003,
        2.9530434901400002,
        2.87589223614,
        2.81105437014,
        2.80389587714
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.92720174414,
      "stddev": 0.13721954287832094,
      "median": 2.8595268371399998,
      "user": 2.73502234,
      "system": 3.02192832,
      "min": 2.80966271214,
      "max": 3.21688517514,
      "times": [
        2.80966271214,
        3.21688517514,
        2.84724877414,
        2.85735632914,
        2.84767694214,
        2.86169734514,
        2.99928134814,
        2.84517937114,
        3.11419419714,
        2.87283524714
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 623.4 ± 10.4 612.9 642.2 1.00
pacquet@main 656.9 ± 17.4 630.3 685.2 1.05 ± 0.03
pnpr@HEAD 671.2 ± 14.7 652.4 697.2 1.08 ± 0.03
pnpr@main 682.0 ± 18.6 663.1 710.7 1.09 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6233786675000001,
      "stddev": 0.010366323254251394,
      "median": 0.6205539463,
      "user": 0.37420697999999997,
      "system": 1.3035937799999997,
      "min": 0.6128543043000001,
      "max": 0.6422059153,
      "times": [
        0.6148272073000001,
        0.6383111623000001,
        0.6128543043000001,
        0.6202897773000001,
        0.6208181153000001,
        0.6227348523,
        0.6422059153,
        0.6173074163000001,
        0.6135659433,
        0.6308719813000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6569339177000001,
      "stddev": 0.01738605748611635,
      "median": 0.6540962673000001,
      "user": 0.38972658,
      "system": 1.3255395799999998,
      "min": 0.6302715503,
      "max": 0.6851986623,
      "times": [
        0.6752223663000001,
        0.6302715503,
        0.6768200633000001,
        0.6528323633,
        0.6589526623,
        0.6419227243000001,
        0.6442274603000001,
        0.6485311533000001,
        0.6553601713000001,
        0.6851986623
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6712346410000001,
      "stddev": 0.014742597693276899,
      "median": 0.6723852948000001,
      "user": 0.37458537999999997,
      "system": 1.3359689799999999,
      "min": 0.6523770123000001,
      "max": 0.6972046383000001,
      "times": [
        0.6873912233000001,
        0.6569061593000001,
        0.6812605223000001,
        0.6566933913,
        0.6523770123000001,
        0.6600790393000001,
        0.6972046383000001,
        0.6731018043000001,
        0.6716687853000001,
        0.6756638343000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6820335215000001,
      "stddev": 0.018610579789093855,
      "median": 0.6719910308000001,
      "user": 0.39534018000000004,
      "system": 1.3456004799999999,
      "min": 0.6631382983,
      "max": 0.7106528833000001,
      "times": [
        0.6669121203,
        0.6987672833,
        0.7106528833000001,
        0.7004333593000001,
        0.6721591993000001,
        0.7026350293000001,
        0.6691494553,
        0.6646647243000001,
        0.6718228623000001,
        0.6631382983
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.657 ± 0.037 4.597 4.734 1.48 ± 0.04
pacquet@main 4.684 ± 0.029 4.644 4.729 1.49 ± 0.04
pnpr@HEAD 3.221 ± 0.132 3.082 3.406 1.03 ± 0.05
pnpr@main 3.138 ± 0.086 3.008 3.304 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.657370294420001,
      "stddev": 0.036697287026121524,
      "median": 4.65799212272,
      "user": 3.7952919800000005,
      "system": 3.3673605800000006,
      "min": 4.596738382720001,
      "max": 4.734074753720001,
      "times": [
        4.63961251172,
        4.6882632947200005,
        4.734074753720001,
        4.65931938672,
        4.6652380217200005,
        4.65666485872,
        4.6496067747200005,
        4.62341889472,
        4.660766064720001,
        4.596738382720001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.6837295896199995,
      "stddev": 0.02858832466429318,
      "median": 4.683790048220001,
      "user": 3.80942558,
      "system": 3.38643088,
      "min": 4.64355585072,
      "max": 4.72881832172,
      "times": [
        4.700542713720001,
        4.68023968572,
        4.72881832172,
        4.64355585072,
        4.68360858972,
        4.6578838537200005,
        4.72376887572,
        4.683971506720001,
        4.649949121720001,
        4.684957376720001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.22148373102,
      "stddev": 0.13243273248500975,
      "median": 3.18015583172,
      "user": 2.8523930799999997,
      "system": 3.1921283799999998,
      "min": 3.08189910072,
      "max": 3.40648006772,
      "times": [
        3.3812710247199997,
        3.11368338672,
        3.11040912572,
        3.13875039772,
        3.38840613872,
        3.09278481072,
        3.22156126572,
        3.40648006772,
        3.27959199172,
        3.08189910072
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.13767206242,
      "stddev": 0.08607726470189776,
      "median": 3.12115534272,
      "user": 2.8477577799999994,
      "system": 3.1540606799999997,
      "min": 3.00815935872,
      "max": 3.30403438472,
      "times": [
        3.0881123707199998,
        3.18250933572,
        3.05147000172,
        3.15995686572,
        3.12461962272,
        3.11021271772,
        3.22995490372,
        3.11769106272,
        3.30403438472,
        3.00815935872
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.287 ± 0.008 1.274 1.298 1.00
pacquet@main 1.327 ± 0.028 1.299 1.395 1.03 ± 0.02
pnpr@HEAD 1.393 ± 0.064 1.354 1.573 1.08 ± 0.05
pnpr@main 1.415 ± 0.076 1.355 1.601 1.10 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.2870708353400002,
      "stddev": 0.008080256355036123,
      "median": 1.2879562832400002,
      "user": 1.26530192,
      "system": 1.6699436400000003,
      "min": 1.27383086224,
      "max": 1.2982077222400001,
      "times": [
        1.27383086224,
        1.28365504624,
        1.29450320824,
        1.28730840224,
        1.2886041642400001,
        1.2780469272400001,
        1.29564899724,
        1.2982077222400001,
        1.2800333832400002,
        1.2908696402400002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.32720536814,
      "stddev": 0.028141581540076413,
      "median": 1.31940620524,
      "user": 1.3067203199999997,
      "system": 1.70457614,
      "min": 1.29885727324,
      "max": 1.3946486952400001,
      "times": [
        1.3035736852400002,
        1.3946486952400001,
        1.32145418724,
        1.31322049924,
        1.35238318924,
        1.31735822324,
        1.32847071724,
        1.29885727324,
        1.31156239024,
        1.33052482124
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.39325570334,
      "stddev": 0.06406930048046257,
      "median": 1.37403483224,
      "user": 0.55795252,
      "system": 1.5594169399999998,
      "min": 1.35432972424,
      "max": 1.5727676252400002,
      "times": [
        1.37571925424,
        1.37124606324,
        1.5727676252400002,
        1.3723504102400002,
        1.35432972424,
        1.37897721724,
        1.36398931324,
        1.3676688732400002,
        1.3777663132400002,
        1.39774223924
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.41490004614,
      "stddev": 0.07593126726568247,
      "median": 1.38702001424,
      "user": 0.60372132,
      "system": 1.5584531400000001,
      "min": 1.3547349112400002,
      "max": 1.6012227152400003,
      "times": [
        1.49577896824,
        1.37862411824,
        1.4026257772400001,
        1.6012227152400003,
        1.36824579824,
        1.39302043324,
        1.3547349112400002,
        1.3810195952400002,
        1.3776233452400002,
        1.3961047992400002
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.973 ± 0.051 2.940 3.114 2.13 ± 0.05
pacquet@main 2.990 ± 0.019 2.971 3.031 2.14 ± 0.03
pnpr@HEAD 1.395 ± 0.018 1.374 1.432 1.00
pnpr@main 1.396 ± 0.072 1.351 1.586 1.00 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.9730869993800004,
      "stddev": 0.051060743887323165,
      "median": 2.95763736448,
      "user": 1.7354435,
      "system": 1.9463790399999996,
      "min": 2.93956303198,
      "max": 3.11404433998,
      "times": [
        2.9680368599799998,
        2.9428689599799998,
        2.96121914698,
        2.9526324589799997,
        2.94858781598,
        2.95405558198,
        2.97649536598,
        2.97336643198,
        3.11404433998,
        2.93956303198
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9901825434799996,
      "stddev": 0.019125157865758587,
      "median": 2.98652437448,
      "user": 1.7611754999999998,
      "system": 1.9482900399999998,
      "min": 2.97052897998,
      "max": 3.03146798598,
      "times": [
        2.98725940898,
        2.99054051898,
        3.0031293349799997,
        2.97052897998,
        2.98097180498,
        2.97164965298,
        2.9857893399799997,
        2.97325466598,
        3.03146798598,
        3.00723374198
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.3952086705800002,
      "stddev": 0.01826930031026197,
      "median": 1.3866139469800003,
      "user": 0.5656551999999999,
      "system": 1.57890284,
      "min": 1.3738064929800002,
      "max": 1.43222277798,
      "times": [
        1.43222277798,
        1.4158790499800002,
        1.3738064929800002,
        1.39829287198,
        1.3840372789800002,
        1.38022509198,
        1.40801597998,
        1.3866202389800002,
        1.3866076549800002,
        1.38637926798
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.3960901085800002,
      "stddev": 0.07221887016458382,
      "median": 1.3705296424800002,
      "user": 0.5947766,
      "system": 1.5505848399999997,
      "min": 1.3509556709800001,
      "max": 1.5862479119800001,
      "times": [
        1.44624586498,
        1.38805920498,
        1.3631670129800002,
        1.5862479119800001,
        1.37261008298,
        1.35370577998,
        1.37359593298,
        1.36844920198,
        1.3509556709800001,
        1.3578644219800002
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12586
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,657.37 ms
(+0.19%)Baseline: 4,648.39 ms
5,578.07 ms
(83.49%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,973.09 ms
(-2.38%)Baseline: 3,045.68 ms
3,654.81 ms
(81.35%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,287.07 ms
(-4.75%)Baseline: 1,351.28 ms
1,621.53 ms
(79.37%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,455.32 ms
(-1.01%)Baseline: 4,500.85 ms
5,401.02 ms
(82.49%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
623.38 ms
(-0.78%)Baseline: 628.27 ms
753.93 ms
(82.68%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12586
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
3,221.48 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,395.21 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
1,393.26 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,872.93 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
671.23 ms
🐰 View full continuous benchmarking report in Bencher

@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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In `@pacquet/crates/cli/tests/dedupe.rs`:
- Around line 6-35: The test name `dedupe_writes_lockfile_without_materializing`
contradicts the actual behavior since the dedupe command is run without the
`--check` flag, which means node_modules will be materialized. Either rename the
test to reflect that materialization occurs (e.g.,
`dedupe_writes_lockfile_and_materializes`) and add an assertion to verify that
the node_modules directory exists after the dedupe command runs, or add the
`--check` argument to the pacquet.with_arg("dedupe") call to prevent
materialization and match the test name's intent.
- Around line 37-63: The test function dedupe_check_does_not_materialize
correctly asserts that node_modules is not created by dedupe --check, but it
lacks verification that the lockfile is not written. Add an additional assertion
after the existing node_modules check that verifies pnpm-lock.yaml does not
exist in the workspace directory by checking that
workspace.join("pnpm-lock.yaml").exists() returns false, with a message
indicating that dedupe --check must not write the lockfile in dry-run mode.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b2699a53-3f4e-436e-a81d-229882342255

📥 Commits

Reviewing files that changed from the base of the PR and between bba2b69 and bc8163e.

📒 Files selected for processing (2)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/tests/dedupe.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pacquet/crates/cli/src/cli_args.rs

Comment thread pacquet/crates/cli/tests/dedupe.rs Resolved
Comment thread pacquet/crates/cli/tests/dedupe.rs Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 5b1c49d

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@pacquet/crates/cli/src/cli_args/dedupe.rs`:
- Around line 70-78: `Dedupe::check` currently returns the `Lockfile would be
modified by deduplication` error without explicitly restoring the original
lockfile, so a failed rollback can leave `pnpm-lock.yaml` changed while still
reporting only the mismatch. Update the `dedupe` flow in `cli_args/dedupe.rs` to
perform an explicit restore before returning the `--check` mismatch error, and
make the restore/remove path in the affected block (including the guard/rollback
logic used around `existing`, `current`, and `guard`) propagate failures instead
of discarding them. Ensure `--check` preserves atomicity: if rollback fails,
surface that error rather than the generic mismatch.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5b63c794-df34-4c1a-abdc-38fc87910e87

📥 Commits

Reviewing files that changed from the base of the PR and between 5b1c49d and dfd8e88.

📒 Files selected for processing (2)
  • pacquet/crates/cli/src/cli_args.rs
  • pacquet/crates/cli/src/cli_args/dedupe.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pacquet/crates/cli/src/cli_args.rs

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

Copy link
Copy Markdown

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

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

Copy link
Copy Markdown

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

kairosci added 7 commits June 24, 2026 21:33
…zation

The previous commit left the CliCommand::Dedupe arm as a bare match on
reporter (returning () instead of Pin<Box<dyn Future>>), which failed
to compile in all CI targets (clippy, doc, dylint, test).

This commit adds DedupePipeline, mirroring InstallPipeline:

- Calls sync_package_manager_dependencies, install_config_deps, and
  run_update_config_hooks before State::init (config-finalization).
- Wraps the reporter match in Box::pin(async move { ... Ok(()) })
  so each arm produces the right future type.
- Fixes lockfile path derivation to use config.workspace_dir.
- Sets prefer_frozen_lockfile: Some(false) and UpdateSeedPolicy::DropAll
  so the dedupe pipeline re-resolves from scratch.
- Changes lockfile_only to true and dry_run to false (always compute
  resolution; --check uses a backup/restore pattern).
- Fixes integration test names and adds lockfile-equality assertion
  in the --check test.
DedupePipeline::run runs config-dependency ops that can persist the
env-lockfile document into pnpm-lock.yaml BEFORE DedupeArgs::run
snapshots the existing lockfile, so --check would compare post-install
output against the already-modified lockfile and silently miss the diff.

Move the snapshot into DedupePipeline::run, before config-dependency
ops. Pass it (and the lockfile path) to DedupeArgs::run as parameters.
Use tempfile::NamedTempFile + persist (rename) for the lockfile restore
in --check so the rollback is atomic: a crash mid-write cannot leave
a torn pnpm-lock.yaml. The old std::fs::write was non-atomic and
followed symlinks.
DedupePipeline::run was always installing config dependencies and
running updateConfig hooks, which creates/modifies
node_modules/.pnpm-config under the workspace root. This breaks the
--check contract of not materializing anything.

Guard the config-dependency ops behind !self.args.check so --check
skips them entirely while the normal dedupe path still runs them.
Both the Install and Dedupe dispatch arms repeated the same
config_root + package_manager_to_sync derivation. Extract a
shared helper so the two paths cannot drift.
…ust_lockfile

Move the lockfile snapshot and LockfileGuard creation into DedupePipeline::run,
before config-dependency syncing, so the --check gate covers all lockfile
mutations (including those written by config-deps). Previously the snapshot
was taken inside DedupeArgs::run, after config-deps had already run, letting
config-dep-driven lockfile changes go undetected by --check.

Also set trust_lockfile: config.trust_lockfile instead of hard-coding false,
matching the behaviour of the install command and avoiding unnecessary
registry round-trips in offline/air-gapped setups.
@kairosci
kairosci force-pushed the feat/pacquet-dedupe branch from dfd8e88 to 12b7a78 Compare June 24, 2026 19:38
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 12b7a78

1 similar comment
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 12b7a78

@kairosci

kairosci commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor Author

@zkochan I addressed coderabbitai and qodo reviews here.

@zkochan
zkochan added this pull request to the merge queue Jun 24, 2026
Merged via the queue into pnpm:main with commit 6b962c9 Jun 24, 2026
31 checks passed
@kairosci
kairosci deleted the feat/pacquet-dedupe branch June 24, 2026 20:13
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 state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants