Skip to main content

Module vfs

Module vfs 

Source
Expand description

VFS capability backing for the sandbox (#483 P2 — REAL, not a sketch).

This is the proof the sandbox capability is real: a guest vfs_* call is bridged, synchronously, to the canonical hyprstream_vfs [Namespace] through the [spawn_vfs_proxy] seam, and is scoped to the Subject the Sandbox is bound to — never to any identity the guest supplies.

§Wiring

  guest env::vfs_cat(path)        -> VfsOp::Cat  { path }   -> Namespace::cat
  guest env::vfs_ls(path)         -> VfsOp::Ls   { path }   -> Namespace::ls
  guest env::vfs_echo(path,data)  -> VfsOp::Echo { path, data } -> Namespace::echo
  guest env::vfs_ctl(path,cmd)    -> VfsOp::Ctl  { path, cmd }  -> Namespace::ctl

The host fns (in build_linker) read caller.data().subject and submit a [VfsRequest] whose op carries the Subject IMPLICITLY: the proxy task is spawn_vfs_proxy(ns, subject) — i.e. each proxy is pinned to ONE Subject at spawn time, so every request through it is executed as that Subject. The guest has no way to name or forge an identity.

§Why path-based ops, not the P1 fid-based sketch

The P1 vfs.rs sketched a fid-based VfsCapability (walk/open/read/write/…), mirroring [hyprstream_vfs::Mount]. The CANONICAL sync seam, however, is the proxy’s [VfsOp] enum, which is PATH-based (Cat/Ls/Echo/Ctl) and DELIBERATELY excludes mount/bind/unmount (its security invariant: scripts cannot remount). We back the capability against that real seam rather than the sketch, so the #483 capability is exactly the proxy’s bounded surface.

§Sync-over-async bridge

wasm host fns are synchronous; the Namespace is async. The proxy ([spawn_vfs_proxy]) bridges: it returns a tokio::sync::mpsc::Sender<VfsRequest> and each [VfsRequest] carries a std::sync::mpsc::SyncSender reply channel. A host fn does blocking_send of the request, then blocks on the std reply receiver — never touching the async runtime directly. (blocking_send requires we are NOT on a tokio worker thread; the Sandbox is driven from a plain thread, and the proxy task runs on a separate runtime — see the tests.)

Structs§

VfsProxyHandle
A handle to a Subject-scoped VFS proxy.
VfsReply
Result of a VFS op exposed to the guest: a status tag + a UTF-8 payload.