Skip to content

fix(inbox): an unplaced inbox follows its registered agent's group - #43

Merged
khaliqgant merged 2 commits into
mainfrom
fix/inbox-follows-agent-group
Nov 17, 2026
Merged

khaliqgant merged 2 commits into
mainfrom
fix/inbox-follows-agent-group

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Problem

relaygate placed relaycast:inbox/<name> streams only by streamDefaults prefixes (local-, pit-, slack-). Agent Relay Desktop agents enrol with a device token (keyId device:<uid>, gid from controlPrincipals) and are named by their harness (cursor-…, claude-…, codex-…), so their inboxes matched no prefix and every DM to them was denied at stage mode, reason unknown_stream. Local agents could not DM each other.

Fix

resolveStream order is now: override → registered stream → longest prefix default → registered agent's inbox (only for relaycast:inbox/<name>):

  • owner = the agent, gid = the agent's gid
  • mode / acl / classify from the new optional policy field inboxDefaults: [{gid, mode, acl?, classify?}] for that gid; otherwise 660, no ACL (same group may message it, no one else)
  • a name no agent has stays unknown_stream (deny)
  • audit reason suffix :agent-inbox

Explicit overrides and streamDefaults keep precedence. The pit (gid 22) never gets w on a gid-11 inbox unless policy grants it (built-in default has other = 0; inboxDefaults mirroring local- gives 22 only r).

Visibility unchanged: GET /v1/agents still uses operator rules only (resolveStream(..., { agentInboxes: false })), so a derived inbox does not show an agent in the directory. If we want local Desktop agents to list each other too, that's a one-line flip — called out deliberately.

Policy validator: inboxDefaults gids/ACL gids must be defined groups, at most one entry per gid, mode validated as elsewhere. Also: an agent can now read its own inbox (owner digit), which previously failed for these agents the same way.

Docs: docs/contract.md (Resources → DMs; pit deployment section). examples/policy.pit.json declares inboxDefaults for gid 11.

Deployer policy addition

"inboxDefaults": [{"gid": 11, "mode": "660", "acl": [{"gid": 22, "perm": "r"}, {"gid": 44, "perm": "r"}]}]

(mirror whatever ACL your relaycast:inbox/local- rule has). Without it, Desktop agents still DM each other with built-in 660/no ACL. Chart default: separate infra PR.

Tests

test/agent-inbox.test.ts: device-enrolled cursor-x and claude-y DM each other; pit agent can't DM them (also with inboxDefaults mirroring local-: r yes, w no); explicit streamDefaults/overrides win; unregistered name → unknown_stream; only inbox ids derived; directory visibility unchanged; explain reports agent-inbox; validator rules. npm run typecheck + npm test (167) 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

Desktop agents register with device tokens and are named by their harness (cursor-…, claude-…, codex-…), so no streamDefaults prefix covered their inboxes and every DM to them was denied as unknown_stream. Resolution for an inbox is now override → registered stream → prefix default → the registered agent's inbox, owned by that agent, in its group, with mode/ACL/classify from the new inboxDefaults policy entry (default 660, no ACL); a name no agent has still stays unknown_stream.

  • Explicit overrides and streamDefaults keep precedence; audit reasons end in :agent-inbox.
  • A relay-control user's synthetic ctl: identity holds no token, so it is never a DM recipient through this rule and those names stay unknown_stream.
  • Directory visibility is unchanged: GET /v1/agents still uses operator rules only, so a derived inbox doesn't list the agent.

Migration

  • Operators may add "inboxDefaults": [{"gid": 11, "mode": "660", "acl": [...]}] mirroring their relaycast:inbox/local- rule; without it, desktop agents still DM each other with the built-in 660/no ACL.

Written for commit 2638a9b. Summary will update on new commits.

View guided diff Turn on auto-fix

Desktop agents enrolled with a device token are named by their harness
(cursor-, claude-, codex-), so no streamDefaults prefix covers their
relaycast:inbox/<name> stream and every DM to them was denied as
unknown_stream.

After override, registered stream and prefix default, an inbox id now
resolves from the registered agent with that name: owned by the agent,
in its gid, with the new optional policy inboxDefaults entry for that gid
(mode, acl, classify) or 660 with no ACL. Unregistered names stay
unknown_stream. The agent directory keeps using operator rules only, so
visibility is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-17T09:21:19.849390Z c602068 PR opened
ℹ️ 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.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The change adds group-specific inbox defaults and resolves inbox IDs for registered agents after existing stream rules. It also updates policy validation, directory visibility, explanations, documentation, and tests.

Changes: Registered agent inboxes

Layer / File(s) Summary
Inbox defaults and policy contract
src/policy.ts, docs/contract.md, examples/policy.pit.json, test/agent-inbox.test.ts
Policy accepts per-group inbox defaults and validates group references and duplicate GIDs. The example and contract describe the defaults, fallback behavior, and access rules. Tests cover policy validation.
Derived inbox resolution and access
src/app.ts, src/explain.ts, src/relaycast.ts, test/agent-inbox.test.ts
resolveStream derives an inbox for a registered agent after overrides, registered streams, and prefixes. Directory visibility excludes derived inboxes. Tests cover resolution precedence, access, control identities, directory visibility, and explanations.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant resolveStream
  participant agentInbox
  participant Store.agentByName
  participant Policy.inboxDefaults
  resolveStream->>agentInbox: Try inbox fallback after existing stream rules
  agentInbox->>Store.agentByName: Look up inbox name
  Store.agentByName-->>agentInbox: Return registered agent ownership and group
  agentInbox->>Policy.inboxDefaults: Read defaults for the agent group
  Policy.inboxDefaults-->>agentInbox: Return mode, classification, and ACL
  agentInbox-->>resolveStream: Return derived stream
Loading
Merge Risk: Minimal · up to 2638a

Inboxes for registered Desktop agents without a matching name prefix now follow the agent's group and optional inbox defaults. Existing overrides, registered streams and prefix defaults still take precedence, and unregistered names are still refused. No concrete merge-blocking defect was found, and the change is easy to revert.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

I’m a rabbit with a policy to read,
I find the right inbox for each registered steed.
Group defaults set the mode and the key,
ACLs say who may read, write, or see.
Unknown names stay out of the queue,
And directory entries remain as they were.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Devin Review

Comment thread src/app.ts Resolved
The synthetic ctl:<userId> agent (keyId control) owns a Control user's
sessions but holds no token, so a DM to it would be enrolled upstream and
never read. Such names stay unknown_stream, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@khaliqgant
khaliqgant merged commit 797e427 into main Nov 17, 2026
3 of 4 checks passed
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