Implement canonical interface names in wit-component - #2602
Conversation
|
Thanks for the PR! Before diving too deep into review though I want to clarify a few things first. Primarily I don't think this'll work if it's a crate or a runtime flag feature unfortunately. We need a way to roll this out gradually which means that the previous implementation has to live side-by-side with the new implementation, and then eventually we can slowly transition everything over. Could you dig in a bit more to see if this is possible? If it's not possible that'd be somewhat surprising to me, so could you explain a bit more? Second is that I'm a bit confused by the breaking change you mentioned here -- I would expect being able to import 0.0.1 and 0.0.2 at the same time to work out. This is similar to importing both WASIp2 and WASIp3 APIs which is intended to work. |
You mean we need a runtime/CLI flag, instead of a feature flag? That's possible, but less cleaner. Primarily, we would like to define a custom If we opt to a runtime flag, like
My bad. It should be |
|
I think the question comes down to this: after we fully switch over, what's the expected behavior of During the transition period, we can probably wrap the Update: this new function is actually better. It decides the behavior at construction time and we can rely on the regular |
|
Personally what I'd expect is a configuration option on Internally though I don't think that updating What I would roughly envision for this is that |
|
I add a new CLI flag I defined a new wrapper type PackageKey, so that we can control whether to use the canonical version or not during construction time.
In this case, |
canon-names feature|
Reading over this, how come there needs to be a flag in |
|
Perhaps it's easier to understand from bytecodealliance/wit-bindgen#1686, with the flag in From the spec's point of view, canonical version essentially renames the package name to exclude the version suffix. This means that the Resolve behavior is going to change, because we are now loading a wit file with a different name, e.g., from
With the changes in
Not sure what you mean. We can do |
Follow-up to #2556.
resolve.use_canonical_namesinwit-parserto merge interfaces with the same canonical version.versionsuffixtowit-component, so that we can link two interfaces via the canonical version name.semver_compat = none|merge|canonicaltowasm-tools component newto control the merging behavior. Deprecate the oldmerge_imports_based_on_semverflag (equivalent tosemver_compat=merge).This is a breaking change. Notably,
import a:b/c@0.1.1; import a:b/c@0.1.2;would fail under the new feature flag, because of duplicate imports. Users can use theimplementsfeature to update the wit file if needed. See themerge-import-versionstest.import a:b/c@0.1.1may becomeimport a:b/c@0.1.2if the wit package fromdeps/is versioned at0.1.2. See thecanon-names-mergetest.Detailed changes
PackageName::canon_version_splitto split canonical version and its version suffix.wit_parser::PackageKey, so that we can control whether to use the canonical version or not during construction time.Resolvewill use PackageKey as the map key, instead ofPackageName. Gradually, we can migrate all uses ofPackageNametoPackageKey.sort_unresolved_packagesmerges packages that share a canonical name, keeping the larger version inResolve. This behavior needs to be made explicit in the spec.encode_interface()andencode_world()consistently use canonical names with version suffixes in the binary encoding.canon-namesfeature)canon-namesfeature use*.canon-names.*alternate blessed fileswit-component, test names withcanon-namesprefix are only run whencanon-namesfeature is enabled.Things left for future PRs
Resolve, when merging two canonical versions, check if the interfaces really conform to the subtyping relation.implementandversionsuffixare present, theversionsuffixshould refer to the version fromimplement, instead of the main package name. Need to clarify this from the spec as well.