Skip to content

Object-Capabilities & Safety

In Mo, a function cannot perform I/O unless a capability value is passed explicitly in its signature. Top-level main receives only the capabilities it declares:

  • Args, Env, Console
  • Files, ReadFiles, Files.File — directory-confined via Linux openat2 RESOLVE_BENEATH or component-wise O_NOFOLLOW traversal (never escaping via .. or symlinks)
  • Clock, Random, SecureRandom
  • Network, Connection — TCP + TLS 1.2+ via pure-Rust rustls with system roots
  • Sqlite, Sqlite.Database — bundled SQLite with WAL mode, PRAGMA foreign_keys = ON, directory confinement, and authorizer blocking ATTACH/VACUUM INTO/extensions
  • Command — shell-free subprocess execution backed by Linux Landlock + seccomp child confinement

Capabilities can only become narrower, never wider:

  • files.within("reports").read_only
  • network.allow_hosts(["api.github.com:443"])
  • command.within(dir).allow_programs(["git"])

mo diff flags any capability authority expansion automatically in code review.

Every capability has an in-memory spec double (Console.fake(), Files.in_memory(...), Clock.fixed(...), Random.seeded(...), Network.fake(...), Sqlite.in_memory(), Command.fake(...)). The MOBC v0.3 bytecode verifier rejects fake constructors outside spec blocks so production builds can never forge authority.

All 17 workspace crates enforce #![forbid(unsafe_code)], unwrap_used = "deny", zero OpenSSL, and zero dynamic libsqlite3.