Skip to content

fix(pacquet): repair licenses command - #13347

Merged
zkochan merged 2 commits into
mainfrom
fix-pacquet-licenses
Jul 25, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-pacquet-licenses

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • accept the documented pnpm licenses list and pnpm licenses ls subcommands in pacquet, matching the TypeScript CLI
  • resolve installed package manifests through pacquet.s canonical virtual-store layout, preserving lockfile and project-selected Node runtime precedence for hashed global virtual-store slots
  • validate package-name components and computed slots before reading manifests, and cover both command spellings with a manifest-selected-runtime global-store integration test

Fixes #13332.
Fixes #13333.

Squash Commit Body

Pacquet parsed license options directly after `pnpm licenses`, so the documented `list` and `ls` subcommands were rejected. Accept those subcommands and report the same missing/unknown-subcommand error codes as the TypeScript CLI.

License discovery also reconstructed the legacy flat virtual-store path. Route it through the shared virtual-store layout instead, preserving lockfile pins and the effective project-selected Node runtime before falling back to the host, and validate package-name components plus slot containment before reading package manifests. This allows license metadata and reported paths to resolve correctly from hashed global virtual-store slots.

Fixes pnpm/pnpm#13332.
Fixes pnpm/pnpm#13333.

Checklist

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

Written by an agent (Codex, GPT-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed licenses list and licenses ls parsing and license metadata discovery when using the global virtual store.
    • Improved reported package paths and license group JSON accuracy in global virtual store mode.
    • Added clearer, structured errors when the licenses command has no or an unsupported subcommand.
    • Strengthened detection of unsafe path components in dependency package info.
  • Tests

    • Added/updated tests for JSON license output, package grouping, version checks, and filesystem path validity.
    • Added tests for missing-subcommand error messaging and improved empty-lockfile coverage.

Copilot AI review requested due to automatic review settings July 25, 2026 12:58

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0892148a-dd30-4ca5-8980-927cedd80cb3

📥 Commits

Reviewing files that changed from the base of the PR and between 10767c9 and 487d7bf.

📒 Files selected for processing (6)
  • pnpm/crates/cli/src/cli_args/deps_tree/pkg_info.rs
  • pnpm/crates/cli/src/cli_args/deps_tree/pkg_info/tests.rs
  • pnpm/crates/cli/src/cli_args/licenses.rs
  • pnpm/crates/cli/src/cli_args/licenses/tests.rs
  • pnpm/crates/cli/tests/licenses.rs
  • pnpm/crates/package-manager/src/virtual_store_layout.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/cli/tests/licenses.rs
  • pnpm/crates/cli/src/cli_args/licenses.rs

📝 Walkthrough

Walkthrough

The licenses command now accepts list and ls, reports structured errors for invalid subcommands, and resolves package metadata using lockfile-aware global virtual-store layouts. Tests cover empty locks, path safety, and global-store license reporting.

Changes

Licenses global virtual-store support

Layer / File(s) Summary
Subcommand validation
pnpm/crates/cli/src/cli_args/licenses.rs, pnpm/crates/cli/src/cli_args/licenses/tests.rs
Adds diagnostics for missing or unknown subcommands and supplies list in the empty-lockfile test.
Lockfile-aware virtual-store layout
pnpm/crates/package-manager/src/virtual_store_layout.rs, pnpm/crates/cli/src/cli_args/licenses.rs
Adds layout construction that derives the runtime engine from snapshots, configured Node version, or detected Node version, then uses computed slot paths for metadata scanning.
License path integration and coverage
pnpm/crates/cli/tests/licenses.rs, pnpm/crates/cli/src/cli_args/deps_tree/pkg_info.rs, pnpm/crates/cli/src/cli_args/deps_tree/pkg_info/tests.rs, .changeset/pacquet-licenses-global-store.md
Tests list/ls license output with the global virtual store enabled and updates path-component safety checks and release metadata.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Support the documented licenses list syntax [#13332] ✅
Read license metadata from global virtual-store paths [#13333] ✅

Possibly related PRs

  • pnpm/pnpm#13090: Introduced the licenses command implementation that this change extends.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-pacquet-licenses

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-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix pacquet licenses subcommand parsing and global virtual store resolution

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Accept pnpm licenses list and pnpm licenses ls, matching TypeScript CLI behavior.
• Resolve license manifests via canonical virtual-store layout (including hashed GVS slots).
• Add integration coverage for both spellings when global virtual store is enabled.
Diagram

graph TD
  CLI["pacquet CLI: licenses"] --> Lockfile[("pnpm-lock.yaml")]
  Lockfile --> Layout["virtual_store_layout_for_lockfile"] --> Validate["slot containment"] --> Slot[("virtual store slot")]
  Slot --> Read["read package.json"]
  IT["CLI integration tests"] --> CLI
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Model `licenses` as clap subcommands
  • ➕ Clearer CLI contract and auto-generated help for list/ls.
  • ➕ Avoids manual params validation and error mapping logic.
  • ➕ Easier to extend with future licenses subcommands.
  • ➖ More invasive CLI surface refactor (may affect parsing/backward-compat).
  • ➖ Requires careful alignment with pnpm TS CLI error codes/messages.
2. Expose a `VirtualStoreLayout::from_lockfile(...)` constructor
  • ➕ Keeps layout logic encapsulated with the type rather than a free function.
  • ➕ Reduces call-site plumbing and clarifies intent.
  • ➖ API churn in package-manager crate; may be premature without more call sites.

Recommendation: Current approach is a good targeted fix: it matches pnpm’s documented CLI spellings, reuses the canonical virtual-store layout logic (including GVS hashing), and adds an end-to-end test that exercises the real filesystem paths. Consider migrating to clap-modeled subcommands later if more licenses verbs are added or parsing grows further.

Files changed (5) +129 / -18

Bug fix (1) +39 / -16
licenses.rsAccept 'list'/'ls' and use canonical virtual-store layout for manifest lookup +39/-16

Accept 'list'/'ls' and use canonical virtual-store layout for manifest lookup

• Adds explicit subcommand parsing for 'licenses' to accept 'list' and 'ls', returning TypeScript-aligned error codes for missing/unknown subcommands. Switches package directory resolution from legacy flat virtual-store reconstruction to the shared 'VirtualStoreLayout', including containment validation before reading manifests.

pnpm/crates/cli/src/cli_args/licenses.rs

Refactor (1) +26 / -2
virtual_store_layout.rsAdd 'virtual_store_layout_for_lockfile' helper matching install runtime precedence +26/-2

Add 'virtual_store_layout_for_lockfile' helper matching install runtime precedence

• Introduces a helper to compute 'VirtualStoreLayout' for a given lockfile using the same Node runtime precedence as installation (lockfile snapshot → config → runtime detection). This enables non-install consumers (like 'licenses') to resolve slot directories correctly under GVS.

pnpm/crates/package-manager/src/virtual_store_layout.rs

Tests (2) +59 / -0
tests.rsUpdate unit test to pass 'licenses' subcommand params +1/-0

Update unit test to pass 'licenses' subcommand params

• Adjusts the existing 'LicensesArgs' unit test to include a 'list' subcommand in the new 'params' field so it exercises the updated argument parsing path.

pnpm/crates/cli/src/cli_args/licenses/tests.rs

licenses.rsAdd global virtual store integration test for 'licenses list/ls' +58/-0

Add global virtual store integration test for 'licenses list/ls'

• Adds an end-to-end test that enables the global virtual store, installs a fixture dependency, and asserts 'licenses list' and 'licenses ls' succeed with valid JSON. Verifies returned package paths exist on disk, covering hashed GVS slot resolution.

pnpm/crates/cli/tests/licenses.rs

Documentation (1) +5 / -0
pacquet-licenses-global-store.mdAdd changeset for 'licenses' parsing/GVS metadata fix +5/-0

Add changeset for 'licenses' parsing/GVS metadata fix

• Introduces a patch changeset documenting the fix to 'pnpm licenses list/ls' parsing and global virtual store license discovery. Provides user-facing release notes tied to the reported issues.

.changeset/pacquet-licenses-global-store.md

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review


Written by an agent (Codex, GPT-5).

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

@zkochan I’ll review the changes in #13347.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

The previously reported runtime-precedence issue is addressed by selecting a lockfile runtime first, then the configured or manifest-selected runtime, before falling back to the host, and the global-store integration test confirms that licenses resolves the installed package path.

Reviews (2): Last reviewed commit: "fix(pacquet): align licenses runtime loo..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.01     11.7±0.04ms    32.0 MB/sec    1.00     11.5±0.02ms    32.5 MB/sec
packument/parse                1.00     37.8±0.35µs  1753.3 MB/sec    1.02     38.7±0.11µs  1714.1 MB/sec
tarball/download_dependency    1.05      2.3±0.09ms  1854.9 KB/sec    1.00      2.2±0.09ms  1956.6 KB/sec

@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 `@pnpm/crates/cli/src/cli_args/licenses.rs`:
- Around line 255-256: Update the is_unsafe calculation in the license
package-path handling to inspect Path components rather than rejecting any name
containing "..". Mark names unsafe when their components include ParentDir, a
root, or a platform-prefix component, while allowing safe names such as
"foo..bar"; preserve the existing unsafe-path handling and manifest behavior.
🪄 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: 3d19320b-0457-44be-8106-e757178bc238

📥 Commits

Reviewing files that changed from the base of the PR and between f7e1fee and 10767c9.

📒 Files selected for processing (5)
  • .changeset/pacquet-licenses-global-store.md
  • pnpm/crates/cli/src/cli_args/licenses.rs
  • pnpm/crates/cli/src/cli_args/licenses/tests.rs
  • pnpm/crates/cli/tests/licenses.rs
  • pnpm/crates/package-manager/src/virtual_store_layout.rs

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.21%. Comparing base (352125d) to head (487d7bf).
⚠️ Report is 12 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/licenses.rs 95.00% 1 Missing ⚠️
...crates/package-manager/src/virtual_store_layout.rs 93.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13347      +/-   ##
==========================================
+ Coverage   87.03%   87.21%   +0.18%     
==========================================
  Files         533      536       +3     
  Lines       91682    92034     +352     
==========================================
+ Hits        79791    80265     +474     
+ Misses      11891    11769     -122     

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

@qodo-code-review

qodo-code-review Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (1) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Typoed diagnostic code ✗ Dismissed 🐞 Bug ≡ Correctness
Description
LicensesError::NoSubcommand uses ERR_PNPM_LICENCES_NO_SUBCOMMAND while the same file uses
ERR_PNPM_LICENSES_UNKNOWN_SUBCOMMAND and other commands follow the ERR_PNPM_<CMD>_NO_SUBCOMMAND
convention. This introduces a new externally visible error-code mismatch and likely breaks
parity/consumers expecting LICENSES spelling.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R34-45]

+#[derive(Debug, Display, Error, Diagnostic)]
+enum LicensesError {
+    #[display("Please specify the subcommand")]
+    #[diagnostic(
+        code(ERR_PNPM_LICENCES_NO_SUBCOMMAND),
+        help("Run `pnpm licenses --help` for available subcommands.")
+    )]
+    NoSubcommand,
+
+    #[display("This subcommand is not known")]
+    #[diagnostic(code(ERR_PNPM_LICENSES_UNKNOWN_SUBCOMMAND))]
+    UnknownSubcommand,
Relevance

⭐⭐⭐ High

Externally visible error-code typo; team has accepted changes enforcing consistent diagnostic codes.

PR-#13203

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The same file contains both spellings (LICENCES and LICENSES), indicating a typo rather than
intentional naming; other commands demonstrate the established NO_SUBCOMMAND code naming
convention.

pnpm/crates/cli/src/cli_args/licenses.rs[34-46]
pnpm/crates/cli/src/cli_args/runtime.rs[33-42]

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

## Issue description
The diagnostic code for `LicensesError::NoSubcommand` is misspelled as `ERR_PNPM_LICENCES_NO_SUBCOMMAND`, while the command name and adjacent diagnostics use `LICENSES`. Diagnostic codes are public/stable identifiers and should match established naming.

## Issue Context
The repo uses consistent `ERR_PNPM_<CMD>_NO_SUBCOMMAND` patterns (e.g., `ERR_PNPM_RUNTIME_NO_SUBCOMMAND`).

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[34-45]

### Suggested fix approach
- Rename the code to `ERR_PNPM_LICENSES_NO_SUBCOMMAND`.
- Add/update a test asserting the exact diagnostic code for the missing-subcommand case, similar to other CLI arg tests.

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



Remediation recommended

2. Weak alias path validation ✓ Resolved 🐞 Bug ⛨ Security
Description
licenses joins lockfile-derived package names into .../node_modules/<name> using only a
../absolute-path filter, instead of the repo’s canonical npm package-name validation that exists
specifically to prevent node_modules path escape/collisions from untrusted lockfiles. This can cause
reading manifests from unintended locations or interpreting malformed names as path components, and
it diverges from install’s security boundary for attacker-controlled lockfiles.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R255-259]

+            let pkg_dir = layout.slot_dir(&key).join("node_modules").join(&name);
+            let is_unsafe = name.contains("..") || std::path::Path::new(&name).is_absolute();
            let manifest = if is_unsafe {
                None
            } else {
Relevance

⭐⭐⭐ High

Matches accepted security hardening: validate untrusted lockfile-derived identifiers before joining
into filesystem paths.

PR-#13178

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The command builds a filesystem path from lockfile-derived name and reads package.json from it,
but only applies an ad-hoc ../absolute check. The repo explicitly documents that dependency
aliases must be validated with npm rules because otherwise joining them under node_modules can
escape/collide, and the manifest reader does no additional confinement.

pnpm/crates/cli/src/cli_args/licenses.rs[245-261]
pnpm/crates/package-manifest/src/lib.rs[826-839]
pnpm/crates/resolving-deps-resolver/src/validate_dependency_alias.rs[1-14]
pnpm/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[13-59]
pnpm/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[367-389]
PR-#13178

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

## Issue description
`pnpm licenses` constructs `pkg_dir` by joining a lockfile-derived package name onto a `node_modules` directory, but it only blocks names containing `..` or absolute paths. The repo already has a canonical npm-name validator (`is_valid_dependency_alias` / lockfile verifier) intended to prevent malformed aliases from escaping directories or colliding with pnpm’s own `node_modules` layout.

## Issue Context
- Lockfiles are attacker-controlled per REVIEW_GUIDE.md.
- `PkgName` parsing does not enforce npm naming rules.
- `safe_read_package_json_from_dir()` does no confinement beyond `dir.join("package.json")`.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[230-261]
- pnpm/crates/resolving-deps-resolver/src/validate_dependency_alias.rs[1-14]
- pnpm/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[367-389]

### Suggested fix approach
- Prefer a single, canonical guard:
 - Call `pacquet_lockfile_verification::verify_lockfile_dependency_names(&lockfile)` early in `LicensesArgs::run()` and fail with `ERR_PNPM_INVALID_DEPENDENCY_NAME` on invalid aliases.
 - And/or validate each `name` with `pacquet_resolving_deps_resolver::is_valid_dependency_alias(&name)` before joining to `node_modules`.
- Replace the current “silently skip manifest read on unsafe” behavior with a typed error that matches install’s behavior, so attacker-controlled lockfiles can’t downgrade into confusing output.

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


3. Licenses hashes all snapshots 🐞 Bug ➹ Performance
Description
When GVS is enabled, licenses now rebuilds a full VirtualStoreLayout for the lockfile (including
per-snapshot graph hashing) and may spawn node --version to derive an engine string, adding
avoidable CPU/process overhead to a read-only command. The cost scales with snapshot count and can
make pnpm licenses noticeably slower on large lockfiles.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R230-238]

+        let allow_build_policy = AllowBuildPolicy::from_config(config).into_diagnostic()?;
+        let layout = virtual_store_layout_for_lockfile(
+            config,
+            lockfile.snapshots.as_ref(),
+            lockfile.packages.as_ref(),
+            Some(&allow_build_policy),
+        );
+        validate_virtual_store_slot_containment(lockfile.snapshots.as_ref(), &layout)
+            .into_diagnostic()?;
Relevance

⭐⭐ Medium

Performance concern is plausible but change matches PR intent; no close precedent on avoiding
layout/hash overhead.

PR-#13150

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new call site in licenses constructs a lockfile-wide layout and validates containment. The
layout builder can spawn node --version via detect_node_major, and the layout constructor loops
all snapshots computing graph hashes, implying CPU/process overhead proportional to lockfile size.

pnpm/crates/cli/src/cli_args/licenses.rs[230-238]
pnpm/crates/package-manager/src/virtual_store_layout.rs[288-305]
pnpm/crates/graph-hasher/src/engine_name.rs[41-68]
pnpm/crates/package-manager/src/virtual_store_layout.rs[192-236]

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

## Issue description
`pnpm licenses` now constructs a full `VirtualStoreLayout` (potentially hashing every snapshot and spawning `node --version`) even though it only needs paths for the packages in `belongs_to`. This adds latency and scales with lockfile size.

## Issue Context
- `virtual_store_layout_for_lockfile()` may fall back to `detect_node_major()` which spawns `node --version`.
- `VirtualStoreLayout::new()` iterates all snapshots and computes `calc_graph_node_hash` per snapshot to precompute GVS suffixes.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[230-238]
- pnpm/crates/package-manager/src/virtual_store_layout.rs[158-236]
- pnpm/crates/package-manager/src/virtual_store_layout.rs[288-305]
- pnpm/crates/graph-hasher/src/engine_name.rs[41-68]

### Suggested fix approach
- Add a `VirtualStoreLayout` constructor/helper that computes slot paths lazily (or only for a provided set of `PackageKey`s) instead of precomputing for all snapshots.
- In `licenses`, build layout only after `belongs_to` is known, and restrict work to those keys.
- Ensure the engine detection path does not spawn `node` unless strictly required (e.g., only when GVS is enabled and there is no runtime major in lockfile/config).

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



Informational

4. Avoidable manifest I/O 🐞 Bug ➹ Performance ⭐ New
Description
LicensesArgs::run reads/parses package.json to derive an effective Node version even when GVS is
disabled or config.node_version already overrides it, adding unnecessary filesystem I/O and JSON
parsing to pnpm licenses runs. This increases command latency (notably on networked
filesystems/CI) without changing output in those cases.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R235-239]

+        let project_manifest = safe_read_package_json_from_dir(dir).into_diagnostic()?;
+        let manifest_node_version =
+            project_manifest.as_ref().and_then(node_version_from_engines_runtime);
+        let effective_node_version =
+            config.node_version.as_deref().or(manifest_node_version.as_deref());
Relevance

⭐ Low

Similar perf-only “avoid extra parse/IO” refactors were rejected as unnecessary micro-optimizations
in CLI code.

PR-#13150
PR-#13297
PR-#13207

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code unconditionally reads package.json and computes effective_node_version, but the layout
helper only uses this value when GVS is enabled, so the work is wasted when GVS is off and also
redundant when config.node_version is present.

pnpm/crates/cli/src/cli_args/licenses.rs[234-246]
pnpm/crates/package-manager/src/virtual_store_layout.rs[288-306]

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

## Issue description
`pnpm licenses` currently reads/parses the project `package.json` to compute `effective_node_version` even when that value is unused (GVS disabled) or redundant (`config.node_version` already set). This adds avoidable I/O and JSON parsing on a user-facing command.

## Issue Context
`virtual_store_layout_for_lockfile()` only consults `effective_node_version` when `config.enable_global_virtual_store` is true; otherwise the parameter is ignored.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[235-239]

### Suggested change
- Compute `effective_node_version` as `config.node_version.as_deref()` first.
- Only if `effective_node_version.is_none()` **and** `config.enable_global_virtual_store` is true, then read `package.json` and attempt `node_version_from_engines_runtime()`.
- Keep behavior identical for GVS+no pin (still allow manifest-selected runtime to influence layout), but skip manifest reads when they cannot affect the layout.

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


5. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and does not include a pnpm entry. This
violates the changeset requirement to explicitly declare a pnpm bump type.
Code

.changeset/pacquet-licenses-global-store.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Exact precedent: requests to add required pnpm entry to pacquet-only changesets were rejected.

PR-#12981
PR-#13117
PR-#13329

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each added/modified changeset to include an explicit pnpm entry
with a valid bump type; the added changeset front-matter lists only pacquet.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-licenses-global-store.md[1-3]

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

## Issue description
The changeset front-matter does not include a `pnpm` package entry with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
Compliance requires changesets to explicitly declare `pnpm` and its bump type. This PR added `.changeset/pacquet-licenses-global-store.md` with only a `pacquet` entry.

## Fix Focus Areas
- .changeset/pacquet-licenses-global-store.md[1-3]

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


Grey Divider

Previous review results

Review updated until commit 487d7bf

Results up to commit 10767c9 ⚖️ Balanced


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


Action required
1. Typoed diagnostic code ✗ Dismissed 🐞 Bug ≡ Correctness
Description
LicensesError::NoSubcommand uses ERR_PNPM_LICENCES_NO_SUBCOMMAND while the same file uses
ERR_PNPM_LICENSES_UNKNOWN_SUBCOMMAND and other commands follow the ERR_PNPM_<CMD>_NO_SUBCOMMAND
convention. This introduces a new externally visible error-code mismatch and likely breaks
parity/consumers expecting LICENSES spelling.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R34-45]

+#[derive(Debug, Display, Error, Diagnostic)]
+enum LicensesError {
+    #[display("Please specify the subcommand")]
+    #[diagnostic(
+        code(ERR_PNPM_LICENCES_NO_SUBCOMMAND),
+        help("Run `pnpm licenses --help` for available subcommands.")
+    )]
+    NoSubcommand,
+
+    #[display("This subcommand is not known")]
+    #[diagnostic(code(ERR_PNPM_LICENSES_UNKNOWN_SUBCOMMAND))]
+    UnknownSubcommand,
Relevance

⭐⭐⭐ High

Externally visible error-code typo; team has accepted changes enforcing consistent diagnostic codes.

PR-#13203

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The same file contains both spellings (LICENCES and LICENSES), indicating a typo rather than
intentional naming; other commands demonstrate the established NO_SUBCOMMAND code naming
convention.

pnpm/crates/cli/src/cli_args/licenses.rs[34-46]
pnpm/crates/cli/src/cli_args/runtime.rs[33-42]

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

## Issue description
The diagnostic code for `LicensesError::NoSubcommand` is misspelled as `ERR_PNPM_LICENCES_NO_SUBCOMMAND`, while the command name and adjacent diagnostics use `LICENSES`. Diagnostic codes are public/stable identifiers and should match established naming.

## Issue Context
The repo uses consistent `ERR_PNPM_<CMD>_NO_SUBCOMMAND` patterns (e.g., `ERR_PNPM_RUNTIME_NO_SUBCOMMAND`).

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[34-45]

### Suggested fix approach
- Rename the code to `ERR_PNPM_LICENSES_NO_SUBCOMMAND`.
- Add/update a test asserting the exact diagnostic code for the missing-subcommand case, similar to other CLI arg tests.

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



Remediation recommended
2. Weak alias path validation 🐞 Bug ⛨ Security
Description
licenses joins lockfile-derived package names into .../node_modules/<name> using only a
../absolute-path filter, instead of the repo’s canonical npm package-name validation that exists
specifically to prevent node_modules path escape/collisions from untrusted lockfiles. This can cause
reading manifests from unintended locations or interpreting malformed names as path components, and
it diverges from install’s security boundary for attacker-controlled lockfiles.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R255-259]

+            let pkg_dir = layout.slot_dir(&key).join("node_modules").join(&name);
+            let is_unsafe = name.contains("..") || std::path::Path::new(&name).is_absolute();
            let manifest = if is_unsafe {
                None
            } else {
Relevance

⭐⭐⭐ High

Matches accepted security hardening: validate untrusted lockfile-derived identifiers before joining
into filesystem paths.

PR-#13178

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The command builds a filesystem path from lockfile-derived name and reads package.json from it,
but only applies an ad-hoc ../absolute check. The repo explicitly documents that dependency
aliases must be validated with npm rules because otherwise joining them under node_modules can
escape/collide, and the manifest reader does no additional confinement.

pnpm/crates/cli/src/cli_args/licenses.rs[245-261]
pnpm/crates/package-manifest/src/lib.rs[826-839]
pnpm/crates/resolving-deps-resolver/src/validate_dependency_alias.rs[1-14]
pnpm/crates/resolving-parse-wanted-dependency/src/validate_npm_package_name.rs[13-59]
pnpm/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[367-389]
PR-#13178

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

## Issue description
`pnpm licenses` constructs `pkg_dir` by joining a lockfile-derived package name onto a `node_modules` directory, but it only blocks names containing `..` or absolute paths. The repo already has a canonical npm-name validator (`is_valid_dependency_alias` / lockfile verifier) intended to prevent malformed aliases from escaping directories or colliding with pnpm’s own `node_modules` layout.

## Issue Context
- Lockfiles are attacker-controlled per REVIEW_GUIDE.md.
- `PkgName` parsing does not enforce npm naming rules.
- `safe_read_package_json_from_dir()` does no confinement beyond `dir.join("package.json")`.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[230-261]
- pnpm/crates/resolving-deps-resolver/src/validate_dependency_alias.rs[1-14]
- pnpm/crates/lockfile-verification/src/verify_lockfile_resolutions.rs[367-389]

### Suggested fix approach
- Prefer a single, canonical guard:
 - Call `pacquet_lockfile_verification::verify_lockfile_dependency_names(&lockfile)` early in `LicensesArgs::run()` and fail with `ERR_PNPM_INVALID_DEPENDENCY_NAME` on invalid aliases.
 - And/or validate each `name` with `pacquet_resolving_deps_resolver::is_valid_dependency_alias(&name)` before joining to `node_modules`.
- Replace the current “silently skip manifest read on unsafe” behavior with a typed error that matches install’s behavior, so attacker-controlled lockfiles can’t downgrade into confusing output.

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


3. Licenses hashes all snapshots 🐞 Bug ➹ Performance
Description
When GVS is enabled, licenses now rebuilds a full VirtualStoreLayout for the lockfile (including
per-snapshot graph hashing) and may spawn node --version to derive an engine string, adding
avoidable CPU/process overhead to a read-only command. The cost scales with snapshot count and can
make pnpm licenses noticeably slower on large lockfiles.
Code

pnpm/crates/cli/src/cli_args/licenses.rs[R230-238]

+        let allow_build_policy = AllowBuildPolicy::from_config(config).into_diagnostic()?;
+        let layout = virtual_store_layout_for_lockfile(
+            config,
+            lockfile.snapshots.as_ref(),
+            lockfile.packages.as_ref(),
+            Some(&allow_build_policy),
+        );
+        validate_virtual_store_slot_containment(lockfile.snapshots.as_ref(), &layout)
+            .into_diagnostic()?;
Relevance

⭐⭐ Medium

Performance concern is plausible but change matches PR intent; no close precedent on avoiding
layout/hash overhead.

PR-#13150

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new call site in licenses constructs a lockfile-wide layout and validates containment. The
layout builder can spawn node --version via detect_node_major, and the layout constructor loops
all snapshots computing graph hashes, implying CPU/process overhead proportional to lockfile size.

pnpm/crates/cli/src/cli_args/licenses.rs[230-238]
pnpm/crates/package-manager/src/virtual_store_layout.rs[288-305]
pnpm/crates/graph-hasher/src/engine_name.rs[41-68]
pnpm/crates/package-manager/src/virtual_store_layout.rs[192-236]

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

## Issue description
`pnpm licenses` now constructs a full `VirtualStoreLayout` (potentially hashing every snapshot and spawning `node --version`) even though it only needs paths for the packages in `belongs_to`. This adds latency and scales with lockfile size.

## Issue Context
- `virtual_store_layout_for_lockfile()` may fall back to `detect_node_major()` which spawns `node --version`.
- `VirtualStoreLayout::new()` iterates all snapshots and computes `calc_graph_node_hash` per snapshot to precompute GVS suffixes.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/licenses.rs[230-238]
- pnpm/crates/package-manager/src/virtual_store_layout.rs[158-236]
- pnpm/crates/package-manager/src/virtual_store_layout.rs[288-305]
- pnpm/crates/graph-hasher/src/engine_name.rs[41-68]

### Suggested fix approach
- Add a `VirtualStoreLayout` constructor/helper that computes slot paths lazily (or only for a provided set of `PackageKey`s) instead of precomputing for all snapshots.
- In `licenses`, build layout only after `belongs_to` is known, and restrict work to those keys.
- Ensure the engine detection path does not spawn `node` unless strictly required (e.g., only when GVS is enabled and there is no runtime major in lockfile/config).

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



Informational
4. Changeset missing pnpm bump 📘 Rule violation § Compliance
Description
The new changeset only declares a bump for pacquet and does not include a pnpm entry. This
violates the changeset requirement to explicitly declare a pnpm bump type.
Code

.changeset/pacquet-licenses-global-store.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Exact precedent: requests to add required pnpm entry to pacquet-only changesets were rejected.

PR-#12981
PR-#13117
PR-#13329

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each added/modified changeset to include an explicit pnpm entry
with a valid bump type; the added changeset front-matter lists only pacquet.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-licenses-global-store.md[1-3]

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

## Issue description
The changeset front-matter does not include a `pnpm` package entry with a valid bump type (`patch`/`minor`/`major`).

## Issue Context
Compliance requires changesets to explicitly declare `pnpm` and its bump type. This PR added `.changeset/pacquet-licenses-global-store.md` with only a `pacquet` entry.

## Fix Focus Areas
- .changeset/pacquet-licenses-global-store.md[1-3]

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


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 10767c9d7c7d

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.504 ± 0.162 2.363 2.784 1.65 ± 0.21
pacquet@main 2.517 ± 0.162 2.358 2.755 1.66 ± 0.21
pnpr@HEAD 1.516 ± 0.166 1.336 1.797 1.00
pnpr@main 1.546 ± 0.151 1.359 1.750 1.02 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5037570795999997,
      "stddev": 0.16175066746909236,
      "median": 2.4345607676,
      "user": 1.5519293600000001,
      "system": 1.3613769999999998,
      "min": 2.3630024856,
      "max": 2.7838076506,
      "times": [
        2.4625167196,
        2.3824667105999997,
        2.3630024856,
        2.4582517336,
        2.7838076506,
        2.7425805236,
        2.4108698016,
        2.3872209306,
        2.6625804376,
        2.3842738025999997
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5171662636999996,
      "stddev": 0.16218411909410962,
      "median": 2.4457087136,
      "user": 1.57250306,
      "system": 1.2928121999999997,
      "min": 2.3580382155999997,
      "max": 2.7546503176,
      "times": [
        2.4178369176,
        2.3984496076,
        2.7299841315999998,
        2.4735805096,
        2.7470441316,
        2.7546503176,
        2.4178053185999997,
        2.5016959366,
        2.3580382155999997,
        2.3725775506
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5158834560000003,
      "stddev": 0.16550243116366348,
      "median": 1.5161559316000002,
      "user": 1.05003526,
      "system": 1.1555191,
      "min": 1.3362075486,
      "max": 1.7971536496,
      "times": [
        1.3617875856000001,
        1.3362075486,
        1.4617542716,
        1.5864838286000003,
        1.7241073016000001,
        1.3497969366,
        1.5705575916,
        1.6031468406000002,
        1.3678390056,
        1.7971536496
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5461035089,
      "stddev": 0.15099943077624525,
      "median": 1.5715728461,
      "user": 1.07103906,
      "system": 1.1524743,
      "min": 1.3594475816000002,
      "max": 1.7502515656000002,
      "times": [
        1.3594475816000002,
        1.6536418116000002,
        1.4992796576,
        1.3693206566,
        1.6536683736000002,
        1.6438660346,
        1.7055419126,
        1.3838136706000002,
        1.4422038246000002,
        1.7502515656000002
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 260.3 ± 12.6 237.5 276.8 1.00
pacquet@main 265.2 ± 5.9 255.9 273.2 1.02 ± 0.05
pnpr@HEAD 277.0 ± 7.5 268.9 296.1 1.06 ± 0.06
pnpr@main 270.8 ± 7.6 257.9 280.8 1.04 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26026655150000005,
      "stddev": 0.012591531771898722,
      "median": 0.262486602,
      "user": 0.2119745,
      "system": 0.5181512799999999,
      "min": 0.23749512500000003,
      "max": 0.276759091,
      "times": [
        0.24532982500000003,
        0.23749512500000003,
        0.254312111,
        0.25355894,
        0.26558133700000003,
        0.271270162,
        0.272016148,
        0.259391867,
        0.266950909,
        0.276759091
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.2651988916,
      "stddev": 0.005901563355394447,
      "median": 0.26569984,
      "user": 0.22014539999999996,
      "system": 0.54485468,
      "min": 0.255922216,
      "max": 0.273182588,
      "times": [
        0.269044095,
        0.265882615,
        0.27048943,
        0.259554574,
        0.264735542,
        0.257330501,
        0.265517065,
        0.273182588,
        0.255922216,
        0.27033029000000003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2769636457,
      "stddev": 0.007541745451962469,
      "median": 0.27537072250000005,
      "user": 0.21951189999999995,
      "system": 0.54797128,
      "min": 0.26886645,
      "max": 0.296132637,
      "times": [
        0.280839143,
        0.26886645,
        0.274521031,
        0.274246572,
        0.276220414,
        0.274480784,
        0.276685962,
        0.27728445,
        0.296132637,
        0.270359014
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.27083982149999997,
      "stddev": 0.007640067878263735,
      "median": 0.27225239349999997,
      "user": 0.20856840000000001,
      "system": 0.53466558,
      "min": 0.257933077,
      "max": 0.280770833,
      "times": [
        0.266419226,
        0.261960089,
        0.257933077,
        0.265183707,
        0.280770833,
        0.273077639,
        0.271427148,
        0.276452042,
        0.276628325,
        0.278546129
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.789 ± 0.021 2.764 2.819 1.80 ± 0.18
pacquet@main 2.791 ± 0.026 2.751 2.835 1.80 ± 0.18
pnpr@HEAD 1.547 ± 0.150 1.419 1.809 1.00
pnpr@main 1.568 ± 0.110 1.427 1.741 1.01 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7886523965200003,
      "stddev": 0.02052404101239454,
      "median": 2.78782925742,
      "user": 1.7278105599999996,
      "system": 1.34279482,
      "min": 2.76364497242,
      "max": 2.81910421042,
      "times": [
        2.79665107742,
        2.76364497242,
        2.77900743742,
        2.80700043742,
        2.8064007484199998,
        2.81910421042,
        2.80632363342,
        2.76653057042,
        2.77092853542,
        2.77093234242
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.7912848529199996,
      "stddev": 0.026218887225117747,
      "median": 2.7888470969199997,
      "user": 1.6971424599999998,
      "system": 1.35501072,
      "min": 2.7507650674199997,
      "max": 2.83495775142,
      "times": [
        2.80632332342,
        2.77639485142,
        2.78603533042,
        2.81624112442,
        2.75689890742,
        2.7507650674199997,
        2.80896002442,
        2.78461328542,
        2.79165886342,
        2.83495775142
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.54669155202,
      "stddev": 0.14980336009525877,
      "median": 1.49648102392,
      "user": 1.05045006,
      "system": 1.1152960200000002,
      "min": 1.41854585342,
      "max": 1.80933038142,
      "times": [
        1.80869275142,
        1.52664743942,
        1.47003558842,
        1.60582839342,
        1.44262160242,
        1.5229264594199998,
        1.41854585342,
        1.42608285142,
        1.80933038142,
        1.4362041994199999
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5683164347199998,
      "stddev": 0.11037263746112037,
      "median": 1.56782319292,
      "user": 1.0550811599999999,
      "system": 1.16572232,
      "min": 1.42693870142,
      "max": 1.74051492442,
      "times": [
        1.55011215742,
        1.43345707342,
        1.45642223242,
        1.42693870142,
        1.67958402142,
        1.5855342284199998,
        1.74051492442,
        1.5210948634199999,
        1.61034080142,
        1.6791653434199998
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 596.5 ± 9.5 580.7 611.1 1.95 ± 0.06
pacquet@main 593.2 ± 6.9 580.7 602.1 1.94 ± 0.06
pnpr@HEAD 307.0 ± 6.9 296.9 317.3 1.01 ± 0.03
pnpr@main 305.2 ± 8.0 290.8 316.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5965206474200001,
      "stddev": 0.00946838986488232,
      "median": 0.59466033642,
      "user": 0.7464535399999999,
      "system": 0.6593705199999998,
      "min": 0.58072555292,
      "max": 0.6111324909200001,
      "times": [
        0.59406051792,
        0.5952601549200001,
        0.58072555292,
        0.6111324909200001,
        0.58794197792,
        0.60360910992,
        0.5898567509200001,
        0.60466074692,
        0.59228554992,
        0.6056736219200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5932258206200001,
      "stddev": 0.006910657722285607,
      "median": 0.5953532539200002,
      "user": 0.7179494399999999,
      "system": 0.6937750199999999,
      "min": 0.58072034392,
      "max": 0.60208711692,
      "times": [
        0.5972478629200001,
        0.58072034392,
        0.58435376892,
        0.5967998309200001,
        0.5904797219200001,
        0.5955191109200001,
        0.5892405409200001,
        0.5951873969200001,
        0.60062251192,
        0.60208711692
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30700184012000004,
      "stddev": 0.006943634433493469,
      "median": 0.30805582742000004,
      "user": 0.20040863999999997,
      "system": 0.52719272,
      "min": 0.29689777892,
      "max": 0.31732432292000007,
      "times": [
        0.30718121192000003,
        0.31196019192,
        0.31732432292000007,
        0.30893044292000005,
        0.30600202492000006,
        0.31101480392,
        0.29689777892,
        0.29933431192000004,
        0.29801886692000007,
        0.31335444492000003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30520573752,
      "stddev": 0.008021216077654714,
      "median": 0.30402838142000005,
      "user": 0.20951364,
      "system": 0.5349475199999999,
      "min": 0.29083055592000007,
      "max": 0.31639979392000006,
      "times": [
        0.29083055592000007,
        0.29780603692,
        0.30136174592000003,
        0.30187448992000004,
        0.31446008492000005,
        0.30246389892000003,
        0.30559286392000007,
        0.30796600892000003,
        0.31639979392000006,
        0.31330189592
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.928 ± 0.006 1.920 1.938 6.23 ± 0.13
pacquet@main 1.922 ± 0.009 1.910 1.939 6.21 ± 0.13
pnpr@HEAD 0.310 ± 0.007 0.295 0.320 1.00 ± 0.03
pnpr@main 0.310 ± 0.006 0.302 0.320 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9283157685399999,
      "stddev": 0.0064959067192377085,
      "median": 1.92676279954,
      "user": 0.95552324,
      "system": 0.7775576199999998,
      "min": 1.9203658860400001,
      "max": 1.93792154004,
      "times": [
        1.93152888504,
        1.93792154004,
        1.93295076904,
        1.92328405504,
        1.9203658860400001,
        1.9377742930400002,
        1.92300802604,
        1.92409107404,
        1.92943452504,
        1.92279863204
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9215866898400003,
      "stddev": 0.009346817120361502,
      "median": 1.92412601704,
      "user": 0.9757363400000001,
      "system": 0.74124382,
      "min": 1.91002653504,
      "max": 1.93935196004,
      "times": [
        1.92344491004,
        1.93935196004,
        1.92545673704,
        1.92736118104,
        1.91002653504,
        1.9148882150400002,
        1.92720908504,
        1.91084132804,
        1.9124798230400002,
        1.9248071240400002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31027923334,
      "stddev": 0.007435488764577033,
      "median": 0.31176884004000005,
      "user": 0.20825613999999998,
      "system": 0.5394967199999999,
      "min": 0.29481991404,
      "max": 0.32047513204,
      "times": [
        0.31236216204,
        0.32047513204,
        0.30671975104,
        0.29481991404,
        0.30502946004,
        0.31368963104,
        0.31933558704,
        0.31189386004,
        0.30682301604,
        0.31164382004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30965476774,
      "stddev": 0.0064796584691185835,
      "median": 0.30783721504,
      "user": 0.20106014,
      "system": 0.5500752200000001,
      "min": 0.30237106604,
      "max": 0.32021363904,
      "times": [
        0.30588862704,
        0.31709672404,
        0.30978580304,
        0.31732989104,
        0.32021363904,
        0.30405909404,
        0.30532333304,
        0.30237106604,
        0.30384100304,
        0.31063849704
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 350.3 ± 6.9 339.0 365.5 4.07 ± 0.13
pacquet@main 357.2 ± 10.1 342.3 373.3 4.15 ± 0.16
pnpr@HEAD 86.0 ± 2.1 81.7 89.4 1.00
pnpr@main 86.1 ± 2.1 82.4 90.3 1.00 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.3502825532,
      "stddev": 0.006856184747088219,
      "median": 0.3491661394,
      "user": 0.33723143999999994,
      "system": 0.059706440000000006,
      "min": 0.3390478149,
      "max": 0.3654694439,
      "times": [
        0.35113494390000005,
        0.3390478149,
        0.35551665190000004,
        0.3463533449,
        0.3654694439,
        0.34630496390000004,
        0.3493365599,
        0.34899571890000003,
        0.3488725259,
        0.35179356390000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.3572142817,
      "stddev": 0.010137804831932013,
      "median": 0.3559406894,
      "user": 0.34738894,
      "system": 0.057106939999999995,
      "min": 0.3423328379,
      "max": 0.3732825999,
      "times": [
        0.3423328379,
        0.36593795590000006,
        0.3668888659,
        0.35368075590000003,
        0.3641669329,
        0.3732825999,
        0.3479510509,
        0.3554670379,
        0.3564143409,
        0.3460204389
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08600071601764707,
      "stddev": 0.0021137702249662783,
      "median": 0.08619738390000001,
      "user": 0.019700604705882353,
      "system": 0.009306494705882353,
      "min": 0.0817203929,
      "max": 0.0893922939,
      "times": [
        0.0839741949,
        0.0886476199,
        0.0883504709,
        0.0875354579,
        0.0887041769,
        0.0848649319,
        0.0859214599,
        0.0837505939,
        0.0870014219,
        0.0824239179,
        0.0840215139,
        0.0854259679,
        0.0836495029,
        0.0864341149,
        0.0886965729,
        0.0855863499,
        0.0817203929,
        0.0840281469,
        0.0893922939,
        0.0847177239,
        0.0848002399,
        0.0875902099,
        0.0881969929,
        0.0862948119,
        0.0853634499,
        0.0829689729,
        0.0880124449,
        0.0861361539,
        0.0870726159,
        0.0825103589,
        0.0874781799,
        0.0883271469,
        0.0881673269,
        0.0862586139
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08612818883939391,
      "stddev": 0.002126729077025047,
      "median": 0.0864875549,
      "user": 0.019236264242424243,
      "system": 0.009979779999999999,
      "min": 0.0823686719,
      "max": 0.0902530629,
      "times": [
        0.0853958909,
        0.0900738649,
        0.0872234509,
        0.0874463299,
        0.0851945709,
        0.0898616159,
        0.0855364549,
        0.0866389499,
        0.0865995859,
        0.0829323939,
        0.0883068199,
        0.0860508429,
        0.0841637319,
        0.0871515549,
        0.0864875549,
        0.0867996129,
        0.0834041619,
        0.0863090889,
        0.0824572799,
        0.0871083829,
        0.0833687459,
        0.0861387689,
        0.0823686719,
        0.0838554719,
        0.0867135399,
        0.0902530629,
        0.0853951589,
        0.0885674699,
        0.0844055169,
        0.0833424749,
        0.0876082849,
        0.0877240229,
        0.0873469029
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.580 ± 0.120 4.432 4.793 1.30 ± 0.05
pacquet@main 4.576 ± 0.148 4.455 4.828 1.30 ± 0.05
pnpr@HEAD 3.546 ± 0.126 3.455 3.858 1.01 ± 0.05
pnpr@main 3.524 ± 0.096 3.438 3.730 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.579886713740001,
      "stddev": 0.12044617969488146,
      "median": 4.59795060324,
      "user": 1.7465573399999996,
      "system": 1.39787204,
      "min": 4.4323981872400005,
      "max": 4.79254090424,
      "times": [
        4.46066382724,
        4.79254090424,
        4.4323981872400005,
        4.43698875724,
        4.61067710624,
        4.52085822424,
        4.59273321324,
        4.61990063724,
        4.6031679932400005,
        4.72893828724
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.57618700004,
      "stddev": 0.1482301575770507,
      "median": 4.50222434674,
      "user": 1.7336400399999998,
      "system": 1.4172434399999998,
      "min": 4.4552810242400005,
      "max": 4.82781346124,
      "times": [
        4.50780733024,
        4.82781346124,
        4.46982623424,
        4.75326189024,
        4.47068103124,
        4.77680319624,
        4.54501549324,
        4.4552810242400005,
        4.49664136324,
        4.45873897624
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5455885901400004,
      "stddev": 0.1258498715596225,
      "median": 3.49920172724,
      "user": 1.1606484399999997,
      "system": 1.2446861399999996,
      "min": 3.45477212524,
      "max": 3.85756749524,
      "times": [
        3.49397457824,
        3.4702082402400003,
        3.56824320524,
        3.45477212524,
        3.50442887624,
        3.52565808224,
        3.85756749524,
        3.4552094872400003,
        3.47005210524,
        3.6557717062400004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.52432794014,
      "stddev": 0.09606019086294845,
      "median": 3.47991131624,
      "user": 1.19072834,
      "system": 1.2190098399999996,
      "min": 3.4379658282400003,
      "max": 3.73004106024,
      "times": [
        3.55183980224,
        3.56245132524,
        3.63604583624,
        3.47119427424,
        3.73004106024,
        3.45278626924,
        3.4621578952400003,
        3.4379658282400003,
        3.45016875224,
        3.48862835824
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13347
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
2,763.64 ms
(-0.59%)Baseline: 2,780.06 ms
3,336.07 ms
(82.84%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,920.37 ms
(-1.67%)Baseline: 1,952.92 ms
2,343.50 ms
(81.94%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
580.73 ms
(-7.85%)Baseline: 630.20 ms
756.24 ms
(76.79%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
339.05 ms
(-11.68%)Baseline: 383.89 ms
460.67 ms
(73.60%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,363.00 ms
(-1.12%)Baseline: 2,389.78 ms
2,867.74 ms
(82.40%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,432.40 ms
(-1.14%)Baseline: 4,483.29 ms
5,379.95 ms
(82.39%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
237.50 ms
(-9.75%)Baseline: 263.14 ms
315.77 ms
(75.21%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13347
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
1,418.55 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
294.82 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
296.90 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
81.72 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,336.21 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,454.77 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
268.87 ms
🐰 View full continuous benchmarking report in Bencher

Copilot AI review requested due to automatic review settings July 25, 2026 14:22

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 487d7bf

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 5e67dfb into main Jul 25, 2026
37 checks passed
@zkochan
zkochan deleted the fix-pacquet-licenses branch July 25, 2026 14:45
zkochan added a commit that referenced this pull request Jul 26, 2026
…check`

pnpm 12 rejected `pnpm peers check` — the spelling pnpm.io documents and
pnpm's own dedupe output recommends — as an unexpected argument, and its
`dedupe --check` failed with a bare "Lockfile would be modified by
deduplication": no diff, no error code, no peer-dependency warning.

`peers` now takes an optional subcommand: `check` (or nothing) runs the
check, anything else prints the command's help and exits 1, mirroring the
TypeScript handler.

`dedupe --check` now renders what deduplication would rewrite, under pnpm's
`ERR_PNPM_DEDUPE_CHECK_ISSUES`. The report reuses the lockfile diff behind
`install --dry-run`, which grew per-alias detail for updated `snapshots:`
entries and a key selector: `--dry-run` keeps comparing importers by
manifest specifier, while `--check` compares them by resolved version,
because deduplication rewrites peer-resolved versions without touching
specifiers. Rendering goes through the archy tree renderer `list` and `why`
already share, so the output matches pnpm's `renderDedupeCheckIssues`. A
snapshot that no longer parses (an older lockfile format the run has just
rewritten) degrades to no baseline rather than replacing the verdict with a
parse error, and a text-only rewrite — drifted settings, a config
dependency the run synced — says so instead of printing an empty report.

Dedupe also emits pnpm's `Issues with peer dependencies found. Run "pnpm
peers check" to list them.` warning. It is derived from the deduplicated
lockfile through the same checker and `peerDependencyRules` filtering the
`peers` command uses, so the warning and the command it recommends always
agree, and it is gated like pnpm's install-time one: a bad peer, or a
missing peer at least one parent requires non-optionally. `pnpm install`
still does not warn — unlike dedupe it can finish without resolving, so
that warning has to come from the resolver rather than a lockfile walk.

The `licenses list` half of the issue was already fixed on main by
#13347.

TypeScript CLI: no counterpart change — pnpm 11 already behaves this way.

Closes #13321
zkochan added a commit that referenced this pull request Jul 26, 2026
…check` (#13395)

pnpm 12 rejected `pnpm peers check` — the spelling pnpm.io documents and
pnpm's own dedupe output recommends — as an unexpected argument, and its
`dedupe --check` failed with a bare "Lockfile would be modified by
deduplication": no diff, no error code, no peer-dependency warning.

`peers` now takes an optional subcommand: `check` (or nothing) runs the
check, anything else prints the command's help and exits 1, mirroring the
TypeScript handler.

`dedupe --check` now renders what deduplication would rewrite, under pnpm's
`ERR_PNPM_DEDUPE_CHECK_ISSUES`. The report reuses the lockfile diff behind
`install --dry-run`, which grew per-alias detail for updated `snapshots:`
entries and a key selector: `--dry-run` keeps comparing importers by
manifest specifier, while `--check` compares them by resolved version,
because deduplication rewrites peer-resolved versions without touching
specifiers. Rendering goes through the archy tree renderer `list` and `why`
already share, so the output matches pnpm's `renderDedupeCheckIssues`. A
snapshot that no longer parses (an older lockfile format the run has just
rewritten) degrades to no baseline rather than replacing the verdict with a
parse error, and a text-only rewrite — drifted settings, a config
dependency the run synced — says so instead of printing an empty report.

Dedupe also emits pnpm's `Issues with peer dependencies found. Run "pnpm
peers check" to list them.` warning. It is derived from the deduplicated
lockfile through the same checker and `peerDependencyRules` filtering the
`peers` command uses, so the warning and the command it recommends always
agree, and it is gated like pnpm's install-time one: a bad peer, or a
missing peer at least one parent requires non-optionally. `pnpm install`
still does not warn — unlike dedupe it can finish without resolving, so
that warning has to come from the resolver rather than a lockfile walk.

The `licenses list` half of the issue was already fixed on main by
#13347.

TypeScript CLI: no counterpart change — pnpm 11 already behaves this way.

Closes #13321
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
Pacquet parsed license options directly after `pnpm licenses`, so the documented `list` and `ls` subcommands were rejected. Accept those subcommands and report the same missing/unknown-subcommand error codes as the TypeScript CLI.

License discovery also reconstructed the legacy flat virtual-store path. Route it through the shared virtual-store layout instead, preserving lockfile pins and the effective project-selected Node runtime before falling back to the host, and validate package-name components plus slot containment before reading package manifests. This allows license metadata and reported paths to resolve correctly from hashed global virtual-store slots.

Fixes pnpm#13332.
Fixes pnpm#13333.
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…check` (pnpm#13395)

pnpm 12 rejected `pnpm peers check` — the spelling pnpm.io documents and
pnpm's own dedupe output recommends — as an unexpected argument, and its
`dedupe --check` failed with a bare "Lockfile would be modified by
deduplication": no diff, no error code, no peer-dependency warning.

`peers` now takes an optional subcommand: `check` (or nothing) runs the
check, anything else prints the command's help and exits 1, mirroring the
TypeScript handler.

`dedupe --check` now renders what deduplication would rewrite, under pnpm's
`ERR_PNPM_DEDUPE_CHECK_ISSUES`. The report reuses the lockfile diff behind
`install --dry-run`, which grew per-alias detail for updated `snapshots:`
entries and a key selector: `--dry-run` keeps comparing importers by
manifest specifier, while `--check` compares them by resolved version,
because deduplication rewrites peer-resolved versions without touching
specifiers. Rendering goes through the archy tree renderer `list` and `why`
already share, so the output matches pnpm's `renderDedupeCheckIssues`. A
snapshot that no longer parses (an older lockfile format the run has just
rewritten) degrades to no baseline rather than replacing the verdict with a
parse error, and a text-only rewrite — drifted settings, a config
dependency the run synced — says so instead of printing an empty report.

Dedupe also emits pnpm's `Issues with peer dependencies found. Run "pnpm
peers check" to list them.` warning. It is derived from the deduplicated
lockfile through the same checker and `peerDependencyRules` filtering the
`peers` command uses, so the warning and the command it recommends always
agree, and it is gated like pnpm's install-time one: a bad peer, or a
missing peer at least one parent requires non-optionally. `pnpm install`
still does not warn — unlike dedupe it can finish without resolving, so
that warning has to come from the resolver rather than a lockfile walk.

The `licenses list` half of the issue was already fixed on main by
pnpm#13347.

TypeScript CLI: no counterpart change — pnpm 11 already behaves this way.

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet: licenses reports every dependency as Unknown pacquet: support the documented pnpm licenses list syntax

3 participants