[kernel-1116] browser events: add external events#227
[kernel-1116] browser events: add external events#227archandatta wants to merge 7 commits intoarchand/kernel-1116/cdp-foundationfrom
Conversation
|
Firetiger deploy monitoring skipped This PR didn't match the auto-monitor filter configured on your GitHub connection:
Reason: PR title and branch suggest browser events feature work, but no file changes are provided to confirm modifications to API endpoints or Temporal workflows. To monitor this PR anyway, reply with |
…ed signal on Stop
…ontrol on all SSE endpoints
809321b to
ca437c0
Compare
7139fb3 to
0a89c58
Compare
Sayan-
left a comment
There was a problem hiding this comment.
matches plan well and deviations from it are reasonable!
| return s.captureSessionID != "" | ||
| } | ||
|
|
||
| // Stop ends the current session. It publishes a synthetic session_ended |
There was a problem hiding this comment.
should seq be monotonic across start/stop cycles? If so, I think Start shouldn't reset it here. That would make seq represent the process-wide event stream position rather than the position within a single capture session.
There was a problem hiding this comment.
I see your point, here are things to consider with how this works currently
- every envelope already carries capture_session_id, so i think (session_id, seq) would be sufficient
- SSE clients don't cross session boundaries, session_ended terminates the stream, so not sure if monotonic seq applies fully
the fix would also require a non-trivial ring buffer refactor to avoid dropped records
| // PublishEvent handles POST /events/publish. | ||
| // Injects a caller-supplied event into the active capture session. Returns 400 | ||
| // if no session is active or the event fails validation. | ||
| func (s *ApiService) PublishEvent(_ context.Context, req oapi.PublishEventRequestObject) (oapi.PublishEventResponseObject, error) { |
There was a problem hiding this comment.
could we add one lifecycle test for the new event flow? Something like start capture session, publish an event through PublishEvent, read it from StreamEvents, then stop and verify the stream receives session_ended.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4cb8f0e. Configure here.
| Type: TypeSessionEnded, | ||
| Category: CategorySystem, | ||
| Source: Source{Kind: KindKernelAPI}, | ||
| }) |
There was a problem hiding this comment.
Stop response seq off-by-one after session_ended publish
Medium Severity
StopCaptureSession calls buildSessionResponse() (which reads Seq()) before s.captureSession.Stop(). Now that Stop() publishes a synthetic session_ended event via publishLocked — which increments s.seq — the Seq in the returned response is one less than the actual final sequence number. Clients comparing the stop response's Seq with the session_ended envelope's seq on the SSE stream will see an inconsistency.
Reviewed by Cursor Bugbot for commit 4cb8f0e. Configure here.


As per plan -> #217
Note
Medium Risk
Adds new public API endpoints that inject and stream capture-session events, plus changes capture-session stop/publish behavior to emit terminal/system events; incorrect validation or streaming behavior could impact clients and event pipeline reliability.
Overview
Adds an external events API:
POST /events/publishto inject validated caller-supplied events into the active capture session (with reserved types blocked andsource.kindforced), andGET /events/streamto stream envelopes over SSE withLast-Event-IDresume support, keepalives, and explicitevents_dropped/session_endedsignaling.Updates the events pipeline to support this:
CaptureSessionnow exposesActive(), publishes a syntheticsession_endedevent onStop(), and addsPublishUnfiltered()to bypass category filtering for externally-initiated events. OpenAPI/generated client/server code is regenerated for the new endpoints and enums, and SSE responses now includeCache-Control: no-cacheandX-Accel-Buffering: noheaders; tests are updated/added to cover the new event lifecycle and enum rename.Reviewed by Cursor Bugbot for commit 4cb8f0e. Bugbot is set up for automated code reviews on this repo. Configure here.