Skip to content

Commit 18b2cce

Browse files
committed
feat(p3)!: vendor 0.3.0-rc-2026-01-06
Update wasmtime's WASI implementation from version 0.3.0-rc-2025-09-16 to 0.3.0-rc-2026-01-06, using wkg for WIT vendoring. This involves API changes in clocks and HTTP.
1 parent dcdbed1 commit 18b2cce

File tree

170 files changed

+9488
-10019
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+9488
-10019
lines changed

ci/vendor-wit.sh

Lines changed: 85 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,119 @@
11
#!/usr/bin/env bash
22

3-
# Script to re-vendor the WIT files that Wasmtime uses as defined by a
4-
# particular tag in upstream repositories.
3+
# Script to re-vendor the WIT files that Wasmtime uses using wkg to fetch
4+
# packages from the OCI registry.
55
#
66
# This script is executed on CI to ensure that everything is up-to-date.
77
set -ex
88

9-
# The make_vendor function takes a base path (e.g., "wasi") and a list
10-
# of packages in the format "name@tag". It constructs the full destination
11-
# path, downloads the tarballs from GitHub, extracts the relevant files, and
12-
# removes any unwanted directories.
13-
make_vendor() {
9+
# Temporary directory for downloads
10+
cache_dir=$(mktemp -d)
11+
trap "rm -rf $cache_dir" EXIT
12+
13+
# vendor_wkg fetches packages from the OCI registry using wkg.
14+
# Using --format wit preserves @unstable annotations.
15+
# Each package is placed in its own directory for wit-bindgen compatibility.
16+
#
17+
# Arguments:
18+
# $1 - Base path for the crate (e.g., "wasi/src/p2")
19+
# $2 - Space-separated list of packages in format "name@version"
20+
vendor_wkg() {
21+
local name=$1
22+
local packages=$2
23+
local path="crates/$name/wit/deps"
24+
25+
rm -rf "$path"
26+
mkdir -p "$path"
27+
28+
for package in $packages; do
29+
IFS='@' read -r pkg_name version <<< "$package"
30+
wkg get "wasi:${pkg_name}@${version}" --format wit --overwrite -o "$path/${pkg_name}.wit"
31+
done
32+
}
33+
34+
# vendor_github fetches packages from GitHub tarballs for packages not
35+
# available in the OCI registry.
36+
#
37+
# Arguments:
38+
# $1 - Base path for the crate (e.g., "wasi-tls")
39+
# $2 - Space-separated list of packages in format "name@tag[@subdir]"
40+
vendor_github() {
1441
local name=$1
1542
local packages=$2
1643
local path="crates/$name/wit/deps"
1744

18-
rm -rf $path
19-
mkdir -p $path
45+
rm -rf "$path"
46+
mkdir -p "$path"
2047

2148
for package in $packages; do
2249
IFS='@' read -r repo tag subdir <<< "$package"
2350
mkdir -p "$path/$repo"
24-
cached_extracted_dir="$cache_dir/$repo-$tag"
25-
26-
if [[ ! -d $cached_extracted_dir ]]; then
27-
mkdir -p $cached_extracted_dir
28-
curl --retry 5 --retry-all-errors -sLO https://github.com/WebAssembly/wasi-$repo/archive/$tag.tar.gz
29-
tar xzf $tag.tar.gz --strip-components=1 -C $cached_extracted_dir
30-
rm $tag.tar.gz
31-
rm -rf $cached_extracted_dir/${subdir:-"wit"}/deps*
51+
local extracted_dir="$cache_dir/$repo-$tag"
52+
53+
if [[ ! -d $extracted_dir ]]; then
54+
mkdir -p "$extracted_dir"
55+
curl --retry 5 --retry-all-errors -sLO "https://github.com/WebAssembly/wasi-$repo/archive/$tag.tar.gz"
56+
tar xzf "$tag.tar.gz" --strip-components=1 -C "$extracted_dir"
57+
rm "$tag.tar.gz"
58+
rm -rf "$extracted_dir/${subdir:-wit}/deps"*
3259
fi
3360

34-
cp -r $cached_extracted_dir/${subdir:-"wit"}/* $path/$repo
61+
cp -r "$extracted_dir/${subdir:-wit}"/* "$path/$repo"
3562
done
3663
}
3764

38-
cache_dir=$(mktemp -d)
65+
# WASI Preview 2 packages (0.2.6)
66+
vendor_wkg "wasi-io" "[email protected]"
3967

40-
make_vendor "wasi-io" "
41-
68+
vendor_wkg "wasi/src/p2" "
69+
70+
71+
72+
73+
74+
4275
"
4376

44-
make_vendor "wasi/src/p2" "
45-
46-
47-
48-
49-
50-
77+
vendor_wkg "wasi-http" "
78+
79+
80+
81+
82+
83+
84+
5185
"
5286

53-
make_vendor "wasi-http" "
54-
55-
56-
57-
58-
59-
60-
61-
"
62-
63-
make_vendor "wasi-tls" "
87+
# wasi-tls is not yet published to OCI registry, use GitHub
88+
vendor_github "wasi-tls" "
6489
6590
6691
"
6792

68-
make_vendor "wasi-config" "[email protected]"
69-
70-
make_vendor "wasi-keyvalue" "keyvalue@219ea36"
71-
72-
make_vendor "wasi/src/p3" "
73-
[email protected]@wit-0.3.0-draft
74-
[email protected]@wit-0.3.0-draft
75-
[email protected]@wit-0.3.0-draft
76-
[email protected]@wit-0.3.0-draft
77-
[email protected]@wit-0.3.0-draft
93+
# wasi-config and wasi-keyvalue from OCI registry
94+
vendor_wkg "wasi-config" "[email protected]"
95+
vendor_wkg "wasi-keyvalue" "[email protected]"
96+
97+
# WASI Preview 3 packages (0.3.0-rc-2026-01-06)
98+
vendor_wkg "wasi/src/p3" "
99+
100+
101+
102+
103+
78104
"
79105

80-
make_vendor "wasi-http/src/p3" "
81-
cli@v0.3.0-rc-[email protected]
82-
clocks@v0.3.0-rc-[email protected]
83-
filesystem@v0.3.0-rc-[email protected]
84-
http@v0.3.0-rc-[email protected]
85-
random@v0.3.0-rc-[email protected]
86-
sockets@v0.3.0-rc-[email protected]
106+
vendor_wkg "wasi-http/src/p3" "
107+
cli@0.3.0-rc-2026-01-06
108+
clocks@0.3.0-rc-2026-01-06
109+
filesystem@0.3.0-rc-2026-01-06
110+
http@0.3.0-rc-2026-01-06
111+
random@0.3.0-rc-2026-01-06
112+
sockets@0.3.0-rc-2026-01-06
87113
"
88114

89-
rm -rf $cache_dir
90-
91-
# Separately (for now), vendor the `wasi-nn` WIT files since their retrieval is
92-
# slightly different than above.
115+
# wasi-nn is fetched separately since it's not in the standard WASI registry
93116
repo=https://raw.githubusercontent.com/WebAssembly/wasi-nn
94117
revision=0.2.0-rc-2024-10-28
95-
curl --retry 5 --retry-all-errors -L $repo/$revision/wasi-nn.witx -o crates/wasi-nn/witx/wasi-nn.witx
96-
curl --retry 5 --retry-all-errors -L $repo/$revision/wit/wasi-nn.wit -o crates/wasi-nn/wit/wasi-nn.wit
118+
curl --retry 5 --retry-all-errors -L "$repo/$revision/wasi-nn.witx" -o crates/wasi-nn/witx/wasi-nn.witx
119+
curl --retry 5 --retry-all-errors -L "$repo/$revision/wit/wasi-nn.wit" -o crates/wasi-nn/wit/wasi-nn.wit

crates/test-programs/src/bin/p2_api_reactor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ wit_bindgen::generate!({
44
world: "test-reactor",
55
path: "../wasi/src/p2/wit",
66
generate_all,
7+
features: ["cli-exit-with-code", "clocks-timezone"],
78
});
89

910
struct T;

crates/test-programs/src/bin/p3_http_middleware.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1+
mod bindings {
2+
wit_bindgen::generate!({
3+
path: "../wasi-http/src/p3/wit",
4+
world: "wasi:http/middleware",
5+
generate_all,
6+
features: ["clocks-timezone"],
7+
});
8+
9+
use super::Component;
10+
export!(Component);
11+
}
12+
113
use {
2-
flate2::{
3-
Compression,
4-
write::{DeflateDecoder, DeflateEncoder},
5-
},
6-
std::{io::Write, mem},
7-
test_programs::p3::{
8-
proxy::exports::wasi::http::handler::Guest as Handler,
14+
bindings::{
15+
exports::wasi::http::handler::Guest as Handler,
916
wasi::http::{
1017
handler,
1118
types::{ErrorCode, Headers, Request, Response},
1219
},
1320
wit_future, wit_stream,
1421
},
22+
flate2::{
23+
Compression,
24+
write::{DeflateDecoder, DeflateEncoder},
25+
},
26+
std::{io::Write, mem},
1527
wit_bindgen::StreamResult,
1628
};
1729

1830
struct Component;
1931

20-
test_programs::p3::proxy::export!(Component);
21-
2232
impl Handler for Component {
2333
/// Forward the specified request to the imported `wasi:http/handler`, transparently decoding the request body
2434
/// if it is `deflate`d and then encoding the response body if the client has provided an `accept-encoding:

crates/test-programs/src/bin/p3_http_middleware_with_chain.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@ mod bindings {
66
package local:local;
77
88
world middleware-with-chain {
9-
include wasi:http/proxy@0.3.0-rc-2025-09-16;
9+
include wasi:http/service@0.3.0-rc-2026-01-06;
1010
1111
import chain-http;
1212
}
1313
1414
interface chain-http {
15-
use wasi:http/[email protected]2025-09-16.{request, response, error-code};
15+
use wasi:http/[email protected]2026-01-06.{request, response, error-code};
1616
1717
handle: async func(request: request) -> result<response, error-code>;
1818
}
1919
",
2020
generate_all,
21+
features: ["clocks-timezone"],
2122
});
2223

2324
use super::Component;

crates/test-programs/src/bin/p3_http_outbound_request_content_length.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use futures::join;
2-
use test_programs::p3::wasi::http::handler;
2+
use test_programs::p3::wasi::http::client;
33
use test_programs::p3::wasi::http::types::{ErrorCode, Headers, Method, Request, Scheme, Trailers};
44
use test_programs::p3::{wit_future, wit_stream};
55
use wit_bindgen::{FutureReader, FutureWriter, StreamWriter};
@@ -47,7 +47,7 @@ impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
4747
{
4848
let (request, mut contents_tx, trailers_tx, transmit) = make_request();
4949
let (handle, transmit, ()) = join!(
50-
async { handler::handle(request).await },
50+
async { client::send(request).await },
5151
async { transmit.await },
5252
async {
5353
let remaining = contents_tx.write_all(b"long enough".to_vec()).await;
@@ -64,7 +64,7 @@ impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
6464
{
6565
let (request, mut contents_tx, trailers_tx, transmit) = make_request();
6666
let (handle, transmit, ()) = join!(
67-
async { handler::handle(request).await },
67+
async { client::send(request).await },
6868
async { transmit.await },
6969
async {
7070
let remaining = contents_tx.write_all(b"msg".to_vec()).await;
@@ -93,7 +93,7 @@ impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
9393
{
9494
let (request, mut contents_tx, trailers_tx, transmit) = make_request();
9595
let (handle, transmit, ()) = join!(
96-
async { handler::handle(request).await },
96+
async { client::send(request).await },
9797
async { transmit.await },
9898
async {
9999
let remaining = contents_tx.write_all(b"more than 11 bytes".to_vec()).await;

crates/test-programs/src/bin/p3_http_outbound_request_missing_path_and_query.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use test_programs::p3::wasi::http::handler::handle;
1+
use test_programs::p3::wasi::http::client::send;
22
use test_programs::p3::wasi::http::types::{Fields, Method, Request, Scheme};
33
use test_programs::p3::wit_future;
44

@@ -18,7 +18,7 @@ impl test_programs::p3::exports::wasi::cli::run::Guest for Component {
1818
// Don't set path/query
1919
// req.set_path_with_query(Some("/")).unwrap();
2020

21-
let res = handle(req).await;
21+
let res = send(req).await;
2222
assert!(res.is_err());
2323
Ok(())
2424
}

crates/test-programs/src/bin/p3_http_proxy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use {
22
test_programs::p3::{
33
proxy::exports::wasi::http::handler::Guest as Handler,
44
wasi::http::{
5-
handler,
5+
client,
66
types::{ErrorCode, Fields, Request, Response, Scheme},
77
},
88
wit_future,
@@ -42,7 +42,7 @@ impl Handler for Component {
4242
outgoing_request
4343
.set_authority(Some(url.authority()))
4444
.unwrap();
45-
handler::handle(outgoing_request).await?
45+
client::send(outgoing_request).await?
4646
} else {
4747
bad_request()
4848
},

crates/test-programs/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ wit_bindgen::generate!({
2525
"../wasi-tls/wit/deps/tls",
2626
],
2727
world: "wasmtime:test/test",
28-
features: ["cli-exit-with-code", "tls"],
28+
features: ["cli-exit-with-code", "clocks-timezone", "tls"],
2929
generate_all,
3030
});
3131

@@ -35,6 +35,7 @@ pub mod proxy {
3535
world: "wasi:http/proxy",
3636
default_bindings_module: "test_programs::proxy",
3737
pub_export_macro: true,
38+
features: ["cli-exit-with-code", "clocks-timezone"],
3839
with: {
3940
"wasi:http/[email protected]": crate::wasi::http::types,
4041
"wasi:http/[email protected]": crate::wasi::http::outgoing_handler,

crates/test-programs/src/p3/http.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use anyhow::{Context as _, Result, anyhow};
22
use core::fmt;
33
use futures::join;
44

5-
use crate::p3::wasi::http::{handler, types};
5+
use crate::p3::wasi::http::{client, types};
66
use crate::p3::{wit_future, wit_stream};
77

88
pub struct Response {
@@ -91,7 +91,7 @@ pub async fn request(
9191
let (transmit, handle) = join!(
9292
async { transmit.await.context("failed to transmit request") },
9393
async {
94-
let response = handler::handle(request).await?;
94+
let response = client::send(request).await?;
9595
let status = response.get_status_code();
9696
let headers = response.get_headers().copy_all();
9797
let (_, result_rx) = wit_future::new(|| Ok(()));

0 commit comments

Comments
 (0)