Skip to content

feat: correlate PreToolUse and PostToolUse events via parent_event_id #35

@tumberger

Description

@tumberger

Problem

PreToolUse and PostToolUse events for the same tool call are stored as independent rows with no explicit link between them. The only way to correlate them is by matching on tool_use_id within a session — which requires a query-time join and assumes tool_use_id is unique within a session.

The API supports a parentEventId field, but the CLI never sends it.

Proposed solution

  1. When the sidecar processes a PreToolUse event, the backend returns an event_id in the response
  2. The sidecar stores a map of tool_use_id → event_id
  3. When the corresponding PostToolUse arrives, the sidecar attaches the PreToolUse's event_id as parent_event_id
  4. Add parent_event_id to the proto ProcessHookEventRequest

This gives the dashboard a direct parent→child link for every tool execution, enabling:

  • Instant Pre→Post correlation without scanning
  • Tool execution timeline visualization
  • Duration calculation without query-time joins

Dependency

Requires #31 (bidi streaming) or at minimum reading the event_id from the unary response, which the sidecar currently ignores.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions