Skip to content

fix(deploy): preserve links to deployed dependencies - #17296

Merged
zkochan merged 5 commits into
pnpm:mainfrom
kairosci:fix/17288-deploy-dependency-symlinks
Oct 24, 2026
Merged

zkochan merged 5 commits into
pnpm:mainfrom
kairosci:fix/17288-deploy-dependency-symlinks

Conversation

@kairosci

@kairosci kairosci commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pnpm deploy dropped a project symlink to a directory that was not among the deployed files, even when the directory was inside the project. A link into node_modules was therefore lost, though deploy installs that dependency in the output. File links to files that are not deployed are still copied as files. Both the default and the legacy deploy are fixed, in pnpm v11 and v12.

Closes #17288.

Squash Commit Body

The symlink-preserving importer recreated a source link only when its
target was also imported. Otherwise a file link was imported as a file
and a directory link was dropped. That rule is right for packages
imported into the virtual store, but deploy copies a project whose
`node_modules` is installed afterwards, so a directory link into it was
dropped.

The importers now take a symlink target policy:

- `Imported` (Rust) / `'imported'` (TS): the existing rule, used by
  virtual-store and hoisted imports of mutable sources.
- `Internal` / `'internal'`: also recreate a directory link whose
  target is left out, used by deploy's project copy. A file link to a
  left-out target is still imported as a file, since a copy works
  wherever the output is moved and a recreated link would dangle.

Both policies still refuse a link whose target escapes the package root.
Rust replaces the `preserve_symlinks: bool` option with
`symlink_targets: Option<SymlinkTargets>`; `None` imports every entry as
a file.

Closes pnpm/pnpm#17288.

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.

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

Summary by CodeRabbit

  • Bug Fixes
    • Deployments now retain symlinks to directories within the project, including links to dependencies that resolve inside the deployed output.
    • Symlinks to files that aren’t included in the deployment are copied as regular files; their targets aren’t added to the deployment.
  • Documentation
    • Updated deployment guidance to explain how directory and file symlinks are handled.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: pnpm/pnpm
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: bf878a9
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ffefbad-8d1b-4dad-9251-7c4d90cb71b1
Commits

Reviewing files that changed from the base of the PR and between 3368928 and 7af1495.

Files selected for processing: 10
  • .changeset/deploy-dependency-symlinks.md
  • pnpm/crates/cli/tests/suite/deploy/target.rs
  • pnpm/crates/deps-restorer/src/import_indexed_dir.rs
  • pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs
  • pnpm/crates/deps-restorer/src/import_indexed_dir/tests/links.rs
  • pnpm/docs/cli/deploy.md
  • pnpm11/docs/cli/deploy.md
  • pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts
  • pnpm11/fs/indexed-pkg-importer/test/importIndexedDir.test.ts
  • pnpm11/releasing/commands/test/deploy/deploy.test.ts
Files skipped from review as they are similar to previous changes: 4
  • pnpm11/docs/cli/deploy.md
  • pnpm/docs/cli/deploy.md
  • .changeset/deploy-dependency-symlinks.md
  • pnpm/crates/deps-restorer/src/import_indexed_dir.rs

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

Walkthrough

The Rust and TypeScript importers now support an internal symlink target policy. Both deploy paths select that policy. Tests cover links to targets omitted from deployed files, and documentation describes the resulting behavior.

Changes: Deploy symlink preservation

Layer / File(s) Summary
Rust symlink target policy
pnpm/crates/deps-restorer/src/import_indexed_dir.rs, pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs, pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs, pnpm/crates/deps-restorer/src/import_indexed_dir/placement/tests.rs
The Rust importer adds SymlinkTargets::Imported and SymlinkTargets::Internal. Internal also recreates links to omitted directories. Both policies refuse links that escape the package root.
Rust import and deploy integration
pnpm/crates/deps-restorer/src/..., pnpm/crates/cli/src/cli_args/deploy/target.rs, pnpm/crates/cli/tests/suite/deploy/target.rs
Shared, staged, and repair imports pass the target policy. Deploy selects Internal. Tests cover omitted targets, import modes, and default and legacy deploys.
TypeScript importer policy
pnpm11/store/controller-types/src/index.ts, pnpm11/fs/indexed-pkg-importer/src/..., pnpm11/fs/indexed-pkg-importer/test/importIndexedDir.test.ts
The importer accepts imported or internal as the symlink target mode. Tests cover links to targets excluded from the import map.
TypeScript deploy integration
pnpm11/releasing/commands/src/deploy/deploy.ts, pnpm11/releasing/commands/test/deploy/deploy.test.ts, pnpm11/docs/cli/deploy.md, pnpm/docs/cli/deploy.md, .changeset/deploy-dependency-symlinks.md
The pnpm 11 deploy path selects internal. Tests cover native and legacy modes. The documentation and changeset describe retained in-project symlinks.

Priority: Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant Deploy as copyProject
  participant Importer as indexed package importer
  participant Output as deploy output
  Deploy->>Importer: select Internal symlink targets
  Importer->>Output: preserve internal directory links
  Importer->>Output: copy omitted file-link targets as files
Loading

Assessment against linked issues

Objective Addressed Explanation
Preserve selected project symlinks to dependencies in default and legacy deploy, retain their relative targets, and resolve the dependency within the output [#17288] ✅

Possibly related issues

  • pnpm/pnpm#17288: The PR changes deploy symlink handling and tests preservation in default and legacy deploy modes.

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

Merge Risk: Minimal · up to 7af14

No actionable merge-blocking risk was identified in the deploy symlink changes.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

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

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.

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

Copy link
Copy Markdown
Contributor

Same-run regression check

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

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

Scenario Engine main median HEAD median Change Tolerance Result
isolated-fresh-restore-cold-cache-cold-store pacquet 2657.13 ms 2767.72 ms 4.2% 132.86 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store pnpr 1521.69 ms 1587.62 ms 4.3% 76.08 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pacquet 327.36 ms 312.71 ms -4.5% 16.37 ms Within tolerance
isolated-fresh-restore-hot-cache-hot-store pnpr 328.26 ms 328.85 ms 0.2% 16.41 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pacquet 11.71 ms 11.95 ms 2.0% 2.00 ms Within tolerance
isolated-repeat-install-hot-cache-hot-store pnpr 11.69 ms 11.20 ms -4.2% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pacquet 13.35 ms 12.92 ms -3.3% 2.00 ms Within tolerance
isolated-repeat-install-cold-cache-hot-store pnpr 12.24 ms 13.42 ms 9.7% 2.00 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pacquet 2493.30 ms 2505.15 ms 0.5% 124.66 ms Within tolerance
isolated-fresh-install-cold-cache-cold-store pnpr 1461.91 ms 1612.07 ms 10.3% 73.10 ms Inconclusive (overlapping samples)
isolated-fresh-install-hot-cache-hot-store pacquet 898.09 ms 767.15 ms -14.6% 44.90 ms Within tolerance
isolated-fresh-install-hot-cache-hot-store pnpr 514.21 ms 533.57 ms 3.8% 25.71 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pacquet 1729.08 ms 1729.93 ms 0.0% 86.45 ms Within tolerance
isolated-fresh-install-cold-cache-hot-store pnpr 356.81 ms 355.72 ms -0.3% 17.84 ms Within tolerance
isolated-fresh-resolve-hot-cache-offline pacquet 361.03 ms 523.39 ms 45.0% 18.05 ms Inconclusive (overlapping samples)
isolated-fresh-resolve-hot-cache-offline pnpr 104.76 ms 117.46 ms 12.1% 5.24 ms Inconclusive (overlapping samples)
isolated-peer-heavy-resolve-hot-cache-offline pacquet 260.41 ms 261.09 ms 0.3% 13.02 ms Within tolerance
isolated-linked-workspace-resolve-hot-cache-offline pacquet 87.72 ms 92.66 ms 5.6% 4.39 ms Inconclusive (overlapping samples)
isolated-injected-workspace-repeat-install-hot-cache-hot-store pacquet 69.93 ms 70.72 ms 1.1% 3.50 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pacquet 4358.36 ms 4398.24 ms 0.9% 217.92 ms Within tolerance
isolated-fresh-restore-cold-cache-cold-store-cold-pnpr pnpr 3482.83 ms 3582.34 ms 2.9% 174.14 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pacquet 170.10 ms 146.25 ms -14.0% 8.50 ms Within tolerance
gvs-fresh-restore-hot-cache-hot-store pnpr 187.73 ms 224.08 ms 19.4% 9.39 ms Inconclusive (overlapping samples)
store-only-unlocked-direct-deps-cold-cache-hot-store pacquet 1346.72 ms 1317.66 ms -2.2% 67.34 ms Within tolerance
cargo-repeat-install-hot-cache-hot-store pacquet 26.42 ms 26.95 ms 2.0% 2.00 ms Within tolerance

Integrated-Benchmark Report (Linux)

Commit: 7af1495794c7

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

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.736 ± 0.187 2.490 2.941 1.74 ± 0.19
pacquet@main 2.631 ± 0.116 2.457 2.843 1.68 ± 0.16
pnpr@HEAD 1.590 ± 0.078 1.487 1.722 1.01 ± 0.10
pnpr@main 1.570 ± 0.130 1.440 1.769 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.7357646130799997,
      "stddev": 0.1866386698122825,
      "median": 2.76772235618,
      "user": 2.7477809,
      "system": 2.28227306,
      "min": 2.49001809518,
      "max": 2.94100662118
    },
    {
      "command": "pacquet@main",
      "mean": 2.63149654528,
      "stddev": 0.11564414200662851,
      "median": 2.65713387918,
      "user": 2.8314417,
      "system": 2.3107853599999997,
      "min": 2.45727159918,
      "max": 2.84283386818
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.59012129648,
      "stddev": 0.07814394828926334,
      "median": 1.58761713718,
      "user": 2.4896063999999996,
      "system": 2.1083105599999996,
      "min": 1.48731809318,
      "max": 1.72170538518
    },
    {
      "command": "pnpr@main",
      "mean": 1.5703433981800003,
      "stddev": 0.1304460835271147,
      "median": 1.52169198968,
      "user": 2.1888497,
      "system": 1.79822546,
      "min": 1.43998710118,
      "max": 1.76927717318
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 313.5 ± 21.0 288.1 363.3 1.00
pacquet@main 315.2 ± 26.8 271.6 346.2 1.01 ± 0.11
pnpr@HEAD 333.5 ± 31.4 295.4 408.3 1.06 ± 0.12
pnpr@main 326.2 ± 14.5 302.1 348.6 1.04 ± 0.08
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.3135121701800001,
      "stddev": 0.020950609258579604,
      "median": 0.31271142308,
      "user": 0.36413150000000005,
      "system": 0.7027849799999999,
      "min": 0.28811166358,
      "max": 0.36328964358000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.31517144408000003,
      "stddev": 0.026817567528279528,
      "median": 0.32735646258,
      "user": 0.38319439999999994,
      "system": 0.6938630799999999,
      "min": 0.27156760358000004,
      "max": 0.34615043458
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.33351082388000003,
      "stddev": 0.031441403626097125,
      "median": 0.32885004908000004,
      "user": 0.34854799999999997,
      "system": 0.72927658,
      "min": 0.29540073058,
      "max": 0.40830997758000004
    },
    {
      "command": "pnpr@main",
      "mean": 0.32616745728,
      "stddev": 0.014542799058038075,
      "median": 0.32826247808,
      "user": 0.35778770000000004,
      "system": 0.70634778,
      "min": 0.30211628458,
      "max": 0.34859628658
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 12.0 ± 1.2 9.3 16.6 1.07 ± 0.16
pacquet@main 11.7 ± 1.2 8.6 15.6 1.05 ± 0.15
pnpr@HEAD 11.2 ± 1.2 8.4 15.7 1.00
pnpr@main 12.0 ± 1.6 9.2 17.2 1.07 ± 0.18
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.01198781703788462,
      "stddev": 0.0011579432665204169,
      "median": 0.01194912486,
      "user": 0.007309387115384615,
      "system": 0.005731684615384617,
      "min": 0.009275401859999999,
      "max": 0.01655557086
    },
    {
      "command": "pacquet@main",
      "mean": 0.011716795183529421,
      "stddev": 0.0011714207682511477,
      "median": 0.01170910336,
      "user": 0.007071419243697479,
      "system": 0.0057698774789916,
      "min": 0.008574744859999999,
      "max": 0.01560212886
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.011206752758617515,
      "stddev": 0.0012158161212384823,
      "median": 0.01120130286,
      "user": 0.006016658894009216,
      "system": 0.006206167004608295,
      "min": 0.00839235186,
      "max": 0.01566918486
    },
    {
      "command": "pnpr@main",
      "mean": 0.012033348581991699,
      "stddev": 0.0015916848025905549,
      "median": 0.01169208586,
      "user": 0.006647632946058094,
      "system": 0.0065155845643153545,
      "min": 0.00919969786,
      "max": 0.017161259860000003
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 13.1 ± 1.5 10.1 18.7 1.06 ± 0.18
pacquet@main 13.5 ± 1.3 10.9 19.2 1.09 ± 0.17
pnpr@HEAD 13.5 ± 1.6 10.2 17.6 1.09 ± 0.19
pnpr@main 12.3 ± 1.5 9.5 15.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.013069042714945054,
      "stddev": 0.0015003919954791585,
      "median": 0.01291650266,
      "user": 0.007314945494505491,
      "system": 0.006940908571428573,
      "min": 0.01005291466,
      "max": 0.018667884660000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.013475348696458321,
      "stddev": 0.0012811189472530073,
      "median": 0.013351217660000001,
      "user": 0.007486476458333336,
      "system": 0.007198105833333333,
      "min": 0.01094706066,
      "max": 0.019229617660000003
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.0134717641102924,
      "stddev": 0.0015996359530258103,
      "median": 0.01342344266,
      "user": 0.007257691461988305,
      "system": 0.007320233216374264,
      "min": 0.01020085166,
      "max": 0.017559787660000003
    },
    {
      "command": "pnpr@main",
      "mean": 0.012313226063846161,
      "stddev": 0.0014859728998293026,
      "median": 0.012235061160000001,
      "user": 0.006900010512820512,
      "system": 0.006396520512820515,
      "min": 0.00945581566,
      "max": 0.015948817660000003
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.495 ± 0.026 2.443 2.520 1.69 ± 0.10
pacquet@main 2.492 ± 0.015 2.467 2.514 1.68 ± 0.10
pnpr@HEAD 1.589 ± 0.083 1.431 1.699 1.07 ± 0.09
pnpr@main 1.479 ± 0.089 1.379 1.631 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.4947205310800005,
      "stddev": 0.025537189798270514,
      "median": 2.50514938808,
      "user": 2.12774094,
      "system": 1.4508647800000003,
      "min": 2.44306293108,
      "max": 2.51975544008
    },
    {
      "command": "pacquet@main",
      "mean": 2.49216597658,
      "stddev": 0.014853087103543963,
      "median": 2.49329749458,
      "user": 2.0983278400000005,
      "system": 1.4536605799999998,
      "min": 2.46694178908,
      "max": 2.51372232608
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.58884025128,
      "stddev": 0.08344709030108764,
      "median": 1.61207189008,
      "user": 1.5855259399999997,
      "system": 1.25430708,
      "min": 1.43077632308,
      "max": 1.69895059308
    },
    {
      "command": "pnpr@main",
      "mean": 1.4794120939800002,
      "stddev": 0.088618056777703,
      "median": 1.46190610808,
      "user": 1.5841778399999997,
      "system": 1.22843358,
      "min": 1.37855677408,
      "max": 1.63133206008
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 825.7 ± 141.2 664.3 1109.6 1.58 ± 0.28
pacquet@main 889.3 ± 68.7 770.2 997.0 1.70 ± 0.15
pnpr@HEAD 526.1 ± 28.0 469.4 555.5 1.01 ± 0.07
pnpr@main 521.6 ± 23.2 497.2 563.3 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.8257303473600001,
      "stddev": 0.14118338367156194,
      "median": 0.7671496476600002,
      "user": 1.1261932199999998,
      "system": 1.26724174,
      "min": 0.66429155366,
      "max": 1.1096164496599998
    },
    {
      "command": "pacquet@main",
      "mean": 0.88928095856,
      "stddev": 0.06872578620021655,
      "median": 0.8980921886600002,
      "user": 1.2563318200000002,
      "system": 1.2886716399999998,
      "min": 0.7702262406600001,
      "max": 0.9970414006600001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.5260911176600002,
      "stddev": 0.028026793732115717,
      "median": 0.53356715166,
      "user": 0.47363121999999996,
      "system": 0.9213759399999999,
      "min": 0.46940429266,
      "max": 0.5555140096600001
    },
    {
      "command": "pnpr@main",
      "mean": 0.52157421226,
      "stddev": 0.023172603842480443,
      "median": 0.51420909766,
      "user": 0.4690681199999999,
      "system": 0.9352678399999999,
      "min": 0.49724265166000003,
      "max": 0.5633367276600001
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.728 ± 0.017 1.704 1.764 4.86 ± 0.10
pacquet@main 1.725 ± 0.016 1.699 1.750 4.85 ± 0.10
pnpr@HEAD 0.356 ± 0.007 0.344 0.366 1.00
pnpr@main 0.357 ± 0.007 0.348 0.370 1.00 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.7281573736400002,
      "stddev": 0.01666237721767187,
      "median": 1.7299264711400002,
      "user": 1.13725082,
      "system": 1.2285821399999999,
      "min": 1.70389589414,
      "max": 1.7643433221400002
    },
    {
      "command": "pacquet@main",
      "mean": 1.7246685675399998,
      "stddev": 0.015765000263077467,
      "median": 1.72907651464,
      "user": 1.12111552,
      "system": 1.2199628399999998,
      "min": 1.69910360614,
      "max": 1.74952052614
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.35560700184,
      "stddev": 0.0066191959267383,
      "median": 0.35571989614,
      "user": 0.34108362,
      "system": 0.7778527399999999,
      "min": 0.34426433714000004,
      "max": 0.36573892114000006
    },
    {
      "command": "pnpr@main",
      "mean": 0.35702222184000004,
      "stddev": 0.007084721381546555,
      "median": 0.35680924664,
      "user": 0.3149744199999999,
      "system": 0.8136472400000001,
      "min": 0.34783159214000003,
      "max": 0.36965797714000004
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 561.9 ± 111.0 452.1 839.6 5.27 ± 1.09
pacquet@main 437.2 ± 144.7 333.5 720.2 4.10 ± 1.38
pnpr@HEAD 121.0 ± 15.0 101.4 157.5 1.13 ± 0.16
pnpr@main 106.7 ± 6.4 98.4 124.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.5619066588600001,
      "stddev": 0.1109667357153562,
      "median": 0.52339224306,
      "user": 0.5700619999999998,
      "system": 0.22065761999999997,
      "min": 0.45210915856000006,
      "max": 0.8396097965600001
    },
    {
      "command": "pacquet@main",
      "mean": 0.43722656016000006,
      "stddev": 0.1447048944221369,
      "median": 0.36102819256000007,
      "user": 0.44790660000000004,
      "system": 0.18185621999999999,
      "min": 0.33351991956000004,
      "max": 0.7202151655600001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.12099008117904762,
      "stddev": 0.014994788940826464,
      "median": 0.11746043356000001,
      "user": 0.0576351619047619,
      "system": 0.022661447619047616,
      "min": 0.10135120956,
      "max": 0.15745635856
    },
    {
      "command": "pnpr@main",
      "mean": 0.10667150413142859,
      "stddev": 0.006354634481219401,
      "median": 0.10476495506,
      "user": 0.0423244,
      "system": 0.021726791428571434,
      "min": 0.09843283056,
      "max": 0.12460785556000002
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 262.3 ± 13.5 245.1 278.8 1.02 ± 0.07
pacquet@main 257.9 ± 12.7 238.8 272.0 1.00
pnpm@HEAD 4309.8 ± 96.0 4151.3 4489.9 16.71 ± 0.90
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.26227403328666665,
      "stddev": 0.013464139251590554,
      "median": 0.26109426762,
      "user": 0.28162688444444445,
      "system": 0.06148560888888889,
      "min": 0.24505673962000002,
      "max": 0.27875860762000004
    },
    {
      "command": "pacquet@main",
      "mean": 0.2579212608422223,
      "stddev": 0.012672322605391835,
      "median": 0.26041390762,
      "user": 0.2657461066666667,
      "system": 0.07552516444444443,
      "min": 0.23876398362,
      "max": 0.27203834162
    },
    {
      "command": "pnpm@HEAD",
      "mean": 4.3097743385088885,
      "stddev": 0.09598066724418419,
      "median": 4.28482928962,
      "user": 7.002303995555555,
      "system": 0.3541386088888888,
      "min": 4.15125476462,
      "max": 4.48990316062
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 92.6 ± 3.3 82.6 99.2 1.06 ± 0.05
pacquet@main 87.7 ± 2.7 83.4 93.1 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.09256825933058822,
      "stddev": 0.0033460377117006165,
      "median": 0.09265940085999999,
      "user": 0.07938951058823529,
      "system": 0.049141464705882376,
      "min": 0.08260481736,
      "max": 0.09924734336
    },
    {
      "command": "pacquet@main",
      "mean": 0.08773247973500001,
      "stddev": 0.0026769671417831223,
      "median": 0.08771735586,
      "user": 0.07422741500000002,
      "system": 0.047784543750000005,
      "min": 0.08336905036,
      "max": 0.09310579236
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 71.3 ± 1.9 69.7 79.3 1.01 ± 0.04
pacquet@main 70.5 ± 2.1 68.2 77.9 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.07128960019500002,
      "stddev": 0.0018755499935564528,
      "median": 0.07071944652,
      "user": 0.027293884999999997,
      "system": 0.04914716999999998,
      "min": 0.06968477952,
      "max": 0.07929536552000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.07052351554380953,
      "stddev": 0.0020890441292403415,
      "median": 0.06993454802000001,
      "user": 0.029038702857142856,
      "system": 0.046708791428571414,
      "min": 0.06822219452,
      "max": 0.07791557552
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.494 ± 0.196 4.327 4.803 1.27 ± 0.07
pacquet@main 4.419 ± 0.114 4.331 4.644 1.25 ± 0.06
pnpr@HEAD 3.624 ± 0.149 3.400 3.835 1.03 ± 0.06
pnpr@main 3.532 ± 0.128 3.423 3.849 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.4942665126,
      "stddev": 0.19563528410052533,
      "median": 4.3982386384000005,
      "user": 1.8750470799999999,
      "system": 1.46348752,
      "min": 4.3271880949,
      "max": 4.8027852819
    },
    {
      "command": "pacquet@main",
      "mean": 4.4189976745,
      "stddev": 0.11410623536699353,
      "median": 4.358363607399999,
      "user": 1.8495496799999998,
      "system": 1.45529202,
      "min": 4.3314904329,
      "max": 4.6437650509
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.6242506336,
      "stddev": 0.14899287074737178,
      "median": 3.5823423339,
      "user": 1.83749548,
      "system": 1.3565855199999999,
      "min": 3.4004244989,
      "max": 3.8353872249
    },
    {
      "command": "pnpr@main",
      "mean": 3.5320807169,
      "stddev": 0.12766894308331947,
      "median": 3.4828274003999997,
      "user": 1.7899942800000002,
      "system": 1.39704432,
      "min": 3.4226907979,
      "max": 3.8486871849
    }
  ]
}

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 148.0 ± 9.5 133.8 161.8 1.00
pacquet@main 169.6 ± 15.7 140.0 201.0 1.15 ± 0.13
pnpr@HEAD 232.7 ± 37.7 190.5 299.8 1.57 ± 0.27
pnpr@main 193.4 ± 15.2 168.4 216.8 1.31 ± 0.13
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.14795497303750002,
      "stddev": 0.009530890115086893,
      "median": 0.14625427810000002,
      "user": 0.17779135999999998,
      "system": 0.14673558000000006,
      "min": 0.13375917360000003,
      "max": 0.16181651960000001
    },
    {
      "command": "pacquet@main",
      "mean": 0.1695681996714286,
      "stddev": 0.015732095142271436,
      "median": 0.17009510560000002,
      "user": 0.19930785999999998,
      "system": 0.16112679428571428,
      "min": 0.13995299060000002,
      "max": 0.20103969160000001
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.23274857706153848,
      "stddev": 0.037700665215420794,
      "median": 0.22407592560000003,
      "user": 0.27700882153846157,
      "system": 0.17666931076923076,
      "min": 0.19054501860000003,
      "max": 0.2998128526
    },
    {
      "command": "pnpr@main",
      "mean": 0.19344294246666668,
      "stddev": 0.015227908763645529,
      "median": 0.18773152760000003,
      "user": 0.22197782666666666,
      "system": 0.16938614666666668,
      "min": 0.16842972460000002,
      "max": 0.21680840060000003
    }
  ]
}

Scenario: Store only: unlocked direct deps, cold cache + hot store

Store-only install (enableModulesDir: false, per-file store index, trusted lockfile) against a lockfile missing the direct dependencies that have peers, with the metadata cache wiped per iteration: the install resolves those from the registry, reuses their subtrees from the lockfile and checks the store, linking nothing. Direct installs only.

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.317 ± 0.023 1.273 1.346 1.00
pacquet@main 1.343 ± 0.039 1.289 1.417 1.02 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.31662080632,
      "stddev": 0.02342112977522791,
      "median": 1.31766471022,
      "user": 0.73347006,
      "system": 0.27589469999999994,
      "min": 1.27313555222,
      "max": 1.34578964922
    },
    {
      "command": "pacquet@main",
      "mean": 1.34292291822,
      "stddev": 0.0389351715765296,
      "median": 1.3467204002200002,
      "user": 0.78294126,
      "system": 0.28396150000000003,
      "min": 1.28922824522,
      "max": 1.41695785122
    }
  ]
}

Scenario: Cargo: repeat install, hot cache + hot store

Frozen repeat install of a Cargo workspace (cargo.enabled: true) whose crates are already materialized in <storeDir>/v11/crates/ and linked into .pnpm/crates/crates-io. Direct installs only.

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 27.1 ± 0.8 25.8 30.6 1.02 ± 0.05
pacquet@main 26.7 ± 0.9 25.8 31.5 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.02713765197714285,
      "stddev": 0.000789977757824388,
      "median": 0.02695358192,
      "user": 0.019227647619047623,
      "system": 0.013779459619047613,
      "min": 0.02580460192,
      "max": 0.030621006920000002
    },
    {
      "command": "pacquet@main",
      "mean": 0.02665294417454546,
      "stddev": 0.0009234286074352409,
      "median": 0.026415218920000004,
      "user": 0.020243809090909087,
      "system": 0.012201881272727267,
      "min": 0.02575358492,
      "max": 0.03145438392
    }
  ]
}

@codecov-commenter

codecov-commenter commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.56%. Comparing base (bf878a9) to head (7af1495).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main   #17296    +/-   ##
========================================
  Coverage   92.56%   92.56%            
========================================
  Files        1875     1877     +2     
  Lines      242682   242780    +98     
========================================
+ Hits       224630   224739   +109     
+ Misses      18052    18041    -11     

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

@garnet-runtime-review

garnet-runtime-review Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Execution Profiles recorded for 1 job, triggered by 7af1495

1 job changed +2 destinations · compared with 3368928
recorded at the kernel by Garnet · 2026-10-24 19:00 UTC

+2 · TS CI / test ↗
@@ 3368928 (previous) vs 7af1495 (current) @@
  systemd
  ├─ bash
  │  └─ bash
  │     └─ bash
  │        └─ bash
  │           └─ bash
  │              └─ bash
  │                 ├─ bash
  │                 │  ├─ node
  │                 │  │  ├─ git (step: "<unknown>")
  │                 │  │  │  ├─ git
  │                 │  │  │  │  └─ git
  │                 │  │  │  │     └─ git-remote-http
  │                 │  │  │  │        └─ ○ github[.]com
  │                 │  │  │  └─ ○ 192.168.127.1
  │                 │  │  └─ pn (step: "Validate test chunk inputs")
  │                 │  │     ├─ dash
  │                 │  │     │  └─ node
  │                 │  │     │     └─ pn
  │                 │  │     │        └─ dash
  │                 │  │     │           └─ pn
  │                 │  │     │              └─ dash
  │                 │  │     │                 └─ pnpm
  │                 │  │     │                    └─ dash
  │                 │  │     │                       └─ node
  │                 │  │     │                          ├─ ○ codeload.github[.]com
  │                 │  │     │                          └─ ○ registry.npmjs[.]org
  │                 │  │     └─ ○ nodejs[.]org
  │                 │  └─ gh (step: "Wait for prebuilt pnpr binaries")
  │                 │     └─ ○ api.github[.]com
  │                 └─ node (runner background · +1 −1)
  │                    ├─ ○ blacksmith.blob.core.windows[.]net
- │                    ├─ ○ blob.bn9prdstrz04a.store.core.windows[.]net
+ │                    └─ ○ productionresultssa11.blob.core[.]windows
  ├─ nginx (runner background · +1)
  │  └─ nginx
  │     ├─ ○ 140.82.113.22
  │     ├─ ○ 140.82.114.21
  │     ├─ ○ 8.8.8.8
+ │     └─ ○ glb-db52c2cf8be544.github[.]com
  ├─ chronyd (runner background · +4 −4)
- │  ├─ ○ 142.248.80.92
+ │  ├─ ○ 149.28.200.179
  │  ├─ ○ 169.254.169.123
- │  ├─ ○ 173.71.69.149
  │  ├─ ○ 185.125.190.56
  │  ├─ ○ 185.125.190.57
  │  ├─ ○ 185.125.190.58
+ │  ├─ ○ 198.71.50.75
+ │  ├─ ○ 216.229.4.66
- │  ├─ ○ 23.111.186.186
- │  ├─ ○ 23.186.168.125
+ │  ├─ ○ 47.89.241.172
  │  └─ ○ 91.189.91.157
  └─ snapd
     └─ ○ api.snapcraft[.]io
 
  Runner.Worker
+ ├─ node
+ │  └─ ○ blob.blz25prdstrz09a.store.core[.]windows
  └─ bash
     ├─ rustup (step: "Initialize Rust before dependenc…tion ($/.github/actions/rustup)")
     │  ├─ ○ dualstack.k.sni.global.fastly[.]net
     │  └─ ○ localhost (dns resolver)
     └─ MainThread
        └─ pn
           └─ dash
              └─ node
+                ├─ pn
+                │  └─ node (step: "Validate test chunk inputs")
+                │     └─ ○ npm.jsr[.]io
                 └─ node
                    └─ node (step: "Validate test chunk inputs")
                       └─ ○ unofficial-builds.nodejs[.]org

2 addresses rotated (github infra)

View this job's Execution Profile in Garnet →


💡 How to read this
Runner.Worker          ← process on a path
└─ npm
   └─ node             ← process that acted
      └─ ○ npmjs[.]org ← observed action

follow a path downward to see what ran and what it did — each path to an observed action is an execution chain

names on the path = processes · ○ = observed action · (…) = context

+ only in the current record · − only in the previous record · runner background = the runner's infrastructure, not your workflow

@kairosci
kairosci marked this pull request as ready for review October 23, 2026 18:47
@kairosci
kairosci requested a review from zkochan as a code owner October 23, 2026 18:47
Copilot AI lite review requested due to automatic review settings October 23, 2026 18:47
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

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

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Oct 23, 2026
@zkochan
zkochan force-pushed the fix/17288-deploy-dependency-symlinks branch from 10782ee to 2e1b63e Compare October 23, 2026 23:50
Copilot AI lite review requested due to automatic review settings October 23, 2026 23:50

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Deploy can preserve links outside the project 📜 Skill insight ⛨ Security
Description
The Internal policy recreates links to unselected targets after validate_symlink_target performs
only lexical containment checks. When an in-root link target traverses an intermediate symlink that
points outside the package, deploy can recreate a link that resolves outside the output root, and
the TypeScript path has the same weakness.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[R102-104]

+    if roots.policy == SymlinkTargets::Imported && !imports_link_target(target, &link_target, roots)
+    {
        return Ok(is_dir);
Relevance

●●● Strong

Recent repository precedent accepts fixes preventing symlink-mediated escapes through intermediate
path components.

PR-#16747
PR-#17040

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed condition makes the internal policy recreate links even when their targets are omitted.
The shared validation uses lexical normalization and prefix checking rather than resolving
intermediate symlink components, so an attacker-controlled package link can traverse an in-root
symlink to an external location. The TypeScript implementation also bypasses its imported-target
check for internal and uses the same lexical path.resolve containment decision.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[91-104]
pnpm/crates/fs/src/is_subdir.rs[3-16]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]
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 `Internal` policy preserves links whose target is not imported, but the containment check is lexical and does not account for intermediate symlinks. A link such as `link -> omitted/secret`, where `omitted` points outside the package, can therefore be recreated as an output link that escapes the package root.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[91-104]
- pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]

## Recommended Fix
Before recreating a symlink under either policy, resolve existing path components of its target and verify the resulting path remains inside the package root, while retaining support for targets that do not yet exist. Apply the equivalent check in the TypeScript importer, and add regression tests for an omitted intermediate symlink that points outside the package.

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

Dismiss ↗ | View ↗



Remediation recommended

2. Deploy builds an unused path index 🐞 Bug ➹ Performance
Description
populate_dir_on_current_pool and the pnpm 11 symlinkDirs helper still index every selected path
and its ancestors when deploy selects the internal-link policy, although only the imported-link
policy queries those indexes. Every project copy consequently performs an avoidable file-map pass
and hash-set allocation, even when the project has no symlinks, adding CPU and memory work for large
deployments in both versions.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[R69-73]

+        .map(|((final_dir, policy), imported)| SymlinkRoots {
+            written_dir: dir_path,
+            final_dir,
+            imported,
+            policy,
Relevance

●●● Strong

Avoidable path-index construction is a straightforward performance regression under the new
internal-only policy.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rust deploy opts into Internal and populate_dir_on_current_pool constructs imported_paths
whenever any policy is set; that helper hashes all file-map paths and ancestors, but the membership
test runs only under Imported. The pnpm 11 deploy also opts into internal while symlinkDirs
constructs the same index before returning the new policy field, and copyInternalSymlink skips its
lookup under internal.

pnpm/crates/cli/src/cli_args/deploy/target.rs[250-261]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[63-74]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[29-40]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[100-105]
pnpm11/releasing/commands/src/deploy/deploy.ts[219-223]
pnpm11/fs/indexed-pkg-importer/src/importIndexedDir.ts[299-312]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]

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

## Issue description
Deploy's new internal-link policy never consults the imported-path index, but both Rust and TypeScript importers still build it for every project copy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[63-74]
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[23-40]
- pnpm11/fs/indexed-pkg-importer/src/importIndexedDir.ts[299-312]

## Recommended Fix
Construct the full imported-path set only for the imported-target policy in both importers. Keep an empty or optional set for the internal policy, and preserve the existing membership checks for imported-target links.

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

Dismiss ↗ | View ↗



Informational

3. Deployed file links to excluded files now dangle ✓ Resolved
Description
Under SymlinkTargets::Internal (and 'internal' in copyInternalSymlink.ts),
place_symlink_entry skips imports_link_target for every link, including file links. It used to
fall back to copying the target's contents. As a result, a project file link whose target is inside
the project but left out by files/.npmignore (for example `dist/config.json ->
../config/default.json with files: ["dist"]`) is now recreated as a symlink pointing at a file
deploy never writes. On Unix the deployed file goes missing at runtime, while on Windows
symlink_file_or_copy still copies it, so the result depends on the platform. A symlinked
package.json hits the same problem and breaks apply_deploy_hook, which reads
deploy_dir/package.json right after the copy.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[R102-105]

+    if roots.policy == SymlinkTargets::Imported && !imports_link_target(target, &link_target, roots)
+    {
        return Ok(is_dir);
    }
Relevance

● Weak

The requested behavior conflicts with deploy’s stated purpose and preserves internal links for
dependencies installed later.

PR-#14788

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
place_symlink_entry now bypasses the imported-target check whenever the policy is Internal, so a
file link (is_dir == false) whose target was not imported is never handed back to the caller
(Ok(false)) to be copied. Instead it is created with symlink_file_or_copy(&link_target, ...).
copy_project turns on Internal for the whole project copy, and apply_deploy_hook reads the
copied manifest back right away. The TypeScript importer behaves the same way: copyInternalSymlink
skips the imported.has check when symlinkTargets === 'internal'. The bug report only needs links
whose targets deploy provides later (dependencies installed in node_modules), not links to files
deploy leaves out on purpose.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[94-127]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[188-214]
pnpm/crates/cli/src/cli_args/deploy/target.rs[236-276]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-36]

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

## Issue description
With the new `Internal` symlink policy, deploy recreates every internal symlink, including file links whose target is excluded from the deployed files. Those links now dangle on Unix, where the file contents used to be copied. A symlinked `package.json` also breaks the manifest read that follows the copy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[94-105]
- pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-30]

## Recommended Fix
Narrow `Internal` so it only changes the outcome in cases the old rule could not handle. Either (a) under `Internal`, when the target is not imported, recreate the link only if it is a directory link, or if the link's resolved target lies under a `node_modules` segment that the later install provides, and otherwise keep the old behaviour (return `Ok(is_dir)` so a file link is copied); or (b) at minimum, never recreate the `package.json` marker as a dangling link and keep the file-copy fallback for file links. Apply the same rule in `copyInternalSymlink` for the TypeScript deploy, and add a test covering a file link to a file excluded by `files`.

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


Grey Divider

Context sources
✅ Compliance rules (platform): 62 rules
✅ Cross-repo context — repo relationships
  Explored: repo: pnpm/pnpm.io (sha: 0aab2bac) — View relationship
Review mode: Auto: 🧠 Deep: Cross-version symlink logic spans many paths with subtle security and correctness risks.
✅ Fix-loop round: fix loop

Grey Divider

Tip of the day
💡 Did you know, you can choose which labels appear on a finding, and whether they show icons or text

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit 7af1495

Results up to commit 2e1b63e 🧠 Deep


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


Action required
1. Deploy can preserve links outside the project 📜 Skill insight ⛨ Security
Description
The Internal policy recreates links to unselected targets after validate_symlink_target performs
only lexical containment checks. When an in-root link target traverses an intermediate symlink that
points outside the package, deploy can recreate a link that resolves outside the output root, and
the TypeScript path has the same weakness.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[R102-104]

+    if roots.policy == SymlinkTargets::Imported && !imports_link_target(target, &link_target, roots)
+    {
        return Ok(is_dir);
Relevance

●●● Strong

Recent repository precedent accepts fixes preventing symlink-mediated escapes through intermediate
path components.

PR-#16747
PR-#17040

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The changed condition makes the internal policy recreate links even when their targets are omitted.
The shared validation uses lexical normalization and prefix checking rather than resolving
intermediate symlink components, so an attacker-controlled package link can traverse an in-root
symlink to an external location. The TypeScript implementation also bypasses its imported-target
check for internal and uses the same lexical path.resolve containment decision.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[91-104]
pnpm/crates/fs/src/is_subdir.rs[3-16]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]
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 `Internal` policy preserves links whose target is not imported, but the containment check is lexical and does not account for intermediate symlinks. A link such as `link -> omitted/secret`, where `omitted` points outside the package, can therefore be recreated as an output link that escapes the package root.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[91-104]
- pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]

## Recommended Fix
Before recreating a symlink under either policy, resolve existing path components of its target and verify the resulting path remains inside the package root, while retaining support for targets that do not yet exist. Apply the equivalent check in the TypeScript importer, and add regression tests for an omitted intermediate symlink that points outside the package.

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

Dismiss ↗ | View ↗



Remediation recommended
2. Deploy builds an unused path index 🐞 Bug ➹ Performance
Description
populate_dir_on_current_pool and the pnpm 11 symlinkDirs helper still index every selected path
and its ancestors when deploy selects the internal-link policy, although only the imported-link
policy queries those indexes. Every project copy consequently performs an avoidable file-map pass
and hash-set allocation, even when the project has no symlinks, adding CPU and memory work for large
deployments in both versions.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[R69-73]

+        .map(|((final_dir, policy), imported)| SymlinkRoots {
+            written_dir: dir_path,
+            final_dir,
+            imported,
+            policy,
Relevance

●●● Strong

Avoidable path-index construction is a straightforward performance regression under the new
internal-only policy.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Rust deploy opts into Internal and populate_dir_on_current_pool constructs imported_paths
whenever any policy is set; that helper hashes all file-map paths and ancestors, but the membership
test runs only under Imported. The pnpm 11 deploy also opts into internal while symlinkDirs
constructs the same index before returning the new policy field, and copyInternalSymlink skips its
lookup under internal.

pnpm/crates/cli/src/cli_args/deploy/target.rs[250-261]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[63-74]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[29-40]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[100-105]
pnpm11/releasing/commands/src/deploy/deploy.ts[219-223]
pnpm11/fs/indexed-pkg-importer/src/importIndexedDir.ts[299-312]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]

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

## Issue description
Deploy's new internal-link policy never consults the imported-path index, but both Rust and TypeScript importers still build it for every project copy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[63-74]
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[23-40]
- pnpm11/fs/indexed-pkg-importer/src/importIndexedDir.ts[299-312]

## Recommended Fix
Construct the full imported-path set only for the imported-target policy in both importers. Keep an empty or optional set for the internal policy, and preserve the existing membership checks for imported-target links.

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

Dismiss ↗ | View ↗



Informational
3. Deployed file links to excluded files now dangle ✓ Resolved
Description
Under SymlinkTargets::Internal (and 'internal' in copyInternalSymlink.ts),
place_symlink_entry skips imports_link_target for every link, including file links. It used to
fall back to copying the target's contents. As a result, a project file link whose target is inside
the project but left out by files/.npmignore (for example `dist/config.json ->
../config/default.json with files: ["dist"]`) is now recreated as a symlink pointing at a file
deploy never writes. On Unix the deployed file goes missing at runtime, while on Windows
symlink_file_or_copy still copies it, so the result depends on the platform. A symlinked
package.json hits the same problem and breaks apply_deploy_hook, which reads
deploy_dir/package.json right after the copy.
Code

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[R102-105]

+    if roots.policy == SymlinkTargets::Imported && !imports_link_target(target, &link_target, roots)
+    {
        return Ok(is_dir);
    }
Relevance

● Weak

The requested behavior conflicts with deploy’s stated purpose and preserves internal links for
dependencies installed later.

PR-#14788

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
place_symlink_entry now bypasses the imported-target check whenever the policy is Internal, so a
file link (is_dir == false) whose target was not imported is never handed back to the caller
(Ok(false)) to be copied. Instead it is created with symlink_file_or_copy(&link_target, ...).
copy_project turns on Internal for the whole project copy, and apply_deploy_hook reads the
copied manifest back right away. The TypeScript importer behaves the same way: copyInternalSymlink
skips the imported.has check when symlinkTargets === 'internal'. The bug report only needs links
whose targets deploy provides later (dependencies installed in node_modules), not links to files
deploy leaves out on purpose.

pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[94-127]
pnpm/crates/deps-restorer/src/import_indexed_dir/placement.rs[188-214]
pnpm/crates/cli/src/cli_args/deploy/target.rs[236-276]
pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-36]

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

## Issue description
With the new `Internal` symlink policy, deploy recreates every internal symlink, including file links whose target is excluded from the deployed files. Those links now dangle on Unix, where the file contents used to be copied. A symlinked `package.json` also breaks the manifest read that follows the copy.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[94-105]
- pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-30]

## Recommended Fix
Narrow `Internal` so it only changes the outcome in cases the old rule could not handle. Either (a) under `Internal`, when the target is not imported, recreate the link only if it is a directory link, or if the link's resolved target lies under a `node_modules` segment that the later install provides, and otherwise keep the old behaviour (return `Ok(is_dir)` so a file link is copied); or (b) at minimum, never recreate the `package.json` marker as a dangling link and keep the file-copy fallback for file links. Apply the same rule in `copyInternalSymlink` for the TypeScript deploy, and add a test covering a file link to a file excluded by `files`.

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


Grey Divider

Qodo Logo

Comment on lines 102 to 104
if roots.policy == SymlinkTargets::Imported && !imports_link_target(target, &link_target, roots)
{
return Ok(is_dir);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Deploy can preserve links outside the project 📜 Skill insight ⛨ Security

The Internal policy recreates links to unselected targets after validate_symlink_target performs
only lexical containment checks. When an in-root link target traverses an intermediate symlink that
points outside the package, deploy can recreate a link that resolves outside the output root, and
the TypeScript path has the same weakness.
Agent Prompt
## Issue description
The new `Internal` policy preserves links whose target is not imported, but the containment check is lexical and does not account for intermediate symlinks. A link such as `link -> omitted/secret`, where `omitted` points outside the package, can therefore be recreated as an output link that escapes the package root.

## Fix Focus Areas
- pnpm/crates/deps-restorer/src/import_indexed_dir/placement/symlinks.rs[91-104]
- pnpm11/fs/indexed-pkg-importer/src/copyInternalSymlink.ts[24-29]

## Recommended Fix
Before recreating a symlink under either policy, resolve existing path components of its target and verify the resulting path remains inside the package root, while retaining support for targets that do not yet exist. Apply the equivalent check in the TypeScript importer, and add regression tests for an omitted intermediate symlink that points outside the package.

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

Dismiss ↗ | View ↗

@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 Oct 24, 2026

Copy link
Copy Markdown
Member

Rebased onto main and pushed 2e1b63e:

  • Dropped .changeset/dependency-io-safety.md. Main already carries the tokio 1.53.3 bump (chore(cargo): bump tokio from 1.53.1 to 1.53.3 #17302), so this branch no longer changes Cargo.lock.
  • Restored doc comments the branch had deleted in unrelated files (package_is_installable.rs, pnpr/crates/error/src/response.rs, deps-installer/test/catalogs.ts).
  • Documented SymlinkTargets, its variants, and the symlink_targets option, and restored the contracts of populate_dir and place_symlink_entry, whose docs the branch had removed.
  • Reworded the changeset and the deploy docs.

Status on 2e1b63e:

  • CodeRabbit and Qodo reported no actionable findings. No review threads are open.
  • Rust CI / Test / windows failed once in pnpm-package-manifest (NamedTempFile::new() got "Access is denied" in the runner's temp directory, in a crate this PR does not touch). It passed on rerun.
  • Audit dependencies fails on two new moderate undici advisories (GHSA-4qv8-2p9j-2685, GHSA-f72v-6w45-q472). The same check fails on main, so it needs a repo-wide undici bump rather than a change here.

The PR was already ready for review and stays that way. Nothing else is left within this PR's scope.


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

kairosci and others added 4 commits October 24, 2026 18:35
Restore doc lines the branch deleted in unrelated crates, and drop the
tokio security changeset: main already carries that Cargo.lock bump, so
this branch no longer changes it. Document `SymlinkTargets` and the
symlink parameters whose docs the branch removed, and reword the
changeset and deploy docs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kairosci
kairosci force-pushed the fix/17288-deploy-dependency-symlinks branch from 2e1b63e to 3368928 Compare October 24, 2026 16:36
Copilot AI lite review requested due to automatic review settings October 24, 2026 16:36

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

The internal symlink policy recreated every link inside the project, so
a file link to a project file outside the deployed set became a dangling
symlink in the output. Before the policy existed, deploy copied such a
file's content, which works wherever the output is moved.

The policy now applies only to directory links: a directory link to a
left-out target is kept, so links into `node_modules` resolve to the
dependencies deploy installs, and a file link to a left-out target is
imported as a file again.

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

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7af1495

@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 Oct 24, 2026

Copy link
Copy Markdown
Member

Pushed 7af1495: the Internal policy now applies only to directory links. A file link whose target is not deployed is copied as a file again, as it was before this PR, because a recreated link would dangle in the output. Directory links to left-out targets (the .next/node_modules/<alias> case from #17288) are still kept. The tests in both versions now assert that a file link to a left-out file is deployed as a copy.

On the two Qodo findings in the review summary, neither needs a change:

  1. Links escaping through an intermediate symlink. Suppose a kept link dir-link -> omitted/secret has an omitted that is itself a link out of the project. Either omitted is not deployed, so it does not exist in the output and the kept link dangles. Or it is deployed, so it is validated itself and refused with SymlinkTargetEscapes. An intermediate node_modules/<dep> link is created by deploy's own install and resolves to the dependency deploy installed, which is the intent. The Internal policy is only used for deploy's copy of the user's own project, never for fetched packages. File links to left-out targets are copied exactly as before this PR, so no new read-through path exists.
  2. Unused path index. Internal still queries the imported-path index for every file link, which is copied when its target is not imported. So the index is not unused.

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

@zkochan
zkochan merged commit 9d361bf into pnpm:main Oct 24, 2026
74 checks passed
@kairosci
kairosci deleted the fix/17288-deploy-dependency-symlinks branch October 24, 2026 20:57
zkochan added a commit that referenced this pull request Oct 27, 2026
…list corpus

- Route every package file selector (`pack`, `DirectoryFetcher`, `GitFetcher`,
  `patch-commit`, `deploy`, and the injected-copy importer and syncers) through
  `pnpm-fs-packlist::select_package_files` and `pnpm-fs`'s internal symlink
  admission and placement API (pnpm/tasks#223).
- Resolve symlinked files to their canonical target before importing as regular
  files in `import_indexed_dir` so `Hardlink` mode materializes a regular file
  rather than a broken symlink.
- Skip internal directory symlinks when importing git-fetched packages into the
  CAS.
- Normalize string `bin` fields in `@pnpm/fs.packlist` when passed an
  unnormalized manifest.
- Add `generated_trees_match_npm_packlist` (`proptest` corpus checked against
  `npm-packlist` and `@pnpm/fs.packlist` with `DELIBERATE_DIVERGENCES`
  allowlist), `pack_matches_npm_pack_dry_run` (checked against `npm pack
  --dry-run --json` and wired into nightly CI), and
  `every_file_selector_agrees_with_pack` (#17033, #17088,
  #17296).

Closes pnpm/tasks#223
zkochan added a commit that referenced this pull request Oct 27, 2026
…list corpus

- Route every package file selector (`pack`, `DirectoryFetcher`, `GitFetcher`,
  `patch-commit`, `deploy`, and the injected-copy importer and syncers) through
  `pnpm-fs-packlist::select_package_files` and `pnpm-fs`'s internal symlink
  admission and placement API (pnpm/tasks#223).
- Resolve symlinked files to their canonical target before importing as regular
  files in `import_indexed_dir` so `Hardlink` mode materializes a regular file
  rather than a broken symlink.
- Skip internal directory symlinks when importing git-fetched packages into the
  CAS.
- Normalize string `bin` fields in `@pnpm/fs.packlist` when passed an
  unnormalized manifest.
- Add `generated_trees_match_npm_packlist` (`proptest` corpus checked against
  `npm-packlist` and `@pnpm/fs.packlist` with `DELIBERATE_DIVERGENCES`
  allowlist), `pack_matches_npm_pack_dry_run` (checked against `npm pack
  --dry-run --json` and wired into nightly CI), and
  `every_file_selector_agrees_with_pack` (#17033, #17088,
  #17296).

Closes pnpm/tasks#223
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.

deploy silently drops project symlinks to dependencies installed in its output

4 participants