Skip to content

@since gates should not transitively apply across package boundaries when worlds are included #325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ydnar opened this issue Mar 23, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@ydnar
Copy link
Collaborator

ydnar commented Mar 23, 2025

Extending from #306, WIT version gates cannot be correctly represented in the fully-resolved representation of a component, e.g. in JSON.

The problem arises when a world in package A includes a world from package B, which imports or exports an interface with a version gate, e.g. @since(version = 0.2.0). The fully-resolved version of the component as emitted from wasm-tools will include the package B version gate in the world inside package A.

Testdata

wit-bindgen-go uses [email protected] internally to parse the WIT, produce a Resolve, and serialize to JSON, which is then loaded and then re-serialized into WIT.

The existing test corpus in this repo performs a WIT → JSON → WIT round trip verification for every JSON file in testdata. This is currently breaking for 2 files (issues/issue325.wit and wit-parser/gated-include-use-with-stable.wit). See #326 for more information.

Links:

  1. https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md#feature-gates
  2. fix mismatch in stability attributes error in wit-parser wasm-tools#2076

cc @alexcrichton @Mossaka

@ydnar ydnar self-assigned this Mar 23, 2025
@ydnar ydnar added the bug Something isn't working label Mar 23, 2025
@ydnar ydnar changed the title @since gates do not interact correctly when a WIT world is included in another WIT world in a different package @since gates should not transitively apply across package boundaries when worlds are included Mar 23, 2025
@ydnar
Copy link
Collaborator Author

ydnar commented Mar 23, 2025

The following WIT demonstrates the issue:

package issues:issue325;

world w {
	@unstable(feature = active)
	include issues:dep1/w@0.1.0;
	include issues:unstable/w@0.1.0;
}

package issues:unstable@0.1.0 {
	world w {
		@unstable(feature = active)
		use issues:dep2/[email protected].{r};
	}
}

package issues:dep1@0.1.0 {
	world w {
		include issues:dep2/[email protected];
	}
}

package issues:dep2@0.2.0 {
	world w {
		@since(version = 0.2.0)
		import i;
	}

	interface i {
		resource r;
	}
}

Result when processed through a version of wit-bindgen-go that strips incompatible @since gates, with wit-bindgen-go wit:

package issues:issue325;

world w {
	import issues:dep2/i@0.2.0;
	@unstable(feature = active)
	use issues:dep2/i@0.2.0.{r};
}

package issues:dep1@0.1.0 {
	world w {
		import issues:dep2/[email protected];
	}
}

package issues:unstable@0.1.0 {
	world w {
		@unstable(feature = active)
		import issues:dep2/[email protected];
		@unstable(feature = active)
		use issues:dep2/[email protected].{r};
	}
}

package issues:dep2@0.2.0 {
	interface i {
		resource r;
	}

	world w {
		@since(version = 0.2.0)
		import i;
	}
}

When the above is processed through wit-bindgen-go wit, the output changes:

package issues:issue325;

world w {
	@unstable(feature = active)
	import issues:dep2/i@0.2.0;
	@unstable(feature = active)
	use issues:dep2/i@0.2.0.{r};
}

package issues:dep1@0.1.0 {
	world w {
		import issues:dep2/[email protected];
	}
}

package issues:unstable@0.1.0 {
	world w {
		@unstable(feature = active)
		import issues:dep2/[email protected];
		@unstable(feature = active)
		use issues:dep2/[email protected].{r};
	}
}

package issues:dep2@0.2.0 {
	interface i {
		resource r;
	}

	world w {
		@since(version = 0.2.0)
		import i;
	}
}

@alexcrichton
Copy link
Member

I wrote up some more thoughts here but tl;dr; I think this is a bug in wasm-tools to fix.

ydnar added a commit that referenced this issue Apr 18, 2025
…rom different packages

Attemped to correct #325.
ydnar added a commit that referenced this issue Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants