Skip to content

fix(install): prune obsolete children during forced installs - #15096

Merged
zkochan merged 2 commits into
mainfrom
fix-15039
Sep 19, 2026
Merged

zkochan merged 2 commits into
mainfrom
fix-15039

Conversation

@zkochan

@zkochan zkochan commented Sep 19, 2026 •

Copy link
Copy Markdown
Member

Summary

pnpm install --force now removes child symlinks that a package no longer declares. This covers pnpm v11 and v12, both after fresh resolution and when installing a lockfile updated with --lockfile-only.

Validation: reproduced the stale links before the fix in both versions. Passed the v11 relinking suite and forced headless-install test, 29 Rust repeat-install tests, and 1,618 tests across pnpm-lockfile, pnpm-deps-restorer, and pnpm-package-manager. The expanded regression, 23 Rust smoke tests, workspace type checks, lint, formatting, and spelling checks also passed.

Closes #15039.

Cleanup validates prior dependency aliases with the existing package-name validator before joining paths. A regression confirms malformed aliases cannot follow a dependency symlink and unlink an entry outside its slot. The Rust force-install regression runs on all platforms.

Squash Commit Body

Keep the previous install's lockfile entries available under --force in
pnpm v12. Snapshot reuse and slot replacement already gate on the force
flag, while child-link cleanup needs the previous dependency records.

In v11, pass the current lockfile to headless child-link cleanup regardless
of incremental relinking, and compute obsolete aliases for packages selected
for re-import by the resolving installer. Reuse the existing dependency-diff
and removal helpers, preserving full relinking during forced installs.

Add matching regressions for fresh and frozen installs in both versions,
including ordinary and scoped optional child links. Assert the links are
absent even when their targets have been pruned, and that the package and
its remaining dependency are still installed.

Closes pnpm/pnpm#15039.

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.
  • Updated the documentation if needed.

Written by an agent (Codex, GPT-6).

Summary by CodeRabbit

  • Bug Fixes
    • pnpm install --force now removes obsolete dependency links when package dependencies change.
    • Forced installs consistently clean up outdated child links in both frozen and non-frozen lockfile modes.
    • Invalid dependency names are ignored during obsolete-link cleanup, preventing unsafe path traversal.
    • Existing packages and valid dependency links are preserved during cleanup.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: pnpm/pnpm/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 91807f98-8e26-43a2-9e66-c2ae3d439a86

📥 Commits

Reviewing files that changed from the base of the PR and between 26def94 and 420af24.

📒 Files selected for processing (5)
  • .changeset/fix-forced-child-links.md
  • pnpm/crates/cli/tests/suite/forced_install.rs
  • pnpm/crates/cli/tests/suite/main.rs
  • pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs
  • pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot/tests.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/fix-forced-child-links.md

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


📝 Walkthrough

Walkthrough

Forced installs now retain previous lockfile entries, compute obsolete child aliases, and remove those aliases from virtual-store packages. Cleanup safely ignores invalid dependency names. Tests cover forced installs with frozen and non-frozen lockfiles.

Changes

Forced child-link cleanup

Layer / File(s) Summary
Preserve previous snapshot entries
pnpm/crates/lockfile/src/lib.rs, pnpm/crates/package-manager/..., pnpm/crates/deps-restorer/...
Previous lockfile entries are retained during forced installs. Reuse behavior and force-replacement tests now reflect this data flow.
Remove obsolete child links
pnpm11/installing/deps-restorer/src/index.ts, pnpm11/installing/deps-installer/src/install/link.ts, pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs
The linking path computes removed child aliases for newly linked packages, disables changed-only filtering during force mode, excludes self-aliases, and safely skips invalid aliases.
Validate and publish the behavior
pnpm/crates/cli/tests/suite/forced_install.rs, pnpm11/installing/deps-installer/test/install/relinkingScope.test.ts, .changeset/fix-forced-child-links.md
Tests cover frozen and non-frozen forced installs and verify that obsolete links are removed while valid links remain. The changeset declares patch releases for affected packages.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant Install
  participant linkAllModules
  participant VirtualStore
  User->>Install: run install --force
  Install->>linkAllModules: pass current lockfile and package link jobs
  linkAllModules->>VirtualStore: remove obsolete child aliases
  VirtualStore-->>User: retain valid package and child links
Loading

Assessment against linked issues

Objective Addressed Explanation
Remove obsolete child symlinks from virtual-store slots during pnpm install --force when dependency snapshots shrink [#15039] ✅

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

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

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 19, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.03     13.5±0.18ms    27.7 MB/sec    1.00     13.1±0.04ms    28.7 MB/sec
packument/parse                                  1.04     43.3±0.15µs  1532.1 MB/sec    1.00     41.7±0.36µs  1589.7 MB/sec
tarball/download_dependency                      1.02      4.5±0.09ms   974.2 KB/sec    1.00      4.3±0.10ms   997.8 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    225.1±1.45ms 71.1 KElem/sec    1.01    226.6±2.12ms 70.6 KElem/sec
workspace_resolution/hoist_heavy                 1.00    272.4±4.57ms        ? ?/sec    1.00    273.1±1.90ms        ? ?/sec
workspace_sort/chained_projects                  1.00     18.5±1.22ms        ? ?/sec    1.03     19.1±0.54ms        ? ?/sec

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 420af24f2ac3

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 thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time).

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.347 ± 0.133 2.227 2.606 1.67 ± 0.18
pacquet@main 2.393 ± 0.134 2.211 2.565 1.70 ± 0.19
pnpr@HEAD 1.409 ± 0.134 1.287 1.614 1.00
pnpr@main 1.451 ± 0.123 1.294 1.642 1.03 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.3466906319799996,
      "stddev": 0.13251949803384896,
      "median": 2.28953722418,
      "user": 1.3389074399999998,
      "system": 1.36864282,
      "min": 2.22655627818,
      "max": 2.60615435418
    },
    {
      "command": "pacquet@main",
      "mean": 2.39306698078,
      "stddev": 0.13429212756127112,
      "median": 2.39855013968,
      "user": 1.2961275399999999,
      "system": 1.33223782,
      "min": 2.21074800218,
      "max": 2.56471567418
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.40871615568,
      "stddev": 0.13352559847686868,
      "median": 1.35205382018,
      "user": 1.2185623399999999,
      "system": 1.22504942,
      "min": 1.2870229831800002,
      "max": 1.6142260801800001
    },
    {
      "command": "pnpr@main",
      "mean": 1.45110565748,
      "stddev": 0.12291851757232117,
      "median": 1.43635048618,
      "user": 1.3420851399999998,
      "system": 1.34218642,
      "min": 1.29444448518,
      "max": 1.6421526021800001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 220.3 ± 18.2 197.4 245.7 1.03 ± 0.10
pacquet@main 213.9 ± 9.0 203.4 232.3 1.00
pnpr@HEAD 228.3 ± 6.0 219.1 238.9 1.07 ± 0.05
pnpr@main 224.4 ± 4.9 217.4 231.0 1.05 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2203080473,
      "stddev": 0.018212467141495735,
      "median": 0.2156364616,
      "user": 0.24493834000000003,
      "system": 0.53635342,
      "min": 0.1973931381,
      "max": 0.2457485611
    },
    {
      "command": "pacquet@main",
      "mean": 0.21392329400000004,
      "stddev": 0.008999077237282035,
      "median": 0.2111347866,
      "user": 0.24403194,
      "system": 0.52515842,
      "min": 0.20338119710000002,
      "max": 0.23226449810000002
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.22827846420000003,
      "stddev": 0.005974139105973,
      "median": 0.22787827910000003,
      "user": 0.24177594,
      "system": 0.5395177199999999,
      "min": 0.2190525241,
      "max": 0.23887661910000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.22436315590000003,
      "stddev": 0.0049388385379544215,
      "median": 0.22547109410000002,
      "user": 0.23634413999999998,
      "system": 0.51739942,
      "min": 0.21741835810000001,
      "max": 0.23097184610000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 6.8 ± 0.6 5.9 9.6 1.06 ± 0.12
pacquet@main 6.4 ± 0.5 5.7 8.6 1.00
pnpr@HEAD 7.1 ± 0.4 6.3 8.6 1.10 ± 0.11
pnpr@main 7.0 ± 0.4 6.1 10.4 1.08 ± 0.11
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.0068332743425737336,
      "stddev": 0.0005888385337134623,
      "median": 0.006693589860000001,
      "user": 0.004036357479892762,
      "system": 0.003184445576407508,
      "min": 0.0059133638600000005,
      "max": 0.00956061386
    },
    {
      "command": "pacquet@main",
      "mean": 0.006433210530129874,
      "stddev": 0.0004963493917897081,
      "median": 0.00632631986,
      "user": 0.0036968215584415585,
      "system": 0.0031164701298701286,
      "min": 0.005685473860000001,
      "max": 0.00863584486
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.007060237266528191,
      "stddev": 0.00041190956023370043,
      "median": 0.007007150860000001,
      "user": 0.004261556261127594,
      "system": 0.003219503857566767,
      "min": 0.006255607860000001,
      "max": 0.008566262860000002
    },
    {
      "command": "pnpr@main",
      "mean": 0.006970025220613812,
      "stddev": 0.0004419841462983166,
      "median": 0.006918673860000001,
      "user": 0.004554776930946291,
      "system": 0.002812784654731456,
      "min": 0.00606521786,
      "max": 0.010386197860000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 6.8 ± 0.9 5.9 13.2 1.00
pacquet@main 7.5 ± 0.9 5.9 11.9 1.09 ± 0.19
pnpr@HEAD 7.8 ± 1.1 6.0 11.2 1.14 ± 0.21
pnpr@main 8.1 ± 1.2 5.9 11.7 1.18 ± 0.23
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.006824136761576763,
      "stddev": 0.0008527115364751416,
      "median": 0.00664096894,
      "user": 0.00404315825726141,
      "system": 0.003160865809128632,
      "min": 0.00590877794,
      "max": 0.01319088894
    },
    {
      "command": "pacquet@main",
      "mean": 0.007455602471772576,
      "stddev": 0.0009086771044759777,
      "median": 0.007258783940000001,
      "user": 0.004439630301003351,
      "system": 0.00344270735785953,
      "min": 0.0058769389400000005,
      "max": 0.01187474594
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.007797026082857138,
      "stddev": 0.0010864073426247141,
      "median": 0.007563770940000001,
      "user": 0.004764901488095233,
      "system": 0.0034625485714285717,
      "min": 0.005950635940000001,
      "max": 0.01123649094
    },
    {
      "command": "pnpr@main",
      "mean": 0.008069291583258427,
      "stddev": 0.001208971038734188,
      "median": 0.00787180794,
      "user": 0.004740475393258425,
      "system": 0.0037670253370786526,
      "min": 0.00588417194,
      "max": 0.01169206394
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.587 ± 0.011 2.575 2.614 1.73 ± 0.12
pacquet@main 2.521 ± 0.093 2.424 2.728 1.68 ± 0.13
pnpr@HEAD 1.524 ± 0.136 1.352 1.693 1.02 ± 0.11
pnpr@main 1.498 ± 0.103 1.383 1.646 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.58711297526,
      "stddev": 0.011381665223400977,
      "median": 2.5840547227600004,
      "user": 2.1652380799999995,
      "system": 1.8898901999999995,
      "min": 2.5749881232600003,
      "max": 2.6137563842600002
    },
    {
      "command": "pacquet@main",
      "mean": 2.52097766826,
      "stddev": 0.09277074515623521,
      "median": 2.50757861276,
      "user": 2.0017145800000002,
      "system": 1.7142153999999998,
      "min": 2.42368125726,
      "max": 2.72789111226
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.52367810846,
      "stddev": 0.13594527675781373,
      "median": 1.52837120376,
      "user": 1.0878498799999998,
      "system": 1.2134265999999998,
      "min": 1.35196390826,
      "max": 1.6928720812599998
    },
    {
      "command": "pnpr@main",
      "mean": 1.4976132226599999,
      "stddev": 0.10326996491062922,
      "median": 1.45009718176,
      "user": 1.04799518,
      "system": 1.2964243999999998,
      "min": 1.38320903526,
      "max": 1.64631212626
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 455.0 ± 14.7 434.2 481.8 1.37 ± 0.05
pacquet@main 596.4 ± 148.2 436.1 798.8 1.80 ± 0.45
pnpr@HEAD 337.1 ± 8.5 327.5 351.6 1.02 ± 0.03
pnpr@main 331.6 ± 5.8 324.1 340.4 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.4550414890200001,
      "stddev": 0.014664330947980473,
      "median": 0.45052249962,
      "user": 0.70351356,
      "system": 1.11354216,
      "min": 0.43420158462,
      "max": 0.48180967962000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.59641469222,
      "stddev": 0.1482065975591359,
      "median": 0.59450047762,
      "user": 0.94890936,
      "system": 1.40516386,
      "min": 0.43608291762,
      "max": 0.7988139216200001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33708680561999993,
      "stddev": 0.008490931796824844,
      "median": 0.33600163762,
      "user": 0.31051755999999997,
      "system": 0.71462566,
      "min": 0.32750615462,
      "max": 0.35160569462
    },
    {
      "command": "pnpr@main",
      "mean": 0.33155903452,
      "stddev": 0.005750316308745224,
      "median": 0.33021121162,
      "user": 0.27796916,
      "system": 0.7126678599999999,
      "min": 0.32406507962000003,
      "max": 0.34037817662000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.549 ± 0.021 1.525 1.594 5.71 ± 0.14
pacquet@main 1.580 ± 0.065 1.511 1.673 5.83 ± 0.27
pnpr@HEAD 0.271 ± 0.006 0.266 0.281 1.00
pnpr@main 0.277 ± 0.007 0.264 0.285 1.02 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.5488814886799998,
      "stddev": 0.020523168145792508,
      "median": 1.54489283358,
      "user": 0.8305030600000001,
      "system": 0.8856899999999998,
      "min": 1.52549104808,
      "max": 1.5937194960799999
    },
    {
      "command": "pacquet@main",
      "mean": 1.5804939458799998,
      "stddev": 0.06521098109482139,
      "median": 1.55238993008,
      "user": 0.8846985599999998,
      "system": 0.941016,
      "min": 1.51126189508,
      "max": 1.67295868508
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27116138407999996,
      "stddev": 0.005704621526635891,
      "median": 0.26830969908,
      "user": 0.21294625999999997,
      "system": 0.5250239,
      "min": 0.26576535208,
      "max": 0.28063869708
    },
    {
      "command": "pnpr@main",
      "mean": 0.27682234048,
      "stddev": 0.007022342029350326,
      "median": 0.27825294258,
      "user": 0.21443105999999998,
      "system": 0.5367120000000001,
      "min": 0.26432470708,
      "max": 0.28532293108
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 190.0 ± 10.9 169.8 206.5 2.14 ± 0.13
pacquet@main 194.7 ± 19.8 161.1 228.5 2.19 ± 0.23
pnpr@HEAD 88.8 ± 2.0 84.5 93.7 1.00
pnpr@main 89.4 ± 2.5 84.9 94.0 1.01 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.19000370209428571,
      "stddev": 0.010890634861578895,
      "median": 0.18837825838,
      "user": 0.19717813142857146,
      "system": 0.06135556285714285,
      "min": 0.16980374788000002,
      "max": 0.20648527288000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.19474354541333336,
      "stddev": 0.01975380613671577,
      "median": 0.19612237388,
      "user": 0.18615009333333335,
      "system": 0.06313135333333335,
      "min": 0.16112372088000002,
      "max": 0.22849441288000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.08877645615272726,
      "stddev": 0.0020392146719663035,
      "median": 0.08833963588,
      "user": 0.032714347878787874,
      "system": 0.011761697575757577,
      "min": 0.08450380588,
      "max": 0.09373500588
    },
    {
      "command": "pnpr@main",
      "mean": 0.0894132305251613,
      "stddev": 0.002459379191375967,
      "median": 0.08954179688000001,
      "user": 0.03214362451612903,
      "system": 0.014673710322580644,
      "min": 0.08492101688,
      "max": 0.09404813188000001
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 697.9 ± 55.0 620.6 788.4 1.00 ± 0.09
pacquet@main 695.4 ± 31.0 635.4 731.0 1.00
pnpm@HEAD 3087.4 ± 92.6 2969.0 3206.4 4.44 ± 0.24
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.69787280812,
      "stddev": 0.05503450208477461,
      "median": 0.70026221712,
      "user": 0.7278369911111111,
      "system": 0.15401053999999997,
      "min": 0.62061716712,
      "max": 0.78841795212
    },
    {
      "command": "pacquet@main",
      "mean": 0.6954390392311111,
      "stddev": 0.031029711219893317,
      "median": 0.70910861212,
      "user": 0.7137755466666668,
      "system": 0.14001754,
      "min": 0.63535955912,
      "max": 0.73098818412
    },
    {
      "command": "pnpm@HEAD",
      "mean": 3.0873670953422225,
      "stddev": 0.09261285600305892,
      "median": 3.0755296261200002,
      "user": 4.840494435555555,
      "system": 0.22747998444444445,
      "min": 2.96896441912,
      "max": 3.20639638412
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 159.4 ± 2.9 155.7 166.0 1.02 ± 0.03
pacquet@main 156.7 ± 2.8 153.0 161.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.15939743135555556,
      "stddev": 0.0029023979332126943,
      "median": 0.1588295903,
      "user": 0.11928911111111108,
      "system": 0.07318306,
      "min": 0.1556972788,
      "max": 0.16598644680000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.1566721858,
      "stddev": 0.0028380419658330515,
      "median": 0.15730364530000002,
      "user": 0.11245438888888887,
      "system": 0.07502533777777777,
      "min": 0.1530041728,
      "max": 0.1610943118
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.377 ± 0.109 4.273 4.595 1.26 ± 0.06
pacquet@main 4.353 ± 0.119 4.250 4.600 1.26 ± 0.06
pnpr@HEAD 3.464 ± 0.140 3.353 3.721 1.00
pnpr@main 3.538 ± 0.085 3.425 3.705 1.02 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.377112528940001,
      "stddev": 0.10875391326211159,
      "median": 4.33959232354,
      "user": 1.39008408,
      "system": 1.4599651200000001,
      "min": 4.27298631904,
      "max": 4.59503474304
    },
    {
      "command": "pacquet@main",
      "mean": 4.35297414984,
      "stddev": 0.11910269405297386,
      "median": 4.29019633454,
      "user": 1.29584738,
      "system": 1.4120299199999997,
      "min": 4.24954786804,
      "max": 4.59979874104
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.46354604804,
      "stddev": 0.14001878459003123,
      "median": 3.39929661854,
      "user": 1.32486038,
      "system": 1.46527362,
      "min": 3.3531978810400003,
      "max": 3.72127850204
    },
    {
      "command": "pnpr@main",
      "mean": 3.53830889264,
      "stddev": 0.0852446947696712,
      "median": 3.5068333475399998,
      "user": 1.58123568,
      "system": 1.67415122,
      "min": 3.42541405404,
      "max": 3.70460372204
    }
  ]
}

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 103.6 ± 2.5 99.7 111.4 1.00
pacquet@main 104.7 ± 3.9 97.7 110.7 1.01 ± 0.05
pnpr@HEAD 113.1 ± 3.4 105.7 119.2 1.09 ± 0.04
pnpr@main 112.9 ± 3.4 106.1 118.4 1.09 ± 0.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.10362235544608694,
      "stddev": 0.002490060856882666,
      "median": 0.10354762862,
      "user": 0.12732187478260867,
      "system": 0.1303770417391304,
      "min": 0.09970330662,
      "max": 0.11137407162
    },
    {
      "command": "pacquet@main",
      "mean": 0.10465794318000002,
      "stddev": 0.003947787785562885,
      "median": 0.10415000562,
      "user": 0.12904276,
      "system": 0.12570804000000002,
      "min": 0.09769027862,
      "max": 0.11068070462
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.11311967207833334,
      "stddev": 0.003357380800547783,
      "median": 0.11371027612000001,
      "user": 0.1303493983333333,
      "system": 0.12839343666666667,
      "min": 0.10568725162,
      "max": 0.11918018662
    },
    {
      "command": "pnpr@main",
      "mean": 0.11293739927217394,
      "stddev": 0.0034302373715570473,
      "median": 0.11373704862,
      "user": 0.13026239652173913,
      "system": 0.1318700852173913,
      "min": 0.10605592562,
      "max": 0.11836790862
    }
  ]
}

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/15096
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
99.70 ms
(-20.26%)Baseline: 125.04 ms
150.05 ms
(66.45%)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,574.99 ms
(+2.50%)Baseline: 2,512.23 ms
3,014.68 ms
(85.41%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,525.49 ms
(-3.89%)Baseline: 1,587.19 ms
1,904.63 ms
(80.09%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
434.20 ms
(+10.67%)Baseline: 392.33 ms
470.80 ms
(92.23%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
169.80 ms
(-26.31%)Baseline: 230.43 ms
276.51 ms
(61.41%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,226.56 ms
(-3.10%)Baseline: 2,297.85 ms
2,757.42 ms
(80.75%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,272.99 ms
(-2.21%)Baseline: 4,369.48 ms
5,243.38 ms
(81.49%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
197.39 ms
(-18.10%)Baseline: 241.02 ms
289.22 ms
(68.25%)
isolated-linker.linked-workspace-resolve.hot-cache.offline📈 view plot
🚷 view threshold
155.70 ms
(-15.04%)Baseline: 183.26 ms
219.91 ms
(70.80%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
620.62 ms
(-1.31%)Baseline: 628.87 ms
754.64 ms
(82.24%)
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
🚷 view threshold
5.91 ms
(-13.69%)Baseline: 6.85 ms
8.21 ms
(71.93%)
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
🚷 view threshold
5.91 ms
(-17.54%)Baseline: 7.17 ms
8.61 ms
(68.72%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/15096
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

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

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
gvs-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
105.69 ms
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,351.96 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
265.77 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
327.51 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
84.50 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,287.02 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,353.20 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
219.05 ms
isolated-linker.repeat-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
5.95 ms
isolated-linker.repeat-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
6.26 ms
🐰 View full continuous benchmarking report in Bencher

@codecov-commenter

codecov-commenter commented Sep 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.24%. Comparing base (b109487) to head (420af24).

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #15096   +/-   ##
=======================================
  Coverage   91.24%   91.24%           
=======================================
  Files        1343     1343           
  Lines      180091   180085    -6     
=======================================
- Hits       164325   164320    -5     
+ Misses      15766    15765    -1     

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

@zkochan
zkochan marked this pull request as ready for review September 19, 2026 01:33
@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Prune obsolete child links during forced installs

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Prunes obsolete virtual-store child links during forced installs in pnpm v11 and v12.
• Preserves prior lockfile records while force still mandates package re-materialization.
• Adds fresh/frozen regressions and command-shim signature compatibility updates.
Diagram

graph TD
  A["Force install"] --> B["Install planner"] -->|"v11"| C["v11 installer"] --> E["Child dependency diff"] --> F["Stale-link removal"] --> G["Virtual store"]
  B -->|"v12"| D["v12 restorer"] --> E
  H["Previous lockfile"] --> C
  H --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Separate cleanup and reuse lockfile views
  • ➕ Makes the distinct cleanup and package-reuse semantics explicit in the type system.
  • ➕ Reduces the chance that future consumers accidentally reuse packages under force.
  • ➖ Duplicates lockfile views and increases plumbing across both materialization paths.
  • ➖ Adds complexity without changing the underlying source data.
2. Reconcile links from the filesystem
  • ➕ Could remove stale links even when previous lockfile metadata is unavailable.
  • ➕ Avoids coupling cleanup directly to historical dependency records.
  • ➖ Requires additional directory traversal and link inspection for every affected package.
  • ➖ Risks deleting nonstandard links and complicates alias-to-package validation.

Recommendation: Keep the PR's approach: retain previous lockfile entries as factual cleanup input and enforce force behavior explicitly in reuse and replacement policies. This reuses existing dependency-diff and removal helpers, avoids filesystem-wide reconciliation, and keeps forced re-materialization intact; targeted tests guard the main risk of consumers mistakenly treating retained records as reusable state.

Files changed (15) +151 / -60

Bug fix (5) +28 / -35
lib.rsRetain previous lockfile entries during forced installs +5/-22

Retain previous lockfile entries during forced installs

• Removes force-based suppression from 'of_previous_install', so it always exposes available prior entries. Consumers now decide reuse policy explicitly while cleanup can compare dependency records.

pnpm/crates/lockfile/src/lib.rs

frozen.rsPass prior entries through frozen materialization +1/-4

Pass prior entries through frozen materialization

• Updates the frozen-install call site for the force-independent previous-entry API, preserving prior dependency records during forced installs.

pnpm/crates/package-manager/src/install/materialize/frozen.rs

on_disk.rsPass prior entries through fresh materialization +1/-4

Pass prior entries through fresh materialization

• Updates fresh-resolution materialization to retain the preceding install's lockfile entries regardless of force mode.

pnpm/crates/package-manager/src/install_with_fresh_lockfile/on_disk.rs

link.tsPrune removed children from re-imported v11 packages +14/-1

Prune removed children from re-imported v11 packages

• Computes removed dependency aliases for packages selected for re-import by comparing current and wanted snapshots. Passes those aliases into existing link cleanup while excluding the package's self-link.

pnpm11/installing/deps-installer/src/install/link.ts

index.tsSeparate v11 cleanup records from relinking policy +7/-4

Separate v11 cleanup records from relinking policy

• Always passes the current lockfile into headless child-link comparison while disabling incremental relinking under force. Forced installs still relink all children, remove obsolete aliases, and protect package self-links.

pnpm11/installing/deps-restorer/src/index.ts

Tests (5) +108 / -10
repeat_install.rsCover forced child-link cleanup in pnpm v12 +71/-0

Cover forced child-link cleanup in pnpm v12

• Adds a Rust integration regression for fresh-resolution and frozen-lockfile installs. It verifies ordinary and scoped optional stale links disappear while the package and its retained child remain installed.

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

security.rsUpdate security tests for relocatable shim helpers +3/-3

Update security tests for relocatable shim helpers

• Passes the new optional generation argument and shim path required by current command-shim helper signatures. This restores test compilation without changing production behavior.

pnpm/crates/cmd-shim/src/link_bins/tests/security.rs

tests.rsUpdate shell-shim generator invocation +1/-1

Update shell-shim generator invocation

• Supplies the newly required optional argument to the shell-shim generator test call.

pnpm/crates/cmd-shim/src/shim/tests.rs

slot_reuse.rsVerify force replaces slots with retained records +7/-6

Verify force replaces slots with retained records

• Expands slot-reuse coverage to prove force replaces unchanged packages both with and without previous metadata records.

pnpm/crates/deps-restorer/src/create_virtual_store/tests/slot_reuse.rs

relinkingScope.test.tsCover forced child-link cleanup in pnpm v11 +26/-0

Cover forced child-link cleanup in pnpm v11

• Adds fresh and frozen regressions for obsolete package-extension links. The test confirms stale ordinary and scoped links are removed without deleting the package or retained dependency.

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

Documentation (5) +15 / -15
fix-forced-child-links.mdDocument forced-install child-link cleanup +8/-0

Document forced-install child-link cleanup

• Adds patch release notes for the affected installer, restorer, pnpm, and pacquet packages. Explains that forced installs now remove obsolete virtual-store dependency links.

.changeset/fix-forced-child-links.md

create_virtual_store.rsClarify previous entries remain available under force +2/-5

Clarify previous entries remain available under force

• Updates field documentation to state that previous lockfile entries support child-link cleanup as well as reuse decisions, including forced installs.

pnpm/crates/deps-restorer/src/create_virtual_store.rs

cache_keys.rsClarify explicit forced slot replacement +1/-2

Clarify explicit forced slot replacement

• Documents that the force flag replaces slots even when previous package metadata is available and unchanged.

pnpm/crates/deps-restorer/src/create_virtual_store/cache_keys.rs

snapshot_plan.rsClarify force disables snapshot reuse paths +2/-4

Clarify force disables snapshot reuse paths

• Refines the force policy documentation to describe both disabled reuse checks independently of current-entry availability.

pnpm/crates/deps-restorer/src/create_virtual_store/snapshot_plan.rs

frozen_install_options.rsDocument retained entries as cleanup input +2/-4

Document retained entries as cleanup input

• Updates frozen-install input documentation to include child-link cleanup among the consumers of previous lockfile entries.

pnpm/crates/deps-restorer/src/frozen_install_options.rs

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Forced installs unlink unrelated files ✓ Resolved 🐞 Bug ⛨ Security
Description
LockfileEntries::of_previous_install now returns attacker-controlled prior-lockfile aliases during
--force, while remove_obsolete_child protects deletion with only lexical normalization and
accepts PkgName values containing slash and dot segments. With a retained alias such as
foo/../victim and a legitimate foo dependency symlink, filesystem resolution follows foo
before applying .., so cleanup can unlink victim in the symlink target's parent rather than this
package slot.
Code

pnpm/crates/lockfile/src/lib.rs[R253-256]

+    /// Entries recorded by the previous install, including under `--force`.
+    /// Consumers decide whether to reuse packages; cleanup always needs the
+    /// previous dependency records. Empty when no current lockfile exists.
+    pub fn of_previous_install(lockfile: Option<&'a Lockfile>) -> Self {
Relevance

●●● Strong

Recent security precedents accept defenses against symlink escapes and unsafe cleanup through
attacker-controlled filesystem paths.

PR-#14233
PR-#14526
PR-#14772

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed helper now retains prior entries under force. Lockfile aliases deserialize through
PkgName::parse, which accepts any nonempty unscoped string; removed aliases flow directly into
cleanup, where is_subdir is explicitly filesystem-free and therefore cannot account for a
symlinked intermediate component before remove_symlink_dir unlinks the resolved entry.

pnpm/crates/lockfile/src/lib.rs[253-257]
pnpm/crates/lockfile/src/pkg_name.rs[27-44]
pnpm/crates/deps-restorer/src/create_virtual_store.rs[372-394]
pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[389-401]
pnpm/crates/fs/src/is_subdir.rs[5-17]
pnpm/crates/fs/src/symlink_dir.rs[133-140]

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

## Issue description
Forced installs now pass prior-lockfile aliases into obsolete-child cleanup. `PkgName` accepts malformed unscoped aliases such as `foo/../victim`, and lexical normalization cannot prevent the filesystem from resolving the legitimate `foo` dependency symlink before `..`, allowing cleanup to unlink an entry outside the intended package slot.

## Fix Focus Areas
- pnpm/crates/lockfile/src/pkg_name.rs[27-44]
- pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[389-401]
- pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot/tests.rs[435-449]

## Recommended Fix
Reject dependency aliases that are not valid npm package names before they reach filesystem cleanup, matching the pnpm v11 validation behavior. Keep the containment defense and add a regression test with `foo/../victim` plus a symlinked `foo` parent, asserting that the external victim is not removed.

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



Remediation recommended

2. The changeset breaks colon style 📘 Rule violation ✧ Quality ⭐ New
Description
fix-forced-child-links.md embeds https://... in its second sentence, so the protocol colon
neither introduces a list nor an example. The violation surfaces when changeset formatting checks
line 8, even though the release-note wording itself is otherwise valid.
Code

.changeset/fix-forced-child-links.md[8]

+`pnpm install --force` now removes obsolete dependency links inside virtual-store packages when their dependencies change. Invalid dependency names are ignored during obsolete-link cleanup [#15039](https://github.com/pnpm/pnpm/issues/15039).
Evidence
Compliance rule 3058313 permits colons in changesets only when they introduce a list or example.
Line 8 contains a protocol colon in https://github.com/..., which serves neither permitted
purpose.

Rule 3058313: Changeset text formatting conventions
.changeset/fix-forced-child-links.md[8-8]

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

## Issue description
The changeset's Markdown URL contains a colon that does not introduce a list or example, contrary to the changeset text formatting convention.

## Fix Focus Areas
- .changeset/fix-forced-child-links.md[8-8]

## Recommended Fix
Replace the explicit Markdown URL with a colon-free GitHub issue reference such as `pnpm/pnpm#15039`, while preserving the two release-note sentences.

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


3. Windows link cleanup remains untested ✓ Resolved 📜 Skill insight ▣ Testability
Description
forced_install_removes_obsolete_child_links is added to repeat_install.rs, whose entire test
module is disabled by #![cfg(unix)]. The pacquet regression therefore never exercises forced
child-link removal on Windows, where link and path behavior differs from Unix.
Code

pnpm/crates/cli/tests/suite/repeat_install.rs[R931-933]

+#[test]
+fn forced_install_removes_obsolete_child_links() {
+    for frozen in [false, true] {
Relevance

●●● Strong

Recent precedents accept platform-specific coverage and strict symlink regression assertions for
install cleanup.

PR-#13306
PR-#14069

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365308 requires Windows coverage for path and link changes. The new regression
covers the changed symlink cleanup, but the containing module is explicitly compiled only on Unix.

pnpm/crates/cli/tests/suite/repeat_install.rs[8-8]
pnpm/crates/cli/tests/suite/repeat_install.rs[931-1000]
Skill: review-code

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 new pacquet regression for forced child-link cleanup is located in a Unix-only test module, leaving the changed link behavior untested on Windows.

## Fix Focus Areas
- pnpm/crates/cli/tests/suite/repeat_install.rs[931-1000]

## Recommended Fix
Add an equivalent regression in a cross-platform or Windows-specific CLI test module. Set up the stale child links using the appropriate Windows link mechanism, run the forced install, and assert that obsolete links disappear while the package and retained dependency remain installed.

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



Informational

4. Unrelated shim edits widen the fix 📘 Rule violation ⚙ Maintainability
Description
The PR updates four generate_sh_shim and is_shim_pointing_at calls in command-shim tests even
though those calls do not participate in forced install child-link pruning. They address separately
changed helper signatures, so the install fix also modifies an independent security-test subsystem
that must be reviewed and reverted separately.
Code

pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379]

+    let outdated = generate_sh_shim(&target, &shim, None, &[], None)
Relevance

● Weak

The edits are required call-site updates for a separately changed helper API, matching the exact
merged cmd-shim fix.

PR-#15098

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 2255067 requires bug-fix PRs to exclude unrelated changes. The cited command-shim
test edits only adapt calls to different helper signatures and are unrelated to the dependency-link
cleanup implemented elsewhere in the PR.

Rule 2255067: Bug fix changes must not include unrelated refactors or reformatting
pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379-404]
pnpm/crates/cmd-shim/src/shim/tests.rs[848-848]

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 forced-install bug fix includes unrelated command-shim test maintenance caused by separately changed helper signatures.

## Fix Focus Areas
- pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379-404]
- pnpm/crates/cmd-shim/src/shim/tests.rs[848-848]

## Recommended Fix
Remove these command-shim test changes from this bug-fix PR and submit them as a separate focused change. Keep this PR limited to forced-install cleanup behavior, its cross-version implementations, and corresponding regressions.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 63 rules
✅ Skills: review-code
✅ Cross-repo context — repo relationships
Review mode: 🧠 Deep: The push adds substantial, independent behavioral logic across Rust and TypeScript install/link cleanup plus shell-completion parsing and escaping, creating multiple security- and correctness-sensitive paths where redundant review is materially valuable.

Grey Divider

Tip of the day
💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 420af24

Results up to commit 26def94 🧠 Deep


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


Action required
1. Forced installs unlink unrelated files ✓ Resolved 🐞 Bug ⛨ Security
Description
LockfileEntries::of_previous_install now returns attacker-controlled prior-lockfile aliases during
--force, while remove_obsolete_child protects deletion with only lexical normalization and
accepts PkgName values containing slash and dot segments. With a retained alias such as
foo/../victim and a legitimate foo dependency symlink, filesystem resolution follows foo
before applying .., so cleanup can unlink victim in the symlink target's parent rather than this
package slot.
Code

pnpm/crates/lockfile/src/lib.rs[R253-256]

+    /// Entries recorded by the previous install, including under `--force`.
+    /// Consumers decide whether to reuse packages; cleanup always needs the
+    /// previous dependency records. Empty when no current lockfile exists.
+    pub fn of_previous_install(lockfile: Option<&'a Lockfile>) -> Self {
Relevance

●●● Strong

Recent security precedents accept defenses against symlink escapes and unsafe cleanup through
attacker-controlled filesystem paths.

PR-#14233
PR-#14526
PR-#14772

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed helper now retains prior entries under force. Lockfile aliases deserialize through
PkgName::parse, which accepts any nonempty unscoped string; removed aliases flow directly into
cleanup, where is_subdir is explicitly filesystem-free and therefore cannot account for a
symlinked intermediate component before remove_symlink_dir unlinks the resolved entry.

pnpm/crates/lockfile/src/lib.rs[253-257]
pnpm/crates/lockfile/src/pkg_name.rs[27-44]
pnpm/crates/deps-restorer/src/create_virtual_store.rs[372-394]
pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[389-401]
pnpm/crates/fs/src/is_subdir.rs[5-17]
pnpm/crates/fs/src/symlink_dir.rs[133-140]

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

## Issue description
Forced installs now pass prior-lockfile aliases into obsolete-child cleanup. `PkgName` accepts malformed unscoped aliases such as `foo/../victim`, and lexical normalization cannot prevent the filesystem from resolving the legitimate `foo` dependency symlink before `..`, allowing cleanup to unlink an entry outside the intended package slot.

## Fix Focus Areas
- pnpm/crates/lockfile/src/pkg_name.rs[27-44]
- pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot.rs[389-401]
- pnpm/crates/deps-restorer/src/create_virtual_dir_by_snapshot/tests.rs[435-449]

## Recommended Fix
Reject dependency aliases that are not valid npm package names before they reach filesystem cleanup, matching the pnpm v11 validation behavior. Keep the containment defense and add a regression test with `foo/../victim` plus a symlinked `foo` parent, asserting that the external victim is not removed.

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



Remediation recommended
2. Windows link cleanup remains untested ✓ Resolved 📜 Skill insight ▣ Testability
Description
forced_install_removes_obsolete_child_links is added to repeat_install.rs, whose entire test
module is disabled by #![cfg(unix)]. The pacquet regression therefore never exercises forced
child-link removal on Windows, where link and path behavior differs from Unix.
Code

pnpm/crates/cli/tests/suite/repeat_install.rs[R931-933]

+#[test]
+fn forced_install_removes_obsolete_child_links() {
+    for frozen in [false, true] {
Relevance

●●● Strong

Recent precedents accept platform-specific coverage and strict symlink regression assertions for
install cleanup.

PR-#13306
PR-#14069

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 3365308 requires Windows coverage for path and link changes. The new regression
covers the changed symlink cleanup, but the containing module is explicitly compiled only on Unix.

pnpm/crates/cli/tests/suite/repeat_install.rs[8-8]
pnpm/crates/cli/tests/suite/repeat_install.rs[931-1000]
Skill: review-code

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 new pacquet regression for forced child-link cleanup is located in a Unix-only test module, leaving the changed link behavior untested on Windows.

## Fix Focus Areas
- pnpm/crates/cli/tests/suite/repeat_install.rs[931-1000]

## Recommended Fix
Add an equivalent regression in a cross-platform or Windows-specific CLI test module. Set up the stale child links using the appropriate Windows link mechanism, run the forced install, and assert that obsolete links disappear while the package and retained dependency remain installed.

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



Informational
3. Unrelated shim edits widen the fix 📘 Rule violation ⚙ Maintainability
Description
The PR updates four generate_sh_shim and is_shim_pointing_at calls in command-shim tests even
though those calls do not participate in forced install child-link pruning. They address separately
changed helper signatures, so the install fix also modifies an independent security-test subsystem
that must be reviewed and reverted separately.
Code

pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379]

+    let outdated = generate_sh_shim(&target, &shim, None, &[], None)
Relevance

● Weak

The edits are required call-site updates for a separately changed helper API, matching the exact
merged cmd-shim fix.

PR-#15098

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Compliance rule 2255067 requires bug-fix PRs to exclude unrelated changes. The cited command-shim
test edits only adapt calls to different helper signatures and are unrelated to the dependency-link
cleanup implemented elsewhere in the PR.

Rule 2255067: Bug fix changes must not include unrelated refactors or reformatting
pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379-404]
pnpm/crates/cmd-shim/src/shim/tests.rs[848-848]

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 forced-install bug fix includes unrelated command-shim test maintenance caused by separately changed helper signatures.

## Fix Focus Areas
- pnpm/crates/cmd-shim/src/link_bins/tests/security.rs[379-404]
- pnpm/crates/cmd-shim/src/shim/tests.rs[848-848]

## Recommended Fix
Remove these command-shim test changes from this bug-fix PR and submit them as a separate focused change. Keep this PR limited to forced-install cleanup behavior, its cross-version implementations, and corresponding regressions.

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


Grey Divider

Qodo Logo

Comment thread pnpm/crates/lockfile/src/lib.rs Resolved
@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 commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge; no actionable correctness, security, or repository-rule violations remain.

Reviews (2) · Last reviewed commit: "fix(deps-restorer): validate obsolete ch..."

greptile-apps[bot]
greptile-apps Bot previously approved these changes Sep 19, 2026
Preserve previous dependency records for child-link cleanup while keeping
force-based re-import decisions explicit. Fix both v11 install paths and
v12, with fresh and frozen regression coverage.

Closes #15039.
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Sep 19, 2026
Reuse dependency-name validation before cleanup to reject paths that can
follow a symlink outside the slot.

Move forced-install regressions into a cross-platform CLI module.
@greptile-apps
greptile-apps Bot dismissed their stale review September 19, 2026 01:43

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

@zkochan

zkochan commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

Addressed the review findings in 420af24:

  • Confirmed and fixed the malformed-alias cleanup escape with the existing dependency-name validator. The new regression fails before the fix and passes after it.
  • Moved the forced-install regression out of the Unix-only module into forced_install.rs, so CI exercises it on Windows too.
  • Rebased onto current main, which now contains the command-shim test repair from fix(cmd-shim): update the test call sites to the relocatable-shim arity #15098. Those changes are no longer part of this PR.

Local validation passed: 508 restorer tests, 23 smoke tests, the cross-platform CLI regression, workspace type checking, lint, and all push hooks. CI and review are running again on the new head.


Written by an agent (Codex, GPT-6).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 420af24

@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 19, 2026

Copy link
Copy Markdown
Member Author

Reviewed Qodo's remaining comments against head 420af24:

  • Changeset URL colon: false positive. The punctuation rule governs release-note prose, not the syntax of a Markdown link destination. AGENTS.md explicitly says to end with the issue link and its Changeset style examples use [#NNN](https://github.com/...). The current link follows that convention, and the changeset checks pass. Keeping it.
  • Command-shim edits: already resolved by the rebase. gh pr diff 15096 --name-only contains neither command-shim test file. Their repair is on the base branch in fix(cmd-shim): update the test call sites to the relocatable-shim arity #15098, so there is no remaining change to remove from this PR.

The security and Windows-coverage findings are fixed in 420af24, as the updated review confirms.


Written by an agent (Codex, GPT-6).

@zkochan
zkochan merged commit 1b9dfa0 into main Sep 19, 2026
58 checks passed
@zkochan
zkochan deleted the fix-15039 branch September 19, 2026 08:30
u9g pushed a commit to u9g/pnpm that referenced this pull request Sep 25, 2026
)

Keep the previous install's lockfile entries available under --force in
pnpm v12. Snapshot reuse and slot replacement already gate on the force
flag, while child-link cleanup needs the previous dependency records.

In v11, pass the current lockfile to headless child-link cleanup regardless
of incremental relinking, and compute obsolete aliases for packages selected
for re-import by the resolving installer. Reuse the existing dependency-diff
and removal helpers, preserving full relinking during forced installs.

Add matching regressions for fresh and frozen installs in both versions,
including ordinary and scoped optional child links. Assert the links are
absent even when their targets have been pruned, and that the package and
its remaining dependency are still installed.

Closes pnpm#15039.
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.

Obsolete child symlinks in a virtual-store slot survive pnpm install --force

2 participants