feat(core,wkg): resolve multiple versions of the same package - #251
feat(core,wkg): resolve multiple versions of the same package#251Aditya1404Sal wants to merge 2 commits into
Conversation
|
Hi @Aditya1404Sal, thanks for the submission. |
76f0b66 to
70b0b27
Compare
Key dependencies by package plus version requirement rather than by package alone, so a wkg.toml can declare a separate override per version and a world naming two versions of the same package resolves both instead of dropping one
70b0b27 to
6e07006
Compare
Sorry for that, this PR description is indeed ai-assisted. I've rewritten it to my taste. |
@lukewagner apologies for pinging, just wanted to get your feedback and see if this is something we want to affirm for package distribution. |
|
Was chatting a bit with @mkatychev. I'm not sure this is desired behavior. First off, in your example, the major version is 0, so the bump from 0.2, to 0.3 should signify a breaking change. I think at the very least we'd probably want to not resolve multiple versions when the change is breaking. But even if not breaking, I think a wit/interface change is meant to be more intentional than just bumping a library. For example, the bump from wasi 0.2 to 0.3 completely changes dependence on wasi:io. All this said, I do believe that package versions are currently treated as a semver carat, so if a new non breaking version is published, you'll automatically get it, which doesn't feel so far off from the spirit of the PR. I am curious though if you've tried using a file path dependency. It seems like that could potentially meet your needs @Aditya1404Sal without the potential baggage of supporting resolution for multiple package versions. |
|
@macovedj, had some discussion with @salmans @vados-cosmonic about it and it feels like this is something we should allow this; more context here: https://github.com/bytecodealliance/meetings//blob/main/SIG-Packaging/2026/2026-08-19.md#multiple-versions-of-the-same-pacakge-as-dependencies-for-one-package |
| pub struct DependencyKey { | ||
| /// The package the dependency refers to. | ||
| pub package: PackageRef, | ||
| /// The version this dependency was requested at. | ||
| /// | ||
| /// `None` means "every version". This only happens for a bare override key (no `@version`), | ||
| /// which applies to every version the WIT names. | ||
| pub version: Option<VersionReq>, | ||
| } |
There was a problem hiding this comment.
Could we reuse the PackageSpec type instead of defining DependencyKey?
wasm-pkg-tools/crates/wasm-pkg-common/src/package.rs
Lines 83 to 86 in bc0ece4
Problem
According to the rules governing wit, there's nothing that actively restricts a scenario in which
a wit world can name more than one version of the same package, say for example when a world exports both
wasmcloud:messaging/handler@0.2.0and@0.3.0in the same component (from where I ran into this limitation wasmCloud/wasmCloud#5459)If there's justification needed as to why this is needed, off the top of my head -- it can help in safe migration
to a new interface rev without a breaking change
or in my use, so that a component can A/B test the new one for regressions
wit-bindgendoes support it by producing versioned bindings (I think that's what they're called)messaging0_2_0andmessaging0_3_0so I don't see why wkg can't have it in the override resolutionback to the problem :
Our
wash buildcommand that builds our components hasWkgFetcherwhich could not resolve the mixed deps and while running the fetch flow, one version was always dropped, and the fetch then failed and cleared the
deps/sub-dir.Change
The resolver is now keyed by
PackageSpec-- a package plus the version requirement it wasrequested under.
[overrides]keys accept an exact version suffix:existing behaviour
A bare key like below
will behave exactly as before.