Skip to content

fix(verify): stop lockfile verification from keeping every version's manifest - #16668

Merged
zkochan merged 4 commits into
mainfrom
altaywtf/fix-16656-verify-lockfile-memory
Oct 6, 2026
Merged

zkochan merged 4 commits into
mainfrom
altaywtf/fix-16656-verify-lockfile-memory

Conversation

@altaywtf

@altaywtf altaywtf commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Lockfile verification under trustPolicy / minimumReleaseAge kept a typed manifest of every published version of every checked package for the rest of the install. This drops that retention; peak RSS falls by 0.6 to 0.7 GB in the repro below.

Closes #16656

Where the memory went (v12, live-heap profile right after verification, 1,355-entry lockfile):

Retained after verification before after
Manifests hydrated into the resolver's shared packuments by the verifier's projections ~320 MB (trust), ~344 MB (age) 0
Trust projection (typed PackageVersion per version) ~230 MB one evidence rank per version
  • PackageVersions::iter_policy_fields walks versions without filling the hydration cache; both verifier projections use it, so the shared packument stays lazy. It decodes only dist and _npmUser, plus every other field whose decode can fail, so a version decodes there exactly when it decodes as a PackageVersion. Skipping the #[serde(flatten)] catch-all cuts the verification pass's CPU time from 4.5–5.3 s to 2.5 s user time (1,211-entry lockfile, warm mirror, Linux).
  • fail_if_trust_downgraded reads a TrustHistory; Package implements it as before, and the verifier caches a compact projection (time map plus an evidence rank per decodable version).
  • Verifier fetches project the document instead of hydrating it whole; a damaged mirror fragment still refetches, and offline still fails with ERR_PNPM_NO_OFFLINE_META.
  • Accept/reject outcomes and error text are unchanged: the projection keeps exactly the versions and evidence the typed projection kept.

Peak RSS, macOS arm64, cold cache and store, pnpm install --lockfile-only -r --ignore-scripts --ignore-pnpmfile --no-frozen-lockfile after bumping one direct dependency (synthetic 2-project workspace from public packages: next, firebase, prisma, aws-sdk, angular, nest, ...):

Policies main peak RSS this PR heap live after verification, main → PR
both 3.19 GB 2.45 GB
trustPolicy only 2.62 GB 2.04 GB 643 → 224 MB
minimumReleaseAge only 1.93 GB 1.30 GB 517 → 251 MB
neither 0.32 GB 0.28 GB

Live heap came from a counting global allocator in a local build. The gap between live heap (peak about 0.5 to 0.7 GB with this PR) and RSS is transient packument decoding plus macOS malloc not returning freed pages; that part is not addressed here.

npm has no lockfile policy verification pass to compare against.

pnpm v11 is not changed. Its projections hold plain JS objects and never hydrate the shared packuments, so the v12 mechanism does not exist there. In the same repro v11 peaks at 2.3 GB with both policies and 2.0 GB with verification skipped (trustLockfile); verification retains about 190 MB of post-GC heap and the rest is resolution.

Not verified: Linux (glibc) RSS, where Mend runs. RSS varies by up to 0.5 GB between runs on this machine; the table shows one run each.

Squash Commit Body

The verifier projected each packument by walking `versions.iter()`, which
hydrates every manifest. On the resolver's shared packument that hydration
stays cached for the rest of the install, so checking a 1,400-entry
lockfile kept a full manifest of every published version of every checked
package. The trust projection also kept a typed manifest per version.

- `PackageVersions::iter_policy_fields` decodes only the fields the
  policy checks read, without filling the cache. It fails to decode
  exactly where a `PackageVersion` does, so the version set is unchanged.
- The trust check reads a `TrustHistory`; the verifier keeps one evidence
  rank per version instead of a manifest.
- Verifier fetches project the document without hydrating it as a whole.

Accept and reject outcomes are unchanged: the projection keeps the same
versions and evidence the typed projection did.

Closes pnpm/pnpm#16656

Checklist

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

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


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Performance
    • Lockfile verification against trust policies and minimum release age uses less memory, especially for packages with long release histories, by avoiding retention of every published version’s full metadata during installation.
  • Reliability
    • Damaged cached package metadata is detected and refreshed when needed, helping verification use valid registry data. Release-age and trust-downgrade checks continue to behave as before.

The verifier projected each packument by walking `versions.iter()`, which
hydrates every manifest. On the resolver's shared packument that hydration
stays cached for the rest of the install, so checking a 1,400-entry
lockfile kept a full manifest of every published version of every checked
package. The trust projection also kept a typed manifest per version.

- `PackageVersions::iter_uncached` decodes without filling the cache.
- The trust check reads a `TrustHistory`; the verifier keeps one evidence
  rank per version instead of a manifest.
- Verifier fetches project the document without hydrating it as a whole.

Accept and reject outcomes are unchanged: the projection keeps the same
versions and evidence the typed projection did.

Closes #16656
Copilot AI balanced review requested due to automatic review settings October 6, 2026 17:13
@altaywtf
altaywtf requested a review from zkochan as a code owner October 6, 2026 17:13
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@altaywtf altaywtf changed the title fix(verify): keep lockfile verification memory flat in the entry count fix(verify): stop lockfile verification from keeping every version's manifest Oct 6, 2026
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 510b3f9d-1a6d-45d4-904a-806b5ce93fb1
📥 Commits

Reviewing files that changed from the base of the PR and between 0278d16 and 6325c05.

📒 Files selected for processing (1)
  • pnpm/crates/registry/src/package_version.rs

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


📝 Walkthrough

Walkthrough

Lockfile verification can read policy fields without retaining decoded manifests in version hydration caches. The npm resolver fetches projected metadata for trust and abbreviated metadata checks. It refetches metadata when it detects a damaged mirror fragment.

Changes

Lockfile verification metadata

Layer / File(s) Summary
Uncached package-version iteration
pnpm/crates/registry/src/package_version.rs, pnpm/crates/registry/src/package_versions.rs, pnpm/crates/registry/src/package_versions/mirror.rs, pnpm/crates/registry/src/lib.rs, pnpm/crates/registry/src/package_versions/tests.rs, .changeset/lockfile-verification-memory.md
VersionPolicyFields and a matching deserialization probe support reading policy fields without caching otherwise-unhydrated manifests. Mirror checking validates fragments without hydrating valid versions. Tests cover decoding, cache behavior, and corrupt fragments. The changeset describes the memory change.
Projected metadata fetch and mirror recovery
pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs, pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached/*, pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs
Projected fetches apply a projection to fetched metadata and check for damaged mirror fragments. The fetch path refetches after detecting corruption. Tests cover offline and online cases.
Trust-history projection and verifier wiring
pnpm/crates/resolving-npm-resolver/src/trust_checks.rs, pnpm/crates/resolving-npm-resolver/src/lookup_context.rs, pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier*, pnpm/crates/resolving-npm-resolver/src/npm_resolver/guarded_pick.rs, pnpm/crates/resolving-npm-resolver/src/lib.rs
Trust checks accept the TrustHistory interface. Verifier paths cache projected trust history and collect abbreviated metadata from policy fields. A test verifies that policy checks do not hydrate versions in a shared packument.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant VerificationMetadataClient
  participant fetch_full_metadata_projected
  participant PackageVersions
  participant TrustHistoryProjection
  VerificationMetadataClient->>fetch_full_metadata_projected: Fetch metadata and apply projection
  fetch_full_metadata_projected->>PackageVersions: Check mirror fragments
  fetch_full_metadata_projected->>TrustHistoryProjection: Build projected trust history
  VerificationMetadataClient->>TrustHistoryProjection: Cache and use projected trust history
Loading

Assessment against linked issues

Objective Addressed Explanation
Reduce verification memory by discarding package metadata or fetching only policy-required data [#16656] ✅

Suggested labels: product: pacquet

Merge Risk: ⚪ Minimal · up to 6325c

No actionable issue is established for this change; it is mergeable after normal checks.

✨ Finishing Touches 💡 1
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 6, 2026

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 review overview

🔵 Needs a closer look

It refactors the supply-chain trust-downgrade verification path across multiple crates with subtle behavior-equivalence claims, so a human should confirm the trust-check parity before merging.

Review effort: Balanced
Findings: None

What changed in this PR

This PR fixes a memory-retention problem in pnpm v12 (pacquet) lockfile verification. Under trustPolicy/minimumReleaseAge, the verifier projected each packument by walking versions.iter(), which hydrated and cached a full typed manifest of every published version on the resolver's shared packument for the rest of the install. The change adds an uncached walk and a compact trust projection so the shared packument stays lazy, cutting peak RSS by ~0.6–0.7 GB in the reported repro. It fits into the resolver's existing verification layer and preserves accept/reject outcomes and error messages.

Changes:

  • Add PackageVersions::iter_uncached (decode without filling the hydration cache) by extracting a reusable decode helper.
  • Introduce a TrustHistory trait and a compact TrustHistoryProjection (time map plus one evidence rank per version), generalizing fail_if_trust_downgraded over it; the verifier caches the small projection instead of a full Package.
  • Add fetch_full_metadata_projected so verifier fetches project the document instead of hydrating it whole, keeping the damaged-mirror/offline behavior intact.
File Description
pnpm/​crates/​registry/​src/​package_versions.rs Adds iter_uncached/hydrated_or_decode and extracts decode from hydrate.
pnpm/​crates/​registry/​src/​package_versions/​tests.rs Tests that iter_uncached reuses hydrated manifests, caches nothing new, and reports damaged fragments.
pnpm/​crates/​resolving-npm-resolver/​src/​trust_checks.rs Defines TrustHistory, implements it for Package, and makes the trust-check helpers generic over it.
pnpm/​crates/​resolving-npm-resolver/​src/​lookup_context.rs Adds TrustHistoryProjection and changes the trust cache value type.
pnpm/​crates/​resolving-npm-resolver/​src/​lib.rs Re-exports TrustHistory.
pnpm/​crates/​resolving-npm-resolver/​src/​fetch_full_metadata_cached.rs Adds fetch_full_metadata_projected; extracts refetch_damaged_mirror/has_damaged_fragment.
pnpm/​crates/​resolving-npm-resolver/​src/​fetch_full_metadata_cached/​tests.rs Imports the new projected-fetch helper for tests.
pnpm/​crates/​resolving-npm-resolver/​src/​fetch_full_metadata_cached/​tests/​damaged_mirror.rs Tests projected fetch over a damaged mirror (offline error, online refetch+project).
pnpm/​crates/​resolving-npm-resolver/​src/​create_npm_resolution_verifier/​metadata_projection.rs project_trust_meta returns TrustHistoryProjection via iter_uncached; abbreviated projection uses one uncached pass.
pnpm/​crates/​resolving-npm-resolver/​src/​create_npm_resolution_verifier/​metadata_fetch.rs Projection-based trust fetch, full_meta_options helper, trust cache now holds the projection.
pnpm/​crates/​resolving-npm-resolver/​src/​create_npm_resolution_verifier/​trust_check.rs Passes the projection via meta.as_ref().
pnpm/​crates/​resolving-npm-resolver/​src/​create_npm_resolution_verifier/​tests/​metadata_cache.rs New test that policy checks read the shared packument without hydrating it.
pnpm/​crates/​resolving-npm-resolver/​src/​create_npm_resolution_verifier.rs Import updates for the new trait/projection/helpers.
pnpm/​crates/​resolving-npm-resolver/​src/​npm_resolver/​guarded_pick.rs Passes full_meta.as_ref() to the now-generic trust check.
.changeset/​lockfile-verification-memory.md Changeset (pacquet patch) describing the memory reduction.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

codecov-commenter commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.07692% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.36%. Comparing base (e5ff6fe) to head (6325c05).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/registry/src/package_versions.rs 94.73% 2 Missing ⚠️
...npm/crates/registry/src/package_versions/mirror.rs 92.30% 1 Missing ⚠️
.../crates/resolving-npm-resolver/src/trust_checks.rs 98.18% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16668      +/-   ##
==========================================
+ Coverage   92.34%   92.36%   +0.01%     
==========================================
  Files        1590     1591       +1     
  Lines      210054   210200     +146     
==========================================
+ Hits       193978   194148     +170     
+ Misses      16076    16052      -24     

☔ 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

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.13     20.3±2.86ms    18.5 MB/sec    1.00     18.0±1.83ms    20.8 MB/sec
packument/parse                                  1.00     50.1±3.23µs  1323.9 MB/sec    1.02     51.0±3.27µs  1301.9 MB/sec
tarball/download_dependency                      1.33      6.9±1.20ms   628.8 KB/sec    1.00      5.2±0.32ms   838.8 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00   262.0±14.53ms 61.1 KElem/sec    1.11   291.2±32.90ms 55.0 KElem/sec
version_pick/repeated_ranges_file                1.00      5.2±0.27ms  6.0 KElem/sec    1.17      6.1±0.54ms  5.1 KElem/sec
version_pick/repeated_ranges_raw                 1.00      5.4±0.42ms  5.7 KElem/sec    1.16      6.3±0.85ms  4.9 KElem/sec
workspace_resolution/hoist_heavy                 1.01  517.0±147.59ms        ? ?/sec    1.00   513.6±68.23ms        ? ?/sec
workspace_sort/chained_projects                  1.00     22.9±3.73ms        ? ?/sec    1.85    42.3±10.96ms        ? ?/sec

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Same-run regression check

HEAD and main are measured on the same runner. The tolerance is 5% of the main median or 2 ms, whichever is larger. A regression requires both the median slowdown and the gap between the fastest retained HEAD sample and slowest retained main sample to exceed this tolerance, after trimming up to 10% from each tail. Suspected regressions are rerun once with target order reversed and only fail if reproduced. This conservative noise guard is not a statistical confidence interval.

Inconclusive rows do not fail the check. They remain visible for performance review. Bencher retains absolute minimum timings for historical tracking; historical alerts do not gate this PR. Sequential measurements can still be affected by runner drift.

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2705.98 ms 2488.81 ms -8.0% 135.30 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1524.60 ms 1565.74 ms 2.7% 76.23 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 362.61 ms 431.68 ms 19.0% 18.13 ms Inconclusive (overlapping samples)
isolated-fresh-restore-hot-cache-hot-store pnpr 372.32 ms 361.44 ms -2.9% 18.62 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 12.14 ms 11.89 ms -2.0% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 11.42 ms 11.43 ms 0.1% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 19.03 ms 17.32 ms -9.0% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 15.88 ms 19.69 ms 24.0% 2.00 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-cold-store pacquet 2790.69 ms 2813.53 ms 0.8% 139.53 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1669.13 ms 1729.24 ms 3.6% 83.46 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 591.36 ms 801.30 ms 35.5% 29.57 ms Inconclusive (not reproduced)
isolated-fresh-install-hot-cache-hot-store pnpr 495.37 ms 404.59 ms -18.3% 24.77 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1819.09 ms 1958.62 ms 7.7% 90.95 ms Inconclusive (overlapping samples)
isolated-fresh-install-cold-cache-hot-store pnpr 389.48 ms 375.74 ms -3.5% 19.47 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 231.84 ms 227.75 ms -1.8% 11.59 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 103.03 ms 91.21 ms -11.5% 5.15 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 577.94 ms 435.96 ms -24.6% 28.90 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 232.99 ms 273.65 ms 17.5% 11.65 ms Inconclusive (overlapping samples)
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4778.41 ms 4634.85 ms -3.0% 238.92 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3987.24 ms 3644.91 ms -8.6% 199.36 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 213.84 ms 172.47 ms -19.3% 10.69 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 193.90 ms 252.22 ms 30.1% 9.70 ms Inconclusive (overlapping samples)

Integrated-Benchmark Report (Linux)

Commit: 6325c0523a14

Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. Bencher consumes pacquet@HEAD and pnpr@HEAD.

The tables below show mean ± σ. Bencher tracks absolute minimum latency; PR regression checks compare HEAD and main samples from the same runner. Historical timing alerts do not gate PRs.

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.519 ± 0.172 2.338 2.831 1.63 ± 0.18
pacquet@main 2.721 ± 0.159 2.533 3.060 1.76 ± 0.19
pnpr@HEAD 1.559 ± 0.134 1.366 1.789 1.01 ± 0.13
pnpr@main 1.542 ± 0.139 1.406 1.855 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5188930646999994,
      "stddev": 0.17180515419335954,
      "median": 2.4888060877,
      "user": 1.91027062,
      "system": 1.8615344,
      "min": 2.3380089297,
      "max": 2.8310609377
    },
    {
      "command": "pacquet@main",
      "mean": 2.7211388048,
      "stddev": 0.1591555461179689,
      "median": 2.7059768632,
      "user": 2.28105842,
      "system": 2.2784788999999996,
      "min": 2.5326311507,
      "max": 3.0598406477
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.5588510073,
      "stddev": 0.1341475135685852,
      "median": 1.5657392017,
      "user": 2.0128166199999997,
      "system": 1.901435,
      "min": 1.3657313657,
      "max": 1.7886536937000002
    },
    {
      "command": "pnpr@main",
      "mean": 1.5418216035999999,
      "stddev": 0.13862797364339638,
      "median": 1.5246038482,
      "user": 1.96498402,
      "system": 1.8410415999999998,
      "min": 1.4064911747,
      "max": 1.8548601927
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 417.6 ± 57.4 303.8 493.9 1.12 ± 0.20
pacquet@main 436.2 ± 176.7 295.6 858.9 1.17 ± 0.49
pnpr@HEAD 399.6 ± 65.4 319.3 486.9 1.07 ± 0.22
pnpr@main 373.3 ± 44.3 304.0 473.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.41762225238,
      "stddev": 0.05736390773834877,
      "median": 0.43167984868000003,
      "user": 0.50566556,
      "system": 0.8808107,
      "min": 0.30376225118000005,
      "max": 0.49393667318000006
    },
    {
      "command": "pacquet@main",
      "mean": 0.43623576037999995,
      "stddev": 0.17665421604714246,
      "median": 0.36261312018,
      "user": 0.48070406,
      "system": 0.8594306999999999,
      "min": 0.29562042118000004,
      "max": 0.8588517331800001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3995765064800001,
      "stddev": 0.0654060964882194,
      "median": 0.36143585118000005,
      "user": 0.44814466,
      "system": 0.7601066999999999,
      "min": 0.31929133218000005,
      "max": 0.48687677418
    },
    {
      "command": "pnpr@main",
      "mean": 0.37327044578000007,
      "stddev": 0.04431936965883461,
      "median": 0.37232186718000004,
      "user": 0.40124806,
      "system": 0.7310340999999999,
      "min": 0.30400894818,
      "max": 0.47380880618000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 12.6 ± 3.1 8.1 25.2 1.09 ± 0.31
pacquet@main 13.2 ± 3.2 9.0 26.2 1.14 ± 0.33
pnpr@HEAD 12.0 ± 2.6 8.1 23.8 1.04 ± 0.27
pnpr@main 11.6 ± 1.7 8.3 21.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.012593644823636363,
      "stddev": 0.0031132287101450786,
      "median": 0.011894752460000001,
      "user": 0.006862705454545455,
      "system": 0.006998838727272727,
      "min": 0.008094776460000001,
      "max": 0.025189180460000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.013188144242352944,
      "stddev": 0.003231069151722003,
      "median": 0.012139536460000001,
      "user": 0.007750742352941177,
      "system": 0.006690541764705882,
      "min": 0.008955190460000002,
      "max": 0.026180300460000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.01200133414644068,
      "stddev": 0.002594022911164819,
      "median": 0.01142541196,
      "user": 0.006888945338983053,
      "system": 0.006322988135593222,
      "min": 0.008123680460000001,
      "max": 0.023797000460000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.011590669025656563,
      "stddev": 0.001719577202088263,
      "median": 0.01141798846,
      "user": 0.00650611222222222,
      "system": 0.006255214949494946,
      "min": 0.008318826460000001,
      "max": 0.02104370746
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 18.3 ± 4.0 12.7 29.5 1.14 ± 0.31
pacquet@main 19.7 ± 5.0 11.1 38.0 1.22 ± 0.37
pnpr@HEAD 20.2 ± 4.2 12.6 39.3 1.25 ± 0.34
pnpr@main 16.1 ± 2.7 10.2 23.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.018348278650450457,
      "stddev": 0.003953575122483644,
      "median": 0.0173157922,
      "user": 0.010378369909909908,
      "system": 0.009367219639639645,
      "min": 0.0126794532,
      "max": 0.029489531200000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.019723207668749996,
      "stddev": 0.004964750126088063,
      "median": 0.0190340677,
      "user": 0.010645038125000002,
      "system": 0.010337480468750004,
      "min": 0.0110887772,
      "max": 0.0379861702
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.020190398135483862,
      "stddev": 0.00423832712183836,
      "median": 0.0196934827,
      "user": 0.01059513741935484,
      "system": 0.01092876467741936,
      "min": 0.0125897262,
      "max": 0.039281226200000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.01610907351782946,
      "stddev": 0.0026728126563305378,
      "median": 0.015880875200000002,
      "user": 0.009235010387596896,
      "system": 0.008331293178294574,
      "min": 0.0102199272,
      "max": 0.0231578702
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.801 ± 0.076 2.693 2.890 1.68 ± 0.11
pacquet@main 2.796 ± 0.074 2.686 2.912 1.68 ± 0.11
pnpr@HEAD 1.738 ± 0.111 1.550 1.936 1.04 ± 0.09
pnpr@main 1.668 ± 0.102 1.506 1.824 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.80097752342,
      "stddev": 0.0761940703920056,
      "median": 2.81352913002,
      "user": 2.9094416,
      "system": 2.17664964,
      "min": 2.69312742102,
      "max": 2.89029969002
    },
    {
      "command": "pacquet@main",
      "mean": 2.79593366482,
      "stddev": 0.07434729506389468,
      "median": 2.79068771702,
      "user": 2.8310982000000005,
      "system": 2.22139094,
      "min": 2.68574828602,
      "max": 2.91228689402
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.73847790042,
      "stddev": 0.11082057432253924,
      "median": 1.72923849852,
      "user": 1.8319828999999999,
      "system": 1.8262408399999999,
      "min": 1.5496388860199999,
      "max": 1.93565796002
    },
    {
      "command": "pnpr@main",
      "mean": 1.6675796140200003,
      "stddev": 0.10152734725694731,
      "median": 1.66913167702,
      "user": 1.7413646,
      "system": 1.8398859399999996,
      "min": 1.50588525502,
      "max": 1.8240667960199999
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 807.1 ± 81.2 675.3 951.2 1.96 ± 0.31
pacquet@main 613.4 ± 61.3 552.4 708.6 1.49 ± 0.23
pnpr@HEAD 411.8 ± 49.8 346.2 481.7 1.00
pnpr@main 495.4 ± 59.5 412.4 632.9 1.20 ± 0.21

Confirmation (reversed target order)

Command Mean [ms] Min [ms] Max [ms] Relative
pnpr@main 402.1 ± 89.5 328.0 598.3 1.10 ± 0.26
pnpr@HEAD 364.3 ± 23.5 329.0 412.3 1.00
pacquet@main 788.5 ± 67.3 647.0 896.2 2.16 ± 0.23
pacquet@HEAD 693.7 ± 72.7 585.5 789.0 1.90 ± 0.23
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.8071040300400002,
      "stddev": 0.08124843871256243,
      "median": 0.8012960177400001,
      "user": 1.13006816,
      "system": 1.13869564,
      "min": 0.67528339824,
      "max": 0.9511574682400001
    },
    {
      "command": "pacquet@main",
      "mean": 0.61340024544,
      "stddev": 0.06133794576128982,
      "median": 0.59136195024,
      "user": 0.8706117600000001,
      "system": 0.9086596400000001,
      "min": 0.55238032424,
      "max": 0.7085800802400001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.41176609503999995,
      "stddev": 0.04979366035012871,
      "median": 0.40459006824,
      "user": 0.38210575999999996,
      "system": 0.76827864,
      "min": 0.34616840124,
      "max": 0.48174717524
    },
    {
      "command": "pnpr@main",
      "mean": 0.49537975094000003,
      "stddev": 0.05954489680718471,
      "median": 0.49536771974000005,
      "user": 0.47756596,
      "system": 0.83047524,
      "min": 0.41237265824,
      "max": 0.6328601422400001
    }
  ],
  "confirmation": {
    "results": [
      {
        "command": "pnpr@main",
        "mean": 0.40214190984,
        "stddev": 0.0894617928284628,
        "median": 0.35566355524000004,
        "user": 0.3669170600000001,
        "system": 0.72378244,
        "min": 0.32801457624,
        "max": 0.59827426124
      },
      {
        "command": "pnpr@HEAD",
        "mean": 0.36427281314000004,
        "stddev": 0.023508227214947542,
        "median": 0.36044090823999997,
        "user": 0.34462226,
        "system": 0.67195724,
        "min": 0.32903407524,
        "max": 0.41230615824
      },
      {
        "command": "pacquet@main",
        "mean": 0.7885145765399999,
        "stddev": 0.06729979571187583,
        "median": 0.79273240324,
        "user": 1.12920926,
        "system": 1.1669016400000003,
        "min": 0.64702784524,
        "max": 0.8962495662400001
      },
      {
        "command": "pacquet@HEAD",
        "mean": 0.69374306324,
        "stddev": 0.07273307383741796,
        "median": 0.7076435077400001,
        "user": 0.9774798599999999,
        "system": 0.97427014,
        "min": 0.58548398624,
        "max": 0.78901056524
      }
    ]
  }
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.967 ± 0.080 1.852 2.142 5.22 ± 0.36
pacquet@main 1.854 ± 0.080 1.763 2.007 4.92 ± 0.35
pnpr@HEAD 0.377 ± 0.021 0.353 0.428 1.00
pnpr@main 0.392 ± 0.023 0.352 0.434 1.04 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9670405415999999,
      "stddev": 0.07971542130498309,
      "median": 1.9586156567,
      "user": 1.5262251,
      "system": 1.2704460199999998,
      "min": 1.8520063037,
      "max": 2.1418612866999998
    },
    {
      "command": "pacquet@main",
      "mean": 1.8538659497999999,
      "stddev": 0.08004859743532274,
      "median": 1.8190879246999998,
      "user": 1.3902432999999998,
      "system": 1.15281952,
      "min": 1.7626785517,
      "max": 2.0071681687
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3769747564,
      "stddev": 0.020898093805597536,
      "median": 0.37574420270000003,
      "user": 0.36025460000000004,
      "system": 0.7179050199999999,
      "min": 0.3532231397,
      "max": 0.42848367470000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.3919215218,
      "stddev": 0.02296019877142362,
      "median": 0.3894780147,
      "user": 0.39722989999999997,
      "system": 0.7317944200000001,
      "min": 0.35237159170000004,
      "max": 0.43383699970000006
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 229.1 ± 14.0 206.6 251.3 2.50 ± 0.18
pacquet@main 228.2 ± 15.0 195.6 244.0 2.49 ± 0.18
pnpr@HEAD 91.5 ± 3.2 86.1 98.2 1.00
pnpr@main 104.4 ± 8.6 91.4 135.4 1.14 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.22911858976545452,
      "stddev": 0.014020326683550095,
      "median": 0.22774816522,
      "user": 0.1989263618181818,
      "system": 0.09489616181818182,
      "min": 0.20662622222,
      "max": 0.25127762322
    },
    {
      "command": "pacquet@main",
      "mean": 0.2281618414342857,
      "stddev": 0.014953793329574241,
      "median": 0.23184191872,
      "user": 0.1949125371428571,
      "system": 0.08374897999999997,
      "min": 0.19560748822000001,
      "max": 0.24404774022
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09151951075125003,
      "stddev": 0.0031721956282900307,
      "median": 0.09121193172,
      "user": 0.03290708625,
      "system": 0.014723480625000002,
      "min": 0.08611176722000001,
      "max": 0.09820888122
    },
    {
      "command": "pnpr@main",
      "mean": 0.10436855775333335,
      "stddev": 0.008605891634486275,
      "median": 0.10303378222000001,
      "user": 0.044070979999999996,
      "system": 0.017013580000000004,
      "min": 0.09136047922000001,
      "max": 0.13539774522
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 450.3 ± 72.3 374.5 608.9 1.00
pacquet@main 581.7 ± 33.7 520.1 639.5 1.29 ± 0.22
pnpm@HEAD 6598.6 ± 1754.9 5324.0 10294.7 14.65 ± 4.55
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.4503082070444445,
      "stddev": 0.0722707304773409,
      "median": 0.43595571260000004,
      "user": 0.44571990000000006,
      "system": 0.12483126444444442,
      "min": 0.3744953536,
      "max": 0.6088714386
    },
    {
      "command": "pacquet@main",
      "mean": 0.5816816018222223,
      "stddev": 0.03365798384722056,
      "median": 0.5779351906000001,
      "user": 0.5691959,
      "system": 0.13227359777777775,
      "min": 0.5200716476000001,
      "max": 0.6395487736000001
    },
    {
      "command": "pnpm@HEAD",
      "mean": 6.598601813266667,
      "stddev": 1.7549409160973286,
      "median": 5.6681222116,
      "user": 9.426464011111111,
      "system": 0.8057873755555556,
      "min": 5.3240040676,
      "max": 10.2947378396
    }
  ]
}

Scenario: Isolated linker: linked-workspace resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 265.5 ± 39.5 213.7 335.2 1.06 ± 0.24
pacquet@main 251.0 ± 42.1 208.4 332.8 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26545341501384623,
      "stddev": 0.0394944827534366,
      "median": 0.27364763186,
      "user": 0.20467086153846148,
      "system": 0.1088934,
      "min": 0.21372807286,
      "max": 0.33519636886000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.25097573806000006,
      "stddev": 0.04212319100438938,
      "median": 0.23298825536,
      "user": 0.1949045,
      "system": 0.10258339999999999,
      "min": 0.20838908386000002,
      "max": 0.33284805186000005
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.634 ± 0.080 4.544 4.808 1.25 ± 0.06
pacquet@main 4.806 ± 0.151 4.664 5.093 1.29 ± 0.07
pnpr@HEAD 3.716 ± 0.152 3.593 4.060 1.00
pnpr@main 3.947 ± 0.162 3.626 4.178 1.06 ± 0.06
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.634082812640001,
      "stddev": 0.07984820897183101,
      "median": 4.6348472780400005,
      "user": 2.08794436,
      "system": 2.17931182,
      "min": 4.54360306404,
      "max": 4.80833421204
    },
    {
      "command": "pacquet@main",
      "mean": 4.805807835040001,
      "stddev": 0.15146407300995948,
      "median": 4.77840972454,
      "user": 2.3001789599999998,
      "system": 2.34973062,
      "min": 4.66358003604,
      "max": 5.09328901804
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.7159872168400008,
      "stddev": 0.1521981740592245,
      "median": 3.6449060710400003,
      "user": 2.0430538599999997,
      "system": 2.1264388199999997,
      "min": 3.59284573504,
      "max": 4.06032711704
    },
    {
      "command": "pnpr@main",
      "mean": 3.9465434002400004,
      "stddev": 0.16185582809764618,
      "median": 3.98723808254,
      "user": 2.2819275599999997,
      "system": 2.26595362,
      "min": 3.62570772204,
      "max": 4.17830020104
    }
  ]
}

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. Scenarios run on separate machines, so compare main and branch within each table.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 170.2 ± 13.1 148.9 193.2 1.00
pacquet@main 205.8 ± 36.6 160.8 260.4 1.21 ± 0.23
pnpr@HEAD 248.5 ± 22.9 204.2 273.9 1.46 ± 0.18
pnpr@main 191.3 ± 9.8 175.6 202.9 1.12 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1701658969541177,
      "stddev": 0.013089339590912772,
      "median": 0.17246529366000002,
      "user": 0.2053007305882353,
      "system": 0.19932644705882357,
      "min": 0.14893653066,
      "max": 0.19324121166000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.2058319595933334,
      "stddev": 0.036609882700159434,
      "median": 0.21384039766000001,
      "user": 0.24694439333333335,
      "system": 0.23659993333333335,
      "min": 0.16077598366,
      "max": 0.26043547866000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.24852866441000002,
      "stddev": 0.02290737482645549,
      "median": 0.25221679616000003,
      "user": 0.2863885933333333,
      "system": 0.2671369666666667,
      "min": 0.20423113266000004,
      "max": 0.27385129366000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.19131703642923079,
      "stddev": 0.00983614654484408,
      "median": 0.19390348866,
      "user": 0.23579687538461538,
      "system": 0.18230872307692308,
      "min": 0.17556393366000003,
      "max": 0.20290647766000003
    }
  ]
}

@blacksmith-sh

This comment has been minimized.

The verifier's projections walked every version of a packument through
`iter_uncached`, decoding each one into a full `PackageVersion` to read
two fields. The `#[serde(flatten)]` catch-all on `PackageVersion` makes
serde buffer every key of the manifest and copy the unknown ones into
`other`, so the walk paid for the whole manifest.

`PackageVersions::iter_policy_fields` decodes a probe that keeps every
field whose decode can fail, with the same deserializers, and drops the
catch-all. A fragment decodes there exactly where it decodes as a
`PackageVersion`, so the projections keep the same versions and the
policy outcomes are unchanged. A test pins that equivalence over
malformed fragments. The walk still reuses a hydrated manifest and
still leaves unhydrated versions unhydrated, which
`PackageVersions::is_hydrated` lets the shared-packument test assert.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 18:30

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Oct 6, 2026

Copy link
Copy Markdown
Member

I pushed 14f2473 on top of your commit. It replaces iter_uncached with PackageVersions::iter_policy_fields, which decodes a probe holding only dist and _npmUser, plus every other field whose decode can fail, using the same deserializers. A fragment decodes there exactly when it decodes as a PackageVersion, so the projections keep the same versions and the outcomes stay unchanged. policy_fields_decode_exactly_where_a_manifest_does pins that over malformed fragments; it fails if a fallible field is dropped from the probe. Skipping the #[serde(flatten)] catch-all cut the verification pass from 4.5–5.3 s to 2.5 s user CPU on a 1,211-entry lockfile with a warm mirror. The shared-packument test now asserts through a new PackageVersions::is_hydrated.


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

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Policy checks allocate unused peer metadata ✓ Resolved
Description
PolicyFieldsProbe deserializes every peerDependenciesMeta entry into a map that
VersionPolicyFields::from immediately discards. When registry metadata contains large
peer-metadata maps across many versions, every policy projection pays for those temporary
allocations and entry conversions.
Code

pnpm/crates/registry/src/package_version.rs[R151-154]

+        rename = "peerDependenciesMeta",
+        deserialize_with = "crate::wire_tolerance::deserialize_record_map"
+    )]
+    _peer_dependencies_meta: Option<HashMap<String, PeerDependencyMeta>>,
Relevance

●●● Strong

PR intent is reducing policy decode overhead; unused peer metadata allocation is a direct, local
performance fix.

PR-#13512
PR-#14448

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added field invokes a deserializer that builds a JSON value and then a map of converted entries;
the probe-to-policy conversion retains neither. The policy iterator runs this decode for each
unhydrated version.

pnpm/crates/registry/src/package_version.rs[149-169]
pnpm/crates/registry/src/wire_tolerance.rs[83-101]
pnpm/crates/registry/src/package_versions.rs[391-398]

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 policy probe must recognize `peerDependenciesMeta` to reject duplicate declared keys, but it does not need to construct the field's map. Its current deserializer allocates and converts entries that verification immediately discards.

## Fix Focus Areas
- pnpm/crates/registry/src/package_version.rs[149-154]
- pnpm/crates/registry/src/package_versions/tests.rs[137-140]

## Recommended Fix
Keep the declared field so Serde rejects duplicate keys, but deserialize its value with a skipping visitor such as `IgnoredAny`. Verify that this preserves the full manifest's accept/reject result for malformed values and duplicated keys.

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


2. Malformed versions pass lockfile checks ✓ Resolved
Description
PolicyFieldsProbe omits the typed peerDependenciesMeta field, so it ignores duplicate
occurrences that cause PackageVersion decoding to fail. If registry metadata contains those
duplicate keys, iter_policy_fields includes the version in the artifact and trust projections,
allowing a matching frozen lockfile to verify even though the previous full-manifest walk omitted
it.
Code

pnpm/crates/registry/src/package_version.rs[R148-150]

+    #[serde(
+        default,
+        rename = "_npmUser",
Evidence
PackageVersion declares peerDependenciesMeta as a serde field, but the new probe moves directly
from optional dependencies to _npmUser without declaring it. Version fragments retain their raw
JSON, and iter_policy_fields decodes them using that probe; both verifier projections then include
probe-accepted versions. The artifact check rejects a missing version but accepts one whose
projected tarball URL matches the lockfile, so the different decode result changes its verdict.

pnpm/crates/registry/src/package_version.rs[40-54]
pnpm/crates/registry/src/package_version.rs[130-157]
pnpm/crates/registry/src/package_versions.rs[178-190]
pnpm/crates/registry/src/package_versions.rs[391-397]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_projection.rs[13-25]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_projection.rs[68-80]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/registry_artifact.rs[23-37]

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 policy-field probe ignores duplicate `peerDependenciesMeta` keys, although full manifest decoding rejects them. This lets lockfile verification accept a malformed registry version that the previous projection omitted.

## Fix Focus Areas
- pnpm/crates/registry/src/package_version.rs[130-157]
- pnpm/crates/registry/src/package_versions/tests.rs[116-151]

## Recommended Fix
Declare `peerDependenciesMeta` in the probe so serde detects duplicate keys. Skip its value without constructing the dependency map if possible, while preserving the full decoder's tolerant handling of a single value. Add a parity test with duplicate `peerDependenciesMeta` keys.

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



Informational

3. Release-age fallback still decodes every manifest ✓ Resolved
Description
VerificationMetadataClient::fetch_full_meta still goes through fetch_full_metadata_cached. Its
has_damaged_fragment check walks versions.iter(), which builds a full PackageVersion
(including the flatten catch-all) for every published version, yet fetch_full_meta_time only keeps
the time map. When minimumReleaseAge reaches its last-resort full fetch (abbreviated,
local-mirror and attestation lookups all missed), each concurrently checked package briefly holds
its whole decoded history in memory. That raises peak RSS on the path this PR says now projects
instead of hydrating the whole document.
Code

pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[R239-241]

+        fetch_full_metadata_cached(&name.to_string(), &self.full_meta_options(registry))
+            .await
+            .map_err(|error| render_fetch_metadata_error(&error))
Evidence
fetch_full_meta_time (metadata_fetch.rs 153-176) calls self.metadata.fetch_full_meta, which the
PR left on fetch_full_metadata_cached. That function runs has_damaged_fragment →
meta.versions.iter().for_each(drop) and so hydrates every slot. The new
fetch_full_metadata_projected only checks for corruption through the projection's
iter_policy_fields walk. age_check.rs 209 uses this path as its final fallback.

pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[153-176]
pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[85-114]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/age_check.rs[187-211]

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

## Issue description
`fetch_full_meta_time` keeps only the packument `time` map. It still fetches through `fetch_full_metadata_cached`, though, and that hydrates every version's full manifest just to check for a damaged mirror fragment. Every package that reaches this fallback pays that cost in peak memory.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[153-176]
- pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[234-242]

## Recommended Fix
Switch `fetch_full_meta_time` to `self.metadata.fetch_full_meta_projected(registry, name, |meta| { meta.versions.iter_policy_fields().for_each(drop); /* build PublishedAtTimeMap from meta.time */ })`. The walk is still needed so a damaged fragment is detected and refetched, but it no longer builds full manifests. Remove `fetch_full_meta` once it has no callers left.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 66 rules
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/update (sha: 2457663d) — View relationship
Review mode: Auto: ⚖️ Balanced: Localized supply-chain verification deserialization change carries security and correctness risk.

Grey Divider

Tip of the day
💡 Did you know, you can add REVIEW.md to your repo root and Qodo follows it on every PR

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 6325c05

Results up to commit 14f2473 🧠 Deep


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


Remediation recommended
1. Malformed versions pass lockfile checks ✓ Resolved
Description
PolicyFieldsProbe omits the typed peerDependenciesMeta field, so it ignores duplicate
occurrences that cause PackageVersion decoding to fail. If registry metadata contains those
duplicate keys, iter_policy_fields includes the version in the artifact and trust projections,
allowing a matching frozen lockfile to verify even though the previous full-manifest walk omitted
it.
Code

pnpm/crates/registry/src/package_version.rs[R148-150]

+    #[serde(
+        default,
+        rename = "_npmUser",
Evidence
PackageVersion declares peerDependenciesMeta as a serde field, but the new probe moves directly
from optional dependencies to _npmUser without declaring it. Version fragments retain their raw
JSON, and iter_policy_fields decodes them using that probe; both verifier projections then include
probe-accepted versions. The artifact check rejects a missing version but accepts one whose
projected tarball URL matches the lockfile, so the different decode result changes its verdict.

pnpm/crates/registry/src/package_version.rs[40-54]
pnpm/crates/registry/src/package_version.rs[130-157]
pnpm/crates/registry/src/package_versions.rs[178-190]
pnpm/crates/registry/src/package_versions.rs[391-397]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_projection.rs[13-25]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_projection.rs[68-80]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/registry_artifact.rs[23-37]

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 policy-field probe ignores duplicate `peerDependenciesMeta` keys, although full manifest decoding rejects them. This lets lockfile verification accept a malformed registry version that the previous projection omitted.

## Fix Focus Areas
- pnpm/crates/registry/src/package_version.rs[130-157]
- pnpm/crates/registry/src/package_versions/tests.rs[116-151]

## Recommended Fix
Declare `peerDependenciesMeta` in the probe so serde detects duplicate keys. Skip its value without constructing the dependency map if possible, while preserving the full decoder's tolerant handling of a single value. Add a parity test with duplicate `peerDependenciesMeta` keys.

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



Informational
2. Release-age fallback still decodes every manifest ✓ Resolved
Description
VerificationMetadataClient::fetch_full_meta still goes through fetch_full_metadata_cached. Its
has_damaged_fragment check walks versions.iter(), which builds a full PackageVersion
(including the flatten catch-all) for every published version, yet fetch_full_meta_time only keeps
the time map. When minimumReleaseAge reaches its last-resort full fetch (abbreviated,
local-mirror and attestation lookups all missed), each concurrently checked package briefly holds
its whole decoded history in memory. That raises peak RSS on the path this PR says now projects
instead of hydrating the whole document.
Code

pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[R239-241]

+        fetch_full_metadata_cached(&name.to_string(), &self.full_meta_options(registry))
+            .await
+            .map_err(|error| render_fetch_metadata_error(&error))
Evidence
fetch_full_meta_time (metadata_fetch.rs 153-176) calls self.metadata.fetch_full_meta, which the
PR left on fetch_full_metadata_cached. That function runs has_damaged_fragment →
meta.versions.iter().for_each(drop) and so hydrates every slot. The new
fetch_full_metadata_projected only checks for corruption through the projection's
iter_policy_fields walk. age_check.rs 209 uses this path as its final fallback.

pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[153-176]
pnpm/crates/resolving-npm-resolver/src/fetch_full_metadata_cached.rs[85-114]
pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/age_check.rs[187-211]

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

## Issue description
`fetch_full_meta_time` keeps only the packument `time` map. It still fetches through `fetch_full_metadata_cached`, though, and that hydrates every version's full manifest just to check for a damaged mirror fragment. Every package that reaches this fallback pays that cost in peak memory.

## Fix Focus Areas
- pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[153-176]
- pnpm/crates/resolving-npm-resolver/src/create_npm_resolution_verifier/metadata_fetch.rs[234-242]

## Recommended Fix
Switch `fetch_full_meta_time` to `self.metadata.fetch_full_meta_projected(registry, name, |meta| { meta.versions.iter_policy_fields().for_each(drop); /* build PublishedAtTimeMap from meta.time */ })`. The walk is still needed so a damaged fragment is detected and refetched, but it no longer builds full manifests. Remove `fetch_full_meta` once it has no callers left.

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


Results up to commit 0278d16 ⚖️ Balanced


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


Remediation recommended
1. Policy checks allocate unused peer metadata ✓ Resolved
Description
PolicyFieldsProbe deserializes every peerDependenciesMeta entry into a map that
VersionPolicyFields::from immediately discards. When registry metadata contains large
peer-metadata maps across many versions, every policy projection pays for those temporary
allocations and entry conversions.
Code

pnpm/crates/registry/src/package_version.rs[R151-154]

+        rename = "peerDependenciesMeta",
+        deserialize_with = "crate::wire_tolerance::deserialize_record_map"
+    )]
+    _peer_dependencies_meta: Option<HashMap<String, PeerDependencyMeta>>,
Relevance

●●● Strong

PR intent is reducing policy decode overhead; unused peer metadata allocation is a direct, local
performance fix.

PR-#13512
PR-#14448

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The added field invokes a deserializer that builds a JSON value and then a map of converted entries;
the probe-to-policy conversion retains neither. The policy iterator runs this decode for each
unhydrated version.

pnpm/crates/registry/src/package_version.rs[149-169]
pnpm/crates/registry/src/wire_tolerance.rs[83-101]
pnpm/crates/registry/src/package_versions.rs[391-398]

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 policy probe must recognize `peerDependenciesMeta` to reject duplicate declared keys, but it does not need to construct the field's map. Its current deserializer allocates and converts entries that verification immediately discards.

## Fix Focus Areas
- pnpm/crates/registry/src/package_version.rs[149-154]
- pnpm/crates/registry/src/package_versions/tests.rs[137-140]

## Recommended Fix
Keep the declared field so Serde rejects duplicate keys, but deserialize its value with a skipping visitor such as `IgnoredAny`. Verify that this preserves the full manifest's accept/reject result for malformed values and duplicated keys.

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


Grey Divider

Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

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 review overview

🔵 Needs a closer look

It reworks security-relevant trust/release-age verification and relies on a subtle serde decode-equivalence invariant between the projection and full manifest, which warrants final human review despite no concrete defect being found.

Review effort: Balanced
Findings: None

…age fallback

The policy-field probe left out `peerDependenciesMeta`. Its decoder
never fails, but serde rejects a duplicated key of any declared field,
so a fragment that repeats `peerDependenciesMeta` failed as a
`PackageVersion` and passed the probe. The probe now declares every
field `PackageVersion` declares.

`fetch_full_metadata_cached`, which the minimumReleaseAge fallback uses
for the `time` map, checked for damaged mirror fragments by hydrating
every version. `PackageVersions::check_mirror_fragments` validates each
fragment as JSON without keeping it, which flags the same fragments the
hydrating walk did.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 19:00

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@zkochan

zkochan commented Oct 6, 2026

Copy link
Copy Markdown
Member

Both Qodo findings were real and are fixed in 0278d16:

  1. Duplicate peerDependenciesMeta: serde rejects a duplicated key of any declared field, so the probe now declares every field PackageVersion declares. policy_fields_decode_exactly_where_a_manifest_does gained duplicate-key cases for peerDependenciesMeta, _npmUser, deprecated and an undeclared key. It fails when peerDependenciesMeta is removed from the probe.
  2. Age fallback hydrating every version: fetch_full_metadata_cached now checks the mirror with PackageVersions::check_mirror_fragments, which validates each fragment as JSON without keeping it. It flags the same fragments the hydrating walk did.

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 0278d16

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

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 review overview

🔵 Needs a closer look

It refactors security-relevant trust-downgrade/release-age verification and hinges on a serde decode-parity invariant (PolicyFieldsProbe failing exactly where PackageVersion does) that cannot be fully verified by static reading and warrants human review.

Review effort: Balanced
Findings: None

The probe declares `peerDependenciesMeta` only so a duplicated key fails
as it does on `PackageVersion`. Its decoder there never fails, so the
probe skips the value as `IgnoredAny` instead of building a map it drops.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 19:23
@zkochan

zkochan commented Oct 6, 2026

Copy link
Copy Markdown
Member

Qodo's new finding (peer metadata allocated and dropped) is fixed in 6325c05. The probe now skips peerDependenciesMeta as IgnoredAny. The duplicate-key case in policy_fields_decode_exactly_where_a_manifest_does still passes, so a repeated key is still rejected.


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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

@qodo-code-review

Copy link
Copy Markdown

Qodo's new finding (peer metadata allocated and dropped) is fixed in 6325c05. The probe now skips peerDependenciesMeta as IgnoredAny. The duplicate-key case in policy_fields_decode_exactly_where_a_manifest_does still passes, so a repeated key is still rejected.


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

That addresses finding 1: using IgnoredAny avoids allocating and converting peerDependenciesMeta entries, while retaining duplicate-key rejection as confirmed by the parity test. The finding remains open until you explicitly ask me to dismiss it.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6325c05

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

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 review overview

🔵 Needs a closer look

It is a broad refactor of security-adjacent trust/release-age verification whose correctness hinges on a subtle serde decode-equivalence and ordering invariant, so it warrants final human review despite strong test coverage.

Review effort: Balanced
Findings: None

@blacksmith-sh

blacksmith-sh Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
"Rust threaded runtime and host services" exited with 1/
"Rust threaded runtime and host services" exited with 1
View Logs

Fix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

@zkochan
zkochan merged commit 629bd20 into main Oct 6, 2026
58 of 59 checks passed
@zkochan
zkochan deleted the altaywtf/fix-16656-verify-lockfile-memory branch October 6, 2026 23:21
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 supply-chain verification peaks at ~2.3 GB RSS for 1,400 entries on pnpm 11 and 12, OOM-killing Mend-hosted Renovate

4 participants