pub struct UcmGraph { /* private fields */ }Expand description
The materialized context graph — primary queryable data structure.
Wraps petgraph’s StableGraph with typed operations and
SCIP-identity → NodeIndex lookup.
Implementations§
Source§impl UcmGraph
impl UcmGraph
pub fn new() -> Self
Sourcepub fn add_entity(&mut self, entity: UcmEntity) -> Result<NodeIndex>
pub fn add_entity(&mut self, entity: UcmEntity) -> Result<NodeIndex>
Add an entity to the graph. Returns the node index. If an entity with the same SCIP ID exists, returns error.
Sourcepub fn upsert_entity(&mut self, entity: UcmEntity) -> NodeIndex
pub fn upsert_entity(&mut self, entity: UcmEntity) -> NodeIndex
Add or update an entity (upsert semantics for replay safety).
Sourcepub fn add_relationship(
&mut self,
from: &EntityId,
to: &EntityId,
edge: UcmEdge,
) -> Result<EdgeIndex>
pub fn add_relationship( &mut self, from: &EntityId, to: &EntityId, edge: UcmEdge, ) -> Result<EdgeIndex>
Add a relationship between two entities.
Sourcepub fn invalidate_file(&mut self, file_path: &str) -> Vec<EntityId>
pub fn invalidate_file(&mut self, file_path: &str) -> Vec<EntityId>
Remove all entities and edges owned by a file path. This is the Glean-style “hide facts” operation for incremental updates.
Sourcepub fn get_entity(&self, id: &EntityId) -> Option<&UcmEntity>
pub fn get_entity(&self, id: &EntityId) -> Option<&UcmEntity>
Get an entity by its SCIP ID.
Sourcepub fn all_entities(&self) -> Vec<&UcmEntity>
pub fn all_entities(&self) -> Vec<&UcmEntity>
Get all entities in the graph.
Sourcepub fn dependencies(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>
pub fn dependencies(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>
Get direct dependencies of an entity (outgoing edges).
Sourcepub fn reverse_deps(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>
pub fn reverse_deps(&self, id: &EntityId) -> Result<Vec<(&UcmEntity, &UcmEdge)>>
Get reverse dependencies of an entity (incoming edges). “What depends on this entity?”
This is the core query for impact analysis — when entity X changes, which entities are affected? (Google TAP, Meta PTS)
Sourcepub fn stats(&self) -> GraphStats
pub fn stats(&self) -> GraphStats
Get graph statistics.
Sourcepub fn inner(&self) -> &StableGraph<UcmEntity, UcmEdge>
pub fn inner(&self) -> &StableGraph<UcmEntity, UcmEdge>
Get a read-only reference to the inner petgraph.
Sourcepub fn entity_node_index(&self, id: &EntityId) -> Option<NodeIndex>
pub fn entity_node_index(&self, id: &EntityId) -> Option<NodeIndex>
Resolve an EntityId to a NodeIndex, if it exists.
Sourcepub fn entity_index_map(&self) -> &HashMap<String, NodeIndex>
pub fn entity_index_map(&self) -> &HashMap<String, NodeIndex>
Get a reference to the full entity index map.