Skip to content

docs(j5): define cross-server peering for A2A - #172

Merged
Jacksondr5 merged 2 commits into
j5/mainfrom
docs/j5-cross-server-peering
Sep 30, 2026
Merged

Jacksondr5 merged 2 commits into
j5/mainfrom
docs/j5-cross-server-peering

Conversation

@Jacksondr5

@Jacksondr5 Jacksondr5 commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Stack 1/8. Based on j5/main. Merge in order, retargeting to j5/main as predecessors land.

Full stack:

Testing: scripts/j5/pr-env.sh <pr> --peer (#255) serves this PR's build as two peered servers, Local and Remote. Rebased onto j5/main on 2026-09-30, after the Effect rc.115 upstream sync and the Playbooks and Crews migrations landed; peer migrations are now 023–027 and the FORK.md case is 48. A test state directory that ran an earlier cut of this stack recorded the peer tables under other ids, so rerun pr-env.sh with --fresh for such environments.


Problem

The cross-device definition deferred server-to-server Exchanges to a future "peer registry" without saying what one is, how two servers learn about each other, or what agents would see. The trigger it waited for has arrived: a remote development server is in daily use, and today's investigation confirmed the A2A implementation is strictly single-server (local-only receiver resolution, both cross-Squadron ledger writes in one SQLite, in-process delivery transport, no peer concept anywhere).

What this defines

In docs/j5/product/cross-device.md, a Peering section plus AC11–AC22 and three scenarios:

  • Peering extends what exists rather than adding a registry service. A peer is an ordinary auth session on the receiving side, visible and revocable in Settings → Connections like a paired device or machine token. The sending side keeps one small record: environment id, reachable origin, credential. The client, already connected to both servers, performs the mutual introduction and the person confirms the origin each server will use.
  • Squadron ids encapsulate the server. Agents address participants by the same id as today; send_message, list_participants, and envelopes gain no server field. The platform resolves participant → Squadron → peer.
  • Rulings from the session: people stay server-local, relay and tunnel are out of scope, peers reach each other directly.

AC6 is rewritten from "when built" into a present-tense criterion. The A2A definition, the agent-tools contract (new AC17), and the glossary get one-line pointers. A worklog record carries the investigation findings, the two design questions and their answers, and the build outline so the criteria can be read against an implementation shape.

No code changes. Formatted with vp fmt; lockfile churn reverted.

Built by Claude Fable 5.1 in Claude Code.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified how participants hosted on peer servers appear alongside local participants and how messages can be addressed across servers.
    • Documented direct server-to-server delivery, including receiving-server records, acknowledgements, retries, and return messages.
    • Added guidance and scenarios for setting up peering, checking connectivity, and handling unreachable peers. Routing details remain hidden from agents, and people and their requests remain local to their server.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: Jacksondr5/j5code/.coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 72d8cd91-97a0-4382-9ec9-36cd45370a67

📥 Commits

Reviewing files that changed from the base of the PR and between 8f56083 and d7438d0d2ad63042b00a7dcde8b0019d73d67479.

📒 Files selected for processing (5)
  • docs/j5/product/a2a/agent-tools.md
  • docs/j5/product/a2a/index.md
  • docs/j5/product/cross-device.md
  • docs/j5/product/glossary.md
  • docs/j5/worklog/2026-09-16-cross-server-peering-session.md

Included review availability: 4 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.


📝 Walkthrough

Walkthrough

The documentation defines direct, mutual server peering and cross-server delivery. It also updates A2A requirements for listing and messaging peer-hosted participants.

Changes

Cross-server peering

Layer / File(s) Summary
Peering and delivery contract
docs/j5/product/cross-device.md, docs/j5/product/glossary.md, docs/j5/worklog/2026-09-16-cross-server-peering-session.md
Cross-device requirements describe peer records, limited credentials, reachability checks, direct delivery, ledger rows, retries, and return messages. The glossary adds peering terms, and the worklog records the session decisions and build outline.
A2A peer participant behavior
docs/j5/product/a2a/index.md, docs/j5/product/a2a/agent-tools.md
A2A documentation specifies how peer-hosted Squadrons appear in participant listing and how their IDs are used for messaging. Delivery rules describe receiving-server ledger recording, and a scenario covers a peer-hosted receiver.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Suggested reviewers: bryantderosier

Merge Risk: 🔵 Low · up to d7438

In the event that peer servers expose the same participant ID, the documented ID-only messaging flow cannot reach that participant. This is a bounded design risk, with no current runtime change; clarify recipient identity before relying on the contract in implementation.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely identifies the main change: defining cross-server peering for A2A.
Description check ✅ Passed The description explains the problem, the proposed changes, the scope, and the testing setup. It also identifies the model and harness. The template’s Checklist section and tracking-issue reference ar…
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@bryantderosier bryantderosier left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec reads well, and the implementation stack keeps to its rulings: a peer participant has the same id and no server field, a peer is a revocable session in Connections, people stay server-local, and there's no relay or tunnel. The gaps I found are where the text promises more than the implementation does, plus one vocabulary clash.

Should fix

  • "Peer" now means two things. The glossary defines a peer as another server, but a2a/index.md still uses "peer" for another agent: the one-open-Exchange rule, the queueing policy, the silence kinds, the envelope section, AC13, and the "A busy receiver" and "A failed delivery" scenarios. The envelope channel is also named peer/peerMessage. This PR puts both senses on one page. (inline on glossary.md)
  • The delivery sentence saying "the receipt, retry and alarm facts are the same" across servers doesn't match the implementation. The origin records delivered as soon as the peer accepts, and a failure injecting into the receiver's thread only alarms on the receiver's side. (inline on a2a/index.md and AC18 in cross-device.md)
  • The "home server is asleep" scenario promises a recorded send that retries and then alarms. The implementation only does that for an agent this server has already exchanged with; a first send to an unreadable peer is refused. (inline on cross-device.md)
  • No criterion covers a peer credential expiring. The session lasts 30 days, and then peering stops with nothing visible. (inline on AC13 in cross-device.md)

Nits

  • AC20 says a withdrawal closes "exactly as a local one would", but the implementation sends a withdrawal notice that starts a turn on the answerer. (inline)
  • AC12 "in one act": introduction stops at the first failure and doesn't roll back. (inline)
  • The new agent-tools.md History line cites AC17, but the criterion it adds is AC21, and the 2026-09-16 entry comes after the 2026-09-17 one. (inline)
  • It would help to say that list_participants reads every peer's roster live, so an unreachable peer adds up to its timeout to the call. (inline on AC17)

Comment thread docs/j5/product/glossary.md Outdated
| Term | Gloss | Owner |
| ---------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------ |
| fleet | All of a user's agents across every connected server — the totality, never a sub-grouping | [cross-device.md](cross-device.md) |
| peer | Another server this server exchanges agent messages with, by mutual record | [cross-device.md](cross-device.md) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes "peer" mean another server, but a2a/index.md still uses "peer" for another agent (the one-open-Exchange rule, the queueing policy, AC13, and the "A busy receiver" and "A failed delivery" scenarios), and the envelope channel is peer/peerMessage. This PR already mixes the two senses on one page: "a participant's Squadron may live on a peer server" sits a few paragraphs from "asks a peer that has been archived". I'd make the term "peer server" here and in cross-device.md, or rename the agent sense, so a reader never has to guess which one is meant.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: "peer server" is the term for another server in the glossary and cross-device.md, leaving "peer" to mean another agent as a2a/index.md uses it.

Comment thread docs/j5/product/a2a/index.md Outdated

## Delivery

Delivery is **log-first**: the ledger row is the act, and delivery is an attempt recorded against it. A successful attempt is a **delivery receipt**; a failed one is retried; a failure past the retry limit is a **delivery alarm** — a visible fact attributed to the sender, never a silent loss, and never assumed repaired because time passed or a later message got through. "Was it delivered" and "was it answered" are independent facts.
Delivery is **log-first**: the ledger row is the act, and delivery is an attempt recorded against it. A successful attempt is a **delivery receipt**; a failed one is retried; a failure past the retry limit is a **delivery alarm** — a visible fact attributed to the sender, never a silent loss, and never assumed repaired because time passed or a later message got through. "Was it delivered" and "was it answered" are independent facts. When the receiver's Squadron lives on a peer server, the attempt crosses to that server, which records its own received row before delivering; the receipt, retry and alarm facts are the same.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"The receipt, retry and alarm facts are the same" isn't what the implementation does. The origin records delivered once the peer accepts the message, and if injecting into the receiver's thread then fails, the alarm only shows on the receiver's server, not on the sender. Either the peer sends that alarm back to the origin, or this sentence should say that across servers the receipt means the peer accepted the message.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: the Delivery paragraph now says that across peer servers the receipt means the peer server accepted the message, and that delivery to the thread is the peer server's to retry and alarm on. Carrying that alarm back is tracked in #260.

Comment thread docs/j5/product/cross-device.md Outdated
15. A peer is recorded only after the recording server has reached the peer at the stated origin; an unreachable origin is refused with the reason, never recorded.
16. An agent addresses a participant homed on a peer by the same participant id it would use locally; no agent verb takes, returns or reveals a server, and the envelope names the sender and its Squadron exactly as for a local send.
17. The address book lists participants homed on peers beside local ones with their Squadron; a peer that cannot be read is reported as unread in the listing, never omitted silently.
18. A message to a participant on a peer is recorded in the sender's Squadron ledger before the call returns; the peer records its own received row before delivering to the agent's thread; the peer's acknowledgement is the sender's delivery receipt; failure to reach the peer retries and alarms as any delivery does.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same gap as the Delivery sentence in a2a/index.md: here the receipt is the peer's acknowledgement, which the implementation sends on acceptance, before the receiver's thread is injected. A later injection failure alarms only on the peer. I'd either require that alarm to travel back to the sender, or say plainly that the receipt means "the peer accepted it" and that delivery to the thread is the peer's to alarm on.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: AC18 says the peer server's acknowledgement is the receipt and that a later injection failure alarms on the peer server. #260 tracks routing that alarm back.

Comment thread docs/j5/product/cross-device.md Outdated
- **A Mac-only job.** An agent that must run on a Mac gets its own Squadron homed on the Mac server; it is asked for results by a Squadron elsewhere through a cross-server Exchange, once peering exists. (AC1, AC6)
- **Peering two servers.** The user opens Settings → Connections on their laptop, connected to the work server and the home server, and peers them. Each server confirms it can reach the other at the origin the user confirmed; each lists the other as an authorized session. Revoking either session later ends the peering. (AC11–AC15)
- **A Mac-only job.** An agent that must run on a Mac gets its own Squadron homed on the Mac server. An agent in Billing Migration, on the work server, asks it for results by participant id, as it would ask any peer; the ask is recorded in Billing Migration's ledger, the Mac server records its received row and delivers it, and the reply travels back and closes the Exchange. Neither agent named a server. (AC1, AC6, AC16, AC18, AC20)
- **The home server is asleep.** An agent on the work server asks an agent homed on the home server. The send is recorded, delivery retries and then alarms on the asker, and the work server's address book reports the home server as unread rather than showing nobody there. (AC17, AC18)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation doesn't do this for a first contact. A send to an agent on an unreadable peer is only recorded and retried if this server has already exchanged with that agent; otherwise it can't be resolved and is refused. That fits the no-persistent-cache ruling in the worklog, so I'd narrow this scenario and AC18 to participants the server has already seen, and say that a first send to an unreachable peer is refused with the reason.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: AC18 and the asleep-server scenario are narrowed to participants this server has already exchanged messages with, and a first send to a peer server that cannot be read is refused with the reason.

Comment thread docs/j5/product/cross-device.md Outdated

11. A server delivers to, and accepts deliveries from, only the servers in its peer registry; a peer record names the peer's environment id, the origin this server reaches it at, and the credential the peer issued.
12. Peering is mutual: peering two environments records each as the other's peer in one act, and removing either side ends delivery in both directions.
13. A peer's credential is an ordinary session of the issuing server, bound to the peer's environment identity and to a scope that permits only accepting deliveries and reading the address book; it appears in Settings → Connections, and revoking it there ends the peering.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This covers revocation but not expiry. The implementation issues the peer a 30-day session, and when it lapses peering just stops with nothing shown to anyone. I'd add what happens when a peer's session expires or is revoked: deliveries alarm with that reason, and the address book reports the peer as unread (per AC17), never omits it.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: AC13 now covers expiry and revocation: deliveries alarm with that reason and the address book reports the peer server as unread. #173 also makes peer sessions long-lived and shows the expiry in the record.

Comment thread docs/j5/product/cross-device.md Outdated
17. The address book lists participants homed on peers beside local ones with their Squadron; a peer that cannot be read is reported as unread in the listing, never omitted silently.
18. A message to a participant on a peer is recorded in the sender's Squadron ledger before the call returns; the peer records its own received row before delivering to the agent's thread; the peer's acknowledgement is the sender's delivery receipt; failure to reach the peer retries and alarms as any delivery does.
19. Retrying one message to a peer never yields a second received row or a second delivery.
20. A reply, silence notice or lifecycle closure for an Exchange across peers travels the peer path back to the origin server and closes or notifies the origin Exchange exactly as a local one would.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Exactly as a local one would" doesn't match the withdrawal path: the implementation sends a withdrawal notice across that starts a turn on the answerer, which a local withdrawal doesn't do. Either that's intended and this criterion should name it, or the notice shouldn't wake the answerer. Worth settling which.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settled in #176 (c7529d6fa5): a withdrawal closes the answerer's Exchange without injecting anything into its thread, locally and across servers. AC20 says so.

Comment thread docs/j5/product/cross-device.md Outdated
### Peering

11. A server delivers to, and accepts deliveries from, only the servers in its peer registry; a peer record names the peer's environment id, the origin this server reaches it at, and the credential the peer issued.
12. Peering is mutual: peering two environments records each as the other's peer in one act, and removing either side ends delivery in both directions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"In one act" reads as atomic, but introduction stops at the first failure and doesn't roll back, so one side can end up recorded without the other. Either require rollback, or note that a partial introduction leaves a one-sided record that a retry or removal clears.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: AC12 states what a failed introduction leaves (one-sided records and issued credentials) and that a retry or removal clears it.

Comment thread docs/j5/product/a2a/agent-tools.md Outdated
@@ -369,3 +370,4 @@ stopping retires nothing.
- 2026-09-14 — `delegate_task`, `task_status`, and `task_cancel` return to the J5 surface, with a saved-agent `agent` parameter on `delegate_task` replacing the J5-only `invoke_agent` ([review](https://github.com/Jacksondr5/j5code/pull/124#issuecomment-5663559782)).
- 2026-09-15 — machine participants appear in `list_participants` as named senders that receive nothing (issue #74).
- 2026-09-17 — personas, not agents: `list_agents` becomes `list_personas`, the `agent` parameter on `spawn_agent`, `delegate_task`, and crew seats becomes `persona` (no alias: pre-dogfood, no legacy-compatibility code), crew results carry `persona_id`, and the mention is `@persona:ID`; "agent" keeps meaning a running participant (Bryant; [record](../../worklog/2026-09-16-crew-command-decoupling.md)).
- 2026-09-16 — participants homed on peer servers appear in the address book and are addressed like local ones; AC17 ([record](../../worklog/2026-09-16-cross-server-peering-session.md)).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cites AC17, but the criterion this PR adds to this file is AC21. The entry is also dated 2026-09-16 and sits after the 2026-09-17 one; I'd move it up so the History stays in date order.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: the entry cites AC21 and sits in date order.

Comment thread docs/j5/product/cross-device.md Outdated
14. Peering is done from a client connected to both environments with administrative scope; the person confirms the origin each server will use, which may differ from the one the client uses.
15. A peer is recorded only after the recording server has reached the peer at the stated origin; an unreachable origin is refused with the reason, never recorded.
16. An agent addresses a participant homed on a peer by the same participant id it would use locally; no agent verb takes, returns or reveals a server, and the envelope names the sender and its Squadron exactly as for a local send.
17. The address book lists participants homed on peers beside local ones with their Squadron; a peer that cannot be read is reported as unread in the listing, never omitted silently.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth a sentence saying the address book reads every peer's roster live on each call, so an unreachable peer adds up to its timeout to list_participants. That cost follows from the no-cache ruling, and an agent calling this in a loop should know about it.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in b46582161e: AC17 states the live roster read and that an unreachable peer server costs the call its timeout.

Jacksondr5 and others added 2 commits September 30, 2026 03:57
The cross-device definition deferred server-to-server Exchanges to a
future "peer registry" without saying what one is, how servers learn
about each other, or what agents would see. The trigger it waited for
has arrived: a remote development server is in daily use.

Defines peering in cross-device.md: mutual peer records that the client
introduces, ordinary auth sessions on the receiving side visible in
Settings → Connections, Squadron-resolved routing that agents never
see, people server-local, no relay or tunnel. AC6 becomes a criterion
rather than a deferral; AC11–AC22 and three scenarios cover the
behavior. The A2A definition, agent tools and glossary gain one-line
pointers, and a session record carries the investigation findings and
the build outline.

Built by Claude Fable 5.1 in Claude Code.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Review of #172 (bryantderosier). "Peer" meant both another server and another
agent on one page; the receipt across servers was described as the same fact
as a local one when it means the peer server accepted the message; the
asleep-server scenario promised record-retry-alarm for a first contact the
implementation refuses; nothing covered a credential expiring; and the
address-book cost of a live roster read was unstated.

Another server is a peer server. AC12 states what a failed introduction
leaves. AC13 covers expiry and revocation. AC17 states the live read. AC18 and
the scenario state acceptance-as-receipt and the known-participant condition.
AC20 names withdrawal as closing without waking the answerer. The agent-tools
history line cites AC21 and sits in date order.

Built by Claude Fable 5.1 in Claude Code.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Jacksondr5
Jacksondr5 force-pushed the docs/j5-cross-server-peering branch from b465821 to b85be05 Compare September 30, 2026 04:18
@vercel

vercel Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
j5-code Ready Ready Preview Sep 30, 2026 4:18am UTC

Request Review

@Jacksondr5
Jacksondr5 merged commit 6a31198 into j5/main Sep 30, 2026
30 checks passed
@Jacksondr5
Jacksondr5 deleted the docs/j5-cross-server-peering branch September 30, 2026 14:36
bryantderosier added a commit that referenced this pull request Sep 30, 2026

This branch was successfully deployed

1 active deployment
Preview — b85be05e Deployed Sep 30, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants