findRootCause method

CausalEvent? findRootCause(
  1. String eventId
)

Finds the root cause of the causal chain containing eventId.

The root cause is the oldest ancestor — typically a CausalEventType.userAction or CausalEventType.networkEvent. Returns the event itself if it has no parent. Returns null if the event is not in the graph.

Implementation

CausalEvent? findRootCause(String eventId) {
  final ancestors = getAncestors(eventId);
  if (ancestors.isEmpty) return null;
  return ancestors.first;
}