Browse the docs · Peers
docs / networking

Peers

A peer is anything that holds a copy of Mod's state and syncs it: the Mod app on your Mac, the window, the CLI, the VMs your sessions run in, and the relay. Every peer holds the same kind of copy, so none of them is the original.

How it works

On a Mac, the Mod app runs a daemon that is the Mac's peer. It keeps the Mac's copy on disk, syncs it with the relay, and hosts the workers that run sessions there. The window you work in is a peer too, with its own copy in the browser's storage. On the same machine, the window syncs straight with the daemon over the loopback interface, so local work never has to leave the laptop to show up on screen.

Between machines, peers sync through the relay. Each device has its own identity and key, so every change it makes is signed as coming from that device.

A VM is a peer through the Mac that hosts it: the host's daemon syncs on its behalf. A new session's VM starts from a saved snapshot of its project on that host, then catches up on whatever changed since, including code, which arrives as git objects. A VM that loses its network keeps working and catches up when the network returns.

Because every peer holds a full copy of what it syncs, losing one loses nothing: the others still have it.

Using it as you build

Anything that uses the CLI or Mod's tools works through a peer, so what you write is local first and syncs after. To see a change from another device, read it back from that device: if it is there, the change crossed.

Limits

  • Peers on different machines sync only through the relay today. Direct sync over a local network is not built.
  • The iPhone app is in internal testing and does not yet sync reliably. soon
  • A VM's starting snapshot is kept on the host that made it and is not synced to other machines.