Expand description
Profile B (#506): preview1 WasiDir/WasiFile backed by a Subject-scoped
hyprstream_vfs::Mount.
This runs a WASI guest whose ENTIRE filesystem is a virtual VFS [Mount] (not the
host). It backs a WASI preopen with an arbitrary async Mount via the legacy
preview1 [wasi_common::WasiDir] / [wasi_common::WasiFile] trait objects,
NOT preview2’s wasmtime-wasi (whose preopen only takes a concrete
cap_std::fs::Dir). See the crate README for the preview1-vs-preview2 rationale.
§The ONE policy enforcement point (MAC invariant)
The MountDir/MountFile adapters do NOT authorize. They thread the
Sandbox-bound Subject into every Mount call and nothing more. The
[Mount] is the single PEP (a future S2/#568 label check lands THERE). There
is deliberately NO parallel capability/permission check in this layer — adding
one would create a second, divergent policy surface. The Subject is fixed at
construction (MountDir { mount, subject, .. }); the guest can neither name nor
forge an identity, exactly mirroring the Profile-A proxy seam.
§Async/sync bridge
wasi-common’s WasiDir/WasiFile are async traits, but we link them via
wasi_common::sync::add_to_linker whose wiggle integration uses the block_on
executor: it expects every async fn to poll to Ready essentially immediately
(no real async suspension). The [Mount] is genuinely async, so each adapter
method drives the Mount future to completion on a dedicated current-thread
tokio [Runtime] via rt.block_on(...). The WasiSandbox is driven from a
plain (non-async) thread (like Profile A), so this nested block_on is NOT on a
tokio worker and does not panic. From the wiggle executor’s view the adapter
future resolves immediately — the contract holds.
§Path model
Mount is fid-based (walk -> open -> read/write). WASI is path-based relative
to a preopen dir. MountDir holds a base path (the preopen root, e.g. the
Mount root) and, per open_file/get_path_filestat, splits the guest-supplied
relative path into components, walks the Mount, then opens/reads/writes. We
reject .. components (no upward traversal past the preopen) — the WASI ABI
also forbids it, but we enforce it here too as defense in depth (this is a path
shape check, NOT an authz check; authz stays in the Mount).