fix(dm): a thread reply under a DM is a DM to the other participant

Merged
KH
5d ago
+90-5

Problem

After a local agent DMs another (dm.send allowed), the recipient's answer via thread.reply on relaycast:message/<dm message id> was denied at stage mode, reason dm_message. Agent Relay clients (relay-node auto-answers, MCP reply) reply to DMs this way, so replies between local agents never arrived.

Fix

POST /v1/messages/:id/replies on a DM message:

  • the caller must be a participant (Relaycast's GET /v1/dm/<conversation>/messages answers participants only); otherwise deny, dm_reply_not_participant
  • the other participant is the message's author, or, when replying under your own message, the conversation's other author
  • decided exactly like POST /v1/dm to them: gateWrite on relaycast:inbox/<other> (mode, ACL, ceilings, classifier on cross-group), audited under that inbox id
  • forwarded upstream as before (from stripped, provenance stamped)

So local↔local is allowed; pit→local is still denied by the local inbox mode/ACL. Reactions under a DM stay refused. docs/contract.md route table updated. Independent of #43 (which makes cursor-…/claude-… inboxes resolvable); both are needed for Desktop agents.

Tests

test/relaycast.test.ts, "a thread reply under a DM is a DM to the other participant": local B replies to local A's DM → 201, forwarded, audited against A's inbox; A replies under its own message → B's inbox; non-participant local C → 403; pit replying to local A's DM → 403 (mode:660+acl:22:r); reactions under DM → 403. Typecheck + full suite green.

🤖 Generated with Claude Code


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.


Summary by cubic

Thread replies under DMs now work as DMs to the other participant, allowing local agents to answer through POST /v1/messages/:id/replies.

  • The recipient comes from Relaycast’s 1:1 participant list, including when the sender follows up before the recipient replies.
  • Replies use the recipient’s inbox permissions and are forwarded with provenance; lookup failures are passed through.
  • Non-participants are denied (dm_reply_not_participant); reactions remain refused. docs/contract.md is updated.