Browse the docs · Sync
docs / networking

Sync

Sync is how the same state reaches every device, VM and person in Mod: documents, session logs and the code your sessions work on. Each one holds its own copy, writes to it straight away, and exchanges changes with the others in the background.

How it works

Every document and every session log is an Automerge CRDT. A CRDT keeps a full history of changes, and any two copies that have seen the same changes end up the same, whatever order they arrived in. That is why there are no locks in Mod and no "someone else is editing": a person and three agents can type in one paragraph at once, offline or not, and every edit merges.

No copy is the authoritative one. Your Mac, the window, a VM and the relay are all peers holding the same state, and any of them can carry it to the others. Changes travel over Subduction, a sync protocol from Ink & Switch that moves only what the other side is missing.

Code syncs too, as git objects. Sessions in different places work on their own branches, and git merges them when they meet. A change git cannot merge on its own becomes a task for the session, rather than something reconciled behind your back.

When you are offline, everything keeps working against your own copy. When you reconnect, your changes go out and everyone else's come in.

Using it as you build

There is no sync API to call. Write a document, a record or a session message through the tools or the CLI, and it syncs:

mod-next docs create <projectId> notes/launch.md --content "# Launch"

What you build on Mod inherits this: an app's records are documents, so your app is multiplayer, offline-first and live without any sync code of its own.

Limits

  • A finished sync round means the changes were sent, not that another peer has stored them. Treat a fresh peer reading the change back as the proof.