Repository navigation
refactor(npm-resolver): decide the pick's mirror shortcuts and cache hit from inputs alone - #17064
Conversation
…hit from inputs alone `route.ts` holds the decisions `pickPackage` makes before it reads a mirror's content, as pnpm v12's `pick_package::route` does: `readsMirrorFirst`, `decideMirrorShortcuts`, `mirrorWrittenAfter`, the unvalidated-mirror checks, and `decideCacheHitCheck` for an in-memory hit. `pickPackage.ts` keeps the reads and the content checks. `canReuseStableCachedRange` and `isUnverifiedPickSafe` are gone: both asked the same stable-range question. No behavior change. Table tests cover each decision. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
@coderabbitai review |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
PR Summary by QodoRefactor v11 npm resolver mirror and cache-hit routing
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
|
Qodo findings:
Written by an agent (Claude Code, claude-opus-5-5). |
Thanks for the update. The current review state is:
The v12 precedents support the rationale for finding 3, but they do not automatically change this PR’s finding status. |
|
Code review by qodo was updated up to the latest commit e140edf |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Qodo finding 4 (route type list misses its final comma): fixed in 093e584. The keys are now a named Written by an agent (Claude Code, claude-opus-5-5). |
There was a problem hiding this comment.
Your trial has ended. Reactivate Greptile to resume code reviews.
Understood. The route type-list finding is currently listed as finding 3 in the published review (despite your reference to finding 4), and your commit |
|
Code review by qodo was updated up to the latest commit 093e584 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Correction to the description's "Where v11 and v12 differ" list. Two of the four items are not CLI differences. v12's
The other two items, the stable-range shortcuts under Written by an agent (Claude Code, claude-opus-5-5). |
Summary
Part of pnpm/tasks#146, v11 only. This is the v11 counterpart of #17032 and #17051. It changes no behavior.
src/route.tsholds the decisionspickPackagemakes before it reads a mirror's content:readsMirrorFirstpickFromMirrorPreferringOfflinedecideMirrorShortcuts(exactVersion,dominantLockfileVersion,unvalidatedMirror)pickExactVersionFromMirror,pickStableRangeFromMirror,pickFromFreshUnvalidatedMirror, andcanReuseStableCachedRangemirrorWrittenAfterpickFromMirrorWrittenAfterCutoffisMirrorWithoutEtag,isFreshUnvalidatedMirrorisReusableMirrorWithoutEtag,isYoungerThanUnvalidatedMirrorMaxAgedecideCacheHitCheck(serve,stableRangePick,revalidate)isUnverifiedPickSafeand thecacheResultCanReturnexpressionpickPackage.tskeeps the reads and the content checks.Hot path. No pick does more work than before. The shortcuts are a few flag reads, decided only after the mirror-first read misses. The
publishedByExcludelookup still runs last, and only when a cutoff is set. A test pins that order. The cache hit now computes the dominant lockfile version only for an unverified stable-range pick. Before, it computed it for every unverified hit.Tests.
test/route.test.tshas table tests with v12's route cases. To test the tests, I madedecideCacheHitCheckserve where it returnsstableRangePick, and let pnpm update reuse an unvalidated mirror. The new table tests failed, and so did the existingmetaCache.test.tstests. The full npm-resolver suite passes: 580 tests.Where v11 and v12 differ. I kept these as they are. Each would be its own fix with its own tests:
minimumReleaseAge. v11 rules them out wheneverminimumReleaseAgeis set, even for an excluded package. v12 rules them out only where the release age applies, so v11 is more conservative.401is not hidden. v11 has no public/private route split.401/403/private404. v11 falls back to the mirror on any error.No changeset: there is no user-visible change.
Squash Commit Body
Checklist
already linked to it solves it.
Written by an agent (Claude Code, claude-opus-5-5).
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit