From 964ef978c24fd86e43b8451e7fe23d15a67a1a59 Mon Sep 17 00:00:00 2001 From: Surma Date: Fri, 6 Nov 2026 15:16:18 +0000 Subject: [PATCH] v3: world directory layout (world/ is the VFS root, host/ is host state) --- host/src/world.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/host/src/world.rs b/host/src/world.rs index 929cdbf..9756a36 100644 --- a/host/src/world.rs +++ b/host/src/world.rs @@ -1,18 +1,32 @@ -//! A world folder and the one virtual root that host code and guests share. +//! A world directory and the one virtual root that host code and guests share. +//! +//! Layout of a world directory: +//! - `world/`: the virtual root `/` that every guest sees. Agents change everything in it. +//! - `host/`: host state outside the sandbox (harness storage, later the vault). No guest sees it. use sausage_vfs::{Host, Layer, Mounts, Process}; -use std::{path::Path, sync::Arc}; +use std::{ + path::{Path, PathBuf}, + sync::Arc, +}; /// An open world. `root` is the filesystem every guest sees as `/`; host code (the harness's file /// tools) reads and writes through the same layer, so both always see the same files. pub struct World { pub root: Arc, + /// The host state folder, `/host`. + pub host_dir: PathBuf, } impl World { - /// Open the world folder at `path`. The process table adds more mounts (`/proc`, `/run`). - pub fn open(path: &Path) -> anyhow::Result { + /// Open (and create if missing) the world directory `dir`. The process table adds more mounts + /// (`/proc`, `/run`). + pub fn open(dir: &Path) -> anyhow::Result { + let root_dir = dir.join("world"); + let host_dir = dir.join("host"); + std::fs::create_dir_all(&root_dir)?; + std::fs::create_dir_all(&host_dir)?; let mut mounts = Mounts::default(); - mounts.mount("/", Arc::new(Host::new(path, Process::default())?), false); - Ok(World { root: Arc::new(mounts) }) + mounts.mount("/", Arc::new(Host::new(&root_dir, Process::default())?), false); + Ok(World { root: Arc::new(mounts), host_dir }) } }