2026-03-10 17:47:06 +00:00
# WEFT OS
2026-03-12 14:41:33 +00:00
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.
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
## What is implemented
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
**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.
2026-03-10 17:47:06 +00:00
fix(shells): paint and present Servo frames and report readiness truthfully
With servo-embed, weft-servo-shell and weft-app-shell did not compile
against the selected Servo revision: the keyboard event shape, key and
mouse action variants, frame readback, shutdown, URL type and window
handle APIs had changed. The frame path never called WebView::paint; the
software path rebuilt its softbuffer surface every frame and read pixels
without painting, and the EGL path presented nothing. weft-app-shell
printed READY right after creating its WebView, before any frame, and its
feature-disabled build printed READY and parked. Servo also disables CSS
Grid by default, which the system UI uses.
Both hosts now build against the selected API. Each frame is painted with
WebView::paint and presented: the software path reads the painted frame
back, presents the context and copies it into a persistent softbuffer
surface; the EGL path presents its window context. Nothing is presented
before Servo's first repaint request. Shutdown drops the WebView and
Servo, whose drop completes the shutdown, and exits the event loop. Both
hosts enable layout_grid_enabled.
weft-app-shell prints READY on the first frame presented after the
document has loaded and Servo reports its rendering settled: on load
completion it requests WebView::take_screenshot, which completes only once
every frame has fired load, render-blocking resources, images and web
fonts are done and the rendering is up to date. Feature-disabled builds of
both hosts exit with an error instead of reporting readiness. weft-appd
does not consume the app shell's READY yet.
tests/frame/check_frame.py runs weft-compositor nested on Xvfb with the
winit backend, starts a host showing tests/frame/reference.html and checks
the presented pixels (four colour quadrants and text). For the app host
the page must be on screen within two seconds of READY; --slow-style
delays a render-blocking stylesheet that reveals the page, so premature
readiness fails.
Validation (Ubuntu 24.04, Mesa 25.2.8 llvmpipe, software path):
- check_frame.py --host system, --host app and --host app --slow-style 3:
5 of 5 runs pass each
- negative fixtures fail: page with red and green swapped; a fake host
printing READY without rendering; a local build printing READY on its
first presented frame (--slow-style 4, 3 of 3)
- cargo clippy -D warnings with and without servo-embed; cargo fmt --check
- unverified: EGL path, DRM, resize, output scale, idle wakeup, input
2026-10-09 01:02:26 +00:00
**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.
2026-03-10 17:47:06 +00:00
fix(appd): resolve each launch to one package and fail closed on images
The runtime, the app shell and grant derivation each searched the
package stores and parsed wapp.toml on their own, so they could use
different roots; the runtime ignored [runtime].module, the image loader
looked for companion files the builder never wrote, and a failed image
mount fell back to the mutable directory install.
weft-appd now resolves a launch once: a verified image wins over a
directory in the same store, and when any image file exists the image
must mount or the launch is refused. The manifest must declare the
requested ID, and both entries must be plain relative paths to regular
files without links. The runtime receives --module and the app shell
--ui; neither looks for the package. Grants come from the same
manifest, and the mount belongs to the session.
The manifest parser and the image file names move to weft-ipc-types,
shared with weft-pack, whose check now applies the same entry rules.
Mapper devices are named after their per-launch mountpoint, so
concurrent sessions no longer collide.
2026-10-09 10:03:40 +00:00
**App shell** — `weft-app-shell` is a per-process Servo host for application WebViews. It shows the UI document `weft-appd` resolved from the package, injects a `weftIpc` WebSocket bridge into the page, and registers with the compositor as an application surface. Also feature-gated behind `servo-embed` .
2026-03-10 17:47:06 +00:00
fix(appd): report sessions running only after the UI host is ready
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
2026-10-09 01:41:09 +00:00
**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.
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
**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.
2026-03-10 17:47:06 +00:00
feat(pack): install and update packages as immutable revisions activated atomically
An installed package could not be updated: install refused it, and
uninstalling and reinstalling it was neither atomic nor safe for running
sessions, which read files from the package directory.
A package is now staged, checked, verified, admitted and flushed. It is
then renamed to an immutable revision named by its content digest,
<store>/.revisions/<id>/<digest>, and activated by one rename of the
link <store>/<id>. A failure or interruption at any point leaves the
previously active revision active, and a failed first installation
leaves nothing installed. The revision active before an update is kept,
and weft-pack rollback makes it active again after checking it against
the owner record. Other revisions are collected by later operations on
the app, unless a session still runs from them. Leftovers of interrupted
operations are collected too.
weft-appd follows the store link only to one of the app's own
revisions. It runs a session from the revision directory and holds a
shared lock on it for the session's lifetime, so an update, rollback or
uninstall never changes or removes the bytes of a running session. A
package directory from before revisions is still read. An update
replaces it in one exchange, and only while no session runs from it.
2026-10-09 17:33:57 +00:00
**Package management** — `weft-pack` handles check, sign, verify, install and update, rollback, uninstall, list, build-image (EROFS dm-verity), and info. Validates capability strings at check time. Installs only packages signed by a trusted key (or explicitly as development content) and binds each app ID to its first publisher. App data is stored apart from packages and survives uninstall.
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
**File portal** — `weft-file-portal` is a per-session file proxy with a path allowlist and `..` blocking.
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
**Mount helper** — `weft-mount-helper` is a setuid helper for EROFS dm-verity mount/umount via `veritysetup` .
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
**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.
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
## Repository layout
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
```
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
2026-03-12 19:45:56 +00:00
security.md Capability model, process isolation, SpiderMonkey security boundary
2026-03-12 14:41:33 +00:00
building.md Build instructions for all targets
```
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
## Building
2026-03-11 11:59:24 +00:00
2026-03-12 19:48:17 +00:00
Linux system packages required (openSUSE):
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
```sh
2026-03-12 19:48:17 +00:00
sudo zypper install -y \
2026-03-12 19:52:34 +00:00
libwayland-devel libxkbcommon-devel libglvnd-devel \
libgbm-devel libdrm-devel libinput-devel seatd-devel libudev-devel \
2026-03-12 19:48:17 +00:00
systemd-devel pkg-config clang cmake python3
2026-03-12 14:41:33 +00:00
```
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
Build non-Servo crates:
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
```sh
cargo build --workspace --exclude weft-servo-shell --exclude weft-app-shell
```
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
Build Linux-only crates (no Servo):
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
```sh
cargo build -p weft-compositor -p weft-servo-shell -p weft-app-shell
```
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
Build with Servo embedding (30– 60 min, requires clang + python3):
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
```sh
cargo build -p weft-servo-shell --features servo-embed
cargo build -p weft-app-shell --features servo-embed
```
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
See `docs/building.md` for full instructions including Wasm component builds, NixOS VM, and signing.
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
## CI
2026-03-10 17:47:06 +00:00
2026-10-09 11:30:01 +00:00
Jobs on every push to `main` and on pull requests:
2026-03-10 17:47:06 +00:00
2026-10-09 08:16:59 +00:00
- `portable` — fmt, clippy and tests for the crates that need no Linux system libraries
2026-03-12 14:41:33 +00:00
- `linux-only` — clippy and tests for compositor and shell crates
fix(runtime): close fetch and preopen gaps in grant enforcement
A component with a host-specific fetch grant could reach another origin
by setting its own Host header, and could inject request lines through
the method string, which ureq writes unvalidated. Fetch now accepts only
standard methods and refuses Host, framing and hop-by-hop headers. Fetch
grants accept canonical DNS names and dotted IPv4 addresses only, so a
grant can never be written in a form that silently never matches.
--preopen split host and guest at the first `::`, so a host path
containing `::` widened the preopened directory; it now splits from the
right, and appd refuses host paths that are not UTF-8 or contain `::`.
appd validated capabilities one at a time, creating the data directory
before a later capability was refused, and required HOME even for
packages without filesystem capabilities. It now checks every capability
first, resolves host directories only when needed, validates the app ID
with the rule weft-pack uses (now shared in weft_ipc_types::package), and
reports 400, 404, 403 or 500 according to the cause. user-dirs.dirs is
read as a shell would: the last assignment wins, $HOME must be followed
by a slash, escaped values are ignored and a relative XDG_CONFIG_HOME is
not used.
The grants probe now also overwrites, renames, removes and creates
directories in read-only data, and sends a forged Host header, an
injected method and a file: URL; it fails when directory permissions of
a read-only preopen are widened or the header check is removed. A new
CI job builds the runtime with its engine and fetch support and runs the
check. The mount test that sets WEFT_APP_STORE now holds the env lock.
Package images are still located separately from directory installs;
deriving grants from the verified image is part of resolving one package
descriptor.
2026-10-09 08:25:40 +00:00
- `runtime-grants` — clippy for `weft-runtime` with its Wasm engine and fetch, and `tests/runtime/check_grants.py`
2026-03-12 14:41:33 +00:00
- `servo-embed-linux` — `cargo check --features servo-embed` for both servo crates
docs: add engineering contract, contributor toolkit and templates
Add AGENTS.md as the single engineering contract: sources of truth,
evidence and proof requirements, ownership, working modes, the reviewed
change loop, maintenance isolation, decision authority, dependency and
fork rules, the 0.0.x to 0.1.0 release progression, and branch and
publication rules.
Add .agents/ with scope, implement, verify, maintenance and release
procedures; reviewer, architecture debt scout, simplicity and refactoring
roles; skills for the compositor, Servo rendering, runtime capabilities,
appd sessions, packages and data, Linux deployment, integration
verification and documentation; and verify.py, which runs the existing
check profiles with --locked from any directory, stops on the first
failure and supports --dry-run.
check_toolkit.py validates local links and heading anchors, metadata,
catalog coverage and issue forms. A new contributor-toolkit CI job runs
both. The structure follows the Resina Design System toolkit at
1e768064f57a1e403ab271822383e732795905a6, adapted to WEFT.
Validation, against the committed lockfiles:
- verify.py toolkit: checker passes, 28 runner/checker tests pass
- verify.py portable, demos, packages: pass
- verify.py linux, runtime, servo-embed: fail on existing defects
(clippy collapsible_if in the winit backend, three clippy lints in
weft-runtime with wasmtime-runtime, and an E0308 in the selected Servo
revision's servo-layout); the runner reports the failing status
Add CONTRIBUTING.md, issue forms for defects and changes, maintenance
problems and decisions of direction, and a pull request template asking
for ownership, proof and the validation actually performed. README.md
links the contribution guide.
2026-10-08 23:40:08 +00:00
- `contributor-toolkit` — links, metadata and catalog of the contributor toolkit, and runner tests
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
## Security
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
See `docs/security.md` . Key points:
2026-03-10 17:47:06 +00:00
2026-03-12 14:41:33 +00:00
- 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`
2026-03-12 19:45:56 +00:00
- SpiderMonkey is not sandbox-isolated beyond process-level isolation (see `docs/security.md` )
2026-03-11 11:59:24 +00:00
2026-03-12 14:41:33 +00:00
## Servo fork
2026-03-10 17:47:06 +00:00
2026-10-09 10:29:24 +00:00
- Servo: `https://github.com/marcoallegretti/servo` at `e5d9a518` , pinned by revision
build: select compiling Servo and Stylo fork revisions
Both Servo hosts tracked the marcoallegretti/servo `servo-weft` branch,
which the lockfile resolved to 8e7dc40. That revision's servo-layout does
not compile (E0308 and E0716 in build_backdrop_filter). WEFT also resolved
upstream Stylo dca3934, where backdrop-filter is gated behind
layout.unimplemented, because the Servo fork's own [patch] for Stylo does
not apply to dependents.
Pin Servo by revision to f0bb1aa (8e7dc40 plus the build fix) and add a
root [patch."https://github.com/servo/stylo"] selecting the
marcoallegretti/stylo fork at f1ba496 for all eight Stylo crates Servo
uses. Cargo.lock changes only the 66 source lines of those packages.
Record both pins, their reachable branches, purpose and removal
conditions in SERVO_PIN.md, and restate its limitations against executed
evidence. Update the Nix outputHashes: the Stylo hash is recomputed for
f1ba496 with the method that reproduces the previous dca3934 value; the
Servo hash is not yet known for f0bb1aa and is left as lib.fakeHash, so
Nix builds report the expected value instead of using a stale one.
Validation:
- cargo metadata --locked: ok; no servo/stylo sources remain in the lock
- cargo check -p weft-servo-shell --features servo-embed --locked:
all of Servo, including servo-layout, compiles; the remaining errors are
in the shell's own embedder code
- cargo fmt --check; portable workspace tests: 78 passed
- Nix fetchgit could not run here (archive downloads and the sandbox's
TLS to the proxy fail), so the Servo hash remains unverified
2026-10-09 00:13:08 +00:00
- Stylo: `https://github.com/marcoallegretti/stylo` at `f1ba4969` , through the root `[patch]`
2026-10-09 10:03:30 +00:00
- Patches: `backdrop-filter` parsing (Stylo) and rendering (Servo), rooting of compiled classic scripts and `navigator.servo` exposure (Servo)
2026-03-12 19:45:56 +00:00
- See `crates/weft-servo-shell/SERVO_PIN.md` for Servo integration status and known limitations
docs: add engineering contract, contributor toolkit and templates
Add AGENTS.md as the single engineering contract: sources of truth,
evidence and proof requirements, ownership, working modes, the reviewed
change loop, maintenance isolation, decision authority, dependency and
fork rules, the 0.0.x to 0.1.0 release progression, and branch and
publication rules.
Add .agents/ with scope, implement, verify, maintenance and release
procedures; reviewer, architecture debt scout, simplicity and refactoring
roles; skills for the compositor, Servo rendering, runtime capabilities,
appd sessions, packages and data, Linux deployment, integration
verification and documentation; and verify.py, which runs the existing
check profiles with --locked from any directory, stops on the first
failure and supports --dry-run.
check_toolkit.py validates local links and heading anchors, metadata,
catalog coverage and issue forms. A new contributor-toolkit CI job runs
both. The structure follows the Resina Design System toolkit at
1e768064f57a1e403ab271822383e732795905a6, adapted to WEFT.
Validation, against the committed lockfiles:
- verify.py toolkit: checker passes, 28 runner/checker tests pass
- verify.py portable, demos, packages: pass
- verify.py linux, runtime, servo-embed: fail on existing defects
(clippy collapsible_if in the winit backend, three clippy lints in
weft-runtime with wasmtime-runtime, and an E0308 in the selected Servo
revision's servo-layout); the runner reports the failing status
Add CONTRIBUTING.md, issue forms for defects and changes, maintenance
problems and decisions of direction, and a pull request template asking
for ownership, proof and the validation actually performed. README.md
links the contribution guide.
2026-10-08 23:40:08 +00:00
## Contributing
See [CONTRIBUTING.md ](CONTRIBUTING.md ). [AGENTS.md ](AGENTS.md ) is the engineering contract and [BLUEPRINT.md ](BLUEPRINT.md ) the accepted direction toward `0.1.0` .