pub struct ProvenanceGraph { /* private fields */ }Expand description
Core structure that maintains an in‑memory DAG of provenance nodes and a
persistent DoltGraph backend.
- WHAT – Holds:
persistence: The Dolt‑based storage implementation.dag: Apetgraph::DiGraphwhere node payloads are UUIDs and edges areProvenanceEdges.node_map: A fast lookup map from node UUID to the correspondingpetgraph::NodeIndex.
- HOW – Provides methods to create nodes (
record_node) and edges (record_link). These methods insert into the in‑memory graph and then persist the data in Dolt tables using simpleINSERTstatements followed by acommit. - WHY – Separating the transient in‑memory representation from durable storage gives fast runtime queries while guaranteeing that the provenance graph can survive process restarts and be inspected via Dolt tools.
Implementations§
Source§impl ProvenanceGraph
impl ProvenanceGraph
Sourcepub fn new(persistence: DoltGraph) -> Self
pub fn new(persistence: DoltGraph) -> Self
Creates a new ProvenanceGraph backed by a pre‑initialised DoltGraph.
- WHAT – Returns a fresh instance with empty in‑memory structures.
- HOW – Stores the supplied
persistenceand constructs a newDiGraphand emptyHashMap. - WHY – Allows callers to decide where the Dolt repository lives (e.g. a temporary directory for tests or a permanent location for production).
Sourcepub fn record_node(
&mut self,
id: Uuid,
address: &str,
) -> Result<(), BubbleError>
pub fn record_node( &mut self, id: Uuid, address: &str, ) -> Result<(), BubbleError>
Records a provenance node with a unique Uuid and an associated address.
- WHAT – Persists the node both in‑memory (
dag+node_map) and in a Dolt table calledprovenance_nodes. - HOW – If the node does not already exist, it is added to the DAG and a
row is inserted via
persistence.insert_node. A commit is performed with a descriptive message. - WHY – Storing the address (typically a UCXL address) allows later resolution of where the artifact originated.
Sourcepub fn record_link(
&mut self,
source: Uuid,
target: Uuid,
edge: ProvenanceEdge,
) -> Result<(), BubbleError>
pub fn record_link( &mut self, source: Uuid, target: Uuid, edge: ProvenanceEdge, ) -> Result<(), BubbleError>
Records a directed edge between two existing nodes.
- WHAT – Adds an edge of type
ProvenanceEdgeto the DAG and stores a corresponding row in theprovenance_linksDolt table. - HOW – Retrieves the
NodeIndexfor each UUID (erroring withBubbleError::NodeNotFoundif missing), adds the edge todag, then inserts a row containing a new link UUID, source/target IDs and the edge type as a string. - WHY – Persisting links allows the full provenance graph to be queried outside the process, while the in‑memory representation keeps runtime operations cheap.
Auto Trait Implementations§
impl Freeze for ProvenanceGraph
impl RefUnwindSafe for ProvenanceGraph
impl Send for ProvenanceGraph
impl Sync for ProvenanceGraph
impl Unpin for ProvenanceGraph
impl UnwindSafe for ProvenanceGraph
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more