Keyboard shortcuts

Press ← or β†’ to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

collie architecture πŸ‘

iPhone (Collie.app)                                   Mac (or Linux)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SwiftUI (Swift 6, UI only)    β”‚                     β”‚ collied (launchd agent, user)        β”‚
β”‚  β”” CollieCore (UniFFI)        β”‚   tailnet (WG)      β”‚  β”œ tailnet node (user-owned)         β”‚
β”‚     β”œ protocol codec          β”‚ ── WebSocket/JSON ─▢│  β”‚   tailscale_listen :port only     β”‚
β”‚     β”” tailnet node (libts)    β”‚   dial only         β”‚  β”œ whois gate β†’ paired node IDs      β”‚
β”‚ CollieWidgets  (Swift only)   β”‚                     β”‚  β”œ protocol allowlist + audit log    β”‚
β”‚ ColliePush NSE (Swift only)   │◀── APNs ────────────│  β”œ approvals (nonce, expiry, replay) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                     β”‚  β”œ APNs client (Keychain .p8, HTTP/2)β”‚
                                                      β”‚  β”œ herdr client ─▢ herdr.sock (0600) β”‚
                                                      β”‚  β”” herdr-core client ─▢ hc socket    β”‚
                                                      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

On Linux, collied is a systemd user unit (Linux). The service logs warnings and errors to its stderr (collied.err.log in the data folder on macOS, the journal on Linux); RUST_LOG overrides that level. A warning whose cause lasts is logged when it starts, not on every retry: a failing accept on the control socket at most once a minute and on the tailnet once until an accept succeeds, a herdr outage seen by the phone's list request once until herdr answers it, and an agent with an invalid id (shown escaped) once while it is listed. collied exits with a failure status, so launchd or systemd restarts it, when a loop it needs for its whole life returns or panics before shutdown: the tailnet and control socket accept loops, the agent reconcile (approvals and alerts), the Herdr Core and Rex followers, and push delivery (#822). The pull request, plan usage and upkeep loops are left out: without one of them the phone still sees agents, decides and is alerted, and a restart would drop its sessions. It logs which loop ended. A loop that fails at every start therefore restarts collied at the service manager's pace instead of leaving it running without that loop.

Decisions (2026-10-03)

  • Phone and computer run independent embedded nodes owned by the same personal Tailscale user. Authorization checks the node's own positive owner, a same-user untagged and unshared whois, the paired StableID and independent TLS key pins. Neither needs an OS VPN profile or the native Tailscale client; the Mac's corporate VPN is separate.
  • libtailscale: upstream submodule pinned by SHA, plus a patch series in crates/tailscale-sys/patches.
  • XcodeGen generates the iOS project from Collie/project.yml; .xcodeproj is not checked in.
  • APNs display content (alert titles, bodies and approval context; initial, update and end Live Activity labels and state) is authenticated ciphertext under each phone's per-machine notification key. Public alerts stay generic. Approval nonces never enter a push.
  • macOS: arm64 only.
  • 2026-10-04: collied also runs on Linux. x86_64 is built and tested; aarch64 is mapped in tailscale-sys but not built or tested. Any other OS is a compile error.
  • 2026-10-04: on Linux the service is a systemd user unit with the launchd agent's semantics: kept alive, and collied stop keeps it off across reboots until collied start.
  • 2026-10-04: each machine sends its own pushes with its own APNs key (own key ID, revoked on its own). On Linux the key is a systemd user credential (host key, plus the TPM2 when systemd finds one usable), or a 0600 file when systemd-creds is unavailable.
  • 2026-10-06: plain shell panes from the phone (Terminals): off by default, turned on per machine only in collied.toml, never from the phone; their own allowlist class, audited like prompts. Opening one and typing into it need a grant collied verifies, signed by a second Secure Enclave key that signs only after Face ID or the passcode; one grant covers one terminal for 5 minutes in one session.
  • 2026-10-16: user-owned embedded desktop nodes replace the per-OS tagged identities. Existing tagged nodes and old phone owner pins need an explicit reset and re-pairing; nothing is migrated or retagged. Normal user key expiry applies on both ends. No version bump: no phone wire type changed; the positive owner pin is local persistence and the OS is netmap presentation metadata.
  • 2026-11-20: decisions that code comments carried are architecture decision records in docs/adr. Comments are limited to the classes ADR-0001 allows, and scripts/comment-ratchet.py keeps their count per file from growing.

herdr integration (verified against 0.9.3 source and live socket)

  • The socket answers one request per connection (NDJSON, 5 s timeouts, 1 MiB line), so collied opens a connection per call; long calls (events.subscribe, waits) get their own. On each connection collied reads the peer's uid (peer_cred) before it writes the request, and sends nothing to a herdr another user serves: the call fails with "herdr is served by another user", which counts as a herdr that runs and does not answer, and collied doctor fails the herdr line with it whether or not Herdr Core or Rex answers. It matters where collied, as herdr does, falls back to the temp dir for the socket (neither XDG_CONFIG_HOME nor HOME set), which any user can write to.
  • herdr has no auth: same-UID means full control. collied's allowlist is the only boundary between the phone and every shell on the machine.
  • No global agent-status stream: pane.agent_status_changed is per pane, and pane.updated ignores status. collied keeps one subscription (lifecycle events plus a status entry per agent pane), rebuilt on pane.created/closed/moved/exited/agent_detected, workspace.closed and events_lost because an entry for a vanished pane goes silent; a 1 s agent.list reconcile plus ping covers silent streams. It sends agent.status when an agent's state_change_seq, status, title, name, kind or cwd changes, or, while a phone has a session open, its transcript values (below), and flock.changed when agents come, go or change workspace, or a workspace is renamed or renumbered.
  • Agents are keyed by terminal_id; pane_id changes on cross-workspace moves and never reaches the phone. Statuses: idle | working | blocked | done | unknown.
  • With no phone session connected, a status change reads no transcript and builds no event; status times, pane cleanup, approvals, done alerts, followed Live Activities, Tailscale upkeep and APNs carry on. A connection lost without a close frame ends at the 45 s silence limit (collied pings every 15 s).
  • No output stream in the JSON API. During agent.watch, collied polls agent.read {source: recent_unwrapped, lines, format: ansi} at 4 Hz (1 Hz after 5 s without a change) and pushes only changes. The phone's lines is clamped to 1 to 1000, 200 when absent. In Low Data Mode (NWPath.isConstrained) the phone sends low_data: true on agent.watch and terminal.watch, and collied polls that watch at 1 Hz throughout; low_data can only slow a watch.
    • The first push of a watch is a full agent.output; later ones are agent.output_patch {terminal_id, base, head, skip, keep, tail, trail, truncated} when that carries at most half the text. The new text is, joined with \n: the head lines, lines skip..skip + keep of the previous text, the tail lines, then the last trail lines of the previous text, starting at or after skip + keep. A Claude Code spinner tick then costs a few hundred bytes. base is the 64-bit FNV-1a of the previous text; collie-core applies a patch only to the text its watch delivered last and only when base matches, else it re-issues agent.watch.
    • The phone sends its Scrollback setting with agent.watch and recent reads. It renders at most 2000 rows and, without wrapping, 500 columns. In wrap mode it drops the oldest lines that would not fit and breaks a line after the last space that fits, continuing at the line's indent or past a leading symbol such as ⏺; each break is a NEL, so selection, copy and links read the line whole.
    • Claude Code's fullscreen mode ("tui": "fullscreen") draws in the alternate screen and keeps its own transcript, so the pane has no scrollback and an ANSI read returns only visible rows.
    • Reads and changed watch output drop Copilot's terminal-cell scrollbar, a trailing ┃ set off by a space: at the column that repeated, separately styled scrollbar cells outside boxes give (Copilot 1.0.100-1 can draw it one column inside the width herdr reports), else at the pane width. A ┃ in a row with box drawing stays unless styled apart. Wrap detection runs on the original rows. No version bump: only read normalization changes.
    • Copilot's wraps and splits (as for Claude Code, below) cover its prose under ● and its sent prompts, shaded β–„-to-β–€ boxes whose text wraps at the box's width before an HH:MM timestamp. A row joins the next only where Copilot certainly broke it after a word: it ends with one space in the text's style and the next word would not have fit. Any other row stays, since a typed newline looks the same.
    • Claude Code wraps its prose at the pane width with real line ends, which recent_unwrapped cannot undo, so for a Claude Code agent agent.read and each changed watch push list the rows that continue a paragraph wrapped at the layout width: wraps (after a space) and splits (inside a word), on TerminalRead and, when they changed, on agent.output_patch. With line wrapping on, the phone joins those rows and rewraps at its own width.
      • Width: the widest all-─ row from column 0 that is no wider than the pane (the input box's rules, drawn at exactly the terminal width), else herdr's pane.layout width, which is 1 to 3 columns wider than the terminal (1 for a single pane, 2 or 3 in a split): enough to read a soft wrap as a typed newline. A zoomed tab, or no width from herdr, joins nothing.
      • Rows that count: prose under an indent-0 ⏺ or β€» row (Claude Code 2.1.327 draws ● for ⏺ on any platform but macOS, and its feedback surveys' questions behind ● everywhere, which never count) at exactly the hang of the row above (numbered items also at the number's indent, as Claude Code 2.1.303 continues them across blank rows; Claude Code 2.1.317 numbers nested items a. and then i.), and a shaded sent prompt's rows, wrapped 3 columns short of the terminal width as the draft is wrapped (wrap-ansi {hard: true, trim: false}): after a row ending with a space in the text's style where the next word would not have fit, and after a row its text fills, which Claude Code 2.1.330 ends without that space and follows with a row holding one column less (a typed newline right after a full row looks the same as a wrap and joins; words longer than a row join as Draft sync reads them). The ⎿ attachment row below a sent prompt never joins it. In a list, Claude Code 2.1.317 draws an item's code block at the list's indent and the paragraph after it back at the item's text indent, without blank rows. A row at another indent than the hang above starts a paragraph only at the marker or text indent of a list item since the last blank or indent-0 row, and only where the row above certainly ended (its first word would have fit there); after any other such row, nothing joins until a blank row. A letter or roman numeral marker counts only at a list item's text indent: a wrapped row like v. Wade elsewhere still joins, but at that indent it reads as an item, so it and the rows after it stay unjoined. A paragraph whose first row keeps leading spaces (Claude Code 2.1.317 keeps them on the first row only, also after ⏺, where they count toward the row's width) continues at the reply's indent, unless a list or held rows, such as code, came after the last paragraph at the reply's indent: there an indented row may belong to them, so it keeps its own indent. Never list items, tool calls and their output, box, table and quote (β–Ž) rows or the status line. Wide characters cut one column short of the edge split only inside a word longer than a row, so Korean words keep their spaces.
      • The input box's unsent ❯ text joins where Draft sync reads a soft wrap or a split word, at the box's own width (its bottom rule's, minus 4), so the phone rewraps the whole draft and its cells match Claude Code's text. A typed newline stays a row of its own, except one right where the next word would not have fit, which looks the same as a soft wrap and joins. Bash mode (!) and other modes join nothing. No version bump: only which rows are listed changes.
      • Claude Code's true black background (a standalone 48;2;0;0;0, used by its logo) becomes the default background, so it does not show as black cells on the phone.
    • Codex's wraps and splits (prose under β€’, sent prompts under β€Ί) take the width of the widest blank row shaded from column 0 that is no wider than the pane (Codex pads its composer and sent prompt boxes to exactly the terminal width), else the pane.layout width, 1 to 3 columns too wide here as well (codex-cli 0.163.0 and herdr 0.9.5: 205 columns for a 206-column rect, 101 and 100 for two 103-column split panes).
    • Antigravity's wraps and splits cover indent-2 prose (including prose directly under column-0 β€’, ● and β—‹ action or thought rows without a blank line), expanded thinking paragraphs under β–Ύ Thought and list items above the > input box (continuing either under the marker, as Glamour draws them, or at the text's hanging indent), using the widest all-─ rule no wider than the pane (as for Claude Code) else the pane width, minus three columns on the right (the alt-screen scrollbar column and Glamour's two-column right margin), plus Question dialogs under a Question heading and its ─ rule (column-0 question text and > or indent-2 options whose continuations wrap at column 0 at the rule width, stopping before the ↑/↓ footer), plus soft-wrapped rows inside the > input box at its bottom rule width minus 4 (two columns for the prompt or indent, one for the cursor and one right margin), plus the rows of a sent prompt in the scrollback (a column-0 > row above the input box and its indent-2 continuation rows) at the rule width minus 3, as in the input box it was typed in. A typed newline or indent in a sent prompt stays a row of its own, except one right where the next word would not have fit; a blank row, the β–Έ attachment row and the action rows end the sent prompt and stay unjoined, and its paragraphs after a blank row it contains are read as indent-2 prose. Indented tool output, fenced code blocks, box drawing, dim placeholders or hints, rows below the input box, and an input box with a > row below it stay unjoined. No version bump: only which rows are listed changes.
  • herdr's agent.prompt refuses blocked agents; its agent.send_keys does not. collied also rejects agent.prompt for an agent it sees as blocked, re-read with agent.get just before the call. Manual input to a blocked agent goes through agent.send_keys and agent.type_text (Prompts without decisions).
  • Scrolled-up Claude Code. While Claude Code's fullscreen transcript is scrolled up on the machine, a permission prompt scrolls out of view and herdr reports the agent idle, so keys would answer it unseen. collied refuses agent.send_keys, agent.type_text and agent.prompt to a Claude Code agent that is not blocked (agent_not_ready) when the visible screen, read just before the write, shows the "Jump to bottom" or "N new messages" banner. protocol::jump_banner matches it as Claude Code draws it, a space-padded label on an SGR background: its own background run (with or without its hint) or, as herdr writes no escape between it and same-style prompt text, label and hint centered on the row inside a run.
    • agent.scroll_bottom {terminal_id} (Drive class, audited, idempotent so no op_id) sends Ctrl+End as the fixed bytes ESC[1;5F through pane.send_text (herdr 0.9.3 has no key name for it), only to a ready or blocked claude agent while the banner shows; nothing from the phone becomes input. Ctrl+End never moves a dialog's selection; a prompt it brings back is blocked again with a new state_change_seq, so its approval is raised again. Meanwhile the phone offers a Jump to bottom button and disables the key strip.
    • Limits: background text quoting the padded banner (a prompt row or diff line) reads as scrolled up until it scrolls away. A banner without color (FORCE_COLOR=0) or in reverse video is not detected. A prompt that appears while already scrolled up is not blocked, so it raises no approval or notification until scrolled back down.
  • Claude Code notices. Notices above Claude Code's input box (the "Heads up" tip, its Learn more explanation, the feedback row after a Dismiss, the session rating) take a single keypress, which a prompt cannot carry (herdr pastes it and ends it with Enter). protocol::notice reads any notice's options from the screen by one rule, not a list of known notices; only the rating's lead is told by its wording:
    • Options are rows indented two spaces whose cells all read <digit>: <label>: digits exactly 1 to n (n up to 4), then 0: Dismiss; each label non-empty, at most 64 characters, with no control or format character and no :. Above them is the lead: a row starting at column 0 with ✦ (tips), or with ● and the wording of one of Claude Code's surveys (protocol::SURVEYS, which the wrapping rules above read too: the rating's "How is Claude doing this session?", and "How was Claude's recollection?", which no capture shows and is assumed to be drawn as the rating is). The lead may carry the first options, and rows indented two spaces or blank follow it. Below them, after at most three blank rows and right-aligned hint rows, is the input box: the last row starting at column 0 with ❯, directly under the box's top rule (─, or a renamed session's ─── <title> ─). A dialog replaces the box, so it never matches.
    • Transcript rows start with other glyphs (⏺ reply on macOS, ❯ prompt, ✻ finished turn), so a reply in that shape does not match. Off macOS Claude Code 2.1.327 marks replies with ●, the rating's glyph, so ● leads a notice only with a survey's wording: a reply ending in rows shaped like options, directly above the box, is not a notice unless it starts with that wording (see the threat model). A question wrapped off its first row gives no options; the one capture that narrow (32 columns) gave none before, its options being drawn into each other. When the lead holds a blank row, as an explanation's side-agent text does, the options must follow a blank row and sit directly on the box's top margin (or the blank rows above a hint), with no other blank row below them, since each card a side agent writes ends with a blank row. Anything else gives no options.
    • agent.answer_notice {terminal_id, digit, label} (Drive class, audited with the digit and label; no op_id, since a replay finds the notice gone) sends the digit alone through pane.send_text. collied sends it only to a ready claude agent (never blocked, where a digit could pick a permission option) with no banner, and only when the visible screen, read just before the write, lists that digit with that label directly above an empty input box (the dim placeholder counts as empty): notices reuse digits, and a digit must never land in a draft. It then holds the input box lock for up to 1 s, until the box shows something other than empty or the digit, since the option Claude Code runs 400 ms later can fill the box and a prompt pasted meanwhile would submit that fill.
    • The phone shows the options as buttons for a Claude Code agent that is not blocked or scrolled up, 600 ms after first seeing them (Claude Code ignores a digit typed sooner, leaving it in the box).
    • Option effects are Claude Code's: Chat in main session and feedback option 4 (/plugin disable cc-plugin-you-should-know@builtin) fill the box unsent (Claude Code would submit the note only with no input box, and collied answers only above an empty one), and the phone withholds Enter from the key strip while it knows the box starts with /; feedback options 1 to 3 log an event about the tip (enums and counts, never its text or the transcript). A Claude Code plugin whose band draws this shape is answered the same way, and its option's code runs (see the threat model). What follows a rating is answered on the machine.
  • Prompt text rejects ESC and C0/C1 controls because herdr pastes it with bracketed paste.
  • Residual race (herdr side): herdr checks the foreground agent before queuing the text and the delayed Enter, so if the agent exits in between, the shell receives the prompt. Closing it needs a conditional input in herdr (expect: {terminal_id, state_change_seq, foreground pid} on agent.prompt / agent.send_keys), to be proposed upstream.
  • Mutations (agent.prompt, agent.send_keys, agent.type_text, agent.send_text, task.new, task.schedule, task.unschedule, task.archive, terminal.run, terminal.send_keys, terminal.send_text, attachment.begin, attachment.commit) carry a client op_id; collied keeps a per-peer outcome cache so a retry after a dropped connection returns the first result.
  • Task folders. task.options also returns roots, the canonical [tasks] roots. task.folders {path} (Drive class, read-only so no op_id, audited with the path and count, never the names) lists the folders directly inside a folder under the roots. collied opens the canonical path one component at a time from its root with openat(O_DIRECTORY | O_NOFOLLOW), so a folder swapped for a symlink after the check fails instead of leading outside, and refuses (folder is hidden) a path through a folder below the root that starts with a dot or, on macOS, carries UF_HIDDEN, such as ~/.ssh or ~/Library. Of at most 10,000 scanned entries it returns at most 500, sorted case-insensitively: valid FolderNames (1 to 255 bytes; no leading dot, /, \, control, format or invisible character, or surrounding whitespace) that are directories, or symlinks resolving to a directory under the roots, and on macOS not UF_HIDDEN. Nothing inside the folders is read.
    • new_folder on task.new (a FolderName) is created inside cwd, which is opened and refused when hidden the same way; a path reaching 1024 bytes is refused. collied runs mkdirat(parent_fd, name, 0755) (any existing entry, symlink included, is folder already exists) and checks that <parent>/<name> resolves under the roots to that folder (same device and inode) before starting the agent there; nothing else is created. The audit target is <path> (created), else <cwd> new_folder="<name>". The op_id covers the whole request, so a retry replays the first result. A failed start leaves the folder and says so.
    • Only the phone keeps the base folder, per machine (taskBases in prefs.json), as task.folders returned it, so a folder collied refuses is never stored; New Task completes names locally and sends <base>/<name>, which collied checks like any cwd.
  • Clone. clone on task.new (a CloneSource, exclusive with new_folder and worktree) is owner/repo (GitHub), https://host[:port]/path or git@host:path, every path segment ASCII letters, digits, ., _ or -, starting with neither . nor -. Both ends refuse any other transport, a local path, userinfo, a query, .. or a leading - at parse time. collied creates the folder (the last segment without .git) inside cwd as for new_folder, then clones into it: owner/repo with gh repo clone -- owner/repo <folder> when gh is in /opt/homebrew/bin, /usr/local/bin, /usr/bin or ~/.local/bin, otherwise (or when gh exits 4, not logged in, and left the folder empty) with git clone -- https://github.com/owner/repo.git <folder>; a URL with git clone -- <url> <folder>.
    • The child gets null stdin, GIT_TERMINAL_PROMPT=0, GH_PROMPT_DISABLED=1, none of collied's GIT_* variables, no GH_TOKEN or GITHUB_TOKEN, and, through GIT_CONFIG_COUNT, protocol.allow=never with only https and ssh allowed (file, ext, git and http denied explicitly), which outranks config files and survives a url.<base>.insteadOf rewrite. It runs in its own process group, killed 75 s after the first attempt or when dropped.
    • A failed clone returns the cleaned tail of git's stderr (at most 1000 bytes) and removes the folder if it is empty again. The audit target is <cwd> clone="<source>", or <folder> (cloned) clone="<source>" after a successful clone, which stays if the agent then fails to start. The phone waits 165 s for the reply.
  • Pull request worktree. task.new's worktree can be {"mode": "pull_request", "number": N}, N from 1 to 2^32 - 1. collied lists the repository with herdr as for Create, then runs gh pr view N --json headRefName,headRefOid,isCrossRepository in its checkout, with the linked pull request read's gh and environment (30 s).
    • A pull request from a fork (isCrossRepository) is refused: its branch is someone else's code, and a project's agent settings in it would run on the machine. The untrusted head branch must pass the typed branch name rules (ASCII letters, digits, /, ., _ and -, no .., no leading -, no trailing /, at most 255 bytes) and git check-ref-format --branch, the head commit must be 40 or 64 lowercase hex digits, and .worktree/<branch with / as -> must not exist.
    • collied fetches only that branch, with the clone's environment (git fetch --no-tags --no-recurse-submodules --no-write-fetch-head origin -- +refs/heads/<branch>:refs/remotes/origin/<branch>), checks that origin/<branch> is the head commit gh named (else try again), and creates a tracking branch unless the branch exists; an existing local branch at another commit refuses the task and is not moved. The task then continues as Create. The gh read, the checks and the fetch share one 75 s budget. The audit target is <cwd> pull_request=<N>; the phone waits 165 s for the reply.
  • Issue worktree (#940). task.issues {cwd} (Drive class, read-only so no op_id, audited with the path and count, never the titles) runs gh issue list --state open --limit 50 --json number,title in a folder under the roots, with the linked pull request read's gh and environment (30 s; collie-core waits 40 s). It answers the open issues, newest first by number, at most 50, so that 50 titles stay within the protocol's 64 KiB frame limit (limits::MAX_FRAME_BYTES): numbers outside 1 to 2^32 - 1 are dropped, and titles lose control and format characters and are cut at 200 characters. Failures answer fixed messages, so nothing gh prints reaches the phone or the audit: "gh is not installed on the machine", exit code 4 asks for gh auth login, a repository with no remote ("no git remotes found", gh 2.105.0) or no GitHub one reads "the repository has no GitHub remote", output past 1 MiB on either stream kills gh and reads "gh's issue list is too large", and anything else "gh could not list the issues".
    • task.new's worktree can be {"mode": "issue", "number": N}, N from 1 to 2^32 - 1. collied turns it into Create with the branch issue-<N> before anything else, so it starts wherever Create does (herdr, Herdr Core, Rex) and reads nothing from GitHub. The branch carries the number and never the title: anyone who can open an issue writes the title, and a fixed name needs no second gh read at start and no slug rules. The app puts Work on GitHub issue #<N>. at the start of the prompt, or in place of the reference it put there for the issue picked before, wherever that still stands whole, and the user can edit it. Picking is off while dictation runs, since dictation rebuilds the prompt from the text it started with; the title shows in the list and never reaches the prompt, so the agent reads the issue itself with gh. A second task on the same issue goes as Create does with that name: while .worktree/issue-<N> exists it is refused ("checkout path already exists"), and Open works in it. The audit target is <cwd> issue=<N>.
    • No version bump. issues on task.options is an optional, additive field on a server-to-phone type: an older app ignores it, and an older collied sends none. An older collied answers task.issues with unknown_method and refuses the issue mode (TaskWorktree denies unknown variants), so the app offers GitHub issue (a Location of its own in New task) only to a collied whose task.options says issues, as it does for code_mode. Revision 24 bumped for the pull_request mode because the app then had no such switch.
  • Resume. task.sessions {cwd} (Drive class, read-only so no op_id, audited with the path and count, never the prompts) lists the 20 most recent sessions of each allowed kind in a folder under the roots, newest first (each kind is capped on its own, so the app can drop the kinds the chosen runtime does not start without emptying the list), among claude, codex, copilot and agy, leaving out sessions an agent in herdr, Herdr Core or Rex already reports as its agent_session. Since #744 (ADR-0014) it also leaves out a Copilot CLI session any process holds (an flock on one of its inuse.<pid>.hold, or a session folder collied cannot read whole) and an Antigravity CLI conversation whose presence/<id>.lock is flocked, or open in any of the user's processes named agy (found by name from the process list, proc_listpids on macOS and /proc on Linux, their open files read as for the binding), or cannot be checked whole, so a conversation running outside the runtimes' bindings is not resumed twice. An agy running under another process name is not found that way. A Copilot CLI session is listed from session-state/<id>/ when its workspace.yaml names that id and the folder as cwd and its events.jsonl starts with a session.start naming it, with the first typed user.message (no source or source: "user", no agentId) as its first prompt. An Antigravity CLI transcript names no folder, so a conversation's folder is the workspace of the oldest entry naming its conversationId still in the last 1 MiB of history.jsonl in the CLI's data folder (its prompt history; / commands carry no id, and its internal conversations have no entry); it is listed when its transcript exists, with the first USER_INPUT of source USER_EXPLICIT (inside <USER_REQUEST>) as its first prompt. collied never logs, audits or pushes those prompts. task.new with resume checks the same source for that folder and the same holders, then starts copilot --resume=<id> or agy --conversation <id> where the runtime starts that kind, Copilot CLI in herdr, herdr-core and Rex since #743. The app lists only the sessions of kinds the chosen runtime starts. No version bump: TaskSessionInfo.agent already carries a validated kind string the app labels.
    • Claude Code sessions are the <uuid>.jsonl files directly in ~/.claude/projects/<project dir of cwd>/. Codex sessions are the rollouts under $CODEX_HOME/sessions/YYYY/MM/DD/ (newest folders first, at most 10,000 listed; a plain .jsonl wins over its .jsonl.zst) whose first line is session_meta with that exact cwd, the file name's id and a cli or vscode source.
    • Only the 400 newest files of each kind are opened (O_NOFOLLOW | O_NONBLOCK), reading at most their first 256 KiB (a compressed rollout decodes with an 8 MiB window limit). Chat and the status readers read only plain rollouts: Codex decompresses a rollout before appending, so a live session is never compressed.
    • An entry has the kind, the session id (a lowercase UUID), the mtime and the first line of the first human prompt, cleaned and capped at 160 characters like last_prompt. A session whose head holds no complete prompt is listed with an empty one if the transcript is longer than the head, and left out otherwise. The prompt line goes to the phone only: never logged, audited or pushed.
    • resume on task.new (a SessionId, exclusive with new_folder, worktree and clone) makes prompt optional. collied refuses a kind other than claude or codex, a session whose transcript is not in that folder, and one a herdr agent already reports. It starts the agent with args: ["--resume", <id>] for Claude Code (2.1.296) or ["resume", <id>, "--no-daemon"] for Codex (0.162.1); without a prompt nothing is typed and the startup dialog check is skipped. The audit target is <cwd> resume=<id>.
  • Ultracode. ultracode on task.new (default false; refused for agents other than Claude Code) is the Ultracode switch of Claude Code's /effort picker, which Claude Code 2.1.299 also takes at launch as a session setting: collied adds ["--settings", "{\"ultracode\":true}"] to args (after --resume <id> on a resume), which herdr 0.9.4 quotes for the shell. Claude Code leaves it off when unavailable (dynamic workflows off, or a model without it), so once the agent is ready collied waits up to 1 s for the input box's top rule to carry the ultracode tag (─── ultracode ─); otherwise the start fails with agent_not_ready ("ultracode could not be enabled; nothing was sent"), leaving the workspace open and the prompt unsent.
  • Code Mode. code_mode on task.new (absent by default; refused for agents other than Claude Code) starts Claude Code with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE set to 1 (true) or 0 (false); absent, the agent's environment decides, as before. Claude Code's Remote Control is not available in Code Mode, so a user whose shell start-up files export the variable needs it off for a task started from the phone, and one who keeps it off needs it on to start one in Code Mode. The value must reach the agent's own process: a variable set on a shell's environment before its start-up files run (herdr's workspace.create env) is overwritten by an export there.
    • herdr-core and Rex add CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=<0|1> to the env argument vector, after the -u names and before the CLI, so env sets it over the core's environment and after Rex's login shell has read the profile. live_herdr_core_tasks starts Claude Code with 0 from a core holding 1, and live_rex_tasks with 1 under a login profile that exports 0, whose 0 a Codex task without the field keeps.
    • herdr 0.9.5's agent.start takes only name, kind, pane_id, args and timeout_ms and types the command into the pane's shell, whose start-up files already ran, so in herdr the value goes in Claude Code's own settings: one --settings object holding env beside ultracode, such as {"env":{"CLAUDE_CODE_EXPERIMENTAL_CODE_MODE":"0"},"ultracode":true}. Read from Claude Code 2.1.329's bundle, not observed: Code Mode stays off when any of the flag settings, the user settings or the shell environment sets the variable off, so off wins over a shell's 1, but on cannot win over a shell's 0 in herdr.
    • The app sends the field only to a collied whose task.options carries code_mode: true, and only then shows the Code Mode switch, for Claude Code alone: a new task, or a resumed Claude Code session. It remembers the switch per machine (taskCodeMode in prefs.json), on until turned off.
    • No version bump. code_mode on task.options is an optional, additive field on a server-to-phone type: an older app ignores it, and an older collied sends none. code_mode on task.new is a phone-to-server field an older collied refuses (TaskNewParams denies unknown fields), so the phone never sends it to one, as with runtime; there the switch does not show and the agent starts as before.
  • Runtime. runtime on task.new (herdr, herdr_core or rex; absent means Automatic, the app's default) is the only runtime the task may start in, from the app's Start tasks in setting, one for the app and not one per machine. It covers every way a task starts: a prompt, a worktree (Create, Open, pull request, issue), new_folder, clone and resume; archive, focus and every other call on the task follow the task's own runtime, by its id. collied decides it once per task.new in Runtime::task_host, before new_folder or clone creates anything. Herdr costs one ping; Herdr Core and Rex must be followed right then and cost no call, herdr's ping included. A chosen runtime that cannot take the task starts nothing anywhere and answers invalid_params in words the app shows as they are: "Herdr is not running on this computer" (no socket, or the connection refused); "Herdr Core is reconnecting; try again in a moment" (a core that answered and is not followed now, the message Automatic gives) and "Rex is reconnecting; try again in a moment" (a server that answered and is not followed now, not yet read or lost and not found gone since); collied does not follow Herdr Core on this computer: <why> and collied does not follow Rex on this computer: <why> (one collied refused, with the reason collied status shows, such as "lacks session.list_blocks"); "Herdr Core is not running on this computer" and "Rex is not running on this computer" otherwise. A herdr that runs but does not answer stays herdr_unavailable. A runtime this collied does not know (a later app's) answers invalid_params, "collied on this computer does not know that runtime". Without runtime everything below is unchanged.
    • One task per checkout holds across runtimes, as each runtime's archive removes the checkout. Open and archive with Herdr Core or Rex refuse a checkout a herdr pane works in or a herdr workspace has open, and herdr must answer unless it is not running at all ("herdr did not answer, so collied cannot tell whether it works in this checkout"). herdr's own Open and archive of a linked worktree (the automatic archive of a merged pull request included) refuse a checkout that a followed core or Rex lists a terminal in, any terminal, by its folder or foreground folder: "a Herdr Core terminal works in this checkout", "a Rex block works in this checkout". herdr is the primary runtime and asked the others nothing before tasks could start beside it, so a core or Rex that does not list its terminals, or stops being followed meanwhile, never holds herdr back: herdr then goes on as before #723, reading the core's terminals from memory and Rex's with one listing only while they are followed. Create, the pull request mode and the issue mode make a new checkout, which nothing works in yet.
    • task.options lists in runtimes where a task can start right then: herdr when herdr answered, herdr_core and rex while followed. The app shows a chosen runtime the list lacks under the location, in red ("Rex is not available on this computer right now": the list does not say why), and still sends the task: collied's answer is the one that counts, and it replaces the hint. Only that hint reads the list.
    • task.options says in runtime_agents which allowed kinds each runtime starts on that computer: for herdr the kinds herdr has a manifest for, only when herdr answered; for herdr_core and rex the kinds whose CLI collied finds (Kinds under herdr-core), whenever collied has a socket path for that runtime (always on macOS), followed or not, so a runtime that reconnects while the sheet opens still gets its own kinds. collied is the only source: the app keeps no table of kinds. With a runtime chosen, the Agent picker offers that runtime's entry alone. A kind picked before gives way to the default (default_agent when the entry has it, else the entry's first kind) once the entry lacks it, and with a runtime chosen, picking another computer drops the last one's options at once, so Start waits for the new list and never sends the last computer's kind (on Automatic canStart ignores options, as before). An entry with no kind hides the picker, keeps Start dimmed for a new prompt (Resume sends the session's kind, which collied then refuses) and says so under the location ("Rex cannot start any allowed agent on this computer"). With no entry for the chosen runtime (herdr not answering, or a collied without the field) the picker offers agents as before, and Start's refusal says why. Automatic offers agents, unchanged, and Resume lists sessions as before.
    • task.options and task.worktrees decide as Automatic does, except that a herdr that runs but does not answer, or a core that reconnects while herdr is not running, no longer fails them while a core or Rex is followed: task.options then offers the kinds herdr-core and Rex start, leaves herdr (and the reconnecting core) out of runtimes, and task.worktrees lists with git. For a phone on Automatic the New task sheet now loads where it used to fail, and Start is refused with the same message as before (herdr_unavailable, or "Herdr Core is reconnecting; try again in a moment").
    • No version bump. runtimes and runtime_agents are optional, additive fields on a server-to-phone type that every retained codec passes whole: an older app ignores them, and an older collied sends none. An unknown runtime in either reads as unknown, which the app drops. runtime is a phone-to-server field an older collied refuses (TaskNewParams denies unknown fields), so the phone never sends it to one: the app leaves it out on Automatic, and with a runtime chosen sends the task only to a collied whose task.options carried runtimes; otherwise it sends nothing and says that collied is too old for the setting. A newer collied takes a request without the field as Automatic, so an older app is served as before.
  • Scheduled tasks. task.schedule {start_at_ms, task} (Drive class, task a TaskNewParams whose op_id covers the request) leaves a task with collied, which starts it at start_at_ms (Unix time) through task.new's own path.
    • At schedule time collied runs the checks task.new makes before it creates anything (Driver::task_check: the exclusive options, a prompt or a resume, Ultracode and Code Mode for Claude Code only, the runtime through Runtime::task_host, the host's kinds, the allowed agents). When the task would start in herdr, which Automatic picks without asking herdr while nothing else is followed, it pings herdr and checks that herdr has a manifest for the kind. It then resolves cwd and an Open path under the roots, refuses a new_folder or clone folder that already exists, checks a Create branch name and that a resumed session exists in the folder and is not open. Nothing is created, cloned or started. It then refuses a start time that has passed or lies more than 24 hours ahead, which keeps a task within the 24 hours attachments are kept, and an 11th record on the machine (waiting, starting and blocked records all count). The answer is task_scheduled with a ScheduledTask: a schedule_id (16 random bytes, hex), the start time, cwd, agent and label.
    • A resent task.schedule (same phone, same op_id) whose record is still stored answers that record, even after a restart lost the op cache; the same op_id with other content is refused. A resend that arrives after its task already left the store would schedule it again; the phone resends only until collied answers, on reconnecting.
    • The store is scheduled-tasks.json in the data folder, a private (0600) file written with save_json, which flushes it, and read at most 1 MiB (10 prompts of 32 KiB after JSON escaping fit); a larger, insecure or malformed file, or one with more than 10 records, reads as empty, with a warning. Each record holds the phone's StableID, the start time, the TaskNewParams exactly as the phone sent them, and its state: waiting, starting or blocked.
    • At start, a loop waits up to 30 s for herdr-core and Rex to finish their first connection, as reconcile does, so a task recovered after a restart does not fail for a runtime that was still connecting. A record still starting from before the restart is removed, audited (interrupted: collied stopped while it started) and alerted, never started again: collied cannot tell whether its agent started. Then every 5 s the loop drops the records of phones no longer paired and blocked records a day past their start, and claims due tasks one at a time, soonest first, by the wall clock, so a machine that wakes or a collied that restarts finds an overdue task at its next tick. A claim judges that task alone, right before its start: more than an hour late, it is removed and dropped; otherwise it is saved as starting before Driver::task_new runs, with an authorization that holds while the scheduling phone stays paired, and removed once the start returns. A save that fails leaves the task waiting for the next tick, so a task never starts twice. collied peers revoke, online or offline, removes that phone's tasks.
    • A start that stops at a startup prompt keeps its record, with the prompt removed and blocked naming the terminal, until a phone clears it with task.unschedule or a day after the start time.
    • task.scheduled (Read class, not audited, since the app asks it while a task starts) lists every record, starting ones as waiting, soonest first; task.unschedule {op_id, schedule_id} removes a waiting or blocked one, refuses a starting one (agent_not_ready, "the task is starting and can no longer be cancelled") and answers not_found once it is gone.
    • The audit log records each schedule (task.schedule, the task.new target plus start_at_ms, result ok schedule=<id>), each cancel (task.unschedule, the id) and each start, drop or interrupted start (peer collied, task.new, <cwd> schedule=<id>, the start's outcome, dropped: more than an hour late or the interruption), never the prompt. A start's prompt goes through quiet_fail, which drops herdr's, herdr-core's and Rex's error text before it reaches the debug log, since that text can quote the input.
    • Alerts go to every registered device through Push::notify, so muting done alerts does not silence them (notifications). A failed start's alert gives a fixed reason chosen by its error code, never the error's text, which can hold paths or git output; the audit log keeps the text.
    • The app offers Start later only to a collied whose task.options carries schedule: true, sends start_at_ms from a date picker bounded to the next 24 hours, and lists the machine's waiting tasks in the sheet, where a swipe sends task.unschedule. With Start later on, the sheet never starts a task at once: on another computer, Schedule stays dimmed until its task.options loads and offers scheduling, and on one too old it says so until the user turns Start later off. The app keeps each scheduled prompt and its attachments in scheduled-drafts.json in its state folder, by machine and schedule_id, and drops them only after a successful cancel, a reconcile that no longer finds the task, or the machine's removal. Once a kept task's start time has passed, the Agents tab's refresh loop (for a connected machine) and a tap on an alert ask task.scheduled, one query per machine at a time, and reconcile only the copies kept before the query: a blocked task's copy goes into AgentDrafts for its terminal before the record is cleared, and copies of tasks no longer listed are dropped. A restored draft is kept from AgentDrafts.prune until the machine's flock lists its terminal. collied never sends a prompt back.
    • task.reschedule {op_id, schedule_id, start_at_ms, prompt} (Drive class) replaces a waiting task's start time and prompt; its folder, agent, place and options stay. Only the phone that scheduled the task may edit it; another phone gets invalid_params ("only the phone that scheduled the task can edit it"), checked before the checks and again when the edit is stored. collied builds the edited TaskNewParams, runs the schedule-time checks on it again, then replaces the record if it is still waiting, under the same start-time limits, and answers task_scheduled. A starting or blocked task answers agent_not_ready ("the task is starting or started and can no longer be edited"), a missing one not_found. Each record keeps the op_ids of its last 10 edits beside the edit itself, so a resent edit answers what it stored, even after a restart or once the task started; the same op_id with other content, or an older edit's, is refused, so a late resend never replaces a newer edit. A store save whose rename succeeded counts as saved even when flushing the folder fails, so collied's memory never goes back to a record the file no longer holds. The request's Debug redacts the prompt. The audit line is task.reschedule with <schedule_id> start_at_ms=<ms>, never the prompt. The app offers it only to a collied whose task.options carries edit_schedule: true: tapping a waiting task in the sheet, while no upload or dictation runs, loads the phone's kept prompt and attachments into the prompt field and hides the folder, agent and location, and Save sends the edit, then keeps exactly what it sent as the phone's copy. While Save waits, the prompt and Cancel are disabled and reconcile leaves that task alone; leaving an edit cancels its upload and dictation, whose late results the sheet then ignores, and reconcile clears a kept copy only if it is still the copy it read. A resumed session scheduled without a prompt keeps an empty copy, so its start time can be edited and its prompt may stay empty. A task whose prompt this phone does not hold (scheduled from another phone) cannot be edited, since collied never sends a prompt back. New attachments upload through the usual path, so the 24-hour retention runs from each upload.
    • Attachments are deleted 24 hours after upload, not after scheduling, and an overdue task can start up to an hour late, so a task can start after its attachments are gone.
    • No version bump. task.schedule, task.scheduled and task.unschedule are methods an older collied refuses as unknown, so the app sends them only to a collied whose task.options says schedule, and task.reschedule only to one that says edit_schedule; both flags are optional, additive fields on a server-to-phone type that an older app ignores. The task_scheduled and scheduled_tasks responses answer only those methods, which an older app never sends.
  • Agent kinds. [tasks] agents in collied.toml defaults to ["claude", "codex", "copilot", "agy"]. task.options offers those herdr has a manifest for (server.agent_manifests), the first as the default, and task.new refuses any other. herdr 0.9.5 starts each with agent.start and its canonical executable (a missing CLI fails the start, leaving the workspace open) and reads their state from its screen manifests (codex 2026.10.11.1, copilot 2026.08.29.1, agy 2026.10.05.1). On Automatic, while herdr is not running, tasks start in a followed herdr-core core instead, else in a followed Rex, and the app's Start tasks in can choose either (Runtime, above; herdr-core and Rex, Tasks).
    • Antigravity CLI (agy): OSC 7501 reports app=antigravity (normalized to agy alongside antigravity-cli and the foreground CLI agy). collied hook accepts Antigravity's camelCase SessionStart and PreInvocation payloads (hookEventName, conversationId), emits {} on stdout as agy requires, and binds the session in Herdr Core and Rex when the hook runs under the foreground agy process and agrees with the presence locks that process has open (Herdr Core's and Rex's sessions, below). Transcripts live under <ANTIGRAVITY_APP_DATA_DIR or ~/.gemini/antigravity-cli>/brain/<id>/.system_generated/logs/transcript.jsonl and feed Chat, Inbox summaries (USER_INPUT with <USER_REQUEST> unwrapped and PLANNER_RESPONSE) and token counts in costs.rs. collied doctor checks herdr's antigravity-cli hook (<config>/hooks/herdr-agent-state.sh, v4+) and collied hook in <ANTIGRAVITY_CLI_CONFIG_DIR or ~/.gemini/config>/hooks.json. No version bump: Agent.kind and TaskOptions.agents already carry validated kind strings, and agy is additive in live-activity-content-state.json.
    • Codex: collied passes --no-daemon, so Codex's SessionStart hook inherits the launching pane's environment instead of a shared app-server's, keeping /new and resume reports bound to that pane. The hook (version 10, herdr integration install codex) reports only the session; collied doctor warns about a missing or older hook. Codex falls back to unknown when no rule matches, so a Codex agent that is unknown but interactive_ready counts as started.
    • A startup prompt (Claude Code's folder trust or MCP approval, Codex's folder trust or update picker, Copilot's folder trust, Antigravity's sign-in or trust prompt) stops before the initial prompt is sent and returns task_started with startup_blocked: true (and the session's workspace_id and terminal_id) whenever the agent is running and listed in the flock, so the app can save the unsent prompt and uploaded attachments into AgentDrafts and open the new session directly in Terminal. herdr does not rule every non-Claude startup prompt blocked, so before the prompt collied reads a Codex, Copilot or Antigravity agent's screen and treats a numbered option (❯, β€Ί or no cursor), folder trust wording, or an unreadable screen the same way; for a Copilot agent collied waits up to 10 s for its empty input box, since Copilot may still be drawing its banner, and returns startup_blocked at once on a numbered option, folder trust wording or an unreadable screen, or when the wait ends (ADR-0015). In herdr-core and Rex, where Copilot reports idle at its folder trust prompt, that wait starts once its report has held for a second, so the trust prompt returns startup_blocked too. If agent.start itself fails before the agent runs, or a host runtime agent is not yet listed as an agent when a startup dialog appears (such as an npm node wrapper with no status), task.new still returns agent_blocked (with CODEX_UPDATE for Codex's update picker). No version bump: startup_blocked on Response::TaskStarted is an optional, additive boolean field on a server-to-phone response, omitted when false and ignored by older apps.
    • On macOS herdr refuses an agent.start whose launch line exceeds the terminal's canonical input limit while the shell starts (agent_start_input_failed); collied answers too_large, asking to wait for the prompt and try again.

herdr-core (Herdr Core)

collied also lists the agents of a running herdr-core core (hc, 0.1.16), beside herdr's, with no setting: herdr only, herdr-core only and both work alike. It lists agents and their status, reads their screens, binds Claude Code and Codex sessions to them, sends them prompts, keys and approval decisions, and archives and closes them. While herdr is not running, it also starts and resumes tasks there (the herdr-core plan).

  • Discovery. collied resolves the socket as hc does, from its own environment: HC_SOCKET, else socket in $XDG_CONFIG_HOME/herdr-core/config.toml (~/.config), else $XDG_RUNTIME_DIR/herdr-core/<session>.sock (or /run/user/<uid>/... when that folder exists), else $XDG_STATE_HOME/herdr-core/<session>/<session>.sock (~/.local/state), where the session is HC_SESSION or default. collied never starts a core: an absent socket means none runs. It retries every 1 s, backing off to 30 s.
  • Connection. JSON-RPC 2.0, one message per line; a connection keeps answering. collied refuses a socket whose peer is another user (peer_cred): the socket is 0755, so only its folder keeps others from serving one there. It sends hello {generation: 1} and follows the core only when it speaks generation 1, is 0.1.16 or later and lists every method collied calls. It then calls events.subscribe on the same connection: a snapshot with its seq, then every change in order, a heartbeat every 15 s (45 s of silence drops the connection) and missed with a fresh snapshot for a subscriber that fell behind (events at or below its seq are ignored). The 1 s reconcile reads what the subscription holds, so no call reaches the core per poll.
  • Methods. collied calls only hello, events.subscribe, terminal.get, terminal.read, terminal.send, terminal.keys, terminal.attach (watch-only to read, typing only to write text without Enter), terminal.run (a task's agent, by absolute path, Tasks below), terminal.kill and terminal.rm, and server.status from collied doctor; never machine.*, file.*, doc.*, server.stop, server.restart or a template; the client refuses any other method before it writes.
  • Agents. A live terminal is an agent once it reports OSC 7501 or its foreground process is claude, codex or copilot, and no shell leads it (Input, below); plain shells are not listed. Terminals on other machines (box/t7) are skipped. Its id is hc:<core id>:<address> (at most 64 bytes; the core id is permanent, so a wiped core never aliases old ids), used as both terminal_id and pane_id; herdr's are term_<hex>, and collied routes each call by the prefix. The phone parses no id, so it needs no change.
    • Kind: status.app (claude-code is claude), else the foreground CLI. app is the program's own text and the phone shows a kind it has no logo for as text, so agents::kind drops its control, bidi and format characters, trims it and cuts it at 64 characters, as an approval's labels are; an app with nothing left counts as none. No version bump: Agent.kind holds a string as before. Only the basename of the leader's argv[0] is kept, never the rest of argv.
    • Status: the OSC 7501 state (idle, working, blocked, done); error, and an agent that never reported (Copilot CLI 1.0.105), are unknown. Copilot CLI 1.0.106 and later reports app=copilot (#741).
    • Title: the terminal title without a leading spinner or status glyph, so Codex's 100 ms spinner changes nothing the phone shows. Name and cwd come from the terminal.
    • Session (agent_session), since herdr's hooks exit without HERDR_PANE_ID. Claude Code: the sessionId in sessions/<pid>.json under its config folder (CLAUDE_CONFIG_DIR, else ~/.claude) for the terminal's foreground pid, read on each listing and trusted as for subagents (the file is the user's and names that pid, which is alive and started no later than the file says), so it follows /clear. A Claude Code that inherited CLAUDE_CODE_CHILD_SESSION writes no such file (2.1.316), so it has none. Codex: collied hook as Codex's SessionStart hook sends {cmd: "session", terminal_id, session_id} over the control socket when HC_TERMINAL_ID is set; collied keeps it for that address with the terminal's foreground pid, only when the session id is a plain UUID, the address is one the core lists, and the reporter (the connection's peer pid) descends from that foreground process through exactly one process named codex. Codex without --no-daemon runs the hook under its shared app-server, a second codex whose environment names the terminal that started it, so those reports are refused. A kept session holds while the same process leads the terminal and lives only in memory: a Codex running before collied started reports again at its next start, /new or resume. Copilot CLI (#744, ADR-0014): the session whose session-state/<id>/inuse.<pid>.hold the terminal's foreground process holds (an flock), with inuse.<pid>.lock naming that pid, the process started before the marker (2 s slack), workspace.yaml naming the id and the process's folder and events.jsonl starting with that id's session.start, when that process marks exactly one session. A new session has no events.jsonl until its first prompt (package 1.0.115 on a scratch home), so it binds then; a resumed one binds at once. After /new it marks two until it exits, so none binds, as for a session folder collied cannot read or a listing past 10,000 entries. Antigravity CLI: the presence/<id>.lock files under its data folder that its foreground process has open (device and inode against its open files, proc_pidinfo on macOS, /proc on Linux) and the hook's report for that process. With no report, exactly one open lock binds; a report binds when the process has no presence lock open or has the reported one open; otherwise nothing binds. An inspection that cannot finish binds nothing either: a presence folder that cannot be read or holds more than 4,096 entries, or a process whose descriptors cannot be listed whole (an error, or 4,096 or more); a missing presence folder means no lock. collied reads both on the reconcile tick (1 s), outside the core's lock, for the terminals the core lists as Copilot CLI or Antigravity CLI agents, and keeps what it found with the foreground pid; a listing reads no file for them, and a read that finds nothing clears the binding. Each tick lists session-state once for every Copilot CLI agent together, keeping each session folder's inuse.<pid>.hold names until the folder's mtime or ctime changes and checking the flock only where a name matches an agent's pid, and lists presence once; open files are a hash set. Chat, context, costs and the resume exclusion in task.sessions and task.new then read it as for herdr agents. A Copilot CLI agent's Chat reads the bound session; herdr's panes keep their own selection (Conversation history).
    • state_change_seq is the seq of the event where the status's state last changed; a status event that repeats the state keeps it. A terminal first seen in a snapshot takes the snapshot's seq, and one already held takes it only when its state or turn differs, so blocked, idle, blocked across a gap still moves it. Status times, done alerts and Live Activities follow it as for herdr agents.
  • Group. A core's agents form one group, hc:<core id>, labelled "Herdr Core" and numbered after herdr's workspaces; it is listed only while it holds an agent. The phone's workspace.close on it is refused (internal, which the phone shows with its message): a core is not a workspace, and closing it would end every terminal in it, a desktop app's included. pane.close on a herdr-core agent calls terminal.kill, then terminal.rm. Its screen is read, and input and approvals reach it, as below. Focus on a herdr-core agent is refused (internal, "not available for Herdr Core agents yet") without reaching herdr; agent.history reads the bound session, and without one answers available: false with a reason naming what is missing (Claude Code's session file, or the Codex hook and --no-daemon).
  • Screens. herdr-core's terminal.read gives text only, so collied emulates a herdr-core agent's terminal itself (alacritty_terminal 0.26.0) for agent.read, pane.read, agent.watch and agent.draft; the phone reads the jump banner and notices from that output as for a herdr agent. collied attaches only while it reads.
    • Attach: a framed connection of its own (hello {framed: true}), then terminal.attach {observe: true, history}. A watch-only attach never types and never sizes the terminal: the emulator takes the size the core answers, whatever size a desktop client set. A unit test against a fake core checks that every attach asks observe and that only credit and close frames follow it; a live test keeps a terminal that hc attach holds at 70x20 at that size through reads and a watch. The core then paints the screen, after history rows of scrollback, in one burst and streams the output; collied gives each chunk back as credit. A core's answer of more than 1000 columns or 500 rows is emulated cut down to that.
    • A read attaches with history set to its lines (1000 when absent, none for visible), takes the paint until the stream pauses for 20 ms (1 s at most once it began), and closes the attach.
    • A watch holds one attach per terminal, shared by every watch of it and closed with the last, with 1000 rows of history (the most the phone reads); every read of that terminal meanwhile, a draft or a grid preview included, comes from it. Its memory grows with that history, about 5 MB at 200 columns once full. Nothing on a watch-only stream says a desktop client resized the terminal, so the watch compares the size the core's size events report with the size it attached at every 500 ms and attaches again at once when they differ, or after 1 s when the stream ends, until the last watch of the terminal ends.
    • Output is in herdr's format, so the phone needs no change: rows joined by \r\n; at each style change ESC[0m, then one SGR per attribute (bold, dim, italic, underline, reverse, hidden, strikethrough, then foreground and background), the sixteen named colors as palette indexes (38;5;n), and ESC[0m after a row that ends styled, as herdr-core paints and herdr reads. recent_unwrapped is the last lines rows of history and screen with soft-wrapped rows joined, without blank rows at the top or bottom; the width for Claude Code's and Codex's wrap detection is the terminal's own, exact.
    • Limits: blanks a program wrote at the end of a row are dropped, as the emulator cannot tell them from empty cells; a row the terminal wrapped before collied attached arrives as two rows, since a paint draws every row on its own (Claude Code and Codex wrap their own text, so this rarely shows); a synchronized update (DEC 2026) still open shows the screen before it until its 150 ms deadline.
    • The emulator answers nothing back: the core answers terminal queries itself, and titles, clipboard writes and links stay in collied. Only SGR reaches the phone (sanitize_ansi, as for herdr). The emulated text equals terminal.read for Claude Code 2.1.316 and Codex 0.166.0 (crates/collied/tests/fixtures/herdr-core-0.1.16).
  • Input. Every check before a write stays as for herdr; only the last call changes. The ready check reads the agent with terminal.get, as herdr's agent.get.
    • Prompts and typed answers: terminal.send (a paste, then Enter). When the status the ready check saw is idle or working, the send carries if with it, and the core types only while the status is still that (status_mismatch answers agent_not_ready). if takes only those two, and Claude Code stays done after a turn until the next prompt, so a prompt to a done or error agent goes without it: only the core's own refusal of a blocked agent (agent_blocked) applies after the check. A typed answer to a blocked agent sets force, as it answers the dialog.
    • Keys: terminal.keys, which the core encodes for the program's keyboard modes. Every Key keeps its name, and each listed key is checked live against herdr-core 0.1.16 by the bytes a program receives, combinations against 0.1.18. Combinations need herdr-core 0.1.18: collied's minimum stays 0.1.16, on which they are not checked. herdr-core 0.1.18 takes only an unshifted US keyboard's characters (a shortcut's key is limited to those) and refuses Control with [ or with Shift and a letter (ctrl+shift+a), and it has no Command modifier: it refuses cmd, so a ⌘ shortcut fails on a herdr-core agent with the core's error; Jump to bottom sends ctrl+end (ESC[1;5F, as herdr's raw write) and a notice's digit is a key of its own.
    • Text without Enter (the slash mirror and an approval note), which no method takes, goes through a typing attach (observe: false) opened at the terminal's current size, as the core's size events report it, written as one DATA frame and closed. A typing attach sizes the terminal to what it asks, so asking for the current size leaves the size a desktop client chose (live test at 70x20).
    • The core holds a send or keys call until nobody has typed for about 3 s, and counts a typing attach's input as typing (measured 2.8 to 3.3 s); a held call is delivered even after its caller disconnects. The slash mirror's next clear waits that long. A note's Enter would land that long after collied's last read, so for a herdr-core agent collied waits 3.5 s from typing the note, reads the dialog again, and only then sends Enter; such a decision gets that much more budget (9.5 s), and notes never come from the lock screen.
    • herdr-core 0.1.16 keeps a program's OSC 7501 status after the program exits, and while it is suspended (Ctrl+Z), with its shell leading the terminal again (checked with a stand-in reporting app=codex, idle, run from sh -i); 0.1.19 and 0.1.20 drop it in both cases. So no terminal whose foreground process is a shell is an agent, whatever status the core holds: the basename of the leader's argv[0], a login shell's leading - aside, is one of sh, bash, zsh, fish, dash, ksh, tcsh, csh or nu. It is not listed, so it raises no approval and takes no input, and terminal.get in the ready check answers not_found. The rule needs no history, so it holds across collied restarts, core reconnects and missed snapshots. It holds once the core has seen the shell lead the terminal: the core's foreground check lags a few hundred ms (0.38 to 0.49 s after Ctrl+Z, measured), and within that window the ready check still sees the agent. An agent that leaves the list this way has its followed Live Activity ended as for any agent that is gone, and a suspended one comes back with fg. With 0.1.19 and later it comes back with no status, so unknown and read-only, until it reports again: Claude Code 2.1.325 reported again at its next prompt (#732), and Codex came back idle, apparently from a report of its own on resume (#719). An agent a shell wrapper runs without handing it the terminal (sh -c 'codex; exec zsh', or a terminal started as sh -c 'cd x && claude') is not listed either.
    • Phone input reaches a herdr-core agent only when it reported a status whose app names Claude Code, Codex, Copilot CLI or Antigravity CLI, the kinds whose reports were checked: they report blocked at their permission and question dialogs (TASK_KINDS), and its foreground CLI, when collied recognises one, is that same kind (agents::read_only). A Copilot CLI agent, which reports idle at its folder trust prompt and with a picker open (#741), takes a prompt, a typed answer, keys or typed text, in every runtime, herdr included, only while the screen collied reads last before the write shows Copilot's input box at the bottom, empty for a prompt or a typed answer, whose Enter would run a command typed or completed in the box (prompt::copilot_box, Driver::copilot_input, ADR-0015): from the last row up, one to three footer rows indented one column without the word cancel, the box's bottom edge, its input rows and its top edge, the edges ╻▄… and ╹▀… from column 0 to the width of the screen's widest row with every input row starting ┃ (as in Rex and herdr-core), or full-width ─ rules with a first input row starting ❯ (as in herdr 0.9.5, or with neither COLORTERM nor TERM_PROGRAM set); any other screen, or one collied cannot read, is refused with agent_not_ready and a message to answer the dialog in the terminal. A batch of keys is refused too (one key per call), Rex is read with a polled format rather than its watched stream, and in herdr-core collied waits until 3.5 s after it last typed into the terminal, the core's typing hold, before the read. A Copilot CLI or Antigravity CLI report takes input only while that program leads the terminal (cli), blocked included, so a report a core keeps after the program stopped never makes another program writable; Claude Code and Codex still take it under an unrecognised foreground, for npm's node. Every other agent is read-only: one with no status (Claude Code 2.1.316 reports nothing at its folder trust prompt; Copilot CLI 1.0.105 never reports), any other app, never checked, and a report naming another CLI than the one leading the terminal, a previous program's that herdr-core 0.1.16 keeps after it exits. A read-only agent's status, done alerts and approval alerts still show (an approval for a Copilot agent offers no decision, as under herdr), and prompts, typed answers, keys, notice digits, Jump to bottom and the slash mirror are refused: agent_blocked for a prompt, a notice digit or the slash mirror to an agent that reports blocked (the ready check comes first), else agent_not_ready. One exception (#895): a Codex that has reported nothing (its foreground process sent no status, so its kind is its foreground CLI's, unreported) takes the dialog's own keys while its folder trust prompt or update picker fills the screen, audited as input to a blocked agent: agent.send_keys with only up, down, left, right, enter, esc and a digit 1 to 9, and nothing after the first key that can answer it (Enter, Esc or a digit), and agent.send_text with one digit, sent as that key. Any other call is refused whole and nothing is sent; the phone then drops its queued input with the error. After an answering key the screen read right away can still show the dialog, so a call that finds the same screen within 1 s of it is refused: Codex and Copilot CLI redrew within 50 ms on a scratch Rex and a scratch herdr-core. Copilot CLI (#897) takes its folder trust box's own keys the same way, audited the same way, a digit picking its option at once, and only when its own report names Copilot (reported, not a kind taken from the CLI for want of one), its foreground CLI is Copilot (cli) and it is not blocked (a permission prompt is refused before the screen is read). prompt::copilot_trust reads the box only as Copilot 1.0.112 to 1.0.115 draw it with truecolor, checked on a scratch Rex server and a scratch herdr-core 0.1.21: its tab bar on the first row, the box as wide as the terminal from its first column and its bottom border on the terminal's last row, both measured against the terminal's own size (an unknown size refuses), rows counted in display cells as the screen shows them (a wide character in the folder's path takes two), Confirm folder trust on its first row over a rule, exactly one ❯ option, and the key hint (↑/↓ to navigate to esc to cancel, wrapped on a narrow terminal) on its last rows. Copilot draws its input box and status line under anything an agent or a tool writes, so their text never ends the screen. prompt::codex_startup reads the dialog only as Codex 0.160.1 to 0.171.0 draw it: blank rows, its heading on the first row, indented text, options numbered from 1 under exactly one cursor, the first one Trust and continue or Update now, and its key hint on the last row, with nothing else on screen. Codex draws its composer under any transcript, so text an agent or a tool writes never passes, and neither does a report the core or Rex keeps from another program, an error report or a report naming Codex over another CLI. Codex 0.171.0 reports nothing at its folder trust prompt and idle once it is answered, checked on a scratch Rex server and a scratch herdr-core 0.1.21; a digit there moves the cursor and Return confirms. On the scratch Rex server the other kinds needed no change: Claude Code 2.1.330 reports blocked at its folder trust prompt, which its approval answers, Antigravity CLI 1.5.13 blocked at its sign-in prompt, which takes keys and typed answers, and Copilot CLI 1.0.112 idle at its folder trust prompt (below). The answer is the user's own keys; collied picks no option, and the screen read only lets them through. Prompts and typed answers stay refused, since their Enter would pick the highlighted option whatever the text says.
  • Approvals. A blocked report's kind stands in for herdr's matched rule, in the menu gate and in the fingerprint. Claude Code 2.1.316 reports permission for its permission and plan prompts and question for its forms (AskUserQuestion), so they parse as under herdr's generic_permission_prompt, legacy_no_prompt_blocker and live_blocked_form; a Codex agent's kind parses no menu, as under herdr. The screen is terminal.read (text, no attach), what herdr's detection read gives. state_change_seq (above) does not move while one dialog redraws, so its approval and fingerprint stay, and the next dialog gets a new seq; decisions go through terminal.keys and a note through the typing attach, with every re-read as for herdr. The report's msg is never read. A form in a session named with /rename is not cut under its name rule (herdr's live_blocked_form_named_session), so with a task panel under that rule the form's accepts_input can be true where herdr's is false (it only shows the key strip on the phone), and Claude Code's auth kind ("Not logged in") raises an approval with no options.
  • Tasks. On Automatic, New task starts in herdr while herdr answers ping, which gives the agent herdr's screen rules, focus and workspace; it starts in a followed core only when herdr is not running, so a machine moved to Herdr Core needs no setting. A task the app asks of Herdr Core starts in a followed core whether herdr runs or not (Runtime). On Automatic collied decides once per task.new with a single herdr ping, and task.options and task.worktrees follow the same rule, except as Runtime says while a core or Rex is followed: herdr is not running when its socket is missing or refuses the connection; any other failure (a herdr busy or restarting) answers herdr_unavailable and starts nothing. The decision, and for Herdr Core the CLI check below, come before new_folder or clone creates anything.
    • Kinds: task.options offers the allowed kinds among claude, codex, copilot and agy (TASK_KINDS) whose CLI collied finds, by absolute path, in its own PATH, then /opt/homebrew/bin, /usr/local/bin, ~/.cargo/bin and ~/.local/bin (a path holding = is skipped, as env would read it as a variable). Copilot CLI is offered since #743, its input guarded by its screen (Input). No version bump: the app already offers the kinds task.options lists for each runtime, and read_only already says which agents take input.
    • Start: terminal.run {argv, cwd, name, labels, env: {TERM: "xterm-256color", COLORTERM: "truecolor"}, no_parent: true, no_notify: true}, with labels (which the core reports in events.subscribe snapshots as in created events, checked live, so collied knows its tasks again after a restart or a missed; a label whose value is not a string is ignored): collie.kind (the agent kind, which marks the terminal as a task collied started) and, for a worktree task (Create, pull request, issue or Open), collie.worktree (the canonical checkout collied created or opened for it); the phone's task label is not kept, as nothing would show it. argv is /usr/bin/env -u <name> ... <CLI path> <args> (with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=<0|1> before the CLI path for a task that sets Code Mode) and -u for each of sixteen names: HERDR_ENV, HERDR_PANE_ID, HERDR_SOCKET_PATH, HERDR_TAB_ID, HERDR_WORKSPACE_ID, HERDR_BIN_PATH, CLAUDECODE, CLAUDE_CODE_CHILD_SESSION, CLAUDE_CODE_ENTRYPOINT, CLAUDE_CODE_EXECPATH, CLAUDE_CODE_MESSAGING_SOCKET, CLAUDE_CODE_MESSAGING_TOKEN, CLAUDE_CODE_SESSION_ATTENDED, CLAUDE_CODE_SESSION_ID, CLAUDE_EFFORT and CLAUDE_PID. A core passes the environment of whatever started it to every terminal, and env in terminal.run cannot remove a variable, so a core started inside a herdr pane running Claude Code would otherwise give the agent that pane's herdr variables (herdr's hooks would report its session against that pane) and CLAUDE_CODE_CHILD_SESSION (Claude Code 2.1.316 then saves no transcript and writes no session file). Plugin exports and variables the user chose, such as CLAUDE_CONFIG_DIR, stay. The arguments are herdr's: --resume <id> and the ultracode settings for Claude Code, --no-daemon for Codex always (resume <id> --no-daemon on a resume), so its SessionStart hook reports from the terminal's own Codex. The CLI path is absolute: terminal.run starts a template for a bare name that matches one. The name is the task's collie-<hex>.
    • Ready: herdr-core has no launch state, so the agent is ready once it reports idle or done and keeps that report (the same state_change_seq) for 1 s, within 30 s: Codex 0.166.0 reports idle, then working, then idle again while it starts. A blocked report or a detected startup dialog stops before sending the prompt and returns task_started with startup_blocked: true when the agent is listed (with its group and agent id), else fails with agent_blocked as before. While the agent has no status, listed or not yet (an npm install leads as node until it reports), collied reads the terminal's screen, since no approval can answer a dialog there: for Claude Code any menu the approval parser reads (its folder trust prompt, where it reports nothing, an MCP server approval, the bypass permissions confirmation), for Codex its update picker, or an option under a cursor (❯ or β€Ί) beside another option with no β€Ί line below it (Codex repaints a resumed session's prompts above its composer, a β€Ί line a dialog replaces). Then the checks, ultracode, the non-Claude startup dialog read and the prompt are herdr's, the prompt through terminal.send; for Claude Code collied also reads the screen once more and returns startup_blocked: true without sending the prompt while it shows a menu, since one that reported idle beside a dialog would take the prompt's Enter as its answer. Any other failure after terminal.run leaves the agent running and names it; an agent whose terminal finished, listed or not, fails the start at once as exited. task.started answers the group and the agent's id.
    • Worktrees: task.worktrees and the worktree modes list with git worktree list --porcelain -z in the folder (the first entry is the source checkout, every other one a linked worktree; none is marked open). Create, the pull request mode and the issue mode run git worktree add <path> <branch> for an existing branch, else git worktree add -b <branch> <path> from the source's HEAD, in the same .worktree/<branch> folder herdr would use, with the clone's environment (no prompt, none of collied's GIT_* variables) and 45 s. collied then requires git to list that checkout on that branch (Open: the branch it listed), refuses an Open while another Herdr Core task, or a Rex task of a followed Rex, records that checkout ("the worktree root pane is occupied", as herdr answers; a Rex that does not list its blocks refuses the start, and the archive, with an error naming Rex), and starts the agent in it; a failure leaves the checkout and names it. The checks before (branch rules, roots, the pull request's head) are herdr's.
    • Archive: only a worktree task's recorded checkout (collie.worktree) is ever removed, and only while it exists under the roots and git lists it there as an unlocked linked worktree; a terminal without that label, a plain task whose folder happens to be a worktree included, is closed and its folder kept. A folder with no .git above it is a regular folder; a git failure in a repository, a locked worktree or a checkout outside the roots refuses the archive, closing nothing. Before removing, collied closes nothing and refuses while anything else may work in the checkout: a core terminal without the label, shells included, a block of a followed Rex (read afresh, as for a Rex task's archive), any other task's terminal (a Resume started there, or a second task that recorded the checkout), or a herdr pane whose start or foreground folder (symlinks resolved) lies in the checkout, or a herdr workspace that has it open (worktree.list). herdr-core 0.1.16 reports a shell's new folder after a cd while the shell stays in the foreground (checked live: hc get and the followed events both showed it before the archive ran); a cd the core has not reported yet is not seen. herdr must answer for that check unless it is not running at all (no socket, or the connection refused); a herdr that does not answer refuses the archive. The terminals are read from a core collied follows right then, and the archived agent must be among them: a core whose events connection dropped meanwhile knows nothing about them, so the archive is refused. Otherwise collied kills and removes the task's terminal (terminal.kill, then terminal.rm, as pane.close), naming it in its answer, reads the core's terminals once more and refuses if anything else now works in the checkout, then runs git worktree remove --force <checkout> in the source checkout (60 s) and checks the checkout is gone; then gh poi as for herdr. Otherwise, and for any terminal collied did not start, it closes the agent and leaves the folder. The automatic archive of a merged pull request stays herdr's: a herdr-core group is no linked worktree workspace, so it never qualifies. A task whose agent exited is no longer listed, so the phone cannot archive it: its checkout stays, and collied removes no finished terminal.
  • Both at once. herdr's calls answer as before, with the core's agents, group and panes added while the core is followed; without a followed core every answer is herdr's, unchanged. A runtime that never answered stays quiet. A core that stops after answering logs once and its agents leave with one flock.changed; herdr stopping while the core answers logs once and drops herdr's agents the same way. What collied keeps for herdr's agents outlasts a herdr outage: while the core answers in herdr's place, reconcile hands approvals, done alerts and status times herdr's agents as herdr last listed them, and their Live Activities stay without an update until herdr answers again, or go stale; stars, pull request watches, wakes and status times of a runtime that lists no agent stay (as herdr's stars, watches and wakes did before for an empty list). Started while herdr is down, collied follows the core's agents as usual and leaves herdr's saved state alone (its Live Activities neither updated nor ended) until herdr first answers. herdr_unavailable is answered only when neither answers, or for a herdr agent's lookups (prompt, read, close, archive) while herdr is down. At start, the first reconcile waits up to 5 s for the first attempt to reach the core.
  • Status and doctor. collied status prints a herdr-core: line: version and generation (or not running), the socket, its folder's mode and any method the core lacks. collied doctor resolves the socket from its own environment and calls hello and server.status: not running is not a failure; a core it cannot follow is a warning; its folder must be 0700 and the user's. It warns when the environment of the core's holder process, which every terminal inherits, holds HERDR_PANE_ID, HERDR_SOCKET_PATH or CLAUDE_CODE_CHILD_SESSION, reading variable names only (sysctl(KERN_PROCARGS2) on macOS, /proc/<pid>/environ on Linux). herdr's line stays a failure only when herdr-core does not answer either. Once ~/.codex (or $CODEX_HOME) exists, a second codex hook line checks for collied hook under SessionStart in its hooks.json: a warning while a core answers or collied would follow a Rex server, else informational.
  • No version bump: no phone wire type changed; herdr-core agents use the existing Agent, Workspace and error codes, their screens the existing agent.output and agent.output_patch, and their input and approvals the existing calls and Approval.

Rex

collied also lists the agents of a running personal Rex server, beside herdr's and herdr-core's, with no setting: any combination works. #704 lists agents and their status and closes them, #705 reads their screens, #707 binds their sessions, #706 sends them prompts, typed answers and keys and raises and answers their approvals, and #708 starts, resumes and archives tasks there while neither herdr nor herdr-core answers, or whenever the app asks for Rex (#723), and #727 removes an archived task's own session once it is empty, #765 follows a watched terminal as a stream, and #755 lists the blocks that run a shell under Terminals, which the phone opens and types into as it does herdr's shells; focus on a Rex agent answers internal ("a Rex agent cannot be focused from the phone"), since session.focus_block changes only the server's view of the session and Rex.app (0.1.0-preview.19, checked 2026-11-15 in #709) neither switched to that session nor came forward, and collied never calls Rex.app's own client.* actions; herdr's own pane calls on a Rex agent answer internal ("not available for Rex agents yet") (the Rex design). Phase 1 (#704) was checked against 0.1.0-preview.16 (API revision 13), Streams (#765) and Terminals (#755) against 0.1.0-preview.20 (revision 16, which speaks 13 to collied), and the rest against 0.1.0-preview.19 (revision 14, which speaks 13).

  • Discovery. As the rex CLI does, from collied's own environment: $REX_RUNTIME_DIR/server.sock, else $XDG_RUNTIME_DIR/rex/server.sock, else ~/Library/Application Support/rex/server.sock on macOS and /run/user/<uid>/rex/server.sock on Linux; never REX_SERVER, which can name another machine, and never the host list. Only the daemon and collied doctor look: every other caller names a socket or none (ServerConfig.rex), so no test reaches the user's server. collied never starts a server and never runs rex, which starts one by default; an absent socket means none runs. It retries every 1 s, backing off to 30 s.

  • Personal server only. The socket's folder must be a folder and the socket a socket, neither followed through a symlink, both owned by the user with no group or other permission bits, and the peer on the socket (peer_cred) must run as the user. Otherwise collied does not follow it, logs once and doctor says why. That keeps out Rex's shared server on Linux, whose group members all type into every session as the rex account, and a personal socket opened to a group.

  • Connection. One control WebSocket per server: /api/control, subprotocol rex.control.v1, over the Unix socket with tokio-tungstenite, without compression, messages up to 1 MiB (the server's own limit). The hello sends api_revision: 13 and api_min_revision: 13, so an older server closes the connection rather than answer in older shapes. Any policy close (1008) before the welcome counts as that refusal, whatever its reason says, and doctor says so in plain words with the server's reason, since a server keeps the revision of the build it started from until the server restarts (a launchd service that outlives Rex.app). A server that took the connection and then closed it or failed is not followed and is reported with the reason, never as not running; collied logs it once per distinct reason. Requests time out after 5 s (block.close after 15 s), and 300 s of silence drops the connection (the server pings every 120 s). One task reads the connection: it hands each response to its call and applies each event to the model under a short lock, so it never waits on a caller.

  • Methods. The client takes a method enum, with no call by string, so only these can be sent: help.all, server.version, server.status, block_creator.list, session.attach_all, session.list, session.attach, session.list_blocks, block.close, block.event (only its paste and key events, the only ones collied builds), and the terminal methods process, program_status, title, size, format and blob_read; for tasks, session.create, session.disown_block, the terminal method resize, only to repair a task's block left at 80x24, and session.destroy, the last only on an archived task's own session once it is empty (Tasks, below); session.new_split, only to start a resumed agent beside its restored shell (Resume after a restart, below); and data.connect, for a watched terminal's stream (Streams, below). None is called before help.all lists it (block_creator.list for the terminal methods); a server that lacks one is not followed, and collied status and doctor name it. Never server.stop, server.tailscale.*, hosts.*, client.*, write, own_block or any method a later phase has not added.

  • Listeners. server.status lists the server's listeners and its built-in Tailscale state. A listener that admits anonymous callers makes collied refuse to follow: anyone who reaches it would type into the same agents. Tailscale running or a tailnet listener is followed, with one log line and a warning in collied status and doctor.

  • Subscribe, then read. session.attach_all {event_scope: "session"} (sessions created and destroyed, no block events), then session.list, then for each session session.attach (its block events from then on) and session.list_blocks, and for each terminal block process, program_status, title and size. Each value keeps the seq that set it: an event's own, or a read's response seq, the last event the read reflects. A read replaces a value only when no later event set it, and an event replaces one only when it is newer than the read that set it, so a report between the subscription and the read is kept and one the read reflects is not applied twice. A session created or a block added later is read the same way when its event arrives; events for a block not read yet are dropped, since its reads start after them. A read that began before a block closed never adds it back. A session's label is also taken from session.attach, so a rename that arrived before the session was listed is not lost. A block whose reads fail to decode or time out is skipped and logged once, and read again on its next block event or its session's next read; the rest of the server is still followed. After a reconnect seq starts again at 1, so collied reads everything again.

  • Agents. A terminal block (com.superlogical.terminal) whose host_id is the server's is an agent once its foreground process reports OSC 7501 or runs claude, codex or copilot (the basename of argv0, else name); blocks of other hosts are skipped. As for herdr-core, and from the same code: no block whose foreground process is a shell is an agent, the kind is the status app (claude-code is claude) else the CLI, and error is unknown. Rex keeps a record after its program exits into another one, so a root record whose owner (pid and name) is not the current foreground process is ignored, as if nothing had reported. Ids: rex:block:<uuid> as terminal_id and pane_id, within the phone's 64 bytes; Rex never reuses an id. cwd is the terminal's own program's, foreground_cwd the foreground process's. Phone input follows herdr-core's rule, from the same code: only an agent whose own record's app names a kind in TASK_KINDS, with a matching foreground CLI when one is recognised, takes it, a Copilot CLI agent only while its screen shows its input box (#742); any other agent is read-only.

  • Terminals (#755). A terminal block of this host that is no agent is listed as a terminal (Terminals) while a shell runs in it: its foreground process is a shell, or one of the foreground's ancestors is (the basename of argv0, else name, a leading - aside, from the list herdr-core's rule uses). So a command the shell runs (make, vim, sleep) keeps the block listed and its watch going, as a herdr pane stays a shell whatever runs in it. Rex.app's terminals run /usr/bin/login, which runs the user's login shell: checked on a scratch server (0.1.0-preview.20), child is login, the foreground -zsh, and a command's ancestors are -zsh then login; process and process_changed both carry the ancestors. A block whose program Rex started with no shell above it (rex new -- top), or whose program exited, is listed as nothing, and none of its screen is read. An agent under a shell that keeps the terminal (sh -c 'cd x && claude') is no agent, since a shell is in front, and Rex names that shell as its record's owner. Such a block is no terminal either: it is listed as a pane hosting an agent, which Terminals leaves out and on which a terminal call answers as on a herdr pane where an agent started (not_found, "the pane now hosts an agent"), dropping the terminal's grants. That holds while a shell in front that is not a login shell owns the root record (pid and name), whatever the record says (a login shell, argv0 with a leading - as Rex.app starts one, is left out, so a report ever credited to the user's own shell cannot hide it for as long as it lives; sh -c is never one), or while the record says working or blocked and its owner's pid is alive (kill(pid, 0); Rex blocks run on this host). Checked on a scratch server (build 2003): an agent run from an interactive shell, directly or from a nested shell, owned its own record; one under sh -c had the sh as owner through idle, working and done; after a normal exit, Ctrl+C or Ctrl+Z no shell back at its prompt owned a live record, and Rex dropped a directly run agent's record on Ctrl+Z. So a wrapper suspended at idle or done leaves the user's shell listed for fg, while one suspended mid-turn, still working under a live owner, keeps it unlisted until it resumes and finishes or exits; a reused pid only hides a terminal. A wrapped agent that has not reported yet (Claude Code reports nothing at its folder trust prompt) leaves the shell listed. An agent started in a shell moves the block from Terminals to the agents, and back once it exits, as for herdr. A terminal's terminal_id and pane_id are rex:block:<uuid>, its workspace_id its session's group, its label none (Rex's block label is not read, and a title the program sets never leaves the machine), and its cwd the terminal's own program's folder, else the foreground process's (Rex.app's login reports none), which an archive's cleanup runs in. Terminals come from the model the events keep, as agents do: listing them calls nothing.

    • state_change_seq: Rex's seq restarts with each connection, so collied derives its own from the root record's updated_at (the first 8 bytes of its SHA-256), which each report sets anew. Every report moves it, two identical dialogs in a row never share one, and a record unchanged across a reconnect or a restart of collied keeps it, and with it its status time.
  • Screens. agent.read, pane.read, agent.watch, drafts, the jump banner, notices and the screen text startup checks read (herdr's detection source, approvals included) come from collied's emulator (runtime::screen::Screen, as for herdr-core) fed a tail of format's VT rendering, at the terminal's size (size, read before the block is listed, then size_changed). Rex sends no event for output and nothing in a format answer says whether the screen changed (it carries content, id and total only), so a read is polled unless a watch holds the terminal's stream (Streams, below). Each polled read asks format {format: vt, max_bytes: 1}, which renders the whole scrollback on the server and keeps it as a result, then blob_reads the last 64 KiB, cut after its first line break, and doubled while it holds fewer line breaks than the screen's rows plus the lines asked for. One answer holds at most 983,040 bytes counted as a JSON string, quotes and escapes included: when a doubled tail does not fit, the read uses the last one that did, and that reader never asks for the larger size again, so in the steady state a poll makes one blob_read of a tail it uses. A tail that cannot hold the screen's rows (a line longer than any tail on screen) fails the read rather than show a screen without it. A terminal whose whole rendering was 64 KiB or less last time is read by one format asking for up to 960 KiB, which holds it whole: Rex answers a result's first blob_read more slowly than it renders a short terminal. Reads with history ask unwrap: true, which joins rows the terminal soft-wrapped, so the emulator wraps them again and recent_unwrapped joins them as herdr does; visible and detection keep rows as Rex draws them, so one long line cannot push the screen out of the tail. Rex keeps the newest four results of each block (and each for about five minutes): a result gone before its tail is read is formatted again, up to three times, and a read that still fails is an error the watch skips. One format runs at a time per block and unwrap: readers that ask while one runs wait, then share the next one, so every reader is served a rendering asked for after it asked, as with a format of its own, and the reads right before input and an approval's decision stay as fresh as they were. The wait costs a queued reader up to one more format; a format that fails or times out is not shared, and the wait and the reader's own format together end within one 5 s timeout of when it asked, so no reader fails later than it would alone. Each reader of a block (its source, and for history its lines) keeps the tail it last fed and what it read back: the same tail at the same size answers that again, without the emulator, so an unchanged watch poll sends nothing. Neither format nor blob_read changes a block's size or owner (checked on a block Rex.app owns). pane_columns is the block's width. agent.explain is the blocked report's kind, as for herdr-core.

  • Streams (#765). While a phone watches a Rex agent, or a Rex terminal under its grant (terminal.watch, #755), collied follows its terminal as a stream instead of polling format, which renders the whole scrollback on every poll: one stream per terminal, shared by every watch of it, held by the watch as herdr-core's attach is and closed with the last watch (status 1000, which ends Rex's stream at once). Every read of a terminal whose stream is live, detection reads included (approvals, menus, the screen read before input), is served from it with no call to the server; any other read is polled as above, unchanged.

    • Opening: data.connect on the follower's control connection (it attached every session, which Rex requires), then /api/data with rex.data.terminal.v1 over the same personal socket, messages up to 64 KiB, and a HELLO with the ticket. A REJECT gives up streaming for the rest of the watch and the reads poll, except reason 2 (this client's previous connection to the block is still closing) and 4 (a limit), which try again with a new ticket after 1 s, backing off to 30 s, and 3 (the block closed).
    • Restore: the stream opens with a Ghostty snapshot (GHOSTSNP). collied checks its envelope (the magic, then a little-endian u16 version) before libghostty-vt reads anything, and an unknown version, or a snapshot the library refuses, gives up streaming for the rest of the watch: the format is versioned apart from the library and outside its ABI promise, and Rex writes it with its own Ghostty. The snapshot is restored on a blocking thread while the bytes after it queue; the decoder reads nothing past the snapshot's end, so they follow it exactly. The restored terminal's history is then cut to about 3,024 rows, what a read needs (twice the rows and up to 1,000 lines of history; the line limit prunes whole pages, which can keep fewer), and the snapshot's bytes are dropped as they are read.
    • Live: the program's bytes go to the terminal as they come. Rex's own messages, ESC _ rex1;<nonce>;<json> ESC \, are taken out of the stream only with the WELCOME's channel nonce: one with another nonce is a program's look-alike and reaches the terminal as Rex's own terminal saw it. resize (cols, rows) resizes the terminal at that point of the stream, child_exited marks it finished, and theme and any type collied does not know are ignored.
    • Reads: the rows a read needs (the screen, or twice the screen and history asked for, unwrap with history) are formatted as VT (text, styles and each cell's OSC 8 link, which the emulator drops before the phone) and fed to the same emulation a polled read feeds Rex's format to. Streamed and polled reads came out byte-identical on everything checked, so fingerprints do not change there: the captured streams (colored, wide and wrapped lines, a look-alike, a resize, a part-filled screen with the cursor mid-screen, a dialog on the alternate screen, entered live and restored from a snapshot) and live_rex_stream's reads after output, a resize and a resumed drop. The formatter writes a cell's whole link again each time the link changes, so a screen of alternating long links formats to megabytes: a format stops at 983,040 bytes, what one polled answer holds, and that read, or any read the library fails, polls instead. A read formats only once the stream brought something since that reader's last read; otherwise it answers what it read then, so a watch of a still terminal costs no formatting.
    • Freshness: a streamed read is the terminal as of the bytes applied so far, which can trail Rex by the socket's and the scheduler's delay (well under a millisecond on the local socket, not measured), where a polled read is a rendering Rex made after the reader asked. Approvals tolerate it as they tolerate a dialog drawn just after a poll: a blocked report is read up to three times, and a pending approval whose screen drifts is superseded by the next read and asked again, while a decision still checks its own read's fingerprint and seq before any key.
    • Gaps: while the stream is not live (opening, restoring, resuming, given up), reads poll format. A dropped connection resumes at once on a new one with the latest reconnect token and the count of every stream byte received (RESUME), and Rex replays what was missed; a refused resume, a resumed connection that ends before any byte arrives, a close Rex asks a new stream for (1011, 1013), a failed resize and a stream cut during its snapshot start a new stream with a new ticket after a delay: 1 s, doubling to 30 s, and back to 1 s only after a stream that stayed live longer than 30 s, so no sequence of answers makes collied ask Rex in a loop. 1000 and 4000 (the block closed), or any end once the program exited, end the stream, and 1008 (no terminal stream) gives up streaming. A watch that ends once a data connection exists closes it with status 1000, so Rex ends the stream at once, mid-snapshot included.
    • Containment: a program whose output trips a ReleaseSafe check aborts collied (threat model). rex-streaming in the data folder exists while any stream is followed and is removed when the last one ends and when collied stops cleanly; a run that starts and finds it removes it and reads every Rex terminal by polling, with one warning in the log, so a terminal whose output or snapshot aborts collied does not abort it again on the next watch, and a kill or an unrelated crash during a stream costs one run of polling. A marker that cannot be written is logged, and streaming goes on without that protection.
    • Cost, measured through collied on a scratch server (0.1.0-preview.20) with a changing 80x24 terminal of 100,000 lines: Rex 0.9% of a core against 0.7% with no watch (polling cost 28 to 32%), collied 1.5% against 0.2%, most of it the watch loop's own work on a screen that changes four times a second (inferred), and 27 MB more resident once restored (rex.md).
  • Sessions (agent_session, #707), from herdr-core's lookup and hook. Claude Code: the sessionId in sessions/<pid>.json for the pid Rex reports as the block's foreground process, trusted as for herdr-core (the file is the user's and names that pid, which is alive and started no later than the file says). collied reads it when it reads the block, on each process_changed and program_status_changed of a Claude Code agent, and for every Claude Code agent once per reconcile tick (1 s), since /clear rewrites the file with no report and no block event (Claude Code 2.1.325); never per listing, and always outside the lock listings take, so a binding whose process changed while its file was read is refused. It keeps the session with that pid: it holds while that process leads the block, and a later read that finds no file keeps it. Codex: collied hook, as Codex's SessionStart hook, also reports rex: and the REX_BLOCK Rex sets in every terminal; with both HC_TERMINAL_ID and REX_BLOCK set (a server started inside the other runtime's terminal passes its variable on) it reports both and collied keeps the one it verifies. collied keeps it only when the session id is a plain UUID, the followed server lists the block as a Codex agent, and the reporter (the connection's peer pid) descends from the block's foreground process through exactly one process named codex, the check herdr-core's reports pass, from the same code. Codex 0.167.1 runs the hook when its first prompt starts the session, not when it opens; Codex without --no-daemon runs it under its shared app-server, so those reports are refused, as for herdr-core. A Codex report is kept by block id outside the model, so a reconnect to Rex keeps it and applies it when the block is read again, while the same process leads the block; it lives only in memory, so a restart of collied loses it until Codex's next start, /new or resume. Claude Code's comes back from its file after either. Copilot CLI and the Antigravity CLI (#744): as for herdr-core, from the same code, read whenever Claude Code's file is (the block's reads, its process_changed and program_status_changed, and the reconcile tick), and a read that finds nothing clears the binding; an Antigravity CLI hook report is weighed against the presence locks when it arrives, and one remembered across a reconnect is never shown before that check. Each read takes the block's next scan number, and its result is kept only if no later read of the block has started, so an older read never replaces a newer one. Chat, context, costs and the resume exclusion in task.sessions and task.new then read it as for herdr agents.

  • Groups. One per Rex session that holds an agent or a terminal, rex:session:<uuid>, labelled with the session's label (renames follow session_label_changed) and numbered after herdr's workspaces and herdr-core's group. Windows are not shown.

  • Calls. poll, agent.list, session.snapshot and agent.get answer from the model, with no call to the server. pane.close on a listed Rex agent or terminal is block.close, which ends its program (a window whose last block closes closes too; the session stays); on any other block it is not_found, with no call. task.archive on a Rex agent or terminal closes its own block the same way and leaves its folder, as for a herdr-core terminal outside a task, then runs the usual gh poi cleanup in its repository; a worktree task's archive also removes its recorded checkout, and a task's archive the session collied created for it once empty (Tasks, below). workspace.close on a Rex group is refused (internal, "a Rex session cannot be closed from the phone; close its agents one at a time"): it would be session.destroy, which ends every block in the session, Rex.app's included.

  • Tasks (#708). On Automatic, New task starts in herdr while herdr answers, else in a followed herdr-core, else in a followed Rex (Runtime::task_host); a task the app asks of Rex starts in a followed Rex whatever else runs (#723, Runtime under herdr integration), on Automatic decided once per task.new with herdr's ping as for herdr-core, and task.options and task.worktrees follow the same rule, except as Runtime says while herdr does not answer. A herdr-core that answered and whose connection then ended is, until collied's next attempt finds it gone, an error ("Herdr Core is reconnecting; try again in a moment"), not a reason to start in Rex, as for a herdr that runs but does not answer; one collied refused to follow (another generation, a missing method) is not. collied knows no more without probing: once a retry finds no core (a core restarting finds its socket gone between attempts), tasks start in Rex until collied follows the core again, up to its 30 s backoff. A Rex task is a third target of herdr-core's task code, not a copy of it: the same kinds (claude, codex) and CLI lookup by absolute path, the same arguments (herdr's: --resume <id> and the ultracode settings for Claude Code, --no-daemon for Codex, resume <id> --no-daemon on a resume), the same git worktree runs for Create, pull request and Open, the same ready check and prompt delivery, and the same archive checks.

    • Start: session.create {label, initial_windows: [{layout: {block: {flavor: "com.superlogical.terminal.shell", label: <name>, options: {command, cwd}}}}]}: a session of the task's own, labelled with the phone's task label or else the task's collie-<hex> name, which is also the block's label (Rex.app shows it) and the agent's name. command is the argument vector /usr/bin/env -u <name> ... <CLI path> <args> (with Code Mode's variable before the CLI path, as for herdr-core) with herdr-core's sixteen names (runtime::STRIPPED, one list for both): options.command is an argument vector that reaches the program unchanged, never a command line, and with no shell option Rex runs it through the user's login shell (the account's shell from the user database, /bin/zsh here, not the server's SHELL), which reads the profile first, so the agent gets the profile's PATH, as the user's own Rex terminals do (checked live: a scratch home's .zprofile put its folder first on the agent's PATH; the server's PATH was /usr/bin:/bin:/usr/sbin:/sbin). The shell execs the command, so the agent's process is the block's own (no shell stays in front). Arguments with spaces, quotes, ;, $(), backticks, a newline, a leading -, $HOME and * reached a program unchanged (checked live). The agent also gets Rex's own variables (REX_SESSION, REX_BLOCK, TERM_PROGRAM=rex) and the server's environment less the sixteen names.
    • Ownership: the creating connection owns the new block, which would keep collied's size (80x24), so collied attaches the session (session.attach, harmless when the follower already did) and gives the block up (session.disown_block), and fails the start, naming the block it left running, if Rex still names collied's client as its owner or the attach names no client. A block no client owns stays 80x24, so a fullscreen agent such as Claude Code drew 24 rows on the alternate screen, which the phone pinned to the bottom of its Terminal view while Rex.app did not show the session (#951). So session.create gives the block the size of the tallest terminal collied follows (the widest on a tie) as the shell flavor's options.size, the starting size block_creator.list documents, only when that is larger than 80x24 by rows, then columns; with nothing larger it starts at 80x24. A client that takes the block later sizes it as its owner. Repair of a block that started unsized uses resize, which Rex applies at once while no client owns the block (checked on a scratch server); a failed resize is logged. While another client owns the block the resize only queues, and it is not applied when that client leaves (checked on a scratch server). Each record carries sized, set when session.create supplied the block's size, once collied's repair resize succeeds, on any size_changed for its block, or when a sync finds it no longer 80x24; each sync (collied's start and every reconnect, after every session is read) sends the same resize, once, to a recorded block not yet sized that collied lists as an agent leading the block with no shell above it and that is still 80x24, checked again right before each send (never a shell, such as a task's block restored as one after a Rex restart, nor an agent the user starts in it). So a task started before #951 is repaired without restarting its agent, and a size picked later stays. A lost answer to session.create (the connection dropped) fails the start saying an agent may have been started in a new Rex session: Rex may have made it, and a block that was never given up stays owned by a client that is gone, keeps its starting size (80x24 unless collied asked for a larger one) and stays when its program exits (checked live in the review), until the phone archives or closes it. A block no client owns closes when its program exits (checked live), and one a client took stays with its exit; collied follows both (block_closed and child_exited for its task blocks, last_exit in a read), so an agent that exits before it is ready fails the start at once, and the session stays.
    • Records: the task's name, the id of the session session.create made for it and, for a worktree task, the canonical checkout, by block id in rex-tasks.json (0600, data directory, replaced atomically without sync_all): Rex has no label of collied's own on a block, and its ids are never reused. A record goes when its block's block_closed arrives, and each full read of the server (connect and reconnect) forgets the records of blocks it no longer holds. A lost file loses the checkout's removal on archive (the archive then closes the block and leaves the folder) and the one-task-per-checkout check at start, which fails safe: the earlier task's block then counts as one collied did not start, so an archive in that checkout is refused.
    • Ready and prompt: as for herdr-core, from the same code: polled from the model every 250 ms for up to 30 s, ready once the agent reports idle or done and keeps that report for 1 s and its foreground process runs in the folder asked for (Rex starts a block whose folder is no directory in the home folder instead; herdr-core 0.1.x refuses such a start with spawn_failed, checked live, and gets the same check), failed by a blocked report or, while it has no status, by a startup dialog on its screen; the screen is read only while it has no status, so a Claude Code that reports reads none. Then the prompt is pasted after the screen check and with the status re-check of Input, below; it is never on the command line.
    • Archive: as for herdr-core, from the same code, with the checkout recorded for the block: collied refuses while any other block works in the checkout (shells, Rex.app's blocks and other tasks included), reading every terminal block's process afresh (session.list, session.list_blocks, then process per block), since Rex sends no event when a shell changes folder; a block whose current or foreground folder (symlinks resolved) lies in it counts. A followed herdr-core's terminals count too, and Rex's for a herdr-core task's archive. Then block.close of the task's own block (a listed agent only), the occupancy read again, git worktree remove --force, gh poi.
    • Session removal (#727): right after block.close, and only when the task's record names the block's session as the one collied created for it, collied reads that session's view (session.attach, whose windows Rex leaves out when there are none) and its blocks (session.list_blocks, detached ones included) and, when both are empty, destroys it (session.destroy). The record is on disk, so a task started before collied restarted is still known; with no record or no session in it (earlier builds), or a read that leaves it unclear, the session stays, as every session collied did not create for that task does, and sessions left empty another way (the agent exited, its block closed in Rex.app, a failed start). Rex has no conditional destroy: a block or window added after session.list_blocks answers and before session.destroy arrives, one round trip, ends with the session. The archive's answer says what became of the session ("Removed its Rex session.", "Kept its Rex session, which still holds something or could not be read." or "Could not remove its Rex session (...)."), and the task is archived either way. Resume reads the agent's transcript and starts a new session, so it is unchanged.
    • Rex sends process_changed only when the foreground process's pid or name changes: a program that execs another of the same name (a bash script that execs bash with another argv[0]) keeps the first one's argv0 in the model until its next process event (seen live with such a stand-in). Claude Code and Codex start through env under other names, so each step sends one.
  • Input. A prompt and a typed answer are a block.event paste then a key event for Enter; text without Enter (the slash mirror, an approval note, keystrokes from the phone's terminal view) is a paste alone, which Rex brackets itself: the slash mirror's bracketed paste markers are added only for herdr and herdr-core. Rex brackets a paste only when the program turned bracketed paste on, sends its newlines as \r otherwise, and turns an ESC in it into a space, so a paste cannot end itself. Keys, Ctrl+End and a notice digit are key events: a W3C key code, Rex's modifier string (shift+ctrl+alt) and the text the key types. All go on the follower's own control connection, attached to every session as block.event requires, where they run in the order sent; a send to a block collied does not list, or while no server is followed, is not_found with no call, and one on a connection that dropped fails at once. The ready check is the one herdr and herdr-core agents take, with the agent from the model. block.event takes no condition, so before each event of a prompt or a typed answer (the paste, and the Enter after the paste's response) collied reads the agent again from the model, with no call, and stops on a status other than the one the ready check saw (agent_not_ready, as herdr-core's status_mismatch); a typed answer to a blocked agent also requires the same state_change_seq, so it never lands in the next dialog. Rex pushes every report, and collied applies those that came before an event's response before that response returns. What remains: a dialog that opens after that check and before Rex handles the event, one round trip, which herdr refuses at the call and herdr-core's if holds. Keys carry no status (as herdr's and herdr-core's), so they are sent without it. One call's events go out together: no other call's key lands among them. Keys reach a program as herdr-core sends them, checked live for every named Key and every character key: Shift makes a letter a capital and leaves any other key as it is. Refused before anything is sent, every key of the call included (internal): cmd, and Control without Alt on a character with Shift or on i ' , - . ; = or `, which Rex sends to a program without a keyboard protocol as nothing (herdr-core refuses all of these), ctrl+[ (nothing either) and ctrl+alt+[, which arrives as ESC [ and with the next keys could spell an escape sequence. Prompts to Claude Code, the slash mirror, notice answers and Ctrl+End read the screen first, as for herdr, through the screens #705 reads (checked live against a stand-in input box: a prompt, the slash mirror and its clearing, a refused prompt and Ctrl+End under the jump banner, a notice's digit).

    • Terminals (#755): terminal.run is a paste then Enter, terminal.send_keys key events, with the same refusals, and terminal.send_text a paste, after drive's checks for a herdr shell (Watch and input), on the same connection, one call at a time. They reach only a block listed as a terminal: before each event collied reads the block again from the model, with no call, and stops (not_found) once it is no longer one, so the Enter of a line meant for the shell does not follow it into an agent whose start Rex reported meanwhile. An agent started in the shell is still sent the event from its exec until Rex reports the change, a delay of Rex's own that was not measured, and one round trip after, as an agent starting in a herdr pane gets the write; agent input reaches no terminal the same way. herdr types terminal.run's line and terminal.send_text as keystrokes, Rex takes them as a paste, which it brackets only for a program that turned bracketed paste on (zsh's line editor does), so such a program gets the text as pasted; macOS /bin/sh does not, and live_rex_terminals checks there that a line runs as typed.
  • Approvals. The approvals engine follows Rex agents as it does herdr's and herdr-core's, from the same code. A blocked report's kind (permission, question) decides whether it parses a menu, as herdr's rule id does, and state_change_seq (from the record's updated_at) moves on every report, so two identical dialogs in a row raise two approvals and a decision meant for the first finds another seq and sends nothing; an unchanged record keeps its seq across a reconnect, and with it the pending approval. Approve and Deny are the keys a herdr agent's are (enter, arrows then enter, or esc), sent as key events. A screen read makes Rex render the whole scrollback, so while a blocked Rex agent's approval stands its screen is read on at most three reconciles of each report (a dialog may still be drawing on the first), not on every reconcile: three format calls per report, all in its first seconds, against one a second (measured on Claude Code 2.1.325 left blocked with no phone connected: 3 in 60 s). A read that failed does not count, and an approval that ends while the agent stays blocked on the same report (expired after the approval TTL, or superseded because its dialog changed on screen) lets the next reconcile read again and raise a fresh one, up to three reads more, as a herdr agent gets. The cost: a dialog that changes on screen without a new report after those reads, as when the Mac's user presses Tab on it, keeps its approval on the phone until a decision, whose own read before any key finds another fingerprint and sends nothing, or until it expires.

  • Resume after a restart (#927, ADR-0013). Rex restores its sessions, windows and blocks under the same ids when its server starts again, each block as a new shell (a block started with a command too) in the folder its shell was last in, and server.status names a new instance_id (checked on a scratch server, Rex.app 0.1.0 build 2104, API revision 19). collied resumes Claude Code, Codex, Copilot CLI and Antigravity CLI (#934). While it follows a server, collied records each listed agent of those kinds with its conversation and an absolute foreground folder, by block id, once the conversation's transcript exists. The conversation is a Claude Code's pid-file binding, a Codex's hook binding or an Antigravity CLI's binding (its hook or its one open presence lock, whichever does not disagree with the other; Sessions, above; a Codex only with --no-daemon, since otherwise its hook runs under the shared app-server and is refused, and its terminal process holds no file of the conversation), and for Copilot CLI the session whose inuse.<pid>.hold the block's foreground process holds (an flock), with inuse.<pid>.lock naming that pid and the process started before the marker, when that process holds exactly one such marker under session-state (after /new, Copilot keeps the old session's marker beside the new one's) and the session has an events.jsonl and the folder as its cwd; several, a marker that cannot be read, or a listing cut at its cap records nothing. A confirmed resume is also recorded under its new block while that block's process still passes its kind's proof below, until a binding names another conversation, so a Codex resumed and not prompted yet is resumed again after a second restart. The transcript is <claude dir>/projects/<the folder's project name>/<id>.jsonl for Claude Code, a rollout whose session_meta names the id and the folder for Codex, session-state/<id>/events.jsonl for Copilot CLI and brain/<id>/.system_generated/logs/transcript.jsonl for the Antigravity CLI. Claude Code writes its transcript with the first prompt, and claude --resume of a conversation without one prints No conversation found with session ID and exits (checked with Claude Code 2.1.331, which looks the id up in the folder's project, then the git worktrees', then every project, and gives up on none or several). A Claude Code agent's foreground folder is the claude process's own, the folder its pid file names and its transcript is kept under; a ! cd in Claude Code moved neither (checked), and its worktree commands were not checked. The record lives with the server's instance_id in rex-resume.json (0600, data directory, flushed on each change). collied reads at most 256 KiB of it (the limit applies to the read itself, on the descriptor it checked), keeps at most 256 entries with a valid block id, a lowercase UUID conversation and an absolute folder of at most 4,096 bytes, and drops entries before writing until the record fits 256 KiB, so it never writes a record it would refuse. A record that cannot be read or parsed is logged with the error's category only, never its text. An agent that leaves its block stays recorded for 15 s while collied follows the same instance, across a reconnect to it too, since a shutdown ends the agents before the server stops; a SIGTERM to the server alone sends no exit before the connection closes (checked). When collied follows another instance than the recorded one and that instance's started_at is less than 90 s before now (a started_at in the future is not eligible), it takes the recorded agents off the record and saves it, and only then plans them, until 90 s after that start measured on collied's monotonic clock from the moment it planned. A reconnect to the same instance keeps the plan and the grace timers. On each reconcile tick (every second) of that window collied starts each planned agent beside its restored shell, never typing into it. It starts one only when:

    • the block is on the new instance with a shell in front, and a fresh process read shows that shell running nothing: it is the block's own program, or the only process under Rex.app's login;
    • the shell's screen (format VT through the emulator, as text) matches the first read collied took of it, which it takes on the first tick it finds that shell running nothing. Changes in the 2 s after that first read are taken as the prompt settling and become the reference; after those 2 s, any change refuses the block for good, and the screen must have stayed unchanged for 2 s. No prompt shape is read, so any prompt (several lines, a right prompt, none ending in a blank) passes; a first version required an empty prompt with nothing after the cursor, and a shell with a two-line prompt and a right prompt was never resumed (live_rex_resume checks one);
    • collied's own SHELL (which launchd sets from the account for its LaunchAgent) is an absolute path with no = to zsh or bash, the shells checked (any other, or none, is logged and starts nothing);
    • the recorded folder is still a directory, the transcript still exists, no live process holds the conversation, which waits for it to go (a Claude Code's pid file, sessions/<pid>.json, alive and started no later than it says; an flock on Codex's thread-writer-locks/<id>.lock; any held inuse.<pid>.hold of the Copilot session, or one collied cannot tell (a folder or entry it cannot read, or more than its listing cap); for the Antigravity CLI an flock on presence/<id>.lock under its data folder, or one collied cannot tell, or a listed agy block whose process has that file open), and no agent in the live model runs the conversation;
    • a claim, under the lock the option's toggle takes, still finds the block planned, the option on, the window open and the conversation not started on this instance.

    It then calls session.new_split anchored on that block (side: before) with one shell-flavor block with options: {command, cwd, shell: "none", login: false}. command is /usr/bin/env, -u with each stripped name, the login shell by its absolute path, -l, -i, -c, the script builtin cd -- "$1" && <cli> <resume arguments>, collied as $0 and the recorded folder as $1 (never part of the script), so a startup file that cds elsewhere is undone and a folder that cannot be entered starts nothing (live_rex_resume checks one that does). The CLI's part is its bare name and its resume arguments (claude --resume ID, codex resume ID --no-daemon, copilot --resume=ID or agy --conversation ID; every word only lowercase letters, digits, - and =, the id a lowercase hyphenated UUID), and cwd is the recorded folder. Nothing is typed: the interactive login shell reads the user's startup files once, as a Rex.app terminal's does, so their environment (CLAUDE_CODE_EXPERIMENTAL_CODE_MODE, whose absence made every Claude Code started by absolute path refuse its Code Mode conversation in the field), aliases and functions apply, and it execs the CLI, or for a shell function stays with the agent in front, which owns its OSC 7501 record (checked on a scratch server with zsh and bash). Without shell: none, Rex's own login shell around the argv would read the profile a second time (checked). The new block starts at the restored shell's size (options.size; Rex keeps a block's size across a restart, checked), and collied gives it up at once, so Rex.app sizes it once it shows it; a task's record moves to it unchanged. On the following ticks, an exit is decided first: a new block whose program exited (child_exited or last_exit), or one collied saw and the server no longer lists, ends the attempt, and collied closes neither block. Rex closes the new one as its program exits (checked on a scratch server for a program exiting a second after it started, whether or not collied's connection still owned the block; one exiting within milliseconds stayed with last_exit), so the agent's error shows only for a moment. A block missing from the model because its reads failed (Model::holds), or while collied is not in sync with the server, is never taken for an exit. Otherwise the old block closes only once collied has listed the new block for 3 s in a row as an agent of that kind in the recorded folder (its foreground_cwd) with its proof: for Claude Code its pid file's binding, for the Antigravity CLI its hook's, or the block's foreground process having presence/<id>.lock open (device and inode, as for Codex) and no other presence lock (several, or a listing collied cannot read whole, confirm nothing); for Codex, the block's foreground process having both thread-writer-locks/<id>.lock and the conversation's rollout open (device and inode against the process's open files, from proc_pidinfo on macOS and /proc on Linux) while an flock on that lock file is held, as collied's own try shows, by whichever process; for Copilot CLI, that process marking exactly one session, the resumed conversation's, as above, so a second marker or one collied cannot read leaves both blocks. Each holds before the agent's first turn (checked with Codex 0.171.0 and Copilot CLI 1.0.112 on a scratch home), except the Antigravity CLI's hook, which reports only with a prompt. The owner's live Rex restart on 1cc4a875 (Antigravity CLI 1.5.16) resumed an agy whose hook had not reported, since it reports only with a prompt, and its shell stayed. lsof on that process, file names only, showed it holding presence/<id>.lock under its data folder open read-write before any prompt, the only process with any presence lock open, beside stale 0-byte locks of past conversations no process had open. On a scratch home agy --conversation ID stops at its sign-in screen before creating presence/, so the lock's timing before sign-in and whether agy flocks it were not checked live; its binary names a flock.Flock type and the error "presence: held by another process", so the flock is inferred, not shown. Right before the close, collied reads the old block's process and screen again, the only awaits before block.close, then checks from the model, with no await, that the new block still runs that conversation in that folder and has not exited, and that the option is on and the window still open. A collied task's record (rex-tasks.json) moves to the new block first. Rex then gives the new block the old one's place in the layout (the same split id, ratio and rect, and the focus, checked live). If the agent stopped meanwhile, both stay; if the shell changed, the option went off or the window ended, both blocks stay; if the agent is not confirmed within 30 s, both stay. A confirmed agent is the new block's program (or its foreground, under a shell function), so the block closes when the agent exits, as a task's does. For an id with no transcript, Codex and Copilot CLI print an error and exit; the Antigravity CLI warns and goes on, so only its hook's report or its presence lock for that conversation confirms it. Each decision and outcome is logged at warn level, which the service log keeps, with the block id and the kind, never the conversation id or folder; a block still waiting when the window ends is logged with its last wait reason, and a restart that plans nothing is logged with why (no earlier server recorded, the record could not be saved, a start time unknown or later than now, or more than 90 s ago). rex-resume-off in the data directory turns it off and deletes the record; the control socket's rex_resume request ({"cmd":"rex_resume"} reads it, "on": true|false sets it, audited as rex.resume) answers {"type":"rex_resume","on":BOOL}, or an error where collied follows no Rex. live_rex_resume runs a real restart: a scratch Rex server with restore on, inside sandbox-exec denying every folder under /Users (a restored block runs the account's default shell), a shell whose prompt has two lines and a right prompt, a stand-in claude started in it and recorded, the server stopped by its pid and started again, and collied starting the stand-in with --resume ID through the account's login shell, wrapped in a .zshrc function, with the rc's CLAUDE_CODE_EXPERIMENTAL_CODE_MODE and its new block's REX_BLOCK, in the restored shell's place once a pid file binds the conversation.

  • Both at once. As for herdr-core: without a followed runtime every answer is herdr's, unchanged; a Rex that never answered stays quiet; one that stops after answering logs once and its agents leave with one flock.changed. herdr stopping while herdr-core or Rex answers logs once, and its return once: the core and Rex share that record, so it holds when one stops while herdr is down.

  • Status and doctor. collied status prints a rex: line: the version and the server's newest API revision (or not running, or running when a server answered but is not followed), the socket, its folder's mode, why it is not followed, and how other machines reach it. collied doctor: no server is ok; otherwise the version and revision, the folder (0700) and socket (0600) checks, a warning for a server it does not follow (revision, missing methods, the personal-server checks, an anonymous listener, a server that answered and then failed) and for remote access, and a warning when the server's environment, which every block inherits, holds HERDR_PANE_ID, HERDR_SOCKET_PATH or CLAUDE_CODE_CHILD_SESSION (names only, from server.status's pid, as for herdr-core's holder). herdr not running is ok while herdr-core or a followed Rex answers.

  • Code and tests. Owner::of classifies an id once (herdr, herdr-core or Rex, by prefix) and every Runtime call matches on it. runtime/rex/ holds one concern per file: wire.rs (wire types), client.rs (the method enum, handshake, calls and event pump), discovery.rs (the socket and the personal-server checks), model.rs (sessions and blocks from reads and events), screen.rs (format tails into the emulator), input.rs (pastes and keys as block.events), mod.rs (the method check, subscribe and read, reconnect, report), sessions.rs (the session binding) and tasks.rs (task start, records and occupancy). What herdr-core and Rex share (the agent CLI and shell lists, kind, status, title, group status, the Codex reporter's ancestry check, the task kinds, CLI lookup, stripped names and env argv) is in runtime/agents.rs; runtime::TaskHost is where a task starts when herdr is not running, and drive's task code takes it for either. CI has no Rex: an in-process fake rex.control.v1 server (runtime/rex/fake.rs) on a Unix socket in a temporary folder covers the revision refusal, the method check, subscribe before read with a session created in between, seq reconciliation, reconnect, the owner and shell rules, other hosts, the folder and socket checks, the listener checks, the message limit, and screens: Rex's own format VT of a Claude Code permission dialog, emulated, reads as its format text; an unchanged tail is not emulated again; readers that ask together share one format made after they asked, and fail within one timeout behind a format Rex never answers; a dropped result is formatted again; 100,000 lines of scrollback move only the tail; input (pastes and keys, the refused keys, and no input to an agent with no status or one collied does not list); approvals (Approve on Rex's own screen of a permission dialog, two identical dialogs in a row, a reconnect with the same report, and the bound on screen reads); the session binding (a pid file for the block's foreground pid, one naming another pid, a stale one, one rewritten with no event and read at the reconcile tick, a binding whose process changed while its file was read, a hook report from under the block's Codex and from elsewhere and kept across a reconnect, task.sessions, a Copilot CLI marking one session, two after /new and a session folder collied cannot read, an Antigravity CLI presence lock against its hook); and tasks (the session.create payload for each kind and a resume, hostile values as single elements, the block given up and a server that keeps it, the routing order by injection, records on disk and forgotten once their block is gone or closes, an exit before the agent is ready, an agent running in another folder, an idle Claude Code beside a menu that gets no prompt, a lost session.create answer, archive closing only the task's block and removing its checkout, removing the task's own session once empty (by a collied started again too) and keeping it while another block is in it (a detached one, which only session.list_blocks shows, included), while its view shows a window, or for an agent collied did not start, and refusing under another block, under a herdr-core terminal, for a herdr-core task under a Rex block, or for anything Rex does not list); and terminals (#755: the listing rule on a shell, a command under a shell, an agent started in one, a program with no shell, another host's shell, and a shell keeping an agent under it, unlisted whatever the record says while that shell owns it, listed for fg once suspended at idle, unlisted again for a working record under a live owner, and listed once the owner is gone, its input answered as a pane hosting an agent; a group per session, from the model with no call; input reaching only a listed terminal of this host, behind drive's grant and shell checks; an agent started during a line getting no Enter; a watched terminal streamed and an unwatched one never read). live_rex (e2e) runs a Rex server of its own, as AGENTS.md says, with a stand-in agent reporting OSC 7501 and another below 100,000 lines of scrollback, and is skipped when no rex is found; live_rex_phone adds the phone over a test tailnet, a stand-in Claude Code writing its pid file and a stand-in Codex running collied hook's code with the block's REX_BLOCK, and a stand-in Copilot CLI marking its session and then a second one as /new does (as does live_herdr_core_phone), for Chat, task.sessions and a /clear with no report; live_rex_input checks the bytes a raw-mode program in a block receives for every key against herdr-core's, live_rex_approvals Deny, Approve and two identical dialogs on a stand-in that draws one and moves its cursor, live_rex_drive drive's prompts, slash mirror, Ctrl+End and notice answers on a stand-in input box, live_rex_terminals an interactive /bin/sh started with --shell=none, listed in its session's group and kept while it runs a command, taking drive's line, keys and text, and streamed while watched, beside a program with no shell that is not listed, and unlisted from the first report of a stand-in agent under sh -c, refusing a line as a pane hosting an agent, then listed again once it exits, and live_rex_tasks New task with stand-in claude and codex CLIs on a server holding dummy values for the sixteen names (none reaches the agent; PATH comes from the scratch home's login profile), a worktree task, the block's owner, hostile arguments, an archive refused under a shell that cds into the checkout, and the archives: a task's own session removed once empty and kept while it holds a window the test opened, the session of an agent collied did not start kept, and an archived task resumed.

  • No version bump: no phone wire type changed. Rex agents and groups use the existing Agent, Workspace and error codes, and Rex terminals (#755) the existing Terminal, so an installed app lists and opens them as herdr's. StatusInfo.rex is a new optional field on the control socket, with a serde default, read only by collied status.

Runtime marks

  • Wire. Each Agent carries runtime (herdr, herdr_core or rex, the TaskRuntime of New task), which collied sets from Owner::of on the terminal id when it maps a listed agent, in flock.snapshot and agent.status alike. It is on the agent, not the group, because the session header has only the agent; the grid, the list and the inbox have both. The app never reads the id prefixes.
  • App. The grid card, the list row, the inbox row and the session header draw the runtime's mark as a badge on the bottom-right corner of the agent's mark, with a gap cut into the agent's mark around it, so it works on any background. The badge is 12 pt, growing with the text to at most 14 pt, so the half that hangs below the agent's mark stays inside a grid card's 10 pt bottom padding (at Accessibility XL an unbounded badge, 29 pt, crossed the card's edge). No row is added. On a grid card the badge's overhang fits the agent mark's fixed 16 pt column and the 6 pt spacing after it, so the group's label does not move; in the list, the inbox and the header, which space the mark 4 to 6 pt from what follows, the mark reserves the overhang (3 pt). Drawn beside the agent's mark instead, it cost 20 pt, and "Herdr Core" truncated on a grid card that also shows the remaining context. Herdr Core shares herdr's mark, and its group's label is the same for every agent, so a Herdr Core agent's card or row shows its folder whenever one is known, also alone in its core (below, #866). With no folder known, the app shows the group's label as "Core" beside the badge (decided from the agent's runtime and cwd at display time; the group's name on the wire stays "Herdr Core", and anywhere without a badge, or with Runtime icons off, it reads "Herdr Core"). The session header, which shows no group label, adds "Core" after the badge. The badge's accessibility label is "Rex" or "Herdr", and "Herdr Core" in the header, where no group label follows, and beside a folder, which does not say it; cards and rows combine it with their label, so a Herdr Core card with no folder reads "Herdr, Core". With no runtime, an unknown one, or no agent kind, no badge is drawn.
  • Setting. Settings > Sessions > Runtime icons (DevicePrefs.runtimeMarks, on by default, a missing field reading as on) reaches every badge and the header's "Core" through the environment and applies at once. Off, nothing of the above is drawn and no space is reserved, so rows and labels are as they were before the field existed.
  • The watch app, CollieBar and CollieTray show no runtime.
  • No version bump: runtime is an optional, additive field on a server-to-phone type that every retained codec passes whole. An older app ignores it, an older collied sends none and the app shows no mark, and an unknown runtime reads as unknown, which collie-core drops.
  • Marks. The app draws other projects' marks; none is collie's. The PNGs are renditions sized for where they are drawn (12 pt at 1x, 2x and 3x for the runtime badges).
    • herdr and Herdr Core (Herdr.imageset, added in #752 at the owner's request): herdr's logo, assets/logo.png in herdrdev/herdr at ee5bfb5041bb3e4a49d591c72308aae3c81ecdde (the file last changed in a57b97285c3308fbdcc167ab3da9ae1dd78767b6), resized. It is copied under the repository's Apache-2.0 license, which grants no trademark rights. The license ships as Collie/Resources/herdr-LICENSE.txt, whose first lines say the logo was resized, and shows in Acknowledgements. The repository has no NOTICE file at that commit.
    • Rex (Rex.imageset, added in #752 at the owner's request): the release app icon without the "BETA" banner, AppIconLightPreview in the asset catalog of Rex Beta.app (com.superlogical.rex, version 0.1.0, build 1987, read on 2026-11-15), resized. The bundle carries no license or notice for it, and it is used without a license or trademark grant. Rex is a closed preview.
    • Claude Code, Codex and Copilot (Claude.imageset, Codex.imageset, Copilot.imageset, #63), Ghostty (Ghostty.imageset, the Terminal kind, #75) and Tux (Tux.imageset, Linux machines, #31, a template image its commit says was drawn): Anthropic's, OpenAI's, GitHub's and Ghostty's marks and the Linux mascot, with no recorded source.

Tailscale (libtailscale, pinned commit, never tagged upstream)

  • libtailscale main@dacde75 (bindings 0.2.0, with the listener fd-passing fix 258321b and the close-on-exec fix ac7ed43; dacde75 itself changes only the Swift TailscaleKit, which collie does not build) as a git submodule. Upstream pins tailscale.com v1.104.1; patch 0001 only raises its go directive to 1.27.4, and patch 0011 only raises tailscale.com to v1.104.7 in go.mod and go.sum, with the newer golang.org/x, gliderssh and wireguard-go versions it requires, since no upstream commit uses it yet. Requires Go β‰₯ 1.27.4; builds use GOTOOLCHAIN=local, -mod=vendor, -trimpath, -buildvcs=false, -ldflags=-w.
  • collie calls neither tailscale_getremoteaddr, which before 0.2.0 returned the wrong peer 17% of the time under concurrent fd churn in testing, nor tailscale_loopback, which would open a 127.0.0.1 TCP listener (SOCKS5 + LocalAPI) on the machine and which iOS reclaims on suspend. The series (patches 0002 to 0010):
    1. tailscale_accept_with_addr returns the peer ip:port from the record that carries the fd (upstream's holds the IP only). A per-listener lock keeps concurrent accepts from interleaving a record whose MSG_WAITALL read was cut short; the short-read path keeps the control message (upstream drops it and miscounts on EINTR) and upstream's close-on-exec receive flags; a failed accept closes any fd it received; an accept that waited for the lock re-checks that the listener is open. The tailnet end-to-end tests check each accepted address and whois against its dialer under concurrent accepts.
    2. tailscale_whois_json(sd, addr) via the in-memory LocalClient (as tailscale_status_json).
    3. Disable log upload to log.tailscale.com in Go (TS_NO_LOGS_NO_SUPPORT): a c-archive snapshots the environment at load, so a later setenv is invisible to Go.
    4. Guard the per-handle lastErr with a mutex (also where getremoteaddr sets it): upstream's unsynchronized write is a Go data race when one handle is used from several threads.
    5. Keep the Go copy of each accepted fd open until C has received it: macOS's unix-socket GC can dispose of a socket whose only reference is in flight, losing the peer's first bytes (reproduced at about 1 in 150 connections).
    6. tailscale_dial_timeout and tailscale_set_advertise_tags.
    7. Socketpair proxy: a non-blocking Go end so close always delivers EOF (a lost shutdown wakeup left readers hanging), shutdowns through Control so they never hit a reused fd number, cleanup once as soon as either direction ends (upstream waits for both), no fd-number-keyed map.
    8. UserLogf discarded: tsnet otherwise prints the interactive login URL to stderr every few seconds.
    9. Listener socket close waits for in-flight sendmsg (and item 5 sends each fd inside its os.File Control), so no fd number can be reused under a send.
    10. tailscale_rebind(sd, default_if). iOS can defunct netmon's route socket while the app is suspended (XNU exempts only local and system sockets), and on iOS netmon has no time-jump check, so it never sees another change and the node keeps binding to the Wi-Fi interface the phone left. The call records default_if from NWPathMonitor (netmon.UpdateLastKnownDefaultRouteInterface, like Tailscale's own apps) so new sockets bind to it, injects a netmon event and waits up to 1.5 s for netmon to re-read the interfaces through a routing-table sysctl, not its route socket, and publish a move as a major link change (engine rebind, DERP reconnect, control connection closed), then runs the LocalAPI rebind and restun debug actions: magicsock re-binds its UDP sockets, reconnects any DERP connection that misses a 3 s ping, forgets the peers' direct paths and re-STUNs.
    11. logtail.Disable() next to TS_NO_LOGS_NO_SUPPORT: with uploads off, every log line was still written to the tailscaled.log*.txt buffer, read back and compressed. crates/tailnet/tests/end_to_end.rs asserts both files stay empty.
    12. tailscale_close first cancels a context every dial derives from: netstack's close aborts only the TCP endpoints registered when it starts and waits for later ones, so a racing dial held the close, and the node restart, up to its 5 s timeout. collie-core closes a replaced node while its dials are in flight.
  • Every fd libtailscale hands out is close-on-exec (upstream ac7ed43): the listener and connection socketpairs, both ends, and each connection fd received over SCM_RIGHTS, so a process collied starts (git and its hooks, gh, codex app-server) cannot, outside a narrow window on macOS, keep a phone connection or the listener open after collied closes it. Linux sets the flag atomically (SOCK_CLOEXEC, MSG_CMSG_CLOEXEC); macOS has neither and marks each fd right after creating or receiving it (threat model). crates/tailnet/tests/end_to_end.rs starts a child while holding the listener, a dialed and an accepted connection, and checks by socket identity that the child holds none of them.
  • The iOS archive is built with -tags=ios,ts_omit_portmapper: no NAT-PMP, PCP or UPnP probes of the Wi-Fi gateway on every netcheck. collied keeps its port mapper, so a direct path to a phone behind a hard NAT can still form from the Mac's side.
  • Vendored module patches (patches/<import path>/<file>.patch, applied after go mod vendor; go.sum still verifies every module):
    • tailscale.com tsnet/tsnet.go: with no advertised tags specified, keep the existing requests (read through the sanitized LocalBackend.Prefs() API before startup), so fresh nodes stay untagged and an old tagged node can be observed and rejected without removing its requests or forcing reauthentication. Explicit nonempty requests keep upstream behavior.
    • tailscale.com ipn/ipnlocal/peerapi.go: never open the kernel peerapi listener when netstack is present; upstream binds it to every interface in netstack mode, exposing a TCP port to the LAN. Tests and collied doctor check that no kernel TCP listener exists (Kernel TCP listener check).
    • gvisor tcp/connect.go + stack/stack.go: a SYN reusing a 4-tuple in TIME-WAIT goes to the forwarder instead of being dropped (the cause of a 63 s dial stall).
    • tailscale.com wgengine/netstack/netstack.go: close link queues before aborting endpoints so tsnet.Server.Close cannot hang.
    • tailscale.com wgengine/magicsock/magicsock.go: TS_DEBUG_MAGICSOCK_BIND_LOOPBACK=1 binds the UDP sockets to 127.0.0.1 and ::1 instead of every interface. Only the tailnet tests set it (with TS_DISABLE_PORTMAPPER), so the macOS firewall never prompts for a new test binary; collied and the app leave it unset.
  • Every patch applies with patch --fuzz=0: a hunk whose context lines changed fails the build, naming the patch; one whose context only moved still applies.
  • Bumping: move the submodule, rebase the patches and review upstream's changes to the files they touch; redo a patch that no longer applies by hand, never force it. crates/tailnet/testcontrol must use the same tailscale.com as libtailscale's patched go.mod (crates/tailscale-sys/tests/versions.rs checks the build's copy). To run a newer tailscale.com than upstream pins, run go get tailscale.com@vX.Y.Z and go mod tidy in a copy of the submodule with the series applied, save the go.mod/go.sum diff as a patch and do the same in testcontrol; drop the patch once upstream pins that version or newer.
  • Control sees Hostinfo App libtailscale, Package tsnet, IPNVersion 1.104.7-ERR-BuildInfo (the suffix from -buildvcs=false) and GoVersion, but no libtailscale version, so it cannot tell 0.2.0 from an older one. What Tailscale keys its libtailscale notice on is unknown (collie's nodes were flagged while already reporting 1.104.1); stamping -X tailscale.com/version.longStamp=... and shortStamp waits on that answer.
  • Gate per connection, before the WebSocket upgrade: whois(peer) must show an untagged node, not shared in, owned by the owner user. The owner is the daemon's verified positive embedded self user before listening; the optional [tailnet] owner_user_id, the persisted owner and every paired phone must agree, and a first pairing cannot choose or replace it. Then:
    • paired StableID with a pinned TLS key β†’ full session (hello first, then the allowlist). While a pairing window is open, a paired phone's pair.complete goes through the same y/N confirmation as a new phone's and replaces its record, so a phone that removed the machine while it was unreachable pairs again without a revoke. A paired phone's unpair, which the app sends when it removes a connected machine, revokes it as collied peers revoke does: collied answers, then removes it, drops its push tokens and closes its sessions;
    • unpaired (or paired without a TLS key), while a locally opened pairing window is active β†’ pairing-only session: hello and pair.complete only, one attempt, then close;
    • otherwise a fixed 403 without reading the request, close, and log; the phone treats 403 as final.
    • At most 4 live sessions per node: a fifth evicts that node's oldest, so a phone reconnecting after iOS killed its sockets is never locked out. Global cap 64 connections. Of those, one source address holds at most 8 that have not finished the WebSocket upgrade, counted from the accept: a ninth is dropped unanswered (never the 403, which the phone treats as final) and audited as too many connections from this address, so an address that opens connections and leaves them silent until the 5 s whois and 10 s handshake deadlines cannot take every slot (#795). 8 leaves room for a phone's 4 sessions all dialing again while collied still holds one abandoned attempt of each. A whois lookup that outlives its timeout keeps its place in both counts until it returns, and a session evicted during its WebSocket handshake stays counted until the handshake ends. Revocation cancels in-flight replies and re-checks authorization before every frame.
  • Phone: tailscale_dials the IP of the Mac's pinned entry in its own netmap (tailscale_status_json) after the ownership and whois checks in tailnet.md; no DNS lookup.
  • tailscale_up blocks until Running and is not cancellable; collied drives its own state machine from status_json (BackendState, AuthURL) and always calls tailscale_start first.
  • Accepted fds are AF_UNIX socketpairs: collied awaits the listener's readability with tokio's AsyncFd, accepts, and reads each fd as a non-blocking tokio::net::UnixStream.
  • magicsock binds a UDP socket on real interfaces: that is the WireGuard tunnel itself and the one unavoidable non-tailnet socket. No TCP listener exists outside the tailnet.

libghostty-vt in collied

collied links libghostty-vt, the terminal library the app renders with, to follow a watched Rex terminal as a stream (#764, #765; Streams under Rex): it restores Rex's snapshot and parses the live output. collied keeps both emulators: alacritty_terminal still emulates Herdr Core's terminals and every polled Rex read, and the move of Herdr Core to libghostty-vt (#766) is not planned (libghostty-vt.md).

  • crates/ghostty-vt-sys: the C functions collied calls, declared by hand from the pinned release's headers (no bindgen, no third-party crate), linked statically. Compile-time asserts pin every struct's size and offsets to the headers'. Its tests reference every declared function and create a terminal, feed it bytes and format them, so a misspelled declaration or a broken link fails cargo test on macOS and Linux. runtime::ghostty is the only caller, a safe wrapper that keeps the headers' rules: the formatter borrows the terminal and a selection's grid references hold only until the terminal next changes, so both are made and freed within one call under a shared borrow; empty output is a null pointer with length 0, never made into a slice; a terminal is Send but not Sync (no thread affinity, no locking of its own) and lives behind a mutex.
  • scripts/ghostty/pins.env holds the version, the vt- tag's commit, the two release tarballs' SHA-256s, the Zig version and a Zig SHA-256 per download host (arm64 macOS, x86_64 Linux), and the uucode license pins. The app's build-xcframework.sh and collied's build-collied.sh both read it, through common.sh. Zig is 0.17.1, the version the app already used; Ghostty's own CI builds 1.0.1 with 0.17.0, its minimum_zig_version.
  • build.rs runs scripts/ghostty/build-collied.sh <target>, which writes target/ghostty/collied/<target>/ (lib/libghostty-vt.a and the license texts scripts/notices.py collied reads) and does nothing when its stamp matches: version, Zig version, features, Zig target and a checksum of pins.env, common.sh and the script, so a change to any of them rebuilds (the app's stamp does the same). A finished build is also kept, under its stamp, in the user's cache folder (~/Library/Caches/dev.rbstp.collie-build/ghostty on macOS, $XDG_CACHE_HOME/collie-build/ghostty, else ~/.cache/collie-build/ghostty, on Linux), and another checkout or worktree whose stamp matches copies it from there instead of building; the app's xcframework is kept the same way. That folder is trusted as target/ is: it is used only when the user owns it, and is set to mode 0700. Cargo reruns it only when those files, build.rs or the archive change, so an archive removed or not restored by CI is built again. A cold build takes about 90 s on an M3 Max, for macOS and for Linux x86_64 cross-compiled from it, and about 4.5 minutes on the 4-core ubuntu-24.04 runner.
  • Zig: on the two hosts with a pinned download (arm64 macOS, x86_64 Linux) the build always uses the release it downloads into zig-<version> in that cache folder, checked against its SHA-256, never a zig on PATH, so the same pins give the same compiler everywhere; a developer needs no Zig installed there. The download is unpacked beside that folder and moved into place, with a marker holding its checksum, only once the whole extraction succeeded; a folder without the marker is downloaded again. Any other host (aarch64 Linux, Intel macOS) needs Zig at the pinned version on PATH. The tarballs come from release.files.ghostty.org, or this repository's ghostty-vt-<version> release when that fails, and are checked against pins.env either way. Zig has no mirror: a build that has to download it, every release build among them, needs ziglang.org reachable.
  • Features: -all,+grid-introspection,+formatter,+snapshot (grid references and the formatter for screens, the snapshot decoder for Rex streams). Targets: aarch64-apple-darwin (Zig aarch64-macos, objects for macOS 13.0), x86_64-unknown-linux-gnu and aarch64-unknown-linux-gnu (x86_64-linux-gnu, aarch64-linux-gnu, Zig's default glibc), all with -Dcpu=baseline, each built from an empty Zig cache as PACKAGING-LIBGHOSTTY.md asks. aarch64 Linux is mapped, not built or tested.
  • Build mode: ReleaseSafe, where the app's framework uses ReleaseFast and the phone filters what it parses instead: before each render, TerminalScreen keeps only text, CR, LF, TAB and SGR, the grammar sanitize_ansi writes, so a paired machine that was taken over reaches only those paths of the phone's parser (#808, threat model). collied parses program output in the process that holds its tailnet identity and keys, so a slice-bounds, overflow or assertion fault in the Zig code panics and aborts the daemon, which launchd or systemd restarts, instead of corrupting memory. Pointer arithmetic, which the page storage is built on, use after free and the C++ libraries it bundles (simdutf, Highway) stay unchecked (threat model). It costs size: linked into a small program that formats a terminal, the library takes 1.20 MB on macOS (0.91 MB in ReleaseFast) and 2.02 MB on Linux (1.61 MB), stripped. On the stream path it costs little (#765, M3 Max): restoring an 8.8 MB snapshot of 96,456 rows took 16 ms against 12 ms in ReleaseFast, parsing 5.1 MB of Rex's VT output 191 MB/s against 220 MB/s, a 200-line read 0.71 ms against 0.57 ms, and collied's CPU on a changing 100,000-line watch was 1.5% of a core in both modes.
  • No C++ runtime and no new shared library: the Linux archive's only outside symbols are glibc's, and a program linked against it needs only libc.so.6 and ld-linux-x86-64.so.2.
  • CI: the rust job restores target/ghostty/collied from a cache keyed on pins.env and the two scripts. Its cargo cache lists target/* and !target/ghostty: actions/cache matches the listed paths without their descendants and archives each whole, so the negation can only drop a listed child, and a bare target would carry target/ghostty into the cargo cache. The linux job (ubuntu-24.04) does the same, runs the crate's tests and builds collied for Linux when a change touches what collied builds from. Both desktop-release.yml jobs run build-collied.sh for their target before cargo build.
  • A version bump changes pins.env alone, after the checks in libghostty-vt.md; CI rebuilds the app's and collied's libraries, since every cache key hashes it.

Mutual TLS

Inside the tunnel, after the whois gate and before the WebSocket upgrade: TLS 1.3 only, RFC 7250 raw public keys (no certificates), ECDSA P-256 with SHA-256 only, and no session resumption (it would skip the key check). Each side pins the other's key by the SHA-256 of its SubjectPublicKeyInfo (KeyPin, base64url); the shared verifiers are in crates/tls.

  • collied makes its P-256 key on first start (tls-key.json, PKCS#8, 0600 in the data dir). Its pin is in the pairing QR (k=, invite v=2), and the phone keeps it as the machine's key. A new key means pairing every phone again.
  • The phone's key is a non-exportable Secure Enclave key, kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly so lock-screen decisions can connect. collie-core holds only its public key and asks the app to sign each handshake. The simulator uses a software key. Its Keychain item is in the app's own access group, and the app replaces the key only when the enclave calls the stored one corrupt (iOS).
  • A full session needs the phone's pinned key (peers.json tls_key). A pairing session takes any P-256 key, and confirming the pairing records it.
  • A peer the gate rejects gets the fixed clear 403 before any TLS, so nothing from it is parsed; the phone recognizes it from the first bytes (Sniff) and stops retrying. A machine presenting another key is a pin violation, and collied refusing the phone's key reaches the phone on its first read as KeyRefused (TLS 1.3 checks the client after the client's side is done); both stop retrying and ask to pair again.
  • After the handshake collied runs the gate again under the peers, pairing and sessions locks and refuses the connection on a different decision, such as a revoke, a pairing or the window closing during the handshake. The per-node session cap and the registration happen under those same locks.

Negotiated protocol compatibility

Revision 26 is the first negotiated baseline; the floor is 26 (PROTOCOL_MIN_VERSION) and the ceiling 32 (PROTOCOL_VERSION). Revisions 3 through 25 used exact matching and have no retained codecs: update both peers once to reach the baseline; paired keys do not change.

hello.protocol_version offers the highest supported revision and the optional protocol_min_version the floor (absent: that one revision). The daemon selects the highest common revision and returns it as protocol_version, with its own protocol_min_version and protocol_max_version and the selected capabilities. It rejects a reversed or zero range, a duplicate capability, an unknown request field or a malformed parameter; an empty intersection closes the session with unsupported_protocol, the daemon's maximum and which side to update. The phone rejects a selection outside the common range or below the highest common revision, and capabilities it did not implement.

Omitted offer capabilities mean exactly the baseline set, currently terminal_grants_v1; [] opts out, and unknown names are ignored and never echoed. A baseline phone omits its singleton floor and baseline capabilities, so its hello has revision 25's fields and a strict revision-25 daemon refuses the version rather than a new field; nothing falls back or sends revision-25 operations. A wider offer sends its floor explicitly, which revision 26 accepts; the current phone offers 26 to 32, so a revision-25 daemon rejects its hello as malformed.

terminal_grants_v1 names the existing P-256 terminal grant codec and the optional pairing terminal_key. Without it, the phone omits the key and refuses terminal methods locally; the daemon rejects an unsolicited key or terminal method, audited as not_implemented, and never serializes terminal challenge or grant results. Every request, daemon result and event passes through the negotiated codec, which for revision 26 covers the complete baseline, including current request parameters and enum variants; unknown events cannot be emitted. Paired sessions, pairing and short-lived approval or bootstrap connections all negotiate through Session::hello, after TLS pinning, whois, pairing windows and authorization.

Rules for new revisions:

  • Retain the current and previous two negotiated revisions; raise the floor only once three real codecs exist.
  • Before the advertised range widens, every wire change gates its fields and enum variants (request, parameter, response or event) for each retained revision.
  • A future relay grant or encrypted payload format needs its own implemented capability and codec; terminal_grants_v1 promises nothing about them.
  • Never claim pre-baseline compatibility by widening a range.
  • Before removing a revision, publish the new floor in the release notes and the update guide, and test both upgrade orders with serialized fixtures for every retained revision and for peers below the floor.

The checked-in compatibility fixtures exercise the real revision-26 to 32 codecs; synthetic 33/34 ranges test negotiation arithmetic, not claimed codecs.

Revision history, exact matching (3 to 25):

  • 3: mutual TLS; apps and collied from before it cannot talk to newer ones.
  • 4: agent.output_patch, which an older app would drop, freezing its terminal view.
  • 5: lines on agent.watch (an older collied refuses the unknown field).
  • 6: terminal_key on pair.complete, and the terminal methods.
  • 7: trail on agent.output_patch, which an older app would apply wrongly.
  • 8: low_data on agent.watch and terminal.watch (unknown field).
  • 9: agent.scroll_bottom (an older collied refuses the unknown method).
  • 10: agent.answer_notice (unknown method).
  • 11: agent.slash_draft (unknown method).
  • 12: label on agent.answer_notice (unknown field) and its digit "4"; collied and the app ship together.
  • 13: task.folders and new_folder on task.new (unknown method and field), and roots on task.options.
  • 14: mute_done on push.register (unknown field).
  • 15: task.worktrees and the worktree option on task.new.
  • 16: task.archive and its result.
  • 17: root on agent.changes (unknown field), and worktrees and the committed section in its result, which an older app cannot read.
  • 18: scope on agent.changes (unknown field), and base and each file's hash in its result; the branch scope compares HEAD with origin/HEAD, then main, then master, which collied resolves itself.
  • 19: clone on task.new (unknown field).
  • 20: task.sessions (unknown method), and resume on task.new with prompt optional when it is set (unknown field or missing prompt).
  • 21: agent.watch_pull_request (unknown method) and pr_watch on Agent.
  • 22: ultracode on task.new (unknown field).
  • 23: task.archive_on_merge (unknown method).
  • 24: the pull_request mode of task.new's worktree (unknown variant).
  • 25: backspace and the Control letters ctrl+a, b, e, k, l, u and w in Key (unknown variants).

Revision history, negotiated:

  • 26: negotiated ranges, selected capabilities and required hello-result negotiation fields; a bump because an older peer rejects the new revision or cannot validate the selected baseline.
  • 27: latest on agent.history, for chat previews on grid cards. A revision-26 daemon rejects the unknown parameter, so the revision-27 codec allows it only when 27 is selected, and a revision-26 session refuses it locally.
  • 28: the usage.costs read method and its usage_costs result, for token cost in the Usage view. An older daemon answers unknown_method, so the revision-28 codec allows them only when 28 is selected; a revision-26 or 27 session refuses the request locally, and the card asks to update collied.
  • 29: the file.open, file.chunk and file.close read methods and their file_opened and file_chunk results, for files from Chat. An older daemon answers unknown_method, so the revision-29 codec allows them only when 29 is selected; a revision-26 to 28 session refuses them locally, and the viewer asks to update collied.
  • 30: the worktrees and pull_request scopes of agent.changes with its pull_request parameter, and the pull_request section of agent.diff with its own, for the Git changes worktree list. A revision-29 daemon rejects the unknown variants and fields, so the revision-30 codec allows them only when 30 is selected, and refuses a git_changes result holding a pull_request file otherwise; a revision-26 to 29 session refuses them locally, and Git changes asks to update collied. The summary fields of GitWorktree and GitChanges.pull_requests are optional and additive, sent only for the new scope.
  • 31: agent.send_text and terminal.send_text, which type keystrokes into a pane without Enter, for typing straight into the terminal view. A revision-30 daemon answers unknown_method, so the revision-31 codec allows them only when 31 is selected (terminal.send_text also needs terminal_grants_v1); a revision-26 to 30 session refuses them locally, and the phone shows its error until collied is updated.
  • 32: key combinations in Key, a key shortcut's modifiers and one key (ctrl+alt+x), on agent.send_keys and terminal.send_keys. A revision-31 daemon rejects them as unknown variants, so the revision-32 codec allows a call holding one only when 32 is selected; a revision-26 to 31 session refuses it locally, and the phone shows its error until collied is updated. The nineteen listed names decode as before, so saved shortcuts keep working with an older collied.

The floor stays 26: raising it is a separate release step with its own notice.

Approvals

The agent reconcile (approvals.rs) issues one approval per blocked terminal_id: {approval_id (16 B), terminal_id, agent_label, workspace_label, snippet, tool, reason, options, choices, accepts_input, has_text_field, supports_note, nonce (32 B), created_at_ms, expires_at_ms}, expiring after 600 s (approvals::TTL, not a collied.toml key). collied reads the screen (pane.read source=detection) and the matched rule id (agent.explain, whose output carries raw pane text and is never exposed).

  • Menu. collied answers only Claude Code's select menu: agent kind claude, a rule in prompt::CLAUDE_MENU_RULES (herdr claude manifest 2026.10.11.1), and the last numbered block under the dialog's top rule (see Context; one above it is old output), numbered from 1 without gaps, with exactly one ❯. Inside the block only Claude Code 2.1.289's rule above "Chat about this", a row of ─ alone indented no deeper than the options around it, is skipped; any other rule-like row there, such as an option description the agent wrote starting with ───, is text of the option above it and stays in its label, its choice and every cursor fingerprint. Anything else raises an approval with no options, which the phone shows but cannot decide.
    • Renamed sessions (Claude Code 2.1.300, herdr 0.9.5 rule live_blocked_form_named_session): the name sits on a rule (─── <name> ─) under the question's footer. Under that rule only, prompt::without_session_name cuts the name rule and all below it and reads the rest as live_blocked_form, if the last rule on screen carries text after its dashes (so a menu typed into an idle input box is not read), the last line above it ends in "Esc to cancel", and only blank lines and task panel rows follow. A footer wrapped in a very narrow pane is not cut, so that question is answered in the terminal.
    • Folder trust: the only unnumbered menu read is the folder trust prompt ("No, exit", then "Yes, I trust this folder"; rule live_blocked_form), and only in its exact layout: one ❯ line, one-line options at the cursor's label column set off by blank lines, each mapping to its own decision and one carrying trust wording. It is then handled as a numbered menu.
  • Other agent kinds. Codex and Copilot CLI prompts are not parsed: their approval's alert has no actions and never goes on a Live Activity, and approval.decide is refused (invalid_params, nothing sent). Any agent can be answered by hand (Prompts without decisions). A pending approval ends when its snippet no longer matches the screen, so a new prompt never shows with the old command.
  • Why no approval actions for Codex and Copilot (codex-cli 0.160.1, Copilot CLI 1.0.94): collied never takes an approval from screen parsing alone, Copilot has no usable non-screen source, and Codex's is not built. Codex's PermissionRequest hook hides the terminal prompt until it exits, gets a stale HERDR_PANE_ID and must be trusted by hand; its app-server sends approvals (item/commandExecution/requestApproval) to every same-uid client, but under approvals_reviewer = "auto_review" asks the user only when neither hooks nor guardian decide, so a phone path would rarely fire, and each request would need binding to a pane. Copilot's permissionRequest hook fires before allow rules, locks the terminal, misses path prompts and carries no request id; its SDK extension path needs the global experimental flag and @experimental permission RPCs and gets the session's whole RPC surface. Revisit if Codex's approvals_reviewer is "user" or Copilot's extension and permission APIs become stable.
  • Settings pickers (prompt::settings_picker, Claude Code 2.1.294): /effort and /config's time format, output style and flagged message pickers change a setting, run no tool and grant nothing, so they raise no approval. Each must match its exact text under the last β–” border, whitespace removed, for agent kind claude under live_blocked_form or the renamed-session rule. Any other dialog still raises one, as do a picker whose text a later Claude Code changes and /advisor, whose "No advisor" reads as a decision. /model raises none: herdr leaves its status unchanged. A suppressed picker still takes arrows, Enter and Esc on the agent screen.
  • Options. Each decision maps to exactly one option label: approve to Yes, Yes, proceed, Yes, I trust or, for the dynamic workflow prompt, Yes, run it (that label whole: Yes, run it and ... is none); approve_always to Yes, and don't ask again and similar; deny to No or No, .... An option is read as the phone shows it, its label and detail together and cleaned as the choice is (Menu::text), never from the raw label: a format character in front of Yes, or the wording split between the last label and the row under it, would otherwise show as a grant and read as none. Menu::grants and Menu::takes_choice read the same text. Decisions matching zero or several options, and other options ("Yes, and switch to auto mode"), are not offered. approve_always is also not offered when its option's label or detail is longer than a choice holds (300 chars each), the rows that continue the last option counting as its detail (see Choices): the app shows that wording as what the grant covers, and a cut would hide its scope. Nor is it offered when a row under its option is not shown as its text (the option is last and a row under it sits left of its label, or any non-blank row sits further down, under a blank row or a rule, to the screen's end: the rows read stop at those, and the option's own text can draw either, so a footer there withholds it too): this check does not rest on the display rule, since spaces inside a label move the label's column and one row set left ends what is read as detail, either of which would leave the rest of a scope unseen. No captured dialog has a row under that option: each ends on No. A menu with no approve or approve-always option (questions, plan prompts) is not a permission prompt and offers no decision, not even deny. A numbered menu whose top is not on screen (Menu::on_screen) offers nothing at all: Claude Code draws a dialog taller than the terminal from its bottom (2.1.328 says ↑ N more lines under the options), so its head and a command's first lines have scrolled off, and rows no read shows are neither displayed nor bound. A question form that tall scrolls its options instead (2.1.329): it hides its header and top rule, marks the last option on screen ↓ in the cursor column when more are hidden under it and the first ↑ when more are hidden above, and says ↑ 1 more line. Menu::parse reads no menu there, whatever rule sits above the form: a ↓ row under the last option read stops it, and otherwise a number is missing (Chat about this keeps its number under the hidden options) or option 1 is off screen. A numbered row inside an option's own text is no option (option_rows): one under an option row, set in deeper than that row's number, with every row between them as deep, blank rows aside. Claude Code draws an option's number left of all its text, and the agent writes that text: 2.1.329 draws a description as one paragraph wrapped at the label's column, a line break in it as U+FFFD (captured), so a description of the right width starts rows with a rule, a header, the question, 1. A and ❯ 2. B. Read as options, those rows were a menu of the agent's making under a rule of its own, its cursor on B while Claude Code's is on A: no arrow is sent and Enter picks A. They are that option's text, shown in its detail and bound, and with more than three of them the form is no menu. A menu's numbers also share one column, so such rows over Claude Code's own entries, their option row off screen, are no menu either. The top is the dialog's top rule. A menu with no granting option (Menu::grants: a label classify reads as a decision, No included, or one starting with Yes) may sit under a β–” border instead, as the rate limit form does, which has no rule: from the last option up, the nearest row that starts at column 0 must start with β–”, which Claude Code draws at column 0 above a form whose every row is indented, its options included. No text of such a form sits at column 0, and a question form, whose text does, has its cursor row there too, so neither passes a β–” row of its own off as the border. A granting menu needs the rule, since the plan prompt is drawn under such a border behind a rule of its own and could lose the rule and keep the border. That approval carries no options, choices or tool and sets neither accepts_input nor has_text_field, its context is the question line, and it is answered in the terminal. A form with a numbered row that does not parse as a menu (its option 1 off screen, or more than three rows under an option) sets no accepts_input either, since it may be a menu cut under its first rows. prompt::numbered reads the whole screen and counts a numbered row with no β–” border under it: a numbered list in the transcript above an unnumbered form (/memory, /ide, usage credits) is old output, and those forms take keys as before. A row of rule characters under the options hides no numbered row from it, since an option's own text can draw one. A row of ─ in a question's own text passes for the top rule, so a question form needs more than its top on screen (see Question forms).
  • Choices. choices lists the menu collied answers, permission prompts included and a question form only when it is matched to its call (see Question forms), as {index (0-based), label, current}, current marking the ❯ option; labels and details lose controls, bidi and format characters, and one longer than 300 chars is cut to 300 with the … that marks the cut (120 before; no version bump, the fields only hold a longer string). A detail is the rows under an option's first line. For the last option it takes the rows under it that continue it: those indented at least as deep as its label, up to the first row left of that, a blank row or a rule. Claude Code draws a wrapped label there, and nothing tells a hint at that column (a plan's shift+tab to approve with this feedback) from the label wrapped onto it, so such a row is shown as the option's own. A row left of the label is not shown as the option's text; in the captures it is the footer Claude Code 2.1.294 draws right under a /config picker's options, left of their numbers. It stays bound: the region holds every row under the last option and marks those shown as its text, so a row moved across the label's column supersedes the approval, and a pending approval is reissued when any of them changes. Under an option that reads as approve_always it withholds that decision (see Options). An approval with no options is answered with approval.decide {decision: "choose", choice: <index>}. A permission prompt never takes choose, which would bypass the decision mapping (Deny is sent as Esc). Nor does a granting option (Menu::grants's rule on its label: one classify reads as a decision, or one starting with Yes) of a menu that holds an option reading as an approval (classify gives approve or approve_always), whatever the approval offers (Menu::takes_choice): a menu whose only decision was withheld (one other option beside an approve_always with a cut scope) offers no decision and lists its options as choices, and choose on a granting option's index is refused (invalid_params, nothing sent) while the other option is chosen as usual. ApprovalChoice has no field to mark such an option, so it is listed and refused. A plan prompt holds no option that reads as an approval (Yes, and ..., No, keep planning), so its options stay chosen by index. The phone reads a permission prompt's choices for one thing: the rule approve_always saves. It finds that option by classify's prefixes over the label and detail (ApprovalChoice.grantsAlways) and draws it verbatim above Always allow, in the review sheet only; with no such option or several, the phone neither offers nor sends approve_always.
  • Question forms (Menu::asks, Transcripts::asking, Waits). Claude Code draws AskUserQuestion's form, and that call's review page, with no β–” border, and the screen cannot say such a form is whole: its text starts at the top rule's column, so a row of ─ in the question passes for that rule, and a form taller than the terminal scrolls its options and hides its header and top rule (see Options). So it is answered on more than its top rule, by one of two paths. Where the call that asks is in the session's transcript, as for a question asked from a Code Mode script, the form must draw that call whole. Where it is not, as for a question asked outside Code Mode (Claude Code 2.1.329 writes a message that holds an AskUserQuestion call only once the call has its result, so nothing of it is on disk while the form is up), the form is held to what the screen alone proves, below, and only while the transcript shows an open turn with no call.
    • Which menus. The report of what blocks the agent says which dialog a menu is, never the wording on screen: the agent writes a question's labels and every option's description, which 2.1.329 wraps as one paragraph at the label's column, so with that option's row and Claude Code's own entries off screen a description can draw a whole plan prompt or permission prompt, its cursor where the agent put it. Under a report of a form (herdr's live_blocked_form, question from Claude Code itself on Rex and herdr-core) every menu with no β–” border is a question, held to its call or to what the screen proves and answered only by choosing an option: no decision, no note, and no Esc for an option labelled (esc). The one exception is the unnumbered folder trust prompt under herdr's live_blocked_form, which herdr reports for it, and only with its cursor at column 1, where Claude Code draws it: no row the agent writes starts there, an option's text starting at its label's column (5 or deeper) and a question's at column 0 or behind the gutter. Which rule herdr gives Claude Code 2.1.329's plan and permission prompts is not captured; under live_blocked_form they now offer nothing. Under any other report a menu that reads as a question, as below, is refused (not reported as a question), whatever call the transcript names. Wording does not make a menu a question or not either: the agent can word a question's labels as an approval (Yes), as an amend field or as the plan prompt. So how Claude Code drew the menu comes first (Menu::asked_shape): a menu with its cursor row at column 0, where Claude Code 2.1.289 to 2.1.329 draws AskUserQuestion's form and its review page while it indents its other dialogs, or with an entry Claude Code adds to a question's options (Type something., Chat about this, [ ] Type something over Submit), is a question form whatever its labels read. The agent writes neither mark and can leave neither out. Only a menu drawn otherwise, and with no β–” border, is another dialog by its wording (Menu::is_question): a permission prompt holds an option that reads as an approval (classify gives approve or approve_always on the option as shown) or, left in its amend state, one that reads as the field Tab opens on Approve or Deny (Yes, and tell Claude what to do next, No, and tell Claude what to do differently), and the plan prompt, which holds neither, is told by its own wording (its question over option 1 ends Would you like to proceed?, and option 1 starts with Yes). The plan is left to the screen so that plans are still chosen from when no session is tied; ExitPlanMode is not required for it. A menu with none of these is no dialog collied knows and is treated as a question: a form Claude Code came to draw without those marks does not fail open. Over the fixtures, every permission, trust, amend and plan screen is drawn without the marks, and every question form with one (the 2.1.289, 2.1.300 and 2.1.329 captures have their cursor at column 0).
    • The session is the terminal's by process, never by folder or by herdr's own id. For a herdr pane it is the session that every sessions/<pid>.json of the pane's processes names, checked as in Context and inbox (an attach client, or a pane whose processes are not listed, has none; a process list cut at its 16 entries ties nothing, since a second Claude Code past the cut is not seen); for a herdr-core or Rex terminal, the id the runtime read from the foreground process's file. Exactly one live process may claim that session, since two would write one transcript; a sessions folder of more than 256 files gives none.
    • What the session waits on (Waits) is one of six things (a Code Mode script, waiting or dispatched, is below), and "not known" is never read as "nothing". collied reads the transcript's last 1 MiB backward to the start of the last assistant message: an assistant line of another message, or, on lines that carry no message id, a user line that is not only tool results. Claude Code writes one line per content block, so parallel calls are several lines of one message, and a result or another line can come between them. A question: exactly one tool_use there lacks a tool_result, it is named AskUserQuestion, and its line carries the session's id and a timestamp no older than the process's startedAt. Another call: the same with any other name (ExitPlanMode, Bash). An open turn: no call lacks its result and no script runs, and the last line of the conversation is a user line of this session's process, a prompt or the results of the last calls, and not the line Claude Code writes when a call is interrupted; this is what the transcript holds while a question asked outside Code Mode is on screen, read from captures of a first prompt, a later one, a question after a Bash call and one after a sentence in the same message. A user record that is no prompt is passed over, as the history reader tells them (isMeta, a compaction summary, a task-notification origin, a slash command, a local command's output): it opens no turn, so a question asked right under one, before that turn's first tool result, is refused. The read must also show that the session is not in Code Mode, where a question is a script's and the screen stands for no call: Claude Code 2.1.329 writes a permission-mode record at a session's start and again through it, followed in Code Mode by a repl-mode record. So a turn is open only where the read holds no REPL call and no repl-mode record, and either starts at the file's start or holds a permission-mode record. Nothing: the same with the turn over, the last line an assistant line or that interrupted line, with a script still running that asks nothing, or with a REPL call or a repl-mode record in the read. Not known: no session tied, no transcript, a last line without its newline (Claude Code is still writing it: it can be the call's result or a second call) or a line that does not parse, a result above the call it answers, a read that ends before the message's start, several calls without a result, a call older than the process or of another session (one that a killed session left in a transcript another process resumed), or an open turn in a read that starts inside the file and holds no permission-mode record, which shows nothing of the session's mode.
    • The match. The options on screen read, in order, the label and description of one question's options, followed only by the entries Claude Code adds: Type something., then Chat about this when it draws it; for a multi-select question a [ ] or [βœ”] box before each label, [ ] Type something over Submit, then Chat about this. No row sits under the last one, and the cursor row is at column 0, where Claude Code draws a question form's and no row of an option's text starts (see Options). The rows between the dialog's first row (the header, or the tabs of a call with several questions) and option 1 read that question's whole text, all of them behind the β”‚ gutter (2.1.329 draws a question that holds a newline or is wider than 80 columns behind it) or none. When the options on screen read as those of more than one question of the call, the form is refused, since a cut first question can draw the second's tabs and text; the test is the one that matches an option, label and description together with whitespace aside, so SQLite with Simple and embedded and SQLite Simple with and embedded are two such questions. The review page is matched whole too: Review your answers, then every question in order, its text behind ● and an answer behind β†’, over Submit answers and Cancel. Text is compared as the transcript holds it, whitespace aside, which wrapping moves.
    • What is answered. While the session waits on a question, a menu is answered only when it draws that question, whatever it reads as. In an open turn a question form is answered when the screen proves it whole (next entry). In every other state (another call pending, nothing pending, not known) a question form, as told above, offers nothing, and a permission prompt, the plan prompt and a form under a β–” border are answered as the screen reads them, so approvals keep working when the session cannot be tied or its transcript cannot be read. A call that is no question does not make a menu that call's dialog: a transcript written late can still name the call before the question. The workflow prompt (Yes, run it, View raw script, No) is a permission prompt by its Yes, run it: it offers approve and deny in every state. View raw script is listed among its choices and is no decision; choose presses nothing where a decision is offered, so that option is reached in the terminal.
    • Outside Code Mode: the screen's own proof (Menu::stands_whole). In an open turn there is no call to match, so a question form is answered only when all of this holds. The report of what blocks the agent calls it a form: herdr's rule for one (live_blocked_form), or, for a herdr-core or Rex agent, the kind question that Claude Code's own report gives, which is not read from the screen (permission is its kind for permission and plan prompts). The open turn's line carries Claude Code version 2.1.329 or later, the version whose drawing was captured. And the form stands whole on screen: its cursor row is at column 0; Claude Code's header (☐ or β˜’ at column 1) or its tabs row sits directly under its top rule; the text under it is one row of at most 80 columns under a rule of more than 80, or rows all behind the β”‚ gutter under a rule of more than 75; the menu ends in Claude Code's own entries, and no row sits under the last one. This closes the row of ─ that passes for the top rule, on these facts of 2.1.329, each captured: a question that holds a line break, or is wider than 80 columns, is drawn behind the gutter, where no row is a rule; any other question is one line of at most 80 columns, which a terminal wider than that draws as one row, so it draws no rule and no header of its own, and which a narrower one wraps at column 0 (2.1.330, captured), where its 80 characters cannot hold a rule of more than 75, a header of four or more and a row that starts with β”‚; a form taller than the terminal hides its top rule; and every row the agent writes above a form, in a reply or in a tool's output, is indented, so none passes for a rule at the screen's edge with a header under it. A form that scrolls is no menu (see Options). What this path does not offer: the review page of a call with several questions (its rows are the questions' own text with no gutter), any form in a terminal of 75 columns or fewer, one of 80 or fewer whose question fits one row, and any form of an older Claude Code, which drew a question of several lines at column 0 where a rule and a copy of the header pass for the top: nothing on screen tells that drawing from a whole form, so the version decides. Nothing binds such an approval to a call: the fingerprint holds the session and the region, as for any dialog.
    • Code Mode. With Code Mode on (CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, 2.1.329) the model's one tool is REPL, a script runner, and AskUserQuestion is a function the script calls (await tools.AskUserQuestion({...})). The transcript then holds nothing of the question but the script's text, and the form is drawn as outside Code Mode. A script is running in one of two shapes. Where Claude Code asks before it runs a tool, the REPL call has no result until its script ends. In auto mode (--permission-mode auto) Claude Code answers the call at once with a receipt, a result that reads (dispatched #N) and nothing else (as a string or as its one text block), lets the script run, and when it ended writes an attachment of type poll_events whose repl-eval event names script N, then the question as an AskUserQuestion call of its own with its result. When the model waits for its scripts itself, with a Poll call, the event comes in that call's result instead, under a first line that reads <system>authentic event nonces ..., and the attachment is empty; such a result's lines that open an event with a nonce its first line names are read the same way, and no other: an event's body is the script's output, which can hold a line that opens an event of its own. Any tool's output can hold the text of a receipt or of an event, a script's own included, so each result is read as its call's, tied by tool_use_id: a receipt only as the result of a REPL call, an event only as the result of a Poll call or in the attachment. So a REPL call with a receipt is running until such an event sits under it. The numbers start again in a new context, so an event counts for the nearest receipt above it, and only an event's opening tag is read, since its body is the script's output. Running scripts are looked for over the whole 1 MiB read and not only in the last message: the model can go on to other calls while a script runs. A script whose line is older than the process died with the process that ran it; one of another session, or with no time, makes the state not known (stale call), as does a result that reads as a receipt or as events whose call the read does not hold, or a repl-eval event with no number. A script dispatched before the read's first line is not seen, and its question is refused as no pending call. The state "a script" is exactly one running REPL call whose input.code names AskUserQuestion, whatever else waits beside it: Claude Code's own wait for its scripts (a pending Poll), another running script, or another pending call, whose permission prompt is no question form. Two such scripts, or one beside a pending AskUserQuestion call, are several pending calls: nothing says whose form is drawn. A running script that does not name it is another call when its call has no result, and nothing when it was dispatched. Once the script ended nothing is pending, and the screen's own proof is not taken in its place: a read that shows Code Mode gives no open turn (above), so a form still drawn between the script's event and the model's reply is refused as no pending call. A read that lands between the question's own call and that call's result, which Claude Code writes after the script's event, finds an AskUserQuestion call with no result that nobody is asked any more: 2.1.329 ends that message with stop_sequence, and such a call is not known rather than a pending question. The script is not parsed, so nothing says which call or which question of it is drawn. Instead, what the form draws must each be the whole content of a string literal of the script (Menu::scripted): the question's text, and of every option other than Claude Code's own entries the label and the description, each a literal and each on rows of its own (the function's declaration requires a description, and an option drawn without one is refused); on the review page, every question's text. A literal is the text between two matching quote characters (', " or a backtick) with \n, an escaped quote or backslash and \u escapes undone. The read is whole or it is nothing: the suffix check below needs every literal, and a read that does not parse loses its step at a quote in a comment or a regular expression and then passes over literals without seeing them. So a script answers nothing, with the reason pending script not read whole, when it holds a quote that a line break (LF or CR) or the script's end leaves open, which is where a stray quote shows, a template that holds ${, whose text is not what it gives and which can hold literals of its own, or an escape that is not undone (\t, \x41, a surrogate pair). Comments are read as comments (// and /* outside a literal, except after a backslash, as \/ stands in a regular expression), so a quote in one opens nothing and hides no literal. The price is that a genuine script with a quote in a regular expression or a template with a substitution lists no choices for its question. Whitespace is set aside as above, and the other checks stay: the top on screen, the text directly above the options, Claude Code's entries after them, no row under the last one, and a form that scrolls is no menu. A whole literal is what defeats a cut form: the rows left under a rule the question draws are the end of its text and no literal of their own. When the script holds that end as a literal too, as a second question worded like the first one's end would, the form is refused, since a longer literal ends in the text on screen. This assumes that Claude Code draws no question's options under another question's text, so that a text and options that are each whole are one question's; no other way was found for a screen to match the literals of two questions and be answered as the wrong one. A form not found so (its text or a label built by concatenation, by a template with a substitution, or read from a file) offers nothing, with no fall back to the screen. Any other dialog beside a pending script is read as the screen says: the script is pending through every call it makes, and the permission prompts of those calls are decided as before. The session id, the REPL call's id, the text and the options are hashed into the fingerprint. The literals are kept as a set: an option is looked up once for each way its rows, four at most, split into a label and a description, and the suffix check goes over the set once for each question. The limits: a script written to hold a decoy literal equal to a cut form's rows makes that form answerable, and so does one that builds its question from pieces when the rows a cut form shows are exactly one piece ('Continue?' after a warning and a rule). What refuses the second today is not the literal rule but the screen: under a rule the question draws the dialog has no header row and its top is not on screen, and Claude Code 2.1.329 draws a question of several rows behind its gutter, where a rule row is no top at all; a script that also draws a copy of the header as a piece of its own is a decoy. Such a script can as well ask the short question outright, so this defends against a question taller than the terminal and against a transcript that does not ask what the screen shows, not against a model that sets out to deceive.
    • A decision under way compares each read with the menu it claimed (Menu::only_changed: the same body, the same other options) on the menu as drawn, before this rule. The note it types turns Yes into Yes, <note>, which reads as no approval, on the same permission prompt: Edit's and Write's prompts hold no other option that reads as one.
    • Without an answer the approval is the one a menu with no top gets: no options, no choices, neither accepts_input nor has_text_field, and the phone says to answer in the terminal. That is every form cut or scrolled, at any height; a question whose own text draws the rule, since the rows under it are less than its text; a form with no call pending, or with another session's; every question in a terminal whose session collied cannot tie or whose transcript it cannot read; and also a form Claude Code rewrites on screen (format characters replaced, a question cut at 2000 columns, duplicate labels merged, a plugin's render hook), an option with more than three rows under it, an option of a Code Mode question drawn with no description, a question asked outside Code Mode in a session whose last 1 MiB holds no permission-mode record or right under a slash command or a background task's notice, a question asked right after a tool result of 1 MiB or more, a permission prompt with no other approval than Yes (Edit, Write) left holding a typed note in its place, outside a decision, and a read that comes while Claude Code is writing a line (the last line has no line break yet): every reconcile, once a second, reads the screen and the transcript of a pending approval again and reissues it when what it offers changed, so that refusal lasts one read. For a Rex agent the screen is read on three reconciles of a report, and again after each reissue. collied logs one line at warn level, which the service's default filter shows, for a menu it refuses so, once per terminal, blocked episode (state_change_seq) and reason, so neither a read, a moved cursor nor an approval reissued at its expiry logs it again, and under herdr, whose sequence does not move between the questions of one call, nor does the next question refused for the same reason (a form that does not read as a menu at all, as one that scrolls or holds more than three rows under an option, is not logged): question form not answered from the phone, the terminal id and one of fourteen reasons (no session tied, truncated process list, too many session files, transcript unreadable or incomplete, no pending call, another call pending, several pending calls, stale call, question not drawn whole, ambiguous, question not found in the pending script, pending script not read whole, not reported as a question, Claude Code version not known), never the question's text, its labels or a path.
    • Bound. The session id, the call's tool_use id and the question matched (its text, labels, descriptions and whether it is multi-select, as the transcript holds them; every question for the review page) are hashed into the fingerprint, and a decision reads the screen and the transcript again before any key. So a call answered since supersedes the approval, and so does another call that asks the same question on the same screen, which the question's content alone would not tell apart. Nothing read from the transcript is shown or sent: the approval's text is still the screen's.
    • Multi-select. choose on an option presses Enter on it, as on any menu. The form stays on screen (the captures show it with a box checked), so the outcome is chosen_unconfirmed and the approval is reissued with the boxes as drawn; which key checked the box in the capture was not recorded, and the form's footer reads Enter to select. Submit is a row under Type something, not a numbered option, and is no choice; the review page's Submit answers is one.
  • Context (prompt::context): the dialog from its top rule to the last option block, lines kept, controls, bidi and format characters stripped, at most 600 chars with …. A Bash prompt gives Bash: <every non-empty line between the header and the last "Do you want to" question, and every blank row of the command block>, Claude's description included, since plain text cannot tell it from a command line. The approver acts on this text, so a command must not be able to hide its own lines (with a Tip: line, a blank line, a fake question or option): no row of the command block is dropped, a blank one included (echo safe \ over a blank row and a second command must not read as one continued command, which the shell would not run as one), and Tip: lines are skipped only at the dialog's margin, never between the first and last β•Œ rule, where no row is dropped as a box border either (a dialog without β•Œ rules, as before 2.1.289, still drops a command row made only of box-drawing characters, and its blank rows, which Claude Code draws itself around the command there; no captured dialog with β•Œ rules has a blank row between them). Only a β•Œ row left of the dialog's text margin (the head row's indent) is such a rule: Claude Code draws its own at column 0 with the head at 1, while a β•Œ row the agent writes in a description or a command sits at or right of the margin and delimits nothing, so it can neither move the block up ahead of the command nor make a block inside a command drawn without rules. A command block row keeps its indent within the block and the spaces inside it (rm -- 'a b' is not shown as rm -- 'a b'): the fingerprint takes off only the dialog's margin (nothing from any row when one lacks it), so a gutter-shaped β”‚ a command writes itself still binds, and the context, tool and snippet also take off the 2.1.327 β”‚ gutter when the block has more than one row and every row has it (a one-row command gets none). No other box character is trimmed, so a heredoc's EOF against EOF, Python or YAML indentation, or a row that is itself β”‚ reads as the fingerprint binds it. Rows outside the block are trimmed, their runs of spaces shown as one. The top rule is the last horizontal rule (─) below the last option with rows under it, which makes a numbered menu above it old output, else the nearest one above option 1 that no non-blank row between them sits left of, found in one pass up from option 1: Claude Code draws it at the dialog's left edge, while a command row of ─ always has the closing β•Œ rule, the question or the header to its left, so a command cannot pass a rule of its own off as the top and hide its first rows from the context, the tool, the snippet and the fingerprint. A rule-like row between option 1 and the last option, such as an option's label wrapped onto a row starting with ─, never tops the dialog. Claude Code 2.1.327 draws every row of a command over more than one row behind a β”‚ gutter, which is no rule; the check covers dialogs drawn without it. A question form's text starts at its rule's column (0), so a row of ─ in it still starts the dialog as the screen reads it; the rows under it are then less than the question's text, and the form offers nothing (see Question forms). A plan's text is drawn above the plan prompt's top rule, so it is outside the region and the fingerprint: a choice on that prompt is bound only to the prompt's own rows. A Claude Code dialog with no top rule on screen is read from the whole screen, whose first rows are not its head: it names no call and gives the question line. Another tool gives <Tool>: <target> (Edit: src/main.rs); else the question line; else the dialog's first line (and the next when it ends in :). An approval that carries a tool (above) gets <name>: <summary> as its alert context instead, the command first.
  • Fingerprint. Since state_change_seq moves only on status changes, the approval is also bound to SHA-256 over the length-prefixed agent kind, rule id, terminal_id, agent session id, dialog region (the dialog's top rule through the last option and every row under it up to a blank row or a rule, those shown as that option's detail marked, cursor included, each command block row with its indent within the block, blank ones included), reason and, for a question form, the session, the call and the question matched in the transcript (see Question forms). collied also keeps, per option, the fingerprint with the cursor on that option.
    • Deny countdown (Claude Code 2.1.295 on, in a session it takes for unattended): ⚠ Claude Code will automatically deny this request in M:SS, to avoid blocking progress on an unattended session (or about N minutes / about N seconds) ticks every second, so prompt::without_deny_countdown removes it before approvals, or drive paths typing into a dialog, read the screen: only for agent kind claude with a parsed last option block, in that exact wording on up to three rows of its own at the dialog's margin, above a blank line and the question (its first row when a long file name wraps it), under the last of Claude Code's own β•Œ rules when the dialog has any (never when they are unpaired). A β•Œ row the agent writes at or right of the dialog's margin is none of them, so it cannot keep the countdown in the region and have the approval reissued every second. A copy in the transcript or the command stays. Its time is not read, and its ticking neither reissues nor supersedes the approval; when Claude Code denies on its own, the agent leaves blocked and the approval ends.

approval.decide

  1. Rate limit per paired StableID: 1/s, burst 5 (rate_limited).
  2. Claim. Any attempt burns a pending approval, whatever the result; a burned id answers approval_already_resolved, an unknown one approval_not_found.
  3. Expiry, nonce (constant time), decision offered. choose needs empty options and an index inside the menu; the decoder requires choice exactly with choose. A note needs approve or deny and supports_note; the decoder takes one line of at most 200 characters without bidi or invisible format characters, so the amend field still parses once it wraps (onto at most 4 rows). Anything else is invalid_params.
  4. Re-read the screen: still blocked, same state_change_seq and fingerprint, else superseded. Re-check peer authorization.
  5. Keys, from a fixed set (up, down, enter, esc), never pane text:
    • Deny is a single esc, wherever the cursor is, when its label ends in (esc) or on the folder trust prompt, whose "Esc to cancel" exits like "No, exit".
    • Otherwise: arrows to the target option, 150 ms pause, re-read (the fingerprint must equal that option's cursor fingerprint, else superseded), peer re-checked, then enter in its own call, since lost arrows would confirm another option. Digit shortcuts, which vary across Claude Code versions, are not used.
    • choose always takes this path and never sends esc.
    • With a note, Approve and Deny take this path too, never sending esc (in the amend field it cancels the whole prompt). Before enter go tab, a poll until the cursor's option shows its amend field (Yes, and tell Claude what to do next, No, and tell Claude what to do differently), the note through herdr's pane.send_text, and a poll until the option reads Yes, <note> or No, <note>. Each poll (every 100 ms, up to 1 s) needs the same reason and the rest of the dialog unchanged (its body, every other option and, unless the note goes into the last option, whose label wraps onto them, the rows under the last option) and the agent still blocked with the same state_change_seq; the peer is re-checked before each write. On any mismatch nothing more is sent: superseded, and the next reconcile issues a new approval.
  6. Settle: poll agent.list every 250 ms for up to 3 s (approvals::SETTLE) for the agent to leave blocked or move its state_change_seq.

The decide budget is 6 s from the claim to the last key; no key is sent after it. With the 3 s settle, a decision answers in under 10 s. A note to a herdr-core agent gets 3.5 s more, to wait out the core's typing hold (herdr-core); notes are never sent from the lock screen.

OutcomeWhen
applied {decision, by}final key sent, agent left blocked within the settle
unconfirmed {decision, by}final key sent (or its send timed out, it may have arrived), agent still blocked
chosen {choice, by}, chosen_unconfirmed {choice, by}the same two for choose, as their own outcomes so an older app decodes them as other. A multi-question form stays blocked on its next question: chosen_unconfirmed, then a new approval
supersededfingerprint, seq or cursor mismatch; amend field or note not shown; budget spent before the final key; bad nonce; decision not offered; peer no longer authorized; herdr failed; on reconcile, the agent left blocked or moved seq without a decision
expiredpast expires_at_ms, at decide or on reconcile

Every attempt that passes the per-peer frame limit is audited with its decision (choose <index>, <decision> with note) and result, replays, rate-limited and expired ones included. Sent keys are logged as terminal=<id> keys=<keys>; the note never is.

Reissue. A resolved approval is never reused: while the agent stays blocked, the next reconcile issues a new one (new id and nonce), sent at once to live sessions. It alerts for a new blocked episode, a changed screen (seq or fingerprint) or an expired previous alert, never for the same prompt within 30 s of the last alert, so bad attempts cannot flood the phone; the new alert replaces the old one (APNs). In the app the new approval's card takes the old one's place: its decision and option buttons stay off for half a second (ApprovalsModel.settling, set when an approval id first shows on a terminal that had shown a card, never for a terminal's first card), and decide refuses it meanwhile, so a tap aimed at the old card answers nothing.

Drift. state_change_seq stays put when a form moves to its next question, a question is answered on the Mac or a dialog finishes drawing after the approval was built. So each reconcile re-reads every pending, undecided approval of a claude agent and supersedes and rebuilds it when what it tells the phone changed (snippet, reason, options, menu labels, accepts_input, has_text_field or supports_note; not the cursor alone). The rebuilt approval does not alert within 30 s of the episode's last alert, so typing on the Mac cannot become an alert stream.

Prompts without decisions

Every agent takes manual input on permissions, trust prompts, questions and plans: every terminal button stays enabled (Codex's Shift+Left included), and the composer sends a typed answer whenever the agent is blocked, an approval is pending or a Codex question editor is open. Manual input relies on the paired session, not an approval nonce, expiry or LocalAuthentication: it can grant permissions, accept plans or trust a folder, and a changed prompt receives whatever the user sends.

  • agent.send_keys forwards Keys (listed and combinations, as terminal.send_keys below) after checking the live agent identity and peer authorization, with no approval, menu or decision check; blocked startup prompts take input too, as does a Codex that reports no status at a startup dialog in Herdr Core or Rex (Input). When a fresh read shows a Claude Code agent not blocked, keys and typed answers still respect a scrolled transcript, whatever approval metadata the phone holds. Enter reaches a box that starts with /: the phone withholds it only for a command it mirrored, so a slash command typed in the terminal view submits on Return.
  • agent.type_text {op_id, terminal_id, text} sends bracketed-paste text and Enter in one ordered pane.send_input write, without selecting a free-text option, reading an answer back or binding to a prompt fingerprint; the terminal buttons focus the intended control first. Newlines and tabs pass; unsafe controls, bidi and invisible format characters are rejected; the 32 KiB prompt limit applies.
  • agent.send_text {op_id, terminal_id, text} types TypedText as is with pane.send_text (herdr-core: a typing attach), no Enter and no bracketed paste. TypedText is 1 byte to 32 KiB with no C0 or C1 control (so no ESC, newline or tab, which go as keys) and no bidi or invisible format character. It takes agent.send_keys's agent, authorization and scrolled-transcript checks; Enter goes through agent.send_keys. Audit: the terminal and result, never the text; text to a blocked agent logs <terminal_id> blocked text.
  • agent.prompt still refuses blocked agents, so the composer answers them through agent.type_text; attachments wait for the next normal prompt. accepts_input and has_text_field restrict nothing.
  • The phone queues terminal keys and typed answers in order, approval card answers included. A failed input cancels queued actions with a visible error; an agent-to-shell transition discards pending agent input.
  • Authorization is re-checked before every herdr write; both methods carry an op_id through the outcome cache. Audit: keys to a blocked agent log <terminal_id> blocked keys=<keys>, separated by spaces, which no key contains (, is a key); agent.type_text logs the terminal and result, never the text.
  • No version bump: the method, choices, accepts_input, has_text_field, supports_note, note, the choose decision and the two outcomes are additive. An older app ignores choices and decodes the new outcomes as other; an older collied sends no choices (it defaults to empty) and no accepts_input, has_text_field or supports_note (all default to false), and answers choose and a note with invalid_params and agent.type_text with unknown_method, so the app and collied update together.

APNs

  • [apns] in collied.toml holds key_id, team_id (10 uppercase alphanumerics), bundle_id and the key's location; key with key_path, or a store for the other OS, is an error. collied apns test sends a test alert through the selected sender and reports acceptance, not display.
Key locationmacOSLinux
key = "keychain"the default when omittedconfig error
key = "systemd-creds"config errorthe default when omitted (APNs key on Linux)
key_path (a 0600 file owned by the user, opened without following symlinks)legacy; collied doctor warnsthe fallback when systemd-creds is unavailable; collied doctor warns while systemd-creds works
  • Keychain item (macOS): generic password in the login keychain, service dev.rbstp.collied.apns, account = key ID. Its ACL trusts only the storing program's designated requirement, so only a collied signed with the same Developer ID Application identity (team RM3UT3MMSR) and identifier dev.rbstp.collied reads it without a prompt. just collied-install signs that way (hardened runtime, timestamp), installs to ~/.cargo/bin/collied as a fresh inode and restarts a loaded launchd agent; an ad hoc signed cargo install build cannot read the item unattended.
  • collied apns import <AuthKey_ID.p8> (macOS) needs the [apns] ids, refuses a file named for another key ID, and requires an ES256 key passing the key_path checks. It stores the key (keeping an existing item), reads it back to compare, rewrites key_path to key = "keychain" (atomic, same mode, never through a symlink), then asks y/N before deleting the file if it is still the same inode.
  • collied doctor (macOS) checks the signature, reads the item with user interaction disabled as the daemon does, signs a provider token as a dry run, and warns about any .p8 left in <data dir>/apns.
  • push.register tokens are stored per StableID in push.json (0600, atomic) with the device's notification key and environment (Debug builds sandbox, TestFlight production; collied keeps a client for each). Every send re-checks the pairing, so a registration racing a revoke gets no alert. Unregistered and BadDeviceToken drop the token; revoking a peer forgets its tokens. Direct sends use a 64-alert queue, dropped when full, and 10 s per send.
  • Approval alert: push type alert, priority 10, apns-expiration = approval expiry, collapse id per terminal (table below). A device whose Live Activity for that terminal shows approvals gets the approval there instead (Approval on the activity).
  • Approval clear: when an alerted approval's agent is no longer blocked (answered anywhere, or gone), collied pushes {"aps":{"content-available":1},"approval_id":…,"node_id":…} to every registered device: push type background, priority 5, no collapse id, apns-expiration 0, since APNs keeps one undelivered push per app and a stored clear would displace a pending alert. Each alert gets at most one clear, recorded in memory only, so an alert whose agent moves on while collied is stopped gets none. The woken app (remote-notification mode) removes the delivered alerts with that node_id and approval_id; since iOS may delay or drop clears, it also removes alerts of approvals no longer pending whenever it runs.
  • Done alert: when an agent's turn of 30 s or more ends (checked each 1 s reconcile, after approvals). A turn runs from working to the next done or idle, through any blocked; blocked to idle (a denial, Esc) and unknown end it silently. An agent's first poll never alerts; a turn under way when collied first sees it is timed from then. The 30 s, equal to the approvals' alert gap, skips quick replies and slash commands and limits a flapping agent to one alert per 30 s per terminal; the record is in memory only.
    • Push type alert, priority 10, apns-expiration 0 and the approval alert's collapse id, so a terminal shows only its latest notification. It cannot replace a pending approval: it needs the agent out of blocked, which supersedes the approval, and the single send queue keeps the order. mutable-content: 1 runs ColliePush for the encrypted title and body (PR watch wake and archive-on-merge alerts too).
    • The encrypted title names the session as the app's session page does (approvals::session_title: the terminal title without its glyph, else the reported title, the herdr name, then the agent kind) and the body is Done in <folder> (approvals::folder_label: the last component of the foreground cwd, else the cwd, as the app's cards show it, else the workspace label). An approval alert keeps the herdr name or the agent kind as its title (approvals::alert_title), since the pane's program sets the terminal title and must not word an alert that offers Approve; with no context its body reads Blocked in <folder>. Wake and archive alerts put the same session title after Woke and Archived. Live Activity pushes keep the herdr name or kind. No version bump: only text inside the encrypted display changed.
    • A device registered with mute_done gets none. A followed agent's Live Activity gets only a silent status update.
    • Skipped at the desk (#774, macOS and herdr only, desk.rs): no device gets it when, as the turn ends, herdr reports it idle rather than done (herdr 0.9.5 ends a turn done, idle and not yet seen, when its tab is not active or the foreground client's terminal reported focus out, unless it suppressed the completion, as for an agent process exit, which ends idle whatever the focus; a terminal that tells herdr nothing of focus counts as focused), the agent's pane is herdr's focused_pane_id, the frontmost window's application holds a herdr client of the followed session, and the user is active. Each signal is unknown unless read, and an unknown one sends the alert; the decision is desk::in_front. Read in-process with no permission prompt, step by step, each step only when the one before allows a skip: the agent's status, from the list collied already has; the session, from CGSessionCopyCurrentDictionary (kCGSSessionOnConsoleKey, and the undocumented CGSSessionScreenIsLocked, set only while locked), CGEventSourceSecondsSinceLastEventType(kCGEventSourceStateHIDSystemState, kCGAnyInputEventType) under 30 s (MIN_TURN_MS, so input came after the turn began), and CGDisplayIsAsleep(CGMainDisplayID()); then CGWindowListCopyWindowInfo (on screen, no desktop elements), reading only kCGWindowLayer and kCGWindowOwnerPID of the first layer-0 window; then that process and its descendants (proc_listchildpids, unknown at pid 0 or 1 or past 4096 processes), and of those only the ones proc_name calls herdr (the CLI) or sheprd (Herdr.app, itself a client), whose open sockets are each described (proc_pidinfo(PROC_PIDLISTFDS), proc_pidfdinfo(PROC_PIDFDSOCKETINFO), which also return a network socket's addresses, discarded once its kind is not Unix) and whose Unix ones are checked for a peer address equal to herdr-client.sock beside collied's herdr socket; then one herdr session.snapshot. NSWorkspace.frontmostApplication is not used: a daemon runs no main run loop to refresh it. A locked screen still lists the windows behind it, hence the lock check. Limit: collied knows the application, not its tabs or windows; herdr's done covers them only in a terminal that tells herdr when its tab or window loses focus. A skipped turn shows as idle, since herdr counts it seen. Herdr Core reports no client's view, Rex no session a client shows, and Linux would need a Wayland idle client: their agents alert as before (research on #774). Nothing read is logged or sent beyond an info-level line with the terminal id when an alert is skipped.
Public alert fieldValue
aps.alert{"title":"Collie","body":"An agent needs attention"}; done alerts use An agent finished
aps.thread-id, collapse IDbase64url of the first 16 bytes of SHA-256(terminal_id)
aps.mutable-content, aps.sound1, default
node_id, event_id, optional approval_idopaque machine, fresh event and approval lookup IDs
encversioned authenticated display envelope, canonical unpadded base64url

The alert as sent carries no category. ColliePush adds APPROVAL locally only after authenticating display content that offers both Approve and Deny, and restores the private terminal ID for navigation. An extension timeout, unavailable key or failed decryption leaves the generic alert without approval controls. The app authenticates encrypted responses again before classifying a decision, and requires proof that ColliePush rewrote the notification: the mark it leaves there (collie_shown, an HMAC of the envelope under the notification key, which no sender holds), or the notification's own title, body and category equal to what ColliePush writes for that display (PushDisplay.shownTitle, shownBody and category; the body with or without the unreachable note, through PushBody; no subtitle, which ColliePush clears): iOS shows the sender's text and category when the extension does not run. A decision action without that proof sends nothing: it leaves the app on the approval, and a local notification says the action was not verified.

Relay sender

[push.relay] selects the fixed publisher endpoint https://collie-push.rbstp.dev/v1/send (relay.md), [apns] direct delivery for self-built apps; configuration rejects both together.

No version bump: optional relay_grant registrations and hello.push_mode require both relay_grants_v1 and encrypted_display_v1. The configured sender determines none, direct or relay; no endpoint comes from the phone. Grants persist only beside their own device or activity in private push.json, redacted in diagnostics. HTTP sends carry only the grant, in a sensitive Authorization header, and the strict v1 encrypted or generic envelope, never a caller-provided destination, topic or URL. Redirects are refused; responses are capped at 1 KiB and each attempt at 15 s.

Relay delivery has its own bounded worker: a 64-job ingress and at most 64 each of pending encrypted destinations, activity cadence records and routed-approval deduplication records.

  • Routine updates keep only each activity's newest state and go out at most once per 60 s per agent and phone, unchanged refreshes included. Ready urgent updates, clears, alerts and ends bypass that cadence and go first; an urgent retry due later never blocks ready routine work. With cadence tracking full, replacing a record first pauses all routine work for 60 s, so the limit holds. Direct APNs keeps its own cadence and order.
  • Network failures, timeouts, 429, 5xx and unexpected non-JSON responses (such as Cloudflare error 1027 HTML) enter bounded exponential backoff with random jitter; Retry-After (seconds or date) is clamped to one hour; a daily quota reset is used only within 24 hours, else 60 s. An exhausted routine daily quota pauses only routine work, keeping the reserved urgent budget; other outages pause everything. The server enforces quotas per installation, across machines, so the remaining budget is unknown locally.
  • Non-approval work expires after 2 min, approval work with its approval (at most one hour). A restart loses all work: with no durable queue or exactly-once claim, an ambiguous accepted send can be duplicated.
  • Before every attempt, retries included, the worker re-checks the pairing, the exact destination token and grant generation, grant and approval expiry, the approval's live state, and whether the activity was replaced or ended; a clear or newer activity state replaces obsolete pending work. Only an authenticated 410 invalid_route removes a registration, and only the exact token or grant that failed; configuration and authorization errors keep registrations for repair or renewal. A failed activity send keeps the encrypted approval-notification fallback.
  • collied doctor shows counts, the earliest grant expiry, the last send error and retry or reset times, never grants, destinations or payloads. A push outage does not block the tailnet or control tasks.

Encrypted display envelope

  • The phone generates a 32-byte notification key per paired machine, kept in the shared Keychain (AfterFirstUnlockThisDeviceOnly) and a 0600 App Group mirror (no backup, protected until first unlock) so CollieWidgets can decrypt without Keychain access. Only the authenticated tailnet push.register sends it to collied, which keeps it beside the token in push.json and never logs it. Re-pairing rotates it; unpair or revoke removes it.
  • No version bump: the additive display_binding registration field and the replacement APNs and ActivityKit codec require the explicitly negotiated encrypted_display_v1 capability; revision 26's omitted capabilities still mean only terminal_grants_v1. A peer without the encrypted codec cannot register push or activity tokens. Persisted registrations without the encrypted-display marker or activity binding send no private display content and stay disabled until refreshed. There is no plaintext compatibility path.
  • enc is canonical unpadded base64url of header || nonce(12) || ciphertext || tag(16), ChaCha20-Poly1305 with a fresh random nonce. header is binary version(1 byte = 1) || kind(1 byte) || node_id_length(1 byte) || scope_length(1 byte) || node_id(UTF-8) || scope(UTF-8) || event_id(16 random bytes); node and scope are 1 to 64 ASCII letters, digits, underscores or hyphens. Kinds: 1 alert, 2 activity state, 3 private static attributes. AAD is the bytes collie.push.v1, a zero byte, the header, and SHA-256 of the 32-byte destination notification key, so the key binds the receiving phone and machine, and the authenticated header binds kind, machine, scope and event. The public event_id is the header event in unpadded base64url; the widget reads it from the envelope because ActivityKit exposes only content-state.
  • Alerts: scope is the opaque thread ID; plaintext is {"v":1,"title":...,"body":...,"terminalId":...,"offersApproval":...}, with approvalId only on approval alerts. ColliePush checks the authenticated machine, thread, event and optional approval against the public lookup fields, then restores title, body and routing locally. The body is the approval context, if any; done and agent alerts carry their own complete body. Unsupported versions, noncanonical encoding, oversized input and failed authentication produce no private text or controls.
  • Activities: the phone gives each a fresh UUID bindingId before ActivityKit assigns its activity ID, and sends display_binding: {node_id,binding_id} with its token over the tailnet. State is kind 2 under this scope ({"v":1,"state":...}); static attributes keep only opaque machine, terminal, node and binding IDs and a kind 3 envelope of {"v":1,"machineLabel":...,"title":...}. Initial, local and remote updates and ends carry only ciphertext. A widget checks the envelope against its own immutable node and binding before using any state; without keys (as before first unlock after a reboot) it shows a neutral Collie state without approval controls.
  • Limits: envelopes 3,800 encoded characters; APNs payloads 4,096 serialized bytes; static activity attributes 1,536 bytes; each encrypted initial, update or end state 2,400 bytes; attributes and state together 4,000 bytes, leaving ActivityKit framing room. The remote sender always reserves the full static-attribute allowance; the phone checks both caps and the combined size before every local update. An oversized alert is dropped; an activity that cannot be encrypted or fit falls back to the approval notification where it applies. Alert bodies are visibly truncated at 1,800 JSON-escaped bytes and activity approval context at 600 bytes before its inner command seal, on whole Unicode scalars.
  • Still observable: IDs, generic categories, priority and urgency, timing, size, and the update or end lifecycle. Public activity relevance is omitted remotely and zero locally, and activity alert text is generic. The raw APNs token stays a delivery destination. No push carries an approval nonce.
  • protocol/push-display-vectors.json holds exact Rust and CryptoKit vectors for all three kinds and relay-compatible public payloads. protocol/live-activity-content-state.json describes the private state before the outer seal; its inner approval command uses the notification-vector.json seal, authenticated by approval ID, which never appears outside the authenticated display envelope.

Lock-screen approval

  • Category APPROVAL has two actions, Approve and Deny (no Always allow, no note), both authenticationRequired: iOS makes the user unlock first, then launches the app in the background without UI.
  • The app holds a background task assertion and calls collie-core's decide_from_notification with a 20 s budget (the cap; 0 is refused). This one-shot session runs outside the connection supervisor: node up from cached state (never a login), the pinned Mac in the netmap, dial, hello, the nonce from the cached snapshot or approval.list, then approval.decide, never retrying past the budget.
  • It fails at once with Unauthorized when Tailscale is not set up on the phone, the node reports NeedsLogin or NeedsMachineAuth, the netmap violates the pin, or hello reports the phone unpaired.
  • An action decides only from a notification that shows the authenticated display's text and category (APNs); from any other it sends nothing, leaves the app on the approval and says so in a local notification, since the action runs in the background. The follow-up names the agent from the authenticated display, never from the notification's title.
  • A follow-up local notification in the same thread claims success only for applied:
Background outcomeFollow-upOpens the approval
applied"Approved/Denied: agent. The agent moved on."no
unconfirmed"..., not confirmed": keys sent, agent still looks blockedyes
expired, already_resolved, not_foundexpired or no longer pending, nothing was sentno
supersededthe prompt changed, nothing was sentyes
unreachable at decidecould not confirm the decision reached colliedyes
unreachable earlier, unknown_machine, unauthorized, failed"Couldn't reach collied, open to decide"yes
  • Tapping the alert opens the agent's session, found by node and approval id while the approval is pending, else by a validated notification thread. Structured in-app approval actions pass LocalAuthentication (deviceOwnerAuthentication, a fresh LAContext each time); manual terminal input does not. The sheet's reason is the decision, the workspace and the machine ("Approve in collie on Mac"), never the agent's label, which can be a title its program set.

Attachments

The phone uploads a prompt's photo or file over the tailnet session; collied stores a private copy and returns its absolute path, which the app inserts into the prompt draft for the agent to read from disk. Nothing goes through herdr.

Flow

  1. attachment.begin {op_id, name, size, sha256} answers {upload_id} (16 random bytes, hex). name (AttachmentName: 1 to 64 characters, no control, bidi or format characters, no / or \, no surrounding whitespace, not . or ..) is only a hint; size is 1 byte to 20 MiB; sha256 is lowercase hex of the whole file.
  2. attachment.chunk {upload_id, offset, data} in order: offset must equal the bytes received so far; data is padded standard base64 of 1 byte to 32 KiB, so a chunk frame stays under the 64 KiB frame cap. collie-core sends one chunk at a time and awaits each reply.
  3. attachment.commit {op_id, upload_id} answers {path} once the received size equals size and the SHA-256 matches; otherwise the partial file is deleted and the error is invalid_params (size) or checksum_mismatch.
  4. attachment.abort {upload_id} is best effort and always answers ok.

An upload is bound to the session and peer StableID that began it; another session, even of the same phone, gets not_found. Nothing resumes across connections: closing the session drops its uploads, which collie-core reports as interrupted. begin and commit go through the op_id outcome cache, so a retried commit returns the stored path. Authorization is the agent.prompt gate (a paired, full session), re-checked on every frame and before begin, each chunk and the commit.

On any failure collie-core sends attachment.abort. UniFFI 0.32 does not forward Swift task cancellation to Rust, so the app cancels with cancel_uploads(machine_id), which fails the upload with Cancelled and aborts it on the Mac.

No version bump: the methods, responses and error codes (too_large, checksum_mismatch) are additive. An older collied answers unknown_method, which collie-core reports as "update collied".

Limits

LimitValue
File size20 MiB, checked by the phone, the protocol decoder and collied
Chunk32 KiB decoded, in order, never past the declared size
Uploads in flight2 per session (rate_limited beyond)
Stored bytes200 MiB: committed files (the larger of length and allocated blocks) plus the declared size of every upload in flight; else begin answers too_large
Stored entries1000 under the root, uploads in flight included, so tiny files cannot exhaust the disk or slow begin's scan; else too_large
Chunk rateown bucket per paired StableID, 128/s, burst 128 (4 MiB/s); collie-core retries a rate-limited chunk up to 8 times with backoff. Other attachment frames use the shared 20/s bucket

Storage

  • Root: ~/Library/Caches/dev.rbstp.collied/attachments on macOS, $XDG_CACHE_HOME/collied/attachments (else ~/.cache/collied/attachments) on Linux, with no spaces so the path reads cleanly in a prompt. Created 0700; an existing root that is a symlink, owned by someone else or not exactly 0700 stops collied at start.
  • Each upload gets a fresh <root>/<16 hex>/ (0700, create_dir, fails if it exists). Data goes to a .part file opened create_new with O_NOFOLLOW, mode 0600; the commit fsyncs it and renames it, inside that directory, to the sanitized name. Files are never executable.
  • Sanitized name: [A-Za-z0-9._-] kept, each run of anything else becomes -, leading dots and dashes dropped, at most 64 characters keeping an extension of up to 16 alphanumerics, attachment when nothing is left (.env becomes attachment.env).
  • Audit: attachment.begin with the sanitized name, and one attachment.commit line per committed upload with result ok size=<bytes> sha256=<first 12 hex>. Chunks and aborts are not audited; content and base64 are never logged.
  • collied doctor prints an attachments line: root, mode, bytes stored.

Cleanup

  • Session close: its uploads in flight are dropped and their directories removed.
  • Every 10 s: uploads idle for 60 s are dropped with their directories.
  • At start and every hour: root entries older than 24 h are removed (symlinks as links, never followed). At start, directories still holding a .part from a previous run are removed too.

Files from Chat

Chat links file paths in agent messages and tool records, never hidden names or tokens with .., ://, *, $, =, @ or \, and an agent session's Terminal selection menu offers Open on a selection holding exactly one path and no http link. Both open a read-only preview; collied decides what may be read.

Flow

  1. file.open {terminal_id, path} (Read class; path 1 to 1024 bytes, no control characters) answers file_opened {download_id, name, size, kind, sha256}.
    • collied takes the agent's checkout as agent.changes does, joins a relative path to it, refuses .., requires the result under a task root, then opens the parent one component at a time from the root with O_NOFOLLOW (open_beneath) and the file with O_NOFOLLOW | O_NONBLOCK.
    • open_beneath refuses a folder that starts with a dot or carries UF_HIDDEN, except the checkout path's own folders when the file lies below the checkout, so a worktree in <repo>/.worktree/<branch> opens its files; other hidden folders, below the checkout or outside it, are refused. A checkout that is or lies inside a hidden folder (an agent started in ~/.ssh or under ~/Library) thus exposes the non-hidden regular files below it, as the threat model notes.
    • Hidden names, symlinks, folders and anything but a regular file are refused with a plain message (invalid_params). kind is image (PNG, JPEG, GIF, HEIC or WebP by extension), pdf, text (other files whose first 8 KiB are UTF-8 without a NUL) or other; an unknown kind decodes as other. A file over 20 MiB, or over 1 MiB for text, is refused with too_large and its fstat size before any content is sent. sha256 is computed from the open descriptor.
  2. file.chunk {download_id, offset} answers file_chunk {data}: up to 32 KiB of base64 from offset, read with pread from the same descriptor, so a chunk frame stays under the 64 KiB frame cap. A file that shrank fails with "The file changed while it was read"; one rewritten in place fails the phone's checksum. Chunks draw from the attachment chunk bucket (128/s).
  3. file.close {download_id} always answers ok.

A download is bound to the session and peer StableID that opened it (another session gets not_found), at most 2 per session (rate_limited beyond), and closed by file.close, at session end or after 60 s without a chunk. Nothing is copied, cached or written on the machine. file.open is audited with <terminal_id> path="<path>" and its outcome; chunks and closes are not, and content never reaches a log or a push.

collie-core's open_file fetches chunks 4 at a time (retrying a rate-limited chunk up to 8 times), checks each chunk's length and the whole file's SHA-256, and always sends file.close, waiting at most 1 s for its answer since collied also drops the file with the session. Closing the viewer cancels the transfer but lets a pending file.open answer, so the file it opened is closed. The viewer keeps the bytes in memory and, once the file opens, writes a copy for Share to a fresh folder under viewer in the app's temporary directory (complete Data Protection), removed when the viewer closes. At launch the app removes the viewer folder, for a copy left by an app killed with the viewer open. A PDF shows in a PDFView whose delegate implements pdfViewWillClick(onLink:with:) and opens nothing, so a tap on a link annotation leaves the app where it is. An image is decoded by ImageIO (CGImageSourceCreateThumbnailAtIndex, as attachment thumbnails are) to at most the screen's longer side in pixels, so its decoded size depends on the screen and not on the file. ImageIO still decodes an interlaced PNG whole to make that thumbnail, so the viewer first reads the pixel size from the header (CGImageSourceCopyPropertiesAtIndex) and shows an image over 100 megapixels as too large to preview, with its name and size, without decoding it; Copy puts that decoded image on the clipboard, and Share sends the file itself.

Draft sync

Claude Code keeps unsent text in its input box, and herdr's agent.prompt pastes after it. For agent kind claude only:

  • agent.draft {terminal_id} answers {text}: the box's text from the visible screen (pane.read source=visible format=ansi), "" for only its dim placeholder, null when the phone may pre-fill nothing (another agent kind, no box, an opaque box).
    • The box is the last block on screen between two horizontal rules drawn from column 0, its first row at column 0 and the others indented two spaces, so a typed row of ─ never closes it. A first row other than ❯ (bash mode's !), or a collapsed paste or image placeholder ([Pasted text #1 +40 lines], [Image #1], [...Truncated text #1 ...]), makes the box opaque: its screen text is not its content. Dim text (placeholder, completion hints) is not typed text.
    • Claude Code 2.1 soft-wraps the draft (wrap-ansi {hard: true, trim: false} at the terminal width minus 4) and hides the space at each wrap; collied rejoins rows as a soft wrap, a split word or a typed newline.
    • Controls, bidi and format characters are dropped, trailing whitespace is trimmed, and the text is capped at 32 KiB.
  • agent.prompt takes an optional expected_draft, what the phone last saw. After the ready check, collied reads the box before the paste and fails closed:
The boxagent.prompt
emptygoes ahead. Prompts queued while Claude Code works draw outside the box, above the spinner, so they are never cleared and the new prompt queues after them
missing or opaquedraft_not_cleared, nothing sent: whatever replaced the box may still take the paste, and an opaque box may be a shell command or hold content the phone never saw
a selection below itinput_unfocused, nothing sent, and agent.draft answers null; the phone asks the user to press ↑ and send again
equal to expected_draft (both normalized)clears it, then re-reads every 100 ms for up to 1 s until the box is empty, else draft_not_cleared, nothing sent
any other draft, or no expected_draftdraft_changed, nothing sent, with the current text in ErrorBody.draft so the phone can show it and send again to replace it. The audit line is draft_changed alone: draft text is never logged
  • Why input_unfocused (#588; Claude Code 2.1.310, herdr 0.9.5): down on the box's last row selects the background task pill, then the agent list below. The box looks unchanged, but a paste may be dropped and herdr's Enter opens the tasks dialog or switches agent: agent.prompt answered ok for prompts that never arrived.
  • Clearing (verified on Claude Code 2.1.310 in herdr 0.9.5, a draft of N visual rows, the cursor anywhere): N times ctrl+e, ctrl+u, backspace (clear a row, join it to the one above) empties the cursor's row and those above, then N-1 times ctrl+k, ctrl+k (join the next row, clear it). Never down (on the last row it selects the task pill while a task runs), ctrl+c (interrupts a working agent) or ctrl+d (exits Claude Code on an empty input); no key used interrupts a working agent, and herdr has no delete key name. collied sends these keys itself, whatever the phone's Key allowlist holds, in batches of at most 16, re-checking authorization before each.
  • The phone loads the box's text into an empty prompt field once per visit to the agent's screen. Until the phone edits it, a new non-null last_prompt triggers one agent.draft read, and an empty box, meaning the text was sent on the machine, empties the field but keeps its attachments. last_prompt comes from human prompts only, so text deleted on the machine, an approval, a background task's turn or last_prompt going null leave the field alone. Key strip text shortcuts send expected_draft: "", so they never replace unsent text.
  • No version bump: the method, response, field and error codes are additive. An older collied answers agent.draft with unknown_method, which collie-core returns as no draft, so the phone never sends it expected_draft. An older app sends no expected_draft, so a Mac draft refuses its prompt rather than being appended to. An older app reads input_unfocused as unrecognized and shows collied's message; an older collied never sends it.
  • Slash command mirror. While the phone's draft starts with /, its command token (up to the first whitespace) is mirrored into the box, so Claude Code's command menu shows on the machine and in the phone's terminal view.
    • agent.slash_draft {terminal_id, command, expected_draft} (Drive class, idempotent so no op_id, audited with the terminal only) takes a SlashCommand: "", or / and up to 63 of A-Z a-z 0-9 _ : . -, so nothing can end the paste early. For a ready claude agent (never blocked, launch pending, or another agent or session) without a "Jump to bottom" banner, collied replaces the draft as agent.prompt does. For a non-empty command it then repeats the ready, banner and authorization checks, requires an empty ❯ box (else agent_not_ready) and pastes the command in one bracketed pane.send_text (herdr 0.9.3 has no paste without Enter). It replies and releases the lock only once a re-read (every 100 ms, up to 1 s) shows exactly the command, since a paste takes up to about 110 ms to render and a next call reading the box empty would paste after it (/stat/statu); other text gives draft_changed, an empty or unreadable box agent_not_ready, and nothing more is written. It never sends Enter or a key; a paste that did not land heals on the next call.
    • The phone mirrors only keyboard typing (the iOS keyboard's dictation and paste included, not the app's own dictation, paste, restored drafts or text it sets), one call at a time 150 ms after the last keystroke, for a Claude Code agent not blocked or scrolled up, never while dictating or sending, and only while it knows the box holds nothing or a command. It clears the box once when the draft stops starting with /. A draft_changed with the command this screen last asked for (a lost reply) is replaced; other text pauses the mirror and shows until the next send, so machine text is never replaced unseen. A reopened screen trusts only a bare command equal to its draft's token, and tokens, not text, are compared, so a hint after a completed command (/rename [name]) triggers no write.
    • Picking a command: the key strip's joystick moves Claude Code's highlight up and down and β‡₯ takes it. 150 ms after keys sent while the box holds a command, the phone reads the box and takes its command into the draft, keeping its own arguments (/mod opus and β‡₯ give /model opus); at send, a draft_changed whose command extends the draft's catches a missed read. Send is refused after ↑ or ↓ until β‡₯ or an edit, and ⏎ and βŒƒβŽ are off, and dropped from queued keys, while the box holds a command no prompt covers. collied does not refuse them: only the phone knows a command came from its mirror, and one typed straight into the terminal view submits on Return.
    • agent.prompt, agent.send_keys and agent.slash_draft share one lock, so another session's input never lands between a mirror's read and its paste. Only the phone's send runs a mirrored command: after any mirror call in flight, agent.prompt clears the token (it equals expected_draft) and pastes the whole draft with Enter. A partial command runs Claude Code's top match.
  • Codex and Copilot: collied refuses agent.slash_draft, and the phone never calls it. collied cannot read, so cannot check or clear, their input box, and their prompts paste after whatever it holds, so a mirrored token would lead the prompt.
  • Residual: text typed on the Mac between collied's read and its clearing keys is cleared too; text typed after the empty re-read is appended to by the paste. A typed newline exactly where the next word would not have fit reads as a space. When Claude Code limits the box to a viewport (a draft taller than its visible rows), only the visible rows are read and cleared, so the re-read refuses the prompt.
  • Prompt suggestions (#684). After a turn, Claude Code may draw its predicted next prompt dim in the empty box. collied reads it with the draft: the dim text of an otherwise empty ❯ box that is neither opaque nor unfocused, joined and normalized like a draft, unless it is one of Claude Code 2.1.321's placeholders: Try "…" until the first prompt, Message @… while it shows an agent, and the queued prompt hints starting Press up to or Press Enter to edit. Style cannot tell them apart, and neither renderer draws a hint on or below the box. The draft stays "", so agent.draft and agent.prompt are unchanged, and a prompt pasted over a suggestion replaces it.
    • TerminalRead.suggestion carries it on agent.read and agent.watch reads of a claude agent, and every OutputPatch carries the suggestion of its new text, absent for none. collied reports only what the screen shows, so a suggestion Claude Code has dropped, such as one from an older turn, never reaches the phone.
    • Checked on Claude Code 2.1.321 (fixtures in claude-2.1.321, default and fullscreen renderers) in herdr 0.9.5 and herdr-core 0.1.19: Tab in an empty box with a suggestion makes it typed text and sends nothing; Enter alone does nothing (checked in the default renderer); a typed character replaces it; emptying the box shows it again. From its source, Claude Code makes none before the conversation holds two replies, when its model has no obvious next step, after a turn that wrote over 10k uncached tokens, while a permission prompt or MCP elicitation waits, in plan mode, near rate limits or on extra usage, after an API error, and, once 20 suggestions in a row went unused, on all but every tenth turn until one is used.
    • Phone: while the latest screen of a Claude Code agent that is not blocked or scrolled up reports a suggestion, Terminal shows a β‡₯ key before return in the bottom row (key strip hidden), and a tap sends Tab and hides the key until the next screen. Residual: collied's agent.send_keys does not re-read the box, so a tap on a screen up to about 1.25 s old, or a screen read before the Tab landed that shows the suggestion again, can send Tab to a box that has changed; a stray Tab at worst accepts an open completion and never submits. Chat shows it as an empty field's placeholder, with a β‡₯ button that fills the field; filled text is never mirrored. Only the agent screen reads it: it never goes into push notifications, Live Activities or the watch.
    • No version bump: the fields are optional and additive on server-to-phone types. An older collied never sends them, so the phone shows no β‡₯ key or suggestion, and an older app ignores them.

Context and inbox

herdr reports each agent's session id (agent_session.value in agent.list and session.snapshot), which its SessionStart hooks set, so it follows /clear, resume and compaction. From that session's transcript collied derives four optional Agent fields: context_left (0 to 100), last_line (the latest reply's first non-empty line), last_prompt (both cleaned and capped at 160 characters) and last_activity_ms (the transcript's mtime). No version bump: the fields are additive on a server-to-phone type, so an older app ignores them and an older collied leaves them out.

  • Live Claude Code session: herdr's id can be stale (a session restarted while herdr's server was down) or name a client showing another conversation (/resume of a background session), and a claude attach <id|name> pane has none: the attach client fires no hook and writes no sessions/<pid>.json.
    • collied takes a Claude Code pane's foreground pids from herdr's pane.process_info (every 10 s per pane and on a pane id change), keeping only the pids and a foreground claude attach target, never the rest of argv or cmdline. A pid's sessions/<pid>.json (at most 64 KiB) counts only when its pid matches, the process is alive and started no later than the file's startedAt (2 s of slack for Linux's whole-second start times), and its cwd is the pane's. When all such files agree on one sessionId, it replaces herdr's (logged once per terminal, ids only).
    • Otherwise, for claude attach <target>, the session is the one live bg process (same checks except cwd) whose jobId starts with a target of 1 to 8 lowercase hex, or whose name equals any other target exactly. None or several keep herdr's id, as does a target lost on Linux when Claude Code overwrites argv with a process title. The client can switch sessions without changing argv, so a named record counts only while the pane title (herdr's terminal_title_stripped, which Claude Code sets to the shown session's name) equals its name.
    • collied then follows at most 4 hand-offs in that session's last 64 KiB (a loop or longer chain keeps the starting session): the latest continued-in record (continuedInSessionId) to a transcript in the same project directory, or a /resume whose output ends running in the background (<8 hex>) when exactly one live bg process (same pid checks) has that jobId, a sessionId starting with it, the same project directory and that transcript. A later reply or human prompt drops the hand-off.
    • Chat history, the summaries and subagents all read the session found. The summaries cache it per terminal until herdr's id or the pane's pids refresh, following hand-offs again when the starting transcript changes.
  • Claude Code: projects/<cwd with every non-alphanumeric character as '-'>/<id>.jsonl under CLAUDE_CONFIG_DIR or ~/.claude, else projects/*/<id>.jsonl for a session started in another directory.
    • Usage: the latest main-thread (isSidechain: false), non-<synthetic> assistant entry's input_tokens + cache_creation_input_tokens + cache_read_input_tokens + output_tokens, as Claude Code's auto-compact indicator counts it (its status line leaves out output_tokens); after a compact_boundary with no reply since, its compactMetadata.postTokens.
    • Window: the session's context_window.context_window_size from the status line tap (Plan usage), else inferred from the model: 1M for Opus 4.7 and later, Sonnet 5 and later and Fable, otherwise 200K, and 1M once usage passes 200K. Without the tap, an Opus 4.6 or Sonnet 4 session on the 1M window shows too little left until it passes 200K (0% from 167K, 78% at 210K), and a session held to 200K on a 1M model too much.
    • Percentage: like Claude Code's "% until auto-compact", round((W - 33000 - used) / (W - 33000)), 0 past it (Claude Code 2.1.314 compacts at the window less min(max output tokens, 20000) less 13,000, which is 33,000 for current models); with auto-compact off, the full window. Auto-compact counts as off only when settings.json in the same config dir has autoCompactEnabled: false. Other controls (DISABLE_AUTO_COMPACT, DISABLE_COMPACT, project and managed settings, the legacy key in ~/.claude.json, a smaller autoCompactWindow or CLAUDE_CODE_AUTO_COMPACT_WINDOW) are not read, so such a session's ring can differ from Claude Code's.
    • Prompt: the latest of the last user entry with origin.kind: "human", the last mid-turn prompt (the queued_command attachment Chat shows) and the last last-prompt entry. Claude Code keeps writing a turn's first prompt to last-prompt, so a last-prompt entry after a mid-turn prompt is passed over, unless a ! shell command followed the mid-turn prompt: then the last-prompt entry after the command, such as "!git status", wins. The Inbox "You:" line, the phone's draft clearing and its arrival check before a resend follow it. A skill or custom slash command gives its marker, such as "/review pr 12", as Claude Code's own lastPrompt does; a <local-command-stdout> entry is skipped.
  • Codex: sessions/YYYY/MM/DD/rollout-<local time>-<id>.jsonl under CODEX_HOME or ~/.codex. The id is a UUIDv7, so its UTC creation day and the day on each side are searched. The latest token_count event gives last_token_usage.total_tokens and model_context_window, with Codex's own percentage, (W - 12000 - max(used - 12000, 0)) / (W - 12000). item_completed events give the last AgentMessage and UserMessage.
  • Claude Code subagents (subagents, additive, no version bump): one entry per running subagent, with agent_type, title, activity, started_at_ms, tokens and called_tools.
    • Sources: the session's subagents/agent-<id>.jsonl and subagents/workflows/<workflow>/agent-<id>.jsonl, each with a .meta.json. agent_type is the meta agentType (workflow-subagent for workflow agents, whose description is the workflow label); title is the meta description, else agent_type.
    • activity is the Claude Code agent panel's fallback line for the latest tool call (such as Reading <file name>), or the meta description before the first call; the panel's model-written summary lives only in Claude Code's memory.
    • tokens is the panel's count, rounded to the nearest 1,000: the latest assistant usage's input, cache creation and cache read, plus the run's output tokens, each message.id counted once. Unlike the panel, it has no streaming estimate and misses output written before the first read's window. called_tools picks the panel's arrow (↓ once a tool was called, ↑ before).
    • A run ends when its latest assistant record ends its turn (stop_reason end_turn), calls SubagentHandback or StructuredOutput (a workflow agent's result) or is an API error (<synthetic> with isApiErrorMessage), or when a [Request interrupted by user record follows. A later prompt or follow-up (a user record that is not isMeta, or has a coordinator, peer or human origin) starts a new run at that record's time, else the file's first record's, else the earliest read.
    • Subagents count as running only while a Claude Code process of the session lives (a sessions/<pid>.json beside projects whose pid matches its name and is alive), and only subagent files written since its latest start count.
    • Reads: an unchanged file (size and mtime) is not opened; at most 8 others open per refresh, from the session's directory and its 8 most recently modified workflow directories, with the transcript's checks (no symlink, non-blocking, real directories under the session's, alphanumeric ids, workflow names of letters, digits, _ and -). A file that grew by at most 512 KiB is read from where the last read ended, else only its last 64 KiB; a line over 64 KiB is skipped. Text loses control characters, is capped at 120 characters and goes only to the phone, never to logs, pushes or the audit log.
    • Updates ride the 1 s reconcile tick, only while a phone is connected: a new or finished subagent or a new activity line sends agent.status on that tick; a change to tokens or the arrow alone goes out at most every 5 s. The phone counts elapsed time locally.
  • Copilot CLI: its session events carry no window size and no running token count, so a Copilot agent has no ring, and summaries do not read its prompt or reply (Chat does: Conversation history).
  • Live Copilot conversation: after /new, herdr can keep reporting the first conversation while the same Copilot process holds inuse.<pid>.hold locks in both session directories, so neither a held lock nor the newest directory says what the pane shows.
    • A candidate needs a live foreground pane PID started before the hold marker's mtime (same 2 s slack), a held regular marker with a matching numeric inuse.<pid>.lock, one session ID across directory, workspace and header, and native workspace metadata. collied selects only a unique candidate whose cwd is the pane's and whose workspace name (a native single-line YAML scalar, set by the user or by Copilot after the first prompt) matches the terminal title, optionally with the native intent and GitHub Copilot suffix. A held session with no events.jsonl yet is skipped when unnamed (Copilot 1.0.103's first session, still held after /new before any prompt) and fails the selection when named. Unsupported metadata, title-less panes, partial process lists, ambiguity and read failures never fall back to herdr's possibly stale ID.
    • Selection reruns on every query, catching same-title renames and /new, and inspects at most 10,000 directory entries, 16 PID-marker checks per directory, 256 held candidates and 1 MiB of workspace and header bytes (64 KiB per file). Only markerless directories are cached, per exact live PID and start-time set; names and positive identity claims are always reread.
    • Summaries and the history readers share this decision. Chat reads only the selected conversation and its children; reply and context summaries stay unsupported rather than borrowed from another conversation. Before treating the pane as quiet, the archive guard checks every verified conversation the pane's processes still hold, including a hidden one with background work.
  • Copilot CLI and Codex subagents: No version bump: both fill the existing subagents fields, with Claude Code's status-event comparison and elapsed-time display; the phone orders them by run start and stable child identity.
    • Copilot reads the selected conversation's session-state/<session>/events.jsonl (under COPILOT_HOME, else ~/.copilot), whose first session.start must name it. A held inuse.<pid>.hold lock shows the session is live, and only subagent.started events at or after its mtime count. The envelope agentId identifies the child, data.toolCallId matches its completion or failure, and agentName and agentDisplayName give its type and title. Activity is the latest tool.execution_start.toolTitle; tokens are the latest session.usage_record.usage input plus output. subagent.completed, subagent.failed, a child or session abort, or session.shutdown ends the run. A multi-turn child can restart on its own user.message; a final assistant.message without tool requests, followed by its assistant.turn_end, ends that follow-up.
    • Codex lists held thread-writer-locks/<child>.lock files beside sessions while the parent's writer lock is held, and looks for a child's rollout in the three local dates around its UUIDv7's UTC date. Only its first session_meta counts: its id must match the file and source.subagent.thread_spawn.parent_thread_id must name the parent, which excludes guardians and other parents' children. The title is the last component of agent_path, else agent_nickname; the type is agent_role, else codex. A fork's subagent_history_start_ordinal excludes inherited parent records; a fork or paginated inherited history without it fails closed. Its own task_started starts a run; a matching task_complete or turn_aborted, shutdown_complete, or a released child or parent lock ends it. Activity is the latest native tool name; tokens are the latest token_count.info.total_token_usage.total_tokens.
    • Bounds: each scan lists at most 256 lock or session-directory entries; each refresh reads at most 8 changed Codex rollouts, 512 KiB per rollout and 16 MiB of Copilot's events.jsonl, which holds every child's records and reaches tens of MB: a fresh scan (after collied starts, or in a new conversation) shows no subagents until caught up, about 5 refreshes of about 40 ms for an 80 MB file instead of about 160. A new Codex rollout lookup examines at most 10,000 entries per date directory. Records over 64 KiB are skipped, their ordinals still counted. The Copilot cache keeps at most 256 child identities.
    • Codex's shared daemon can hold a writer lock for a thread with no input, rollout or parent; such a lock neither establishes a child nor blocks unrelated parents. A verified parent association stays cached while the child lock is held, so a missing, unreadable, damaged or replaced rollout still marks that parent busy (a verified foreign one that disappears does not). An incomplete, undecodable or oversized (over 64 KiB) first header, a bounded lookup that leaves files out, or a file still catching up marks the scan truncated. Files are cached by device, inode, size and mtime; a replaced or shortened one is parsed again, keeping a verified parent relation.
    • These reads and the selection's are non-blocking, regular files only, never following final symlinks, through real directories; text gets the same control-character cleaning and 64/120-character limits and goes only to the paired phone. The archive guard treats an unreadable or truncated scan of any provider as busy, and lock-probe and registry I/O errors as unknown, not released: they block archiving and keep cached parent associations (the per-parent cache is capped at 256 identities when an incomplete registry cannot be safely pruned).
    • The file-only reader cannot identify a child that never persisted parent metadata. Codex 0.163.0 defers rollout creation until persistence is requested and only warns if rollout or spawn-edge persistence fails, so a wholly unrecorded child is outside the archive check's guarantee; writer-lock age is never used to invent a parent association.
    • Sanitized fixtures capture Copilot CLI 1.0.100-1 and Codex 0.163.0 normal and interrupted scratch sessions, plus a Codex 0.162.1 inherited-history prefix. A Copilot CLI 1.0.96-2 parent session was also verified read-only through Transcripts::derive.
  • Antigravity CLI subagents: No version bump: it fills the existing subagents fields, with Claude Code's status-event comparison, elapsed-time display and quiet archive guard.
    • Under ANTIGRAVITY_APP_DATA_DIR/brain (default ~/.gemini/antigravity-cli/brain), the parent session lists spawned subagents and swarm workers in <session>/.system_generated/subagents/<child>.json with conversationId, state (SUBAGENT_STATE_ALIVE while kept, SUBAGENT_STATE_KILLED once killed) and subagentDescriptor (typeName and role). Swarm worker roles of the form Swarm Worker (<name>) show <name> as the title.
    • For each alive child, collied reads <child>/.system_generated/logs/transcript.jsonl incrementally under the same real-directory, UUID-only, non-blocking, 64 KiB descriptor/line, 512 KiB per-refresh, 8-file and 256-entry bounds. Step 0, a USER_INPUT, or a non-low-priority SYSTEM_MESSAGE carrying [Message] starts a run; a PLANNER_RESPONSE with active tool_calls keeps it running, sets called_tools, updates activity from the call (toolSummary or command for run_command, file basename for read_file/edit_file/write_file, query for search_web, else the tool name) and counts input_tokens + cache_read_tokens plus the run's output_tokens. Backgrounded child tasks (GENERIC RUNNING with with task id: <child>/task-<n>) keep the subagent running across a turn pause until cleared by sender=<child>/task-<n> or Task "<child>/task-<n>" cancelled.. A PLANNER_RESPONSE with no tool_calls (when no background task is pending), calling swarm_wait, or with status ERROR or CANCELLED ends the turn, as does a descriptor whose state leaves SUBAGENT_STATE_ALIVE. An unreadable, oversized, mismatched or catching-up alive child marks the scan truncated so automatic archiving fails closed.
  • Cost: summaries read only a transcript's last 1 MiB (transcripts reach tens of MB; the values sit near the end), scanning backward until all three values are found, cached per session id by size and mtime, so an unchanged transcript costs one open and fstat. A value missing from the tail (a single tool result over 1 MiB) keeps the previous one. A missing transcript is looked for again only before an agent.status event and on each flock.snapshot. While a phone has a session open, the 1 s reconcile derives every agent's values, re-reading a working agent's tail, and sends agent.status when the context left, reply line, prompt or running subagents change; the activity time only rides along. A phone connecting or leaving sends nothing. With no session open, collied reads no transcript between snapshots.
  • Phone: the percentage left, a chip glyph and "38%" (spoken "38% of context left"), on list rows, grid cards, inbox rows and the agent screen's header, only once less than 70% is left (ContextRing.shows), secondary (a deeper gray in light mode, to read on white, as for the other card and row metadata) until 20% or less is left, then orange, and red from 10% (ContextRing.tone: the accent, orange at 80% used, red at 90%, which Usage bars share; in light mode, to read on white and light glass, orange takes a deeper orange of the same hue (180,75,0) and red the deeper red blocked agents use). The Inbox groups agents into Needs you (blocked), Working, Done (completed within 24 hours) and Inactive (idle, unknown, or completed 24 hours ago or more), with a filter for each group and a search button in the toolbar whose field takes their place, with its own close button while the toolbar button hides, and searches every group across machines; a dot after the time marks a completion not opened since. A row shows the title and time, one supporting line, the latest reply line or else "You: <last prompt>", then the workspace, machine and context; Working rows show the transcript activity time, others the status change time, since transcript metadata can move the mtime without agent activity. Only live herdr agents appear: listing sessions whose pane is closed would mean scanning every transcript on the machine.

Security: Agent transcripts on the Mac.

With Settings > Sessions > Default view on Chat (the default), visible grid cards preview the conversation with agent.history latest, read at once on a status change, a star or a setting change, then every 5 s while working or unknown, or after a failed read. A blocked agent's card shows its terminal, so the prompt stays visible. On available: false or a collied too old for latest (the revision-26 codec refuses it locally), the card reads its terminal until the agent's status changes, and an empty conversation shows the terminal for that read. On Terminal, the grid reads only terminals.

Grid cards list running subagents in transcript order at the top of the terminal preview: title and elapsed time, at most 2 rows (4 when starred), then "+N more". Blocked cards hide the list but keep the caption's subagent count. No version bump: this uses AgentSummary.subagents without changing collied or the wire types.

Grid cards, list rows, inbox rows, the inbox search and the watch's agent list name an agent's workspace, or its folder when another agent of the machine has the same workspace_id (MachineFlockEntry.workspaceLabel(for:)), since agents in one Rex session would otherwise all read the session's name (#861). A Herdr Core agent shows its folder also when it is alone, since its group's label says nothing of its own (#866). The folder is the last component of the agent's cwd, without control, format, line separator and paragraph separator characters, so it stays one line. Any other agent alone in its workspace, or one with no folder name (cwd missing, empty or /), keeps the workspace's label, as do approvals, the Face ID and terminal grant reasons, Live Activities and terminals. Beside a badge, a Herdr Core agent with no folder name reads "Core" (Runtime marks). No version bump: the phone already receives cwd.

The session header shows the full subagent list with usage below the status row, hidden while typing in landscape, unlike the band of approval cards at its bottom. Glass, dimming and appearance follow docs/reviews/liquid-glass.md. The terminal or Chat runs full height under the header, navigation bar and composer; the composer takes every touch in its area, so a swipe there never reaches the terminal. The inbox's search field is a plain text field, because a .searchable field moved into the navigation bar when focused.

Linked pull requests

Each Agent can carry an optional pull_request: number, state (open, draft, merged, closed), checks (passing, failing, pending, none), url, failing_checks (names), remarks (reviews plus comments) and conflicting. No version bump: the fields are additive on a server-to-phone type, and both enums read an unknown value as unknown.

  • Daemon: a task beside the reconcile loop wakes every 30 s. It works only with gh in /opt/homebrew/bin, /usr/local/bin, /usr/bin or ~/.local/bin (without it no agent has a pull request), and only while a phone is connected or a paired phone has Archive when the PR merges on.
    • It finds the agent's checkout as agent.changes does (only inside the task roots), then the repository root and branch; an agent outside a repository or on a detached head has none. There it runs gh pr view --json number,state,isDraft,url,statusCheckRollup,mergeable,reviews,comments,headRefOid --jq '.reviews |= length | .comments |= length' with no argument, so gh finds the current branch's pull request, no branch name reaches the command line, and reviews and comments reach collied as counts, never text.
    • Cadence: once per 2 minutes per checkout and branch, except that a pull request last read as MERGED is read again only once HEAD leaves its headRefOid, or after 30 minutes, so a new pull request from the same commit is still found. "no pull requests found" caches none; any other failure keeps the last value for one refresh, then shows none, and logs nothing. A read whose branch changed while gh ran is dropped. A change to what the phone is shown sends flock.changed.
    • gh, here and for gh poi, runs from a fixed path with GH_PROMPT_DISABLED=1, without GH_TOKEN, GITHUB_TOKEN or the enterprise token variables, and without GH_REPO or any of collied's GIT_* variables, so the folder it runs in alone picks the repository, with null stdin, a timeout (30 s here) and kill_on_drop. Its reads here, the issue list and the pull request file list keep at most 1 MiB (2 MiB for the file list) of each stream and kill gh past it. An unknown state, or a url that is not https:// or holds whitespace or control characters, drops the read. failing_checks holds at most 10 distinct names, in rollup order, without control or format characters or ", cut at 100 characters.
  • Checks (from statusCheckRollup): a status context passes on SUCCESS, is pending on PENDING or EXPECTED, and otherwise fails; a check run is pending until COMPLETED, then passes on SUCCESS, NEUTRAL or SKIPPED and otherwise fails. Any failure makes failing, else any pending pending, else passing; an empty rollup is none. conflicting means mergeable is CONFLICTING.
  • Phone: grid cards, Inbox rows and the agent screen's header show a badge with the state's icon, color and number. A tap opens the https url, except on the agent screen, where it opens a menu: Open PR; while open or a draft, Fix failing checks (checks failing), Address review comments (remarks above 0) and Resolve conflicts (conflicting); and Explain this PR. Each adds one line to the composer, after any draft, holding the url (and for failing checks the quoted names), and sends nothing.
  • collied doctor warns when gh is missing or gh auth status fails.

Watching a pull request

For a Claude Code agent, the session menu offers "Watch PR" while its linked pull request is open or a draft, and "Stop watching #N, every M min" while the terminal has a watch. agent.watch_pull_request {terminal_id, watching, every_minutes} starts or ends a watch; Agent.pr_watch (number, url, every_minutes) reports it, and the badge shows "Watching" when it follows the linked pull request. Starting needs every_minutes of 2, 5, 15 or 30, a Claude Code agent, an open or draft linked pull request with a https://host/owner/name/pull/number URL in GitHub's characters, a checkout on a branch, and gh with gh auth status passing (else the error asks for gh auth login on the machine); stopping takes no interval, and watching the same pull request again only changes it. Watches belong to the machine, one per terminal, in pr-watches.json (0600, data directory) with the interval, checkout, branch and the starting phone's StableID, so they survive a restart.

  • Reads: a daemon task ticks every 30 s, with or without a phone, and reads each watched pull request once its interval has passed (at once for a new watch and after a restart) with gh api graphql --hostname <host> in the data directory, owner, name and number as variables, in the linked pull request read's environment. The query asks for the signed-in user, state, mergeable, head commit, the base branch's required check names (protection rule and RequiredStatusChecksParameters rulesets), the head's check runs and status contexts (name, outcome, isRequired) and rollup state, and the author, URL and time of the last 20 comments and 20 reviews, but no body, so no comment or review text reaches collied.
  • Wakes, queued on the watch until the agent takes them:
    • A failing check: once per check until it passes again or the head moves. An empty check list keeps the last check state.
    • All required checks passing: once per head commit. Required checks are the base branch's plus any listed check marked isRequired; each must be listed and pass, so an unreported one or a rollup state of EXPECTED holds the wake, while an optional check failing or running does not. With no required check, every listed check must pass and the rollup must not be PENDING or EXPECTED. A required check from a rule the signed-in user cannot read counts only once it reports.
    • A comment or review newer than the newest seen, by someone other than the signed-in gh user. Times are compared, with URLs breaking ties within a second, so a deletion that lets an older one into the window wakes nothing. The first read only records what is there.
    • mergeable turning CONFLICTING; UNKNOWN keeps the last answer.
  • Prompt: while changes are queued, each tick wakes the agent only if agent.list shows an idle or done Claude Code agent still on the watched repository root and branch; otherwise the wake waits. The wake goes through Driver::prompt and its guards, with no expected_draft: an agent just starting work, a box holding text, a scrolled screen or a blocked agent refuses it until a later tick. Right before the write, collied re-checks that the agent is still Claude Code and that the watch still exists for that URL with its phone paired, so "Stop watching" or a revoke during the attempt types nothing.
    • The prompt is one line naming at most 10 changes: Pull request #N (<url>) changed: check "<name>" failed; new review <url>; .... Check names lose control and format characters and quotes and are cut at 100 characters; comment and review URLs must be https:// without whitespace or control characters.
    • A head move drops queued check changes, and a queued failure, pass or conflict that no longer holds is dropped.
  • After a wake: an audit line (pr.wake, the terminal id, the summary and the pull request URL) and an alert "Woke <session>" with the summary through the done alert path, so mute_done silences it.
  • Wake prompts in Chat: collied records each wake's exact prompt, summary and time in pr-wakes.json (0600, data directory), never in the log or a push: the last 20 per terminal, apart from the watch, so they outlive it (a merge ends the watch right after its last wake) and a restart, until the terminal is missing from a non-empty agent.list.
    • agent.history sets HistoryMessage.origin (kind: "pr_watch" and the summary) on a main-thread user message whose text equals a remembered prompt for that terminal, and Agent.last_prompt_origin when last_prompt equals one's first line. Matching compares text only, so re-sending a wake's exact text also shows as a wake. Marks are keyed by herdr's terminal id, so a herdr restore after a reboot, which reassigns it, loses them.
    • Chat shows a marked message as one collapsed "PR watch: <summary>" row with the eye, expanding to the full prompt; grid previews and the Inbox show that line instead of the prompt. No version bump: both fields are optional and additive on server-to-phone types, which no retained revision decodes strictly, so an older app ignores them (and an unknown kind shows as an ordinary message) and an older collied sends neither.
  • Stops: the watch ends, with anything queued, when:
    • the pull request is merged or closed;
    • 10 wakes in a row held only comments and reviews (a wake with any other change resets the count);
    • 8 reads in a row failed (no gh, no login, network, an unreadable answer);
    • the terminal is missing from a non-empty agent.list;
    • the phone that started it is revoked, unpairs, or is no longer paired when the task ticks (a revoke while collied was stopped);
    • the user picks "Stop watching". The menu and badge follow through flock.changed.

Archiving when the pull request merges

A merged pull request's badge reads "Merged", and the session menu puts Archive first. Settings > Sessions > "Archive when the PR merges" (off by default; archiveOnMerge in prefs.json, absent until the user picks it) has collied archive the task itself. Once the user has picked it, collie-core sends task.archive_on_merge {enabled} (Drive class, audited with enabled=) to every connected machine on a change and to each machine at every session start, after push.register. collied keeps the StableIDs of the phones that turned it on in archive-on-merge.json (0600, data directory), so it holds with no phone connected and across a restart, while any of them is paired. Any phone turning it off empties the file, so a stale StableID (after a reinstall) cannot keep it on; a revoke or unpair removes that phone.

  • When: on the linked pull request task's 30 s tick, also with no phone connected (then one herdr snapshot per tick, only for agents passing the workspace check below, without changing what a phone is shown), once per 2 minutes per checkout and branch, so a merge is noticed within about 2 minutes. Only a fresh gh pr view finding MERGED, or a kept merged result, makes the agent a candidate; one failing a check is tried again at the next such read.

  • Checks, all read fresh in this order (Driver::archive_if_merged):

    1. The setting is on.
    2. A herdr snapshot shows the terminal's workspace is a linked worktree whose every pane is an idle or done agent with no subagent running. A plain shell pane, an agent working, blocked or unknown, or a Claude Code agent with a running subagent, an unreadable transcript or an incomplete subagent scan holds it.
    3. git status --porcelain --untracked-files=normal --ignore-submodules=none in the checkout prints nothing (ignored files do not count; a submodule with changes, untracked files or a commit other than the recorded one does, whatever .gitmodules or the config say), and git ls-files -v --recurse-submodules lists no assume-unchanged (lowercase tag, as core.ignoreStat sets) or skip-worktree (S) entry, since git status does not look at those files.
    4. gh pr view --json number,state,headRefOid again still says MERGED with the same number.
    5. git merge-base --is-ancestor HEAD <headRefOid> (a 40 or 64 hex character id only): the checkout holds no commit the pull request does not.

    Then Driver::archive_merged runs task.archive's archive, which re-checks the workspace on its own snapshot and refuses a regular folder (it never only closes the pane). Right before worktree.remove, after its last authorization check (a paired phone still has the setting on, so turning it off or revoking the phone stops an archive in flight), it requires the checkout herdr will remove to be the one whose pull request was read and repeats the git checks. It skips the manual archive's gh poi, which deletes every merged branch and removes the repository's other clean worktrees, whatever their agents are doing.

  • After: one audit line per attempt that reached archive_merged (collied, task.archive, the terminal id, PR #N merged: <result>); a candidate failing an earlier check is not audited. On success, an alert "Archived <session>" with "PR #N merged" through the done alert path, so mute_done silences it, and flock.changed.

Git reads

Git changes, the archive checks and the pull request branch checks run git in the agent's checkout through git::git_command, which treats the repository's config as untrusted: null stdin, none of collied's GIT_* variables, GIT_TERMINAL_PROMPT=0, GIT_OPTIONAL_LOCKS=0, an empty core.fsmonitor= (every git reads it as no fsmonitor; git before 2.36 takes any other value for the hook to run, so false would name a program), diff.external=, safe.bareRepository=explicit, core.hooksPath=/dev/null (no hook runs; the one write through this builder is git branch --track for a pull request worktree task) and an 8 s timeout. Diffs pass --no-ext-diff and --no-textconv; diff and status blank filter.<driver>.clean and .process for every driver the checkout's config lists. With --ignore-submodules=none, git also runs git status with GIT_DIR=.git in every populated submodule (each gitlink in the index whose folder holds a .git, inactive or missing from .gitmodules alike, and theirs in turn), which reads that submodule's own config, includes and all. collied reads each one the same way, with --git-dir=<folder>/.git: rev-parse --show-toplevel, ls-files --stage for its gitlinks (read as a stream that keeps only gitlinks, so an index of any size reads; an entry over 8 KiB refuses the read) and config --get-regexp for its drivers, which it blanks too. A submodule it cannot read refuses the read, as do more than 100, and the whole listing has one 8 s deadline, as long as the command it guards may run. Config written after the listing and before that command is not covered. Each blank is --config-env=<key>=COLLIE_GIT_EMPTY (COLLIE_GIT_FALSE for .required), with those two variables set to the empty string and false, not -c: -c splits at the first =, so a driver named x=y would set filter.x, and one named a.clean=<command> would set filter.a.clean to that command. --config-env splits at the last = and travels in GIT_CONFIG_PARAMETERS, which git passes on to those submodule children; git before 2.31 refuses the option, so the read fails wherever a config git reads there, the user's own included, defines a filter. safe.bareRepository=explicit (git 2.38) keeps git from taking a folder shaped like a bare repository, which a checkout can track as ordinary files, for one, so an agent inside such a folder gets no Git changes. A herdr-core or Rex worktree task reads its folder with the same builder (the worktree list, the branch check before git worktree add, the pull request branch checks); when git refuses the folder, collied names it with --git-dir only if no .git lies at or above it, or if the nearest one is a regular file whose gitdir: resolves to that folder (repo/.git holding gitdir: ./.bare, beside the checkouts), which a checkout cannot supply since git tracks no path named .git. So a bare repository kept for worktrees works as before while one inside a checkout is refused. Create and the pull request mode still refuse a source whose name starts with a dot (folder is hidden: .worktree is never made in a hidden folder), so repo/.bare serves the worktree list and Open only. In a partial clone, a diff needing a missing blob would fetch it, running repository-configured programs such as remote.<name>.uploadpack, core.sshCommand or a credential helper. GIT_NO_LAZY_FETCH=1 stops that fetch (git 2.45, and the 2.39.4 to 2.44.1 security releases). For older git, an empty GIT_ALLOW_PROTOCOL refuses every transport, overriding protocol.*.allow, and a blank fetch.bundleURI, which the fetch inherits, keeps it from starting git-remote-https for a bundle URI before that check (its setup can run a credential helper for http.sslCertPasswordProtected), so such a read fails instead.

An untracked file is the one thing Git changes reads without git: ls-files --others --exclude-standard names it, and collied opens it one component at a time from the checkout with O_NOFOLLOW, up to 1 MiB, for its line count, its digest and its diff. It does not read one whose path below the checkout has a component that starts with a dot or, on macOS, carries UF_HIDDEN, as file.open would not open it (Files from Chat): agent.changes lists the file with no hash, additions or deletions, as it lists one too large to read, and agent.diff answers invalid_params ("Hidden files are not shown"). The checkout's own path may be hidden (a worktree under <repo>/.worktree). A file git tracks is not held to this, since its diffs come from git: a changed .gitignore or workflow file shows as before, and so does a tracked or staged .env. No version bump: the three fields were optional already.

Git changes worktrees and pull requests

Git changes opens on the repository's worktrees: agent.changes with scope worktrees (revision 30) answers the agent's checkout as root, no files, the listed worktrees (at most 20, the agent's own always kept) and the user's open pull requests whose branch has no worktree.

  • Worktrees: each listed worktree other than the agent's checkout is re-checked as a picked one is (it must resolve to itself under the task roots and share the checkout's Git common directory, read once per list) before collied reads it; one failing the check keeps only its path and branch. Up to 8 are read at once with the git reads above: log -1 --no-show-signature --format=%ct %s for subject (control and format characters removed, cut at 200 characters) and committed_at_ms; status --porcelain -z --untracked-files=all --ignore-submodules=none for uncommitted (entries, a rename counted once, each untracked file as in the Uncommitted scope); against the branch scope's base, rev-list --count <base>..HEAD for ahead and diff --numstat -z --merge-base <base> for additions and deletions (tracked files, committed or not, binary files counting no lines). A field whose read fails is left out.
  • Pull requests: with gh installed, collied runs gh pr list --author @me --state open --limit 100 --json number,state,isDraft,url,headRefName,title,isCrossRepository in the agent's checkout, in the linked pull request read's environment and timeout; any failure means none. Only open and draft pull requests are read, so merged or closed ones never crowd out an open one; a worktree whose pull request merged shows no badge here. A worktree gets the newest listed pull request whose head branch equals its branch (state and URL; checks is unknown). Those matching no worktree are listed in pull_requests with their branch and title. Pull requests from forks, a URL that is not https://, a number outside 1 to 2^32 - 1, or a branch name empty, over 255 bytes or holding control or format characters are dropped; titles are cleaned like subjects. pull_requests is trimmed first when the answer passes the 48 KiB response cap.
  • Pull request scope: agent.changes {scope: "pull_request", pull_request: N} reads, in the agent's checkout, gh pr view N --json number,baseRefName,headRefName,changedFiles (base and head cleaned like subjects as base and branch), then gh api repos/{owner}/{repo}/pulls/N/files?per_page=100&page=P --jq 'map({filename, previous_filename, status, additions, deletions, sha})' for pages 1 and 2 (200 files, the listing cap), so the list is GitHub's: the pushed head against the pull request's base, whether or not a worktree still has the branch. Files are in section pull_request; a file whose path or previous path is not a plain relative path is left out and the listing marked truncated, as it is when GitHub has more files. status maps GitHub's to one letter (added A, removed D, renamed R, copied C, changed T, anything else M); a count above 2^32 - 1 is unknown. hash digests the number, status, paths and blob sha, so a Viewed mark clears when GitHub's file changes.
  • Pull request diff: agent.diff {section: "pull_request", pull_request: N, path} reads the same pages, at most two, with --jq '{count: length, file: ([.[] | select(.filename == $ENV.COLLIE_PATH) | {filename, previous_filename, status, patch}] | first)}' and the path in COLLIE_PATH, so no path reaches gh's command line or program text and only the one patch reaches collied; the answer must name the same file. A missing patch (binary, or too large for GitHub) shows as a binary notice. Output over 2 MiB is refused, and the patch is cut to the response cap like a local one. root is not used for this section.
  • A pull request read fails with gh's first stderr line (control and format characters removed, 200 characters), or asks for gh auth login on exit code 4. All of one pull request read's gh calls share one 30 s deadline, and the worktree list's gh pr list has its own 30 s timeout beside the git reads; collie-core waits 40 s for these reads.
  • Phone: the list shows each worktree's branch, the session's own checkout marked, last commit subject and age, commits ahead, uncommitted files, line totals and the pull request badge, plus the herdr agents of the machine whose folder lies in it (the deepest worktree holding the agent's cwd, from the flock; Claude Code subagents are not placed, since their transcripts record the parent session's folder unless started in a worktree). A worktree opens on Uncommitted and Branch, plus Pull request while its pull request is open or a draft; a pull request without a worktree opens on that scope alone. Pull request files use the agent's checkout as their root, so feedback on them stays valid after the worktree goes and names pull request #N instead of a folder; it is sent only while the agent's checkout is still that root, so it cannot name another repository's pull request. Feedback names its file, and a worktree other than the agent's checkout, as JSON strings like the cleanup prompt's, so a new line in a name cannot start a line of its own in the message. Agents are placed by the cwd herdr reports, not a canonical path, so one whose folder goes through a symlink to a worktree is not placed.
  • Clean up: Select mode on the list picks worktrees other than the agent's checkout and any on main or master (the default branch fallbacks; the phone is not told the origin/HEAD branch). Clean up first re-reads the agent's checkout and refuses if it moved since the list loaded, then sends one prompt through the feedback path, so the same checks apply: it is refused while the agent is blocked or the session is a plain terminal, while the phone is sending another prompt, answering a question or dictating, and when the agent's input box holds unsent text. The prompt lists each worktree's path and branch as JSON strings (so a U+2028 or U+2029 in a name cannot start a line of its own) and asks the agent to remove only those not in use (no agent or process in it, no uncommitted, untracked or unpushed work, pull request merged, closed or absent, and without a pull request nothing created or changed in it in the last 24 hours, since a background agent that just started there shows no other sign) with their local branches, keep the main worktree and the default branch, and report what it kept and why. The phone removes nothing itself, so no protocol or collied change.

Conversation history

agent.history is a read method on the paired connection: a terminal ID, an optional before or after cursor and an optional case-insensitive query. Cursors bind the agent kind, session UUID, file device and inode, byte offset and a hash of the preceding 64 bytes; replacement, truncation, changed cursor bytes or a session change reset the page. The daemon resolves the live agent before reading and verifies it again before replying. Identity comes from herdr, never a folder or recency guess; a missing identity or an unreadable file returns available: false with a distinct unavailable_reason, so the next poll can recover, and an existing empty transcript available: true with no messages. No version bump: an older daemon rejects the additive method, and the phone keeps Terminal available.

  • Copilot CLI reads the conversation selected for the pane (Live Copilot conversation in Context and inbox), not herdr's possibly stale ID; without a unique selection the reply is available: false with its own reason. Since /new can switch conversations without changing herdr's ID, the daemon selects again after the read and refuses a page from another session.
  • latest: true (revision 27, with no cursor or query) returns, without cursors, only the last two user messages and the last two assistant text messages, in order, from the same tail window and per-record caps, within 40 KiB. Tool calls, results, events, subagent records and blank text never count, and thinking and reasoning are never read (except a Claude progress update written as thinking, below); a record mixing text and tool calls counts only its text.
  • The reader uses the transcript locations of Context and inbox. A blocking worker reads at most a 64 KiB format header and a 2 MiB history window without holding the shared transcript mutex, consuming only newline-terminated records, so a partial append is retried. Backward pages and forward updates carry distinct cursors. A reply holds at most 40 message blocks and 40 KiB of serialized messages, below the 64 KiB transport limit; an oversized record is skipped with a notice, and cursors still progress. Search matches the full text; large text is then truncated on UTF-8 boundaries. No transcript content or search text reaches audit, push or notification state. Stable record and block IDs prevent duplicates across pages and reconnects.

Claude. The reader takes main-thread user and assistant content blocks, tool_use and tool_result included, and excludes synthetic replies, foreign session records and user records the harness injected (isMeta, such as skill text and subagent hand-backs, compaction summaries, and task-notification origins). No version bump for any of the following: each arrives as an ordinary message.

  • A subagent hand-back leaves a one-line event message, "Subagent finished: <description>" (the description, else the agent type, from the subagent's meta file); a task notification, with no structured status or summary, leaves "Background task finished".
  • A slash command (a user record with no promptSource, not isMeta, whose string content starts with <command-name> or <command-message> and names a / command; a typed prompt always has a promptSource) leaves its name and arguments, such as "/effort high", and its <local-command-stdout> record is left out. These event lines carry no other record text, are capped at 120 characters without control characters and stay out of search.
  • A ! shell command (a user record with no promptSource, not isMeta, whose string content is <bash-input>CMD</bash-input>) shows as the user's message ! CMD. The next record, <bash-stdout>OUT</bash-stdout><bash-stderr>ERR</bash-stderr>, becomes one tool result with no call ID: stdout, then any stderr on the next line, without terminal escape sequences (removed before truncation and search). Chat shows it as its own collapsed activity row.
  • A prompt sent while Claude is working is written only as an attachment record (attachment.type queued_command, commandMode prompt, origin.kind human) once Claude Code absorbs it into the running turn; its prompt (a string, or text and image blocks) shows as an ordinary user message there. A prompt that waits for the turn to end is a user record with promptSource queued instead, never both. Other attachments and queued commands (task notifications, subagent hand-backs, coordinator messages) stay hidden.
  • Claude 5.1 and later (from message.model, such as claude-opus-5-5: a family name, a major version and an optional one- or two-digit minor) write the short progress update before a tool call as a second thinking block. Claude Code writes each block as its own record sharing message.id, numbered by apiBlockIndex, and thinking blocks lead a message, so from such a model a main-thread thinking block at index 1 or later (apiBlockIndex plus its position in the record) is that update. It shows as assistant text and as last_line, even when a page or tail window splits the message. Every other thinking block (a lone or first one, or any from an older model, a synthetic reply or a subagent) stays hidden as reasoning.
  • Subagents: each subagent's records live in <session>/subagents/agent-<id>.jsonl, with agent-<id>.meta.json naming the parent Agent call (toolUseId). The reader adds them after the Agent call, tagged with its ID in parent_call_id (additive), and on forward pages after the hand-back (origin.from), so an open Chat gets the steps when a background subagent finishes. It opens them like the transcript, only for an id of letters and digits through real directories under the session's. They share one more 2 MiB tail window, plus up to 64 KiB of each file's head for its prompt, and count toward the page's 40 blocks and 40 KiB: a subagent larger than the room left keeps its first and latest steps and marks the page omitted, as do records left out in between, and its call starts the next page only when not one step fits. Context and the last line ignore subagents.

Codex. Codex 0.160 and later (or a header window containing item_completed) uses UserMessage and AgentMessage completion events for conversation text, avoiding their overlapping response_item messages; older Codex uses response_item messages. Both read function_call and custom_tool_call and their outputs with call IDs; encrypted reasoning and internal instructions are excluded.

Copilot CLI. The file must start with a session.start naming the selected conversation. The reader shows typed user.message content with no source or source: "user" (other sources, such as autopilot, skill-* or agent-<id> outside a subagent, were injected), assistant.message content with its toolRequests as calls, and tool.execution_complete results (result.content, or error.message on failure) paired by toolCallId; reasoning, system prompts, hooks, model and usage records and the duplicate tool.execution_start are hidden. A system.notification of kind agent_idle or shell_completed leaves a "Subagent finished" or "Background task finished" event line. Subagent records, marked with the child's agentId, are tagged in parent_call_id (additive, no version bump) with their parentToolCallId, or, for the child's prompt, the toolCallId of its subagent.started or of another record of that child in the same 2 MiB window; a child record whose call is not in the window is left out rather than shown as the parent's. Record IDs come from each event's id.

Phone. Chat projects records into a lazy timeline: text replies stay visible, consecutive tools form one collapsed activity row paired by call ID, and an Agent call nests its subagent's steps. It keeps an ID-based scroll position, loads older pages on demand, polls only the appended portion while visible in the foreground, and searches in bounded batches back to the beginning. Terminal keeps keys and wrapping and serves shells and unavailable transcripts. A web link (http or https, with a host and no user or password) opens on a tap only when its visible text is its address; Chat rewrites any other one to its own collie-ask: scheme when it renders the Markdown, and a tap on that one asks first in a confirmation that shows the host, after checking the address again, since a message can write that scheme itself. Links of any other kind are discarded, apart from file paths.

Plan usage

Claude Code passes the plan's limits only to the status line command, on stdin at each refresh (a new reply, /compact, a mode change, or a window reaching its reset), as rate_limits.five_hour and rate_limits.seven_day (used_percentage 0 to 100, resets_at in Unix seconds). On disk they sit only in a /usage cache in ~/.claude.json, which also holds account data collied should not read. Codex's rollout rate_limits (primary, secondary) are null for credit-metered workspaces, so the daemon asks the local Codex app-server (account/read, account/rateLimits/read) every five minutes and keeps only individualLimit's used credits, allowance and reset date; Codex manages its own OAuth token. A confirmed sign-out, or a successful response without a limit, clears the Codex reading; a failed fetch keeps it.

  • Tap: collied statusline reads the status line JSON from stdin (at most 1 MiB), keeps the two windows (percentage rounded and clamped to 0 to 100, reset time in ms) and, for a lowercase-UUID session_id, context_window.context_window_size (1K to 100M) and the two windows that session last reported, and drops the rest (spend_limit included). It merges them into usage.json (0600, data dir) under an exclusive flock on usage.lock, so concurrent sessions keep each other's windows, then replaces the file atomically without sync_all (a full drive flush on macOS; the next refresh redoes a lost write).
    • Each session reports the limits from its own last reply, and a plan's usage can be reset before a window ends, so a lower figure or an earlier resets_at does not mark an older report. The tap compares a session's report with that session's last one instead:
      • A new reading differs from it in a window still open: the session received a reply, so the report's open windows replace the recorded ones, lower or not, and recorded_ms moves.
      • A repeat changes no figure.
      • A session's first report only fills a window with no open recorded value: after an upgrade or an eviction it cannot be told from a quiet session's older figures.
      • Input without a session id merges per window as before: the later resets_at wins, then the higher percentage.
    • A window the input leaves out or shows past its reset is no change, since every session's status line drops a window when it resets; the recorded one is kept until its reset. Apart from a new reading, recorded_ms moves only when the input agrees with the recorded result, so a quiet session's older figures neither replace newer ones nor look fresh.
    • The status line runs several times a second while a reply streams, so an unchanged value is restamped at most once a minute, and input that changes nothing leaves the file alone. Input without rate_limits (a session before its first reply) keeps the last limits. At most 64 sessions are kept, each with its window size and last reported limits, the oldest seen first out. The tap starts no runtime and prints nothing.
  • Daemon: Transcripts re-reads usage.json (O_NOFOLLOW, regular file, at most 64 KiB) when its size or mtime changed, checked for flock.snapshot, approval.list, each claude transcript derivation and the 1 s reconcile poll. The plan belongs to the machine, so it goes out on the snapshot as Flock.plan_usage (five_hour and seven_day, each used_percent and resets_at_ms, and recorded_ms), with or without a Claude Code agent open. When it changes and a phone has a session open, that tick sends plan.usage, or flock.changed for a cleared plan. No version bump: the field is additive on a server-to-phone type, and an older app ignores the unknown event.
  • Phone: Usage shows one card per machine with a plan recorded, with the recording's age once no reading is current (each past its agent's limit below), and blocks for Claude Code ("5-hour limit", "Weekly limit"), Codex ("Monthly limit", when Codex reports an individual limit) and Copilot ("Monthly premium usage", when collied read one). A block shows a bar with an elapsed-time tick, the amount used (percent for Claude; used and allowed credits for Codex and Copilot, or requests for a Copilot seat that is not token-billed; "Unlimited" with no bar for an uncapped seat) and the reset; Copilot overage keeps the bar full and shows the real amount. A window past its reset is hidden; Claude data over 5 minutes old and Codex and Copilot data over 10 minutes old are dimmed.
  • Copilot: a task beside the Codex one runs gh api --hostname github.com copilot_internal/user (which also answers for a seat an enterprise assigns) every five minutes, with or without a phone, with the linked pull requests' gh setup (Linked pull requests) and the user's own gh auth login. It reads github.com only; GitHub Enterprise Cloud with data residency (*.ghe.com) is not read.
    • --jq reduces the answer inside gh to token_based_billing, quota_reset_date, quota_reset_date_utc and quota_snapshots.premium_interactions, so the login, account id, tracking id, organization and enterprise lists and service endpoints never reach collied.
    • collied keeps used (entitlement minus remaining, at least 0, plus overage_count, so overage counts however GitHub reports it), limit (entitlement), unlimited, token_based_billing and resets_at_ms (quota_reset_date_utc, else quota_reset_date as UTC midnight) as copilot in usage.json and PlanUsage.
    • No gh, gh exit code 4 (no login), an HTTP 404, an answer without premium_interactions, or an entitlement of 0 on a limited seat clears the reading; any other failure (network, timeout, a malformed answer, a reset already past) keeps the last one. The chat and completions quotas are not read. Nothing from gh is logged, audited or pushed. No version bump: copilot is an optional, additive field on a server-to-phone type, which an older app ignores.
  • Antigravity: collied statusline also accepts Antigravity's status line JSON (quota map of buckets with remaining_fraction, reset_time or reset_in_seconds, and optional disabled), keeping up to 16 live non-disabled buckets as agy (id, used_percent, resets_at_ms, window_seconds) in usage.json and PlanUsage, plus context_window.context_window_size for session_id; account fields (email, cwd, plan_tier, transcript_path) are dropped. Unchanged readings restamp at most once a minute. No version bump: agy is an optional, additive field on a server-to-phone type, which an older app ignores.
  • collied doctor: plan usage says when the tap last recorded the limits and how many sessions' windows it holds, or warns that it has recorded nothing. copilot reports the daemon's last read while under 10 minutes old; otherwise it asks GitHub once and says whether the usage is readable, that there is no gh, login or premium quota, or why the read failed.

Security: Status line tap, Copilot premium usage.

Token cost

The Usage view's "Tokens and cost" card reads usage.costs (revision 28, a read method) with a range (today, 7d or 30d) and the phone's current UTC offset in minutes (within 18 hours), so days end at the phone's midnight; one offset covers the whole range, so after a daylight saving change earlier days are an hour off. The reply carries scanning, token totals (input without cached input, output, cache read, cache write), the estimated cost and cache savings, a cost per day, and at most 32 model rows by cost, each with its agent, model id, tokens, cost_usd and cache_savings_usd (null for an unpriced model). Totals cover every model, listed or not; only priced models add to costs. The audit log leaves the method out, like flock.snapshot, since the card polls it.

  • Sources: Claude Code's projects (every *.jsonl, subagent and workflow transcripts included), Codex's sessions/YYYY/MM/DD/rollout-*.jsonl and rollout-*.jsonl.zst, and Copilot CLI's session-state/*/events.jsonl. The walk never follows a symlink, opens only regular files, skips names starting with ., descends at most 5 levels and lists at most 20,000 files per root, counting only files modified in the last 32 days. When a root hits the cap, indexed files missing from the listing are kept. Codex compresses a rollout idle for 7 days to .jsonl.zst and decompresses one it resumes; while both forms exist, only the plain file counts, as Codex reads that one.
  • Claude Code: assistant records with message.usage (input_tokens, output_tokens, cache_read_input_tokens, cache_creation_input_tokens and its cache_creation.ephemeral_1h_input_tokens part), speed: "fast" and message.model. Sidechain records count; <synthetic> records do not. Claude Code writes one record per content block, and a resumed session repeats earlier records in its new file, so a record counts once per message.id plus requestId across all files, kept by the first file in path order. A streamed message's earlier block records carry a partial output_tokens, so the file keeps the output counted per key and adds only the increase when a later record of that key reports more.
  • Codex: event_msg token_count events' info.last_token_usage (less cached_input_tokens and cache_write_input_tokens, which input_tokens includes), under the latest turn_context's model; a call over 272,000 input tokens, cached included, is long. An event is skipped before any turn_context, or when its total_token_usage equals the last counted one (Codex repeats unchanged events). After a counter restart (total_token_usage equals last_token_usage) Codex can later replay that first request, so a hash of its timestamp and last_token_usage is kept and a restart to that exact event is skipped; a restart with the same counters at another time still counts, and a zeroed total_token_usage forgets the kept request. Codex forks and subagent rollouts start their own counts (checked against 0.163 rollouts), so no fork suppression is needed.
  • Copilot CLI: session.usage_record events, one per model call of the main agent and each subagent: data.usage.model, inputTokens (including cacheReadTokens and cacheWriteTokens; long above 272,000) and outputTokens. A record without a model counts under unknown, unpriced. Copilot bills premium requests, so its cost is an API-equivalent estimate, and the card says so.
  • Model ids: at most 64 characters of letters, digits and ._:/[]-, else unknown, so only plain ids leave the machine.
  • Index: usage-costs.json (0600, data dir) keeps per transcript path its device, inode and size, the offset past its last complete line, Codex's model, last counted total and sequence's first request (the last two hashed), token sums per 15-minute UTC slot, model, fast mode and long call, and the hashed Claude keys it counted with their slot and output.
    • A scan reads each file from its offset in 1 MiB chunks, consuming only newline-terminated lines (a line over 8 MiB is skipped), so a partial last line is read again once complete. A file of unchanged size is not opened past fstat; one that shrank or changed device or inode loses its counts and keys and is read from the start.
    • A compressed rollout is decoded (pure-Rust ruzstd, 8 MiB window as for Resume, stopping past 512 MiB of output) and read whole whenever its device, inode or size changes; one that decodes past the limit or fails is recorded with no counts until it changes.
    • Each scan drops slots and keys older than 32 days and files that disappeared or went quiet, and replaces a changed index atomically after releasing the lock; an index of another format version is rebuilt. Deleting a file that a resumed copy deduplicated against takes the shared records with it until the copy is read again from the start.
  • Scans: usage.costs starts a scan on its own thread unless one is running or finished in the last 15 s, and answers at once from the index. The scan holds the index lock only to merge one file, so a reply during a cold scan has the totals so far and scanning: true. A first scan of about 4 GB of transcripts takes a few seconds; a later one, a fraction of a second.
  • Prices: crates/collied/data/prices.json holds LiteLLM's entries for anthropic and openai chat and responses models, Gemini chat models and Vertex AI's gpt-oss-120b-maas: input, output, cache read, cache write and one-hour cache write rates, OpenAI's rates above 272K input tokens, and the fast-mode multiplier. just prices refreshes it and LiteLLM's license from the commit pinned in the justfile, and a weekly workflow moves that pin and proposes the result as a pull request (docs/release.md); collied fetches nothing at runtime.
    • Lookup lowercases the id, drops a [...] suffix (Claude Code's [1m]) and a provider prefix, writes Claude ids with - for . (Copilot's claude-opus-5.5 is Claude Code's claude-opus-5-5), then tries the id without a trailing -YYYYMMDD.
    • A missing cache rate is the input rate, and a missing one-hour rate the cache write rate. A long call uses OpenAI's above-272K rates; other tiers, such as Claude Haiku 5.5's above-100K rates, do not apply. Fast mode multiplies every rate. Cache savings are cache reads times the input rate less the cache read rate.
  • Phone: each machine's card asks on appear, on a range or link change and on pull to refresh, then every 2 s while scanning; a failed read keeps the figures shown for the same range. Below revision 28 the session refuses the method locally, and the card asks to update collied on that machine.

Security: Agent transcripts on the Mac.

Starred agents

  • agent.star {terminal_id, starred} (Drive class: audited and rate limited) stars or unstars a pane and sends flock.changed. Starring reads session.snapshot and answers not_found for a terminal herdr does not list; unstarring reads nothing, so it works for a pane already gone.
  • collied keeps the stars in stars.json (0600, data dir), one set per machine shared by all the owner's paired phones, as terminal_id to pane_id: a herdr session restore (after a reboot) gives every pane a new terminal_id but keeps the pane_id, and a cross-workspace move does the reverse. On each flock.snapshot, and every second while a star is missing from that tick's agent.list at its last pane (with or without a phone, at one more session.snapshot per tick), collied keeps a star whose terminal is listed (updating its pane id), moves one whose terminal is gone to the terminal now in its pane, and drops the rest; a snapshot with no pane changes nothing, since herdr answers before restoring its panes. pane_id never leaves the machine.
  • The snapshot carries them as Flock.starred (additive, no version bump, but the app and collied update together since client params deny unknown fields). A star survives an app reinstall, a phone offline, an agent exiting (its pane stays) and a herdr restore; it goes when its pane closes or a phone removes the machine (unpair clears them all). Gaps: a pane id herdr reuses within about a second (or while herdr is unreachable) takes the old star with it, and a move followed by a restore in that window loses it. Closing every pane keeps their stars, since an empty list is not trusted, so a new pane that gets one of their pane ids inherits that star.

Terminals

A pane with no agent is a plain shell: herdr keeps the pane and its terminal_id when the agent exits (verified on 0.9.3). Since #755 a Rex block that runs a shell is one too (Rex, Terminals); Herdr Core's terminals are listed only as agents, and its plain shells stay unplanned. The phone lists, watches and types into shells under these rules. Security: Shell input from the phone.

Opt-in

[terminals]
enabled = true   # false, the default, when the section or the key is absent
  • Read at start, so a change needs a restart, which ends every session. No method changes it; only collied apns import and collied setup's push step rewrite collied.toml.
  • Off: flock.snapshot has terminals: [] and no terminals_enabled; every terminal.* request but terminal.lock (always ok) answers terminals_disabled before any herdr call, audited.
  • pane.read reads agent panes only, whatever the setting.

What is a shell

  • A pane is a shell when its PaneInfo.agent is absent and its terminal_id is not in session.snapshot.agents, which includes agents herdr is still launching. A Rex block is one when it is no agent and a shell runs in it, in front or above the program in front.
  • flock.snapshot lists shells as Terminal {terminal_id, workspace_id, label, cwd}: label is the herdr pane name, cwd the foreground process's directory, else the pane's. Titles a program sets (terminal_title, which a zsh theme fills with the running command) never leave the machine.

Grants

  • Terminal key. A second Secure Enclave P-256 key beside the TLS key, created with .userPresence and kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly: every signature needs Face ID or the passcode, and removing the passcode destroys the key. The app replaces it only when the enclave calls the stored one corrupt, or when the owner confirms it on the card of a shell that could not use it (iOS). Only the simulator uses a software key, behind a LocalAuthentication prompt.
  • Registration. pair.complete carries terminal_key, base64url of the 91-byte SubjectPublicKeyInfo. The pairing fails (audited invalid terminal key) unless it is a P-256 key other than the session's TLS key, which would sign without Face ID. The machine's y/N prompt shows the key as none, new, unchanged or a replacement. collied keeps the key in the peer record, which pairing again replaces whole, so a pairing without a key forgets it. The phone keeps its paired key in machines.json and, when its current key differs (as after the passcode was removed), answers TerminalKeyMissing (pair again) before any Face ID.
  • Challenge. terminal.challenge {terminal_id} needs a stored key (else terminal_key_missing) and a shell, and answers {terminal_id, challenge, ttl_ms: 60000}: 32 random bytes, one outstanding per session, a new one replacing it.
  • Grant. terminal.grant {terminal_id, challenge, signature} burns the session's challenge on any attempt. The signature (ECDSA P-256, SHA-256, DER, base64url) covers u32be(len) || bytes of each of "collie terminal grant v1", the machine's node ID (on the phone, the one pinned at pairing), the terminal_id and the challenge (protocol::terminal_grant_message). collied verifies it with the stored key and answers {terminal_id, ttl_ms: 300000}, else terminal_locked with the reason.
  • A grant covers one terminal in one session for 5 minutes from its issue (not a collied.toml key) and is bound to the key that verified it; at most 16 per session. Grants and challenges live in collied's memory only (lock order peers, sessions, terminals). They end with terminal.lock, the session, a revoke, unpair or re-pairing, or an agent seen on the terminal.

Watch and input

  • terminal.watch {terminal_id, lines?, low_data?} needs a live grant and shares the session's one watch, and its events, with agent.watch. It reads nothing while the session lacks a live grant under the peer's current key (a new grant resumes it), and ends with flock.changed when the pane closes or an agent starts in it. agent.watch {terminal_id: null} stops either kind.
  • terminal.run {op_id, terminal_id, text} sends one line of PromptText (no newline, tab or other control, no bidi or invisible format character) as pane.send_input with keys: ["enter"], the one ordered write herdr pane run makes (verified on 0.9.3 with sh and zsh). On macOS, herdr 0.9.5 refuses a line over the canonical input limit while the pane is in canonical mode, as a starting shell is; collied answers too_large (wait for the prompt, then retry) and keeps nothing else of herdr's message.
  • terminal.send_keys {op_id, terminal_id, keys} sends at most 16 keys. A Key is one of nineteen listed names or a combination (KeyCombo) in herdr's key-combo syntax: modifiers from ctrl, alt, shift and cmd, each once and in that order, then one key: enter, esc, tab, backspace, space, an arrow, f1 to f12, a lowercase letter, a digit or one of ' , - . / ; = [ \ ] `, the characters herdr-core 0.1.18 takes besides herdr. So a key names one key press, though a call of 16 can type 16 characters. [ goes only with Control (ESC in herdr; herdr-core refuses it), so keys alone cannot put [, digits, ; and a letter after an ESC from Esc, Alt or Control-3 to spell an escape sequence such as ESC[100;5u, the kitty form of Control-D; an Esc key followed by typed text still can, when both reach the program in one read. Control is refused with d, z and r, which would widen agent.send_keys too (EOT, SUSP, reverse search); j and m, which submit like Enter without its checks; o and t, which open Claude Code and Codex transcript views the scrolled-up check may miss, so later keys could answer a prompt hidden behind them; and 4 and \, which send QUIT. The refusal holds whatever other modifiers come with Control: herdr's legacy encoding sends Control-Shift-D as Control-D, and Alt only prefixes ESC. The phone withholds a combination ending in enter wherever it withholds Enter.
  • Command (cmd, Super) reaches only a program that turned on a keyboard protocol: herdr 0.9.5 encodes it in the kitty protocol (ESC[107;9u for ⌘K) or modifyOtherKeys level 2, and sends nothing for it to a program in legacy mode, such as a shell. Claude Code 2.1.318 and Codex 0.166.0 turn the kitty protocol on in herdr (checked from their output in a scratch pane), and Claude Code binds cmd keys in its keybindings.json; herdr-core refuses cmd (above).
  • terminal.send_text {op_id, terminal_id, text} types TypedText (as for agent.send_text) with pane.send_text, without Enter, under the same checks as terminal.send_keys.
  • All three go through the op_id outcome cache: a retry from the phone's next session replays the first attempt, checked against the first session's grant. herdr targets panes by pane_id and reuses pane ids, so right before each write collied checks a fresh snapshot: an agent there now gives not_found and drops the terminal's grants. It then requires the peer, the sending session's grant under the peer's current key, and no approval pending on the terminal (hook-driven approvals see an agent before herdr does), else terminal_locked (never not_paired, which would stop the phone reconnecting). A herdr error from these writes keeps only its code, since its message may quote the input. Nothing checks the foreground process: ctrl+c and answers reach whatever runs in the shell.
  • terminal.lock ends the session's grants and terminal watch.
  • Creating shell panes (tab.create) is a follow-up.

Audit

MethodTargetResult
terminal.challenge<terminal_id>refusals only
terminal.grant<terminal_id>every attempt: granted ttl=300s, or the error with its reason
terminal.watch<terminal_id>ok or the error
terminal.run<terminal_id>ok or the error; never the text or its length
terminal.send_keys<terminal_id> keys=ctrl+c enterok or the error
terminal.send_text<terminal_id>ok or the error; never the text or its length
terminal.locknoneok

Phone

  • The app passes the terminal public key to collie-core at start and on every foreground, since the Keychain item is readable only while unlocked. A new connection starts locked and never resumes a shell watch by itself: grants are per session.
  • On .background (not inactive, which the Face ID sheet causes), lock_terminals locks every terminal on the phone, then sends terminal.lock to each connected machine; any answer but ok closes that machine's session, ending its grants.
  • A shell's screen leaves with its grant (#818). When the session screen's poll, 10 times a second on a shell, sees its terminal locked again (that lock, the grant's 5 minutes, a new session or a terminal_locked answer), it drops the shell's text and blanks the terminal view under the Unlock card, at once even during a scroll; an agent's last screen in a pane that became a shell stays, since agent.read needs no grant. collie-core keeps and serves a watched shell's output only under a live grant: lock_terminals, a new connection and a terminal_locked answer drop it, the first agent_view after the grant's time has passed drops it, an agent.output or a patch for a watched shell is applied only under a live grant, and an agent watch on the same terminal starts empty. So neither output collied sent before the lock nor a session screen opened on the locked shell, which watches it as an agent and never saw it unlocked, brings the screen back.
  • When its agent exits, the agent screen becomes the pane's terminal, typed into directly (Typing into the terminal). Face ID runs only from the unlock button or an input, each time with a fresh LAContext (no reuse duration); a cancelled prompt sends nothing.

Typing into the terminal

The session's Terminal view (an agent's, or a shell's) has no prompt field; its keyboard types straight into the pane, as in a terminal app. Chat keeps its composer.

  • A single tap on the terminal that clears no selection, or the keyboard button, makes the terminal view first responder (UIKeyInput, no autocorrection, capitals or smart punctuation); the button hides it again, as does Return (typed, or the composer's or the strip's return key) unless Keep keyboard open after sending is on. Scrolling, long-press selection and the double- and triple-tap gestures are unchanged.

  • Tap to place the cursor (Claude Code, Codex, Copilot CLI and Antigravity): the pane's cursor position is not on the wire (sanitize_ansi drops cursor moves, herdr's pane.read does not report it, and Claude Code draws no cursor of its own), so the phone finds the agent's input box in the rendered frame and walks there with keys. Claude Code's is found as draft::parse does (the last two rules from column 0, the first row starting with ❯, other Mac rows indented two); Antigravity's is the same shape with > on its first row (and no > row below the box); Codex's is the last row starting with β€Ί at column 0, shaded, between two blank rows in its shade, other Mac rows indented two; Copilot CLI's is the last β•»β–„ border, then rows starting with ┃, then a β•Ήβ–€ border. A tap in the box picks the character boundary nearest to it; the phone sends βŒƒA, then ← and βŒƒA once per further Mac row in the box, which reaches the start from anywhere, also past spaces typed at the end of a row, which the screen does not show (βŒƒA goes to the start of the line in Claude Code and Codex and of the row in Copilot CLI, and ← at the start does nothing), then ↓ once per Mac row above the tapped one, then β†’ across the tapped row up to the tapped boundary, as keys in the strip's queue, and shows the keyboard. Checked on Claude Code 2.1.318, Codex 0.166.0 and Copilot CLI 1.0.105: ↓ moves by row as drawn, wrapped or after a newline, keeps the column, and lands on the row's first character shown, past spaces typed at the end of the row above (Claude Code and Codex hide them; Copilot CLI shows those that do not fit at the start of the next row, and the phone counts them there). So the walk counts only characters the screen shows: those before the tap on its own row, never past the typed text, so β†’ never accepts a suggestion shown after it. Codex's ↓ at the very start of a draft recalled from history unchanged recalls the next entry instead, so for Codex the walk sends β†’ before ↓: ↓ keeps that column (one cell, or two after a wide first character) and stops before a character that would cross it, and a row narrower than that column (an empty row, which may hold spaces typed there) takes the old single tap, as do rows after an empty first row. Where the screen shown joins rows the Mac wrapped (collied's wraps and splits: Claude Code's box as Draft sync reads it, Antigravity's > box, and Codex's rows under β€Ί), the phone renders the unjoined snapshot when tapped and maps the tap onto the Mac's rows: a joined row's space stands for the one hidden at the wrap. A wide character counts once. Taps elsewhere keep the old single tap, as do taps in a box showing only a dim placeholder or hint, a slash command (β†’ would complete its menu), a ❯ row below Claude Code's box (a selected background agent), a menu right above Codex's or Copilot CLI's box (Codex's ← and β†’ switch its list), and in Codex and Copilot CLI any text in a color of its own or dim: Codex's scroll arrows and collapsed pastes and images, and Copilot CLI's suggestions. Claude Code's file and resource suggestions, drawn right above its box indented four, take ↓, so while they show only the box's first row places the cursor. Copilot CLI scrolls a box taller than about half its pane without a sign (10 rows in a 25-row pane), so its box of eight Mac rows or more takes the old single tap. The walk to the start counts the Mac's rows, not the lines shown: collied also joins a typed newline right where the next word would not have fit, which looks the same as a soft wrap. Known limit: a collapsed paste or image in Claude Code counts its label's characters.

  • While the terminal is first responder, the view keeps that box above the keyboard: following the bottom stops at the offset that puts the box's bottom rule, blank row or border at the visible bottom (never past the real bottom). A scroll that ends elsewhere stops following; a change to the box's text while typing, or a scroll back to the bottom, resumes it.

  • Text goes out with agent.send_text or terminal.send_text, Return as the enter key and Tab as tab, Backspace as backspace, in one queue with the key strip's keys, so order holds. Text typed while a call is in flight goes out together in the next one. Control and format characters are dropped on the phone. With βŒƒ selected on the strip, a listed letter goes out as that Control key.

  • A slash command typed into Claude Code's box shows its menu on the screen, and Return runs it (Claude Code's highlighted match); the phone withholds Return only for a command it mirrored from Chat (Draft sync).

  • Attachments upload as before; each file's machine path is then typed into the terminal, followed by a space. The app's dictation types its final text when it stops, leaving Chat's draft alone. Neither is typed while the phone shows the agent waiting for an answer, where a digit of the path or of what was heard could be the answer: the file stays attached, the words join Chat's draft, and a notice says so. A saved prompt is typed, new lines as Return, and under the same rule joins Chat's draft with a notice instead, since its list can stay open while a dialog appears (#847); the paste gesture types the clipboard with new lines as spaces, so it never submits, and types nothing while the phone shows the agent waiting for an answer (an approval, the blocked status or an open Codex question), where one character can be the answer. Text of these four kinds can wait in the phone's queue behind another send, so it is checked again as it goes out (AgentModel.drainInput): once the phone shows the agent waiting for an answer, what is left of it, new lines included, joins Chat's draft with a notice, and keys typed on the strip or the keyboard go out as before, since they are how a dialog is answered there (#860). Quote from a terminal selection goes to Chat's draft and switches to Chat, since its newlines would submit.

  • A herdr-core pane takes each batch through a typing attach, and the core holds a keys call until nobody has typed for about 3 s, so Return after typing lands about 3 s later there.

  • Shells appear under "Terminals" in the Agents list and grid, without a grid preview, which would need a grant. The inbox and Live Activities show agents only; notification actions, the Live Activity intent and the lock-screen decide never send terminal.*.

ColliePush (notification service extension)

  • Pure Swift, no CollieCore, no network. It shares only Sources/Shared, the App Group group.dev.rbstp.collie and the notification keys' Keychain access group with the app. That group holds nothing but the notification keys: the app's TLS key, terminal key and relay state are in the app's own group (iOS).
  • It authenticates the display envelope against node, thread, event and approval IDs before replacing title and body and restoring the terminal ID, and always clears the subtitle, which collied never sends. Only authenticated content offering a decision gets the approval category; on failure or timeout the generic original shows, without controls. The app checks an action's notification against the same text and category before it decides.
  • collie-core writes each machine's last connection success and failure times, nothing else, to reachability.json in the App Group. When the alert's machine last failed, the NSE appends " (machine may be unreachable, open collie to check)" to the body.
  • Codex alert context leaves out the user-input region before an assistant response. On Codex 0.162.1's detection screen, a structured question's context is the text from the last Question N/M (K unanswered) heading to the first numbered choice, wrapped lines joined, read only while the screen ends with the exact submit or notes footer; missing choices, incomplete dialogs and ambiguous screens fall back to the encrypted Blocked in <folder>. The older question editor and action extraction stay supported; completion alerts stay generic. No version bump: no wire field, encryption, routing or approval action changed.

CollieBar (Mac/) is its own XcodeGen project: pure Swift, no packages, no CollieCore, a SwiftUI MenuBarExtra with LSUIElement (no Dock icon).

  • It talks to collied only over the control socket, like the CLI, with four requests: watch, pair (then confirm), peers_list and rex_resume. It opens no listener and reads none of collied's data files; Open Audit Log hands audit.log to Console.
  • watch is read-only and not audited, like status: collied answers {"type":"watch","pending_approvals":N,"collied_version":"VERSION"} at once and again whenever the pending count changes. It does not subscribe to the phone event broadcast, whose receiver count means a phone is connected. An open connection means running, EOF off; the app retries a failed connect every 2 s, its only polling. The menu shows this connection's collied_version, never the installed binary's, or version unavailable without one. No version bump: collied_version is an optional additive field on the local control reply; the phone protocol is unchanged.
  • While collied is off, Set Up runs ~/.cargo/bin/collied setup in Terminal through a private 0700 command file that quotes the path and removes itself before exec (or when Terminal cannot open), so it needs no Automation permission or shell interpolation.
  • Turn Off and Quit run collied stop, Turn On collied start, through the plist's ProgramArguments[0], without a shell, so launchd's semantics (disabled until start, across reboots) stay in one place. The socket cannot do it: a stopped collied has no socket, and KeepAlive would restart one stopped from inside. A collied run by hand, outside launchd, is not stopped.
  • Pairing shows what collied pair shows, each phone string escaped like collied::printable, with 60 s to answer. Pair is not the default button and goes live 1 s after the candidate appears (the window's tcflush); it sends one answer, never on its own. Only the QR image (correction level M) is kept: the invite is never shown as text, copied, logged or stored, and window restoration is off. Closing the window cancels, as Ctrl-C does.
  • Open at Login uses SMAppService.mainApp, off by default.
  • Resume Rex Agents After Restart reads rex_resume when the menu opens and sets it when toggled (Rex); it shows only while collied runs and answers it, so an older collied, which refuses the request, hides it. CollieTray has no equivalent: collie follows Rex on the Mac only.
  • just mac-install signs it without App Sandbox, which would block the socket and running collied; release.md covers signing and notarization.
  • Its unit tests have no host app, so they never launch it against the live socket.

Bar widget (Linux, Omarchy)

CollieTray (Linux/CollieTray) is CollieBar for the Omarchy shell: a third-party Quickshell plugin, rbstp.collie, with one service (Service.qml) for the shell and a bar-widget (Panel.qml) per monitor's bar. Through Quickshell's Socket it sends CollieBar's exact control socket lines, with the same watch states, 2 s retry and version display; peers_list runs when the menu opens, and each pairing gets its own connection.

  • The socket path comes from the unit's pinned XDG_DATA_HOME, else the shell's, else ~/.local/share, as collied resolves it. Turn Off, Turn On and Quit run the unit's ExecStart executable with stop or start by argv, never through a shell, as CollieBar does.
  • Pairing matches CollieBar. Phone strings are drawn as plain text, never rich text; Pair is bound to no key (not Return, not the panel's activate key); Esc means Don't Pair. Closing the panel, another popout taking its place, or a plugin reload closes the connection, which cancels.
  • The invite reaches qrencode -l M -t ASCII on stdin only, never argv, a file or a log (Quickshell keeps console.log in /run/user/<uid>/quickshell; the plugin logs nothing). The drawn matrix is dropped with the pairing; qrencode's output stays in the process's StdioCollector until the next pairing.
  • Quickshell's JS has no \p{} classes, so Printable.js holds code point ranges that Linux/Tests/gen-printable.mjs generates from node's Unicode data, checked against CollieBar's vectors.
  • A bar plugin cannot quit the shell: Quit runs collied stop, then omarchy-plugin-disable rbstp.collie. The shell loads enabled plugins at login, which stands for Open at Login. Open Audit Log runs less with LESSSECURE=1 (no editor, no shell escape) through omarchy-launch-tui.
  • The icon is a copy of CollieBar's MenuIcon.svg (omarchy-plugin-validate refuses symlinks), dimmed while collied is off, with a dot while approvals are pending.
  • just tray-test checks the icon copy and runs the model tests and Service.qml against Linux/Tests/fake_collied.cjs, never the real socket. just tray-install validates the plugin, copies it through a dot directory the shell's watcher ignores, then enables it.

Live Activities

The lock screen and the Dynamic Island show an agent only while the user follows it: off by default, at most 5 at once on the phone. The phone starts each activity from the foreground; collied only updates and ends it. Push-to-start is not used: it is unreliable from background wakes.

Phone and collie-core

  • Following starts an Activity (pushType: .token) with the agent's current state and registers each update token with that agent's Mac, again on every foreground. The app's title for the agent (its terminal title, at most 64 characters) is encrypted in the static attributes and fixed for the activity's life: the lock screen and the expanded island show it, while collied's pushes carry the agent name or kind. Unfollowing ends the activity at once and tells the Mac.
  • collie-core keeps push and activity registrations per machine in memory only and sends them on every connection, push.register first, since collied takes the APNs environment from it. Ends the Mac has not acknowledged go out on every connection until it answers, even after an app kill: they persist in activity-ends.json in the state dir (0600, atomic; per machine, only activity_id and end time, at most 16). At start collie-core loads only paired machines' ends under 8 h old and ignores an unreadable file; removing a machine drops its ends.

Protocol

  • push.activity_token {activity_id, terminal_id, token, shows_approvals?, display_binding?} and push.activity_end {activity_id}, both MethodClass::Push. activity_id is ActivityKit's Activity.id ([A-Za-z0-9-], at most 64); token is the update token in hex (64 to 256 characters, redacted in Debug). shows_approvals (omitted when false) means the activity shows an approval's command and buttons; collie-core always sends true, since every activity the app starts carries the Mac's node id.
  • No version bump: push and activity registrations require the negotiated encrypted_display_v1; peers without it keep ordinary tailnet operations but cannot register this codec. The optional activity binding is sent only with that capability.

collied

  • Stored in push.json (0600, atomic) under activities: {stable_id, activity_id, terminal_id, token, environment, registered_at, shows_approvals, display_binding}.
  • Bound to the session's StableID: a device registers, replaces and ends only its own activities. The same activity_id or terminal_id from that device replaces the old entry, so an activity the phone never ended holds no slot. The environment is the device's own from push.register (not_found without one). At most 8 per device (too_large beyond); ending an id the device does not have answers ok.
  • Dropped on push.activity_end, on revoke, at start for peers no longer paired, on Unregistered or BadDeviceToken, when the terminal is gone, and quietly (no push, audited ended: expired) 8 h after that activity_id first registered, since ActivityKit ends an activity 8 h after it starts.
  • Updates come from the 1 s agent reconcile, after the approvals pass, never from terminal output. Per activity:
    • first sight (a new activity, a new token, or a collied restart): one update without alert;
    • content changed: an update, at most one per 2 s (a change inside the gap goes out on the first reconcile after it); a status change alone never alerts, since the end of a turn is the done alert;
    • an approval routed to the activity (below): in the same reconcile, whatever the gap;
    • nothing changed: the same content every 10 min, moving the stale date while the Mac is up;
    • the terminal missing from two reconciles in a row: end with dismissal-date = now + 60 s, then the token is dropped. A failed agent.list (herdr down) changes nothing.
  • Every send re-checks the pairing. The audit log has one line per register (push.activity_token, target <terminal_id> activity=<activity_id>) and per end (push.activity_end, ended: agent gone or ended: expired); tokens are never logged or audited.
HeaderValue
apns-push-typeliveactivity
apns-topic<bundle_id>.push-type.liveactivity
apns-priority10 for an update carrying an approval alert and for the first update after an approval leaves the activity, else 5 (updates, refreshes, ends)
apns-expirationfor an update carrying an approval alert, the approval's expiry, as for the alert it replaces; else now + 5 min
apns-collapse-idnone
{"aps":{"timestamp":1791028800,"event":"update","content-state":{"v":1,"enc":"<authenticated envelope>"},
        "stale-date":1791029700,"alert":{"title":"Collie","body":"An agent needs attention"}},
 "node_id":"nMAC","event_id":"<opaque event>"}

Approval on the activity

  • A device that follows an agent gets that agent's approvals that offer Approve and Deny on the activity alone: one alert expands the Dynamic Island with the command and both buttons, and no approval notification comes. Other prompts, such as a question, a plan or a Codex or Copilot prompt, go as the approval alert, without actions.
  • Only an activity registered with shows_approvals takes approvals. An activity without a current encrypted display binding gets no private state; an urgent send that cannot be encrypted falls back to the encrypted approval notification.
  • When alert_due lets an approval alert go out, a device with such an activity for the terminal gets instead, in the same reconcile, a priority 10 activity update: a generic aps.alert and encrypted state holding approvalId and the inner context enc, sealed to that device's notification key like the alert's enc (AAD = approval_id; none without a key or a context) and cut at 600 JSON-escaped bytes, so the update fits APNs' 4 KB with labels at their caps. Other paired devices get the approval alert: an approval alerts once either way.
  • A reissue that alert_due keeps quiet reaches only the activity, as a priority 5 update without alert carrying the new approvalId and enc, so its buttons never decide a burned approval.
  • Fallback: if the activity push fails (any APNs or network error, or a dead token, dropped as usual), or the activity or the agent is gone by push time, the device gets the approval alert at once.
  • Late fallback: APNs accepts pushes to an activity the phone has ended (dismissed, ended by iOS while suspended, Live Activities off, an update dropped by iOS's budget or replaced while offline), and nothing tells collied. So an approval that alerted on an activity and 2 min later is still pending and not being decided also reaches that device once as the approval alert, never after an early fallback. The cost: a reminder after 2 min unanswered, and up to 2 min of delay behind a dead activity. Both timers live in collied's memory; a restart reissues pending approvals, which alert again.
  • The inner enc is sealed once per device and approval and repeated inside freshly sealed outer envelopes on later updates, so coalescing still sees an unchanged state. Once the approval resolves or the agent leaves blocked, the next update omits approvalId and enc and carries no alert; it goes out at once at priority 10, skipping the 2 s gap and the relay's 60 s cadence, so a locked phone drops the buttons. An end never carries them.
  • On the phone, AgentActivityAttributes carries the Mac's nodeId. The widget authenticates the whole state against its node and activity binding, then shows the inner command, privacySensitive (redacted while locked), on the lock screen and the expanded Dynamic Island. Failed authentication shows a neutral display without buttons; authenticated blocked state without a command shows "Approval needed"; Approve and Deny need a command that decrypts. Their LiveActivityIntent requires authentication, so iOS makes the user unlock first; the intent then takes the notification actions' path in the app (Lock-screen approval).

collied setup

One interactive command adds or updates a Mac or Linux machine. Its steps reuse the subcommands through a setup::Host trait, which unit tests fake to check the step order and skip rules. Each step checks its own done state, so a rerun resumes where the last one stopped:

StepDone whenOtherwise
loginthe daemon answers status with backend Running, which it does only once its node passes the ownership checks; a loaded job first gets 20 s, for a daemon just collied-install just restartedunload a loaded job without disabling it (a crash loop or a logged-out daemon holds the node lock or the socket), run collied login, and if that fails start the job again
servicethe plist on disk is what install would write, the job is loaded, and the daemon's started_ms is not older than the binary's mtimeservice install (bootout, then bootstrap), then wait up to 60 s for the daemon, including up to 10 s for an untagged device in its netmap, so a fresh node does not trigger the policy hint; on a timeout print the last 20 lines of collied.err.log. A plist with another --config stops setup: run collied --config <path> setup
doctorno fail linestop: fix, then run setup again
push[push.relay] or [apns] is in collied.tomloffer it: by default add [push.relay]; with --direct-apns, ask for the .p8 (key ID from AuthKey_<KEY_ID>.p8), team and bundle IDs, append [apns] and run apns import, restoring the old config if the import fails (a new file is created 0600; an existing one is rewritten atomically, keeping its mode). Then restart the service so the daemon reads it
pairnever: phones may need to pair again after an updateoffer collied pair

Before any step, setup refuses unless stdin is a terminal, so yes | collied setup cannot answer the pairing prompt, and unless it runs as ~/.cargo/bin/collied (on Linux also a packaged /usr/bin/collied), a regular file, not a symlink, and on macOS Developer ID signed as dev.rbstp.collied. So the service never runs an unsigned binary or target/release, which the next cargo build replaces. Setup never confirms a pairing: the y typed after the tcflush does.

On Linux only the service backend differs:

StepDone whenOtherwise
loginas on macOS; "loaded" is any ActiveState but inactive and failed (a unit restarting after a crash counts); while a daemon answers, only active counts, so a foreground collied run beside a restart loop is refused as running outside the servicesystemctl --user stop (the unit stays enabled), collied login, and if that fails collied start
serviceas on macOS, for the unit file (executable, --config, pinned XDG_*_HOME) instead of the plistservice install (daemon-reload, enable, restart), then wait as on macOS; on a timeout print the last 20 lines of journalctl --user -u collied.service

On Linux, the service check also stops setup when the user manager loads collied.service from another file or applies a collied.service.d drop-in, when the unit pins another XDG_DATA_HOME (another node's data dir, so setup would log in a new node), or when it runs another --config. The direct APNs step stores the key as APNs key on Linux describes, and never prints it.

Doctor's service line reports the same state on both OSes: up to date (on Linux, adding that the unit stops at logout without linger), or a warn naming what setup would do. A doctor other than the installed binary skips it with a warn, since the check compares the service with the running binary.

The control socket's status reply carries started_ms and user_peers (visible untagged nodes of the daemon's verified user; visible does not mean TCP-reachable), both with serde defaults; setup treats a daemon reporting neither as outdated. The phone protocol is unchanged.

On macOS, an interactive login without an auth key prints the URL and QR, then tries once to open the URL with /usr/bin/open and an argument array if it is HTTPS with exact authority login.tailscale.com (port 443 optional) and no userinfo; failure is nonfatal. Other logins (noninteractive, auth key, custom control) only print the URL.

Startup verifies the node's own user identity (tailnet.md) before exposing any listener or the control socket, with no first-phone-owner fallback. A restarted node reports Running from Tailscale's netmap disk cache, which can lack user profiles, so its own-address whois answers "peer not found" until control sends the live map: collied run and collied login repeat the whole check on exactly that answer until their start deadlines (60 s and 10 minutes), and stop at once on any other failure, a mismatch included. Admission and the post-TLS gate recheck the self identity and a fresh peer whois, so changing the owner or tagging the running node refuses new sessions instead of rebinding trust. Local reauthentication requires stopping the daemon first; collied login prints Tailscale's last login error.

User ownership gives the embedded daemon its user's network privileges, not a separate service tag's confinement. tailnet.md covers doctor's reach line and setup's policy hint, key expiry, scoped state reset, reauthentication and the physical-device and corporate VPN acceptance gap.

Linux

collied runs on Linux with the same protocol, gate, allowlist and approvals as on macOS. Built and tested on Arch with systemd 261; Requirements names the tested herdr version.

Platforms and build

TargetState
aarch64-apple-darwinbuilt and tested
x86_64-unknown-linux-gnubuilt and tested
aarch64-unknown-linux-gnumapped in tailscale-sys (GOARCH arm64); needs a cross C compiler in CC; not built or tested
any other OScompile_error! in collied
  • Linux builds need Go β‰₯ 1.27.4, a C compiler (CC, default cc), libclang (bindgen) and, on a host other than x86_64, Zig 0.17.1 on PATH (x86_64 downloads its own, libghostty-vt), and no code signing.
  • tailscale-sys sets GOOS linux and passes no Apple target or sysroot flags, frameworks or libresolv. The pinned libtailscale, patch series and vendored module patches apply unchanged.

Paths

WhatmacOSLinux
Data dir~/Library/Application Support/collie$XDG_DATA_HOME/collie, else ~/.local/share/collie
Attachments root~/Library/Caches/dev.rbstp.collied/attachments$XDG_CACHE_HOME/collied/attachments, else ~/.cache/collied/attachments
Service~/Library/LaunchAgents/dev.rbstp.collied.plist$XDG_CONFIG_HOME/systemd/user/collied.service, else ~/.config/systemd/user/collied.service
Logscollied.out.log, collied.err.log in the data dirthe user journal (journalctl --user -u collied)
  • For the data dir, attachments root and unit path, an unset, empty or relative XDG_*_HOME is ignored, as the XDG spec says. The herdr resolver, like herdr, takes XDG_CONFIG_HOME as given.
  • The data dir holds collied.toml, tsnet/, tls-key.json, peers.json, peers.lock, push.json, status.json, stars.json, pr-watches.json, pr-wakes.json, archive-on-merge.json, rex-tasks.json, rex-resume.json (and rex-resume-off while resuming Rex agents is off), usage.json, usage.lock, usage-costs.json, audit.log, control.sock, node.lock and apns/. status.json (when collied first saw each agent's status) is replaced atomically, 0600, without sync_all (a full drive flush on macOS), so a power cut can reset those times.
  • herdr socket, same resolver on both OSes: [herdr] session, else HERDR_SOCKET_PATH, else HERDR_SESSION; then $XDG_CONFIG_HOME/herdr[/sessions/<name>]/herdr.sock, else ~/.config/herdr/.... Verified: herdr 0.9.3 on Linux puts its socket at $XDG_CONFIG_HOME/herdr/herdr.sock (mode 0600), not under XDG_RUNTIME_DIR.
  • tsnet creates an empty ~/.local/share/tailscale (0700) for a non-root user; collied keeps its node state only in <data dir>/tsnet. A system tailscaled (root, /var/lib/tailscale) is untouched: the embedded node is a separate device with its own keys.

Embedded node ownership

Both OSes apply the same user-owned node rules; doctor fails on a tagged node. Neither daemon calls the native Tailscale CLI, changes system routes or reads the system VPN's account or state.

The phone records the verified positive embedded Tailscale user in machines.json; pairing, reconnects and one-shot background approval and list sessions require its current self user, the machine's netmap owner and a fresh whois to match it (tailnet.md). A zero owner pin needs explicit re-pairing, never inference from a new login, and a machines.json missing a field is set aside, so its machines pair again. kind, from netmap OS metadata at pairing, is presentation only and never changes on reconnect.

systemd user unit

collied service install makes the data dir private, writes the unit with the canonical executable and --config paths (0644, through collied.service.tmp and a rename), runs daemon-reload, checks that the user manager loads the unit from that file (FragmentPath), then runs enable and restart. Another unit of that name, or another XDG_CONFIG_HOME in the manager, fails the install there (the written file stays), so it never reports success for a unit that never starts.

# Written by `collied service install`; rewritten on every install.
[Unit]
Description=collie daemon: herdr agents over the tailnet
Documentation=https://github.com/rbstp/collie
StartLimitIntervalSec=0

[Service]
Type=exec
ExecStart="<exe>" "--config" "<config>" "run"
Environment="XDG_DATA_HOME=<dir>"
Environment="XDG_CACHE_HOME=<dir>"
Environment="XDG_CONFIG_HOME=<dir>"
Restart=always
RestartSec=2s
RestartSteps=5
RestartMaxDelaySec=1min
UMask=0077
NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectSystem=strict
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictSUIDSGID=yes
RestrictRealtime=yes
RestrictNamespaces=yes
LockPersonality=yes
MemoryDenyWriteExecute=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallErrorNumber=EPERM
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK

[Install]
WantedBy=default.target

The --config pair appears only when --config was given. No User=, no socket activation, no listener.

Quoting follows systemd.syntax; a test checks it with systemd-analyze --user verify where systemd-analyze and a user manager exist:

FieldRule
ExecStart= executableabsolute UTF-8 path with no ", ' or \, else install refuses; quoted, % doubled (systemd does not expand $ there)
ExecStart= argumentsquoted; \ and " escaped; % and $ doubled
Environment=the whole KEY=value quoted; \ and " escaped; % doubled ($ is literal there)
every fieldcontrol characters and non-UTF-8 paths are refused

Pinned XDG. Units the user manager starts (at first login, or at boot with linger) do not get the session's XDG_*_HOME (verified on the dev machine), so the unit pins all three to what the installing CLI resolved, fallbacks included; otherwise the daemon could use another data dir (control socket, peers), attachments root and herdr socket than the CLI. As with launchd, HERDR_* is not captured: [herdr] session in collied.toml picks a session.

Restart gives launchd's KeepAlive without a hot loop: the delay grows from 2 s to 1 min, and systemd never gives up. collied exits when the tailnet listener fails for good or another loop it cannot serve without ends, so the manager restarts it.

Sandboxing is best effort: in a user manager most of these settings need unprivileged user namespaces, and systemd skips them without those. ProtectSystem=strict leaves the home directory and /run/user writable in a user unit. UMask=0077 always applies.

Commandsystemctl --user
collied stopdisable --now, then reset-failed: off across logouts and reboots until collied start; the unit file stays
collied startenable, then start unless already active
collied service uninstalldisable --now (when the file exists), remove the file, daemon-reload, reset-failed; refuses when the unit runs but its file is not at that path
  • collied stop and collied start fail when the unit file is not installed.
  • A user unit runs while the user has a session; loginctl enable-linger keeps it running without one. The launchd agent likewise runs only in the GUI session.
  • just collied-install on Linux builds in release, copies the binary to ~/.cargo/bin/collied as a fresh inode (the running daemon keeps its copy until it restarts) and restarts the unit if it is active.

Kernel TCP listener check

tailnet::kernel_tcp_listeners(pid) lists the kernel TCP sockets in LISTEN state that a live process (checked with signal 0) holds, for doctor's listen line and tests. It never reports an error as an empty list.

  • macOS: /usr/sbin/lsof. Any stderr except exact copies of lsof's three-line warning for a mount point it cannot stat() (disk images under the temp folder; it never touches socket rows), or an exit other than 0 or 1, is an error.
  • Linux: the inodes of the socket:[N] links in /proc/<pid>/fd, matched against the LISTEN rows (state 0A) of /proc/<pid>/net/tcp and tcp6 after a header check. It skips an fd closed during the listing, and a missing tcp6 table without an IPv6 stack (no /proc/sys/net/ipv6); any other read or parse error is an error.

APNs key on Linux

Each machine has its own APNs key and key ID, revoked on its own, so a Linux machine pushes while the Mac is off. The default store is key = "systemd-creds" (APNs).

  • The credential <data dir>/apns/<KEY_ID>.cred is named collied-apns-<KEY_ID>, and the name is sealed in it, so a credential renamed or copied for another key ID does not decrypt. collied always passes the name: an empty or missing one skips systemd's check of the sealed name.
  • collied runs systemd-creds --user --no-ask-password {encrypt|decrypt} --name=collied-apns-<KEY_ID> - - over stdin and stdout (at most 64 KiB each way), never through a file, and zeroizes the decrypted key after use. It runs systemd-creds, systemctl, systemd-analyze, loginctl and journalctl by absolute path (/usr/bin, else /bin, else /run/current-system/sw/bin), never from PATH.
  • The credential file gets the key_path checks (0600 regular file owned by the user, opened with O_NOFOLLOW). The daemon, collied apns test and doctor decrypt it each time they load the key.

collied apns import AuthKey_<ID>.p8 makes the macOS checks except the signature check, then writes the credential itself (0600, O_NOFOLLOW, atomic), since systemd-creds would write its output file with the umask's mode. It checks that the new credential decrypts to the key before storing it and after reading it back. An existing credential with the same key is kept unless only the new one has a TPM2 seal; one that no longer decrypts, or holds another key, fails the import. Import then rewrites [apns] to key = "systemd-creds" (the default, so nothing to rewrite without a key line) and asks y/N to delete the original file, only if it is still the same inode.

Where systemd-creds cannot encrypt (no systemd, no systemd-creds.socket, systemd older than 256, a container), import says so, copies the key to a 0600 <data dir>/apns/AuthKey_<KEY_ID>.p8 (an existing file there must hold the same key and is kept), points key_path at it and offers the same delete, unless the imported file is that copy. If <KEY_ID>.cred already exists, a failed encrypt fails the import instead: it never falls back to a plaintext file.

Seal. An unprivileged caller cannot choose the key with --with-key: systemd's varlink service (io.systemd.Credentials, behind systemd-creds.socket) seals with the host key plus the TPM2 when one is usable, else the host key alone, and silently falls back to the host key alone if TPM2 sealing fails. So collied reads the seal from the credential header, whose first 16 bytes after base64 decoding are the key type id (ids from systemd src/shared/creds-util.h, v261 and main). The first encrypt on a machine makes systemd create /var/lib/systemd/credential.secret (root, 0400). The credential stops decrypting after an OS reinstall, a machine-id change, a uid or user name change, or a restore to another machine: import again from the backup.

Doctor on Linux has no codesign line. Its apns line:

StateResult
credential, host keyok, "host key only (no usable TPM2)"; warn when systemd-analyze has-tpm2 finds a usable TPM2 (import again to bind it)
credential, host key and TPM2ok, "host key and TPM2"
credential, TPM2 onlyok, "TPM2"
credential, null keyfail, "null key, not encrypted" (integrity only)
credential, unrecognized sealwarn, "unrecognized seal"
credential missing or not decryptingfail
key_path, systemd-creds workswarn: encrypt it with collied apns import
key_path, systemd-creds unavailableok: "0600 file fallback (systemd-creds unavailable): protected by its mode only"

Only with key_path does doctor probe systemd-creds, by encrypting and decrypting a test value named collied-apns-doctor-probe (on a machine with no credential yet, that first encrypt creates the host secret). As on macOS, doctor also signs a provider token as a dry run and warns about any other .p8 in <data dir>/apns.

Storage difference. Other unprivileged users cannot decrypt the credential, but any same-UID process can, without a prompt: no Keychain-style ACL binds it to collied. So same-UID malware on Linux can read the key, not only use collied to send pushes, and the 0600 fallback is protected by its mode only (threat-model.md).

collied status

On both OSes, collied status also prints tags: ((none), or (not reported) when the node status failed) and, when herdr answers, agents: N and one terminal-escaped line per agent (status, name or kind, workspace label, terminal_id), mapped from the daemon's herdr session.snapshot as for flock.snapshot, herdr-core agents included. With a herdr-core socket resolved, it also prints herdr-core: with the core's version and generation (or not running), the socket, its folder's mode and any method the core lacks (herdr-core). With a Rex socket found, it prints rex: with the server's version and API revision (or not running), the socket, its folder's mode, why it is not followed and how other machines reach it (Rex). A flock too large for one control line prints too many to list here, so the status request, also the liveness probe, never fails on a large session. The reply's tags, flock, flock_too_large, herdr_core and rex have serde defaults, so a newer CLI reads an older daemon's reply.

iOS

  • Keyboard: a downward swipe that starts on the focused editable text field or text view dismisses the keyboard anywhere in the app (one UISwipeGestureRecognizer per key window). New task scrolls its focused prompt row, or its focused workspace label field, above the keyboard, without animation, on each keyboard frame change and again once the form takes the keyboard's inset, its content height changes or its scroll offset moves while its scroll phase is idle, since after a rotation the frame change can arrive first, the prompt row can take its new height after the last scroll, and a scroll measured while the sheet still animates into its rotated frame can land last, each of which left the row under the navigation bar.
  • App switcher: when a scene enters the background, the app adds an opaque view in the system background color over each of the scene's windows, and removes it when the scene returns to the foreground, so the snapshot iOS stores for the app switcher shows no terminal, chat or file. An observer of UIScene.didEnterBackgroundNotification adds it synchronously, before iOS takes the snapshot; an overlay SwiftUI draws on a scenePhase change can come too late. The cover's layer has the highest z position, so a view the window gets later, as UIKit adds one for a sheet or an alert presented in the background, draws under it. Nothing covers the app while it is only inactive, since the Face ID sheet makes it inactive. No version bump: phone only.
  • New task warns under the agent picker, from the selected machine's last snapshot, when the selected agent's usage reaches 80%, orange from 80% and red from 90% like the Usage bars: Claude Code's fuller window (5-hour or weekly), Codex's monthly credits or a capped Copilot CLI seat's monthly premium usage. Like the Usage view, it leaves out a window past its reset and shows a stale reading's age (past 5 min for Claude Code, 10 min for Codex and Copilot). It never changes the agent or blocks Start. Debug builds take COLLIE_DEMO_PLAN_USED (a percent) for the UI tests. No version bump: phone only.
  • Only the app target links CollieCore (Rust + Go), whose Go runtime starts at image load (a __mod_init_func initializer), so the widget extension, the NSE and the watch targets stay pure Swift. The widget extension and the NSE share an App Group container (reachability hint, Live Activity state).
  • Keychain access groups: the items of the TLS key and the terminal key (dev.rbstp.collie.identity) and the relay state (dev.rbstp.collie.relay) name the app's own group in every query, $(AppIdentifierPrefix)dev.rbstp.collie, which the app holds through its application identifier and no extension holds. Info.plist's ColliePrivateKeychainGroup expands the name from the build setting, as CollieKeychainGroup does for the shared group, and a missing name stops the app instead of leaving the group out. A query that names no group writes to the first keychain-access-groups entry, dev.rbstp.collie.shared, which ColliePush and CollieWidgets hold too; only the notification keys are kept there, and NotificationKey names that group itself. Builds up to 0.2.3 named no group for the three items, which put them in the shared one. The builds after it moved each to the app's own group with one SecItemUpdate of the access group, a deliberate exception to the rule against migration code (owner, 2026-11-19, #805), and the move went once the owner's phone had run it (#869). The app now reads, writes and deletes these items in its own group only, and nothing in it names the shared group for them: a read answers that there is no item when its own group holds none, and fails for any other error (the Keychain is locked), so the app never makes a new key over one it could not reach. An install that went from 0.2.3 or older straight to a build without the move finds no item: it makes new keys and a new relay enrollment and pairs again, and the copies the old build left in the shared group stay there, unread and never deleted by the app. The relay state also has its installation marker, which nothing removes: under a marker whose item is gone or holds another installation, the store answers a fresh installation instead of failing at every launch, and it still fails for any other Keychain error (#880, relay.md). A build up to 0.2.3 still finds an item in the app's own group, since a query without a group searches every group the app holds. No version bump: phone-only storage.
  • Stored keys: the TLS key and the terminal key are Secure Enclave keys, which the app rebuilds from the blob in their Keychain item. A new key makes every machine refuse the phone until it is revoked there and paired again, so the app makes one only when no item is stored, or when the phone is unlocked and the enclave answers the rebuild with CryptoTokenKit's corruptedData (-3) carrying no AKSError. Apple documents no error of SecureEnclave.P256.Signing.PrivateKey(dataRepresentation:), so the rule rests on what macOS's CryptoKit links (CryptoTokenKit's TKClientTokenSession; the iOS binary was not read) and on Apple Developer Forums reports, and it keeps a key in doubt. In thread 748565, data that was no enclave blob (a Keychain persistent reference) gave that code with corrupted objectID detected and no AKSError; the post does not name the call, and the initializer is the likely one. In threads 124196 and 682162 the key store's own failures, a locked phone among them, gave the same code with an AKSError when signing. None of this was seen on the owner's phone. Every other failure may pass, so it keeps the item (EnclaveBlob): for the TLS key the app shows "collie could not start" with the error's domain and code, for the terminal key a shell's card shows them where its unlock fails, and both are logged. A blob can be dead while the enclave reports it another way (how it reports one the phone restored from its own backup after an erase is not known), and a Keychain item outlives a reinstall, so a kept TLS key would stop the app at every launch. That screen therefore offers Reset this phone's key, for a kept TLS key and for no other startup error: the owner's choice is the only other way a key is replaced. Behind a confirmation that names the cost, the app first rebuilds the key once more, because the error on the screen is as old as the process, which may have started while the phone was locked; only if the enclave still refuses does it delete the items of the TLS key and the terminal key, each by its exact group, service and account (EnclaveBlob.reset). The app delegate then replaces the app model with a new one, which starts as at launch and makes the keys again: the tailnet sign-in, the settings and the machines stay, and each machine refuses the phone until collied peers revoke and a new pairing there. A kept terminal key stops no launch, so it shows where a shell's unlock fails (#876). TerminalKey.publicKey and sign throw EnclaveBlob.Kept and answer nil for every other failure, as before. The core answers TerminalKeyMissing without a key as it does with another key than the paired one, and it has none while the app could not rebuild the stored one, so on that answer AgentModel rebuilds the key again: a kept key shows its cause, and a key that works by now goes to the core for one more challenge, so a failure that passed costs no pairing. The card then reads "This phone's terminal key could not be used:" with the cause's domain and code, in place of the pair-again notice, which pairing again could not clear while the item stays. The cause is on the card alone, never in the Face ID prompt or the confirmation. Unlock stays, as its icon alone, since the cause may pass, and beside it a struck-out key opens a confirmation that names the cost: "Shell terminals stop working on every machine until you pair each one again." Confirmed, TerminalKey.reset rebuilds the key once more and, only if the enclave still refuses, deletes the terminal key's item alone, by its exact group, service and account. The TLS key is not touched, so every machine still accepts the phone and a pairing without a revoke records the new terminal key. The model hands the key in use afterwards to the core (setTerminalKey), which the next pairing sends, and the next unlock shows the pair-again notice. Removing the phone's passcode also deletes that item. KeychainItem.write updates a stored item in place and adds one only when none is stored: a delete followed by an add that failed, because the phone locked in between, would leave no copy. The decision and the resets are unit-tested with injected rebuilds; the device code that calls the enclave runs only on a phone (#871).
  • UniFFI 0.32.2 bindings and the app compile in Swift 6 language mode. One xcframework holds one static library per slice (device, simulator): the Rust staticlib bundles the Go c-archive linked by tailscale-sys.
  • Terminal font: Ghostty's default, the files Ghostty embeds at the pinned libghostty-vt 1.0.1 release (tag vt-1.0.1, commit 108cacb17ed8990840cd14abfce43d8ed8503ca1; src/font/embedded.zig, fetched by build.zig.zon), bundled unmodified in the GhosttyTerminal package and loaded from data without registering them system-wide.
    • JetBrains Mono 2.304 (OFL 1.1, fonts/variable/ in https://deps.files.ghostty.org/JetBrainsMono-2.304.tar.gz, Zig hash N-V-__8AAIC5lwAVPJJzxnCAahSvZTIlG-HhtOvnM1uh-66x) draws text with its ligatures, at weight 400 and 700 for bold as Ghostty sets them: JetBrainsMono[wght].ttf 662a196d58f1183bf2d77428b6d5283fe3f45161ab021bea4036bc98e5cac016 and JetBrainsMono-Italic[wght].ttf f115aaa12113718c02ce72864fe6823b87241bc23d3e44cf1220155f861063f2. Ghostty's static faces are not bundled: its terminal never draws with them.
    • Symbols Nerd Font from Nerd Fonts 3.4.0 (MIT and its glyph sources' licenses, SymbolsNerdFont-Regular.ttf in https://deps.files.ghostty.org/NerdFontsSymbolsOnly-3.4.0.tar.gz, Zig hash N-V-__8AAMVLTABmYkLqhZPLXnMl-KyN38R8UVYqGrxqO26s) 71db104aa66567d0efe0b98758f9dfc1895573a453fe85fb53d1c38544a55106 comes first in each face's cascade list, for Nerd Font prompt and status-line glyphs. Glyphs neither font has fall back through CoreText's cascade (iOS picks Menlo for dingbats such as Claude Code's spinner, at one cell).
    • Placement, Nerd Font constraints and cell widths follow Ghostty at that commit (CellMetrics.placement; NerdConstraint, ported from src/font/Glyph.zig; constraintWidth in src/renderer/cell.zig); block elements stretch to the row, solid ones without antialiasing, so rows meet. scripts/ghostty/nerd-font-constraints.py generates NerdFontConstraints.swift from src/font/nerd_font_tables.zig; rerun it when the Ghostty pin moves. Unlike Ghostty, collie draws symbols without a constraint as the font places them, and cannot hold the last column to one cell or give two cells to every wide character: a snapshot cannot tell the last column from the last written one, and its runs carry no width.
    • App Store Connect runs Apple's FontValidator on every bundled font (TN3214); check new font files with /System/Library/Frameworks/ApplicationServices.framework/Frameworks/ATS.framework/Support/FontValidator -platform iOS -level strict -appleFonts <files> before shipping them.
  • Machine names: collie-core stores the name from collied's pair.complete reply as label in machines.json, never refreshed. rename_machine (a machine's context menu or its Machines detail) sets label to a trimmed name of 1 to 64 characters without control characters and keeps the pairing name in default_label, which a blank name, the default name, Reset or pairing again restores. The name stays on this phone: collied, the pairing and the machine ID are unchanged, and collied's alerts carry no machine name. A running Live Activity keeps its name.
  • Machine order: a phone-local list of paired machine IDs in machine-order.json, edited in Machines; new pairings are appended, removed machines pruned, offline machines keep their place. It orders the grouped Agents layouts, Usage and cross-machine agent-neighbor navigation, not per-machine agent sorting, drag preferences or the Inbox's ranking. No version bump: local Swift presentation and persistence, with no wire change or re-pairing.
  • Swiping between agents (the terminal's sideways swipe, while lines wrap) follows the layout the session opened from. Opening from the Agents tab or a deep link snapshots that layout's agent order, after the inbox's filter and search; swipes keep it while statuses change and skip agents closed since, except the current one. For an agent not in the snapshot (opened from a notification, Live Activity or New Task, or on a cold start before the first list), each swipe recomputes the order from the core's cache, without filter and search. Shell panes are never neighbors. No version bump: phone-only presentation.
  • CI's ios job keys the simulator xcframework, its Swift bindings and the app's Acknowledgements.json on the git hashes of everything they are made from (the crates the core links, libtailscale's pinned commit, the Rust and Go toolchains through rust-toolchain.toml and ci.yml, the notice inputs and Xcode's version). On a hit it restores them and skips Go, Rust, the cargo cache and both builds, which took about 11 minutes; the restore runs before the simulator boot, which slows every restore for minutes. On a miss the boot also waits for Go, Rust and the cargo cache to restore: twice SimLaunchHost crashed with SIGBUS while the cargo cache restored during the boot, and xcodebuild then ran the UI suite inside a second boot. On a miss it caches only the native build directories the simulator framework needs. Before the tests, the check the simulator step waits for a boot still in progress, and boots the simulator again and waits for it if it is no longer booted and its first boot has ended, so neither xcodebuild nor the suite starts inside a boot unless the step reaches its 10-minute timeout. On a native hit the boot starts seconds before the tests; when xcodebuild was left to wait for it, it stalled a median of 3.5 minutes, up to 8, before its first output (seconds on a miss, 45 s at most), and the UI suite's first launch hung for about three minutes in 3 of 32 such runs and in none of 54 others (#753). The Xcode build turns on Xcode's compilation cache (COMPILATION_CACHE_ENABLE_CACHING, through XCODE_XCCONFIG_FILE, so the TestFlight build never uses it), which keys each compile job on the content of its inputs, its arguments and the compiler: an unchanged module replays its stored results, and a changed one compiles again, along with every module whose imports changed with it. A cached DerivedData would not help, since a fresh checkout makes every source newer than its products. A pull request restores the newest ios-cas- entry it can see (target/ios/DerivedData/CompilationCache.noindex, about 270 MB compressed) before the simulator boot: restore-keys searches the pull request's own entries first, but the workflow never saves from a pull request, so in normal operation that is master's latest. A push to master builds without restoring it and saves a new one, so an entry holds a single build; once ios passes, the prune-compilation-cache job deletes master's older entries, which nothing reads, so they cannot push rarely read entries such as ios-sim- out of the repository's 10 GB of caches. On a native hit, a full hit compiles in about 1.3 minutes against about 7 without the cache; the rest of the native hit's wait is the simulator boot, now in check the simulator. The job runs just --no-deps test_iterations=2 ios-test never, skipping simulator failure diagnostics such as sysdiagnose, which can stall for ten minutes; Xcode's test results keep failures, logs and screenshots. The TestFlight workflow runs ios-test on-failure CollieUITests, which skips the UI tests: the unit tests only, since ci runs the UI suite on the pull request and on the push to master.
  • just ios-test runs the GhosttyTerminal tests on the simulator only, in the Collie scheme's test action, so one build serves the package's tests and the app's. swift test --package-path Collie/GhosttyTerminal runs the same tests on macOS without the 19 that need UIKit, in seconds, as a local loop.
  • UI tests launch the app once each. XCUIApplication.open(url) launches the app even when it runs, about 10 s on the hosted runner, so a test that starts on a session opens its link instead of calling launch (launch(onSession:)), and a later link goes to the running app with XCUIDevice.shared.system.open(url).
  • Test budget: after the tests, the ios job runs scripts/ios-test-budget.py measure, which reads the result bundle with xcresulttool and, on a pull request, fails when a value passes its ceiling in Collie/Tests/budget.json: the UI tests run, the app launches in the UI suite (each test's last run), the UI tests' summed time and the unit tests' summed time. A parameterized test counts every argument, and a test that passed on the retry leaves out its failed attempts (the table still names it, as it does a parameterized test whose failed argument passed on the retry, which Xcode keeps marked failed). The slowest UI test is reported but not enforced: one 60 s idle stall in a passing attempt would fail the job with no regression. The counts are exact, so a new UI test or launch raises its ceiling in the same pull request; the UI suite's ceiling sits 20% over the highest passing-attempt total of recent runs, which already spread from 783 to 884 s, and the unit tests' about 30% over master's last value. On a push to master it runs with --warn-only, which turns a passed ceiling into a warning: pull requests enforce the budget, and a slow runner on master leaves nothing to act on. It also names, as warnings, the tests that passed only on the retry, writes the table to the job summary and keeps the values as the ios-test-metrics artifact. Once a pull request's ci run ends, .github/workflows/ios-test-budget.yml comments that table on the pull request beside the values of the latest successful ci run on master that has the artifact, in one comment it updates in place (threat model).
  • CI and the TestFlight workflow set test_iterations=2, so xcodebuild reruns a failed app test once (-retry-tests-on-failure) and the run fails only when a test fails twice; the retry is for runner faults such as a launch that never returns, and a test that needs it is named in the budget table. A retried test still shows in the log as started (Iteration 1 of 2) and failed, then started (Iteration 2 of 2) and passed, and in the result bundle as a failed First Run and a passed Retry 1. A test that ends the runner gets no retry: xcodebuild relaunches it for the remaining tests only. XCTest ends the runner on a failure in an async setUp, tearDown or test method when continueAfterFailure is false, so UI tests stay synchronous. -test-repetition-relaunch-enabled YES would retry such a test, but it reruns the whole UI test bundle in a new runner for any failure. Local just ios-test keeps one iteration.
  • On a push to master, ci runs rust and ios by the same path lists as a pull request, over every commit of the push (github.event.before to github.sha), and runs every job when that range cannot be worked out: a first push, a rewritten branch or a missing commit. Each push to master has its own concurrency group, so a later push never cancels a run whose commits it would not test; the runs can then end in any order, and prune-compilation-cache deletes only the ios-cas- entries created before its own run's.

Apple Watch

  • CollieWatch (embedded under Collie.app/Watch) and its CollieWatchWidgets complication hold no keys, never link CollieCore and never talk to collied: everything goes through the phone over WatchConnectivity.
  • Phone to watch: updateApplicationContext(["state": WatchState JSON]) on a change, from the app's 1 s poll loop once each machine has a snapshot or is known down, and on going to the background (live false); a change to the agents alone goes out only while the watch app is reachable, at most once a minute. The state holds at most 5 unexpired approvals (with the command, the agent's reason, the output and the choices with their details, never Always allow or a nonce), at most 30 agents as in the inbox, the newest plan readings, whether watch decisions are allowed and the phone's accent resolved for dark mode (the color of working agents), with the agents' texts capped to fit. An approval's texts go whole, in the order the watch shows them (agent, place, command, reason, output, choices), under one bound of 4,096 UTF-8 bytes (WatchApproval.maxTextBytes): a permission prompt at every collied cap is about 3,600, and five approvals at the bound fit the context beside 30 agents, even where JSON doubles each byte. The first text past the bound is cut at an ellipsis on a whole character and nothing after it is sent, nor any choice past the ninth; the approval is then marked cut, which the watch shows read-only ("Too long for the watch. Answer it on the iPhone") and for which WatchApproval.offers is false, so the phone refuses its decisions too. The watch draws a menu's choices as buttons where it can answer the menu and lists them as text everywhere else (a permission prompt, a read-only or cut one), so every text sent is drawn. A background launch publishes only a refresh's answer, or the state a superseded decision leaves (Decisions, below).
  • Decisions: after deviceOwnerAuthenticationWithWristDetection (a fresh LAContext each time, its reason the decision, the workspace and the machine, never the agent's label), the watch sends sendMessage(["decide": {nodeId, approvalId, decision}]), which wakes the iPhone app. The phone (AppModel.decideFromWatch) re-reads watchDecisions from prefs.json on every request (off by default; turning it on needs deviceOwnerAuthentication) and decides only an unexpired approval, with an answer, from the last application context it sent, through the lock-screen path decide_from_notification, so the machine's nonce, expiry, replay and fingerprint checks apply unchanged. The reply {title, body, answered} carries the follow-up text and whether the watch can stop offering the approval (false when a later try can still decide it). A decision the phone refuses (WatchLink.refusal) is answered with state too, the last context it sent with the setting as read for that request, and answered false. The watch applies that state at once: an approval it does not list leaves the watch, which goes back to its list, and with the setting off the approvals stay, read-only. A decision collied answers superseded ended the approval there while the last context still lists it. Its reply carries that context without the approval (WatchLink.afterDecision, from the context as read after the decision, which can take 20 s), with answered false, and the phone sends it as the context too: the watch drops the approval at once, the phone refuses it from then on, and the approval that took its place arrives with the next state. A phone that has sent no context has no state to carry: its reply says refresh instead, and the watch asks for a refresh at once. Neither adds a listing to the decision, whose 20 s budget is unchanged (#857).
  • Refresh, sendMessage(["refresh": true]): sent when the watch app becomes active, opens from an alert or receives an approval alert while in front, and from a background app refresh scheduled 15 minutes ahead, which watchOS may delay or skip. Activation and background refreshes send at most once a minute after the phone answered, even if a Mac did not, since each refresh of a locked phone can take its full 15 s budget, so a returning Mac's approvals can arrive a minute late. The watch waits 25 s for the reply, 20 s in a background refresh.
    • A foreground phone publishes and answers with its state. Otherwise (AppModel.refreshForWatch) it calls collie-core approvals_in_background (15 s budget): the lock-screen path's node start and a pinned one-shot approval.list session per paired Mac, whose reply also carries the Mac's plan usage. New approvals replace the shown ones (a Mac that did not answer keeps its own); the newest plan usage replaces the shown one and that Mac's older cached plan, so the app's return does not publish the older plan. The agents stay as last shown, live is false, and the result goes out as the application context, which decisions check.
    • The reply is {state, silent}, silent naming the Macs that did not answer. Without a reply the watch keeps what it has; without a reply or with a silent Mac, it says it could not refresh. A failed updateApplicationContext leaves the state out of the reply.
  • Alerts: the watch app is the watch's UNUserNotificationCenter delegate and registers APPROVAL without actions. An alert carrying node_id and approval_id opens that approval after a refresh (read-only unless watch decisions are on); nothing decides from an alert.
  • Usage complication (CollieUsage): the watch app writes plan usage to watch-usage.json in its App Group container and reloads the complication, accessoryCircular rings and accessoryRectangular gauges, both linking to a details screen at collie-watch://usage. White ticks mark elapsed time, so fill past a tick means usage ahead of an even pace; the Codex and Copilot months start one calendar month before their reported reset, in UTC. An unlimited Copilot seat shows an empty track and "Unlimited". Antigravity quota buckets (up to 16, newest reading across machines) travel in the same WatchUsage payload and show in the watch app's Plan usage detail list only, not in the complication or widget.
    • UsageAgentsIntent (an AppIntentConfiguration) has three Bool parameters, Claude Code, Codex and Copilot, all on by default; an empty recommendations() lets watchOS 26 offer them wherever the owner edits the widget. Each placed widget shows only its chosen agents, or all three when all are off.
    • Each reading carries its own source timestamp, and a missing one counts as stale. Stale rectangular readings get an orange dot, missing or expired ones a dim "No data" gauge or dashed ring, and a reset dims its ring until fresh usage arrives. The last phone receipt time is stored separately, so old data never looks fresh.
    • Timeline: five-minute entries in one-hour batches plus stale transitions and resets, at most 19 per batch so watchOS never archives a full day of rectangular layouts; an empty or expired timeline retries after 15 minutes. Snapshots outside the widget gallery read cached usage; sample values are for previews only. Changed usage reloads the complication at once, unchanged usage or opening the app at most once a minute.

Client runtime

  • collie-core runs one connection supervisor per paired machine, each with its own backoff, request queue and link state, so a machine that is off affects only its own section.

    • Backoff 3, 4, 8, 16, 30, 60 s, reset after 30 s connected. While the phone's tailnet is offline it re-checks every 3 s, and at once when the node first reaches Running.
    • An auth failure stops the link until the next resume or manual retry. Only a known, wrong self identity is a self-ownership failure: a tagged self node, a user other than the paired owner, an own-address whois naming another node or user, or a self node with a positive user and StableID but no Tailscale address. A self node without a positive user or StableID, or a failing own-address whois (after a suspend, a restarted node answers "peer not found" from its netmap disk cache until control sends the live map), is retried like a failed status call.
    • A protocol version mismatch also stops the link, naming the side to update (collied sends its version in unsupported_protocol); requests fail at once with that message until the next resume or manual retry, so an update needs no new pairing.
    • A machine the netmap reports offline is Unavailable and not dialed, since a 20 s dial to a dead peer occupies the node all machines share. It is re-checked locally after 3, 6, 12, then every 15 s (every 3 s for 30 s after a resume, and from 3 s again after any other outcome), and dialed once online or every 15 min in case control is wrong. Pairing, lock-screen decisions and each resume or manual retry dial once regardless, since the netmap can be stale after a resume; an attempt that ends before the dial (failed status call, phone key not loaded) keeps that dial.
    • A session that receives nothing for 45 s (collied pings every 15 s) reconnects, so a machine that slept or lost power does not stay Connected.
    • Resume: after 10 s or more in the background the link reconnects at once (iOS suspends sockets without a close); a shorter gap gets a 3 s probe. A resume restarts the normal backoff and dials an Unavailable link at once. For 10 s after it, failures (the old session's close, a node rebuilding its paths or not yet running) retry after 0.5, 1, then 2 s, the link staying Connecting with no error; a failure from just before the resume is retried at once, and auth failures still stop. A snapshot request cut off by the reconnect answers from the cache.
  • Manual retry (reconnect(machine_id)): pull to refresh on the Agents list retries every machine, a tap on a machine's header that one. A live session gets the 3 s probe; any other link is dialed at once, past the offline flag.

  • Offline reason: a link that is not connected carries an OfflineReason on MachineFlock, the sentence under its pill, classified from what each attempt already reads, with no extra polling:

    LinkCauseThe reason says
    Offlinethe phone's node is not Running or not startedthe phone is not connected to Tailscale
    Unavailablethe netmap reports the machine offlinethe machine is asleep or off, last seen at its LastSeen when set (not Go's zero time)
    Waitingthe machine is online and the dial is refused (connection was refused) or times out (context deadline exceeded)collied is not answering: run collied start there
    Waitingany other dial error, including a dial forced past the offline flagthe phone cannot reach the machine

    TLS, pin, hello and version failures carry no reason and keep their own messages. The classifier reads libtailscale's error text, which a concurrent failure on the same node can replace (check_unlocked in the tailnet crate), so a reason can name another dial's cause, and a machine that just powered off can read as not answering until control marks it offline. The reason clears when the link moves back to Connecting. Debug terminal demos show these errors with COLLIE_DEMO_CONNECTION_ERROR.

  • The Agents tab reads the core's cache every 3 s (agent.status events keep it current), and every 0.25 s while a machine waits for a dial, its first list or, in the tab's first 20 s, the node. It asks connected machines for flock.snapshot when it appears, on pull to refresh, after a close and every 60 s, which covers shells (no event lists them). When reconcile first finds herdr unreachable, collied sends flock.changed; the refetch's herdr_unavailable stays on the link's view until a snapshot works, so the list shows the outage and asks again every 3 s.

  • Node recovery, for paths that died while the app was suspended: on cellular, carrier NATs silently drop idle UDP mappings and TCP state, so the home DERP connection looks open until its 120 s read deadline. On any network iOS can defunct the node's UDP sockets, ending wireguard-go's receive loop for them (health "The MagicSock function ReceiveIPv4 is not running"); a rebind replaces the sockets but not the loop, so only DERP works until a restart.

    • Rebind (tailscale_rebind) when no machine is connected 3 s after a resume from a suspend or 10 s or more in the background. Not sooner: a dial in flight during a rebind can stall for its whole 5 s attempt, and a healthy reconnect takes well under 3 s.
    • Restart when no machine has connected 10 s after the resume while the node reports Running and a machine still dialing or failing is online (or the node cannot report status), and on a manual retry while dials fail. The old node is closed once only dial attempts hold it (a lock-screen decide holds it until answered), which fails a dial in flight at once; a new node starts from the same state and every link redials, showing connecting rather than an error. Measured with the phone on the Mac's Wi-Fi: every reconnect that came at all did so within 7 s of the resume, rebind included, while a node the rebind did not help stayed unreachable until a restart or relaunch, which connected within seconds.
    • Immediate restart, without the rebind or the 10 s wait, of a node with the receive-loop warning: when a dial to a machine Tailscale reports online had already failed on it before the resume and nothing is connected, or when such a dial fails past the resume grace in the foreground. Measured on Wi-Fi: most resumes with the warning still connected within a second through DERP, but once a dial to the online Mac had failed, nothing connected until a restart, and with a 10 s wait on each resume a short visit never got there.
    • Queued requests wait for the new node. The old node is put back if a machine connects meanwhile (no session is cut) or the app is suspended (a waiting lock-screen decide then gets it at once); a restart of a node another restart already replaced does nothing. Holding the node-start lock, a restart hands a waiting lock-screen decide the new node and never lets two nodes share the state dir. A new node that cannot start is retried at once, then on the next resume or manual retry.
  • Network changes: the app reports the interface NWPathMonitor routes through (never a VPN tunnel; empty with no path) with network_changed, the first report only recorded. A move to another interface, or back after no path, that holds 1 s (paths flap at the edge of Wi-Fi) rebinds the node. A live session gets the 3 s probe, redialing only if it fails, since its TCP runs inside the node and can survive the move, but iOS reports no error when it does not. Other links redial past the offline flag with the resume grace. If nothing connects within 15 s (three dial attempts) while the node reports Running and a machine still dialing or failing is online, the node restarts as above; that check, like the 10 s one after a resume, is dropped once the path changed or a resume came, and restarts only the node its flow started with. A move reported while the core is suspended rebinds at once, for lock-screen decides; the redial waits for the resume. A Wi-Fi network replaced by another on the same interface without a gap is not a move.

  • Diagnostics: each resume logs one line (subsystem dev.rbstp.collie, category core) with the node's state and health warnings and, per machine, the link phase, last dial, last error and netmap online state. Path changes, rebinds and restarts are logged with reason, outcome and timings. No keys, tokens or nonces. These lines are public in the device log and carry text a machine chose, its label and its last error; so do the app's own lines for a lock-screen or watch decision's outcome and for an approval that did not open. collie-core therefore keeps only the first 200 characters, without control or format characters, of the error that becomes a link's last error or such a decision's outcome, and names a frame that does not parse by serde's category, line and column, never by serde's message, which quotes the frame. The error a request returns to the screen that made it keeps the machine's whole message (threat model).

  • Snapshot plus sequence: flock.snapshot returns the seq it reflects; every event frame carries seq; the client drops seq <= last applied; unknown events still advance the cursor. collie-core keeps the first agent of each terminal id in a snapshot (threat model).

    • Replay queue: collie-core keeps the list events it applied since the last snapshot (agent.status, approval.needed, approval.resolved, plan.usage) and replays those past a snapshot's seq onto it, so a snapshot that answers late erases nothing. The queue takes 1024 events and 4 MiB of frames. An event it has no room for is not applied: collie-core asks for a snapshot instead, and asks again while the snapshot it gets is older than that event. A snapshot is one frame of at most 4 MiB, so the list the phone holds for a machine is at most one snapshot and 4 MiB of events, whatever the machine sends.
    • The machine's name in the answer to pair.complete must be a label (1 to 64 characters, no control or format character), as a rename's must: it is the name the app stores, shows and logs. Otherwise the pairing fails on the phone.
    • No version bump: no wire type changed.
  • Mutations are never replayed automatically, except a prompt to an unreachable machine: up to 5 attempts a minute apart (at once when the link reconnects while its agent screen is open), none later than 270 s after the first.

    • The app holds one such prompt per agent, in memory only: resends outlive the screen but not the app process or the machine's removal. Editing it, tapping its spinner, the agent exiting or another prompt from that screen stops it (the new one waits for any attempt in flight). A prompt that never arrived and that no screen shows returns to the agent's saved draft with a one-time "may not have been sent" note. Not detected: a new agent started in the same pane before the resend would receive it.
    • Each retry is resend_prompt, which collie-core sends only under the op_id an unanswered identical prompt still holds (300 s of wall time from its first send; collie-core reports Unreachable only while it holds it), and otherwise refuses with NotResent; only the user's Send mints an op_id. collied replays an attempt that arrived instead of typing the prompt twice, but its outcome cache lives in memory for 600 s, so a collied restart forgets the op_id. Before each retry the phone therefore treats the prompt as sent when the agent's last prompt, read with the link up, changed to its first line.
  • Lock-screen approve and deny over an authenticated tailnet session (Lock-screen approval) has no prior art, and its timings still need measuring on device.

Risks

RiskImpactMitigation
libtailscale has no git tags and lags tailscale.com releasessecurity updates can be ours to carrypin SHA + patch series; track upstream (0.2.0 at dacde75)
Peer attribution race in getremoteaddr (fixed upstream in 0.2.0)wrong peer authorizedtailscale_accept_with_addr (patch 0002); never call getremoteaddr
Go runtime size~20 MB per binary (iOS stripped), ~25 MB colliedmeasure per slice; Go archives built with -w
Cold start in a background launchApprove from lock screen failstsnet state cached, node started from cache (never a login), 20 s budget, follow-up local notification on every outcome; measure on device
Suspend/resume leaves stale DERP/magicsock stateslow reconnectsredial, rebind and node restart on resume (Client runtime)
Wi-Fi to cellular leaves the node bound to the old interfaceno reconnect until a relaunchNWPathMonitor drives a rebind with a netmon refresh, redials and a node restart (Client runtime)
herdr server load (status entry polls pane.get every 100 ms)CPU with many panesmeasure; fall back to agent.list polling if needed
UniFFI + Swift 6build frictionbindings compile in Swift 6 language mode; no async foreign traits on hot paths
APNs .p8 is team wideleak allows pushes to every app on the teamrevocable key per machine; on macOS a Keychain item whose ACL trusts only the Developer ID signed collied; on Linux a systemd user credential any same-UID process can decrypt; no nonce in the payload (threat-model.md)
APNs payload transits Appleproject names exposedalert and Live Activity display content (initial, update, end) is authenticated ciphertext; generic text, opaque IDs, urgency, lifecycle, timing and size stay visible; nonces and decisions stay on the tailnet
Answering a blocked prompt outside approvalsbypasses nonce/expirycollied refuses prompts while blocked; keys and typed answers reach a blocked agent only over the paired session, authorization re-checked before each write; audited
Prompt delivered after agent exitprompt runs as a shell commandforeground check before send; conditional input in herdr upstream
Retried mutationsduplicate prompts/tasksop_id outcome cache
A paired phone writes files on the Macdisk use, files an agent may readsize, rate, in-flight, 200 MiB and 1000 entry caps; private 0600 non-executable files in a 0700 cache dir; 24 h retention (threat-model.md)
Older app vs newer collieddecode failuresadditive events, errors and statuses decode to Unrecognized; anything else bumps PROTOCOL_VERSION
Shell input from a paired phonecommand execution as the useroff by default, collied.toml only; its own method class; a grant signed by a Secure Enclave key behind Face ID, per terminal, session and 5 minutes; pane re-read before every write; audited without the text (threat-model.md)

Release sample workspace

Welcome and Settings open a clearly labeled, bundled sample workspace, in Release builds too. Its synthetic in-memory core implements the agent and approval interfaces with no daemon, relay, pairing or network client; prompts, terminal input and decisions append visible local results. Reset replaces the sample session; Exit dismisses it. Its authenticator is private to the view that builds this core; real approvals keep device-owner authentication. The sample creates no Live Activities or push registrations, disables New task, and never persists or prunes real preferences, drafts, viewed changes, inbox markers, snoozes or layout order. Arbitrary fixture files, developer launch flags and screenshot environment overrides stay Debug-only. No version bump: the sample uses no wire protocol.

Desktop distribution

Desktop releases (collied for macOS and Linux, CollieBar, CollieTray) share the TestFlight version tag and exact source commit. TestFlight, or a protected manual run, dispatches the desktop workflow from master, as the master-only signing environment requires. One publisher owns each release: it rejects moved tags and mismatched source markers, keeps already uploaded signed packages when a draft is retried, and verifies a completed release without replacing its assets.

The publisher and the installer check the macOS daemon's strict signature and notarization online. The installer, which only the user runs, copies the daemon to ~/.cargo/bin/collied and changes only the executable of an existing launchd plist or systemd unit; Linux packages may own /usr/bin/collied instead. Package operations run no root hooks against user homes or sessions. Desktop release downloads covers assets, platform floors, installation, AUR adoption, release controls and validation. No protocol change or version bump.

Push relay

The Worker and D1 implementation under relay/ provides a bounded authenticated send contract, fixed topics, deterministic provider JWTs and atomic indexed installation and global quotas. Released builds deliver through the production relay, whose hourly Cron trigger runs its bounded retention cleanup. relay.md has the contract, local measurements and retention bound. No version bump: no phone or daemon wire type changes.

Attested push control validation

The relay authenticates installation enrollment with Apple App Attest, and later operations with assertions over a stateless five-minute HMAC challenge bound to the operation, exact destination, pairing, installation, environment and prior counter and epoch. One D1 transaction advances the replay and control counters and changes routes; a conditional zero-row update alone never authorizes a route. Every send checks registered generations and revocation epochs, and an APNs expired or unregistered destination revokes only the matching generation and destination. The phone enrolls only for a paired daemon that reports relay mode through the negotiated capabilities, so direct senders never trigger enrollment. relay.md has the contract, the client's rules, limits, renewal and retention. No version bump: optional relay_grant registration fields are sent only with the implemented relay_grants_v1 and encrypted_display_v1 capabilities, the optional server-to-phone hello push_mode is omitted without relay negotiation, revision 26 remains the codec, and older peers never receive new request fields.

The isolated Free-plan benchmark failed the CPU gate for full App Attest verification, so production runs on Workers Paid with the single internal crypto actor and a provisional shared 250 ms CPU ceiling (validation report).

Internal relay crypto prototype

Apple verification and APNs signing run in one internal SQLite Durable Object, with no public HTTP handler, separate from the public HTTP policy and D1 state (relay.md). Missing or exhausted compute fails closed, with no inline fallback. Shared per-location control and enrollment admission limits repeated verification from rotating sources but is not a global spending cap, and local real-actor tests do not establish deployed Free-plan viability. No version bump: the public relay and phone-daemon wire contracts are unchanged.

Simulator relay isolation

The local Simulator relay (simulator.md) provisions a software P-256 identity into a private local D1 and a DEBUG Simulator container, through a separate entry that refuses enrollment and fixes sandbox APNs. Everything after it uses the production validators and, in a Miniflare harness, the production RelayCrypto class. Production has no local key, local send secret, synthetic enrollment verifier or unsupported-attestation fallback; its Worker graph excludes relay/dev, and a separately seeded development database never counts as evidence of production trust. Only DEBUG Simulator builds include the Swift identity import, mock destinations and the exact loopback ATS exception, and only debug-assertion builds include the daemon's loopback sender switch; Release uses the fixed HTTPS publisher endpoint. No protocol change or version bump.

Isolated VM and Simulator tailnet

The VM procedure runs the Debug daemon in an owned macOS guest and the Debug iOS Simulator on the host. An account-free testcontrol server, DERP relay and mock publisher on host loopback reach guest loopback ports 8788 to 8790 through task-key SSH reverse forwards; each side runs its own STUN server on 8791. No owner Tailscale account, APNs key, home directory or Keychain enters the guest.

COLLIE_VM_TEST=1 works only in Debug macOS and Debug iOS Simulator Rust builds. It requires a private collie-vm-test directory and a bounded private, non-symlink vm-tailnet.json with a synthetic test auth key, fixes the control URL at http://127.0.0.1:8789, and selects a separate data directory, state folder and Keychain namespace. The Simulator checks the Debug capability symbol before initialization, so a Release-profile core fails closed. Pairing pins, mutual TLS, owner checks, registration and relay proofs run their normal code, and the harness confirms only its expected candidate at the daemon's ordinary prompt. Release and physical-device artifacts exclude the test entry. No protocol change or version bump.