Skip to content

fix(resolving-deps-resolver): keep synthesized reuse results out of the wanted-dep cache - #13122

Merged
zkochan merged 1 commit into
mainfrom
fix-compile2
Jul 18, 2026
Merged

zkochan merged 1 commit into
mainfrom
fix-compile2

Conversation

@zkochan

@zkochan zkochan commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Fixes the resolver bug behind the TS CI / Compile & Lint failure on the [email protected] bump PR (related to #13070, failing run).

During a non-frozen re-install, resolve_reused_node registered its synthesized ResolveResult in the workspace-shared resolved_by_wanted cache. That result's manifest deliberately omits dependencies (a reused node's children come from the snapshot graph), so when another edge with the identical wanted key was denied reuse — by the changed-direct-dep gate in a different importer, or by subtree_fully_reusable's provisional-false guard racing a concurrent check — its fresh resolve read the dependency-less result back, classified the package as a leaf, and (when that occurrence won children ownership) recorded it with no children. The package's lockfile snapshot collapsed to {}, its peer suffix was dropped, its dependents were re-pointed at the bare instance, and none of its dependencies were linked.

On the bump PR this emptied the snapshots of @yarnpkg/[email protected] and [email protected] (the alpha.14 per-importer freshness regression — since fixed by #13117 — pushed CI's plain install onto the re-resolution path), which left pnpm/dist bundling unable to resolve tslib, @yarnpkg/fslib, chalk, and the rest of @yarnpkg/shell's deps. The corruption itself predates alpha.14: it reproduces on alpha.13 by forcing a re-resolution with any manifest change.

The fix drops the cache insert — only the fresh-resolve path ever read it, and a denied edge must see the real registry manifest to walk its children. Verified end-to-end: with the fix, the forced re-resolution of the repo's own lockfile no longer produces any empty snapshot and the global-virtual-store links directory for @yarnpkg/[email protected] contains all of its dependency links.

The regression test drives the deterministic cross-importer variant using new @pnpm.e2e/reuse-chain-* registry fixtures (an unchanged importer reuses the target at depth 2 and caches the synthesized result under the exact-pin wanted key; a later importer whose changed direct dep overlaps the target's snapshot is denied reuse at depth 1). The test fails on the previous code and passes with the fix.

Note: #13070 stays red until a next-12 release carries this fix together with #13117, since its CI runs the released alpha.14 binary.

Squash Commit Body

During a non-frozen re-install, a node reused from the prior lockfile
registered its synthesized ResolveResult in the workspace-shared
resolved_by_wanted cache. That result's manifest deliberately omits
dependencies (a reused node's children come from the snapshot graph), so
when another edge with the identical wanted key was denied reuse - by
the changed-direct-dep gate in a different importer, or by
subtree_fully_reusable's provisional-false cycle guard racing a
concurrent check - its fresh resolve read the dependency-less result
back, classified the package as a leaf, and (when that occurrence was
shallow enough to win children ownership) recorded it with no children:
the package's lockfile snapshot collapsed to an empty map, its peer
suffix was dropped, its dependents were re-pointed at the bare instance,
and none of its dependencies were linked.

This is what broke the Compile & Lint job on the [email protected]
bump PR (pnpm/pnpm#13070): the alpha.14 per-importer freshness check
regression (since fixed by pnpm/pnpm#13117) pushed CI's plain install
onto the re-resolution path, which then emptied the snapshots of
`@yarnpkg/[email protected]` and `[email protected]`, leaving
`pnpm/dist` bundling unable to resolve their dependencies. The
corruption itself predates alpha.14 (reproducible on alpha.13 by
forcing a re-resolution with any manifest change).

Drop the cache insert: only the fresh-resolve path ever read it, and a
denied edge must see the real registry manifest to walk its children.
The regression test drives the deterministic cross-importer variant
using new reuse-chain-* registry fixtures: an unchanged importer reuses
the target at depth 2 (caching the synthesized result under the
exact-pin wanted key), then a later importer whose changed direct dep
overlaps the target's snapshot is denied reuse at depth 1 and must
re-resolve fresh.

The TypeScript CLI has no equivalent cache of synthesized reuse
results, so the fix is pacquet-only.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    (Pacquet-only: the TypeScript resolver has no equivalent cache of
    synthesized reuse results — verified pnpm 11.14.0 keeps the snapshots
    intact under the same forced re-resolution.)
  • 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-fable-5).


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed lockfile corruption and missing dependency links during non-frozen reinstalls when subtree reuse is denied for a specific dependency path.
    • Ensured denied reuse no longer replaces packages with empty lockfile snapshots, preserving auto-installed peer-suffixed and dependency entries for correct later installs/builds.
  • Tests
    • Added an end-to-end test covering denied subtree reuse in lockfile resolution, along with supporting fixture packages.
  • Chores
    • Added a changeset for this patch release.

Copilot AI review requested due to automatic review settings July 18, 2026 10: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 reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 24774f6c-2747-41cc-8bf7-5f25be1adb1f

📥 Commits

Reviewing files that changed from the base of the PR and between 9e8cd6e and 1d1e23a.

📒 Files selected for processing (6)
  • .changeset/reuse-denied-edge-empty-snapshot.md
  • pnpm/crates/cli/tests/lockfile_resolution_reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-grand/1.0.0/package.json
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-parent/1.0.0/package.json
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-target/1.0.0/package.json
🚧 Files skipped from review as they are similar to previous changes (6)
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-grand/1.0.0/package.json
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-parent/1.0.0/package.json
  • .changeset/reuse-denied-edge-empty-snapshot.md
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-target/1.0.0/package.json
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpm/crates/cli/tests/lockfile_resolution_reuse.rs

📝 Walkthrough

Walkthrough

The resolver no longer stores synthesized reused resolutions in the shared wanted-dependency cache. New fixtures and an end-to-end test verify that denied reuse preserves dependency-bearing lockfile snapshots instead of producing empty entries.

Changes

Denied reuse lockfile preservation

Layer / File(s) Summary
Reuse-chain fixture graph
pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-.../package.json
Adds manifests defining the grandparent, parent, target, and target dependency chain used by the reuse scenario.
Synthesized reuse cache handling
pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
Stops caching synthesized reused resolutions in resolved_by_wanted and documents why their child snapshots remain external to that cache.
Denied-edge regression coverage
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs, .changeset/reuse-denied-edge-empty-snapshot.md
Adds a two-install regression test confirming the target retains its dependency-bearing snapshot and records a pacquet patch release.

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

Possibly related issues

Suggested labels: product: pacquet, product: pnpr

Suggested reviewers: copilot

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

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

❤️ Share

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix lockfile corruption by excluding reused-node synth results from wanted-dep cache

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Prevent reused-node synthesized resolutions from polluting the wanted-dependency cache.
• Add regression test for denied-reuse edges preserving snapshots and peer suffixes.
• Add reuse-chain fixtures and a pacquet patch changeset describing the fix.
Diagram

graph TD
  A["pacquet install"] --> B["resolve_dependency_tree"] --> C{"subtree reusable?"}
  C -->|"yes"| D["resolve_reused_node"] --> E[("lockfile snapshots")]
  C -->|"no"| F["resolve_node (fresh)"] --> G[("resolved_by_wanted cache")] --> H["registry metadata"]

  subgraph Legend
    direction LR
    _p["Process"] ~~~ _d[("Cache/Lockfile")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep caching but mark entries as 'reused/synthesized'
  • ➕ Retains potential performance win from reusing exact-pin metadata across edges
  • ➕ Allows explicit logic to prevent leaf/child extraction from incomplete manifests
  • ➖ Introduces additional cache entry types and branching logic at lookup sites
  • ➖ Easy to miss call sites and reintroduce similar corruption via new code paths
2. Populate synthesized manifests with full dependency lists
  • ➕ Would make cached entries safe for fresh-resolve child walking
  • ➕ Reduces special-casing between reused and fresh paths
  • ➖ May require additional I/O or assumptions; reused nodes intentionally derive children from snapshots
  • ➖ Risk of drift between snapshot graph and reconstructed manifest dependencies

Recommendation: Prefer the PR’s approach: do not insert synthesized reused-node ResolveResults into the workspace shared wanted-dependency cache. It eliminates the unsafe cross-importer cache coupling with minimal surface area, and the added regression test exercises the deterministic denied-reuse scenario that previously produced empty {} snapshots and dropped peer suffixes.

Files changed (6) +155 / -23

Bug fix (1) +8 / -23
resolve_dependency_tree.rsStop inserting reused-node synthesized results into resolved_by_wanted +8/-23

Stop inserting reused-node synthesized results into resolved_by_wanted

• Removes the code that inserted a reused node’s synthesized ResolveResult into the workspace-shared wanted-dependency cache. Documents why this is unsafe: the synthesized manifest omits dependencies, so fresh resolves denied reuse must not read it and misclassify packages as leaves.

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

Tests (4) +142 / -0
lockfile_resolution_reuse.rsAdd regression test for denied-reuse edge not collapsing snapshots +120/-0

Add regression test for denied-reuse edge not collapsing snapshots

• Introduces an end-to-end test covering a workspace scenario where one importer reuses a subtree and another importer is denied reuse after a direct dependency bump. Asserts the lockfile does not contain an empty bare snapshot for the target and retains the peer-suffixed snapshot and expected dependencies.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs

package.jsonAdd reuse-chain grand fixture package +7/-0

Add reuse-chain grand fixture package

• Adds a mocked-registry fixture package that depends on the reuse-chain parent, forming the top of the grand→parent→target chain used by the regression test.

pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-grand/1.0.0/package.json

package.jsonAdd reuse-chain parent fixture package +7/-0

Add reuse-chain parent fixture package

• Adds a mocked-registry fixture package that depends on the reuse-chain target, enabling controlled transitive reuse/denied-reuse scenarios.

pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-parent/1.0.0/package.json

package.jsonAdd reuse-chain target fixture package with transitive deps +8/-0

Add reuse-chain target fixture package with transitive deps

• Adds a mocked-registry fixture target package with dependencies that exercise subtree reuse while ensuring fresh resolve must consult registry manifest dependencies.

pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-target/1.0.0/package.json

Documentation (1) +5 / -0
reuse-denied-edge-empty-snapshot.mdAdd pacquet patch changeset documenting lockfile corruption fix +5/-0

Add pacquet patch changeset documenting lockfile corruption fix

• Adds a patch changeset for pacquet describing the non-frozen reinstall lockfile corruption scenario and its user impact (empty snapshots, dropped peer suffixes, missing links).

.changeset/reuse-denied-edge-empty-snapshot.md

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Remediation recommended

1. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter lists only pacquet and does not include an entry for pnpm, which
violates the changeset front-matter requirement as written. This can cause incomplete or
inconsistent release metadata according to the compliance checklist.
Code

.changeset/reuse-denied-edge-empty-snapshot.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
The rule requires changeset front-matter to include a pnpm entry with a valid bump type; the added
changeset includes only "pacquet": patch.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/reuse-denied-edge-empty-snapshot.md[1-3]

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

## Issue description
The changeset front-matter does not include a `pnpm` entry.

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and a valid bump type.

## Fix Focus Areas
- .changeset/reuse-denied-edge-empty-snapshot.md[1-3]

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


2. Future mtime test dependency 🐞 Bug ☼ Reliability
Description
The new regression test forces package.json's mtime into the future via
set_times(...).expect(...), which will deterministically panic on platforms/filesystems that don’t
support or reject timestamp updates. There’s no fallback/verification, so the test’s pass/fail can
become environment-dependent rather than purely behavior-dependent.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R249-254]

+    let future = std::time::SystemTime::now() + std::time::Duration::from_secs(2);
+    fs::OpenOptions::new()
+        .write(true)
+        .open(&pkg_b_manifest_path)
+        .and_then(|file| file.set_times(std::fs::FileTimes::new().set_modified(future)))
+        .expect("bump manifest mtime");
Evidence
The new test hard-depends on a future-mtime set_times call and panics on failure, with no fallback
or post-check. The same approach already exists earlier in the file, so this PR increases the number
of tests that can fail due to filesystem timestamp semantics rather than resolver behavior.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[119-135]
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[244-255]

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 test depends on successfully setting the manifest mtime to a future timestamp and panics if the operation is unsupported/rejected. This makes the test suite less portable and can fail CI for filesystem/permission reasons rather than a real regression.

### Issue Context
This pattern is now used in two places in the same test file.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[119-135]
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[244-255]

### Suggested fix
- Introduce a small helper like `fn bump_mtime(path: &Path)` that:
 - reads the current `metadata.modified()` (best-effort),
 - attempts `set_times` to a slightly-future time,
 - verifies the resulting `metadata.modified()` is strictly greater than the previous value when possible,
 - and **falls back** to a deterministic approach if `set_times` fails (e.g., `std::thread::sleep(Duration::from_millis(1100))` then re-write/touch the file).
- Replace both inline `set_times(...).expect(...)` blocks with the helper so the suite has one well-defined portability policy.

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


3. Historical phrasing in doc-comment 📘 Rule violation ⚙ Maintainability
Description
The new Rust test doc-comment references past behavior with phrases like before the fix and
original report, which violates the requirement that comments describe current behavior. This
makes the comment harder to maintain and can confuse readers about what the code guarantees now.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R166-184]

+/// (`'@yarnpkg/[email protected]': {}` in the original report).
+///
+/// Scenario, driven by the `@pnpm.e2e/reuse-chain-*` fixtures
+/// (`grand → parent → target`, where `target` deps `@pnpm.e2e/abc` +
+/// `@pnpm.e2e/dep-of-pkg-with-1-dep`):
+///
+/// * `pkg-a` deps `grand`, so its unchanged walk reuses `target` at
+///   depth 2 and caches the synthesized resolution under the exact-pin
+///   wanted key.
+/// * `pkg-b` deps `parent` plus `dep-of-pkg-with-1-dep` directly. The
+///   test bumps that direct dep; `target`'s snapshot also depends on
+///   it, so pkg-b's transitive edge to `target` (depth 1) is denied
+///   reuse by the changed-direct-dep gate and resolves fresh — with
+///   the same wanted key pkg-a already cached.
+///
+/// Importers resolve in order, so pkg-a's cache entry exists when
+/// pkg-b's denied edge looks up; the depth-1 occurrence out-ranks the
+/// depth-2 one for children ownership, making the corruption (before
+/// the fix) deterministic rather than a race.
Evidence
The rule forbids comments that describe past behavior; the added doc-comment explicitly uses
historical phrasing (before the fix, original report).

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[166-184]

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

## Issue description
A newly-added doc-comment describes historical context (e.g., `before the fix`, `original report`) instead of stating the current behavior/contract.

## Issue Context
Compliance requires comments to describe the present code behavior and guarantees, not past implementations.

## Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[166-184]

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


Grey Divider

Previous review results

Review updated until commit 1d1e23a

Results up to commit 9e8cd6e


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


Remediation recommended
1. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter lists only pacquet and does not include an entry for pnpm, which
violates the changeset front-matter requirement as written. This can cause incomplete or
inconsistent release metadata according to the compliance checklist.
Code

.changeset/reuse-denied-edge-empty-snapshot.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
The rule requires changeset front-matter to include a pnpm entry with a valid bump type; the added
changeset includes only "pacquet": patch.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/reuse-denied-edge-empty-snapshot.md[1-3]

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

## Issue description
The changeset front-matter does not include a `pnpm` entry.

## Issue Context
Compliance requires changesets to explicitly declare the `pnpm` package and a valid bump type.

## Fix Focus Areas
- .changeset/reuse-denied-edge-empty-snapshot.md[1-3]

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


2. Future mtime test dependency 🐞 Bug ☼ Reliability
Description
The new regression test forces package.json's mtime into the future via
set_times(...).expect(...), which will deterministically panic on platforms/filesystems that don’t
support or reject timestamp updates. There’s no fallback/verification, so the test’s pass/fail can
become environment-dependent rather than purely behavior-dependent.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R249-254]

+    let future = std::time::SystemTime::now() + std::time::Duration::from_secs(2);
+    fs::OpenOptions::new()
+        .write(true)
+        .open(&pkg_b_manifest_path)
+        .and_then(|file| file.set_times(std::fs::FileTimes::new().set_modified(future)))
+        .expect("bump manifest mtime");
Evidence
The new test hard-depends on a future-mtime set_times call and panics on failure, with no fallback
or post-check. The same approach already exists earlier in the file, so this PR increases the number
of tests that can fail due to filesystem timestamp semantics rather than resolver behavior.

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[119-135]
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[244-255]

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 test depends on successfully setting the manifest mtime to a future timestamp and panics if the operation is unsupported/rejected. This makes the test suite less portable and can fail CI for filesystem/permission reasons rather than a real regression.

### Issue Context
This pattern is now used in two places in the same test file.

### Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[119-135]
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[244-255]

### Suggested fix
- Introduce a small helper like `fn bump_mtime(path: &Path)` that:
 - reads the current `metadata.modified()` (best-effort),
 - attempts `set_times` to a slightly-future time,
 - verifies the resulting `metadata.modified()` is strictly greater than the previous value when possible,
 - and **falls back** to a deterministic approach if `set_times` fails (e.g., `std::thread::sleep(Duration::from_millis(1100))` then re-write/touch the file).
- Replace both inline `set_times(...).expect(...)` blocks with the helper so the suite has one well-defined portability policy.

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


3. Historical phrasing in doc-comment 📘 Rule violation ⚙ Maintainability
Description
The new Rust test doc-comment references past behavior with phrases like before the fix and
original report, which violates the requirement that comments describe current behavior. This
makes the comment harder to maintain and can confuse readers about what the code guarantees now.
Code

pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[R166-184]

+/// (`'@yarnpkg/[email protected]': {}` in the original report).
+///
+/// Scenario, driven by the `@pnpm.e2e/reuse-chain-*` fixtures
+/// (`grand → parent → target`, where `target` deps `@pnpm.e2e/abc` +
+/// `@pnpm.e2e/dep-of-pkg-with-1-dep`):
+///
+/// * `pkg-a` deps `grand`, so its unchanged walk reuses `target` at
+///   depth 2 and caches the synthesized resolution under the exact-pin
+///   wanted key.
+/// * `pkg-b` deps `parent` plus `dep-of-pkg-with-1-dep` directly. The
+///   test bumps that direct dep; `target`'s snapshot also depends on
+///   it, so pkg-b's transitive edge to `target` (depth 1) is denied
+///   reuse by the changed-direct-dep gate and resolves fresh — with
+///   the same wanted key pkg-a already cached.
+///
+/// Importers resolve in order, so pkg-a's cache entry exists when
+/// pkg-b's denied edge looks up; the depth-1 occurrence out-ranks the
+/// depth-2 one for children ownership, making the corruption (before
+/// the fix) deterministic rather than a race.
Evidence
The rule forbids comments that describe past behavior; the added doc-comment explicitly uses
historical phrasing (before the fix, original report).

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[166-184]

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

## Issue description
A newly-added doc-comment describes historical context (e.g., `before the fix`, `original report`) instead of stating the current behavior/contract.

## Issue Context
Compliance requires comments to describe the present code behavior and guarantees, not past implementations.

## Fix Focus Areas
- pnpm/crates/cli/tests/lockfile_resolution_reuse.rs[166-184]

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


Qodo Logo

@greptile-apps

greptile-apps Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is a targeted deletion of incorrect code with no behaviour change on the happy path, backed by a deterministic regression test.

The fix removes exactly the code that caused the corruption and leaves the only legitimate resolved_by_wanted write (on the fresh-resolve path) intact. All fixture packages needed by the new test exist in the mock registry. The changeset accurately describes the user-visible impact.

No files require special attention.

Reviews (2): Last reviewed commit: "fix(resolving-deps-resolver): keep synth..." | Re-trigger Greptile

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@github-actions

github-actions Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.2±0.15ms    33.3 MB/sec    1.00     11.2±0.03ms    33.4 MB/sec
packument/parse                1.04     37.5±0.04µs  1769.5 MB/sec    1.00     36.0±0.46µs  1844.2 MB/sec
tarball/download_dependency    1.02      2.2±0.06ms  1949.6 KB/sec    1.00      2.2±0.08ms  1979.2 KB/sec

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
pnpm/crates/cli/tests/lockfile_resolution_reuse.rs (1)

154-189: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use regular comments for test descriptions.

As per coding guidelines, use rustdoc comments (///) for public API contracts and regular comments (//) for implementation rationale and internal descriptions. Since tests are not public APIs, consider using regular comments for this scenario description.

♻️ Proposed refactor
-/// An edge denied subtree reuse re-resolves from the registry instead of
-/// reading another edge's reused resolution out of the wanted-dep cache.
-///
-/// The synthesized `ResolveResult` a reused node is built from carries a
-/// manifest without `dependencies` (a reused node's children come from
-/// the snapshot graph), so it must never satisfy a fresh-resolve cache
-/// lookup: a fresh edge walks children from the manifest, and the
-/// dependency-less manifest would make it record the package as a leaf.
-/// When that leaf occurrence sits at a shallower depth than the healthy
-/// reused occurrence it wins children ownership, so the package's
-/// snapshot collapses to `{}`, its peer suffix is dropped, and its
-/// dependents re-point at the bare instance
-/// (`'`@yarnpkg/shell`@4.0.0': {}` in the original report).
-///
-/// Scenario, driven by the `@pnpm.e2e/reuse-chain-*` fixtures
-/// (`grand → parent → target`, where `target` deps `@pnpm.e2e/abc` +
-/// `@pnpm.e2e/dep-of-pkg-with-1-dep`):
-///
-/// * `pkg-a` deps `grand`, so its unchanged walk reuses `target` at
-///   depth 2 and caches the synthesized resolution under the exact-pin
-///   wanted key.
-/// * `pkg-b` deps `parent` plus `dep-of-pkg-with-1-dep` directly. The
-///   test bumps that direct dep; `target`'s snapshot also depends on
-///   it, so pkg-b's transitive edge to `target` (depth 1) is denied
-///   reuse by the changed-direct-dep gate and resolves fresh — with
-///   the same wanted key pkg-a already cached.
-///
-/// Importers resolve in order, so pkg-a's cache entry exists when
-/// pkg-b's denied edge looks up; the depth-1 occurrence out-ranks the
-/// depth-2 one for children ownership, making the corruption (before
-/// the fix) deterministic rather than a race.
-///
-/// `target`'s dep `@pnpm.e2e/abc` wants peers nothing in the subtree
-/// provides, so auto-install-peers suffixes `target` — the corrupted
-/// instance is then visible as a distinct bare-key `{}` snapshot rather
-/// than colliding with the healthy suffixed one.
+// An edge denied subtree reuse re-resolves from the registry instead of
+// reading another edge's reused resolution out of the wanted-dep cache.
+//
+// The synthesized `ResolveResult` a reused node is built from carries a
+// manifest without `dependencies` (a reused node's children come from
+// the snapshot graph), so it must never satisfy a fresh-resolve cache
+// lookup: a fresh edge walks children from the manifest, and the
+// dependency-less manifest would make it record the package as a leaf.
+// When that leaf occurrence sits at a shallower depth than the healthy
+// reused occurrence it wins children ownership, so the package's
+// snapshot collapses to `{}`, its peer suffix is dropped, and its
+// dependents re-point at the bare instance
+// (`'`@yarnpkg/shell`@4.0.0': {}` in the original report).
+//
+// Scenario, driven by the `@pnpm.e2e/reuse-chain-*` fixtures
+// (`grand → parent → target`, where `target` deps `@pnpm.e2e/abc` +
+// `@pnpm.e2e/dep-of-pkg-with-1-dep`):
+//
+// * `pkg-a` deps `grand`, so its unchanged walk reuses `target` at
+//   depth 2 and caches the synthesized resolution under the exact-pin
+//   wanted key.
+// * `pkg-b` deps `parent` plus `dep-of-pkg-with-1-dep` directly. The
+//   test bumps that direct dep; `target`'s snapshot also depends on
+//   it, so pkg-b's transitive edge to `target` (depth 1) is denied
+//   reuse by the changed-direct-dep gate and resolves fresh — with
+//   the same wanted key pkg-a already cached.
+//
+// Importers resolve in order, so pkg-a's cache entry exists when
+// pkg-b's denied edge looks up; the depth-1 occurrence out-ranks the
+// depth-2 one for children ownership, making the corruption (before
+// the fix) deterministic rather than a race.
+//
+// `target`'s dep `@pnpm.e2e/abc` wants peers nothing in the subtree
+// provides, so auto-install-peers suffixes `target` — the corrupted
+// instance is then visible as a distinct bare-key `{}` snapshot rather
+// than colliding with the healthy suffixed one.
🤖 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/tests/lockfile_resolution_reuse.rs` around lines 154 - 189,
Convert the test scenario documentation preceding the lockfile reuse test from
rustdoc comments (`///`) to regular comments (`//`). Preserve the existing
explanatory content and formatting, changing only the comment style because this
is internal test rationale rather than a public API contract.

Source: Coding guidelines

.changeset/reuse-denied-edge-empty-snapshot.md (1)

5-5: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Simplify the release note to focus on the user-visible bug.

As per path instructions, changesets should be accurate and concise for users, while implementation rationale (such as explanations of the "wanted-dependency cache" and "dependency-less resolution") belongs in commits. Consider simplifying the text to remove these internal details.

♻️ Proposed refactor
-Fixed a lockfile corruption during non-frozen re-installs: when one workspace project reused a package's resolution from the lockfile and another project's edge to the same package was denied reuse (for example because it also depends on a direct dependency whose specifier changed), the denied edge could read the reused, dependency-less resolution from the shared wanted-dependency cache and record the package as a leaf. Its lockfile snapshot became empty (`{}`), its peer suffix was dropped, and none of its dependencies were linked, which later broke installs and builds consuming that lockfile [`#13070`](https://github.com/pnpm/pnpm/pull/13070).
+Fixed a lockfile corruption during non-frozen re-installs: when one workspace project reused a package's resolution from the lockfile and another project's edge to the same package was denied reuse (e.g., due to a changed direct dependency), the package's lockfile snapshot could become empty (`{}`), dropping its peer suffix and dependencies, which broke subsequent installs [`#13070`](https://github.com/pnpm/pnpm/pull/13070).
🤖 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 @.changeset/reuse-denied-edge-empty-snapshot.md at line 5, Rewrite the
changeset entry to concisely describe the user-visible outcome: non-frozen
reinstalls could produce an incomplete lockfile when resolving shared
dependencies, causing later installs and builds to fail. Remove internal
implementation details about caches, denied edges, resolutions, peer suffixes,
and dependency linking while retaining the issue reference.

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.

Nitpick comments:
In @.changeset/reuse-denied-edge-empty-snapshot.md:
- Line 5: Rewrite the changeset entry to concisely describe the user-visible
outcome: non-frozen reinstalls could produce an incomplete lockfile when
resolving shared dependencies, causing later installs and builds to fail. Remove
internal implementation details about caches, denied edges, resolutions, peer
suffixes, and dependency linking while retaining the issue reference.

In `@pnpm/crates/cli/tests/lockfile_resolution_reuse.rs`:
- Around line 154-189: Convert the test scenario documentation preceding the
lockfile reuse test from rustdoc comments (`///`) to regular comments (`//`).
Preserve the existing explanatory content and formatting, changing only the
comment style because this is internal test rationale rather than a public API
contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b6f473b1-5536-4b63-a81f-5e0d2af45ce5

📥 Commits

Reviewing files that changed from the base of the PR and between 2bc4dd5 and 9e8cd6e.

📒 Files selected for processing (6)
  • .changeset/reuse-denied-edge-empty-snapshot.md
  • pnpm/crates/cli/tests/lockfile_resolution_reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-grand/1.0.0/package.json
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-parent/1.0.0/package.json
  • pnpr/.fixtures/packages/@pnpm.e2e/reuse-chain-target/1.0.0/package.json

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 18, 2026
@codecov-commenter

codecov-commenter commented Jul 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.66%. Comparing base (9657c88) to head (1d1e23a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13122   +/-   ##
=======================================
  Coverage   85.66%   85.66%           
=======================================
  Files         505      505           
  Lines       83555    83535   -20     
=======================================
- Hits        71574    71557   -17     
+ Misses      11981    11978    -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 9e8cd6e6d970

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.500 ± 0.164 2.341 2.759 1.67 ± 0.20
pacquet@main 2.494 ± 0.135 2.350 2.732 1.66 ± 0.19
pnpr@HEAD 1.560 ± 0.161 1.371 1.734 1.04 ± 0.15
pnpr@main 1.500 ± 0.147 1.349 1.775 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4997674412400004,
      "stddev": 0.16392983665116517,
      "median": 2.43406623194,
      "user": 1.6697030800000001,
      "system": 1.2827762,
      "min": 2.34092416544,
      "max": 2.75910372644,
      "times": [
        2.37849991344,
        2.42861380744,
        2.36825121444,
        2.39472397444,
        2.34092416544,
        2.45810253844,
        2.43951865644,
        2.67445582644,
        2.75910372644,
        2.75548058944
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.49418159484,
      "stddev": 0.13465045761194283,
      "median": 2.4931141619400004,
      "user": 1.6160705800000001,
      "system": 1.2866126999999998,
      "min": 2.35020968744,
      "max": 2.73165233444,
      "times": [
        2.50832630844,
        2.47790201544,
        2.38491717044,
        2.53079404844,
        2.36731418844,
        2.51178434844,
        2.37851215944,
        2.73165233444,
        2.70040368744,
        2.35020968744
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.56038329204,
      "stddev": 0.16081096486101168,
      "median": 1.56143049494,
      "user": 1.1617274800000001,
      "system": 1.1605596,
      "min": 1.37141370944,
      "max": 1.73389824444,
      "times": [
        1.7216079844399998,
        1.43810167044,
        1.6908559914399999,
        1.3801955774399999,
        1.6771229724399999,
        1.7296510764400002,
        1.41524767644,
        1.44573801744,
        1.73389824444,
        1.37141370944
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5003644612399998,
      "stddev": 0.14690820160179663,
      "median": 1.46422290444,
      "user": 1.1929161799999999,
      "system": 1.143369,
      "min": 1.34924986644,
      "max": 1.7751204194399999,
      "times": [
        1.5102765064399999,
        1.47647623344,
        1.7751204194399999,
        1.59137794344,
        1.34924986644,
        1.3736444214399999,
        1.7031464564399998,
        1.41234414844,
        1.3600390414399999,
        1.45196957544
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 245.4 ± 6.9 233.3 253.0 1.00
pacquet@main 245.8 ± 4.5 238.8 250.7 1.00 ± 0.03
pnpr@HEAD 259.9 ± 4.3 253.0 265.7 1.06 ± 0.03
pnpr@main 254.6 ± 5.2 248.8 266.7 1.04 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.24543539056000002,
      "stddev": 0.006857926568913409,
      "median": 0.24746313006000004,
      "user": 0.19488938,
      "system": 0.4939494000000001,
      "min": 0.23327779656000003,
      "max": 0.25300445556,
      "times": [
        0.25191077656000005,
        0.23677023456000001,
        0.25070430656000003,
        0.24583570356000004,
        0.24942242856000002,
        0.24818862356000002,
        0.25300445556,
        0.23850194356000004,
        0.24673763656000003,
        0.23327779656000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.24583005966000004,
      "stddev": 0.004506289127411957,
      "median": 0.24683991006000003,
      "user": 0.20316857999999996,
      "system": 0.48990619999999996,
      "min": 0.23876685356000002,
      "max": 0.25071996756000003,
      "times": [
        0.25071996756000003,
        0.23885831156000004,
        0.23876685356000002,
        0.25016070356000003,
        0.25049198156,
        0.24351769356000003,
        0.24382976556000002,
        0.24572222356000004,
        0.24827549956000003,
        0.24795759656000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.25989805326000004,
      "stddev": 0.0042681826283294646,
      "median": 0.2608865905600001,
      "user": 0.20038647999999998,
      "system": 0.5018399,
      "min": 0.25296093756000004,
      "max": 0.26568990556000005,
      "times": [
        0.25296093756000004,
        0.26313216056000005,
        0.25504199156,
        0.26071843056000005,
        0.26105475056000005,
        0.26568990556000005,
        0.26410655056000004,
        0.25689099756,
        0.26280665756000005,
        0.25657815056000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.25456504946,
      "stddev": 0.0051512950290063,
      "median": 0.25258432506000006,
      "user": 0.19206048,
      "system": 0.5184649,
      "min": 0.24881182456000003,
      "max": 0.26671118256000004,
      "times": [
        0.25702735756,
        0.25267809056,
        0.25682057556000004,
        0.26671118256000004,
        0.24881182456000003,
        0.25249055956000005,
        0.25039195356000005,
        0.25704557056000005,
        0.25123488756,
        0.25243849256
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.680 ± 0.008 2.667 2.697 1.78 ± 0.16
pacquet@main 2.662 ± 0.023 2.631 2.691 1.76 ± 0.16
pnpr@HEAD 1.594 ± 0.173 1.387 1.823 1.06 ± 0.15
pnpr@main 1.509 ± 0.138 1.374 1.735 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6802239211200005,
      "stddev": 0.007965100928916722,
      "median": 2.68159509842,
      "user": 1.7394789400000001,
      "system": 1.2735720799999999,
      "min": 2.6672149954199997,
      "max": 2.6968690024199997,
      "times": [
        2.6741421924199997,
        2.68259586842,
        2.6672149954199997,
        2.67541500242,
        2.68190104842,
        2.68128914842,
        2.68329489942,
        2.67500753742,
        2.6968690024199997,
        2.68450951642
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.6618080139199995,
      "stddev": 0.022943258958668736,
      "median": 2.67236219442,
      "user": 1.7150372400000002,
      "system": 1.28573928,
      "min": 2.63057867942,
      "max": 2.69116918742,
      "times": [
        2.69116918742,
        2.64780449442,
        2.6306799764199997,
        2.63684305442,
        2.66909233142,
        2.67689314242,
        2.6756320574199997,
        2.67926328542,
        2.63057867942,
        2.6801239304199997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5939552444199998,
      "stddev": 0.17282539238498784,
      "median": 1.6196229954199999,
      "user": 1.12635234,
      "system": 1.10501738,
      "min": 1.38735322742,
      "max": 1.82341000942,
      "times": [
        1.68119927542,
        1.76637308942,
        1.65268911242,
        1.82341000942,
        1.38735322742,
        1.44117463642,
        1.4017842874200002,
        1.7896461944200002,
        1.40936573342,
        1.58655687842
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5090615172200004,
      "stddev": 0.13783693625030083,
      "median": 1.44105540292,
      "user": 1.1398757400000001,
      "system": 1.08010828,
      "min": 1.37446406042,
      "max": 1.7354841594200001,
      "times": [
        1.37446406042,
        1.44106590142,
        1.38068942342,
        1.5246127794200002,
        1.44104490442,
        1.42066161042,
        1.7354841594200001,
        1.65827758842,
        1.41410109142,
        1.70021365342
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 535.3 ± 8.9 518.7 546.3 1.91 ± 0.06
pacquet@main 526.0 ± 7.9 513.2 538.8 1.87 ± 0.05
pnpr@HEAD 280.7 ± 7.0 270.5 291.9 1.00
pnpr@main 284.2 ± 3.8 278.4 289.7 1.01 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.53531606146,
      "stddev": 0.008910531511385596,
      "median": 0.5348383246599999,
      "user": 0.6720642199999999,
      "system": 0.6310432400000001,
      "min": 0.51868730466,
      "max": 0.54626604966,
      "times": [
        0.52782260666,
        0.53402958366,
        0.53200843666,
        0.5299375066600001,
        0.54626604966,
        0.5457328836600001,
        0.54569914366,
        0.51868730466,
        0.53564706566,
        0.53733003366
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5259630472600001,
      "stddev": 0.00787640492049623,
      "median": 0.5275271051600001,
      "user": 0.6518833199999998,
      "system": 0.6269634399999999,
      "min": 0.51323021366,
      "max": 0.53877241166,
      "times": [
        0.51323021366,
        0.51909288966,
        0.5324396476600001,
        0.53133425666,
        0.5190416666600001,
        0.53877241166,
        0.53047527666,
        0.52557107566,
        0.5201898996600001,
        0.5294831346600001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28065684925999995,
      "stddev": 0.007008041426038309,
      "median": 0.27980416516,
      "user": 0.16456511999999998,
      "system": 0.49372153999999996,
      "min": 0.27046819266,
      "max": 0.29187144566,
      "times": [
        0.27848311866000003,
        0.29000246766,
        0.28130439666,
        0.28013730966,
        0.27404245966,
        0.27046819266,
        0.27947102066,
        0.28649274966,
        0.27429533166000003,
        0.29187144566
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.28417036955999997,
      "stddev": 0.00375113677230441,
      "median": 0.28503583966,
      "user": 0.16980672000000002,
      "system": 0.49143033999999997,
      "min": 0.27836045066,
      "max": 0.28972084766,
      "times": [
        0.28730806666,
        0.28497147566000003,
        0.27836045066,
        0.28536198566,
        0.28972084766,
        0.28510020366,
        0.28136847066,
        0.28753665466,
        0.28320862966,
        0.27876691066000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.846 ± 0.008 1.835 1.860 6.56 ± 0.20
pacquet@main 1.827 ± 0.010 1.808 1.844 6.49 ± 0.20
pnpr@HEAD 0.286 ± 0.009 0.274 0.300 1.01 ± 0.04
pnpr@main 0.281 ± 0.008 0.270 0.295 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.8460559754,
      "stddev": 0.008421170698352326,
      "median": 1.8464670586,
      "user": 0.88703164,
      "system": 0.73282114,
      "min": 1.8353606481,
      "max": 1.8604177161,
      "times": [
        1.8357214511,
        1.8466683231,
        1.8604177161,
        1.8399732101,
        1.8391570721000001,
        1.8500801841,
        1.8533725651000001,
        1.8535427901,
        1.8462657941,
        1.8353606481
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.8268404847,
      "stddev": 0.009762133201016347,
      "median": 1.8256974796,
      "user": 0.8715273399999999,
      "system": 0.7182286400000001,
      "min": 1.8075588241,
      "max": 1.8436305761,
      "times": [
        1.8225223491,
        1.8242465681,
        1.8274234351,
        1.8377569771,
        1.8238417571,
        1.8436305761,
        1.8321307330999999,
        1.8221452361000001,
        1.8271483911,
        1.8075588241
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28557266119999997,
      "stddev": 0.009070922941313618,
      "median": 0.2878121041,
      "user": 0.15968043999999998,
      "system": 0.50174004,
      "min": 0.27382597410000004,
      "max": 0.30041609610000003,
      "times": [
        0.2773013831,
        0.29167138410000004,
        0.27382597410000004,
        0.29130454710000003,
        0.30041609610000003,
        0.27489758810000003,
        0.2860563601,
        0.2928760141,
        0.2778094171,
        0.2895678481
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.281381048,
      "stddev": 0.008360632197951893,
      "median": 0.2797782956,
      "user": 0.17352524,
      "system": 0.4870830399999999,
      "min": 0.2702690351,
      "max": 0.2950328501,
      "times": [
        0.27161831610000003,
        0.2833225991,
        0.2702690351,
        0.2821597361,
        0.2773008381,
        0.27653766310000005,
        0.2876344361,
        0.2773968551,
        0.2950328501,
        0.29253815110000003
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 324.2 ± 6.6 314.4 336.6 3.91 ± 0.13
pacquet@main 322.8 ± 7.7 314.1 335.4 3.89 ± 0.14
pnpr@HEAD 84.6 ± 3.8 80.0 94.7 1.02 ± 0.05
pnpr@main 83.0 ± 2.1 80.9 89.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.32418065676,
      "stddev": 0.006584388631094896,
      "median": 0.32421927256000005,
      "user": 0.30794256000000003,
      "system": 0.07299053999999999,
      "min": 0.31442679956,
      "max": 0.33656548556000004,
      "times": [
        0.31702786056000004,
        0.32782045856,
        0.31442679956,
        0.32794787156000005,
        0.33656548556000004,
        0.32482721556000005,
        0.32897327856,
        0.32245737756000004,
        0.31814889056000006,
        0.32361132956000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.32282383826,
      "stddev": 0.007679083877741812,
      "median": 0.32217752006,
      "user": 0.31285046,
      "system": 0.06448113999999999,
      "min": 0.31405813156000006,
      "max": 0.33535408756000007,
      "times": [
        0.31728850356000005,
        0.33535408756000007,
        0.31415999856000004,
        0.32299597156000004,
        0.32135906856,
        0.32590813456000006,
        0.31405813156000006,
        0.32975689456,
        0.31561806056,
        0.33173953156
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08464736168121213,
      "stddev": 0.0038130242937935177,
      "median": 0.08373529656,
      "user": 0.016985626666666667,
      "system": 0.010900328484848483,
      "min": 0.08002792756000002,
      "max": 0.09469523856,
      "times": [
        0.08485038556000002,
        0.08857605756,
        0.08369187255999999,
        0.08002792756000002,
        0.08336202456,
        0.08018643056,
        0.08183243056,
        0.08644322956,
        0.08019065656000002,
        0.08463044556000002,
        0.08373529656,
        0.08003270356,
        0.09006911856,
        0.08330431356000001,
        0.08992230856,
        0.09407008656000002,
        0.08349842156000001,
        0.08167947256,
        0.08510306056,
        0.08741005256,
        0.08127279656,
        0.08854661856000001,
        0.08422839456,
        0.08026427856000001,
        0.08218421356,
        0.08707937656,
        0.08239140355999999,
        0.08558284156000001,
        0.08092511856000001,
        0.08231140456,
        0.08495561056,
        0.09469523856,
        0.08630934456
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08299516556000003,
      "stddev": 0.0021093201762368377,
      "median": 0.08231301856,
      "user": 0.016901929696969693,
      "system": 0.00919274181818182,
      "min": 0.08085220556,
      "max": 0.08934388656,
      "times": [
        0.08305053456,
        0.08143410556,
        0.08139430556000002,
        0.08149276156000002,
        0.08231301856,
        0.08119700556000001,
        0.08162550556,
        0.08198432056000002,
        0.08290082756,
        0.08238160656000001,
        0.08383235356000002,
        0.08196192056000001,
        0.08274945355999999,
        0.08497342356000001,
        0.08257208056000001,
        0.08610210656,
        0.08275417956,
        0.08196154756000001,
        0.08095849156000001,
        0.08643950556000002,
        0.08171715056000001,
        0.08095385256000001,
        0.08696928856,
        0.08085220556,
        0.08183424656000002,
        0.08248716655999999,
        0.08744814856,
        0.08934388656,
        0.08162393856,
        0.08480917256,
        0.08200256456000002,
        0.08287497956,
        0.08184480856000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.559 ± 0.158 4.400 4.846 1.28 ± 0.07
pacquet@main 4.501 ± 0.129 4.421 4.786 1.27 ± 0.06
pnpr@HEAD 3.553 ± 0.151 3.441 3.845 1.00
pnpr@main 3.569 ± 0.141 3.439 3.835 1.00 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.559140439079999,
      "stddev": 0.15776587117295407,
      "median": 4.4984931355799995,
      "user": 1.7729950199999998,
      "system": 1.39292262,
      "min": 4.39965584658,
      "max": 4.84645770858,
      "times": [
        4.5376298215799995,
        4.39965584658,
        4.588230201579999,
        4.4593564495799995,
        4.84645770858,
        4.44186316358,
        4.792520801579999,
        4.45207653758,
        4.42708520558,
        4.64652865458
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.500869117880001,
      "stddev": 0.12869133674825556,
      "median": 4.44325256608,
      "user": 1.7851472199999996,
      "system": 1.3995057199999998,
      "min": 4.4212629325799995,
      "max": 4.78649485358,
      "times": [
        4.4212629325799995,
        4.69162602558,
        4.42527705658,
        4.42731426758,
        4.4775678035799995,
        4.436309748579999,
        4.45019538358,
        4.432326949579999,
        4.78649485358,
        4.460316157579999
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5530338071800003,
      "stddev": 0.15061625726386452,
      "median": 3.49349520358,
      "user": 1.2936174200000001,
      "system": 1.22209272,
      "min": 3.44090157858,
      "max": 3.84523359958,
      "times": [
        3.44090157858,
        3.4575438105800003,
        3.4466220125800002,
        3.4694583955800002,
        3.51753201158,
        3.45259879858,
        3.55458630158,
        3.81200944758,
        3.84523359958,
        3.5338521155800002
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.568696003179999,
      "stddev": 0.1405169948957502,
      "median": 3.53379562808,
      "user": 1.2690392199999998,
      "system": 1.25696372,
      "min": 3.43863595358,
      "max": 3.83462853858,
      "times": [
        3.64128233058,
        3.56792016258,
        3.83462853858,
        3.77515386058,
        3.45425427558,
        3.45858025458,
        3.52460466858,
        3.54298658758,
        3.44891339958,
        3.43863595358
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13122
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,667.21 ms
(-8.46%)Baseline: 2,913.65 ms
3,496.38 ms
(76.28%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,835.36 ms
(-11.80%)Baseline: 2,080.87 ms
2,497.04 ms
(73.50%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
518.69 ms
(-27.04%)Baseline: 710.87 ms
853.05 ms
(60.80%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
314.43 ms
(-26.34%)Baseline: 426.87 ms
512.25 ms
(61.38%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,340.92 ms
(-11.66%)Baseline: 2,650.05 ms
3,180.06 ms
(73.61%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,399.66 ms
(-7.43%)Baseline: 4,752.75 ms
5,703.29 ms
(77.14%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
233.28 ms
(-20.78%)Baseline: 294.49 ms
353.38 ms
(66.01%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/13122
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,387.35 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
273.83 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
270.47 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
80.03 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,371.41 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,440.90 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
252.96 ms
🐰 View full continuous benchmarking report in Bencher

…he wanted-dep cache

During a non-frozen re-install, a node reused from the prior lockfile
registered its synthesized ResolveResult in the workspace-shared
resolved_by_wanted cache. That result's manifest deliberately omits
dependencies (a reused node's children come from the snapshot graph), so
when another edge with the identical wanted key was denied reuse — by
the changed-direct-dep gate in a different importer, or by
subtree_fully_reusable's provisional-false cycle guard racing a
concurrent check — its fresh resolve read the dependency-less result
back, classified the package as a leaf, and (when that occurrence was
shallow enough to win children ownership) recorded it with no children:
the package's lockfile snapshot collapsed to an empty map, its peer
suffix was dropped, its dependents were re-pointed at the bare instance,
and none of its dependencies were linked.

This is what broke the Compile & Lint job on the [email protected]
bump PR (#13070): the alpha.14 per-importer freshness check
regression (since fixed by #13117) pushed CI's plain install
onto the re-resolution path, which then emptied the snapshots of
`@yarnpkg/[email protected]` and `[email protected]`, leaving
`pnpm/dist` bundling unable to resolve their dependencies. The
corruption itself predates alpha.14 (reproducible on alpha.13 by
forcing a re-resolution with any manifest change).

Drop the cache insert: only the fresh-resolve path ever read it, and a
denied edge must see the real registry manifest to walk its children.
The regression test drives the deterministic cross-importer variant
using new reuse-chain-* registry fixtures: an unchanged importer reuses
the target at depth 2 (caching the synthesized result under the
exact-pin wanted key), then a later importer whose changed direct dep
overlaps the target's snapshot is denied reuse at depth 1 and must
re-resolve fresh.

The TypeScript CLI has no equivalent cache of synthesized reuse
results, so the fix is pacquet-only.
Copilot AI review requested due to automatic review settings July 18, 2026 11:17

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 1d1e23a

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

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

Labels

product: pacquet product: pnpr reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants