Repository navigation
fix(deps-resolver): dedupe injected deps despite unrelated peer-suffix mismatch - #12800
Conversation
|
💖 Thanks for opening this pull request! 💖 |
|
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:
📝 WalkthroughWalkthroughThis PR updates injected workspace dependency deduplication to accept compatible peer-suffixed variants with matching package identities. It centralizes compatibility helpers, adds regression tests for positive and negative cases, and records patch releases. ChangesDedupe compatibility fix
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Consumer
participant dedupeInjectedDeps
participant depGraph
participant depPathCompatibility
Consumer->>dedupeInjectedDeps: resolve injected workspace dependency
dedupeInjectedDeps->>depGraph: read target and injected depPaths
dedupeInjectedDeps->>depPathCompatibility: compare same-package dependency sets
depPathCompatibility-->>dedupeInjectedDeps: return compatibility result
dedupeInjectedDeps-->>Consumer: use link: or retain file:
Possibly related PRs
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 |
PR Summary by QodoFix injected-workspace dedupe when unrelated deps differ only by peer-suffix
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
Context used 1. Identity-blind compatibility dedupe
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm11/installing/deps-resolver/test/dedupeInjectedDeps.test.ts (1)
23-91: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winSolid regression test; consider adding a negative case.
The fixture accurately reproduces the reported bug and correctly asserts the OS-independent
link:outcome. Since the fix hinges onisCompatibleAndHasMoreDepsbeing a superset check (not just "differs"), a complementary case where the target is not compatible (e.g., missing a required child, or fewer deps) — asserting dedupe does not happen — would guard against a future regression that makes the check too permissive.🧪 Example negative-case sketch
test('injected dependency does not dedupe when the target is missing a required child', () => { // reuse the fixture above, but set: // dependenciesByProjectId['packages/pkg-c'].set('debug', '[email protected]' as DepPath) // where '[email protected]' has no children/resolvedPeerNames overlap with '[email protected]' // then assert resolvedDep.pkgId is unchanged (still file:...), not link:../pkg-c })🤖 Prompt for 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. In `@pnpm11/installing/deps-resolver/test/dedupeInjectedDeps.test.ts` around lines 23 - 91, The existing test in dedupeInjectedDeps.test.ts covers the positive link: case for deduping injected deps, but it should also protect the compatibility check used by isCompatibleAndHasMoreDeps. Add a negative test alongside the current dedupeInjectedDeps fixture where the target dependency is not a superset of the injected one (for example, a missing child or fewer deps for debug in the packages/pkg-c resolution), and assert that resolvedImporters['packages/consumer'].directDependencies[0].pkgId stays unchanged instead of becoming link:../pkg-c.
🤖 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.
Nitpick comments:
In `@pnpm11/installing/deps-resolver/test/dedupeInjectedDeps.test.ts`:
- Around line 23-91: The existing test in dedupeInjectedDeps.test.ts covers the
positive link: case for deduping injected deps, but it should also protect the
compatibility check used by isCompatibleAndHasMoreDeps. Add a negative test
alongside the current dedupeInjectedDeps fixture where the target dependency is
not a superset of the injected one (for example, a missing child or fewer deps
for debug in the packages/pkg-c resolution), and assert that
resolvedImporters['packages/consumer'].directDependencies[0].pkgId stays
unchanged instead of becoming link:../pkg-c.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6cf7b97d-a6fe-4c8c-ad99-12cda001b70f
📒 Files selected for processing (4)
.changeset/dedupe-injected-deps-unrelated-peer-suffix.mdpnpm11/installing/deps-resolver/src/dedupeInjectedDeps.tspnpm11/installing/deps-resolver/src/resolvePeers.tspnpm11/installing/deps-resolver/test/dedupeInjectedDeps.test.ts
|
Code review by qodo was updated up to the latest commit 3d50c9f |
|
Thanks for the automated review — addressed in dc4dc18: 🐞 Identity-blind compatibility dedupe (correctness) — Fixed. 🐞 New 🐞 Extra allocations in dedupe (performance) — Not changing. Written by an agent (Claude Code, claude-opus-4-8). |
Confidence Score: 5/5Safe to merge — the change is narrowly scoped to the isSubset check inside getDedupeMap, uses an already-proven compatibility predicate, and cannot widen the dedupe set beyond what deduplicateDepPaths already permits. The fix is a minimal, well-reasoned relaxation of a strict equality check: three defensive guards (null, graph membership, package identity) precede the compatibility call, making false-positive dedupes impossible. Both TypeScript and Rust implementations are symmetric. Regression tests directly exercise the confirmed failure shape. No files require special attention. Reviews (10): Last reviewed commit: "chore(changeset): add pacquet to the inj..." | Re-trigger Greptile |
74633fe to
cfed4a0
Compare
cfed4a0 to
bb50e42
Compare
Code Review by Qodo
Context used✅ Compliance rules (platform):
18 rules 1.
|
PR Code Suggestions ✨Warning
|
|||||||||
|
Code review by qodo was updated up to the latest commit 587d56f |
PR Code Suggestions ✨Warning
|
|||||||||
|
Thanks @qodo — addressed both new findings:
Written by an agent (Claude Code, claude-opus-4-8). |
|
Code review by qodo was updated up to the latest commit 193974d |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
Thanks for the update. The historical-comment change is reflected in commit |
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.9015159601400002,
"stddev": 0.13693646457142403,
"median": 3.84597484744,
"user": 3.62390786,
"system": 3.4925954399999997,
"min": 3.7980312509400003,
"max": 4.220589416939999,
"times": [
4.220589416939999,
3.82503718294,
3.81568239694,
3.87567228394,
3.80687354394,
3.8115270259400003,
3.7980312509400003,
4.0508795609399995,
3.94395442694,
3.8669125119400003
]
},
{
"command": "pacquet@main",
"mean": 3.86030371814,
"stddev": 0.14595067115712082,
"median": 3.8078377129400005,
"user": 3.7006603599999996,
"system": 3.48575914,
"min": 3.67994125394,
"max": 4.06819013294,
"times": [
3.7784182089400002,
3.74980354894,
4.057890608939999,
4.06819013294,
3.73444845894,
3.67994125394,
4.04986191194,
3.8260224219400003,
3.7896530039400003,
3.86880763094
]
},
{
"command": "pnpr@HEAD",
"mean": 2.09145049984,
"stddev": 0.07614778791265919,
"median": 2.06819477144,
"user": 2.70285936,
"system": 3.0934928399999997,
"min": 2.00498171094,
"max": 2.26360605694,
"times": [
2.26360605694,
2.09681663994,
2.03045832294,
2.15785561094,
2.0460771929400003,
2.05431639094,
2.00498171094,
2.13025373394,
2.0480661869400003,
2.08207315194
]
},
{
"command": "pnpr@main",
"mean": 2.18298698334,
"stddev": 0.1296172453778408,
"median": 2.1406679434400004,
"user": 2.72789146,
"system": 3.0852371400000007,
"min": 2.0498336739400003,
"max": 2.4313773749400003,
"times": [
2.1207885179400003,
2.36951101694,
2.0996948099400004,
2.21993642394,
2.22052356494,
2.4313773749400003,
2.0498336739400003,
2.16054736894,
2.1033731659400003,
2.05428391594
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.6816573761000001,
"stddev": 0.026548923804368175,
"median": 0.6724756561,
"user": 0.40868225999999996,
"system": 1.3539632399999997,
"min": 0.6579211811000001,
"max": 0.7472324561000001,
"times": [
0.6642647921,
0.6784035351000001,
0.6962859181000001,
0.6775672591,
0.6668407881,
0.6673840531,
0.7472324561000001,
0.6962985771000001,
0.6643752011,
0.6579211811000001
]
},
{
"command": "pacquet@main",
"mean": 0.6893613189000001,
"stddev": 0.03200098584915062,
"median": 0.6916436961000001,
"user": 0.40291516000000005,
"system": 1.3622421399999998,
"min": 0.6426264301000001,
"max": 0.7458873181000001,
"times": [
0.6984848191,
0.6725294951,
0.6892981391,
0.6426264301000001,
0.6939892531,
0.6696300791,
0.7458873181000001,
0.6956867721000001,
0.7314514801,
0.6540294031
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7336157314,
"stddev": 0.03694108110940039,
"median": 0.7331143726,
"user": 0.43216216,
"system": 1.37176294,
"min": 0.6959666421,
"max": 0.8223345541000001,
"times": [
0.6975943631,
0.7433558281,
0.7449940711,
0.7450434991,
0.6959666421,
0.7019754581000001,
0.7186641531000001,
0.7255091251000001,
0.7407196201,
0.8223345541000001
]
},
{
"command": "pnpr@main",
"mean": 0.7544281899,
"stddev": 0.05762960724288709,
"median": 0.7359084431,
"user": 0.42200935999999994,
"system": 1.3774664399999996,
"min": 0.7196825531000001,
"max": 0.9128205281,
"times": [
0.7532362561,
0.7418320491,
0.7336351221,
0.7210335201000001,
0.7289277441,
0.7265334881000001,
0.7381817641,
0.7196825531000001,
0.9128205281,
0.7683988741000001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.36051421724,
"stddev": 0.047522921281315314,
"median": 4.35307488284,
"user": 3.8362516999999996,
"system": 3.4837108199999998,
"min": 4.30172998134,
"max": 4.43007183234,
"times": [
4.35290606734,
4.43007183234,
4.31211624134,
4.35324369834,
4.38945457734,
4.31339141534,
4.410180656340001,
4.32724524434,
4.4148024583400005,
4.30172998134
]
},
{
"command": "pacquet@main",
"mean": 4.33892107644,
"stddev": 0.05731862851361171,
"median": 4.32234076934,
"user": 3.863405099999999,
"system": 3.4543311200000004,
"min": 4.26278168434,
"max": 4.41836359534,
"times": [
4.41418341534,
4.41836359534,
4.31991725534,
4.30745529934,
4.26857557134,
4.3857690083400005,
4.30461369334,
4.3827869583400005,
4.32476428334,
4.26278168434
]
},
{
"command": "pnpr@HEAD",
"mean": 2.1991402419400004,
"stddev": 0.07893280485371389,
"median": 2.1928398918400003,
"user": 2.5077916,
"system": 2.98203512,
"min": 2.08183867434,
"max": 2.29100613034,
"times": [
2.08183867434,
2.1519421643400003,
2.17134226134,
2.21433752234,
2.1126653123400003,
2.28582540734,
2.2842457183400002,
2.29100613034,
2.1342614713400003,
2.2639377573400004
]
},
{
"command": "pnpr@main",
"mean": 2.25496453414,
"stddev": 0.11233343434737682,
"median": 2.22622946234,
"user": 2.5606339,
"system": 3.0020055199999995,
"min": 2.14240561034,
"max": 2.42959862534,
"times": [
2.2190280333400003,
2.2334308913400003,
2.14569895134,
2.42684613234,
2.14240561034,
2.3644560413400004,
2.42959862534,
2.15710451634,
2.2508328303400003,
2.18024370934
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.45451974934,
"stddev": 0.016091366030999955,
"median": 1.45250456174,
"user": 1.44116046,
"system": 1.7702324000000005,
"min": 1.43148076874,
"max": 1.48262853974,
"times": [
1.45409641174,
1.44960339274,
1.45885219074,
1.44040881174,
1.47032603374,
1.43148076874,
1.43759993274,
1.45091271174,
1.46928869974,
1.48262853974
]
},
{
"command": "pacquet@main",
"mean": 1.4477350871400003,
"stddev": 0.043251009621229033,
"median": 1.43747758324,
"user": 1.39658666,
"system": 1.7656389000000001,
"min": 1.41354206174,
"max": 1.5665989667400002,
"times": [
1.5665989667400002,
1.42090360774,
1.44120955874,
1.45070960674,
1.43165534574,
1.44593259874,
1.41354206174,
1.44190910174,
1.43374560774,
1.4311444157400002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.7119819460400001,
"stddev": 0.036870311552646556,
"median": 0.69879992574,
"user": 0.37340806,
"system": 1.3250302,
"min": 0.69298685274,
"max": 0.81427021174,
"times": [
0.69571148674,
0.81427021174,
0.7215560177400001,
0.70245167874,
0.70487923474,
0.69589211474,
0.6992465857400001,
0.6944720117400001,
0.69835326574,
0.69298685274
]
},
{
"command": "pnpr@main",
"mean": 0.70552925454,
"stddev": 0.053156912701832766,
"median": 0.6946199267400001,
"user": 0.36882366,
"system": 1.3172555,
"min": 0.6685607357400001,
"max": 0.85284003474,
"times": [
0.6918807827400001,
0.68265224274,
0.6722030117400001,
0.6685607357400001,
0.6982424867400001,
0.7023649067400001,
0.6852536427400001,
0.69735907074,
0.85284003474,
0.7039356307400001
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.1600209163599997,
"stddev": 0.021396458455088044,
"median": 3.15743626066,
"user": 1.94860082,
"system": 2.0321578199999997,
"min": 3.13152232416,
"max": 3.19529773616,
"times": [
3.1744286021600003,
3.13513250316,
3.1553941401600003,
3.18153864916,
3.19529773616,
3.14506482716,
3.15947838116,
3.14496535016,
3.13152232416,
3.1773866501600003
]
},
{
"command": "pacquet@main",
"mean": 3.1701918353600003,
"stddev": 0.028657072543435268,
"median": 3.17665215116,
"user": 1.8644539199999994,
"system": 2.00898802,
"min": 3.11559721316,
"max": 3.2129158921600003,
"times": [
3.16003006616,
3.18349636616,
3.1580925731600002,
3.17966118316,
3.13599773016,
3.19039837416,
3.1736431191600003,
3.2129158921600003,
3.11559721316,
3.19208583616
]
},
{
"command": "pnpr@HEAD",
"mean": 0.6898079931600001,
"stddev": 0.01055904411326214,
"median": 0.69102402316,
"user": 0.36986172000000006,
"system": 1.3118337199999999,
"min": 0.66858297016,
"max": 0.70412996516,
"times": [
0.69066242416,
0.6893122461600001,
0.67635361616,
0.69401365216,
0.70412996516,
0.69230473116,
0.6897196721600001,
0.66858297016,
0.7016150321600001,
0.69138562216
]
},
{
"command": "pnpr@main",
"mean": 0.72587789256,
"stddev": 0.03622486614167061,
"median": 0.71569992216,
"user": 0.36356762,
"system": 1.3391374199999997,
"min": 0.69587952616,
"max": 0.81703912316,
"times": [
0.7201222851600001,
0.70228265416,
0.7028341031600001,
0.69587952616,
0.71127755916,
0.74976450916,
0.81703912316,
0.72413657616,
0.73444231916,
0.70100027016
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.66611194916,
"stddev": 0.015339936663455756,
"median": 0.66462637276,
"user": 0.6255671599999999,
"system": 0.16139434,
"min": 0.64078628926,
"max": 0.68474104526,
"times": [
0.67557860626,
0.68219154226,
0.65557524326,
0.67343940926,
0.65530020126,
0.64078628926,
0.65508844726,
0.68474104526,
0.65581333626,
0.68260537126
]
},
{
"command": "pacquet@main",
"mean": 0.6759720684599999,
"stddev": 0.012251938940567579,
"median": 0.67384863526,
"user": 0.64153616,
"system": 0.15554494000000002,
"min": 0.65211983426,
"max": 0.6929091202600001,
"times": [
0.6929091202600001,
0.68924086726,
0.68701465426,
0.67519635726,
0.67250091326,
0.66861962126,
0.66803518426,
0.67133222826,
0.68275190426,
0.65211983426
]
},
{
"command": "pnpr@HEAD",
"mean": 0.11024757082521738,
"stddev": 0.002772588732426575,
"median": 0.10978935626000001,
"user": 0.029000107826086953,
"system": 0.020401492173913044,
"min": 0.10622165826,
"max": 0.11569978226000001,
"times": [
0.11569978226000001,
0.10879987526000001,
0.11152273026000001,
0.10922005626,
0.10622165826,
0.10978935626000001,
0.11166260026000001,
0.10686676826000001,
0.10939669526000001,
0.11330731026000002,
0.11313294626,
0.11353242926000001,
0.11269450026000001,
0.11190622426,
0.10834158226000001,
0.10718040126000002,
0.10731446126000001,
0.10809267926,
0.10760126526000001,
0.10661175426000001,
0.11003837926000001,
0.11394759226000001,
0.11281308126
]
},
{
"command": "pnpr@main",
"mean": 0.11099933855166666,
"stddev": 0.002246695664936872,
"median": 0.11189459276000001,
"user": 0.029289259999999994,
"system": 0.02057842333333333,
"min": 0.10715800026000001,
"max": 0.11392807526000001,
"times": [
0.11333970126000001,
0.11161838826,
0.11070135226000001,
0.10956322826,
0.11261673626,
0.10715800026000001,
0.11015010726,
0.11179361526,
0.11199557026000001,
0.10732575226,
0.10895100626000001,
0.11231688026000002,
0.11392807526000001,
0.11218349926000001,
0.10729930026000001,
0.10749214126000001,
0.10923015526,
0.10857451826,
0.11269243626000001,
0.11296760626,
0.11243862426000001,
0.11271684226,
0.11360074626000001,
0.11332984226000001
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 6.746411383500001,
"stddev": 0.09126891922622116,
"median": 6.7150952827,
"user": 3.9192254400000004,
"system": 3.76942266,
"min": 6.652844182200001,
"max": 6.9252512652,
"times": [
6.685537920200001,
6.9252512652,
6.7148246682,
6.6950097342,
6.652844182200001,
6.7070983902000005,
6.715365897200001,
6.7493133342,
6.718812270200001,
6.9000561732
]
},
{
"command": "pacquet@main",
"mean": 6.678250071300001,
"stddev": 0.16117149649095505,
"median": 6.6241221467,
"user": 3.90152634,
"system": 3.74487036,
"min": 6.5293218282000005,
"max": 7.0337211452,
"times": [
6.859449507200001,
6.5677908702000005,
6.5293218282000005,
6.5910578292,
6.6571864642000005,
6.551644979200001,
6.576216892200001,
6.6636148272,
6.7524963702,
7.0337211452
]
},
{
"command": "pnpr@HEAD",
"mean": 5.010376951,
"stddev": 0.06915550022398136,
"median": 5.0251916477,
"user": 2.7965893399999997,
"system": 3.3530165600000004,
"min": 4.904893143200001,
"max": 5.089696890200001,
"times": [
4.904893143200001,
5.0468924432,
5.008999466200001,
5.0175419502,
4.9353910662,
5.0803703532,
5.0730880502,
5.0328413452000005,
4.914054802200001,
5.089696890200001
]
},
{
"command": "pnpr@main",
"mean": 5.013902862,
"stddev": 0.07002552117240265,
"median": 5.0064791157,
"user": 2.82069834,
"system": 3.30266066,
"min": 4.871748351200001,
"max": 5.099011664200001,
"times": [
5.0045279032000005,
4.983768861200001,
5.092465109200001,
5.0084303282,
5.0921760842,
5.031775249200001,
5.099011664200001,
4.871748351200001,
4.9916243252,
4.9635007442
]
}
]
} |
…r history Per review: the module comment should explain why the file exists (avoiding a runtime import cycle) rather than narrate that it was extracted from resolvePeers.ts, which belongs in git history. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…Deps fixtures main made hoistedPeerProviderNodeIds a required field on the resolvedImporters entry type; the hand-built test fixtures need it to type-check. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Mirror the TypeScript getDedupeMap fix in pacquet's build_dedupe_map so the two stacks stay behaviorally identical. An injected workspace dependency's child edge is now considered satisfied by the target project's own direct dep when the two depPaths are the same package identity (pkgIdWithPatchHash) and the target's copy isCompatibleAndHasMoreDeps than the injected occurrence needed, not only when the depPath strings are byte-identical. This lets an injected dep dedupe back to link: when an unrelated shared dependency (e.g. debug's optional supports-color peer) resolves peer-free on the injected side but peer-suffixed for the target project after reconciling against an existing lockfile. The pkgIdWithPatchHash guard keeps two genuinely different versions of a shared leaf dep -- whose empty dependency/peer sets would otherwise look compatible -- from being wrongly treated as interchangeable. Extract node_deps_count and is_compatible_and_has_more_deps from dedupe_peer_dependents into a shared dep_path_compatibility module so both dedupe passes use one implementation. Add a Rust regression test matching the TypeScript one (peer-suffix tolerated) alongside the existing version-mismatch test that now also guards the identity check. See pnpm#10433. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Per review, the header comment described the pre-fix strict string-equality
check as if it were still current ("today's ... check strands the entry").
Reword it as a counterfactual ("Without the compatibility tolerance ... a
strict string-equality check would strand ...") so the comment states current
behavior, and drop the "previously-locked" framing in favor of naming the
existing lockfile as the thing that pinned the peer.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The injected-dep dedupe fix re-derived the same peer-suffix rationale in five places (the getDedupeMap call site, both depPathCompatibility helpers, and the TS and Rust tests). Per the repo comment convention -- state a shared why once, in its natural home, and don't restate what the code says -- collapse them: - The peer-suffix scenario now lives in a short note at the getDedupeMap / build_dedupe_map call site (both stacks). - The "compares sets, not identity; callers must guard pkgIdWithPatchHash" precondition lives once on isCompatibleAndHasMoreDeps. - Test comments drop the paragraph-length preambles and fixture narration the test names and literals already convey. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Since pnpm#12949 unified the Rust release flow under changesets, a parity change that lands in both stacks names the Rust wrapper alongside the TypeScript packages. This fix ships in pacquet too, so add "pacquet": patch. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
28c8b23 to
e38bdcc
Compare
|
Code review by qodo was updated up to the latest commit e38bdcc |
PR Code Suggestions ✨Warning
No code suggestions found for the PR.
|
|
Congrats on merging your first pull request! 🎉🎉🎉 |
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
…10433) (#13112) A workspace dependency that deduped to `link:` on install could be rewritten to a peer-suffixed `file:` by any run that re-resolves it without deduping back to `link:` — e.g. `pnpm update <other-pkg>` (with or without --recursive), a root/catalog bump, or a plain install that hits a genuine peer-context divergence. When finalizing importer refs, keep the previous `link:` for a workspace dependency the run doesn't target: not new, specifier unchanged, and not matched by `pnpm update <name>`. `updateSpec` is intentionally excluded from the criterion because a plain install marks every manifest dependency with it. A workspace `link:` dependency has no version to update, so a run that doesn't target it must not flip it to `file:`; targeted dependencies still resolve freely. Adds regression tests for the update-recursive and plain-install paths (both fail without the fix) and ports the guard to the Rust package-manager crate. Completes the fix for #10433 — the first mechanism was fixed in #12800. --------- Co-authored-by: Zoltan Kochan <[email protected]>
…olves A plain install kept a workspace dependency's previously recorded `link:` whenever the run did not target it, even when the injected copy now binds a peer the linked project does not provide. The guard was added for #10433, whose flips came from two spurious mismatches: a same-version peer-suffix decoration, which the dedupe pass now absorbs (#12800), and re-resolution paths the dedupe pass did not reach. With the guard off, the update scenario from #10433 keeps its `link:` in both stacks, so dedupe alone now covers it. The guard's only remaining effect was that an incremental install recorded a stale `link:` that a fresh install does not, which left the injected package unable to find the peer its consumer provides. The guard and the inputs only it consumed are removed in both stacks: v12's `preserved_link_version`, `LockfileImporterReuse` and the install path's `guard_*` fields, and v11's preserve-prior-link branch with its previous-ref and targeted-alias bookkeeping. The importer entry now follows the dedupe pass, which the workspaces docs already describe. The v11 ancestor-divergence test now expects the injected copy, a new v12 CLI test checks that an incremental install records the copy a fresh one does, and the peer convergence harness drops this divergence. The two rows still differing there come from #17058's moved auto-installed peer, whose divergence now owns the injected entries that follow from it. Closes #17057 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…olves (#17075) A plain install kept a workspace dependency's previously recorded `link:` whenever the run did not target it, even when the injected copy now binds a peer the linked project does not provide. The guard was added for #10433, whose flips came from two spurious mismatches: a same-version peer-suffix decoration, which the dedupe pass now absorbs (#12800), and re-resolution paths the dedupe pass did not reach. With the guard off, the update scenario from #10433 keeps its `link:` in both stacks, so dedupe alone now covers it. The guard's only remaining effect was that an incremental install recorded a stale `link:` that a fresh install does not, which left the injected package unable to find the peer its consumer provides. The guard and the inputs only it consumed are removed in both stacks: v12's `preserved_link_version`, `LockfileImporterReuse` and the install path's `guard_*` fields, and v11's preserve-prior-link branch with its previous-ref and targeted-alias bookkeeping. The importer entry now follows the dedupe pass, which the workspaces docs already describe. The v11 ancestor-divergence test now expects the injected copy, a new v12 CLI test checks that an incremental install records the copy a fresh one does, and the peer convergence harness drops this divergence. The two rows still differing there come from #17058's moved auto-installed peer, whose divergence now owns the injected entries that follow from it. Closes #17057 Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
The problem
With
injectWorkspacePackages: true, a workspace package injected into a consumer sometimes fails to dedupe back tolink:even when it safely could, staying as a peer-suffixedfile:packages/pkg-c(...)entry instead. This shows up aspnpm-lock.yamlchurn after an unrelatedpnpm install/pnpm updateagainst an existing lockfile — the affected package itself, and everything it depends on, is untouched by the triggering change. WithnodeLinker: hoisted, thefile:entry makes pnpm copy a stale/unbuilt snapshot intonode_modulesinstead of linking to the live workspace source.Standalone minimal reproduction: https://github.com/omril1/pnpm-workspace-link-corruption-repro
Root cause
getDedupeMapdecides whether an injected occurrence's resolved children match the target project's own resolved dependencies via strict depPath string equality:This can fail even when the injected package itself resolves identically on both sides, because a completely unrelated, ordinary (non-workspace) shared dependency can legitimately resolve to two different-but-compatible depPaths:
resolveDependencies/resolvePeersruns twice per install — a first pass with no lockfile influence, then a second pass seeded withresolvedPeerProviderPathsfrom the first, which only runs when the tree has anylockedPeerContext(i.e. only when reconciling against an existing lockfile with a peer-resolved package somewhere).debug'ssupports-coloris a concrete, public instance) can get pinned to its previously-locked peer-suffixed depPath for the target project's own resolution, while the injected occurrence of the workspace package resolves that same shared dependency fresh, without the suffix.[email protected]and[email protected]([email protected])are valid resolutions of the same package.dedupePeerDependents'sdeduplicateDepPathsalready has a notion of this ("compatible and has more deps" —isCompatibleAndHasMoreDeps), butdedupeInjectedDepsruns before that pass and has no way to see it.The fix
isSubsetnow also accepts a target depPath thatisCompatibleAndHasMoreDepsthan the injected occurrence's depPath, instead of requiring the two strings to be byte-identical — reusing the exact compatibility notion the codebase already applies to this class of problem elsewhere, rather than introducing a new one.How to verify the analysis
dedupeInjectedDepswith a hand-builtdepGraph/dependenciesByProjectIdreproducing the exact confirmed shape (injected occurrence:[email protected]; target project:[email protected]([email protected])). It fails onmainand passes with this change.pkg-c/pkg-dentries correctly staylink:.injectWorkspacePackagesPersistence.test.ts(the fix: dedupe workspace deps with children in single-project mode #11448 regression suite) and the fulldeps-resolvertest suite (125 tests) still pass unmodified.Note on scope
The issue as filed (#10433) is broader than this specific mechanism — it doesn't mention peer dependencies and was reported against plain
pnpm update. This PR fixes a confirmed, reproducible cause within the samelink:→file:symptom family; it may not be the only one, so I'm not claiming to fully close it.Squash Commit Body
Checklist
pacquet/port, or the description notes what still needs porting. — Now implemented in both. The pacquet port mirrors the fix inpnpm/crates/resolving-deps-resolver/src/dedupe_injected_deps.rs(build_dedupe_mapnow tolerates a same-identity,isCompatibleAndHasMoreDepspeer-suffix mismatch), extractsnode_deps_count/is_compatible_and_has_more_depsinto a shareddep_path_compatibilitymodule, and adds a matching Rust regression test.Written by an agent (Claude Code, claude-sonnet-5).
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
file:instead of switching tolink:when dependency compatibility differs.Tests