Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions crates/wasm-pkg-client/src/decoded_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,12 @@ fn extract_package_version(decoded: &DecodedWasm) -> Result<(PackageRef, Version
Ok((package, version))
}

/// Borrow the inner `wit_parser::Resolve` and resolve a concrete `WorldId`.
/// For a decoded component the world is fixed; for a WIT package we ask
/// `Resolve::select_world` to pick one — deferred until needed so a
/// multi-world WIT package can publish its first version unambiguously.
/// Borrow the inner `wit_parser::Resolve` and resolve a concrete `WorldId`
/// for semver checking.
///
/// Semver checks compare two versions of the same component, and a
/// component is defined by exactly one world. Therefore it is considered
/// an error if a `WitPackage` defines more than one world.
Comment on lines +215 to +216

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying that a multi world package is unsupported or unexpected/undesired?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's more of a limitation of the current implementation because I was working under the incorrect assumption that a published artifact would map 1:1 to a component.

This is likely to be the common case but it's not strictly true and it will require some additional handling on the client to fix this.

Namely that we need to decode the WitPackage and extract all the components defined within.

While I'm quite certain there is a 1:1 mapping of Component to world I'm not sure if there is a 1:1 mapping of world to component.

Do you happen to know?

Given that you are preparing a release it seemed prudent not to try expand this functionality today but to instead document the existing behavior.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably getting a bit too hung up on the wording here but "can be thought of" causes some doubt.

https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md?plain=1#L159C42-L160C57

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkatychev mkatychev Jul 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I'm quite certain there is a 1:1 mapping of Component to world I'm not sure if there is a 1:1 mapping of world to component.

You're usually able to map a component to a known world or one that a component creates, you can see this by calling --importize in wasm-tools:

$ wasm-tools component wit my_component_0.1.0.wasm --importize
package root:component;

world root-importized {
  ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for now it's safe to go with the assumption that a component will map to a well-known world or a root:component it creates for itself.
pinged @salmans to config.

fn extract_resolve_and_world_id(
decoded: &DecodedWasm,
) -> Result<(&wit_parser::Resolve, wit_parser::WorldId), Error> {
Expand All @@ -220,7 +222,7 @@ fn extract_resolve_and_world_id(
DecodedWasm::WitPackage(resolve, pkg) => {
let world_id = resolve
.select_world(&[*pkg], None)
.map_err(Error::InvalidPackage)?;
.map_err(|e| Error::InvalidPackage(e.context("we currently do not support multiple wolds, etc...")))?;
Ok((resolve, world_id))
}
}
Expand Down