Files
sausage/userland/cwd-init
surma 57a47b069e host: process table, shell, coreutils and harness (T8, T9)
T8: sausage:process WIT (spawn, wait, kill), one store per process over the
shared root, /proc/processes, /run, pipeline and cancellation groups, Exec.
brush and 78 uutils commands; the shared cwd-init object sets the cwd from PWD
and keeps numeric exit codes. The corpus matches native bash.

T9: V8 (deno_core) runs pi-durable, pi-ai and chord; SQLite storage in
<dir>/host/harness.sqlite (WAL, synchronous=FULL); file tools on the VFS, bash
through Exec; resumes after SIGKILL.
2026-11-06 16:34:34 +00:00
..

Shared WASI startup object

This constructor adopts PWD before Rust calls main. The process table supplies PWD from the spawn request, not from the host environment. The constructor exits with status 1 if the directory does not exist. It preserves one / preopen and the whole-world view.

Build the object before you build userland:

nix develop -c nu --no-config-file userland/cwd-init/build.nu

Run workspace Cargo commands from userland/ so Cargo loads .cargo/config.toml. Its rustflags request the startup object. The linker wrapper resolves the object path independently of each crate's directory. The builder must use the same rustflags, wrapper, and object for agent programs.

The object also replaces libc's success/failure exit conversion with standard wasi:cli/exit.exit-with-code. Rust std on this toolchain does not use that interface directly. The host registers this gated standard function. The linker places the object before libc to resolve _Exit and _exit. Numeric exit codes use the usual low eight bits.

probe/ uses normal Rust APIs without startup code. It reads relative and absolute files or calls std::process::exit with its first argument.

The standard initial-cwd import is preferable to PWD. The current Rust component does not declare that import. An upstream wasi-libc fix must declare it in the component type and initialize the local cwd before main. The fix must initialize cwd even when the linker omits chdir from program code.