Skip to content

feat(cc-peer): reply path via lazy per-correspondent aliases - #182

Merged
Mearman merged 6 commits into
mainfrom
feat/ccpeer-reply-aliases
Sep 17, 2026
Merged

Mearman merged 6 commits into
mainfrom
feat/ccpeer-reply-aliases

Conversation

@Mearman

@Mearman Mearman commented Sep 17, 2026

Copy link
Copy Markdown
Member

Closes #158

Builds the reply half of the default cc-peer front (#157): a relayed Claude Code session can answer mesh agents natively, not just receive from them.

Design (as scoped in the issue): when a mesh agent messages a relayed session, the front materialises a cc-peer reply alias for that correspondent via cc-peer 1.4.1's AliasPool (cc-peer/alias-pool), so the session can address a reply to that correspondent the way it addresses any other local peer. A reply arriving on an alias is translated into a mesh DM sent as the session's own device-id. Aliases are created only on inbound contact, are ephemeral (in-memory only, re-materialised by the next inbound message after a restart), and a reply to a stale alias produces an explicit error back into the session rather than a silent drop.

Work in progress, following strict TDD one module at a time. Will flip to ready once complete and green.

Reply aliases (agent-comms#158) need cc-peer's AliasPool, published
under the cc-peer/alias-pool subpath in 1.4.1 (agent-comms#40).
Derives a deterministic cc-peer peer name from a mesh correspondent's
device-id and tracks the correspondent-to-alias mapping in a bounded,
in-memory directory, bijective in both directions. Also identifies
which DeliveryEvent types carry a single originating correspondent
worth aliasing (dm, room_message) versus ones that describe something
happening rather than a message from someone (room membership/status/
capability events).

The directory is deliberately unpersisted: reply aliases are ephemeral
by design, lost on restart and re-materialised by the next inbound
message from that correspondent.
Adds CcPeerFront.handleAliasMessage, matching an inbound reply-alias
message to the fronted session that sent it the same way
handleInboundMessage already does, then resolving the alias to its
correspondent via an injected directory. A resolved correspondent
routes to the session's own handleAliasReply; an alias the directory
no longer knows about (ephemeral aliases don't survive a front
restart) routes to notifyStaleAlias instead of being silently
dropped. A message matching no fronted session is dropped, same as
handleInboundMessage, since there is nowhere to safely deliver an
error for a session this front does not control.
Extends buildFrontedSessionRecord so a mesh delivery with a single
originating correspondent (a dm or room_message) materialises that
correspondent's reply alias before delivery and mentions it in the
message body, so the fronted session can address a reply to that
specific correspondent the way it addresses any other local peer.
An event with no single correspondent (room membership/status/
capability events) still delivers via the shared peer unchanged; a
failure to materialise the alias still delivers the message, just
without a reply hint the session couldn't have used anyway.

Adds handleAliasReply (translates a reply arriving on an alias into a
mesh DM to that correspondent, sent as the session's own agentId) and
notifyStaleAlias (a clear error back into the session for a reply on
an alias the directory no longer recognises) to the record CcPeerFront
tracks each fronted session under.
Wires cc-peer 1.4.1's AliasPool (cc-peer/alias-pool) and a shared
ReplyAliasDirectory into the real cc-peer front construction: the pool
is materialised lazily on first use, mirroring the shared CcPeer
peer's own lazy-construction convention, and its "message" event (a
reply arriving on any fronted session's own correspondent alias)
routes straight into CcPeerFront.handleAliasMessage. Both the pool and
the directory are shared across every fronted session on this
machine, so two sessions corresponding with the same mesh agent share
one alias rather than minting a duplicate. The pool is stopped
alongside the shared peer when the front itself stops.
Extends the existing "Default cc-peer front" section with the reply
path: lazy per-correspondent aliases via cc-peer's AliasPool, created
only on inbound contact, ephemeral across restarts, and a clear error
for a reply landing on a stale alias.
@Mearman
Mearman marked this pull request as ready for review September 17, 2026 17:49
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review Completed 2026-09-17T17:58:50.481992Z fc688b2 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Mearman
Mearman merged commit 55e5add into main Sep 17, 2026
6 checks passed
@Mearman
Mearman deleted the feat/ccpeer-reply-aliases branch September 17, 2026 17:50
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cc-peer reply path: lazy per-correspondent aliases

1 participant