Skip to content

fix(self-update): stop the project config from steering the pnpm download - #12813

Merged
zkochan merged 10 commits into
pnpm:mainfrom
aqeelat:fix/self-update-minimum-release-age
Jul 24, 2026
Merged

zkochan merged 10 commits into
pnpm:mainfrom
aqeelat:fix/self-update-minimum-release-age

Conversation

@aqeelat

@aqeelat aqeelat commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #12803.

pnpm self-update resolved the pnpm download through the active project's registry/auth config and loaded the repo's default .pnpmfile.(c|m)js, and its minimumReleaseAge policy came from the workspace manifest with no limit on the direction. That is one reported bug and one unreported hole:

  • the reported one — a workspace minimumReleaseAge makes self-update fail inside the repo and succeed outside it, with nothing in the error pointing at the workspace setting;
  • the unreported one — the same manifest could set minimumReleaseAge: 0, minimumReleaseAgeStrict: false, or list pnpm in minimumReleaseAgeExclude and silently switch off the cooldown the user configured globally, on the one download that replaces the binary every later install runs through.

This PR closes both without giving up the protection.

The fetch goes through the trusted package-manager bootstrap config. That is the channel switchCliVersion / syncEnvLockfile already use and that pacquet's self-update already used — it is built from the non-project config sources, so a project .npmrc or pnpm-workspace.yaml cannot redirect the pnpm download or attach its own credentials to it. getPackageManagerBootstrapConfig moved from pnpm11/pnpm/src into @pnpm/config.reader so the command package can use it too. The repo's default pnpmfile is no longer auto-loaded for self-update: its updateConfig hook can rewrite any setting and its customResolvers / customFetchers reach the same requests. Pnpmfiles from trusted sources (the pnpmfile setting, the global pnpmfile, config-dependency plugins) still load.

The project's release-age settings no longer reach self-update. minimumReleaseAge is dangerous in both directions for a command that replaces the global binary: lowering it waives the cooldown the user configured, and raising it pins the machine to the installed pnpm — including past a release that fixes a vulnerability in it. Unlike a blocked dependency upgrade, that decision follows the user into every other project. So pnpm-workspace.yaml gets no say: the cutoff comes from the built-in default, the global config, PNPM_CONFIG_*, or a CLI flag. Every other command is unaffected, and there is no new default — at zero config pnpm self-update behaves exactly as before.

Nor do its trustPolicy settings or its ci flag. The same reasoning covers the rest of what decides whether the binary may be replaced. Self-update's resolve is its only version selection, so trustPolicy / trustPolicyExclude / trustPolicyIgnoreAfter are what run the no-downgrade check on the pnpm release itself — a repo that turns the policy off waives it, one that turns it on blocks the update. And ci gates the confirmation prompt below: ci: false in a checkout would re-enable it on a CI runner with a pseudo-TTY, exactly where self-update has to fail closed. Global config, env, and CLI flags still set all of them.

The refusal is actionable. An interactive run offers to update anyway when the requested version is younger than the cutoff, the same way a strict install prompts — the cutoff can now only be the user's own policy, so confirming it is theirs to give. CI and other non-interactive runs still fail closed with ERR_PNPM_NO_MATURE_MATCHING_VERSION. A trustPolicy downgrade remains non-negotiable.

Both stacks: the TypeScript config reader skips the settings under getConfig({ forSelfUpdate: true }), pacquet under Config::current_for_self_update, and both commands gained the same prompt and message. Pacquet's gate detects CI with is_ci — the crate package_manager::install already uses for its own prompt — so a runner that attaches a pseudo-TTY fails closed there too. pnpm's ci setting remains unported in pacquet (it sits in the pnpm_default_parity NOT_PORTED bucket), which is why pacquet detects CI at each point of use rather than reading it from config.

Squash Commit Body

Fixes pnpm/pnpm#12803.

`pnpm self-update` resolved the pnpm download through the project's own
registry/auth config, loaded the repo's default `.pnpmfile.(c|m)js`, and took
its `minimumReleaseAge` policy from the active workspace — so the outcome of a
global tooling operation depended on the directory it ran in, and on config a
checkout controls.

Route the fetch through the trusted package-manager bootstrap config — the
channel `switchCliVersion` already uses, which excludes the project `.npmrc`
and workspace manifest — and stop auto-loading the repo pnpmfile, whose
`updateConfig` hook and custom resolvers/fetchers reach the same requests.
`getPackageManagerBootstrapConfig` moves into `@pnpm/config.reader` so the
command package can reuse it.

Stop reading the project's `minimumReleaseAge` and `trustPolicy` settings, and
its `ci` flag, for self-update. Each is dangerous in both directions for a
command that replaces the global binary: a cooldown lowered waives the
protection the user configured, raised it pins the machine to the installed
pnpm, including past a release that fixes a vulnerability in it; a trust policy
turned off accepts a release whose evidence the user meant to reject, turned on
blocks the update the same way; and `ci` decides whether an immature pick may be
confirmed at the keyboard at all. Unlike a blocked dependency upgrade, those
decisions follow the user into every other project. The policies come from the
built-in defaults, the global config, the environment, and CLI flags instead.
Other commands keep reading them from `pnpm-workspace.yaml`, and there is no new
default.

When an immature version is refused, an interactive run offers to update
anyway, matching how a strict install prompts; non-interactive runs still fail
closed.

Mirrored in pacquet: `Config::current_for_self_update` skips the same settings,
and `self-update` gained the matching prompt and error.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
  • Updated the documentation if needed.

Originally written by an agent (opencode, glm-5.2); reworked by an agent (Claude Code, claude-opus-4-8).

@coderabbitai

coderabbitai Bot commented Jul 5, 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

pnpm self-update now uses a self-update-specific config path in the Rust pacquet CLI and the pnpm11 config reader. That path skips workspace and project .npmrc inputs, and forces minimumReleaseAgeStrict unless explicitly disabled.

Changes

Self-update trusted config path

Layer / File(s) Summary
Config crate self-update path
pacquet/crates/config/src/lib.rs, pacquet/crates/config/src/workspace_yaml.rs, pacquet/crates/config/src/tests.rs
Adds Config::current_for_self_update, skips project .npmrc and workspace yaml application in self-update mode, forces minimum_release_age_strict by default, and adds coverage for skipped workspace settings, skipped .npmrc, and env overrides.
Pacquet self-update config routing
pacquet/crates/cli/src/cli_args/dispatch.rs, pacquet/crates/cli/src/cli_args/dispatch_query.rs, pacquet/crates/cli/tests/self_update.rs
Adds a self-update config closure to RunCtx, routes self_update through that closure, and adds CLI coverage for reaching the resolver path.
Config reader self-update mode
pnpm11/config/reader/src/index.ts, pnpm11/config/reader/src/loadNpmrcFiles.ts, pnpm11/config/reader/test/index.ts
Adds forSelfUpdate to config reader options, skips project .npmrc and workspace manifest settings when it is set, forces minimumReleaseAgeStrict unless explicitly disabled, and adds tests for workspace settings and release-age overrides.
pnpm self-update forwarding
pnpm11/pnpm/src/getConfig.ts, pnpm11/pnpm/src/main.ts, .changeset/self-update-release-age.md
Threads forSelfUpdate through pnpm/src/getConfig.ts, enables it from main.ts for self-update, and updates the changeset entry.

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

Assessment against linked issues

Objective Addressed Explanation
pnpm self-update should ignore workspace minimumReleaseAge settings and still work inside a workspace [#12803] ✅
Behavior should not depend on the current working directory [#12803] ✅

Possibly related PRs

  • pnpm/pnpm#11664: Both PRs change self-update release-age handling in the resolver/config path.
  • pnpm/pnpm#11736: Both PRs change Config::current layering structure in pacquet/crates/config/src/lib.rs.
  • pnpm/pnpm#11752: Both PRs touch workspace-yaml/config layering in the shared config reader.

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

Suggested reviewers: zkochan, KSXGitHub

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

❤️ Share

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

@aqeelat
aqeelat marked this pull request as ready for review July 5, 2026 01:22
@aqeelat
aqeelat requested a review from zkochan as a code owner July 5, 2026 01:22
Copilot AI review requested due to automatic review settings July 5, 2026 01:22
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Self-update: load config from trusted sources and force strict release-age by default

🐞 Bug fix ✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Route self-update config loading through trusted layers, ignoring workspace settings and project
 .npmrc.
• Enforce minimumReleaseAgeStrict=true for self-update unless explicitly disabled via trusted
 inputs.
• Add Rust+TS tests and a changeset covering the new self-update behavior.
Diagram

graph TD
A(["Self-update cmd"]) --> B{{"Use trusted config"}} --> C["TS getConfig (forSelfUpdate)"] --> D["Npmrc loader (ignore project)"] --> E[("Trusted layers")]
B --> F["Rust Config::current_for_self_update"] --> G[("Trusted layers")]
E --> H["Self-update resolver"]
G --> H

subgraph Legend
direction LR
_cmd(["Command"]) ~~~ _dec{{"Decision"}} ~~~ _mod["Module"] ~~~ _src[("Trusted source")]
end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Allowlist only self-update-relevant keys from workspace/.npmrc
  • ➕ Less behavior change for users relying on workspace config during self-update
  • ➕ Can still block the most sensitive settings (registry/auth/release-age)
  • ➖ Hard to maintain: new keys can accidentally become security-sensitive later
  • ➖ Still allows repo-controlled config to influence parts of the update path, increasing attack surface
  • ➖ Diverges from the stated security goal of trusted-sources-only self-update
2. Run self-update in an isolated directory (e.g., PNPM_HOME) and never read project files
  • ➕ Even stronger isolation from repo-controlled files
  • ➕ Simpler conceptual model: self-update never consults project context
  • ➖ Would break the current behavior of updating packageManager/devEngines.packageManager pins in the project
  • ➖ More surprising UX and likely requires additional flags/flow to update pins
3. Introduce an explicit `--ignore-project-config` / `--trusted-config-only` mode and enable it for self-update
  • ➕ Reusable safety mechanism for other commands with similar risks
  • ➕ Makes the trust model explicit and testable across commands
  • ➖ More surface area (new flag + docs + support) for a targeted fix
  • ➖ Still requires implementing the same trusted-layer semantics under the hood

Recommendation: Keep the PR’s approach: a dedicated self-update config-loading path that skips repo-controlled .npmrc and workspace settings, while still reading package.json for pin updates. This provides a clear security boundary (trusted sources only) and eliminates cwd-dependent behavior; the alternatives either add long-term maintenance risk (allowlists) or break existing pin-update behavior (full isolation).

Files changed (12) +364 / -50

Enhancement (6) +148 / -46
dispatch.rsAdd self-update-specific config closure and shared finalization +25/-15

Add self-update-specific config closure and shared finalization

• Extends 'RunCtx' with a 'config_self_update' loader and introduces a 'finalize_config' helper to apply CLI-only overrides consistently. Routes standard commands through 'Config::current' and self-update through 'Config::current_for_self_update'.

pacquet/crates/cli/src/cli_args/dispatch.rs

lib.rsAdd 'current_for_self_update' and skip repo-controlled config layers +75/-21

Add 'current_for_self_update' and skip repo-controlled config layers

• Introduces 'Config::current_for_self_update' backed by a shared 'current_inner(..., for_self_update)' implementation. When enabled, skips reading project '.npmrc' and applying workspace manifest settings, and forces 'minimum_release_age_strict=true' unless explicitly disabled via trusted config/env.

pacquet/crates/config/src/lib.rs

index.tsAdd 'forSelfUpdate' flag to load config from trusted layers only +28/-1

Add 'forSelfUpdate' flag to load config from trusted layers only

• Adds a 'forSelfUpdate' option to 'getConfig' that skips workspace-manifest settings merge and ignores project '.npmrc' for fetch-related config. Forces 'minimumReleaseAgeStrict=true' by default for self-update unless explicitly opted out via trusted CLI/env/global config.

pnpm11/config/reader/src/index.ts

loadNpmrcFiles.tsSupport ignoring project '.npmrc' during npmrc loading +17/-9

Support ignoring project '.npmrc' during npmrc loading

• Extends npmrc loading with 'ignoreProjectNpmrc' to omit the workspace/project '.npmrc' layer. Keeps user '.npmrc', auth.ini, env, and CLI sources intact.

pnpm11/config/reader/src/loadNpmrcFiles.ts

getConfig.tsPlumb 'forSelfUpdate' through pnpm wrapper getConfig +2/-0

Plumb 'forSelfUpdate' through pnpm wrapper getConfig

• Adds an optional 'forSelfUpdate' flag to pnpm’s 'getConfig' wrapper and forwards it into the config reader.

pnpm11/pnpm/src/getConfig.ts

main.tsEnable trusted-only config loading for the self-update command +1/-0

Enable trusted-only config loading for the self-update command

• Sets 'forSelfUpdate' when 'cmd === 'self-update'', ensuring the self-update invocation uses the trusted-only config loading behavior end-to-end.

pnpm11/pnpm/src/main.ts

Bug fix (1) +4 / -1
dispatch_query.rsRoute pacquet self-update through trusted-only config loader +4/-1

Route pacquet self-update through trusted-only config loader

• Updates the 'self_update' dispatcher to call 'ctx.config_self_update()' instead of the regular config closure. Preserves early corepack rejection before any project config could interfere.

pacquet/crates/cli/src/cli_args/dispatch_query.rs

Tests (3) +204 / -0
self_update.rsAdd dispatch-level self-update wiring test +45/-0

Add dispatch-level self-update wiring test

• Adds a CLI test ensuring 'self-update' reaches the handler and triggers expected output, validating the dispatch path uses the self-update config closure. Accepts resolver failure due to mock registry limitations.

pacquet/crates/cli/tests/self_update.rs

tests.rsTest trusted-only self-update config semantics +76/-0

Test trusted-only self-update config semantics

• Adds unit tests verifying 'current_for_self_update' drops all workspace settings, ignores project '.npmrc' registry overrides, and honors trusted env overrides for release-age policy.

pacquet/crates/config/src/tests.rs

index.tsAdd forSelfUpdate tests covering trust boundary and strict defaults +83/-0

Add forSelfUpdate tests covering trust boundary and strict defaults

• Adds test coverage ensuring 'forSelfUpdate' drops all workspace settings, ignores project '.npmrc', forces strict-by-default release-age, and respects CLI opt-outs ('--minimum-release-age=0', '--minimum-release-age-strict=false').

pnpm11/config/reader/test/index.ts

Documentation (2) +8 / -3
self-update-release-age.mdAdd changeset documenting trusted-only self-update config +6/-0

Add changeset documenting trusted-only self-update config

• Introduces a changeset announcing that 'pnpm self-update' ignores workspace settings and project '.npmrc' for fetch-related config. Documents the strict-by-default release-age policy and opt-out mechanisms.

.changeset/self-update-release-age.md

workspace_yaml.rsClarify WorkspaceSettings apply_to documentation +2/-3

Clarify WorkspaceSettings apply_to documentation

• Minor doc/comment refinement around how path-valued workspace settings are resolved against the workspace root base directory.

pacquet/crates/config/src/workspace_yaml.rs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 5, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (2) 📜 Skill insights (0)

Context used

Grey Divider


Action required

1. Workspace dir not set 🐞 Bug ≡ Correctness
Description
In pacquet current_for_self_update, workspace YAML settings are skipped by not calling
WorkspaceSettings::apply_to(), but that also prevents Config.workspace_dir from being set even
when the workspace root was discovered. self-update later uses config.workspace_dir to locate
the workspace-root env lockfile / root dir, so running self-update from a workspace subdirectory
may read/write lockfile state in the wrong directory.
Code

pacquet/crates/config/src/lib.rs[R2047-2056]

+                // `self-update` loads config from trusted sources only, so
+                // the repo-controlled project workspace manifest does not
+                // contribute settings — not just release-age, all of them.
+                // It can still be discovered for structural context above;
+                // the project `package.json` is read separately for
+                // `packageManager` pin detection.
+                if !for_self_update {
+                    collect_explicit_settings(&mut self.explicit_settings, &settings);
+                    settings.apply_to(&mut self, &base_dir);
+                }
Evidence
The PR change gates settings.apply_to() behind !for_self_update, but apply_to() is the code
that assigns Config.workspace_dir. self-update then relies on config.workspace_dir to locate
the workspace-root lockfile/root dir; when it is None it falls back to the current dir, which is
wrong for workspace subdirectory invocations.

pacquet/crates/config/src/lib.rs[2029-2056]
pacquet/crates/config/src/workspace_yaml.rs[772-775]
pacquet/crates/cli/src/cli_args/self_update.rs[260-330]

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

## Issue description
`Config::current_for_self_update()` skips applying workspace settings by bypassing `WorkspaceSettings::apply_to()`. However, `apply_to()` is also where `config.workspace_dir` is assigned (workspace-root structural context). Without `workspace_dir`, `self-update` falls back to using the command `dir` for workspace-root operations (env lockfile reads/writes and persistence), which can mis-anchor these operations when invoked from a workspace subdirectory.
### Issue Context
- In `WorkspaceSettings::apply_to`, `config.workspace_dir` is set unconditionally to the discovered workspace root (`base_dir`).
- In `current_inner(..., for_self_update=true)`, `settings.apply_to(...)` is skipped, so `workspace_dir` stays `None`.
- `pacquet self-update` uses `config.workspace_dir.as_deref().unwrap_or(dir)` to pick the lockfile/root directory.
### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[2034-2056]
Implement by setting `self.workspace_dir = Some(base_dir.to_path_buf())` whenever a workspace root is discovered (i.e., when `workspace_yaml` is `Some((base_dir, _))`), even in `for_self_update` mode, while still skipping *other* workspace settings application.
Also ensure the env-var workspace-dir path branch (`NPM_CONFIG_WORKSPACE_DIR`) similarly sets `workspace_dir` when it provides a base dir, even if the YAML file is missing.

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


2. Self-update executes repo hooks 🐞 Bug ⛨ Security
Description
pnpm self-update still runs installConfigDepsAndLoadHooks before dispatch, which (by default)
auto-loads and executes .pnpmfile.(mjs|cjs) from the current project; those hooks can inject
custom resolvers/fetchers and steer where self-update downloads pnpm from despite forSelfUpdate
skipping repo .npmrc/workspace settings. This undermines the PR’s threat model (repo-controlled
steering) and allows arbitrary code execution on self-update invocation inside a malicious repo.
Code

pnpm11/pnpm/src/main.ts[114]

+      forSelfUpdate: cmd === 'self-update',
Evidence
The self-update hardening only affects config loading; the CLI still loads and executes repo hooks
by default, and those hooks are wired into resolver/fetcher construction used by self-update,
allowing a repo to steer the download path despite skipping .npmrc and workspace settings.

pnpm11/pnpm/src/main.ts[109-151]
pnpm11/pnpm/src/main.ts[365-372]
pnpm11/config/reader/src/index.ts[254-267]
pnpm11/pnpm/src/getConfig.ts[47-99]
pnpm11/hooks/pnpmfile/src/requireHooks.ts[54-92]
pnpm11/store/connection-manager/src/createNewStoreController.ts[71-83]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[213-215]

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

## Issue description
`pnpm self-update` now loads config from trusted sources via `forSelfUpdate`, but it still executes repo-controlled hook code because the CLI always calls `installConfigDepsAndLoadHooks()` before command dispatch. That function auto-loads the default project `.pnpmfile.(mjs|cjs)` when no explicit `pnpmfile` is configured, and those hooks can provide `customFetchers/customResolvers` used by the store/resolver stack.
This creates a bypass: a malicious repo can add a `.pnpmfile.cjs` that runs arbitrary code and/or redirects the `self-update` fetch through a custom fetcher, negating the “trusted sources only” hardening.
## Issue Context
- `main.ts` sets `forSelfUpdate` but still unconditionally loads hooks/configDependencies.
- `installConfigDepsAndLoadHooks()` calls `requireHooks()` with `tryLoadDefaultPnpmfile` when `config.pnpmfile == null`.
- `requireHooks()` loads `.pnpmfile.mjs` or `.pnpmfile.cjs` from the project prefix.
- The store/client wiring uses `opts.hooks?.customFetchers/customResolvers`, and `self-update` uses `createStoreController(opts)`.
## Fix Focus Areas
- pnpm11/pnpm/src/main.ts[109-151]
- pnpm11/pnpm/src/getConfig.ts[47-100]
### Suggested fix approach
Implement a self-update-specific guard so repo hooks cannot run:
1. When `cmd === 'self-update'`, skip hook loading entirely (recommended), e.g. don’t call `requireHooks` / don’t run `installConfigDepsAndLoadHooks`, or call a variant that only installs trusted `configDependencies` but does not load any pnpmfile.
2. If you must keep hook loading, at minimum disable *default* pnpmfile loading for self-update (do not auto-load `.pnpmfile.*`), and only honor explicitly configured pnpmfiles from trusted layers.
Add a regression test to prove that `.pnpmfile.cjs` in a workspace is not executed during `pnpm self-update` (e.g., have it write a marker file and assert it is absent).

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


3. self-update still reads workspace settings 📎 Requirement gap ≡ Correctness
Description
ignoreProjectReleaseAge only skips minimumReleaseAge*, while other pnpm-workspace.yaml
settings are still applied, so pnpm self-update can behave differently depending on whether it is
run inside a workspace.
Code

pnpm11/config/reader/src/index.ts[R1061-1096]

+// The `minimumReleaseAge` family. When `self-update` loads config, these are
+// ignored on the project workspace manifest so the policy is sourced from
+// trusted layers only.
+const RELEASE_AGE_CFG_KEYS = new Set([
+  'minimumReleaseAge',
+  'minimumReleaseAgeExclude',
+  'minimumReleaseAgeIgnoreMissingTime',
+  'minimumReleaseAgeStrict',
+])
+
function addSettingsFromWorkspaceManifestToConfig (pnpmConfig: Config & ConfigContext, {
configFromCliOpts,
expandRequestDestinationEnv,
+  ignoreProjectReleaseAge,
projectManifest,
workspaceManifest,
workspaceDir,
}: {
configFromCliOpts: Record<string, unknown>
expandRequestDestinationEnv?: boolean
+  ignoreProjectReleaseAge?: boolean
projectManifest: ProjectManifest | undefined
workspaceDir: string | undefined
workspaceManifest: WorkspaceManifest
}): void {
const newSettings = Object.assign(getOptionsFromPnpmSettings(workspaceDir, workspaceManifest, { manifest: projectManifest, expandRequestDestinationEnv }), configFromCliOpts)
for (const [key, value] of Object.entries(newSettings)) {
if (!isCamelCase(key)) continue
+    // `self-update` sources its release-age policy from trusted layers only
+    // (built-in default, global rc.yaml, CLI flags, and `PNPM_CONFIG_*` /
+    // `pnpm_config_*` env vars), never from the repo-controlled project
+    // workspace manifest — see `ignoreProjectReleaseAge`.
+    if (ignoreProjectReleaseAge && RELEASE_AGE_CFG_KEYS.has(key)) continue
// @ts-expect-error
pnpmConfig[key] = value
Evidence
PR Compliance ID 2 requires pnpm self-update to produce the same result regardless of cwd. The
implementation of ignoreProjectReleaseAge only skips minimumReleaseAge* keys and continues
applying other workspace settings from pnpm-workspace.yaml, and the newly added test explicitly
asserts that unrelated workspace settings (e.g. nodeLinker) are still read when
ignoreProjectReleaseAge is enabled.

pnpm self-update behavior must be consistent regardless of current working directory
pnpm11/config/reader/src/index.ts[1061-1098]
pnpm11/config/reader/test/index.ts[575-592]

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

## Issue description
`pnpm self-update` is required to behave consistently regardless of the current working directory, but the new `ignoreProjectReleaseAge` flag only filters out `minimumReleaseAge*` keys and still applies other workspace-manifest settings.
## Issue Context
This means running `pnpm self-update <version>` inside a workspace can pick up repo-controlled settings (e.g. registry-related config) that are not present outside the workspace, which can change the command's outcome.
## Fix Focus Areas
- pnpm11/config/reader/src/index.ts[1061-1098]
- pnpm11/pnpm/src/main.ts[109-115]

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


View more (1)
4. Pacquet self-update enforces maturity 📎 Requirement gap ≡ Correctness
Description
Self-update is required to bypass resolver maturity filtering, but the current self-update config
path forces minimum_release_age_strict=true (even when ignoreProjectReleaseAge is enabled) while
leaving the default minimum_release_age/minimumReleaseAge in effect. As a result,
pacquet/pnpm self-update  can still reject the requested pnpm engine/binary due to maturity
policy, violating PR Compliance ID 2.
Code

pacquet/crates/config/src/lib.rs[R2156-2165]

+        // `self-update` self-protects: enforce a strict release-age for pnpm
+        // itself by default, even at zero config, so a freshly published
+        // malicious pnpm cannot reach users before the cutoff elapses. The
+        // policy is sourced from trusted layers only (built-in default,
+        // global `config.yaml`, env) — the project workspace manifest was
+        // already skipped. An explicit `minimum_release_age_strict: false`
+        // (global / env) or `minimum_release_age: 0` opts out.
+        if ignore_project_release_age && self.minimum_release_age_strict != Some(false) {
+            self.minimum_release_age_strict = Some(true);
+        }
Evidence
PR Compliance ID 2 states that self-update must proceed without applying maturity filtering, yet the
new configuration logic for the self-update path explicitly enables strictness
(minimum_release_age_strict=Some(true) / minimumReleaseAgeStrict=true). The tests confirm that,
under self-update, the default minimum age threshold remains active (e.g., minimumReleaseAge=1440)
while strict mode is turned on; because the self-update handler consults the resolved minimum
release age together with strictness and fails closed on policy_violation, this combination can
block “immature” pnpm versions even when self-update is invoked.

pnpm self-update must not enforce dependency resolver maturity rules on the pnpm binary
pacquet/crates/config/src/lib.rs[2156-2165]
pacquet/crates/config/src/tests.rs[1839-1854]
pacquet/crates/cli/src/cli_args/self_update.rs[135-143]
pnpm11/config/reader/src/index.ts[574-582]
pnpm11/config/reader/test/index.ts[551-573]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-113]

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

## Issue description
Self-update flows (`pacquet self-update` / `pnpm self-update <version>`) must not enforce resolver maturity filtering (`minimum_release_age*` / `minimumReleaseAge*`) when selecting the pnpm engine/binary version, but the current self-update config logic enables strict maturity checking by default while keeping the default minimum release age active. This can cause self-update to fail (or reject explicitly requested versions) due to policy violations, contrary to PR Compliance ID 2.
## Issue Context
- PR Compliance ID 2 requires self-update to proceed without maturity filtering.
- The current self-update resolver/handler path evaluates `resolved_minimum_release_age` together with strictness and fails closed on `policy_violation`.
- Tests indicate self-update retains the default minimum release age (e.g., `minimumReleaseAge=1440`) while setting strictness on (`minimum_release_age_strict=Some(true)` / `minimumReleaseAgeStrict=true`), which is sufficient to trigger maturity-based blocking.
## Fix Focus Areas
- pacquet/crates/config/src/lib.rs[2156-2165]
- pnpm11/config/reader/src/index.ts[574-582]

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



Remediation recommended

5. Workspace YAML blocks self-update 🐞 Bug ☼ Reliability
Description
The self-update config path still parses the repo-controlled pnpm-workspace.yaml (via
getConfig()/readWorkspaceManifest() and Config::current_for_self_update() routing through
current_inner()), so a malformed or unreadable workspace manifest can abort pnpm/`pacquet
self-update` before reaching the resolver even though workspace settings aren’t applied. This
preserves a repository-controlled denial-of-service vector in the intended “trusted sources only”
self-update flow.
Code

pnpm11/config/reader/src/index.ts[R471-481]

const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir)
pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? ['.']
-      if (workspaceManifest) {
+      // `self-update` loads config from trusted sources only, so the
+      // repo-controlled workspace manifest does not contribute settings (it
+      // can still be discovered for structural context). The project
+      // `package.json` above is still read for `packageManager` pin detection.
+      if (workspaceManifest && !opts.forSelfUpdate) {
addSettingsFromWorkspaceManifestToConfig(pnpmConfig, {
 configFromCliOpts,
 projectManifest: pnpmConfig.rootProjectManifest,
Evidence
The cited logic shows that getConfig() reads the workspace manifest before gating on
!opts.forSelfUpdate, and that readWorkspaceManifest() throws on any error other than ENOENT
(including invalid YAML or permission issues), meaning pnpm self-update can fail purely due to a
broken repo pnpm-workspace.yaml. Similarly, Config::current_for_self_update() calls
current_inner(..., true), and current_inner() still invokes
WorkspaceSettings::find_and_load(), which explicitly propagates read/parse failures except ENOENT,
so a malformed/unreadable workspace YAML can still block pacquet self-update despite the intent to
avoid repo-controlled configuration.

pnpm11/config/reader/src/index.ts[470-485]
pnpm11/workspace/workspace-manifest-reader/src/index.ts[37-54]
pacquet/crates/config/src/lib.rs[1720-1739]
pacquet/crates/config/src/lib.rs[1785-1816]
pacquet/crates/config/src/workspace_yaml.rs[593-627]

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 self-update paths (`opts.forSelfUpdate` / `Config::current_for_self_update()`) are intended to avoid repo-controlled configuration impacting updates, but they still attempt to load/parse the repo’s `pnpm-workspace.yaml` and propagate non-ENOENT read/parse errors. This means an invalid YAML file or permission-denied workspace manifest can stop `pnpm`/`pacquet self-update` from running at all, leaving a repo-controlled DoS vector in the “trusted sources only” flow.
## Issue Context
Even if workspace settings are not applied during self-update, failing early on workspace manifest read/parse errors still allows a repository to prevent users from updating by committing a malformed `pnpm-workspace.yaml` or manipulating permissions. The self-update path should be able to proceed using trusted sources even when workspace settings cannot be loaded.
## Fix Focus Areas
- pnpm11/config/reader/src/index.ts[470-485]
- pnpm11/workspace/workspace-manifest-reader/src/index.ts[37-54]
- pacquet/crates/config/src/lib.rs[1720-1816]
- pacquet/crates/config/src/workspace_yaml.rs[593-627]

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


Grey Divider

Previous review results

Review updated until commit afb864d

Results up to commit afb864d


🐞 Bugs (3) 📘 Rule violations (0) 📎 Requirement gaps (2) 📜 Skill insights (0)

Context used

Action required
1. Workspace dir not set 🐞 Bug ≡ Correctness
Description
In pacquet current_for_self_update, workspace YAML settings are skipped by not calling
WorkspaceSettings::apply_to(), but that also prevents Config.workspace_dir from being set even
when the workspace root was discovered. self-update later uses config.workspace_dir to locate
the workspace-root env lockfile / root dir, so running self-update from a workspace subdirectory
may read/write lockfile state in the wrong directory.
Code

pacquet/crates/config/src/lib.rs[R2047-2056]

+                // `self-update` loads config from trusted sources only, so
+                // the repo-controlled project workspace manifest does not
+                // contribute settings — not just release-age, all of them.
+                // It can still be discovered for structural context above;
+                // the project `package.json` is read separately for
+                // `packageManager` pin detection.
+                if !for_self_update {
+                    collect_explicit_settings(&mut self.explicit_settings, &settings);
+                    settings.apply_to(&mut self, &base_dir);
+                }
Evidence
The PR change gates settings.apply_to() behind !for_self_update, but apply_to() is the code
that assigns Config.workspace_dir. self-update then relies on config.workspace_dir to locate
the workspace-root lockfile/root dir; when it is None it falls back to the current dir, which is
wrong for workspace subdirectory invocations.

pacquet/crates/config/src/lib.rs[2029-2056]
pacquet/crates/config/src/workspace_yaml.rs[772-775]
pacquet/crates/cli/src/cli_args/self_update.rs[260-330]

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

## Issue description
`Config::current_for_self_update()` skips applying workspace settings by bypassing `WorkspaceSettings::apply_to()`. However, `apply_to()` is also where `config.workspace_dir` is assigned (workspace-root structural context). Without `workspace_dir`, `self-update` falls back to using the command `dir` for workspace-root operations (env lockfile reads/writes and persistence), which can mis-anchor these operations when invoked from a workspace subdirectory.
### Issue Context
- In `WorkspaceSettings::apply_to`, `config.workspace_dir` is set unconditionally to the discovered workspace root (`base_dir`).
- In `current_inner(..., for_self_update=true)`, `settings.apply_to(...)` is skipped, so `workspace_dir` stays `None`.
- `pacquet self-update` uses `config.workspace_dir.as_deref().unwrap_or(dir)` to pick the lockfile/root directory.
### Fix Focus Areas
- pacquet/crates/config/src/lib.rs[2034-2056]
Implement by setting `self.workspace_dir = Some(base_dir.to_path_buf())` whenever a workspace root is discovered (i.e., when `workspace_yaml` is `Some((base_dir, _))`), even in `for_self_update` mode, while still skipping *other* workspace settings application.
Also ensure the env-var workspace-dir path branch (`NPM_CONFIG_WORKSPACE_DIR`) similarly sets `workspace_dir` when it provides a base dir, even if the YAML file is missing.

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


2. Self-update executes repo hooks 🐞 Bug ⛨ Security
Description
pnpm self-update still runs installConfigDepsAndLoadHooks before dispatch, which (by default)
auto-loads and executes .pnpmfile.(mjs|cjs) from the current project; those hooks can inject
custom resolvers/fetchers and steer where self-update downloads pnpm from despite forSelfUpdate
skipping repo .npmrc/workspace settings. This undermines the PR’s threat model (repo-controlled
steering) and allows arbitrary code execution on self-update invocation inside a malicious repo.
Code

pnpm11/pnpm/src/main.ts[114]

+      forSelfUpdate: cmd === 'self-update',
Evidence
The self-update hardening only affects config loading; the CLI still loads and executes repo hooks
by default, and those hooks are wired into resolver/fetcher construction used by self-update,
allowing a repo to steer the download path despite skipping .npmrc and workspace settings.

pnpm11/pnpm/src/main.ts[109-151]
pnpm11/pnpm/src/main.ts[365-372]
pnpm11/config/reader/src/index.ts[254-267]
pnpm11/pnpm/src/getConfig.ts[47-99]
pnpm11/hooks/pnpmfile/src/requireHooks.ts[54-92]
pnpm11/store/connection-manager/src/createNewStoreController.ts[71-83]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[213-215]

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

## Issue description
`pnpm self-update` now loads config from trusted sources via `forSelfUpdate`, but it still executes repo-controlled hook code because the CLI always calls `installConfigDepsAndLoadHooks()` before command dispatch. That function auto-loads the default project `.pnpmfile.(mjs|cjs)` when no explicit `pnpmfile` is configured, and those hooks can provide `customFetchers/customResolvers` used by the store/resolver stack.
This creates a bypass: a malicious repo can add a `.pnpmfile.cjs` that runs arbitrary code and/or redirects the `self-update` fetch through a custom fetcher, negating the “trusted sources only” hardening.
## Issue Context
- `main.ts` sets `forSelfUpdate` but still unconditionally loads hooks/configDependencies.
- `installConfigDepsAndLoadHooks()` calls `requireHooks()` with `tryLoadDefaultPnpmfile` when `config.pnpmfile == null`.
- `requireHooks()` loads `.pnpmfile.mjs` or `.pnpmfile.cjs` from the project prefix.
- The store/client wiring uses `opts.hooks?.customFetchers/customResolvers`, and `self-update` uses `createStoreController(opts)`.
## Fix Focus Areas
- pnpm11/pnpm/src/main.ts[109-151]
- pnpm11/pnpm/src/getConfig.ts[47-100]
### Suggested fix approach
Implement a self-update-specific guard so repo hooks cannot run:
1. When `cmd === 'self-update'`, skip hook loading entirely (recommended), e.g. don’t call `requireHooks` / don’t run `installConfigDepsAndLoadHooks`, or call a variant that only installs trusted `configDependencies` but does not load any pnpmfile.
2. If you must keep hook loading, at minimum disable *default* pnpmfile loading for self-update (do not auto-load `.pnpmfile.*`), and only honor explicitly configured pnpmfiles from trusted layers.
Add a regression test to prove that `.pnpmfile.cjs` in a workspace is not executed during `pnpm self-update` (e.g., have it write a marker file and assert it is absent).

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


3. self-update still reads workspace settings 📎 Requirement gap ≡ Correctness
Description
ignoreProjectReleaseAge only skips minimumReleaseAge*, while other pnpm-workspace.yaml
settings are still applied, so pnpm self-update can behave differently depending on whether it is
run inside a workspace.
Code

pnpm11/config/reader/src/index.ts[R1061-1096]

+// The `minimumReleaseAge` family. When `self-update` loads config, these are
+// ignored on the project workspace manifest so the policy is sourced from
+// trusted layers only.
+const RELEASE_AGE_CFG_KEYS = new Set([
+  'minimumReleaseAge',
+  'minimumReleaseAgeExclude',
+  'minimumReleaseAgeIgnoreMissingTime',
+  'minimumReleaseAgeStrict',
+])
+
function addSettingsFromWorkspaceManifestToConfig (pnpmConfig: Config & ConfigContext, {
configFromCliOpts,
expandRequestDestinationEnv,
+  ignoreProjectReleaseAge,
projectManifest,
workspaceManifest,
workspaceDir,
}: {
configFromCliOpts: Record<string, unknown>
expandRequestDestinationEnv?: boolean
+  ignoreProjectReleaseAge?: boolean
projectManifest: ProjectManifest | undefined
workspaceDir: string | undefined
workspaceManifest: WorkspaceManifest
}): void {
const newSettings = Object.assign(getOptionsFromPnpmSettings(workspaceDir, workspaceManifest, { manifest: projectManifest, expandRequestDestinationEnv }), configFromCliOpts)
for (const [key, value] of Object.entries(newSettings)) {
if (!isCamelCase(key)) continue
+    // `self-update` sources its release-age policy from trusted layers only
+    // (built-in default, global rc.yaml, CLI flags, and `PNPM_CONFIG_*` /
+    // `pnpm_config_*` env vars), never from the repo-controlled project
+    // workspace manifest — see `ignoreProjectReleaseAge`.
+    if (ignoreProjectReleaseAge && RELEASE_AGE_CFG_KEYS.has(key)) continue
// @ts-expect-error
pnpmConfig[key] = value
Evidence
PR Compliance ID 2 requires pnpm self-update to produce the same result regardless of cwd. The
implementation of ignoreProjectReleaseAge only skips minimumReleaseAge* keys and continues
applying other workspace settings from pnpm-workspace.yaml, and the newly added test explicitly
asserts that unrelated workspace settings (e.g. nodeLinker) are still read when
ignoreProjectReleaseAge is enabled.

pnpm self-update behavior must be consistent regardless of current working directory
pnpm11/config/reader/src/index.ts[1061-1098]
pnpm11/config/reader/test/index.ts[575-592]

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

## Issue description
`pnpm self-update` is required to behave consistently regardless of the current working directory, but the new `ignoreProjectReleaseAge` flag only filters out `minimumReleaseAge*` keys and still applies other workspace-manifest settings.
## Issue Context
This means running `pnpm self-update <version>` inside a workspace can pick up repo-controlled settings (e.g. registry-related config) that are not present outside the workspace, which can change the command's outcome.
## Fix Focus Areas
- pnpm11/config/reader/src/index.ts[1061-1098]
- pnpm11/pnpm/src/main.ts[109-115]

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


View more (1)
4. Pacquet self-update enforces maturity 📎 Requirement gap ≡ Correctness
Description
Self-update is required to bypass resolver maturity filtering, but the current self-update config
path forces minimum_release_age_strict=true (even when ignoreProjectReleaseAge is enabled) while
leaving the default minimum_release_age/minimumReleaseAge in effect. As a result,
pacquet/pnpm self-update  can still reject the requested pnpm engine/binary due to maturity
policy, violating PR Compliance ID 2.
Code

pacquet/crates/config/src/lib.rs[R2156-2165]

+        // `self-update` self-protects: enforce a strict release-age for pnpm
+        // itself by default, even at zero config, so a freshly published
+        // malicious pnpm cannot reach users before the cutoff elapses. The
+        // policy is sourced from trusted layers only (built-in default,
+        // global `config.yaml`, env) — the project workspace manifest was
+        // already skipped. An explicit `minimum_release_age_strict: false`
+        // (global / env) or `minimum_release_age: 0` opts out.
+        if ignore_project_release_age && self.minimum_release_age_strict != Some(false) {
+            self.minimum_release_age_strict = Some(true);
+        }
Evidence
PR Compliance ID 2 states that self-update must proceed without applying maturity filtering, yet the
new configuration logic for the self-update path explicitly enables strictness
(minimum_release_age_strict=Some(true) / minimumReleaseAgeStrict=true). The tests confirm that,
under self-update, the default minimum age threshold remains active (e.g., minimumReleaseAge=1440)
while strict mode is turned on; because the self-update handler consults the resolved minimum
release age together with strictness and fails closed on policy_violation, this combination can
block “immature” pnpm versions even when self-update is invoked.

pnpm self-update must not enforce dependency resolver maturity rules on the pnpm binary
pacquet/crates/config/src/lib.rs[2156-2165]
pacquet/crates/config/src/tests.rs[1839-1854]
pacquet/crates/cli/src/cli_args/self_update.rs[135-143]
pnpm11/config/reader/src/index.ts[574-582]
pnpm11/config/reader/test/index.ts[551-573]
pnpm11/engine/pm/commands/src/self-updater/selfUpdate.ts[83-113]

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

## Issue description
Self-update flows (`pacquet self-update` / `pnpm self-update <version>`) must not enforce resolver maturity filtering (`minimum_release_age*` / `minimumReleaseAge*`) when selecting the pnpm engine/binary version, but the current self-update config logic enables strict maturity checking by default while keeping the default minimum release age active. This can cause self-update to fail (or reject explicitly requested versions) due to policy violations, contrary to PR Compliance ID 2.
## Issue Context
- PR Compliance ID 2 requires self-update to proceed without maturity filtering.
- The current self-update resolver/handler path evaluates `resolved_minimum_release_age` together with strictness and fails closed on `policy_violation`.
- Tests indicate self-update retains the default minimum release age (e.g., `minimumReleaseAge=1440`) while setting strictness on (`minimum_release_age_strict=Some(true)` / `minimumReleaseAgeStrict=true`), which is sufficient to trigger maturity-based blocking.
## Fix Focus Areas
- pacquet/crates/config/src/lib.rs[2156-2165]
- pnpm11/config/reader/src/index.ts[574-582]

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



Remediation recommended
5. Workspace YAML blocks self-update 🐞 Bug ☼ Reliability
Description
The self-update config path still parses the repo-controlled pnpm-workspace.yaml (via
getConfig()/readWorkspaceManifest() and Config::current_for_self_update() routing through
current_inner()), so a malformed or unreadable workspace manifest can abort pnpm/`pacquet
self-update` before reaching the resolver even though workspace settings aren’t applied. This
preserves a repository-controlled denial-of-service vector in the intended “trusted sources only”
self-update flow.
Code

pnpm11/config/reader/src/index.ts[R471-481]

const workspaceManifest = await readWorkspaceManifest(pnpmConfig.workspaceDir)
pnpmConfig.workspacePackagePatterns = cliOptions['workspace-packages'] as string[] ?? workspaceManifest?.packages ?? ['.']
-      if (workspaceManifest) {
+      // `self-update` loads config from trusted sources only, so the
+      // repo-controlled workspace manifest does not contribute settings (it
+      // can still be discovered for structural context). The project
+      // `package.json` above is still read for `packageManager` pin detection.
+      if (workspaceManifest && !opts.forSelfUpdate) {
addSettingsFromWorkspaceManifestToConfig(pnpmConfig, {
  configFromCliOpts,
  projectManifest: pnpmConfig.rootProjectManifest,
Evidence
The cited logic shows that getConfig() reads the workspace manifest before gating on
!opts.forSelfUpdate, and that readWorkspaceManifest() throws on any error other than ENOENT
(including invalid YAML or permission issues), meaning pnpm self-update can fail purely due to a
broken repo pnpm-workspace.yaml. Similarly, Config::current_for_self_update() calls
current_inner(..., true), and current_inner() still invokes
WorkspaceSettings::find_and_load(), which explicitly propagates read/parse failures except ENOENT,
so a malformed/unreadable workspace YAML can still block pacquet self-update despite the intent to
avoid repo-controlled configuration.

pnpm11/config/reader/src/index.ts[470-485]
pnpm11/workspace/workspace-manifest-reader/src/index.ts[37-54]
pacquet/crates/config/src/lib.rs[1720-1739]
pacquet/crates/config/src/lib.rs[1785-1816]
pacquet/crates/config/src/workspace_yaml.rs[593-627]

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 self-update paths (`opts.forSelfUpdate` / `Config::current_for_self_update()`) are intended to avoid repo-controlled configuration impacting updates, but they still attempt to load/parse the repo’s `pnpm-workspace.yaml` and propagate non-ENOENT read/parse errors. This means an invalid YAML file or permission-denied workspace manifest can stop `pnpm`/`pacquet self-update` from running at all, leaving a repo-controlled DoS vector in the “trusted sources only” flow.
## Issue Context
Even if workspace settings are not applied during self-update, failing early on workspace manifest read/parse errors still allows a repository to prevent users from updating by committing a malformed `pnpm-workspace.yaml` or manipulating permissions. The self-update path should be able to proceed using trusted sources even when workspace settings cannot be loaded.
## Fix Focus Areas
- pnpm11/config/reader/src/index.ts[470-485]
- pnpm11/workspace/workspace-manifest-reader/src/index.ts[37-54]
- pacquet/crates/config/src/lib.rs[1720-1816]
- pacquet/crates/config/src/workspace_yaml.rs[593-627]

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


Qodo Logo

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.

Pull request overview

This PR fixes #12803 by making pnpm self-update ignore minimumReleaseAge* settings coming from the current project’s pnpm-workspace.yaml, so the self-update release-age policy cannot be influenced by the directory you run the command from. The change is implemented in both the TypeScript CLI and the Rust pacquet/ port, with tests and a changeset.

Changes:

  • Add an ignoreProjectReleaseAge config-loading mode used by self-update to skip minimumReleaseAge* from the project workspace manifest and default minimumReleaseAgeStrict to true unless explicitly disabled by trusted sources.
  • Add TypeScript config-reader tests validating workspace release-age keys are ignored while unrelated workspace settings still apply and CLI overrides still work.
  • Mirror the behavior in pacquet by adding current_for_self_update and routing pacquet’s self-update command through it, plus Rust tests.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm11/pnpm/src/main.ts Routes self-update through config loading with ignoreProjectReleaseAge.
pnpm11/pnpm/src/getConfig.ts Threads the new ignoreProjectReleaseAge option through the pnpm CLI wrapper.
pnpm11/config/reader/src/index.ts Skips minimumReleaseAge* keys from project workspace manifest when requested and enforces strict-by-default for self-update.
pnpm11/config/reader/test/index.ts Adds coverage for the self-update “trusted layers only” release-age behavior.
pacquet/crates/config/src/workspace_yaml.rs Adds workspace-settings application mode that can skip release-age fields.
pacquet/crates/config/src/lib.rs Introduces current_for_self_update and enforces strict-by-default when ignoring project release age.
pacquet/crates/config/src/tests.rs Adds tests validating workspace release-age policy is ignored for self-update and env overrides are honored.
pacquet/crates/cli/src/cli_args/dispatch.rs Adds a separate config loader closure for self-update using current_for_self_update.
pacquet/crates/cli/src/cli_args/dispatch_query.rs Switches pacquet self-update to use the self-update-specific config loader.
.changeset/self-update-release-age.md Publishes the behavioral change as a patch release note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pnpm11/config/reader/src/index.ts Resolved
Comment thread pnpm11/config/reader/src/index.ts Resolved
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 09c7c7e

@codecov-commenter

codecov-commenter commented Jul 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.47619% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.96%. Comparing base (209aa31) to head (30b4a0d).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pnpm/crates/cli/src/cli_args/self_update.rs 0.00% 26 Missing ⚠️
pnpm/crates/cli/src/config_deps.rs 25.00% 3 Missing ⚠️
pnpm/crates/cli/src/cli_args/dispatch.rs 97.29% 1 Missing ⚠️
pnpm/crates/config/src/workspace_yaml.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12813      +/-   ##
==========================================
+ Coverage   86.91%   86.96%   +0.05%     
==========================================
  Files         530      530              
  Lines       90785    90848      +63     
==========================================
+ Hits        78903    79008     +105     
+ Misses      11882    11840      -42     

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pacquet/crates/config/src/lib.rs (1)

2000-2046: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Skip minimumReleaseAge* from explicit_settings on self-update. config_to_record() reads Config::explicit_settings for pnpm config list/get, so workspace minimumReleaseAge* values are still surfaced as explicit even when self-update ignores them. Filter those keys in the ignore_project_release_age branch so the reported config matches the effective one.

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

In `@pacquet/crates/config/src/lib.rs` around lines 2000 - 2046,
`Config::explicit_settings` is still collecting workspace `minimumReleaseAge*`
entries even when `ignore_project_release_age` is true, so `pnpm config
list/get` can report values that are not actually applied. Update the
`workspace_yaml` handling in `Config` so the `ignore_project_release_age` path
filters out `minimumReleaseAge*` before or during `collect_explicit_settings`,
while leaving the normal `settings.apply_to` path unchanged. Use the existing
`collect_explicit_settings` and `apply_to_skipping_release_age` flow to keep the
recorded explicit config aligned with the effective config seen by
`config_to_record()`.
🧹 Nitpick comments (2)
pacquet/crates/cli/src/cli_args/dispatch.rs (1)

156-217: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

config and config_self_update closures duplicate the same post-load finalization logic.

Both closures are identical except for the current::<Host> vs current_for_self_update::<Host> call — the override-application, recursive/filter/filter_prod assignment, and Config::leak block (Lines 162-176 and 188-194) is copy-pasted. This is exactly the kind of duplication that tends to drift silently (e.g., a future field added to one finalization path and forgotten in the other).

♻️ Proposed refactor to share the finalization step
+        let finalize_config = |mut cfg: Config| -> &'static mut Config {
+            config_overrides.apply(&mut cfg);
+            cfg.recursive = recursive;
+            cfg.filter.clone_from(&filter);
+            cfg.filter_prod.clone_from(&filter_prod);
+            Config::leak(cfg)
+        };
         let config = || -> miette::Result<&'static mut Config> {
             Config { npmrc_auth_file: npmrc_auth_file.clone(), ..Config::default() }
                 .current::<Host>(&dir)
-                .map(|mut cfg| {
-                    config_overrides.apply(&mut cfg);
-                    cfg.recursive = recursive;
-                    cfg.filter.clone_from(&filter);
-                    cfg.filter_prod.clone_from(&filter_prod);
-                    Config::leak(cfg)
-                })
+                .map(finalize_config)
                 .map_err(miette::Report::new)
                 .wrap_err("load configuration")
         };
         let config_self_update = || -> miette::Result<&'static mut Config> {
             Config { npmrc_auth_file: npmrc_auth_file.clone(), ..Config::default() }
                 .current_for_self_update::<Host>(&dir)
-                .map(|mut cfg| {
-                    config_overrides.apply(&mut cfg);
-                    cfg.recursive = recursive;
-                    cfg.filter.clone_from(&filter);
-                    cfg.filter_prod.clone_from(&filter_prod);
-                    Config::leak(cfg)
-                })
+                .map(finalize_config)
                 .map_err(miette::Report::new)
                 .wrap_err("load configuration")
         };
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pacquet/crates/cli/src/cli_args/dispatch.rs` around lines 156 - 217, The
config-loading closures duplicate the same post-load finalization logic, so
extract that shared step from `config` and `config_self_update` into a single
helper and reuse it after `current::<Host>` / `current_for_self_update::<Host>`.
Keep the helper responsible for applying `config_overrides`, setting
`recursive`, `filter`, and `filter_prod`, and calling `Config::leak` so both
paths stay in sync. Make sure the new helper is used by both closures in
`dispatch.rs` and preserves the existing behavior.
pacquet/crates/config/src/tests.rs (1)

1856-1894: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a self-update CLI override regression test
current_for_self_update is only covered here for trusted env input; add a CLI path test for --config.minimum-release-age* (or the equivalent override) so self-update coverage matches the dispatch-layer behavior.

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

In `@pacquet/crates/config/src/tests.rs` around lines 1856 - 1894, Add a
regression test for the self-update CLI override path, since
`current_for_self_update` is only validated here with trusted env vars. Extend
the existing
`Config::new()`/`current_for_self_update::<HostWithReleaseAgeEnv>()` test
coverage to exercise the dispatch-layer override behavior for
`--config.minimum-release-age` and `--config.minimum-release-age-strict` (or the
equivalent CLI config override), and assert those values win the same way as the
env-based test.

Source: Path instructions

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

Outside diff comments:
In `@pacquet/crates/config/src/lib.rs`:
- Around line 2000-2046: `Config::explicit_settings` is still collecting
workspace `minimumReleaseAge*` entries even when `ignore_project_release_age` is
true, so `pnpm config list/get` can report values that are not actually applied.
Update the `workspace_yaml` handling in `Config` so the
`ignore_project_release_age` path filters out `minimumReleaseAge*` before or
during `collect_explicit_settings`, while leaving the normal `settings.apply_to`
path unchanged. Use the existing `collect_explicit_settings` and
`apply_to_skipping_release_age` flow to keep the recorded explicit config
aligned with the effective config seen by `config_to_record()`.

---

Nitpick comments:
In `@pacquet/crates/cli/src/cli_args/dispatch.rs`:
- Around line 156-217: The config-loading closures duplicate the same post-load
finalization logic, so extract that shared step from `config` and
`config_self_update` into a single helper and reuse it after `current::<Host>` /
`current_for_self_update::<Host>`. Keep the helper responsible for applying
`config_overrides`, setting `recursive`, `filter`, and `filter_prod`, and
calling `Config::leak` so both paths stay in sync. Make sure the new helper is
used by both closures in `dispatch.rs` and preserves the existing behavior.

In `@pacquet/crates/config/src/tests.rs`:
- Around line 1856-1894: Add a regression test for the self-update CLI override
path, since `current_for_self_update` is only validated here with trusted env
vars. Extend the existing
`Config::new()`/`current_for_self_update::<HostWithReleaseAgeEnv>()` test
coverage to exercise the dispatch-layer override behavior for
`--config.minimum-release-age` and `--config.minimum-release-age-strict` (or the
equivalent CLI config override), and assert those values win the same way as the
env-based test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7ba91fad-f918-41de-a411-0324f755ae56

📥 Commits

Reviewing files that changed from the base of the PR and between 2b5e9bc and 09c7c7e.

📒 Files selected for processing (10)
  • .changeset/self-update-release-age.md
  • pacquet/crates/cli/src/cli_args/dispatch.rs
  • pacquet/crates/cli/src/cli_args/dispatch_query.rs
  • pacquet/crates/config/src/lib.rs
  • pacquet/crates/config/src/tests.rs
  • pacquet/crates/config/src/workspace_yaml.rs
  • pnpm11/config/reader/src/index.ts
  • pnpm11/config/reader/test/index.ts
  • pnpm11/pnpm/src/getConfig.ts
  • pnpm11/pnpm/src/main.ts

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: 59593b8835ca

Each scenario reports direct installs and pnpr installs. 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.629 ± 0.146 2.482 2.884 1.57 ± 0.14
pacquet@main 2.643 ± 0.134 2.401 2.830 1.57 ± 0.14
pnpr@HEAD 1.678 ± 0.123 1.423 1.791 1.00
pnpr@main 1.683 ± 0.166 1.469 1.925 1.00 ± 0.12
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 2.6285896650800002,
      "stddev": 0.146228596050474,
      "median": 2.57208612008,
      "user": 2.3606262,
      "system": 1.8117933599999998,
      "min": 2.48198002808,
      "max": 2.88428675908,
      "times": [
        2.53538152508,
        2.54902389608,
        2.52397058308,
        2.68705922608,
        2.88428675908,
        2.64897518808,
        2.59514834408,
        2.87320546508,
        2.50686563608,
        2.48198002808
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 2.64326583478,
      "stddev": 0.13355583428567896,
      "median": 2.6517675030800003,
      "user": 1.7571396999999997,
      "system": 1.4018302599999999,
      "min": 2.40107055108,
      "max": 2.82961793908,
      "times": [
        2.40107055108,
        2.59162487408,
        2.58794741708,
        2.82961793908,
        2.70563183108,
        2.48576467608,
        2.75738570208,
        2.77008035108,
        2.69345631808,
        2.61007868808
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.67842826038,
      "stddev": 0.12282266479970559,
      "median": 1.74198242958,
      "user": 1.5539619999999998,
      "system": 1.6243337599999996,
      "min": 1.42289393308,
      "max": 1.7906212260799999,
      "times": [
        1.7906212260799999,
        1.75050862508,
        1.54371799408,
        1.57568646208,
        1.73345623408,
        1.42289393308,
        1.75395320508,
        1.6821093780799998,
        1.76868323608,
        1.76265231008
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.6828384281799997,
      "stddev": 0.16552854468009617,
      "median": 1.69156704358,
      "user": 1.6665830000000004,
      "system": 1.7670928599999995,
      "min": 1.46889799108,
      "max": 1.92537576008,
      "times": [
        1.7463231750800001,
        1.50587884908,
        1.46889799108,
        1.58322246808,
        1.71342864208,
        1.87872668408,
        1.83699114108,
        1.92537576008,
        1.49983412608,
        1.66970544508
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 310.8 ± 18.7 291.0 348.9 1.02 ± 0.10
pacquet@main 311.4 ± 17.7 288.4 339.4 1.02 ± 0.09
pnpr@HEAD 306.0 ± 22.3 265.7 342.6 1.00
pnpr@main 316.7 ± 13.7 292.6 338.4 1.03 ± 0.09
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.31076771564,
      "stddev": 0.018664543833782344,
      "median": 0.30478621074,
      "user": 0.26376887999999993,
      "system": 0.60615652,
      "min": 0.29103802024000003,
      "max": 0.34891498624,
      "times": [
        0.30864433724,
        0.33643655324000005,
        0.30679829924,
        0.30192667524,
        0.31732688024,
        0.30277412224,
        0.29103802024000003,
        0.29230291924,
        0.30151436324,
        0.34891498624
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.31137521994000006,
      "stddev": 0.017666304534798647,
      "median": 0.31268967074000004,
      "user": 0.25863508,
      "system": 0.6187818199999999,
      "min": 0.28840886524000003,
      "max": 0.33942087424,
      "times": [
        0.32504003724,
        0.31026557524000004,
        0.28854278724000004,
        0.28840886524000003,
        0.32993716924,
        0.31666878824,
        0.33942087424,
        0.30878695524,
        0.29156738124000003,
        0.31511376624000004
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30602367894000004,
      "stddev": 0.022302883518664548,
      "median": 0.29964979524,
      "user": 0.24612157999999998,
      "system": 0.56537832,
      "min": 0.26569999024,
      "max": 0.34258640324,
      "times": [
        0.29289489724,
        0.33078742324000004,
        0.29556873624,
        0.29427819924000004,
        0.34258640324,
        0.32355424524000004,
        0.26569999024,
        0.30048957324000003,
        0.29881001724,
        0.31556730424
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.31669645174000005,
      "stddev": 0.01371914775427754,
      "median": 0.31493719924,
      "user": 0.26099878,
      "system": 0.60522652,
      "min": 0.29255039324000004,
      "max": 0.33837138824,
      "times": [
        0.31450710824,
        0.32878903924,
        0.33837138824,
        0.32980388124000004,
        0.30531727624,
        0.29255039324000004,
        0.31444475224,
        0.32302764724,
        0.31536729024000004,
        0.30478574124
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.336 ± 0.071 3.230 3.425 1.83 ± 0.18
pacquet@main 3.254 ± 0.065 3.186 3.362 1.79 ± 0.17
pnpr@HEAD 1.850 ± 0.169 1.626 2.078 1.02 ± 0.13
pnpr@main 1.821 ± 0.173 1.623 2.048 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.3355801749199996,
      "stddev": 0.07083505915730491,
      "median": 3.34899241282,
      "user": 2.9291196599999996,
      "system": 2.1100082999999996,
      "min": 3.22952618182,
      "max": 3.42479204282,
      "times": [
        3.39693921782,
        3.37745001482,
        3.2640125058200002,
        3.3205594988200002,
        3.42479204282,
        3.23806524782,
        3.22952618182,
        3.35879184082,
        3.40647221382,
        3.33919298482
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.25432296702,
      "stddev": 0.06457135798484141,
      "median": 3.22878788332,
      "user": 2.8139050600000006,
      "system": 2.0428287,
      "min": 3.18575107482,
      "max": 3.36209605082,
      "times": [
        3.18575107482,
        3.36209605082,
        3.19986799082,
        3.36115669082,
        3.28455229482,
        3.22819334382,
        3.22938242282,
        3.19391164182,
        3.27046344082,
        3.22785471882
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 1.85038036732,
      "stddev": 0.1689389183267974,
      "median": 1.9252142433200001,
      "user": 1.6191995599999998,
      "system": 1.7969126000000002,
      "min": 1.62616387282,
      "max": 2.07819718882,
      "times": [
        1.62616387282,
        1.92136854382,
        1.6937897988200001,
        1.6797353408200002,
        2.07819718882,
        1.64830361782,
        2.01054395082,
        1.92905994282,
        1.96218942582,
        1.95445199082
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 1.82122832682,
      "stddev": 0.17310849406479153,
      "median": 1.8001838733200002,
      "user": 1.6648873600000003,
      "system": 1.7571160000000003,
      "min": 1.62287302682,
      "max": 2.04839205282,
      "times": [
        1.66402898682,
        2.00086411682,
        2.04839205282,
        1.62287302682,
        1.97608817282,
        1.6727324438200002,
        1.97975229882,
        1.8987502368200002,
        1.7016175098200002,
        1.64718442282
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 776.7 ± 181.3 603.2 1114.1 2.53 ± 0.59
pacquet@main 588.8 ± 23.2 563.3 641.2 1.92 ± 0.08
pnpr@HEAD 307.1 ± 6.2 298.9 315.3 1.00
pnpr@main 327.8 ± 29.3 298.2 391.2 1.07 ± 0.10
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.77669489124,
      "stddev": 0.1813358756501667,
      "median": 0.76257021114,
      "user": 0.96114406,
      "system": 0.8235182199999999,
      "min": 0.60323439514,
      "max": 1.11406265214,
      "times": [
        0.86428123114,
        0.87310983114,
        0.91755253214,
        1.11406265214,
        0.90769981414,
        0.60846083614,
        0.60323439514,
        0.60903129514,
        0.66085919114,
        0.60865713414
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.58883305614,
      "stddev": 0.02322164999068417,
      "median": 0.5829815576399999,
      "user": 0.71977196,
      "system": 0.67471832,
      "min": 0.56330956914,
      "max": 0.64124714914,
      "times": [
        0.64124714914,
        0.56330956914,
        0.60610966214,
        0.57534494514,
        0.59718457114,
        0.56840160814,
        0.57828686714,
        0.5721452821399999,
        0.58767624814,
        0.59862465914
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.30708069834,
      "stddev": 0.006210042936228424,
      "median": 0.30700721564,
      "user": 0.18694365999999998,
      "system": 0.54264472,
      "min": 0.29888998414,
      "max": 0.31527882714000005,
      "times": [
        0.31300503714000005,
        0.31527882714000005,
        0.31280563314000004,
        0.31272887014,
        0.30469395714,
        0.30932047414,
        0.29888998414,
        0.30289145014,
        0.30116832214,
        0.30002442814
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.32782524414,
      "stddev": 0.029277975513008987,
      "median": 0.31700537214,
      "user": 0.23320876000000004,
      "system": 0.55463542,
      "min": 0.29821694314,
      "max": 0.39116482514,
      "times": [
        0.31247241014000005,
        0.30751688514000003,
        0.30508444914000005,
        0.30734925114,
        0.32153833414000005,
        0.33037023014000005,
        0.35283728014000004,
        0.39116482514,
        0.35170183314000003,
        0.29821694314
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.961 ± 0.011 1.943 1.977 6.13 ± 0.25
pacquet@main 1.972 ± 0.036 1.927 2.045 6.16 ± 0.27
pnpr@HEAD 0.320 ± 0.013 0.301 0.346 1.00
pnpr@main 0.328 ± 0.017 0.299 0.353 1.02 ± 0.07
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.9610596137200003,
      "stddev": 0.010920114652393216,
      "median": 1.9576296401200002,
      "user": 1.0156415799999998,
      "system": 0.8163982999999998,
      "min": 1.94327690562,
      "max": 1.9769728626200003,
      "times": [
        1.9769728626200003,
        1.9553009216200001,
        1.97483326562,
        1.94327690562,
        1.95906081662,
        1.9561984636200003,
        1.95389643162,
        1.9534363086200002,
        1.97225366262,
        1.9653664986200001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.9720226630200002,
      "stddev": 0.03625936314218684,
      "median": 1.95874576662,
      "user": 1.04802108,
      "system": 0.8110555999999999,
      "min": 1.9274108866200002,
      "max": 2.04500587962,
      "times": [
        1.9798987446200003,
        1.95308570162,
        2.01588127762,
        2.04500587962,
        1.9900919416200002,
        1.93866344062,
        1.9274108866200002,
        1.9605250816200002,
        1.95269722462,
        1.95696645162
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.32017072941999997,
      "stddev": 0.012912501046719121,
      "median": 0.31787454812000004,
      "user": 0.21778657999999998,
      "system": 0.5373029,
      "min": 0.30146086862,
      "max": 0.34550617462,
      "times": [
        0.30824282362,
        0.30146086862,
        0.31429899962,
        0.32421623062,
        0.33332620662,
        0.32145009662,
        0.34550617462,
        0.31373657562,
        0.31269725062,
        0.32677206762
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.32809220562,
      "stddev": 0.01736054504757659,
      "median": 0.32681326162,
      "user": 0.22667198000000002,
      "system": 0.5526194999999999,
      "min": 0.29887289062,
      "max": 0.35260694262,
      "times": [
        0.29887289062,
        0.33541530062,
        0.31671450562,
        0.31821122262,
        0.31635234962,
        0.31436112962,
        0.34396739662,
        0.35260694262,
        0.34231223462,
        0.34210808362
      ]
    }
  ]
}

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

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 429.4 ± 25.4 395.8 474.5 4.57 ± 0.31
pacquet@main 423.0 ± 23.3 385.0 464.1 4.50 ± 0.29
pnpr@HEAD 93.9 ± 3.1 87.6 99.8 1.00
pnpr@main 97.4 ± 3.4 89.6 104.3 1.04 ± 0.05
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.42942247402000006,
      "stddev": 0.025441824552349505,
      "median": 0.42255150442,
      "user": 0.41930366,
      "system": 0.07233478000000002,
      "min": 0.39583951442000004,
      "max": 0.47445493942000005,
      "times": [
        0.41141259042,
        0.42037508242000005,
        0.41509768542000003,
        0.42736692142000005,
        0.39583951442000004,
        0.42472792642,
        0.41599692942000005,
        0.43720660542,
        0.47174654542000005,
        0.47445493942000005
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.42296001161999996,
      "stddev": 0.023343659514513275,
      "median": 0.42502030442000005,
      "user": 0.40261515999999997,
      "system": 0.08156608000000001,
      "min": 0.38497531142,
      "max": 0.46414230942,
      "times": [
        0.38497531142,
        0.42696636042,
        0.38678822642000005,
        0.46414230942,
        0.41918054342000005,
        0.43938469642000005,
        0.42865635642000005,
        0.42232950342000003,
        0.42307424842,
        0.43410256042
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.09389723961354839,
      "stddev": 0.003097543484380349,
      "median": 0.09477714942000001,
      "user": 0.02550307935483871,
      "system": 0.011225373548387096,
      "min": 0.08764249342000001,
      "max": 0.09981479742,
      "times": [
        0.09048412742,
        0.09194569542,
        0.09640479842,
        0.09050847142000001,
        0.09369325942000001,
        0.09555446542000001,
        0.09786975342000001,
        0.09705440542,
        0.09273612642000001,
        0.09261122142,
        0.09201174942000001,
        0.09806927742,
        0.09552800642,
        0.09727614142,
        0.09083011542000001,
        0.09343427442,
        0.09170159742,
        0.09159033942000001,
        0.09050025742000001,
        0.09647837642000001,
        0.09657277442000001,
        0.09981479742,
        0.09587148942000001,
        0.09483899542,
        0.09477714942000001,
        0.08829032742000001,
        0.08764249342000001,
        0.09494221942,
        0.08940894242000001,
        0.09636042542,
        0.09601235442
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.09743607331655174,
      "stddev": 0.0033671612714739015,
      "median": 0.09693829842000001,
      "user": 0.02745817724137931,
      "system": 0.01229379448275862,
      "min": 0.08961300542,
      "max": 0.10431917542000001,
      "times": [
        0.09560591342000001,
        0.09647234542000001,
        0.09968761942000001,
        0.09176539642,
        0.09732059442,
        0.09596450442000001,
        0.09615653442000001,
        0.08961300542,
        0.09461829242000001,
        0.09591075242000001,
        0.09763789942000001,
        0.09700152642000001,
        0.09629102642000001,
        0.10172640942000001,
        0.10191457242,
        0.09587021742,
        0.09891426042000001,
        0.09934198142,
        0.09693829842000001,
        0.10345729142000001,
        0.09496255842000001,
        0.10063039542,
        0.09583584342000001,
        0.09243562342,
        0.09840797242,
        0.10431917542000001,
        0.09618040942,
        0.09870109142000001,
        0.10196461542
      ]
    }
  ]
}

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

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.708 ± 0.164 4.503 4.936 1.30 ± 0.07
pacquet@main 4.747 ± 0.214 4.517 5.081 1.31 ± 0.08
pnpr@HEAD 3.674 ± 0.144 3.533 3.887 1.01 ± 0.06
pnpr@main 3.622 ± 0.141 3.481 3.952 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.70835057038,
      "stddev": 0.164369706553302,
      "median": 4.7170027352799995,
      "user": 2.2498091,
      "system": 1.6525364,
      "min": 4.50253732728,
      "max": 4.9362034242799995,
      "times": [
        4.89370965228,
        4.9362034242799995,
        4.66644109928,
        4.822482219279999,
        4.76756437128,
        4.50253732728,
        4.56077873128,
        4.58114114128,
        4.50865934728,
        4.84398839028
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.7465782685799995,
      "stddev": 0.21410189340722185,
      "median": 4.650715400779999,
      "user": 2.3682239,
      "system": 1.7569886000000001,
      "min": 4.51657382528,
      "max": 5.080841727279999,
      "times": [
        4.53454017528,
        4.5794045172799995,
        4.51657382528,
        5.00729923028,
        4.615181091279999,
        4.99889062028,
        4.66655068628,
        5.080841727279999,
        4.63488011528,
        4.83162069728
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 3.67388642298,
      "stddev": 0.14376669753968513,
      "median": 3.61984470478,
      "user": 1.6713948000000003,
      "system": 1.5670578,
      "min": 3.53296022628,
      "max": 3.8874999582800003,
      "times": [
        3.8388096222800003,
        3.5456299112800003,
        3.8874999582800003,
        3.5629041522800002,
        3.8793946632800003,
        3.69048886828,
        3.53296022628,
        3.57754490128,
        3.56148741828,
        3.6621445082800004
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 3.62246030218,
      "stddev": 0.14099781048920093,
      "median": 3.57521730478,
      "user": 1.5074983000000002,
      "system": 1.4857041,
      "min": 3.48126848528,
      "max": 3.95161427928,
      "times": [
        3.53848931328,
        3.6097189542800003,
        3.74656988028,
        3.95161427928,
        3.55659669628,
        3.69146727128,
        3.53395520928,
        3.52108501928,
        3.48126848528,
        3.5938379132800002
      ]
    }
  ]
}

@github-actions

github-actions Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12813
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,733.25 ms
(-20.01%)Baseline: 3,417.05 ms
4,100.46 ms
(66.66%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
1,867.40 ms
(-22.96%)Baseline: 2,423.80 ms
2,908.56 ms
(64.20%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
624.48 ms
(-35.77%)Baseline: 972.19 ms
1,166.63 ms
(53.53%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
413.97 ms
(-16.82%)Baseline: 497.67 ms
597.20 ms
(69.32%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
2,655.01 ms
(-14.85%)Baseline: 3,118.20 ms
3,741.84 ms
(70.95%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
4,718.81 ms
(-16.62%)Baseline: 5,659.61 ms
6,791.54 ms
(69.48%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
242.25 ms
(-41.66%)Baseline: 415.27 ms
498.33 ms
(48.61%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

github-actions Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12813
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,553.99 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
272.28 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
282.77 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
85.28 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
1,513.59 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
3,691.21 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
251.92 ms
🐰 View full continuous benchmarking report in Bencher

@aqeelat
aqeelat force-pushed the fix/self-update-minimum-release-age branch from 09c7c7e to 6ecc1c8 Compare July 5, 2026 11:59
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

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

@aqeelat

aqeelat commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@aqeelat
aqeelat marked this pull request as draft July 5, 2026 12:21
@aqeelat aqeelat changed the title fix: isolate self-update release-age policy feat(self-update): load config from trusted sources only Jul 5, 2026
@aqeelat
aqeelat marked this pull request as ready for review July 5, 2026 13:25
zkochan and others added 7 commits July 25, 2026 00:45
Fixes pnpm#12803.

`pnpm self-update` resolved the pnpm download through the project's own
registry/auth config and loaded the repo's default `.pnpmfile.(c|m)js`, and
its `minimumReleaseAge` policy came from the active workspace with no limit
on the direction — a repo could raise the cutoff (the reported cwd-dependent
failure) but equally set `minimumReleaseAge: 0`, `minimumReleaseAgeStrict:
false`, or list pnpm in `minimumReleaseAgeExclude` and silently disable the
cooldown the user configured globally, on the one download that replaces the
binary every later install runs through.

Route the fetch through the trusted package-manager bootstrap config — the
channel `switchCliVersion` already uses, which excludes the project `.npmrc`
and workspace manifest — and stop auto-loading the repo pnpmfile, whose
`updateConfig` hook and custom resolvers/fetchers reach the same requests.

Keep the project's `minimumReleaseAge` applying to self-update, but only in
the tightening direction: the manifest may raise the cutoff and turn strict
mode on, never lower it, waive strict mode, or exempt pnpm. A trusted source
(global config, env, CLI flag) that sets a key explicitly wins outright.

When an immature version is refused, the error now names where the cutoff
came from — the reported issue's real complaint was that nothing in the
message pointed at the workspace setting — and an interactive run offers to
update anyway, matching how a strict install prompts. CI still fails closed.

Mirrored in pacquet: `Config::current_for_self_update` resolves the same
policy, and `self-update` gained the matching prompt and error.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Typecheck fixes on top of the previous commit: `ci` is a required `Config`
field, so `self-update`'s option type takes it as optional, and
`minimumReleaseAgeSource` has to be split out into the returned
`ConfigContext` for callers to read it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Also adds the trailing comma the `perfectionist` dylint rule wants in the
self-update prompt's `format!`.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
`cargo doc -D warnings` rejects a public doc comment linking to a private
method, so state the self-update release-age rule inline instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…merging them

Reworks the previous commits' rule. Comparing the project's `minimumReleaseAge`
against the trusted layers rested on "a repository can only make the cooldown
stricter, which is the safe direction". That is true for a dependency install,
where the worst case is a failed install, but not for `self-update`: raising
the cutoff is a denial of update. A repository can pin the machine to the
installed pnpm — including past a release that fixes a vulnerability in it —
and unlike a blocked dependency upgrade that decision follows the user into
every other project, because it is the global binary.

There is therefore no direction in which repo-controlled input on this setting
is worth honoring. The project `pnpm-workspace.yaml` no longer contributes the
release-age settings to `self-update` at all; the policy comes from the
built-in defaults, the global config, the environment, and CLI flags — the same
trust boundary the fetch already uses. Other commands are unaffected.

This removes the trusted-layer snapshot, the env-set-key tracking, the merge
function, and the `minimumReleaseAgeSource` reporting field from both stacks.
The refusal keeps its interactive "update anyway?" prompt, and there is still
no new default: at zero config `self-update` behaves as it did before.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The project `pnpm-workspace.yaml` still contributed `trustPolicy`,
`trustPolicyExclude`, `trustPolicyIgnoreAfter`, and `ci` to `self-update`. Both
reach the decision the release-age settings were removed from: the trust policy
is passed straight into self-update's resolve (the only version selection it
makes, so it is what runs the no-downgrade check on the pnpm release), and `ci`
gates whether an immature pick may be confirmed at the keyboard — a repo
setting `ci: false` re-enables that prompt on a runner with a pseudo-TTY, where
self-update has to fail closed.

The reasoning is the one already applied to the cooldown: a repository must not
get a say in whether the machine's pnpm binary may be replaced, in either
direction. Both settings join the skip set; global config, env, and CLI flags
still set them.

Reported by qodo-code-review on pnpm#12813.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Pacquet's prompt gate tested only `stdin().is_terminal()`, so a CI runner that
allocates a pseudo-TTY reached the "update anyway?" confirmation, where the
TypeScript CLI refuses. `is_ci::cached()` closes it — the same detection
`package_manager::install` already uses for its own prompt gate, so the two
prompts in pacquet now agree with each other as well as with pnpm.

pnpm's `ci` setting itself is still unported (it is listed in the
`pnpm_default_parity` NOT_PORTED bucket), so a trusted `PNPM_CONFIG_CI=false`
cannot re-enable the prompt in pacquet the way it can in the TypeScript CLI.
Pacquet detects CI at each point of use instead of carrying the setting.

The prompt branch has no test on either stack: reaching it needs a pty, and no
pty harness exists in the workspace.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 24, 2026 22:50
@zkochan
zkochan force-pushed the fix/self-update-minimum-release-age branch from 8fa8789 to 8caa581 Compare July 24, 2026 22:50

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 8caa581

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

The doc comment on enforce_resolution_policy links to
WorkspaceSettings::clear_self_update_policy, but WorkspaceSettings is not
in scope in pacquet-cli, so rustdoc rejected the intra-doc link under
-D warnings. Point the link at the public re-export in pacquet_config.

Co-Authored-By: Claude Fable 5 <[email protected]>
Copilot AI review requested due to automatic review settings July 24, 2026 23:15

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 30b4a0d

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

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.

pnpm self-update fails under workspace minimumReleaseAge, but succeeds everywhere else

4 participants