Repository navigation
fix(resolver): targeted updates resolve exactly like a fresh install - #12558
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds ChangesupdateRequested flag — contracts, resolution, propagation, and tests
Estimated code review effort: 4 (Complex) | ~45 minutes Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches🧪 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 pnpm up targeted package downgrades by bypassing preferred versions Description
Diagram
High-Level Assessment
Files changed (11)
|
Code Review by Qodo
1. Selector proto pollution
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12558 +/- ##
==========================================
- Coverage 85.62% 85.07% -0.56%
==========================================
Files 413 415 +2
Lines 64343 65531 +1188
==========================================
+ Hits 55093 55749 +656
- Misses 9250 9782 +532 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Code review by qodo was updated up to the latest commit 967fe74 |
|
Code review by qodo was updated up to the latest commit 14597ce |
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 `@pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs`:
- Around line 2213-2226: The real_package_name_of function currently only
handles npm-alias dependencies (those with the "npm:" prefix) but fails for
plain dependencies like "foo@^1.0". When strip_prefix returns None for a plain
dependency, the function should fall back to returning wanted.alias instead of
continuing with the current logic. Modify the function to check if the
bare_specifier contains an "npm:" prefix, and if not, return wanted.alias
directly as the real package name, since the doc comment confirms that for plain
deps, the real name is just wanted.alias.
🪄 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: d5a43bb3-3af3-4b65-b76c-ed9c145d62be
📒 Files selected for processing (1)
pacquet/crates/resolving-deps-resolver/src/resolve_dependency_tree.rs
|
Code review by qodo was updated up to the latest commit 14597ce |
|
Code review by qodo was updated up to the latest commit d1bef9d |
|
Code review by qodo was updated up to the latest commit d1bef9d |
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD. Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.7246608341600003,
"stddev": 0.1413476162543192,
"median": 3.6936887975599997,
"user": 3.6314598600000005,
"system": 3.31275064,
"min": 3.5920496630599996,
"max": 3.99267119706,
"times": [
3.7084784380599998,
3.99267119706,
3.60288112706,
3.6788991570599996,
3.7215013670599997,
3.93323800206,
3.5920496630599996,
3.62063784306,
3.79157988906,
3.60467165806
]
},
{
"command": "pacquet@main",
"mean": 3.7736063234599997,
"stddev": 0.1554930969427297,
"median": 3.72446619956,
"user": 3.63038906,
"system": 3.2825523399999996,
"min": 3.60297294806,
"max": 4.01344600106,
"times": [
3.89356138206,
3.62142474806,
3.75419748706,
3.87829433306,
4.01344600106,
3.98283444106,
3.63794603206,
3.69473491206,
3.60297294806,
3.65665095006
]
},
{
"command": "pnpr@HEAD",
"mean": 2.0612072767600003,
"stddev": 0.10109192813474265,
"median": 2.0373949935599995,
"user": 2.72377386,
"system": 2.8905569399999997,
"min": 1.93094209306,
"max": 2.26504542506,
"times": [
2.0771813250599998,
1.93094209306,
2.0160667550599998,
1.9495641430600001,
2.13558053406,
2.26504542506,
2.03917992306,
2.15631354706,
2.0356100640599997,
2.00658895806
]
},
{
"command": "pnpr@main",
"mean": 2.11257380156,
"stddev": 0.12791401200244656,
"median": 2.1029812675599997,
"user": 2.7405535599999995,
"system": 2.86263344,
"min": 1.94556165606,
"max": 2.3035358480599997,
"times": [
2.1661562110599997,
1.99985305706,
2.2161403950599996,
1.94556165606,
2.0238690620599997,
2.04488172306,
1.98913212806,
2.27552712306,
2.16108081206,
2.3035358480599997
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6432221237600001,
"stddev": 0.00606261116951773,
"median": 0.6449747596600001,
"user": 0.38356344,
"system": 1.31634674,
"min": 0.63090664216,
"max": 0.64952163616,
"times": [
0.64952163616,
0.6447209341600001,
0.64931593316,
0.63900464416,
0.6359434461600001,
0.6470536651600001,
0.6442000531600001,
0.64522858516,
0.6463256981600001,
0.63090664216
]
},
{
"command": "pacquet@main",
"mean": 0.64992375246,
"stddev": 0.03617550731575041,
"median": 0.64295270616,
"user": 0.37260374,
"system": 1.3154927400000003,
"min": 0.6127498611600001,
"max": 0.7270844831600001,
"times": [
0.6418891791600001,
0.61938881516,
0.6127498611600001,
0.6511332641600001,
0.6497267131600001,
0.61776608316,
0.63824622616,
0.64401623316,
0.7270844831600001,
0.69723666616
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7165955367600001,
"stddev": 0.05047376638906819,
"median": 0.70269024616,
"user": 0.4044834399999999,
"system": 1.3540593399999998,
"min": 0.6820169151600001,
"max": 0.8575931401600001,
"times": [
0.6992500941600001,
0.6820169151600001,
0.70653923616,
0.71190903216,
0.70283189116,
0.68938501316,
0.69936279716,
0.8575931401600001,
0.71451864716,
0.7025486011600001
]
},
{
"command": "pnpr@main",
"mean": 0.6851919167600001,
"stddev": 0.012194666727259176,
"median": 0.68900372666,
"user": 0.39208504,
"system": 1.34093114,
"min": 0.6616861351600001,
"max": 0.69938462416,
"times": [
0.69567526516,
0.68641380716,
0.6616861351600001,
0.6853688011600001,
0.6768844661600001,
0.69298017416,
0.6915936461600001,
0.69938462416,
0.6925125951600001,
0.6694196531600001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.19087040094,
"stddev": 0.02979444097484045,
"median": 4.189701530740001,
"user": 3.8026526399999994,
"system": 3.27924328,
"min": 4.14304652624,
"max": 4.23524670624,
"times": [
4.156063260240001,
4.167661245240001,
4.20854535324,
4.23524670624,
4.14304652624,
4.2017213922400005,
4.230044776240001,
4.18949550324,
4.189907558240001,
4.18697168824
]
},
{
"command": "pacquet@main",
"mean": 4.197200707240001,
"stddev": 0.029221173191613353,
"median": 4.19740371924,
"user": 3.7753069399999992,
"system": 3.28793858,
"min": 4.14066493424,
"max": 4.239380225240001,
"times": [
4.2071600592400005,
4.239380225240001,
4.19663766624,
4.1989170622400005,
4.166816193240001,
4.19816977224,
4.19440636724,
4.192051660240001,
4.14066493424,
4.237803132240001
]
},
{
"command": "pnpr@HEAD",
"mean": 2.0997359499400003,
"stddev": 0.13320936603279712,
"median": 2.07485739074,
"user": 2.5641078399999997,
"system": 2.8100061800000002,
"min": 1.9638266962400002,
"max": 2.40058860024,
"times": [
2.02803596324,
2.1703762362399996,
2.06906757724,
2.08064720424,
1.9815169592400002,
2.1875032762399997,
1.97392371124,
2.14187327524,
2.40058860024,
1.9638266962400002
]
},
{
"command": "pnpr@main",
"mean": 2.18486803304,
"stddev": 0.15747450519189865,
"median": 2.1388556117399995,
"user": 2.5609335399999997,
"system": 2.7857392800000005,
"min": 2.02576343324,
"max": 2.4763505922399998,
"times": [
2.0997601912399997,
2.0740777102399997,
2.04987871824,
2.31024613224,
2.4763505922399998,
2.1779510322399998,
2.20022104624,
2.3861412992399997,
2.04829017524,
2.02576343324
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.3674657685599998,
"stddev": 0.0064020247084026535,
"median": 1.3685669947599999,
"user": 1.34993514,
"system": 1.71739192,
"min": 1.35735361076,
"max": 1.37551656376,
"times": [
1.36976965676,
1.35735361076,
1.36442660176,
1.36964657676,
1.37551656376,
1.36064009576,
1.3674874127599999,
1.36111836176,
1.37369625876,
1.37500254676
]
},
{
"command": "pacquet@main",
"mean": 1.34420980196,
"stddev": 0.014047279689980183,
"median": 1.34646956976,
"user": 1.2963967399999998,
"system": 1.7014382199999996,
"min": 1.3248971457599998,
"max": 1.36899370676,
"times": [
1.34545818676,
1.34748095276,
1.36899370676,
1.35233806076,
1.3310696017599999,
1.35770737176,
1.33073138776,
1.35069355276,
1.3248971457599998,
1.33272805276
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6697719189600002,
"stddev": 0.04086806318362009,
"median": 0.65832224376,
"user": 0.34643503999999997,
"system": 1.27411552,
"min": 0.6436913617600001,
"max": 0.78472725876,
"times": [
0.6598468997600001,
0.6436913617600001,
0.65949425776,
0.65715022976,
0.78472725876,
0.65628353776,
0.66659973776,
0.6551539777600001,
0.66290462376,
0.6518673047600001
]
},
{
"command": "pnpr@main",
"mean": 0.6575524184600001,
"stddev": 0.027380004779573263,
"median": 0.6518776702600001,
"user": 0.33985273999999993,
"system": 1.26578272,
"min": 0.6383659787600001,
"max": 0.7328555517600001,
"times": [
0.6396732887600001,
0.6546215697600001,
0.6491337707600001,
0.6433728967600001,
0.6383659787600001,
0.64724782276,
0.6567990787600001,
0.7328555517600001,
0.6567110797600001,
0.6567431467600001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0379021092599996,
"stddev": 0.04801095384740627,
"median": 3.02238226476,
"user": 1.77275806,
"system": 2.0008987599999997,
"min": 2.99946986526,
"max": 3.15228198726,
"times": [
3.04578110726,
3.00757579826,
2.99946986526,
3.0049384672599997,
3.04270025326,
3.00295974926,
3.0371887312599997,
3.15228198726,
3.0055156252599997,
3.08060950826
]
},
{
"command": "pacquet@main",
"mean": 3.03873861996,
"stddev": 0.0315467777302544,
"median": 3.03179269576,
"user": 1.7321957600000002,
"system": 2.0349439599999997,
"min": 2.99089168026,
"max": 3.0801738202599998,
"times": [
3.01679755426,
3.0799099442599998,
2.99089168026,
3.0801738202599998,
3.02872715726,
3.06282495326,
3.02237935026,
3.06531910026,
3.00550440526,
3.0348582342599997
]
},
{
"command": "pnpr@HEAD",
"mean": 0.65968629656,
"stddev": 0.01008373991773447,
"median": 0.65905324026,
"user": 0.34939606,
"system": 1.2609610600000003,
"min": 0.6455293682600001,
"max": 0.67440460426,
"times": [
0.65776979826,
0.65079700226,
0.67440460426,
0.6603366822600001,
0.67217264726,
0.64918686426,
0.66908662826,
0.65336508926,
0.6455293682600001,
0.66421428126
]
},
{
"command": "pnpr@main",
"mean": 0.6546763072600001,
"stddev": 0.01244834605671281,
"median": 0.65193842776,
"user": 0.32973936000000004,
"system": 1.26189036,
"min": 0.64072478526,
"max": 0.67989959326,
"times": [
0.66341332726,
0.6553937172600001,
0.64609541526,
0.64072478526,
0.64848313826,
0.6664179572600001,
0.65718014526,
0.64091361826,
0.67989959326,
0.64824137526
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.64138592506,
"stddev": 0.01302149363832944,
"median": 0.6391970812600001,
"user": 0.5956248399999999,
"system": 0.15549252,
"min": 0.6229394222600001,
"max": 0.67368245926,
"times": [
0.64053888126,
0.6370206942600001,
0.6455919292600001,
0.6229394222600001,
0.63781587326,
0.63291621026,
0.63785528126,
0.6412381582600001,
0.6442603412600001,
0.67368245926
]
},
{
"command": "pacquet@main",
"mean": 0.6413510436600001,
"stddev": 0.013005213884198877,
"median": 0.63870946526,
"user": 0.59453784,
"system": 0.15877791999999996,
"min": 0.62776365426,
"max": 0.6720424512600001,
"times": [
0.6352267152600001,
0.64224699626,
0.64659692526,
0.62968657126,
0.6319066762600001,
0.63718340626,
0.6402355242600001,
0.62776365426,
0.6720424512600001,
0.6506215162600001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.10720012282,
"stddev": 0.00031577405422219797,
"median": 0.10720259426,
"user": 0.027990759999999993,
"system": 0.0198191,
"min": 0.10664802326,
"max": 0.10800045526,
"times": [
0.10664802326,
0.10728672826,
0.10737588026,
0.10731035426,
0.10731882626,
0.10681577226,
0.10753341326,
0.10709646726000001,
0.10678749926,
0.10739377726,
0.10739572026000001,
0.10692215826,
0.10719522226,
0.10723914826,
0.10712407826,
0.10720259426,
0.10741339626,
0.10781969726,
0.10730500626,
0.10704187626,
0.10706846526,
0.10704761426,
0.10800045526,
0.10678768926,
0.10687320726
]
},
{
"command": "pnpr@main",
"mean": 0.10722833038000001,
"stddev": 0.0002752894617884526,
"median": 0.10728917226,
"user": 0.028251520000000002,
"system": 0.0198509,
"min": 0.10645634926,
"max": 0.10757024826,
"times": [
0.10728917226,
0.10703953226,
0.10742529326,
0.10723379026,
0.10756990726,
0.10695347526,
0.10735444926,
0.10757024826,
0.10678904226000001,
0.10716478726,
0.10749250326,
0.10645634926,
0.10752113526,
0.10731022426,
0.10749018026,
0.10730095126,
0.10717467426,
0.10691644226000001,
0.10684408426,
0.10743217426,
0.10737159426000001,
0.10745604026,
0.10728553326,
0.10709128026,
0.10717539526
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.49742467444,
"stddev": 0.09678707370494787,
"median": 6.48427666734,
"user": 3.82981762,
"system": 3.57848378,
"min": 6.37010639934,
"max": 6.64656966134,
"times": [
6.572486766340001,
6.44278483134,
6.62754620934,
6.45395314834,
6.37010639934,
6.53418198434,
6.51460018634,
6.4007924133400005,
6.64656966134,
6.41122514434
]
},
{
"command": "pacquet@main",
"mean": 6.496139363439999,
"stddev": 0.17262853246324641,
"median": 6.43807284934,
"user": 3.8395580200000006,
"system": 3.54729368,
"min": 6.3284106513400005,
"max": 6.82617591634,
"times": [
6.3284106513400005,
6.76242691834,
6.39802745634,
6.47523504134,
6.82617591634,
6.354013221340001,
6.57142991134,
6.36952881934,
6.46577004334,
6.41037565534
]
},
{
"command": "pnpr@HEAD",
"mean": 4.8904755505400015,
"stddev": 0.100843261050688,
"median": 4.837263891840001,
"user": 2.83791242,
"system": 3.11557498,
"min": 4.77773546834,
"max": 5.04647124634,
"times": [
4.837106659340001,
4.83669082934,
5.0420204253400005,
4.8374211243400005,
4.829896225340001,
4.77773546834,
4.94151422134,
5.04647124634,
4.787481333340001,
4.96841797234
]
},
{
"command": "pnpr@main",
"mean": 4.89195004114,
"stddev": 0.11153771060066227,
"median": 4.87914891884,
"user": 2.8331100200000003,
"system": 3.12527798,
"min": 4.734754227340001,
"max": 5.117012503340001,
"times": [
4.93991125834,
4.98957440734,
4.900824911340001,
4.7981664983400005,
5.117012503340001,
4.84990697834,
4.734754227340001,
4.942056331340001,
4.78982036934,
4.857472926340001
]
}
]
} |
|
| Branch | pr/12558 |
| Testbed | pnpr |
⚠️ 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-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 2,099.74 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 659.69 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 669.77 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 107.20 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 2,061.21 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 4,890.48 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 716.60 ms |
|
Code review by qodo was updated up to the latest commit 579bf4a |
1 similar comment
|
Code review by qodo was updated up to the latest commit 579bf4a |
|
Code review by qodo was updated up to the latest commit 5cec28d |
1 similar comment
|
Code review by qodo was updated up to the latest commit 5cec28d |
|
Code review by qodo was updated up to the latest commit 4aad8b8 |
Summary
Redefines the update contract so that
pnpm up <pkg>produces exactly the lockfile a fresh install of the same manifests would (equivalently: delete the target's lockfile entries and runpnpm install). Three cases are fixed under that principle:updateRequestedmakes the picker ignore only the target's lockfile-derived pins; manifest pins, down-chain propagated versions, andrange/tagselectors (audit-fix penalties) keep applying, so updates never install duplicates a reinstall would not reproducepreferredVersions, allowing unrelated open ranges to re-resolvepreferredVersionsfrom the lockfile; caller-supplied preferred versions (audit-fix penalties) merge over the seed instead of replacing itpnpm update <dep>@<version>silently ignored<version>when<dep>is only a transitive dependency (#12744)pnpm.overridesentry, which is the mechanism that does pin transitive dependenciesWhen a preferred version legitimately holds the update target below the newest version its range admits (e.g. a sibling's pin in the fresh-install resolution), pnpm now prints a warning recommending an override — a warning rather than an error so existing scripts keep passing.
All three fixes are implemented in both the TypeScript CLI and pacquet. On the pacquet side the picker needs no selector stripping at all:
UpdateSeedPolicyalready withholds the target's lockfile pins at seed-build time, which is the same semantics;update_requestedthere only gates the held-back-update warning.Relationship to #12752
#12752 (by
m2na7, credited viaCo-authored-by) was folded into this PR because the two changes interact. Its approach — injecting the requested version of a transitive-only update intopreferredVersions— was ultimately replaced by the warning above: under the update-matches-install contract there is no install that produces the requested version for a transitive dep, so synthesizing a temporary preference would create a lockfile that the next fresh install silently undoes. Its regression tests (including the prototype-pollution guard for crafted package names) are retained, updated to the final behavior, and its seed-merge insight survives in the install layer (interaction 2 above).What's preserved
pnpm audit --fixpenalties. Vulnerability penalties arerangeselectors with negative weight; they keep applying even to the targeted package, and the held-back warning's baseline includes them, so it never recommends a version the penalties avoid.Closes #10662.
Closes #12744.
Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting. Targeted-bump direction and jsr folding are in both stacks; the unrelated-stays-pinned direction is TS-only (pacquet already correct viaUpdateSeedPolicy::DropOnly(names)— see Summary).pnpm changeset) if this PR changes any published package. Keep it short and written for pnpm users — it becomes a release note. Two changesets:update-requested-bypass-preferred.md(targeted-bump direction) andfix-update-unrelated-bumps.md(unrelated-stays-pinned).up -rcloser to install for these two cases.Written by an agent (opencode, glm-5.2).
Summary by CodeRabbit
pnpm up -r <pkg>so updating one package no longer downgrades unrelated packages due to unrelated exact preferred versions..gitignorefor additional generatedpnpmcompile output directories.