pub struct Edge {
pub src: String,
pub dst: String,
pub kind: EdgeKind,
pub provenance: Provenance,
pub confidence: Option<f64>,
pub src_ref: Option<String>,
}Expand description
An edge in the knowledge graph, connecting two nodes by their keys.
The Provenance invariant is enforced on insert: confidence is present
if and only if the provenance is Provenance::Inferred.
Fields§
§src: StringNatural key of the source node.
dst: StringNatural key of the destination node.
kind: EdgeKindThe relationship this edge records.
provenance: ProvenanceHow this edge was produced.
confidence: Option<f64>Confidence score in 0.0..=1.0; Some iff provenance is inferred.
src_ref: Option<String>Where the fact came from (e.g. blob#span, or an ADR id).
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn derived(
src: impl Into<String>,
dst: impl Into<String>,
kind: EdgeKind,
) -> Self
pub fn derived( src: impl Into<String>, dst: impl Into<String>, kind: EdgeKind, ) -> Self
Construct a derived edge (no confidence).
Construct an authored edge (no confidence).
Sourcepub fn inferred(
src: impl Into<String>,
dst: impl Into<String>,
kind: EdgeKind,
confidence: f64,
) -> Self
pub fn inferred( src: impl Into<String>, dst: impl Into<String>, kind: EdgeKind, confidence: f64, ) -> Self
Construct an inferred edge carrying a confidence score.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Whether this edge is valid for storage: a confidence score is present
exactly when the edge is inferred, and any present score is a finite
value in 0.0..=1.0 (rejecting NaN, infinities, and out-of-range).
§external-inferred is not inferred for this purpose
The test names Provenance::Inferred exactly, so an imported edge —
including one at Provenance::ExternalInferred — must carry no
confidence. A score is a number this graph computed; OKF records none
for a relationship, so an import has nothing to adopt and putting one
there would fabricate a precision nobody measured. Reaching for
Provenance::tier() here would quietly require the opposite, and the
store’s own CHECK (migration 14) would then reject what this accepts.