pub struct FindingGraph { /* private fields */ }Expand description
Sole owner of findings and their causal edges (todo.md §15.2). Each edge
is stored exactly once as a cause → effect pair; the per-finding
caused_by/causes views are derived from that one set, so root
reduction and cycle checking can never read diverging truths.
FindingGraph::into_findings exports findings with both directions
filled in, keeping the schema-v2 JSON shape unchanged.
Implementations§
Source§impl FindingGraph
impl FindingGraph
pub fn new() -> Self
Sourcepub fn add_finding(&mut self, finding: Finding) -> Result<(), GraphError>
pub fn add_finding(&mut self, finding: Finding) -> Result<(), GraphError>
Adds a finding, rejecting ids already present in the graph. Callers
pass findings without edges (detectors never set them; edges are
attached via FindingGraph::add_edge).
Sourcepub fn add_edge(
&mut self,
cause: &FindingId,
effect: &FindingId,
) -> Result<(), GraphError>
pub fn add_edge( &mut self, cause: &FindingId, effect: &FindingId, ) -> Result<(), GraphError>
Records that cause caused effect. Rejects unknown ids, duplicate
edges, and any edge that would close a cycle (including self-edges).
Sourcepub fn roots(&self) -> Vec<&Finding>
pub fn roots(&self) -> Vec<&Finding>
Findings with no recorded cause, in insertion order — the same edge set the cycle check validates.
Sourcepub fn causes_of(&self, id: &FindingId) -> Vec<&Finding>
pub fn causes_of(&self, id: &FindingId) -> Vec<&Finding>
Findings that id caused (the cascade direction), derived from the
stored edges. Unknown ids yield an empty list.
Sourcepub fn caused_by_of(&self, id: &FindingId) -> Vec<&Finding>
pub fn caused_by_of(&self, id: &FindingId) -> Vec<&Finding>
Findings that caused id (the root-cause direction), derived from
the stored edges. Unknown ids yield an empty list.
Sourcepub fn into_findings(self) -> Vec<Finding>
pub fn into_findings(self) -> Vec<Finding>
Consumes the graph and returns the findings in insertion order with
caused_by/causes filled in from the single stored edge set — the
serialized schema-v2 shape is exactly what it was when the fields
were set directly.