Skip to content

Convert component resource to list<u8> - #17

Merged
scothis merged 4 commits into
componentized:mainfrom
scothis:resourceless
Sep 4, 2026
Merged

Convert component resource to list<u8>#17
scothis merged 4 commits into
componentized:mainfrom
scothis:resourceless

Conversation

@scothis

@scothis scothis commented Sep 1, 2026

Copy link
Copy Markdown
Member

Resources are not composable from unique sources within the same component. For example, component resources in the wac-loader could only be consumed as resources from the wac-loader. This makes it impossible to actually bootstrap and compose a component.

Switching to list<u8> avoids these issues.

@scothis
scothis requested a review from markfisher September 1, 2026 11:37
Resources are not composable from unique sources within the same
component. For example, component resources in the wac-loader could only
be consumed as resources from the wac-loader. This makes it impossible
to actually bootstrap and compose a component.

Switching to a record avoids these issues.

A significant downside to using a record is that the bytes for the
component must be initialized when the record is created. This makes
lazy loading components on demand impossible. Likewise, if we wanted to
change the list<u8> to stream<u8>, it could only be read once, and
inherently less useful.

Signed-off-by: Scott Andrews <scott@andrews.me>
wit map's are now part of the component model spec. Unfortunately, the
key cannot be a complex type like a record, or even a type alias for a
supported type. So we're denormalizing the id types from records to
strings. Each id take the form of `type:{value}` so that the keys in
each map are unique.

Signed-off-by: Scott Andrews <scott@andrews.me>
Loaders may extract and populate the wit, or leave it empty until a
consumer needs the wit content.

Signed-off-by: Scott Andrews <scott@andrews.me>
Move wit types back into the wit interface.

Signed-off-by: Scott Andrews <scott@andrews.me>
@scothis scothis changed the title Convert component resource to a record Convert component resource to list<u8> Sep 4, 2026

@markfisher markfisher left a comment

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.

A few questions, but the overall direction seems right.

let package = wit
.package(ExtractedWit::package_id(decoded.package()))
.expect("decoded package must exist");
async fn extract(component: Component) -> Result<Wit, Error> {

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.

This function actually returns WIT for any valid bytes, including a package that has 0..N worlds, right? Maybe the extract func should be explicitly more general than "component". It looks like the Wit type itself already is.

#[allow(async_fn_in_trait)]
fn into_wasm(&self) -> Vec<u8> {
self.wasm.clone()
Ok(wasm.collect().await)

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.

Now that this is effectively a single-line implementation, is having it in a component justifiable? Why wouldn't a consuming component just call collect() itself instead of call this component's function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yea, can clean that up when restructuring the loaders

Comment thread components/wit/worlds.wit

world wac-loader {
import componentized:component/types@0.0.0-0;
export componentized:component/types@0.0.0-0;

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.

The explicit types export shouldn't be necessary.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

it is because of the error

) -> Result<Component, Error> {
async fn plug(socket: Component, plugs: Vec<Component>) -> Result<Component, Error> {
let mut graph = CompositionGraph::new();

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.

Should this component also import a wasm-validator, or are the error messages from wac_graph just as useful?

@scothis scothis Sep 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm not sure if wac validates anything more that the interfaces being combined, plug even less so than graph. We can add explicit validation if it proves useful in the future.

@scothis
scothis merged commit 2e71193 into componentized:main Sep 4, 2026
3 checks passed
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.

2 participants