[kernel 1116] browser logging: cdp pipeline#194
Conversation
…ader godoc, and test correctness
… add concurrent publish+read race test
Event is the agreed portable name. DetailStandard avoids Go keyword ambiguity with "default".
Moves CDP-specific fields (target_id, cdp_session_id, frame_id, parent_frame_id) under source.metadata. Top-level Event schema now contains only stable cross-producer fields.
…ut of Event Event is now purely producer-emitted content. Pipeline-assigned metadata (seq, capture_session_id) lives on the Envelope. truncateIfNeeded operates on the full Envelope. Pipeline type comment now documents lifecycle semantics.
Ring buffer now indexes by envelope.Seq directly, removing the separate head/written counters. NewReader takes an explicit afterSeq for resume support. Renamed notify to readerWake for clarity.
Drops are now stream metadata (ReadResult.Dropped) rather than fake events smuggled into the Event schema. Transport layer decides how to surface gaps on the wire.
truncateIfNeeded now warns if the envelope still exceeds the 1MB limit after nulling data (e.g. huge url or source.metadata). Pipeline.Publish skips the file write when marshal returns nil to avoid writing corrupt bare-newline JSONL lines.
| xvfbResizeMu sync.Mutex | ||
|
|
||
| // CDP event pipeline and cdpMonitor. | ||
| eventsPipeline *events.Pipeline |
There was a problem hiding this comment.
Will change this to CaptureSession once #184 is merged
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
|
|
||
| s.eventsPipeline.Start(uuid.New().String()) | ||
|
|
||
| if err := s.cdpMonitor.Start(r.Context()); err != nil { |
There was a problem hiding this comment.
HTTP request context will cancel long-running CDP monitor
High Severity
s.cdpMonitor.Start(r.Context()) passes the HTTP request context to a long-running CDP WebSocket monitor. An HTTP request context is cancelled as soon as the handler returns (after sending the 200 OK response), which means the monitor's context will be cancelled almost immediately. A detached or server-scoped context (like context.Background()) is needed so the monitor survives beyond the request lifecycle. For reference, main.go uses a signal-based context for similarly long-lived operations like upstreamMgr.Start(ctx).
| default: | ||
| return CategorySystem | ||
| } | ||
| } |
There was a problem hiding this comment.
CategoryFor omits liveview and captcha category mappings
Low Severity
The new CategoryFor function maps event-type prefixes to EventCategory values but omits "liveview" → CategoryLiveview and "captcha" → CategoryCaptcha, even though both constants are defined in the same file. Any event type with a liveview_* or captcha_* prefix will silently fall through to the default branch and be mis-categorized as CategorySystem. This could route events to the wrong log file via FileWriter.


Note
Medium Risk
Introduces a new capture-control surface (
/events/start//events/stop) and wires in a new events pipeline/monitor lifecycle, which can affect runtime behavior and shutdown ordering. The CDP monitor implementation is currently stubbed, so follow-up changes may be needed to ensure capture actually works and doesn’t leak resources.Overview
Adds a browser logging capture path by wiring an
events.Pipelineand newcdpmonitor.MonitorintoApiService, including lifecycle management duringShutdown.Introduces non-OpenAPI HTTP endpoints
POST /events/startandPOST /events/stopto start/stop capture sessions (generating a new session ID and restarting the monitor when needed), and updatesmain.goto construct the pipeline (ring buffer + file writer) and pass it into the API service.Extends the events schema with
events.CategoryForto deriveEventCategoryfrom event type prefixes, and updates tests to use the newApiService.New(...)signature with an events pipeline and display number.Written by Cursor Bugbot for commit 1e544a7. This will update automatically on new commits. Configure here.