mirror of
https://github.com/marcoallegretti/WEFT_OS.git
synced 2026-11-24 09:13:59 +00:00
weft-appd marked a session Running and broadcast APP_READY as soon as the runtime printed READY, then started weft-app-shell with its output discarded and never watched it. A session with no UI, a UI host that failed to start, or one that crashed was still reported running. Early failure paths skipped parts of the cleanup: the image mount was not unmounted, the compositor association was not released, and the abort sender leaked on spawn failure. Readiness was any stdout line equal to READY, which a Wasm guest (inherited stdout) or a page (window.alert writes to the app shell's stdout) could print. Now a session becomes Running only after the runtime and then the app shell report readiness, each within 30 s; WEFT_APP_SHELL_BIN is required and checked before anything starts. After that, the runtime exiting, the app shell exiting or a terminate request ends the session. Every exit path goes through one teardown that kills both children, releases the compositor association, unmounts the image, stops the file portal and broadcasts Stopped. Readiness uses a per-session random token passed to both children in WEFT_READY_TOKEN. weft-runtime and weft-app-shell print READY <token>, and appd accepts only a line ending with it; guests receive only the variables the runtime names and pages cannot read the host environment. Child output is read in bounded, lossily decoded lines, so invalid UTF-8 or long lines no longer stop the readers. Compositor notifications use try_send so a disconnected compositor cannot stall teardown, and all children are killed if the supervisor is dropped. The IPC relay is not yet owned by the session, and children are killed without a graceful period. Validation: - cargo test -p weft-appd (43 passed); new tests cover: not ready until the app shell is ready, runtime exit before that, no app shell configured (runtime never starts), app shell exit ending a running session with the runtime process gone, and READY lines without the token; they fail against the previous supervisor - end to end with weft-compositor (nested), weft-appd, weft-runtime (wasmtime-runtime) and weft-app-shell: the Counter demo reaches APP_READY and is on screen; a page that prints a READY line through alert and never loads is stopped after 30 s without APP_READY; terminate leaves no child processes - clippy -D warnings and fmt --check for weft-appd and weft-runtime
100 lines
4.9 KiB
Markdown
100 lines
4.9 KiB
Markdown
# WEFT OS
|
||
|
||
WEFT OS is a Wayland compositor and application runtime where every app is a WebAssembly component rendered in an isolated Servo WebView. No capability is granted by default; all resource access is declared in a per-app manifest and enforced at runtime.
|
||
|
||
## What is implemented
|
||
|
||
**Compositor** — `weft-compositor` is a Smithay-based Wayland compositor with DRM/KMS and winit backends. It implements the `zweft-shell-unstable-v1` protocol extension, which typed shell slots (panel, application) register against.
|
||
|
||
**System shell** — `weft-servo-shell` embeds Servo (feature-gated, `--features servo-embed`) and renders `system-ui.html` as a Wayland panel. Without `servo-embed`, the binary exits with an error instead of rendering. Navigation gestures from the compositor are forwarded to `weft-appd` over WebSocket.
|
||
|
||
**App shell** — `weft-app-shell` is a per-process Servo host for application WebViews. It resolves `weft-app://<id>/ui/index.html`, injects a `weftIpc` WebSocket bridge into the page, and registers with the compositor as an application surface. Also feature-gated behind `servo-embed`.
|
||
|
||
**App daemon** — `weft-appd` supervises sessions: spawns `weft-runtime`, waits for its READY, spawns `weft-app-shell` and reports the session running only after the app shell's READY, manages the per-session IPC relay between the Wasm component and the WebView, and handles session teardown. Wraps processes in systemd scopes (`CPUQuota=200%`, `MemoryMax=512M`) when available.
|
||
|
||
**Runtime** — `weft-runtime` runs WASI Component Model binaries under Wasmtime 30 (`--features wasmtime-runtime`). Provides `weft:app/notify`, `weft:app/ipc`, `weft:app/fetch`, `weft:app/notifications`, and `weft:app/clipboard` host imports. Preopens filesystem paths according to declared capabilities.
|
||
|
||
**Package management** — `weft-pack` handles check, sign, verify, install, uninstall, list, build-image (EROFS dm-verity), and info. Validates capability strings at check time.
|
||
|
||
**File portal** — `weft-file-portal` is a per-session file proxy with a path allowlist and `..` blocking.
|
||
|
||
**Mount helper** — `weft-mount-helper` is a setuid helper for EROFS dm-verity mount/umount via `veritysetup`.
|
||
|
||
**Demo apps** — `examples/org.weft.demo.counter` and `examples/org.weft.demo.notes` are pre-built Wasm Component binaries (`wasm32-wasip2`, wit-bindgen 0.53) with HTML UIs, signed with a committed demo keypair.
|
||
|
||
## Repository layout
|
||
|
||
```
|
||
crates/ Rust workspace members
|
||
examples/ Demo app packages (wasm32-wasip2, not workspace members)
|
||
keys/ Demo Ed25519 keypair
|
||
protocol/ zweft-shell-unstable-v1 Wayland protocol XML
|
||
infra/
|
||
nixos/ NixOS VM configuration and package derivations
|
||
scripts/ check.ps1, check.sh
|
||
shell/ system-ui.html, weft-ui-kit.js
|
||
systemd/ service unit files
|
||
vm/ build.sh, run.sh (QEMU)
|
||
docs/
|
||
architecture.md Component map, IPC, capability table, env vars
|
||
security.md Capability model, process isolation, SpiderMonkey security boundary
|
||
building.md Build instructions for all targets
|
||
```
|
||
|
||
## Building
|
||
|
||
Linux system packages required (openSUSE):
|
||
|
||
```sh
|
||
sudo zypper install -y \
|
||
libwayland-devel libxkbcommon-devel libglvnd-devel \
|
||
libgbm-devel libdrm-devel libinput-devel seatd-devel libudev-devel \
|
||
systemd-devel pkg-config clang cmake python3
|
||
```
|
||
|
||
Build non-Servo crates:
|
||
|
||
```sh
|
||
cargo build --workspace --exclude weft-servo-shell --exclude weft-app-shell
|
||
```
|
||
|
||
Build Linux-only crates (no Servo):
|
||
|
||
```sh
|
||
cargo build -p weft-compositor -p weft-servo-shell -p weft-app-shell
|
||
```
|
||
|
||
Build with Servo embedding (30–60 min, requires clang + python3):
|
||
|
||
```sh
|
||
cargo build -p weft-servo-shell --features servo-embed
|
||
cargo build -p weft-app-shell --features servo-embed
|
||
```
|
||
|
||
See `docs/building.md` for full instructions including Wasm component builds, NixOS VM, and signing.
|
||
|
||
## CI
|
||
|
||
Three jobs on every push and pull request:
|
||
|
||
- `cross-platform` — fmt, clippy, tests on Ubuntu and Windows
|
||
- `linux-only` — clippy and tests for compositor and shell crates
|
||
- `servo-embed-linux` — `cargo check --features servo-embed` for both servo crates
|
||
|
||
## Security
|
||
|
||
See `docs/security.md`. Key points:
|
||
|
||
- Capabilities declared in `wapp.toml`, validated at install, enforced at runtime
|
||
- Per-app OS processes with systemd cgroup limits
|
||
- WASI filesystem isolation via preopened directories
|
||
- Ed25519 package signing; optional EROFS dm-verity
|
||
- Optional seccomp BPF blocklist in `weft-runtime`
|
||
- SpiderMonkey is not sandbox-isolated beyond process-level isolation (see `docs/security.md`)
|
||
|
||
## Servo fork
|
||
|
||
- Servo: `https://github.com/marcoallegretti/servo` at `f0bb1aaf`, pinned by revision
|
||
- Stylo: `https://github.com/marcoallegretti/stylo` at `f1ba4969`, through the root `[patch]`
|
||
- Patches: `backdrop-filter` parsing (Stylo) and rendering (Servo)
|
||
- See `crates/weft-servo-shell/SERVO_PIN.md` for Servo integration status and known limitations
|