From 7a3ee980fabe16666e94606854b98aef03a34d26 Mon Sep 17 00:00:00 2001
From: Roman Volosatovs <rvolosatovs@riseup.net>
Date: Fri, 17 Jan 2025 11:24:14 +0100
Subject: [PATCH 1/3] ci: update `wit-deps` to 0.5.0

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---
 .github/workflows/main.yml | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a4336b2..09d9836 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -13,9 +13,10 @@ jobs:
     - uses: actions/checkout@v4
     - name: ensure `./wit/deps` are in sync
       run: |
-        curl -Lo 'wit-deps' https://github.com/bytecodealliance/wit-deps/releases/download/v0.3.2/wit-deps-x86_64-unknown-linux-musl
+        curl -Lo 'wit-deps' https://github.com/bytecodealliance/wit-deps/releases/download/v0.5.0/wit-deps-x86_64-unknown-linux-musl
         chmod +x ./wit-deps
         ./wit-deps lock --check
+        ./wit-deps -m wit-0.3.0-draft/deps.toml -l wit-0.3.0-draft/deps.lock -d wit-0.3.0-draft/deps lock --check
     - uses: WebAssembly/wit-abi-up-to-date@v22
       with:
         wasm-tools: '1.223.0'

From 684484d93e5e92366c6f2f661ebff6b6cc8b33c3 Mon Sep 17 00:00:00 2001
From: Roman Volosatovs <rvolosatovs@riseup.net>
Date: Fri, 17 Jan 2025 11:21:24 +0100
Subject: [PATCH 2/3] chore(0.3): update `wasi:clocks` to `0.3.0`

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---
 wit-0.3.0-draft/deps.lock                     | 36 ++++++------
 wit-0.3.0-draft/deps.toml                     |  9 +--
 .../deps/clocks-0-3-0/monotonic-clock.wit     | 45 +++++++++++++++
 .../deps/clocks-0-3-0/timezone.wit            | 55 +++++++++++++++++++
 .../deps/clocks-0-3-0/wall-clock.wit          | 46 ++++++++++++++++
 wit-0.3.0-draft/deps/clocks-0-3-0/world.wit   | 11 ++++
 wit-0.3.0-draft/deps/filesystem/preopens.wit  |  2 +-
 wit-0.3.0-draft/deps/filesystem/types.wit     | 10 +---
 wit-0.3.0-draft/deps/io/streams.wit           |  4 ++
 .../deps/sockets/ip-name-lookup.wit           |  2 +-
 wit-0.3.0-draft/deps/sockets/network.wit      | 16 ++++++
 wit-0.3.0-draft/deps/sockets/tcp.wit          |  2 +-
 wit-0.3.0-draft/deps/sockets/udp.wit          |  6 +-
 wit-0.3.0-draft/proxy.wit                     |  2 +-
 wit-0.3.0-draft/types.wit                     |  2 +-
 15 files changed, 208 insertions(+), 40 deletions(-)
 create mode 100644 wit-0.3.0-draft/deps/clocks-0-3-0/monotonic-clock.wit
 create mode 100644 wit-0.3.0-draft/deps/clocks-0-3-0/timezone.wit
 create mode 100644 wit-0.3.0-draft/deps/clocks-0-3-0/wall-clock.wit
 create mode 100644 wit-0.3.0-draft/deps/clocks-0-3-0/world.wit

diff --git a/wit-0.3.0-draft/deps.lock b/wit-0.3.0-draft/deps.lock
index a12064a..184d09c 100644
--- a/wit-0.3.0-draft/deps.lock
+++ b/wit-0.3.0-draft/deps.lock
@@ -1,29 +1,31 @@
 [cli]
-url = "https://github.com/WebAssembly/wasi-cli/archive/main.tar.gz"
-sha256 = "1de50b8e6940e73110cda10b7f90ca87a8fea886f0fa36c748f96dc70671ee38"
-sha512 = "bbb6cd3e7b4d3237b6af9bfbb2633ccd2c4ea2a4f37b8c033255c7e0c1cb037be7f22ec1f8ca792cc8ec1942199582943979e646b4b272b85dcff7654eac51d0"
+url = "https://github.com/WebAssembly/wasi-cli/archive/v0.2.3.tar.gz"
+sha256 = "4dadd13d55aaf626833d1f4b9c34a17b0f04e993babd09552b785cda3b95ea76"
+sha512 = "898dcc4e8c15d18acc6b88dbe232336fa4d19019430a910dbc9e7aeaace3077a164af3be9f002de6e7e65ef693df340801ac0c7e421e9a746bf1b6d698a90835"
+deps = ["clocks", "filesystem", "io", "random", "sockets"]
 
 [clocks]
+sha256 = "93a701968a7dd3c5d69031bc0601681c468972fdf7e28a93bb6150a67d6ebe8b"
+sha512 = "98fca567c7a01887b0fb38981f1772169b6ea8de475b546508f8b86738d84e44ba95cae81def40ac34e8809f5f60e85224077ab8cb6d6d5d6296acc1df73c159"
+
+[clocks-0-3-0]
 url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
-sha256 = "ea9d69ee803bc176e23e5268f5e24a2ac485dd1f62a0ab4c748e9d3f901f576f"
-sha512 = "5efc22927c46cd56c41e5549ec775561c7fac2ea0d365abc0b55396d9475a7c9f984077a81f84a44a726f1c008fd2fadbffffa4fa53ecd5fbfd05afd379ab428"
+subdir = "wit-0.3.0-draft"
+sha256 = "26e315db0d371495f8834edfc0e479042f94152ce677d96d54d3623d0e4ffb1e"
+sha512 = "e1c76f499435841316f9287b88d8173558e64f277c321ff390556de8707a0b18dd6c1749bbb17bbbba8d523da246ef6eb05c990ceddb762e03efb2ae30cacc76"
 
 [filesystem]
-url = "https://github.com/WebAssembly/wasi-filesystem/archive/main.tar.gz"
-sha256 = "cfe8c420e8b857de612ae2a3336680dae16b95c93c8ba3a6ff05b21210966740"
-sha512 = "3c00c5544a58658e3e8025677091685286027fd49f37abf198c30b4e83b9e68f19723975aaa98794fba9f425ae9ef4f3dc0f5b9cf59203b5ecfaadf62b296f9a"
+sha256 = "69d42fb10a04a33545b17e055f13db9b1e10e82ba0ed5bdb52334e40dc07c679"
+sha512 = "612effbac6f4804fe0c29dae20b78bbba59e52cb754c15402f5fe229c3153a221e0fbdff1d9d00ceaa3fe049c6a95523a5b99f772f1c16d972eade2c88326a30"
 
 [io]
-url = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
-sha256 = "2a74bd811adc46b5a0f19827ddbde89870e52b17615f4d0873f06fd977250caf"
-sha512 = "94624f00c66e66203592cee820f80b1ba91ecdb71f682c154f25eaf71f8d8954197dcb64503bc21e72ed5e812af7eae876df47b7eb727b02db3a74a7ce0aefca"
+sha256 = "1cccbfe4122686ea57a25cd368e8cdfc408cbcad089f47fb6685b6f92e96f050"
+sha512 = "7a95f964c13da52611141acd89bc8876226497f128e99dd176a4270c5b5efbd8cc847b5fbd1a91258d028c646db99e0424d72590cf1caf20f9f3a3343fad5017"
 
 [random]
-url = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz"
-sha256 = "9e2d5056186f81b2e7f96bc97d2babd0341840f6abb4f170449b70992f1b598f"
-sha512 = "67bf41d8d5d4b7af084124ee85196585225785969059f59e2f9ddb77ac1a8095cfe811ae29d076aac817418fa01064d7b9fbc0233930bace680758eeb21e36f8"
+sha256 = "dd0c91e7125172eb8fd4568e15ad9fc7305643015e6ece4396c3cc5e8c2bf79a"
+sha512 = "d1ca2e7b0616a94a3b39d1b9450bb3fb595b01fd94a8626ad75433038dde40988ecb41ab93a374d569ab72163af3b30038d7bfc3499b9c07193181f4f1d9292a"
 
 [sockets]
-url = "https://github.com/WebAssembly/wasi-sockets/archive/main.tar.gz"
-sha256 = "4c361137a7e61e8b9a73da2a0899dd9ad1a0c2dfee7d310cf168704c57b7a07c"
-sha512 = "348b4ef381f57aec23d48537df8b69ab8963587dcb056e94c4cd5657e217677a4ee2a545868a5c829d2334cc6b8b0a61d3e72797999f44d78553fbd3a73c5b8d"
+sha256 = "2bc0f65a8046207ee3330ad7d63f6fafeafd4cc0ea4084f081bd5e4f7b177e74"
+sha512 = "3e5490e41547dffa78d52631825d93da8d60f4af0246cbaf97e1ecb879285953a86d5f1f390b10c32f91dd7eaec6f43e625a26b1c92c32a0c86fde428aedaaab"
diff --git a/wit-0.3.0-draft/deps.toml b/wit-0.3.0-draft/deps.toml
index dd738ac..c0c49cb 100644
--- a/wit-0.3.0-draft/deps.toml
+++ b/wit-0.3.0-draft/deps.toml
@@ -1,7 +1,2 @@
-io = "https://github.com/WebAssembly/wasi-io/archive/main.tar.gz"
-cli = "https://github.com/WebAssembly/wasi-cli/archive/main.tar.gz"
-random = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz"
-clocks = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz"
-# not used by http/proxy, but included to allow full contents of wasi-cli to validate
-filesystem = "https://github.com/WebAssembly/wasi-filesystem/archive/main.tar.gz"
-sockets = "https://github.com/WebAssembly/wasi-sockets/archive/main.tar.gz"
+cli = "https://github.com/WebAssembly/wasi-cli/archive/v0.2.3.tar.gz" # TODO: update to v0.3.0-draft and remove custom clock import
+clocks-0-3-0 = { url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz", subdir = "wit-0.3.0-draft" }
diff --git a/wit-0.3.0-draft/deps/clocks-0-3-0/monotonic-clock.wit b/wit-0.3.0-draft/deps/clocks-0-3-0/monotonic-clock.wit
new file mode 100644
index 0000000..87ebdaa
--- /dev/null
+++ b/wit-0.3.0-draft/deps/clocks-0-3-0/monotonic-clock.wit
@@ -0,0 +1,45 @@
+package wasi:clocks@0.3.0;
+/// WASI Monotonic Clock is a clock API intended to let users measure elapsed
+/// time.
+///
+/// It is intended to be portable at least between Unix-family platforms and
+/// Windows.
+///
+/// A monotonic clock is a clock which has an unspecified initial value, and
+/// successive reads of the clock will produce non-decreasing values.
+@since(version = 0.3.0)
+interface monotonic-clock {
+    /// An instant in time, in nanoseconds. An instant is relative to an
+    /// unspecified initial value, and can only be compared to instances from
+    /// the same monotonic-clock.
+    @since(version = 0.3.0)
+    type instant = u64;
+
+    /// A duration of time, in nanoseconds.
+    @since(version = 0.3.0)
+    type duration = u64;
+
+    /// Read the current value of the clock.
+    ///
+    /// The clock is monotonic, therefore calling this function repeatedly will
+    /// produce a sequence of non-decreasing values.
+    @since(version = 0.3.0)
+    now: func() -> instant;
+
+    /// Query the resolution of the clock. Returns the duration of time
+    /// corresponding to a clock tick.
+    @since(version = 0.3.0)
+    resolution: func() -> duration;
+
+    /// Wait until the specified instant has occurred.
+    @since(version = 0.3.0)
+    wait-until: func(
+        when: instant,
+    );
+
+    /// Wait for the specified duration has elapsed.
+    @since(version = 0.3.0)
+    wait-for: func(
+        how-long: duration,
+    );
+}
diff --git a/wit-0.3.0-draft/deps/clocks-0-3-0/timezone.wit b/wit-0.3.0-draft/deps/clocks-0-3-0/timezone.wit
new file mode 100644
index 0000000..ac91468
--- /dev/null
+++ b/wit-0.3.0-draft/deps/clocks-0-3-0/timezone.wit
@@ -0,0 +1,55 @@
+package wasi:clocks@0.3.0;
+
+@unstable(feature = clocks-timezone)
+interface timezone {
+    @unstable(feature = clocks-timezone)
+    use wall-clock.{datetime};
+
+    /// Return information needed to display the given `datetime`. This includes
+    /// the UTC offset, the time zone name, and a flag indicating whether
+    /// daylight saving time is active.
+    ///
+    /// If the timezone cannot be determined for the given `datetime`, return a
+    /// `timezone-display` for `UTC` with a `utc-offset` of 0 and no daylight
+    /// saving time.
+    @unstable(feature = clocks-timezone)
+    display: func(when: datetime) -> timezone-display;
+
+    /// The same as `display`, but only return the UTC offset.
+    @unstable(feature = clocks-timezone)
+    utc-offset: func(when: datetime) -> s32;
+
+    /// Information useful for displaying the timezone of a specific `datetime`.
+    ///
+    /// This information may vary within a single `timezone` to reflect daylight
+    /// saving time adjustments.
+    @unstable(feature = clocks-timezone)
+    record timezone-display {
+        /// The number of seconds difference between UTC time and the local
+        /// time of the timezone.
+        ///
+        /// The returned value will always be less than 86400 which is the
+        /// number of seconds in a day (24*60*60).
+        ///
+        /// In implementations that do not expose an actual time zone, this
+        /// should return 0.
+        utc-offset: s32,
+
+        /// The abbreviated name of the timezone to display to a user. The name
+        /// `UTC` indicates Coordinated Universal Time. Otherwise, this should
+        /// reference local standards for the name of the time zone.
+        ///
+        /// In implementations that do not expose an actual time zone, this
+        /// should be the string `UTC`.
+        ///
+        /// In time zones that do not have an applicable name, a formatted
+        /// representation of the UTC offset may be returned, such as `-04:00`.
+        name: string,
+
+        /// Whether daylight saving time is active.
+        ///
+        /// In implementations that do not expose an actual time zone, this
+        /// should return false.
+        in-daylight-saving-time: bool,
+    }
+}
diff --git a/wit-0.3.0-draft/deps/clocks-0-3-0/wall-clock.wit b/wit-0.3.0-draft/deps/clocks-0-3-0/wall-clock.wit
new file mode 100644
index 0000000..b7a85ab
--- /dev/null
+++ b/wit-0.3.0-draft/deps/clocks-0-3-0/wall-clock.wit
@@ -0,0 +1,46 @@
+package wasi:clocks@0.3.0;
+/// WASI Wall Clock is a clock API intended to let users query the current
+/// time. The name "wall" makes an analogy to a "clock on the wall", which
+/// is not necessarily monotonic as it may be reset.
+///
+/// It is intended to be portable at least between Unix-family platforms and
+/// Windows.
+///
+/// A wall clock is a clock which measures the date and time according to
+/// some external reference.
+///
+/// External references may be reset, so this clock is not necessarily
+/// monotonic, making it unsuitable for measuring elapsed time.
+///
+/// It is intended for reporting the current date and time for humans.
+@since(version = 0.3.0)
+interface wall-clock {
+    /// A time and date in seconds plus nanoseconds.
+    @since(version = 0.3.0)
+    record datetime {
+        seconds: u64,
+        nanoseconds: u32,
+    }
+
+    /// Read the current value of the clock.
+    ///
+    /// This clock is not monotonic, therefore calling this function repeatedly
+    /// will not necessarily produce a sequence of non-decreasing values.
+    ///
+    /// The returned timestamps represent the number of seconds since
+    /// 1970-01-01T00:00:00Z, also known as [POSIX's Seconds Since the Epoch],
+    /// also known as [Unix Time].
+    ///
+    /// The nanoseconds field of the output is always less than 1000000000.
+    ///
+    /// [POSIX's Seconds Since the Epoch]: https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap04.html#tag_21_04_16
+    /// [Unix Time]: https://en.wikipedia.org/wiki/Unix_time
+    @since(version = 0.3.0)
+    now: func() -> datetime;
+
+    /// Query the resolution of the clock.
+    ///
+    /// The nanoseconds field of the output is always less than 1000000000.
+    @since(version = 0.3.0)
+    resolution: func() -> datetime;
+}
diff --git a/wit-0.3.0-draft/deps/clocks-0-3-0/world.wit b/wit-0.3.0-draft/deps/clocks-0-3-0/world.wit
new file mode 100644
index 0000000..f97bcfe
--- /dev/null
+++ b/wit-0.3.0-draft/deps/clocks-0-3-0/world.wit
@@ -0,0 +1,11 @@
+package wasi:clocks@0.3.0;
+
+@since(version = 0.3.0)
+world imports {
+    @since(version = 0.3.0)
+    import monotonic-clock;
+    @since(version = 0.3.0)
+    import wall-clock;
+    @unstable(feature = clocks-timezone)
+    import timezone;
+}
diff --git a/wit-0.3.0-draft/deps/filesystem/preopens.wit b/wit-0.3.0-draft/deps/filesystem/preopens.wit
index 4bc202e..cea9749 100644
--- a/wit-0.3.0-draft/deps/filesystem/preopens.wit
+++ b/wit-0.3.0-draft/deps/filesystem/preopens.wit
@@ -5,7 +5,7 @@ interface preopens {
     @since(version = 0.2.0)
     use types.{descriptor};
 
-    /// Return the set of preopened directories, and their path.
+    /// Return the set of preopened directories, and their paths.
     @since(version = 0.2.0)
     get-directories: func() -> list<tuple<descriptor, string>>;
 }
diff --git a/wit-0.3.0-draft/deps/filesystem/types.wit b/wit-0.3.0-draft/deps/filesystem/types.wit
index 826acd1..d229a21 100644
--- a/wit-0.3.0-draft/deps/filesystem/types.wit
+++ b/wit-0.3.0-draft/deps/filesystem/types.wit
@@ -327,7 +327,7 @@ interface types {
         /// May fail with an error-code describing why the file cannot be appended.
         ///
         /// Note: This allows using `write-stream`, which is similar to `write` with
-        /// `O_APPEND` in in POSIX.
+        /// `O_APPEND` in POSIX.
         @since(version = 0.2.0)
         append-via-stream: func() -> result<output-stream, error-code>;
 
@@ -523,12 +523,6 @@ interface types {
 
         /// Open a file or directory.
         ///
-        /// The returned descriptor is not guaranteed to be the lowest-numbered
-        /// descriptor not currently open/ it is randomized to prevent applications
-        /// from depending on making assumptions about indexes, since this is
-        /// error-prone in multi-threaded contexts. The returned descriptor is
-        /// guaranteed to be less than 2**31.
-        ///
         /// If `flags` contains `descriptor-flags::mutate-directory`, and the base
         /// descriptor doesn't have `descriptor-flags::mutate-directory` set,
         /// `open-at` fails with `error-code::read-only`.
@@ -629,7 +623,7 @@ interface types {
         /// replaced. It may also include a secret value chosen by the
         /// implementation and not otherwise exposed.
         ///
-        /// Implementations are encourated to provide the following properties:
+        /// Implementations are encouraged to provide the following properties:
         ///
         ///  - If the file is not modified or replaced, the computed hash value should
         ///    usually not change.
diff --git a/wit-0.3.0-draft/deps/io/streams.wit b/wit-0.3.0-draft/deps/io/streams.wit
index c441d77..0de0846 100644
--- a/wit-0.3.0-draft/deps/io/streams.wit
+++ b/wit-0.3.0-draft/deps/io/streams.wit
@@ -18,6 +18,9 @@ interface streams {
         /// The last operation (a write or flush) failed before completion.
         ///
         /// More information is available in the `error` payload.
+        ///
+        /// After this, the stream will be closed. All future operations return
+        /// `stream-error::closed`.
         last-operation-failed(error),
         /// The stream is closed: no more input will be accepted by the
         /// stream. A closed output-stream will return this error on all
@@ -205,6 +208,7 @@ interface streams {
         /// The created `pollable` is a child resource of the `output-stream`.
         /// Implementations may trap if the `output-stream` is dropped before
         /// all derived `pollable`s created with this function are dropped.
+        @since(version = 0.2.0)
         subscribe: func() -> pollable;
 
         /// Write zeroes to a stream.
diff --git a/wit-0.3.0-draft/deps/sockets/ip-name-lookup.wit b/wit-0.3.0-draft/deps/sockets/ip-name-lookup.wit
index 6b87a0a..c1d8a47 100644
--- a/wit-0.3.0-draft/deps/sockets/ip-name-lookup.wit
+++ b/wit-0.3.0-draft/deps/sockets/ip-name-lookup.wit
@@ -48,7 +48,7 @@ interface ip-name-lookup {
 
         /// Create a `pollable` which will resolve once the stream is ready for I/O.
         ///
-        /// Note: this function is here for WASI Preview2 only.
+        /// Note: this function is here for WASI 0.2 only.
         /// It's planned to be removed when `future` is natively supported in Preview3.
         @since(version = 0.2.0)
         subscribe: func() -> pollable;
diff --git a/wit-0.3.0-draft/deps/sockets/network.wit b/wit-0.3.0-draft/deps/sockets/network.wit
index 8c13b34..f3f60a3 100644
--- a/wit-0.3.0-draft/deps/sockets/network.wit
+++ b/wit-0.3.0-draft/deps/sockets/network.wit
@@ -1,5 +1,8 @@
 @since(version = 0.2.0)
 interface network {
+    @unstable(feature = network-error-code)
+    use wasi:io/error@0.2.3.{error};
+
     /// An opaque resource that represents access to (a subset of) the network.
     /// This enables context-based security for networking.
     /// There is no need for this to map 1:1 to a physical network interface.
@@ -105,6 +108,19 @@ interface network {
         permanent-resolver-failure,
     }
 
+    /// Attempts to extract a network-related `error-code` from the stream
+    /// `error` provided.
+    ///
+    /// Stream operations which return `stream-error::last-operation-failed`
+    /// have a payload with more information about the operation that failed.
+    /// This payload can be passed through to this function to see if there's
+    /// network-related information about the error to return.
+    ///
+    /// Note that this function is fallible because not all stream-related
+    /// errors are network-related errors.
+    @unstable(feature = network-error-code)
+    network-error-code: func(err: borrow<error>) -> option<error-code>;
+
     @since(version = 0.2.0)
     enum ip-address-family {
         /// Similar to `AF_INET` in POSIX.
diff --git a/wit-0.3.0-draft/deps/sockets/tcp.wit b/wit-0.3.0-draft/deps/sockets/tcp.wit
index 3a86f5e..b4cd87f 100644
--- a/wit-0.3.0-draft/deps/sockets/tcp.wit
+++ b/wit-0.3.0-draft/deps/sockets/tcp.wit
@@ -353,7 +353,7 @@ interface tcp {
         /// See <https://github.com/WebAssembly/wasi-sockets/blob/main/TcpSocketOperationalSemantics.md#pollable-readiness>
         /// for more information.
         ///
-        /// Note: this function is here for WASI Preview2 only.
+        /// Note: this function is here for WASI 0.2 only.
         /// It's planned to be removed when `future` is natively supported in Preview3.
         @since(version = 0.2.0)
         subscribe: func() -> pollable;
diff --git a/wit-0.3.0-draft/deps/sockets/udp.wit b/wit-0.3.0-draft/deps/sockets/udp.wit
index 357d1d5..01901ca 100644
--- a/wit-0.3.0-draft/deps/sockets/udp.wit
+++ b/wit-0.3.0-draft/deps/sockets/udp.wit
@@ -184,7 +184,7 @@ interface udp {
 
         /// Create a `pollable` which will resolve once the socket is ready for I/O.
         ///
-        /// Note: this function is here for WASI Preview2 only.
+        /// Note: this function is here for WASI 0.2 only.
         /// It's planned to be removed when `future` is natively supported in Preview3.
         @since(version = 0.2.0)
         subscribe: func() -> pollable;
@@ -220,7 +220,7 @@ interface udp {
 
         /// Create a `pollable` which will resolve once the stream is ready to receive again.
         ///
-        /// Note: this function is here for WASI Preview2 only.
+        /// Note: this function is here for WASI 0.2 only.
         /// It's planned to be removed when `future` is natively supported in Preview3.
         @since(version = 0.2.0)
         subscribe: func() -> pollable;
@@ -280,7 +280,7 @@ interface udp {
         
         /// Create a `pollable` which will resolve once the stream is ready to send again.
         ///
-        /// Note: this function is here for WASI Preview2 only.
+        /// Note: this function is here for WASI 0.2 only.
         /// It's planned to be removed when `future` is natively supported in Preview3.
         @since(version = 0.2.0)
         subscribe: func() -> pollable;
diff --git a/wit-0.3.0-draft/proxy.wit b/wit-0.3.0-draft/proxy.wit
index f391992..a0f659e 100644
--- a/wit-0.3.0-draft/proxy.wit
+++ b/wit-0.3.0-draft/proxy.wit
@@ -4,7 +4,7 @@ package wasi:http@0.3.0-draft;
 /// It is intended to be `include`d in other worlds.
 world imports {
   /// HTTP proxies have access to time and randomness.
-  include wasi:clocks/imports@0.2.3;
+  include wasi:clocks/imports@0.3.0;
   import wasi:random/random@0.2.3;
 
   /// Proxies have standard output and error streams which are expected to
diff --git a/wit-0.3.0-draft/types.wit b/wit-0.3.0-draft/types.wit
index f2ed3a5..8521302 100644
--- a/wit-0.3.0-draft/types.wit
+++ b/wit-0.3.0-draft/types.wit
@@ -1,7 +1,7 @@
 /// This interface defines all of the types and methods for implementing HTTP
 /// Requests and Responses, as well as their headers, trailers, and bodies.
 interface types {
-  use wasi:clocks/monotonic-clock@0.2.3.{duration};
+  use wasi:clocks/monotonic-clock@0.3.0.{duration};
   use wasi:io/error@0.2.3.{error};
 
   /// This type corresponds to HTTP standard Methods.

From e9e978cd33c45593510c330f44be668ad5fd9b7e Mon Sep 17 00:00:00 2001
From: Roman Volosatovs <rvolosatovs@riseup.net>
Date: Fri, 17 Jan 2025 12:09:16 +0100
Subject: [PATCH 3/3] chore(0.3): update `wasi:random` to `0.3.0`

Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
---
 wit-0.3.0-draft/deps.lock                     |  6 ++++
 wit-0.3.0-draft/deps.toml                     |  3 +-
 .../deps/random-0-3-0/insecure-seed.wit       | 27 +++++++++++++++++
 .../deps/random-0-3-0/insecure.wit            | 25 ++++++++++++++++
 wit-0.3.0-draft/deps/random-0-3-0/random.wit  | 29 +++++++++++++++++++
 wit-0.3.0-draft/deps/random-0-3-0/world.wit   | 13 +++++++++
 wit-0.3.0-draft/proxy.wit                     |  2 +-
 7 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 wit-0.3.0-draft/deps/random-0-3-0/insecure-seed.wit
 create mode 100644 wit-0.3.0-draft/deps/random-0-3-0/insecure.wit
 create mode 100644 wit-0.3.0-draft/deps/random-0-3-0/random.wit
 create mode 100644 wit-0.3.0-draft/deps/random-0-3-0/world.wit

diff --git a/wit-0.3.0-draft/deps.lock b/wit-0.3.0-draft/deps.lock
index 184d09c..43e3f8c 100644
--- a/wit-0.3.0-draft/deps.lock
+++ b/wit-0.3.0-draft/deps.lock
@@ -26,6 +26,12 @@ sha512 = "7a95f964c13da52611141acd89bc8876226497f128e99dd176a4270c5b5efbd8cc847b
 sha256 = "dd0c91e7125172eb8fd4568e15ad9fc7305643015e6ece4396c3cc5e8c2bf79a"
 sha512 = "d1ca2e7b0616a94a3b39d1b9450bb3fb595b01fd94a8626ad75433038dde40988ecb41ab93a374d569ab72163af3b30038d7bfc3499b9c07193181f4f1d9292a"
 
+[random-0-3-0]
+url = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz"
+subdir = "wit-0.3.0-draft"
+sha256 = "f14fa20b4a1ab8e93adc6aa81175b886c951a75ea8fe36f94902bd31c3b709da"
+sha512 = "fea98fb83f997e436457652a9f11b911fabd7a904fcce52fc8dcd5c5746609d6329b3992570c12d04b6b0e09427674805f4a563cde90a4af014fe0915178e189"
+
 [sockets]
 sha256 = "2bc0f65a8046207ee3330ad7d63f6fafeafd4cc0ea4084f081bd5e4f7b177e74"
 sha512 = "3e5490e41547dffa78d52631825d93da8d60f4af0246cbaf97e1ecb879285953a86d5f1f390b10c32f91dd7eaec6f43e625a26b1c92c32a0c86fde428aedaaab"
diff --git a/wit-0.3.0-draft/deps.toml b/wit-0.3.0-draft/deps.toml
index c0c49cb..772bb1b 100644
--- a/wit-0.3.0-draft/deps.toml
+++ b/wit-0.3.0-draft/deps.toml
@@ -1,2 +1,3 @@
-cli = "https://github.com/WebAssembly/wasi-cli/archive/v0.2.3.tar.gz" # TODO: update to v0.3.0-draft and remove custom clock import
+cli = "https://github.com/WebAssembly/wasi-cli/archive/v0.2.3.tar.gz" # TODO: update to v0.3.0-draft and remove custom clock and random imports
 clocks-0-3-0 = { url = "https://github.com/WebAssembly/wasi-clocks/archive/main.tar.gz", subdir = "wit-0.3.0-draft" }
+random-0-3-0 = { url = "https://github.com/WebAssembly/wasi-random/archive/main.tar.gz", subdir = "wit-0.3.0-draft" }
diff --git a/wit-0.3.0-draft/deps/random-0-3-0/insecure-seed.wit b/wit-0.3.0-draft/deps/random-0-3-0/insecure-seed.wit
new file mode 100644
index 0000000..66a4694
--- /dev/null
+++ b/wit-0.3.0-draft/deps/random-0-3-0/insecure-seed.wit
@@ -0,0 +1,27 @@
+package wasi:random@0.3.0;
+/// The insecure-seed interface for seeding hash-map DoS resistance.
+///
+/// It is intended to be portable at least between Unix-family platforms and
+/// Windows.
+@since(version = 0.2.0)
+interface insecure-seed {
+    /// Return a 128-bit value that may contain a pseudo-random value.
+    ///
+    /// The returned value is not required to be computed from a CSPRNG, and may
+    /// even be entirely deterministic. Host implementations are encouraged to
+    /// provide pseudo-random values to any program exposed to
+    /// attacker-controlled content, to enable DoS protection built into many
+    /// languages' hash-map implementations.
+    ///
+    /// This function is intended to only be called once, by a source language
+    /// to initialize Denial Of Service (DoS) protection in its hash-map
+    /// implementation.
+    ///
+    /// # Expected future evolution
+    ///
+    /// This will likely be changed to a value import, to prevent it from being
+    /// called multiple times and potentially used for purposes other than DoS
+    /// protection.
+    @since(version = 0.2.0)
+    insecure-seed: func() -> tuple<u64, u64>;
+}
diff --git a/wit-0.3.0-draft/deps/random-0-3-0/insecure.wit b/wit-0.3.0-draft/deps/random-0-3-0/insecure.wit
new file mode 100644
index 0000000..7f2b86f
--- /dev/null
+++ b/wit-0.3.0-draft/deps/random-0-3-0/insecure.wit
@@ -0,0 +1,25 @@
+package wasi:random@0.3.0;
+/// The insecure interface for insecure pseudo-random numbers.
+///
+/// It is intended to be portable at least between Unix-family platforms and
+/// Windows.
+@since(version = 0.2.0)
+interface insecure {
+    /// Return `len` insecure pseudo-random bytes.
+    ///
+    /// This function is not cryptographically secure. Do not use it for
+    /// anything related to security.
+    ///
+    /// There are no requirements on the values of the returned bytes, however
+    /// implementations are encouraged to return evenly distributed values with
+    /// a long period.
+    @since(version = 0.2.0)
+    get-insecure-random-bytes: func(len: u64) -> list<u8>;
+
+    /// Return an insecure pseudo-random `u64` value.
+    ///
+    /// This function returns the same type of pseudo-random data as
+    /// `get-insecure-random-bytes`, represented as a `u64`.
+    @since(version = 0.2.0)
+    get-insecure-random-u64: func() -> u64;
+}
diff --git a/wit-0.3.0-draft/deps/random-0-3-0/random.wit b/wit-0.3.0-draft/deps/random-0-3-0/random.wit
new file mode 100644
index 0000000..5edfa2b
--- /dev/null
+++ b/wit-0.3.0-draft/deps/random-0-3-0/random.wit
@@ -0,0 +1,29 @@
+package wasi:random@0.3.0;
+/// WASI Random is a random data API.
+///
+/// It is intended to be portable at least between Unix-family platforms and
+/// Windows.
+@since(version = 0.2.0)
+interface random {
+    /// Return `len` cryptographically-secure random or pseudo-random bytes.
+    ///
+    /// This function must produce data at least as cryptographically secure and
+    /// fast as an adequately seeded cryptographically-secure pseudo-random
+    /// number generator (CSPRNG). It must not block, from the perspective of
+    /// the calling program, under any circumstances, including on the first
+    /// request and on requests for numbers of bytes. The returned data must
+    /// always be unpredictable.
+    ///
+    /// This function must always return fresh data. Deterministic environments
+    /// must omit this function, rather than implementing it with deterministic
+    /// data.
+    @since(version = 0.2.0)
+    get-random-bytes: func(len: u64) -> list<u8>;
+
+    /// Return a cryptographically-secure random or pseudo-random `u64` value.
+    ///
+    /// This function returns the same type of data as `get-random-bytes`,
+    /// represented as a `u64`.
+    @since(version = 0.2.0)
+    get-random-u64: func() -> u64;
+}
diff --git a/wit-0.3.0-draft/deps/random-0-3-0/world.wit b/wit-0.3.0-draft/deps/random-0-3-0/world.wit
new file mode 100644
index 0000000..d01746d
--- /dev/null
+++ b/wit-0.3.0-draft/deps/random-0-3-0/world.wit
@@ -0,0 +1,13 @@
+package wasi:random@0.3.0;
+
+@since(version = 0.2.0)
+world imports {
+    @since(version = 0.2.0)
+    import random;
+
+    @since(version = 0.2.0)
+    import insecure;
+
+    @since(version = 0.2.0)
+    import insecure-seed;
+}
diff --git a/wit-0.3.0-draft/proxy.wit b/wit-0.3.0-draft/proxy.wit
index a0f659e..8e10fd7 100644
--- a/wit-0.3.0-draft/proxy.wit
+++ b/wit-0.3.0-draft/proxy.wit
@@ -5,7 +5,7 @@ package wasi:http@0.3.0-draft;
 world imports {
   /// HTTP proxies have access to time and randomness.
   include wasi:clocks/imports@0.3.0;
-  import wasi:random/random@0.2.3;
+  import wasi:random/random@0.3.0;
 
   /// Proxies have standard output and error streams which are expected to
   /// terminate in a developer-facing console provided by the host.