feat(observability): emit EventBus events from HTTP write paths#52
Open
barrygfox wants to merge 1 commit into
Open
feat(observability): emit EventBus events from HTTP write paths#52barrygfox wants to merge 1 commit into
barrygfox wants to merge 1 commit into
Conversation
Before this change only MCP tool handlers emitted EventBus events. The
HTTP fast paths — /observe, /remember (sync + async), the AutoCapture
pipeline, and the pending materializer drain — were completely silent.
This left the dashboard health-pane event stream and events_last_24h
counter structurally empty regardless of how much traffic the daemon
served.
This change is purely observational. It does not alter any write
behaviour, recall semantics, data model, or API contract.
Changes:
- infra/event_bus.py: register four new event types (memory.observed,
memory.captured, memory.dropped, memory.queued). memory.stored already
existed.
- server/unified_daemon.py: add _emit_event() helper (source_protocol=
"http", best-effort, never raises) and wire it into six callsites:
ObserveBuffer.enqueue → memory.observed
ObserveBuffer._flush match → memory.captured
ObserveBuffer._flush miss → memory.dropped
POST /remember (async) → memory.queued
POST /remember?wait=true → memory.stored
materializer drain → memory.stored (source_agent=materializer)
- tests/test_server/test_http_eventbus_emissions.py: 10 new tests
covering event type registration, never-raises guarantee, http protocol
tagging, enqueue emission, duplicate suppression, and flush
captured/dropped paths.
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.
Description
Wires the EventBus into the six HTTP write-path chokepoints that were previously silent. This is a pure observability improvement — it does not change any write behaviour, recall semantics, data model, or API contract.
Why proposed
Only MCP tool handlers emit EventBus events. Every HTTP fast path —
/observe,/remember(sync and async), AutoCapture decisions, and the pending materializer drain — was silent. As a result, the dashboard health pane showedevents_last_24h: 0, and the event stream stayed empty regardless of daemon traffic, making it impossible to distinguish a healthy, busy daemon from a stuck one.Changes
infra/event_bus.py— four new event types registered (3 lines):memory.observed/observeaccepted content into the debounce buffermemory.capturedmemory.droppedmemory.queued/rememberaccepted content into pending.db (async path)memory.storedalready exists and is reused for the sync/rememberand materializer paths.server/unified_daemon.py— one new helper, six callsites:_emit_event(): mirrorsmcp.shared.emit_eventbut tagssource_protocol="http"so the dashboard can distinguish HTTP traffic from MCP tool calls. Best-effort — never raises, logs at DEBUG on failure.ObserveBuffer.enqueue,ObserveBuffer._flush(both capture and drop branches),POST /remembersync path,POST /rememberasync path, and materializer drain (source_agent="materializer").tests/test_server/test_http_eventbus_emissions.py— 10 new tests:VALID_EVENT_TYPES_emit_eventnever raises on bus error_emit_eventtagssource_protocol="http"ObserveBuffer.enqueueemitsmemory.observedmemory.observed_flushemitsmemory.capturedon AutoCapture match_flushemitsmemory.droppedon AutoCapture missWhat does not change