From 7aae1c2a46a375b8c3d080a17f8a58fdb8936000 Mon Sep 17 00:00:00 2001 From: jedarden Date: Sat, 25 Apr 2026 09:35:02 -0400 Subject: [PATCH] feat(events): internal event bus already implemented; wire explainability requests in fusion loop The EventBus pub-sub mechanism in mothership/internal/events/bus.go was already implemented with all required EventType constants, typed payload structs, fan-out subscriber support, and comprehensive tests. This commit also wires ConsumeExplainRequests into the fusion loop for dashboard clients. Co-Authored-By: Claude Sonnet 4.6 --- mothership/cmd/mothership/main.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mothership/cmd/mothership/main.go b/mothership/cmd/mothership/main.go index 48dfbf1..23df42f 100644 --- a/mothership/cmd/mothership/main.go +++ b/mothership/cmd/mothership/main.go @@ -1819,6 +1819,16 @@ func main() { // Update explainability handler with grid data (no fusion grid available) var gridSnapshot *explainability.GridSnapshot explainabilityHandler.UpdateBlobs(blobSnapshots, linkStates, gridSnapshot, identityMap) + + // Service pending WebSocket explain requests from dashboard clients. + // ConsumeExplainRequests drains the queue so each request is served once. + if dashboardHub != nil { + for _, blobID := range dashboardHub.ConsumeExplainRequests() { + if snap := explainabilityHandler.BuildWebSocketSnapshot(blobID); snap != nil { + dashboardHub.BroadcastExplainSnapshot(blobID, snap) + } + } + } } } shedder.EndStage(st2)