Skip to content

Wire pid0 into ww run <image>, remove exec + TCP RPC#32

Merged
mikelsr merged 8 commits intofix/pid0-cleanupfrom
feat/ww-run-image
Feb 20, 2026
Merged

Wire pid0 into ww run <image>, remove exec + TCP RPC#32
mikelsr merged 8 commits intofix/pid0-cleanupfrom
feat/ww-run-image

Conversation

@lthibault
Copy link
Copy Markdown
Contributor

@lthibault lthibault commented Feb 14, 2026

Depends on: #31#28

Summary

This replaces the two-command daemon+client pattern (ww run + ww exec) with a single command that boots pid0 directly from an image path:

ww run examples/images/pid0           # local filesystem
ww run /ipfs/QmSomeHash               # IPFS (when daemon is running)

The daemon no longer opens a TCP port for external RPC clients. Instead, it loads the guest image itself and serves the Host capability over in-memory streams — same as docker run loads and boots a container image directly.

Image layout (FHS convention)

Images follow a simplified Filesystem Hierarchy Standard layout. This gives us a predictable, extensible structure whether the image lives on local disk or is fetched from IPFS:

<image>/
  bin/
    main.wasm        # guest entrypoint (required)
  etc/               # reserved — configuration files
  usr/
    lib/             # reserved — shared libraries, deps

Today only bin/main.wasm is required. The other directories are reserved so we can later add support for:

  • etc/ — guest configuration (capability grants, resource limits, etc.)
  • usr/lib/ — shared WASM libraries that guests can link against

This mirrors how OCI container images use FHS paths, making the layout immediately familiar. The <image> argument can be either a local filesystem path or an IPFS path — the ChainLoader tries IPFS resolution first, then falls back to the host filesystem.

What changed

  • ww run <image> — now requires a positional <image> argument pointing to an FHS image directory
  • ww exec removed — no more side-loading WASM over TCP; the daemon loads and runs pid0 itself
  • TCP RPC listener deleted (src/rpc/server.rs, port 2021) — Host RPC is now served exclusively over in-memory duplex streams between host and guest
  • Cell/CellBuilder cleaned up — removed dead ipfs and port fields, fixed entrypoint path from <image>/main.wasm<image>/bin/main.wasm (FHS)
  • Legacy spawn_with_rpc_internal removed — only the data-streams code path remains
  • Doc comments added to Cell, CellBuilder, CLI help text, and src/rpc/mod.rs

What stays the same

  • In-memory Host RPC (build_peer_rpc) — guests still bootstrap Cap'n Proto over data streams
  • ExecutorImpl — pid0 can still spawn children via host.executor().runBytes(wasm)
  • Guest code (pid0, child-echo, shell) — unchanged
  • peer.capnp schema — unchanged
  • All 32 tests pass, clean build with zero warnings

Test plan

  • cargo build — clean compile, zero warnings
  • cargo test --lib — 32/32 pass
  • make guests images && cargo run -- run examples/images/pid0 — e2e boot
  • Verify pid0 traces appear on stderr (stdio forwarding via spawn_with_streams)

Replace the two-command daemon+client pattern (ww run / ww exec) with a
single ww run <image> that boots pid0 directly from an image path.

- Remove Exec subcommand and all supporting code (parse_tcp_multiaddr,
  pump_stdin_to_bytestream, pump_bytestream_to_stdout, etc.)
- Delete src/rpc/server.rs (TCP accept loop on port 2021)
- Remove dead ipfs/port fields from Cell and CellBuilder
- Fix FHS path: <image>/main.wasm → <image>/bin/main.wasm
- Remove legacy spawn_with_rpc_internal method
- Wire CellBuilder with ChainLoader (IPFS + host FS) in CLI
- Add doc comments to Cell, CellBuilder, and CLI help text
@lthibault lthibault marked this pull request as ready for review February 14, 2026 04:34
@lthibault lthibault requested a review from mikelsr February 14, 2026 04:34
@lthibault lthibault self-assigned this Feb 14, 2026
@lthibault lthibault added the enhancement New feature or request label Feb 14, 2026
The old README documented flags (--volume, --ipfs, --preset) and workflows
(two-terminal daemon+client) that no longer exist. Replace with current
reality: single ww run <image> command, FHS image layout, architecture
diagram, and build instructions for the staged guest pipeline.
Add boot/ to the FHS image layout spec. Each file is named with a
base58btc-encoded libp2p peer ID and contains that peer's multiaddrs,
one per line. The runtime will decode filenames via PeerId::from_str()
and dial the listed addresses.

Not yet wired into the runtime — specced in README, CellBuilder docs,
and CLI help for now.
Each entry under svc/ is a nested image with its own FHS layout,
spawned automatically at boot. The directory name is the service name.
Services are images all the way down — they can carry their own boot/,
etc/, and even nested svc/.
Captures the architectural insights from the ww-run-image work: capability-based
security with no ambient authority, the runtime/pid0/children layer model,
bidirectional capability flow (host -> guest -> network), the Membrane export
pattern, and two-layer configuration (image config vs node config).
One config model: FHS. The image root pid0 sees is assembled from
stacked layers (Stem base + positional overlays) via per-file union.
Later layers override earlier; no deletes. Only the union must contain
bin/main.wasm.
lthibault and others added 2 commits February 18, 2026 19:13
Move generic membrane primitives (Epoch, EpochGuard, MembraneServer,
SessionExtensionBuilder) from wetware/membrane into rs as a workspace
crate. stem.capnp is now canonical in rs/capnp/.

This consolidates the runtime workspace: membrane is consumed as a
path dep by other rs crates, and as a git dep by stem/atom.
@mikelsr mikelsr merged commit 436e7f6 into fix/pid0-cleanup Feb 20, 2026
@mikelsr mikelsr deleted the feat/ww-run-image branch February 20, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants