Repository navigation
Description
Summary
Design a Tower-to-Tower protocol so that agents on one Tower can message agents on another. Today afx send stops at the edge of one machine's Tower. This issue asks for a spec (SPIR); the design is the deliverable for now.
The scope is primarily sending messages — the afx send capability, extended across Towers. Remote terminals, remote spawn, and remote gate approval are not asked for here.
Goals, in the owner's order
- Architects other than
maincan talk to one another. A named architect must be addressable from outside its own workspace. This is probably the simplest of the three: it needs no second Tower, no transport and no cross-owner trust. It goes first and must not wait behind the other two. - My Tower talks to my other Towers. One owner, several machines (laptop, a dev VM, …). An agent on one sends a message to an agent on another.
- My Tower talks to someone else's Tower. Two different owners, e.g. a collaborator's Tower. Same capability, across a trust boundary.
Each stage should be shippable on its own. The addressing scheme and the security model must be designed for all three up front, so that stage 1's address grammar already has room for a Tower and stages 2 and 3 do not force a second migration.
What the spec must design
1. An addressing scheme (the heart of this)
The current colon-separated grammar cannot carry this. It has to be replaced by something that names the Tower as well as the workspace and the agent.
Explore the options; do not start from a conclusion. The owner has floated a URI scheme such as afx://…, but that is one idea among several and the owner is explicitly open to others. The spec must lay out several genuinely different address designs and compare them, not present afx:// with token alternatives beside it. Families worth considering include a URI scheme, an email-like form ([email protected]), a path-like form, dotted DNS-style names, and short handles or aliases resolved through a directory — and anything better the builder finds. Compare them on at least: what a human types at a shell (quoting, length, tab completion), what an agent writes reliably in a reply, how short and relative forms fall out, how well each survives a Tower or workspace rename, room for a future component, and the cost of migrating from today's colon forms. Show the same handful of real addresses written in each candidate so the owner can judge them side by side.
Why the current grammar is at its limit:
parseAddress(packages/codev/src/agent-farm/utils/agent-names.ts) splits on the first colon into{ project, agent }.architect:<name>(named architect, same workspace) and<workspace>:architect(main architect, another workspace) are the same shape.resolveTarget(packages/codev/src/agent-farm/servers/tower-messages.ts) tells them apart with a special-case intercept on the literal wordarchitect.- Consequence: there is no way to write "the architect named
Xin workspaceY". Cross-workspace addressing only ever reachesmain. That is goal 1, and it is the gap on a single Tower today. - A workspace is identified by path basename, which is not unique even on one machine and means nothing on another.
The spec should cover: the full grammar (Tower, workspace, agent kind, agent name); how short and relative forms resolve (a bare architect from a builder must keep meaning "my spawning architect"); what happens to the existing colon forms (compatibility, deprecation, or both); how a Tower and a workspace get stable names that survive a rename; and how the address is shown to the recipient as the message's provenance.
2. Discovery
- Which Towers can I reach, and how did I come to know about them — my own, and someone else's?
- Which workspaces are running on a remote Tower, and which agents (architects by name, builders) are live in each?
- How much of that a remote Tower reveals, and to whom. Discovery is itself a disclosure: workspace names and builder ids leak what someone is working on.
3. Security model
A message delivered to an agent is text typed into the prompt of a coding agent that usually runs with permissions skipped. Accepting a message from another Tower is, in effect, accepting remote instructions for an agent with shell access. The spec must treat it that way. At minimum:
- Identity — what identifies a Tower and its owner, and how that is proven.
- Trust establishment — how two of my own Towers come to trust each other, and how two different owners' Towers do (pairing, invitation, an allow-list, a cloud-mediated introduction, …).
- Authorization — who may message which agent. Default-deny for other owners' Towers; the granularity of a grant (whole Tower, a workspace, one architect); whether a remote sender can reach builders at all or only architects.
- Provenance and spoofing — the recipient must be able to tell a remote message from a local one and see who really sent it. Today's only spoofing rule is that a builder may address only its own spawning architect (Spec 755, multi-architect support); the cross-Tower equivalent needs designing.
- Revocation, rate limiting, audit — how trust is withdrawn, how flooding is bounded, and what record is kept.
- The human in the loop — whether a message from another owner's Tower should be delivered straight to an agent, or held for the human to release.
4. Transport and delivery semantics
- Owner's direction: the Codev Cloud tunnel is the transport. Towers already hold an HTTP/2-over-WebSocket tunnel to Codev Cloud (Spec 97, cloud Tower client). Routing every cross-Tower message through it keeps things simple and gives the system a single security choke point. Design around that. Direct Tower-to-Tower connections (LAN, VPN/tailnet) need only a short considered-and-set-aside note; raise them again only if the spec finds a concrete requirement the tunnel cannot meet.
- Follow that choice through. If Codev Cloud is the choke point, say what it is responsible for (identity, authorization, rate limiting, audit, revocation) and what the receiving Tower still enforces for itself, so that the Tower is not trusting the relay blindly. Say what the cloud can read of message bodies. Say what happens when the cloud or the tunnel is down. Identify the work that lands in the Codev Cloud repository rather than this one.
- Stage 1 (architects on one Tower) involves no transport at all and must not depend on a Tower being connected to Codev Cloud.
- The receiving Tower must still honour the mailbox-first invariant (Spec 1313, mailbox-first delivery): a remote message is persisted to the mailbox and delivered through the render gate. Nothing remote writes a PTY directly.
- What
delivered/held+ reason mean when the recipient is on another Tower, how the sender learns the outcome, and what happens to mail for a Tower that is offline (store-and-forward, or fail fast). - Replies: an agent that receives a remote message needs an address it can reply to.
Existing ground to build on (check before designing from scratch)
- Issue Cloud messaging: send and receive afx-style messages via Codev Cloud #655 (cloud messaging: send and receive afx-style messages via Codev Cloud) is an earlier, narrower framing of the same need. The spec should say whether it subsumes that issue.
- Issue Tower persists the typed tower name instead of the cloud's canonical slug; add rename, deregistration and name-takeover handling (Tower half of codev-cloud#17) #1871 (Tower persists the typed tower name instead of the cloud's canonical slug) — Tower naming and renames, directly relevant to the Tower part of an address.
- Issue afx: device-authorization flow for 'tower connect' (replace paste-token UX) #1165 (device-authorization flow for
afx tower connect) — how a Tower authenticates to Codev Cloud today. - Spec 755 (multi-architect support) and Spec 823 (multi-architect coordination) — named architects and sibling messaging.
- Spec 1313 (mailbox-first delivery), plus the held-mail work that followed it.
- Spec 62 (secure remote access) and Spec 97 (cloud Tower client) — prior security and tunnel design.
- Windows: workspaces are keyed by
workspaceKey()'s canonical spelling; an address must not depend on how a path is spelled.
Constraints
- End-to-end usable at each stage. Every stage needs a one-sentence headline path a human can actually run (e.g. "from my laptop's
mainarchitect, send a message to thelocalarchitect on my dev VM and see it arrive"). A stage that ships a primitive with the usable path deferred is not acceptable. - Server/client isolation (issue Introduce packages/codev-sdk: client SDK for Tower (server/client dependency isolation) #1189): wire contracts live in
codev-types;codev-coreandcodev-sdkdo not import each other. - Fail fast, no fallbacks. An address that does not resolve fails loudly with the reason; it never falls back to a different recipient.
- Keep it proportionate. Design the address and the trust model for all three stages; do not design machinery that only a hypothetical fourth stage would need.
Deliverable
A SPIR spec that presents the alternatives it considered for the address grammar, the trust model, and the transport, with a recommendation for each (transport is already directed: the Codev Cloud tunnel). Decisions that are genuinely the owner's — above all the security posture toward other owners' Towers — should be surfaced as explicit open questions at spec approval, not settled silently.
Activity