Mova0.6 pre-release

vfs — file system for the execution sandbox

Prototype. This is an experiment beside Mova, not part of its core yet: it works, but its interfaces and data may change at any time.

Goal (Context, layers and memory): guest programs, including untrusted and generated code, see only virtual files in memory. Only an approved result goes outside. Every SLM (small language model) lesson starts from a clean snapshot restored in constant time. WASM/WASI guests reach the same file system through wasi-host.

A crate without dependencies, std only. Three implementations of the FileSystem trait:

typewhat it iswhen
Vfsin-memory tree with snapshots, limits, a journal and a virtual clockdefault: untrusted and generated code (--fs mem)
DirFsa real directory, the root is the boundary (like chroot)working with operator data (--fs dir:<dir>)
RealFsunrestricted real FSexplicit only (--fs real)

Alongside it — wasi-host: runs wasm32-wasip1 modules (like mlab.wasm), and their WASI calls go into the same Vfs (see "WASI host" below).

What Vfs can do

DirFs — a real directory with a confined root

Tests and negative controls

cargo test covers root escape (.., /../, links pointing outside, loops, absolute host paths), limits with their error texts and unchanged state after a violation, snapshot → changes → byte-exact restore, isolation of copies and parallel sandboxes from one snapshot, POSIX semantics, the journal and its cap, import and export, and DirFs with outside and dangling links.

A gate that cannot show red is not a gate. Vfs::fault and DirFs::fault deliberately break the implementation (ClampDotDot: .. above the root silently stays at the root; NoLimits; RestoreForgetsClock: restore does not roll back the clock; NoConfine: DirFs without the canonical path check), and the test gates_green_and_negative_controls_red requires green without the fault and red with it.

cargo run --release --example snapbench times snapshot, restore, a lesson (restore + write one file), the first append to a shared large file and a full dump(). A lesson costs in proportion to the width of the directories on its path, not to the volume of the tree; appending to a shared large file copies its contents once per snapshot.

WASI host (wasi-host)

Runs wasm32-wasip1 modules in a sandbox. For the emulated code it looks like a real machine, for us it is fully reproducible.

cd mlab && cargo build --release --target wasm32-wasip1        # mlab.wasm
cd ../wasi-host && cargo build --release
../target/release/wasi-run [--fs-import DIR[:VIRT]]… [--fs-export DIR[:VIRT]]… [--fs-limits …] [--seed N] \
    [--fuel N] [--mem-limit 1G] [--journal j.tsv] [--stats] ../target/wasm32-wasip1/release/mlab.wasm \
    -e "writematrix(magic(4), '/tmp/m.csv'); disp(readdir('/tmp'))" --fs real
cargo run --release --example mlab_gate -- ../mlab/data/suite-fs.txt [--vm]    # gate with per-scenario timing

--fs real in the guest means: the guest's std::fs → WASI calls → the host's Vfs. Without it, mlab in the guest uses its own Vfs inside the module, i.e. a double sandbox.

WASI gate (cargo test in wasi-host)

Limits

Licence

This page in Markdown https://md.mova.elamur.ai/free/en/docs/vfs/