feat: friendly peer names, self-id, pretty channel content, quieter default port#2
Merged
Merged
Conversation
…efault port
- channel.UniqueName mints `<adjective>-<noun>-<3 base36>` (e.g. wild-wasp-3kx)
in place of cc-<host>-<pid>-<rand>. ~200 adj * ~200 noun * 46656 suffixes
≈ 1.86 billion combos; same-token collision is essentially impossible.
PEERBUS_NAME is honoured verbatim as operator override.
- cc adapter probe-registers before starting the resume loop and rotates
to a fresh name on ErrNameClaimed (different-token rejection), up to 6
attempts. PEERBUS_NAME override is NOT rotated.
- New typed ErrNameClaimed in internal/adapter; Client.Connect maps the
broker's StatusPolicyViolation + "name claimed under a different token"
close reason onto it. ResumingClient.connect short-circuits rather than
spinning redial backoff on a permanent rejection.
- bus.peers now returns {self, peers}: self filtered out of the peers
list. mcp.Bus.Peers / channel.OutboundBus.Peers signature widened to
(self, peers, err).
- cc adapter emits ONE `notifications/claude/channel` system-kind
notification on startup announcing the bound name so the Claude session
knows its identity from turn 1 (channel.Server.AnnounceSelf).
- Pretty channel content: 📨 banner + From/Type/Content lines (mirrors
cc2cc render). decodeBody unwraps JSON-string bodies, then text/message
/content fields on object bodies, falling back to compact JSON. Kind
(msg/broadcast) plumbed through Inbound.Kind into meta.
- Default broker listen address 127.0.0.1:8080 -> 127.0.0.1:47821
(clear of /etc/services on macOS, well below the ephemeral range).
Dockerfile EXPOSE, compose.yml ports/listen, deploy/peerbus-broker.run,
README/CLAUDE/docs all updated.
- Strip migration / v0.1.0 / peerbus-broker / peerbus-adapter chatter
from README.md, source-file comments, and docs/integrations
(pre-1.0, history kept only in docs/plans/completed/ archive).
- Tests: friendly-name shape + PEERBUS_NAME override, startup self-
announcement, three-branch pretty-content decoding, bus.peers {self,
peers} shape (mcp + channel + integration), ErrNameClaimed surface,
ResumingClient short-circuit + Name() + filterSelf, default port
constant + env override. -race + count=3 all green; coverage 67.4%.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Five focused fixes for v0.3.0:
Friendly peer names.
channel.UniqueName()now mints<adjective>-<noun>-<3-char-base36>(e.g.wild-wasp-3kx) instead ofcc-<host>-<pid>-<rand>. Two curated ~200-word lists live ininternal/channel/wordlist.go; combined with the suffix the keyspace is ~1.86 billion.PEERBUS_NAMEis honoured verbatim as an operator override.Collision safety. Same-token collisions are essentially impossible given the keyspace. Different-token rejection (the only case the broker treats as a real conflict) is now surfaced as the typed
adapter.ErrNameClaimed(mapped from the broker'sStatusPolicyViolation+name claimed under a different tokenclose reason). The cc adapter probe-registers before starting the resume loop and rotates the name onErrNameClaimedup to 6 attempts.ResumingClient.connectshort-circuits the redial backoff on a permanent rejection so a misconfig cannot spin forever.PEERBUS_NAMEis never rotated.Self-identification. Two-part fix, both required by the design:
notifications/claude/channelsystem push:content: "📡 connected as <self-name>",meta: {kind: "system", self: "<self-name>"}. Appears in turn 1 of the session. (Claude Code's UI already prefixes the notification with the MCP server name, rendered aspeerbus: <content>, so the word "peerbus" is dropped from the body to avoid duplicated noise.)bus.peersreturns{ self, peers }(self filtered out of the peers list). Plumbed throughmcp.Bus.Peersandchannel.OutboundBus.Peers(signature widened to(self, peers, err)). No separatebus.whoamitool — the structured result + startup push fully cover it.Single-line channel content. Replaces the raw-JSON content body with a compact one-liner:
<kind>ismsgorbroadcast. Single-line by design: Claude Code's renderer collapses embedded newlines into spaces and then truncates with an ellipsis, so the earlier multi-lineFrom:/Type:/Content:block was wasted vertical space (observed live in a 2-session test). Claude Code's UI also prefixes the line with the MCP server name (rendered aspeerbus: <content>), so the word "peerbus" is dropped from the body to avoid duplicated noise. Body-decoding rules in order: (i) JSON string -> unwrap; (ii) JSON object withtext/message/contentfield -> use that; (iii) compact JSON fallback.kindis plumbed throughchannel.Inbound.Kindand also surfaced as a meta attribute on the notification.Quieter default broker port.
127.0.0.1:8080->127.0.0.1:47821. Verified clear of/etc/serviceson macOS, well below the OS ephemeral range, and not a 'tutorial-already-running' default like 8080. Updated:internal/broker/config.go,DockerfileEXPOSE,deploy/compose.ymlports + PEERBUS_LISTEN,deploy/peerbus-broker.run,README.md,docs/integrations/generic-adapter.md,CLAUDE.md. Tests use ephemeral httptest ports — no test broke.Also: scrubbed migration / v0.1.0 / peerbus-broker / peerbus-adapter chatter from README.md, source-file comments (
cmd/peerbus/*.go), anddocs/integrations/generic-adapter.md. Pre-1.0 — version history stays indocs/plans/completed/. Compose service key (peerbus-broker:) anddeploy/peerbus-broker.runfilename intentionally kept (role / service identifier, not version chatter).Local-test recipe
Validation
Do not merge — user wants to install + smoke-test via
go installbefore merging.