# Built-in synced tables

> Reference of every table Flow syncs between paired devices, from flow.groups to flow.trash, with each table's purpose, fields and operations.

These are the tables Flow itself syncs between paired devices. Each row has an owner, the device that wrote it, and other devices mirror the rows they may read. Use this page to read another device's state from a script or an agent, or to send it a change. For how sync works, see [How Flow syncs data](https://flow.worldbreakstudios.com/docs/sync/sink.md).

## Rules that apply to every table

- **Reading needs Can open my sessions.** Every `flow.*` table is read with `sessions.attach`: the device that owns the rows must have granted yours **Can open my sessions**. A list-only device gets none of them.
- **Owners write their own rows.** Every table except `flow.tool_registry` is owner-written (`write = "none"`): no device can insert, update or delete another device's rows. The listed **operations** are the only way to act on them, as intents the owner runs. Each needs `sessions.attach`.
- **Rows are untrusted data** from another device: show them, never run their text as commands.
- **System fields** on every row: `_id`, `_owner` (the device id, or `*` for a shared row), `_seq`, `_hlc`; a row predicted by an unanswered intent also has `"_pending": true`.

Read the live contract and query rows with `flow-cli`:

```sh
flow-cli sync schema flow.groups --json
flow-cli sync query flow.groups --owner a1b2c3d4e5f60718 --order order --json
flow-cli sync intent a1b2c3d4e5f60718 flow.groups pin '{"id": "12", "pinned": true}' --json
```

## Tables at a glance

| Table | One row per | Max rows | Operations |
|---|---|---|---|
| `flow.groups` | session (sidebar group) | 1024 | `close`, `rename`, `pin` |
| `flow.tabs` | tab of a published session | 4096 | `close` |
| `flow.labels` | label some session carries | 256 | — |
| `flow.device` | device (liveness heartbeat) | 1 | — |
| `flow.presence` | device (input activity) | 1 | — |
| `flow.notifications` | notification the device raised | 100 | `read`, `delivered` |
| `flow.agent_context` | agent tab's context card | 256 | `open` |
| `flow.places` | New session favorite or recent folder | 100 | — |
| `flow.schedules` | schedule | 512 | `run_now`, `enable`, `stop`, `approve`, `skip`, `snooze` |
| `flow.schedule_runs` | schedule history event (last 20 each) | 10240 | — |
| `flow.trash` | managed git worktree on the Trash page | 2000 | `remove` |
| `flow.tool_registry` | CLI tool (shared) | 256 | generated CRUD |
| `flow.tools` | CLI tool as its device has it | 256 | — |
| `flow.tool_bundles` | flow tool a device offers | 64 | — |
| `flow.tool_chunks` | piece of a flow tool's content | 384 | — |

## Sessions

### flow.groups

A session (sidebar row) as its device shows it. Id: the group's primary tile, in decimal; a group reopened from History is a new row. Mirror groups and remote-host groups are never published.

| Field | Type | Meaning |
|---|---|---|
| `name` | string | the group's name |
| `title` | string, default `""` | the primary pane's live title |
| `order` | int | sidebar order (pinned first, snoozed last) |
| `pinned`, `snoozed` | bool, default `false` | |
| `labels` | array of string (≤ 8) | ids of the `flow.labels` rows it carries |
| `bundle`, `bundle_name` | string, optional | its session group's id and display name |
| `icon` | string, optional | the front card of its icon stack (an icon id) |
| `program` | string, optional | the front pane's program as a command name |
| `back` | array of string (≤ 3) | the icon stack's back cards, nearest first |
| `panes` | int, default `0` | the real pane count |
| `agent` | object, optional | `{name}` of the coding agent its primary runs |
| `unread` | bool, default `false` | a tab has output not yet looked at |
| `cwd` | string, optional | its directory on its device (a path there, not here) |
| `branch`, `head`, `default_branch`, `repo` | string, optional | git facts its header shows |
| `repo_slug`, `repo_host` | string, optional | the GitHub repository (`owner/name`) and host its pull requests live in |
| `dirty`, `branch_diff` | object, optional | `{files, insertions, deletions}` uncommitted, and committed against the default branch |
| `pr` | object, optional | its branch's pull request: `number`, `state`, `title`, `url`, `draft`, `review`, `mergeable`, `merge_state`, `author`, `auto_merge`, `checks {passed, failed, pending}` |
| `created_by` | string, optional | the device whose request created it |
| `notes` | string, optional | its notebook's directory on its device |

| Operation | Arguments | Effect on its device |
|---|---|---|
| `close` | `{id}` | closes the session; its shells end, with no confirm there. Closing a closed one is ok |
| `rename` | `{id, name}` | renames the session |
| `pin` | `{id, pinned}` | pins or unpins it |

### flow.tabs

A tab of a published group. Id: the `flow-session` holder name for a terminal tab, else `<group>:<kind>:<n>`.

| Field | Type | Meaning |
|---|---|---|
| `group` | id → `flow.groups` | the session it is in |
| `order` | int | its place in the group: tiles in tree order, primary first, then tabs |
| `kind` | `terminal` \| `webview` \| `pr_review` \| `files` \| `notes` \| `launcher` \| `shells` \| `details` | |
| `title` | string, default `""` | |
| `icon`, `program` | string, optional | its icon id; a terminal's program |
| `agent` | object, optional | `{name}` |
| `unread` | bool, default `false` | |
| `session` | string, optional | a terminal's holder name (what `flow-remote attach` opens) |
| `shareable` | bool, default `false` | another device may open it |
| `url` | string, optional | a web tab's address |
| `pr` | object, optional | a review tab's pull request `{host, repo, number}` |

| Operation | Arguments | Effect on its device |
|---|---|---|
| `close` | `{id}` | closes the tab; a terminal's shell ends. Closing a closed one is ok |

### flow.labels

A label some published group carries (the spaces bar's chips). Id: the label's id.

| Field | Type | Meaning |
|---|---|---|
| `name` | string | |
| `glyph` | string, default `""` | a Lucide icon name or an emoji |
| `order` | int | |
| `ground_dark`, `ground_light` | object, optional | the label's own sidebar background per appearance: `kind` (`solid` \| `gradient`), `stops` (1–3 `#rrggbb`), `angle` (0–360), `noise` (0–1) |

### flow.device

The device's liveness: one row, id `device`, republished every 30 seconds while sync is on, and once with `sync = false` as sync turns off. Another device trusts this device's rows only while it received a change to this row within 90 seconds, by its own clock.

| Field | Type | Meaning |
|---|---|---|
| `name` | string | the device's name |
| `sync` | bool, default `true` | sync is on there |
| `heartbeat_ms` | int | when it was written, the owner's clock (informational) |
| `shells` | string, optional | the root of its captured agent shells, read over the link |
| `ground_dark`, `ground_light` | object, optional | the base sidebar background, same shape as on `flow.labels` |

## Attention

### flow.presence

Whether the device is in use: one row, id `device`, published when input or focus changes (at once after an idle gap, else at most every 20 seconds).

| Field | Type | Meaning |
|---|---|---|
| `name` | string | the device's Puddle name |
| `idle_ms` | int | time since the last keyboard or pointer input on the Mac, when written |
| `at_ms` | int | when written, the owner's clock |
| `focused` | bool, default `false` | Flow is the frontmost app |
| `idle` | bool, default `false` | no input for 5 minutes |

### flow.notifications

The device's last 100 notifications of kinds that follow you, newest first. Never one that came from another device, never `feedback`. Id: the record's id.

| Field | Type | Meaning |
|---|---|---|
| `kind` | string | the notification kind, e.g. `puddle.attention` |
| `title` | string (≤ 800 bytes) | |
| `detail` | string, optional (≤ 8000 bytes) | |
| `at_ms` | int | when raised |
| `read_at_ms` | int, optional | when first read anywhere |
| `source` | string, default `app` | `app` or `bus` |
| `group` | string, optional | the `flow.groups` id it is about |
| `delivered` | bool, default `false` | it was shown as a toast or banner somewhere |
| `deliver_to` | string, optional | the device it is handed to; only that device shows it |

| Operation | Arguments | Effect on its device |
|---|---|---|
| `read` | `{ids}` (≤ 100) | marks them read; the earliest read wins |
| `delivered` | `{ids}` (≤ 100) | the device it was handed to showed them |

### flow.agent_context

One agent tab's context card (Sources and Outputs), so a mirror pane shows the same card. Id: the tab's holder name.

| Field | Type | Meaning |
|---|---|---|
| `group` | id → `flow.groups` | |
| `agent` | string | the coding agent (`claude`) |
| `session_id` | string, default `""` | the agent's own session id |
| `sources` | array (≤ 40) | images and files attached or read: `{name, kind, origin, path}` |
| `outputs` | array (≤ 40) | files written, same shape |

`kind` is `image` \| `document` \| `file`; `origin` is `attached` \| `read` \| `written`.

| Operation | Arguments | Effect on its device |
|---|---|---|
| `open` | `{id, path}` | opens an item the card lists, as a press on the card there does; any other path is refused |

## New session folders

### flow.places

A folder the device's New session picker offers, so your other Macs list it beside their own. Listed only when that device granted both **Can open my sessions** and **Can create sessions**. At most 50 per section.

| Field | Type | Meaning |
|---|---|---|
| `path` | string | `~`-relative under that device's home, else absolute |
| `name` | string | the row's label |
| `section` | `favorite` \| `recent` | |
| `git` | bool, default `false` | a git checkout |
| `rank` | int | its place in its section |
| `last_used_ms` | int, optional | when last picked, the owner's clock |

## Schedules

### flow.schedules

A schedule on its device. `schedule` is the schedule's own id (its file name without extension).

| Field | Type | Meaning |
|---|---|---|
| `schedule` | string | the schedule's id |
| `name` | string | its title |
| `command` | string, default `""` | the command, cut to 1 KiB; blank for a reminder |
| `command_hash` | string | a hash of the full command, to pass to `run_now` |
| `cwd` | string | |
| `cron` | string | |
| `human` | string | the cron in words |
| `cron_error` | string, optional | |
| `output` | string, default `background` | |
| `enabled` | bool, default `true` | |
| `missed` | string | the If missed column |
| `colour` | string | list colour, `#rrggbb` |
| `next_run_ms` | int, optional | next slot; absent when paused, invalid or nothing within 40 days |
| `running` | object, optional | the run going now: `{event, started_ms}` |
| `latest` | object, optional | newest history event: `{event, kind, at_ms, note, exit}` |
| `waiting` | int, optional | its waiting Inbox item |
| `until_ms` | int, optional | when a snoozed Inbox item comes back |
| `scheduler` | bool, default `false` | the device runs the scheduler; only then do runs and Inbox answers take effect |

| Operation | Arguments | Effect on its device |
|---|---|---|
| `run_now` | `{id, command_hash?}` | runs it now; refused for a reminder or a running schedule, `conflict` if the command changed |
| `enable` | `{id, enabled}` | pauses or resumes it |
| `stop` | `{id}` | stops its running run; `conflict` if none |
| `approve` | `{id, item}` | approves the waiting Inbox item |
| `skip` | `{id, item}` | skips it |
| `snooze` | `{id, item, until_ms}` | snoozes it until then (whole minutes, at least one) |

For `approve`, `skip` and `snooze`, another item waiting, or none, is `conflict`.

### flow.schedule_runs

One history event of a published schedule, the last 20 per schedule. Id: `<schedule row id>:<event id>`.

| Field | Type | Meaning |
|---|---|---|
| `schedule` | id → `flow.schedules` | |
| `event` | int | the event's id on its device |
| `kind` | string | `ok`, `fail`, `late`, `caught`, `replay`, `skipped`, `held`, `recovery`, `stopped`, `done`, `approved` or `running` |
| `at_ms` | int | |
| `note` | string | |
| `run` | string, optional | why it ran (`on_time`, `manual`, …) |
| `scheduled_for_ms`, `started_ms`, `finished_ms` | int, optional | |
| `exit` | int, optional | exit status |

## Trash

### flow.trash

A managed git worktree on the device's Trash page, as its last scan saw it.

| Field | Type | Meaning |
|---|---|---|
| `path` | string | the worktree's absolute path on its device |
| `repo_root`, `repo`, `name` | string | its repo's main working tree, repo name, and folder name |
| `branch` | string, optional | |
| `detached` | bool | |
| `head` | string | HEAD's full SHA at scan time |
| `dirty_count` | int | changed and untracked files |
| `ahead`, `behind` | int | |
| `base_ref` | string, optional | |
| `merged` | bool | HEAD is an ancestor of the base |
| `notes` | int | Flow notes files in it |
| `unpushed` | int, optional | commits beyond the base on no remote |
| `pr` | object, optional | `{number, state, title, url, head_oid}`; `state` is `open` \| `draft` \| `merged` \| `closed` |
| `pr_pending` | bool | the pull request isn't looked up yet |
| `size_bytes` | int, optional | size on disk, once measured |
| `last_activity_ms` | int | |
| `in_session` | bool | a session there has its folder inside it |
| `verdict` | `safe` \| `pushed` \| `loses_work` \| `in_use` | the device's verdict |
| `reason` | string | |
| `live_minutes` | int (1–120), default `10` | the device's In use window |
| `scanned_at_ms` | int | when the scan landed |
| `deleting` | bool | the device is deleting it now |

| Operation | Arguments | Effect on its device |
|---|---|---|
| `remove` | `{ids, seen}` (≤ 64 each); `seen` is `[{id, head, branch?, dirty}]` | deletes the worktrees without a confirm there, branches kept. Only rows whose verdict is Safe or Pushed and still match `seen`; anything else refuses the whole request (`forbidden`, `conflict` or `not_found`) |

## Tools

### flow.tool_registry

One CLI tool of the synced registry. **Shared**: any device granted **Can open my sessions** may write it, and fields merge last-writer-wins. Id: the tool's name, encoded.

| Field | Type | Meaning |
|---|---|---|
| `name` | string | |
| `command` | string (≤ 4096 bytes) | |
| `cwd` | string, default `~` | `~`-relative when under the writer's home |
| `enabled` | bool, default `true` | shown in the sidebar's Tools band |
| `icon` | string, optional | the icon picked for it; absent for Automatic |

### flow.tools

One CLI tool as its device has it, sync on or off, in its order. Same fields as `flow.tool_registry`, plus:

| Field | Type | Meaning |
|---|---|---|
| `order` | int | its place in the device's list |
| `synced` | bool, default `false` | the device has `tools.sync` on |

### flow.tool_bundles

A flow tool (from `~/.flow/tools`) the device offers its other Macs: one row per tool that checks clean and fits the limits (64 files, 256 KiB). Another Mac installs it only after a confirm that names the device and lists every file. Id: the tool's name.

| Field | Type | Meaning |
|---|---|---|
| `title`, `description` | string | from the tool's manifest |
| `icon`, `version` | string, optional | |
| `kind` | `cli` \| `tui` | |
| `hash` | string | the bundle hash over every file |
| `base` | string, optional | the bundle this copy was installed from |
| `bytes` | int (≤ 262144) | the files' total size |
| `files` | array (≤ 64) | `{path, mode, sha256, size}` per file |
| `chunks` | int (≤ 6) | how many `flow.tool_chunks` rows hold the content |

### flow.tool_chunks

The content of a `flow.tool_bundles` row, in base64 pieces of 45,000 bytes. Id: `<tool>:<index>`. A piece whose `hash` isn't the tool's current bundle hash is ignored.

| Field | Type | Meaning |
|---|---|---|
| `tool` | string | |
| `hash` | string | the bundle hash it belongs to |
| `index` | int (0–5) | |
| `data` | string | base64 of the piece |
