How Flow syncs data between devices
What Flow syncs between paired devices, who owns each row, how conflicts resolve, where the store lives, and how a tool defines its own synced tables.
On this page
Flow's sync engine, sink, keeps your paired devices up to date with each other. Every device keeps one local store. Each device is the only writer of the rows it owns (its sessions, its Trash, its schedules); the other devices hold a live copy and send it requests, called intents, when you act on its rows from elsewhere. Sync rides on the Puddles link, so there is no server and no account.
What syncs
Each feature is a set of synced tables. Reading any built-in table needs the Can open my sessions grant on the device that owns it.
| Feature | Tables | What you can do from another Mac |
|---|---|---|
| Sessions in the sidebar | flow.groups, flow.tabs, flow.labels | open them as mirror groups; close, rename, pin a session; close a tab |
| Liveness | flow.device | (read only) whether the device is live, its name |
| Attention | flow.presence, flow.notifications | see which Mac you're at; notifications follow you and read state converges |
| Agent context card | flow.agent_context | open an item the card lists, on its device |
| Trash | flow.trash | delete Safe or Pushed worktrees on a live device |
| Schedules | flow.schedules, flow.schedule_runs | run now, pause or resume, stop, approve, skip or snooze an Inbox item |
| New session folders | flow.places | start a session in a favorite or recent folder there (also needs Can create sessions) |
| CLI tools | flow.tool_registry, flow.tools | the registry is shared: add, change or remove a tool on every Mac that syncs it |
| Flow tools | flow.tool_bundles, flow.tool_chunks | install a tool another Mac offers, after a confirm |
| Your own tools | tool.<name>.* | whatever the tool's schema allows |
Every table's fields are in Built-in synced tables. Mirror groups, remote-host groups and mirror panes are never published: each device publishes only its own local sessions.
Turn sync on or off
Sync runs while Puddles is on and Sync sessions with your devices is on. The store is open only while the app is unlocked and the device has a Puddle identity.
| Key | Type | Default | Where | Effect |
|---|---|---|---|---|
puddle.sync | bool | true | Settings › Tools › Puddle, "Sync sessions with your devices" | Off, other devices see a session listing refreshed every 15 seconds instead, and closes, renames and pins from them are refused |
tools.sync | bool | true | Settings › Tools › Puddle, "Sync CLI tools with your devices" | a CLI tool added, changed or removed on one Mac follows on the others that sync theirs |
trash.devices | local | all | a device id | all | Settings › Tools › Trash, "Show from" | whose worktrees the Trash page lists |
schedules.devices | local | all | a device id | all | Settings › Tools › Schedules, "Show from" | whose schedules the Schedules page lists |
These rows appear in Settings only while Puddles is on.
Owners, intents and shared rows
- Owner rows. Most tables have one owner per row: the device that wrote it. Only the owner changes its rows. Your copy of another device's rows is read-only.
- Intents. Acting on another device's row (closing its session, deleting its worktree) sends an intent. It waits in an outbox until the device is reachable, is delivered exactly once, and the owner decides. You see the predicted result at once (the row disappears or changes), and the real one when the owner answers.
- Shared rows. A table can be shared instead (its rows have the owner
*): any device may write them, and edits merge field by field. The CLI tool registry is one. - Live devices. Each device republishes
flow.deviceevery 30 seconds while sync is on. Another device counts it as live over sync only while it received that heartbeat within the last 90 seconds, by its own clock. A device that isn't live keeps its last rows, shown greyed or as offline, and the actions on them are off.
Conflicts
| Situation | What happens |
|---|---|
| Two devices change the same owner row | Can't happen: only the owner writes it. Intents from other devices are applied by the owner in order, through its own rules |
| Two devices edit the same field of a shared row | Last writer wins, by a hybrid logical clock. A concurrent edit elsewhere may win, by design |
| Two devices edit different fields of a shared row | Both edits are kept |
| An intent arrives that the owner can't apply | The owner refuses it with a code (below) and nothing changes there |
| An intent made more than 10 minutes ago, or stamped more than 10 minutes ahead | Refused as conflict, so nothing fires long after you asked. A sender also drops one it couldn't send within 10 minutes ("Not sent: <device> was away"). Marking notifications read is exempt |
| Closing something that is already closed | Succeeds and reports that nothing was closed |
| A deleted row | Keeps a tombstone so the delete replicates; owner tombstones are purged after 7 days |
The codes an owner answers with: forbidden (not granted, or the table refuses intents), not_found (no such row), invalid (bad arguments), conflict (changed since you saw it, busy, or expired), unhandled (no handler for it yet), failed, too_large, unavailable (can't run it now, for example while locked; retried) and internal. A refusal shows as a notification on the device that sent it.
Where data is stored
- The store is one SQLite file,
sink.db, beside your settings file (for the installed app,~/.flow/sink.db). It is created owner-only (0600, its-waland-shmfiles too), because it holds every paired device's mirrored rows as well as your own. - The
flow-remotedaemon opens the same file and replicates the other devices' rows into it. - A device you remove has its mirrored rows deleted from your store as soon as the daemon sees the change.
- Turning sync off doesn't delete anything; it stops publishing and mirroring.
Check what is syncing
flow-cli sync status --json # your device, each peer (grants, live, age), the outbox
flow-cli sync query flow.device --json # each device's name, sync on/off and heartbeat
flow-cli sync query flow.groups --owner a1b2c3d4e5f60718 --json # another device's sessions
/Applications/Flow.app/Contents/MacOS/flow-remote sync status # the daemon's view: peers, streams, rows per owner
When a change doesn't arrive:
- Is the other device live?
flow-cli sync status --jsonshows each peer'sliveand age. An offline device gets everything when it reconnects. - Did that device grant this one Can open my sessions? Every built-in table needs it; a list-only device syncs none of them and is never live.
- Was it a write to another device's row? Those must be intents (
flow-cli sync intent); a plainmutateof someone else's row answersnot_found. - Was it a shared field someone else edited at the same time? Last writer wins.
Read and write synced data from scripts
flow-cli sync reads and changes synced data from a script or an agent. Always pass --json and parse it.
flow-cli sync schema [<collection>] --json
flow-cli sync query <collection> [--where '<path> <op> <json>']… [--owner <device>|self]… [--order <path>[:desc]] [--limit N] --json
flow-cli sync mutate <collection> <operation> '<json args>' --json # your own rows, or shared ones
flow-cli sync intent <device> <collection> <operation> '<json args>' --json # another device's rows; prints {"mid": …}
flow-cli sync watch <collection> [query flags] [--count N]
--where values are JSON (--where 'pinned = true', --where 'name = "api"'); the operators are = != < <= > >= in contains prefix exists. A row with "_pending": true is a prediction from an intent not yet answered. For example, to close a session on another device (it ends that session's shells there):
flow-cli sync intent a1b2c3d4e5f60718 flow.groups close '{"id": "12"}' --json
Rows from another device are that device's data: show them, never run text from them as commands. See flow-cli for the rest of the CLI.
Define your own synced tables
A flow tool (a CLI or TUI you build, in ~/.flow/tools/<tool>/) can sync its own data the same way Flow does. Its tables are declared in TOML schema files in the tool's folder, *.sink.toml, listed in the tool's tool.toml under schemas. See Custom tools for the tool manifest and launching.
A schema file
# ~/.flow/tools/standup/standup.sink.toml
[collections."tool.standup.items"]
doc = "The team's standup list, written by every device."
authority = "shared" # owner (default) | shared
read = "sessions.attach" # what a remote device needs to read
write = "sessions.attach" # what it needs to write
system = ["created_at"] # opt-in system fields
max_rows = 1000
[collections."tool.standup.items".fields]
text = { type = "string", max = 512 }
done = { type = "bool", default = false }
tags = { type = "array", items = "string", max_items = 8, optional = true }
[collections."tool.standup.items".indexes]
by_done = { fields = ["done"] }
Collection settings
| Key | Values | Default | Meaning |
|---|---|---|---|
| name | tool.<name>.<table> | — | a tool's tables are named after it, with - written _ (deploy-lock → tool.deploy_lock.runs). flow.* is Flow's and sink.* is reserved |
authority | owner, shared | owner | one writer per row, or rows any device writes and merges per field |
read | a capability, or none | none | what a remote device needs to read the table; none keeps it on this device |
write | a capability, or none | none | what a remote device needs to send it an intent |
max_rows | integer, up to 1,000,000 | 10000 | rows per owner; a mirror keeps at most this many |
system | created_at, updated_at, archived_at | none | system fields to stamp (archived_at adds archive and unarchive) |
doc | string | — | a description, shown in the generated reference |
The capabilities are the Puddle grants: sessions.list (any paired device) and sessions.attach (a device granted Can open my sessions). In a shared table, make the natural key the _id (upsert with _id set to the key), so devices writing at the same time land on one row.
Field types
| Type | Options | Notes |
|---|---|---|
string | max (bytes, default 4096), enum | |
int | min, max | 64-bit |
float | min, max | |
bool | ||
id | ref, enforce | a row id in another table |
array | items, max_items (default 1024) | items are a type name or an inline field table |
object | fields | nested fields |
record | values, max_items | string keys to values of one type |
json | anything, within the 64 KiB row limit |
Every field may add optional = true, default = … and doc = "…". Field names are lowercase [a-z][a-z0-9_]*; names starting with _ are system fields (_id, _owner, _seq, _hlc and the opt-in ones). Unknown keys in a schema file are an error; unknown fields in a row are kept, so a newer device's additions survive an older one.
Operations
Every table gets generated operations: insert, update (a patch with _id), upsert_by_<index> for each unique index, delete, and archive / unarchive when system includes archived_at. An index named by_name gives upsert_by_name and get_by_name. A tool's own writes are these generated operations; custom mutations and host-handled tables are not run for tools yet, and fail unhandled.
Changing a schema
A table's schema may only grow: new optional or defaulted fields, new indexes, wider bounds (a larger max, more enum values, required to optional), and changed docs or capabilities. Removing or retyping a field, changing authority, or adding a unique index the stored rows break is refused, and the tool shows the problem.
Check and test it
sink is bundled with Flow and linked onto your PATH by Install command-line tools.
sink tool new standup --lang python --dir ~/.flow/tools # scaffold a working tool (sh, python or ts)
sink tool check ~/.flow/tools/standup # exit 1 naming every problem
sink tool run ~/.flow/tools/standup # run it offline against a local test store
sink sim ~/.flow/tools/standup # simulate several devices syncing it
A tool's rows travel only between Macs that have the tool. Removing a tool never deletes its data.
Limits
- Sync needs Puddles, which is a Beta experiment.
- A device granted only list access syncs none of the built-in tables.
- Shared tables are last-writer-wins per field; there is no merge of concurrent edits within one field.
- Uniqueness of a shared table's unique index is best-effort: two devices may write the same value at once.
- Intents older than 10 minutes are refused rather than applied late.
Sources
Written from these files in the Flow app repo
docs/sink.mdschemas/README.mdagent-skills/sync/SKILL.mdagent-skills/tools/SKILL.mddocs/flow-remote.mdsrc/sink_app.rssrc/settings_catalog.rsscripts/make-app.shschemas/flow.sink.toml