Vendor the cap-primitives crate within the wasmtime-wasi crate - #14219
Open
alexcrichton wants to merge 34 commits into
Open
Vendor the cap-primitives crate within the wasmtime-wasi crate#14219alexcrichton wants to merge 34 commits into
wasmtime-wasi crate#14219alexcrichton wants to merge 34 commits into
Conversation
Copy the entire contents of this crate into `crates/wasi/src/filesystem/primitives` for future modifications to get it building.
* Add necessary dependencies * Adjust imports
* Rename `cap-primitives to `public-cap-primitives` * Move public-facing dependencies to `public-cap-primitives` * Move internal dependencies to `crate::filesystem::primitives`
This isn't something used in Wasmtime so it's all dead code
These are related to nightly features that cap-primitives optionally used, and Wasmtime won't be using any nightly features from Wasmtime.
Not going to be used by Wasmtime.
* `unix_file_vectored_at` * `io_error_more` * `io_error_uncategorized`
Will work on handling these later.
Much of cap-primitives isn't used by Wasmtime, so this commit goes through and resolves all rustc warnings and deletes a whole bunch of dead code.
This commit gets all relevant tests from cap-std compiling against the vendored version of cap-primitives. The goal here is to retain as much test coverage as possible so tests are modified pretty heavily to the new API structure where `cap-primitives` is effectively used instead of `cap-std`'s API surface area. This includes lots of various hlepers and such to keep tests relatively terse and such.
This commit resolves a debug-mode-only panic about an overflow which happens internally within cap-std.
Not needed from the cap-primitives vendoring
Also remove unused cap-fs-ext dependency
prtest:full
fitzgen
removed their request for review
August 27, 2026 22:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR is a series of commits which vendors the
cap-primitivescrate, or what Wasmtime needs, within thewasmtime-wasicrate. This is done as an acknowledgement of the current maintenance and state of the cap-std repository and project where having a security-critical dependency external of Wasmtime itself is becoming more and more of a burden. This was discussed in today's Wasmtime meeting and had unanimous agreement about this transition. The Bytecode Alliance TSC will, I believe, ask if anyone would like to end up maintaining the cap-std crates in parallel to this but our decision was that regardless of that outcome it's still best to vendor the code here within Wasmtime itself.This PR is structured as a sequential list of commits which tell a story of sorts of how this was vendored. This is a very large change so the intention is to be as methodical and "obviously correct" as possible. The
cap-primitivescrate contains quite a bit of functionality which Wasmtime doesn't need and can thus be deleted. Additionally the tests forcap-primitivesare all written against thecap-stdlayer which has a differently-shaped API surface area. To that end the major adjustments from cap-primitives are:fs,rustix, andwindowssubmodules are vendored here.cap-primitives, added towasmtime-wasi, were subsequently removed as they were pretty light dependencies.The end result is intended to be a source-wise pretty much line-for-line vendor of cap-primitives. The tests are spiritually all ported over but greatly differ at the source level due to API differences. This PR is intended to be proactively backported to supported release branches of Wasmtime to avoid the need to patch external code should future security issues arise with the
wasi:filesystemimplementation. This includes Wasmtime 36, 47, and 48. To this end the switch-over here was audited to ensure that the public API of thewasmtime-wasicrate does not change as a result of this commit and is thus semver-compatible to backport. This means that there's a single remaining vestigal use of thecap-primitivescrate to simply reexport theSystemTimeSpectype at the root of thewasmtime-wasicrate. This isn't actually used anywhere, though, so the only purpose is its reexport. This reexport will be deleted onmainafter this PR, but will not be deleted in backports.The backport situation for Wasmtime 36 and 47 is going to be more complicated because they do not contain #13872. Despite that I think we'll still be able to basically pull it off, but I've not yet proven this out.