Skip to content

feat(cli): project-aware global bins with managed Node.js runtime switching - #13731

Merged
zkochan merged 29 commits into
mainfrom
bare-node
Aug 9, 2026
Merged

zkochan merged 29 commits into
mainfrom
bare-node

Conversation

@zkochan

@zkochan zkochan commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #13735.

Bins installed into the global bin dir (pnpm add -g, pnpm runtime set node -g) become context-aware shims: typing bare node inside a project runs the Node.js version the project pins through devEngines.runtime / engines.runtime, with the release authenticated and executed from pnpm's trusted global virtual store. This is the fnm/nodenv workflow — bare commands following the project you're standing in — but per-invocation instead of per-cd, so it needs no shell hooks and also covers scripts, CI, and editors that spawn node with a project cwd.

Each context-aware shim dispatches through a protocol-versioned executable (.pnpm-shim-v1) installed next to it, so replacing the main pnpm binary with an older version never breaks the global bins; self-update refreshes an existing dispatcher from the newly installed v12+ engine, while leaving it absent for users who have not enabled context-aware shims and preserving it across downgrades. When the dispatcher is missing, shims degrade to direct execution of the global target.

The new globalShims setting is a record of package names to policies selecting which globally installed packages are project-aware, keyed by the providing package's manifest name (so typescript: true covers tsc):

  • The built-in default is { node: true, deno: true, bun: true }. Layers merge key-wise (default → global config.yaml → the pnpm home's pnpm-workspace.yaml → env), so globalShims: { bun: false } switches one default off without restating the rest, and { typescript: true } adds prompted switching for another package.
  • Values name the policy per package: "auto" (shorthand: true) defers to artifact authentication — a stable Node.js pin runs without prompting because the release is authenticated against the Node.js release-team signatures, every other candidate keeps the candidate-bound Do you trust this project? prompt, and if Deno/Bun releases gain publisher signatures later they become promptless with no config change. "always" switches without ever asking — a deliberate, machine-local consent a repository cannot grant itself, which is also the CI story for unsigned runtime pins. "prompt" always asks, even for authenticated candidates. false disables the package's shim.
  • The scalar shorthands globalShims: false (disable everything) and true (just the defaults) are accepted; PNPM_SHIM_BYPASS=1 is a one-invocation bypass. The runtime names only qualify when actually installed through the runtime: protocol, so an npm package that happens to be called node is not elevated.

Security posture:

  • Runtime dispatch never consults the project's node_modules/.bin; a compromised local shim cannot become the executable. The selected release is materialized with scripts and project dependency rewrites disabled, and the resolved package and executable must canonicalize inside the trusted store.
  • The runtime materialization reads its configuration only from machine-local sources (anchored in pnpm's state dir) — a repository cannot redirect the store, mirrors, or registries the dispatched executable comes from — and always installs the host-native artifact, so supportedArchitectures cross-target overrides never select a different binary than the policy checked.
  • Stable Node.js artifacts are publisher-signature-verified during installation, including when downloaded through a mirror. musl hosts are the exception: their assets come from unofficial-builds without signatures, so stable pins stay behind the trust prompt there.
  • Manifest-controlled bin names are escaped in every generated dispatch line (sh single-quoting, PowerShell quote-doubling, cmd %%); .cmd/.bat targets are spawned through the standard library's CVE-2024-24576 argument escaping; project-local candidate lookup never accepts a .exe (identity is derived from the sibling script, so a planted binary cannot ride a benign script's validation); and the test-only trust escape hatch is compiled out of release builds.
  • A local bin must be provided by the same-named package as the global one (provider-name validation), and the first use of each concrete non-signature-verified candidate asks Do you trust this project? on the terminal. Approvals are recorded machine-locally, bound to the provider manifest, canonical target, shim contents, and file identity, so a changed checkout or replaced bin cannot inherit an earlier approval. Non-interactive sessions fall back to the global command.
  • The dispatcher reads its mode only from non-project-controllable sources — the env override, the pnpm home's own pnpm-workspace.yaml, and the global config.yaml — with no ancestor discovery, so neither a repository nor an unrelated workspace above the pnpm home can influence dispatch. Turning globalShims off takes effect immediately, without relinking.

On Windows, globally installed Node.js uses the native dispatcher as node.exe, with the original managed executable recorded as its direct fallback, so programs can continue spawning node.exe without a shell.

This is intentionally a Rust pnpm v12 breaking change; TypeScript pnpm parity is not required.

Squash Commit Body

Bins linked into the global bin dir (pnpm add -g, pnpm runtime set -g)
are written as context-aware shims that dispatch through a
protocol-versioned executable (.pnpm-shim-v1) installed next to them.
The dispatcher walks up from the invocation cwd; under the new
globalShims record's defaults ({ node: true, deno: true, bun: true },
merged key-wise across config layers with scalar false/true
shorthands), a stable Node.js pin in
devEngines.runtime / engines.runtime is resolved, authenticated with
the Node.js release-team signatures, materialized into the trusted
global virtual store (scripts and project dependency rewrites
disabled, package and executable required to canonicalize inside the
store), and executed — bare `node` follows the project's pin with no
shell hooks (closes pnpm/pnpm#13735). Project node_modules/.bin is
never consulted for runtimes.

Entries for unsigned candidates — Deno, Bun, Node.js prereleases, and
any ordinary package the user enables (e.g. typescript: true) — are
gated by provider-name validation and a candidate-bound trust prompt
whose machine-local approvals are tied to the provider manifest,
canonical target, shim contents, and file identity. The record values
name the policy per package: "auto" (shorthand true) defers to
artifact authentication, "always" switches without ever asking,
"prompt" always asks even for authenticated candidates.
globalShims: false dispatches nothing; PNPM_SHIM_BYPASS=1 is a one-invocation
bypass and the dispatcher's recursion guard. The mode is read only from the env override, the
pnpm home's own pnpm-workspace.yaml, and the global config.yaml —
never a discovered ancestor — and takes effect without relinking.

The runtime materialization anchors its configuration in pnpm's state
dir (machine-local sources only, host-native artifacts only) so a
repository cannot redirect the store or mirrors feeding the dispatched
executable; musl hosts stay behind the trust prompt because their
assets are not publisher-signed. Manifest-controlled bin names are
escaped in every dispatch line, batch targets spawn through the
standard library's escaping, project-local lookup rejects .exe
candidates, and the test-only trust escape is debug-builds-only.

On Windows the global node.exe is the native dispatcher itself, with
the managed executable recorded as its direct fallback so shell-less
spawns of node.exe keep working. Fallback paths re-enter the
generated shim with the bypass set so the shell's own shebang
handling performs the direct execution, degrading to the embedded
target when the shim itself cannot be started.

Rust-only by design: this ships in pnpm v12's breaking-change
surface; the TypeScript CLI does not mirror it.

Checklist

  • I checked the referenced issue and verified that none of the PRs already linked to it solves it.
  • The change is implemented in the Rust pnpm/ port only — deliberately: it is a v12-only breaking change and the TypeScript CLI will not receive it (see Summary).
  • Added a changeset (pnpm changeset) for pacquet.
  • Added or updated unit and end-to-end tests, including Windows-native dispatcher coverage.
  • Updated the documentation if needed — pnpm.io documentation for globalShims and the trust prompt is a follow-up once the design settles in review.

Written by agents (Claude Code, claude-fable-5; Codex, GPT-5.6).

Summary by CodeRabbit

  • New Features

    • Added configurable global shims for Node, Deno, and Bun.
    • Global commands can prefer project-local binaries or fall back to globally installed versions.
    • Added off, auto, prompt, and always policies with per-package overrides.
    • Added trust prompts and persistent decisions for unverified runtime candidates.
    • Added PNPM_SHIM_BYPASS=1 for per-invocation bypassing.
    • Added Windows support for context-aware shims and runtime dispatch.
  • Bug Fixes

    • Improved executable replacement reliability and recovery during updates.

zkochan and others added 2 commits August 8, 2026 15:13
Global bins dispatch through `pnpm --shim` and prefer the nearest
project's version of the invoked bin — bare `node` follows the
project's devEngines pin, downloading it on demand when missing.
First use of a project's bins prompts for trust; decisions persist
machine-locally. `globalShims: false` restores direct shims.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

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

Use the following commands to manage reviews:

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

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds configurable context-aware global shims. It links direct or dispatcher-backed binaries, resolves project-local candidates and managed runtimes, persists trust decisions, supports Unix and Windows execution, and adds configuration, unit, and end-to-end tests.

Changes

Context-aware global shims

Layer / File(s) Summary
Configuration and machine-local state
pnpm/crates/config/*, pnpm/crates/config-dir/*, pnpm/crates/crypto-hash/*, pnpm/crates/deps-restorer/...
Adds globalShims policies, workspace merging, environment support, state-directory resolution, file hashing, and related fixtures.
Context-aware shim generation
pnpm/crates/cmd-shim/src/*
Adds direct and context-aware styles for POSIX shell, CMD, and PowerShell shims.
Global linking and executable publication
pnpm/crates/cli/src/cli_args/global.rs, pnpm/crates/global/src/*, pnpm/crates/cli/src/executable_link.rs, pnpm/crates/cli/src/cli_args/self_update/install_pnpm.rs
Global add and update select shim styles from configuration and runtime dependencies. Executable publication uses shared replacement logic.
Dispatcher and managed runtime execution
pnpm/crates/cli/src/shim_dispatch.rs, pnpm/crates/cli/src/lib.rs
Adds candidate discovery, provider validation, trust persistence, runtime materialization, fallback execution, and platform-specific dispatch.
Validation
pnpm/crates/cli/src/shim_dispatch/tests.rs, pnpm/crates/cli/tests/suite/*
Adds coverage for policies, local and global selection, runtime pins, trust, identity checks, malformed input, argument forwarding, and Unix and Windows behavior.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant GeneratedShim
  participant ShimDispatcher
  participant ProjectLocalBin
  participant GlobalTarget
  User->>GeneratedShim: Invoke global binary
  GeneratedShim->>ShimDispatcher: Pass shim metadata and arguments
  ShimDispatcher->>ProjectLocalBin: Resolve project candidate
  ShimDispatcher->>ShimDispatcher: Apply policy and trust checks
  ShimDispatcher->>GlobalTarget: Execute global fallback
  ShimDispatcher->>User: Return command status
Loading

Assessment against linked issues

Objective Addressed Explanation
Add an opt-in shell integration that switches Node.js versions on cd [#13735] ❌ No shell cd/chpwd hook or interactive Node version switching was added.

Out-of-scope changes

Code Change Explanation
Context-aware global shim dispatch and managed runtime execution (pnpm/crates/cli/src/shim_dispatch.rs, lines 101-847) The linked objective requests a shell directory-change hook, not global binary dispatch or runtime selection during shim invocation.

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#13177 — Both changes modify global bin linking and shim generation.
  • pnpm/pnpm#13375 — Both changes modify executable replacement in install_pnpm.rs.
  • pnpm/pnpm#13633 — Both changes modify global add and update bin installation flows.

Suggested labels: product: pacquet

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bare-node

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 Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                                            main                                   pr
-----                                            ----                                   --
lockfile/parse_pnpm_lock                         1.00     11.9±0.03ms    31.5 MB/sec    1.00     11.9±0.04ms    31.5 MB/sec
packument/parse                                  1.00     38.8±0.17µs  1707.8 MB/sec    1.05     40.6±0.27µs  1631.9 MB/sec
tarball/download_dependency                      1.00      2.4±0.08ms  1801.2 KB/sec    1.00      2.4±0.07ms  1808.1 KB/sec
tarball_batch/cold_store_many_medium_tarballs    1.00    176.0±1.73ms 90.9 KElem/sec    1.02    178.8±4.86ms 89.5 KElem/sec
workspace_resolution/hoist_heavy                 1.01    238.9±0.81ms        ? ?/sec    1.00    236.4±1.25ms        ? ?/sec

@codecov-commenter

codecov-commenter commented Aug 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.78614% with 278 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.09%. Comparing base (9b20598) to head (1abb732).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/shim_dispatch/runtime_env.rs 15.20% 106 Missing ⚠️
pnpm/crates/cli/src/shim_dispatch.rs 63.41% 90 Missing ⚠️
pnpm/crates/cli/src/shim_dispatch/trust.rs 56.06% 29 Missing ⚠️
pnpm/crates/config-dir/src/lib.rs 0.00% 18 Missing ⚠️
pnpm/crates/config/src/defaults.rs 0.00% 11 Missing ⚠️
pnpm/crates/cli/src/cli_args/self_update.rs 47.36% 10 Missing ⚠️
pnpm/crates/cli/src/executable_link.rs 84.37% 5 Missing ⚠️
pnpm/crates/cmd-shim/src/link_bins.rs 91.11% 4 Missing ⚠️
pnpm/crates/cli/src/cli_args/global.rs 95.45% 2 Missing ⚠️
...rates/cli/src/cli_args/self_update/install_pnpm.rs 75.00% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13731      +/-   ##
==========================================
- Coverage   88.23%   88.09%   -0.14%     
==========================================
  Files         616      621       +5     
  Lines      100167   101071     +904     
==========================================
+ Hits        88380    89042     +662     
- Misses      11787    12029     +242     

☔ 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 and others added 2 commits August 8, 2026 15:39
The local candidate must be provided by the same-named package as the
global bin, and the trust prompt is skipped when the project's lockfile
has a matching machine-local verification record. `globalShims: false`
now also disables dispatch immediately, without relinking.

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 1abb73216f45

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

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

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.550 ± 0.118 2.346 2.735 1.66 ± 0.23
pacquet@main 2.469 ± 0.096 2.330 2.640 1.61 ± 0.21
pnpr@HEAD 1.533 ± 0.196 1.341 1.790 1.00
pnpr@main 1.548 ± 0.165 1.341 1.747 1.01 ± 0.17
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.54986082096,
      "stddev": 0.1179452839186949,
      "median": 2.54629120176,
      "user": 1.6926766399999997,
      "system": 1.32721224,
      "min": 2.3459975862599998,
      "max": 2.73496087426,
      "times": [
        2.66424126726,
        2.58643946826,
        2.65940376126,
        2.55576067026,
        2.43731751426,
        2.3459975862599998,
        2.73496087426,
        2.45251924626,
        2.53682173326,
        2.52514608826
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.46914064666,
      "stddev": 0.09648357096323633,
      "median": 2.45071661726,
      "user": 1.6833124399999995,
      "system": 1.31363094,
      "min": 2.32991980126,
      "max": 2.64001361826,
      "times": [
        2.64001361826,
        2.32991980126,
        2.37052873326,
        2.45590538526,
        2.4314182402599998,
        2.53181265026,
        2.54113287226,
        2.44552784926,
        2.38834942926,
        2.5567978872599997
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.53302262876,
      "stddev": 0.1956214734214914,
      "median": 1.46321307876,
      "user": 1.2078122399999998,
      "system": 1.1289385399999998,
      "min": 1.34076701626,
      "max": 1.7897351872599998,
      "times": [
        1.7897351872599998,
        1.7102140292599999,
        1.37900834326,
        1.3467471872599999,
        1.54741781426,
        1.36916616426,
        1.35267563526,
        1.76075308226,
        1.34076701626,
        1.73374182826
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5478834895600002,
      "stddev": 0.164577655892559,
      "median": 1.5690951652599998,
      "user": 1.1955142399999998,
      "system": 1.1257061399999997,
      "min": 1.34138880726,
      "max": 1.74721038426,
      "times": [
        1.36402813126,
        1.71178711626,
        1.44688370726,
        1.34138880726,
        1.71455073426,
        1.6423029332599999,
        1.6620879522599998,
        1.49588739726,
        1.74721038426,
        1.3527077322599999
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 257.5 ± 7.8 242.7 270.1 1.03 ± 0.04
pacquet@main 249.9 ± 4.0 243.4 254.6 1.00
pnpr@HEAD 270.6 ± 5.6 261.3 279.9 1.08 ± 0.03
pnpr@main 268.7 ± 5.6 257.0 277.8 1.08 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.25752855504000005,
      "stddev": 0.007846466538850379,
      "median": 0.2566755298400001,
      "user": 0.19779014,
      "system": 0.52205956,
      "min": 0.24274445734,
      "max": 0.27010215734000004,
      "times": [
        0.26884955534000005,
        0.27010215734000004,
        0.25776503934000006,
        0.25558602034000005,
        0.25466975534,
        0.25348542534,
        0.25881731134,
        0.25960436434000006,
        0.24274445734,
        0.25366146434000003
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.24993125444000003,
      "stddev": 0.0039837802987769105,
      "median": 0.25141574734000005,
      "user": 0.19161274,
      "system": 0.51628576,
      "min": 0.24343411034,
      "max": 0.25455467934000003,
      "times": [
        0.25452749334,
        0.25213233934,
        0.25132403734000003,
        0.25179824834000003,
        0.25150745734,
        0.24898507434,
        0.24720267534,
        0.24384642934,
        0.25455467934000003,
        0.24343411034
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.27056379824000004,
      "stddev": 0.005582879545657246,
      "median": 0.26994199084000003,
      "user": 0.21009583999999998,
      "system": 0.5068370600000001,
      "min": 0.26130962234000005,
      "max": 0.27989525334000004,
      "times": [
        0.27844317534,
        0.26130962234000005,
        0.27246599534000004,
        0.27209265734000004,
        0.27989525334000004,
        0.27137742934000003,
        0.26773587934000004,
        0.26713604034000005,
        0.26667537734,
        0.26850655234000004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.26870538964000007,
      "stddev": 0.005569715542129626,
      "median": 0.26992118084000005,
      "user": 0.20247014000000002,
      "system": 0.51522036,
      "min": 0.25703427534,
      "max": 0.27783864134,
      "times": [
        0.26995114634000006,
        0.27783864134,
        0.25703427534,
        0.27136020534000005,
        0.27090069434,
        0.26989121534000005,
        0.26815329334000004,
        0.26257317134,
        0.26810285034000003,
        0.27124840334000005
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 2.581 ± 0.013 2.565 2.605 1.62 ± 0.12
pacquet@main 2.576 ± 0.012 2.545 2.592 1.62 ± 0.12
pnpr@HEAD 1.605 ± 0.161 1.436 1.832 1.01 ± 0.12
pnpr@main 1.595 ± 0.115 1.465 1.802 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.5814473582,
      "stddev": 0.013112597450885517,
      "median": 2.5785716287,
      "user": 1.6625702,
      "system": 1.3540859399999998,
      "min": 2.5652597067,
      "max": 2.6047286766999997,
      "times": [
        2.5797711557,
        2.5986888577,
        2.6047286766999997,
        2.5747052977,
        2.5799793747,
        2.5917878937,
        2.5773721017,
        2.5652597067,
        2.5764586537,
        2.5657218637
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.5762761228999995,
      "stddev": 0.01230036996410497,
      "median": 2.5786600932,
      "user": 1.6857205999999998,
      "system": 1.3100481399999997,
      "min": 2.5454177377000002,
      "max": 2.5924578557,
      "times": [
        2.5814311307,
        2.5820000897,
        2.5706420437,
        2.5924578557,
        2.5773491056999998,
        2.5767982206999998,
        2.5824009457,
        2.5799710807,
        2.5742930187,
        2.5454177377000002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.6049670654,
      "stddev": 0.1607845591072967,
      "median": 1.5619662312,
      "user": 1.1794759,
      "system": 1.1573123399999998,
      "min": 1.4361766367,
      "max": 1.8315405677,
      "times": [
        1.4477285247,
        1.4361766367,
        1.4549244827,
        1.4966994067,
        1.8233341747,
        1.8315405677,
        1.6272330557,
        1.4900072627,
        1.7736987496999999,
        1.6683277927
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.5946473782,
      "stddev": 0.11514489495455243,
      "median": 1.5821698311999999,
      "user": 1.1627157000000001,
      "system": 1.1564446399999997,
      "min": 1.4649838327,
      "max": 1.8015499737,
      "times": [
        1.5483885947,
        1.8015499737,
        1.6277209017,
        1.4773434167000001,
        1.7634904817,
        1.6159510677,
        1.6184127947,
        1.5260864277000001,
        1.5025462907,
        1.4649838327
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 430.4 ± 9.2 421.7 448.0 1.45 ± 0.04
pacquet@main 413.8 ± 12.4 390.3 430.6 1.39 ± 0.05
pnpr@HEAD 299.6 ± 12.4 288.7 331.0 1.01 ± 0.05
pnpr@main 297.5 ± 5.6 290.4 306.6 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.43041249608000004,
      "stddev": 0.009205502422618323,
      "median": 0.42719391338,
      "user": 0.5171555399999999,
      "system": 0.7123398599999999,
      "min": 0.42170164938000004,
      "max": 0.44795387138000003,
      "times": [
        0.43245454038000003,
        0.42329510638,
        0.44795387138000003,
        0.42170164938000004,
        0.42965421138000004,
        0.43566690938,
        0.44275603338,
        0.42329072938,
        0.42473361538000004,
        0.42261829438000004
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.41380691888000004,
      "stddev": 0.012364280710981576,
      "median": 0.41258977788000006,
      "user": 0.5050571399999999,
      "system": 0.68341186,
      "min": 0.39033771438000003,
      "max": 0.43058631238,
      "times": [
        0.39033771438000003,
        0.40674837138000003,
        0.41366391038,
        0.43058631238,
        0.40973681938,
        0.41314036538000004,
        0.42717743238000006,
        0.41203919038000003,
        0.40569840638000004,
        0.42894066638
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.29955244287999994,
      "stddev": 0.012433980735551544,
      "median": 0.29731925638,
      "user": 0.17289503999999997,
      "system": 0.5185278600000001,
      "min": 0.28869273738,
      "max": 0.33096331338,
      "times": [
        0.33096331338,
        0.29374505638000004,
        0.28869273738,
        0.29417783138000003,
        0.30046068138000004,
        0.30178756338,
        0.28989911938,
        0.28960941338,
        0.30389599938,
        0.30229271338
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29754652938000004,
      "stddev": 0.005631096114491589,
      "median": 0.29587032788,
      "user": 0.18580484,
      "system": 0.5046524600000001,
      "min": 0.29038724238,
      "max": 0.30660642938000005,
      "times": [
        0.29551850138,
        0.30660642938000005,
        0.30263900438,
        0.30111301938,
        0.30374430338,
        0.29134284338,
        0.29038724238,
        0.29237329438000004,
        0.29586092738,
        0.29587972838000004
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.718 ± 0.007 1.702 1.728 5.75 ± 0.11
pacquet@main 1.722 ± 0.009 1.710 1.739 5.76 ± 0.11
pnpr@HEAD 0.301 ± 0.006 0.293 0.310 1.01 ± 0.03
pnpr@main 0.299 ± 0.006 0.287 0.307 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.71783635592,
      "stddev": 0.0072803445768385155,
      "median": 1.7172805957200001,
      "user": 0.7617416799999999,
      "system": 0.7651285800000001,
      "min": 1.7018894357199998,
      "max": 1.72783554272,
      "times": [
        1.71773493772,
        1.7140692367200001,
        1.7234740047200001,
        1.7146557197199999,
        1.71544571772,
        1.72422072272,
        1.72221198772,
        1.71682625372,
        1.7018894357199998,
        1.72783554272
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.7219165517200001,
      "stddev": 0.008838393112349047,
      "median": 1.72401448622,
      "user": 0.76664518,
      "system": 0.7715561799999999,
      "min": 1.71019281972,
      "max": 1.73852237472,
      "times": [
        1.71222571772,
        1.7260975567199999,
        1.72863794272,
        1.71841739372,
        1.7251967797199999,
        1.7241903247200001,
        1.71184595972,
        1.71019281972,
        1.73852237472,
        1.7238386477199998
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30142079712,
      "stddev": 0.005973566785481777,
      "median": 0.30083247172000005,
      "user": 0.17409038,
      "system": 0.52627728,
      "min": 0.29336296072,
      "max": 0.31019891472000005,
      "times": [
        0.30441044272,
        0.29502232472,
        0.31019891472000005,
        0.29788083972,
        0.30336948572000005,
        0.29336296072,
        0.30462498072000005,
        0.31000594472000004,
        0.29703661972,
        0.29829545772000005
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.29900640122000005,
      "stddev": 0.005586581740201195,
      "median": 0.29871230122000003,
      "user": 0.18875577999999998,
      "system": 0.51159618,
      "min": 0.28671704072000004,
      "max": 0.30668241972000004,
      "times": [
        0.29688189772,
        0.29761916372,
        0.29971992372,
        0.29770467872,
        0.30249307272000003,
        0.30526892172000003,
        0.29620970972000005,
        0.30076718372000005,
        0.28671704072000004,
        0.30668241972000004
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 227.6 ± 17.1 195.0 258.4 2.55 ± 0.22
pacquet@main 224.2 ± 22.9 199.0 269.2 2.51 ± 0.28
pnpr@HEAD 90.8 ± 3.9 85.7 103.2 1.02 ± 0.06
pnpr@main 89.4 ± 3.7 85.1 104.2 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.2276148973123077,
      "stddev": 0.01706237188423311,
      "median": 0.22349846662,
      "user": 0.1692757969230769,
      "system": 0.07914290615384616,
      "min": 0.19501460562,
      "max": 0.25844027062,
      "times": [
        0.22349846662,
        0.24618789962,
        0.23103194562,
        0.23321543662,
        0.22084203062,
        0.22330904162,
        0.21416615262,
        0.25844027062,
        0.19501460562,
        0.20927409762,
        0.21972242462,
        0.23998626962,
        0.24430502362
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.22424006534727275,
      "stddev": 0.022929821422242886,
      "median": 0.22473770062,
      "user": 0.16194353818181814,
      "system": 0.08488378727272727,
      "min": 0.19895781162,
      "max": 0.26921996362000006,
      "times": [
        0.25341404662000006,
        0.21694149462,
        0.23094292462,
        0.26921996362000006,
        0.22473770062,
        0.20100521262,
        0.22537621862,
        0.23919356862,
        0.20072396062,
        0.20612781662,
        0.19895781162
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09083522840125002,
      "stddev": 0.00393176462394708,
      "median": 0.09105020762,
      "user": 0.023058688750000004,
      "system": 0.010704903750000001,
      "min": 0.08572246562000001,
      "max": 0.10322068262,
      "times": [
        0.08910779062,
        0.08731369062000001,
        0.09627648562,
        0.08588867562000001,
        0.10322068262,
        0.09766356762,
        0.09243799762,
        0.08862850762,
        0.08935342562000001,
        0.09110987162,
        0.09183614362,
        0.09566755062000001,
        0.08975447062000001,
        0.08615738662000001,
        0.09157224262000001,
        0.09147684262000001,
        0.09587873462,
        0.09456667062,
        0.09247294662000001,
        0.09099054362,
        0.09025293862000001,
        0.08699346162,
        0.08801078962,
        0.09121776262,
        0.09152735362,
        0.09116887962,
        0.08588747062,
        0.08768510462000001,
        0.08896958962000001,
        0.09167160262000001,
        0.08572246562000001,
        0.08624566262000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.08937266437000001,
      "stddev": 0.003676474525880055,
      "median": 0.08927799112000001,
      "user": 0.022345188749999995,
      "system": 0.01011752125,
      "min": 0.08505701262000001,
      "max": 0.10422950462000001,
      "times": [
        0.08709938462000001,
        0.08681613562000001,
        0.08542851762,
        0.08575303662,
        0.08704321062,
        0.09213575462000001,
        0.08680077862,
        0.08999275162,
        0.09154120162000001,
        0.09021131962000001,
        0.08659280862,
        0.08569388362000001,
        0.08909990562,
        0.08984680962000001,
        0.08591932262,
        0.08600353862000001,
        0.08729725362,
        0.08505701262000001,
        0.09231899262000001,
        0.09100235962000001,
        0.09341620162000001,
        0.08865746462,
        0.09059378862,
        0.08793934262000001,
        0.08945607662,
        0.09296411862000001,
        0.09079182562,
        0.10422950462000001,
        0.09057361362,
        0.08664052162000001,
        0.09138411562000001,
        0.09162470762000001
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 836.9 ± 183.8 582.3 1108.7 1.18 ± 0.39
pacquet@main 708.9 ± 172.6 536.2 1015.8 1.00
pnpm@HEAD 2975.2 ± 131.5 2869.9 3229.5 4.20 ± 1.04
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.8369239411666667,
      "stddev": 0.1837771536106097,
      "median": 0.8787906785,
      "user": 0.7714447711111112,
      "system": 0.18053236666666667,
      "min": 0.5823475945000001,
      "max": 1.1087443315,
      "times": [
        0.9949708155000001,
        1.1087443315,
        0.5984146215,
        0.8999850395000001,
        0.7574071055,
        0.5823475945000001,
        0.8787906785,
        0.9915925745,
        0.7200627095000001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.7089368046111111,
      "stddev": 0.17259518829245743,
      "median": 0.6139533105,
      "user": 0.6533839933333332,
      "system": 0.12795014444444444,
      "min": 0.5362306405,
      "max": 1.0158318545,
      "times": [
        1.0158318545,
        0.6139533105,
        0.5921443015,
        0.5924739695,
        0.7375036335,
        0.7829195725,
        0.5708403235,
        0.5362306405,
        0.9385336355
      ]
    },
    {
      "command": "pnpm@HEAD",
      "mean": 2.9751876411666665,
      "stddev": 0.1314744864693575,
      "median": 2.9059559975,
      "user": 4.239877326666667,
      "system": 0.3024988111111111,
      "min": 2.8698771655,
      "max": 3.2294902135,
      "times": [
        2.8826679405,
        2.8974163545000002,
        2.8927934705000005,
        3.0337030285,
        2.9059559975,
        3.2294902135,
        2.8698771655,
        2.9175764785000005,
        3.1472081215000003
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.574 ± 0.166 4.430 4.882 1.31 ± 0.05
pacquet@main 4.515 ± 0.094 4.429 4.676 1.29 ± 0.03
pnpr@HEAD 3.534 ± 0.125 3.451 3.825 1.01 ± 0.04
pnpr@main 3.500 ± 0.039 3.453 3.563 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.573552040200001,
      "stddev": 0.1656655022534087,
      "median": 4.5014065406,
      "user": 1.82367338,
      "system": 1.43956484,
      "min": 4.4302946766,
      "max": 4.8817626076,
      "times": [
        4.6008107296,
        4.4513517576,
        4.5112756296,
        4.8461423506,
        4.4302946766,
        4.4458169806,
        4.8817626076,
        4.4915374516,
        4.4604945346000004,
        4.6160336835999995
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.5154938575,
      "stddev": 0.09402895102261251,
      "median": 4.4843359191,
      "user": 1.8679870800000002,
      "system": 1.4219491399999997,
      "min": 4.4291653596,
      "max": 4.6757731066,
      "times": [
        4.4291653596,
        4.4420978376,
        4.5664581696,
        4.4678715336,
        4.6711363856,
        4.4456548986,
        4.6757731066,
        4.5008003046,
        4.5229779346,
        4.4330030446
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.5335622494999996,
      "stddev": 0.12479789014844664,
      "median": 3.4780203351,
      "user": 1.32801828,
      "system": 1.2212861399999997,
      "min": 3.4510369976,
      "max": 3.8251333786,
      "times": [
        3.4961306106,
        3.4900235896,
        3.4553240056,
        3.5459571956,
        3.4604696656,
        3.4591949736,
        3.6863349976,
        3.4510369976,
        3.8251333786,
        3.4660170806
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.500476856,
      "stddev": 0.039378287024118185,
      "median": 3.4805854976,
      "user": 1.30061488,
      "system": 1.23425634,
      "min": 3.4534865476,
      "max": 3.5626771436,
      "times": [
        3.4729845096,
        3.5240771166,
        3.4677022756,
        3.4842804856000003,
        3.5394998246,
        3.4768905096,
        3.4734819846000002,
        3.5626771436,
        3.5496881626,
        3.4534865476
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13731
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
2,565.26 ms
(-3.91%)Baseline: 2,669.59 ms
3,203.50 ms
(80.08%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,701.89 ms
(-3.98%)Baseline: 1,772.52 ms
2,127.02 ms
(80.01%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
421.70 ms
(-6.54%)Baseline: 451.23 ms
541.48 ms
(77.88%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
195.01 ms
(-11.99%)Baseline: 221.59 ms
265.91 ms
(73.34%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,346.00 ms
(-4.01%)Baseline: 2,444.06 ms
2,932.87 ms
(79.99%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,430.29 ms
(-2.09%)Baseline: 4,524.95 ms
5,429.94 ms
(81.59%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
242.74 ms
(-14.47%)Baseline: 283.82 ms
340.58 ms
(71.27%)
isolated-linker.peer-heavy-resolve.hot-cache.offline📈 view plot
🚷 view threshold
582.35 ms
(-20.25%)Baseline: 730.18 ms
876.21 ms
(66.46%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Projectpnpm's project
Branchpr/13731
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

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

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,436.18 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
293.36 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
288.69 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
85.72 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,340.77 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,451.04 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
261.31 ms
🐰 View full continuous benchmarking report in Bencher

zkochan added 2 commits August 8, 2026 17:33
Default globalShims to auto. It follows only publisher-signature-verified stable Node.js pins.

Resolve runtimes from the trusted global virtual store. Do not consult project bin entries.

Keep ordinary package switching behind globalShims: all, retain off and the one-shot bypass.

Install a native Windows node.exe dispatcher with a recorded direct fallback.
@zkochan zkochan changed the title feat(cli): context-aware global bin shims feat(cli): secure automatic Node.js runtime shims Aug 8, 2026
zkochan and others added 5 commits August 8, 2026 19:49
The dispatcher's mode now reads the pnpm home's own
pnpm-workspace.yaml directly instead of walking the home's ancestors,
so an unrelated workspace above the pnpm home can no longer influence
dispatch. The Windows node dispatcher refuses a target file that
points back at itself instead of recursing. A fallback shim the host
cannot execute degrades to the embedded target instead of failing the
invocation.

Co-Authored-By: Claude Fable 5 <[email protected]>
@zkochan zkochan changed the title feat(cli): secure automatic Node.js runtime shims feat(cli): project-aware global bins with managed Node.js runtime switching Aug 9, 2026
zkochan and others added 6 commits August 9, 2026 10:19
`globalShims` selects eligible packages as a record of package names
to booleans, keyed by the providing package's manifest name and
merged key-wise over the built-in { node, deno, bun } defaults across
config layers, with scalar false/true shorthands. Eligibility stays
orthogonal to trust: signature-verified stable Node runs promptless,
every other eligible candidate keeps the candidate-bound prompt.

Co-Authored-By: Claude Fable 5 <[email protected]>
The setting is now `contextAwareGlobalShims` — every global bin is a
shim either way; what the record controls is which ones are
context-aware. Values grow from booleans into policies:
`true` defers to artifact authentication, `"trusted"` pre-answers
the trust prompt for a package (machine-local consent a repository
cannot grant itself, and the CI story for unsigned runtime pins),
`"prompt"` always asks even for authenticated candidates, `false`
disables the package's shim.

Co-Authored-By: Claude Fable 5 <[email protected]>
…cy to always

In the version-manager lineage (rbenv, asdf, Volta, corepack, mise) a
shim is by definition the executable that picks the project's version,
so the short name is the ecosystem-correct one; the context-aware
qualifier restated an internal implementation contrast users don't
share. The `"trusted"` value read ambiguously as a condition
("only when the source is trusted") when it grants consent, so it is
now `"always"`: always switch, never prompt.

Co-Authored-By: Claude Fable 5 <[email protected]>
With "prompt" and "always" in the vocabulary, a bare true sat next to
them as a third, unnamed policy. "auto" names it — defer to artifact
authentication — and the booleans stay as shorthand (true ≡ "auto",
false ≡ disabled).

Co-Authored-By: Claude Fable 5 <[email protected]>
The cfg(windows) test still passed the raw target path where
validate_candidate now takes the resolved provider; Linux builds never
compile it, so Windows CI was the first to see the mismatch.

Co-Authored-By: Claude Fable 5 <[email protected]>
@zkochan
zkochan marked this pull request as ready for review August 9, 2026 09:28
Copilot AI lite review requested due to automatic review settings August 9, 2026 09:28

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 reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 623e6c5

The trust prompt leaves a human-scale window between fingerprinting a
candidate and executing it; a bin swapped during that window would run
without approval. Revalidating right before exec closes it — the
residual race is process-scale and requires an attacker already
executing code as the user, outside the gate's threat model.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings August 9, 2026 12:09

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 reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1abb732

@zkochan
zkochan merged commit 8a453e3 into main Aug 9, 2026
33 checks passed
@zkochan
zkochan deleted the bare-node branch August 9, 2026 12:36
zkochan added a commit that referenced this pull request Aug 9, 2026
The managed runtime dispatcher read the entire pnpm executable to detect libc on every invocation. Since the bundled executable is tens of megabytes, this dominated otherwise warm runtime dispatch.

Detect libc by opening /proc/self/exe and seeking only to the bounded ELF header, program-header table, and PT_INTERP value. Preserve the existing filesystem and command fallbacks for malformed or unsupported ELF layouts.

Do not add persistent launcher state: every managed runtime invocation continues through the existing materialization path and reloads current trusted configuration. This brings warm runtime dispatch close to direct process startup without introducing cache invalidation or a new executable-path trust surface.

Related to #13731.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shell hook to auto-switch Node.js version on cd

3 participants