Skip to content

fix(cli): close the remaining pnpm 12 CLI-surface parity gaps - #13376

Merged
zkochan merged 5 commits into
mainfrom
fix-13315
Jul 26, 2026
Merged

zkochan merged 5 commits into
mainfrom
fix-13315

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #13315.

The issue listed six CLI-surface differences between pnpm 12 (pacquet) and pnpm 11 on the same install. Three landed on main while this was in review — the ignored-package.json#pnpm warning in #13359, and the parsable allowBuilds placeholder plus ERR_PNPM_LOCKFILE_CONFIG_MISMATCH in #13375 — so this PR is rebased down to the four that remain.

1. Scope: is never reported (Rust engine). New pnpm:scope channel (ScopeLog { selected, total?, workspacePrefix? }, matching pnpm's ScopeMessage wire shape) plus a port of reportScope.ts in the default reporter. pnpm gates the line on two things at once — the command must be in COMMANDS_THAT_REPORT_SCOPE, and the run must be workspace-wide (-r / --filter, or install, which pnpm makes recursive by default). pacquet's recursive_by_default set is deliberately narrower than pnpm's, so that conjunction is computed at dispatch (CliCommand::reports_scope) and seeded into the reporter, leaving the event itself command-agnostic.

It is emitted from the two places that already know the counts — the --filter resolution and the installer's workspace walk — so no extra directory walk is added to any install. select_install_family_plan reports once for every plan shape, which matters for sharedWorkspaceLockfile: false: that plan installs each selected project separately, and a child reporting the whole workspace would both duplicate the record and overwrite the filtered count. a_dedicated_lockfile_install_reports_its_scope_once pins that (and fails without the guard).

Seeding the reporter globals also moved ahead of the pre-command checks. They are OnceLocks and the pre-command checks emit — the ignored-pnpm-field warning is the first thing many installs print — so whatever fired first was locking in unset values. That was visible as a missing Scope: line, and latent for cwd and summary_scope. CliArgs::run and the install fast path call it again so a direct in-process caller is configured too; the repeat calls are no-ops.

2. ERR_PNPM_IGNORED_BUILDS does not scaffold allowBuilds entries (Rust engine). #13375 made a scaffolded placeholder loadable; this writes it. Mirrors handleIgnoredBuilds: an install that blocks a build appends <pkg>: set this to true or false under allowBuilds:, keyed by allow_build_key_from_ignored_build so the key matches what pnpm approve-builds writes. Existing entries are never overwritten, and a global install is exempt — its root is a throwaway per-group directory, and its approval prompt already records decisions against the stable global packages dir.

3. The store block on a first install (TypeScript CLI). This one goes the other way: it is a lost log event in pnpm 11, not a pnpm 12 addition. reportContext needs pnpm:package-import-method, which is only emitted by @pnpm/fs.indexed-pkg-importer — and that now runs inside a @pnpm/worker thread whose logger never reaches the reporter. Confirmed with --reporter=ndjson: pnpm 11 emits pnpm:context and never pnpm:package-import-method, so the block is unreachable. The main process already receives importMethod back from the worker and logs it as a progress event, so the two emissions are now one reportPackageImported helper, replacing three copies of the same block.

4. Elapsed time in the verification line (Rust engine). ✓ Lockfile passes supply-chain policies (verified 253ms ago) instead of the timeless (previously verified). The verifiedAt timestamp was already on the wire; only the renderer ignored it.

Every item was checked against pnpm 11.17.0 on the issue's fixtures, not just against the source.

Squash Commit Body

Close the four CLI-surface differences left over from pnpm/pnpm#13315
after pnpm/pnpm#13359 and pnpm/pnpm#13375 landed the other two.

Three land in the Rust engine. The `Scope:` line arrives via a new
`pnpm:scope` channel and a port of `reportScope.ts`; pnpm gates it on the
command being one that reports scope *and* the run being workspace-wide,
and since the engine's recursive-by-default set is narrower than pnpm's,
that conjunction is computed at dispatch and seeded into the reporter.
The event is emitted where the counts already exist — the `--filter`
resolution and the installer's workspace walk — so no install pays for a
second directory walk. A `sharedWorkspaceLockfile: false` plan reports
once for the whole selection rather than once per child install, which
would otherwise overwrite the filtered count with the workspace total.

The second is the `allowBuilds` placeholder an install writes for a build
it blocked, which pnpm/pnpm#13375 taught the engine to read but not yet to
write. The third is the elapsed time on a cache-satisfied lockfile
verdict.

The fourth goes the other way. The store block a first install prints is
unreachable in the TypeScript CLI: `reportContext` needs
`pnpm:package-import-method`, which only `@pnpm/fs.indexed-pkg-importer`
emits, and that runs inside a `@pnpm/worker` thread whose logger never
reaches the reporter. The main process already receives the import method
back from the worker, so it is reported from there instead.

Reporter globals are now seeded before the pre-command checks. They are
`OnceLock`s and the pre-command checks emit, so whatever fired first was
locking in unset values.

Closes pnpm/pnpm#13315

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

Summary by CodeRabbit

  • New Features

    • Install output now displays the resolved workspace scope, including filtered project counts.
    • Blocked dependency build scripts now add editable allowBuilds placeholders without overwriting existing decisions.
    • Restored first-install output explains package linking and store locations.
    • Cached lockfile verification reports how recently it was completed.
  • Bug Fixes

    • Improved recursive command reporting consistency.
    • Lockfile configuration mismatches now produce clearer installation errors.
    • Existing allowBuilds settings are preserved safely.

Copilot AI review requested due to automatic review settings July 25, 2026 17:55

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

Warning

Review limit reached

@zkochan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 10 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e36901e-1dc3-48d5-970a-403df603911e

📥 Commits

Reviewing files that changed from the base of the PR and between cbf633b and 54857d8.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (34)
  • .changeset/restore-package-import-method-log.md
  • .changeset/rust-engine-dates-cached-verification.md
  • .changeset/rust-engine-reports-scope.md
  • .changeset/rust-engine-scaffolds-allow-builds.md
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/dispatch_install.rs
  • pnpm/crates/cli/src/cli_args/dispatch_script.rs
  • pnpm/crates/cli/src/cli_args/install.rs
  • pnpm/crates/cli/src/cli_args/pipelines.rs
  • pnpm/crates/cli/src/cli_args/reporter.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/lib.rs
  • pnpm/crates/cli/tests/approve_builds.rs
  • pnpm/crates/cli/tests/scope_report.rs
  • pnpm/crates/default-reporter/Cargo.toml
  • pnpm/crates/default-reporter/src/format.rs
  • pnpm/crates/default-reporter/src/lib.rs
  • pnpm/crates/default-reporter/src/state.rs
  • pnpm/crates/default-reporter/src/state/tests.rs
  • pnpm/crates/default-reporter/tests/render.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install/tests.rs
  • pnpm/crates/reporter/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/edit.rs
  • pnpm/crates/workspace-manifest-writer/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
  • pnpm11/cli/default-reporter/test/reportingContext.ts
  • pnpm11/core/core-loggers/src/all.ts
  • pnpm11/core/core-loggers/src/reportPackageImported.ts
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm11/installing/deps-restorer/src/linkHoistedModules.ts
📝 Walkthrough

Walkthrough

This PR restores package import method logging in pnpm 11 and adds Rust-engine support for workspace scope reporting, cached lockfile verification ages, automatic allowBuilds scaffolding, and configuration-specific frozen-lockfile diagnostics.

Changes

Package import reporting

Layer / File(s) Summary
Package import event bridge
.changeset/restore-package-import-method-log.md, pnpm11/core/core-loggers/*, pnpm11/installing/deps-*/**, pnpm11/cli/default-reporter/test/*
Package imports use reportPackageImported, which emits progress and recognized import-method events and restores the default reporter’s store-import output.

Rust-engine behavior updates

Layer / File(s) Summary
Scope event and dispatch wiring
.changeset/rust-engine-reports-scope.md, pnpm/crates/cli/src/cli_args/*, pnpm/crates/cli/src/cli_args/run/*, pnpm/crates/cli/src/lib.rs, pnpm/crates/package-manager/src/install.rs, pnpm/crates/reporter/src/lib.rs, pnpm/crates/cli/tests/scope_report.rs
Selected workspace counts are emitted as ScopeLog events, configured per command, threaded through recursive execution, and validated for workspace, filtered, silent, and NDJSON cases.
Scope and cached-verification rendering
.changeset/rust-engine-dates-cached-verification.md, pnpm/crates/default-reporter/*
The default reporter conditionally renders scope lines and formats valid cached lockfile verdicts using relative elapsed time, with fallback and future-timestamp handling.
Tri-state allowBuilds and scaffolding
.changeset/rust-engine-scaffolds-allow-builds.md, pnpm/crates/package-manager/src/install.rs, pnpm/crates/workspace-manifest-writer/*, pnpm/crates/cli/tests/approve_builds.rs
Blocked builds add undecided allowBuilds placeholders without overwriting existing entries; placeholder parsing, manifest merging, idempotency, and blocked-build behavior are tested.
Frozen-lockfile mismatch diagnostics
pnpm/crates/package-manager/src/install.rs
Stale lockfiles caused by changed configuration settings use ERR_PNPM_LOCKFILE_CONFIG_MISMATCH; other stale conditions remain outdated-lockfile errors.

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

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant InstallPipeline
  participant DefaultReporter
  CLI->>DefaultReporter: configure scope reporting
  InstallPipeline->>DefaultReporter: emit selected and total project counts
  DefaultReporter-->>CLI: render Scope line when applicable
Loading
sequenceDiagram
  participant DependencyLinker
  participant CoreLogger
  participant DefaultReporter
  DependencyLinker->>CoreLogger: report imported package and method
  CoreLogger->>DefaultReporter: emit progress and import-method events
  DefaultReporter-->>DependencyLinker: render store import message
Loading

Possibly related issues

  • pnpm/pacquet issue 347 — Covers the same package-import logging call sites updated in this PR.
  • pnpm/pnpm issue 13315 — Covers the scope reporting, allowBuilds scaffolding, and cached verification changes implemented here.

Possibly related PRs

  • pnpm/pnpm#13150 — Related allowBuilds and pending-build handling changes.
  • pnpm/pnpm#13294 — Related CLI startup and directory-resolution changes.
  • pnpm/pnpm#13375 — Related parsing and handling of undecided allowBuilds entries.

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

Suggested reviewers: copilot

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13315

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.

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (5): Last reviewed commit: "test(cli): compare the scope prefix agai..." | Re-trigger Greptile

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix pnpm 12 parity gaps: scope reporting, allowBuilds scaffolds, config-mismatch errors

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

Grey Divider

AI Description

• Restore pnpm 11-compatible CLI output: Scope: line, store/import-method block, and ignored
 package.json#pnpm warnings.
• Improve frozen-lockfile diagnostics by separating manifest drift from settings drift
 (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
• Scaffold allowBuilds placeholders on ignored builds and harden YAML parsing; add coverage across
 Rust + pnpm11.
Diagram

graph TD
  A["Rust CLI (pacquet)"] --> B["Reporter events"] --> C["Default reporter"]
  A --> D["Installer"] --> B
  D --> G["Workspace manifest writer"] --> F[("pnpm-workspace.yaml")] --> D
  D --> E["Lockfile freshness"] --> D
  H["pnpm11 reportPackageImported"] --> B
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Eliminate global OnceLock reporter state
  • ➕ Removes ordering hazards ("first emitter wins") entirely
  • ➕ Makes reporter behavior more explicit and testable per invocation
  • ➖ Requires more plumbing through CLI/installer to pass options into the reporter sink
  • ➖ Potentially larger refactor across many call sites than this parity-focused PR
2. Gate `Scope:` printing at emission sites only
  • ➕ Keeps reporter command-agnostic without needing a reports_scope flag
  • ➕ Avoids emitting events that will be dropped
  • ➖ Duplicates gating logic across multiple emitters (--filter resolution, workspace walk, recursive run)
  • ➖ Harder to keep exact parity with pnpm’s COMMANDS_THAT_REPORT_SCOPE behavior over time
3. Write allowBuilds scaffolds via YAML AST serialization
  • ➕ More robust handling of YAML edge-cases (comments/quotes/multiline)
  • ➕ Less custom string surgery
  • ➖ Would likely lose existing formatting/order guarantees that pnpm users expect
  • ➖ Higher dependency/complexity cost for a small, well-scoped edit operation

Recommendation: Keep the current approach: it targets CLI-surface parity with minimal behavioral risk and adds solid regression tests. The early configure_reporter() call is the right localized fix for the OnceLock ordering bug without forcing a large refactor; consider the "no global reporter state" alternative only if more reporter options accumulate.

Files changed (45) +1057 / -84

Enhancement (17) +433 / -35
cli_command.rsAdd command-level 'reports_scope' gating +21/-0

Add command-level 'reports_scope' gating

• Introduces 'CliCommand::reports_scope(recursive)' to mirror pnpm’s rule: only certain commands report scope, and only when operating workspace-wide (recursive/filter, or install-by-nature).

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

dispatch_install.rsThread reporter emitter into recursive install/test flow +2/-2

Thread reporter emitter into recursive install/test flow

• Plumbs 'reporter_emit()' into recursive script/install execution so scope events and other early output are correctly routed for the active reporter type.

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

dispatch_script.rsThread reporter emitter into recursive run/test paths +3/-3

Thread reporter emitter into recursive run/test paths

• Passes an 'emit' function into recursive run paths so workspace scope can be reported before scripts execute.

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

pipelines.rsEmit 'pnpm:scope' when resolving '--filter' selections +40/-6

Emit 'pnpm:scope' when resolving '--filter' selections

• Emits a 'ScopeLog' event during filter/recursive selection resolution to confirm the chosen workspace subset without adding extra directory walks. Makes plan selection generic over the reporter to emit events.

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

reporter.rsAdd 'reports_scope' to default reporter configuration +4/-2

Add 'reports_scope' to default reporter configuration

• Extends 'configure_default_reporter()' to seed whether the current command should render 'Scope:' lines, alongside cwd and summary-scope seeding.

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

run.rsPass emit callback into recursive run +8/-2

Pass emit callback into recursive run

• Changes recursive run entrypoints to accept an 'emit' callback so the recursive runner can publish scope information before executing scripts.

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

recursive.rsEmit scope before executing recursive scripts +18/-1

Emit scope before executing recursive scripts

• Emits a 'ScopeLog' event based on the resolved workspace graph so users can verify what '--filter' selected before any scripts run.

pnpm/crates/cli/src/cli_args/run/recursive.rs

lib.rsRe-export AllowBuild and decided_allow_builds +3/-3

Re-export AllowBuild and decided_allow_builds

• Surfaces the new 'AllowBuild' type and 'decided_allow_builds()' helper from the workspace YAML module for use by CLI and installer code.

pnpm/crates/config/src/lib.rs

format.rsAdd compact duration formatter for relative ages +14/-0

Add compact duration formatter for relative ages

• Introduces 'pretty_ms_compact()' to render a single truncated unit (e.g., '2m', '2d') for short relative-age strings.

pnpm/crates/default-reporter/src/format.rs

lib.rsSeed 'reports_scope' option into reporter state +15/-3

Seed 'reports_scope' option into reporter state

• Adds a process-global 'REPORTS_SCOPE' OnceLock and uses unified options initialization to pass 'reports_scope' into 'ReporterState' construction.

pnpm/crates/default-reporter/src/lib.rs

state.rsRender 'Scope:' and date cached lockfile verification verdicts +60/-4

Render 'Scope:' and date cached lockfile verification verdicts

• Adds 'reports_scope'/slot state and a 'pnpm:scope' handler that matches pnpm behavior (silent for single-project selection). Enhances cached lockfile verification output to include relative ages when timestamps are present and safe (clamped at zero).

pnpm/crates/default-reporter/src/state.rs

freshness.rsExpose staleness reasons’ originating setting name +40/-2

Expose staleness reasons’ originating setting name

• Adds 'StalenessReason::changed_setting()' to distinguish settings drift (named setting) from manifest drift (unnamed), aligning with pnpm’s 'getOutdatedLockfileSetting' conventions.

pnpm/crates/lockfile/src/freshness.rs

install.rsAdd config-mismatch error, emit scope, scaffold allowBuilds placeholders +69/-3

Add config-mismatch error, emit scope, scaffold allowBuilds placeholders

• Introduces 'ERR_PNPM_LOCKFILE_CONFIG_MISMATCH' and maps freshness staleness reasons with named settings to that error under frozen installs. Emits workspace scope for unnarrowed installs and scaffolds undecided allowBuilds placeholders for ignored builds (excluding global installs), failing loudly if the scaffold cannot be written.

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

lib.rsAdd 'pnpm:scope' log event and payload type +24/-0

Add 'pnpm:scope' log event and payload type

• Extends the shared reporter protocol with a 'Scope' event and 'ScopeLog' payload mirroring pnpm’s wire shape (selected/total/workspacePrefix).

pnpm/crates/reporter/src/lib.rs

edit.rsSupport inserting undecided allowBuilds entries and robust comment handling +60/-4

Support inserting undecided allowBuilds entries and robust comment handling

• Adds 'add_undecided_allow_build()' to insert placeholders without overwriting existing entries. Fixes boolean replacement to preserve inline comments even when scalar values contain spaces by correctly detecting comment boundaries.

pnpm/crates/workspace-manifest-writer/src/edit.rs

lib.rsAdd public allowBuilds scaffolding API for ignored builds +51/-0

Add public allowBuilds scaffolding API for ignored builds

• Introduces 'scaffold_allow_builds()' and a shared placeholder constant, creating/updating 'pnpm-workspace.yaml' deterministically while preserving formatting and rejecting control characters.

pnpm/crates/workspace-manifest-writer/src/lib.rs

all.tsExport new reportPackageImported helper +1/-0

Export new reportPackageImported helper

• Re-exports 'reportPackageImported' from the core-loggers index so installers/restorers can use it in place of direct progress logging.

pnpm11/core/core-loggers/src/all.ts

Bug fix (10) +96 / -20
cli_args.rsDeclare legacy pnpm-field warning module +1/-0

Declare legacy pnpm-field warning module

• Registers the previously-unused legacy pnpm-field module so it is compiled and can be invoked from pre-command checks.

pnpm/crates/cli/src/cli_args.rs

dispatch.rsSeed default reporter state before any emission +18/-6

Seed default reporter state before any emission

• Adds 'CliArgs::configure_reporter()' and moves default-reporter configuration earlier in the CLI lifecycle so pre-command output (warnings/scope) sees correct globals. Stops configuring the reporter in later codepaths where it could lose the OnceLock race.

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

global.rsDrop undecided allowBuilds entries for global installs +4/-2

Drop undecided allowBuilds entries for global installs

• Applies 'decided_allow_builds()' when loading global workspace settings so string placeholders do not enter the effective boolean allowBuilds map.

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

pre_command.rsWarn about ignored 'package.json#pnpm' fields early +3/-0

Warn about ignored 'package.json#pnpm' fields early

• Invokes legacy pnpm-field warning logic during pre-command planning, anchored at the workspace root used for manifest loading, so the warning precedes command output.

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

lib.rsConfigure reporter immediately after argument normalization +1/-0

Configure reporter immediately after argument normalization

• Calls 'args.configure_reporter()' after recursive/workspace-root promotion so reporter globals are initialized before pre-command checks can emit warnings or scope lines.

pnpm/crates/cli/src/lib.rs

workspace_yaml.rsModel allowBuilds as boolean-or-string and drop undecided entries +29/-3

Model allowBuilds as boolean-or-string and drop undecided entries

• Changes 'allowBuilds' parsing to accept booleans or string placeholders via an untagged 'AllowBuild' enum. Applies only decided boolean entries to effective config via 'decided_allow_builds()'.

pnpm/crates/config/src/workspace_yaml.rs

reportPackageImported.tsAdd main-process package import reporting helper +34/-0

Add main-process package import reporting helper

• Adds 'reportPackageImported()' to emit both progress and import-method logs from the main process using the method returned by the worker, restoring first-install context output.

pnpm11/core/core-loggers/src/reportPackageImported.ts

link.tsUse reportPackageImported instead of direct progress logging +2/-3

Use reportPackageImported instead of direct progress logging

• Switches the linking path to call 'reportPackageImported()' when an import method is available, so the reporter receives both the progress increment and the import-method signal.

pnpm11/installing/deps-installer/src/install/link.ts

index.tsUse reportPackageImported in deps-restorer linking path +2/-3

Use reportPackageImported in deps-restorer linking path

• Replaces direct progress logging with 'reportPackageImported()' so import-method reporting is consistent in the restore flow.

pnpm11/installing/deps-restorer/src/index.ts

linkHoistedModules.tsUse reportPackageImported when linking hoisted modules +2/-3

Use reportPackageImported when linking hoisted modules

• Switches hoisted-module linking to the main-process helper so the store/import-method context block can be rendered again.

pnpm11/installing/deps-restorer/src/linkHoistedModules.ts

Tests (10) +478 / -29
approve_builds.rsTest allowBuilds scaffold behavior and YAML merging +54/-6

Test allowBuilds scaffold behavior and YAML merging

• Adds coverage ensuring installs scaffold undecided allowBuilds entries, do not duplicate on reruns, and keep blocked builds blocked until explicitly decided. Updates YAML parsing and seeding helpers to tolerate string placeholders.

pnpm/crates/cli/tests/approve_builds.rs

frozen_config_mismatch.rsAdd CLI-level test for 'ERR_PNPM_LOCKFILE_CONFIG_MISMATCH' +78/-0

Add CLI-level test for 'ERR_PNPM_LOCKFILE_CONFIG_MISMATCH'

• Introduces an end-to-end test that creates a lockfile under overrides, then removes overrides and asserts frozen install fails with the config-mismatch code and message.

pnpm/crates/cli/tests/frozen_config_mismatch.rs

scope_report.rsAdd CLI-level tests for 'Scope:' and ignored pnpm-field warning +138/-0

Add CLI-level tests for 'Scope:' and ignored pnpm-field warning

• Adds workspace fixtures and assertions covering full-workspace scope, filtered scope, silence for single-project selections and non-reporting commands, and the ignored 'package.json#pnpm' keys warning.

pnpm/crates/cli/tests/scope_report.rs

tests.rsTest allowBuilds placeholder parsing and filtering +27/-4

Test allowBuilds placeholder parsing and filtering

• Updates allowBuilds tests for the new enum representation and adds a regression test ensuring string placeholders load and do not influence build policy.

pnpm/crates/config/src/workspace_yaml/tests.rs

tests.rsUnit-test cached verification age rendering +33/-0

Unit-test cached verification age rendering

• Adds tests for relative age formatting, fallback behavior without usable timestamps, and clamping when timestamps are in the future.

pnpm/crates/default-reporter/src/state/tests.rs

render.rsAdd render tests for 'Scope:' behavior +56/-1

Add render tests for 'Scope:' behavior

• Extends render harness to include 'ScopeLog' and verifies output for full vs partial workspace, non-workspace scopes, silence for single selection, and silence when command does not report scope.

pnpm/crates/default-reporter/tests/render.rs

tests.rsTest 'changed_setting()' mapping for settings drift +29/-0

Test 'changed_setting()' mapping for settings drift

• Adds regression tests ensuring settings-drift reasons return the correct pnpm setting names and that manifest-drift reasons return 'None'.

pnpm/crates/lockfile/src/freshness/tests.rs

tests.rsUpdate frozen-lockfile tests to expect config-mismatch errors +14/-17

Update frozen-lockfile tests to expect config-mismatch errors

• Adjusts tests so overrides and packageExtensions checksum drift are treated as settings drift and assert the new 'LockfileConfigMismatch' error payload instead of generic outdated-lockfile errors.

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

tests.rsTest placeholder replacement and comment preservation +16/-0

Test placeholder replacement and comment preservation

• Adds coverage ensuring deciding a previously-scaffolded placeholder replaces the full scalar and that inline comments are preserved when updating allowBuilds decisions.

pnpm/crates/workspace-manifest-writer/src/tests.rs

reportingContext.tsAdd test ensuring import-method block is emitted from main process +33/-1

Add test ensuring import-method block is emitted from main process

• Updates reporter test to drive output through a new main-process helper, ensuring the store block prints even though the actual import happens in a worker thread.

pnpm11/cli/default-reporter/test/reportingContext.ts

Documentation (6) +48 / -0
restore-package-import-method-log.mdAdd changeset for restored store/import-method block +16/-0

Add changeset for restored store/import-method block

• Documents restoring the first-install store block by re-reporting the package import method from the main process. Notes why the worker-thread logger never reached the reporter and links to the parity issue.

.changeset/restore-package-import-method-log.md

rust-engine-dates-cached-verification.mdAdd changeset for dated cached lockfile verification +5/-0

Add changeset for dated cached lockfile verification

• Documents improved lockfile-verification output that reports how long ago a cached verdict was verified instead of a timeless message.

.changeset/rust-engine-dates-cached-verification.md

rust-engine-lockfile-config-mismatch.mdAdd changeset for frozen-lockfile settings drift error code +5/-0

Add changeset for frozen-lockfile settings drift error code

• Documents distinguishing settings drift from manifest drift under '--frozen-lockfile', emitting 'ERR_PNPM_LOCKFILE_CONFIG_MISMATCH' naming the setting.

.changeset/rust-engine-lockfile-config-mismatch.md

rust-engine-reports-scope.mdAdd changeset for workspace 'Scope:' reporting +5/-0

Add changeset for workspace 'Scope:' reporting

• Documents printing 'Scope:' lines for selected commands, including filtered vs full-workspace shapes.

.changeset/rust-engine-reports-scope.md

rust-engine-scaffolds-allow-builds.mdAdd changeset for allowBuilds scaffolding on ignored builds +12/-0

Add changeset for allowBuilds scaffolding on ignored builds

• Documents appending 'allowBuilds' placeholders to 'pnpm-workspace.yaml' when builds are blocked, without overwriting existing entries and without breaking config load on string values.

.changeset/rust-engine-scaffolds-allow-builds.md

rust-engine-warns-about-ignored-pnpm-field.mdAdd changeset for ignored package.json#pnpm warning +5/-0

Add changeset for ignored package.json#pnpm warning

• Documents emitting a warning that enumerates ignored 'package.json#pnpm' keys to make downstream failures self-explanatory.

.changeset/rust-engine-warns-about-ignored-pnpm-field.md

Other (2) +2 / -0
Cargo.lockAdd chrono dependency to default reporter crate +1/-0

Add chrono dependency to default reporter crate

• Updates the workspace lockfile to include 'chrono' for the Rust default reporter, enabling timestamp parsing for cached-verification messaging.

Cargo.lock

Cargo.tomlAdd chrono dependency for timestamp handling +1/-0

Add chrono dependency for timestamp handling

• Adds 'chrono' to support parsing RFC3339 timestamps when rendering cached lockfile verification ages.

pnpm/crates/default-reporter/Cargo.toml

@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.03     11.8±0.03ms    31.7 MB/sec    1.00     11.5±0.04ms    32.6 MB/sec
packument/parse                1.00     37.0±0.14µs  1794.2 MB/sec    1.02     37.7±0.08µs  1760.0 MB/sec
tarball/download_dependency    1.06      2.4±0.09ms  1833.8 KB/sec    1.00      2.2±0.06ms  1940.3 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Action required

1. Scaffold leaks URL credentials ✗ Dismissed 🐞 Bug ⛨ Security
Description
The new ignored-build scaffolding writes allowBuilds keys derived from ignored depPaths into
pnpm-workspace.yaml; for non-registry artifacts those keys can be full git/tarball locators that
may embed credentials/tokens. This can persist secrets into a repo file (and thus into VCS/CI
artifacts) even though the credential was only meant for dependency fetching.
Code

pnpm/crates/package-manager/src/install.rs[R2468-2486]

+        let is_global_install = config
+            .global_pkg_dir
+            .as_deref()
+            .is_some_and(|global_pkg_dir| workspace_root.starts_with(global_pkg_dir));
+        // Leave the user a line to edit in `pnpm-workspace.yaml` for every
+        // build this install blocked, so approving one is an edit rather
+        // than recalling the `allowBuilds` shape. Written before the strict
+        // failure below, which is the very run whose message it answers.
+        if !ignored_builds.is_empty() && !is_global_install {
+            let allow_build_keys: BTreeSet<String> = ignored_builds
+                .iter()
+                .map(|dep_path| crate::allow_build_key_from_ignored_build(dep_path))
+                .collect();
+            pacquet_workspace_manifest_writer::scaffold_allow_builds(
+                config.workspace_dir.as_deref().unwrap_or(&workspace_root),
+                allow_build_keys.iter().map(String::as_str),
+            )
+            .map_err(InstallError::ScaffoldAllowBuilds)?;
+        }
Relevance

⭐⭐⭐ High

Repo has accepted multiple fixes to prevent leaking credentials/tokens via URLs/headers; persisting
locator secrets to YAML will be fixed.

PR-#13207
PR-#13000

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The scaffolding path collects keys from ignored_builds depPaths and writes them to
pnpm-workspace.yaml; for non-registry artifacts the key is the peer-suffix-free depPath itself,
which can be a URL-like locator. That means any credentials embedded in the locator can be persisted
into the workspace manifest.

pnpm/crates/package-manager/src/install.rs[2464-2486]
pnpm/crates/package-manager/src/build_modules.rs[266-276]
pnpm/crates/deps-path/src/suffix_index.rs[59-67]
pnpm/crates/workspace-manifest-writer/src/lib.rs[305-354]

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

### Issue description
`install` scaffolds `allowBuilds` placeholders using `allow_build_key_from_ignored_build(dep_path)` and writes those keys into `pnpm-workspace.yaml`. For git/tarball deps, the key can be a URL-like depPath which may include `user:pass@host` or token userinfo, causing secret persistence in a workspace file.

### Issue Context
- This is security-sensitive because dependency locators are attacker-controlled and may contain embedded credentials.
- The key still needs to remain a stable, trust-relevant identifier for build approval (don’t broaden approvals by over-normalizing).

### Fix Focus Areas
- pnpm/crates/package-manager/src/install.rs[2468-2486]
- pnpm/crates/package-manager/src/build_modules.rs[266-276]
- pnpm/crates/workspace-manifest-writer/src/lib.rs[305-354]

### Suggested fix
1. Introduce a normalization step for allowBuilds keys that **strips URL userinfo only** (e.g. `https://[email protected]/...` -> `https://github.com/...`) while preserving the rest of the locator (path + ref + query/fragment if they are identity-relevant in your depPath format).
2. Apply the same normalization consistently wherever allowBuild keys are:
  - generated from ignored builds (`allow_build_key_from_ignored_build`), and
  - matched against config (`BuildPolicy::from_config` / `check`).
3. Add a regression test covering a git depPath that contains userinfo, asserting scaffolding does not write the secret but approvals still match the normalized key.

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


2. Scope events bypass gating 🐞 Bug ≡ Correctness
Description
select_install_family_plan emits pnpm:scope for any recursive/filter selection, but the command
gate (reports_scope) is only applied inside the default reporter’s rendering logic. As a result,
--reporter=ndjson will still output pnpm:scope records for commands pnpm doesn’t report scope
for (e.g. add), which can break consumers relying on pnpm-compatible ndjson event sets.
Code

pnpm/crates/cli/src/cli_args/pipelines.rs[R82-87]

+    Reporter::emit(&LogEvent::Scope(ScopeLog {
+        level: LogLevel::Debug,
+        selected: selection.selected_dirs.len(),
+        total: Some(selection.projects.len()),
+        workspace_prefix: Some(selection.workspace_root.to_string_lossy().into_owned()),
+    }));
Relevance

⭐⭐ Medium

Potential ndjson contract break is plausible, but no close historical precedent on gating event
emission vs rendering policy.

PR-#13176

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Scope is emitted during install-family plan selection whenever recursion/filter selection exists,
but the command-level policy is defined separately and only wired into the default reporter
configuration; ndjson emission does not consult that policy and will serialize the event if it is
emitted.

pnpm/crates/cli/src/cli_args/pipelines.rs[63-87]
pnpm/crates/cli/src/cli_args/cli_command.rs[615-634]
pnpm/crates/cli/src/cli_args/dispatch.rs[56-74]
pnpm/crates/cli/src/cli_args/reporter.rs[23-31]
pnpm/crates/reporter/src/lib.rs[21-46]
pnpm/crates/reporter/src/lib.rs[906-927]

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

### Issue description
`LogEvent::Scope` is emitted unconditionally for any recursive/filter workspace selection, while the pnpm command gate (which commands "report scope") is enforced only by the default reporter via `reports_scope`. Other reporters (notably ndjson) will serialize all events, so they can expose scope records for commands that should not report scope.

### Issue Context
- `CliCommand::reports_scope(...)` defines which commands should report scope.
- `NdjsonReporter` writes every `LogEvent` it receives.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pipelines.rs[63-87]
- pnpm/crates/cli/src/cli_args/cli_command.rs[615-634]
- pnpm/crates/cli/src/cli_args/dispatch.rs[66-73]
- pnpm/crates/cli/src/cli_args/reporter.rs[23-31]

### Suggested fix
Option A (preferred): Gate emission at the source.
- Thread a `reports_scope: bool` into `select_install_family_plan(...)` (or into its callers) and only `emit(LogEvent::Scope(...))` when true.

Option B: Gate at the emitter wrapper for all reporters.
- Extend `reporter_emit(...)` (or add a new helper) to return an `emit` fn that drops `LogEvent::Scope` when `!reports_scope`.

Add a regression test:
- Run a non-reporting command (e.g. `pnpm -r add ... --reporter=ndjson`) and assert there is **no** `"name":"pnpm:scope"` record.

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



Remediation recommended

3. Fast-path drops workspacePrefix 🐞 Bug ≡ Correctness
Description
finished_via_up_to_date_fast_path populates ScopeLog.workspace_prefix only from
config.workspace_dir, but install_already_up_to_date may discover a workspace root even when
config.workspace_dir is None, causing the fast path to emit a different pnpm:scope shape and
the default reporter to render “projects” instead of “workspace projects”. This creates pnpm/pacquet
CLI-surface parity drift specifically on the common “Already up to date” path and can break ndjson
consumers expecting workspacePrefix when total is present.
Code

pnpm/crates/cli/src/cli_args/install.rs[R355-363]

+        emit(&pacquet_reporter::LogEvent::Scope(pacquet_reporter::ScopeLog {
+            level: pacquet_reporter::LogLevel::Debug,
+            selected: up_to_date.project_count.unwrap_or(1),
+            total: up_to_date.project_count,
+            workspace_prefix: config
+                .workspace_dir
+                .as_deref()
+                .map(|dir| dir.to_string_lossy().into_owned()),
+        }));
Relevance

⭐⭐⭐ High

Repo repeatedly fixes fast-path/full-path parity; differing scope payload/wording on up-to-date path
is likely addressed.

PR-#13144
PR-#13152

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The fast path emits workspace_prefix from config.workspace_dir, but the fast-path checker can
discover the workspace directory even when config.workspace_dir is None and returns it via
UpToDateWorkspace.root. The full install path emits workspace_prefix from the discovered
workspace dir (workspace_dir_opt), so the two paths can produce different scope payloads/wording
for the same workspace.

pnpm/crates/cli/src/cli_args/install.rs[333-364]
pnpm/crates/package-manager/src/install.rs[3700-3710]
pnpm/crates/package-manager/src/install.rs[4036-4043]
pnpm/crates/package-manager/src/install.rs[908-928]

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 up-to-date fast path emits `pnpm:scope` with `workspace_prefix` sourced from `config.workspace_dir`, but the fast-path decision logic can discover the workspace root even when `config.workspace_dir` is unset. This makes the fast-path scope payload (and default reporter wording) diverge from the full install path.

### Issue Context
- `install_already_up_to_date()` discovers the workspace dir via `configured_or_discovered_workspace_dir()` when `config.workspace_dir` is `None`, and returns the discovered root as `UpToDateWorkspace.root`.
- The full install path’s scope emission uses the discovered `workspace_dir_opt` for `workspace_prefix`.
- The fast path should mirror that behavior to keep human output and ndjson payloads consistent.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/install.rs[352-363]
- pnpm/crates/package-manager/src/install.rs[3700-3710]
- pnpm/crates/package-manager/src/install.rs[4036-4043]
- pnpm/crates/package-manager/src/install.rs[908-928]

### Implementation guidance
- In the fast path, set `workspace_prefix` based on the *discovered* workspace root (e.g., `up_to_date.root`) when `up_to_date.project_count.is_some()`.
 - Example logic: `let workspace_prefix = up_to_date.project_count.map(|_| up_to_date.root.to_string_lossy().into_owned());`
 - Or extend `UpToDateWorkspace` to carry `workspace_prefix: Option<PathBuf/String>` directly (preferred if you want a single source of truth).
- Add a regression test that exercises the fast path in a workspace where `config.workspace_dir` is not explicitly set, and asserts the ndjson `pnpm:scope.workspacePrefix` is present and matches the discovered workspace root.

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


4. Duplicate reportPackageImported comment 📘 Rule violation ⚙ Maintainability
Description
The new test comment above reportPackageImported restates the same rationale already documented in
the callee’s JSDoc, duplicating documentation and increasing maintenance burden when behavior
changes.
Code

pnpm11/cli/default-reporter/test/reportingContext.ts[R89-92]

+// The import itself runs in a worker thread whose loggers never reach the
+// reporter, so the store block only appears if the main process re-emits
+// the method the worker reported back. This drives the reporter through
+// `reportPackageImported`, the call the linking code actually makes.
Relevance

⭐⭐⭐ High

Team has accepted de-duplicating repeated explanatory comments to avoid drift; likely to
remove/shorten this call-site comment.

PR-#13207

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The call-site comment explains why reportPackageImported must be used (worker thread loggers not
connected; main process re-emits), which is already covered by the JSDoc on reportPackageImported;
this is duplicated documentation at the call site.

Rule 713431: Avoid duplicating JSDoc content in call-site comments
pnpm11/cli/default-reporter/test/reportingContext.ts[89-92]
pnpm11/core/core-loggers/src/reportPackageImported.ts[4-13]

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 duplicates the existing JSDoc contract/rationale of `reportPackageImported`, which violates the rule to avoid repeating JSDoc content at call sites.

## Issue Context
`pnpm11/core/core-loggers/src/reportPackageImported.ts` already documents why this helper exists and what it emits.

## Fix Focus Areas
- pnpm11/cli/default-reporter/test/reportingContext.ts[89-92]

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


5. Historical comment in scope_report ✓ Resolved 📘 Rule violation ⚙ Maintainability
Description
Newly added comments use historical phrasing (e.g., "stopped reading ... in v10" and "from before
the timestamp existed") instead of documenting the current behavior contract. This risks the
comments becoming stale and violates the guideline to avoid historical/temporal implementation notes
inline.
Code

pnpm/crates/cli/tests/scope_report.rs[R109-111]

+/// pnpm stopped reading install settings from `package.json#pnpm` in v10.
+/// A project that never migrated gets told which keys were dropped, so the
+/// downstream lockfile mismatch is self-explanatory.
Relevance

⭐⭐⭐ High

Repo repeatedly accepts rewording comments to avoid historical phrasing and maintenance drift,
especially in tests.

PR-#13138
PR-#13246
PR-#13343

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 requires that added/modified comments describe current behavior rather than
historical implementations. The cited additions in pnpm/crates/cli/tests/scope_report.rs
explicitly reference past behavior ("stopped reading ... in v10"), and the cited comment in
pnpm/crates/default-reporter/src/state/tests.rs similarly frames a case historically ("from before
the timestamp existed") rather than stating the present-day condition being handled (e.g.,
missing/unusable timestamp), demonstrating noncompliance with the rule.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/scope_report.rs[109-111]
pnpm/crates/default-reporter/src/state/tests.rs[17-19]

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

## Issue description
Rewrite newly added comments that currently use historical/temporal phrasing so they describe the present-day behavior contract/invariant (e.g., conditions like missing/unparsable timestamps) rather than referencing when behavior changed.

## Issue Context
PR Compliance ID 772199 forbids historical/temporal phrasing in added comments because it can become stale; inline comments should document current behavior/invariants instead of notes like "stopped reading ... in v10" or "from before the timestamp existed".

## Fix Focus Areas
- pnpm/crates/cli/tests/scope_report.rs[109-111]
- pnpm/crates/default-reporter/src/state/tests.rs[17-19]

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


View more (2)
6. Extra dir canonicalization 🐞 Bug ➹ Performance
Description
CliArgs::configure_reporter() canonicalizes --dir, but it’s invoked before pre-command checks
and again inside CliArgs::run, and CliArgs::run then canonicalizes --dir again for actual
dispatch. This adds redundant filesystem work to every invocation, which can show up as startup
latency on slow/remote filesystems.
Code

pnpm/crates/cli/src/cli_args/dispatch.rs[R66-73]

+    pub fn configure_reporter(&self) {
+        let dir = dunce::canonicalize(&self.dir).unwrap_or_else(|_| self.dir.clone());
+        configure_default_reporter(
+            self.reporter,
+            &dir,
+            self.command.default_reporter_summary_scope(),
+            self.command.reports_scope(self.recursive),
+        );
Relevance

⭐⭐ Medium

Perf/micro-duplication refactors around canonicalize/normalize were previously rejected; unclear if
multiple canonicalize calls matter here.

PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The entrypoint calls args.configure_reporter() early, CliArgs::run calls it again, and
CliArgs::run also canonicalizes --dir for dispatch; each configure_reporter() call runs
dunce::canonicalize before hitting the reporter’s write-once globals.

pnpm/crates/cli/src/cli_args/dispatch.rs[56-74]
pnpm/crates/cli/src/cli_args/dispatch.rs[151-197]
pnpm/crates/cli/src/lib.rs[97-103]

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

### Issue description
`configure_reporter()` performs `dunce::canonicalize(&self.dir)` even though `CliArgs::run` later canonicalizes again for execution, and the entrypoint calls `configure_reporter()` up-front as well. The `OnceLock` makes the *set* idempotent, but the canonicalize syscall still runs each time.

### Issue Context
This is a small but global perf tax: canonicalization can touch the filesystem and be slow on network mounts.

### Fix Focus Areas
- pnpm/crates/cli/src/lib.rs[97-102]
- pnpm/crates/cli/src/cli_args/dispatch.rs[56-74]
- pnpm/crates/cli/src/cli_args/dispatch.rs[187-197]

### Suggested fix
- Avoid re-canonicalizing when already configured:
 - add a cheap `pacquet_default_reporter::is_configured()` / `cwd_is_set()` check, and return early before canonicalizing, **or**
 - refactor `configure_reporter` to accept an already-canonicalized `&Path` so `CliArgs::run` can pass its `dir` through.
- Keep the early call (before pre-command emits) but ensure only one canonicalize happens in the common path.

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


7. Redundant import-method events 🐞 Bug ➹ Performance
Description
reportPackageImported() emits pnpm:package-import-method on every imported package, but the
default reporter only consumes the first import-method message to render the store block. This adds
avoidable per-package event creation/dispatch overhead on large installs (especially in the same
loops already emitting progress).
Code

pnpm11/core/core-loggers/src/reportPackageImported.ts[R21-29]

+  progressLogger.debug({
+    method: opts.method,
+    requester: opts.requester,
+    status: 'imported',
+    to: opts.to,
+  })
+  if (isKnownImportMethod(opts.method)) {
+    packageImportMethodLogger.debug({ method: opts.method })
+  }
Relevance

⭐⭐ Medium

Team accepts perf cleanups, but changing per-package logging semantics may be contentious without
closer precedent for event deduping.

PR-#13289
PR-#12491

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper emits pnpm:package-import-method per import, and it is called from code that runs once
per package. Meanwhile, the reporter explicitly takes only the first import-method event, so
emitting more than one is redundant work.

pnpm11/core/core-loggers/src/reportPackageImported.ts[14-30]
pnpm11/installing/deps-installer/src/install/link.ts[538-552]
pnpm11/cli/default-reporter/src/reporterForClient/reportContext.ts[15-18]
pnpm11/fs/indexed-pkg-importer/src/index.ts[31-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
`reportPackageImported()` emits `packageImportMethodLogger.debug({ method })` for every imported package. The default reporter only needs the first `pnpm:package-import-method` event (it does `take(1)`), so subsequent emissions are redundant and add per-package overhead.

### Issue Context
- Call sites invoke `reportPackageImported()` inside per-dependency import loops.
- The reporter’s context block combines the first `pnpm:context` and first `pnpm:package-import-method`.
- Historically, `packageImportMethodLogger.debug(...)` was emitted once when the importer chose a method, not per package.

### Fix Focus Areas
- pnpm11/core/core-loggers/src/reportPackageImported.ts[14-34]

### Suggested fix approach
Implement deduping so `pnpm:package-import-method` is emitted at most once per install/run (or at most once per `requester` unless the method changes). For example:
- Keep a `Map<string, string>` of `lastEmittedMethodByRequester`.
- In `reportPackageImported`, only call `packageImportMethodLogger.debug(...)` when `isKnownImportMethod(method)` AND `lastEmittedMethodByRequester.get(requester) !== method`; then update the map.
- Ensure tests that reuse the same `requester` across runs don’t get starved; if needed, provide a reset hook for tests or key the cache more granularly (e.g., include `process.pid` + a monotonic run id if available in the caller).

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



Informational

8. Quadratic allowBuilds scaffolding 🐞 Bug ➹ Performance ⭐ New
Description
scaffold_allow_builds() applies one YAML locate+splice per missing package, and the helper path
re-locates the mapping again during insertion; when many builds are blocked this can make the
failing install path spend disproportionate time rewriting pnpm-workspace.yaml before surfacing
ERR_PNPM_IGNORED_BUILDS. This is avoidable by batching inserts (single locate / single rewrite) or
at least avoiding the double locate() per entry.
Code

pnpm/crates/workspace-manifest-writer/src/lib.rs[R318-354]

+pub fn scaffold_allow_builds<'a, Names>(
+    dir: &Path,
+    names: Names,
+) -> Result<(), UpdateWorkspaceManifestError>
+where
+    Names: IntoIterator<Item = &'a str>,
+{
+    let path = dir.join(WORKSPACE_MANIFEST_FILENAME);
+
+    let original = match fs::read_to_string(&path) {
+        Ok(text) => Some(text),
+        Err(err) if err.kind() == io::ErrorKind::NotFound => None,
+        Err(source) => return Err(UpdateWorkspaceManifestError::Read { path, source }),
+    };
+
+    let mut manifest = Manifest::parse(original.as_deref())
+        .map_err(|source| UpdateWorkspaceManifestError::Parse { path: path.clone(), source })?;
+
+    let mut changed = false;
+    for name in names {
+        // Same guard as `set_allow_builds`: the block-style splice writes
+        // the entry on one line, so a control character in `name` would
+        // corrupt the document.
+        if has_control_char(name) {
+            return Err(UpdateWorkspaceManifestError::InvalidControlCharacter {
+                path,
+                value: name.to_string(),
+            });
+        }
+        changed |= edit::add_undecided_allow_build(&mut manifest, name, UNDECIDED_ALLOW_BUILD);
+    }
+    if !changed {
+        return Ok(());
+    }
+
+    write_or_remove_manifest(&path, manifest)
+}
Relevance

⭐⭐ Medium

Perf refactor is speculative; similar micro-optimizations in this crate have been rejected before.

PR-#13172

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The scaffolding loop edits the manifest once per name, and the per-name helper locates the same
mapping and then calls an insertion helper that locates again; locate() is implemented as a linear
scan over lines, so repeated calls can make this scale poorly with many inserted names.

pnpm/crates/workspace-manifest-writer/src/lib.rs[318-354]
pnpm/crates/workspace-manifest-writer/src/edit.rs[589-615]
pnpm/crates/workspace-manifest-writer/src/edit.rs[900-924]
pnpm/crates/workspace-manifest-writer/src/edit.rs[1197-1235]
pnpm/crates/package-manager/src/install.rs[2468-2490]

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

### Issue description
`scaffold_allow_builds()` currently loops over names and, for each one, triggers repeated full-text scans and string splices of `pnpm-workspace.yaml` (including a double mapping lookup per inserted entry). This can scale poorly when an install blocks many builds (large `ignored_builds`).

### Issue Context
This runs on the strict-builds failure path, so it can add noticeable extra time before the user sees `ERR_PNPM_IGNORED_BUILDS` when a lot of dependencies have build scripts.

### Fix Focus Areas
- pnpm/crates/workspace-manifest-writer/src/lib.rs[318-354]
- pnpm/crates/workspace-manifest-writer/src/edit.rs[589-615]

### What to change
- Prefer a batched edit API (e.g., `add_undecided_allow_builds(manifest, names, placeholder)`) that:
 - Locates/parses the `allowBuilds` mapping once.
 - Computes the set of missing keys once.
 - Applies a single splice (or minimal number of splices) to insert all missing entries in deterministic order.
- If batching is too invasive, at least refactor `add_undecided_allow_build()` to avoid calling `locate()` twice per insertion (reuse the `Mapping` computed by the first `locate()` call when inserting).

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


9. Changesets missing pnpm entry 📘 Rule violation § Compliance ⭐ New
Description
New changeset files declare a bump for pacquet but omit the required pnpm entry in the
front-matter. This violates the changeset policy and can cause incomplete or inconsistent release
metadata.
Code

.changeset/rust-engine-dates-cached-verification.md[R1-3]

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

⭐ Low

Team often rejects adding pnpm to pacquet-only changesets despite the bot policy reminder.

PR-#13329
PR-#12995
PR-#13386

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires changeset front-matter to include an explicit pnpm bump entry.
The cited changeset files contain only a "pacquet": patch entry and no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/rust-engine-dates-cached-verification.md[1-3]
.changeset/rust-engine-reports-scope.md[1-3]
.changeset/rust-engine-scaffolds-allow-builds.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
Several newly added changesets include only a `pacquet` bump and omit the required `pnpm` entry in the front-matter.

## Issue Context
The compliance checklist requires each new/modified changeset to explicitly declare a bump for `pnpm` with a valid bump type.

## Fix Focus Areas
- .changeset/rust-engine-dates-cached-verification.md[1-3]
- .changeset/rust-engine-reports-scope.md[1-3]
- .changeset/rust-engine-scaffolds-allow-builds.md[1-3]

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


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.

@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: 5

Caution

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

⚠️ Outside diff range comments (1)
pnpm/crates/cli/src/cli_args/dispatch.rs (1)

193-194: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve reporter setup for direct CliArgs::run callers.

run_cli now calls args.configure_reporter(), but CliArgs::run remains public and no longer sets the process-global default-reporter state. Direct in-process callers are also skipped through the completion server, so add an idempotent setup call at the start of CliArgs::run or make the entrypoint-only contract explicit and verify no direct callers remain.

🤖 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 `@pnpm/crates/cli/src/cli_args/dispatch.rs` around lines 193 - 194, Ensure the
public CliArgs::run method performs idempotent reporter configuration at its
start, preserving the process-global default reporter for direct in-process
callers. Reuse the existing configure_reporter setup used by run_cli, and avoid
changing the remaining run flow.
🧹 Nitpick comments (2)
pnpm/crates/lockfile/src/freshness/tests.rs (1)

1707-1734: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover every changed_setting branch.

This test exercises only four of the 13 StalenessReason variants. Add table-driven assertions for every configuration-drift key and each remaining None case so mapping changes cannot silently regress the frozen-install error code.

Based on path instructions, REVIEW_GUIDE.md requires regression tests for changed behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/lockfile/src/freshness/tests.rs` around lines 1707 - 1734, Expand
settings_drift_names_the_setting_that_changed to table-driven assertions
covering all 13 StalenessReason variants: verify the expected configuration key
for every changed_setting Some result and None for every remaining
non-configuration drift case. Construct representative values for each variant
and preserve the existing mappings, ensuring future mapping changes are
detected.

Source: Path instructions

pnpm/crates/cli/src/cli_args/run/recursive.rs (1)

98-108: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for the emitted ScopeLog.

Please add or point to a recording-emitter test covering filtered counts, empty selections, workspace_prefix, and emission before script execution. This event is the basis for the new Scope: output, so selector changes should not be able to alter its payload silently.

As per path instructions, REVIEW_GUIDE.md requires regression tests for changed observable behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/cli/src/cli_args/run/recursive.rs` around lines 98 - 108, Add
regression coverage for the ScopeLog emission in the recursive run flow around
emit and script execution. Use a recording emitter to verify filtered
selections, empty selections, the workspace_prefix value, and that the event is
emitted before the script runs; preserve the exact selected and total counts in
each case.

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.

Inline comments:
In @.changeset/restore-package-import-method-log.md:
- Line 16: Update the changeset text to remove the internal worker-thread and
logger implementation details, retaining only a concise description of the
user-visible restoration of the package import method event or block.
- Line 10: Specify the Markdown fence language in
restore-package-import-method-log.md by changing the unfenced code block marker
to ```text, satisfying MD040 while leaving the block contents unchanged.

In `@pnpm/crates/cli/src/cli_args/pipelines.rs`:
- Around line 68-77: The pipeline must preserve the already-reported filtered
scope when launching PerProject children: update the pipeline in
pnpm/crates/cli/src/cli_args/pipelines.rs lines 68-77 to carry that state into
child execution, and update Install::run in
pnpm/crates/package-manager/src/install.rs lines 906-920 to skip the
full-workspace scope event for those children. Add recording-reporter coverage
for a filtered dedicated-lockfile workspace, asserting exactly one scope event
with the filtered selected and total counts.

In `@pnpm/crates/cli/src/cli_args/pre_command.rs`:
- Around line 152-153: Guard the warn_ignored_pnpm_manifest_fields call in the
pre-command argument flow with !input.global so global commands skip
project-scoped manifest warnings, and add a focused regression test covering
pnpm --global behavior.

In `@pnpm/crates/workspace-manifest-writer/src/edit.rs`:
- Around line 1137-1156: Update inline_comment to ignore escaped bytes while
scanning double-quoted scalars, so an escaped double quote does not end the
quoted state before detecting comments. Preserve existing single-quote handling
and comment-boundary behavior, and add a regression test covering a value such
as `"x\" # text"` to ensure scalar content is not rewritten as a comment.

---

Outside diff comments:
In `@pnpm/crates/cli/src/cli_args/dispatch.rs`:
- Around line 193-194: Ensure the public CliArgs::run method performs idempotent
reporter configuration at its start, preserving the process-global default
reporter for direct in-process callers. Reuse the existing configure_reporter
setup used by run_cli, and avoid changing the remaining run flow.

---

Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/run/recursive.rs`:
- Around line 98-108: Add regression coverage for the ScopeLog emission in the
recursive run flow around emit and script execution. Use a recording emitter to
verify filtered selections, empty selections, the workspace_prefix value, and
that the event is emitted before the script runs; preserve the exact selected
and total counts in each case.

In `@pnpm/crates/lockfile/src/freshness/tests.rs`:
- Around line 1707-1734: Expand settings_drift_names_the_setting_that_changed to
table-driven assertions covering all 13 StalenessReason variants: verify the
expected configuration key for every changed_setting Some result and None for
every remaining non-configuration drift case. Construct representative values
for each variant and preserve the existing mappings, ensuring future mapping
changes are detected.
🪄 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: 3aba7235-557d-4bf4-934b-de0ad336d230

📥 Commits

Reviewing files that changed from the base of the PR and between d17710c and 0c72afa.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (44)
  • .changeset/restore-package-import-method-log.md
  • .changeset/rust-engine-dates-cached-verification.md
  • .changeset/rust-engine-lockfile-config-mismatch.md
  • .changeset/rust-engine-reports-scope.md
  • .changeset/rust-engine-scaffolds-allow-builds.md
  • .changeset/rust-engine-warns-about-ignored-pnpm-field.md
  • pnpm/crates/cli/src/cli_args.rs
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/dispatch_install.rs
  • pnpm/crates/cli/src/cli_args/dispatch_script.rs
  • pnpm/crates/cli/src/cli_args/global.rs
  • pnpm/crates/cli/src/cli_args/pipelines.rs
  • pnpm/crates/cli/src/cli_args/pre_command.rs
  • pnpm/crates/cli/src/cli_args/reporter.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/lib.rs
  • pnpm/crates/cli/tests/approve_builds.rs
  • pnpm/crates/cli/tests/frozen_config_mismatch.rs
  • pnpm/crates/cli/tests/scope_report.rs
  • pnpm/crates/config/src/lib.rs
  • pnpm/crates/config/src/workspace_yaml.rs
  • pnpm/crates/config/src/workspace_yaml/tests.rs
  • pnpm/crates/default-reporter/Cargo.toml
  • pnpm/crates/default-reporter/src/format.rs
  • pnpm/crates/default-reporter/src/lib.rs
  • pnpm/crates/default-reporter/src/state.rs
  • pnpm/crates/default-reporter/src/state/tests.rs
  • pnpm/crates/default-reporter/tests/render.rs
  • pnpm/crates/lockfile/src/freshness.rs
  • pnpm/crates/lockfile/src/freshness/tests.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/package-manager/src/install/tests.rs
  • pnpm/crates/reporter/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/edit.rs
  • pnpm/crates/workspace-manifest-writer/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
  • pnpm11/cli/default-reporter/test/reportingContext.ts
  • pnpm11/core/core-loggers/src/all.ts
  • pnpm11/core/core-loggers/src/reportPackageImported.ts
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm11/installing/deps-restorer/src/linkHoistedModules.ts

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: cbf633b8ee14

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

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.518 ± 0.160 2.353 2.784 1.66 ± 0.18
pacquet@main 2.552 ± 0.180 2.374 2.802 1.68 ± 0.19
pnpr@HEAD 1.519 ± 0.134 1.381 1.745 1.00
pnpr@main 1.609 ± 0.135 1.354 1.758 1.06 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5175179969400006,
      "stddev": 0.1601964498623898,
      "median": 2.4754876238400003,
      "user": 1.5617219,
      "system": 1.30451454,
      "min": 2.3525417868400003,
      "max": 2.78405967084,
      "times": [
        2.78405967084,
        2.54530965684,
        2.7333195748400003,
        2.3525417868400003,
        2.52512468484,
        2.3733635788400003,
        2.39961569484,
        2.6632886778400002,
        2.37270608084,
        2.4258505628400004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.55155715114,
      "stddev": 0.17999602200941658,
      "median": 2.48540889584,
      "user": 1.557845,
      "system": 1.30917134,
      "min": 2.37389075284,
      "max": 2.80203870784,
      "times": [
        2.6060366738400003,
        2.7892188408400003,
        2.37389075284,
        2.54348899284,
        2.3876163958400003,
        2.80203870784,
        2.4069213728400003,
        2.40023510584,
        2.42732879884,
        2.77879586984
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5186580369400002,
      "stddev": 0.13399140856276404,
      "median": 1.4782686058399999,
      "user": 1.0612331,
      "system": 1.1519906400000002,
      "min": 1.38085195584,
      "max": 1.74473242784,
      "times": [
        1.73256253484,
        1.38573305284,
        1.3908150288399999,
        1.74473242784,
        1.55875964284,
        1.49107450184,
        1.46546270984,
        1.38085195584,
        1.46121486584,
        1.57537364884
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.60923771134,
      "stddev": 0.1350874848921284,
      "median": 1.60847965184,
      "user": 1.0772575,
      "system": 1.15655444,
      "min": 1.35410109484,
      "max": 1.75788080684,
      "times": [
        1.75788080684,
        1.62231440084,
        1.49800665084,
        1.5366573448399998,
        1.75229568484,
        1.51517595884,
        1.59464490284,
        1.7199534998400001,
        1.35410109484,
        1.74134676884
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 262.9 ± 6.2 254.7 273.4 1.00 ± 0.03
pacquet@main 261.9 ± 4.0 255.8 268.2 1.00
pnpr@HEAD 278.7 ± 7.8 270.0 295.4 1.06 ± 0.03
pnpr@main 281.4 ± 5.8 269.0 289.9 1.07 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26290828818,
      "stddev": 0.006178956223718749,
      "median": 0.26230991857999997,
      "user": 0.20876211999999997,
      "system": 0.55573394,
      "min": 0.25465353308,
      "max": 0.27337242208,
      "times": [
        0.25761943308,
        0.25465353308,
        0.25750654108,
        0.26720728308,
        0.25838362408,
        0.26484546208,
        0.27337242208,
        0.26595529408,
        0.26976491408000003,
        0.25977437508
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.26191397898,
      "stddev": 0.0040125624780293434,
      "median": 0.26315397858,
      "user": 0.20831581999999998,
      "system": 0.5451387400000001,
      "min": 0.25581174608,
      "max": 0.26820716808,
      "times": [
        0.26313128108,
        0.26360027508,
        0.26820716808,
        0.25825416008,
        0.25828123108,
        0.25854608908,
        0.26317667608,
        0.26653962508,
        0.26359153808,
        0.25581174608
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27869372457999997,
      "stddev": 0.007769589223722794,
      "median": 0.27700241408,
      "user": 0.23154392000000001,
      "system": 0.5385467399999999,
      "min": 0.26999222208,
      "max": 0.29540745108,
      "times": [
        0.29540745108,
        0.26999222208,
        0.27826544408,
        0.27656621208,
        0.27410639608,
        0.28882835208,
        0.27949889908000003,
        0.27245377108,
        0.27743861608,
        0.27437988208
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28142154378,
      "stddev": 0.005767606003865325,
      "median": 0.28090977358,
      "user": 0.22126131999999998,
      "system": 0.54915534,
      "min": 0.26897179908,
      "max": 0.28990295708,
      "times": [
        0.27978111108,
        0.28718697808,
        0.27988420508,
        0.28549521008,
        0.28339210708,
        0.28990295708,
        0.27892758308,
        0.28193534208,
        0.27873814508,
        0.26897179908
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.792 ± 0.021 2.763 2.834 1.78 ± 0.14
pacquet@main 2.791 ± 0.024 2.762 2.828 1.78 ± 0.14
pnpr@HEAD 1.572 ± 0.119 1.432 1.841 1.00
pnpr@main 1.576 ± 0.124 1.436 1.781 1.00 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.79196975292,
      "stddev": 0.02109644824759546,
      "median": 2.78994690462,
      "user": 1.7571783200000002,
      "system": 1.32824602,
      "min": 2.76293455262,
      "max": 2.83398008762,
      "times": [
        2.79829181762,
        2.81250546762,
        2.76293455262,
        2.7766670846199997,
        2.78650204762,
        2.80071680062,
        2.78659568562,
        2.79329812362,
        2.76820586162,
        2.83398008762
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.79091674092,
      "stddev": 0.023820542238421442,
      "median": 2.79068426362,
      "user": 1.7178785199999997,
      "system": 1.36727882,
      "min": 2.76174842562,
      "max": 2.82846746562,
      "times": [
        2.81506458262,
        2.7645249116199997,
        2.8118446116199998,
        2.80310313962,
        2.76174842562,
        2.80020159762,
        2.78116692962,
        2.76671278362,
        2.82846746562,
        2.7763329616199997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5723351437200002,
      "stddev": 0.11931514686404855,
      "median": 1.52868009662,
      "user": 1.03758302,
      "system": 1.20513642,
      "min": 1.43200526362,
      "max": 1.8410539966200001,
      "times": [
        1.53545158062,
        1.8410539966200001,
        1.4985378556200002,
        1.52190861262,
        1.67060007262,
        1.43200526362,
        1.60877900662,
        1.4766461166200002,
        1.51124926762,
        1.6271196646200001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5763034049200002,
      "stddev": 0.12416049792830285,
      "median": 1.5672433636200003,
      "user": 1.04835382,
      "system": 1.1795427200000002,
      "min": 1.43602408662,
      "max": 1.7808031906200001,
      "times": [
        1.4473306596200002,
        1.5532614986200002,
        1.4485564796200001,
        1.7808031906200001,
        1.7793477476200001,
        1.5812252286200001,
        1.54153983262,
        1.58326301862,
        1.43602408662,
        1.6116823066200001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 614.2 ± 13.1 592.3 639.7 1.98 ± 0.06
pacquet@main 597.2 ± 11.0 582.6 613.8 1.93 ± 0.05
pnpr@HEAD 309.6 ± 6.0 301.6 318.0 1.00 ± 0.03
pnpr@main 309.6 ± 5.8 298.9 320.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.61420527766,
      "stddev": 0.013077302333270698,
      "median": 0.61606982886,
      "user": 0.7469183399999999,
      "system": 0.68949302,
      "min": 0.59231471886,
      "max": 0.6397233678600001,
      "times": [
        0.59231471886,
        0.6046604008600001,
        0.61461979686,
        0.60762066886,
        0.62356702586,
        0.60320358586,
        0.61977243486,
        0.6397233678600001,
        0.61751986086,
        0.61905091586
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.59717354846,
      "stddev": 0.010989623661870316,
      "median": 0.59480744486,
      "user": 0.7322971399999999,
      "system": 0.67767082,
      "min": 0.58262183486,
      "max": 0.61384821286,
      "times": [
        0.59510323186,
        0.58262183486,
        0.60240677386,
        0.60692559886,
        0.59290366786,
        0.59451165786,
        0.61076139686,
        0.61384821286,
        0.58278306786,
        0.58987004186
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30963574856000003,
      "stddev": 0.006004837862447073,
      "median": 0.30996676236,
      "user": 0.19085504000000003,
      "system": 0.5596882199999998,
      "min": 0.30156361386,
      "max": 0.31797610886,
      "times": [
        0.31797610886,
        0.30490108186,
        0.30326535086,
        0.31423071186,
        0.31373216286,
        0.30620136186,
        0.30156361386,
        0.31401023586,
        0.30488815786,
        0.31558869986
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.30959338326,
      "stddev": 0.005847118147403758,
      "median": 0.30935640136,
      "user": 0.20163314,
      "system": 0.5537812200000001,
      "min": 0.29891473286,
      "max": 0.32082618786,
      "times": [
        0.31401420386,
        0.30933915386,
        0.30937364886,
        0.31203086586,
        0.31176663786000003,
        0.30405361486,
        0.30758360686,
        0.32082618786,
        0.30803117986,
        0.29891473286
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.958 ± 0.017 1.936 1.994 6.34 ± 0.13
pacquet@main 1.925 ± 0.007 1.918 1.937 6.23 ± 0.12
pnpr@HEAD 0.309 ± 0.006 0.299 0.315 1.00
pnpr@main 0.312 ± 0.008 0.300 0.324 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9582324961200004,
      "stddev": 0.01723568462659477,
      "median": 1.95232260372,
      "user": 0.96739532,
      "system": 0.8572909799999999,
      "min": 1.9363083002200001,
      "max": 1.9940208952200003,
      "times": [
        1.9940208952200003,
        1.94447612022,
        1.94943313022,
        1.94490345522,
        1.96678357322,
        1.9363083002200001,
        1.9708127752200002,
        1.95391203922,
        1.9709415042200003,
        1.9507331682200002
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9252795009199999,
      "stddev": 0.007335032150918328,
      "median": 1.92271381772,
      "user": 0.9803761199999999,
      "system": 0.7587614799999999,
      "min": 1.9175743982200002,
      "max": 1.93735549122,
      "times": [
        1.9175918812200001,
        1.93735549122,
        1.9347325782200002,
        1.92078774322,
        1.91971166622,
        1.92463989222,
        1.93153922222,
        1.9175743982200002,
        1.9200517762200002,
        1.92881036022
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30909155272000005,
      "stddev": 0.00574353727924193,
      "median": 0.31009130872,
      "user": 0.20117722,
      "system": 0.54012338,
      "min": 0.29882281122000004,
      "max": 0.31516176722,
      "times": [
        0.31434275422,
        0.30788876322000003,
        0.31491461122000003,
        0.30862719522000004,
        0.29882281122000004,
        0.30071571722,
        0.31155542222000004,
        0.31218015022,
        0.31516176722,
        0.30670633522
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31232346042000003,
      "stddev": 0.008314659862318835,
      "median": 0.31386430272,
      "user": 0.20642131999999994,
      "system": 0.54807878,
      "min": 0.29984890422,
      "max": 0.32444252422000003,
      "times": [
        0.30806268122,
        0.32047825622000004,
        0.29984890422,
        0.30034110122,
        0.31376070822,
        0.32444252422000003,
        0.31527090322,
        0.31396789722,
        0.31965908122000003,
        0.30740254722000004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 370.9 ± 10.8 349.7 385.4 4.27 ± 0.15
pacquet@main 368.1 ± 16.9 352.9 406.1 4.24 ± 0.21
pnpr@HEAD 87.3 ± 1.5 84.5 90.5 1.01 ± 0.03
pnpr@main 86.8 ± 1.7 82.9 89.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.37094969534,
      "stddev": 0.010841551615996283,
      "median": 0.37518016474000004,
      "user": 0.36155046,
      "system": 0.05922247999999999,
      "min": 0.34965014424,
      "max": 0.38535704524,
      "times": [
        0.37611296824,
        0.36614613624,
        0.37567859924,
        0.38535704524,
        0.37741287724,
        0.37468173024,
        0.34965014424,
        0.35977147523999997,
        0.36397703024,
        0.38070894724
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.36812902054,
      "stddev": 0.016886681528050857,
      "median": 0.36307701323999997,
      "user": 0.36156886,
      "system": 0.05669928,
      "min": 0.35293647624,
      "max": 0.40606641724,
      "times": [
        0.35293647624,
        0.36723267324,
        0.35626487724,
        0.37185498324,
        0.35697279124,
        0.35367379524,
        0.40606641724,
        0.35892135324,
        0.37161412924,
        0.38575270924
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08733282454303032,
      "stddev": 0.0014795766421988228,
      "median": 0.08702841724,
      "user": 0.020308605454545443,
      "system": 0.009412164848484849,
      "min": 0.08454291324,
      "max": 0.09054801824000001,
      "times": [
        0.08611937424,
        0.08778848824,
        0.08697770124000001,
        0.08681547524000001,
        0.08693992024000001,
        0.08980075124,
        0.08594797124,
        0.08643319524000001,
        0.08830770624,
        0.08761604324000001,
        0.09054801824000001,
        0.08454291324,
        0.08669157224000001,
        0.08935400924,
        0.08833722224000001,
        0.08532446524000001,
        0.08747706224000001,
        0.08634412724000001,
        0.09019572524000001,
        0.08563355924,
        0.08885959724,
        0.08512313524000001,
        0.08767376224000001,
        0.08679587824000001,
        0.08673781924000001,
        0.08813494224000001,
        0.08630286024,
        0.08878506624,
        0.08782697124000001,
        0.08527763824000001,
        0.08702841724,
        0.08868918624000001,
        0.08755263524000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08683257596727273,
      "stddev": 0.0017071254693723863,
      "median": 0.08725301024000001,
      "user": 0.019797363030303026,
      "system": 0.009581507878787879,
      "min": 0.08294493124,
      "max": 0.08973370424,
      "times": [
        0.08451960024,
        0.08742854124,
        0.08790849524000001,
        0.08725301024000001,
        0.08917600324000001,
        0.08540480824,
        0.08625707324000001,
        0.08849457924000001,
        0.08552405224000001,
        0.08368831424,
        0.08783973524000001,
        0.08570245824,
        0.08956965424,
        0.08833593024000001,
        0.08549857324000001,
        0.08693148424000001,
        0.08973370424,
        0.08779489224,
        0.08329492224000001,
        0.08294493124,
        0.08820216824,
        0.08741519624,
        0.08687175124,
        0.08779188524,
        0.08693732424,
        0.08506394524000001,
        0.08642908824000001,
        0.08778302824,
        0.08840478024000001,
        0.08527226724,
        0.08743616524,
        0.08757659924000001,
        0.08699004524000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.521 ± 0.114 4.433 4.734 1.28 ± 0.05
pacquet@main 4.598 ± 0.138 4.467 4.847 1.31 ± 0.06
pnpr@HEAD 3.562 ± 0.149 3.441 3.857 1.01 ± 0.05
pnpr@main 3.519 ± 0.115 3.451 3.823 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.520924663120001,
      "stddev": 0.11353246826352836,
      "median": 4.45576415562,
      "user": 1.67332374,
      "system": 1.4599068,
      "min": 4.43294469212,
      "max": 4.73419088612,
      "times": [
        4.49602755612,
        4.43811052512,
        4.43294469212,
        4.44480048012,
        4.45761249212,
        4.64831531512,
        4.44467416412,
        4.73419088612,
        4.65865470112,
        4.45391581912
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.59832599402,
      "stddev": 0.1375742753119083,
      "median": 4.56280550312,
      "user": 1.7437906399999998,
      "system": 1.3659831999999998,
      "min": 4.46738979812,
      "max": 4.84676311812,
      "times": [
        4.52719101712,
        4.79322821412,
        4.47073533112,
        4.66468317512,
        4.84676311812,
        4.46738979812,
        4.50022032812,
        4.64321124712,
        4.59841998912,
        4.47141772212
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.56154931992,
      "stddev": 0.14942824838357396,
      "median": 3.51300362862,
      "user": 1.18891974,
      "system": 1.2432366999999998,
      "min": 3.44084491512,
      "max": 3.85696045112,
      "times": [
        3.4483980881200003,
        3.54607472212,
        3.47993253512,
        3.56617401412,
        3.57258603612,
        3.85696045112,
        3.46469968312,
        3.79751015312,
        3.44084491512,
        3.4423126011200003
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.51930733962,
      "stddev": 0.11539082841056954,
      "median": 3.47462425962,
      "user": 1.1956240399999998,
      "system": 1.2515694,
      "min": 3.45089324012,
      "max": 3.8226807001200003,
      "times": [
        3.45089324012,
        3.45765746412,
        3.8226807001200003,
        3.48898118512,
        3.59380729012,
        3.45336287212,
        3.50005665712,
        3.51399832912,
        3.45136832412,
        3.46026733412
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13376
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,762.93 ms
(+1.04%)Baseline: 2,734.61 ms
3,281.53 ms
(84.20%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,936.31 ms
(+2.42%)Baseline: 1,890.50 ms
2,268.60 ms
(85.35%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
592.31 ms
(+3.68%)Baseline: 571.27 ms
685.53 ms
(86.40%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
349.65 ms
(+1.28%)Baseline: 345.22 ms
414.26 ms
(84.40%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,352.54 ms
(-0.26%)Baseline: 2,358.59 ms
2,830.30 ms
(83.12%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,432.94 ms
(+0.13%)Baseline: 4,427.23 ms
5,312.67 ms
(83.44%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
254.65 ms
(+3.40%)Baseline: 246.29 ms
295.55 ms
(86.16%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13376
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,432.01 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
298.82 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
301.56 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.54 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,380.85 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,440.84 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
269.99 ms
🐰 View full continuous benchmarking report in Bencher

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

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 changed the title fix(cli): close the pnpm 12 CLI-surface parity gaps fix(cli): close the remaining pnpm 12 CLI-surface parity gaps Jul 25, 2026
@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Rebased onto main at cbf633b8ee, and addressed the review.

The PR shrank. Three of the six items landed on main while this was in review — the ignored-package.json#pnpm warning in #13359, and the parsable allowBuilds placeholder plus ERR_PNPM_LOCKFILE_CONFIG_MISMATCH in #13375. My branch predated both and had converged on near-identical implementations, so I reset onto main and re-applied only what is still missing: the Scope: line, the allowBuilds placeholder write, the store block in the TypeScript CLI, and the elapsed time on a cached lockfile verdict. The title, description and changesets were rewritten to match; two changesets were deleted.

Review outcomes:

Finding Outcome
Duplicate scope events for dedicated per-project installs Confirmed and fixed, with a regression test that fails without the guard
Changeset fence language Fixed
Implementation mechanics in the changeset Fixed — moved to the commit body
Reporter setup for direct CliArgs::run callers Fixed — run and the install fast path both call configure_reporter, which is idempotent
Regression coverage for the recursive-run ScopeLog Added a_recursive_run_reports_the_scope_it_selected
Skip legacy-field warnings for global commands Superseded by #13359; verified add -g does not warn on that placement
Escaped double quotes when finding comments Superseded by #13375, which already handles it
Table-driven coverage for every changed_setting branch Superseded — setting_name is #13375's code on main now

just ready is green, and each behavior is still checked against pnpm 11.17.0 on the issue's fixtures.


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

Comment on lines +82 to +87
Reporter::emit(&LogEvent::Scope(ScopeLog {
level: LogLevel::Debug,
selected: selection.selected_dirs.len(),
total: Some(selection.projects.len()),
workspace_prefix: Some(selection.workspace_root.to_string_lossy().into_owned()),
}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

3. Scope events bypass gating 🐞 Bug ≡ Correctness

select_install_family_plan emits pnpm:scope for any recursive/filter selection, but the command
gate (reports_scope) is only applied inside the default reporter’s rendering logic. As a result,
--reporter=ndjson will still output pnpm:scope records for commands pnpm doesn’t report scope
for (e.g. add), which can break consumers relying on pnpm-compatible ndjson event sets.
Agent Prompt
### Issue description
`LogEvent::Scope` is emitted unconditionally for any recursive/filter workspace selection, while the pnpm command gate (which commands "report scope") is enforced only by the default reporter via `reports_scope`. Other reporters (notably ndjson) will serialize all events, so they can expose scope records for commands that should not report scope.

### Issue Context
- `CliCommand::reports_scope(...)` defines which commands should report scope.
- `NdjsonReporter` writes every `LogEvent` it receives.

### Fix Focus Areas
- pnpm/crates/cli/src/cli_args/pipelines.rs[63-87]
- pnpm/crates/cli/src/cli_args/cli_command.rs[615-634]
- pnpm/crates/cli/src/cli_args/dispatch.rs[66-73]
- pnpm/crates/cli/src/cli_args/reporter.rs[23-31]

### Suggested fix
Option A (preferred): Gate emission at the source.
- Thread a `reports_scope: bool` into `select_install_family_plan(...)` (or into its callers) and only `emit(LogEvent::Scope(...))` when true.

Option B: Gate at the emitter wrapper for all reporters.
- Extend `reporter_emit(...)` (or add a new helper) to return an `emit` fn that drops `LogEvent::Scope` when `!reports_scope`.

Add a regression test:
- Run a non-reporting command (e.g. `pnpm -r add ... --reporter=ndjson`) and assert there is **no** `"name":"pnpm:scope"` record.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not fixing this as described — the premise is inverted — but it led to a real bug next to it, fixed in d5014df05b.

pnpm emits pnpm:scope for every command. scopeLogger.debug is called unconditionally in pnpm/src/main.ts; COMMANDS_THAT_REPORT_SCOPE lives in reportScope.ts and gates rendering, not emission. Against pnpm 11.17.0:

$ pnpm -r add is-even --reporter=ndjson
{"name":"pnpm:scope","selected":2,"total":3,"workspacePrefix":"…"}

$ pnpm add is-even --reporter=ndjson
{"name":"pnpm:scope","selected":1,"workspacePrefix":"…"}

So gating emission would make the engine emit fewer records than pnpm, which is the opposite of a pnpm-compatible ndjson event set. The reporter-side gate is the faithful placement.

What was actually wrong is the payload, not the gating. For a partial install the engine reported selected: N where pnpm reports selected: 1 with no total — the numbers were wrong for exactly the commands you named. The payload now follows the install's own is_full_install, which is pnpm's mutation: "install" versus "installSome" distinction, so add now emits {selected: 1, workspacePrefix} byte-for-byte as above. a_partial_install_reports_the_single_project_shape covers it.

Chasing it also turned up a gap: the repeat-install short-circuit emitted nothing, so an up-to-date pnpm install printed no Scope: line where pnpm prints one. It already loads the workspace projects to reach its verdict, so it now reports from there.


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

@qodo-code-review

Copy link
Copy Markdown

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

@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: 2

🧹 Nitpick comments (2)
pnpm/crates/workspace-manifest-writer/src/tests.rs (1)

379-386: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Make the idempotency test observe the no-write guarantee.

The helper creates a fresh directory and calls scaffold_allow_builds only once, then compares file contents. This still passes if an already-scaffolded entry is rewritten atomically, so it does not verify the comment’s “must not rewrite” contract. Reuse one temporary path for two calls and assert the second call leaves metadata unchanged, or instrument the write boundary in a portable test.

Based on the review guide, regression tests should prove the changed behavior rather than only its resulting bytes.

🤖 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 `@pnpm/crates/workspace-manifest-writer/src/tests.rs` around lines 379 - 386,
Update scaffold_allow_builds_no_op_when_already_scaffolded_keeps_file to reuse
the same temporary file across two scaffold_allow_builds calls, then capture its
metadata (including modification time) after the first call and assert it is
unchanged after the second call. Keep the existing content assertion while
ensuring the second invocation proves no write occurred.
pnpm/crates/workspace-manifest-writer/src/lib.rs (1)

325-353: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the shared manifest update pipeline.

scaffold_allow_builds duplicates set_allow_builds’s file loading, parsing, error mapping, change tracking, and write/no-op handling. Extracting that common flow will prevent the two APIs from drifting around missing files, validation, or write semantics.

As per coding guidelines, “Before writing non-trivial code, search for existing functionality and reuse or extract shared utilities.”

🤖 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 `@pnpm/crates/workspace-manifest-writer/src/lib.rs` around lines 325 - 353,
Extract the duplicated manifest update pipeline from scaffold_allow_builds and
set_allow_builds into a shared helper, covering file loading, Manifest::parse
error mapping, change tracking, and write_or_remove_manifest/no-op handling.
Keep each API’s operation-specific validation and edit function (including
add_undecided_allow_build and has_control_char) in its existing flow while
delegating common persistence behavior to the helper.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/tests/scope_report.rs`:
- Around line 161-165: Replace the substring-based assertions in the scope
report test with parsing of the sole NDJSON record and an exact assertion of its
canonical wire payload, including name, level, selected, total, and
workspacePrefix fields. Keep the existing uniqueness check for the pnpm:scope
record and ensure the expected values match the test workspace.

In `@pnpm/crates/reporter/src/lib.rs`:
- Around line 793-798: Update the `pnpm:scope` payload documentation to state
that `total` is present for workspace commands, including filtered commands
selecting a single project; it is absent only for non-workspace or
single-project payloads. Keep the existing distinction for `workspace_prefix`
and the reporter’s “projects” versus “workspace projects” rendering.

---

Nitpick comments:
In `@pnpm/crates/workspace-manifest-writer/src/lib.rs`:
- Around line 325-353: Extract the duplicated manifest update pipeline from
scaffold_allow_builds and set_allow_builds into a shared helper, covering file
loading, Manifest::parse error mapping, change tracking, and
write_or_remove_manifest/no-op handling. Keep each API’s operation-specific
validation and edit function (including add_undecided_allow_build and
has_control_char) in its existing flow while delegating common persistence
behavior to the helper.

In `@pnpm/crates/workspace-manifest-writer/src/tests.rs`:
- Around line 379-386: Update
scaffold_allow_builds_no_op_when_already_scaffolded_keeps_file to reuse the same
temporary file across two scaffold_allow_builds calls, then capture its metadata
(including modification time) after the first call and assert it is unchanged
after the second call. Keep the existing content assertion while ensuring the
second invocation proves no write occurred.
🪄 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: 5abdae6c-69f7-42d6-9e71-9a67cf9ce187

📥 Commits

Reviewing files that changed from the base of the PR and between 0c72afa and cbf633b.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (32)
  • .changeset/restore-package-import-method-log.md
  • .changeset/rust-engine-dates-cached-verification.md
  • .changeset/rust-engine-reports-scope.md
  • .changeset/rust-engine-scaffolds-allow-builds.md
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/dispatch_install.rs
  • pnpm/crates/cli/src/cli_args/dispatch_script.rs
  • pnpm/crates/cli/src/cli_args/pipelines.rs
  • pnpm/crates/cli/src/cli_args/reporter.rs
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/lib.rs
  • pnpm/crates/cli/tests/approve_builds.rs
  • pnpm/crates/cli/tests/scope_report.rs
  • pnpm/crates/default-reporter/Cargo.toml
  • pnpm/crates/default-reporter/src/format.rs
  • pnpm/crates/default-reporter/src/lib.rs
  • pnpm/crates/default-reporter/src/state.rs
  • pnpm/crates/default-reporter/src/state/tests.rs
  • pnpm/crates/default-reporter/tests/render.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/reporter/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/edit.rs
  • pnpm/crates/workspace-manifest-writer/src/lib.rs
  • pnpm/crates/workspace-manifest-writer/src/tests.rs
  • pnpm11/cli/default-reporter/test/reportingContext.ts
  • pnpm11/core/core-loggers/src/all.ts
  • pnpm11/core/core-loggers/src/reportPackageImported.ts
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm11/installing/deps-restorer/src/linkHoistedModules.ts
🚧 Files skipped from review as they are similar to previous changes (23)
  • pnpm11/core/core-loggers/src/all.ts
  • .changeset/rust-engine-scaffolds-allow-builds.md
  • pnpm/crates/default-reporter/src/state/tests.rs
  • .changeset/rust-engine-reports-scope.md
  • pnpm11/core/core-loggers/src/reportPackageImported.ts
  • pnpm/crates/cli/src/cli_args/run.rs
  • pnpm/crates/workspace-manifest-writer/src/edit.rs
  • pnpm/crates/cli/src/cli_args/reporter.rs
  • pnpm/crates/cli/src/cli_args/dispatch_install.rs
  • pnpm/crates/default-reporter/src/format.rs
  • pnpm11/installing/deps-installer/src/install/link.ts
  • pnpm/crates/cli/src/lib.rs
  • .changeset/rust-engine-dates-cached-verification.md
  • pnpm/crates/default-reporter/src/lib.rs
  • pnpm/crates/cli/src/cli_args/run/recursive.rs
  • pnpm/crates/cli/src/cli_args/dispatch_script.rs
  • pnpm11/installing/deps-restorer/src/index.ts
  • pnpm/crates/default-reporter/tests/render.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/pipelines.rs
  • pnpm/crates/cli/tests/approve_builds.rs
  • pnpm/crates/package-manager/src/install.rs
  • pnpm/crates/default-reporter/src/state.rs

Comment thread pnpm/crates/cli/tests/scope_report.rs Resolved
Comment thread pnpm/crates/reporter/src/lib.rs Resolved
Copilot AI review requested due to automatic review settings July 25, 2026 23:21

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

Second review round addressed in d5014df05b.

Finding Outcome
Scope events bypass gating (Qodo) Premise inverted — pnpm emits pnpm:scope for every command and gates only rendering, verified against 11.17.0. But it pointed at a real payload bug, now fixed
Scaffold leaks url credentials (Qodo) Declined — the key derivation is shared with pnpm 11, which writes the same keys to the same file, and the string is already in the committed lockfile
Assert the complete wire payload (CodeRabbit) Fixed — the record is parsed and every field asserted
Correct the total contract (CodeRabbit) Fixed — and writing it down is what exposed the payload bug

The payload bug. For a partial install (add, update, remove) the engine reported selected: N where pnpm reports selected: 1 with no total. Rendering agreed either way — both stacks suppress the line for one selected project — but the record did not, and that record is the contract. It now follows the install's own is_full_install, which is pnpm's mutation: "install" vs "installSome" distinction.

And a gap it uncovered. The repeat-install short-circuit reported nothing, so an up-to-date pnpm install — the most common invocation there is — printed no Scope: line where pnpm prints one. It already loads the workspace projects to reach its verdict, so it now returns the count and reports the same scope the full path would.

Full suite green (7208 passed). One mockito test failed on the first run and passed on a clean rerun of the whole suite — the known concurrency starvation, not a regression.


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

@qodo-code-review

Copy link
Copy Markdown

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

@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 added 2 commits July 26, 2026 01:58
Close the four CLI-surface differences left over from #13315
after #13359 and #13375 landed the other two.

Three land in the Rust engine. The `Scope:` line arrives via a new
`pnpm:scope` channel and a port of `reportScope.ts`; pnpm gates it on the
command being one that reports scope *and* the run being workspace-wide,
and since the engine's recursive-by-default set is narrower than pnpm's,
that conjunction is computed at dispatch and seeded into the reporter.
The event is emitted where the counts already exist — the `--filter`
resolution and the installer's workspace walk — so no install pays for a
second directory walk. A `sharedWorkspaceLockfile: false` plan reports
once for the whole selection rather than once per child install, which
would otherwise overwrite the filtered count with the workspace total.

The second is the `allowBuilds` placeholder an install writes for a build
it blocked, which #13375 taught the engine to read but not yet to
write. The third is the elapsed time on a cache-satisfied lockfile
verdict.

The fourth goes the other way. The store block a first install prints is
unreachable in the TypeScript CLI: `reportContext` needs
`pnpm:package-import-method`, which only `@pnpm/fs.indexed-pkg-importer`
emits, and that runs inside a `@pnpm/worker` thread whose logger never
reaches the reporter. The main process already receives the import method
back from the worker, so it is reported from there instead.

Reporter globals are now seeded before the pre-command checks. They are
`OnceLock`s and the pre-command checks emit, so whatever fired first was
locking in unset values.

Closes #13315
@zkochan zkochan added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
zkochan added 2 commits July 26, 2026 01:58
… shape

A partial install (`add`, `update`, `remove`, …) targets the project it
was run in, but the engine was reporting the whole workspace for it:
`pnpm:scope` carried `selected: N` where pnpm carries `selected: 1` and
no `total`. The rendered output agreed either way — both stacks suppress
the line for a single selected project — but the record on the wire did
not, and that record is the contract. The payload now follows the
install's own `is_full_install`, which is pnpm's `mutation: "install"`
versus `"installSome"` distinction.

The repeat-install short-circuit reported nothing at all, so the most
common invocation of all — an up-to-date `pnpm install` — printed no
`Scope:` line where pnpm prints one. It already loads the workspace
projects to reach its verdict, so it now returns the count alongside the
root and reports the same scope the full path would.

Also correct the `total` contract on `ScopeLog`: it accompanies a
workspace-wide run including a `--filter` that narrowed it to a single
project, and is absent only from the single-project shape.
Copilot AI review requested due to automatic review settings July 26, 2026 00:05

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 efab61f

@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 CLI canonicalizes `--dir` before anything is emitted, so the
`workspacePrefix` it reports is the resolved path. On macOS `/var` is a
symlink to `/private/var`, so comparing it against the raw `TempDir`
path failed there while passing on Linux, where the temp path is already
canonical.

Reproduced on Linux by pointing `TMPDIR` at a symlink: the same two
tests fail without this and pass with it.
Copilot AI review requested due to automatic review settings July 26, 2026 00:14

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 26, 2026

Copy link
Copy Markdown
Member Author

macOS test failure fixed in 54857d8c9a. It was test-side only — the product behaviour is unchanged.

The CLI canonicalizes --dir before anything can emit, so the workspacePrefix it reports is the resolved path. On macOS /var is a symlink to /private/var, so the two new tests comparing it against the raw TempDir path failed there and passed on Linux, where the temp path is already canonical:

left:  "/private/var/folders/…/pacquet-test-XzpGzX/workspace"
right: "/var/folders/…/pacquet-test-XzpGzX/workspace"

The expected prefix now goes through dunce::canonicalize, the same call the CLI makes, matching the pattern already used in crates/cli/tests/bin.rs and current_lockfile.rs.

Reproduced the failure on Linux by pointing TMPDIR at a symlink — the same two tests fail without the fix and pass with it — so this is verified rather than assumed.


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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 54857d8

@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 760b2ec into main Jul 26, 2026
30 of 31 checks passed
@zkochan
zkochan deleted the fix-13315 branch July 26, 2026 00:24
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
…3376)

Close the four CLI-surface differences left over from pnpm#13315
after pnpm#13359 and pnpm#13375 landed the other two.

Three land in the Rust engine. The `Scope:` line arrives via a new
`pnpm:scope` channel and a port of `reportScope.ts`; pnpm gates it on the
command being one that reports scope *and* the run being workspace-wide,
and since the engine's recursive-by-default set is narrower than pnpm's,
that conjunction is computed at dispatch and seeded into the reporter.
The event is emitted where the counts already exist — the `--filter`
resolution and the installer's workspace walk — so no install pays for a
second directory walk. A `sharedWorkspaceLockfile: false` plan reports
once for the whole selection rather than once per child install, which
would otherwise overwrite the filtered count with the workspace total.

The second is the `allowBuilds` placeholder an install writes for a build
it blocked, which pnpm#13375 taught the engine to read but not yet to
write. The third is the elapsed time on a cache-satisfied lockfile
verdict.

The fourth goes the other way. The store block a first install prints is
unreachable in the TypeScript CLI: `reportContext` needs
`pnpm:package-import-method`, which only `@pnpm/fs.indexed-pkg-importer`
emits, and that runs inside a `@pnpm/worker` thread whose logger never
reaches the reporter. The main process already receives the import method
back from the worker, so it is reported from there instead.

Reporter globals are now seeded before the pre-command checks. They are
`OnceLock`s and the pre-command checks emit, so whatever fired first was
locking in unset values.

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 12 CLI-surface parity gaps: no ignored-pnpm-field warning, no Scope: line, no allowBuilds scaffold

2 participants