Skip to content

fix(lockfile): keep bundledDependencies and the libc shape on a reused package entry - #14154

Merged
zkochan merged 2 commits into
pnpm:mainfrom
lazerg:fix/issue-14153-preserve-bundled-dependencies
Aug 25, 2026
Merged

zkochan merged 2 commits into
pnpm:mainfrom
lazerg:fix/issue-14153-preserve-bundled-dependencies

Conversation

@lazerg

@lazerg lazerg commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When the resolver reuses a locked resolution, synthesize_manifest rebuilds the package's manifest from its packages: entry, but it never carried bundledDependencies over. The lockfile writer reads that field off the synthesized manifest, so every reused entry lost it — bumping one dependency stripped bundledDependencies from all 9 entries carrying it in the reproduction, none of them related to the change. Synthesizing the field back, in both its list and boolean form, makes a reused entry round-trip. The TypeScript CLI already keeps the field through the pick list in lockfile/fs/src/lockfileFormatConverters.ts, so this is Rust-only.

The same function also flattened libc through a &[String] helper, so an entry recorded as libc: musl came back as libc: [musl] on any rewrite. StringOrList exists precisely to keep that distinction, so it now keeps the scalar form too.

The prepare half of the report does not hold up: the TypeScript CLI drops that field too. It is absent from LockfilePackageInfo and from the same pick list, so a prepare: true marker is read into memory and then dropped on the next write there as well. Preserving it in the Rust CLI alone would be a divergence, so I left it out. Happy to do both stacks in a follow-up if you want the field kept.

Fixes #14153

Squash Commit Body

`synthesize_manifest` in the lockfile reuse gate rebuilds a manifest fragment
from a reused `packages:` entry, carrying peerDependencies, engines, cpu, os,
libc, deprecated and bin. bundledDependencies was missing, so
`BundledDependencies::from_manifest` in `build_package_metadata` found nothing
and the rewritten entry dropped the field. Any lockfile rewrite that reused a
resolution therefore deleted bundledDependencies from unrelated entries.

Both recorded shapes are synthesized back: the name list as a JSON array and
`true` as a JSON boolean, which is what `from_manifest` reads on the fresh
resolve path.

libc had a narrower case of the same bug. It was synthesized through
`string_array`, which takes `&[String]` and so reached StringOrList::String
through its Deref, always emitting an array; the writer then read that back as
a list. An entry recorded as `libc: musl` was rewritten as `libc: [musl]`. It
is now matched on and the scalar form is preserved.

The issue also reports that `prepare` is dropped. The TypeScript CLI drops it
as well — it is not a field of LockfilePackageInfo and not in the pick list of
convertToLockfileFile — so preserving it here alone would break parity, and it
is left for a change that covers both stacks.

Closes pnpm/pnpm#14153

Checklist

  • I checked the referenced issue and verified that none of the PRs
    already linked to it solves it.
  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.

Summary by CodeRabbit

  • Bug Fixes

    • Preserved bundledDependencies metadata when rewriting the lockfile.
    • Prevented unrelated package entries from losing bundled dependency information when another dependency is added or updated.
    • Preserved the original format of libc metadata, including plain-string values.
  • Tests

    • Added regression coverage for named and boolean bundled dependency metadata.
    • Added coverage ensuring scalar libc values remain unchanged.

@lazerg
lazerg requested a review from zkochan as a code owner August 25, 2026 11:09
@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 →

@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ea20f67e-d01a-4843-9e64-810e739545cf

📥 Commits

Reviewing files that changed from the base of the PR and between 45ebc85 and 49ba38e.

📒 Files selected for processing (4)
  • .changeset/lockfile-rewrite-keeps-bundled-dependencies.md
  • pnpm/crates/cli/tests/suite/bundled_dependencies.rs
  • pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs
  • pnpm/crates/resolving-deps-resolver/src/lockfile_reuse/tests.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/cli/tests/suite/bundled_dependencies.rs
  • .changeset/lockfile-rewrite-keeps-bundled-dependencies.md

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


📝 Walkthrough

Walkthrough

The resolver now preserves bundledDependencies and the recorded scalar-or-list shape of libc when it reconstructs reused lockfile entries. Tests cover manifest reconstruction and lockfile rewriting. A changeset records a patch release.

Changes

Lockfile metadata preservation

Layer / File(s) Summary
Reconstruct reused manifest metadata
pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs
synthesize_manifest now restores boolean or named bundledDependencies values and preserves scalar or list libc values.
Validate metadata during reuse and rewrite
pnpm/crates/resolving-deps-resolver/src/lockfile_reuse/tests.rs, pnpm/crates/cli/tests/suite/bundled_dependencies.rs, .changeset/lockfile-rewrite-keeps-bundled-dependencies.md
Tests verify both bundled dependency forms, scalar libc, and bundled dependency retention after a lockfile rewrite. The changeset declares a patch release for pacquet.

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

Merge Risk: ⚪ Minimal · up to 49ba3

This localized lockfile-preservation change has no actionable merge-blocking risk remaining and is merge-ready after normal checks and review.

Assessment against linked issues

Objective Addressed Explanation
Preserve bundledDependencies on reused entries during lockfile rewrites [#14153] ✅
Preserve prepare on reused entries during lockfile rewrites [#14153] ❌ The changed code does not reconstruct or preserve the prepare field.

Out-of-scope changes

Code Change Explanation
Preserve scalar-or-list libc metadata (pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs:340-344) Issue #14153 specifies bundledDependencies and prepare; it does not state a libc preservation objective.

Suggested labels: product: pacquet

Suggested reviewers: zkochan

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (3): Last reviewed commit: "fix(lockfile): keep a reused entry's lib..." | Re-trigger Greptile

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 25, 2026
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 25, 2026
@codecov-commenter

codecov-commenter commented Aug 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.62%. Comparing base (d669c8b) to head (3069c39).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ates/resolving-deps-resolver/src/lockfile_reuse.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14154   +/-   ##
=======================================
  Coverage   88.62%   88.62%           
=======================================
  Files         679      679           
  Lines      114319   114328    +9     
=======================================
+ Hits       101310   101323   +13     
+ Misses      13009    13005    -4     

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

@greptile-apps
greptile-apps Bot dismissed their stale review August 25, 2026 11:35

Dismissed because a newer commit was pushed; Greptile will re-review the current head.

@lazerg lazerg changed the title fix(lockfile): keep bundledDependencies on a reused package entry fix(lockfile): keep bundledDependencies and the libc shape on a reused package entry Aug 25, 2026
@zkochan zkochan mentioned this pull request Aug 25, 2026
13 of 14 tasks
@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 49ba38e4f645

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. 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.378 ± 0.110 2.270 2.605 1.75 ± 0.14
pacquet@main 2.362 ± 0.083 2.247 2.474 1.74 ± 0.13
pnpr@HEAD 1.360 ± 0.092 1.294 1.593 1.00
pnpr@main 1.436 ± 0.122 1.310 1.685 1.06 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.37776981048,
      "stddev": 0.11048851442283898,
      "median": 2.3345255265800002,
      "user": 1.3736549399999998,
      "system": 1.49291418,
      "min": 2.26985277008,
      "max": 2.60511048608
    },
    {
      "command": "pacquet@main",
      "mean": 2.3622438052800003,
      "stddev": 0.0831419824476842,
      "median": 2.35955017858,
      "user": 1.3066313399999998,
      "system": 1.41010868,
      "min": 2.2470962500800002,
      "max": 2.4740696470800003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.35953891138,
      "stddev": 0.09226024153457957,
      "median": 1.31660886158,
      "user": 1.17832524,
      "system": 1.22678198,
      "min": 1.2935193460799999,
      "max": 1.59336471908
    },
    {
      "command": "pnpr@main",
      "mean": 1.43567579938,
      "stddev": 0.12207245008073456,
      "median": 1.4082110015799998,
      "user": 1.31211484,
      "system": 1.3664445799999998,
      "min": 1.31009627208,
      "max": 1.68457692808
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 292.6 ± 15.8 268.5 318.8 1.06 ± 0.07
pacquet@main 285.4 ± 10.5 271.4 307.9 1.04 ± 0.05
pnpr@HEAD 275.2 ± 9.9 261.2 296.4 1.00
pnpr@main 290.8 ± 17.3 268.0 322.0 1.06 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.29256932638,
      "stddev": 0.01584921769402875,
      "median": 0.28948086538000006,
      "user": 0.23675998000000004,
      "system": 0.50675352,
      "min": 0.26851245138,
      "max": 0.31878549438000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.28537751318000004,
      "stddev": 0.010514381302444887,
      "median": 0.28259701288000005,
      "user": 0.21941548000000002,
      "system": 0.51711622,
      "min": 0.27138620338,
      "max": 0.30786757538000004
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2751616263800001,
      "stddev": 0.009933832015297295,
      "median": 0.27630225188,
      "user": 0.21774127999999998,
      "system": 0.4587825199999999,
      "min": 0.26121478638000006,
      "max": 0.29638314338000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.29079346588000005,
      "stddev": 0.017325921966835738,
      "median": 0.29126757738000003,
      "user": 0.23888777999999994,
      "system": 0.47308512,
      "min": 0.26802838238000004,
      "max": 0.32195219638000006
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 7.7 ± 0.7 6.3 10.5 1.03 ± 0.14
pacquet@main 7.8 ± 0.6 6.4 10.4 1.05 ± 0.14
pnpr@HEAD 8.3 ± 0.7 6.2 11.2 1.11 ± 0.15
pnpr@main 7.5 ± 0.8 6.4 12.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.007732854235945951,
      "stddev": 0.0007307823761337131,
      "median": 0.00769483904,
      "user": 0.004512934729729727,
      "system": 0.003261195810810809,
      "min": 0.0063187860400000006,
      "max": 0.01054991004
    },
    {
      "command": "pacquet@main",
      "mean": 0.007826872130185677,
      "stddev": 0.0006470588667585787,
      "median": 0.007816983040000001,
      "user": 0.004356448700265252,
      "system": 0.0035017020689655162,
      "min": 0.006429626040000001,
      "max": 0.010350936040000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008314204208674701,
      "stddev": 0.0007326601718683613,
      "median": 0.00821549754,
      "user": 0.004451486626506025,
      "system": 0.0038940499999999996,
      "min": 0.00624218404,
      "max": 0.01122737304
    },
    {
      "command": "pnpr@main",
      "mean": 0.007471389949348442,
      "stddev": 0.0007559324452436312,
      "median": 0.007328966040000001,
      "user": 0.00428996668555241,
      "system": 0.0032193976203966006,
      "min": 0.00643589704,
      "max": 0.012262588040000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 8.6 ± 1.0 6.9 12.2 1.09 ± 0.18
pacquet@main 8.2 ± 0.9 6.7 12.0 1.04 ± 0.17
pnpr@HEAD 8.5 ± 0.8 7.0 12.8 1.08 ± 0.16
pnpr@main 7.9 ± 0.9 6.0 11.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.008612499534545447,
      "stddev": 0.0009810110544927022,
      "median": 0.00848934508,
      "user": 0.004697521660079053,
      "system": 0.0039279187351778655,
      "min": 0.006871905080000001,
      "max": 0.01222246108
    },
    {
      "command": "pacquet@main",
      "mean": 0.008222633469438943,
      "stddev": 0.0009255172715902179,
      "median": 0.008047815080000001,
      "user": 0.0045526500990098985,
      "system": 0.003683344356435643,
      "min": 0.00666757108,
      "max": 0.012023025080000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008497017673525181,
      "stddev": 0.000792887385783188,
      "median": 0.008343345080000002,
      "user": 0.004592825467625897,
      "system": 0.003917795827338129,
      "min": 0.00700025608,
      "max": 0.012816006080000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.00788931666214286,
      "stddev": 0.0009378271692515984,
      "median": 0.00778300208,
      "user": 0.004857992142857142,
      "system": 0.003050996428571429,
      "min": 0.00600666808,
      "max": 0.01177158308
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.821 ± 0.030 2.784 2.887 1.83 ± 0.18
pacquet@main 2.780 ± 0.029 2.732 2.828 1.81 ± 0.18
pnpr@HEAD 1.538 ± 0.153 1.381 1.765 1.00
pnpr@main 1.570 ± 0.112 1.415 1.737 1.02 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.8208546304399995,
      "stddev": 0.03038993625648028,
      "median": 2.8131587317399998,
      "user": 1.88305832,
      "system": 1.4716430199999997,
      "min": 2.78432830474,
      "max": 2.88691455174
    },
    {
      "command": "pacquet@main",
      "mean": 2.7803268434399997,
      "stddev": 0.02871664851473919,
      "median": 2.7819421377399998,
      "user": 1.7616448200000001,
      "system": 1.38394412,
      "min": 2.73246949774,
      "max": 2.82836750874
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5381289099400002,
      "stddev": 0.15297414299838874,
      "median": 1.4968975742400001,
      "user": 1.13768892,
      "system": 1.3439716200000003,
      "min": 1.38057378074,
      "max": 1.76538415074
    },
    {
      "command": "pnpr@main",
      "mean": 1.5696833843400002,
      "stddev": 0.11223990691895433,
      "median": 1.57066216674,
      "user": 1.17312512,
      "system": 1.3473201199999998,
      "min": 1.4153344197400002,
      "max": 1.7371122277400002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 410.2 ± 23.1 369.9 443.2 1.33 ± 0.09
pacquet@main 408.8 ± 17.5 389.0 446.6 1.32 ± 0.07
pnpr@HEAD 335.2 ± 11.6 322.2 360.6 1.08 ± 0.05
pnpr@main 309.3 ± 9.9 295.2 325.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.41016535986,
      "stddev": 0.02308372211395936,
      "median": 0.40642634836,
      "user": 0.4433206399999999,
      "system": 0.6201228999999999,
      "min": 0.36985670536000004,
      "max": 0.44318193236000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.40879138275999993,
      "stddev": 0.017493337230942475,
      "median": 0.40594019536000003,
      "user": 0.44775763999999996,
      "system": 0.6370066000000001,
      "min": 0.38895844436000004,
      "max": 0.44662511336000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33516364486,
      "stddev": 0.011637955220974213,
      "median": 0.33195158086,
      "user": 0.21985634000000004,
      "system": 0.5071144,
      "min": 0.32215496436,
      "max": 0.36055927136
    },
    {
      "command": "pnpr@main",
      "mean": 0.30926894456000004,
      "stddev": 0.009929335014293925,
      "median": 0.30862631436,
      "user": 0.19435293999999997,
      "system": 0.47664919999999994,
      "min": 0.29517278436,
      "max": 0.32506688736
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.834 ± 0.024 1.798 1.877 5.88 ± 0.27
pacquet@main 1.851 ± 0.022 1.824 1.881 5.94 ± 0.27
pnpr@HEAD 0.312 ± 0.014 0.296 0.341 1.00
pnpr@main 0.332 ± 0.031 0.316 0.419 1.06 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.8340852710600004,
      "stddev": 0.02425509952367353,
      "median": 1.8321422463600001,
      "user": 0.64950226,
      "system": 0.6528742000000001,
      "min": 1.7978406798600002,
      "max": 1.8768075298600002
    },
    {
      "command": "pacquet@main",
      "mean": 1.85106703726,
      "stddev": 0.021821814885033194,
      "median": 1.8519167818600002,
      "user": 0.66706746,
      "system": 0.6784699,
      "min": 1.8235914688600001,
      "max": 1.8814805458600001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.31179621246000006,
      "stddev": 0.013865572962872271,
      "median": 0.30786290486,
      "user": 0.21171215999999998,
      "system": 0.4540826,
      "min": 0.29593909586,
      "max": 0.34077096286
    },
    {
      "command": "pnpr@main",
      "mean": 0.33191461296,
      "stddev": 0.030965587903193398,
      "median": 0.32234168136,
      "user": 0.21384276,
      "system": 0.5275212,
      "min": 0.31575450686,
      "max": 0.41912101486000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 219.7 ± 23.4 182.4 257.3 2.23 ± 0.25
pacquet@main 228.6 ± 18.1 206.2 251.6 2.32 ± 0.19
pnpr@HEAD 98.7 ± 2.8 95.2 108.3 1.00
pnpr@main 99.0 ± 3.1 94.8 108.0 1.00 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2197131418436364,
      "stddev": 0.023409139726186926,
      "median": 0.21120778148000002,
      "user": 0.15736053454545454,
      "system": 0.05917639272727273,
      "min": 0.18242228248000003,
      "max": 0.25725791848
    },
    {
      "command": "pacquet@main",
      "mean": 0.22855126671076922,
      "stddev": 0.018095410869890593,
      "median": 0.22363678148000002,
      "user": 0.17570608000000001,
      "system": 0.05278865846153846,
      "min": 0.20620065148000002,
      "max": 0.25156566048
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09872267682482756,
      "stddev": 0.0028244410587671435,
      "median": 0.09824694248,
      "user": 0.028831080000000002,
      "system": 0.011987257931034483,
      "min": 0.09518561948,
      "max": 0.10833570248
    },
    {
      "command": "pnpr@main",
      "mean": 0.09903906615857143,
      "stddev": 0.0031450544581574425,
      "median": 0.09807628148,
      "user": 0.028054294285714286,
      "system": 0.013721262857142856,
      "min": 0.09479626648,
      "max": 0.10804150048
    }
  ]
}

Scenario: Isolated linker: peer-heavy resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 613.3 ± 85.8 479.6 719.6 1.05 ± 0.27
pacquet@main 586.0 ± 127.3 382.9 769.2 1.00
pnpm@HEAD 3018.2 ± 39.6 2965.2 3088.0 5.15 ± 1.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6133241789533334,
      "stddev": 0.08576463230516448,
      "median": 0.63862218262,
      "user": 0.5944811666666666,
      "system": 0.11484736666666666,
      "min": 0.47963002962000006,
      "max": 0.71959257862
    },
    {
      "command": "pacquet@main",
      "mean": 0.5860244652866666,
      "stddev": 0.12728236360485243,
      "median": 0.55844723062,
      "user": 0.546473611111111,
      "system": 0.11651925555555558,
      "min": 0.38287782462000003,
      "max": 0.76917532462
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0182054027311107,
      "stddev": 0.03959333542656282,
      "median": 3.01753895962,
      "user": 4.563949833333333,
      "system": 0.28043258888888883,
      "min": 2.96522931862,
      "max": 3.0879767816199997
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.367 ± 0.126 4.298 4.720 1.27 ± 0.05
pacquet@main 4.429 ± 0.152 4.304 4.710 1.29 ± 0.06
pnpr@HEAD 3.536 ± 0.153 3.370 3.796 1.03 ± 0.06
pnpr@main 3.436 ± 0.110 3.362 3.738 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.36711169342,
      "stddev": 0.12616542896262806,
      "median": 4.329838758520001,
      "user": 1.4553259600000001,
      "system": 1.4635933199999998,
      "min": 4.298318532520001,
      "max": 4.72035398952
    },
    {
      "command": "pacquet@main",
      "mean": 4.428863250220001,
      "stddev": 0.15182690074424454,
      "median": 4.37062728602,
      "user": 1.4520395599999998,
      "system": 1.45145042,
      "min": 4.303809402520001,
      "max": 4.710272914520001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.53588374222,
      "stddev": 0.15302050665335806,
      "median": 3.5564870430199997,
      "user": 1.3823657599999999,
      "system": 1.4539514199999997,
      "min": 3.36990967152,
      "max": 3.79595149852
    },
    {
      "command": "pnpr@main",
      "mean": 3.43628136542,
      "stddev": 0.10954924535852721,
      "median": 3.39547543802,
      "user": 1.3773522599999999,
      "system": 1.4229188199999996,
      "min": 3.36215288152,
      "max": 3.73802510452
    }
  ]
}

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

Same install as the isolated fresh-restore hot/hot scenario, into the shared virtual store — the layout pnpm 12 installs into by default. Comparable to that scenario head-to-head.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 162.7 ± 5.3 154.8 172.5 1.00
pacquet@main 164.0 ± 5.5 156.5 175.9 1.01 ± 0.05
pnpr@HEAD 177.4 ± 5.8 169.8 186.9 1.09 ± 0.05
pnpr@main 177.1 ± 6.3 168.1 189.3 1.09 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1627001101666667,
      "stddev": 0.00528455359063347,
      "median": 0.16454313090000003,
      "user": 0.18444447999999994,
      "system": 0.19077230666666667,
      "min": 0.1547587619,
      "max": 0.17249558590000003
    },
    {
      "command": "pacquet@main",
      "mean": 0.16403449302500006,
      "stddev": 0.005474165604538138,
      "median": 0.16312483090000002,
      "user": 0.18858046750000004,
      "system": 0.19057082750000004,
      "min": 0.15649489490000001,
      "max": 0.1758691679
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1773631411857143,
      "stddev": 0.005778110822706669,
      "median": 0.1773875814,
      "user": 0.20672278000000002,
      "system": 0.1878509971428571,
      "min": 0.1698228629,
      "max": 0.18690786290000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.1770503287666667,
      "stddev": 0.0062795895035642445,
      "median": 0.17454609990000003,
      "user": 0.19709327999999995,
      "system": 0.19429550666666667,
      "min": 0.1680984329,
      "max": 0.1892924649
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/14154
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
154.76 ms
(-5.08%)Baseline: 163.04 ms
195.65 ms
(79.10%)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,784.33 ms
(+2.33%)Baseline: 2,720.80 ms
3,264.96 ms
(85.28%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,797.84 ms
(-3.56%)Baseline: 1,864.12 ms
2,236.94 ms
(80.37%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
369.86 ms
(-6.13%)Baseline: 394.02 ms
472.82 ms
(78.22%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
182.42 ms
(-12.82%)Baseline: 209.24 ms
251.08 ms
(72.65%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,269.85 ms
(-0.57%)Baseline: 2,282.97 ms
2,739.56 ms
(82.85%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,298.32 ms
(-0.64%)Baseline: 4,326.21 ms
5,191.45 ms
(82.80%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
268.51 ms
(-0.87%)Baseline: 270.88 ms
325.06 ms
(82.60%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
479.63 ms
(-0.78%)Baseline: 483.38 ms
580.05 ms
(82.69%)
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
🚷 view threshold
6.87 ms
(+15.83%)Baseline: 5.93 ms
7.12 ms
(96.52%)
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
🚷 view threshold
6.32 ms
(+3.62%)Baseline: 6.10 ms
7.32 ms
(86.35%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/14154
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)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
169.82 ms
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,380.57 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
295.94 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
322.15 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
95.19 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,293.52 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,369.91 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.21 ms
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
7.00 ms
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
6.24 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan force-pushed the fix/issue-14153-preserve-bundled-dependencies branch from 49ba38e to 3069c39 Compare August 25, 2026 12:09
@zkochan
zkochan merged commit 08a082f into pnpm:main Aug 25, 2026
30 checks passed
@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Bundled deps double-cloned 🐞 Bug ⛨ Security
Description
When a resolution is reused, synthesize_manifest clones bundledDependencies into a JSON Value,
and later BundledDependencies::from_manifest clones it again when rebuilding PackageMetadata,
amplifying memory/CPU for large (attacker-controlled) lockfiles. This adds a resource-exhaustion
(DoS) surface during lockfile rewrite paths that wasn’t present for this field before the PR.
Code

pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs[R349-354]

+    if let Some(bundled) = metadata.bundled_dependencies.as_ref() {
+        let value = match bundled {
+            BundledDependencies::Boolean(bundles_all) => Value::Bool(*bundles_all),
+            BundledDependencies::Names(names) => string_array(names),
+        };
+        manifest.insert("bundledDependencies".to_string(), value);
Relevance

●●● Strong

Recent resolver reviews accepted eliminating avoidable allocations involving potentially large
lockfile-controlled data.

PR-#13787
PR-#13855

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR adds bundledDependencies emission by cloning the stored vector into a JSON array, and the
lockfile writer path later re-creates BundledDependencies from the manifest by collecting/cloning
strings again. This creates an avoidable second allocation proportional to the size of
bundledDependencies for each reused entry, which matters for large/hostile lockfiles.

pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs[339-369]
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[773-863]
pnpm/crates/lockfile/src/package_metadata.rs[67-92]
PR-#13787

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

### Issue description
On the lockfile-reuse path, `bundledDependencies` is cloned into a synthesized manifest (`serde_json::Value`) and then immediately re-parsed/cloned back into `PackageMetadata` by `BundledDependencies::from_manifest`. For large lockfiles (including maliciously large ones), this creates unnecessary extra allocations and CPU during `pnpm` operations that rewrite the lockfile.

### Issue Context
This PR adds `bundledDependencies` to the synthesized manifest to preserve round-trip fidelity. That correctness goal is valid, but the current approach introduces a double-clone of potentially large vectors.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs[349-369]
- pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs[773-863]
- pnpm/crates/lockfile/src/package_metadata.rs[67-92]

### Proposed fix direction
Introduce a fast-path for reused entries so `PackageMetadata.bundled_dependencies` (and other reused-only metadata) can be carried directly from the reused `packages:` entry instead of being re-derived from the synthesized JSON manifest. Concretely, consider one of:
1) Extend the reused-node representation (e.g., on `ResolveResult` or the graph node) to carry `bundled_dependencies: Option<BundledDependencies>` and have `build_package_metadata` prefer that field when present.
2) Add an explicit reuse marker and let `build_package_metadata` pull `bundled_dependencies` from the prior lockfile metadata when reuse is active.

Either option preserves the PR’s round-trip guarantee while avoiding the extra clone/parse step.

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


2. Reuse test can false-green 🐞 Bug ☼ Reliability
Description
The new integration test asserts bundledDependencies survives a rewrite, but it does not verify
the first package’s resolution was actually reused (the only path that previously dropped the
field). If the implementation later stops reusing in this scenario, the test will still pass because
a fresh resolve would also keep bundledDependencies.
Code

pnpm/crates/cli/tests/suite/bundled_dependencies.rs[R157-160]

+    // Adding an unrelated package rewrites the lockfile while the first
+    // entry's resolution is reused rather than resolved again.
+    pacquet_in(&workspace).with_args(["add", "@pnpm.e2e/[email protected]"]).assert().success();
+
Relevance

●●● Strong

Recent CLI test reviews accepted strengthening assertions that prove the intended path actually
executed.

PR-#14148
PR-#14085
PR-#13993

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Lockfile reuse is explicitly best-effort and returns None to force fresh resolution in multiple
cases, so a test that doesn’t prove reuse occurred can pass without exercising the intended path.
The existing lockfile reuse test suite demonstrates discriminating patterns (dead registry) to
guarantee reuse actually happened.

pnpm/crates/cli/tests/suite/bundled_dependencies.rs[150-166]
pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs[19-52]
pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs[681-695]
PR-#13425

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

### Issue description
`bundled_dependencies_survive_a_lockfile_rewrite` is intended to cover the lockfile-reuse rewrite path, but it does not assert that reuse actually occurred. That makes the test vulnerable to false-greens if future behavior re-resolves the first dependency instead of reusing it.

### Issue Context
Lockfile reuse is conditional and can fall back to a fresh resolve for multiple reasons; tests in `lockfile_resolution_reuse.rs` use discriminating setups (e.g., dead registry) to prove reuse must have happened.

### Fix Focus Areas
- pnpm/crates/cli/tests/suite/bundled_dependencies.rs[150-169]
- pnpm/crates/resolving-deps-resolver/src/lockfile_reuse.rs[19-52]
- pnpm/crates/cli/tests/suite/lockfile_resolution_reuse.rs[681-695]

### Proposed fix direction
Make the test discriminating by ensuring the second operation can only succeed if the first package is reused. For example:
- After the first `add`, make the mocked registry unavailable, then perform a lockfile-rewriting operation that does **not** require registry access (e.g., add a local `file:` or workspace dependency). If the first package were re-resolved, the command would fail.

Alternatively, assert reuse via CLI output if there is a stable progress line indicating `reused > 0` for the second operation (only if that output is guaranteed across platforms/verbosity).

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



Informational

3. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset only bumps pacquet and does not include a pnpm entry. This violates the
requirement that changeset front-matter explicitly declares the pnpm package and an appropriate
bump type.
Code

.changeset/lockfile-rewrite-keeps-bundled-dependencies.md[R1-3]

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

● Weak

Recent matching compliance findings were rejected, including the explicit pnpm-entry request in PR
#14142.

PR-#14142

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires that each new/modified changeset file includes an entry for the
pnpm package with a valid bump type. The added changeset front-matter lists only pacquet, with
no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/lockfile-rewrite-keeps-bundled-dependencies.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 is missing a required `pnpm` entry.

## Issue Context
Compliance requires every added/modified changeset to explicitly include the `pnpm` package with a valid bump type (`patch`/`minor`/`major`). This PR adds a changeset that currently only lists `pacquet`.

## Fix Focus Areas
- .changeset/lockfile-rewrite-keeps-bundled-dependencies.md[1-3]

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


Grey Divider

Context sources
✅ Compliance rules (platform): 27 rules
Review mode: ⚖️ Balanced

Grey Divider

Tip of the day
💡 Did you know, you can hide the parts of a finding you never read, like the evidence or the agent prompt

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

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

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review state: automerge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lockfile rewrite drops bundledDependencies (and prepare) from reused package entries

3 participants