Repository navigation
feat(a2a): name Squadrons in the address book and remote senders in the timeline - #198
Conversation
5bd17e9 to
1efdb2b
Compare
1efdb2b to
53da6fd
Compare
|
Astra review (gpt-6-astra, 2026-09-24) of this PR after the rebase onto current
Built by Claude Fable 5.1 in Claude Code. |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedWe couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughPeer deliveries now support sender display labels, which receiving services retain and identity lookup can use. Participant directory rows now include Squadron names for local and remote participants. The peer delivery contract also limits message text length. ChangesA2A labels
Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Feature Sequence Diagram(s)sequenceDiagram
participant DeliveryTransport
participant participantIdentityRows
participant PeerInboundService
participant message_received
DeliveryTransport->>participantIdentityRows: Look up sender identity
DeliveryTransport->>PeerInboundService: Send peer delivery with senderLabel
PeerInboundService->>message_received: Store senderLabel in received payload
Suggested reviewers: Merge Risk: 🟡 Moderate · up to Oversized peer messages can remain undelivered, and a Squadron-name lookup failure can hide an otherwise available address book. Align send validation with the wire limit before merging; address the narrower label and test gaps as well. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
bryantderosier
left a comment
There was a problem hiding this comment.
Sending the sender's name with each peer delivery is the right idea, but one of the new fields has no reader, the name lookup is duplicated, and the peer-supplied names need limits.
Should fix
originSquadronNamegets sent, validated and persisted, but nothing reads it. The contract comment and AC23 describe a reader that doesn't exist. (inline,contracts.ts)DeliveryTransport.ts: the sender-label query is a second definition of a participant's display name, alongsideClientReadsService.participantIdentityRows. (inline)- The peer-supplied names have no length cap and
texthas no max. The label lookup is keyed by sender id alone, and a future-datedcreatedAtpins a label for good. (inline,ClientReadsService.ts)
Nits
DeliveryTransport.ts:squadronRowsisn't wrapped inorElseSucceedthe waylabelRowsis, so despite the "best-effort" comment an SQL error there still fails the delivery. (inline)ClientReadsService.ts: the unresolved filter is quadratic; aSetfixes it. (inline)PeerRegistryService.ts: thereasonOfcause-chain change is unrelated to names and belongs in its own PR. (inline)- Docs:
cross-device.mdadds AC23 and edits AC17 without a History line, and theagent-tools.mddescription change has no History entry either. (inline, on AC23)
| @@ -150,6 +150,9 @@ const NonMembershipCommEvent = Schema.Struct({ | |||
| export const MessageReceivedPayload = Schema.Struct({ | |||
| originSquadronId: SquadronId, | |||
| originEnvironmentId: Schema.optional(Schema.String.check(Schema.isNonEmpty())), | |||
| /** From a peer delivery: the names its server sent, read by the client identity lookup. */ | |||
There was a problem hiding this comment.
Only senderLabel feeds ClientReadsService. originSquadronName is sent by DeliveryTransport.ts, validated in both contracts and persisted by PeerInboundService.ts, but nothing reads it, so this comment isn't accurate. AC23 describes the same reader, and also mentions the inbox, which doesn't apply because people are server-local. I'd either wire it into the timeline now or drop the field until something reads it, then fix this comment and AC23 to match.
There was a problem hiding this comment.
Done in ff33fdc6f1: originSquadronName is dropped from the wire, the payload and the inbound service; the comment and AC23 say only what the timeline shows (the sender's label).
| const squadronRows = yield* sql<{ readonly name: string }>` | ||
| SELECT name FROM j5_a2a_squadron WHERE id = ${input.originSquadronId} LIMIT 1 | ||
| `; | ||
| const labelRows = yield* Effect.orElseSucceed( |
There was a problem hiding this comment.
This is a second definition of a participant's display name. ClientReadsService.participantIdentityRows uses the thread title from the first participant.joined, while this joins the membership threadId to orchestration_v2_projection_threads. The two can disagree, so a peer could see a different name than we do locally. It also reads an upstream projection table from a new place, and orElseSucceed would hide it if that schema drifted. I'd export participantIdentityRows and reuse it here.
There was a problem hiding this comment.
Done in ff33fdc6f1: participantIdentityRows is exported and the transport uses it, wrapped in orElseSucceed.
| FROM j5_a2a_comm_event AS event | ||
| WHERE event.kind = 'message.received' | ||
| AND json_extract(event.payload, '$.senderLabel') IS NOT NULL | ||
| AND event.sender IN ${sql.in(participantIds)} |
There was a problem hiding this comment.
These labels are peer-controlled, and there are a few problems with trusting them as-is. senderLabel and originSquadronName only check isNonEmpty (and text has no max), so a peer can send a megabyte of name. This lookup matches on sender alone, not (originEnvironmentId, sender). And "newest" is ordered by the peer-supplied createdAt, so a single delivery dated in the future pins its label permanently. I'd cap names at around 200 chars and put a max on text in the contract, key this lookup and the NOT EXISTS probe by originEnvironmentId, and order by local seq rather than created_at. A peer can also name its Squadron after one of ours, so it may be worth showing the peer's environment label next to remote senders.
There was a problem hiding this comment.
Done in ff33fdc6f1: senderLabel is capped at 200 and text at 256k in the wire contract, the lookup and its NOT EXISTS probe are keyed by originEnvironmentId, and newest is by local seq (the test dates the older row in 2099). Showing the peer's environment label beside remote senders is a client concern I would take separately.
| // Names travel with the message for the peer's people, so its timeline | ||
| // can name the sender as it names a local one. Best-effort: a name the | ||
| // origin cannot read never holds a delivery. | ||
| const squadronRows = yield* sql<{ readonly name: string }>` |
There was a problem hiding this comment.
Nit: the comment above says a name the origin can't read never holds up a delivery, but only labelRows is wrapped in orElseSucceed. An SQL error here still fails the send. I'd wrap this one too. The (): ReadonlyArray<{ readonly title: string | null }> => [] annotation on line 476 isn't needed either; () => [] infers.
There was a problem hiding this comment.
Done in ff33fdc6f1: the squadron read is gone and the one remaining read is wrapped; the annotation went with it.
| // A sender homed on a peer has no thread here; the label its server | ||
| // sent with its latest delivery stands in, and only for ids nothing | ||
| // local named, so local-only reads never touch received history. | ||
| const unresolved = participantIdBatch.filter( |
There was a problem hiding this comment.
Nit: this scans every accumulated row for each id in the batch, so it's quadratic in the batch size. I'd build a Set of the resolved participant_ids first and filter against that.
There was a problem hiding this comment.
Done in ff33fdc6f1: a Set of resolved ids.
| @@ -138,7 +138,17 @@ const recordFromRow = (row: PeerRow): PeerRecord => ({ | |||
|
|
|||
| const decodeHello = Schema.decodeUnknownEffect(PeerHelloResponse); | |||
|
|
|||
| const reasonOf = (cause: unknown) => (cause instanceof Error ? cause.message : String(cause)); | |||
| /** The message plus the cause chain: a transport error alone never says why the socket failed. */ | |||
| const reasonOf = (cause: unknown): string => { | |||
There was a problem hiding this comment.
Nit: walking the cause chain is a useful change, but it's unrelated to carrying names. I'd move it to its own small PR so this one stays about one thing.
There was a problem hiding this comment.
Done: moved to its own branch, j5/peer-unreachable-reason (844ba9d0ae), based on #173's branch. I have not opened the PR yet.
| 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. | ||
| 21. A person is never addressed across peers: an ask to a person is delivered on the sender's own server. | ||
| 22. Peers reach each other directly at the recorded origin; no relay or tunnel is required for peering. | ||
| 23. A delivery to a peer carries the sender's display name and its Squadron's name; the receiving server keeps them with its received row so the client names a remote sender in the timeline and the inbox as it names a local one, and no agent verb needs them. |
There was a problem hiding this comment.
Nit: AC23 is new and AC17 changed, but there's no History line for either, and the list_participants description change in agent-tools.md has no History entry. I'd add both. If originSquadronName stays unread, this AC should also drop the inbox and say only what the timeline actually shows.
There was a problem hiding this comment.
Done in ff33fdc6f1: History lines for AC17/AC23 in cross-device.md and for the list_participants description in agent-tools.md; AC23 drops the inbox and the Squadron name.
53da6fd to
ff33fdc
Compare
ff33fdc to
3b143a7
Compare
3b143a7 to
14e2a09
Compare
14e2a09 to
d7936c5
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
d7936c5 to
e8eabd5
Compare
e8eabd5 to
756035b
Compare
…he timeline Two-server testing showed agents could see only Squadron ids in list_participants, and the timeline showed a remote sender as "Unnamed participant" because its display name lives on the other server. list_participants rows now carry squadron_name beside squadron_id, for local and peer-homed rows alike, and the tool description says the self row's Squadron is the caller's own. A peer delivery carries the sender's thread title and its Squadron's name; the receiving server keeps them on its received row, and the client identity lookup falls back to that label after any local name, so the web names a remote sender as it names a local one. Agents keep addressing by participant id and still see no server. Built by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…ne definition of a display name Review of #198. The origin Squadron's name was sent, validated and persisted but read by nothing, so it goes; AC23 and the payload comment now say what the timeline actually shows. The sender's label comes from the same statement the client identity read uses, so a peer sees the name we see, and the wire bounds it and the message text so a peer names a sender rather than filling the ledger. The client's label lookup is keyed by the server the label came from and ordered by this ledger's sequence, so a delivery the origin dated in the future cannot pin a name, and it runs on the peer route index from migration 21, so the extra index migration goes. The unresolved set is a Set. The cause-chain change to peer errors moves to its own branch. History lines cover AC17, AC23 and the list_participants description. Built by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…st-effort, and let the plan test see a scan CodeRabbit on #198. The wire capped message text but nothing stopped a local send from recording a longer message that the peer would then refuse on every retry until the alarm; the cap is now the platform's (A2A_MESSAGE_TEXT_MAX_CHARS) and the send service refuses it before anything is written. list_participants no longer loses the whole address book when the Squadron-name read fails; names are enrichment and fall back to null. The query-plan assertion matched the table name, which a SCAN under the query's aliases never contains; it now requires both ledger reads to be index searches. Built by Claude Fable 5.1 in Claude Code. Co-Authored-By: Claude Fable 5.1 <[email protected]>
…er numbering The peering migrations moved above main's Playbooks and Crews migrations to 23–26 in this rebase. The client identity read's comment names the route index by its new id, and FORK.md case 48 says that development databases that ran either earlier numbering are disposable. Built by Claude Opus 5.5 in Claude Code. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…und with one index seek Astra review of #198. The label lookup took the row with the highest seq as newest, but seq is allocated per Squadron, so a stale label received in one Squadron at a high seq hid a renamed sender's later label in another. Received rows carry this server's own clock, stamped at receipt, so the lookup orders by that, with Squadron id then seq as the tie-break so exactly one row wins. Ordering by time on the seq-ordered route index made the "nothing newer" check walk a sender's history, so migration 27 indexes labeled received rows by sender, receipt time, Squadron and seq, and the statement takes each asked id's latest row with one backward seek on it. A sender id belongs to one peer, since the inbound ownership check refuses a second origin, so that row is its peer's latest label. The test spans two Squadrons and a same-instant tie, and the plan test rejects a scan or a sort. FORK.md case 48 names migration 27, and the round-trip fake says why it carries no sender label. Built by Claude Opus 5.5 in Claude Code. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
756035b to
c299729
Compare
…sonas Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Stack 8/8. Depends on #197. Merge in order, retargeting to
j5/mainas 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 ontoj5/mainon 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 rerunpr-env.shwith--freshfor such environments.Stack 7 of the cross-server peering build. Base: #197. Fixes two things the first real two-server test surfaced.
Problems
list_participantsrows carriedsquadron_idonly, and a peer's Squadron never appears inlist_squadrons, so an agent could not tell "Remote Squad" from an opaque id, nor confirm its own Squadron's name from its self row.What this does
squadron_nameon every address-book row, local and peer-homed, from the ledger's Squadron list and the peer roster respectively. The tool description now says the self row's Squadron is the one the caller belongs to. No server is named anywhere; the existing assertion that no row reveals an environment still holds.originSquadronNameandsenderLabel(the sender's thread title) to the delivery request, best-effort. The receiving server keeps both on itsmessage.receivedpayload.senderLabela peer sent for that participant id stands in, so the timeline and inbox name a remote sender as they name a local one.agent-tools.mdresult rows and description;cross-device.mdAC17 gains the name, new AC23 states the label carriage.Deliberately not added: a server or environment name on any agent-facing row, per the 2026-09-16 ruling that agents never see servers. The envelope text is unchanged in this PR; naming the origin Squadron there is a possible follow-up.
Verification
apps/server,packages/contracts,apps/web: clean. Lint on changed files: clean.After the 2026-09-30 Astra review: a remote sender's latest label is chosen by the time this server recorded it, not by
seq, which is allocated per Squadron. Migration 27 indexes labeled received rows by sender and receipt time so each lookup is one backward index seek.Built by Claude Fable 5.1 in Claude Code.
🤖 Generated with Claude Code
Summary by CodeRabbit