Skip to content

fix(lockfile.verification): reuse local dependency walks per importer - #17375

Merged
zkochan merged 4 commits into
pnpm:mainfrom
kairosci:fix/17374-shared-local-dependency-walk
Oct 26, 2026
Merged

zkochan merged 4 commits into
pnpm:mainfrom
kairosci:fix/17374-shared-local-dependency-walk

Conversation

@kairosci

@kairosci kairosci commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes #17374.

The v11 lockfile check walked each direct file: dependency's local directory subtree with a fresh visited map. A project whose direct local dependencies share transitive local directories (the issue's 5×40 DAG) re-walked the shared graph once per direct dependency. The check now creates one checker per importer, so all of an importer's direct local dependencies share the visited snapshots and peer scopes.

pnpm v12 is not affected (see the issue), so this is a v11-only fix.

The checker collects the lockfile's recorded peers on its first check, so a project with no local directory dependency pays nothing extra.

Measurements

The issue's compact-repro.mjs (200 file: packages, 5 levels × 40), Node 24, Linux. Same bundle, three runs each. The baseline patches the shared map back to a fresh one per direct dependency.

phase before after
seed 1538–1691 ms 1430–1493 ms
repeat 1729–1786 ms 362–378 ms
frozen 1002–1027 ms 342–349 ms

The lockfile stayed unchanged in every run.

Squash Commit Body

checkLinkedPackagesAreUpToDate creates one local directory checker per
importer. Its checks share the `visited` map and the recorded peers, so a
snapshot reached through several direct dependencies is walked once per
peer scope instead of once per direct dependency.

The visited key (snapshot plus peer scope) and cycle handling are
unchanged. A revisit returns true while the first visitor may still be
checking the snapshot. That is safe because the importer's results are
combined with AND, so the first visitor's failure still marks the importer
outdated. This is the same contract siblings within one walk already had.

The recorded peers are collected on the first check, so an importer with
no local directory dependency does not scan the locked packages.

The one-shot localDirectoryDepIsUpToDate wrapper had no callers left and
is removed.

On the issue's 200-package file: DAG, a repeat install went from ~1.75s to
~0.37s and a frozen install from ~1.0s to ~0.35s.

Closes pnpm/pnpm#17374

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • New features are implemented only in the Rust pnpm v12 CLI. Bug fixes
    are implemented in every affected version.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

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

Summary by CodeRabbit

  • Performance
    • Installs involving local-directory dependencies now avoid rechecking the same shared transitive directory for each direct dependency that reaches it.
    • When checking local-directory dependencies within a project, pnpm reuses information gathered during earlier checks, reducing repeated work while preserving verification behavior.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: pnpm/pnpm
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 4d625be
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d4b9ad75-cd1a-4b79-bc9d-31ac868f5615
Commits

Reviewing files that changed from the base of the PR and between c542734 and becb466.

Files selected for processing: 3
  • .changeset/quiet-lizards-travel.md
  • pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts
  • pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts
Files skipped from review as they are similar to previous changes: 1
  • .changeset/quiet-lizards-travel.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

The linked-package verifier now shares local-directory verification state across dependencies in a project check. A regression test checks two direct dependencies that share a transitive local-directory dependency. The changeset declares patch releases for the verifier and pnpm.

Changes: Shared local-directory verification

Layer / File(s) Summary
Reuse checker state
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts
A checker factory retains visited-snapshot and recorded-peer state across checks.
Share the checker across project dependencies
pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts, pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts, .changeset/quiet-lizards-travel.md
The project check creates one checker and passes it to local-directory dependency checks. A regression test confirms that the read count for a shared dependency’s dependencies property is the same through one route and two routes, and is greater than zero. The changeset declares patch releases.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant ProjectCheck
  participant DependencyCheck
  participant LocalDirectoryChecker
  ProjectCheck->>DependencyCheck: check project dependencies with shared context
  DependencyCheck->>LocalDirectoryChecker: check snapshot and dependency aliases
  LocalDirectoryChecker-->>DependencyCheck: return up-to-date result
Loading

Assessment against linked issues

Objective Addressed Explanation
Reuse verification state across shared local-directory subgraphs to reduce repeated traversal [#17374] ✅
Preserve transitive freshness, cycles, and peer-scope correctness while sharing traversal state [#17374] ❓ The change shares visited-snapshot state and recorded peers, but the supplied test summary does not show separate coverage for freshness, cycles, or peer-scope correctness.

Possibly related issues

  • pnpm/pnpm#17374: The change shares verification state across direct dependencies to avoid repeated walks of shared local-directory subgraphs.

Suggested labels: product: pnpm@11

Suggested reviewers: charan-rathore

Merge Risk: Minimal · up to becb4

The shared-directory verification change is ready to merge after normal checks.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

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

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

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

❤️ Share

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

@garnet-runtime-review

garnet-runtime-review Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Execution Profiles recorded for 1 job, triggered by becb466

1 job unchanged · compared with 6977517
recorded at the kernel by Garnet · 2026-10-26 13:38 UTC

TS CI / test ↗ · 28 destinations
@@ 6977517 (previous) vs becb466 (current) @@
  systemd
  ├─ bash
  │  └─ bash
  │     └─ bash
  │        └─ bash
  │           └─ bash
  │              └─ bash
  │                 ├─ bash
  │                 │  ├─ node
  │                 │  │  ├─ git (step: "<unknown>")
  │                 │  │  │  ├─ git
  │                 │  │  │  │  └─ git
  │                 │  │  │  │     └─ git-remote-http
  │                 │  │  │  │        └─ ○ github[.]com
  │                 │  │  │  └─ ○ 192.168.127.1
  │                 │  │  └─ pn (step: "Validate test chunk inputs")
  │                 │  │     ├─ dash
  │                 │  │     │  └─ node
  │                 │  │     │     └─ pn
  │                 │  │     │        └─ dash
  │                 │  │     │           └─ pn
  │                 │  │     │              └─ dash
  │                 │  │     │                 └─ pnpm
  │                 │  │     │                    └─ dash
  │                 │  │     │                       └─ node
  │                 │  │     │                          ├─ ○ codeload.github[.]com
  │                 │  │     │                          └─ ○ registry.npmjs[.]org
  │                 │  │     └─ ○ nodejs[.]org
  │                 │  └─ gh (step: "Wait for prebuilt pnpr binaries")
  │                 │     └─ ○ api.github[.]com
  │                 └─ node
  │                    ├─ ○ blacksmith.blob.core.windows[.]net
  │                    └─ ○ productionresultssa12.blob.core[.]windows
  ├─ chronyd (runner background · +3 −3)
+ │  ├─ ○ 108.61.73.243
- │  ├─ ○ 142.248.80.92
  │  ├─ ○ 149.28.200.179
  │  ├─ ○ 169.254.169.123
  │  ├─ ○ 185.125.190.56
  │  ├─ ○ 185.125.190.57
  │  ├─ ○ 185.125.190.58
- │  ├─ ○ 198.178.138.197
- │  ├─ ○ 38.28.93.135
+ │  ├─ ○ 45.33.53.84
+ │  ├─ ○ 45.63.54.13
  │  └─ ○ 91.189.91.157
  ├─ nginx (runner background · +2 −1)
  │  └─ nginx
  │     ├─ ○ 140.82.113.21 (github infra · rotated from 140.82.112.21)
+ │     ├─ ○ 140.82.113.22
  │     ├─ ○ 140.82.114.21
+ │     ├─ ○ 140.82.114.22
  │     ├─ ○ 8.8.8.8
- │     └─ ○ glb-db52c2cf8be544.github[.]com
  └─ snapd
     └─ ○ api.snapcraft[.]io
 
  Runner.Worker
  ├─ node
  │  └─ ○ blob.blz25prdstrz09a.store.core[.]windows
  └─ bash
     ├─ rustup (step: "Initialize Rust before dependenc…tion ($/.github/actions/rustup)")
     │  ├─ ○ dualstack.k.sni.global.fastly[.]net
     │  └─ ○ localhost (dns resolver)
     └─ MainThread
        └─ pn
           └─ dash
              └─ node
                 └─ node
                    └─ node (step: "Validate test chunk inputs")
                       ├─ ○ pnpm[.]io
                       └─ ○ unofficial-builds.nodejs[.]org

View this job's Execution Profile in Garnet →


💡 How to read this
Runner.Worker          ← process on a path
└─ npm
   └─ node             ← process that acted
      └─ ○ npmjs[.]org ← observed action

follow a path downward to see what ran and what it did — each path to an observed action is an execution chain

names on the path = processes · ○ = observed action · (…) = context

+ only in the current record · − only in the previous record · runner background = the runner's infrastructure, not your workflow

@kairosci
kairosci marked this pull request as ready for review October 26, 2026 12:13
@kairosci
kairosci requested a review from zkochan as a code owner October 26, 2026 12:13
Copilot AI lite review requested due to automatic review settings October 26, 2026 12:14
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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 insufficient remaining quota.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 26, 2026
@zkochan
zkochan force-pushed the fix/17374-shared-local-dependency-walk branch from 52e2ac4 to 85a5562 Compare October 26, 2026 12:24
Copilot AI lite review requested due to automatic review settings October 26, 2026 12:24

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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 insufficient remaining quota.

…tory check

The importer check now creates a checker per project, so the single-call
wrapper had no callers left. Its contract moves to the checker factory, which
also documents that its checks share visited snapshots. Reword the changeset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 26, 2026 12:26

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 insufficient remaining quota.

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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

@qodo-code-review

qodo-code-review Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Release note overstates how often directories are checked ✗ Dismissed
Description
The changeset says pnpm "now checks each shared directory once per project", but
createLocalDirectoryDepUpToDateChecker shares a visited map keyed by snapshot plus peer scope
(markVisited). A directory reached under two different peer scopes in the same project is still
checked once per scope, so the note promises more than the code delivers.
Code

.changeset/quiet-lizards-travel.md[6]

+Sped up installs of projects whose local directory dependencies share transitive local directory dependencies. pnpm now checks each shared directory once per project [#17374](https://github.com/pnpm/pnpm/issues/17374).
Relevance

●●● Strong

Concrete, trivial accuracy fix to changeset wording; the commit body itself says 'once per peer
scope', so the release note should match.

PR-#17141
PR-#16407

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365343 requires changeset statements to match the implemented behavior. The changeset claims
one check per project, while the checker docstring in localDirectoryDepIsUpToDate.ts and
markVisited show deduplication per (snapshot, peer scope). The PR commit body itself states
'walked once per peer scope', which confirms the changeset wording is inaccurate.

.changeset/quiet-lizards-travel.md[6-6]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[89-111]
Skill: review-code

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

## Issue description
The changeset says each shared directory is checked once per project, but the implementation deduplicates per snapshot and peer scope, so a directory can still be checked once per distinct peer scope.

## Fix Focus Areas
- .changeset/quiet-lizards-travel.md[6-6]
- pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[89-111]

## Recommended Fix
Reword the changeset sentence so it matches the implemented scope, for example: "pnpm now checks each shared directory once per peer scope of a project." Keep it short and user-facing, with no em dashes and no implementation internals.

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


2. Regression test would also pass without the fix ✗ Dismissed
Description
The new test asserts bDependenciesReads equals 3 by counting dependencies property reads on a
proxied manifest, but readHookedManifestOnce already caches hooked manifests in hookedManifests,
and the test pre-populates that map as an empty new Map() per check. The count depends on how many
times the proxy's getter is hit across prepareDependencyManifest, clone and
recordedPeersMatch, not on how many times b is walked, so it neither demonstrates the shared
visited map nor is shown to fail when the per-importer checker is removed.
Code

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[R1506-1507]

+    expect((await checkLinkedPackagesAreUpToDate(checkContext, projectWithSharedDependency)).upToDate).toBe(true)
+    expect(bDependenciesReads).toBe(3)
Relevance

●● Moderate

Test-strength critiques are often accepted by this team (15435, 15369), but this specific 'would
pass without fix' claim is unverified and the read-count assertion is debatable.

PR-#15435
PR-#15369
PR-#14530

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365251 requires a bug-fix test that fails when the production fix is removed. The assertion
expect(bDependenciesReads).toBe(3) is an indirect proxy-read count whose value is not tied to the
number of traversals of b, and nothing in the test shows it yields a different number under the
pre-fix per-dependency visited map. Rule 3365260 likewise requires assertions that prove the
changed effect rather than incidental execution.

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]
Skill: review-code

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 added test counts `dependencies` getter reads on a proxied manifest and expects 3. That number is not a direct measure of how many times the shared directory `b` is walked, and it is not demonstrated to differ from the pre-fix behavior.

## Fix Focus Areas
- pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]

## Recommended Fix
Count a signal that maps one-to-one to a walk of `b`, such as the number of times the read-package hook is invoked for `b` with a fresh `hookedManifests` map, or reads of a property touched exactly once per walk. Verify by temporarily restoring a per-dependency `visited` map that the assertion fails, then keep the assertion tied to that count. Also assert the resulting `upToDate` value is true.

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



Remediation recommended

3. Speedup claim ships with no timing numbers 📜 Skill insight ➹ Performance
Description
The changeset announces faster installs for projects with shared local directory dependencies, but
neither the PR description nor the new test supplies a before/after timing. The added test only
asserts an internal read count (bDependenciesReads toBe 3), which does not show the install-time
effect on a realistic project.
Code

.changeset/quiet-lizards-travel.md[6]

+Sped up installs of projects whose local directory dependencies share transitive local directory dependencies. pnpm now checks each shared directory once per project [#17374](https://github.com/pnpm/pnpm/issues/17374).
Relevance

●● Moderate

Team precedents split: unquantified 'sped up' changelog claims were rejected in some PRs (16772,
16412) but accepted in others (17044), so no clear pattern.

PR-#16772
PR-#16412
PR-#17044

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365159 requires numeric before/after evidence whenever a PR claims a performance
improvement. The changeset claims a speedup, and the PR description gives only a qualitative
explanation with no benchmark. The review guide's performance section likewise requires a number
when a change is pitched as performance.

.changeset/quiet-lizards-travel.md[6-6]
pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1498-1507]
Skill: review-code

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

## Issue description
The changeset presents this change as a performance fix ("Sped up installs of projects whose local directory dependencies share transitive local directory dependencies"), but no numeric before/after measurement is supplied. The only new assertion counts internal manifest reads, which does not demonstrate install-time impact.

## Fix Focus Areas
- .changeset/quiet-lizards-travel.md[6-6]
- pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]

## Recommended Fix
Run the lockfile verification or install path on a project with the shared-directory DAG from pnpm/pnpm#17374 (for example the 5x40 layout), with multiple runs and variance, before and after this change. Add the timings (mean and spread) to the PR description. If the gain is negligible at realistic dependency counts, reconsider whether the change is worth its added complexity.

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

Dismiss ↗ | View ↗


4. Ordinary installs scan every locked package ✓ Resolved
Description
createLocalDirectoryDepUpToDateChecker calls recordedPeersOf as soon as
checkLinkedPackagesAreUpToDate starts, before it knows whether any dependency needs a
local-directory walk. For a lockfile with no local directory dependencies, the first importer check
now scans every package snapshot to collect peers, even though no checker is used; normal and frozen
verification both reach this path.
Code

pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[85]

+  const localDirectoryDepIsUpToDate = createLocalDirectoryDepUpToDateChecker(ctx)
Relevance

●● Moderate

Plausible eager-work perf regression with a concrete fix, but no closely matching precedent for
lazily creating checkers; the team accepted similar local-directory perf caching asks (17065).

PR-#17065
PR-#17141

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Checker creation precedes dependency enumeration. Its peer collection iterates every lockfile
package on the first call for a packages object, while the local-directory check is conditional;
both aggregate and frozen verification invoke the importer check.

pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[84-106]
pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[117-138]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[101-125]
pnpm11/lockfile/verification/src/allProjectsAreUpToDate.ts[54-76]
pnpm11/installing/deps-installer/src/install/verifyFrozenLockfile.ts[148-181]

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

## Issue description
Checker creation scans all lockfile packages even when an importer has no local directory dependency to check.

## Fix Focus Areas
- pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[101-110]
- pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[84-96]

## Recommended Fix
Defer `recordedPeersOf(ctx.lockfilePackages)` until the returned checker is first invoked. Keep its result shared by all invocations of that checker so local-directory walks retain the intended per-importer reuse.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 51 rules
✅ Cross-repo context — repo relationships
Review mode: Auto: ⚖️ Balanced: Shared visited state across concurrent checks affects lockfile freshness; one-file change.
✅ Fix-loop round: fix loop

Grey Divider

Tip of the day
💡 Did you know, you can type 'qodo, fix this' on a finding and the fix lands right on your PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit becb466

Results up to commit c542734 ⚖️ Balanced


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


Action required
1. Release note overstates how often directories are checked ✗ Dismissed
Description
The changeset says pnpm "now checks each shared directory once per project", but
createLocalDirectoryDepUpToDateChecker shares a visited map keyed by snapshot plus peer scope
(markVisited). A directory reached under two different peer scopes in the same project is still
checked once per scope, so the note promises more than the code delivers.
Code

.changeset/quiet-lizards-travel.md[6]

+Sped up installs of projects whose local directory dependencies share transitive local directory dependencies. pnpm now checks each shared directory once per project [#17374](https://github.com/pnpm/pnpm/issues/17374).
Relevance

●●● Strong

Concrete, trivial accuracy fix to changeset wording; the commit body itself says 'once per peer
scope', so the release note should match.

PR-#17141
PR-#16407

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365343 requires changeset statements to match the implemented behavior. The changeset claims
one check per project, while the checker docstring in localDirectoryDepIsUpToDate.ts and
markVisited show deduplication per (snapshot, peer scope). The PR commit body itself states
'walked once per peer scope', which confirms the changeset wording is inaccurate.

.changeset/quiet-lizards-travel.md[6-6]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[89-111]
Skill: review-code

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

## Issue description
The changeset says each shared directory is checked once per project, but the implementation deduplicates per snapshot and peer scope, so a directory can still be checked once per distinct peer scope.

## Fix Focus Areas
- .changeset/quiet-lizards-travel.md[6-6]
- pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[89-111]

## Recommended Fix
Reword the changeset sentence so it matches the implemented scope, for example: "pnpm now checks each shared directory once per peer scope of a project." Keep it short and user-facing, with no em dashes and no implementation internals.

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


2. Regression test would also pass without the fix ✗ Dismissed
Description
The new test asserts bDependenciesReads equals 3 by counting dependencies property reads on a
proxied manifest, but readHookedManifestOnce already caches hooked manifests in hookedManifests,
and the test pre-populates that map as an empty new Map() per check. The count depends on how many
times the proxy's getter is hit across prepareDependencyManifest, clone and
recordedPeersMatch, not on how many times b is walked, so it neither demonstrates the shared
visited map nor is shown to fail when the per-importer checker is removed.
Code

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[R1506-1507]

+    expect((await checkLinkedPackagesAreUpToDate(checkContext, projectWithSharedDependency)).upToDate).toBe(true)
+    expect(bDependenciesReads).toBe(3)
Relevance

●● Moderate

Test-strength critiques are often accepted by this team (15435, 15369), but this specific 'would
pass without fix' claim is unverified and the read-count assertion is debatable.

PR-#15435
PR-#15369
PR-#14530

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rule 3365251 requires a bug-fix test that fails when the production fix is removed. The assertion
expect(bDependenciesReads).toBe(3) is an indirect proxy-read count whose value is not tied to the
number of traversals of b, and nothing in the test shows it yields a different number under the
pre-fix per-dependency visited map. Rule 3365260 likewise requires assertions that prove the
changed effect rather than incidental execution.

pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]
Skill: review-code

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 added test counts `dependencies` getter reads on a proxied manifest and expects 3. That number is not a direct measure of how many times the shared directory `b` is walked, and it is not demonstrated to differ from the pre-fix behavior.

## Fix Focus Areas
- pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]

## Recommended Fix
Count a signal that maps one-to-one to a walk of `b`, such as the number of times the read-package hook is invoked for `b` with a fresh `hookedManifests` map, or reads of a property touched exactly once per walk. Verify by temporarily restoring a per-dependency `visited` map that the assertion fails, then keep the assertion tied to that count. Also assert the resulting `upToDate` value is true.

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



Remediation recommended
3. Speedup claim ships with no timing numbers 📜 Skill insight ➹ Performance
Description
The changeset announces faster installs for projects with shared local directory dependencies, but
neither the PR description nor the new test supplies a before/after timing. The added test only
asserts an internal read count (bDependenciesReads toBe 3), which does not show the install-time
effect on a realistic project.
Code

.changeset/quiet-lizards-travel.md[6]

+Sped up installs of projects whose local directory dependencies share transitive local directory dependencies. pnpm now checks each shared directory once per project [#17374](https://github.com/pnpm/pnpm/issues/17374).
Relevance

●● Moderate

Team precedents split: unquantified 'sped up' changelog claims were rejected in some PRs (16772,
16412) but accepted in others (17044), so no clear pattern.

PR-#16772
PR-#16412
PR-#17044

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365159 requires numeric before/after evidence whenever a PR claims a performance
improvement. The changeset claims a speedup, and the PR description gives only a qualitative
explanation with no benchmark. The review guide's performance section likewise requires a number
when a change is pitched as performance.

.changeset/quiet-lizards-travel.md[6-6]
pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1498-1507]
Skill: review-code

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

## Issue description
The changeset presents this change as a performance fix ("Sped up installs of projects whose local directory dependencies share transitive local directory dependencies"), but no numeric before/after measurement is supplied. The only new assertion counts internal manifest reads, which does not demonstrate install-time impact.

## Fix Focus Areas
- .changeset/quiet-lizards-travel.md[6-6]
- pnpm11/lockfile/verification/test/allProjectsAreUpToDate.test.ts[1471-1508]

## Recommended Fix
Run the lockfile verification or install path on a project with the shared-directory DAG from pnpm/pnpm#17374 (for example the 5x40 layout), with multiple runs and variance, before and after this change. Add the timings (mean and spread) to the PR description. If the gain is negligible at realistic dependency counts, reconsider whether the change is worth its added complexity.

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

Dismiss ↗ | View ↗


4. Ordinary installs scan every locked package ✓ Resolved
Description
createLocalDirectoryDepUpToDateChecker calls recordedPeersOf as soon as
checkLinkedPackagesAreUpToDate starts, before it knows whether any dependency needs a
local-directory walk. For a lockfile with no local directory dependencies, the first importer check
now scans every package snapshot to collect peers, even though no checker is used; normal and frozen
verification both reach this path.
Code

pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[85]

+  const localDirectoryDepIsUpToDate = createLocalDirectoryDepUpToDateChecker(ctx)
Relevance

●● Moderate

Plausible eager-work perf regression with a concrete fix, but no closely matching precedent for
lazily creating checkers; the team accepted similar local-directory perf caching asks (17065).

PR-#17065
PR-#17141

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Checker creation precedes dependency enumeration. Its peer collection iterates every lockfile
package on the first call for a packages object, while the local-directory check is conditional;
both aggregate and frozen verification invoke the importer check.

pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[84-106]
pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[117-138]
pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[101-125]
pnpm11/lockfile/verification/src/allProjectsAreUpToDate.ts[54-76]
pnpm11/installing/deps-installer/src/install/verifyFrozenLockfile.ts[148-181]

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

## Issue description
Checker creation scans all lockfile packages even when an importer has no local directory dependency to check.

## Fix Focus Areas
- pnpm11/lockfile/verification/src/localDirectoryDepIsUpToDate.ts[101-110]
- pnpm11/lockfile/verification/src/linkedPackagesAreUpToDate.ts[84-96]

## Recommended Fix
Defer `recordedPeersOf(ctx.lockfilePackages)` until the returned checker is first invoked. Keep its result shared by all invocations of that checker so local-directory walks retain the intended per-importer reuse.

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


Grey Divider

Qodo Logo

Comment thread .changeset/quiet-lizards-travel.md Resolved
@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.

…rect dependency

The regression test asserted a fixed count of `dependencies` reads, which
depends on how often one walk reads the manifest. It now asserts that two
direct dependencies sharing a directory read it as often as one does.

The changeset no longer claims one check per project, since the walk
deduplicates per peer scope.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 26, 2026 12:50

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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 insufficient remaining quota.

@qodo-code-review

Copy link
Copy Markdown

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

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

Your trial has ended. Reactivate Greptile to resume code reviews.

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 insufficient remaining quota.

@zkochan

zkochan commented Oct 26, 2026

Copy link
Copy Markdown
Member

@coderabbitai review


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

@qodo-code-review

Copy link
Copy Markdown

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

@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 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Already reviewed the last commit. Use @coderabbitai full review to rerun a review of the entire changeset.

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

@zkochan

zkochan commented Oct 26, 2026

Copy link
Copy Markdown
Member

Review-and-fix pass complete. Head: becb466.

Changes pushed

  • Rebased onto main (no conflicts).
  • c542734: removed the one-shot localDirectoryDepIsUpToDate wrapper, which had no callers left. Its contract now lives on createLocalDirectoryDepUpToDateChecker. Reworded the changeset.
  • 6977517: the regression test compares the reads through two direct dependencies against a one-dependency baseline, instead of a hard-coded count. It fails with a per-dependency visited map (expected 3, received 6). The changeset no longer claims one check per project, since deduplication is per peer scope.
  • becb466: recorded peers are collected on the first local directory check. Previously the factory scanned every locked package for every importer, including projects with no file: dependency (Qodo finding 4).

Qodo summary-only finding 3 (no timing numbers): addressed. The PR description now has before/after timings from the issue's repro. Repeat install went from ~1.75s to ~0.37s, frozen install from ~1.0s to ~0.35s, and the lockfile stayed unchanged.

Review status

  • CodeRabbit approved becb466 with no actionable comments.
  • Qodo updated its review to becb466 with no open bugs. Both of its inline threads were answered and resolved.
  • Greptile (trial ended) and Copilot (quota) did not review.
  • CI: all checks pass.

No remaining work within scope. pnpm v12 is unaffected, as the issue reports.


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

@zkochan
zkochan merged commit ad495b3 into pnpm:main Oct 26, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm 11.28.7/11.28.8 repeats shared local-directory verification, inflating repeat install memory and time

3 participants