Skip to content

refactor(cli): record the package manager pin from one place - #14627

Merged
zkochan merged 3 commits into
mainfrom
unify-pm-sync
Sep 6, 2026
Merged

zkochan merged 3 commits into
mainfrom
unify-pm-sync

Conversation

@zkochan

@zkochan zkochan commented Sep 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #14626, which is merged; this PR rebases onto it and is the refactor alone.

While fixing #14575 it turned out packageManagerDependencies reached the lockfile from eight call sites, not two: the pre-command checks for most commands, plus an identical three-call prologue copy-pasted into each of the seven install-family pipelines. A hand-maintained list of ten command variants (syncs_env_lockfile_in_pipeline) decided which side owned the write. That list is what let #14575 exist, and the two sides also disagreed about what and where they wrote.

The pre-command checks now record the pin for every command. The list and the seven copies are gone; the pipelines keep only the config-dependency pair they all share, behind config_deps::prepare.

Two bugs fell out of the merge

Both confirmed on released 12.3.4 before anything was changed, so neither comes from #14626.

Case Before After
lockfileDir is set The pin is written to a stray pnpm-lock.yaml at the workspace root, and the lockfile the install actually reads never carries it Written once, in the lockfile directory
pnpm unlink with nothing to unlink Returns before its pipeline, so the pin is never recorded Recorded

The lockfileDir one is the more serious of the two. pre_command derived its root from workspace_dir alone while the pipelines used root_project_manifest_dir (which honours lockfileDir), so the two wrote to different files. PinRoots now separates them: the manifest declaring the pin is read at the workspace root, the env lockfile follows the lockfile.

Behaviour parity, checked rather than assumed

--frozen-lockfile has a history of regressions in this block (#14009, #14124, #14129, #14132), so it was the risk to clear. Pre- and post-refactor binaries on an out-of-date packageManagerDependencies:

[pre]  --frozen-lockfile exit=1  err=ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE  (lockfile untouched)
[post] --frozen-lockfile exit=1  err=ERR_PNPM_FROZEN_LOCKFILE_WITH_OUTDATED_LOCKFILE  (lockfile untouched)

The frozenLockfile setting still blocks the write identically.

The install family used to layer --lockfile-dir and --offline onto its config before recording, so both now reach the pre-command config; without that, moving the write would have silently dropped them. --frozen-lockfile as typed reaches the write for the first time, where that path previously saw only the frozenLockfile setting.

The install fast path no longer gives itself up so the pipeline can record the pin, since the record has already happened by the time it runs.

Net −62 lines. All 3318 pnpm-cli tests pass; the new lockfileDir end-to-end test was verified to fail with the two-root change reverted.

Squash Commit Body

`packageManagerDependencies` reached the lockfile from eight call sites:
the pre-command checks for most commands, and a copy-pasted prologue in
each of the seven install-family pipelines. A hand-maintained list of
command variants decided which of the two owned the write, and the two
did not agree on what they wrote.

The pre-command checks now record the pin for every command, so the list
and the pipeline copies are gone. The seven pipelines keep only the
config-dependency pair they all share, behind `config_deps::prepare`.

The install family used to layer `--lockfile-dir` and `--offline` onto
its config before recording, so both now reach the pre-command config
too. `--frozen-lockfile` as typed reaches the write for the first time;
it previously only saw the `frozenLockfile` setting there.

Two bugs fall out of the merge. The pre-command path derived its root
from `workspace_dir` alone while the pipelines used `lockfileDir`, so a
project setting one recorded the pin in a stray lockfile at the
workspace root and never in the lockfile the install reads; the write
now follows the lockfile while the manifest is still read from the
workspace root. And `pnpm unlink` returns before its pipeline when there
is nothing to unlink, which used to skip the record entirely.

The install fast path no longer has to give itself up to let the
pipeline record the pin, since the record already happened by then.

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • 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).

🤖 Generated with Claude Code

https://claude.ai/code/session_01FPfp4dvqS7Nac4Luy3URJm

Summary by CodeRabbit

  • Bug Fixes
    • Fixed package manager pin recording when lockfileDir is configured. Pins are now written alongside the configured lockfile instead of creating an incorrect second lockfile at the workspace root.
    • Ensured package manager pins are recorded consistently across install, update, remove, deploy, dedupe, prune, unlink, and related commands.
    • Improved offline and prefer-offline command-line overrides, including support for explicitly clearing configured values.
  • Tests
    • Added coverage verifying pinned package manager versions are stored alongside the configured lockfile.

@coderabbitai

coderabbitai Bot commented Sep 6, 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: Team

Run ID: 774596a8-2597-42e8-9ec8-24cfc9ae3143

📥 Commits

Reviewing files that changed from the base of the PR and between 3cf2ad7 and 571ff55.

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

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The CLI records the pnpm pin during pre-command processing. It separates the workspace manifest directory from the environment lockfile directory. Install-family pipelines use shared config dependency preparation and no longer carry package-manager synchronization state.

Changes

pnpm pin recording

Layer / File(s) Summary
Pre-command pin synchronization
pnpm/crates/cli/src/cli_args/pre_command.rs, pnpm/crates/cli/src/cli_args/pre_command/tests.rs, pnpm/crates/cli/tests/suite/package_manager_check.rs, .changeset/record-the-pin-in-one-place.md
Pre-command planning applies pin flags, tracks separate manifest and environment roots, and records pins for install-family commands. Tests verify recording beside a configured lockfileDir.
Install pipeline preparation
pnpm/crates/cli/src/cli_args/dispatch_install.rs, pnpm/crates/cli/src/cli_args/install.rs, pnpm/crates/cli/src/cli_args/package_manager.rs, pnpm/crates/cli/src/cli_args/pipelines.rs, pnpm/crates/cli/src/config_deps.rs
Install-family pipelines remove package_manager_to_sync, use derive_config_root, and call config_deps::prepare. The old recording check is removed.

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

Merge Risk: ⚪ Minimal · up to 571ff

This centralizes pnpm pin recording before command execution, preserves lockfile-directory and offline flag behavior, and adds coverage for command flags and lockfile-directory pin persistence. No concrete merge-blocking risk remains.

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant PreCommandPlan
  participant EnvLockfile
  participant InstallPipeline
  participant ConfigDeps
  CLI->>PreCommandPlan: Parse command flags
  PreCommandPlan->>EnvLockfile: Record pnpm pin at configured lockfile directory
  PreCommandPlan->>InstallPipeline: Provide synchronization plan
  InstallPipeline->>ConfigDeps: Prepare config dependencies and hooks
Loading

Possibly related PRs

  • pnpm/pnpm#14079: Adds the lockfileDir support that this change uses for pnpm pin recording.

Suggested labels: product: pacquet

Suggested reviewers: ayush442842q

✨ 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 unify-pm-sync

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

Centralize package manager pin recording in pre-command checks

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Records package manager pins once during pre-command checks for every command.
• Writes pins to the active lockfile directory while reading workspace-level policy.
• Preserves frozen-lockfile, offline, and lockfile-directory behavior across install commands.
Diagram

sequenceDiagram
    actor User
    participant CLI as CLI Command
    participant Pre as Pre-command
    participant Config as CLI Config
    participant Manifest as Workspace Manifest
    participant Lockfile as Active Lockfile
    participant Pipeline as Install Pipeline
    participant ConfigDeps as Config Preparation
    User->>CLI: Run command
    CLI->>Pre: Build plan
    Pre->>Config: Apply CLI flags
    Config-->>Pre: Resolve pin roots
    Pre->>Manifest: Read package manager pin
    Manifest-->>Pre: Return policy
    Pre->>Lockfile: Record pinned version
    CLI->>Pipeline: Run command pipeline
    Pipeline->>ConfigDeps: Prepare config dependencies
Loading
High-Level Assessment

Centralizing pin recording in pre-command processing is the strongest approach because every command traverses it, including early-return paths such as an empty unlink. Retaining per-pipeline writers or a command ownership list would preserve duplicated policy and root-resolution behavior, recreating the synchronization risk this refactor removes.

Files changed (9) +262 / -324

Bug fix (1) +105 / -68
pre_command.rsCentralize pin recording and separate manifest and lockfile roots +105/-68

Centralize pin recording and separate manifest and lockfile roots

• Makes pre-command processing the sole package manager pin writer for all commands. Introduces separate manifest and env lockfile roots, applies lockfile-directory, offline, and frozen CLI flags before synchronization, and removes the manually maintained pipeline command list.

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

Refactor (5) +58 / -226
dispatch_install.rsRemove pin synchronization state from install dispatch +22/-46

Remove pin synchronization state from install dispatch

• Simplifies install-family dispatch by deriving only the config root and no longer passing package manager synchronization state into pipelines. All affected command constructors now rely on pre-command synchronization.

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

install.rsRestore the install up-to-date fast path +1/-10

Restore the install up-to-date fast path

• Removes the special fast-path rejection used when a pin still required recording. Pre-command processing now records the pin before the install fast path is evaluated.

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

package_manager.rsRemove pipeline-specific pin recording detection +0/-41

Remove pipeline-specific pin recording detection

• Deletes the helper that inspected manifests and env lockfiles to force install pipeline execution. Package manager pin selection remains available to the centralized pre-command path.

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

pipelines.rsConsolidate install pipeline configuration preparation +16/-129

Consolidate install pipeline configuration preparation

• Removes package manager synchronization fields and duplicated synchronization prologues from seven install-family pipelines. Pipelines now call the shared config preparation helper and derive only their operational config root.

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

config_deps.rsAdd shared install-family config preparation helper +19/-0

Add shared install-family config preparation helper

• Adds a helper that installs config dependencies and runs updateConfig hooks in their required order. This replaces identical setup sequences across install-family pipelines.

pnpm/crates/cli/src/config_deps.rs

Tests (2) +94 / -30
tests.rsVerify install-family pre-command synchronization +54/-30

Verify install-family pre-command synchronization

• Updates switch-target tests for separate pin roots and verifies install-family commands now produce pre-command lockfile synchronization plans. Test fixtures include the new lockfile-directory and offline inputs.

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

package_manager_check.rsTest pin recording with a configured lockfile directory +40/-0

Test pin recording with a configured lockfile directory

• Adds an integration regression test confirming the pin is written into the configured lockfile directory. It also verifies no stray pnpm-lock.yaml is created at the workspace root.

pnpm/crates/cli/tests/suite/package_manager_check.rs

Documentation (1) +5 / -0
record-the-pin-in-one-place.mdDocument corrected lockfile-directory pin recording +5/-0

Document corrected lockfile-directory pin recording

• Adds a patch changeset explaining that package manager pins now follow the configured lockfile directory instead of creating a stray workspace-root lockfile.

.changeset/record-the-pin-in-one-place.md

@greptile-apps

greptile-apps Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 4/5

The implementation appears behaviorally safe, but the changeset must be adjusted to satisfy the repository’s explicit release-note format.

The previously reported deploy flag and negated-offline defects are fixed, and their threads were resolved. The earlier comment-related thread was also resolved. The remaining issue is limited to the changeset ending with historical behavior rather than the issue link, contrary to the repository’s release-note requirement.

Files Needing Attention: .changeset/record-the-pin-in-one-place.md

Reviews (3): Last reviewed commit: "docs(cli): correct how the install-famil..." | Re-trigger Greptile

@qodo-code-review

qodo-code-review Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Online override still runs offline ✓ Resolved 🐞 Bug ≡ Correctness
Description
pre_command_plan_from_input combines the parsed --no-offline value with config.offline using
offline || config.offline, so Some(false) cannot clear an offline=true configuration value.
When a stale package-manager pin requires synchronization, the resolver consumes that retained
offline setting before dispatch reaches the install pipeline, where the CLI override would otherwise
be applied correctly.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R233-235]

+    if let Some(offline) = switch.offline {
+        config.offline = offline || config.offline;
+    }
Relevance

●●● Strong

Explicit negative CLI overrides are accepted when lower configuration values otherwise remain
enabled; recent override precedent supports this bug.

PR-#14541
PR-#13993

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The parser represents --no-offline as Some(false), but the pre-command assignment ORs that value
with the existing configuration, leaving a configured true unchanged. By contrast, the normal
install configuration uses resolve_bool_override, which permits an explicit negative CLI flag to
clear configured offline mode; because package-manager resolution constructs its context from the
pre-command configuration before install dispatch, it consumes the incorrectly preserved value.

pnpm/crates/cli/src/cli_args/pre_command.rs[230-235]
pnpm/crates/cli/src/cli_args/pre_command.rs[318-325]
pnpm/crates/cli/src/cli_args/pre_command.rs[654-667]
pnpm/crates/cli/src/cli_args/pipelines.rs[916-919]
pnpm/crates/cli/src/cli_args/install.rs[283-292]
pnpm/crates/cli/src/config_deps.rs[365-375]
pnpm/crates/cli/src/cli_args/pre_command.rs[227-235]
pnpm/crates/cli/src/cli_args/pre_command.rs[650-668]
pnpm/crates/cli/src/config_deps.rs[162-167]

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 pre-command package-manager synchronization does not honor `--no-offline` when `offline=true` is loaded from configuration. Replace the boolean-OR behavior with the same explicit CLI precedence used by install-family configuration, and add coverage for `offline=true` combined with `--no-offline`.

## Issue Context
`offline_flag` returns `Some(false)` for `--no-offline`. Because the pre-command assignment runs only when the parsed value is `Some`, that explicit value should override `config.offline` rather than be ORed with it. Pin synchronization now occurs before install dispatch, so it must use the same effective offline setting as the install-family pipeline, whose shared `resolve_bool_override` helper already implements the `--flag` / `--no-flag` semantics.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pre_command.rs[230-235]
- pnpm/crates/cli/src/cli_args/pipelines.rs[916-919]
- pnpm/crates/cli/src/cli_args/pre_command/tests.rs[461-471]

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



Remediation recommended

2. Maintainers inherit obsolete history ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
pre_command_plan_from_input adds a comment that says the install family used to write the pin
and contrasts that removed pipeline with what happens now. When this flow changes again, a
maintainer must reconstruct obsolete ownership instead of learning only the current invariant that
CLI overrides must be applied before the centralized pre-command sync.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R227-229]

+    // The install family used to record the pin from its own pipeline, after
+    // it had layered these two flags onto the loaded config. The record is
+    // made here for every command now, so they have to be layered on here.
Relevance

●●● Strong

Recent history accepts replacing historical comments with current invariants, including this file
and similar no-history rules.

PR-#14583
PR-#14443
PR-#13932

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 772199 prohibits inline comments that describe past implementations using phrases
such as used to. The added comment explicitly describes the former install-pipeline writer before
explaining the current flow.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/src/cli_args/pre_command.rs[227-229]

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

## Issue description
Replace the historical comparison with a comment describing only the current invariant.

## Issue Context
The comment uses `used to` and `now` to explain a removed implementation. State why the CLI flags must be applied before the centralized pre-command pin synchronization without discussing prior ownership.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pre_command.rs[227-229]

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


3. Stale installs reread their lockfile 🐞 Bug ➹ Performance
Description
env_lockfile_sync parses the environment lockfile to decide whether the package-manager pin is
stale, then discards that parsed value when it schedules synchronization. For a stale pin,
execute_plan calls the resolver with only the directory and that resolver parses the same lockfile
again before resolving dependencies, adding redundant filesystem I/O and YAML parsing to this
install path.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R351-352]

+            read = read_env_lockfile(&roots.env)?;
            read.as_ref()
Relevance

●● Moderate

Recent reviews accept eliminating duplicate lockfile reads, but exact same-path performance
precedent is limited and somewhat subjective.

PR-#14269
PR-#13828

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The new pre-command branch reads the lockfile solely to test whether the current pin is resolved and
returns only the package-manager descriptor. The subsequent synchronization receives no loaded
lockfile and resolve_package_manager_integrities independently calls EnvLockfile::read, so a
stale entry takes both reads.

pnpm/crates/cli/src/cli_args/pre_command.rs[336-364]
pnpm/crates/cli/src/cli_args/pre_command.rs[108-118]
pnpm/crates/cli/src/config_deps.rs[103-125]
pnpm/crates/env-installer/src/resolve_package_manager_integrities.rs[33-52]

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 stale package-manager pin causes the moved pre-command check to parse the environment lockfile once to detect staleness, then the synchronization routine parses it again. Preserve or pass the loaded lockfile into the synchronization path so a stale install does not perform duplicate lockfile I/O.

## Issue Context
The prior install-family pipeline delegated directly to package-manager synchronization. The new pre-command freshness check is necessary for avoiding unnecessary synchronization, but its parsed result is currently not reusable by `sync_package_manager_dependencies`.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pre_command.rs[336-364]
- pnpm/crates/cli/src/cli_args/pre_command.rs[108-118]
- pnpm/crates/cli/src/config_deps.rs[79-125]
- pnpm/crates/env-installer/src/resolve_package_manager_integrities.rs[33-52]

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


Grey Divider

Context sources
✅ Compliance rules (platform): 36 rules
Review mode: 🚀 Fast: This is a single-hunk comment-only change in runtime code with no behavioral effect, so a lightweight review is sufficient.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

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

github-actions Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.04     11.8±0.02ms    31.7 MB/sec    1.00     11.4±0.26ms    32.9 MB/sec
packument/parse                                  1.04     41.3±0.08µs  1607.8 MB/sec    1.00     39.7±0.34µs  1672.8 MB/sec
tarball/download_dependency                      1.02      4.1±0.17ms  1059.7 KB/sec    1.00      4.0±0.07ms  1084.5 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.01    183.3±1.52ms 87.3 KElem/sec    1.00    182.0±1.48ms 87.9 KElem/sec
workspace_resolution/hoist_heavy                 1.00    246.4±0.95ms        ? ?/sec    1.02   250.7±17.27ms        ? ?/sec
workspace_sort/chained_projects                  1.00     13.4±1.24ms        ? ?/sec    1.06     14.2±0.87ms        ? ?/sec

Base automatically changed from fix-14575 to main September 6, 2026 22:26
@codecov-commenter

codecov-commenter commented Sep 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.19355% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.38%. Comparing base (46f2140) to head (571ff55).

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/pre_command.rs 98.73% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14627      +/-   ##
==========================================
+ Coverage   89.34%   89.38%   +0.03%     
==========================================
  Files         757      757              
  Lines      135826   135720     -106     
==========================================
- Hits       121355   121308      -47     
+ Misses      14471    14412      -59     

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

`packageManagerDependencies` reached the lockfile from eight call sites:
the pre-command checks for most commands, and a copy-pasted prologue in
each of the seven install-family pipelines. A hand-maintained list of
command variants decided which of the two owned the write, and the two
did not agree on what they wrote.

The pre-command checks now record the pin for every command, so the list
and the pipeline copies are gone. The seven pipelines keep only the
config-dependency pair they all share, behind `config_deps::prepare`.

The install family used to layer `--lockfile-dir` and `--offline` onto
its config before recording, so both now reach the pre-command config
too. `--frozen-lockfile` as typed reaches the write for the first time;
it previously only saw the `frozenLockfile` setting there.

Two bugs fall out of the merge. The pre-command path derived its root
from `workspace_dir` alone while the pipelines used `lockfileDir`, so a
project setting one recorded the pin in a stray lockfile at the
workspace root and never in the lockfile the install reads; the write
now follows the lockfile while the manifest is still read from the
workspace root. And `pnpm unlink` returns before its pipeline when there
is nothing to unlink, which used to skip the record entirely.

The install fast path no longer has to give itself up to let the
pipeline record the pin, since the record already happened by then.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FPfp4dvqS7Nac4Luy3URJm
@qodo-code-review

qodo-code-review Bot commented Sep 6, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Offline deployments contact registries ✓ Resolved 🐞 Bug ⛨ Security
Description
offline_flag omits CliCommand::Deploy, so centralized pre-command pin synchronization receives
the loaded config.offline value instead of deploy's flattened --offline option. When a
deployment has an absent or stale package-manager pin, synchronization constructs a resolver and may
contact the bootstrap registry before dispatch applies deploy's install arguments.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R656-661]

+    let (offline, no_offline) = match command {
+        CliCommand::Ci(args) => (args.install_args.offline, args.install_args.no_offline),
+        CliCommand::Dedupe(args) => (args.offline, args.no_offline),
+        CliCommand::Install(args) => (args.offline, args.no_offline),
+        CliCommand::InstallTest(args) => (args.install_args.offline, args.install_args.no_offline),
+        _ => return None,
Relevance

●●● Strong

Deploy’s flattened offline flag is omitted before synchronization, allowing registry access despite
an explicit offline request.

PR-#14167
PR-#13932

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
DeployArgs embeds flattened InstallArgs, but the new offline-flag extraction match excludes
deploy, and apply_install_cli_config applies those offline fields only during dispatch.
Package-manager synchronization runs earlier and builds its environment resolver directly from the
existing configuration; because that resolver's offline setting controls registry access,
resolving a stale or missing pin can issue a registry request before deploy's offline option takes
effect.

pnpm/crates/cli/src/cli_args/deploy.rs[42-46]
pnpm/crates/cli/src/cli_args/pre_command.rs[227-235]
pnpm/crates/cli/src/cli_args/pre_command.rs[655-669]
pnpm/crates/cli/src/cli_args/pre_command.rs[319-326]
pnpm/crates/cli/src/cli_args/dispatch_install.rs[353-366]
pnpm/crates/cli/src/config_deps.rs[79-124]
pnpm/crates/cli/src/cli_args/pipelines.rs[916-919]
pnpm/crates/cli/src/config_deps.rs[327-340]
pnpm/crates/cli/src/config_deps.rs[365-387]

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 deploy --offline` does not propagate the CLI offline setting into centralized pre-command package-manager pin synchronization. A stale or missing package-manager pin can therefore be resolved online before deploy's configuration is applied.

## Issue Context

`DeployArgs` flattens `InstallArgs`, but `offline_flag` does not extract deploy's nested offline option. Pre-command synchronization constructs its resolver from the earlier loaded configuration before dispatch calls `apply_install_cli_config`, so it may contact the bootstrap registry when pin resolution is required despite the command's offline request. Add deploy's nested install arguments to the shared flag extraction so synchronization observes the same offline mode, and cover this behavior in the pre-command tests.

## Fix Focus Areas

- pnpm/crates/cli/src/cli_args/pre_command.rs[655-669]
- pnpm/crates/cli/src/cli_args/dispatch_install.rs[353-366]
- pnpm/crates/cli/src/cli_args/pre_command/tests.rs[266-283]

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


2. Deploy records pins in the wrong file ✓ Resolved 🐞 Bug ≡ Correctness
Description
lockfile_dir_flag omits CliCommand::Deploy even though DeployArgs flattens InstallArgs and
deploy dispatch later applies those install options before deriving its pipeline root. When `pnpm
deploy --lockfile-dir ...` encounters an unrecorded pin, pre-command synchronization writes using
the configured or default root, after which deploy uses the requested directory without another pin
synchronization.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R644-646]

+        CliCommand::Remove(args) => &args.lockfile_dir,
+        CliCommand::Update(args) => &args.lockfile_dir,
+        _ => return None,
Relevance

●●● Strong

Deploy flattens install options; omitting it deterministically sends pin writes to the wrong
lockfile directory.

PR-#14569
PR-#14079

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
DeployArgs embeds the complete InstallArgs, while deploy dispatch applies those arguments and
derives its actual configuration root only after pre-command processing. The new helper enumerates
other embedded-install commands but falls through for deploy, and the refactored deploy pipeline
only runs config-dependency preparation.

pnpm/crates/cli/src/cli_args/deploy.rs[42-46]
pnpm/crates/cli/src/cli_args/dispatch_install.rs[353-366]
pnpm/crates/cli/src/cli_args/pre_command.rs[635-648]
pnpm/crates/cli/src/cli_args/pipelines.rs[843-851]

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

## Issue description
Deploy's flattened `--lockfile-dir` option is not forwarded into centralized package-manager pin synchronization.

## Issue Context
Deploy applies its embedded install arguments only after pre-command synchronization, and its pipeline no longer performs a second synchronization.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pre_command.rs[638-648]
- pnpm/crates/cli/src/cli_args/pre_command/tests.rs[266-283]

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



Remediation recommended

3. Pin sync ignores install network controls ✓ Resolved 🐞 Bug ➹ Performance
Description
SwitchInput forwards only the offline pair from install arguments, while centralized
synchronization now runs before apply_install_cli_config applies prefer_offline, network
concurrency, timeout, and user-agent overrides. When a stale pin requires resolution, commands using
those options resolve with configuration defaults, including querying the registry instead of
preferring cached metadata.
Code

pnpm/crates/cli/src/cli_args/pre_command.rs[R651-655]

+/// `--offline` / `--no-offline` as typed on the command line. The flags
+/// only turn the setting on, matching [`apply_install_cli_config`].
+///
+/// [`apply_install_cli_config`]: super::pipelines::apply_install_cli_config
+fn offline_flag(command: &CliCommand) -> Option<bool> {
Relevance

●● Moderate

Network-control propagation is plausible, but historical evidence only broadly supports preserving
command configuration before centralized resolution.

PR-#13932
PR-#14167

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
InstallArgs exposes cache and network controls beyond offline, and apply_install_cli_config
writes them into Config. The environment resolver consumes prefer_offline and the configured
network settings, but the newly centralized pre-command path currently extracts only offline before
synchronization occurs.

pnpm/crates/cli/src/cli_args/install.rs[231-274]
pnpm/crates/cli/src/cli_args/pipelines.rs[916-940]
pnpm/crates/cli/src/cli_args/pre_command.rs[651-670]
pnpm/crates/cli/src/config_deps.rs[343-387]

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

## Issue description
Centralized pin synchronization loses install-specific network and cache overrides that previously reached the pipeline synchronization.

## Issue Context
Forward the resolution-relevant `InstallArgs` settings before building the package-manager resolver, while avoiding duplication with normal dispatch configuration.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pre_command.rs[651-671]
- pnpm/crates/cli/src/cli_args/pre_command.rs[1107-1124]

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


Grey Divider

Context sources
✅ Compliance rules (platform): 36 rules
Review mode: 🚀 Fast: This is a single-hunk comment-only change in runtime code with no behavioral effect, so a lightweight review is sufficient.

Grey Divider

Tip of the day
💡 Did you know, you can show, collapse, or hide each part of a finding: code, evidence, and all

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3cf2ad7

@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 github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 6, 2026
The record reads `--lockfile-dir` and the offline flags straight from the
command line, and the two extractors that pulled them out were separate
hand-written lists. Both omitted `pnpm deploy`, which flattens
`InstallArgs` and so carries all of them: a `pnpm deploy --lockfile-dir`
recorded the pin against the wrong directory, and `pnpm deploy
--offline` could reach the bootstrap registry.

The flags are now one `PinFlags` list, and a test asks clap which
commands declare them instead of trusting the list, so a command that
grows one and is not added fails the build rather than the user.

`--offline` also layered onto the config with a boolean or, which cannot
express `--no-offline` clearing a configured `offline`. It goes through
`resolve_bool_override` now, the precedence every other install-family
boolean gets. `--prefer-offline` is read for the same reason: the
bootstrap resolver reads that setting too.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FPfp4dvqS7Nac4Luy3URJm
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 96f5dd8

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

The note above the install `config()` call said `--offline` and
`--prefer-offline` "cannot turn an explicit yaml `true` back off". They
can: `resolve_bool_override` is `force_on || (config && !force_off)`,
its own contract says a set flag wins "either way", and its tests pin
that direction. The note is what the boolean or in the commit before
this one was written from.

The precedence belongs to `resolve_bool_override` and is documented
there, so the note keeps only what the call site knows: why the flags
are applied at that point.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FPfp4dvqS7Nac4Luy3URJm
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 571ff55

@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 fc84749 into main Sep 6, 2026
39 checks passed
@zkochan
zkochan deleted the unify-pm-sync branch September 6, 2026 23:04
biisal pushed a commit to biisal/pnpm that referenced this pull request Sep 15, 2026
)

`packageManagerDependencies` reached the lockfile from eight call sites:
the pre-command checks for most commands, and a copy-pasted prologue in
each of the seven install-family pipelines. A hand-maintained list of
command variants decided which of the two owned the write, and the two
did not agree on what they wrote.

The pre-command checks now record the pin for every command, so the list
and the pipeline copies are gone. The seven pipelines keep only the
config-dependency pair they all share, behind `config_deps::prepare`.

The install family used to layer `--lockfile-dir` and `--offline` onto
its config before recording, so both now reach the pre-command config
too. `--frozen-lockfile` as typed reaches the write for the first time;
it previously only saw the `frozenLockfile` setting there.

Two bugs fall out of the merge. The pre-command path derived its root
from `workspace_dir` alone while the pipelines used `lockfileDir`, so a
project setting one recorded the pin in a stray lockfile at the
workspace root and never in the lockfile the install reads; the write
now follows the lockfile while the manifest is still read from the
workspace root. And `pnpm unlink` returns before its pipeline when there
is nothing to unlink, which used to skip the record entirely.

The install fast path no longer has to give itself up to let the
pipeline record the pin, since the record already happened by then.
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.

2 participants