Repository navigation
test(cargo): compare pnpm's Cargo resolution against cargo's own - #14979
Conversation
pnpm v12 resolves Cargo dependencies itself rather than shelling out to cargo, so it is a second implementation of cargo's resolver, and being a drop-in replacement means producing the versions cargo produces rather than merely producing a lockfile. Unit tests pin that against synthetic indexes, which is where the rules are easiest to state and easiest to get subtly wrong: the resolver fixes in #14952, #14960, #14961 and #14962 were each confirmed by hand-checking a real workspace against cargo after the unit tests were already green. This is that hand-check, written down. For each workspace in the corpus it resolves twice, compares the locked crates, and asks cargo whether it accepts pnpm's lockfile with `--locked` in a copy pnpm never touched, so the lockfile is measured apart from the source replacement written beside it. Requirements are open rather than pinned: both resolvers read the same index on the same day, so an upstream release changes what they agree on, not whether they agree. A workspace declares whether the two are expected to agree yet. A known gap reports as such and does not fail the run, but does fail if the two start agreeing, so a fixed issue cannot leave a stale expectation behind. `feature-activated-deps` is the one gap today, tracking #14978. It runs on a daily cron rather than per-PR because it reads the live index, where a yank or a release can change a result with nothing in this repo changing. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (9)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughAdds a Cargo equivalence harness with workspace fixtures, resolver comparison, expectation-based verdicts, CLI execution, documentation, a local command, and scheduled GitHub Actions validation. ChangesCargo equivalence validation
Priority: ⬇️ Low Estimated code review effort: 4 (Complex) | ~45 minutes Change: Other Sequence Diagram(s)sequenceDiagram
participant cargo_equivalence
participant Cargo
participant pnpm
cargo_equivalence->>Cargo: Resolve workspace and write Cargo.lock
cargo_equivalence->>pnpm: Resolve workspace and write pnpm lockfile
cargo_equivalence->>cargo_equivalence: Compare crate names and versions
cargo_equivalence->>Cargo: Check pnpm lockfile with --locked
cargo_equivalence-->>cargo_equivalence: Produce verdict and report
Merge Risk: ⚪ Minimal · up to This change only adds an internal test harness, its documentation, and a daily scheduled check that compares dependency resolution results. Published packages and user-facing behavior are unchanged, so there is no identified merge-readiness risk. ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 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 QodoAdd Cargo resolver equivalence harness and scheduled validation
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Code Review by Qodo
1. New resolver regressions pass as known
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Micro-Benchmark ResultsLinux |
…hing else A workspace expected to differ accepted every error its comparison stages produced, so a lockfile that would not parse, or a cargo that would not start, was waved through as the tracked difference and the run stayed green. A tracked gap would have been a blind spot: any regression reaching the same stage would have been read as the thing already known about. A stage now reports what it concluded rather than a bare message. Agreeing and disagreeing are conclusions about what the two resolvers produced; a stage that could not reach one is broken, and broken is never a known gap whatever the workspace expects. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 2e3b46a |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…ption Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 5121b4f |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #14979 +/- ##
==========================================
- Coverage 91.02% 91.02% -0.01%
==========================================
Files 1281 1281
Lines 171835 171835
==========================================
- Hits 156416 156414 -2
- Misses 15419 15421 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm; the linked-workspace scenario compares current Rust against main Rust. 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.5177398965,
"stddev": 0.17587775853386944,
"median": 2.4804688952,
"user": 1.56254122,
"system": 1.67439516,
"min": 2.3108977257,
"max": 2.8637027127
},
{
"command": "pacquet@main",
"mean": 2.3991121983,
"stddev": 0.08810144388119978,
"median": 2.4120046572,
"user": 1.54791282,
"system": 1.7153755599999996,
"min": 2.2797778297,
"max": 2.5394118677
},
{
"command": "pnpr@HEAD",
"mean": 1.5263380627,
"stddev": 0.13217564076880436,
"median": 1.5317065187,
"user": 1.5066436199999997,
"system": 1.5848400599999999,
"min": 1.3390908087,
"max": 1.6912983957
},
{
"command": "pnpr@main",
"mean": 1.5654011530999998,
"stddev": 0.1026055571114326,
"median": 1.5933773612,
"user": 1.63654802,
"system": 1.67887826,
"min": 1.3812603757000002,
"max": 1.7054737767
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.30863535082000004,
"stddev": 0.03757863544816592,
"median": 0.30137889772000004,
"user": 0.34089152000000006,
"system": 0.65731854,
"min": 0.25574716922,
"max": 0.38631977522000005
},
{
"command": "pacquet@main",
"mean": 0.27539211052000007,
"stddev": 0.034146173981602926,
"median": 0.27298232772000003,
"user": 0.29562332,
"system": 0.6233399399999999,
"min": 0.23520283922000002,
"max": 0.34530776422000004
},
{
"command": "pnpr@HEAD",
"mean": 0.27155786642,
"stddev": 0.033596430530041084,
"median": 0.25601358472,
"user": 0.27543032,
"system": 0.6065592399999999,
"min": 0.23778183322000002,
"max": 0.33753861622000003
},
{
"command": "pnpr@main",
"mean": 0.27471110262000004,
"stddev": 0.020018124630183425,
"median": 0.27146552822000003,
"user": 0.29643682,
"system": 0.59452014,
"min": 0.24801389822,
"max": 0.30313796122000003
}
]
}Scenario: Isolated linker: repeat install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.01078971733509433,
"stddev": 0.0012947543238502094,
"median": 0.01050461992,
"user": 0.005826245471698109,
"system": 0.005809348396226417,
"min": 0.00797200492,
"max": 0.01446195492
},
{
"command": "pacquet@main",
"mean": 0.011160395819999998,
"stddev": 0.0016385086004226928,
"median": 0.010936432920000001,
"user": 0.0061981679999999996,
"system": 0.0058117357600000015,
"min": 0.00810875592,
"max": 0.016390955920000002
},
{
"command": "pnpr@HEAD",
"mean": 0.01167403201311742,
"stddev": 0.0013909220618939684,
"median": 0.011507795920000001,
"user": 0.006294730040485828,
"system": 0.0062942373279352235,
"min": 0.00889786992,
"max": 0.01589858292
},
{
"command": "pnpr@main",
"mean": 0.011504283942522524,
"stddev": 0.0014017651794478645,
"median": 0.011395385420000001,
"user": 0.006484208288288285,
"system": 0.0059113928828828845,
"min": 0.00827831592,
"max": 0.01497718692
}
]
}Scenario: Isolated linker: repeat install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.012037975718235285,
"stddev": 0.0015200036439985583,
"median": 0.011994735880000001,
"user": 0.006952810392156863,
"system": 0.0058420735294117685,
"min": 0.008644524380000001,
"max": 0.01652343538
},
{
"command": "pacquet@main",
"mean": 0.013367112779999999,
"stddev": 0.0027191929677020644,
"median": 0.01301802238,
"user": 0.00759118212765957,
"system": 0.006588425531914895,
"min": 0.00940026038,
"max": 0.02332927538
},
{
"command": "pnpr@HEAD",
"mean": 0.01362865480384106,
"stddev": 0.002791568634203023,
"median": 0.012831282380000001,
"user": 0.0084116098013245,
"system": 0.006027768211920528,
"min": 0.009781350380000001,
"max": 0.02483581738
},
{
"command": "pnpr@main",
"mean": 0.011633473140368665,
"stddev": 0.001742267167867651,
"median": 0.011466352380000001,
"user": 0.006486711336405526,
"system": 0.005869239631336403,
"min": 0.00815759438,
"max": 0.024825238380000003
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.8821383584799998,
"stddev": 0.08259687112988708,
"median": 2.8677832906800003,
"user": 2.8871904999999995,
"system": 2.42834034,
"min": 2.75009653718,
"max": 3.03945609818
},
{
"command": "pacquet@main",
"mean": 2.79011778128,
"stddev": 0.14170108834937933,
"median": 2.7450296826800002,
"user": 2.6942600999999997,
"system": 2.27142344,
"min": 2.56753804518,
"max": 3.01170986218
},
{
"command": "pnpr@HEAD",
"mean": 1.6432602513799999,
"stddev": 0.10001449846547912,
"median": 1.6650489311799999,
"user": 1.6455935,
"system": 1.83750084,
"min": 1.45542547718,
"max": 1.75029619318
},
{
"command": "pnpr@main",
"mean": 1.5207884158799998,
"stddev": 0.09397397155937451,
"median": 1.49867927768,
"user": 1.2550767,
"system": 1.4900696399999998,
"min": 1.39596101218,
"max": 1.66813182118
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.3767989595,
"stddev": 0.022030618434390217,
"median": 0.3736716644,
"user": 0.60016246,
"system": 0.87063424,
"min": 0.3555344294,
"max": 0.43055238040000005
},
{
"command": "pacquet@main",
"mean": 0.40196636380000006,
"stddev": 0.019212127310414173,
"median": 0.3961594799,
"user": 0.66402186,
"system": 0.9036413400000001,
"min": 0.3846888704,
"max": 0.4476874384
},
{
"command": "pnpr@HEAD",
"mean": 0.2948642333,
"stddev": 0.009222494884107023,
"median": 0.29327381490000004,
"user": 0.25294556,
"system": 0.53569574,
"min": 0.28613601040000003,
"max": 0.31541646840000004
},
{
"command": "pnpr@main",
"mean": 0.34844767600000004,
"stddev": 0.027591486742017734,
"median": 0.3476867294,
"user": 0.3048338599999999,
"system": 0.65209474,
"min": 0.3116095884,
"max": 0.4126193804
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.94022428812,
"stddev": 0.24889334877373528,
"median": 1.85111633692,
"user": 1.5376663199999998,
"system": 1.43518332,
"min": 1.7316483159199998,
"max": 2.51159741692
},
{
"command": "pacquet@main",
"mean": 1.7829881692199998,
"stddev": 0.07130462968501924,
"median": 1.7887683989199998,
"user": 1.2694225199999998,
"system": 1.2665835200000002,
"min": 1.6802025459199998,
"max": 1.87199190992
},
{
"command": "pnpr@HEAD",
"mean": 0.33710360572000003,
"stddev": 0.02810330054127554,
"median": 0.33622094742,
"user": 0.28905662000000004,
"system": 0.59789552,
"min": 0.30540389392000006,
"max": 0.39580230992000004
},
{
"command": "pnpr@main",
"mean": 0.3766864847200001,
"stddev": 0.03008316315660067,
"median": 0.37235703292000005,
"user": 0.34579202,
"system": 0.6481440199999999,
"min": 0.34171320992000004,
"max": 0.4261124089200001
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.22865792598909093,
"stddev": 0.017305781365018664,
"median": 0.22560418908,
"user": 0.2289804690909091,
"system": 0.07697871636363635,
"min": 0.20003225208,
"max": 0.25775790108
},
{
"command": "pacquet@main",
"mean": 0.23404649462545457,
"stddev": 0.01591329000437152,
"median": 0.23067750508,
"user": 0.23179410545454546,
"system": 0.08532644363636364,
"min": 0.20873003908,
"max": 0.25845496908000004
},
{
"command": "pnpr@HEAD",
"mean": 0.0946739717466667,
"stddev": 0.005329623255793612,
"median": 0.09472678058,
"user": 0.032677726666666664,
"system": 0.018446913333333332,
"min": 0.08646783008,
"max": 0.10975668108
},
{
"command": "pnpr@main",
"mean": 0.0975304976283871,
"stddev": 0.00426955972147132,
"median": 0.09660767108000001,
"user": 0.038390818064516115,
"system": 0.01739982193548387,
"min": 0.08916834908,
"max": 0.10487792508
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.8798863687266666,
"stddev": 0.16761525905362518,
"median": 0.8403685360600001,
"user": 0.9310186844444444,
"system": 0.18250362888888888,
"min": 0.63938476606,
"max": 1.11858555006
},
{
"command": "pacquet@main",
"mean": 0.9404876208377778,
"stddev": 0.17770418935868323,
"median": 0.9210610440600001,
"user": 0.9756785733333333,
"system": 0.20003118444444445,
"min": 0.72618390006,
"max": 1.2175396190599999
},
{
"command": "pnpm@HEAD",
"mean": 5.512834148615556,
"stddev": 1.1112089891423027,
"median": 4.78008103906,
"user": 8.54011824,
"system": 0.3944281844444444,
"min": 4.59234619106,
"max": 7.76677923206
}
]
}Scenario: Isolated linker: linked-workspace resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.19165127770000004,
"stddev": 0.007706114278596495,
"median": 0.1904750419,
"user": 0.13990598666666665,
"system": 0.09528985333333334,
"min": 0.1734078189,
"max": 0.2031939329
},
{
"command": "pacquet@main",
"mean": 0.19196379943333333,
"stddev": 0.011186481600383135,
"median": 0.18746224690000002,
"user": 0.15001292,
"system": 0.08787465333333332,
"min": 0.1781518969,
"max": 0.2151959179
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.55712292236,
"stddev": 0.12087686734981629,
"median": 4.552839046759999,
"user": 2.08446918,
"system": 2.06395604,
"min": 4.4027626157599995,
"max": 4.73898065876
},
{
"command": "pacquet@main",
"mean": 4.60177980176,
"stddev": 0.15941340088887693,
"median": 4.552278039759999,
"user": 1.9105057799999998,
"system": 1.8814795400000002,
"min": 4.42878430776,
"max": 4.91848782976
},
{
"command": "pnpr@HEAD",
"mean": 3.64211279186,
"stddev": 0.11535836364509924,
"median": 3.66530021576,
"user": 1.96180648,
"system": 2.0019419399999996,
"min": 3.4666999927599997,
"max": 3.85963276576
},
{
"command": "pnpr@main",
"mean": 3.7476375024600004,
"stddev": 0.16247152700752832,
"median": 3.79089934376,
"user": 2.15775988,
"system": 2.2508158400000005,
"min": 3.50027379376,
"max": 3.95243134676
}
]
}Scenario: GVS linker: fresh restore, hot cache + hot storeSame install as the isolated fresh-restore hot/hot scenario, into the shared virtual store, the layout pnpm 12 installs into by default. Scenarios run on separate machines, so compare main and branch within each table.
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.1778706139457143,
"stddev": 0.014318440960359832,
"median": 0.18015714366000002,
"user": 0.20249645142857145,
"system": 0.20730358571428573,
"min": 0.14752915016,
"max": 0.19452853216000002
},
{
"command": "pacquet@main",
"mean": 0.16927011476000003,
"stddev": 0.015903449602426744,
"median": 0.16835368616000002,
"user": 0.21494684666666666,
"system": 0.17681073333333333,
"min": 0.14341707316,
"max": 0.19766661716
},
{
"command": "pnpr@HEAD",
"mean": 0.18961535669846155,
"stddev": 0.019339808848283246,
"median": 0.18311491016,
"user": 0.21719922615384613,
"system": 0.1863954153846154,
"min": 0.16857397516,
"max": 0.24376686916
},
{
"command": "pnpr@main",
"mean": 0.20475665582666666,
"stddev": 0.01721692822830728,
"median": 0.20153031816,
"user": 0.2355454633333333,
"system": 0.20263079999999997,
"min": 0.18201191316,
"max": 0.23745901716
}
]
} |
|
CI notes, since this PR went red twice for reasons that were not the change. Resolved: Remaining: Written by an agent (Claude Code, claude-opus-5). |
…m#14979) pnpm v12 resolves Cargo dependencies itself rather than shelling out to cargo, so it is a second implementation of cargo's resolver, and being a drop-in replacement means producing the versions cargo produces rather than merely producing a lockfile. Unit tests pin that against synthetic indexes, which is where the rules are easiest to state and easiest to get subtly wrong: the resolver fixes in pnpm#14952, pnpm#14960, pnpm#14961 and pnpm#14962 were each confirmed by hand-checking a real workspace against cargo after the unit tests were already green. This is that hand-check, written down. For each workspace in the corpus it resolves twice, compares the locked crates, and asks cargo whether it accepts pnpm's lockfile with `--locked` in a copy pnpm never touched, so the lockfile is measured apart from the source replacement written beside it. Requirements are open rather than pinned: both resolvers read the same index on the same day, so an upstream release changes what they agree on, not whether they agree. A workspace declares whether the two are expected to agree yet. A known gap reports as such and does not fail the run, but does fail if the two start agreeing, so a fixed issue cannot leave a stale expectation behind. `feature-activated-deps` is the one gap today, tracking pnpm#14978. It runs on a daily cron rather than per-PR because it reads the live index, where a yank or a release can change a result with nothing in this repo changing.
Summary
pnpm v12 resolves Cargo dependencies itself rather than shelling out to
cargo, so it is a second implementation ofcargo's resolver. Being a drop-in replacement means producing the versionscargoproduces, not merely producing a lockfile.The unit tests pin that against synthetic indexes, which is where the rules are easiest to state and easiest to get subtly wrong. Each of #14952, #14960, #14961 and #14962 was confirmed by hand-checking a real workspace against
cargoafter the unit tests were already green. This PR writes that hand-check down so it runs by itself.For each workspace in the corpus:
cargo generate-lockfile;pnpm install --lockfile-only --no-frozen-lockfile;cargo metadata --locked, so the lockfile is measured apart from the source replacement pnpm writes beside it.Requirements in the corpus are open rather than pinned. Both resolvers read the same index on the same day, so an upstream release changes what they agree on, not whether they agree.
It found a bug on its first run
feature-activated-depsdoes not agree, and the reason is not in the corpus's exotic shapes but inuuid = "1":cargoresolves its lockfile with every feature enabled and only applies the selected features when it builds. pnpm resolves once, with the selected features, so its lockfile is a subset andcargo --lockedrejects it. A workspace whose only dependency isuuid = "1", requesting no features at all, is enough to hit it. Filed as #14978, and left in the corpus as a tracked gap rather than fixed here, since it is a change to what resolution locks rather than to how it chooses versions.Expectations
A workspace declares whether the two are expected to agree yet:
Expectation::Agree— they must produce the same crates.Expectation::Differ { issue }— a known gap. It reportsKNOWNand does not fail the run, but does fail if the two start agreeing, which is the signal that the issue is fixed and the expectation is stale.That keeps one tracked gap from turning the whole run red, and stops the gap from being quietly forgotten once it closes. I verified both directions: flipping a passing workspace to
Differmakes the run fail with "agrees with cargo, so … looks fixed".Current run:
Why cron rather than per-PR
It reads the live index, so a yank or a release can change a result with nothing in this repo changing. Same reasoning as
ecosystem-e2e, and the workflow follows its shape.Squash Commit Body
Checklist
already linked to it solves it.
are implemented in every affected version. (Test tooling for pnpm v12.)
pnpm changeset) if this PR changes any publishedpackage. (Nothing published changes: a task crate, a workflow and a recipe.)
pnpm/tasks/cargo-equivalence/README.md)Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
New Features
Documentation