Skip to content

fix(message): route message send via host mailbox when peer is local-only - #38

Merged
antonyevans merged 1 commit into
mainfrom
fix/message-send-mailbox-fallback
Jun 18, 2026
Merged

antonyevans merged 1 commit into
mainfrom
fix/message-send-mailbox-fallback

Conversation

@antonyevans

Copy link
Copy Markdown
Owner

Problem

edge-book message send --deliver only calls deliverToPeer, which resolves direct / relay endpoints and throws No direct or relay endpoint when the peer card advertises only a local transport. By default buildCard emits a local-only transport, so this affects essentially every host-connected peer.

Friend requests, objects, escalations, and posts already fall back to the host mailbox (deliverViaMailboxRecorded). Private messages were the only deliverable that did not — so two agents connected to the same host could complete a friend handshake but could not exchange a plain message.

Found while connecting two real agents: the friend request landed fine, the message failed with No direct or relay endpoint.

Fix

In the message send handler (cli-social.ts), catch the no_route EdgeBookError from deliverToPeer and fall back to deliverViaMailboxRecorded, exactly as escalations/objects/posts do. Direct/relay peers are unaffected (still delivered directly); only the previously-failing local-only case changes.

Test

Adds test/message-send-mailbox-fallback.test.ts: full friend handshake between two stores, asserts the peer is local-only, then drives handleCli with a fake mailbox host and asserts the send routes over the mailbox (host-assigned id) instead of throwing.

  • npm test -> 507 pass (was 506)
  • npm run typecheck clean, npm run lint clean (pre-existing warnings only)

Bumps to 0.18.2 for publish.

🤖 Generated with Claude Code

…only

edge-book message send --deliver only called deliverToPeer, which handles
direct/relay endpoints and throws "No direct or relay endpoint" when the peer
card advertises only a local transport. Friend requests, objects, escalations
and posts already fall back to the host mailbox (deliverViaMailboxRecorded);
private messages were the lone deliverable that did not, so messaging between
two host-connected agents failed even though every other envelope type worked.

Add a no_route-catch fallback to the host mailbox, mirroring the other
deliverables. Adds a regression test driving handleCli with a fake mailbox host
for a local-only peer. Bumps to 0.18.2 for publish.
@antonyevans
antonyevans merged commit 168b7a9 into main Jun 18, 2026
1 check passed
@antonyevans
antonyevans deleted the fix/message-send-mailbox-fallback branch June 18, 2026 19:44

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 535d194d66

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/cli-social.ts
const action = args.shift();
if (action === "send") {
const deliver = takeBoolFlag(args, "--deliver");
const hostUrl = parseHost(args, ctx);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Defer host parsing until delivery needs it

When the message text itself is the literal flag token --host (for example edge-book message send <peer> --body --host, or an API caller passing ['message','send', peer, '--body', '--host']), this new unconditional parseHost runs before takeFlag(args, '--body') and strips the body token as a host flag, causing Missing --body or dropping the next token as a host value. Since hostUrl is only used in the no-route delivery fallback, parse it inside that fallback or after extracting the body so existing valid message text is preserved.

Useful? React with 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant