Skip to content

feat(update): support --workspace in pacquet and honor --depth per dependency - #13288

Merged
zkochan merged 5 commits into
mainfrom
fix-12101
Jul 25, 2026
Merged

zkochan merged 5 commits into
mainfrom
fix-12101

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Two of the gaps tracked in #12101 — pacquet's pnpm update --workspace and per-dependency --depth — plus the two TypeScript --workspace bugs that stood in the way of making the stacks agree.

--workspace (pacquet). A workspace-link update rewrites each matched direct dependency to a workspace: specifier before the install resolves it, so the existing workspace: resolver produces the link and its errors (ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE and friends). Which dependencies are matched follows the TypeScript CLI: with no selectors, every direct dependency (minus updateConfig.ignoreDependencies) that a workspace project publishes; with selectors, the direct dependencies they match, where naming one the workspace does not publish fails with ERR_PNPM_WORKSPACE_PACKAGE_NOT_FOUND. --latest and running outside a workspace are rejected up front with the same codes the TypeScript CLI uses.

The written specifier reproduces calcSpecifierForWorkspaceDep: under saveWorkspaceProtocol: 'rolling' (the default) the declared range operator is written alone (workspace:* / ^ / ~), otherwise the linked version is written under that operator. saveWorkspaceProtocol therefore joins pacquet's config and leaves the not-ported list in pnpm_default_parity.

--depth (pacquet). The flag was only consulted as a > 0 predicate gating the name matcher, so a compatible bump always behaved as depth = Infinity. UpdateDepth now travels with the seed policy into the resolver and gates reuse per node, matching pnpm's currentDepth <= updateDepth: a node past the ceiling keeps its locked resolution even when its name is an update target.

--workspace fixes (TypeScript). Two cases linked dependencies the user never named. Both come from params being rewritten into the matched dependency names before the workspace block reads it, so the block could no longer tell "the user named nothing" from "the user's selectors matched nothing":

  • With updateConfig.ignoreDependencies set, params becomes the non-ignored dependency names, and createWorkspaceSpecs then threw ERR_PNPM_WORKSPACE_PACKAGE_NOT_FOUND for the project's ordinary registry dependencies — so pnpm update --workspace could not be run at all in a workspace that ignores any dependency.
  • Selectors that matched no direct dependency left params empty, which read as "no selectors given" and answered by linking every workspace dependency.

Both now key off whether the user named any package.

Related to #12101 — --global, the recursive sibling-manifest rewrite, and full interactive parity are still open there.

Squash Commit Body

Two of the gaps tracked in pnpm/pnpm#12101.

`--workspace` (pacquet): a workspace-link update rewrites each matched direct
dependency to a `workspace:` specifier before the install resolves it, so the
existing `workspace:` resolver produces the link and its errors. Which
dependencies are matched follows the TypeScript CLI exactly: with no selectors,
every direct dependency (minus `updateConfig.ignoreDependencies`) that a
workspace project publishes; with selectors, the direct dependencies they
match, where naming one the workspace does not publish fails with
ERR_PNPM_WORKSPACE_PACKAGE_NOT_FOUND. `--latest` and running outside a
workspace are rejected up front with the same codes the TypeScript CLI uses.
Selecting nothing to link is not an error: the run falls through to the
ordinary update branches.

The written specifier reproduces `calcSpecifierForWorkspaceDep`:
`saveWorkspaceProtocol: 'rolling'` (the default) writes the declared range
operator alone, so a sibling's next release does not invalidate the entry;
otherwise the linked version is written under that operator. This adds
`saveWorkspaceProtocol` to pacquet's config, which is why it leaves the
not-ported list in `pnpm_default_parity`. The workspace-packages map the
resolver already builds is reused as the source of link targets.

`--depth` (pacquet): the flag was only consulted as a `> 0` predicate gating
the name matcher, so a compatible bump always behaved as `depth = Infinity`.
`UpdateDepth` now travels with the seed policy into the resolver and gates
reuse per node, matching pnpm's `currentDepth <= updateDepth`. The
subtree-reuse memo is keyed by depth bucket, collapsed to a single bucket for
an unlimited update and to `max_depth + 1` beyond the ceiling, so the common
case costs nothing.

`--workspace` fixes (TypeScript): two cases linked dependencies the user never
named, which pacquet would otherwise have had to reproduce. Both come from
`params` being rewritten into the matched dependency names before the workspace
block reads it, so the block could not tell "the user named nothing" from "the
user's selectors matched nothing". With `updateConfig.ignoreDependencies` set,
`createWorkspaceSpecs` threw ERR_PNPM_WORKSPACE_PACKAGE_NOT_FOUND for the
project's ordinary registry dependencies; those are now skipped, as they
already were when nothing was ignored. Selectors that matched no direct
dependency left `params` empty, which the workspace block answered by linking
every workspace dependency. Both now key off whether the user named any
package.

Related to pnpm/pnpm#12101.

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 (Claude Code, claude-opus-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

  • New Features
    • Added save-workspace-protocol (off/on/rolling) support and honored it from workspace configuration.
  • Bug Fixes
    • Refined pnpm update --workspace to link only explicitly targeted workspace deps, preserve non-targeted registry specs, avoid errors when dependencies are ignored, and handle unmatched selectors without modifying package.json.
    • Improved validation for --workspace usage (including rejecting --workspace with --latest) and clearer missing-workspace errors.
    • Refined pnpm update --depth so depth limits apply per dependency, with correct --depth 0 behavior.
  • Tests
    • Expanded coverage for --workspace and --depth 0, including new negative cases.

Copilot AI review requested due to automatic review settings July 25, 2026 00:27

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: 51b61edc-0ccc-40ec-9e4f-6d9ab8907743

📥 Commits

Reviewing files that changed from the base of the PR and between 68452bb and 0fb200d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (30)
  • .changeset/pacquet-update-workspace-and-depth.md
  • .changeset/update-workspace-only-links-named-deps.md
  • pnpm/crates/cli/src/cli_args/audit.rs
  • pnpm/crates/cli/src/cli_args/dedupe.rs
  • pnpm/crates/cli/src/cli_args/import.rs
  • pnpm/crates/cli/src/cli_args/update.rs
  • pnpm/crates/cli/src/cli_args/update/tests.rs
  • pnpm/crates/cli/tests/update.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/config/src/pnpm_default_parity.rs
  • pnpm/crates/config/src/workspace_yaml.rs
  • pnpm/crates/napi/src/install.rs
  • pnpm/crates/package-manager/Cargo.toml
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install/tests.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile/tests.rs
  • pnpm/crates/package-manager/src/update.rs
  • pnpm/crates/package-manager/src/update/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/lib.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm11/installing/commands/src/installDeps.ts
  • pnpm11/installing/commands/src/recursive.ts
  • pnpm11/installing/commands/src/updateWorkspaceDependencies.ts
  • pnpm11/installing/commands/test/update/update.ts
  • pnpm11/installing/commands/test/updateWorkspaceDependencies.test.ts
🚧 Files skipped from review as they are similar to previous changes (27)
  • pnpm/crates/package-manager/Cargo.toml
  • .changeset/update-workspace-only-links-named-deps.md
  • pnpm/crates/cli/src/cli_args/audit.rs
  • pnpm/crates/cli/src/cli_args/dedupe.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile/tests.rs
  • .changeset/pacquet-update-workspace-and-depth.md
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/lib.rs
  • pnpm/crates/cli/src/cli_args/import.rs
  • pnpm/crates/cli/src/cli_args/update/tests.rs
  • pnpm/crates/napi/src/install.rs
  • pnpm/crates/package-manager/src/install/tests.rs
  • pnpm11/installing/commands/test/update/update.ts
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm11/installing/commands/src/recursive.ts
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/package-manager/src/update/tests.rs
  • pnpm11/installing/commands/src/installDeps.ts
  • pnpm/crates/config/src/workspace_yaml.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/config/src/pnpm_default_parity.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs
  • pnpm11/installing/commands/src/updateWorkspaceDependencies.ts
  • pnpm/crates/cli/tests/update.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpm/crates/package-manager/src/update.rs

📝 Walkthrough

Walkthrough

Adds pnpm update --workspace linking with workspace protocol configuration, centralizes workspace option validation, and propagates update depth through dependency resolution. Named selector handling avoids unintended workspace links and preserves registry dependencies.

Changes

Workspace-aware update flow

Layer / File(s) Summary
Workspace protocol configuration
pnpm/crates/config/..., pnpm/crates/package-manager/src/install_package_from_registry/tests.rs, .changeset/...
Adds tri-state saveWorkspaceProtocol configuration, workspace YAML propagation, default parity coverage, and release notes.
Depth-aware dependency resolution
pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs, pnpm/crates/resolving-deps-resolver/..., pnpm/crates/cli/tests/update.rs
Threads update-depth limits through seed policies, resolver reuse decisions, workspace options, and regression tests.
Rust workspace update flow
pnpm/crates/cli/src/cli_args/update.rs, pnpm/crates/package-manager/src/update.rs, pnpm/crates/cli/tests/update.rs
Validates workspace options, builds workspace package maps, rewrites eligible dependencies, and reports missing workspace packages.
Named workspace selector handling
pnpm11/installing/commands/src/..., pnpm11/installing/commands/test/...
Restricts linking to requested dependencies and skips non-workspace selectors when configured, with update coverage.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#13171 — Overlaps in selected update execution and package-manager update plumbing.
  • pnpm/pnpm#13234 — Overlaps in update preparation and workspace-related context propagation.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: yeshyungseok, qodo-code-review

✨ 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-12101

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Support pacquet pnpm update --workspace and apply --depth per dependency

✨ Enhancement 🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Add pacquet update --workspace to rewrite eligible direct deps to workspace: specifiers.
• Honor --depth as a per-node update ceiling, keeping deeper nodes locked.
• Fix TypeScript --workspace to only link user-named deps and avoid false errors.
Diagram

graph TD
A["Rust CLI: update args"] --> B["Workspace discovery"] --> C["pacquet Update prep"] --> E["Deps resolver"] --> F[("Manifest + lockfile")]
C --> D["workspace: spec rewrite"] --> F
G["TS update --workspace"] --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Resolver-native workspace linking (no manifest rewrite)
  • ➕ Avoids mutating package.json before resolution (fewer side effects if update fails).
  • ➕ Keeps workspace linking decisions closer to resolution logic.
  • ➖ Harder to match pnpm/TS CLI semantics that intentionally persist workspace: specs.
  • ➖ Requires deeper resolver API changes and new persistence logic anyway.
2. Apply `--depth` only to initial target selection (status quo)
  • ➕ Smaller change set; no resolver memoization changes.
  • ➖ Incorrect behavior: transitive nodes still re-resolve for targeted names beyond the depth ceiling.
  • ➖ Diverges from pnpm semantics (currentDepth &lt;= updateDepth).
3. Separate command mode for workspace linking (new subcommand/flag)
  • ➕ Avoids overloading update semantics and reduces flag interactions (e.g. --latest).
  • ➖ Breaks parity with pnpm CLI and user expectations; additional surface area to maintain.

Recommendation: Keep the PR’s approach: rewriting matched direct deps to workspace: leverages existing workspace protocol resolution and produces pnpm-compatible persisted specs. Carrying UpdateDepth into the resolver is the right fix for correct per-node reuse decisions and matches pnpm’s depth semantics. The early CLI validation for --workspace combinations (outside workspace, --latest) is also preferable for predictable errors and faster failures.

Files changed (31) +915 / -125

Enhancement (2) +246 / -38
update.rsImplement '--workspace' validation and workspace package indexing +51/-21

Implement '--workspace' validation and workspace package indexing

• Replaces the previous blanket '--workspace' rejection with structured diagnostics and early validation. When enabled inside a workspace, discovers projects and builds the workspace packages map, threading it into 'pacquet_package_manager::Update'.

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

update.rsImplement pacquet 'update --workspace' and correct depth semantics +195/-17

Implement pacquet 'update --workspace' and correct depth semantics

• Adds workspace linking mode that rewrites matched direct deps to 'workspace:' specifiers (honoring 'saveWorkspaceProtocol') and ensures '--depth' limits which nodes are treated as update targets during resolution/reuse.

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

Bug fix (6) +197 / -48
install_with_fresh_lockfile.rsCarry UpdateDepth inside UpdateSeedPolicy and into resolver options +46/-12

Carry UpdateDepth inside UpdateSeedPolicy and into resolver options

• Refactors UpdateSeedPolicy variants to include a 'max_depth: UpdateDepth', adds helpers ('drop_all()', 'max_depth()'), and threads update depth into workspace resolution options so reuse decisions are depth-aware.

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

resolve_dependency_tree.rsMake reuse/update-target decisions depth-aware via UpdateDepth +91/-22

Make reuse/update-target decisions depth-aware via UpdateDepth

• Introduces UpdateDepth and applies it to update-target detection and subtree reuse memoization, ensuring nodes past the ceiling keep locked resolutions even if names match update targets.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs

resolve_workspace.rsThread UpdateDepth through workspace resolve options +7/-1

Thread UpdateDepth through workspace resolve options

• Extends WorkspaceResolveOptions and WorkspaceTreeCtx wiring to carry update depth into the resolver for workspace-level resolution.

pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs

installDeps.tsFix '--workspace' to respect whether user named selectors +11/-2

Fix '--workspace' to respect whether user named selectors

• Captures whether the user provided params before they are rewritten, and uses that to avoid linking everything when selectors match nothing and to avoid misclassifying registry deps as missing workspace packages.

pnpm11/installing/commands/src/installDeps.ts

recursive.tsApply same '--workspace' selector intent fix in recursive update +12/-4

Apply same '--workspace' selector intent fix in recursive update

• Mirrors the installDeps change for recursive flows by preserving user selector intent across per-project param rewriting and passing the appropriate workspace-spec creation options.

pnpm11/installing/commands/src/recursive.ts

updateWorkspaceDependencies.tsAllow createWorkspaceSpecs to skip non-workspace packages when appropriate +30/-7

Allow createWorkspaceSpecs to skip non-workspace packages when appropriate

• Extends 'createWorkspaceSpecs' with 'skipPackagesOutsideWorkspace' to support manifest-derived selector lists (e.g., after ignoreDependencies filtering) without throwing workspace-not-found errors for registry-only deps.

pnpm11/installing/commands/src/updateWorkspaceDependencies.ts

Refactor (6) +13 / -6
audit.rsPass workspace_packages through audit fix-with-update path +1/-0

Pass workspace_packages through audit fix-with-update path

• Extends the audit 'fix_with_update' options to include 'workspace_packages: None', keeping the Update API callsites consistent after adding the new field.

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

dedupe.rsUse 'UpdateSeedPolicy::drop_all()' helper +1/-1

Use 'UpdateSeedPolicy::drop_all()' helper

• Replaces direct enum construction with the new 'drop_all()' helper, aligning dedupe with the updated seed policy shape that now carries depth.

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

import.rsUse 'UpdateSeedPolicy::drop_all()' helper +1/-1

Use 'UpdateSeedPolicy::drop_all()' helper

• Updates import to use the new seed policy constructor, ensuring depth defaults are correctly applied for commands without '--depth'.

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

install.rsAlign napi install update seed policy with new API +2/-2

Align napi install update seed policy with new API

• Updates the napi install binding to use 'UpdateSeedPolicy::drop_all()' when 'update: true', reflecting the seed policy’s new depth-carrying structure.

pnpm/crates/napi/src/install.rs

install.rsExport 'build_workspace_packages_map' for CLI consumption +7/-1

Export 'build_workspace_packages_map' for CLI consumption

• Documents and makes 'build_workspace_packages_map' public so the CLI can build the workspace publish index and pass it into update operations.

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

lib.rsRe-export UpdateDepth from resolver crate +1/-1

Re-export UpdateDepth from resolver crate

• Exports the new UpdateDepth type so callers (package-manager/workspace resolver) can thread depth ceilings into resolution.

pnpm/crates/resolving-deps-resolver/src/lib.rs

Tests (10) +349 / -30
tests.rsUnit tests for '--workspace' preflight validation +24/-0

Unit tests for '--workspace' preflight validation

• Adds tests ensuring '--workspace' is validated before resolution, including correct errors for outside-workspace usage and '--workspace' + '--latest'.

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

update.rsE2E tests for '--workspace' linking and true depth=0 behavior +187/-18

E2E tests for '--workspace' linking and true depth=0 behavior

• Adds a workspace helper for creating sibling packages and introduces new end-to-end assertions for 'update --workspace' spec rewriting, error cases, and '--depth 0' keeping transitives locked.

pnpm/crates/cli/tests/update.rs

tests.rsUpdate tests for new UpdateSeedPolicy constructor +1/-1

Update tests for new UpdateSeedPolicy constructor

• Adjusts install tests to construct update seed policy via 'drop_all()' after the enum’s shape change.

pnpm/crates/package-manager/src/install/tests.rs

tests.rsInitialize new config field in test config builder +1/-0

Initialize new config field in test config builder

• Extends test config creation to include 'save_workspace_protocol: Default::default()' to satisfy the expanded Config struct.

pnpm/crates/package-manager/src/install_package_from_registry/tests.rs

tests.rsUpdate reuse-scope tests for new ByImporter shape +7/-4

Update reuse-scope tests for new ByImporter shape

• Adapts tests to build 'UpdateSeedPolicy::ByImporter { policies, max_depth }' explicitly, preserving previous behavior with unlimited depth.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/tests.rs

tests.rsUpdate helper callsites for new workspace_packages param +6/-0

Update helper callsites for new workspace_packages param

• Updates update tests to pass 'workspace_packages: None' into preparation helpers after expanding the Update API surface.

pnpm/crates/package-manager/src/update/tests.rs

tests.rsAdd tests for UpdateDepth behavior in target selection +55/-7

Add tests for UpdateDepth behavior in target selection

• Extends unit tests to validate depth=0 direct-only targeting, finite depth ceilings, and 'usize::MAX' behaving as unlimited.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs

tests.rsSet default UpdateDepth in workspace resolver tests +1/-0

Set default UpdateDepth in workspace resolver tests

• Updates test helper options to include 'update_depth: UNLIMITED' after expanding the options struct.

pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs

update.tsAdd regression tests for '--workspace' ignore/selectors edge cases +62/-0

Add regression tests for '--workspace' ignore/selectors edge cases

• Adds tests verifying registry dependencies remain unchanged when some deps are ignored and that unmatched selectors do not fall back to linking all workspace dependencies.

pnpm11/installing/commands/test/update/update.ts

updateWorkspaceDependencies.test.tsTest createWorkspaceSpecs skipping behavior +5/-0

Test createWorkspaceSpecs skipping behavior

• Adds a unit test ensuring 'createWorkspaceSpecs' can skip non-workspace packages when configured, returning only workspace-applicable specs.

pnpm11/installing/commands/test/updateWorkspaceDependencies.test.ts

Documentation (2) +16 / -0
pacquet-update-workspace-and-depth.mdChangeset: pacquet 'update --workspace' + per-dependency '--depth' +7/-0

Changeset: pacquet 'update --workspace' + per-dependency '--depth'

• Adds a minor changeset documenting new pacquet support for 'pnpm update --workspace' and correct per-dependency '--depth' semantics, including error codes and 'saveWorkspaceProtocol' behavior.

.changeset/pacquet-update-workspace-and-depth.md

update-workspace-only-links-named-deps.mdChangeset: TS '--workspace' no longer links unintended deps +9/-0

Changeset: TS '--workspace' no longer links unintended deps

• Adds a patch changeset for '@pnpm/installing.commands' and 'pnpm' describing two '--workspace' selector/ignore edge case fixes.

.changeset/update-workspace-only-links-named-deps.md

Other (5) +94 / -3
Cargo.lockLockfile update for new workspace-range-resolver crate +1/-0

Lockfile update for new workspace-range-resolver crate

• Updates the Rust workspace lockfile to include the new 'pacquet-workspace-range-resolver' dependency referenced by pacquet update workspace resolution.

Cargo.lock

lib.rsAdd 'SaveWorkspaceProtocol' config setting +75/-0

Add 'SaveWorkspaceProtocol' config setting

• Introduces 'SaveWorkspaceProtocol' ('false | true | "rolling"') with serde support and adds it to the main Config as 'save_workspace_protocol', defaulting to rolling.

pnpm/crates/config/src/lib.rs

pnpm_default_parity.rsMap 'save-workspace-protocol' into default parity table +11/-2

Map 'save-workspace-protocol' into default parity table

• Removes 'save-workspace-protocol' from the not-ported list and adds scalar mapping so parity output reflects the new config setting.

pnpm/crates/config/src/pnpm_default_parity.rs

workspace_yaml.rsParse 'saveWorkspaceProtocol' from pnpm-workspace.yaml settings +6/-1

Parse 'saveWorkspaceProtocol' from pnpm-workspace.yaml settings

• Extends workspace YAML settings to include optional 'save_workspace_protocol' and ensures it resets/threads through the settings lifecycle.

pnpm/crates/config/src/workspace_yaml.rs

Cargo.tomlAdd 'pacquet-workspace-range-resolver' dependency +1/-0

Add 'pacquet-workspace-range-resolver' dependency

• Adds the workspace range resolver crate to package-manager dependencies so update workspace linking can resolve workspace semver ranges.

pnpm/crates/package-manager/Cargo.toml

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge because no blocking failure related to the prior lifecycle threads remains.

No blocking failure remains.

Reviews (6): Last reviewed commit: "refactor(update): extract the --workspac..." | 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.05     11.6±0.09ms    32.2 MB/sec    1.00     11.1±0.05ms    33.7 MB/sec
packument/parse                1.00     37.0±0.07µs  1794.6 MB/sec    1.04     38.5±0.09µs  1724.6 MB/sec
tarball/download_dependency    1.00      2.3±0.06ms  1906.3 KB/sec    1.00      2.3±0.07ms  1900.4 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. No-op workspace skips scripts ✓ Resolved 🐞 Bug ☼ Reliability
Description
prepare_manifest() marks linked_workspace_packages true whenever any workspace link target
exists, even if the computed workspace: specifier is identical to what the manifest already
declares, so Update::run forces is_full_install false and skips lifecycle scripts. This can
leave projects stale when they rely on postinstall/build scripts during a no-op `pnpm update
--workspace` run.
Code

pnpm/crates/package-manager/src/update.rs[R329-331]

+            // `--workspace` names the dependencies it re-points, so a
+            // run that linked any of them is partial too.
+            is_full_install: packages.is_empty() && !linked_workspace_packages,
Relevance

⭐⭐⭐ High

Repo often accepts fixes preventing incorrect “no-op/fast-path” behavior that skips needed work like
scripts.

PR-#13152
PR-#13173
PR-#13141

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Update::run treats any run with linked_workspace_packages as partial by setting
is_full_install to false, which is documented to control whether project lifecycle scripts run.
But linked_workspace_packages is computed from workspace_targets presence and workspace rewrites
are generated per-target without checking whether the computed specifier differs from the existing
declared specifier; workspace_specifier() can also intentionally return the existing declared
workspace:*/workspace:^/workspace:~ unchanged, making the no-op case real.

pnpm/crates/package-manager/src/update.rs[298-346]
pnpm/crates/package-manager/src/update.rs[578-602]
pnpm/crates/package-manager/src/update.rs[1005-1036]
pnpm/crates/package-manager/src/update.rs[776-797]

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

### Issue description
`linked_workspace_packages` is used to downgrade `pnpm update` to a partial install (skipping project lifecycle scripts). Today it becomes `true` whenever any workspace target exists, even when the resulting `workspace:` specifier is unchanged (e.g. dependency already `workspace:*` under rolling), causing script skipping on a no-op rewrite.

### Issue Context
This impacts `pnpm update --workspace` runs where targets are already normalized to the intended `workspace:` specifiers. The code comment indicates only dependencies that are actually re-pointed should make the run partial, but the current boolean is derived from target existence rather than actual manifest change.

### Fix Focus Areas
- pnpm/crates/package-manager/src/update.rs[578-602]
- pnpm/crates/package-manager/src/update.rs[329-331]
- pnpm/crates/package-manager/src/update.rs[776-797]

### Suggested approach
- When building workspace rewrites, compare the computed `specifier` to `target.declared` and only:
 - push into `rewrites`
 - insert into `drop_names`
 - and consider it “linked”
 if the specifier actually differs.
- Derive `linked_workspace_packages` from the count of *effective* workspace rewrites (or a dedicated `did_change_any_workspace_specifier` flag) rather than `workspace_targets.is_empty()`.
- Add a regression test where a dependency already has `workspace:*` (or `workspace:^`) and `update --workspace` still runs project scripts (i.e. full install) because nothing was re-pointed.

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


2. createWorkspaceSpecs() missing trailing comma 📘 Rule violation ⚙ Maintainability
Description
The multi-line parameter list for createWorkspaceSpecs() omits a trailing comma on the last
parameter. This violates the repo’s TypeScript trailing-comma requirement and creates noisier diffs
on future edits.
Code

pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[R31-35]

+export function createWorkspaceSpecs (
+  specs: string[],
+  workspacePackages: WorkspacePackages,
+  opts?: { skipPackagesOutsideWorkspace?: boolean }
+): string[] {
Relevance

⭐⭐⭐ High

Trivial formatting/compliance fix (trailing comma) is low-risk and usually accepted when flagged.

PR-#13195

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TypeScript parameter lists. The
updated createWorkspaceSpecs() signature spans multiple lines and the last parameter opts?: ...
does not end with a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[31-35]

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

## Issue description
A multi-line TypeScript parameter list is missing a trailing comma on the last parameter.

## Issue Context
The repo requires trailing commas for multi-line TypeScript constructs to reduce diff churn.

## Fix Focus Areas
- pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[31-35]

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



Informational

3. userNamedDeps comment duplicates JSDoc 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The new inline comment explaining userNamedDeps largely restates the contract already documented
in toWorkspaceSpecs() JSDoc, creating duplicated documentation that can drift. Prefer keeping the
behavior explanation in the function-level JSDoc and leaving only call-specific rationale (if any)
at the call site.
Code

pnpm11/installing/commands/src/installDeps.ts[R360-363]

+  // `params` is rewritten below into the dependency names it matched, so
+  // remember whether the user named any package. `--workspace` only insists
+  // that a dependency exists in the workspace when it was asked for by name.
+  const userNamedDeps = params.length > 0
Relevance

⭐ Low

Similar “remove call-site comment duplicating JSDoc” suggestions were rejected before; team keeps
such comments.

PR-#12876
PR-#12971

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call-site comment documents the same reasoning that toWorkspaceSpecs() JSDoc already covers
(distinguishing empty selectors cases and when missing workspace packages should error), which
violates the rule against duplicating JSDoc content at call sites.

Rule 713431: Avoid duplicating JSDoc content in call-site comments
pnpm11/installing/commands/src/installDeps.ts[360-363]
pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[21-45]

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

## Issue description
A call-site comment near `userNamedDeps` duplicates the contract already described in `toWorkspaceSpecs()` JSDoc, which increases maintenance burden and risk of docs drifting.

## Issue Context
`toWorkspaceSpecs()` now centralizes the `--workspace` selector behavior and documents the key edge cases (`selectors` empty vs user named none, and when missing workspace deps should error). The call site repeats essentially the same explanation.

## Fix Focus Areas
- pnpm11/installing/commands/src/installDeps.ts[360-363]
- pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[21-45]

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


4. Unchecked depth increment 🐞 Bug ☼ Reliability
Description
The resolver increments an i32 depth using depth + 1 without overflow handling, which can
theoretically wrap in release builds (or panic in debug) if an extreme depth were reached. This is a
low-likelihood but cheap-to-harden robustness issue in depth-aware subtree reuse.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[R2693-2694]

+            if !subtree_fully_reusable(ctx, lockfile, &child_key, depth + 1) {
                return false;
Relevance

⭐⭐ Medium

Overflow-hardening is plausible but very theoretical; no clear history on guarding depth increments
in resolver recursion.

PR-#13196

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
UpdateDepth is stored as an Option<i32> and the subtree reuse recursion increments depth via
depth + 1 when descending to children, which is unchecked arithmetic on a signed integer.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[65-96]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[2671-2696]

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

### Issue description
Depth is tracked as `i32`, and the subtree reuse recursion uses `depth + 1` without `checked_add`/`saturating_add`. While real graphs are unlikely to approach `i32::MAX`, the change is easy to make safer and avoids any possibility of wraparound affecting update-depth gating.

### Issue Context
This was introduced as part of making `--depth` apply per dependency via `UpdateDepth`.

### Fix Focus Areas
- Replace `depth + 1` with `depth.saturating_add(1)` (or `checked_add(1).unwrap_or(i32::MAX)`) at every recursive depth increment.
- Optionally add a small unit test that constructs a synthetic call with `depth = i32::MAX` and verifies it does not panic.

### Fix Focus Areas (code references)
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[65-96]
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[2671-2696]

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


5. Repeated matcher compilation ✓ Resolved 🐞 Bug ➹ Performance
Description
workspace_link_targets() recompiles a per-selector matcher inside a per-dependency .find(...)
via matcher_one(), adding repeated allocations and matcher-building work when multiple selectors
and many direct deps are involved. This deterministic work can be precomputed once per selector.
Code

pnpm/crates/package-manager/src/update.rs[R970-974]

+        let wanted = selectors
+            .iter()
+            .find(|selector| matcher_one(&selector.pattern).matches(name))
+            .and_then(|selector| selector.version.clone())
+            .unwrap_or_else(|| "*".to_string());
Relevance

⭐⭐ Medium

Team sometimes accepts removing repeated work, but also rejects many micro-optimizations; no close
precedent for matcher recompilation.

PR-#13170
PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code calls matcher_one(&selector.pattern) inside a per-dependency scan; matcher_one()
allocates a new String and constructs a new matcher each time, which is repeated work when many
dependencies are matched.

pnpm/crates/package-manager/src/update.rs[961-974]
pnpm/crates/package-manager/src/update.rs[1032-1037]

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

### Issue description
`workspace_link_targets()` uses an aggregate matcher to decide which direct deps match, but then re-builds a matcher per selector (and allocates a `String`) in the inner `.find(...)` to recover the selector version for the matching dep.

### Issue Context
This path is new for `pacquet update --workspace` and runs per direct dependency that matches the selector set.

### Fix Focus Areas
- Precompute `Vec<(Matcher, Option<String>)>` from `selectors` once, and then scan that list for the first matcher that matches `name`.
- Avoid `pattern.to_string()` allocation inside the hot loop by storing `String` patterns once.

### Fix Focus Areas (code references)
- pnpm/crates/package-manager/src/update.rs[961-980]
- pnpm/crates/package-manager/src/update.rs[1032-1037]

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


View more (2)
6. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset .changeset/pacquet-update-workspace-and-depth.md omits a pnpm package entry in
its front-matter. This violates the changeset policy requiring explicit pnpm bump declaration.
Code

.changeset/pacquet-update-workspace-and-depth.md[R1-3]

+---
+"pacquet": minor
+---
Relevance

⭐ Low

Repo repeatedly rejected “always add pnpm entry” changeset rule; they prefer bumping only actually
affected packages.

PR-#13234
PR-#13231
PR-#13225

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each added/modified changeset to include a pnpm entry with a
valid bump type. The changeset front-matter lists only pacquet and therefore fails the
requirement.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-update-workspace-and-depth.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
A newly added changeset does not include an explicit `pnpm` entry in its front-matter.

## Issue Context
Compliance requires that changesets explicitly declare the `pnpm` package and an appropriate bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/pacquet-update-workspace-and-depth.md[1-3]

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


7. Workspace version list cloned 🐞 Bug ➹ Performance
Description
pick_workspace_version() clones all workspace version keys into a new Vec<String> and
resolve_workspace_range() reparses versions, adding avoidable allocation+CPU per linked dependency
during pacquet update --workspace. This can become noticeable in unusual workspaces that publish
multiple versions per name or in large batch updates.
Code

pnpm/crates/package-manager/src/update.rs[R1027-1030]

+fn pick_workspace_version(versions: &WorkspacePackagesByVersion, range: &str) -> Option<String> {
+    let range = if node_semver::Range::parse(range).is_ok() { range } else { "*" };
+    resolve_workspace_range(range, &versions.keys().cloned().collect::<Vec<_>>())
+}
Relevance

⭐ Low

Similar “avoid per-call Vec cloning/allocation” perf suggestions were explicitly rejected as
micro-optimizations.

PR-#13149
PR-#13170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new update code clones all workspace-package version keys into a Vec on every call, and the
workspace range resolver then iterates and semver-parses those strings, so work scales with the
number of versions stored for that workspace package.

pnpm/crates/package-manager/src/update.rs[1024-1030]
pnpm/crates/workspace-range-resolver/src/lib.rs[19-65]

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

### Issue description
`pick_workspace_version()` builds a fresh `Vec<String>` by cloning `versions.keys()` for each lookup, then calls `resolve_workspace_range()` which iterates and semver-parses those versions. This is avoidable overhead in the new `--workspace` update path.

### Issue Context
- The workspace range resolver currently accepts `&[String]`, which pushes call sites toward cloning.

### Fix Focus Areas
- Consider changing `resolve_workspace_range()` to accept borrowed versions (e.g. `&[&str]`, or `impl IntoIterator<Item = impl AsRef<str>>`) so callers can pass `versions.keys().map(|s| s.as_str())` without cloning.
- Alternatively, cache a `Vec<String>`/`Vec<Version>` per workspace package name (built once when building the workspace packages map) and reuse it for all range picks.

### Fix Focus Areas (code references)
- pnpm/crates/package-manager/src/update.rs[1024-1030]
- pnpm/crates/workspace-range-resolver/src/lib.rs[19-65]

ⓘ 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 0fb200d

Results up to commit 3ebfa07 ⚖️ Balanced


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


Remediation recommended
1. createWorkspaceSpecs() missing trailing comma 📘 Rule violation ⚙ Maintainability
Description
The multi-line parameter list for createWorkspaceSpecs() omits a trailing comma on the last
parameter. This violates the repo’s TypeScript trailing-comma requirement and creates noisier diffs
on future edits.
Code

pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[R31-35]

+export function createWorkspaceSpecs (
+  specs: string[],
+  workspacePackages: WorkspacePackages,
+  opts?: { skipPackagesOutsideWorkspace?: boolean }
+): string[] {
Relevance

⭐⭐⭐ High

Trivial formatting/compliance fix (trailing comma) is low-risk and usually accepted when flagged.

PR-#13195

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713434 requires trailing commas in multi-line TypeScript parameter lists. The
updated createWorkspaceSpecs() signature spans multiple lines and the last parameter opts?: ...
does not end with a comma.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[31-35]

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

## Issue description
A multi-line TypeScript parameter list is missing a trailing comma on the last parameter.

## Issue Context
The repo requires trailing commas for multi-line TypeScript constructs to reduce diff churn.

## Fix Focus Areas
- pnpm11/installing/commands/src/updateWorkspaceDependencies.ts[31-35]

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



Informational
2. Unchecked depth increment 🐞 Bug ☼ Reliability
Description
The resolver increments an i32 depth using depth + 1 without overflow handling, which can
theoretically wrap in release builds (or panic in debug) if an extreme depth were reached. This is a
low-likelihood but cheap-to-harden robustness issue in depth-aware subtree reuse.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[R2693-2694]

+            if !subtree_fully_reusable(ctx, lockfile, &child_key, depth + 1) {
                return false;
Relevance

⭐⭐ Medium

Overflow-hardening is plausible but very theoretical; no clear history on guarding depth increments
in resolver recursion.

PR-#13196

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
UpdateDepth is stored as an Option<i32> and the subtree reuse recursion increments depth via
depth + 1 when descending to children, which is unchecked arithmetic on a signed integer.

pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[65-96]
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[2671-2696]

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

### Issue description
Depth is tracked as `i32`, and the subtree reuse recursion uses `depth + 1` without `checked_add`/`saturating_add`. While real graphs are unlikely to approach `i32::MAX`, the change is easy to make safer and avoids any possibility of wraparound affecting update-depth gating.

### Issue Context
This was introduced as part of making `--depth` apply per dependency via `UpdateDepth`.

### Fix Focus Areas
- Replace `depth + 1` with `depth.saturating_add(1)` (or `checked_add(1).unwrap_or(i32::MAX)`) at every recursive depth increment.
- Optionally add a small unit test that constructs a synthetic call with `depth = i32::MAX` and verifies it does not panic.

### Fix Focus Areas (code references)
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[65-96]
- pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs[2671-2696]

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


3. Repeated matcher compilation ✓ Resolved 🐞 Bug ➹ Performance
Description
workspace_link_targets() recompiles a per-selector matcher inside a per-dependency .find(...)
via matcher_one(), adding repeated allocations and matcher-building work when multiple selectors
and many direct deps are involved. This deterministic work can be precomputed once per selector.
Code

pnpm/crates/package-manager/src/update.rs[R970-974]

+        let wanted = selectors
+            .iter()
+            .find(|selector| matcher_one(&selector.pattern).matches(name))
+            .and_then(|selector| selector.version.clone())
+            .unwrap_or_else(|| "*".to_string());
Relevance

⭐⭐ Medium

Team sometimes accepts removing repeated work, but also rejects many micro-optimizations; no close
precedent for matcher recompilation.

PR-#13170
PR-#13151

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The code calls matcher_one(&selector.pattern) inside a per-dependency scan; matcher_one()
allocates a new String and constructs a new matcher each time, which is repeated work when many
dependencies are matched.

pnpm/crates/package-manager/src/update.rs[961-974]
pnpm/crates/package-manager/src/update.rs[1032-1037]

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

### Issue description
`workspace_link_targets()` uses an aggregate matcher to decide which direct deps match, but then re-builds a matcher per selector (and allocates a `String`) in the inner `.find(...)` to recover the selector version for the matching dep.

### Issue Context
This path is new for `pacquet update --workspace` and runs per direct dependency that matches the selector set.

### Fix Focus Areas
- Precompute `Vec<(Matcher, Option<String>)>` from `selectors` once, and then scan that list for the first matcher that matches `name`.
- Avoid `pattern.to_string()` allocation inside the hot loop by storing `String` patterns once.

### Fix Focus Areas (code references)
- pnpm/crates/package-manager/src/update.rs[961-980]
- pnpm/crates/package-manager/src/update.rs[1032-1037]

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


4. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset .changeset/pacquet-update-workspace-and-depth.md omits a pnpm package entry in
its front-matter. This violates the changeset policy requiring explicit pnpm bump declaration.
Code

.changeset/pacquet-update-workspace-and-depth.md[R1-3]

+---
+"pacquet": minor
+---
Relevance

⭐ Low

Repo repeatedly rejected “always add pnpm entry” changeset rule; they prefer bumping only actually
affected packages.

PR-#13234
PR-#13231
PR-#13225

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires each added/modified changeset to include a pnpm entry with a
valid bump type. The changeset front-matter lists only pacquet and therefore fails the
requirement.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-update-workspace-and-depth.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
A newly added changeset does not include an explicit `pnpm` entry in its front-matter.

## Issue Context
Compliance requires that changesets explicitly declare the `pnpm` package and an appropriate bump type (`patch`/`minor`/`major`).

## Fix Focus Areas
- .changeset/pacquet-update-workspace-and-depth.md[1-3]

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


View more (1)
5. Workspace version list cloned 🐞 Bug ➹ Performance
Description
pick_workspace_version() clones all workspace version keys into a new Vec<String> and
resolve_workspace_range() reparses versions, adding avoidable allocation+CPU per linked dependency
during pacquet update --workspace. This can become noticeable in unusual workspaces that publish
multiple versions per name or in large batch updates.
Code

pnpm/crates/package-manager/src/update.rs[R1027-1030]

+fn pick_workspace_version(versions: &WorkspacePackagesByVersion, range: &str) -> Option<String> {
+    let range = if node_semver::Range::parse(range).is_ok() { range } else { "*" };
+    resolve_workspace_range(range, &versions.keys().cloned().collect::<Vec<_>>())
+}
Relevance

⭐ Low

Similar “avoid per-call Vec cloning/allocation” perf suggestions were explicitly rejected as
micro-optimizations.

PR-#13149
PR-#13170

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new update code clones all workspace-package version keys into a Vec on every call, and the
workspace range resolver then iterates and semver-parses those strings, so work scales with the
number of versions stored for that workspace package.

pnpm/crates/package-manager/src/update.rs[1024-1030]
pnpm/crates/workspace-range-resolver/src/lib.rs[19-65]

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

### Issue description
`pick_workspace_version()` builds a fresh `Vec<String>` by cloning `versions.keys()` for each lookup, then calls `resolve_workspace_range()` which iterates and semver-parses those versions. This is avoidable overhead in the new `--workspace` update path.

### Issue Context
- The workspace range resolver currently accepts `&[String]`, which pushes call sites toward cloning.

### Fix Focus Areas
- Consider changing `resolve_workspace_range()` to accept borrowed versions (e.g. `&[&str]`, or `impl IntoIterator<Item = impl AsRef<str>>`) so callers can pass `versions.keys().map(|s| s.as_str())` without cloning.
- Alternatively, cache a `Vec<String>`/`Vec<Version>` per workspace package name (built once when building the workspace packages map) and reuse it for all range picks.

### Fix Focus Areas (code references)
- pnpm/crates/package-manager/src/update.rs[1024-1030]
- pnpm/crates/workspace-range-resolver/src/lib.rs[19-65]

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


Results up to commit a93a226 ⚖️ Balanced


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


Remediation recommended
1. No-op workspace skips scripts ✓ Resolved 🐞 Bug ☼ Reliability
Description
prepare_manifest() marks linked_workspace_packages true whenever any workspace link target
exists, even if the computed workspace: specifier is identical to what the manifest already
declares, so Update::run forces is_full_install false and skips lifecycle scripts. This can
leave projects stale when they rely on postinstall/build scripts during a no-op `pnpm update
--workspace` run.
Code

pnpm/crates/package-manager/src/update.rs[R329-331]

+            // `--workspace` names the dependencies it re-points, so a
+            // run that linked any of them is partial too.
+            is_full_install: packages.is_empty() && !linked_workspace_packages,
Relevance

⭐⭐⭐ High

Repo often accepts fixes preventing incorrect “no-op/fast-path” behavior that skips needed work like
scripts.

PR-#13152
PR-#13173
PR-#13141

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Update::run treats any run with linked_workspace_packages as partial by setting
is_full_install to false, which is documented to control whether project lifecycle scripts run.
But linked_workspace_packages is computed from workspace_targets presence and workspace rewrites
are generated per-target without checking whether the computed specifier differs from the existing
declared specifier; workspace_specifier() can also intentionally return the existing declared
workspace:*/workspace:^/workspace:~ unchanged, making the no-op case real.

pnpm/crates/package-manager/src/update.rs[298-346]
pnpm/crates/package-manager/src/update.rs[578-602]
pnpm/crates/package-manager/src/update.rs[1005-1036]
pnpm/crates/package-manager/src/update.rs[776-797]

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

### Issue description
`linked_workspace_packages` is used to downgrade `pnpm update` to a partial install (skipping project lifecycle scripts). Today it becomes `true` whenever any workspace target exists, even when the resulting `workspace:` specifier is unchanged (e.g. dependency already `workspace:*` under rolling), causing script skipping on a no-op rewrite.

### Issue Context
This impacts `pnpm update --workspace` runs where targets are already normalized to the intended `workspace:` specifiers. The code comment indicates only dependencies that are actually re-pointed should make the run partial, but the current boolean is derived from target existence rather than actual manifest change.

### Fix Focus Areas
- pnpm/crates/package-manager/src/update.rs[578-602]
- pnpm/crates/package-manager/src/update.rs[329-331]
- pnpm/crates/package-manager/src/update.rs[776-797]

### Suggested approach
- When building workspace rewrites, compare the computed `specifier` to `target.declared` and only:
 - push into `rewrites`
 - insert into `drop_names`
 - and consider it “linked”
 if the specifier actually differs.
- Derive `linked_workspace_packages` from the count of *effective* workspace rewrites (or a dedicated `did_change_any_workspace_specifier` flag) rather than `workspace_targets.is_empty()`.
- Add a regression test where a dependency already has `workspace:*` (or `workspace:^`) and `update --workspace` still runs project scripts (i.e. full install) because nothing was re-pointed.

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

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.39344% with 21 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.98%. Comparing base (069bc0f) to head (0fb200d).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/config/src/lib.rs 48.00% 13 Missing ⚠️
pnpm/crates/package-manager/src/update.rs 96.61% 4 Missing ⚠️
pnpm/crates/config/src/pnpm_default_parity.rs 71.42% 2 Missing ⚠️
pnpm/crates/cli/src/cli_args/update.rs 96.15% 1 Missing ⚠️
pnpm/crates/napi/src/install.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13288      +/-   ##
==========================================
+ Coverage   86.96%   86.98%   +0.01%     
==========================================
  Files         530      530              
  Lines       90954    91171     +217     
==========================================
+ Hits        79099    79303     +204     
- Misses      11855    11868      +13     

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

Copilot AI review requested due to automatic review settings July 25, 2026 00:40

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.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Thanks — triage of the Qodo findings:

Fixed

  • Repeated matcher compilation (workspace_link_targets) — real, fixed in a93a226. The per-selector matchers are now compiled once before the per-dependency scan instead of being rebuilt (with a fresh pattern allocation) for every matched dependency.

Not changing, with reasons

  • createWorkspaceSpecs() missing trailing comma — the repo's convention for multi-line parameter lists is no trailing comma. updateToWorkspacePackagesFromManifest directly above it in the same file, and matchDependencies in recursive.ts, are both written that way, and ESLint passes on the file. Adding one here would make the file inconsistent with itself. (The repo's trailing-comma convention applies to collections and object literals, which this diff already follows.)

  • Unchecked depth + 1 — depth is an i32 node depth in the resolver's subtree walk. Reaching i32::MAX would require ~2 billion nested dependency levels; the recursion would exhaust the stack many orders of magnitude earlier. The surrounding resolver already uses plain depth + 1 at every other recursion site, so hardening only the sites this PR touches would be inconsistent without making anything reachable safer. (UpdateDepth::memo_bucket does use saturating_add, because there the addend is a user-supplied --depth value.)

  • Changeset missing pnpm entry — deliberate, and required by the repo's own policy: AGENTS.md states "Do not add "pnpm" to a Rust-only changeset: in changesets, pnpm always means the TypeScript CLI package." The Rust-only changeset targets pacquet; the TypeScript half of this PR has its own changeset that does name "pnpm".

  • Workspace version list cloned — pick_workspace_version is called once per linked dependency, over a map that holds one entry per workspace project publishing that name (almost always exactly one). Widening resolve_workspace_range's signature to avoid it would touch a shared crate for no measurable gain.


Written by an agent (Claude Code, claude-opus-5).

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

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

Copilot AI review requested due to automatic review settings July 25, 2026 00:50

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.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 105904d

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

@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

🧹 Nitpick comments (1)
pnpm11/installing/commands/src/installDeps.ts (1)

399-410: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated userNamedDeps-gated workspace-selector branch into a shared helper. The same "expand-from-manifest when nothing was named, else rewrite with skipPackagesOutsideWorkspace: !userNamedDeps" logic is now copy-pasted three times, and this PR adds a new parameter that all three copies must keep in sync going forward.

  • pnpm11/installing/commands/src/installDeps.ts#L399-L410: replace this branch with a call to a new shared helper, e.g. resolveWorkspaceSelectors(params, userNamedDeps, manifest, includeDirect, workspacePackages) exported from updateWorkspaceDependencies.ts.
  • pnpm11/installing/commands/src/recursive.ts#L279-L287: replace this branch (shared-lockfile path) with the same shared helper call.
  • pnpm11/installing/commands/src/recursive.ts#L409-L417: replace this branch (per-project path) with the same shared helper call.
♻️ Proposed shared helper
+// updateWorkspaceDependencies.ts
+export function resolveWorkspaceSelectors (
+  currentInput: string[],
+  userNamedDeps: boolean,
+  manifest: ProjectManifest,
+  includeDirect: IncludedDependencies,
+  workspacePackages: WorkspacePackages
+): string[] {
+  if (!currentInput || currentInput.length === 0) {
+    return userNamedDeps ? currentInput : updateToWorkspacePackagesFromManifest(manifest, includeDirect, workspacePackages)
+  }
+  return createWorkspaceSpecs(currentInput, workspacePackages, { skipPackagesOutsideWorkspace: !userNamedDeps })
+}
🤖 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 `@pnpm11/installing/commands/src/installDeps.ts` around lines 399 - 410,
Extract the duplicated workspace-selector resolution into an exported helper
such as resolveWorkspaceSelectors in updateWorkspaceDependencies.ts, preserving
the userNamedDeps behavior: expand from the manifest when no selectors were
named, otherwise call createWorkspaceSpecs with skipPackagesOutsideWorkspace set
to !userNamedDeps. Replace the three duplicated branches in
pnpm11/installing/commands/src/installDeps.ts lines 399-410,
pnpm11/installing/commands/src/recursive.ts lines 279-287, and
pnpm11/installing/commands/src/recursive.ts lines 409-417 with calls to this
helper, passing the existing params, userNamedDeps, manifest, includeDirect, and
workspacePackages values.
🤖 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 `@pnpm11/installing/commands/test/update/update.ts`:
- Around line 228-251: Update the test case around preparePackages and
update.handler so updateConfig.ignoreDependencies targets the declared
`@pnpm.e2e/foo` dependency instead of the undeclared bar pattern. Add assertions
verifying foo remains unchanged while project-2 is linked, ensuring the
regression test covers both ignored registry and workspace dependency behavior.

---

Nitpick comments:
In `@pnpm11/installing/commands/src/installDeps.ts`:
- Around line 399-410: Extract the duplicated workspace-selector resolution into
an exported helper such as resolveWorkspaceSelectors in
updateWorkspaceDependencies.ts, preserving the userNamedDeps behavior: expand
from the manifest when no selectors were named, otherwise call
createWorkspaceSpecs with skipPackagesOutsideWorkspace set to !userNamedDeps.
Replace the three duplicated branches in
pnpm11/installing/commands/src/installDeps.ts lines 399-410,
pnpm11/installing/commands/src/recursive.ts lines 279-287, and
pnpm11/installing/commands/src/recursive.ts lines 409-417 with calls to this
helper, passing the existing params, userNamedDeps, manifest, includeDirect, and
workspacePackages values.
🪄 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: 47a0ec31-2e79-431d-a46e-82886100eb6a

📥 Commits

Reviewing files that changed from the base of the PR and between d47ab91 and 105904d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (30)
  • .changeset/pacquet-update-workspace-and-depth.md
  • .changeset/update-workspace-only-links-named-deps.md
  • pnpm/crates/cli/src/cli_args/audit.rs
  • pnpm/crates/cli/src/cli_args/dedupe.rs
  • pnpm/crates/cli/src/cli_args/import.rs
  • pnpm/crates/cli/src/cli_args/update.rs
  • pnpm/crates/cli/src/cli_args/update/tests.rs
  • pnpm/crates/cli/tests/update.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/config/src/pnpm_default_parity.rs
  • pnpm/crates/config/src/workspace_yaml.rs
  • pnpm/crates/napi/src/install.rs
  • pnpm/crates/package-manager/Cargo.toml
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install/tests.rs
  • pnpm/crates/package-manager/src/install_package_from_registry/tests.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs
  • pnpm/crates/package-manager/src/install_with_fresh_lockfile/tests.rs
  • pnpm/crates/package-manager/src/update.rs
  • pnpm/crates/package-manager/src/update/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/lib.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree/tests.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_workspace/tests.rs
  • pnpm11/installing/commands/src/installDeps.ts
  • pnpm11/installing/commands/src/recursive.ts
  • pnpm11/installing/commands/src/updateWorkspaceDependencies.ts
  • pnpm11/installing/commands/test/update/update.ts
  • pnpm11/installing/commands/test/updateWorkspaceDependencies.test.ts

@blacksmith-sh

This comment has been minimized.

Copilot AI review requested due to automatic review settings July 25, 2026 01:11

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.

@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

The test/update/issue-7415.ts failure on 105904d is a network flake, not a regression from this PR.

  • The failure is TimeoutError: The operation was aborted due to timeout after 62s, not an assertion. That test resolves github:kevva/is-negative#2.1.0, so it needs to reach github.com from the runner.
  • TS CI passed on 3ebfa07, which already contained every TypeScript change in this PR. The two commits after it (a93a226, 105904d) touched only Rust files, so the failure landed on a commit that changed no TypeScript at all.
  • The test does not use --workspace, and every behavior change in the TypeScript diff is inside the if (opts.workspace) branch. It passes locally.

CI is re-running on fec1d27 anyway; I'll follow up if it reproduces.


Written by an agent (Claude Code, claude-opus-5).

@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

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pnpm11/installing/commands/src/recursive.ts (1)

229-232: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve selector intent instead of using params.length.

A wildcard or mixed selector is treated as an explicitly named dependency. After matching, a registry dependency selected by * reaches createWorkspaceSpecs() with skipping disabled and throws instead of remaining unchanged. The same boolean also makes an ignored-only importer expand back to all workspace dependencies in the shared-lockfile path when --depth > 0.

  • pnpm11/installing/commands/src/recursive.ts#L229-L232: retain whether each match came from a literal package selector, pattern selector, or ignore filtering.
  • pnpm11/installing/commands/src/updateWorkspaceDependencies.ts#L40-L44: require workspace presence only for literal-selector matches; keep empty-after-ignore distinct from “update all workspace dependencies.”

Add focused regressions for wildcard/mixed selectors containing registry dependencies and an ignored-only importer with shared lockfile plus positive depth. As per path instructions, user-visible behavior must retain parity and changed behavior needs regression coverage.

🤖 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 `@pnpm11/installing/commands/src/recursive.ts` around lines 229 - 232, Preserve
selector provenance instead of deriving intent from params.length: in
pnpm11/installing/commands/src/recursive.ts:229-232, retain whether each match
came from a literal selector, pattern/wildcard selector, or ignore filtering
before calling createWorkspaceSpecs(). In
pnpm11/installing/commands/src/updateWorkspaceDependencies.ts:40-44, require
workspace presence only for literal-selector matches and keep an
empty-after-ignore result distinct from updating all workspace dependencies. Add
regressions for wildcard/mixed selectors containing registry dependencies and
ignored-only importers with shared lockfiles and positive depth.

Source: Path instructions

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

Outside diff comments:
In `@pnpm11/installing/commands/src/recursive.ts`:
- Around line 229-232: Preserve selector provenance instead of deriving intent
from params.length: in pnpm11/installing/commands/src/recursive.ts:229-232,
retain whether each match came from a literal selector, pattern/wildcard
selector, or ignore filtering before calling createWorkspaceSpecs(). In
pnpm11/installing/commands/src/updateWorkspaceDependencies.ts:40-44, require
workspace presence only for literal-selector matches and keep an
empty-after-ignore result distinct from updating all workspace dependencies. Add
regressions for wildcard/mixed selectors containing registry dependencies and
ignored-only importers with shared lockfiles and positive depth.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1823c3d2-1926-4f43-8035-6cc73c0a9409

📥 Commits

Reviewing files that changed from the base of the PR and between 105904d and fec1d27.

📒 Files selected for processing (4)
  • pnpm11/installing/commands/src/installDeps.ts
  • pnpm11/installing/commands/src/recursive.ts
  • pnpm11/installing/commands/src/updateWorkspaceDependencies.ts
  • pnpm11/installing/commands/test/update/update.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm11/installing/commands/test/update/update.ts
  • pnpm11/installing/commands/src/installDeps.ts

@coderabbitai coderabbitai Bot mentioned this pull request Sep 7, 2026
5 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants