WebAssembly / WebAssembly/component-model
Loosing information and possible discrepancy in the WIT specs
Nobody has claimed this yet.
- Dominant language
- WebAssembly
- Stars
- 1.4k
- Forks
- 130
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 15
Description
I'm not sure if what I'm describing here is a problem with the specs, or a problem with the implementation(s) so please let me know if I should report it somewhere else.
Recently I've discovered that when we convert a WIT package into the component-model binary representation (or just use it to build a component), we loose the name of the root package and world it was created from. Implementations like wit-parser are reconstructing this by introducing a fake root component (called root:component, with a world called root, in that library). This means that converting WIT to binary and back does not give back the original package, and prevents uses where for example a registry or runner could identify a WASM binary by extracting the root package's name.
While I was trying to understand if this is by design, I found the following example in the WIT.md specs:
I don't think this (and the other examples around it) is true - with all the tooling I've tried (although probably all using the same implementation under the hood) what happens is that the top-level component will have an exported function directly, with only the function's name as it's name. The information about the world and package is not present in the resulting WASM at all:
(export (;22;) "example1" (func 21))
When exporting interfaces the exported interface's name contains the package name:
(export (;13;) "golem:it/api" (instance 12))
but still it is the package of the exported inteface and not the "root package" of the component. (Note that both exports are directly under the top level component.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with WIT.md and the examples describing the top-level component, then compare them with the shown component-model binary exports and wit-parser's root:component reconstruction. Determine whether the root package and world should be preserved or whether the specification examples need correction; done means an agreed specification or implementation direction that resolves the discrepancy.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100