Skip to content

fix(pacquet): resolve latest through the maturity-aware picker - #13102

Merged
zkochan merged 6 commits into
mainfrom
fix/minimum-release-age-latest-picker
Jul 17, 2026
Merged

zkochan merged 6 commits into
mainfrom
fix/minimum-release-age-latest-picker

Conversation

@zkochan

@zkochan zkochan commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

Summary

Supersedes #13021. The original PR's fork branch does not allow maintainer edits, so the required rebase could not be pushed after current main introduced a conflicting multi-package add refactor. This replacement preserves Manuel Pelloni's original commits and authorship, rebases them onto current main, and adds the small integration fixes needed for the newer command flow.

Related to #11165 (partial fix; the held-back summary log remains deferred).

With an active minimumReleaseAge, bare update already picks the newest mature in-range version in both stacks. This PR locks that behavior in with parity tests. The broken Rust manifest-writing paths were pnpm add <pkg> without a version and pnpm update --latest: they fetched the raw latest dist-tag, bypassing the maturity filter, and could write a range that no mature version satisfied. They now resolve through the same maturity-aware package picker used by install, keeping package.json and the lockfile consistent.

The picker is constructed lazily so invalid minimumReleaseAgeExclude configuration does not preempt command validation or turn an unmatched-selector no-op into an error. It is shared for all selectors in a multi-package command, and its errors use the same ERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDE diagnostic as the install path and TypeScript CLI.

The TypeScript CLI already had the correct resolution behavior and gains regression coverage for pnpm add, pnpm update, and pnpm update --latest. The rebase also reuses the shared workspace-YAML test helper introduced on main instead of retaining duplicate fixture-editing logic.

Behavior TypeScript CLI pacquet
install / bare update pick the newest mature in-range version tested here tested here
add <name> / update --latest write mature-anchored ranges tested here fixed here
Held-back summary log at the end of the run deferred deferred

Squash Commit Body

`pacquet add <name>` without a version and `pacquet update --latest`
fetched the raw `latest` dist-tag, so with an active
`minimumReleaseAge` they could write a range into `package.json` that
the follow-up install rejects (related to pnpm/pnpm#11165).

Resolve the tag through the same package-picking path as install. The
maturity filter repoints `latest` to the newest mature version, keeping
the manifest and lockfile consistent and matching the TypeScript CLI.

Share one lazily constructed `LatestPicker` across every selector in a
command. This preserves command-validation and unmatched-selector error
ordering while reusing the policy, metadata cache, fetch locker, and
registries map. Report invalid `minimumReleaseAgeExclude` values with
`ERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDE`, matching install and the
TypeScript CLI.

Add TypeScript and Rust regression coverage for bare update, update
with `--latest`, and add without a version.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust pnpm/ port, or the description notes what still needs porting. (The fix is pacquet-only because the TypeScript CLI already behaves correctly; both stacks gain parity tests.)
  • Added a changeset (pnpm changeset) because this changes the published pacquet package.
  • Added or updated tests.

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


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Summary by CodeRabbit

  • New Features
    • pnpm add without a specified version now respects minimumReleaseAge when resolving the newest eligible version.
    • pnpm update and pnpm update --latest now select the newest eligible mature version based on minimumReleaseAge.
  • Bug Fixes
    • Invalid minimumReleaseAgeExclude now consistently reports ERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDE.
  • Tests
    • Expanded minimumReleaseAge coverage across add and update, including lockfile and --latest scenarios.

manuelpelloni and others added 3 commits July 17, 2026 13:24
`pacquet add <name>` (no version) and `pacquet update --latest` used to
fetch the raw `latest` dist-tag from the registry, so with an active
`minimumReleaseAge` they could write a range into `package.json` that the
follow-up install rejects (#11165). Resolve the tag through the
same `pick_package` path the install uses instead: the maturity filter
repoints `latest` to the newest mature version, keeping the manifest and
the lockfile in agreement. This also matches the TypeScript CLI's
registry traffic (one packument fetch instead of a `/latest` request).

The new `LatestPicker` owns the pick policy, metadata cache, fetch
locker, and registries map for a whole command run, so an
`update --latest` resolves every matched dependency against one shared
view — and a plain `update` never builds any of it. The `latest`-tag
spec literal moves behind `RegistryPackageSpec::latest_tag`, shared with
the picker's internal fallback, and `pick_package_context` centralizes
the config-to-context mapping already shared with the explicit-spec path
of `pacquet add`.
Parity coverage for the pacquet-side fix (#11165): the
TypeScript resolver already picks the newest mature version when
resolving the `latest` tag, so lock in `pnpm update`,
`pnpm update --latest`, and bare `pnpm add` behavior with tests at the
deps-installer and CLI e2e levels. The shared maturity cutoff (and the
bravo-dep publish-dates rationale) lives in
`@pnpm/testing.registry-mock`, which owns the mock registry's fixture
timeline.
Copilot AI review requested due to automatic review settings July 17, 2026 12:29

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.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b02c9a58-06a4-4a97-a7ea-2510451bf40a

📥 Commits

Reviewing files that changed from the base of the PR and between a3ec3d1 and c3443ae.

📒 Files selected for processing (2)
  • pnpm/crates/package-manager/src/add/tests.rs
  • pnpm/crates/package-manager/src/resolve_latest.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/package-manager/src/resolve_latest.rs

📝 Walkthrough

Walkthrough

pacquet add without a version and pacquet update --latest now use minimumReleaseAge-aware latest resolution. Shared picker infrastructure, error handling, workspace helpers, documentation, and integration coverage were added.

Changes

Minimum release age latest resolution

Layer / File(s) Summary
Latest picker and resolution context
pnpm/crates/package-manager/src/{resolve_latest.rs,resolution_policy.rs,lib.rs}, pnpm/crates/resolving-npm-resolver/src/*
Adds maturity-aware latest-tag picking, shared package context construction, and a reusable latest-tag package specification.
Add latest resolution
pnpm/crates/package-manager/src/add.rs, pnpm/crates/package-manager/src/add/tests.rs
Routes versionless add resolution through a cached picker and updates related diagnostics and test configuration.
Update latest resolution
pnpm/crates/package-manager/src/update.rs
Uses a lazy, reusable picker for update --latest, including minimumReleaseAgeExclude overrides and typed picker errors.
CLI and integration coverage
pnpm/crates/cli/tests/*, pnpm11/installing/deps-installer/test/install/minimumReleaseAge.ts, pnpm11/pnpm/test/update.ts, pnpm11/testing/registry-mock/src/index.ts, .changeset/*, AGENTS.md
Adds workspace helpers and tests for mature-version selection, invalid excludes, lockfile behavior, command parity, release notes, and Rust changeset guidance.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant LatestPicker
  participant PackageRegistry
  CLI->>LatestPicker: resolve latest package version
  LatestPicker->>PackageRegistry: fetch metadata or pick package
  PackageRegistry-->>LatestPicker: return versions and dist-tags
  LatestPicker-->>CLI: return newest mature version
Loading

Possibly related issues

  • pnpm/pnpm#11633 — Covers minimumReleaseAge resolution for add and update paths.
  • pnpm/pnpm#12101 — Tracks related pacquet update --latest resolution work.
  • pnpm/pnpm#13089 — Modifies the same add-resolution functions for a different resolution-policy change.

Possibly related PRs

  • pnpm/pnpm#13021 — Directly overlaps the maturity-aware latest-resolution implementation and tests.

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/minimum-release-age-latest-picker

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.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix pacquet add/update --latest to honor minimumReleaseAge when resolving latest

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Route add  (no version) and update --latest through the maturity-aware picker.
• Lazily share a single LatestPicker per command to preserve validation/no-op behavior.
• Add Rust + TypeScript parity tests for minimumReleaseAge across add/update flows.
Diagram

graph TD
A["pacquet add/update"] --> B["LatestPicker"] --> C["pick_package resolver"] --> D["Registry packument"]
A --> E["package.json"]
C --> F["pnpm-lock.yaml"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep `/latest` endpoint, then post-filter by minimumReleaseAge
  • ➕ Potentially fewer code changes by reusing existing tag fetch path
  • ➖ Easy to diverge from install's picker semantics (dist-tags rewriting, deprecations, full-metadata rules)
  • ➖ Would still need shared caching/locking and consistent error/reporting behavior
2. Always build the picker up-front (eager construction)
  • ➕ Simpler control flow (no Option / ensure helpers)
  • ➖ Would change error ordering: invalid minimumReleaseAgeExclude could preempt command validation and unmatched-selector no-ops
  • ➖ Unnecessary work for plain update (no --latest) and other no-op paths
3. Move latest-tag resolution into the resolver layer implicitly
  • ➕ Centralizes behavior so all call sites automatically match install
  • ➖ Harder to reason about command-specific needs (e.g., laziness for validation/no-op paths)
  • ➖ Larger refactor surface and higher regression risk

Recommendation: Current approach is the best trade-off: it reuses the install-equivalent pick_package path (ensuring semantic parity under minimumReleaseAge), shares a single per-command picker for consistent caching/locking, and constructs it lazily to preserve existing validation/no-op behavior and TypeScript CLI parity.

Files changed (16) +568 / -142

Enhancement (3) +119 / -0
lib.rsExpose resolve_latest module and error type +2/-0

Expose resolve_latest module and error type

• Registers the new 'resolve_latest' module in the crate and re-exports 'ResolveLatestError' for use by command error enums.

pnpm/crates/package-manager/src/lib.rs

resolve_latest.rsIntroduce LatestPicker for maturity-aware latest-tag resolution +105/-0

Introduce LatestPicker for maturity-aware latest-tag resolution

• Adds a new module implementing 'LatestPicker', which resolves 'latest' dist-tags through 'pick_package' with the config-derived 'PickPolicy'. Includes a dedicated 'ResolveLatestError' for pick failures and missing-latest scenarios.

pnpm/crates/package-manager/src/resolve_latest.rs

pick_package_from_meta.rsAdd RegistryPackageSpec::latest_tag constructor +12/-0

Add RegistryPackageSpec::latest_tag constructor

• Introduces a convenience constructor for creating a 'latest' dist-tag spec, used by both the resolver and pacquet's latest resolution wrapper.

pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs

Bug fix (2) +89 / -65
add.rsResolve bare-add latest via shared maturity-aware LatestPicker +32/-40

Resolve bare-add latest via shared maturity-aware LatestPicker

• Replaces direct registry '/latest' dist-tag fetching with a lazily initialized 'LatestPicker' that resolves via 'pick_package', honoring 'minimumReleaseAge'. Shares one picker across multiple selectors and aligns invalid 'minimumReleaseAgeExclude' diagnostics with install/TS CLI.

pnpm/crates/package-manager/src/add.rs

update.rsUse LatestPicker for update --latest with lazy construction and shared policy +57/-25

Use LatestPicker for update --latest with lazy construction and shared policy

• Switches 'update --latest' from direct dist-tag fetching to 'LatestPicker' resolution, ensuring 'minimumReleaseAge' affects the chosen version. Constructs the picker only when needed to preserve validation/no-op behavior and adds a dedicated error for invalid 'minimumReleaseAgeExclude' with the standard error code.

pnpm/crates/package-manager/src/update.rs

Refactor (2) +40 / -10
resolution_policy.rsCentralize PickPackageContext construction for pre-resolution paths +38/-4

Centralize PickPackageContext construction for pre-resolution paths

• Adds 'pick_package_context()' helper to build a consistent 'PickPackageContext' from config + policy + caches/locker. Clarifies docs to include both add and update pre-resolution use cases.

pnpm/crates/package-manager/src/resolution_policy.rs

pick_package.rsReuse RegistryPackageSpec::latest_tag helper when including latest tag +2/-6

Reuse RegistryPackageSpec::latest_tag helper when including latest tag

• Refactors latest-spec construction to use a centralized 'RegistryPackageSpec::latest_tag()' helper and preserves normalized specifier propagation.

pnpm/crates/resolving-npm-resolver/src/pick_package.rs

Tests (8) +315 / -67
_utils.rsAdd workspace-yaml helpers and minimumReleaseAge cutoff fixture +40/-1

Add workspace-yaml helpers and minimumReleaseAge cutoff fixture

• Adds helpers to append top-level keys to 'pnpm-workspace.yaml' and to set 'minimumReleaseAge'. Introduces a time cutoff helper aligned with mocked registry publish dates for '@pnpm.e2e/bravo-dep'.

pnpm/crates/cli/tests/_utils.rs

add.rsRegression test: add without version respects minimumReleaseAge +20/-0

Regression test: add without version respects minimumReleaseAge

• Adds a CLI-level test asserting 'pacquet add @pnpm.e2e/bravo-dep' (no version) pins '^1.0.1' under an active 'minimumReleaseAge', rather than using the immature 'latest' (1.1.0). Uses the new YAML helper utilities.

pnpm/crates/cli/tests/add.rs

lockfile_verification.rsRefactor lockfile verification tests to reuse YAML helpers +5/-23

Refactor lockfile verification tests to reuse YAML helpers

• Replaces inline workspace-yaml string editing with 'set_minimum_release_age' and 'append_workspace_yaml_key'. Keeps test intent the same while reducing duplicate file-mutation logic.

pnpm/crates/cli/tests/lockfile_verification.rs

update.rsAdd update/minimumReleaseAge regression coverage and YAML helper reuse +131/-14

Add update/minimumReleaseAge regression coverage and YAML helper reuse

• Refactors a local YAML append helper to use the shared '_utils' implementation. Adds multiple tests covering 'update', 'update --latest', and error-ordering/no-op behavior when 'minimumReleaseAgeExclude' is invalid.

pnpm/crates/cli/tests/update.rs

tests.rsUpdate add registry-routing test to expect packument fetch only +0/-29

Update add registry-routing test to expect packument fetch only

• Adjusts mocked registry expectations so add no longer calls the '/latest' endpoint, instead fetching the packument. Removes now-unused helpers tied to '/latest' responses.

pnpm/crates/package-manager/src/add/tests.rs

minimumReleaseAge.tsAdd TS installer tests for add/update/latest under minimumReleaseAge +54/-0

Add TS installer tests for add/update/latest under minimumReleaseAge

• Adds regression tests ensuring 'pnpm update', 'pnpm update --latest', and 'pnpm add' (no version) resolve to the newest mature version when 'minimumReleaseAge' excludes the 'latest' tag. Uses a shared registry-mock helper for stable cutoff computation.

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

update.tsAdd pnpm CLI tests for update and update --latest minimumReleaseAge behavior +52/-0

Add pnpm CLI tests for update and update --latest minimumReleaseAge behavior

• Adds end-to-end CLI tests verifying 'update' and 'update --latest' pick the newest mature version under 'minimumReleaseAge', keeping both manifest and lockfile consistent. Uses synchronous execution to assert success and stable config behavior.

pnpm11/pnpm/test/update.ts

index.tsExport shared minimumReleaseAge cutoff helper for bravo-dep fixtures +13/-0

Export shared minimumReleaseAge cutoff helper for bravo-dep fixtures

• Adds 'bravoDepMatureUpTo101MinimumReleaseAge()' helper that returns a cutoff (in minutes) where '@pnpm.e2e/bravo-dep''s 1.1.0 (latest tag) is immature but 1.0.1 is mature. Supports deterministic tests across repos/packages.

pnpm11/testing/registry-mock/src/index.ts

Other (1) +5 / -0
pacquet-minimum-release-age-add-update.mdAdd pacquet patch changeset for maturity-aware latest resolution +5/-0

Add pacquet patch changeset for maturity-aware latest resolution

• Introduces a patch changeset documenting that 'add <pkg>' (no version) and 'update --latest' now resolve 'latest' through the 'minimumReleaseAge'-aware picker. Notes error-code parity for invalid 'minimumReleaseAgeExclude' (now 'ERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDE').

.changeset/pacquet-minimum-release-age-add-update.md

@github-actions

github-actions Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     12.1±0.54ms    31.0 MB/sec    1.01     12.2±0.38ms    30.6 MB/sec
packument/parse                1.04     40.0±0.32µs  1656.5 MB/sec    1.00     38.6±0.49µs  1718.0 MB/sec
tarball/download_dependency    1.00      2.4±0.20ms  1801.5 KB/sec    1.00      2.4±0.17ms  1809.0 KB/sec

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

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

Inline comments:
In @.changeset/pacquet-minimum-release-age-add-update.md:
- Line 5: Update the changeset description to refer to the affected CLI as
pacquet instead of pnpm in both command references, preserving the existing
behavior and error-code details.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

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

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2de6ae1b-5881-4cf5-8270-c2e7a6534640

📥 Commits

Reviewing files that changed from the base of the PR and between e7138af and 000bba6.

📒 Files selected for processing (16)
  • .changeset/pacquet-minimum-release-age-add-update.md
  • pnpm/crates/cli/tests/_utils.rs
  • pnpm/crates/cli/tests/add.rs
  • pnpm/crates/cli/tests/lockfile_verification.rs
  • pnpm/crates/cli/tests/update.rs
  • pnpm/crates/package-manager/src/add.rs
  • pnpm/crates/package-manager/src/add/tests.rs
  • pnpm/crates/package-manager/src/lib.rs
  • pnpm/crates/package-manager/src/resolution_policy.rs
  • pnpm/crates/package-manager/src/resolve_latest.rs
  • pnpm/crates/package-manager/src/update.rs
  • pnpm/crates/resolving-npm-resolver/src/pick_package.rs
  • pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs
  • pnpm11/installing/deps-installer/test/install/minimumReleaseAge.ts
  • pnpm11/pnpm/test/update.ts
  • pnpm11/testing/registry-mock/src/index.ts
💤 Files with no reviewable changes (1)
  • pnpm/crates/package-manager/src/add/tests.rs

@greptile-apps

greptile-apps Bot commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the fix is narrowly scoped to the latest dist-tag resolution path in pacquet, the fast-path guard is correct, and the lazy initialization preserves all existing error-ordering guarantees.

The core logic is sound: published_by.is_none() correctly gates the fast path so a non-None cutoff always routes through pick_package. Lazy picker initialization preserves spec-rejection and no-op ordering. Both stacks have regression coverage for every fixed scenario, and error types are updated consistently across add and update.

No files require special attention.

Reviews (3): Last reviewed commit: "perf(pacquet): avoid redundant latest pa..." | Re-trigger Greptile

Comment thread pnpm/crates/cli/tests/_utils.rs Resolved
@qodo-code-review

qodo-code-review Bot commented Jul 17, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Changeset missing pnpm entry ✗ Dismissed 📘 Rule violation § Compliance
Description
The new changeset front-matter only declares a bump for pacquet and does not include a pnpm
entry. This violates the changeset compliance requirement and can lead to incomplete or incorrect
release metadata.
Code

.changeset/pacquet-minimum-release-age-add-update.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires newly added/modified changeset files to include a pnpm package
entry with a valid bump type. The added changeset front-matter contains only "pacquet": patch and
no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-minimum-release-age-add-update.md[1-3]

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

## Issue description
The changeset front-matter is missing a required `pnpm` entry (with a valid bump type).

## Issue Context
Compliance requires changeset front-matter to explicitly include `pnpm` with a `patch`/`minor`/`major` bump type.

## Fix Focus Areas
- .changeset/pacquet-minimum-release-age-add-update.md[1-3]

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



Remediation recommended

2. Latest fast-path unnecessarily disabled 🐞 Bug ➹ Performance ⭐ New
Description
LatestPicker::resolve skips the lightweight dist-tag endpoint whenever published_by_exclude is
set, even if published_by is None (i.e., minimumReleaseAge is effectively disabled). This
forces a full packument-based pick, adding extra network/CPU work and changing failure modes for
configs that set only minimumReleaseAgeExclude.
Code

pnpm/crates/package-manager/src/resolve_latest.rs[R79-95]

+        let registry = pick_registry_for_package(&self.registries, package_name, None);
+        if self.policy.published_by.is_none()
+            && self.policy.published_by_exclude.is_none()
+            && !self.config.offline
+            && !self.config.prefer_offline
+        {
+            return PackageVersion::fetch_from_registry(
+                package_name,
+                PackageTag::Latest,
+                self.http_client,
+                &registry,
+                &self.config.auth_headers,
+            )
+            .await
+            .map(Arc::new)
+            .map_err(ResolveLatestError::Registry);
+        }
Evidence
The fast-path is currently gated on published_by_exclude.is_none(), but published_by_exclude can
be present even when no cutoff exists (published_by == None). The underlying picker logic only
applies published_by_exclude when published_by is Some, so blocking the fast-path in the
excludes-only case provides no semantic benefit while incurring extra work.

pnpm/crates/package-manager/src/resolve_latest.rs[79-95]
pnpm/crates/package-manager/src/resolution_policy.rs[86-102]
pnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rs[159-195]

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

### Issue description
`LatestPicker::resolve` currently requires both `policy.published_by` **and** `policy.published_by_exclude` to be `None` before using the lightweight `/<pkg>/latest` dist-tag endpoint.

However, `published_by_exclude` can be present even when `published_by` is `None` (e.g. user configured `minimumReleaseAgeExclude` but not `minimumReleaseAge`). In that case, the exclude policy has no effect on picking, yet the code forces the heavier packument path.

### Issue Context
- `PickPolicy` sets `published_by_exclude` whenever `minimum_release_age_exclude` is configured, regardless of whether `published_by` is `Some`.
- The maturity exclude policy is only consulted when `published_by` is `Some`; when `published_by` is `None`, the picker does not filter by age.

### Fix Focus Areas
- pnpm/crates/package-manager/src/resolve_latest.rs[79-95]

### Suggested fix
Change the fast-path guard to depend on `published_by.is_none()` (and the offline flags), but not on `published_by_exclude.is_none()`. Example shape:
- Keep using `/latest` when `published_by` is `None` and `offline/prefer_offline` are false.
- Only use the packument picker when an actual cutoff is active (`published_by.is_some()`) or offline/prefer-offline requires it.

Optionally add a regression test that sets only `minimumReleaseAgeExclude` (without `minimumReleaseAge`) and confirms the `/latest` endpoint is used / no packument fetch is required.

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


3. Redundant latest metadata pick ✓ Resolved 🐞 Bug ➹ Performance
Description
LatestPicker::resolve resolves latest through pick_package (packument-based metadata
resolution) before Add/Update runs Install, but the picker's in-memory metadata cache is not
shared with the install resolver. As a result, metadata loaded/parsing work done to compute the
manifest rewrite cannot be reused by the immediately-following install resolution in the same
command run.
Code

pnpm/crates/package-manager/src/resolve_latest.rs[R71-104]

+    pub(crate) async fn resolve(
+        &self,
+        package_name: &str,
+        dry_run: bool,
+    ) -> Result<Arc<PackageVersion>, ResolveLatestError> {
+        let registry = pick_registry_for_package(&self.registries, package_name, None);
+        let spec = RegistryPackageSpec::latest_tag(package_name);
+
+        let opts = PickPackageOptions {
+            registry: &registry,
+            preferred_version_selectors: None,
+            published_by: self.policy.published_by,
+            published_by_exclude: self.policy.published_by_exclude.as_ref(),
+            pick_lowest_version: false,
+            // The spec already is the `latest` tag.
+            include_latest_tag: false,
+            dry_run,
+            optional: false,
+            update_checksums: false,
+            blocked_versions: None,
+        };
+        let ctx = pick_package_context(
+            self.http_client,
+            self.config,
+            &self.policy,
+            &self.meta_cache,
+            &self.fetch_locker,
+        );
+
+        let pick = pick_package(&ctx, &spec, &opts)
+            .await
+            .map_err(|error| ResolveLatestError::Pick(Box::new(error)))?;
+        pick.picked_package.ok_or(ResolveLatestError::NoLatestVersion)
+    }
Evidence
The new LatestPicker::resolve path always uses pick_package, which is the packument metadata
fetch/orchestration path, and the picker’s cache is explicitly per-pre-resolution (not the
install’s). Because both add and update invoke Install::run() immediately after computing
rewrites, any metadata work done in the picker cannot be reused by the install resolver in-process,
increasing total resolver work on these hot paths.

pnpm/crates/package-manager/src/resolve_latest.rs[36-104]
pnpm/crates/resolving-npm-resolver/src/pick_package.rs[401-452]
pnpm/crates/resolving-npm-resolver/src/pick_package.rs[648-727]
pnpm/crates/package-manager/src/resolution_policy.rs[106-112]
pnpm/crates/package-manager/src/add.rs[224-260]
pnpm/crates/package-manager/src/update.rs[529-610]

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

## Issue description
`LatestPicker::resolve()` always resolves `latest` via `pick_package()`, which is the packument metadata path. `pacquet add` and `pacquet update` then immediately call `Install::run()`, but the picker’s in-memory metadata cache is separate from the install resolver’s, so this pre-resolution work can’t be reused within the process.

## Issue Context
- The picker owns its own `InMemoryPackageMetaCache` and fetch locker.
- `pick_package()` is the full metadata orchestration path (cache keying, mirror reads, conditional fetch, JSON parse).
- `Add::run()` and `Update::run()` invoke `Install` after computing the manifest rewrite.

## Fix proposal
Add a conditional fast path in `LatestPicker::resolve()` that uses the lightweight dist-tag endpoint (`PackageVersion::fetch_from_registry(..., PackageTag::Latest, ...)`) when **no maturity filtering is needed** and **network access is allowed**.

Suggested gating (adjust as needed for parity):
- `self.policy.published_by.is_none()` AND `self.policy.published_by_exclude.is_none()` (no `minimumReleaseAge` behavior to enforce)
- `!self.config.offline` AND `!self.config.prefer_offline` (preserve offline/prefer-offline semantics that `pick_package()` supports via disk)

Keep the current `pick_package()`-based resolution when `minimumReleaseAge` is active or when offline/prefer-offline is set.

## Fix Focus Areas
- pnpm/crates/package-manager/src/resolve_latest.rs[51-104]
- pnpm/crates/package-manager/src/add.rs[224-257]
- pnpm/crates/package-manager/src/update.rs[569-610]
- pnpm/crates/resolving-npm-resolver/src/pick_package.rs[401-452]
- pnpm/crates/registry/src/package_version.rs[242-276]

ⓘ 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 c3443ae

Results up to commit 000bba6


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


Action required
1. Changeset missing pnpm entry ✗ Dismissed 📘 Rule violation § Compliance
Description
The new changeset front-matter only declares a bump for pacquet and does not include a pnpm
entry. This violates the changeset compliance requirement and can lead to incomplete or incorrect
release metadata.
Code

.changeset/pacquet-minimum-release-age-add-update.md[R1-3]

+---
+"pacquet": patch
+---
Evidence
PR Compliance ID 713436 requires newly added/modified changeset files to include a pnpm package
entry with a valid bump type. The added changeset front-matter contains only "pacquet": patch and
no pnpm entry.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-minimum-release-age-add-update.md[1-3]

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

## Issue description
The changeset front-matter is missing a required `pnpm` entry (with a valid bump type).

## Issue Context
Compliance requires changeset front-matter to explicitly include `pnpm` with a `patch`/`minor`/`major` bump type.

## Fix Focus Areas
- .changeset/pacquet-minimum-release-age-add-update.md[1-3]

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



Remediation recommended
2. Redundant latest metadata pick ✓ Resolved 🐞 Bug ➹ Performance
Description
LatestPicker::resolve resolves latest through pick_package (packument-based metadata
resolution) before Add/Update runs Install, but the picker's in-memory metadata cache is not
shared with the install resolver. As a result, metadata loaded/parsing work done to compute the
manifest rewrite cannot be reused by the immediately-following install resolution in the same
command run.
Code

pnpm/crates/package-manager/src/resolve_latest.rs[R71-104]

+    pub(crate) async fn resolve(
+        &self,
+        package_name: &str,
+        dry_run: bool,
+    ) -> Result<Arc<PackageVersion>, ResolveLatestError> {
+        let registry = pick_registry_for_package(&self.registries, package_name, None);
+        let spec = RegistryPackageSpec::latest_tag(package_name);
+
+        let opts = PickPackageOptions {
+            registry: &registry,
+            preferred_version_selectors: None,
+            published_by: self.policy.published_by,
+            published_by_exclude: self.policy.published_by_exclude.as_ref(),
+            pick_lowest_version: false,
+            // The spec already is the `latest` tag.
+            include_latest_tag: false,
+            dry_run,
+            optional: false,
+            update_checksums: false,
+            blocked_versions: None,
+        };
+        let ctx = pick_package_context(
+            self.http_client,
+            self.config,
+            &self.policy,
+            &self.meta_cache,
+            &self.fetch_locker,
+        );
+
+        let pick = pick_package(&ctx, &spec, &opts)
+            .await
+            .map_err(|error| ResolveLatestError::Pick(Box::new(error)))?;
+        pick.picked_package.ok_or(ResolveLatestError::NoLatestVersion)
+    }
Evidence
The new LatestPicker::resolve path always uses pick_package, which is the packument metadata
fetch/orchestration path, and the picker’s cache is explicitly per-pre-resolution (not the
install’s). Because both add and update invoke Install::run() immediately after computing
rewrites, any metadata work done in the picker cannot be reused by the install resolver in-process,
increasing total resolver work on these hot paths.

pnpm/crates/package-manager/src/resolve_latest.rs[36-104]
pnpm/crates/resolving-npm-resolver/src/pick_package.rs[401-452]
pnpm/crates/resolving-npm-resolver/src/pick_package.rs[648-727]
pnpm/crates/package-manager/src/resolution_policy.rs[106-112]
pnpm/crates/package-manager/src/add.rs[224-260]
pnpm/crates/package-manager/src/update.rs[529-610]

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

## Issue description
`LatestPicker::resolve()` always resolves `latest` via `pick_package()`, which is the packument metadata path. `pacquet add` and `pacquet update` then immediately call `Install::run()`, but the picker’s in-memory metadata cache is separate from the install resolver’s, so this pre-resolution work can’t be reused within the process.

## Issue Context
- The picker owns its own `InMemoryPackageMetaCache` and fetch locker.
- `pick_package()` is the full metadata orchestration path (cache keying, mirror reads, conditional fetch, JSON parse).
- `Add::run()` and `Update::run()` invoke `Install` after computing the manifest rewrite.

## Fix proposal
Add a conditional fast path in `LatestPicker::resolve()` that uses the lightweight dist-tag endpoint (`PackageVersion::fetch_from_registry(..., PackageTag::Latest, ...)`) when **no maturity filtering is needed** and **network access is allowed**.

Suggested gating (adjust as needed for parity):
- `self.policy.published_by.is_none()` AND `self.policy.published_by_exclude.is_none()` (no `minimumReleaseAge` behavior to enforce)
- `!self.config.offline` AND `!self.config.prefer_offline` (preserve offline/prefer-offline semantics that `pick_package()` supports via disk)

Keep the current `pick_package()`-based resolution when `minimumReleaseAge` is active or when offline/prefer-offline is set.

## Fix Focus Areas
- pnpm/crates/package-manager/src/resolve_latest.rs[51-104]
- pnpm/crates/package-manager/src/add.rs[224-257]
- pnpm/crates/package-manager/src/update.rs[569-610]
- pnpm/crates/resolving-npm-resolver/src/pick_package.rs[401-452]
- pnpm/crates/registry/src/package_version.rs[242-276]

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


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

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

No code suggestions found for the PR.

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

@codecov-commenter

codecov-commenter commented Jul 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.02649% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.47%. Comparing base (e7138af) to head (c3443ae).

Files with missing lines Patch % Lines
pnpm/crates/package-manager/src/add.rs 81.81% 4 Missing ⚠️
pnpm/crates/package-manager/src/update.rs 94.73% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13102      +/-   ##
==========================================
+ Coverage   85.45%   85.47%   +0.01%     
==========================================
  Files         501      502       +1     
  Lines       80654    80748      +94     
==========================================
+ Hits        68924    69018      +94     
  Misses      11730    11730              

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

Copilot AI review requested due to automatic review settings July 17, 2026 12:46

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 a3ec3d1

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

Copilot AI review requested due to automatic review settings July 17, 2026 12:59

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.

@zkochan

zkochan commented Jul 17, 2026

Copy link
Copy Markdown
Member Author

Review follow-up:

  • The redundant-packument performance finding was valid and is fixed in c3443ae. With no maturity policy and normal online resolution, LatestPicker keeps the lightweight /latest endpoint; maturity filtering and offline modes still use the full package picker. The scoped-registry test now covers the fast path.
  • The exact-versus-caret observation is fixture-driven, not a stack divergence: the TypeScript test starts from an exact 1.0.0 specifier while the pacquet test starts from ^1.0.0; both implementations preserve the existing operator during update --latest.
  • The changeset naming rules are clarified in a3ec3d1: pacquet is the frontmatter package name, pnpm is the shipped executable used in release-note command examples, and Rust-only changesets must omit the TypeScript "pnpm" package.

Validation passed: focused package-manager routing, all six minimum-release-age add/update CLI tests, Rust formatting and touched-package clippy, plus the full pre-push suite.


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

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

Copy link
Copy Markdown

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

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

Auto-approved notes - no code suggestions found
- 'approve_pr_on_self_review' flag enabled

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

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants