Stream: git-wasmtime

Topic: wasmtime / PR #15167 wasi: retain embedder owners for fil...


view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:32):

lthibault requested pchickey for a review on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:32):

lthibault opened PR #15167 from wetware:lthibault/pasted-text-file-v2 to bytecodealliance:main:

Why: embedders need to bound active filesystem work and retain its backing
content. A native worker can outlive its initiating future, descriptor, or Store.
An idle handle can still access backing content after active work ends. Existing
filesystem APIs do not let embedders attach owners to these independent lifetimes.

This adds two opaque owners:

Both are needed for is_same_object(A, B): A admits the operation, while the
worker must retain B's backing owner after B's descriptor disappears. link_at
and rename_at have the same requirement.

Prior discussion: filesystem operation and native handle lifecycle hooks.

Compatibility

File.file and Dir.dir change from Arc<std::fs::File> to
Arc<FilesystemHandle>. Typed raw-Arc uses and native-file trait bounds can
require changes. Borrowed methods remain available through Deref; try_clone
now returns the owner-preserving wrapper. Constructors accept raw files, though
explicit .into() calls can need type annotations. RELEASES.md records the
break. Guest WIT interfaces do not change.

A descriptor sidecar cannot follow escaped raw-Arc clones. An admission hook
cannot retain idle handles or B's independent owner. Private fields would also
break callers; a registry would add tracking machinery. Explicit raw-file or
OS-handle duplication remains the embedder's responsibility.

Validation

Tests cover cancellation, native worker unwinding, child/result handoff,
secondary descriptors, idle duplicates, directory iterators, and terminal P3
streams while the Store remains alive. Native-worker gates establish ordering;
tests do not infer completion from sleeps.

On macOS arm64 with Rust 1.99.1, cargo test -p wasmtime-wasi --locked
passed 171 unit, 227 integration, and 54 documentation tests. Three existing
tests were ignored. P1 and P3-only filesystem suites passed 136 and 145 tests.
WASI all-target Clippy passed with warnings denied; changed tests pass Rustfmt.

All nine negative controls made their targeted test fail. The passing suites ran
after restoring those mutations. Linux, Windows, the full repository CI matrix,
and performance overhead remain unvalidated.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:32):

lthibault removed the review request for wasmtime-wasi-reviewers from PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:32):

lthibault requested wasmtime-wasi-reviewers for a review on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:32):

lthibault requested wasmtime-core-reviewers for a review on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:33):

lthibault removed the review request for wasmtime-default-reviewers from PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:33):

lthibault requested alexcrichton for a review on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:33):

lthibault requested wasmtime-default-reviewers for a review on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 17:56):

pchickey commented on PR #15167:

This PR doesn't appear to comply with our policy on tool-generated content, and requires additional justification for why it is valuable enough to the project for us to review it. Please see our developer policy on AI-generated contributions: https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:23):

lthibault commented on PR #15167:

Thanks, Patrick. I appreciate the concern about review cost, and have previously familiarized myself with the policy.

Before opening this PR, I looked into the existing filesystem lifecycle mechanisms and prior discussions, then raised the proposed API on Zulip to get design feedback. I didn't receive a response, so I opened the PR hoping to make the proposal concrete.

The motivating problem is that an embedder (Wetware) needs to account for native filesystem work (wetware/ww#713) and backing resources (wetware/ww#266) independently of guest lifetimes:

These are distinct lifetimes. In particular, operations involving multiple descriptors (e.g. is_same_object, rename_at) demonstrate why tracking only the initiating operation or descriptor is insufficient.

The patch implements both contracts and includes regression tests for the relevant cancellation and ownership boundaries.

I recognize this is a substantial diff, and I'm happy to narrow or split it if that would make review more manageable. I'm also open to taking a different approach if there's a better fit for Wasmtime's embedder API.

Ultimately, I'm just trying to move the discussion forward and would welcome your thoughts on the right design. If I've overlooked or under-delivered on any part of the AI tool policy, I'm ofc happy to correct that! :)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:23):

lthibault deleted a comment on PR #15167:

Thanks, Patrick. I appreciate the concern about review cost, and have previously familiarized myself with the policy.

Before opening this PR, I looked into the existing filesystem lifecycle mechanisms and prior discussions, then raised the proposed API on Zulip to get design feedback. I didn't receive a response, so I opened the PR hoping to make the proposal concrete.

The motivating problem is that an embedder (Wetware) needs to account for native filesystem work (wetware/ww#713) and backing resources (wetware/ww#266) independently of guest lifetimes:

These are distinct lifetimes. In particular, operations involving multiple descriptors (e.g. is_same_object, rename_at) demonstrate why tracking only the initiating operation or descriptor is insufficient.

The patch implements both contracts and includes regression tests for the relevant cancellation and ownership boundaries.

I recognize this is a substantial diff, and I'm happy to narrow or split it if that would make review more manageable. I'm also open to taking a different approach if there's a better fit for Wasmtime's embedder API.

Ultimately, I'm just trying to move the discussion forward and would welcome your thoughts on the right design. If I've overlooked or under-delivered on any part of the AI tool policy, I'm ofc happy to correct that! :)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 18:24):

lthibault commented on PR #15167:

Thanks, @pchickey. I appreciate the concern about review cost, and have previously familiarized myself with the policy.

Before opening this PR, I looked into the existing filesystem lifecycle mechanisms and prior discussions, then raised the proposed API on Zulip to get design feedback. I didn't receive a response, so I opened the PR hoping to make the proposal concrete.

The motivating problem is that an embedder (Wetware) needs to account for native filesystem work (wetware/ww#713) and backing resources (wetware/ww#266) independently of guest lifetimes:

These are distinct lifetimes. In particular, operations involving multiple descriptors (e.g. is_same_object, rename_at) demonstrate why tracking only the initiating operation or descriptor is insufficient.

The patch implements both contracts and includes regression tests for the relevant cancellation and ownership boundaries.

I recognize this is a substantial diff, and I'm happy to narrow or split it if that would make review more manageable. I'm also open to taking a different approach if there's a better fit for Wasmtime's embedder API.

Ultimately, I'm just trying to move the discussion forward and would welcome your thoughts on the right design. If I've overlooked or under-delivered on any part of the AI tool policy, I'm ofc happy to correct that! :)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 19:19):

pchickey commented on PR #15167:

Thanks, your comment is a much better description and I can understand this PR a lot better from it. I missed that discussion on Zulip, sorry about that. I will review this PR this week and also I want to tag in @dicej because I know he is working on some issues related to these.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 20:03):

lthibault commented on PR #15167:

No worries at all -- I imagine you guys have to deal with quite a few drive-by PRs these days!

Sounds good. Looking forward to discussing in the coming days!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 22:44):

github-actions[bot] added the label wasi on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 05 2026 at 22:44):

github-actions[bot] added the label wasmtime:docs on PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 22:06):

pchickey commented on PR #15167:

So I've looked at this, and also asked two other colleagues who know this code well to look at this to see if I was missing something.

The first issue, an operation on a host resource outliving the store, is a known systemic problem throughout wasmtime-wasi{-http} and broadly speaking we are exploring solutions to it, though it isnt at the top of anyones priority queue right now.

The second issue, I think means that guest resources pointing at some host file descriptor outlives the file descriptor? If there is a specific case this is a bug, we need a minimal reproducable case showing this, to help us understand what exactly the problem is here.

This is 2500 lines of code that nobody on the maintainer team is enthusiastic about reviewing deeper and maintaining based on this PR so far. So, we'd like to ask you to please file an issue with a reproducer about issue number 2, and if you'd like to collaborate with the maintainers on PRs to solve these issues, please submit an agenda item and attend one of our wasmtime project calls to discuss it with us further.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 08:10):

lthibault updated PR #15167.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 08:18):

lthibault edited PR #15167:

Embedders that manage external filesystem content need to retain that content while guest descriptors or native operations still depend on it. They also need to track admitted native work until it finishes, including work that outlives its initiating future or Store. These lifetimes differ: an idle descriptor can still need backing content after an operation releases admission.

This PR proposes optional filesystem operation hooks to support both lifetimes. Descriptors retain hook factories that can own backing content. Admitted operations retain values supplied by those factories until the required native work and resource handoff finish.

Public File.file and Dir.dir have type Arc<std::fs::File>. File::new and Dir::new accept std::fs::File. The proposal preserves these upstream types and guest WIT signatures.

Factories can retain backing content while descriptors are idle. On admission, a factory returns a FilesystemOperation containing the embedder's admission token and any required backing owner. Wasmtime retains that value through native execution, even after the initiating future or Store is destroyed. Secondary operands retain their own factories without a second admission.

Ownership continues through child-result installation or disposal and P3 iterator use. Cancellation does not release ownership required by a running native worker. Terminal file streams release admission while their descriptors retain their factories.

Naked native Arc clones and OS-handle duplicates do not automatically retain backing owners. Embedders must pair extracted native state with an attached descriptor or explicit backing owner. Embedders must dispose of the native state before releasing that owner.

Wetware uses the corresponding Wasmtime 48.0.1 backport at 96e45d8b025aac7a5aea5aa505bd73826996919d. Its consumer migration uses factories that own content generations, prepared descriptor results, and explicit pairs of native state and backing owners. The migration passed 156 selected local tests. The proposal supplies a missing embedder ownership capability. The investigation did not demonstrate premature native-descriptor closure in unmodified upstream Wasmtime.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 08:19):

lthibault commented on PR #15167:

@pchickey Thanks for taking a look, and for checking with your colleagues.

Regarding the second issue, I went back through my reproducers and confirmed that the failures were in the ownership machinery I'd added to my fork, not in upstream Wasmtime. Sorry for the confusion; please disregard that part.

As for the main feature request, I've since simplified the public API changes. In particular, I've eliminated FilesystemHandle and restored the original native file types. The overall diff is still large, mostly because of the tests, so I understand this likely doesn't change your decision. I've pushed the changes anyway, just in case it becomes useful for discussion later.

At any rate, I'm happy to discuss the design at a project meeting before making further changes. I'll look into submitting an agenda item and joining a call.

Thanks again for your consideration, and I look forward to speaking with you and the rest of the team soon!

view this post on Zulip Wasmtime GitHub notifications bot (Nov 19 2026 at 08:25):

lthibault updated PR #15167.


Last updated: Nov 19 2026 at 20:05 UTC