feat(bridge): generic event envelope dispatch#138
Merged
benvinegar merged 1 commit intomainfrom Feb 23, 2026
Merged
Conversation
Refactor processPulledMessage() in broker-bridge.mjs to support a generic envelope format alongside the legacy raw Slack event_callback format. Changes: - Add isGenericEnvelope() detection function for structured envelopes with source, type, payload, and broker_timestamp fields - Extract existing Slack handling into standalone handleSlackPayload() - Add stub handlers for dashboard and system event sources - Dispatch generic envelopes by source (slack, dashboard, system) - Unknown sources are acked to avoid blocking the queue - Legacy raw Slack payloads continue to work (backwards compat) Tests: - Add 3 integration tests: generic slack dispatch, dashboard dispatch, unknown source ack - Fix test env inheritance (cleanEnv helper) to prevent false failures when host broker token is expired Refs: modem-dev/baudbot-services#56
Greptile SummaryRefactors the broker bridge message processor to support a generic multi-source envelope format while maintaining backwards compatibility with legacy Slack payloads. Key changes:
Testing:
The implementation is production-ready and follows the deployment strategy where the broker will be updated first, requiring backwards compatibility for agents still sending legacy format messages. Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Broker pulls encrypted message] --> B[Verify signature]
B --> C[Decrypt envelope]
C --> D{isGenericEnvelope?}
D -->|Yes| E{Check source field}
D -->|No| F[Legacy path: handleSlackPayload]
E -->|slack| G[handleSlackPayload with payload.payload]
E -->|dashboard| H[handleDashboardEvent - stub]
E -->|system| I[handleSystemEvent - stub]
E -->|unknown| J[Log warning + ack]
F --> K[Process Slack event]
G --> K
H --> L[Return true - ack]
I --> L
J --> L
K --> L
Last reviewed commit: c21a62a |
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
Client-side support for modem-dev/baudbot-services#56.
Refactors
processPulledMessage()inbroker-bridge.mjsto support a generic envelope format alongside the legacy raw Slackevent_callbackformat. This enables the broker to deliver events from multiple sources (Slack, dashboard, system) through a single inbox.Changes
slack-bridge/broker-bridge.mjsisGenericEnvelope()— detects the new structured envelope format (source,type,payload,broker_timestamp)handleSlackPayload()— extracted fromprocessPulledMessage(), handles Slackevent_callbackeventshandleDashboardEvent()— stub handler for dashboard events (env updates, config changes)handleSystemEvent()— stub handler for system eventsprocessPulledMessage()— now dispatches by envelope format:sourcefield (slack → handleSlackPayload, dashboard → handleDashboardEvent, system → handleSystemEvent)test/broker-bridge.integration.test.mjssource=slack→ forwards to agent via Slack handlersource=dashboard→ logs + ackscleanEnv()helper) to prevent false failures when host broker token is expiredBackwards Compatibility
Critical: the broker will be deployed before all agents update, so old-format messages (raw Slack
event_callback) continue to work via the legacy path.Testing