Skip to content

clarify single-world requirement in extract_resolve_and_world_id#229

Open
ryan-surname-p wants to merge 3 commits into
bytecodealliance:mainfrom
ryan-surname-p:rnpridgeon-multi-world-wit
Open

clarify single-world requirement in extract_resolve_and_world_id#229
ryan-surname-p wants to merge 3 commits into
bytecodealliance:mainfrom
ryan-surname-p:rnpridgeon-multi-world-wit

Conversation

@ryan-surname-p

Copy link
Copy Markdown
Contributor

The original wording was factually inaccurate as wit_parser will not arbitrarily select a world from a wit package.

Furthermore semver checks are performed on a per component basis so the wit package being decoded must too define as a single world.

https://component-model.bytecodealliance.org/design/wit.html#worlds

a world describes the contract of a component. A world describes a set of imports and exports…

Comment on lines +215 to +216
/// component is defined by exactly one world. Therefore it is considered
/// an error if a `WitPackage` defines more than one world.

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.

Comment thread crates/wasm-pkg-client/src/decoded_component.rs Outdated
Co-authored-by: Mikhail Katychev <mkatych@gmail.com>
@hiSandog

Copy link
Copy Markdown

Would it be useful for the error text to distinguish a package with zero worlds from one with multiple worlds? Both violate the single-world requirement, but the likely corrective action differs: define a world versus select or split the intended component contract. Including the observed world count, and possibly names when there are only a few, could make this clarification more actionable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants