CausalGraph class

A directed acyclic graph (DAG) of CausalEvent nodes.

Every event emitted to TrinityEventBus is automatically added as a node. Parent-child edges are formed via CausalEvent.parentId. The graph supports traversal in both directions: ancestors (root-cause tracing) and descendants (impact analysis).

Pruning

The graph uses a sliding window to prevent unbounded memory growth. Events older than _windowSeconds or exceeding _windowMaxEvents are pruned. Pruning happens automatically on every addEvent call.

Serialization

toJson exports the entire graph for bug reports. The exported JSON contains all events and their causal edges.

Properties

eventIds Iterable<String>
All event IDs currently in the graph.
no setter
hashCode int
The hash code for this object.
no setterinherited
length int
Total number of events currently in the graph.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addEvent(CausalEvent event) → void
Adds an event to the graph manually.
connectToBus() → void
Wire the graph to the event bus. Call once during initialization.
debugClear() → void
Clears the entire graph. For testing only.
dispose() → void
Disconnects from the event bus and clears graph. For testing cleanup.
findRootCause(String eventId) CausalEvent?
Finds the root cause of the causal chain containing eventId.
fromJson(Map<String, dynamic> json) → void
Imports a previously exported graph. Merges with existing data.
getAncestors(String eventId) List<CausalEvent>
Returns the ordered ancestor chain from root to eventId (inclusive).
getDescendants(String eventId) List<CausalEvent>
Returns all events transitively caused by eventId (excluding itself).
getDirectChildren(String eventId) List<CausalEvent>
Returns the direct children of eventId (one level only).
getEvent(String eventId) CausalEvent?
Returns the event with the given eventId, or null.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Exports the entire graph as JSON for bug reports.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance CausalGraph
The singleton instance.
final