ADR-001: WebAssembly as Primary Target
Status
Accepted
Context
We want to build a mini operating system that is: - Accessible to anyone with a browser - Requires no installation - Runs in a sandboxed environment - Demonstrates OS concepts without requiring bare metal
Traditional OS development requires: - Bootable images - Hardware or emulators - Complex toolchains - Platform-specific code
Decision
We will target WebAssembly (wasm32-unknown-unknown) as the primary compilation target, with the browser as the runtime environment.
The OS will: - Compile to a single .wasm file - Run in any modern browser - Use browser APIs for I/O (console, storage, networking) - Be embeddable in any web page
Consequences
Positive
- Zero installation: Users just open a URL
- Cross-platform: Works on any device with a modern browser
- Sandboxed: Can't damage the host system
- Shareable: Easy to demo, link, embed
- Modern tooling: wasm-pack, wasm-bindgen are mature
- Rust ecosystem: Full access to Rust crates (with wasm support)
Negative
- No true threads: WASM has limited threading support
- No direct hardware: Must use browser APIs
- No bare metal path: Can't boot on real hardware (without rewrite)
- Performance ceiling: Browser adds overhead
- Browser differences: Subtle API variations
Alternatives Considered
1. Native Binary (Linux target)
- Pro: Full OS capabilities, real scheduling
- Con: Requires VM/emulator, harder to share
2. UEFI Application
- Pro: Closer to real OS, direct hardware
- Con: Complex toolchain, testing requires reboot/VM
3. Microkernel on Embedded
- Pro: Real hardware, constrained environment
- Con: Specialized hardware, harder to access
4. Educational OS Framework (e.g., xv6, MINIX)
- Pro: Well-documented, proven for learning
- Con: Not Rust, less modern
Notes
The browser environment actually provides a surprisingly good OS substrate: - Console → Terminal I/O - Origin Private File System → Persistent storage - WebSocket → Networking - Crypto API → Random numbers - requestAnimationFrame → Timer events
This decision shapes everything else: async execution model, IPC design, filesystem abstraction.