A crew run's wire hops
The owner's direction (2026-11-20, #14650): do the work on this machine, and let only the model call cross the uplink. The outage of #14614 came from one hop that did not need to be one.
Every run's log carries one line just before its timing: line:
hops: 4, off-host: 1 — clone loopback · model internet · agent loopback · push loopback
src/crew/hops.ts tallies them and names where each goes from the URL's host
alone (no DNS lookup): in-process (a unix socket), loopback, lan (private
ranges, cluster names and any name with no dot) or internet. lan and
internet are off the host. A dotless name counts as lan, so a public alias
with no dot in it would be miscounted.
Each hop is counted once its step has succeeded: the clone or fetch after
prepareClone returns, the push after git accepts it, and the model and agent
hops once the session has taken a turn. A run that fails in prepareClone logs
no clone. The model and agent hops are counted per session, not per request:
the agent's own traffic is not observed, only the address it was given.
When a hop other than the model call leaves the host, a second line names it:
stray hops: agent internet
The map
| Hop | Made by | Goes to | Per run |
|---|---|---|---|
mirror fetch and clone (clone) | the forge | localUrl, loopback; objects borrowed from the local mirror (crew/mirror.ts) | one, on a fresh clone |
fetch of a kept clone (fetch) | the forge | localUrl, loopback | one, on a resumed run |
model call (model) | the agent | the account's gateway, or api.anthropic.com | one session (many requests) |
the agent's git and API (agent) | the agent | FORGE_URL, through the sandbox's proxy | one session (many requests) |
push for the agent (push) | the forge | localUrl, loopback | only when the agent left commits unpushed |
| check run, preview deploy | the forge | in-process, after the push lands | not the run's own: counted by the check and the deploy |
Before and after
Before (#14614): the forge's own mirror fetches were paced like uplink traffic
and timed out. They already went to localUrl. #14605 keeps the mirror when a
fetch fails, and the clone borrows its objects (crew/mirror.ts). Nobody
measured hop counts before this change, so there is no "before" column. The
counts below are what the code expects a run to log, not measured values:
| Run | hops (expected) | off-host (expected) |
|---|---|---|
| fresh clone, forge pushes | 4 | 1 (model) when FORGE_URL is loopback; 2 (model, agent) when it is the forge's public name |
| fresh clone, agent pushes | 3 | the same |
| resumed clone | 3 or 4 | the same |
In production FORGE_URL is the forge's public name, so every real run today
logs off-host: 2 and a stray hops: agent internet line. The agent's
remotes and FORGE_URL carry that name because inside the shell sandbox
localhost is the sandbox's own (prepareClone says why). The next step is to
route that name to the loopback inside the sandbox's proxy. Until then the line
counts the hop rather than hiding it.
The guard
test/crew-hops.test.ts holds the reach of each kind of host and the
stray hops: line. test/crew-run-timing.test.ts runs a whole stand-in run
and fails when its log has a stray hops: line. The stand-in's FORGE_URL is
loopback, so this guards the stand-in only. It cannot fail for the production
agent hop above, which the stray line reports instead.