Repository navigation
fix(pacquet): resolve latest through the maturity-aware picker - #13102
Conversation
`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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthrough
ChangesMinimum release age latest resolution
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
Possibly related issues
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
PR Summary by QodoFix pacquet add/update --latest to honor minimumReleaseAge when resolving latest
AI Description
Diagram
High-Level Assessment
Files changed (16)
|
Micro-Benchmark ResultsLinux |
There was a problem hiding this comment.
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
📒 Files selected for processing (16)
.changeset/pacquet-minimum-release-age-add-update.mdpnpm/crates/cli/tests/_utils.rspnpm/crates/cli/tests/add.rspnpm/crates/cli/tests/lockfile_verification.rspnpm/crates/cli/tests/update.rspnpm/crates/package-manager/src/add.rspnpm/crates/package-manager/src/add/tests.rspnpm/crates/package-manager/src/lib.rspnpm/crates/package-manager/src/resolution_policy.rspnpm/crates/package-manager/src/resolve_latest.rspnpm/crates/package-manager/src/update.rspnpm/crates/resolving-npm-resolver/src/pick_package.rspnpm/crates/resolving-npm-resolver/src/pick_package_from_meta.rspnpm11/installing/deps-installer/test/install/minimumReleaseAge.tspnpm11/pnpm/test/update.tspnpm11/testing/registry-mock/src/index.ts
💤 Files with no reviewable changes (1)
- pnpm/crates/package-manager/src/add/tests.rs
Confidence Score: 5/5Safe to merge — the fix is narrowly scoped to the The core logic is sound: No files require special attention. Reviews (3): Last reviewed commit: "perf(pacquet): avoid redundant latest pa..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit a3ec3d1 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
|
Review follow-up:
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). |
|
Code review by qodo was updated up to the latest commit c3443ae |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Summary
Supersedes #13021. The original PR's fork branch does not allow maintainer edits, so the required rebase could not be pushed after current
mainintroduced a conflicting multi-packageaddrefactor. This replacement preserves Manuel Pelloni's original commits and authorship, rebases them onto currentmain, 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 werepnpm add <pkg>without a version andpnpm update --latest: they fetched the rawlatestdist-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, keepingpackage.jsonand the lockfile consistent.The picker is constructed lazily so invalid
minimumReleaseAgeExcludeconfiguration 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 sameERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDEdiagnostic 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, andpnpm update --latest. The rebase also reuses the shared workspace-YAML test helper introduced onmaininstead of retaining duplicate fixture-editing logic.install/ bareupdatepick the newest mature in-range versionadd <name>/update --latestwrite mature-anchored rangesSquash Commit Body
Checklist
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.)pnpm changeset) because this changes the published pacquet package.Written by an agent (Codex, GPT-5).
Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by CodeRabbit
pnpm addwithout a specified version now respectsminimumReleaseAgewhen resolving the newest eligible version.pnpm updateandpnpm update --latestnow select the newest eligible mature version based onminimumReleaseAge.minimumReleaseAgeExcludenow consistently reportsERR_PNPM_INVALID_MINIMUM_RELEASE_AGE_EXCLUDE.minimumReleaseAgecoverage acrossaddandupdate, including lockfile and--latestscenarios.