Skip to content
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

WIT: Implement @since and @unstable annotations #1508

Merged
merged 11 commits into from
May 28, 2024

Conversation

alexcrichton
Copy link
Member

@alexcrichton alexcrichton commented Apr 19, 2024

This PR is an implementation of WebAssembly/component-model#332 for wasm-tools. This is a pretty big feature for WIT so it's a pretty large PR as well. I've tried to split out separate commits where each commit passes test to more easily digest the changes that are happening here.

At a high level:

  • Most items in WIT can now be tagged with @since and @unstable.
  • When tagged with @unstable items do not appear in Resolve by default
  • Features are enabled through the set at Resolve::features to control whether unstable items appear
  • WIT items always retain their stability annotations throught processing, e.g. in Resolve
  • Round-tripping a WIT document through the WebAssembly component encoding preserves stability annotations

The intention is that this will be a building block for WASI's release processes. Namely all APIs will start as @unstable and only become ungated with @since once they're voted to be at such a phase. @unstable APIs will be available to all consumers but only on an opt-in basis which will enable everyone to have proper gates and processes around ensuring that unstable APIs aren't relied on without knowing that things may change.

@ydnar
Copy link
Contributor

ydnar commented Apr 26, 2024

Would this PR update the JSON fixtures in the wit-parser crate?

@alexcrichton
Copy link
Member Author

It does, yes. You can see examples in the *.json files in this PR diff.

@yoshuawuyts
Copy link

I spoke with Alex last week - in order to move this forward we want to at a minimum have a reference of what this would look like when applied to the existing WASI WIT definitions. So I'll be doing that next, and share a link to that back here.

@yoshuawuyts
Copy link

yoshuawuyts commented May 27, 2024

Okay, I ported all of WASI to use @since, and added the timezones API using @unstable in a PR here: WebAssembly/WASI#604. This all seems to work as expected with wasm-tools. I think with that we can consider this implementation to be working as intended, and ready to merge?

edit (2024-05-28): I also went ahead and filed PRs against the individual specifiations:

@alexcrichton alexcrichton added this pull request to the merge queue May 28, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 28, 2024
Previously the entire error message was replaced, losing any attached
context. This commit updates error highlighting to only augment the
single error found in the chain that's being highlighted (in the most
common case). This required a small refactoring of the `Error` type and
changes all existing users to a method-based constructor rather than
explicit struct-based construction.
Nothing uses the results of parsing yet, that's going to come in a
future commit.
Will be used for errors in a future commit.
This commit pushes stability attributes through the resolution process
to the next stage of AST. The top-level user-facing types in
`wit-parser` now have `Stability` annotations were they can be added.

This commit notably changes the `WorldItem::Interface` enum variant to
contain a stability attribute in addition to the id listed.
This finishes support for `@unstable` and `@since` in `Resolve` by
handling all items there and specifically filtering out any disabled
items.
This involved a number of refactorings and "tricks" to get this to work
out. Namely when possible the old format of the custom section is still
emitted to ensure older/newer tools can interoperate when possible.
@alexcrichton alexcrichton added this pull request to the merge queue May 28, 2024
Merged via the queue into bytecodealliance:main with commit 01bec9c May 28, 2024
25 checks passed
@alexcrichton alexcrichton deleted the since-and-unstable branch May 28, 2024 17:52
alexcrichton added a commit to alexcrichton/witx-bindgen that referenced this pull request May 29, 2024
This commit updates the wasm-tools crates to their 209 versions which
include support for WIT features from bytecodealliance/wasm-tools#1508.
This adds a `--features` CLI flag in addition to a `features`
configuration of the Rust bindings macro.
github-merge-queue bot pushed a commit to bytecodealliance/wit-bindgen that referenced this pull request May 29, 2024
This commit updates the wasm-tools crates to their 209 versions which
include support for WIT features from bytecodealliance/wasm-tools#1508.
This adds a `--features` CLI flag in addition to a `features`
configuration of the Rust bindings macro.
@ydnar
Copy link
Contributor

ydnar commented Jun 7, 2024

I finally got to updating wasm-tools-go to support the new JSON schema.

Q: why was the schema for the WorldItem Interface case changed? But not the others?

Should the gating attributes be present on the Interface?

@alexcrichton
Copy link
Member Author

For types/functions the attributes were already present on the type/function itself, but for interfaces it was intended to help disambiguate:

@unstable(feature = "a")
interface foo {}

world bar {
    @unstable(feature = "b")
    import foo;
}

Here there's two different features that need to be modeled, but in the case of functions/types there's never two features to model.

ydnar added a commit to ydnar/wasm-tools-go that referenced this pull request Jun 8, 2024
ydnar added a commit to ydnar/wasm-tools-go that referenced this pull request Jun 8, 2024
ydnar added a commit to ydnar/wasm-tools-go that referenced this pull request Jun 11, 2024
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.

None yet

4 participants