Repository navigation
fix(deps-resolver): preserve workspace link: on re-resolution (fixes pnpm/pnpm#10433) - #13112
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:
📝 WalkthroughWalkthroughThe resolver and Rust lockfile builder now carry previous importer data and update scopes to preserve untouched workspace ChangesWorkspace link preservation
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant InstallWithFreshLockfile
participant build_fresh_lockfile
participant dependencies_graph_to_lockfile
participant build_importer
participant PreviousImporter
InstallWithFreshLockfile->>build_fresh_lockfile: pass previous importers and update scope
build_fresh_lockfile->>dependencies_graph_to_lockfile: forward lockfile build inputs
dependencies_graph_to_lockfile->>build_importer: pass prior importer and update scope
build_importer->>PreviousImporter: read prior dependency reference
build_importer-->>dependencies_graph_to_lockfile: preserve link or emit file
Suggested labels: 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 |
7ff0e67 to
ea3fa4c
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13112 +/- ##
==========================================
+ Coverage 87.86% 87.87% +0.01%
==========================================
Files 549 549
Lines 96091 96151 +60
==========================================
+ Hits 84429 84492 +63
+ Misses 11662 11659 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: 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
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7440469053600003,
"stddev": 0.05101540573281461,
"median": 2.74877682046,
"user": 2.7836663,
"system": 2.0229925,
"min": 2.63768305946,
"max": 2.8087714414600002,
"times": [
2.80597401446,
2.74473259046,
2.75282105046,
2.63768305946,
2.77100312046,
2.8087714414600002,
2.6897268424600003,
2.73126359146,
2.74171694146,
2.7567764014600002
]
},
{
"command": "pacquet@main",
"mean": 2.84970250106,
"stddev": 0.20953989145992022,
"median": 2.79639372446,
"user": 2.949760199999999,
"system": 2.0063907,
"min": 2.66070984446,
"max": 3.37086988946,
"times": [
2.67432364746,
2.91045855946,
2.66070984446,
2.69839309446,
2.85597649846,
2.77260889346,
2.82017855546,
3.37086988946,
2.75939949546,
2.97410653246
]
},
{
"command": "pnpr@HEAD",
"mean": 1.78136751606,
"stddev": 0.19315394369831893,
"median": 1.70405954746,
"user": 2.0709110999999996,
"system": 1.8723759999999998,
"min": 1.5723402214600002,
"max": 2.09517503646,
"times": [
2.09517503646,
1.71759033846,
1.69052875646,
2.06176656846,
1.9050714644600002,
1.62557048946,
1.89644107146,
1.64321602946,
1.5723402214600002,
1.60597518446
]
},
{
"command": "pnpr@main",
"mean": 1.7445495598599998,
"stddev": 0.1302678062623,
"median": 1.7028034819600002,
"user": 1.8537358999999998,
"system": 1.7662612,
"min": 1.61468814146,
"max": 1.9676935714600001,
"times": [
1.62499265046,
1.6228091124600001,
1.83529092146,
1.66419390546,
1.9332917814600001,
1.61468814146,
1.73526085346,
1.77692855046,
1.9676935714600001,
1.6703461104600001
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.44069508052,
"stddev": 0.03177374093516833,
"median": 0.44026168772,
"user": 0.39244434000000006,
"system": 0.7880976999999999,
"min": 0.38714904522000004,
"max": 0.48463860022000005,
"times": [
0.44169256222000003,
0.45764937522000004,
0.43883081322,
0.38714904522000004,
0.48463860022000005,
0.43554540622000004,
0.46553661422000003,
0.47492933422,
0.42382463422,
0.39715442022
]
},
{
"command": "pacquet@main",
"mean": 0.43078329452,
"stddev": 0.028667673383034983,
"median": 0.42516055872,
"user": 0.39177634,
"system": 0.7781338999999999,
"min": 0.39570432422,
"max": 0.48894069622,
"times": [
0.45834103022,
0.43171301522,
0.48894069622,
0.41860810222,
0.41358695022,
0.40345682922000004,
0.45242348622,
0.43321025022000004,
0.39570432422,
0.41184826122
]
},
{
"command": "pnpr@HEAD",
"mean": 0.48501956992000006,
"stddev": 0.05004512084495434,
"median": 0.48340788222000003,
"user": 0.42478614,
"system": 0.7958657999999998,
"min": 0.39714110622000004,
"max": 0.54428831022,
"times": [
0.39714110622000004,
0.54428831022,
0.53820674622,
0.5250353962200001,
0.48608866922000005,
0.53376875122,
0.46279101822,
0.43324664022000003,
0.48072709522,
0.44890196622
]
},
{
"command": "pnpr@main",
"mean": 0.47369603902,
"stddev": 0.02113469752084153,
"median": 0.47260198722,
"user": 0.41281033999999994,
"system": 0.7807164999999998,
"min": 0.43377205122,
"max": 0.5060183392200001,
"times": [
0.48355172322,
0.46837388122,
0.49553514222,
0.5060183392200001,
0.48968800122,
0.45661401422000003,
0.46487370722000004,
0.47683009322000003,
0.46170343722,
0.43377205122
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.2010035762599998,
"stddev": 0.09789828982808513,
"median": 3.20086972876,
"user": 2.9858979999999997,
"system": 2.1001395,
"min": 3.05498709576,
"max": 3.34518325076,
"times": [
3.30477968676,
3.12832717676,
3.20758813876,
3.08155615176,
3.14579659476,
3.2674052477599997,
3.05498709576,
3.34518325076,
3.19415131876,
3.28026110076
]
},
{
"command": "pacquet@main",
"mean": 3.0773842763599997,
"stddev": 0.06235243227292206,
"median": 3.07509600876,
"user": 2.7701723999999994,
"system": 2.0638456999999995,
"min": 2.97332495576,
"max": 3.17052375376,
"times": [
3.07746221776,
3.11691525876,
2.97332495576,
3.0107083227599998,
3.03871409576,
3.17052375376,
3.07272979976,
3.06935541276,
3.07785957676,
3.16624936976
]
},
{
"command": "pnpr@HEAD",
"mean": 1.8576154694600002,
"stddev": 0.20656138975477872,
"median": 1.86040728526,
"user": 1.9390304000000005,
"system": 1.8780388999999995,
"min": 1.61143663476,
"max": 2.23935803176,
"times": [
1.98671884976,
1.84082008276,
1.72235194476,
1.63547818276,
2.23935803176,
1.6690106127600002,
1.61143663476,
1.89804268676,
1.8799944877599999,
2.09294318076
]
},
{
"command": "pnpr@main",
"mean": 1.83771271006,
"stddev": 0.156221990076029,
"median": 1.76236198676,
"user": 1.9465776,
"system": 1.8833109000000001,
"min": 1.66384715176,
"max": 2.11921414276,
"times": [
1.75439458576,
1.66384715176,
1.7432805287600002,
1.91886552176,
2.09504591776,
1.8187076067599999,
1.77032938776,
1.7417534567600002,
1.75168880076,
2.11921414276
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.9266261087800001,
"stddev": 0.0364814716638094,
"median": 0.93971508808,
"user": 1.2484594999999998,
"system": 1.10204062,
"min": 0.84534461758,
"max": 0.9646077645800001,
"times": [
0.88537044758,
0.9646077645800001,
0.9388756795800001,
0.94449350858,
0.94055449658,
0.94352107358,
0.91617655558,
0.9608141075800001,
0.92650283658,
0.84534461758
]
},
{
"command": "pacquet@main",
"mean": 0.7281267038800001,
"stddev": 0.06069566347190242,
"median": 0.7066889730800001,
"user": 1.0135782,
"system": 0.9785107199999998,
"min": 0.6450555275800001,
"max": 0.84411092858,
"times": [
0.81552430858,
0.6929185745800001,
0.70069855158,
0.69346203058,
0.73919765258,
0.7126793945800001,
0.7456039585800001,
0.84411092858,
0.69201611158,
0.6450555275800001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.49952392188,
"stddev": 0.059837843132071196,
"median": 0.49042415958,
"user": 0.3776015,
"system": 0.8220297200000001,
"min": 0.41910595758,
"max": 0.63983895658,
"times": [
0.41910595758,
0.45356146058,
0.48966990158,
0.46184219358,
0.49859219358,
0.48682050558,
0.54553056658,
0.49117841758,
0.63983895658,
0.5090990655800001
]
},
{
"command": "pnpr@main",
"mean": 0.49967939738,
"stddev": 0.032903385882991326,
"median": 0.50224538108,
"user": 0.3967891,
"system": 0.7776178200000001,
"min": 0.45282904858,
"max": 0.5507781765800001,
"times": [
0.48514823158000003,
0.52717723258,
0.51934253058,
0.5199031885800001,
0.46652888458,
0.45282904858,
0.52713929058,
0.47369080658,
0.47425658358,
0.5507781765800001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.3147615456799997,
"stddev": 0.059385920542954405,
"median": 2.3242327920799997,
"user": 1.6322159799999998,
"system": 1.28745544,
"min": 2.24511061008,
"max": 2.4004613940799997,
"times": [
2.4004613940799997,
2.2682548260799997,
2.24627891408,
2.3097699170799997,
2.37185465608,
2.24695454908,
2.36793528108,
2.24511061008,
2.3386956670799997,
2.3522996420799998
]
},
{
"command": "pacquet@main",
"mean": 2.29314799548,
"stddev": 0.06994015824651333,
"median": 2.3067487510799998,
"user": 1.6562268799999997,
"system": 1.2203524399999999,
"min": 2.17750817108,
"max": 2.38078310008,
"times": [
2.17750817108,
2.31656859208,
2.37615060008,
2.19940329008,
2.2681583820799998,
2.38078310008,
2.2969289100799997,
2.32226564108,
2.3480034970799997,
2.24570977108
]
},
{
"command": "pnpr@HEAD",
"mean": 0.50191163678,
"stddev": 0.02802390126504078,
"median": 0.50082718708,
"user": 0.39967408,
"system": 0.7799032399999999,
"min": 0.46405288808,
"max": 0.53884385808,
"times": [
0.53119327508,
0.5298863000799999,
0.48102718208,
0.52140181408,
0.5144905250799999,
0.46405288808,
0.48716384908000004,
0.48036938108000005,
0.47068729508,
0.53884385808
]
},
{
"command": "pnpr@main",
"mean": 0.45691251708,
"stddev": 0.041339160986654265,
"median": 0.45418708158000004,
"user": 0.34952237999999997,
"system": 0.7344510399999998,
"min": 0.40616467808,
"max": 0.52812627008,
"times": [
0.44947477608,
0.50681873108,
0.46421692708,
0.41765491408000005,
0.42003224008,
0.42554164408,
0.40616467808,
0.52812627008,
0.49219560308000004,
0.45889938708000005
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.46260043381999993,
"stddev": 0.061417166747529256,
"median": 0.48285363872000003,
"user": 0.46321373999999993,
"system": 0.11712022,
"min": 0.35927098272,
"max": 0.5309579277200001,
"times": [
0.5309579277200001,
0.5069966117200001,
0.49489023172,
0.50425088072,
0.35927098272,
0.38287113672000006,
0.45563744772000003,
0.39946923972000004,
0.5208428337200001,
0.47081704572000005
]
},
{
"command": "pacquet@main",
"mean": 0.4091113029200001,
"stddev": 0.035268021342552185,
"median": 0.42357413122000004,
"user": 0.41247343999999997,
"system": 0.10320562,
"min": 0.35547097172000003,
"max": 0.45749214672000005,
"times": [
0.37670837972000004,
0.43010189172,
0.37014736172,
0.37936881872000006,
0.45749214672000005,
0.43867003672000004,
0.41704637072000006,
0.43310985672,
0.43299719472000003,
0.35547097172000003
]
},
{
"command": "pnpr@HEAD",
"mean": 0.12670387214857143,
"stddev": 0.01338809626112298,
"median": 0.12917717672,
"user": 0.04446458761904762,
"system": 0.016332876190476193,
"min": 0.10172378472,
"max": 0.14598441571999998,
"times": [
0.13442937572000002,
0.13270477372,
0.14598441571999998,
0.13772960272,
0.13625252572000002,
0.14551099372000004,
0.13847636172,
0.12917717672,
0.13313526572,
0.11869909872000001,
0.11341937972,
0.10987565472000001,
0.11872131072,
0.13678395872,
0.11429323772000001,
0.11503894572000001,
0.11306925872000001,
0.12767439272000003,
0.14583265972000004,
0.11224914172,
0.10172378472
]
},
{
"command": "pnpr@main",
"mean": 0.12351045081523808,
"stddev": 0.013032595137803573,
"median": 0.12101521972000001,
"user": 0.04311853999999998,
"system": 0.016701405714285713,
"min": 0.10621198172,
"max": 0.14713610872,
"times": [
0.13280054372,
0.14432843272,
0.11655996372,
0.10911014972000001,
0.11280411772000001,
0.13000190372000003,
0.10650909272,
0.10989717472,
0.11447795672000001,
0.11416620772000001,
0.11854337572000001,
0.12101521972000001,
0.13122193572000002,
0.12720756072,
0.14338395072,
0.13330950472000003,
0.13945819372,
0.14713610872,
0.12275411072,
0.11282198172,
0.10621198172
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 5.184260053040001,
"stddev": 0.23310388173035418,
"median": 5.15021724124,
"user": 3.4570569,
"system": 2.3563659400000003,
"min": 4.90470784474,
"max": 5.53558306574,
"times": [
5.05842830774,
5.331293011740001,
4.9684063407400005,
4.93511580174,
5.42171900774,
5.53558306574,
5.42100024574,
5.0243407297400005,
4.90470784474,
5.24200617474
]
},
{
"command": "pacquet@main",
"mean": 5.02268569254,
"stddev": 0.12603941488686426,
"median": 5.00867033924,
"user": 3.4499495,
"system": 2.39571784,
"min": 4.86719891174,
"max": 5.30246820274,
"times": [
5.01166877974,
5.014694055740001,
4.86719891174,
4.95364428474,
5.15430275874,
5.30246820274,
4.94562664974,
5.00567189874,
5.05395945574,
4.91762192774
]
},
{
"command": "pnpr@HEAD",
"mean": 3.8032241371400004,
"stddev": 0.1576127803609377,
"median": 3.74912528324,
"user": 2.1291021999999997,
"system": 1.9375259399999998,
"min": 3.6782994337400003,
"max": 4.08909749774,
"times": [
3.79734373474,
3.78649516774,
4.08909749774,
4.08728010874,
3.69022904974,
3.6782994337400003,
3.80456273374,
3.7117553987400003,
3.6994295067400005,
3.6877487397400004
]
},
{
"command": "pnpr@main",
"mean": 3.821441363140001,
"stddev": 0.12510462846192322,
"median": 3.8092251932400005,
"user": 2.1903288,
"system": 1.9700411399999997,
"min": 3.6749444447400004,
"max": 4.10539320974,
"times": [
3.6867691817400003,
3.90590312474,
3.6749444447400004,
4.10539320974,
3.8826538647400004,
3.8078561847400003,
3.7371180557400003,
3.82945123674,
3.7737301267400003,
3.8105942017400003
]
}
]
} |
|
| Branch | pr/13112 |
| 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 | 1,424.47 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 287.32 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 298.18 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.74 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,355.17 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,450.42 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 252.40 ms |
837e757 to
7f76033
Compare
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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/preserve-workspace-link-on-partial-update.md:
- Line 7: Update the release note so it does not claim pacquet supports the
recursive-update behavior while its per-importer handling differs from
TypeScript pnpm. Split or qualify the pacquet note to accurately describe
supported behavior, or implement equivalent recursive-update handling before
retaining the shared claim; preserve identical observable behavior between
pacquet and TypeScript pnpm.
In `@pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs`:
- Around line 1263-1270: Preserve per-importer update targets during
fresh-lockfile construction instead of forwarding only the global update scope:
in pnpm/crates/package-manager/src/install_with_fresh_lockfile.rs:1263-1270,
pass the target map or a dedicated matcher into lockfile building; in
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rs:328-382,
select targets by importer ID and close the parity gap so recursive named
updates produce TypeScript-equivalent paths; in
pnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rs:2028-2053,
add a recursive ByImporter regression covering this behavior. Pacquet and
TypeScript observable behavior must remain identical.
In
`@pnpm11/installing/deps-installer/test/install/injectWorkspacePackagesPersistence.test.ts`:
- Around line 513-518: Extend the assertions in the install regression test to
inspect both the injected and original divergent q peer contexts in the
resulting lockfile. Verify that each context resolves `@pnpm.e2e/foo` to 100.1.0
and 100.0.0 respectively, while preserving the existing consumer and link:
assertions so the test meaningfully covers peer-context deduplication.
🪄 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: e13cdc09-186b-48a3-9340-219f1f8a47c2
📒 Files selected for processing (6)
.changeset/preserve-workspace-link-on-partial-update.mdpnpm/crates/package-manager/src/dependencies_graph_to_lockfile.rspnpm/crates/package-manager/src/dependencies_graph_to_lockfile/tests.rspnpm/crates/package-manager/src/install_with_fresh_lockfile.rspnpm11/installing/deps-installer/test/install/injectWorkspacePackagesPersistence.test.tspnpm11/installing/deps-resolver/src/index.ts
Confidence Score: 5/5Safe to merge. The guard is narrowly scoped (only fires when the fresh resolution is Both the TypeScript and Rust implementations are well-reasoned and internally consistent. The internal lockfile representation ( Files Needing Attention: No files require special attention. Reviews (10): Last reviewed commit: "chore: drop unrelated bytes downgrade fr..." | Re-trigger Greptile |
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
9dbb12d to
55a59f4
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
a258bf9 to
36927b5
Compare
|
Nice! |
A workspace dependency that deduped to `link:` on install could be rewritten to a peer-suffixed `file:` by a partial update (e.g. `pnpm update <other-pkg> --recursive`) that re-resolves it without going through dedupeInjectedDeps. When finalizing importer refs, keep the previous `link:` for a workspace dependency the run doesn't target (no spec change, not matched by `pnpm update <name>`). Follow-up to pnpm#12800 for the update path of pnpm#10433. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…lated dependency is updated Reproduces pnpm#10433's update path exactly as the CLI lowers it (installing/commands/src/recursive.ts): the importer whose manifest has the updated dependency gets `installSome` with the selector, every other importer gets `installSome` with no selectors and `update: true`. Without the fix the untouched injected workspace dep flips from link:../d to file:d(a@file:a)(b@file:b(a@file:a)([email protected])); with it, the entry stays link:../d while the targeted dependency still updates. Co-Authored-By: Claude Fable 5 <[email protected]>
…ecursive The guard applies to any install that re-resolves an untargeted workspace dependency, not only `pnpm update --recursive`; say so in the comments and the changeset. Co-Authored-By: Claude Fable 5 <[email protected]>
… as targeting A plain `pnpm install` marks every manifest dependency with `updateSpec: true` (deps-installer install/index.ts), so consulting it made the preserve-link: guard consider every workspace dependency "targeted" and never fire on the install path — precisely the catalog/root version-bump scenario from pnpm#10433. Real targeting is already captured by `isNew`, an actual specifier change (`prevSpecifier !== bareSpecifier`, which covers explicit `pnpm update <pkg>@<version>` selectors), and `updateMatching` (`pnpm update <name>`). Co-Authored-By: Claude Fable 5 <[email protected]>
…nstall Add a non-vacuous regression test for the plain `pnpm install` path of pnpm#10433: when a consumer change makes an ancestor-provided peer of an injected workspace dependency diverge, dedupeInjectedDeps correctly keeps the injected copy `file:`, but the untouched importer entry must be preserved as `link:` rather than rewritten to a peer-suffixed `file:`. This exercises the criterion that a plain install's blanket `updateSpec` must not count as targeting a dependency. Fails without the deps-resolver fix. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nstall Port the pnpm#10433 preserve-`link:` guard to the Rust (`pacquet-package-manager`) fresh-lockfile builder. When an install does not target a workspace dependency (a plain install / add, or an update whose scope doesn't name it, with no specifier change), keep its previous `link:` importer entry instead of rewriting it to a peer-suffixed `file:` that the divergent fresh resolution produced. `dedupe_injected_deps` runs earlier in the resolver and does not reach this importer-ref finalization path, mirroring the TS resolver bug. Threads the previous run's importer entries and the update reuse scope from `install_with_fresh_lockfile` into `build_importer`, and adds non-vacuous unit tests (preserve when untargeted; keep file: on a first install, when an update targets the dep, or when the specifier changed). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…nk: guard Codecov flagged two uncovered lines in the pnpm#10433 guard: the `UpdateReuseScope::None` (bare `update`) arm and the `name_ver` branch of `node_pkg_name`. Add a scope-wide-update test (file: stands) and an update-targets-a-named-node test (injected node carries a structured name_ver), bringing the guard's branches to full coverage. Co-Authored-By: Claude Opus 4.8 <[email protected]>
`cargo doc --document-private-items` with `-D warnings` rejects a public item that intra-doc-links to a private one (rustdoc::private_intra_doc_links). The `previous_importers` / `update_reuse_scope` field docs linked `[build_importer]` (private); demote those to plain code spans. Fixes the Rust CI / Doc job. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The fix also preserves link: on a plain install after a root/catalog change, not only on pnpm update <pkg>; widen the changeset accordingly. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-update parity gap Address review of the Rust port: - Add "pacquet": patch to the changeset — the lockfile-shape change lands in the Rust stack too, so the parity change carries the wrapper per CLAUDE.md. - Document, in build_importer, that the guard reads the global update scope (not the per-importer scope), so pnpm update <name> --recursive targeting of a workspace-link dep that also flips its peer context is not honored, and why threading the per-importer scope would reintroduce pnpm#10433. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address review of the Rust port. The guard read the workspace-wide update scope, so `pacquet update <name> --recursive` (a ByImporter policy whose global scope is All, with the named packages recorded per importer) did not target the named workspace-link dep — diverging from the TS side's per-importer `updateMatching`. Resolve each importer's effective scope the same way the resolver does (`update_reuse_scope_for`: global None applies to all, else per-importer entry, else global) and thread the per-importer scope map from install_with_fresh_lockfile into build_importer. This is safe (does not reintroduce pnpm#10433): a recursive update of <name> lowers non-target importers to the global All fallback (importers lacking the dep are skipped), never a side-effect DropAll, so untouched workspace edges are still preserved. Also, per review: - Strengthen the plain-install TS regression test to assert both foo versions resolved, proving the peer context genuinely diverged (guards against a vacuous pass). - Add Rust tests for the recursive per-importer target and the recursive pnpm#10433-protection case (updating another package preserves the link:). Co-Authored-By: Claude Opus 4.8 <[email protected]>
The Dylint custom lint rejects a bare `#NNN` (ambiguous). Qualify the pnpm#10433 reference in the recursive-guard test comment. Fixes the Rust CI / Dylint job. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The fresh-lockfile builder now rejects unkeyed dep paths, so the guard tests' bare file:packages/n fixture no longer parses. Reuse the existing make_file_node helper (the realistic n@file:packages/n shape) instead of a duplicate, and test node_pkg_name's name_ver arm directly: a node with name_ver set parses to a Regular version, so the end-to-end named-node scenario can no longer reach the guard — and never occurs for directory resolutions. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
66b50f7 to
504a968
Compare
PR Summary by QodoPreserve workspace link: refs during partial re-resolution (#10433)
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Unexplained bytes lock bump
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
@zkochan — thanks for carrying this the rest of the way; the reproduction-repo case is handled now. One ask before this auto-closes #10433: we've seen the same Written by an agent (Claude Code, claude-opus-4-8). |
Summary
Related to #10433. #12800 (already merged) fixed the first mechanism; this PR closes the remaining re-resolution paths, so the reported corruption no longer reproduces.
The issue is a workspace
link:that correctly deduped being spuriously rewritten to a peer-suffixedfile:. There were two such mechanisms: a same-version peer-suffix decoration thatdedupeInjectedDepsfailed to collapse (fixed in #12800), and re-resolution of an untargeted workspace dependency onpnpm update/plain install (fixed here). With both landed, the reporter's exact repro produces zero corruptions (validated end-to-end below).With
injectWorkspacePackages: true, a workspace dependency that correctly deduped tolink:on install can be spuriously rewritten to a peer-suffixedfile:when an unrelated dependency changes — e.g.pnpm update <pkg>(with or without--recursive), a version bump of a root/catalog dependency, or a plainpnpm installafter such a change. On a workspace whereconsumer→pkg-dresolved tolink:../pkg-d, running:flips it to
file:packages/pkg-d(@repro/pkg-a@…)(@repro/pkg-b@…([email protected]))— even thoughpkg-dand everything it depends on is untouched by the change. UndernodeLinker: hoistedthefile:entry copies a stale/unbuilt snapshot intonode_modulesinstead of symlinking the live workspace source, which surfaces as build/e2e failures.#12800 fixed the plain-install path where
dedupeInjectedDepscollapses a peer-suffix decoration back tolink:. The paths here re-resolve untouched injected workspace deps and either bypass that dedupe (the update-style runs) or land on a genuine peer-context divergence that dedupe correctly keeps asfile:— so the importer entry is re-derived asfile:even though the dependency wasn't touched.Reproduction (still reproduces on 11.13.0, which already contains #12800): https://github.com/omril1/pnpm-workspace-link-corruption-repro — the
winstonadd+update sequence above.Fix
When finalizing importer dependency refs in
resolveDependencies, preserve the previouslink:for a workspace dependency that this run does not target. A dependency is targeted when it is new, its specifier changed (prevSpecifier !== bareSpecifier), or it is matched byupdateMatching(pnpm update <name>). A workspace dependency resolved tolink:has no version to update, so a run that doesn't target it must not flip it tofile:; a dependency the run actually targets still resolves freely.updateSpecis deliberately not part of the targeting criterion: a plainpnpm installmarks every manifest dependency withupdateSpec: true(it means "re-check the spec", not "the user asked to change this"), so consulting it would treat every dependency as targeted and defeat the guard on the plain-install path. The guard is not specific to any one command — it applies to every mutation type that re-resolves importers (install,installSome,uninstallSome), covering the install, update, add, and remove entry points.Regression tests
injectWorkspacePackagesPersistence.test.tsgains two tests, both verified non-vacuous (they fail ongit checkout main -- installing/deps-resolver/src/index.tsand pass with the fix):pnpm update [email protected] --recursive(seeinstalling/commands/src/recursive.ts): the importer whose manifest haswinstongetsmutation: 'installSome'with the selector; every other importer getsinstallSomewith no selectors andupdate: true. Without the fix it fails withReceived: "file:d(a@file:a)(b@file:b(a@file:a)([email protected]))"; with it,consumer → dstayslink:../dandwinstonstill updates to3.19.0.dedupeInjectedDepsrightly keepsfile::qpeer-depends@pnpm.e2e/foo, provided by the root at100.0.0, so the injected copy ofnmatches and dedupes tolink:on install. Adding[email protected]to the consumer and running a plain install makes the injectedqdiverge (100.1.0) fromn's own context (100.0.0); the untouchedconsumer → nentry must staylink:. This is the case that exercises theupdateSpeccriterion above.Also validated end to end: built from this branch and run against the reproduction,
pkg-dstayslink:,winstonupdates, andpnpm install --frozen-lockfileaccepts the result unchanged. The existinginjectWorkspacePackagesPersistenceanddedupeInjectedDepssuites still pass.Rust (
pnpm/) portThe equivalent guard is ported to
pacquet-package-manager's fresh-lockfile builder (dependencies_graph_to_lockfile::build_importer): after computing an importer dependency's version cell, if it resolved tofile:, the previous lockfile recorded it aslink:, and the run doesn't target it, the priorlink:is restored. Targeting is derived from the importer's effective update scope together with a specifier change — the same criterion as the TS side. The effective scope mirrors the resolver'supdate_reuse_scope_for: a globalNone(bareupdate) applies to every importer, otherwise the per-importer scope wins with the global as fallback. This is what letspacquet update <name> --recursive(aByImporterpolicy: globalAll, named packages recorded per importer) target the named dependency in the importer that declares it while leaving untouched importers'link:entries intact. Both the previous importer entries and the per-importer update scopes are threaded frominstall_with_fresh_lockfileinto the builder. Adds unit tests for: preserve when untargeted; keepfile:on a first install, on a single-projectupdate <name>, on a scope-wide bareupdate, and on a specifier change; the recursive per-importer case (named dep flips tofile:); and the #10433 recursive-protection case (a recursive update of another package preservesn'slink:) — the last verified non-vacuous by neutering the per-importer resolution.Squash Commit Body
Checklist
pnpm/port.Written by an agent (Claude Code, claude-opus-4-8).
Summary by CodeRabbit
Bug Fixes
link:dependency entries during partial installs and unrelated dependency updates.file:entries.link:form during lockfile rebuilds when the dependency isn’t targeted, while still switching tofile:for truly targeted updates.Tests