Skip to content

fix: support semver build metadata in workspace dependency resolution (pnpm/pnpm#6483) - #15340

Merged
zkochan merged 3 commits into
mainfrom
fix-6483
Sep 23, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-6483

Conversation

@zkochan

@zkochan zkochan commented Sep 23, 2026 •

Copy link
Copy Markdown
Member

Summary

When a workspace package version carries SemVer build metadata (e.g. 0.5.6-next.3+f60facc), exact version specifiers (such as workspace:0.5.6-next.3+f60facc or workspace:0.5.6-next.3) failed with ERR_PNPM_NO_MATCHING_VERSION_INSIDE_WORKSPACE.

This occurred because version-selector-type (in TypeScript) and Version parsing (in Rust) normalize exact version specifiers by stripping build metadata into fetchSpec. When checking the workspace packages map, direct string key lookups failed because the version stored in the workspace map retains its original build metadata from package.json.

According to SemVer spec item 10, build metadata MUST be ignored when determining version precedence. This PR updates pickMatchingLocalVersionOrNull in both pnpm v11 (TypeScript) and v12 (Rust) to fall back to SemVer range resolution when exact key lookup fails. In addition, @pnpm/installing.deps-resolver reuses the exported pickMatchingLocalVersionOrNull helper.

Closes #6483

Squash Commit Body

When a workspace package version carries SemVer build metadata,
exact version specifiers (e.g. `workspace:0.5.6-next.3+f60facc` or
`workspace:0.5.6-next.3`) failed to resolve because version-selector-type
and Version normalization strip build metadata before matching keys in
the workspace packages map.

Fall back to SemVer range resolution for Version specifiers in both
pnpm v11 (TypeScript) and v12 (Rust) to honor SemVer precedence
rules (spec item 10) where build metadata is ignored.

Closes pnpm/pnpm#6483

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.

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

  • Bug Fixes
    • Workspace dependencies now resolve correctly when package versions include SemVer build metadata, including exact, range, and wildcard workspace specifiers.
    • When an exact workspace version is unavailable, resolution can fall back to a compatible version that satisfies the requested range.
    • Available workspace versions are listed in a consistent order in resolution errors, including versions with equal SemVer precedence, making it easier to compare the options shown.

…#6483)

When a workspace package version carries SemVer build metadata,
exact version specifiers (e.g. `workspace:0.5.6-next.3+f60facc` or
`workspace:0.5.6-next.3`) failed to resolve because version-selector-type
and Version normalization strip build metadata before matching keys in
the workspace packages map.

Fall back to SemVer range resolution for Version specifiers in both
pnpm v11 (TypeScript) and v12 (Rust) to honor SemVer precedence
rules (spec item 10) where build metadata is ignored.

Closes #6483
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 02367ff9-a08d-4a92-b586-c8900d26d2fe

📥 Commits

Reviewing files that changed from the base of the PR and between e4c6b73 and 2ba3460.

📒 Files selected for processing (5)
  • pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace/tests.rs
  • pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts
  • pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts
  • pnpm11/resolving/npm-resolver/src/index.ts
  • pnpm11/resolving/npm-resolver/test/index.ts

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


📝 Walkthrough

Walkthrough

Workspace dependency resolution now matches packages whose versions include SemVer build metadata. The Rust and TypeScript resolvers apply workspace matching, and installer tests cover linking these packages. Changesets declare patch releases.

Changes

Workspace dependency resolution

Layer / File(s) Summary
Workspace version matching
pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs, pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace/tests.rs, pnpm11/resolving/npm-resolver/src/index.ts, pnpm11/resolving/npm-resolver/test/index.ts
Both resolvers match workspace packages for exact, caret, tilde, and wildcard specs with and without build metadata. They also sort available versions deterministically when SemVer precedence is equal.
Installer integration and release metadata
pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts, pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts, pnpm11/installing/deps-installer/test/install/multipleImporters.ts, pnpm/crates/cli/tests/suite/workspace_install.rs, .changeset/*workspace-dependency-build-metadata.md
The dependency availability check uses the shared resolver helper. Installer tests cover workspace linking with build metadata. Changesets declare patch releases.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Low

Sequence Diagram(s)

sequenceDiagram
  participant Installer
  participant WantedDepIsLocallyAvailable
  participant NpmResolver
  participant WorkspacePackages
  Installer->>WantedDepIsLocallyAvailable: Check local dependency availability
  WantedDepIsLocallyAvailable->>NpmResolver: Match non-tag spec against workspace versions
  NpmResolver->>WorkspacePackages: Read versions for the package
  WorkspacePackages-->>NpmResolver: Return available versions
  NpmResolver-->>WantedDepIsLocallyAvailable: Return matching local version
  WantedDepIsLocallyAvailable-->>Installer: Return availability result
Loading

Assessment against linked issues

Objective Addressed Explanation
Support workspace dependency resolution for versions with SemVer build metadata [#6483] ✅

Out-of-scope changes

Code Change Explanation
Sort available workspace versions in no-match error messages using a string-order tiebreaker (pnpm11/resolving/npm-resolver/src/index.ts:1123) This changes error-message ordering. The linked issue concerns resolving workspace dependencies with build metadata.

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

Merge Risk: ⚪ Minimal · up to 2ba34

Workspace dependencies with SemVer build metadata can now resolve locally. No material merge blocker was identified.

✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

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

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

pnpm11/resolving/npm-resolver/src/index.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).

  • 1 others

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 commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.21     16.2±1.78ms    23.2 MB/sec    1.00     13.4±0.43ms    28.0 MB/sec
packument/parse                                  1.08     46.0±1.74µs  1441.2 MB/sec    1.00     42.7±0.71µs  1554.2 MB/sec
tarball/download_dependency                      1.01      5.8±0.94ms   744.8 KB/sec    1.00      5.8±1.00ms   749.0 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    276.6±5.74ms 57.8 KElem/sec    1.02    281.3±7.92ms 56.9 KElem/sec
workspace_resolution/hoist_heavy                 1.24    339.9±8.88ms        ? ?/sec    1.00    273.6±1.84ms        ? ?/sec
workspace_sort/chained_projects                  1.00     21.4±3.16ms        ? ?/sec    1.11     23.9±6.01ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Sep 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.55%. Comparing base (0f2ba4b) to head (2ba3460).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15340      +/-   ##
==========================================
- Coverage   91.56%   91.55%   -0.01%     
==========================================
  Files        1388     1390       +2     
  Lines      186810   187448     +638     
==========================================
+ Hits       171045   171625     +580     
- Misses      15765    15823      +58     

☔ 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 Sep 23, 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 2375.25 ms 2430.04 ms 2.3% 118.76 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1418.08 ms 1435.17 ms 1.2% 70.90 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 251.60 ms 255.33 ms 1.5% 12.58 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 323.46 ms 300.40 ms -7.1% 16.17 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 7.31 ms 6.68 ms -8.7% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 6.69 ms 8.22 ms 22.9% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 7.80 ms 9.06 ms 16.1% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 8.53 ms 8.51 ms -0.3% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2687.59 ms 2606.75 ms -3.0% 134.38 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1565.58 ms 1526.77 ms -2.5% 78.28 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pacquet 566.59 ms 505.72 ms -10.7% 28.33 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 309.69 ms 297.48 ms -3.9% 15.48 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1584.97 ms 1601.05 ms 1.0% 79.25 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 266.75 ms 270.02 ms 1.2% 13.34 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 225.25 ms 223.78 ms -0.7% 11.26 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pnpr 93.25 ms 93.22 ms -0.0% 4.66 ms Within tolerance
isolated-peer-heavy-resolve-hot-cache-offline pacquet 983.91 ms 921.31 ms -6.4% 49.20 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 186.95 ms 191.79 ms 2.6% 9.35 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4454.86 ms 4475.78 ms 0.5% 222.74 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3462.99 ms 3424.76 ms -1.1% 173.15 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 150.19 ms 199.40 ms 32.8% 7.51 ms Inconclusive (overlapping samples)
gvs-fresh-restore-hot-cache-hot-store pnpr 139.56 ms 145.86 ms 4.5% 6.98 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 2ba346037998

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.470 ± 0.146 2.312 2.721 1.71 ± 0.16
pacquet@main 2.396 ± 0.130 2.262 2.605 1.66 ± 0.15
pnpr@HEAD 1.480 ± 0.120 1.342 1.665 1.03 ± 0.11
pnpr@main 1.440 ± 0.099 1.339 1.654 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4697112620400006,
      "stddev": 0.14627318698367622,
      "median": 2.43003558274,
      "user": 1.36830122,
      "system": 1.5228391000000001,
      "min": 2.31171292474,
      "max": 2.7213371627400003
    },
    {
      "command": "pacquet@main",
      "mean": 2.3961075001400003,
      "stddev": 0.12954206363557758,
      "median": 2.37524707724,
      "user": 1.3997533199999999,
      "system": 1.5359551,
      "min": 2.26156342874,
      "max": 2.60534662374
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.4802299522400002,
      "stddev": 0.1204881531591283,
      "median": 1.43516948674,
      "user": 1.30548152,
      "system": 1.4205046,
      "min": 1.34178877874,
      "max": 1.66500401274
    },
    {
      "command": "pnpr@main",
      "mean": 1.4404572575399999,
      "stddev": 0.09912498437114792,
      "median": 1.41807580124,
      "user": 1.32853072,
      "system": 1.4117957,
      "min": 1.3387986707400001,
      "max": 1.65405678074
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 265.2 ± 23.5 240.7 298.4 1.00
pacquet@main 271.2 ± 53.2 221.0 399.9 1.02 ± 0.22
pnpr@HEAD 294.8 ± 17.9 265.3 312.6 1.11 ± 0.12
pnpr@main 330.7 ± 29.1 293.3 385.4 1.25 ± 0.16
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26516083762,
      "stddev": 0.023476921749892667,
      "median": 0.25533496072,
      "user": 0.30266454000000004,
      "system": 0.6097913399999999,
      "min": 0.24068598372000002,
      "max": 0.29843837872
    },
    {
      "command": "pacquet@main",
      "mean": 0.27117540402000007,
      "stddev": 0.05322594546632942,
      "median": 0.25160321872,
      "user": 0.30688604,
      "system": 0.63218184,
      "min": 0.22099488272000004,
      "max": 0.39993535772
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29482222502,
      "stddev": 0.017938309755430107,
      "median": 0.30039572721999996,
      "user": 0.31155224000000004,
      "system": 0.62749024,
      "min": 0.26526005772,
      "max": 0.31261571172
    },
    {
      "command": "pnpr@main",
      "mean": 0.33069236782,
      "stddev": 0.02908570559110972,
      "median": 0.32345599822000004,
      "user": 0.34762674000000005,
      "system": 0.7006436399999999,
      "min": 0.29326560272,
      "max": 0.38543763372
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 6.9 ± 0.7 5.8 10.5 1.02 ± 0.14
pacquet@main 7.7 ± 1.2 6.0 13.2 1.12 ± 0.20
pnpr@HEAD 8.4 ± 1.3 6.2 12.3 1.24 ± 0.22
pnpr@main 6.8 ± 0.6 6.0 10.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.006944996419761899,
      "stddev": 0.0007137393936552559,
      "median": 0.006678221640000001,
      "user": 0.004396456666666663,
      "system": 0.0029508830952380957,
      "min": 0.005804756140000001,
      "max": 0.01047218014
    },
    {
      "command": "pacquet@main",
      "mean": 0.007677693283283578,
      "stddev": 0.0012322638099557775,
      "median": 0.00731372514,
      "user": 0.004657565373134329,
      "system": 0.0035127601194029846,
      "min": 0.0060159281400000006,
      "max": 0.01318108114
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.008445788144115226,
      "stddev": 0.0013169896538081363,
      "median": 0.00822141814,
      "user": 0.004593788971193418,
      "system": 0.004311207407407407,
      "min": 0.006216240140000001,
      "max": 0.012313641140000001
    },
    {
      "command": "pnpr@main",
      "mean": 0.006832776000215055,
      "stddev": 0.0005871985986980109,
      "median": 0.006689977640000001,
      "user": 0.004169593763440862,
      "system": 0.0030765353763440853,
      "min": 0.005953876140000001,
      "max": 0.010104976140000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 9.2 ± 1.8 6.4 14.1 1.13 ± 0.28
pacquet@main 8.1 ± 1.2 6.2 14.0 1.00
pnpr@HEAD 8.7 ± 0.9 6.9 13.6 1.06 ± 0.20
pnpr@main 8.6 ± 1.1 6.6 12.2 1.06 ± 0.21
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.009229782383846155,
      "stddev": 0.0017520479075288334,
      "median": 0.009058482980000001,
      "user": 0.005652040961538461,
      "system": 0.004202902980769233,
      "min": 0.006435818980000001,
      "max": 0.01405971198
    },
    {
      "command": "pacquet@main",
      "mean": 0.008149974853015874,
      "stddev": 0.0012424002208466403,
      "median": 0.0078031459800000005,
      "user": 0.005013395555555557,
      "system": 0.003664998285714286,
      "min": 0.00619311998,
      "max": 0.01396568198
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.00867738212122138,
      "stddev": 0.0009198613426756746,
      "median": 0.00850706398,
      "user": 0.00494064992366412,
      "system": 0.004345976412213742,
      "min": 0.006903267980000001,
      "max": 0.01357110198
    },
    {
      "command": "pnpr@main",
      "mean": 0.008647363030387595,
      "stddev": 0.0010767814833847187,
      "median": 0.00853374948,
      "user": 0.004908771627906977,
      "system": 0.004325744186046514,
      "min": 0.00656922798,
      "max": 0.012161205980000001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.638 ± 0.097 2.524 2.794 1.67 ± 0.11
pacquet@main 2.679 ± 0.049 2.608 2.739 1.70 ± 0.10
pnpr@HEAD 1.581 ± 0.151 1.427 1.833 1.00 ± 0.11
pnpr@main 1.578 ± 0.090 1.454 1.709 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.63761193688,
      "stddev": 0.09713662793871412,
      "median": 2.6067503518799997,
      "user": 2.2483080399999995,
      "system": 1.91908856,
      "min": 2.5243846843799997,
      "max": 2.79420468438
    },
    {
      "command": "pacquet@main",
      "mean": 2.67918384448,
      "stddev": 0.0487882401198489,
      "median": 2.6875892728799995,
      "user": 2.32582764,
      "system": 1.9357136599999998,
      "min": 2.60815480538,
      "max": 2.7386365953799996
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.58084671398,
      "stddev": 0.15072938657201057,
      "median": 1.52677482288,
      "user": 1.4525958399999999,
      "system": 1.6206998599999998,
      "min": 1.4266916813800001,
      "max": 1.83302155538
    },
    {
      "command": "pnpr@main",
      "mean": 1.57794757268,
      "stddev": 0.0900538708696577,
      "median": 1.56557824788,
      "user": 1.5352737399999998,
      "system": 1.72963616,
      "min": 1.4539722433800002,
      "max": 1.70854428338
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 508.3 ± 38.2 467.6 582.4 1.71 ± 0.18
pacquet@main 569.0 ± 73.7 468.7 710.8 1.91 ± 0.29
pnpr@HEAD 297.2 ± 22.2 267.7 346.8 1.00
pnpr@main 308.5 ± 23.9 265.8 346.5 1.04 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5082554912000001,
      "stddev": 0.03821447774374093,
      "median": 0.50571747,
      "user": 0.7331801600000001,
      "system": 0.8927503399999999,
      "min": 0.46762280100000003,
      "max": 0.582382046
    },
    {
      "command": "pacquet@main",
      "mean": 0.569022351,
      "stddev": 0.07368146869948135,
      "median": 0.5665933065,
      "user": 0.8361345599999999,
      "system": 0.9773157399999999,
      "min": 0.4687307680000001,
      "max": 0.710803731
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.2972497886,
      "stddev": 0.022156718778874047,
      "median": 0.29747674700000004,
      "user": 0.22303156,
      "system": 0.53273734,
      "min": 0.267685989,
      "max": 0.34684382900000005
    },
    {
      "command": "pnpr@main",
      "mean": 0.3084886132000001,
      "stddev": 0.023936638077180362,
      "median": 0.3096859005,
      "user": 0.2690925599999999,
      "system": 0.5491124399999999,
      "min": 0.26580514400000005,
      "max": 0.346523261
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.620 ± 0.060 1.570 1.741 6.06 ± 0.24
pacquet@main 1.595 ± 0.032 1.574 1.683 5.97 ± 0.15
pnpr@HEAD 0.290 ± 0.039 0.251 0.357 1.08 ± 0.15
pnpr@main 0.267 ± 0.004 0.263 0.275 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.6201588712799997,
      "stddev": 0.060498514022725075,
      "median": 1.6010489236799998,
      "user": 0.8287259599999999,
      "system": 0.9289205199999999,
      "min": 1.56978348368,
      "max": 1.74103928168
    },
    {
      "command": "pacquet@main",
      "mean": 1.5954918951800001,
      "stddev": 0.03247169285165982,
      "median": 1.58497461918,
      "user": 0.7810643599999998,
      "system": 0.8522460199999999,
      "min": 1.57382124468,
      "max": 1.6827339956799998
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.28959059838000006,
      "stddev": 0.03857896610586124,
      "median": 0.27001564768,
      "user": 0.23857526,
      "system": 0.5392542199999999,
      "min": 0.25142894968,
      "max": 0.35679320968
    },
    {
      "command": "pnpr@main",
      "mean": 0.26737621978000004,
      "stddev": 0.0037079189097757943,
      "median": 0.26675145118,
      "user": 0.21272686,
      "system": 0.51663112,
      "min": 0.26260536168000004,
      "max": 0.27502266968
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 231.5 ± 30.1 187.9 297.9 2.47 ± 0.33
pacquet@main 224.6 ± 13.9 205.1 251.6 2.40 ± 0.16
pnpr@HEAD 94.0 ± 3.1 89.6 99.8 1.00 ± 0.04
pnpr@main 93.6 ± 2.3 89.2 97.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.23147625272,
      "stddev": 0.030067725600462305,
      "median": 0.22378282622,
      "user": 0.24820475999999997,
      "system": 0.06835838,
      "min": 0.18792159822,
      "max": 0.29786463322
    },
    {
      "command": "pacquet@main",
      "mean": 0.2246457924507692,
      "stddev": 0.013886344263039984,
      "median": 0.22525396022,
      "user": 0.24111976000000002,
      "system": 0.07417958769230769,
      "min": 0.20509527622,
      "max": 0.25158577922
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0939779841533333,
      "stddev": 0.0031119798457997206,
      "median": 0.09322439772,
      "user": 0.03399202666666667,
      "system": 0.016446394666666666,
      "min": 0.08962625122,
      "max": 0.09975639922
    },
    {
      "command": "pnpr@main",
      "mean": 0.09355551428666664,
      "stddev": 0.0023468068622683872,
      "median": 0.09324733322,
      "user": 0.036746393333333335,
      "system": 0.012940937333333331,
      "min": 0.08924464522,
      "max": 0.09767421822
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 955.9 ± 181.4 622.7 1200.6 1.00
pacquet@main 999.3 ± 97.4 834.8 1142.0 1.05 ± 0.22
pnpm@HEAD 3724.6 ± 421.8 3110.0 4239.6 3.90 ± 0.86
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.9559392187688888,
      "stddev": 0.18137555153616994,
      "median": 0.92131145788,
      "user": 1.0067972311111109,
      "system": 0.23221080222222223,
      "min": 0.62272871588,
      "max": 1.20063100088
    },
    {
      "command": "pacquet@main",
      "mean": 0.9993395402133335,
      "stddev": 0.09742299544344879,
      "median": 0.9839082368800001,
      "user": 1.0610167866666664,
      "system": 0.21637613555555552,
      "min": 0.83480834288,
      "max": 1.1420449488800002
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.7245784863244444,
      "stddev": 0.42177254615302257,
      "median": 3.64341101588,
      "user": 5.952338008888888,
      "system": 0.2601849133333334,
      "min": 3.11000001188,
      "max": 4.2395899548800005
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 191.8 ± 10.8 180.5 225.4 1.02 ± 0.07
pacquet@main 188.0 ± 6.5 178.9 202.7 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.1918326463066667,
      "stddev": 0.010784096763731137,
      "median": 0.19179384524,
      "user": 0.14578876666666662,
      "system": 0.09058312666666665,
      "min": 0.18053581924,
      "max": 0.22535237624
    },
    {
      "command": "pacquet@main",
      "mean": 0.188002841115,
      "stddev": 0.006503562536043529,
      "median": 0.18695447924,
      "user": 0.13831859999999999,
      "system": 0.08874614750000001,
      "min": 0.17893310224,
      "max": 0.20269833724
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.530 ± 0.164 4.369 4.774 1.31 ± 0.06
pacquet@main 4.499 ± 0.146 4.336 4.822 1.30 ± 0.05
pnpr@HEAD 3.464 ± 0.087 3.390 3.644 1.00
pnpr@main 3.822 ± 1.052 3.403 6.804 1.10 ± 0.30
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.5304649361000005,
      "stddev": 0.16414296038371348,
      "median": 4.4757845505,
      "user": 1.5233108599999998,
      "system": 1.7837313,
      "min": 4.368641037000001,
      "max": 4.773780394
    },
    {
      "command": "pacquet@main",
      "mean": 4.4990571949,
      "stddev": 0.14598358277482604,
      "median": 4.4548568635,
      "user": 1.52508256,
      "system": 1.7558762999999995,
      "min": 4.335837712,
      "max": 4.8222061940000005
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.4641378614000002,
      "stddev": 0.0874758842144931,
      "median": 3.4247605855,
      "user": 1.4836825599999997,
      "system": 1.5560076,
      "min": 3.39007047,
      "max": 3.644430355
    },
    {
      "command": "pnpr@main",
      "mean": 3.8219076058999994,
      "stddev": 1.051987631686741,
      "median": 3.4629939404999996,
      "user": 1.4257433599999998,
      "system": 1.5461332999999997,
      "min": 3.402919929,
      "max": 6.803955569
    }
  ]
}

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 201.5 ± 30.8 125.0 249.6 1.42 ± 0.23
pacquet@main 164.3 ± 32.9 131.4 253.5 1.16 ± 0.24
pnpr@HEAD 149.5 ± 27.6 119.9 213.2 1.05 ± 0.20
pnpr@main 141.9 ± 6.6 132.8 152.0 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.20154809931684214,
      "stddev": 0.030814524020259717,
      "median": 0.19939851058,
      "user": 0.2432220757894737,
      "system": 0.19030631684210525,
      "min": 0.12498430258000001,
      "max": 0.24960260858000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.1642636762723077,
      "stddev": 0.03293118509543026,
      "median": 0.15019415958000001,
      "user": 0.18961722153846153,
      "system": 0.16861634923076918,
      "min": 0.13144574858,
      "max": 0.25353281358
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1494853738925,
      "stddev": 0.02759811064995542,
      "median": 0.14586174808000002,
      "user": 0.1718084475,
      "system": 0.14162582999999998,
      "min": 0.11994182258,
      "max": 0.21318437258
    },
    {
      "command": "pnpr@main",
      "mean": 0.14187187146235294,
      "stddev": 0.006568173829609753,
      "median": 0.13955853458,
      "user": 0.17264676,
      "system": 0.13788140352941178,
      "min": 0.13282699958,
      "max": 0.15200421258
    }
  ]
}

@zkochan
zkochan marked this pull request as ready for review September 23, 2026 07:54
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Support SemVer build metadata in workspace dependency resolution

🐞 Bug fix 🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Resolve workspace versions with SemVer build metadata after normalized exact matches miss.
• Apply matching behavior consistently across TypeScript v11 and Rust v12 resolvers.
• Reuse shared matching logic and cover exact, range, availability, and installation paths.
Diagram

graph TD
  A["Workspace request"] --> B["v11 resolver"] --> D["Version matcher"] --> F{"Exact key found"}
  A --> C["v12 resolver"] --> D
  E["Deps availability"] --> D
  F -->|Yes| G["Workspace package"]
  F -->|No| H["SemVer fallback"] --> G
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Canonicalize workspace version keys
  • ➕ Retains constant-time lookup for normalized exact versions.
  • ➕ Centralizes normalization when workspace packages are indexed.
  • ➖ Build-metadata variants can collapse onto the same canonical key.
  • ➖ Requires broader changes to workspace package storage and consumers.
  • ➖ Risks losing the original manifest version used for resolution.
2. Strip metadata during comparison
  • ➕ Provides explicit control over exact-version matching.
  • ➕ Could avoid invoking range resolution for version specifications.
  • ➖ Duplicates behavior already provided by SemVer libraries.
  • ➖ Requires equivalent custom logic in TypeScript and Rust.
  • ➖ May diverge from SemVer handling for prereleases and edge cases.

Recommendation: Keep the PR's direct-lookup-first, SemVer-fallback approach. It preserves the fast path and original workspace keys while delegating metadata-insensitive precedence to established SemVer implementations; exporting the TypeScript matcher also prevents resolver and installer behavior from drifting.

Files changed (10) +210 / -25

Bug fix (2) +12 / -5
resolve_from_workspace.rsFall back to SemVer matching in the Rust resolver +8/-2

Fall back to SemVer matching in the Rust resolver

• Preserves direct exact-version lookup, then resolves normalized version specifications against workspace keys using SemVer rules. It also adds a lexical tie-breaker when parsed versions have equal precedence, keeping available-version output stable for metadata variants.

pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs

index.tsSupport metadata-insensitive v11 workspace matching +4/-3

Support metadata-insensitive v11 workspace matching

• Exports the shared local version matcher and adds SemVer fallback when exact normalized lookup misses. It also provides deterministic lexical ordering when versions compare equally by SemVer precedence.

pnpm11/resolving/npm-resolver/src/index.ts

Refactor (1) +2 / -20
wantedDepIsLocallyAvailable.tsReuse the npm resolver's workspace matcher +2/-20

Reuse the npm resolver's workspace matcher

• Removes the duplicated local version-selection implementation and delegates availability checks to the exported npm resolver helper, ensuring metadata matching remains consistent.

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts

Tests (5) +184 / -0
workspace_install.rsTest metadata-bearing workspace installation +41/-0

Test metadata-bearing workspace installation

• Adds an end-to-end Rust CLI test that installs an exact workspace dependency containing build metadata and verifies the generated local link.

pnpm/crates/cli/tests/suite/workspace_install.rs

tests.rsCover Rust workspace metadata matching +29/-0

Cover Rust workspace metadata matching

• Adds a metadata-bearing workspace fixture and verifies exact, caret, tilde, and wildcard specifications resolve to the local package.

pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace/tests.rs

multipleImporters.tsTest v11 multi-importer metadata installation +42/-0

Test v11 multi-importer metadata installation

• Adds an installation test proving an exact workspace dependency with build metadata links between projects.

pnpm11/installing/deps-installer/test/install/multipleImporters.ts

wantedDepIsLocallyAvailable.test.tsTest local availability with build metadata +34/-0

Test local availability with build metadata

• Adds unit coverage showing metadata-bearing workspace packages are available for exact, range, and wildcard specifications.

pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts

index.tsCover v11 resolver metadata variants +38/-0

Cover v11 resolver metadata variants

• Adds parameterized resolver tests for exact, caret, tilde, and wildcard workspace specifications, with and without build metadata.

pnpm11/resolving/npm-resolver/test/index.ts

Documentation (2) +12 / -0
pacquet-workspace-dependency-build-metadata.mdRecord the pacquet workspace metadata fix +5/-0

Record the pacquet workspace metadata fix

• Adds a patch release note for SemVer build metadata support in pacquet workspace dependency resolution.

.changeset/pacquet-workspace-dependency-build-metadata.md

workspace-dependency-build-metadata.mdRecord pnpm v11 package patch releases +7/-0

Record pnpm v11 package patch releases

• Adds patch release notes for pnpm and the affected npm and dependency resolver packages.

.changeset/workspace-dependency-build-metadata.md

@qodo-code-review

qodo-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Stable tag comment repeats the test ✓ Resolved 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The comment Stable in workspace satisfies tag 'latest' paraphrases the fixture, selector, and
following toBe(true) assertion. The test name and values already communicate this case, so the
comment adds no rationale and can drift when the case changes.
Code

pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[65]

+  // Stable in workspace satisfies tag 'latest'
Relevance

●●● Strong

Recent deps-resolver precedents accept removing comments that merely restate directly inferable test
behavior.

PR-#15150
PR-#13878

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713467 rejects comments that merely repeat directly inferable code. The added
comment states exactly what the immediately following stable-version fixture and true assertion
demonstrate.

Rule 713467: Avoid redundant comments that restate the code
pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[65-70]

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 stable-tag test comment only restates behavior already expressed by the fixture and assertion.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[65-70]

## Recommended Fix
Remove the comment on line 65 while retaining the test invocation and assertion unchanged.

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


2. Release lines can link different builds 📘 Rule violation ⌂ Architecture
Description
pickMatchingLocalVersionOrNull sends equal-precedence versions through insertion order in
TypeScript but sorted map order in Rust, while both range resolvers retain the first equal
candidate. When a package name has versions such as 1.0.0+a and 1.0.0+b, normalized exact
requests can therefore select different workspace packages in pnpm v11 and v12.
Code

pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[R237-238]

+            let raw: Vec<String> = versions.keys().cloned().collect();
+            resolve_workspace_range(&spec.fetch_spec, &raw)
Relevance

●●● Strong

Directly violates the PR’s required Rust/TypeScript parity; recent workspace-resolution parity fixes
were accepted.

PR-#14175

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The shared-bug rules require functionally aligned observable behavior across pnpm v11 and v12. The
new TypeScript fallback receives insertion-ordered Map keys, while the new Rust fallback receives
lexicographically ordered BTreeMap keys; because both range resolvers retain the first version
when SemVer precedence ties, versions differing only in build metadata can resolve differently.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
Rule 3102961: Keep pnpm v11 and v12 bug-fix code paths functionally aligned
pnpm11/resolving/npm-resolver/src/index.ts[1138-1151]
pnpm11/installing/context/src/index.ts[393-404]
pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[225-239]
pnpm/crates/resolving-resolver-base/src/resolve.rs[213-216]
pnpm/crates/workspace-range-resolver/src/lib.rs[56-68]

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

## Issue description
Exact version fallback can select different build-metadata variants in pnpm v11 and v12 because candidate ordering differs between the TypeScript `Map` and Rust `BTreeMap` implementations.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/index.ts[1138-1151]
- pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[225-242]
- pnpm11/resolving/npm-resolver/test/index.ts[2798-2834]
- pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace/tests.rs[161-178]

## Recommended Fix
Apply the same explicit raw-version tie-breaker in both implementations when SemVer precedence is equal. Add mirrored tests containing two versions that differ only by build metadata and insert them in an order that proves both release lines select the same entry.

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


3. Warm installs fetch registry metadata ✓ Resolved 🐞 Bug ➹ Performance
Description
wantedDepIsLocallyAvailable now uses a shared picker whose tag branch includes prerelease
workspace versions, unlike the deleted stable-only tag check. With a locked tag dependency and only
a local prerelease, the dependency is marked for update, disabling the store-peek fast path and
causing normal installs to fetch registry metadata unnecessarily.
Code

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1]

+import { parseBareSpecifier, pickMatchingLocalVersionOrNull } from '@pnpm/resolving.npm-resolver'
Relevance

●●● Strong

Introduces a documented prerelease semantic regression that disables the warm-install fast path and
adds unnecessary metadata fetching.

PR-#14932

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The imported picker uses includePrerelease: true for tags, while resolveDependenciesOfDependency
treats a positive availability result as an update and the npm resolver only uses its store-peek
fast path when opts.update is false. The resolver's own comment explicitly records the intended
invariant that this availability check ignores prereleases so the store peek keeps winning.

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1-16]
pnpm11/resolving/npm-resolver/src/index.ts[1138-1153]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[1088-1111]
pnpm11/resolving/npm-resolver/src/index.ts[591-602]
pnpm11/resolving/npm-resolver/src/index.ts[643-648]

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 shared workspace picker includes prereleases for tag selectors, but `wantedDepIsLocallyAvailable` previously excluded them. This marks locked tag dependencies for update and bypasses the warm store-peek path when the workspace contains only a prerelease.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1-16]
- pnpm11/resolving/npm-resolver/src/index.ts[1138-1153]

## Recommended Fix
Preserve the old stable-only behavior for tag availability checks while continuing to reuse shared matching for version and range selectors. Either add an explicit prerelease policy option to the shared picker and disable it here, or handle tag selectors locally with `semver.maxSatisfying` without `includePrerelease`.

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



Informational

4. Two test calls omit trailing commas 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The multiline wantedDepIsLocallyAvailable calls leave their final options arguments at lines 62
and 69 without trailing commas. Both calls place each argument on a separate line, so later argument
changes produce noisier diffs than the required collection style.
Code

pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[R62-63]

+    { defaultTag: 'latest', registry: 'https://registry.npmjs.org/' }
+  )).toBe(false)
Relevance

● Weak

Recent precedents reject trailing-comma findings in multiline TypeScript calls and signatures.

PR-#14245
PR-#14841

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 713434 requires trailing commas in multiline TypeScript argument lists. The two
added calls end their final arguments without commas.

Rule 713434: Require trailing commas in TypeScript collections and multi-line constructs
pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[59-70]

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

## Issue description
Two multiline TypeScript function calls omit the required trailing comma after their final argument.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/test/wantedDepIsLocallyAvailable.test.ts[59-70]

## Recommended Fix
Add a comma after each final options-object argument on lines 62 and 69, preserving the existing call formatting.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 64 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/node-semver-rs (sha: 1ae976a0)
Review mode: ⚖️ Balanced: The push changes workspace dependency resolution behavior across TypeScript and Rust-related paths, including semver tag handling and error ordering, so it carries real correctness risk but not enough independent logic for extended review.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Finding overflow, which tucks the rest behind 'View more'

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 2ba3460

Results up to commit e4c6b73 ⚖️ Balanced


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


Remediation recommended
1. Release lines can link different builds 📘 Rule violation ⌂ Architecture
Description
pickMatchingLocalVersionOrNull sends equal-precedence versions through insertion order in
TypeScript but sorted map order in Rust, while both range resolvers retain the first equal
candidate. When a package name has versions such as 1.0.0+a and 1.0.0+b, normalized exact
requests can therefore select different workspace packages in pnpm v11 and v12.
Code

pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[R237-238]

+            let raw: Vec<String> = versions.keys().cloned().collect();
+            resolve_workspace_range(&spec.fetch_spec, &raw)
Relevance

●●● Strong

Directly violates the PR’s required Rust/TypeScript parity; recent workspace-resolution parity fixes
were accepted.

PR-#14175

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The shared-bug rules require functionally aligned observable behavior across pnpm v11 and v12. The
new TypeScript fallback receives insertion-ordered Map keys, while the new Rust fallback receives
lexicographically ordered BTreeMap keys; because both range resolvers retain the first version
when SemVer precedence ties, versions differing only in build metadata can resolve differently.

Rule 713428: Keep pnpm v11 and v12 observable behavior aligned when fixing shared bugs
Rule 3102961: Keep pnpm v11 and v12 bug-fix code paths functionally aligned
pnpm11/resolving/npm-resolver/src/index.ts[1138-1151]
pnpm11/installing/context/src/index.ts[393-404]
pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[225-239]
pnpm/crates/resolving-resolver-base/src/resolve.rs[213-216]
pnpm/crates/workspace-range-resolver/src/lib.rs[56-68]

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

## Issue description
Exact version fallback can select different build-metadata variants in pnpm v11 and v12 because candidate ordering differs between the TypeScript `Map` and Rust `BTreeMap` implementations.

## Fix Focus Areas
- pnpm11/resolving/npm-resolver/src/index.ts[1138-1151]
- pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace.rs[225-242]
- pnpm11/resolving/npm-resolver/test/index.ts[2798-2834]
- pnpm/crates/resolving-npm-resolver/src/resolve_from_workspace/tests.rs[161-178]

## Recommended Fix
Apply the same explicit raw-version tie-breaker in both implementations when SemVer precedence is equal. Add mirrored tests containing two versions that differ only by build metadata and insert them in an order that proves both release lines select the same entry.

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


2. Warm installs fetch registry metadata ✓ Resolved 🐞 Bug ➹ Performance
Description
wantedDepIsLocallyAvailable now uses a shared picker whose tag branch includes prerelease
workspace versions, unlike the deleted stable-only tag check. With a locked tag dependency and only
a local prerelease, the dependency is marked for update, disabling the store-peek fast path and
causing normal installs to fetch registry metadata unnecessarily.
Code

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1]

+import { parseBareSpecifier, pickMatchingLocalVersionOrNull } from '@pnpm/resolving.npm-resolver'
Relevance

●●● Strong

Introduces a documented prerelease semantic regression that disables the warm-install fast path and
adds unnecessary metadata fetching.

PR-#14932

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The imported picker uses includePrerelease: true for tags, while resolveDependenciesOfDependency
treats a positive availability result as an update and the npm resolver only uses its store-peek
fast path when opts.update is false. The resolver's own comment explicitly records the intended
invariant that this availability check ignores prereleases so the store peek keeps winning.

pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1-16]
pnpm11/resolving/npm-resolver/src/index.ts[1138-1153]
pnpm11/installing/deps-resolver/src/resolveDependencies.ts[1088-1111]
pnpm11/resolving/npm-resolver/src/index.ts[591-602]
pnpm11/resolving/npm-resolver/src/index.ts[643-648]

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 shared workspace picker includes prereleases for tag selectors, but `wantedDepIsLocallyAvailable` previously excluded them. This marks locked tag dependencies for update and bypasses the warm store-peek path when the workspace contains only a prerelease.

## Fix Focus Areas
- pnpm11/installing/deps-resolver/src/wantedDepIsLocallyAvailable.ts[1-16]
- pnpm11/resolving/npm-resolver/src/index.ts[1138-1153]

## Recommended Fix
Preserve the old stable-only behavior for tag availability checks while continuing to reuse shared matching for version and range selectors. Either add an explicit prerelease policy option to the shared picker and disable it here, or handle tag selectors locally with `semver.maxSatisfying` without `includePrerelease`.

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


Grey Divider

Qodo Logo

@greptile-apps

greptile-apps Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable new issue remains after the follow-up changes.

Reviews (3) · Last reviewed commit: "test: remove narrative comments from tes..."

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 23, 2026
…6483)

Use deterministic ordinal comparison in `@pnpm/resolving.npm-resolver`
for available versions hint, matching Rust's ordering.

Preserve stable-only behavior for tag selectors in
`wantedDepIsLocallyAvailable` within `@pnpm/installing.deps-resolver`.

Add regression tests for both behaviors in TypeScript and Rust.
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6c397fb

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

@qodo-code-review

qodo-code-review Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

No code changes since the last review — review skipped

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.

@zkochan

zkochan commented Sep 23, 2026

Copy link
Copy Markdown
Member Author

Summary of Changes & Status

  • Issue Addressed: pnpm does not support semver spec on build metadata yet? #6483
  • Root Cause: Version normalization strips SemVer build metadata before matching keys against the workspace packages map, causing exact version specifiers like workspace:0.5.6-next.3+f60facc or workspace:0.5.6-next.3 to fail lookup.
  • Solution:
    • Per SemVer 2.0.0 specification item 10, build metadata is ignored when determining version precedence.
    • In both pnpm v11 (TypeScript) and v12 (Rust), updated pickMatchingLocalVersionOrNull to fall back to SemVer range resolution when an exact version key is not present in the workspace packages map.
    • Aligned diagnostic ordering of available workspace versions in error messages using deterministic ordinal string comparison across both stacks.
    • Preserved stable-only behavior for tag availability checks in wantedDepIsLocallyAvailable while reusing shared matching for version and range specifiers.
  • Verification & Review:
    • Regression tests added and verified in both TypeScript (@pnpm/resolving.npm-resolver and @pnpm/installing.deps-resolver) and Rust (pnpm-resolving-npm-resolver and CLI suite).
    • All review bot threads resolved; both CodeRabbit and Greptile have approved the latest commit (2ba3460379).
    • All 57 CI checks are green.

Written by an agent (Gemini).

@zkochan
zkochan merged commit 9cd72d2 into main Sep 23, 2026
60 checks passed
@zkochan
zkochan deleted the fix-6483 branch September 23, 2026 09:39
u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
…pnpm#6483) (pnpm#15340)

When a workspace package version carries SemVer build metadata,
exact version specifiers (e.g. `workspace:0.5.6-next.3+f60facc` or
`workspace:0.5.6-next.3`) failed to resolve because version-selector-type
and Version normalization strip build metadata before matching keys in
the workspace packages map.

Fall back to SemVer range resolution for Version specifiers in both
pnpm v11 (TypeScript) and v12 (Rust) to honor SemVer precedence
rules (spec item 10) where build metadata is ignored.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pnpm does not support semver spec on build metadata yet?

2 participants