Why Collie is shaped the way it is. The deployment model, the interaction loop, and especially the security posture — the reasoning the code can't state itself. This describes what is built; a few deliberate non-decisions are called out as such, and §8 parks ideas that are not built on purpose. For how to run it see
README.md; for repo conventionsCLAUDE.md; for the verified socket contractHERDR_API.md; for the multiplexer seamMUX_CONTRACT.md; for the lead↔peer wireCREW_PROTOCOL.md.
The route Collie replaces: Termux on Android → SSH into a tailnet machine → run the Herdr TUI. Three pains:
- The on-screen terminal keyboard is terrible to type on.
- No voice control in a terminal.
- Re-SSHing / re-logging-in every time is tedious.
The goal: a mobile web interface, reachable over Tailscale, that you don't have to keep logging into — so you can check on and steer your agent herd from a phone with the native keyboard and voice, no SSH.
A collie — a long-lived local process that
- drives one terminal multiplexer through the mux port (
bridge/mux/, §5) — Herdr's Unix-socket API ($HERDR_SOCKET_PATH) by default, tmux or zellij by configuration, - serves a mobile-first web app, with live state polled over HTTP (see §5),
- translates browser actions → socket methods,
- sits behind one hardened front door —
tailscale serve(default; tailnet-only HTTPS + MagicDNS) or a conforming reverse proxy (docs/deployment.md → Variant C) — installable as a PWA.
The browser never touches the multiplexer directly; the bridge is the only thing that does.
phone / laptop (PWA)
│ HTTPS over tailnet (https://herd.<tailnet>.ts.net)
▼
tailscale serve ── injects identity headers, terminates TLS (Variant C: a reverse proxy instead)
│ 127.0.0.1:PORT (bridge binds loopback ONLY)
▼
Collie (this project)
• static web app + small JSON API (browser polls /api/snapshot)
• mux port (bridge/mux/ — the ONLY code that knows a multiplexer's verbs)
• snapshot poll, event-poked (see §5)
│ the driver's own transport
▼
Herdr / tmux / zellij (owns panes, agents, state)
Every operator verb is bin/collie <verb>, implemented once in cli/ — pairing, serving, crews,
speech-to-text, build and update. scripts/collie-ctl.sh is a frozen bootstrap shim that compiles
the binary and execs it; it implements nothing
(ADR 0006).
Everything above describes one machine. A crew is several machines each running a full collie, one
of which — the lead — holds the front door the phone talks to. A crew of one is today's install
exactly, and pays no tax for the feature (CREW_PROTOCOL.md §11).
phone / laptop (PWA)
│ HTTPS /api/* (the phone talks to the lead and to NOTHING else)
▼
lead collie ── managed front door, serves the PWA
│ /crew/v1/* ── pinned mutual TLS + crew secret, lead dials outbound
├──────────────▶ peer collie (no front door; its own mux, journal, uploads, audit)
└──────────────▶ deputy collie (a peer, plus a warrant naming it)
╎ standby door: bound, never published, three routes
operator ─ ssh ─▶ every member ← code rides HERE, never the crew link
- The lead consumes a peer's Collie HTTP API. It never dials a peer's multiplexer across a
machine boundary, and no Herdr (or tmux, or zellij) verb ever crosses the link — that is the
mux-driver seam (ADR 0144). What crosses
is Collie's own domain model: snapshots, pane grids, replies, history, uploads. What never crosses:
software.
collie crew add/crew updatepush a git bundle over the operator's own ssh (ADR 0144), so the link is never a distribution channel. A peer may also level itself to the release its lead is running, taking that public tag from GitHub over anonymous HTTPS on its own decision (ADR 0143,CREW_PROTOCOL.md§20); still no code, route or verb on the link. - Two independent factors gate
/crew/v1/*, before any handler runs: pinned mutual TLS and the crew secret (CREW_PROTOCOL.md§8). Neither browser gate of §6 applies there, and a peer publishes nothing — its listener is a path prefix on its own bind, not a front door (ADR 0013). - The deputy is named ahead of time, never elected. The operator names one peer while the crew is
healthy and the lead signs a warrant saying so; a higher generation supersedes it everywhere it
lands, and revocation is generation N+1 naming nobody. Nothing infers a dead lead from silence —
the operator is the quorum (ADR 0026 ·
ADR 0144 ·
CREW_PROTOCOL.md§18). - The standby door is a second listener that arms on silence and is spent by the operator. It
binds
COLLIE_STANDBY_PORT(absent ⇒ no door), serves three routes and404s everything else, and arms only while a verified warrant names this machine, the lead has been silent past a threshold, and a synced pairing registry is non-empty. Arming grants nothing: the takeover is confirmed with the phone's own pairing credential (ADR 0144 ·CREW_PROTOCOL.md§18.15).
This is the clearest call in the design. A plugin pane runs inside a terminal pane: if the pane closes, the user detaches, or Herdr restarts, the bridge dies — exactly when you're on mobile and not watching the TUI. A long-lived network daemon must be supervised independently.
- The bridge runs as a
systemd --userservice (launchd agent on macOS) — starts at login, restarts on failure, survives Herdr restarts. - The Herdr plugin stays — as a thin registration/launcher, so Collie shows up in
herdr plugin listand Herdr conventions still apply. Its[[actions]]are frozen command strings that hand a verb toscripts/collie-ctl.sh, whichexecs the compiledbin/collie— start, stop, update, print the tailnet URL; they do not host the server. A[[build]]step builds the web UI onherdr plugin install(GitHub); locallinkinstalls skip it and build lazily on firststart. Concretely that's[[actions]]+[[build]]and nothing else:[[panes]]is what this section argues against, and[[events]]would duplicate the bridge's ownevents.subscribestream (§5). - The checkout on disk is the plugin — in one of two shapes.
herdr plugin installdoes not clone: itgit inits,git fetch --depth 1 origin HEADs andgit checkout --detach FETCH_HEADs into~/.config/herdr/plugins/github/<hashed-id>, so a turnkey install is detached and shallow with no remote-tracking refs, while a linked clone sits on a branch. Theupdateaction carries both (ADR 0143) because Herdr has noplugin updateof its own — its refresh is a reinstall, which replaces the checkout but does not restart the service. - Endpoint discovery is per driver. A non-Herdr-launched daemon won't get
$HERDR_SOCKET_PATHinjected, so the Herdr driver resolves the path from a well-known location (~/.config/herdr/herdr.sockdefault, or the bridge's own config) and re-resolves on reconnect in case it moves. The other drivers takeCOLLIE_MUX_ENDPOINT_<NAME>in their own words — a tmux server socket, a zellij session name (MUX_CONTRACT.md→ Pointing a collie at a multiplexer). A unit file that dropsXDG_RUNTIME_DIRbreaks zellij discovery; the same file is where a plugin action's minimal environment bites.
Deliberately not full terminal mirroring. The loop:
agent goes blocked
→ PUSH notification (which agent, which workspace — see the gap below)
→ tap → app opens to that agent
→ the pane, with recognised prompts parsed into tappable blocks
(prompt-select · preview-select · wizard) ← structured, not a raw screenful
→ reply: plain text box (the phone keyboard's own dictation works in it;
an in-app mic appears only after `collie stt setup`)
+ quick actions + a special-key strip
→ explicit Send button → typeText + Enter, verified
→ "Sent ✓" + card flips blocked → working ("did it land?" confirmation)
Product details that shaped the loop:
- Don't show a raw screenful. A "last screenful" is often a mid-stack-trace — the actual
question is lines above. Collie parses recognised prompts out of the pane text into interactive
blocks (
web/src/lib/blocks.ts), so answering a permission dialog or a menu is a tap, not a transcription exercise. The raw pane stays below for context.- Where this stops short of the design. The original intent was for the bridge to capture the
output chunk at the moment Herdr says an agent went blocked, and hand the client a structured
BlockingMessage. That was never built: parsing is client-side and pattern-based, over whatever the current pane happens to show. It works because agent prompts are formulaic, and it degrades to "read the pane" when they aren't.
- Where this stops short of the design. The original intent was for the bridge to capture the
output chunk at the moment Herdr says an agent went blocked, and hand the client a structured
- Dictation needs zero special build; the in-app mic is opt-in. The reply box is a plain text
field, so the phone keyboard's own mic works in it with nothing built, and Send stays an explicit
button — dictated text is reviewable before it goes. Beyond that,
collie stt setupswitches on Collie's own record button through a provider seam (bridge/stt/, CLIcli/stt.ts, docs/voice-and-push.md → Voice input). The seam is absent until that verb runs: no key, no outbound path, no child process, no button. Turning it on is what buys the credential in the state dir and the outbound path carrying microphone audio — a local engine keeps that egress on loopback, and hands-free sends go through the same guarded reply path a typed reply takes (ADR 0029). A fourth provider,whistle, is Collie's own code: a vendored WebAssembly engine and a 16.9 MB model that the host fetches once on a tap orcollie stt whistle. It runs in two places, chosen per device. The Host engine runs it in a short-lived child of Collie's binary and takes a 16 kHz WAV upload. The This phone engine runs it in a worker with its own CSP, with no upload at all (ADR 0096). - Quick replies are heuristics, not guarantees. Different agents expect different input (a Y/n prompt vs a numbered menu vs an approval phrase), so there is always a "send exactly what I type" fallback.
- Opinionated triage, without moving anything. The home screen leads with one summary line that
counts what needs you and jumps to it; every pane stays where it sits, in the multiplexer's own
order, and urgency is a mark on the row, never a position
(ADR 0147). The one exception is the
large-screen dashboard, where a band above the grid repeats the sessions that need you and no row leaves
its place (ADR 0158). Simultaneous blocks
batch into one summary notification, not three races. The split rests on the
agentDetectioncapability: a driver that cannot tell an agent from a shell says so, and the screen is panes rather than a triage it would have to invent. - Close the trust loop. A "Sent" state on the
POST's HTTP response, then the visible blocked→working transition. Without it, latency makes users double-tap. - Manage a pane in place. Long-pressing a pane pill in the tab's pane switcher opens a small
actions sheet — rename it (the label then leads its cards/headers), close it, or show it in the
operator's own terminal. All three are declared capabilities (
renamePane,closePane,setFocus), greyed out where a driver declines them, and all three are writes the security posture already covers (web/src/components/pane-actions-sheet.tsx). Moving the operator's terminal happens on that one named tap and never as a side effect of navigation (ADR 0031).
Known gap — the notification body doesn't carry the question. The design called for putting the
agent's question in the notification, so a tap is actionable even before the app loads (§7 explains
why that matters on Android). What ships identifies which agent needs you — title <agent> <verb>, body <workspace> · <cwd> (bridge/notifications.ts) — and you read the question in the
app. Closing this needs the server-side blocking-message capture described above.
The shape of one collie, end to end — the ASCII sketches in §2 stay the precise ones; this is the overview the rest of this section fills in.
graph TD
subgraph phone["The phone"]
pwa["PWA — the mobile web app, installed to the home screen"]
end
subgraph door["One hardened front door"]
serve["tailscale serve — tailnet-only HTTPS (or a conforming reverse proxy)"]
end
subgraph collie["The collie — one long-lived local process, bound to 127.0.0.1 only"]
api["static web app + small JSON API"]
muxport["mux port (bridge/mux/) — the only code that knows a multiplexer's verbs"]
journal["journal adapters (bridge/journal/) — one per harness"]
end
subgraph mplex["The multiplexer — exactly one per install (COLLIE_MUX)"]
herdr["Herdr driver"]
tmuxd["tmux driver"]
zellijd["zellij driver"]
panes["the agents' terminal panes"]
end
logs[("the agents' own session logs, on this machine's disk")]
beacons[("beacons — written by the agent's own hooks")]
pwa -->|"HTTPS over the tailnet, polls /api/snapshot"| serve
serve -->|"127.0.0.1:PORT — the browser never reaches further"| api
api -->|"snapshot poll, event-poked"| muxport
api -->|"/api/pane/:id/history"| journal
muxport -->|"registry.ts loads exactly one driver"| herdr
muxport --> tmuxd
muxport --> zellijd
herdr -->|"JSON-RPC over the Herdr socket"| panes
tmuxd -->|"capture-pane"| panes
zellijd -->|"dump-screen --ansi"| panes
panes -.->|"the harness writes its own turns"| logs
journal -->|"reads the transcript off local disk, never the screen"| logs
panes -.->|"collie beacon emit, from the agent's hooks"| beacons
beacons -.->|"which pane holds an agent, and its session key"| tmuxd
beacons -.-> zellijd
-
bridge/mux/is a port with three drivers, and nothing above it knows which one is loaded. The port is Collie's own contract (types.ts), not Herdr's shape renamed (ADR 0022); the drivers areherdr/,tmux/andzellij/, andregistry.tsis the one placeCOLLIE_MUXbecomes an adapter. A driver is the only code that knows its multiplexer's verbs (pane.read,capture-pane -p -e,dump-screen --ansi, …) and it translates to/from the internal domain model (AgentStatus,AgentView,SnapshotResponse—bridge/types.ts), so a Herdr API rename is a one-driver fix.- Each driver declares what it can do (
capabilities.ts) and the declaration is fail-closed: an unprobed cell is never declared supported. The UI asks the capability, never the multiplexer's name —setFocus,gridScrollback,createSpaceand the rest are read out of/api/config(web/src/lib/mux-capability.ts).unsupportedis a refusal shape the UI explains, not an error. - Freshness, focus and shape are declared promises, not folklore
(ADR 0031):
topologyLatencysayspushorbounded {ms}— a ceiling, so the phone can say "synced Ns ago" and offerPOST /api/refresh(a read: it mutates nothing);MuxPane.focusedmeans exactly the pane the operator's own terminal is showing, and moving it is the separatesetFocuscapability behind one named tap, never a side effect of navigation;spaces: "one" | "many"is why zellij renders no space strip. - A shared conformance suite (
conformance.ts, run per driver) holds every adapter to the contract's floor and to its own declaration. The capability matrix, with the probe behind each cell, isMUX_CONTRACT.md; adding a driver isMUX_CONTRIBUTING.md.
- Each driver declares what it can do (
-
One protocol, two dialers (the Herdr driver's transport). Herdr's control socket is AF_UNIX on Linux/macOS and a named pipe on Windows (named after the full socket path).
bridge/dial.tsis the only place that knows the difference:Bun.connect({unix})on POSIX,node:neton Windows. The wire protocol is identical — theinterprocesscrate Herdr uses inserts no framing or metadata, so the same newline-delimited JSON-RPC speaks to both, streamingevents.subscribeincluded.COLLIE_HERDR_DIAL=netforces the Windows dialer anywhere, which is how that branch stays tested off Windows. -
Output model: poll, not stream — event-poked. The port's floor is
snapshot()pluswatch()("tell me to look again"); whether a driver keepswatch()by a push or a census is whatpushTopologyEvents/pushPaneEventsdeclare, andbridge/event-poker.tsconsumes the declaration rather than the name. Herdr, the default driver, exposespane.read(snapshot) andpane.output_matched(regex event) but no raw output-stream event, so there is nothing to stream even if we wanted to; the live pane view is poll-on-status-change + caching. Its poll tickssession.snapshot— one RPC returning every workspace/tab/pane/agent/ layout — falling back to theworkspace.list+pane.list(+tab.list) trio on older servers (full contract inHERDR_API.md). A long-livedevents.subscribestream runs alongside purely to poke that poll: lifecycle events plus a per-agent-panepane.agent_status_changedsubscription trigger an immediate debounced re-poll, while the interval relaxes toCOLLIE_POLL_IDLE_MS(12 s default) whenever the stream is healthy and drops back to the fastCOLLIE_POLL_MSwhen it isn't. The snapshot poll stays the source of truth throughout — a missed event costs one interval, never correctness. Some changes come with no event at all: Herdr announces nothing when an agent reports its session (measured on 0.9.3). So two INTENTS tighten the same interval toCOLLIE_POLL_MSforHOT_POLLS(8) polls and then let it relax: an input landed on a pane through/replyor/keys(on the member that owns the pane, and on a lead that forwarded it, whose sweep rides this tick), and a pane that has just become an agent with no session yet, whose hold also ends the moment its session is seen (bridge/state-engine.ts§ noteInput, § noteNewAgents). No second timer, and the hot spell decays by counted polls, never by a deadline. -
Scrollback comes from the transcript, not the terminal. An agent's TUI runs on the alternate screen (
ESC[?1049h), so the emulator keeps no scrollback ring and a grid read can never return more than the visible viewport — the live mirror physically cannot scroll back past it. (Screen scrollback, where a driver has it, is its own capability —gridScrollback— and it is untyped screen text, never the agent's turns.) Pane history is therefore read from the agent's own transcript file off disk (bridge/journal/,/api/pane/:id/history), a separate source from the mirror with different fidelity: turns and their text, not a replay of the screen. Each harness writes a different log in a different place, so this is a per-agent adapter (bridge/journal/registry.tsmaps the pane'sagentto one); a harness with no adapter simply has no journal. A harness can have several roots — one machine routinely holds more than one agent home (CLAUDE_CONFIG_DIRper Claude profile), so eachCOLLIE_*_ROOTtakes a comma-separated list, searched in order until a root holds the session id; ids are globally unique, so that's a lookup, not a preference. Containment is checked per root, never against their union. The client fetches the whole conversation in one request and renders a window that grows upward, which is what lets find-in-history and jump-to-user-turn work across turns you haven't scrolled to. Rationale and the measured numbers are commented at the top ofweb/src/routes/history.tsx.- The same source also repairs the pane view in place. A reply longer than the pane is tall
reaches the mirror with its opening already scrolled off, and leaving for the history route to
read it is a heavy answer to a small question. So the pane view reads the newest turn from the
journal and, when
web/src/lib/latest-reply.tssays that turn IS the one on screen and its start is missing, renders it in full in place of the rows it covers —locateReplyreturns where those rows end andAnsiOutput'shideLeadingLinestakes them off the top, so the message is never printed twice and the mirror below it (tool calls, a dialog, the cursor) is untouched. Both probes fold the two texts to letters and digits only, which is what makes Markdown source comparable to a hard-wrapped, SGR-coloured render; the tail probe is an identity check, and its failure (a streaming reply, a stale read) means show nothing. The hiding is render-only and runs after every grammar, so no detector, guard or draft probe can see it; find restores the whole mirror, since find can only highlight there. One journal read per finished message, off the poll path (web/src/hooks/use-latest-reply.ts), and switchable off in ⚙ View.
- The same source also repairs the pane view in place. A reply longer than the pane is tall
reaches the mirror with its opening already scrolled off, and leaving for the history route to
read it is a heavy answer to a small question. So the pane view reads the newest turn from the
journal and, when
-
The browser polls too.
useRevalidator→/api/snapshoton an adaptive interval. There is no WebSocket fan-out to the browser and no push of state; pulling is what makes the two recovery loops below trivial. A snapshot poll that got no answer at all is retried on a short backoff (0.5, 1, 2, 4 s, never slower than the normal gap); a poll that got any answer, a 5xx included, keeps the gap. -
Two independent recovery loops, designed in from the start (not retrofitted):
- bridge ↔ multiplexer: the snapshot poll doubles as resync — a failed tick marks the herd
disconnected (the UI's connection bar names the multiplexer that went away) and keeps retrying;
the driver's
watch()reconnects with backoff and re-subscribes, and since it only pokes the poll, a dropped watch costs latency, never correctness. A transport that died mid-call answersunreachable, neverrefused— that distinction is the contract's, not each driver's. A write, a key or a create whose request already went out answersunconfirmedinstead (MUX_CONTRACT.md). - browser ↔ bridge: polling makes reconnect trivial — failed polls surface in the connection bar / offline banner, and the next successful poll heals the UI. No socket lifecycle to manage.
- bridge ↔ multiplexer: the snapshot poll doubles as resync — a failed tick marks the herd
disconnected (the UI's connection bar names the multiplexer that went away) and keeps retrying;
the driver's
-
Polling moots per-client backpressure. A push design would need
bufferedAmountwatching so a slow phone couldn't OOM the bridge. Each client instead fetches a bounded snapshot at its own pace, so there is nothing to buffer or coalesce. -
Render the pane grid safely (see §6): strip ANSI server-side to plain text and render it as React text nodes; never
innerHTMLraw terminal output. -
PWA cache-busting. Service workers serve stale clients after an update, so the build stamp travels in every response (
X-Collie-Buildheader +/api/config); on mismatch the footer offers "new build — tap to update." -
The operator's slash-command rows ride
/api/configtoo, read from theircommands.tomlbehind an mtime check (bridge/operator-commands.ts), so editing the file is live like a web rebuild. On a pane they address they replace the shipped catalog rather than merging into it — ADR 0018. Their Keys-tray presets ride the same request on the same terms, fromkeys.toml(bridge/operator-keys.ts), and their Quick-dock groups fromquick-replies.toml(bridge/operator-quick-replies.ts); the three share one reader (bridge/operator-file.ts) and one scope ladder (web/src/lib/operator-scope.ts). Their launcher rows, fromlaunchers.toml(bridge/operator-launchers.ts), share the reader but NOT/api/config: a launcher row creates its own pane rather than addressing an existing one, so it carries no scope, and its rows ride their own session-scopedGET /api/launchersinstead. The lead's merged rows are the crew's (ADR 0145): the lead offers them for every host and each row is checked on the host that runs it (not_found,no_folder). A launch of a lead row on a member carries the row over the crew link (row), which a member accepts only from its lead; adds are answered on the lead; the deputy keeps a read-only copy (CREW_PROTOCOL.md §5, §18.14). -
UI strings are translated by a typed dictionary, not a library (
web/src/lib/i18n/, six locales, English the compile-time source of truth) —t()/tn()plus theuseLocale()hook (web/src/hooks/use-locale.ts), lazy per-locale chunks with an English fallback while one loads. The bridge answers every refusal with a stablecode— plus an optionaldetailcarrying the machine half (the multiplexer's own words, a limit, a reason) — frombridge/error-codes.ts, mirrored atweb/src/lib/api-error-codes.tsbecause the two trees cannot import each other; a drift test (bridge/error-codes.test.ts) fails the build if the two catalogues disagree. The phone translates the code and falls back to the bridge's own English sentence for one it doesn't know (ADR 0030).
Driving a multiplexer equals arbitrary code execution on the host — typeText / sendKeys type
into live terminals, whichever driver is loaded. The posture is single-user, behind one hardened front
door (tailnet-only by default; one per crew — §2.1). These four are genuine RCE vectors and are
load-bearing — do not regress them:
-
The bridge binds
127.0.0.1only and lets its single front door proxy it. Binding0.0.0.0makes the whole access check theater. But be exact about what that bind buys: it bounds remote reach, not local. A multiplexer's own socket is a filesystem object, so its permissions bound callers to the owning uid; a TCP port bounds callers to the network namespace, which every uid on the host shares. So a process running as a different user — an agent you deliberately put undersudo -u agent-reviewto contain it — cannot open your herdr socket but can open127.0.0.1:$COLLIE_PORTand drive any pane in the herd. Installing Collie removes that uid boundary; if it is the containment you were relying on, pairing below is the gate that doesn't rest on "local means trusted". Since ADR 0086 it gates reads as well as writes, so that uid reads nothing but/api/healthunless it holds a token. The token is then the boundary: a uid that can read your browser profile can read the token too. Keeping the port unshared (its own network namespace, or a uid owner-match filter such as nftablesmeta skuid) still closes even that; a plain port firewall rule won't stop a same-host peer (raised in #33). Named exception: the crew listener. When crew federation is enabled, a peer's/crew/v1/*prefix shares the bridge's one listener and one bind —COLLIE_HOST, the operator's to set, with a loud warning on a wildcard bind — and admits a request only past two independent factors, pinned mutual TLS plus the crew secret, before any handler runs. SeeCREW_PROTOCOL.md§3 (amended 2026-08-08, F3) and ADR 0013. Undertailscale serve, theTailscale-User-Loginheader is the person gate — trusted only when the request source is loopback (i.e. it came from tailscaled).COLLIE_TRUSTED_USERrejects a mismatching login and an absent one:serveinjects no header for a tagged node, so tolerating the absence let any tagged node write.COLLIE_TRUSTED_USER_OPTIONAL=1restores the old pass, for host-local development. The header exists only undertailscale serveingress, so underCOLLIE_SKIP_SERVEonly a mismatch is rejected. Under a reverse-proxy front door (docs/deployment.md → Variant C) there is none, and the equivalent write gate is per-device auth (COLLIE_DEVICE_HEADER) with the proxy contract (docs/deployment.md Variant B/C requirements) as the load-bearing piece. That gate fails closed since 0.15.0: withCOLLIE_DEVICE_HEADERset, a request arriving without the header is read-only, so reaching the port is no longer sufficient to write. Device ids are names your proxy asserts, not secrets — treat them as guessable and keep the front door and its ACL as the real containment. Device pairing (bridge/pairing.ts) is the second, independent factor, and the one that needs no proxy at all:collie pairmints a one-time code out of band (the operator's own terminal), the phone trades it atPOST /api/pairfor a 256-bit bearer token, and the bridge keeps only its SHA-256. It is always on, and reads need the pairing token as well as writes: every/api/*route but/api/healthand/api/pairanswers403 device not pairedwithout a valid token, so an install that has paired nothing answers no device (ADR 0086). Revocation (collie devices revoke) lands on the running service without a restart because the registry is re-read per request. The header gate stays write-only (plus the Files view'sdevice-read). The two gates compose by AND — neither weakens or replaces the other — and neither touches/crew/v1/*, whose two factors are its own. Where the header gate answers is this device on the operator's list, pairing answers does this device hold a credential I issued: a claim no proxy, DNS name or tailnet identity can forge. -
The
Hostheader is validated, on by default, and fails closed. A request whoseHostis not the tailnet name, a loopback name,COLLIE_PUBLIC_HOSTSor a configured origin is refused, so a DNS-reboundHost: evil.examplecannot reach the API.collie startdiscovers the node's MagicDNS name and Tailscale IPs intoCOLLIE_TAILSCALE_HOSTSand bakes them into the service unit, so a normal tailnet install configures nothing; behind your own front doorCOLLIE_PUBLIC_HOSTSis required.COLLIE_ALLOW_ANY_HOST=1is the opt-out, and re-opens rebinding./crew/v1/*is exempt: a lead addresses a peer by its own hostname, and that surface carries its own two factors (ADR 0013). -
The bridge refuses a non-loopback bind. A
COLLIE_HOSToutside loopback does not start unlessCOLLIE_ALLOW_NON_LOOPBACK_BIND=1, and a non-loopback TCP peer is rejected — every gate above trusts headers that are only untamperable while the sole client is the local front door. A crew member is the one machine that must listen wide, so a crew-configured instance carries the same permission implicitly (bridge/crew/config.ts) and/crew/v1/*is exempt from the peer check. -
Pane-grid output renders safely — it's attacker-influenceable (filenames, agent output, fetched web content). Never
innerHTML; it renders as React text nodes under a strict CSP (default-src 'self'), so an escaping miss can't run injected script that calls back into the socket. -
A same-origin gate on every API request — accepted only when the browser's
Originhost equals theHostheader the bridge receives, so a page on any other tailnet device, or on another loopback port, can't CSRF the bridge. A loopbackOrigingets no exemption: it passes only when it names the bridge's own host and port, or is listed inCOLLIE_ALLOWED_ORIGINS. With a plaintailscale serveon the MagicDNS name these match automatically (no config). When Collie is fronted by a different public hostname or an extra reverse proxy / TLS terminator (custom domain, load balancer, Headscale + upstream TLS, or a reverse-proxy front door — docs/deployment.md → Variant C), the public origin no longer matches the forwardedHost— list that exact origin inCOLLIE_ALLOWED_ORIGINS(the only sanctioned way to widen the gate; never bind off-loopback to "fix" it). Also shipped, as defence in depth: -
Audit log — every write-level action appends a JSONL line (timestamp, method, truncated params) to
<stateDir>/audit.log, mode 0600 since it may echo reply text. An audit failure never fails the user's action.COLLIE_AUDIT_CONTENT=nonekeeps the trail and drops the bodies — what survives is an allowlist of action parameters, documented at the list itself (bridge/audit.ts). -
Destructive-action confirm — a browser-side prompt when input pattern-matches
rm,sudo,git push --force,dd, etc. (web/src/lib/destructive.ts). Prevents catastrophic mistaps.
Considered, not built:
- Tailscale ACL scoping to your specific devices (
src: tag:my-phone → dst: this:bridge). Promote this to mandatory the moment the tailnet has any device you don't fully control. - A short PIN gating reconnection — friction against a grabbed phone. This, not the idle lock, is where that friction would have to live: the lock is a pause on an unattended screen and deliberately gates nothing (ADR 0007).
Full passthrough (no command allow-list) is acceptable for a personal tool — an allow-list would
defeat the purpose. Never use tailscale funnel (public exposure).
tailscale serve→ tailnet-only HTTPS on a stable MagicDNS hostname; the node cert doesn't rotate, so the PWA stays signed in. No login screen; the front door itself is the identity.collie servepublishes exactly this one mapping and tears down only a mapping it recorded (ADR 0001). Pairing (§6) adds a credential the phone holds, minted once at a keyboard — not a login, and off until the operator pairs something.- Install as a PWA (Add to Home Screen) → app icon, instant open, persistent.
- Known failure mode (accept, don't engineer around): if
tailscaledis down, the bridge is reachable on localhost but not via MagicDNS. On Android specifically, the OS backgrounds Tailscale aggressively — a notification tap may hit the app before the tunnel is up, and you wait. The intended mitigation (the agent's question in the notification body, so the tap is at least informative) is the gap noted at the end of §4.
Not planned, not scheduled — a parking lot for ideas surfaced while reading Herdr's socket surface, so they don't get re-discovered from scratch or acted on by accident.
herdr terminal session observe/control(new in 0.7.2). A CLI subcommand pair that streams a pane as NDJSON live ANSI frames —observeis read-only;controladditionally accepts stdin commands (terminal.input,terminal.resize,terminal.scroll,terminal.release) with one-controller-at-a-time semantics (--takeoverto steal control). Consuming either would mean running a terminal emulator, and Collie doesn't — the emulation already happened one process upstream, sopane.readhands us a rendered grid rather than a byte stream. Latency is a transport question and cursor position is an upstream ask;controlwould resize the shared PTY and fight the desktop. The full argument, the costs the proposal hides, and the narrow shape that would be admissible if this is ever revisited: ADR 0008.