feat(room-worker): publish InboxMemberEvent to local INBOX + fix inbox-worker Subjects#111
Merged
mliu33 merged 1 commit intoApr 21, 2026
Conversation
…x-worker Subjects Wires the publisher side of the INBOX-based search-sync pipeline landed in #109. After this, search-sync-worker's spotlight + user-room collections actually receive events end-to-end instead of spinning up with an empty feed. room-worker changes (handler.go) -------------------------------- processAddMembers, processRemoveIndividual, processRemoveOrg now split their member list by home site and publish InboxMemberEvent: - Same-site accounts → one publish per call to `chat.inbox.{site}.member_added/removed` - Cross-site accounts → existing OUTBOX publish per destination, inner payload migrated MemberAddEvent/MemberRemoveEvent → InboxMemberEvent so the remote site's search-sync sees RoomName + RoomType (needed for spotlight typeahead indexing). InboxMemberEvent is a strict JSON superset of MemberAddEvent on the fields inbox-worker reads (Accounts, RoomID, SiteID, JoinedAt, HistorySharedSince), so inbox-worker's handleMemberAdded / handleMemberRemoved continue to unmarshal into their existing types and simply ignore the extra RoomName/RoomType fields. OrgID on MemberRemoveEvent is dropped from the INBOX payload — not currently read by any consumer, and InboxMemberEvent stays focused on what search-sync needs. If inbox-worker ever needs OrgID, add it then. Remove events omit RoomName/RoomType entirely (search-sync keys its deletes by {account}_{roomID} and script-removes by roomID; neither needs room metadata) so we skip the extra DB lookup on the remove path. inbox-worker changes (main.go) ------------------------------ One-line fix: `CreateOrUpdateStream` was copying only `.Name` from `stream.Inbox()` and dropping `.Subjects`. The INBOX stream was being created with zero subjects, so any publish to `chat.inbox.{site}.*` would have failed once room-worker started publishing. Now passes both. The remote-site Sources + SubjectTransforms federation config is intentionally left out — production multi-site isn't deployed yet, and when it is we want inbox-worker (not search-sync-worker's bootstrap path) to own that config. Tests ----- - TestHandler_ProcessAddMembers_PublishesToInbox — new, verifies local INBOX publish carries RoomName/RoomType + cross-site OUTBOX payload is InboxMemberEvent. - TestHandler_ProcessRemoveMember_SelfLeave_IndividualOnly + _OwnerRemovesIndividual + _OwnerRemovesOrg — bump expected publish count +1 and assert the local INBOX publish carries the right Accounts. - TestHandler_ProcessRemoveMember_CrossSiteOutbox — assert OUTBOX payload is InboxMemberEvent (not MemberRemoveEvent) and confirm NO local INBOX publish fires when the removed user is remote. Follows PR #109. https://claude.ai/code/session_01XTmSpmv5dT6UXX7NpRdYqN
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
711cad4
into
claude/recover-search-sync-worker-dCjyV
4 checks passed
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
Wires the publisher side of the INBOX-based search-sync pipeline landed in #109. After this, search-sync-worker's spotlight + user-room collections actually receive events end-to-end instead of spinning up with an empty feed.
Stacked on top of #109 — base branch is
claude/recover-search-sync-worker-dCjyV. Merge #109 first, then this; GitHub will auto-retarget tomainwhen #109 lands.Scope
room-worker
processAddMembers,processRemoveIndividual,processRemoveOrgnow split their member list by home site and publishInboxMemberEvent:chat.inbox.{site}.member_added/removedMemberAddEvent/MemberRemoveEvent→InboxMemberEventso the remote site's search-sync seesRoomName+RoomType(needed for spotlight typeahead indexing).Backward-compatibility:
InboxMemberEventis a strict JSON superset ofMemberAddEventon the fields inbox-worker reads (Accounts,RoomID,SiteID,JoinedAt,HistorySharedSince), soinbox-worker'shandleMemberAdded/handleMemberRemovedcontinue to unmarshal into their existing types and simply ignore the extraRoomName/RoomTypefields.OrgIDonMemberRemoveEventis dropped from the INBOX payload — not currently read by any consumer, andInboxMemberEventstays focused on what search-sync needs. If inbox-worker ever needs OrgID, it can be added then.Remove events omit
RoomName/RoomTypeentirely — search-sync keys its deletes by{account}_{roomID}and script-removes byroomID; neither path needs room metadata, so the remove path skips the extra DB lookup.inbox-worker
One-line fix:
CreateOrUpdateStreamwas copying only.Namefromstream.Inbox()and dropping.Subjects. The INBOX stream was being created with zero subjects, so any publish tochat.inbox.{site}.*would have failed once room-worker started publishing. Now passes both.Out of scope: remote-site Sources + SubjectTransforms federation config — production multi-site isn't deployed yet, and when it is we want inbox-worker (not search-sync-worker's bootstrap path) to own that config.
BOOTSTRAP_STREAMSin search-sync-worker stays as the dev-only toggle for now.Tests
TestHandler_ProcessAddMembers_PublishesToInbox— new, asserts local INBOX publish carriesRoomName/RoomType+ cross-site OUTBOX payload isInboxMemberEventwith a split across local (bob, carol on site-a) and remote (dave on site-b) accounts.TestHandler_ProcessRemoveMember_SelfLeave_IndividualOnly+_OwnerRemovesIndividual+_OwnerRemovesOrg— bumped expected publish count +1 and assert the local INBOX publish carries the right accounts.TestHandler_ProcessRemoveMember_CrossSiteOutbox— assert OUTBOX payload isInboxMemberEvent(notMemberRemoveEvent) and confirm no local INBOX publish fires when the removed user is remote.Test plan
make lint— 0 issuesmake test— all services greenFollows #109.
https://claude.ai/code/session_01XTmSpmv5dT6UXX7NpRdYqN