# See what your fleet does

> See every machine, agent and session on a repository, and read what changed since you last looked.

Source: https://getbay.io/docs/fleet (HTML).

`bay status --all` shows what each agent on each machine works on, and in which agent product. `bay status --since` lists what changed since you last looked: merges, events and invalidations. Both read Git, so you need no server and no SSH between machines.

The fleet map shows your last fetch, not a live feed. It never contacts the remote itself, and it says how old its fetch is. A notice is a convenience. The runner's log and main stay the record.

## When to use the fleet map

- **Before you start**: see who holds a change, and on which machine.
- **Find a stalled session**: see each session's state and the age of its last report.
- **Catch up after a break**: run `bay status --since` with your last cursor and read what merged.
- **Spot a red main**: see which post checks are red, and who works on their paths.
- **Feed a chat or a dashboard**: point the notify plugin at it, and fill gaps with `bay status --since`.
- **Follow open talks**: see every open talk, and how many each session must answer.

## Show the fleet map

Run `bay status` first. It fetches main, then copies each machine's live ref into `refs/bay/fleet/*`. Then run `bay status --all`. It reads that copy and fetches nothing.

```sh
bay status           # fetch main and the live refs
bay status --all     # read the map from that fetch
```

## Where the map comes from

1. **Record** Each agent hook event writes the session's state to a local work record.

2. **Summarise** A hook event starts a background `bay live push`. It pushes at once when a session starts, ends or holds another change. Other changes, such as a new state, go out within a sixth of the takeover window: 20 seconds by default. It writes `refs/bay/live/<machine>`: one commit that holds `live.json`, one row per live session. With a key registry, the agent key of that machine signs the commit. `bay doctor` also pushes this summary with its verdict, when the verdict changed or is 10 minutes old.

3. **Keep each clone's rows** Each clone of the repository on one machine pushes to that machine's one live ref. Each row carries a hash of the path of its clone, so the path stays on the machine. The views of one clone share that hash. A push replaces only its own clone's rows, and keeps each fresh row of another clone. A push takes effect only when the remote ref has not moved since this clone last read or pushed it. When another clone pushed first, bay reads the remote's summary and writes again, at most three pushes in all.

4. **Fetch** `bay status` fetches every `refs/bay/live/*` into `refs/bay/fleet/*`. It records when that fetch first brought each summary, by this machine's clock.

5. **Read** `bay status --all` joins those summaries with this machine's own records. With a key registry, a summary that its named agent did not sign lists no sessions.

## What the map shows

| Field | Meaning |
|---|---|
| `machines` | Each machine in the fetch, with its age, its number of fresh sessions and its last doctor verdict. An unreadable summary shows `readable: false` and why. |
| `machines[].doctor` | The machine's last `bay doctor` verdict: `at`, `bay_version`, `decision`, `reason`, `red` (the red rows' names), `hooks`, `sandbox`, `role` and `age_s`. `null` when it never ran doctor. |
| `this_machine` | The machine this read ran on, as `machines` names it. `null` when bay cannot tell. |
| `ready` | The fleet's count: `machines`, `green`, `red`, `never_ran_doctor`, `unreadable`, and `lowest_bay_version`, the lowest bay a verdict names. |
| `actors` | Each actor the cache knows, the machines it is on, and its freshest age. The senders and recipients of open talks count too. An actor known only as the recipient of an unacked talk has `age_s` `null`. |
| `sessions` | One entry per fresh session: machine, actor, agent, change, state, last event, context use, last write, age and `permission_mode`. It also names the agent `product`, what the session is `waiting_for`, and whether it is `tracked`. |
| `sessions[].behind` | Whether main moved past the base of that session's change. `null` when this cache does not hold the change. |
| `sessions[].behind_commits` | How many main commits the change's base is behind main, in this cache. `null` when `behind` is. |
| `sessions[].session_age_s` | How long ago the session started, without comparing two machines' clocks. `null` when the row does not say. |
| `sessions[].actor_source` | Where the agent's name came from: `env` for `BAY_ACTOR`, else `user-default` or `default`. |
| `default_actor_sessions` | How many fresh sessions took their agent's name from a default, not `BAY_ACTOR`. |
| `behind` | Whether the fetch is behind the remote: `true` once the fetch is one takeover window old, else `null`. Never `false`. |
| `fetched_at`, `fetch_age_s` | When the fetch ran, and its age in seconds. |
| `machines_truncated` | `true` when the map left machines out. |
| `locks` | Each lock held now, with its holder, change and age. |
| `red` | The post checks main is red on, as `bay status` lists them, from the evidence in this cache. An object with `unread` and the reason when bay cannot read what it needs to judge them. |
| `sessions[].on_red` | The red checks whose paths cover the change's declared paths or the files its session last wrote. A held change with no session carries it too. `[]` when none. |
| `red[].suspect` | Where a red post check could have come from: `last_passed`, `first_failed`, and the `merges` between them. `null` when bay finds no range. With no pass within `[red] reach`, `last_passed` is `null`, and `searched` says how many commits bay read. `failing` lists the merges after the first failure, up to the newest, where the check failed or did not run. `check_added` names the merge that added the check, when the check has not passed since. `apart` names the producers of the last pass (`passed_by`) and of the first failure right above it (`failed_by`), when they share none. |
| `red[].culprit` | The one merge the evidence pins as the cause, with each merge tested on the way. `null` until the evidence pins one merge: a bisect, or a pass right below the first failure. A pass and a failure that share no producer pin no merge, and `suspect.apart` names both sides. |
| `red[].fixes` | The one name a fix gives while the red stands: the first failure's change, else the owner. The check's id works too. |
| `red[].changed_check` | `true` when the red's newest failure changed the check itself: its policy entry or an adapter file. A post run judges a merge with the check of the merge before it, so the red's `say` then names the `--fixes <check>` step. |
| `red_pending` | Post checks that no merge in the red window answers yet, each with `state` `pending` or `pending_beyond_window`. A red check a fix answers is `pending_fix`, with that `fix`, until a run passes. Never read as clear. |
| `runners` | Each runner's presence from the same fetch: `machine`, `bay`, `environments`, `last_pass`, `holding`, `queue_depth`, `age_s`, `stale_after_s` and `stale`. An unreadable one shows `readable: false` and why. `stale` is `null` when this clone's copy of the presences is too old to judge, and `stale_why` says why. |
| `targets` | Each promotion target, as `bay status` lists it under `detail.targets`. Promote main to other branches explains targets. |
| `unattributed` | Main commits in this cache that did not merge through bay, as `bay status` lists them. `null` when the cache holds no main. |
| `unattributed.merges[].lane_leak` | With `[[lane]]` in the config, the sandbox lane commits that a merge outside bay brought onto main. Keep experiments in sandbox lanes explains lanes. |
| `talks` | The open talks this clone holds, newest first, up to 24 KiB, with the fields `bay status` lists for a talk. `talks_more` counts the rest. An object with `unread` and the reason when bay cannot read talks. |
| `sessions[].owes_talks`, `owed_talks` | How many open talks the session's agent must answer, and how many it sent that another agent owes. `null` when bay cannot read talks. |

## Untracked and unknown

A held change with no fresh session gets an entry of its own. Its view may be on this machine with no session record here that names it. Then its state is `untracked`. That change had no hooked session, for example one with hooks off. bay never shows it as idle.

Its view may be on another machine. Then bay cannot judge it from here, and its state is `unknown`. A change whose hooked session here ended gets no entry.

## Ages and clocks

- bay never compares the clocks of two machines.
- A row's age starts with the summary's age on your clock, from the fetch that first brought it.
- bay adds the row's age inside the summary, by the clock of the machine that wrote it.
- A row one takeover window old drops out of the map.
- This machine's own sessions come from its local records, not from the remote's copy.

## See each runner

`bay status` fetches each runner's presence with the live refs, and the map lists them under `runners`. A runner is `stale` after three of its own intervals or one takeover window, whichever is longer. While it holds an operation, the progress deadline adds to that, since it writes nothing mid-operation. A stale runner is a warning, never a refusal. Runners says what a presence holds.

> A presence's age follows the clock rules above, so a wrong clock can only make it look older.
> `stale_after_s` gives the age past which each runner is stale, from its own settings.
> With a key registry, a presence that its runner's key did not sign shows `readable: false`.

## See each machine's readiness

`bay doctor` pushes its verdict to this machine's live ref, so the fleet map needs no SSH. It pushes when the verdict changed, or when the one out is 10 minutes old. It pushes only in a repository set up for bay, and only when its `remote` row is green. A clone that records no sessions, such as a runner's clone, never replaces the verdict of a clone that does.

The verdict holds names, states and versions, never a path or a secret. `hooks` says `on`, `off` or `missing`, and `sandbox` gives the state of doctor's `sandbox` row. `ready` counts a machine green when its last doctor decided `ok`, and red for any other verdict. Run `bay status` to fetch every verdict, then `bay status --all` to read them.

```sh
bay doctor           # on each machine: check it; push a changed verdict
bay status           # on any machine: fetch every live ref
bay status --all     # each machine's doctor block, and ready
```

> A verdict's age follows the clock rules above.
> An unchanged verdict's `age_s` can reach 10 minutes, though doctor ran a moment ago.
> A failed push never changes doctor's result.
> The next doctor's `live` row shows it.
> A machine that never ran doctor shows `doctor` as `null`, and counts under `never_ran_doctor`.
> With a key registry, the machine's agent key signs the verdict, as it signs every live summary.

## See the flow of work

A plain `bay status` in the main checkout names the flow of work under `detail.flow`. A read in a view leaves it `null`. It counts the live changes, and each agent's live changes beside its limit. It counts the merges of the last 7 days, and times the merges of the last 30. It names the oldest live change, and the changes that wait for a person's approval.

bay stores none of it. It reads the change records and runner logs this clone holds, and fetches nothing more.

```sh
bay status --json | jq '.detail.flow'
```

| Field | Meaning |
|---|---|
| `live` | How many changes are live: not merged, abandoned or superseded. A lane change counts. |
| `by_actor` | Each agent with a live change: `actor`, `live`, and `limit` from `[agent] max_live_changes`, or `null`. |
| `merged` | How many changes merged in the last 7 days. |
| `cycle_time_s` | `p50` and `p90` seconds from start to merge, and `merged`, how many changes merged in the last 7 days. `null` when none did. |
| `queue_wait_s` | `p50` and `p90` seconds those changes waited in the queue until a runner took them up as its head, and `merged`, how many carry a wait. `null` when none does. |
| `check_time_s` | `p50` and `p90` seconds of one check run, over the check runs of those changes, and `runs`, how many. An unchecked merge ran no check, so it adds none. `null` when none is timed. |
| `units` | The units of the last check runs of those changes. `total` counts them, and `reused` counts the units bay copied from an earlier record. `null` when no run counts its units. |
| `oldest_live` | The live change that started first, and its `age_s`. `null` when none is live. |
| `waiting_approval` | How many live changes wait for an approval (`count`), the `oldest`, and its `age_s` since its merge request. |
| `recent` | The merges of the last six hours: `merged`, `per_hour`, and the spread of `total_s`, request to main. It splits that time into `queue_wait_s` to a first claim, `rework_s` between first and last claim, and `final_s` to main. `share_pct` gives each part's share. `rework` counts work done again by cause, over those merges: `main_moved`, `member_left`, `yields` and `other`. `null` when none merged. |
| `recent.estimates` | How well the estimates held, replayed for those merges at two moments: `sent` and `in_line`. Each gives `cases`, `inside_pct` (the range held the outcome), `early_pct`, `late_pct` and `median_error_s` of the likely time. `null` when none could be judged. |
| `environments[]` | Each check environment has one row. `checks` gives `p50_s`, `p90_s` and `runs`, and `runners` gives `live` and `busy`. `waiting` gives the places in line that may wake a check there. `adds_s` is its slowest check's `p50_s`. `clears_in_s` is how long its live runners take to check every waiting change. |

> Each time is the committer time of the commit that recorded the step, by that machine's clock.
> When bay cannot read the records, `flow` holds `unread` and the reason.

## When a change reaches main

`bay status` estimates when each live change reaches main, from its draft on, under `changes[].eta`. It reads the merges of a recent window, stage by stage, and gives a range, never one time. Its `say` adds a line such as "On main in about 12 min (8 min–20 min).", with main's branch name. A change that stopped, or waits for a person's yes, has no estimate until someone acts. A draft also says what its agent did last, under `changes[].last_activity`. `detail.flow.recent.estimates` shows how well the estimates held.

```sh
bay status --json | jq '.detail.changes[] | {change, eta: .eta.on_main_at, last: .last_activity.kind}'
```

| Field | Meaning |
|---|---|
| `eta.stage` | Where the change is: `draft`, `sent`, `in_line` or `at_head`. |
| `eta.ahead`, `eta.main` | The places in line before it, and main's branch name. A draft or a sent change counts the whole line. |
| `eta.on_main_at`, `eta.remaining_s` | `low`, `likely` and `high`: the 10th, 50th and 95th percentile, as times and as seconds from now. `null` when a stage has too few cases. |
| `eta.stages[]` | Each stage left, its `remaining_s` and the `cases` it stands on. |
| `eta.basis` | The window the cases came from (`window_s`) and how many changes `merged` in it. |
| `eta.speedups[]` | What would bring the change sooner, each as `what` and the `saves_s` it would save, `null` when no case measures it. |
| `eta.environments[]` | The check environments the change may wait for, each with its live `runners`. |
| `started_at` | When `bay start` opened the change. |
| `last_activity` | `at`, `age_s`, `in_view` and `kind`: `edit`, `check`, `commit`, `bay`, `command`, `read`, `working`, `idle`, `waiting` or `ended`. `waiting_for` names what a waiting agent waits for. |

## See the line

`bay queue` prints the live line, head first, as one `bay.queue/1` document in `detail`. Each place names its change, operation, intent, agent, paths, wait, state and runner. `arriving` lists the changes submitted that no runner has placed yet, oldest request first. With no runner running, those changes are the whole line.

`bay queue` reads only the live places and their change records, never the line's history, so it stays fast. It writes only fetched copies of the remote's refs. Change the line with `bay merge`, `bay abandon` or `bay start <change>`.

```sh
bay queue --json | jq '.detail.places[] | {place, change, state, waited_s}'
```

| Field | Meaning |
|---|---|
| `read_at` | When bay read the line. |
| `depth` | How many places the line holds now. |
| `oldest_wait_s` | The longest wait in seconds, over the places, `arriving` and `taken`. A change held by `--after` does not count. `null` when nothing waits. |
| `places[]` | Each live place, head first: `place` (1 is the head), `seq`, `change`, `op_id`, `intent`, `actor`, `paths`, `fixes` and `after`. |
| `places[].joined_at`, `places[].waited_s` | When the change joined the line, and how many seconds it has waited since. |
| `places[].state` | The operation's state as its record says: `submitted`, `admitted`, `running`, `checked`, `merged`, `blocked`, `failed`, `superseded` or `no_effect`. `unread` when bay cannot read the record. |
| `places[].expedite` | `true` for a place that `bay merge --expedite` got. That change runs next, alone, right behind the head. |
| `places[].attempts`, `places[].runner`, `places[].outcome` | How many attempts the operation has, the runner that took it, and its outcome. `null` when the record does not say. |
| `arriving[]` | The changes submitted that no runner has placed yet, oldest request first, then by change id, each with `requested_at` and `waited_s`, its `outcome`, and in `held_by` the `--after` changes not on main yet. |
| `taken[]` | Each change a runner checks with no place in the line, such as one it took off an empty line, oldest request first. Each names its `runner`, `state` (`running` or `checked`), `beat_at`, `requested_at` and `waited_s`. `checks` lists the operations its check covers, or `null` while the runner plans. |
| `arrivals_listed` | `false` when a read from this machine's copy could not list `arriving`, because no sweep has run here yet. The line's sentence then says so. |
| `sweep` | On a read from this machine's copy past its sweep window: the sweep that refreshes it, `started` by this read or already `running`. `null` when the read started none. |
| `unread[]` | Each change bay could not read, with `why`. |

> `bay help --json` carries the schema as `queue_schema`.
> `bay queue` reads no merged change and no evidence.
> `bay status` reads those.

## Read what changed

`bay status --since` fetches main and the runner logs, then lists what happened after a cursor. It lists merges into main, `bay.event/1` events from the runner logs, and new invalidations of your change. It also lists a `main_red` event when a post check turns main red, and `main_red_cleared` when it clears. In a view, it lists only the red checks whose paths cover the change's declared paths.

`bay status --since` returns `detail.cursor`. Pass it to `--since` next time to go on from there. The cursor is opaque. Use it as bay returned it.

```sh
bay status --since           # the current state of this view's change
bay status --since <cursor>  # what happened after that cursor
```

> When bay cannot read the key registry, it judges no red, and `detail.red_unread` gives the reason.
> The cursor then keeps the red checks it held, so the next `--since` judges them again.
> When bay cannot read talks, `detail.talks_unread` gives the reason, instead of an empty list.

## What it lists

- In a change's view, it lists only events that touch that change's inputs, and your talks.
- Those are events about the change itself, about the policy, or about an input it declared.
- Outside a view, it lists every event and judges no change.
- Without a cursor, a view gets its state first: merges since its base, its events and its invalidations.
- Offline, it reads the local cache, and `freshness` says so.
- `bay status --since` writes no change record and sends no notice. Like `bay status`, it accepts and acks your talks.

### Talks since a cursor

`bay status --since` also follows each open talk you sent or must answer, through its cursor. It lists `talk_arrived` the first time it sees an open talk to you. It lists `talk_answered` when a talk gets a new reply, such as an answer. It lists `talk_lost` or `talk_stale` when a talk turns lost or stale. It lists `talk_closed` once when a talk closes, with `state` set to `answered`, `superseded`, `expired`, `done` or `ended`. Each event carries the talk's row from `bay status`, and `talk_kind` names the talk's kind.

> A talk that opens and closes between two cursors is in neither answer.
> `bay status --since --merged` lists no talk events.

### Targets and lanes since a cursor

Outside a view, `bay status --since` lists `target_moved` when a promotion target moves to a commit its rule allows. It lists `target_unpromotable` when a target moves to a commit that fails its rule. Without a cursor, it lists `target_unpromotable` for each target whose tip fails now. An `outside_merge` event also names `lane` and `lane_leak` for lane commits that a merge outside bay brought. `detail.red_pending` lists the post checks that no merge in the window answers yet, and those a fix waits on. Promote main to other branches and Keep experiments in sandbox lanes explain both.

## Find what turned main red

A red post check names its `suspect` range: the last pass, the first failure, and the merges between. With `[runner] bisect_post = true`, a runner narrows that range to one `culprit` merge. With no pass in its window, bay reads back down to `[red] reach` main commits, 250 by default. Configuration explains the range, the bisect and the red window, under "When a post check fails".

```toml
[red]
window = 200          # main commits a red judgement reads; 50 by default
reach = 500           # how far back a red check with no pass in its window looks; 250 by default

[runner]
bisect_post = true    # narrow a red post check to one culprit merge
```

## Read merges only

`bay status --since --merged` lists only the merges after a cursor, with no events and no invalidations. Each merge names its base, its agent and its commit time. A commit that merged outside bay stays in the list with `outside_bay: true`, and `merged_as` says `merge` or `outside`. `off_first_parent` counts the commits reached only through a merge, and the list leaves them out. One exception: the list holds a bay merge that a merge outside bay put off that line, with `via`.

```sh
bay status --since <cursor> --merged
```

## Merges outside bay

People can merge a pull request or push to main without bay. `bay status` names each such main commit under `detail.unattributed`, and the fleet map under `unattributed`. It reads the newest `[red] window` first-parent main commits, 50 by default, after the commit that added `.bay/config.toml`. A commit is a bay merge when it carries one `Change-Id` and, with a key registry, verifies as one. Outside a view, `bay status --since` also lists an `outside_merge` event for each such merge it lists. A bay merge that such a merge put off the first-parent line still counts as a bay merge.

| Field | Meaning |
|---|---|
| `window` | The most first-parent main commits bay reads: `[red] window`, 50 by default. A young main may hold fewer. |
| `count` | How many commits in the window did not merge through bay. |
| `by_writer` | The same commits counted per committer, as Git records it (`Name <email>`), the most first. |
| `through_bay` | How many commits in the window merged through bay. `bay doctor` reads both counts. |
| `merges[]` | Each such commit, newest first, with its `commit`, `base`, `at` and `subject`. |
| `merges[].merged_as` | `merge` for a commit with more than one parent, else `outside`. |
| `merges[].merged`, `merged_count` | Up to 20 commits that a merge brought in, and how many there are. |
| `off_first_parent` | The sum of `merged_count` over every merge listed. |
| `merges[].merges_off_first_parent` | How many bay merges this merge put off the first-parent line. `landings_off_first_parent_capped` says bay stopped reading at 500 commits. |
| `merges_off_first_parent` | The sum of `merges[].merges_off_first_parent` over every merge listed. |
| `merges[].lane`, `merges[].lane_leak`, `lane_leaks` | With `[[lane]]` in the config: the first lane a merge brought commits from, those commits, and how many merges name a lane. |
| `unread` | Present instead when bay cannot read main, with the reason. |

> On a main branch from `bay host` with a key registry that signs everything, the host refuses such a push.
> On a forge, bay names these commits but cannot stop them.
> `bay status` also names `detail.guard.hook`: `on` when main's config sets `[agent] product = "claude"`, else `off`.
> With Codex it says `off`: Codex can run a tool when bay's hook fails, so bay's deny there is advisory.
> Security and privacy says what bay guards, and when.

### When a merge outside bay hides bay merges

On a forge, someone can push a merge whose first parent is an older main commit. Then bay's merges sit behind that merge's other parent, off main's first-parent line. bay still finds them by ancestry, and places each one at the merge that brought it in. Red judgements, culprits and promotion targets find them there. `bay undo` finds such a merge by ancestry.

`bay status` warns `main_not_linear` under `detail.warnings` for each such merge in the `[red] window`. `bay status --since` names each new such merge once, never with `--merged`. In a view, it names one only when that merge touches the change.

> Each warning names the merge, its `parents`, how many bay merges it put off the line, and a hint.
> Require linear history for main on your host, so only fast-forward pushes reach it.
> bay reads at most 500 commits behind one such merge, and `capped` says when it stopped.

## Find stranded work

`bay status --branches` lists work that exists only on this disk under `detail.stranded`. It names each local branch with commits that no remote-tracking ref holds. It also names each worktree record whose folder is gone. It reads local refs for that part, and never prunes or deletes.

```sh
bay status --branches --json | jq '.detail.stranded'
```

## Clean up merged branches

`bay status --branches` lists every branch on the remote, each with one class. The census costs one `ls-remote` and one fetch, and deletes nothing. `bay prune` lists the archive refs, then archives and deletes only branches shown on main by `ancestor` or `patch`. Before each delete, it archives the tip under `refs/bay/archive/heads/` on the remote, and logs the push that restores it. It deletes under a lease on the tip it judged, so a branch that moved since stays. A branch that only carries a merged change's `Change-Id` stays, because it may hold other work.

```sh
bay status --branches                  # every branch on the remote, with its class; deletes nothing
bay prune                              # delete the merged ones, each archived first
bay status --branches --stale-days 14  # stale after 14 days, not 30
```

| Class | Meaning |
|---|---|
| `main` | Main itself. Never deleted. |
| `target` | The ref of a `[[target]]`. Never deleted. |
| `lane` | A ref that a `[[lane]]` pattern matches. Never deleted. |
| `merged` | Everything it holds is on main. `proof` says how: `ancestor`, `patch`, or `change` (a merged `Change-Id`). `bay prune` deletes it, unless the proof is `change`. |
| `stale` | It holds commits main lacks, and its tip commit is older than `--stale-days`, 30 by default. Never deleted. |
| `unique` | It holds commits main lacks. Never deleted. |

> `detail.pruned` names each deleted branch with its `restore` command, and `detail.skipped` says why others stayed.
> The restore lines also go to `bay/pruned-heads.log` in the repository's common Git directory.
> With a key registry, a host from `bay host` takes an archive ref once, and refuses to move or delete it.

### Run a step after each prune

A deleted branch can leave work elsewhere, such as an open pull request on your host. `[plugin.prune] command` in main's config names a program that bay runs after each branch `bay prune` deletes. bay runs it as `<command> pruned <branch> <sha> <archive ref>`, from main's tip, never from your work tree. It gets only `PATH` and `HOME`, and 30 seconds by default, which `timeout_s` changes. Each `detail.pruned` row records `on_prune`: `ok`, and `why` when the plugin failed or did not run. A failing plugin never undoes the delete, and bay prunes the next branch as usual.

```toml
# .bay/config.toml
[plugin.prune]
command = "scripts/bay-on-prune"   # runs as: scripts/bay-on-prune pruned <branch> <sha> <archive ref>
timeout_s = 30                     # 1 to 600 seconds; 30 by default
```

> bay itself never closes a pull request or calls your host.
> The plugin is where you do that.
> It runs on the machine that ran `bay prune`, with no sandbox.

## Get notices

Set `[plugin.notify] command` in main's `.bay/config.toml` to a program in the repository. The runner runs it once after each event it writes, with the event's JSON on stdin. Exit `0` means delivered. Any other exit, or no exit within `timeout_s`, 5 seconds by default, means lost.

bay never retries a lost notice. `bay status --since` still lists the event. Each event carries an id, so the plugin can drop duplicates. The plugin gets only `PATH` and `HOME` from the runner's environment.

```toml
[plugin.notify]
command = "scripts/notify"   # gets one bay.event/1 on stdin, exits 0 when delivered
```

> Test the plugin with `bay plugin test notify -- scripts/notify` before you merge it.

## What the map cannot do

- It cannot ask the remote. It is as fresh as your last `bay status`.
- It cannot see inside a session with hooks off. It shows that session's change as `untracked`.
- It reads at most 256 machine summaries.

## Refusals

`bay status --all` fails closed with `REMOTE_NOT_FETCHED` until `bay status` has fetched the live refs. A fetch from another remote URL does not count. The result is `blocked`, exits `10`, and lists no machines, actors or sessions.

| Code | Meaning |
|---|---|
| `REMOTE_NOT_FETCHED` | The local cache has no recorded fetch of the configured remote's live refs, so it is not the fleet. |

> A cursor that bay did not return is a usage error.
> When this repository lacks the cursor's main commit, `bay status --since` fails.
> Run it again without `--since`.

## Not built yet

bay has the map, talks, the notify plugin, and wakes for merge outcomes and for conflicts in line. It does not have this part yet:

- Waking an idle session when main moves its draft's inputs, or another change supersedes its draft.

## Limits

- **Machines**: the map reads 256 summaries at most.
- With a registry, a bay-hosted main holds at most 256 live refs.
- **Summary**: `live.json` is at most 32,768 bytes and keeps the newest 64 rows.
- **Push rate**: a summary goes out at once when a session starts, ends or holds another change.
- Other summaries wait up to 20 seconds by default.
- A runner presence goes out at most once per heartbeat, 10 seconds by default.

- **Freshness**: a row drops out after one takeover window, 120 seconds by default.
- **Since a cursor**: one answer lists at most 500 merges and 500 events.
- `more` says when more follow.
- **Notices**: the notify plugin has 5 seconds per event by default, and hook notices 2,048 bytes a session an hour.
