Skip to content

fix: read a single-string trustPolicyExclude/minimumReleaseAgeExclude as a one-entry list - #13737

Merged
zkochan merged 7 commits into
pnpm:mainfrom
Ayush442842q:resolve-pnpm-issue-13721
Aug 17, 2026
Merged

zkochan merged 7 commits into
pnpm:mainfrom
Ayush442842q:resolve-pnpm-issue-13721

Conversation

@Ayush442842q

@Ayush442842q Ayush442842q commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

trustPolicyExclude and minimumReleaseAgeExclude reach the policy builder as a bare string rather than a list whenever they are written as a YAML scalar in pnpm-workspace.yaml or in the global config.yaml, or come from a PNPM_CONFIG_* env var — their schema is [String, Array], so the env parser falls back to String once the value fails to parse as a JSON array. (Not from .npmrc: isNpmrcReadableKey admits only scoped keys, //-prefixed keys, the npm auth settings, and six proxy keys.) createPackageVersionPolicy iterated it, producing one rule per character. Two consequences:

  • The exclusion never matched the package it named, so the install failed on a version the user had explicitly allowed.
  • A * anywhere in the value became a match-everything rule, silently switching the whole policy off for every package. minimumReleaseAgeExclude: '@scope/*' written as a scalar disabled the release-age cooldown entirely.

A lone string is now read as a one-entry list.

Scope

This PR originally also stripped a leading slash in the dependency-path parsers of both stacks, on the theory that trustPolicyExclude fails against a /name@version lockfile key. That was dropped in e6adb88. A leading slash is the lockfile format 6 spelling, and pnpm has not read a format 6 lockfile since the version gate moved to major 9 — both entry points in readLockfiles.ts pass wantedVersions: [LOCKFILE_VERSION], and a lower major is rejected with ERR_PNPM_LOCKFILE_BREAKING_CHANGE before any key is parsed. Such a key can only appear in a file labelled version 9 that was hand-edited or mangled, and the rest of the install pipeline still treats it as a distinct literal string, so normalizing it in the parser alone made the verifier pass an entry the installer could not then find.

It therefore does not close #13721, whose reporter was on pnpm 10.21.0 — also lockfile major 9 — with an array-valued trustPolicyExclude. That issue still needs a root cause.

Parity

TypeScript only. pacquet types both settings as Option<Vec<String>>: a YAML scalar is a parse error and a scalar env var is ignored, so it never had this bug. The wider divergence — the TypeScript config layer accepts a scalar for every [String, Array] setting while pacquet does not — is pre-existing across roughly nine settings and belongs in its own change to both stacks.

Squash Commit Body

fix: read a single-string exclude setting as a one-entry list

`trustPolicyExclude` and `minimumReleaseAgeExclude` are declared as
`[String, Array]`, so a single .npmrc line, env var, or YAML scalar
arrives as a bare string. `createPackageVersionPolicy` iterated it and
built one rule per character: the exclusion never matched the package it
named, and a `*` anywhere in the value matched every package, silently
switching the policy off.

Checklist

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

@Ayush442842q
Ayush442842q requested a review from zkochan as a code owner August 9, 2026 09:04
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@coderabbitai

coderabbitai Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9a14ae2d-118c-4e31-9282-c25eb7cbe737

📥 Commits

Reviewing files that changed from the base of the PR and between 87c8aa1 and 05502b6.

📒 Files selected for processing (2)
  • pnpm/crates/lockfile/src/pkg_name_ver_peer/tests.rs
  • pnpm11/pnpm/test/install/misc.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/lockfile/src/pkg_name_ver_peer/tests.rs
  • pnpm11/pnpm/test/install/misc.ts

📝 Walkthrough

Walkthrough

The changes normalize leading-slash lockfile paths and support single-string trust-policy exclusion patterns. Unit and integration tests cover package parsing, version-policy matching, downgraded dependencies, and lockfile verification.

Changes

Trust policy exclusion handling

Layer / File(s) Summary
Dependency path normalization
pnpm/crates/lockfile/src/pkg_name_suffix.rs, pnpm/crates/lockfile/src/pkg_name/tests.rs, pnpm/crates/lockfile/src/pkg_name_ver_peer/tests.rs, pnpm11/deps/path/src/index.ts, pnpm11/deps/path/test/index.ts
Package and dependency path parsing removes one leading slash and preserves doubled leading slashes. Tests cover registry, scoped, patched, peer-dependent, and legacy lockfile keys.
Single-string policy patterns
pnpm11/config/version-policy/src/index.ts, pnpm11/config/version-policy/test/index.ts
Version-policy creation functions accept a string or string array. Single strings are normalized before pattern parsing.
Trust policy verification coverage
pnpm11/pnpm/test/install/misc.ts, .changeset/fix-trust-policy-exclude-slash.md
Integration tests cover direct and transitive downgraded packages, mismatched exclusions, leading-slash lockfile keys, and single-string exclusions. The changeset records patch releases for the affected packages.

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

Possibly related issues

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

Suggested reviewers: zkochan

Sequence Diagram(s)

sequenceDiagram
  participant WorkspaceConfig
  participant LockfileVerification
  participant DependencyPathParse
  WorkspaceConfig->>LockfileVerification: provide trustPolicyExclude
  LockfileVerification->>DependencyPathParse: parse lockfile package keys
  DependencyPathParse-->>LockfileVerification: return normalized package name
  LockfileVerification->>LockfileVerification: validate trust downgrade
  LockfileVerification-->>WorkspaceConfig: allow match or throw ERR_PNPM_TRUST_DOWNGRADE
Loading
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

@greptile-apps

greptile-apps Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (9): Last reviewed commit: "docs: cut the comment narration down to ..." | Re-trigger Greptile

Comment thread pnpm-lock.yaml Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm11/pnpm/test/install/misc.ts`:
- Around line 746-781: Extend the lockfile verifier regression around the
existing trustPolicyExclude test to rewrite the package and snapshot keys to a
double-slash identifier (`//@pnpm/[email protected]`) while keeping
trustPolicyExclude unprefixed, then assert installation fails with
ERR_PNPM_TRUST_DOWNGRADE. Add equivalent TypeScript and pacquet coverage, plus
corresponding Rust coverage, preserving `//` as distinct from `/` lockfile keys.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 82f984d1-4710-4711-b87e-ce752286b41d

📥 Commits

Reviewing files that changed from the base of the PR and between d98142c and aefcebc.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !pnpm-lock.yaml
📒 Files selected for processing (7)
  • .changeset/fix-trust-policy-exclude-slash.md
  • pnpm/crates/lockfile/src/pkg_name.rs
  • pnpm/crates/lockfile/src/pkg_name_suffix.rs
  • pnpm11/config/version-policy/src/index.ts
  • pnpm11/config/version-policy/test/index.ts
  • pnpm11/deps/path/src/index.ts
  • pnpm11/pnpm/test/install/misc.ts

Comment thread pnpm11/pnpm/test/install/misc.ts Resolved
@codecov-commenter

codecov-commenter commented Aug 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.25%. Comparing base (286d7ea) to head (05502b6).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13737   +/-   ##
=======================================
  Coverage   88.25%   88.25%           
=======================================
  Files         627      627           
  Lines      103341   103342    +1     
=======================================
+ Hits        91203    91209    +6     
+ Misses      12138    12133    -5     

☔ 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 added the reviewed: coderabbit CodeRabbit submitted an approving review label Aug 9, 2026
@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 87c8aa1ccf02

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

The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.007 ± 0.318 2.603 3.561 1.82 ± 0.28
pacquet@main 2.704 ± 0.191 2.475 2.977 1.64 ± 0.22
pnpr@HEAD 1.652 ± 0.190 1.412 2.076 1.00
pnpr@main 1.677 ± 0.165 1.478 1.917 1.02 ± 0.15
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.00676677256,
      "stddev": 0.31780431742741505,
      "median": 2.96825742236,
      "user": 3.05168588,
      "system": 2.32141786,
      "min": 2.60323213686,
      "max": 3.56056830886,
      "times": [
        2.82543572386,
        3.01801430686,
        3.56056830886,
        3.37131804786,
        2.6167552188600003,
        3.04505241586,
        2.82239109586,
        3.28639993286,
        2.91850053786,
        2.60323213686
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.70377588066,
      "stddev": 0.19086805607613822,
      "median": 2.64406634936,
      "user": 2.4134591800000003,
      "system": 1.8420641600000003,
      "min": 2.47544453286,
      "max": 2.97749122986,
      "times": [
        2.9750587088600002,
        2.62655664886,
        2.76859037386,
        2.60692328186,
        2.6615760498600003,
        2.97749122986,
        2.52569298386,
        2.90270211586,
        2.51772288086,
        2.47544453286
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.65179000476,
      "stddev": 0.1895829062754799,
      "median": 1.5799183513600001,
      "user": 1.5027072799999999,
      "system": 1.6049872599999997,
      "min": 1.41152312286,
      "max": 2.07602964986,
      "times": [
        1.55148990886,
        1.41152312286,
        1.62364603186,
        1.5786486378600002,
        1.83798967886,
        2.07602964986,
        1.53308459886,
        1.75048253186,
        1.57381782186,
        1.58118806486
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6772746655600002,
      "stddev": 0.1654137363093747,
      "median": 1.6874490203599999,
      "user": 1.53855398,
      "system": 1.6561365600000002,
      "min": 1.47806867986,
      "max": 1.91692528386,
      "times": [
        1.75729330286,
        1.67600211786,
        1.84717802286,
        1.48868920786,
        1.69889592286,
        1.5380534248600002,
        1.51507554186,
        1.85656515086,
        1.91692528386,
        1.47806867986
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 381.2 ± 52.6 318.2 464.5 1.02 ± 0.21
pacquet@main 374.1 ± 57.5 301.5 499.3 1.00
pnpr@HEAD 490.7 ± 53.1 424.9 567.1 1.31 ± 0.25
pnpr@main 648.4 ± 70.1 546.7 777.7 1.73 ± 0.33
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.38122338186000004,
      "stddev": 0.052624301069423694,
      "median": 0.36648939376,
      "user": 0.34802493999999995,
      "system": 0.6657664000000001,
      "min": 0.31819397176,
      "max": 0.46453244576,
      "times": [
        0.34226627376,
        0.33644662676000003,
        0.36960610176,
        0.36337268576000004,
        0.44687031176,
        0.42930489876,
        0.46453244576,
        0.33084074176,
        0.31819397176,
        0.41079976076
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.37407042756,
      "stddev": 0.057466595113745675,
      "median": 0.37102805626,
      "user": 0.35883393999999996,
      "system": 0.6815222000000001,
      "min": 0.30145345176,
      "max": 0.49932771876000004,
      "times": [
        0.33013124676,
        0.31888701576,
        0.30145345176,
        0.35419537276,
        0.36389823476,
        0.37815787776,
        0.49932771876000004,
        0.42990670176,
        0.38486801076,
        0.37987864476
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.4907380165600001,
      "stddev": 0.05305665531588605,
      "median": 0.48564627226,
      "user": 0.43715074,
      "system": 0.7948993000000001,
      "min": 0.42489135776000003,
      "max": 0.56714889576,
      "times": [
        0.48008977076000003,
        0.42797410776,
        0.5312656457600001,
        0.42489135776000003,
        0.49120277376000004,
        0.43742379276000004,
        0.5594711127600001,
        0.56714889576,
        0.46331394376,
        0.5245987647600001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.64841302416,
      "stddev": 0.07013858858235306,
      "median": 0.6320050042600001,
      "user": 0.5168045400000001,
      "system": 0.9134578999999998,
      "min": 0.5467405857600001,
      "max": 0.77769553976,
      "times": [
        0.5467405857600001,
        0.6225807867600001,
        0.6312837977600001,
        0.7387213757600001,
        0.77769553976,
        0.6730833357600001,
        0.6636283697600001,
        0.6316240977600001,
        0.5663864417600001,
        0.6323859107600001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.310 ± 0.238 3.038 3.586 1.88 ± 0.23
pacquet@main 2.916 ± 0.094 2.802 3.115 1.66 ± 0.17
pnpr@HEAD 1.757 ± 0.174 1.521 2.096 1.00
pnpr@main 1.809 ± 0.174 1.626 2.094 1.03 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.31016653876,
      "stddev": 0.23842173172625283,
      "median": 3.32076389146,
      "user": 2.81107494,
      "system": 2.2964627599999994,
      "min": 3.03825871246,
      "max": 3.58640849346,
      "times": [
        3.57571092046,
        3.58640849346,
        3.53229778746,
        3.38464149546,
        3.53473317046,
        3.25688628746,
        3.06019871246,
        3.09105704046,
        3.04147276746,
        3.03825871246
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.9157179738600005,
      "stddev": 0.09442447800437648,
      "median": 2.9027346514600003,
      "user": 2.22336104,
      "system": 1.68595946,
      "min": 2.80236494746,
      "max": 3.11460008646,
      "times": [
        3.02043375246,
        2.91664915546,
        3.11460008646,
        2.94413114146,
        2.93469923846,
        2.88882014746,
        2.84338960846,
        2.84137268446,
        2.85071897646,
        2.80236494746
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.75747967346,
      "stddev": 0.17441026928710068,
      "median": 1.7558689034600001,
      "user": 1.6399843399999998,
      "system": 1.8569226599999997,
      "min": 1.52131485446,
      "max": 2.09634615246,
      "times": [
        1.75832506846,
        1.5352236484600001,
        1.52131485446,
        1.81588361046,
        2.09634615246,
        1.63592393246,
        1.69790355146,
        1.75341273846,
        1.84958054646,
        1.91088263146
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.8092817068600002,
      "stddev": 0.17447855167454918,
      "median": 1.73617118046,
      "user": 1.6769579399999999,
      "system": 1.8437142599999998,
      "min": 1.62587962846,
      "max": 2.09387458246,
      "times": [
        1.63565884446,
        1.8229418374600002,
        1.7456802524600001,
        1.72448657646,
        2.04755822746,
        1.67246416746,
        1.99761084346,
        2.09387458246,
        1.62587962846,
        1.72666210846
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 645.2 ± 61.5 563.9 742.3 1.68 ± 0.19
pacquet@main 530.1 ± 33.7 468.7 581.2 1.38 ± 0.12
pnpr@HEAD 383.4 ± 23.9 342.3 415.4 1.00
pnpr@main 405.3 ± 38.1 361.9 478.0 1.06 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.64517291454,
      "stddev": 0.0615319100552127,
      "median": 0.6349375258400001,
      "user": 0.8883796199999999,
      "system": 0.96439722,
      "min": 0.56394519434,
      "max": 0.7422540963400001,
      "times": [
        0.65445165334,
        0.56394519434,
        0.61542339834,
        0.61075600834,
        0.7422540963400001,
        0.68228507034,
        0.73342992834,
        0.66835277334,
        0.58050167734,
        0.60032934534
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.5300922709399999,
      "stddev": 0.03369974341931937,
      "median": 0.53324443384,
      "user": 0.7442724199999999,
      "system": 0.7690978199999999,
      "min": 0.46874996434000005,
      "max": 0.58124781034,
      "times": [
        0.53209399934,
        0.50907905634,
        0.51133026134,
        0.53627970334,
        0.50262858234,
        0.58124781034,
        0.57044762534,
        0.55467083834,
        0.5343948683399999,
        0.46874996434000005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.3833628909400001,
      "stddev": 0.023897730400002842,
      "median": 0.38185673734000003,
      "user": 0.27880232,
      "system": 0.6361283199999999,
      "min": 0.34229719734,
      "max": 0.41540979834,
      "times": [
        0.37131302834,
        0.36088357934000004,
        0.40987533634000006,
        0.38938156634000004,
        0.41540979834,
        0.41099865934,
        0.38831632334000005,
        0.37539715134,
        0.34229719734,
        0.36975626934000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.40527887474,
      "stddev": 0.03809341298221454,
      "median": 0.39849329634,
      "user": 0.31672192,
      "system": 0.64431112,
      "min": 0.36194199134000005,
      "max": 0.47795414834000005,
      "times": [
        0.36194199134000005,
        0.37262095934000006,
        0.41373755234000004,
        0.47795414834000005,
        0.39296662934000004,
        0.39821957134,
        0.46403199034000003,
        0.39938948234000005,
        0.37315940134000003,
        0.39876702134
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.336 ± 0.154 2.150 2.655 6.15 ± 0.50
pacquet@main 2.148 ± 0.073 2.066 2.266 5.66 ± 0.33
pnpr@HEAD 0.380 ± 0.018 0.356 0.413 1.00
pnpr@main 0.380 ± 0.033 0.325 0.446 1.00 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.33643479882,
      "stddev": 0.1544687550618431,
      "median": 2.31423109192,
      "user": 1.3608709199999998,
      "system": 1.15430988,
      "min": 2.1503619414200004,
      "max": 2.6548245344200003,
      "times": [
        2.23303590842,
        2.21423310742,
        2.1503619414200004,
        2.32103134342,
        2.49677635342,
        2.6548245344200003,
        2.38777261942,
        2.4018248424200004,
        2.19705649742,
        2.3074308404200004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.1480475535200005,
      "stddev": 0.07321268832280459,
      "median": 2.1370334894200003,
      "user": 1.2294237199999998,
      "system": 0.96989878,
      "min": 2.06585314442,
      "max": 2.26611500042,
      "times": [
        2.25350463042,
        2.26611500042,
        2.1159516534200002,
        2.2049902614200003,
        2.06585314442,
        2.1581153254200003,
        2.07710745442,
        2.0889646884200004,
        2.15999632342,
        2.0898770534200004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.37961463612,
      "stddev": 0.018183167782368042,
      "median": 0.37555165142,
      "user": 0.28899001999999996,
      "system": 0.6342415799999999,
      "min": 0.35642766342,
      "max": 0.41293633942,
      "times": [
        0.37602337342000003,
        0.37507992942,
        0.35642766342,
        0.38779626842,
        0.37764916242,
        0.36674498942,
        0.36494630742,
        0.41293633942,
        0.40738371542,
        0.37115861242
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.38016424412,
      "stddev": 0.032569485404378255,
      "median": 0.37392026392,
      "user": 0.28606471999999994,
      "system": 0.6270620799999999,
      "min": 0.32472522642,
      "max": 0.44630437442,
      "times": [
        0.41387799042,
        0.36670801142,
        0.37816834742,
        0.38255643542,
        0.44630437442,
        0.36616406242,
        0.36967218042,
        0.39159748142,
        0.36186833142,
        0.32472522642
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 263.7 ± 28.1 229.8 330.7 2.57 ± 0.33
pacquet@main 256.0 ± 27.2 219.9 312.2 2.49 ± 0.32
pnpr@HEAD 102.7 ± 7.6 92.3 124.9 1.00
pnpr@main 104.4 ± 5.9 94.6 116.6 1.02 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26373240238000006,
      "stddev": 0.02808317808478539,
      "median": 0.26014099188,
      "user": 0.21735523999999998,
      "system": 0.07487286,
      "min": 0.22975911338000002,
      "max": 0.33066243938,
      "times": [
        0.28503124838,
        0.25377909438,
        0.23484387838000004,
        0.25711670138,
        0.26181332738,
        0.26403623738,
        0.26147790638,
        0.25880407738,
        0.22975911338000002,
        0.33066243938
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.25600700684153843,
      "stddev": 0.027201203936119783,
      "median": 0.25206464038,
      "user": 0.22134148615384613,
      "system": 0.07318045230769231,
      "min": 0.21993561538000003,
      "max": 0.31223505938,
      "times": [
        0.21993561538000003,
        0.28757417138,
        0.28262205738,
        0.24310744138000004,
        0.22221422138000002,
        0.24502982738000004,
        0.25127173938,
        0.25206464038,
        0.22339061438000002,
        0.31223505938,
        0.26672173938,
        0.26385397638,
        0.25806998538
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.1027331476213793,
      "stddev": 0.007649472450735274,
      "median": 0.10190779838,
      "user": 0.029543191724137927,
      "system": 0.014279484137931031,
      "min": 0.09225830738,
      "max": 0.12489014838,
      "times": [
        0.09828341038,
        0.09411554038,
        0.09559024438000001,
        0.09225830738,
        0.09664763338,
        0.09765991738,
        0.09641294238,
        0.10288702038,
        0.10408397038,
        0.09904731738,
        0.09610287838,
        0.09303257338,
        0.10659504538,
        0.11076071938000001,
        0.09686250838,
        0.09703674638,
        0.11309954938000001,
        0.10190779838,
        0.11796116338000001,
        0.10845386138,
        0.10424828938,
        0.10765499838,
        0.09927149938,
        0.10524803038000001,
        0.10903389238000001,
        0.10394077138,
        0.09913853938,
        0.10703596438,
        0.12489014838
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10444873409999998,
      "stddev": 0.005942583280264718,
      "median": 0.10316953138,
      "user": 0.030556679999999992,
      "system": 0.014504569600000001,
      "min": 0.09459881038000001,
      "max": 0.11659614538,
      "times": [
        0.10935778138,
        0.10199058338,
        0.10530607038,
        0.11306210838,
        0.09981114438000001,
        0.09597825438,
        0.10289210838,
        0.10280277238,
        0.10087433438,
        0.10756692238,
        0.10369325638,
        0.09943257138,
        0.09986300238000001,
        0.10212148938,
        0.10827696738,
        0.11092644238,
        0.10416136638000001,
        0.11533372238,
        0.11659614538,
        0.10461500038,
        0.09955280738000001,
        0.09459881038000001,
        0.09674491638,
        0.10316953138,
        0.11249024338000001
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.106 ± 0.135 0.885 1.292 1.11 ± 0.25
pacquet@main 0.994 ± 0.188 0.751 1.418 1.00
pnpm@HEAD 4.415 ± 0.336 3.881 4.840 4.44 ± 0.90
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.105886989231111,
      "stddev": 0.13497980737014864,
      "median": 1.1420789651199998,
      "user": 1.1381953555555553,
      "system": 0.1991832888888889,
      "min": 0.88479319712,
      "max": 1.2923334621199998,
      "times": [
        1.0075809871199999,
        0.9894451041200001,
        1.0291111951199998,
        0.88479319712,
        1.19126791912,
        1.2498056071199999,
        1.2923334621199998,
        1.1420789651199998,
        1.16656646612
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.9944072661200001,
      "stddev": 0.18801758363800927,
      "median": 0.9862963521200001,
      "user": 0.9878680222222224,
      "system": 0.20510062222222225,
      "min": 0.7514851061200001,
      "max": 1.41789368812,
      "times": [
        1.04595369612,
        1.41789368812,
        1.03961877012,
        1.03095688812,
        0.9862963521200001,
        0.8240964981200001,
        0.93593057412,
        0.7514851061200001,
        0.91743382212
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.414598941453334,
      "stddev": 0.33564233415232425,
      "median": 4.566005173120001,
      "user": 6.799633577777777,
      "system": 0.39287717777777775,
      "min": 3.88139535412,
      "max": 4.839980345120001,
      "times": [
        4.27937728012,
        4.839980345120001,
        4.670669565120001,
        4.725123631120001,
        4.566005173120001,
        4.569354592120001,
        3.88139535412,
        4.02705955712,
        4.17242497512
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.821 ± 0.181 4.640 5.132 1.33 ± 0.06
pacquet@main 4.738 ± 0.115 4.624 4.948 1.31 ± 0.05
pnpr@HEAD 3.683 ± 0.152 3.494 3.920 1.02 ± 0.05
pnpr@main 3.613 ± 0.107 3.504 3.883 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.8212109952,
      "stddev": 0.1807507029357736,
      "median": 4.7756133037,
      "user": 2.9594225200000004,
      "system": 2.11378604,
      "min": 4.6396407827,
      "max": 5.1323728057,
      "times": [
        4.6396407827,
        4.6779573517,
        4.7961829677,
        5.0530485077,
        4.7550436397,
        4.6583647847,
        4.6738766267,
        5.0127253567,
        4.8128971287,
        5.1323728057
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.7384470389999995,
      "stddev": 0.11461173711934111,
      "median": 4.6796329012,
      "user": 2.40677272,
      "system": 1.78533704,
      "min": 4.6242912857,
      "max": 4.9476071557,
      "times": [
        4.6805752137,
        4.6286519067,
        4.6778895137,
        4.9476071557,
        4.7990201317,
        4.8900626567,
        4.6515103557,
        4.8061715817,
        4.6242912857,
        4.6786905887
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6830462363,
      "stddev": 0.15200392746704894,
      "median": 3.6704853572,
      "user": 1.4499092199999999,
      "system": 1.44534444,
      "min": 3.4942969887,
      "max": 3.9195126377,
      "times": [
        3.9195126377,
        3.7725779467000002,
        3.8965885777000002,
        3.5642712017,
        3.7507267637,
        3.4995460647,
        3.7006284247,
        3.4942969887,
        3.5919714677,
        3.6403422897
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.6125758400000008,
      "stddev": 0.10734463418005126,
      "median": 3.5899399192,
      "user": 1.53064982,
      "system": 1.52170954,
      "min": 3.5039352277,
      "max": 3.8828120777,
      "times": [
        3.8828120777,
        3.5506062307,
        3.6109237637,
        3.6422085567,
        3.6181576677000002,
        3.5689560747,
        3.5039352277,
        3.5347224777,
        3.5515332167,
        3.6619031067
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13737
Testbedpacquet

🚨 2 Alerts

BenchmarkMeasure
Units
ViewBenchmark Result
(Result Δ%)
Upper Boundary
(Limit %)
isolated-linker.fresh-install.hot-cache.hot-storeLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
563.95 ms
(+23.83%)Baseline: 455.40 ms
546.48 ms
(103.20%)

isolated-linker.peer-heavy-resolve.hot-cache.offlineLatency
milliseconds (ms)
📈 plot
🚷 threshold
🚨 alert (🔔)
884.79 ms
(+26.37%)Baseline: 700.17 ms
840.20 ms
(105.31%)

Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
3,038.26 ms
(+12.13%)Baseline: 2,709.61 ms
3,251.54 ms
(93.44%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
2,150.36 ms
(+18.37%)Baseline: 1,816.67 ms
2,180.00 ms
(98.64%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
🚨 view alert (🔔)
563.95 ms
(+23.83%)Baseline: 455.40 ms
546.48 ms
(103.20%)

isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
229.76 ms
(+2.26%)Baseline: 224.69 ms
269.63 ms
(85.21%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,603.23 ms
(+5.05%)Baseline: 2,478.14 ms
2,973.76 ms
(87.54%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,639.64 ms
(+2.57%)Baseline: 4,523.47 ms
5,428.16 ms
(85.47%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
318.19 ms
(+6.93%)Baseline: 297.56 ms
357.08 ms
(89.11%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
🚨 view alert (🔔)
884.79 ms
(+26.37%)Baseline: 700.17 ms
840.20 ms
(105.31%)

🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Aug 9, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13737
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,436.96 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
279.15 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
293.19 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.45 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,368.57 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,447.87 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
269.13 ms
🐰 View full continuous benchmarking report in Bencher

@Ayush442842q
Ayush442842q force-pushed the resolve-pnpm-issue-13721 branch from 056959a to 2e8ff06 Compare August 11, 2026 03:11
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 11, 2026
@zkochan
zkochan force-pushed the resolve-pnpm-issue-13721 branch from 2e8ff06 to 87c8aa1 Compare August 12, 2026 05:26
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 05:26

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/lockfile/src/pkg_name_ver_peer/tests.rs`:
- Around line 269-274: Add a PkgNameVerPeer test case in the existing test cases
around name_peer_ver for a slash-prefixed dependency key containing both a
patch_hash and peer data, matching the input and expected parsed name/version
from pnpm11/deps/path/test/index.ts. Keep the current doubled-slash regression
case unchanged.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e64f860-0de1-4baa-9c79-9e5c335657ed

📥 Commits

Reviewing files that changed from the base of the PR and between 2e8ff06 and 87c8aa1.

📒 Files selected for processing (8)
  • .changeset/fix-trust-policy-exclude-slash.md
  • pnpm/crates/lockfile/src/pkg_name/tests.rs
  • pnpm/crates/lockfile/src/pkg_name_suffix.rs
  • pnpm/crates/lockfile/src/pkg_name_ver_peer/tests.rs
  • pnpm11/config/version-policy/src/index.ts
  • pnpm11/deps/path/src/index.ts
  • pnpm11/deps/path/test/index.ts
  • pnpm11/pnpm/test/install/misc.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • .changeset/fix-trust-policy-exclude-slash.md
  • pnpm11/deps/path/src/index.ts
  • pnpm11/config/version-policy/src/index.ts

@qodo-code-review

qodo-code-review Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. trustPolicyExclude string unsupported in Rust 📘 Rule violation ⌂ Architecture
Description
TypeScript now accepts trustPolicyExclude/minimumReleaseAgeExclude as either a string or
string-array, but the Rust WorkspaceSettings still requires YAML arrays for these fields. This
creates a user-visible divergence where the same config works in pnpm TypeScript but fails (or is
ignored) in pacquet Rust without any call-out in the PR description.
Code

pnpm11/config/version-policy/src/index.ts[R18-19]

+  const patternList = typeof patterns === 'string' ? [patterns] : patterns
+  for (const pattern of patternList) {
Relevance

●●● Strong

Team often enforces TS↔Rust parity for user-visible behavior; PR intent claims robustness on both
sides.

PR-#12789
PR-#12153

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713428 requires user-visible behavior changes to be kept in sync between pnpm
TypeScript and pacquet Rust (or explicitly called out). The TypeScript change explicitly accepts
string | string[], while Rust still models the corresponding workspace-yaml keys as
Option<Vec<String>> without a deserializer that would accept a scalar string.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/config/version-policy/src/index.ts[6-19]
pnpm/crates/config/src/workspace_yaml.rs[96-110]
pnpm/crates/config/src/workspace_yaml.rs[449-455]

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

## Issue description
TypeScript `createPackageVersionPolicy` now normalizes a lone string config value into a single-element array, but the Rust workspace YAML/config structs still deserialize `trustPolicyExclude`/`minimumReleaseAgeExclude` as `Vec<String>` only.

## Issue Context
This PR intentionally improves robustness for configs that can arrive as a single string (e.g., YAML scalar / env var). To keep pnpm TypeScript and pacquet Rust behavior in sync, Rust should accept the same inputs (or the PR description must explicitly call out the known divergence).

## Fix Focus Areas
- pnpm11/config/version-policy/src/index.ts[6-19]
- pnpm/crates/config/src/workspace_yaml.rs[96-110]
- pnpm/crates/config/src/workspace_yaml.rs[449-455]

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



Informational

2. Historical comment in test ✓ Resolved 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The new test comment describes the previous bug behavior (character-by-character iteration) instead
of stating the current behavior/contract. This makes the comment stale-prone and violates the
no-historical-comments guideline.
Code

pnpm11/pnpm/test/install/misc.ts[R697-699]

+  // A scalar is a legal spelling for this setting, so it has to be read as a
+  // one-entry list. Read character by character it matches nothing, and the
+  // downgrade the user meant to allow fails the install.
Relevance

● Weak

Similar “comment drift / historical narration in tests” suggestion was rejected in pnpm tests
recently.

PR-#13770

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The comment at pnpm11/pnpm/test/install/misc.ts[697-699] uses historical phrasing ("Read character
by character") to describe prior behavior. PR Compliance ID 772199 prohibits
historical-implementation comments and requires comments to describe current behavior.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm11/pnpm/test/install/misc.ts[697-699]

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

## Issue description
A newly added inline comment explains historical behavior ("Read character by character...") rather than the current behavior/contract. Comments should describe the current code behavior and intent, not past implementations.

## Issue Context
This is a regression test for reading `trustPolicyExclude` from `pnpm-workspace.yaml` when provided as a scalar. The comment should explain the present expectation (scalar treated as a one-entry list) without referencing the old, removed behavior.

## Fix Focus Areas
- pnpm11/pnpm/test/install/misc.ts[697-699]

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


3. Lockfile rewrite too strict 🐞 Bug ☼ Reliability
Description
The new test helper prefixLockfileKeyWithSlash() throws unless the target depPath exists in both
lockfile.packages and lockfile.snapshots, even though lockfile file types allow either section
to be absent. This makes the new regression tests brittle against valid lockfile variants
(deterministically failing if one section is missing).
Code

pnpm11/pnpm/test/install/misc.ts[R802-805]

+  for (const section of [lockfile.packages, lockfile.snapshots]) {
+    if (section?.[depPath] == null) {
+      throw new Error(`${depPath} is missing from the lockfile`)
+    }
Relevance

●●● Strong

Brittle test helper; tightening to allow optional lockfile sections is a low-risk reliability fix.

PR-#12786

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper currently throws when either packages or snapshots is absent. The lockfile file type
definitions mark both sections optional, so this helper can reject a lockfile shape the codebase
considers valid.

pnpm11/pnpm/test/install/misc.ts[798-808]
pnpm11/lockfile/types/src/lockfileFileTypes.ts[3-7]

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

### Issue description
`prefixLockfileKeyWithSlash()` currently iterates over `[lockfile.packages, lockfile.snapshots]` and throws when `section?.[depPath] == null`. If either section is `undefined` (which is a permitted lockfile shape), the helper throws even if the depPath exists in the other section.

### Issue Context
This is test-only code, but it can make the newly added regression tests fragile if the generated lockfile (now or in future versions) only contains one of these sections.

### Fix Focus Areas
- pnpm11/pnpm/test/install/misc.ts[798-817]

### Suggested fix
- Track whether the key was rewritten in at least one existing section.
- Only throw if the key is missing from *all* existing sections.

Example approach:
```ts
let found = false
for (const section of [lockfile.packages, lockfile.snapshots]) {
 if (section == null) continue
 if (section[depPath] == null) continue
 section[prefixed] = section[depPath]
 delete section[depPath]
 found = true
}
if (!found) throw new Error(`${depPath} is missing from the lockfile`)
```

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


4. Avoidable substring in depPath parse ✓ Resolved 🐞 Bug ➹ Performance
Description
@pnpm/deps.path's parse() now materializes an intermediate cleanDependencyPath string for
slash-prefixed depPaths, adding extra per-call work on a hot path used across lockfile verification
and other install-time loops. This is likely small per entry but can add up on large lockfiles.
Code

pnpm11/deps/path/src/index.ts[R194-195]

+  const cleanDependencyPath = dependencyPath[0] === '/' ? dependencyPath.substring(1) : dependencyPath
+  const sepIndex = cleanDependencyPath.indexOf('@', 1)
Relevance

● Weak

Team often rejects micro-optimizations removing small per-call allocations without stronger
evidence/need.

PR-#13698

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces the intermediate cleanDependencyPath substring in parse(). parse() is then
used transitively by lockfile verification logic that iterates over all lockfile.packages entries
(potentially thousands), so the additional per-entry work can affect install-time performance.

pnpm11/deps/path/src/index.ts[182-205]
pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]
pnpm11/installing/deps-installer/src/install/verifyLockfileResolutions.ts[381-408]
pnpm11/building/policy/src/index.ts[41-55]

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

### Issue description
`parse()` creates `cleanDependencyPath` via `substring(1)` when the depPath starts with `/`. This introduces avoidable extra work per call.

### Issue Context
`parse()` is called repeatedly in lockfile verification / resolution paths, so even small overhead can accumulate on projects with many packages.

### Fix Focus Areas
- pnpm11/deps/path/src/index.ts[190-205]

### Suggested fix
Avoid creating `cleanDependencyPath`; instead compute an integer `start = dependencyPath[0] === '/' ? 1 : 0` and perform `indexOf`/`substring` directly against `dependencyPath` using that offset:
- `const sepIndex = dependencyPath.indexOf('@', start + 1)`
- `const name = dependencyPath.substring(start, sepIndex)`
- `let version = dependencyPath.substring(sepIndex + 1)`

Preserve the existing behavior for doubled slashes (only one leading slash treated as legacy spelling) and keep the rest of the suffix parsing unchanged.

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


View low (1)
5. createPackageVersionPolicy before first use 📘 Rule violation ⚙ Maintainability
Description
createPackageVersionPolicy() is declared before its first usage in the same file (it is first
called by createPackageVersionPolicyOrThrow). This violates the rule requiring top-level
TypeScript function declarations to appear only after their first usage.
Code

pnpm11/config/version-policy/src/index.ts[16]

+export function createPackageVersionPolicy (patterns: string[] | string): PackageVersionPolicy {
Relevance

● Weak

Similar function-declaration ordering rule was previously rejected by reviewers.

PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713432 requires top-level TypeScript function declarations to be declared only
after their first usage in the same file. Here, createPackageVersionPolicy is declared at line 16,
but its first usage is the call inside createPackageVersionPolicyOrThrow at line 33, which appears
after the declaration.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/config/version-policy/src/index.ts[16-24]
pnpm11/config/version-policy/src/index.ts[31-34]

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

## Issue description
In `pnpm11/config/version-policy/src/index.ts`, the exported function declaration `createPackageVersionPolicy()` appears before its first call site in the same file, which violates the local style rule.

## Issue Context
`createPackageVersionPolicyOrThrow()` calls `createPackageVersionPolicy()` later in the file, making that call the first usage.

## Fix Focus Areas
- pnpm11/config/version-policy/src/index.ts[16-34]

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


Grey Divider

Context
✅ Compliance rules (platform): 18 rules

Grey Divider

Tip of the day
💡 Did you know, you can route each action level your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous review results

Review updated until commit 2f0e1ba

Results up to commit 87c8aa1 ⚖️ Balanced


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


Informational
1. Avoidable substring in depPath parse ✓ Resolved 🐞 Bug ➹ Performance
Description
@pnpm/deps.path's parse() now materializes an intermediate cleanDependencyPath string for
slash-prefixed depPaths, adding extra per-call work on a hot path used across lockfile verification
and other install-time loops. This is likely small per entry but can add up on large lockfiles.
Code

pnpm11/deps/path/src/index.ts[R194-195]

+  const cleanDependencyPath = dependencyPath[0] === '/' ? dependencyPath.substring(1) : dependencyPath
+  const sepIndex = cleanDependencyPath.indexOf('@', 1)
Relevance

● Weak

Team often rejects micro-optimizations removing small per-call allocations without stronger
evidence/need.

PR-#13698

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR introduces the intermediate cleanDependencyPath substring in parse(). parse() is then
used transitively by lockfile verification logic that iterates over all lockfile.packages entries
(potentially thousands), so the additional per-entry work can affect install-time performance.

pnpm11/deps/path/src/index.ts[182-205]
pnpm11/lockfile/utils/src/nameVerFromPkgSnapshot.ts[14-25]
pnpm11/installing/deps-installer/src/install/verifyLockfileResolutions.ts[381-408]
pnpm11/building/policy/src/index.ts[41-55]

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

### Issue description
`parse()` creates `cleanDependencyPath` via `substring(1)` when the depPath starts with `/`. This introduces avoidable extra work per call.

### Issue Context
`parse()` is called repeatedly in lockfile verification / resolution paths, so even small overhead can accumulate on projects with many packages.

### Fix Focus Areas
- pnpm11/deps/path/src/index.ts[190-205]

### Suggested fix
Avoid creating `cleanDependencyPath`; instead compute an integer `start = dependencyPath[0] === '/' ? 1 : 0` and perform `indexOf`/`substring` directly against `dependencyPath` using that offset:
- `const sepIndex = dependencyPath.indexOf('@', start + 1)`
- `const name = dependencyPath.substring(start, sepIndex)`
- `let version = dependencyPath.substring(sepIndex + 1)`

Preserve the existing behavior for doubled slashes (only one leading slash treated as legacy spelling) and keep the rest of the suffix parsing unchanged.

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


2. createPackageVersionPolicy before first use 📘 Rule violation ⚙ Maintainability
Description
createPackageVersionPolicy() is declared before its first usage in the same file (it is first
called by createPackageVersionPolicyOrThrow). This violates the rule requiring top-level
TypeScript function declarations to appear only after their first usage.
Code

pnpm11/config/version-policy/src/index.ts[16]

+export function createPackageVersionPolicy (patterns: string[] | string): PackageVersionPolicy {
Relevance

● Weak

Similar function-declaration ordering rule was previously rejected by reviewers.

PR-#13792

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713432 requires top-level TypeScript function declarations to be declared only
after their first usage in the same file. Here, createPackageVersionPolicy is declared at line 16,
but its first usage is the call inside createPackageVersionPolicyOrThrow at line 33, which appears
after the declaration.

Rule 713432: Declare TypeScript functions only after their first usage
pnpm11/config/version-policy/src/index.ts[16-24]
pnpm11/config/version-policy/src/index.ts[31-34]

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

## Issue description
In `pnpm11/config/version-policy/src/index.ts`, the exported function declaration `createPackageVersionPolicy()` appears before its first call site in the same file, which violates the local style rule.

## Issue Context
`createPackageVersionPolicyOrThrow()` calls `createPackageVersionPolicy()` later in the file, making that call the first usage.

## Fix Focus Areas
- pnpm11/config/version-policy/src/index.ts[16-34]

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


Results up to commit 05502b6 ⚖️ Balanced


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


Remediation recommended
1. trustPolicyExclude string unsupported in Rust 📘 Rule violation ⌂ Architecture
Description
TypeScript now accepts trustPolicyExclude/minimumReleaseAgeExclude as either a string or
string-array, but the Rust WorkspaceSettings still requires YAML arrays for these fields. This
creates a user-visible divergence where the same config works in pnpm TypeScript but fails (or is
ignored) in pacquet Rust without any call-out in the PR description.
Code

pnpm11/config/version-policy/src/index.ts[R18-19]

+  const patternList = typeof patterns === 'string' ? [patterns] : patterns
+  for (const pattern of patternList) {
Relevance

●●● Strong

Team often enforces TS↔Rust parity for user-visible behavior; PR intent claims robustness on both
sides.

PR-#12789
PR-#12153

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713428 requires user-visible behavior changes to be kept in sync between pnpm
TypeScript and pacquet Rust (or explicitly called out). The TypeScript change explicitly accepts
string | string[], while Rust still models the corresponding workspace-yaml keys as
Option<Vec<String>> without a deserializer that would accept a scalar string.

Rule 713428: Keep pnpm TypeScript and pacquet Rust user-visible behavior changes in sync
pnpm11/config/version-policy/src/index.ts[6-19]
pnpm/crates/config/src/workspace_yaml.rs[96-110]
pnpm/crates/config/src/workspace_yaml.rs[449-455]

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

## Issue description
TypeScript `createPackageVersionPolicy` now normalizes a lone string config value into a single-element array, but the Rust workspace YAML/config structs still deserialize `trustPolicyExclude`/`minimumReleaseAgeExclude` as `Vec<String>` only.

## Issue Context
This PR intentionally improves robustness for configs that can arrive as a single string (e.g., YAML scalar / env var). To keep pnpm TypeScript and pacquet Rust behavior in sync, Rust should accept the same inputs (or the PR description must explicitly call out the known divergence).

## Fix Focus Areas
- pnpm11/config/version-policy/src/index.ts[6-19]
- pnpm/crates/config/src/workspace_yaml.rs[96-110]
- pnpm/crates/config/src/workspace_yaml.rs[449-455]

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



Informational
2. Lockfile rewrite too strict 🐞 Bug ☼ Reliability
Description
The new test helper prefixLockfileKeyWithSlash() throws unless the target depPath exists in both
lockfile.packages and lockfile.snapshots, even though lockfile file types allow either section
to be absent. This makes the new regression tests brittle against valid lockfile variants
(deterministically failing if one section is missing).
Code

pnpm11/pnpm/test/install/misc.ts[R802-805]

+  for (const section of [lockfile.packages, lockfile.snapshots]) {
+    if (section?.[depPath] == null) {
+      throw new Error(`${depPath} is missing from the lockfile`)
+    }
Relevance

●●● Strong

Brittle test helper; tightening to allow optional lockfile sections is a low-risk reliability fix.

PR-#12786

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The helper currently throws when either packages or snapshots is absent. The lockfile file type
definitions mark both sections optional, so this helper can reject a lockfile shape the codebase
considers valid.

pnpm11/pnpm/test/install/misc.ts[798-808]
pnpm11/lockfile/types/src/lockfileFileTypes.ts[3-7]

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

### Issue description
`prefixLockfileKeyWithSlash()` currently iterates over `[lockfile.packages, lockfile.snapshots]` and throws when `section?.[depPath] == null`. If either section is `undefined` (which is a permitted lockfile shape), the helper throws even if the depPath exists in the other section.

### Issue Context
This is test-only code, but it can make the newly added regression tests fragile if the generated lockfile (now or in future versions) only contains one of these sections.

### Fix Focus Areas
- pnpm11/pnpm/test/install/misc.ts[798-817]

### Suggested fix
- Track whether the key was rewritten in at least one existing section.
- Only throw if the key is missing from *all* existing sections.

Example approach:
```ts
let found = false
for (const section of [lockfile.packages, lockfile.snapshots]) {
 if (section == null) continue
 if (section[depPath] == null) continue
 section[prefixed] = section[depPath]
 delete section[depPath]
 found = true
}
if (!found) throw new Error(`${depPath} is missing from the lockfile`)
```

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


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 force-pushed the resolve-pnpm-issue-13721 branch from 87c8aa1 to 05502b6 Compare August 12, 2026 07:06
@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 07:06

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 05502b6

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

@greptile-apps
greptile-apps Bot dismissed their stale review August 12, 2026 07:23

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

@zkochan zkochan changed the title fix: support leading slashes in trustPolicyExclude lockfile keys fix: read a single-string trustPolicyExclude/minimumReleaseAgeExclude as a one-entry list Aug 12, 2026
greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 12, 2026
@qodo-code-review

Copy link
Copy Markdown

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

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

Ayush442842q and others added 6 commits August 17, 2026 02:38
Support leading slashes in lockfile package keys for trustPolicyExclude and
normalize single-string values to array in config. Resolves pnpm#13721.
Review follow-up on the leading-slash handling.

On the Rust side the strip lived in `PkgName::parse`, which is the
alias/package-name type rather than the dep-path parser. A lockfile
alias `/foo` was therefore normalized to `foo` and sailed through
`verify_lockfile_dependency_names`, while the TypeScript CLI rejects
the same alias via `isValidDependencyAlias`. Moving it into
`PkgNameSuffix::from_str` — the counterpart of the TypeScript `parse` —
restores that rejection and keeps the scoped-name path allocation-free.

Both stacks drop the `//` carve-out: nothing has ever given a doubled
slash a meaning, and `depPathToFilenameUnescaped` (TypeScript) and
`dep_path_to_filename` (Rust) already strip exactly one leading slash
unconditionally, so the parsers now agree with them.

Tests: add the missing unit coverage in `@pnpm/deps.path` and
`pacquet-lockfile`, and rebuild the end-to-end regression around
`--frozen-lockfile`. Under `--lockfile-only` it re-resolved and never
reached the lockfile verifier, and its guarded lockfile rewrite passed
silently whenever the key was absent.

Also document why a lone string is accepted for the exclude settings,
and revert the unrelated `pnpm-lock.yaml` churn.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The end-to-end regression also installed the slash-prefixed lockfile
with a matching `trustPolicyExclude` and expected success. Verification
does pass — the entry is recognized and excluded — but linking then
fails with `ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY`, because the packages
map is still keyed by the literal `/name@version` string while the
walker looks the entry up under its parsed name. That is independent of
this change: the same install fails the same way with the parser fix
backed out.

Locally the assertion only held when earlier tests in the file had
already warmed the project, so it passed here and failed on CI.

Keep the half that proves the fix — the trust check has to fire on the
slash-keyed entry under its real name — and drop the unsupported half.

Also add the patch-hash key case CodeRabbit asked for, so the Rust
regression covers the same shapes as the TypeScript one.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
A `/name@version` key is the lockfile format 6 spelling, and pnpm has
not read a format 6 lockfile since the version gate moved to major 9:
both entry points in readLockfiles.ts pass `wantedVersions:
[LOCKFILE_VERSION]`, and a lower major is rejected with
ERR_PNPM_LOCKFILE_BREAKING_CHANGE before any key is parsed. Such a key
can only reach the parser inside a file labelled version 9 that was
hand-edited or mangled, and the rest of the install pipeline still
treats it as a distinct literal string — so normalizing it in the
parser alone made the verifier report a clean bill of health for an
entry the installer then could not find.

Leaving those keys malformed everywhere is the behavior pnpm already
has. The vestigial slash handling elsewhere in the module
(`depPathToFilenameUnescaped`, `createPeerDepGraphHash`, `isAbsolute`)
is format 6 residue of the same kind and is being tracked separately.

This also drops the end-to-end trust-policy tests added alongside the
parser change; the exclusion paths they covered already have
equivalent coverage.

What remains is the config fix: `trustPolicyExclude` and
`minimumReleaseAgeExclude` set to a single string are read as a
one-entry list instead of character by character.

Reopens the question of what actually caused
pnpm#13721.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`.npmrc` is not one of the sources. `isNpmrcReadableKey` admits only
scoped keys, `//`-prefixed keys, the npm auth settings, and six
proxy/network keys, so `trust-policy-exclude` never reaches the merged
npmrc config.

The values that do arrive as a bare string come from a YAML scalar in
pnpm-workspace.yaml or the global config.yaml, and from a
`PNPM_CONFIG_*` env var, where the `[String, Array]` schema falls back
to String after the JSON-array parse fails.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@greptile-apps
greptile-apps Bot dismissed their stale review August 17, 2026 00:38

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

greptile-apps[bot]
greptile-apps Bot previously approved these changes Aug 17, 2026
@qodo-code-review

Copy link
Copy Markdown

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

@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 force-pushed the resolve-pnpm-issue-13721 branch from ba8810f to aa44d6b Compare August 17, 2026 00:41
@qodo-code-review

Copy link
Copy Markdown

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

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

The doc comment restated the function's name and signature, walked
through the env parser's type-union fallback, and then described what
the loop would do to a string. The unit test pins that behavior and the
changeset carries the user-facing consequence; what a reader cannot
recover from the code is only why the parameter admits a bare string.

The comment in the end-to-end test restated the test name and its
assertion, so it goes entirely.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@greptile-apps
greptile-apps Bot dismissed their stale review August 17, 2026 00:46

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2f0e1ba

@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 merged commit 366c0ad into pnpm:main Aug 17, 2026
30 checks passed
@Ayush442842q
Ayush442842q deleted the resolve-pnpm-issue-13721 branch August 22, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trustPolicyExclude does not prevent ERR_PNPM_TRUST_DOWNGRADE for excluded package

3 participants