Skip to content

[kernel-1116] browser logging: Event Schema & Pipeline#184

Open
archandatta wants to merge 5 commits intomainfrom
archand/kernel-1116/browser-logging
Open

[kernel-1116] browser logging: Event Schema & Pipeline#184
archandatta wants to merge 5 commits intomainfrom
archand/kernel-1116/browser-logging

Conversation

@archandatta
Copy link
Contributor

@archandatta archandatta commented Mar 23, 2026

Note

Medium Risk
Adds a new concurrent event ingestion pipeline with file I/O and truncation behavior; risks are mainly around correctness under load (dropped-event signaling, write ordering, and silent file-write failures).

Overview
Introduces a new server/lib/events package implementing the browser logging pipeline end-to-end: a canonical BrowserEvent schema with category routing and size-based truncation, a non-blocking fan-out RingBuffer that can emit a synthetic events_dropped event when readers fall behind, and a per-category JSONL FileWriter that lazily opens and appends to *.log files.

Adds a Pipeline wrapper that stamps CaptureSessionID, monotonic Seq, and Ts, applies truncation before both sinks, writes durably to disk before publishing in-memory, and provides reader subscriptions; comprehensive tests cover JSON encoding, routing, concurrency, overflow/drop behavior, and truncation limits.

Written by Cursor Bugbot for commit 29f2bbf. This will update automatically on new commits. Configure here.

@archandatta archandatta marked this pull request as ready for review March 24, 2026 12:50
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

mu sync.RWMutex
buf []BrowserEvent
head int // next write position (mod cap)
count int // items currently stored (0..cap)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RingBuffer count field is maintained but never read

Low Severity

The count field in RingBuffer is declared, incremented in Publish, but its value is never consumed by any reader-facing logic. The oldestSeq function — the only place that needs to know buffer occupancy — derives the answer from written and len(rb.buf) instead. This makes count dead state that adds confusion about the ring buffer's invariants.

Additional Locations (1)
Fix in Cursor Fix in Web

@archandatta archandatta force-pushed the archand/kernel-1116/browser-logging branch from 09ed5ed to 29f2bbf Compare March 24, 2026 13:21
Copy link
Contributor

@rgarcia rgarcia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice direction on the pipeline/schema. one thing i'd consider before cementing BrowserEvent v1: if this is eventually going to drive both capture controls (for example: "turn on cdp console only" or "turn on network request/response capture at headers-only detail") and subscriptions, it might be worth making those selector dimensions first-class in the envelope instead of encoding too much into a single type string.

concretely, i think i'd lean toward:

  • keeping the primary event identity semantic, e.g. console.log, network.request, input.click
  • adding explicit provenance fields like source_kind (cdp, kernel_api, extension, local_process) plus source_name / source_event (for example Runtime.consoleAPICalled)
  • adding an explicit detail_level (minimal, default, verbose, raw)
  • possibly making category first-class too instead of deriving it from the type prefix

i probably would not use raw Runtime.* / Network.* as the primary type, since that makes future non-cdp producers feel awkward/second-class. i think the semantic-type + provenance split ages better if we later want to emit events from things like:

  • third-party extensions running in the browser and talking to localhost
  • vm-local helper processes/programs running alongside the browser
  • server/api-driven tool actions like screenshot/input/recording events

that shape also gives the system a much more natural control surface for both capture config and subscriptions, since selectors can operate directly on stable fields like category, topic, source_kind, and detail_level instead of needing to parse overloaded event names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants