Skip to content

feat(mailbox): persistent per-agent message inbox — closes #2 - #6

Merged
EngineerProjects merged 1 commit into
devfrom
feat/mailbox
Jun 4, 2026
Merged

EngineerProjects merged 1 commit into
devfrom
feat/mailbox

Conversation

@EngineerProjects

Copy link
Copy Markdown
Collaborator

Summary

  • Message struct — UUID ID, Kind, FromAgent, ToAgent, Subject, Body, ReplyTo, TeamID
  • MessageKind enum — task, reply, broadcast, event
  • Mailbox interface — Send, Receive, MarkRead, MarkAllRead, History, Thread, Delete
  • SQLiteMailbox — implementation backed by db.DB
  • Broadcast fan-out — KindBroadcast with ToAgent: "*" expands to one record per team member (sender excluded), via an injectable agentLister callback
  • GMailboxMessage GORM model + migration 20260604_005_mailbox_messages
  • Package is fully independent — no dependency on feat/agent-definition; agents are identified by UUID strings

Design notes

  • agentLister is injected at construction so the mailbox has no hard dependency on the agent registry; the caller wires them together
  • ReplyTo forms conversation threads without nested tables — Thread() fetches root + direct replies
  • Ordering: Receive returns oldest-first (process in order); History returns newest-first (display in UI)

Test plan

  • TestNewMessage_HasUUID — unique UUID per message
  • TestSend_And_Receive — full round-trip, all fields preserved
  • TestReceive_OnlyUnread — read messages excluded
  • TestReceive_OldestFirst — correct ordering
  • TestMarkRead — single message marked read
  • TestMarkAllRead — all unread cleared at once
  • TestHistory_NewestFirst — correct ordering, limit respected
  • TestHistory_IncludesReadMessages — history shows all messages
  • TestThread — root + reply returned, unrelated message excluded
  • TestDelete — message removed from inbox
  • TestDelete_NotFound — returns db.ErrMessageNotFound
  • TestBroadcast — fan-out to all team members, sender excluded
  • TestBroadcast_NoLister — error when lister not configured
  • TestBroadcast_RequiresTeamID — error when TeamID missing
  • TestInbox_Isolation — messages only visible to their recipient

All 15 tests pass. Full go build ./... clean.

Closes #2

- Message struct with UUID ID, Kind, FromAgent, ToAgent, Subject, Body, ReplyTo, TeamID
- MessageKind enum: task, reply, broadcast, event
- Mailbox interface: Send, Receive, MarkRead, MarkAllRead, History, Thread, Delete
- SQLiteMailbox implementation backed by db.DB
- Broadcast fan-out: expands "*" to individual per-recipient records via agentLister callback
- DB model GMailboxMessage + migration 20260604_005_mailbox_messages
- 15 unit tests: send/receive, ordering, mark-read, history, thread, delete, broadcast, inbox isolation

Closes #2

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@EngineerProjects
EngineerProjects merged commit 84e34f2 into dev Jun 4, 2026
@EngineerProjects
EngineerProjects deleted the feat/mailbox branch June 4, 2026 12:18
EngineerProjects added a commit that referenced this pull request Jun 4, 2026
feat(mailbox): persistent per-agent message inbox
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